]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Use "domain" instead of "uri" if supplied
authorMark Spencer <markster@digium.com>
Fri, 22 Aug 2003 16:53:36 +0000 (16:53 +0000)
committerMark Spencer <markster@digium.com>
Fri, 22 Aug 2003 16:53:36 +0000 (16:53 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1407 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index 5df9466981585948667b5b6e4b59c8b131637ea0..ff3f0899ecfdb411fe7d9f4119b81e378ddffa13 100755 (executable)
@@ -221,6 +221,7 @@ static struct sip_pvt {
        char our_contact[256];                          /* Our contact header */
        char realm[256];                                /* Authorization realm */
        char nonce[256];                                /* Authorization nonce */
+       char domain[256];                               /* Authorization nonce */
        int amaflags;                                           /* AMA Flags */
        int pendinginvite;                                      /* Any pending invite */
        int pendingbye;                                         /* Need to send bye after we ack? */
@@ -4087,6 +4088,7 @@ static int reply_digest(struct sip_pvt *p, struct sip_request *req, char *header
        char tmp[256] = "";
        char *realm = "";
        char *nonce = "";
+       char *domain = "";
        char *c;
 
 
@@ -4121,6 +4123,17 @@ static int reply_digest(struct sip_pvt *p, struct sip_request *req, char *header
                                if ((c = strchr(c,',')))
                                        *c = '\0';
                        }
+               } else if (!strncasecmp(c, "domain=", strlen("domain="))) {
+                       c+=strlen("domain=");
+                       if ((*c == '\"')) {
+                               domain=++c;
+                               if ((c = strchr(c,'\"')))
+                                       *c = '\0';
+                       } else {
+                               domain = c;
+                               if ((c = strchr(c,',')))
+                                       *c = '\0';
+                       }
                } else
                        c = strchr(c,',');
                if (c)
@@ -4130,7 +4143,7 @@ static int reply_digest(struct sip_pvt *p, struct sip_request *req, char *header
        /* copy realm and nonce for later authorization of CANCELs and BYEs */
        strncpy(p->realm, realm, sizeof(p->realm)-1);
        strncpy(p->nonce, nonce, sizeof(p->nonce)-1);
-
+       strncpy(p->domain, domain, sizeof(p->domain)-1);
        build_reply_digest(p, orig_header, digest, digest_len); 
        return 0;
 }
@@ -4145,7 +4158,9 @@ static int build_reply_digest(struct sip_pvt *p, char* orig_header, char* digest
        char resp_hash[256];
        char uri[256] = "";
 
-       if (strlen(p->uri))
+       if (strlen(p->domain))
+               strncpy(uri, p->domain, sizeof(uri) - 1);
+       else if (strlen(p->uri))
                strncpy(uri, p->uri, sizeof(uri) - 1);
        else
                snprintf(uri, sizeof(uri), "sip:%s@%s",p->username, inet_ntoa(p->sa.sin_addr));