add send-presence-on-register (true|false|first-only) param to sofia and api command sofia global debug [presence|sla|none]
This commit is contained in:
parent
57b410eba6
commit
7b01cbbca4
|
@ -3695,11 +3695,39 @@ SWITCH_STANDARD_API(sofia_function)
|
||||||
int wdon = -1;
|
int wdon = -1;
|
||||||
|
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
|
if (!strcasecmp(argv[1], "debug")) {
|
||||||
|
|
||||||
|
if (argc > 2) {
|
||||||
|
if (strstr(argv[2], "presence")) {
|
||||||
|
mod_sofia_globals.debug_presence = 1;
|
||||||
|
stream->write_function(stream, "+OK Debugging presence\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strstr(argv[2], "sla")) {
|
||||||
|
mod_sofia_globals.debug_sla = 1;
|
||||||
|
stream->write_function(stream, "+OK Debugging sla\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strstr(argv[2], "none")) {
|
||||||
|
stream->write_function(stream, "+OK Debugging nothing\n");
|
||||||
|
mod_sofia_globals.debug_presence = 0;
|
||||||
|
mod_sofia_globals.debug_sla = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stream->write_function(stream, "+OK Debugging summary: presence: %s sla: %s\n",
|
||||||
|
mod_sofia_globals.debug_presence ? "on" : "off",
|
||||||
|
mod_sofia_globals.debug_sla ? "on" : "off");
|
||||||
|
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
if (!strcasecmp(argv[1], "siptrace")) {
|
if (!strcasecmp(argv[1], "siptrace")) {
|
||||||
if (argc > 2) {
|
if (argc > 2) {
|
||||||
ston = switch_true(argv[2]);
|
ston = switch_true(argv[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcasecmp(argv[1], "watchdog")) {
|
if (!strcasecmp(argv[1], "watchdog")) {
|
||||||
if (argc > 2) {
|
if (argc > 2) {
|
||||||
wdon = switch_true(argv[2]);
|
wdon = switch_true(argv[2]);
|
||||||
|
@ -3714,7 +3742,7 @@ SWITCH_STANDARD_API(sofia_function)
|
||||||
sofia_glue_global_watchdog(wdon);
|
sofia_glue_global_watchdog(wdon);
|
||||||
stream->write_function(stream, "+OK Global watchdog %s", wdon ? "on" : "off");
|
stream->write_function(stream, "+OK Global watchdog %s", wdon ? "on" : "off");
|
||||||
} else {
|
} else {
|
||||||
stream->write_function(stream, "-ERR Usage: siptrace <on|off>|watchdog <on|off>");
|
stream->write_function(stream, "-ERR Usage: siptrace <on|off>|watchdog <on|off>|debug <sla|presence|none");
|
||||||
}
|
}
|
||||||
|
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -4838,6 +4866,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load)
|
||||||
switch_console_set_complete("add sofia global siptrace ::[on:off");
|
switch_console_set_complete("add sofia global siptrace ::[on:off");
|
||||||
switch_console_set_complete("add sofia global watchdog ::[on:off");
|
switch_console_set_complete("add sofia global watchdog ::[on:off");
|
||||||
|
|
||||||
|
switch_console_set_complete("add sofia global debug ::[presence:sla:none");
|
||||||
|
|
||||||
|
|
||||||
switch_console_set_complete("add sofia profile");
|
switch_console_set_complete("add sofia profile");
|
||||||
switch_console_set_complete("add sofia profile restart all");
|
switch_console_set_complete("add sofia profile restart all");
|
||||||
|
|
||||||
|
|
|
@ -225,6 +225,8 @@ typedef enum {
|
||||||
PFLAG_DEL_SUBS_ON_REG,
|
PFLAG_DEL_SUBS_ON_REG,
|
||||||
PFLAG_IGNORE_183NOSDP,
|
PFLAG_IGNORE_183NOSDP,
|
||||||
PFLAG_PRESENCE_PROBE_ON_REGISTER,
|
PFLAG_PRESENCE_PROBE_ON_REGISTER,
|
||||||
|
PFLAG_PRESENCE_ON_REGISTER,
|
||||||
|
PFLAG_PRESENCE_ON_FIRST_REGISTER,
|
||||||
PFLAG_NO_CONNECTION_REUSE,
|
PFLAG_NO_CONNECTION_REUSE,
|
||||||
/* No new flags below this line */
|
/* No new flags below this line */
|
||||||
PFLAG_MAX
|
PFLAG_MAX
|
||||||
|
|
|
@ -2419,6 +2419,17 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile)
|
||||||
} else {
|
} else {
|
||||||
sofia_clear_pflag(profile, PFLAG_PRESENCE_PROBE_ON_REGISTER);
|
sofia_clear_pflag(profile, PFLAG_PRESENCE_PROBE_ON_REGISTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if (!strcasecmp(var, "send-presence-on-register")) {
|
||||||
|
if (switch_true(val)) {
|
||||||
|
sofia_set_pflag(profile, PFLAG_PRESENCE_ON_REGISTER);
|
||||||
|
} else if (!strcasecmp(val, "first-only")) {
|
||||||
|
sofia_clear_pflag(profile, PFLAG_PRESENCE_ON_REGISTER);
|
||||||
|
sofia_set_pflag(profile, PFLAG_PRESENCE_ON_FIRST_REGISTER);
|
||||||
|
} else {
|
||||||
|
sofia_clear_pflag(profile, PFLAG_PRESENCE_ON_REGISTER);
|
||||||
|
sofia_clear_pflag(profile, PFLAG_PRESENCE_ON_FIRST_REGISTER);
|
||||||
|
}
|
||||||
} else if (!strcasecmp(var, "cid-in-1xx")) {
|
} else if (!strcasecmp(var, "cid-in-1xx")) {
|
||||||
if (switch_true(val)) {
|
if (switch_true(val)) {
|
||||||
sofia_set_pflag(profile, PFLAG_CID_IN_1XX);
|
sofia_set_pflag(profile, PFLAG_CID_IN_1XX);
|
||||||
|
@ -3008,6 +3019,7 @@ switch_status_t config_sofia(int reload, char *profile_name)
|
||||||
sofia_set_pflag(profile, PFLAG_PASS_CALLEE_ID);
|
sofia_set_pflag(profile, PFLAG_PASS_CALLEE_ID);
|
||||||
sofia_set_pflag(profile, PFLAG_MESSAGE_QUERY_ON_FIRST_REGISTER);
|
sofia_set_pflag(profile, PFLAG_MESSAGE_QUERY_ON_FIRST_REGISTER);
|
||||||
sofia_set_pflag(profile, PFLAG_SQL_IN_TRANS);
|
sofia_set_pflag(profile, PFLAG_SQL_IN_TRANS);
|
||||||
|
sofia_set_pflag(profile, PFLAG_PRESENCE_ON_REGISTER);
|
||||||
profile->shutdown_type = "false";
|
profile->shutdown_type = "false";
|
||||||
profile->local_network = "localnet.auto";
|
profile->local_network = "localnet.auto";
|
||||||
sofia_set_flag(profile, TFLAG_ENABLE_SOA);
|
sofia_set_flag(profile, TFLAG_ENABLE_SOA);
|
||||||
|
@ -3090,6 +3102,16 @@ switch_status_t config_sofia(int reload, char *profile_name)
|
||||||
} else {
|
} else {
|
||||||
sofia_clear_pflag(profile, PFLAG_PRESENCE_PROBE_ON_REGISTER);
|
sofia_clear_pflag(profile, PFLAG_PRESENCE_PROBE_ON_REGISTER);
|
||||||
}
|
}
|
||||||
|
} else if (!strcasecmp(var, "send-presence-on-register")) {
|
||||||
|
if (switch_true(val)) {
|
||||||
|
sofia_set_pflag(profile, PFLAG_PRESENCE_ON_REGISTER);
|
||||||
|
} else if (!strcasecmp(val, "first-only")) {
|
||||||
|
sofia_clear_pflag(profile, PFLAG_PRESENCE_ON_REGISTER);
|
||||||
|
sofia_set_pflag(profile, PFLAG_PRESENCE_ON_FIRST_REGISTER);
|
||||||
|
} else {
|
||||||
|
sofia_clear_pflag(profile, PFLAG_PRESENCE_ON_REGISTER);
|
||||||
|
sofia_clear_pflag(profile, PFLAG_PRESENCE_ON_FIRST_REGISTER);
|
||||||
|
}
|
||||||
} else if (!strcasecmp(var, "cid-in-1xx")) {
|
} else if (!strcasecmp(var, "cid-in-1xx")) {
|
||||||
if (switch_true(val)) {
|
if (switch_true(val)) {
|
||||||
sofia_set_pflag(profile, PFLAG_CID_IN_1XX);
|
sofia_set_pflag(profile, PFLAG_CID_IN_1XX);
|
||||||
|
|
|
@ -875,9 +875,19 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
|
||||||
long reg_count = 0;
|
long reg_count = 0;
|
||||||
int delete_subs;
|
int delete_subs;
|
||||||
const char *agent = "unknown";
|
const char *agent = "unknown";
|
||||||
|
const char *pres_on_reg = NULL;
|
||||||
|
int send_pres = 0;
|
||||||
|
|
||||||
delete_subs = sofia_test_pflag(profile, PFLAG_DEL_SUBS_ON_REG);
|
delete_subs = sofia_test_pflag(profile, PFLAG_DEL_SUBS_ON_REG);
|
||||||
|
|
||||||
|
if (v_event && *v_event) pres_on_reg = switch_event_get_header(*v_event, "send-presence-on-register");
|
||||||
|
|
||||||
|
if (!(send_pres = switch_true(pres_on_reg))) {
|
||||||
|
if (pres_on_reg && !strcasecmp(pres_on_reg, "first-only")) {
|
||||||
|
send_pres = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* all callers must confirm that sip, sip->sip_request and sip->sip_contact are not NULL */
|
/* all callers must confirm that sip, sip->sip_request and sip->sip_contact are not NULL */
|
||||||
switch_assert(sip != NULL && sip->sip_contact != NULL && sip->sip_request != NULL);
|
switch_assert(sip != NULL && sip->sip_contact != NULL && sip->sip_request != NULL);
|
||||||
|
|
||||||
|
@ -1405,7 +1415,6 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (send && switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
if (send && switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO);
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO);
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", rpid);
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", rpid);
|
||||||
|
@ -1493,6 +1502,10 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sofia_test_pflag(profile, PFLAG_PRESENCE_ON_REGISTER) ||
|
||||||
|
(reg_count == 1 && sofia_test_pflag(profile, PFLAG_PRESENCE_ON_FIRST_REGISTER))
|
||||||
|
|| send_pres == 1 || (reg_count == 1 && send_pres == 2)) {
|
||||||
|
|
||||||
if (sofia_test_pflag(profile, PFLAG_PRESENCE_PROBE_ON_REGISTER)) {
|
if (sofia_test_pflag(profile, PFLAG_PRESENCE_PROBE_ON_REGISTER)) {
|
||||||
if (switch_event_create(&s_event, SWITCH_EVENT_PRESENCE_PROBE) == SWITCH_STATUS_SUCCESS) {
|
if (switch_event_create(&s_event, SWITCH_EVENT_PRESENCE_PROBE) == SWITCH_STATUS_SUCCESS) {
|
||||||
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO);
|
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO);
|
||||||
|
@ -1513,7 +1526,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
|
||||||
switch_event_fire(&s_event);
|
switch_event_fire(&s_event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (switch_event_create_subclass(&s_event, SWITCH_EVENT_CUSTOM, MY_EVENT_UNREGISTER) == SWITCH_STATUS_SUCCESS) {
|
if (switch_event_create_subclass(&s_event, SWITCH_EVENT_CUSTOM, MY_EVENT_UNREGISTER) == SWITCH_STATUS_SUCCESS) {
|
||||||
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "profile-name", profile->name);
|
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "profile-name", profile->name);
|
||||||
|
|
Loading…
Reference in New Issue