diff options
Diffstat (limited to 'net/asterisk12/files/patch-channels::chan_sip.c')
-rw-r--r-- | net/asterisk12/files/patch-channels::chan_sip.c | 233 |
1 files changed, 110 insertions, 123 deletions
diff --git a/net/asterisk12/files/patch-channels::chan_sip.c b/net/asterisk12/files/patch-channels::chan_sip.c index e634ce47c97f..355c558c2ab1 100644 --- a/net/asterisk12/files/patch-channels::chan_sip.c +++ b/net/asterisk12/files/patch-channels::chan_sip.c @@ -1,144 +1,131 @@ $FreeBSD$ ---- channels/chan_sip.c.orig Sun Feb 17 18:01:43 2002 -+++ channels/chan_sip.c Sun Feb 17 18:10:52 2002 -@@ -141,7 +141,7 @@ +--- channels/chan_sip.c.orig Thu Jan 12 18:43:37 2006 ++++ channels/chan_sip.c Thu Jan 12 18:50:11 2006 +@@ -336,7 +336,7 @@ static char global_vmexten[AST_MAX_EXTEN static char default_language[MAX_LANGUAGE] = ""; --static char default_callerid[AST_MAX_EXTENSION] = "asterisk"; -+static char default_callerid[AST_MAX_EXTENSION] = "Unknown"; +-#define DEFAULT_CALLERID "asterisk" ++#define DEFAULT_CALLERID "Unknown" + static char default_callerid[AST_MAX_EXTENSION] = DEFAULT_CALLERID; static char default_fromdomain[AST_MAX_EXTENSION] = ""; +@@ -474,6 +474,7 @@ struct sip_invite_param { -@@ -244,6 +244,7 @@ struct sip_route { struct sip_route *next; - char hop[0]; + int lr; + char hop[0]; }; - struct sip_history { -@@ -2218,7 +2219,7 @@ - if (p->owner) { - /* We already hold the channel lock */ - if (f->frametype == AST_FRAME_VOICE) { -- if (f->subclass != p->owner->nativeformats) { -+ if (!(f->subclass & p->owner->nativeformats)) { - ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass); - p->owner->nativeformats = f->subclass; - ast_set_read_format(p->owner, p->owner->readformat); -@@ -4620,6 +4621,10 @@ +@@ -5993,6 +5994,7 @@ static void build_route(struct sip_pvt * /* Make a struct route */ - thishop = (struct sip_route *)malloc(sizeof(struct sip_route)+len+1); + thishop = malloc(sizeof(*thishop) + len); if (thishop) { -+ if (strnstr(rr, ";lr", len) != NULL) -+ thishop->lr = 1; -+ else -+ thishop->lr = 0; - strncpy(thishop->hop, rr, len); /* safe */ - thishop->hop[len] = '\0'; ++ thishop->lr = (strnstr(rr, ";lr", len) != NULL ? 1 : 0); + ast_copy_string(thishop->hop, rr, len); ast_log(LOG_DEBUG, "build_route: Record-Route hop: <%s>\n", thishop->hop); -@@ -4643,31 +4648,41 @@ - rr += len+1; - } - } -- /* 2nd append the Contact: if there is one */ -- /* Can be multiple Contact headers, comma separated values - we just take the first */ -- contact = get_header(req, "Contact"); -- if (!ast_strlen_zero(contact)) { -- ast_log(LOG_DEBUG, "build_route: Contact hop: %s\n", contact); -- /* Look for <: delimited address */ -- c = strchr(contact, '<'); -- if (c) { -- /* Take to > */ -- ++c; -- len = strcspn(c, ">"); -- } else { -- /* No <> - just take the lot */ -- c = contact; len = strlen(contact); -- } -- thishop = (struct sip_route *)malloc(sizeof(struct sip_route)+len+1); -+ /* Duplicate first route from the list */ -+ if (head && head->lr) { -+ thishop = (struct sip_route *)malloc(sizeof(struct sip_route)+strlen(head->hop)+1); - if (thishop) { -- strncpy(thishop->hop, c, len); /* safe */ -- thishop->hop[len] = '\0'; -- thishop->next = NULL; -- /* Goes at the end */ -- if (tail) -- tail->next = thishop; -- else -- head = thishop; -+ memcpy(thishop, head, sizeof(struct sip_route)+strlen(head->hop)+1); -+ thishop->next = head; -+ head = thishop; -+ } -+ } else { -+ /* Append the Contact: if there is one and first route is w/o `lr' param */ -+ /* Can be multiple Contact headers, comma separated values - we just take the first */ -+ contact = get_header(req, "Contact"); -+ if (!ast_strlen_zero(contact)) { -+ ast_log(LOG_DEBUG, "build_route: Contact hop: %s\n", contact); -+ /* Look for <: delimited address */ -+ c = strchr(contact, '<'); -+ if (c) { -+ /* Take to > */ -+ ++c; -+ len = strcspn(c, ">"); -+ } else { -+ /* No <> - just take the lot */ -+ c = contact; len = strlen(contact); -+ } -+ thishop = (struct sip_route *)malloc(sizeof(struct sip_route)+len+1); -+ if (thishop) { -+ strncpy(thishop->hop, c, len); /* safe */ -+ thishop->hop[len] = '\0'; -+ thishop->next = NULL; -+ /* Goes at the end */ -+ if (tail) -+ tail->next = thishop; -+ else -+ head = thishop; + /* Link in */ +@@ -6018,31 +6020,41 @@ static void build_route(struct sip_pvt * + + /* Only append the contact if we are dealing with a strict router */ + if (!head || (!ast_strlen_zero(head->hop) && strstr(head->hop,";lr") == NULL) ) { +- /* 2nd append the Contact: if there is one */ +- /* Can be multiple Contact headers, comma separated values - we just take the first */ +- contact = get_header(req, "Contact"); +- if (!ast_strlen_zero(contact)) { +- ast_log(LOG_DEBUG, "build_route: Contact hop: %s\n", contact); +- /* Look for <: delimited address */ +- c = strchr(contact, '<'); +- if (c) { +- /* Take to > */ +- ++c; +- len = strcspn(c, ">") + 1; +- } else { +- /* No <> - just take the lot */ +- c = contact; +- len = strlen(contact) + 1; +- } +- thishop = malloc(sizeof(*thishop) + len); ++ /* Duplicate first route from the list */ ++ if (head && head->lr) { ++ thishop = (struct sip_route *)malloc(sizeof(struct sip_route)+strlen(head->hop)+1); + if (thishop) { +- ast_copy_string(thishop->hop, c, len); +- thishop->next = NULL; +- /* Goes at the end */ +- if (tail) +- tail->next = thishop; +- else +- head = thishop; ++ memcpy(thishop, head, sizeof(struct sip_route)+strlen(head->hop)+1); ++ thishop->next = head; ++ head = thishop; + } ++ } else { ++ /* Append the Contact: if there is one and first route is w/o `lr' param */ ++ /* Can be multiple Contact headers, comma separated values - we just take the first */ ++ contact = get_header(req, "Contact"); ++ if (!ast_strlen_zero(contact)) { ++ ast_log(LOG_DEBUG, "build_route: Contact hop: %s\n", contact); ++ /* Look for <: delimited address */ ++ c = strchr(contact, '<'); ++ if (c) { ++ /* Take to > */ ++ ++c; ++ len = strcspn(c, ">") + 1; ++ } else { ++ /* No <> - just take the lot */ ++ c = contact; ++ len = strlen(contact) + 1; ++ } ++ thishop = malloc(sizeof(*thishop) + len); ++ if (thishop) { ++ ast_copy_string(thishop->hop, c, len); ++ thishop->next = NULL; ++ /* Goes at the end */ ++ if (tail) ++ tail->next = thishop; ++ else ++ head = thishop; ++ } + } } } - /* Store as new route */ -@@ -7338,7 +7353,11 @@ - /* Get destination right away */ - gotdest = get_destination(p, NULL); - get_rdnis(p, NULL); -- extract_uri(p, req); -+ build_route(p, req, 0); -+ if (!p->route->lr) -+ strncpy(p->uri, p->route->hop, sizeof(p->uri) - 1); -+ else -+ extract_uri(p, req); - build_contact(p); +@@ -10336,7 +10348,11 @@ static int handle_request_invite(struct + gotdest = get_destination(p, NULL); - if (gotdest) { -@@ -7366,7 +7385,6 @@ - c = sip_new(p, AST_STATE_DOWN, ast_strlen_zero(p->username) ? NULL : p->username ); - *recount = 1; - /* Save Record-Route for any later requests we make on this dialogue */ -- build_route(p, req, 0); - if (c) { - /* Pre-lock the call */ - ast_mutex_lock(&c->lock); -@@ -7426,6 +7444,14 @@ - transmit_response(p, "180 Ringing", req); - break; - case AST_STATE_UP: -+ /* Assuming this to be reinvite, process new SDP portion */ -+ if (!ast_strlen_zero(get_header(req, "Content-Type"))) { -+ process_sdp(p, req); -+ } else { -+ p->jointcapability = p->capability; -+ ast_log(LOG_DEBUG, "Hm.... No sdp for the moment\n"); -+ } -+ - transmit_response_with_sdp(p, "200 OK", req, 1); - break; - default: + get_rdnis(p, NULL); +- extract_uri(p, req); ++ build_route(p, req, 0); ++ if (!p->route->lr) ++ strncpy(p->uri, p->route->hop, sizeof(p->uri) - 1); ++ else ++ extract_uri(p, req); + build_contact(p); + + if (gotdest) { +@@ -10364,7 +10380,6 @@ static int handle_request_invite(struct + c = sip_new(p, AST_STATE_DOWN, ast_strlen_zero(p->username) ? NULL : p->username ); + *recount = 1; + /* Save Record-Route for any later requests we make on this dialogue */ +- build_route(p, req, 0); + if (c) { + /* Pre-lock the call */ + ast_mutex_lock(&c->lock); +@@ -10450,6 +10465,13 @@ static int handle_request_invite(struct + transmit_response(p, "180 Ringing", req); + break; + case AST_STATE_UP: ++ /* Assuming this to be reinvite, process new SDP portion */ ++ if (!ast_strlen_zero(get_header(req, "Content-Type"))) { ++ process_sdp(p, req); ++ } else { ++ p->jointcapability = p->capability; ++ ast_log(LOG_DEBUG, "Hm.... No sdp for the moment\n"); ++ } + transmit_response_with_sdp(p, "200 OK", req, 1); + break; + default: |