Mon Feb 17 07:00:01 CET 2003
authorMatteo Brancaleoni <mbrancaleoni@espia.it>
Mon, 17 Feb 2003 06:00:19 +0000 (06:00 +0000)
committerMatteo Brancaleoni <mbrancaleoni@espia.it>
Mon, 17 Feb 2003 06:00:19 +0000 (06:00 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@617 65c4cc65-6c06-0410-ace0-fbb531ad65f3

CHANGES
channels/chan_sip.c
configs/sip.conf.sample

diff --git a/CHANGES b/CHANGES
index d190dd4..ff89f86 100755 (executable)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,4 @@
+ -- Allow SIP registration to provide an alternative contact
  -- Make HOLD on SIP make use of asterisk MOH
  -- Add supervised transfer (tested with Pingtel only)
  -- Allow maxexpirey and defaultexpirey to be runtime configurable for SIP
index a057eb8..0f8869d 100755 (executable)
@@ -252,6 +252,7 @@ struct sip_registry {
        struct sockaddr_in addr;                /* Who we connect to for registration purposes */
        char username[80];
        char secret[80];                        /* Password or key name in []'s */
+       char contact[80];                       /* Contact extension */
        char random[80];
        int expire;                                     /* Sched ID of expiration */
        int timeout;                                    /* sched id of sip_reg_timeout */
@@ -1060,6 +1061,7 @@ static int sip_register(char *value, int lineno)
        char copy[256] = "";
        char *username, *hostname, *secret;
        char *porta;
+       char *contact;
        char *stringp=NULL;
        
        struct hostent *hp;
@@ -1076,9 +1078,14 @@ static int sip_register(char *value, int lineno)
        stringp=username;
        username = strsep(&stringp, ":");
        secret = strsep(&stringp, ":");
+       stringp = hostname;
+       hostname = strsep(&stringp, "/");
+       contact = strsep(&stringp, "/");
+       if (!contact || !strlen(contact))
+               contact = "s";
        stringp=hostname;
        hostname = strsep(&stringp, ":");
-       porta = strsep(&stringp, ";");
+       porta = strsep(&stringp, ":");
        
        if (porta && !atoi(porta)) {
                ast_log(LOG_WARNING, "%s is not a valid port number at line %d\n", porta, lineno);
@@ -1092,6 +1099,7 @@ static int sip_register(char *value, int lineno)
        reg = malloc(sizeof(struct sip_registry));
        if (reg) {
                memset(reg, 0, sizeof(struct sip_registry));
+               strncpy(reg->contact, contact, sizeof(reg->contact) - 1);
                strncpy(reg->username, username, sizeof(reg->username)-1);
                if (secret)
                        strncpy(reg->secret, secret, sizeof(reg->secret)-1);
@@ -1840,7 +1848,7 @@ static int transmit_register(struct sip_registry *r, char *cmd, char *auth)
        add_header(&req, "To", to);
        {
                char contact[256];
-               snprintf(contact, sizeof(contact), "<sip:s@%s:%d;transport=udp>", inet_ntoa(p->ourip), ourport);
+               snprintf(contact, sizeof(contact), "<sip:%s@%s:%d;transport=udp>", r->contact, inet_ntoa(p->ourip), ourport);
                add_header(&req, "Contact", contact);
        }
        add_header(&req, "Call-ID", p->callid);
index dad7c15..d91b2b3 100755 (executable)
@@ -9,7 +9,10 @@ context = default              ; Default for incoming calls
 ;tos=184
 ;maxexpirey=3600               ; Max length of incoming registration we allow
 ;defaultexpirey=120            ; Default length of incoming/outoing registration
-
+;
+;register => 1234@mysipprovider.com    ; Register with a SIP provider
+;register => 2345@mysipprovider.com/1234 ; Register 2345 at sip provider as 1234 here.
+;
 ;[snomsip]
 ;type=friend
 ;secret=blah