From: Kevin P. Fleming Date: Thu, 16 Oct 2008 15:02:10 +0000 (+0000) Subject: ensure that type=peer entries are only matched on IP/port, not on name (after oej... X-Git-Tag: 1.6.2.0-beta1~1090 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2f3193ec7032ae6e3d15269c19d53fdef0b610de;p=thirdparty%2Fasterisk.git ensure that type=peer entries are only matched on IP/port, not on name (after oej audits all the calls to find_peer() to make sure that forcenamematch is set correctly in each case) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@150052 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 20848fcbc1..88a1593359 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -4177,9 +4177,25 @@ static struct sip_peer *find_peer(const char *peer, struct sockaddr_in *sin, int struct sip_peer *p = NULL; struct sip_peer tmp_peer; + auto int find_by_name(void *obj, void *arg, int flags); + int find_by_name(void *obj, void *arg, int flags) + { + struct sip_peer *search = obj, *match = arg; + + if (strcasecmp(search->name, match->name)) { + return 0; + } + + if (forcenamematch && search->onlymatchonip) { + return 0; + } + + return CMP_MATCH | CMP_STOP; + } + if (peer) { ast_copy_string(tmp_peer.name, peer, sizeof(tmp_peer.name)); - p = ao2_t_find(peers, &tmp_peer, OBJ_POINTER, "ao2_find in peers table"); + p = ao2_t_callback(peers, OBJ_POINTER, find_by_name, &tmp_peer, "ao2_find in peers table"); } else if (sin) { /* search by addr? */ tmp_peer.addr.sin_addr.s_addr = sin->sin_addr.s_addr; tmp_peer.addr.sin_port = sin->sin_port;