diff options
author | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-08-27 19:49:20 +0000 |
---|---|---|
committer | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-08-27 19:49:20 +0000 |
commit | 4c77aae2a6a70acf89c17ebb4f7a63b387f75d2e (patch) | |
tree | 88fc4a9442e15c14d42f4f2454cba5af60361636 | |
parent | ef82102b87e844d1b46343763a654c94ca048af7 (diff) |
Fix tag checking in get_sip_pvt_byid_locked when
in pedantic mode. The problem was that the wrong
tags would be compared depending on the direction
of the call.
(closes issue #13353)
Reported by: flefoll
Patches:
chan_sip.c.br14.139015.patch-refer-pedantic uploaded by flefoll (license 244)
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@140299 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r-- | channels/chan_sip.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 5014f9935..e873a162f 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -9007,10 +9007,7 @@ static int get_destination(struct sip_pvt *p, struct sip_request *oreq) return -1; } -/*! \brief Lock interface lock and find matching pvt lock - - Their tag is fromtag, our tag is to-tag - - This means that in some transactions, totag needs to be their tag :-) - depending upon the direction +/*! \brief Lock interface lock and find matching pvt lock */ static struct sip_pvt *get_sip_pvt_byid_locked(const char *callid, const char *totag, const char *fromtag) { @@ -9025,7 +9022,6 @@ static struct sip_pvt *get_sip_pvt_byid_locked(const char *callid, const char *t for (sip_pvt_ptr = iflist; sip_pvt_ptr; sip_pvt_ptr = sip_pvt_ptr->next) { if (!strcmp(sip_pvt_ptr->callid, callid)) { int match = 1; - char *ourtag = sip_pvt_ptr->tag; /* Go ahead and lock it (and its owner) before returning */ ast_mutex_lock(&sip_pvt_ptr->lock); @@ -9034,8 +9030,21 @@ static struct sip_pvt *get_sip_pvt_byid_locked(const char *callid, const char *t (With a forking SIP proxy, several call legs share the call id, but have different tags) */ - if (pedanticsipchecking && (strcmp(fromtag, sip_pvt_ptr->theirtag) || (!ast_strlen_zero(totag) && strcmp(totag, ourtag)))) - match = 0; + if (pedanticsipchecking) { + const char *pvt_fromtag, *pvt_totag; + + if (ast_test_flag(&sip_pvt_ptr->flags[1], SIP_PAGE2_OUTGOING_CALL)) { + /* Outgoing call tags : from is "our", to is "their" */ + pvt_fromtag = sip_pvt_ptr->tag ; + pvt_totag = sip_pvt_ptr->theirtag ; + } else { + /* Incoming call tags : from is "their", to is "our" */ + pvt_fromtag = sip_pvt_ptr->theirtag ; + pvt_totag = sip_pvt_ptr->tag ; + } + if (ast_strlen_zero(fromtag) || strcmp(fromtag, pvt_fromtag) || (!ast_strlen_zero(totag) && strcmp(totag, pvt_totag))) + match = 0; + } if (!match) { ast_mutex_unlock(&sip_pvt_ptr->lock); @@ -9044,7 +9053,7 @@ static struct sip_pvt *get_sip_pvt_byid_locked(const char *callid, const char *t if (option_debug > 3 && totag) ast_log(LOG_DEBUG, "Matched %s call - their tag is %s Our tag is %s\n", - ast_test_flag(&sip_pvt_ptr->flags[0], SIP_OUTGOING) ? "OUTGOING": "INCOMING", + ast_test_flag(&sip_pvt_ptr->flags[1], SIP_PAGE2_OUTGOING_CALL) ? "OUTGOING": "INCOMING", sip_pvt_ptr->theirtag, sip_pvt_ptr->tag); /* deadlock avoidance... */ |