Changeset 252:690efbd91dd4 in verona for phapi/phapi.c


Ignore:
Timestamp:
Jul 12, 2011 2:47:42 PM (23 months ago)
Author:
Vadim Lebedev <vadim@…>
Branch:
default
Children:
253:cbe0776765ad, 264:f55d03c29bb5
Message:

Add support for specifying explicit NAT router address
Fix handling of route for REGISTER requests
Implement support for adding user=phone to Contact header

File:
1 edited

Legend:

Unmodified
Added
Removed
  • phapi/phapi.c

    r251 r252  
    422422 
    423423ph_config_t phcfg = { 
     424                /* public ip addr */ "", 
    424425                /* local ip addr */ "", 
    425426                /* local audio rtp port */"10600", 
     
    430431                /* local video rtcp port */ "11100", 
    431432                /* sipport  */ "5060", 
     433                /* public sip port */ "", 
    432434                /* sip transport */ IPPROTO_UDP, 
    433435                /* nattype */  "" , 
     
    22882290 
    22892291static void  
    2290 add_contact_param(struct vline *vl,  const char *param, const char *value) 
     2292add_contact_param(struct vline *vl,  const char *param, const char *value, int inside) 
    22912293{ 
    22922294        osip_contact_t *ctct; 
     
    22992301 
    23002302        osip_contact_parse(ctct, vl->contact); 
    2301         osip_contact_param_add(ctct, osip_strdup(param), osip_strdup(value)); 
     2303        if (inside) 
     2304                osip_uri_param_add(&ctct->url->url_params, osip_strdup(param), osip_strdup(value)); 
     2305        else 
     2306                osip_contact_param_add(ctct, osip_strdup(param), osip_strdup(value)); 
    23022307 
    23032308        osip_free(vl->contact); 
     
    29512956        assert(vl->server!=NULL); 
    29522957 
    2953         snprintf(utmp, sizeof(utmp), "sip:%s@%s", vl->username, vl->server); 
     2958        if (vl->displayname) 
     2959                snprintf(utmp, sizeof(utmp), "\"%s\" <sip:%s@%s>", vl->displayname, vl->username, vl->server); 
     2960        else 
     2961                snprintf(utmp, sizeof(utmp), "sip:%s@%s", vl->username, vl->server); 
    29542962 
    29552963        server = stmp; 
     
    29722980                        vl->rid = -2; 
    29732981        }  else { 
     2982#if 1 
     2983                vl->rid = eXosip_register_build_initial_register(utmp, server, vl->contact, vl->regTimeout, &msg); 
     2984                if (vl->proxy) 
     2985                        osip_message_set_route(msg, vl->proxy); 
     2986        } 
     2987#else 
    29742988                if (vl->proxy && vl->proxy[0] == '<') { 
    29752989                        int size = strlen(vl->proxy); 
     
    29852999                        else 
    29863000                                vl->rid = eXosip_register_build_initial_register(utmp, server, vl->contact, vl->regTimeout, &msg); 
    2987                 } 
    2988         } 
     3001 
     3002                } 
     3003        } 
     3004#endif 
    29893005 
    29903006        if (vl->rid >= 0) 
     
    33103326 
    33113327        if (mobility == PH_LINE_MOBILITY_FIXED) 
    3312                 add_contact_param(vl, "mobility", "fixed"); 
     3328                add_contact_param(vl, "mobility", "fixed", FALSE); 
    33133329        else if (mobility == PH_LINE_MOBILITY_MOBILE) 
    3314                 add_contact_param(vl, "mobility", "mobile"); 
     3330                add_contact_param(vl, "mobility", "mobile", FALSE); 
     3331        else if (mobility == PH_LINE_MOBILITY_PHONE) 
     3332                add_contact_param(vl, "user", "phone", TRUE); 
     3333 
    33153334 
    33163335        vl->mobility = mobility; 
     
    39713990        ph_nat_type_str[0] = 0; 
    39723991 
     3992        if (phcfg.public_ip_addr[0]) 
     3993                return; 
     3994 
    39733995        if (!phcfg.use_tunnel && phcfg.nattype[0]) 
    39743996        { 
     
    43094331                return -1; 
    43104332 
     4333        if (phcfg.public_ip_addr[0]) 
     4334        { 
     4335                int port = atoi(phcfg.public_sipport); 
     4336                eXosip_masquerade_contact(phcfg.public_ip_addr, port ? port : atoi(phcfg.sipport)); 
     4337        } 
     4338 
    43114339        if (phcfg.local_ip_addr[0] == 0) 
    43124340                eXosip_listen_addr(proto, NULL, atoi(phcfg.sipport), AF_INET, secure); 
    43134341        else 
    43144342        { 
    4315                 eXosip_masquerade_contact(phcfg.local_ip_addr, atoi(phcfg.sipport)); 
     4343                if (!phcfg.public_ip_addr[0]) 
     4344                        eXosip_masquerade_contact(phcfg.local_ip_addr, atoi(phcfg.sipport)); 
    43164345                eXosip_listen_addr(proto, phcfg.local_ip_addr, atoi(phcfg.sipport), AF_INET, secure); 
    43174346        } 
Note: See TracChangeset for help on using the changeset viewer.