Use URI in sip, update chan_vpb
authorMark Spencer <markster@digium.com>
Sun, 24 Aug 2003 06:24:38 +0000 (06:24 +0000)
committerMark Spencer <markster@digium.com>
Sun, 24 Aug 2003 06:24:38 +0000 (06:24 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1413 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c
channels/chan_vpb.c

index 7934d63..83cf6ac 100755 (executable)
@@ -2149,23 +2149,26 @@ static int reqprep(struct sip_request *req, struct sip_pvt *p, char *msg, int se
                seqno = p->ocseq;
        }
 
-       if (p->outgoing)
-               strncpy(stripped, get_header(orig, "To"), sizeof(stripped) - 1);
-       else
-               strncpy(stripped, get_header(orig, "From"), sizeof(stripped) - 1);
-       
-       c = strchr(stripped, '<');
-       if (c) 
-               c++;
-       else
-               c = stripped;
-       n = strchr(c, '>');
-       if (n)
-               *n = '\0';
-       n = strchr(c, ';');
-       if (n)
-               *n = '\0';
-       
+       if (strlen(p->uri)) {
+               c = p->uri;
+       } else {
+               if (p->outgoing)
+                       strncpy(stripped, get_header(orig, "To"), sizeof(stripped) - 1);
+               else
+                       strncpy(stripped, get_header(orig, "From"), sizeof(stripped) - 1);
+               
+               c = strchr(stripped, '<');
+               if (c) 
+                       c++;
+               else
+                       c = stripped;
+               n = strchr(c, '>');
+               if (n)
+                       *n = '\0';
+               n = strchr(c, ';');
+               if (n)
+                       *n = '\0';
+       }       
        init_req(req, msg, c);
 
        snprintf(tmp, sizeof(tmp), "%d %s", seqno, msg);
@@ -2558,6 +2561,26 @@ static int transmit_reinvite_with_sdp(struct sip_pvt *p, struct ast_rtp *rtp, st
        return send_request(p, &req, 1, p->ocseq);
 }
 
+static void extract_uri(struct sip_pvt *p, struct sip_request *req)
+{
+       char stripped[256]="";
+       char *c, *n;
+       strncpy(stripped, get_header(req, "Contact"), sizeof(stripped) - 1);
+       c = strchr(stripped, '<');
+       if (c) 
+               c++;
+       else
+               c = stripped;
+       n = strchr(c, '>');
+       if (n)
+               *n = '\0';
+       n = strchr(c, ';');
+       if (n)
+               *n = '\0';
+       if (c && strlen(c))
+               strncpy(p->uri, c, sizeof(p->uri) - 1);
+}
+
 static void build_contact(struct sip_pvt *p)
 {
        /* Construct Contact: header */
@@ -4705,6 +4728,7 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
                        /* Get destination right away */
                        gotdest = get_destination(p, NULL);
                        get_rdnis(p, NULL);
+                       extract_uri(p, req);
                        build_contact(p);
 
                        if (gotdest) {
index 61700a1..fe6e1d2 100755 (executable)
@@ -177,7 +177,7 @@ static int vpb_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
               bridges[i].fo = fo;
               bridges[i].c0 = c0;
               bridges[i].c1 = c1;
-              ast_mutex_init(&bridges[i].lock, NULL);
+              ast_mutex_init(&bridges[i].lock);
               pthread_cond_init(&bridges[i].cond, NULL);
          }            
      } ast_mutex_unlock(&bridge_lock); 
@@ -586,7 +586,7 @@ struct vpb_pvt *mkif(int board, int channel, int mode, float txgain, float rxgai
 
      tmp->readthread = 0;
 
-     ast_mutex_init(&tmp->lock, NULL);
+     ast_mutex_init(&tmp->lock);
 
      if (setrxgain)      
          vpb_record_set_gain(tmp->handle, rxgain);