提交 863e6cfa authored 作者: Raymond Chandler's avatar Raymond Chandler

FS-2731 significantly reworked version of Emmanuel's patch to allow subscribing…

FS-2731 significantly reworked version of Emmanuel's patch to allow subscribing and notifying for the as-feature-event events.  we still need a module to handle the FS events for this automatically... coming soon to a repository near you
上级 a524fadf
......@@ -98,6 +98,8 @@ static const char *EVENT_NAMES[] = {
"MESSAGE",
"PRESENCE_IN",
"NOTIFY_IN",
"PHONE_FEATURE",
"PHONE_FEATURE_SUBSCRIBE",
"PRESENCE_OUT",
"PRESENCE_PROBE",
"MESSAGE_WAITING",
......
......@@ -1681,6 +1681,8 @@ typedef uint32_t switch_io_flag_t;
SWITCH_EVENT_RE_SCHEDULE - Something scheduled has been rescheduled
SWITCH_EVENT_RELOADXML - XML registry has been reloaded
SWITCH_EVENT_NOTIFY - Notification
SWITCH_EVENT_PHONE_FEATURE - Notification (DND/CFWD/etc)
SWITCH_EVENT_PHONE_FEATURE_SUBSCRIBE - Phone feature subscription
SWITCH_EVENT_SEND_MESSAGE - Message
SWITCH_EVENT_RECV_MESSAGE - Message
SWITCH_EVENT_NAT - NAT Management (new/del/status)
......@@ -1748,6 +1750,8 @@ typedef enum {
SWITCH_EVENT_RE_SCHEDULE,
SWITCH_EVENT_RELOADXML,
SWITCH_EVENT_NOTIFY,
SWITCH_EVENT_PHONE_FEATURE,
SWITCH_EVENT_PHONE_FEATURE_SUBSCRIBE,
SWITCH_EVENT_SEND_MESSAGE,
SWITCH_EVENT_RECV_MESSAGE,
SWITCH_EVENT_REQUEST_PARAMS,
......
/*
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
*
......@@ -22,14 +22,14 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Anthony Minessale II <anthm@freeswitch.org>
* Ken Rice <krice@freeswitch.org>
* Paul D. Tinsley <pdt at jackhammer.org>
* Bret McDanel <trixter AT 0xdecafbad.com>
* Marcel Barbulescu <marcelbarbulescu@gmail.com>
* Raymond Chandler <intralanman@gmail.com>
* Emmanuel Schmidbauer <e.schmidbauer@gmail.com>
* Emmanuel Schmidbauer <e.schmidbauer@gmail.com>
*
*
* mod_sofia.h -- SOFIA SIP Endpoint
......@@ -149,9 +149,9 @@ typedef enum {
typedef struct sofia_dispatch_event_s {
nua_saved_event_t event[1];
nua_handle_t *nh;
nua_event_data_t const *data;
su_time_t when;
nua_handle_t *nh;
nua_event_data_t const *data;
su_time_t when;
sip_t *sip;
nua_t *nua;
sofia_profile_t *profile;
......@@ -353,7 +353,7 @@ struct mod_sofia_globals {
int reg_deny_binding_fetch_and_no_lookup; /* backwards compatibility */
int auto_nat;
int tracelevel;
char *capture_server;
char *capture_server;
int rewrite_multicasted_fs_path;
int presence_flush;
switch_thread_t *presence_thread;
......@@ -511,10 +511,10 @@ typedef enum {
} sofia_media_options_t;
typedef enum {
PAID_DEFAULT = 0,
PAID_USER,
PAID_USER_DOMAIN,
PAID_VERBATIM
PAID_DEFAULT = 0,
PAID_USER,
PAID_USER_DOMAIN,
PAID_VERBATIM
} sofia_paid_type_t;
#define MAX_RTPIP 50
......@@ -619,7 +619,7 @@ struct sofia_profile {
char *pre_trans_execute;
char *post_trans_execute;
char *inner_pre_trans_execute;
char *inner_post_trans_execute;
char *inner_post_trans_execute;
switch_sql_queue_manager_t *qm;
char *acl[SOFIA_MAX_ACL];
char *acl_pass_context[SOFIA_MAX_ACL];
......@@ -678,7 +678,7 @@ struct sofia_profile {
sofia_paid_type_t paid_type;
uint32_t rtp_digit_delay;
switch_queue_t *event_queue;
switch_thread_t *thread;
switch_thread_t *thread;
switch_core_media_vflag_t vflags;
char *ws_ip;
switch_port_t ws_port;
......@@ -851,7 +851,7 @@ void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t
sofia_dispatch_event_t *de, tagi_t tags[]);
void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, sofia_dispatch_event_t *de, tagi_t tags[]);
void sofia_reg_handle_sip_i_register(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t **sofia_private, sip_t const *sip,
sofia_dispatch_event_t *de,
......@@ -868,9 +868,9 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
void launch_sofia_profile_thread(sofia_profile_t *profile);
switch_status_t sofia_presence_chat_send(switch_event_t *message_event);
/*
* \brief Sets the "ep_codec_string" channel variable, parsing r_sdp and taing codec_string in consideration
* \brief Sets the "ep_codec_string" channel variable, parsing r_sdp and taing codec_string in consideration
* \param channel Current channel
* \param codec_string The profile's codec string or NULL if inexistant
* \param sdp The parsed SDP content
......@@ -935,7 +935,7 @@ switch_call_cause_t sofia_glue_sip_cause_to_freeswitch(int status);
void sofia_glue_do_xfer_invite(switch_core_session_t *session);
uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip,
sofia_dispatch_event_t *de,
sofia_regtype_t regtype, char *key,
sofia_regtype_t regtype, char *key,
uint32_t keylen, switch_event_t **v_event, const char *is_nat, sofia_private_t **sofia_private_p, switch_xml_t *user_xml);
extern switch_endpoint_interface_t *sofia_endpoint_interface;
void sofia_presence_set_chat_hash(private_object_t *tech_pvt, sip_t const *sip);
......@@ -1044,7 +1044,7 @@ void sofia_glue_restart_all_profiles(void);
const char *sofia_state_string(int state);
void sofia_wait_for_reply(struct private_object *tech_pvt, nua_event_t event, uint32_t timeout);
/*
/*
* Logging control functions
*/
......@@ -1117,6 +1117,7 @@ switch_status_t sofia_glue_ext_address_lookup(sofia_profile_t *profile, char **i
void sofia_reg_check_socket(sofia_profile_t *profile, const char *call_id, const char *network_addr, const char *network_ip);
void sofia_reg_close_handles(sofia_profile_t *profile);
void write_csta_xml_chunk(switch_event_t *event, switch_stream_handle_t stream, const char *csta_event, char *fwd_type);
/* For Emacs:
* Local Variables:
* mode:c
......
......@@ -3658,6 +3658,39 @@ void sofia_presence_handle_sip_i_subscribe(int status,
switch_snprintf(exp_delta_str, sizeof(exp_delta_str), "%ld", exp_delta);
if (!strcmp("as-feature-event", event)) {
sip_authorization_t const *authorization = NULL;
auth_res_t auth_res = AUTH_FORBIDDEN;
char key[128] = "";
switch_event_t *v_event = NULL;
if (sip->sip_authorization) {
authorization = sip->sip_authorization;
} else if (sip->sip_proxy_authorization) {
authorization = sip->sip_proxy_authorization;
}
if (authorization) {
char network_ip[80];
sofia_glue_get_addr(de->data->e_msg, network_ip, sizeof(network_ip), NULL);
auth_res = sofia_reg_parse_auth(profile, authorization, sip, de,
(char *) sip->sip_request->rq_method_name, key, sizeof(key), network_ip, &v_event, 0,
REG_REGISTER, to_user, NULL, NULL, NULL);
} else if ( sofia_reg_handle_register(nua, profile, nh, sip, de, REG_REGISTER, key, sizeof(key), &v_event, NULL, NULL, NULL)) {
if (v_event) {
switch_event_destroy(&v_event);
}
goto end;
}
if ((auth_res != AUTH_OK && auth_res != AUTH_RENEWED)) {
nua_respond(nh, SIP_401_UNAUTHORIZED, NUTAG_WITH_THIS_MSG(de->data->e_msg), TAG_END());
goto end;
}
}
if (to_user && strchr(to_user, '+')) {
char *h;
if ((proto = (d_user = strdup(to_user)))) {
......@@ -3991,7 +4024,24 @@ void sofia_presence_handle_sip_i_subscribe(int status,
switch_safe_free(sstr);
if (!strcasecmp(event, "message-summary")) {
if (!strcasecmp(event, "as-feature-event")) {
switch_event_t *event;
char sip_cseq[40] = "";
switch_snprintf(sip_cseq, sizeof(sip_cseq), "%d", sip->sip_cseq->cs_seq);
switch_event_create(&event, SWITCH_EVENT_PHONE_FEATURE_SUBSCRIBE);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "user", from_user);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "host", from_host);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "contact", contact_str);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-id", call_id);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "expires", exp_delta_str);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "cseq", sip_cseq);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "profile_name", profile->name);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "hostname", mod_sofia_globals.hostname);
if (sip->sip_payload) {
switch_event_add_body(event, "%s", sip->sip_payload->pl_data);
}
switch_event_fire(&event);
} else if (!strcasecmp(event, "message-summary")) {
if ((sql = switch_mprintf("select proto,sip_user,'%q',sub_to_user,sub_to_host,event,contact,call_id,full_from,"
"full_via,expires,user_agent,accept,profile_name,network_ip"
" from sip_subscriptions where hostname='%q' and profile_name='%q' and "
......
......@@ -1240,10 +1240,12 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
to_host = to->a_url->url_host;
}
if (!to_user)
if (!to_user) {
to_user = from_user;
if (!to_host)
}
if (!to_host) {
to_host = from_host;
}
if (!to_user || !to_host) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can not do authorization without a complete header in REGISTER request from %s:%d\n",
......
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论