Merged revisions 118251 via svnmerge from
[asterisk/asterisk.git] / channels / chan_sip.c
index 82b25c8..c7a092e 100644 (file)
@@ -3956,7 +3956,7 @@ static struct sip_peer *realtime_peer(const char *newpeername, struct sockaddr_i
 
 
        /* Peer found in realtime, now build it in memory */
-       peer = build_peer(newpeername, var, varregs, !ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS));
+       peer = build_peer(newpeername, var, varregs, 1);
        if (!peer) {
                if(peerlist)
                        ast_config_destroy(peerlist);
@@ -20894,8 +20894,9 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str
        struct sip_peer tmp_peer;
        const char *srvlookup = NULL;
        static int deprecation_warning = 1;
+       struct ast_str *fullcontact = ast_str_alloca(sizeof(peer->fullcontact));
        
-       if (!realtime) {
+       if (!realtime || ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS)) {
                /* Note we do NOT use find_peer here, to avoid realtime recursion */
                /* We also use a case-sensitive comparison (unlike find_peer) so
                   that case changes made to the peer name will be properly handled
@@ -20914,7 +20915,7 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str
                if (!(peer = ao2_t_alloc(sizeof(*peer), sip_destroy_peer_fn, "allocate a peer struct")))
                        return NULL;
 
-               if (realtime) {
+               if (realtime && !ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS)) {
                        ast_atomic_fetchadd_int(&rpeerobjs, 1);
                        ast_debug(3, "-REALTIME- peer built. Name: %s. Peer objects: %d\n", name, rpeerobjs);
                } else
@@ -20958,8 +20959,12 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str
                } else if (realtime && !strcasecmp(v->name, "name"))
                        ast_copy_string(peer->name, v->value, sizeof(peer->name));
                else if (realtime && !strcasecmp(v->name, "fullcontact")) {
-                       ast_copy_string(peer->fullcontact, v->value, sizeof(peer->fullcontact));
-                       peer->rt_fromcontact = TRUE;
+                       /* Reconstruct field, because realtime separates our value at the ';' */
+                       if (fullcontact->used > 0) {
+                               ast_str_append(&fullcontact, 0, ";%s", v->value);
+                       } else {
+                               ast_str_set(&fullcontact, 0, "%s", v->value);
+                       }
                } else if (!strcasecmp(v->name, "secret")) 
                        ast_copy_string(peer->secret, v->value, sizeof(peer->secret));
                else if (!strcasecmp(v->name, "md5secret")) 
@@ -21182,6 +21187,11 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str
                }
        }
 
+       if (fullcontact->used > 0) {
+               ast_copy_string(peer->fullcontact, fullcontact->str, sizeof(peer->fullcontact));
+               peer->rt_fromcontact = TRUE;
+       }
+
        if (srvlookup && peer->dnsmgr == NULL) {
                char transport[MAXHOSTNAMELEN];
                snprintf(transport, sizeof(transport), "_sip._%s", get_transport(peer->socket.type));