merge brian's cleanups
authorMark Spencer <markster@digium.com>
Sun, 9 May 2004 22:03:38 +0000 (22:03 +0000)
committerMark Spencer <markster@digium.com>
Sun, 9 May 2004 22:03:38 +0000 (22:03 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@2939 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index 0c02a06..c1ad16e 100755 (executable)
@@ -3648,6 +3648,7 @@ static int parse_contact(struct sip_pvt *pvt, struct sip_peer *p, struct sip_req
        int expiry = atoi(expires);
        char *c, *n, *pt;
        int port;
+       char *useragent;
        struct hostent *hp;
        struct ast_hostent ahp;
        struct sockaddr_in oldsin;
@@ -3679,6 +3680,7 @@ static int parse_contact(struct sip_pvt *pvt, struct sip_peer *p, struct sip_req
                        ast_sched_del(sched, p->expire);
                p->expire = -1;
                ast_db_del("SIP/Registry", p->name);
+               strcpy(p->useragent, "");
                if (option_verbose > 2)
                        ast_verbose(VERBOSE_PREFIX_3 "Unregistered SIP '%s'\n", p->name);
                return 0;
@@ -3744,10 +3746,13 @@ static int parse_contact(struct sip_pvt *pvt, struct sip_peer *p, struct sip_req
        }
 
        /* Save User agent */
-       strncpy(p->useragent, get_header(req, "User-Agent"),sizeof(p->useragent));
-       if (option_verbose > 2) 
-               ast_verbose(VERBOSE_PREFIX_3 "Saved useragent \"%s\" for peer %s\n",p->useragent,p->name);  
-
+       useragent = get_header(req, "User-Agent");
+       if(useragent && strcasecmp(useragent, p->useragent)) {
+               strncpy(p->useragent, get_header(req, "User-Agent"),sizeof(p->useragent));
+               if (option_verbose > 2) {
+                       ast_verbose(VERBOSE_PREFIX_3 "Saved useragent \"%s\" for peer %s\n",p->useragent,p->name);  
+               }
+       }
        return 0;
 }