Handle call forward on SIP
authorMark Spencer <markster@digium.com>
Sat, 29 Mar 2003 00:42:16 +0000 (00:42 +0000)
committerMark Spencer <markster@digium.com>
Sat, 29 Mar 2003 00:42:16 +0000 (00:42 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@715 65c4cc65-6c06-0410-ace0-fbb531ad65f3

cdr/cdr_mysql.c
channels/chan_sip.c
pbx.c

index 666a4e2..137febb 100755 (executable)
@@ -39,21 +39,18 @@ static MYSQL *mysql;
 static int mysql_log(struct ast_cdr *cdr)
 {
   struct tm *tm;
-  struct timeval *tv;
-  struct timezone *tz;
-  char *sqlcmd, *timestr;
+  struct timeval tv;
+  struct timezone tz;
+  char *sqlcmd, timestr[128];
   time_t t;
 
 
-  tv = (struct timeval *)malloc(sizeof(struct timeval));
-  tz = (struct timezone *)malloc(sizeof(struct timezone));
   sqlcmd = (char *)malloc(2048);
-  timestr = (char*)malloc(128);
   memset(sqlcmd,0,2048);
 
 
-  gettimeofday(tv,tz);
-  t = tv->tv_sec;
+  gettimeofday(&tv,&tz);
+  t = tv.tv_sec;
   tm = localtime(&t);
   strftime(timestr,128,DATE_FORMAT,tm);
   
index d525083..c1afbf3 100755 (executable)
@@ -3189,6 +3189,22 @@ static int sip_poke_peer_s(void *data)
        return 0;
 }
 
+static void parse_moved_contact(struct sip_pvt *p, struct sip_request *req)
+{
+       char tmp[256] = "";
+       char *s, *e;
+       strncpy(tmp, get_header(req, "Contact"), sizeof(tmp) - 1);
+       s = tmp;
+       e = strchr(tmp, '@');
+       if (e)
+               *e = '\0';
+       if (!strncasecmp(s, "sip:", 4))
+               s += 4;
+       ast_log(LOG_DEBUG, "Found 302 Redirect to extension '%s'\n", s);
+       if (p->owner)
+               strncpy(p->owner->call_forward, s, sizeof(p->owner->call_forward) - 1);
+}
+
 static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_request *req)
 {
        char *to;
@@ -3361,6 +3377,11 @@ retrylock:
                                }
                                /* XXX Locking issues?? XXX */
                                switch(resp) {
+                               case 302: /* Moved temporarily */
+                                       parse_moved_contact(p, req);
+                                       if (p->owner)
+                                               ast_queue_control(p->owner, AST_CONTROL_BUSY, 0);
+                                       break;
                                case 486: /* Busy here */
                                case 600: /* Busy everywhere */
                                        if (p->owner)
diff --git a/pbx.c b/pbx.c
index 20d38b3..0c01820 100755 (executable)
--- a/pbx.c
+++ b/pbx.c
@@ -504,7 +504,7 @@ int ast_extension_match(char *pattern, char *data)
 {
        int match;
        /* If they're the same return */
-       if (!strcasecmp(pattern, data))
+       if (!strcmp(pattern, data))
                return 1;
        EXTENSION_MATCH_CORE(data,pattern,match);
        /* Must be at the end of both */
@@ -611,7 +611,7 @@ static struct ast_exten *pbx_find_extension(struct ast_channel *chan, char *cont
        tmp = contexts;
        while(tmp) {
                /* Match context */
-               if (!strcasecmp(tmp->name, context)) {
+               if (!strcmp(tmp->name, context)) {
                        if (*status < STATUS_NO_EXTENSION)
                                *status = STATUS_NO_EXTENSION;
                        eroot = tmp->root;