From f537e2e0eca75fb3715fada6fa5130841a1f4476 Mon Sep 17 00:00:00 2001 From: Mark Spencer Date: Thu, 9 Oct 2003 22:50:42 +0000 Subject: [PATCH] Consider "from" when getting destination (bug #368) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1623 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- channels/chan_sip.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 324b8b622a..26282a50fd 100755 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -3543,6 +3543,7 @@ static int get_rdnis(struct sip_pvt *p, struct sip_request *oreq) static int get_destination(struct sip_pvt *p, struct sip_request *oreq) { char tmp[256] = "", *c, *a; + char tmpf[256]= "", *fr; struct sip_request *req; req = oreq; @@ -3551,6 +3552,13 @@ static int get_destination(struct sip_pvt *p, struct sip_request *oreq) if (req->rlPart2) strncpy(tmp, req->rlPart2, sizeof(tmp) - 1); c = ditch_braces(tmp); + + strncpy(tmpf, get_header(oreq, "From"), sizeof(tmpf) - 1); + fr = ditch_braces(tmpf); + + if (fr && !strlen(fr)) + fr = NULL; + if (strncmp(c, "sip:", 4)) { ast_log(LOG_WARNING, "Huh? Not a SIP header (%s)?\n", c); return -1; @@ -3561,14 +3569,14 @@ static int get_destination(struct sip_pvt *p, struct sip_request *oreq) } if (sipdebug) ast_verbose("Looking for %s in %s\n", c, p->context); - if (ast_exists_extension(NULL, p->context, c, 1, NULL) || + if (ast_exists_extension(NULL, p->context, c, 1, fr) || !strcmp(c, ast_pickup_ext())) { if (!oreq) strncpy(p->exten, c, sizeof(p->exten) - 1); return 0; } - if (ast_canmatch_extension(NULL, p->context, c, 1, NULL) || + if (ast_canmatch_extension(NULL, p->context, c, 1, fr) || !strncmp(c, ast_pickup_ext(),strlen(c))) { return 1; }