aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authordvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b>2009-05-08 20:51:17 +0000
committerdvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b>2009-05-08 20:51:17 +0000
commit63697512edb90ad22b0eb84b3c9006cd62b5f436 (patch)
tree3549cf1acc4abfaa86dab9fe2c6e681336f14d9e /channels
parente054b8d74e5986099f340263a8d727951bc5ef73 (diff)
Merged revisions 193387 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ........ r193387 | dvossel | 2009-05-08 15:32:51 -0500 (Fri, 08 May 2009) | 7 lines TCP not matching valid peer. find_peer() does not find a valid peer when using pvt->recv as the sockaddr_in argument. Because of the way TCP works, the port number in pvt->recv is not what we're looking for at all. There is currently only one place that find_peer searches for a peer using the sockaddr_in argument. If the peer is not found after using pvt->recv (works for UDP since the port number will be correct), a temp sockaddr_in struct is made using the Contact header in the sip_request. This has the correct port number in it. Review: http://reviewboard.digium.com/r/236/ ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.1@193389 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_sip.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index c1113a1cf..d6bb077e1 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -12232,6 +12232,22 @@ static enum check_auth_result check_peer_ok(struct sip_pvt *p, char *of,
if (!peer) {
peer = find_peer(NULL, &p->recv, TRUE, FINDPEERS, FALSE);
}
+
+ /* If the peer is still not found, try the address and port from the
+ * contact header. If the transport type is TCP or TLS it is not possible
+ * to find the peer using p->recv. Because of the way TCP works, the received
+ * packet's destination port will not match the one the peer table is
+ * built with. */
+ if (!peer && (p->socket.type != SIP_TRANSPORT_UDP)) {
+ struct sockaddr_in tmpsin;
+ char contact[SIPBUFSIZE];
+ char *tmp;
+ memcpy(&tmpsin, &p->recv, sizeof(tmpsin));
+ ast_copy_string(contact, get_header(req, "Contact"), sizeof(contact));
+ tmp = get_in_brackets(contact);
+ __set_address_from_contact(tmp, &tmpsin, 1);
+ peer = find_peer(NULL, &tmpsin, TRUE, FINDPEERS, FALSE);
+ }
}
if (!peer) {