]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
help cure connectile-dysfunction
authorAnthony Minessale <anthony.minessale@gmail.com>
Mon, 21 May 2007 19:11:37 +0000 (19:11 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Mon, 21 May 2007 19:11:37 +0000 (19:11 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5207 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/endpoints/mod_sofia/sofia_reg.c

index b064917fddb8b6cee589a7ab94108cf886a71a54..97a8aaaef485bfa356a884017aafe5391e118875 100644 (file)
@@ -263,12 +263,14 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
        const char *rpid = "unknown";
        const char *display = "\"user\"";
        char network_ip[80];
+       int network_port;
 
        /* all callers must confirm that sip, sip->sip_request and sip->sip_contact are not NULL */
        assert(sip != NULL && sip->sip_contact != NULL && sip->sip_request != NULL);
 
        get_addr(network_ip, sizeof(network_ip), &((struct sockaddr_in *) msg_addrinfo(nua_current_request(nua))->ai_addr)->sin_addr);
-
+       network_port = ntohs(((struct sockaddr_in *) msg_addrinfo(nua_current_request(nua))->ai_addr)->sin_port);
+       
        expires = sip->sip_expires;
        authorization = sip->sip_authorization;
        contact = sip->sip_contact;
@@ -333,11 +335,20 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
                }
                
                if (v_event && *v_event && (v_contact_str = switch_event_get_header(*v_event, "force-contact"))) {
-                       char *p;
-                       switch_copy_string(contact_str, v_contact_str, sizeof(contact_str));
-                       for(p = contact_str; p && *p; p++) {
-                               if (*p == '\'' || *p == '[' || *p == ']') {
-                                       *p = '"';
+                       if (!strcasecmp(v_contact_str, "nat-connectile-dysfunction")) {
+                               if (contact->m_url->url_params) {
+                                       snprintf(contact_str, sizeof(contact_str), "%s <sip:%s@%s:%d;%s>",
+                                                        display, contact->m_url->url_user, network_ip, network_port, contact->m_url->url_params);
+                               } else {
+                                       snprintf(contact_str, sizeof(contact_str), "%s <sip:%s@%s:%d>", display, contact->m_url->url_user, network_ip, network_port);
+                               }
+                       } else {
+                               char *p;
+                               switch_copy_string(contact_str, v_contact_str, sizeof(contact_str));
+                               for(p = contact_str; p && *p; p++) {
+                                       if (*p == '\'' || *p == '[' || *p == ']') {
+                                               *p = '"';
+                                       }
                                }
                        }
                }