--- channels/.svn/text-base/chan_sip.c.svn-base 2011-02-22 17:08:09.000000000 +0100 +++ channels/chan_sip.c 2011-03-07 20:50:49.000000000 +0100 @@ -208,7 +208,7 @@ #include "asterisk.h" -ASTERISK_FILE_VERSION(__FILE__, "$Revision$") +ASTERISK_FILE_VERSION(__FILE__, "$Revision: 307891 $") #include #include @@ -15607,6 +15607,7 @@ struct ast_msg *msg; int res; char *from, *to; + char *name = NULL, *number = NULL; if (strncmp(content_type, "text/plain", strlen("text/plain"))) { /* No text/plain attachment */ transmit_response(p, "415 Unsupported Media Type", req); /* Good enough, or? */ @@ -15704,9 +15705,11 @@ to = ast_strdupa(REQ_OFFSET_TO_STR(req, rlPart2)); from = ast_strdupa(get_header(req, "From")); + get_name_and_number(from, &name, &number); res = ast_msg_set_to(msg, "%s", to); - res |= ast_msg_set_from(msg, "%s", get_in_brackets(from)); + //res |= ast_msg_set_from(msg, "%s", get_in_brackets(from)); + res |= ast_msg_set_from(msg, "%s/%s", number, (name?name:"")); res |= ast_msg_set_body(msg, "%s", ast_str_buffer(buf)); res |= ast_msg_set_context(msg, "%s", p->context); @@ -23095,6 +23098,8 @@ struct sip_pvt *pvt; int res; char *peer; + char *todnid = NULL, *number = NULL, *name = NULL; + char *c; if (!(pvt = sip_alloc(NULL, NULL, 0, SIP_MESSAGE, NULL))) { return -1; @@ -23111,6 +23116,22 @@ return -1; } + + c = strchr(to, ':'); + if (c) { + todnid = ast_strdup(c+1); + } + + if (from) { + number = ast_strdupa(from); + c = strchr(number, '/'); + if (c) { + *c = '\0'; + if (c+1) + name = ast_strdupa(c+1); + } + } + sip_pvt_lock(pvt); if (create_addr(pvt, peer, NULL, TRUE, NULL)) { @@ -23122,6 +23143,12 @@ ast_sip_ouraddrfor(&pvt->sa, &pvt->ourip, pvt); ast_set_flag(&pvt->flags[0], SIP_OUTGOING); + if (todnid) + ast_string_field_set(pvt, todnid, todnid); + if (number) + ast_string_field_set(pvt, fromuser, number); + if (name) + ast_string_field_set(pvt, fromname, name); /* XXX Does pvt->expiry need to be set? */ res = transmit_message_with_text(pvt, ast_msg_get_body(msg), 1, 0);