diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-05-25 16:02:04 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-05-25 16:02:04 +0000 |
commit | afcdd5945fa56859175366d8bd740b9b5e44278f (patch) | |
tree | 1262a84dfc358508b846444ca3341d53741fa025 | |
parent | 4d3a765560ed8334b10ea850e69b4870c8766211 (diff) |
Realtime flag affects construction in multiple ways, so consulting whether
rtcachefriends was set was done too soon (needed to be done inside build_peer,
not just as a flag to build_peer).
Also, fullcontact needed to be reconstructed, because realtime separates the
embedded ';' into multiple fields.
(closes issue #12722)
Reported by: barthpbx
Patches:
20080525__bug12722.diff.txt uploaded by Corydon76 (license 14)
Tested by: barthpbx
(Much of the discussion happened on #asterisk-dev for diagnosing this issue)
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@118251 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r-- | channels/chan_sip.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index ea8cfd9c8..28943dfb4 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -2614,7 +2614,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, NULL, !ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS)); + peer = build_peer(newpeername, var, NULL, 1); if (!peer) { if(peerlist) ast_config_destroy(peerlist); @@ -16648,9 +16648,9 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str struct ast_variable *tmpvar = NULL; struct ast_flags peerflags[2] = {{(0)}}; struct ast_flags mask[2] = {{(0)}}; + char fullcontact[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 @@ -16667,7 +16667,7 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str if (!(peer = ast_calloc(1, sizeof(*peer)))) return NULL; - if (realtime) + if (realtime && !ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS)) rpeerobjs++; else speerobjs++; @@ -16704,8 +16704,14 @@ 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)); - ast_set_flag(&peer->flags[1], SIP_PAGE2_RT_FROMCONTACT); + /* Reconstruct field, because realtime separates our value at the ';' */ + if (!ast_strlen_zero(fullcontact)) { + strncat(fullcontact, ";", sizeof(fullcontact) - strlen(fullcontact) - 1); + strncat(fullcontact, v->value, sizeof(fullcontact) - strlen(fullcontact) - 1); + } else { + ast_copy_string(fullcontact, v->value, sizeof(fullcontact)); + ast_set_flag(&peer->flags[1], SIP_PAGE2_RT_FROMCONTACT); + } } else if (!strcasecmp(v->name, "secret")) ast_copy_string(peer->secret, v->value, sizeof(peer->secret)); else if (!strcasecmp(v->name, "md5secret")) @@ -16865,6 +16871,10 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str peer->maxcallbitrate = default_maxcallbitrate; } } + if (!ast_strlen_zero(fullcontact)) { + ast_copy_string(peer->fullcontact, fullcontact, sizeof(peer->fullcontact)); + } + if (!ast_test_flag(&global_flags[1], SIP_PAGE2_IGNOREREGEXPIRE) && ast_test_flag(&peer->flags[1], SIP_PAGE2_DYNAMIC) && realtime) { time_t nowtime = time(NULL); |