[asterisk-commits] twilson: branch russell/messaging r311661 - /team/russell/messaging/channels/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Mar 23 18:07:34 CDT 2011
Author: twilson
Date: Wed Mar 23 18:07:29 2011
New Revision: 311661
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=311661
Log:
Set from for SIP messages sent by MessageSend
If the from parameter is:
a SIP device from sip.conf -
Use the callerid set in sip.conf, otherwise the device name
in the form "Name" <sip:user at example.com>:
Use the information directly
in the form of "Name" <6001>:
Set from to "Name" <6001 at default_ip>
otherwise just use it as calerid name and use defaults for the rest.
Modified:
team/russell/messaging/channels/chan_sip.c
Modified: team/russell/messaging/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/russell/messaging/channels/chan_sip.c?view=diff&rev=311661&r1=311660&r2=311661
==============================================================================
--- team/russell/messaging/channels/chan_sip.c (original)
+++ team/russell/messaging/channels/chan_sip.c Wed Mar 23 18:07:29 2011
@@ -23125,6 +23125,7 @@
struct sip_pvt *pvt;
int res;
char *peer;
+ struct sip_peer *peer_ptr;
if (!(pvt = sip_alloc(NULL, NULL, 0, SIP_MESSAGE, NULL))) {
return -1;
@@ -23139,6 +23140,30 @@
if (ast_strlen_zero(peer)) {
ast_log(LOG_WARNING, "MESSAGE(to) is invalid for SIP - '%s'\n", to);
return -1;
+ }
+
+ if (!ast_strlen_zero(from)) {
+ if ((peer_ptr = find_peer(from, NULL, 0, 1, 0, 0))) {
+ ast_string_field_set(pvt, fromname, S_OR(peer_ptr->cid_name, peer_ptr->name));
+ ast_string_field_set(pvt, fromuser, S_OR(peer_ptr->cid_num, peer_ptr->name));
+ unref_peer(peer_ptr, "unref_peer, from sip_msg_send, find_peer");
+ } else if (strchr(from, '<')) { /* from is callerid-style */
+ char *sender;
+ char *name = NULL, *location = NULL, *user = NULL, *domain = NULL;
+
+ sender = ast_strdupa(from);
+ ast_callerid_parse(sender, &name, &location);
+ ast_string_field_set(pvt, fromname, name);
+ if (strchr(location, ':')) { /* Must be a URI */
+ parse_uri(location, "sip:,sips:", &user, NULL, &domain, NULL);
+ ast_string_field_set(pvt, fromuser, user);
+ ast_string_field_set(pvt, fromdomain, domain);
+ } else { /* Treat it as an exten/user */
+ ast_string_field_set(pvt, fromuser, location);
+ }
+ } else { /* assume we just have the name, use defaults for the rest */
+ ast_string_field_set(pvt, fromname, from);
+ }
}
sip_pvt_lock(pvt);
More information about the asterisk-commits
mailing list