Grab incoming tag on initial events.
authorMark Spencer <markster@digium.com>
Thu, 3 Apr 2003 16:20:47 +0000 (16:20 +0000)
committerMark Spencer <markster@digium.com>
Thu, 3 Apr 2003 16:20:47 +0000 (16:20 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@745 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index f846edc..c18bcf7 100755 (executable)
@@ -3024,6 +3024,8 @@ static int sip_show_channel(int fd, int argc, char *argv[])
                        ast_cli(fd, "Theoretical Address: %s:%d\n", inet_ntoa(cur->sa.sin_addr), ntohs(cur->sa.sin_port));
                        ast_cli(fd, "Received Address:    %s:%d\n", inet_ntoa(cur->recv.sin_addr), ntohs(cur->recv.sin_port));
                        ast_cli(fd, "NAT Support:         %s\n", cur->nat ? "Yes" : "No");
+                       ast_cli(fd, "Our Tag:             %08d\n", cur->tag);
+                       ast_cli(fd, "Their Tag:           %s\n", cur->theirtag);
                        strcpy(tmp, "");
                        if (cur->dtmfmode & SIP_DTMF_RFC2833)
                                strcat(tmp, "rfc2833 ");
@@ -3556,6 +3558,7 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
        struct sip_request resp;
        char *cmd;
        char *cseq;
+       char *from;
        char *e;
        struct ast_channel *c=NULL;
        int seqno;
@@ -3595,6 +3598,17 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
                           respond appropriately  */
                        ignore=1;
                }
+               if (!strlen(p->theirtag)) {
+                       from = get_header(req, "From");
+                       from = strstr(from, "tag=");
+                       if (from) {
+                               from += 4;
+                               strncpy(p->theirtag, from, sizeof(p->theirtag) - 1);
+                               from = strchr(p->theirtag, ';');
+                               if (from)
+                                       *from = '\0';
+                       }
+               }
        } else {
                /* Response to our request -- Do some sanity checks */  
                if (!p->initreq.headers) {