Index: channels/chan_sip.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v retrieving revision 1.900 diff -u -r1.900 chan_sip.c --- channels/chan_sip.c 30 Oct 2005 21:36:27 -0000 1.900 +++ channels/chan_sip.c 31 Oct 2005 00:37:35 -0000 @@ -6481,8 +6481,9 @@ /*! \brief get_destination: Find out who the call is for --*/ static int get_destination(struct sip_pvt *p, struct sip_request *oreq) { - char tmp[256] = "", *uri, *a; + char tmp[256] = "", *uri, *exten, *domain, *port, *a; char tmpf[256], *from; + static char start_exten[] = "s"; /* Is there a constant for this? */ struct sip_request *req; req = oreq; @@ -6515,21 +6516,39 @@ ast_uri_decode(from); } - /* Get the target domain */ + /* split up the uri into parts, perhaps this should be a function */ if ((a = strchr(uri, '@'))) { - char *colon; + /* split user/domain portion */ + exten = uri; *a = '\0'; a++; - colon = strchr(a, ':'); /* Remove :port */ - if (colon) - *colon = '\0'; - ast_copy_string(p->domain, a, sizeof(p->domain)); + domain = a; + } else { + /* no '@' in uri, goto exten => s */ + exten = start_exten; + domain = uri; } - /* Skip any options */ - if ((a = strchr(uri, ';'))) { + + if ((a = strchr(domain, ':'))) { + /* split domain:port */ *a = '\0'; + a++; + port = a; + if ((a = strchr(port, ';'))) { + *a = '\0'; + /* if we want options, a++ would be a nice place to get them */ + } + } else { + /* no port */ + port = NULL; + if ((a = strchr(domain, ';'))) { + *a = '\0'; + /* if we want options, a++ would be a nice place to get them */ + } } + ast_copy_string(p->domain, domain, sizeof(p->domain)); + if (!AST_LIST_EMPTY(&domain_list)) { char domain_context[AST_MAX_EXTENSION]; @@ -6555,19 +6574,19 @@ ast_copy_string(p->fromdomain, from, sizeof(p->fromdomain)); } if (sip_debug_test_pvt(p)) - ast_verbose("Looking for %s in %s (domain %s)\n", uri, p->context, p->domain); + ast_verbose("Looking for %s in %s (domain %s)\n", exten, p->context, p->domain); /* Return 0 if we have a matching extension */ - if (ast_exists_extension(NULL, p->context, uri, 1, from) || - !strcmp(uri, ast_pickup_ext())) { + if (ast_exists_extension(NULL, p->context, exten, 1, from) || + !strcmp(exten, ast_pickup_ext())) { if (!oreq) - ast_copy_string(p->exten, uri, sizeof(p->exten)); + ast_copy_string(p->exten, exten, sizeof(p->exten)); return 0; } /* Return 1 for overlap dialling support */ - if (ast_canmatch_extension(NULL, p->context, uri, 1, from) || - !strncmp(uri, ast_pickup_ext(),strlen(uri))) { + if (ast_canmatch_extension(NULL, p->context, exten, 1, from) || + !strncmp(exten, ast_pickup_ext(),strlen(exten))) { return 1; }