MODENDP-242
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@14581 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
b24a2863c0
commit
49e87ddfe8
|
@ -902,5 +902,6 @@ void sofia_glue_set_rtp_stats(private_object_t *tech_pvt);
|
|||
void sofia_glue_get_addr(msg_t *msg, char *buf, size_t buflen, int *port);
|
||||
sofia_destination_t* sofia_glue_get_destination(char *data);
|
||||
void sofia_glue_free_destination(sofia_destination_t *dst);
|
||||
switch_status_t sofia_glue_send_notify(sofia_profile_t *profile, const char *user, const char *host, const char *event, const char *contenttype, const char *body, const char *o_contact, const char *network_ip);
|
||||
char *sofia_glue_get_extra_headers(switch_channel_t *channel, const char *prefix);
|
||||
void sofia_glue_set_extra_headers(switch_channel_t *channel, sip_t const *sip, const char *prefix);
|
||||
|
|
|
@ -4275,6 +4275,71 @@ void sofia_glue_free_destination(sofia_destination_t *dst)
|
|||
}
|
||||
}
|
||||
|
||||
switch_status_t sofia_glue_send_notify(sofia_profile_t *profile, const char *user, const char *host, const char *event, const char *contenttype, const char *body, const char *o_contact, const char *network_ip)
|
||||
{
|
||||
char *id = NULL;
|
||||
nua_handle_t *nh;
|
||||
sofia_destination_t *dst = NULL;
|
||||
char *contact_str, *contact, *user_via = NULL;
|
||||
|
||||
contact = sofia_glue_get_url_from_contact((char*) o_contact, 1);
|
||||
if (sofia_glue_check_nat(profile, network_ip)) {
|
||||
char *ptr = NULL;
|
||||
const char *transport_str = NULL;
|
||||
|
||||
|
||||
id = switch_mprintf("sip:%s@%s", user, profile->extsipip);
|
||||
switch_assert(id);
|
||||
|
||||
if ((ptr = sofia_glue_find_parameter(o_contact, "transport="))) {
|
||||
sofia_transport_t transport = sofia_glue_str2transport(ptr);
|
||||
transport_str = sofia_glue_transport2str(transport);
|
||||
switch (transport) {
|
||||
case SOFIA_TRANSPORT_TCP:
|
||||
contact_str = profile->tcp_public_contact;
|
||||
break;
|
||||
case SOFIA_TRANSPORT_TCP_TLS:
|
||||
contact_str = profile->tls_public_contact;
|
||||
break;
|
||||
default:
|
||||
contact_str = profile->public_url;
|
||||
break;
|
||||
}
|
||||
user_via = sofia_glue_create_external_via(NULL, profile, transport);
|
||||
} else {
|
||||
user_via = sofia_glue_create_external_via(NULL, profile, SOFIA_TRANSPORT_UDP);
|
||||
contact_str = profile->public_url;
|
||||
}
|
||||
|
||||
} else {
|
||||
contact_str = profile->url;
|
||||
id = switch_mprintf("sip:%s@%s", user, host);
|
||||
}
|
||||
|
||||
dst = sofia_glue_get_destination((char*) o_contact);
|
||||
switch_assert(dst);
|
||||
|
||||
nh = nua_handle(profile->nua, NULL, NUTAG_URL(contact),
|
||||
SIPTAG_FROM_STR(id), SIPTAG_TO_STR(id),
|
||||
SIPTAG_CONTACT_STR(contact_str), TAG_END());
|
||||
nua_handle_bind(nh, &mod_sofia_globals.destroy_private);
|
||||
|
||||
nua_notify(nh,
|
||||
NUTAG_NEWSUB(1),
|
||||
TAG_IF(dst->route_uri, NUTAG_PROXY(dst->route_uri)), TAG_IF(dst->route, SIPTAG_ROUTE_STR(dst->route)),
|
||||
TAG_IF(user_via, SIPTAG_VIA_STR(user_via)),
|
||||
SIPTAG_EVENT_STR(event),
|
||||
SIPTAG_CONTENT_TYPE_STR(contenttype),
|
||||
SIPTAG_PAYLOAD_STR(body), TAG_END());
|
||||
|
||||
switch_safe_free(contact);
|
||||
switch_safe_free(id);
|
||||
sofia_glue_free_destination(dst);
|
||||
switch_safe_free(user_via);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
|
|
|
@ -1365,19 +1365,17 @@ static int sofia_presence_mwi_callback(void *pArg, int argc, char **argv, char *
|
|||
|
||||
static int sofia_presence_mwi_callback2(void *pArg, int argc, char **argv, char **columnNames)
|
||||
{
|
||||
char *sub_to_user = argv[0];
|
||||
char *sub_to_host = argv[1];
|
||||
char *event = "message-summary";
|
||||
char *o_contact = argv[2];
|
||||
const char *user = argv[0];
|
||||
const char *host = argv[1];
|
||||
const char *event = "message-summary";
|
||||
const char *contenttype = "application/simple-message-summary";
|
||||
const char *body = argv[5];
|
||||
const char *o_contact = argv[2];
|
||||
const char *network_ip = argv[4];
|
||||
|
||||
char *profile_name = argv[3];
|
||||
char *network_ip = argv[4];
|
||||
char *body = argv[5];
|
||||
char *id = NULL;
|
||||
nua_handle_t *nh;
|
||||
struct mwi_helper *h = (struct mwi_helper *) pArg;
|
||||
sofia_profile_t *ext_profile = NULL, *profile = h->profile;
|
||||
sofia_destination_t *dst = NULL;
|
||||
char *contact_str, *contact, *user_via = NULL;
|
||||
|
||||
if (profile_name && strcasecmp(profile_name, h->profile->name)) {
|
||||
if ((ext_profile = sofia_glue_find_profile(profile_name))) {
|
||||
|
@ -1385,61 +1383,7 @@ static int sofia_presence_mwi_callback2(void *pArg, int argc, char **argv, char
|
|||
}
|
||||
}
|
||||
|
||||
contact = sofia_glue_get_url_from_contact(o_contact, 1);
|
||||
if (sofia_glue_check_nat(profile, network_ip)) {
|
||||
char *ptr = NULL;
|
||||
const char *transport_str = NULL;
|
||||
|
||||
|
||||
id = switch_mprintf("sip:%s@%s", sub_to_user, profile->extsipip);
|
||||
switch_assert(id);
|
||||
|
||||
if ((ptr = sofia_glue_find_parameter(o_contact, "transport="))) {
|
||||
sofia_transport_t transport = sofia_glue_str2transport(ptr);
|
||||
transport_str = sofia_glue_transport2str(transport);
|
||||
|
||||
switch (transport) {
|
||||
case SOFIA_TRANSPORT_TCP:
|
||||
contact_str = profile->tcp_public_contact;
|
||||
break;
|
||||
case SOFIA_TRANSPORT_TCP_TLS:
|
||||
contact_str = profile->tls_public_contact;
|
||||
break;
|
||||
default:
|
||||
contact_str = profile->public_url;
|
||||
break;
|
||||
}
|
||||
user_via = sofia_glue_create_external_via(NULL, profile, transport);
|
||||
} else {
|
||||
user_via = sofia_glue_create_external_via(NULL, profile, SOFIA_TRANSPORT_UDP);
|
||||
contact_str = profile->public_url;
|
||||
}
|
||||
|
||||
} else {
|
||||
contact_str = profile->url;
|
||||
id = switch_mprintf("sip:%s@%s", sub_to_user, sub_to_host);
|
||||
}
|
||||
|
||||
dst = sofia_glue_get_destination(o_contact);
|
||||
switch_assert(dst);
|
||||
|
||||
nh = nua_handle(profile->nua, NULL, NUTAG_URL(contact),
|
||||
SIPTAG_FROM_STR(id), SIPTAG_TO_STR(id),
|
||||
SIPTAG_CONTACT_STR(contact_str), TAG_END());
|
||||
nua_handle_bind(nh, &mod_sofia_globals.destroy_private);
|
||||
|
||||
nua_notify(nh,
|
||||
NUTAG_NEWSUB(1),
|
||||
TAG_IF(dst->route_uri, NUTAG_PROXY(dst->route_uri)), TAG_IF(dst->route, SIPTAG_ROUTE_STR(dst->route)),
|
||||
TAG_IF(user_via, SIPTAG_VIA_STR(user_via)),
|
||||
SIPTAG_EVENT_STR(event),
|
||||
SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"),
|
||||
SIPTAG_PAYLOAD_STR(body), TAG_END());
|
||||
|
||||
switch_safe_free(contact);
|
||||
switch_safe_free(id);
|
||||
sofia_glue_free_destination(dst);
|
||||
switch_safe_free(user_via);
|
||||
sofia_glue_send_notify(profile, user, host, event, contenttype, body, o_contact, network_ip);
|
||||
|
||||
if (ext_profile) {
|
||||
sofia_glue_release_profile(ext_profile);
|
||||
|
|
|
@ -439,11 +439,8 @@ int sofia_sub_del_callback(void *pArg, int argc, char **argv, char **columnNames
|
|||
void sofia_reg_send_reboot(sofia_profile_t *profile, const char *user, const char *host, const char *contact, const char *user_agent, const char *network_ip)
|
||||
{
|
||||
const char *event = "check-sync";
|
||||
nua_handle_t *nh;
|
||||
char *contact_url = NULL;
|
||||
char *contact_str = NULL;
|
||||
char *user_via = NULL;
|
||||
char *id = NULL;
|
||||
const char *contenttype = "application/simple-message-summary";
|
||||
const char *body = "";
|
||||
|
||||
if (switch_stristr("snom", user_agent)) {
|
||||
event = "check-sync;reboot=true";
|
||||
|
@ -451,65 +448,8 @@ void sofia_reg_send_reboot(sofia_profile_t *profile, const char *user, const cha
|
|||
event = "reboot_now";
|
||||
}
|
||||
|
||||
if ((contact_url = sofia_glue_get_url_from_contact((char *)contact, 1))) {
|
||||
char *p;
|
||||
id = switch_mprintf("sip:%s@%s", user, network_ip);
|
||||
sofia_glue_send_notify(profile, user, host, event, contenttype, body, contact, network_ip);
|
||||
|
||||
if ((p = strstr(contact_url, ";fs_"))) {
|
||||
*p = '\0';
|
||||
}
|
||||
if (sofia_glue_check_nat(profile, network_ip)) {
|
||||
char *ptr = NULL;
|
||||
const char *transport_str = NULL;
|
||||
|
||||
if ((ptr = sofia_glue_find_parameter(contact_url, "transport="))) {
|
||||
sofia_transport_t transport = sofia_glue_str2transport(ptr);
|
||||
transport_str = sofia_glue_transport2str(transport);
|
||||
|
||||
switch (transport) {
|
||||
case SOFIA_TRANSPORT_TCP:
|
||||
contact_str = profile->tcp_public_contact;
|
||||
break;
|
||||
case SOFIA_TRANSPORT_TCP_TLS:
|
||||
contact_str = profile->tls_public_contact;
|
||||
break;
|
||||
default:
|
||||
contact_str = profile->public_url;
|
||||
break;
|
||||
}
|
||||
|
||||
user_via = sofia_glue_create_external_via(NULL, profile, transport);
|
||||
} else {
|
||||
user_via = sofia_glue_create_external_via(NULL, profile, SOFIA_TRANSPORT_UDP);
|
||||
contact_str = profile->public_url;
|
||||
}
|
||||
|
||||
} else {
|
||||
contact_str = profile->url;
|
||||
}
|
||||
|
||||
nh = nua_handle(profile->nua, NULL,
|
||||
NUTAG_URL(contact_url),
|
||||
SIPTAG_FROM_STR(id),
|
||||
SIPTAG_TO_STR(id),
|
||||
SIPTAG_CONTACT_STR(contact_str),
|
||||
TAG_END());
|
||||
|
||||
nua_handle_bind(nh, &mod_sofia_globals.destroy_private);
|
||||
nua_notify(nh,
|
||||
NUTAG_NEWSUB(1),
|
||||
TAG_IF(user_via, SIPTAG_VIA_STR(user_via)),
|
||||
SIPTAG_EVENT_STR(event),
|
||||
SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"),
|
||||
SIPTAG_PAYLOAD_STR(""),
|
||||
TAG_END());
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Sending reboot command to %s\n", contact_url);
|
||||
free(contact_url);
|
||||
}
|
||||
|
||||
switch_safe_free(user_via);
|
||||
switch_safe_free(id);
|
||||
}
|
||||
|
||||
int sofia_sla_dialog_del_callback(void *pArg, int argc, char **argv, char **columnNames)
|
||||
|
|
Loading…
Reference in New Issue