diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 0e47c6ecc919c467ff0b37e9ad0f20658125c07e..bf236f853bdf28946ca01cdfe51ba08f6b93123c 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -6704,6 +6704,7 @@ static int get_destination(struct sip_pvt *p, struct sip_request *oreq) char tmp[256] = "", *uri, *a; char tmpf[256], *from; struct sip_request *req; + char *colon; req = oreq; if (!req) @@ -6735,20 +6736,27 @@ static int get_destination(struct sip_pvt *p, struct sip_request *oreq) ast_uri_decode(from); } + /* Skip any options */ + if ((a = strchr(uri, ';'))) { + *a = '\0'; + } + /* Get the target domain */ if ((a = strchr(uri, '@'))) { - char *colon; *a = '\0'; a++; colon = strchr(a, ':'); /* Remove :port */ if (colon) *colon = '\0'; - ast_string_field_set(p, domain, a); - } - /* Skip any options */ - if ((a = strchr(uri, ';'))) { - *a = '\0'; + } else { /* No username part */ + a = uri; + uri = "s"; /* Set extension to "s" */ } + colon = strchr(a, ':'); /* Remove :port */ + if (colon) + *colon = '\0'; + + ast_string_field_set(p, domain, a); if (!AST_LIST_EMPTY(&domain_list)) { char domain_context[AST_MAX_EXTENSION];