]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
automerge commit
authorAutomerge script <automerge@asterisk.org>
Sun, 23 Dec 2007 02:00:56 +0000 (02:00 +0000)
committerAutomerge script <automerge@asterisk.org>
Sun, 23 Dec 2007 02:00:56 +0000 (02:00 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2-netsec@94712 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index 0a05ab02cc82ecb0834ecb28bbfc989cadc2d956..27f8859e8af4d2bc59b1adadbfbc8882669e616d 100644 (file)
@@ -1720,7 +1720,7 @@ static void update_peer(struct sip_peer *p, int expiry)
 static struct sip_peer *realtime_peer(const char *peername, struct sockaddr_in *sin)
 {
        struct sip_peer *peer=NULL;
-       struct ast_variable *var;
+       struct ast_variable *var = NULL;
        struct ast_variable *tmp;
        char *newpeername = (char *) peername;
        char iabuf[80];
@@ -1728,40 +1728,39 @@ static struct sip_peer *realtime_peer(const char *peername, struct sockaddr_in *
        /* First check on peer name */
        if (newpeername) {
                var = ast_load_realtime("sippeers", "name", newpeername, "host", "dynamic", NULL);
-               if (!var && sin) {
+               if (!var && sin)
                        var = ast_load_realtime("sippeers", "name", newpeername, "host", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), NULL);
-                       if (!var) {
-                               var = ast_load_realtime("sippeers", "name", newpeername, NULL);
-                               /*!\note
-                                * If this one loaded something, then we need to ensure that the host
-                                * field matched.  The only reason why we can't have this as a criteria
-                                * is because we only have the IP address and the host field might be
-                                * set as a name (and the reverse PTR might not match).
-                                */
-                               if (var) {
-                                       for (tmp = var; tmp; tmp = tmp->next) {
-                                               if (!strcasecmp(var->name, "host")) {
-                                                       struct in_addr sin2 = { 0, };
-                                                       struct ast_dnsmgr_entry *dnsmgr = NULL;
-                                                       if ((ast_dnsmgr_lookup(tmp->value, &sin2, &dnsmgr) < 0) || (memcmp(&sin2, &sin->sin_addr, sizeof(sin2)) != 0)) {
-                                                               /* No match */
-                                                               ast_variables_destroy(var);
-                                                               var = NULL;
-                                                       }
-                                                       break;
+               if (!var) {
+                       var = ast_load_realtime("sippeers", "name", newpeername, NULL);
+                       /*!\note
+                        * If this one loaded something, then we need to ensure that the host
+                        * field matched.  The only reason why we can't have this as a criteria
+                        * is because we only have the IP address and the host field might be
+                        * set as a name (and the reverse PTR might not match).
+                        */
+                       if (var) {
+                               for (tmp = var; tmp; tmp = tmp->next) {
+                                       if (!strcasecmp(var->name, "host")) {
+                                               struct in_addr sin2 = { 0, };
+                                               struct ast_dnsmgr_entry *dnsmgr = NULL;
+                                               if ((ast_dnsmgr_lookup(tmp->value, &sin2, &dnsmgr) < 0) || (memcmp(&sin2, &sin->sin_addr, sizeof(sin2)) != 0)) {
+                                                       /* No match */
+                                                       ast_variables_destroy(var);
+                                                       var = NULL;
                                                }
+                                               break;
                                        }
                                }
                        }
                }
-       } else if (sin) {       /* Then check on IP address */
+       }
+
+       if (!var && sin) {      /* Then check on IP address */
                ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr);
                var = ast_load_realtime("sippeers", "host", iabuf, NULL);       /* First check for fixed IP hosts */
                if (!var)
                        var = ast_load_realtime("sippeers", "ipaddr", iabuf, NULL);     /* Then check for registred hosts */
-       
-       } else
-               return NULL;
+       }
 
        if (!var)
                return NULL;