Skinny: Check for socket to see if listener is alive

also, use tab to indent
This commit is contained in:
Mathieu Parent 2010-04-01 19:50:55 +02:00
parent 542f643ef5
commit 54e73c774f
6 changed files with 2454 additions and 2453 deletions

View File

@ -132,7 +132,7 @@ switch_status_t skinny_profile_dump(const skinny_profile_t *profile, switch_stre
skinny_profile_t *skinny_find_profile(const char *profile_name) skinny_profile_t *skinny_find_profile(const char *profile_name)
{ {
skinny_profile_t *profile; skinny_profile_t *profile;
switch_mutex_lock(globals.mutex); switch_mutex_lock(globals.mutex);
profile = (skinny_profile_t *) switch_core_hash_find(globals.profile_hash, profile_name); profile = (skinny_profile_t *) switch_core_hash_find(globals.profile_hash, profile_name);
switch_mutex_unlock(globals.mutex); switch_mutex_unlock(globals.mutex);
@ -166,7 +166,7 @@ switch_status_t skinny_profile_find_listener_by_device_name_and_instance(skinny_
} }
struct skinny_profile_find_session_uuid_helper { struct skinny_profile_find_session_uuid_helper {
skinny_profile_t *profile; skinny_profile_t *profile;
char *channel_uuid; char *channel_uuid;
uint32_t line_instance; uint32_t line_instance;
}; };
@ -178,12 +178,12 @@ int skinny_profile_find_session_uuid_callback(void *pArg, int argc, char **argv,
char *channel_uuid = argv[0]; char *channel_uuid = argv[0];
uint32_t line_instance = atoi(argv[1]); uint32_t line_instance = atoi(argv[1]);
if(helper->channel_uuid == NULL) { if(helper->channel_uuid == NULL) {
helper->channel_uuid = switch_mprintf("%s", channel_uuid); helper->channel_uuid = switch_mprintf("%s", channel_uuid);
helper->line_instance = line_instance; helper->line_instance = line_instance;
} }
return 0; return 0;
} }
char * skinny_profile_find_session_uuid(skinny_profile_t *profile, listener_t *listener, uint32_t *line_instance_p, uint32_t call_id) char * skinny_profile_find_session_uuid(skinny_profile_t *profile, listener_t *listener, uint32_t *line_instance_p, uint32_t call_id)
@ -199,22 +199,22 @@ char * skinny_profile_find_session_uuid(skinny_profile_t *profile, listener_t *l
helper.channel_uuid = NULL; helper.channel_uuid = NULL;
if(listener) { if(listener) {
device_condition = switch_mprintf("device_name='%s' AND device_instance=%d", device_condition = switch_mprintf("device_name='%s' AND device_instance=%d",
listener->device_name, listener->device_instance); listener->device_name, listener->device_instance);
} else { } else {
device_condition = switch_mprintf("1=1"); device_condition = switch_mprintf("1=1");
} }
switch_assert(device_condition); switch_assert(device_condition);
if(*line_instance_p > 0) { if(*line_instance_p > 0) {
line_instance_condition = switch_mprintf("line_instance=%d", *line_instance_p); line_instance_condition = switch_mprintf("line_instance=%d", *line_instance_p);
} else { } else {
line_instance_condition = switch_mprintf("1=1"); line_instance_condition = switch_mprintf("1=1");
} }
switch_assert(line_instance_condition); switch_assert(line_instance_condition);
if(call_id > 0) { if(call_id > 0) {
call_id_condition = switch_mprintf("call_id=%d", call_id); call_id_condition = switch_mprintf("call_id=%d", call_id);
} else { } else {
call_id_condition = switch_mprintf("1=1"); call_id_condition = switch_mprintf("1=1");
} }
switch_assert(call_id_condition); switch_assert(call_id_condition);
if((sql = switch_mprintf( if((sql = switch_mprintf(
@ -225,7 +225,7 @@ char * skinny_profile_find_session_uuid(skinny_profile_t *profile, listener_t *l
device_condition, line_instance_condition, call_id_condition device_condition, line_instance_condition, call_id_condition
))) { ))) {
skinny_execute_sql_callback(profile, profile->sql_mutex, sql, skinny_execute_sql_callback(profile, profile->sql_mutex, sql,
skinny_profile_find_session_uuid_callback, &helper); skinny_profile_find_session_uuid_callback, &helper);
switch_safe_free(sql); switch_safe_free(sql);
} }
switch_safe_free(device_condition); switch_safe_free(device_condition);
@ -237,21 +237,21 @@ char * skinny_profile_find_session_uuid(skinny_profile_t *profile, listener_t *l
switch_core_session_t * skinny_profile_find_session(skinny_profile_t *profile, listener_t *listener, uint32_t *line_instance_p, uint32_t call_id) switch_core_session_t * skinny_profile_find_session(skinny_profile_t *profile, listener_t *listener, uint32_t *line_instance_p, uint32_t call_id)
{ {
char *uuid; char *uuid;
switch_core_session_t *result = NULL; switch_core_session_t *result = NULL;
uuid = skinny_profile_find_session_uuid(profile, listener, line_instance_p, call_id); uuid = skinny_profile_find_session_uuid(profile, listener, line_instance_p, call_id);
if(!zstr(uuid)) { if(!zstr(uuid)) {
/* TODO Why should we force? */ /* TODO Why should we force? */
result = switch_core_session_force_locate(uuid); result = switch_core_session_force_locate(uuid);
if(!result) { if(!result) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
"Unable to find session %s on %s:%d, line %d\n", "Unable to find session %s on %s:%d, line %d\n",
uuid, listener->device_name, listener->device_instance, *line_instance_p); uuid, listener->device_name, listener->device_instance, *line_instance_p);
} }
switch_safe_free(uuid); switch_safe_free(uuid);
} }
return result; return result;
} }
/*****************************************************************************/ /*****************************************************************************/
@ -337,7 +337,7 @@ switch_bool_t skinny_execute_sql_callback(skinny_profile_t *profile,
void skinny_line_perform_set_state(const char *file, const char *func, int line, listener_t *listener, uint32_t line_instance, uint32_t call_id, uint32_t call_state) void skinny_line_perform_set_state(const char *file, const char *func, int line, listener_t *listener, uint32_t line_instance, uint32_t call_id, uint32_t call_state)
{ {
switch_event_t *event = NULL; switch_event_t *event = NULL;
switch_assert(listener); switch_assert(listener);
skinny_device_event(listener, &event, SWITCH_EVENT_CUSTOM, SKINNY_EVENT_CALL_STATE); skinny_device_event(listener, &event, SWITCH_EVENT_CUSTOM, SKINNY_EVENT_CALL_STATE);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Skinny-Line-Instance", "%d", line_instance); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Skinny-Line-Instance", "%d", line_instance);
@ -359,30 +359,30 @@ int skinny_line_get_state_callback(void *pArg, int argc, char **argv, char **col
{ {
struct skinny_line_get_state_helper *helper = pArg; struct skinny_line_get_state_helper *helper = pArg;
helper->call_state = atoi(argv[0]); helper->call_state = atoi(argv[0]);
return 0; return 0;
} }
uint32_t skinny_line_get_state(listener_t *listener, uint32_t line_instance, uint32_t call_id) uint32_t skinny_line_get_state(listener_t *listener, uint32_t line_instance, uint32_t call_id)
{ {
char *line_instance_condition; char *line_instance_condition;
char *call_id_condition; char *call_id_condition;
char *sql; char *sql;
struct skinny_line_get_state_helper helper = {0}; struct skinny_line_get_state_helper helper = {0};
switch_assert(listener); switch_assert(listener);
if(line_instance > 0) { if(line_instance > 0) {
line_instance_condition = switch_mprintf("line_instance=%d", line_instance); line_instance_condition = switch_mprintf("line_instance=%d", line_instance);
} else { } else {
line_instance_condition = switch_mprintf("1=1"); line_instance_condition = switch_mprintf("1=1");
} }
switch_assert(line_instance_condition); switch_assert(line_instance_condition);
if(call_id > 0) { if(call_id > 0) {
call_id_condition = switch_mprintf("call_id=%d", call_id); call_id_condition = switch_mprintf("call_id=%d", call_id);
} else { } else {
call_id_condition = switch_mprintf("1=1"); call_id_condition = switch_mprintf("1=1");
} }
switch_assert(call_id_condition); switch_assert(call_id_condition);
if ((sql = switch_mprintf( if ((sql = switch_mprintf(
"SELECT call_state FROM skinny_active_lines " "SELECT call_state FROM skinny_active_lines "
@ -562,7 +562,7 @@ switch_status_t channel_on_init(switch_core_session_t *session)
switch_status_t channel_on_routing(switch_core_session_t *session) switch_status_t channel_on_routing(switch_core_session_t *session)
{ {
switch_channel_t *channel = switch_core_session_get_channel(session); switch_channel_t *channel = switch_core_session_get_channel(session);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s CHANNEL ROUTING\n", switch_channel_get_name(channel)); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s CHANNEL ROUTING\n", switch_channel_get_name(channel));
@ -571,7 +571,7 @@ switch_status_t channel_on_routing(switch_core_session_t *session)
switch_status_t channel_on_execute(switch_core_session_t *session) switch_status_t channel_on_execute(switch_core_session_t *session)
{ {
switch_channel_t *channel = switch_core_session_get_channel(session); switch_channel_t *channel = switch_core_session_get_channel(session);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s CHANNEL EXECUTE\n", switch_channel_get_name(channel)); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s CHANNEL EXECUTE\n", switch_channel_get_name(channel));
@ -627,33 +627,33 @@ int channel_on_hangup_callback(void *pArg, int argc, char **argv, char **columnN
uint32_t call_state = atoi(argv[16]); uint32_t call_state = atoi(argv[16]);
skinny_profile_find_listener_by_device_name_and_instance(helper->tech_pvt->profile, device_name, device_instance, &listener); skinny_profile_find_listener_by_device_name_and_instance(helper->tech_pvt->profile, device_name, device_instance, &listener);
if(listener) { if(listener) {
if(call_state == SKINNY_CONNECTED) { if(call_state == SKINNY_CONNECTED) {
stop_tone(listener, line_instance, call_id); stop_tone(listener, line_instance, call_id);
} }
set_lamp(listener, SKINNY_BUTTON_LINE, line_instance, SKINNY_LAMP_OFF); set_lamp(listener, SKINNY_BUTTON_LINE, line_instance, SKINNY_LAMP_OFF);
clear_prompt_status(listener, line_instance, call_id); clear_prompt_status(listener, line_instance, call_id);
if(call_state == SKINNY_CONNECTED) { /* calling parties */ if(call_state == SKINNY_CONNECTED) { /* calling parties */
close_receive_channel(listener, close_receive_channel(listener,
call_id, /* uint32_t conference_id, */ call_id, /* uint32_t conference_id, */
helper->tech_pvt->party_id, /* uint32_t pass_thru_party_id, */ helper->tech_pvt->party_id, /* uint32_t pass_thru_party_id, */
call_id /* uint32_t conference_id2, */ call_id /* uint32_t conference_id2, */
); );
stop_media_transmission(listener, stop_media_transmission(listener,
call_id, /* uint32_t conference_id, */ call_id, /* uint32_t conference_id, */
helper->tech_pvt->party_id, /* uint32_t pass_thru_party_id, */ helper->tech_pvt->party_id, /* uint32_t pass_thru_party_id, */
call_id /* uint32_t conference_id2, */ call_id /* uint32_t conference_id2, */
); );
} }
skinny_line_set_state(listener, line_instance, call_id, SKINNY_ON_HOOK); skinny_line_set_state(listener, line_instance, call_id, SKINNY_ON_HOOK);
send_select_soft_keys(listener, line_instance, call_id, SKINNY_KEY_SET_ON_HOOK, 0xffff); send_select_soft_keys(listener, line_instance, call_id, SKINNY_KEY_SET_ON_HOOK, 0xffff);
/* TODO: DefineTimeDate */ /* TODO: DefineTimeDate */
set_speaker_mode(listener, SKINNY_SPEAKER_OFF); set_speaker_mode(listener, SKINNY_SPEAKER_OFF);
set_ringer(listener, SKINNY_RING_OFF, SKINNY_RING_FOREVER, 0, call_id); set_ringer(listener, SKINNY_RING_OFF, SKINNY_RING_FOREVER, 0, call_id);
} }
return 0; return 0;
} }
switch_status_t channel_on_hangup(switch_core_session_t *session) switch_status_t channel_on_hangup(switch_core_session_t *session)
@ -668,9 +668,9 @@ switch_status_t channel_on_hangup(switch_core_session_t *session)
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s CHANNEL HANGUP\n", switch_channel_get_name(channel)); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s CHANNEL HANGUP\n", switch_channel_get_name(channel));
helper.tech_pvt= tech_pvt; helper.tech_pvt= tech_pvt;
skinny_session_walk_lines(tech_pvt->profile, switch_core_session_get_uuid(session), channel_on_hangup_callback, &helper); skinny_session_walk_lines(tech_pvt->profile, switch_core_session_get_uuid(session), channel_on_hangup_callback, &helper);
if ((sql = switch_mprintf( if ((sql = switch_mprintf(
"DELETE FROM skinny_active_lines WHERE channel_uuid='%s'", "DELETE FROM skinny_active_lines WHERE channel_uuid='%s'",
switch_core_session_get_uuid(session) switch_core_session_get_uuid(session)
@ -728,7 +728,7 @@ switch_status_t channel_send_dtmf(switch_core_session_t *session, const switch_d
switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id) switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id)
{ {
switch_channel_t *channel = switch_core_session_get_channel(session); switch_channel_t *channel = switch_core_session_get_channel(session);
private_t *tech_pvt = switch_core_session_get_private(session); private_t *tech_pvt = switch_core_session_get_private(session);
int payload = 0; int payload = 0;
@ -1001,10 +1001,11 @@ switch_io_routines_t skinny_io_routines = {
uint8_t listener_is_ready(listener_t *listener) uint8_t listener_is_ready(listener_t *listener)
{ {
return globals.running return globals.running
&& listener && listener
&& switch_test_flag(listener, LFLAG_RUNNING) && listener->sock
&& listener->profile->listener_ready; && switch_test_flag(listener, LFLAG_RUNNING)
&& listener->profile->listener_ready;
} }
static void add_listener(listener_t *listener) static void add_listener(listener_t *listener)
@ -1260,7 +1261,7 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Connection Closed\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Connection Closed\n");
} }
/* TODO /* TODO
for(int line = 0 ; line < SKINNY_MAX_BUTTON_COUNT ; line++) { for(int line = 0 ; line < SKINNY_MAX_BUTTON_COUNT ; line++) {
if(listener->session[line]) { if(listener->session[line]) {
switch_channel_clear_flag(switch_core_session_get_channel(listener->session[line]), CF_CONTROLLED); switch_channel_clear_flag(switch_core_session_get_channel(listener->session[line]), CF_CONTROLLED);
@ -1461,22 +1462,22 @@ static switch_status_t load_skinny_config(void)
continue; continue;
} }
if (xsettings) { if (xsettings) {
switch_memory_pool_t *profile_pool = NULL; switch_memory_pool_t *profile_pool = NULL;
char dbname[256]; char dbname[256];
switch_core_db_t *db; switch_core_db_t *db;
skinny_profile_t *profile = NULL; skinny_profile_t *profile = NULL;
switch_xml_t param; switch_xml_t param;
if (switch_core_new_memory_pool(&profile_pool) != SWITCH_STATUS_SUCCESS) { if (switch_core_new_memory_pool(&profile_pool) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "OH OH no pool\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "OH OH no pool\n");
return SWITCH_STATUS_TERM; return SWITCH_STATUS_TERM;
} }
profile = switch_core_alloc(profile_pool, sizeof(skinny_profile_t)); profile = switch_core_alloc(profile_pool, sizeof(skinny_profile_t));
profile->pool = profile_pool; profile->pool = profile_pool;
profile->name = profile_name; profile->name = profile_name;
switch_mutex_init(&profile->listener_mutex, SWITCH_MUTEX_NESTED, profile->pool); switch_mutex_init(&profile->listener_mutex, SWITCH_MUTEX_NESTED, profile->pool);
switch_mutex_init(&profile->sql_mutex, SWITCH_MUTEX_NESTED, profile->pool); switch_mutex_init(&profile->sql_mutex, SWITCH_MUTEX_NESTED, profile->pool);
switch_mutex_init(&profile->sock_mutex, SWITCH_MUTEX_NESTED, profile->pool); switch_mutex_init(&profile->sock_mutex, SWITCH_MUTEX_NESTED, profile->pool);
for (param = switch_xml_child(xsettings, "param"); param; param = param->next) { for (param = switch_xml_child(xsettings, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr_soft(param, "name"); char *var = (char *) switch_xml_attr_soft(param, "name");
@ -1552,9 +1553,9 @@ static switch_status_t load_skinny_config(void)
skinny_execute_sql_callback(profile, profile->sql_mutex, "DELETE FROM skinny_buttons", NULL, NULL); skinny_execute_sql_callback(profile, profile->sql_mutex, "DELETE FROM skinny_buttons", NULL, NULL);
skinny_execute_sql_callback(profile, profile->sql_mutex, "DELETE FROM skinny_active_lines", NULL, NULL); skinny_execute_sql_callback(profile, profile->sql_mutex, "DELETE FROM skinny_active_lines", NULL, NULL);
switch_mutex_lock(globals.mutex); switch_mutex_lock(globals.mutex);
switch_core_hash_insert(globals.profile_hash, profile->name, profile); switch_core_hash_insert(globals.profile_hash, profile->name, profile);
switch_mutex_unlock(globals.mutex); switch_mutex_unlock(globals.mutex);
profile = NULL; profile = NULL;
} else { } else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
@ -1575,50 +1576,50 @@ static void event_handler(switch_event_t *event)
if (event->event_id == SWITCH_EVENT_HEARTBEAT) { if (event->event_id == SWITCH_EVENT_HEARTBEAT) {
walk_listeners(kill_expired_listener, NULL); walk_listeners(kill_expired_listener, NULL);
} else if ((subclass = switch_event_get_header_nil(event, "Event-Subclass")) && !strcasecmp(subclass, SKINNY_EVENT_CALL_STATE)) { } else if ((subclass = switch_event_get_header_nil(event, "Event-Subclass")) && !strcasecmp(subclass, SKINNY_EVENT_CALL_STATE)) {
char *profile_name = switch_event_get_header_nil(event, "Skinny-Profile-Name"); char *profile_name = switch_event_get_header_nil(event, "Skinny-Profile-Name");
char *device_name = switch_event_get_header_nil(event, "Skinny-Device-Name"); char *device_name = switch_event_get_header_nil(event, "Skinny-Device-Name");
uint32_t device_instance = atoi(switch_event_get_header_nil(event, "Skinny-Device-Instance")); uint32_t device_instance = atoi(switch_event_get_header_nil(event, "Skinny-Device-Instance"));
uint32_t line_instance = atoi(switch_event_get_header_nil(event, "Skinny-Line-Instance")); uint32_t line_instance = atoi(switch_event_get_header_nil(event, "Skinny-Line-Instance"));
uint32_t call_id = atoi(switch_event_get_header_nil(event, "Skinny-Call-Id")); uint32_t call_id = atoi(switch_event_get_header_nil(event, "Skinny-Call-Id"));
uint32_t call_state = atoi(switch_event_get_header_nil(event, "Skinny-Call-State")); uint32_t call_state = atoi(switch_event_get_header_nil(event, "Skinny-Call-State"));
skinny_profile_t *profile; skinny_profile_t *profile;
listener_t *listener = NULL; listener_t *listener = NULL;
char *line_instance_condition, *call_id_condition; char *line_instance_condition, *call_id_condition;
char *sql; char *sql;
if ((profile = skinny_find_profile(profile_name))) { if ((profile = skinny_find_profile(profile_name))) {
skinny_profile_find_listener_by_device_name_and_instance(profile, device_name, device_instance, &listener); skinny_profile_find_listener_by_device_name_and_instance(profile, device_name, device_instance, &listener);
if(listener) { if(listener) {
if(line_instance > 0) { if(line_instance > 0) {
line_instance_condition = switch_mprintf("line_instance=%d", line_instance); line_instance_condition = switch_mprintf("line_instance=%d", line_instance);
} else { } else {
line_instance_condition = switch_mprintf("1=1"); line_instance_condition = switch_mprintf("1=1");
} }
switch_assert(line_instance_condition); switch_assert(line_instance_condition);
if(call_id > 0) { if(call_id > 0) {
call_id_condition = switch_mprintf("call_id=%d", call_id); call_id_condition = switch_mprintf("call_id=%d", call_id);
} else { } else {
call_id_condition = switch_mprintf("1=1"); call_id_condition = switch_mprintf("1=1");
} }
switch_assert(call_id_condition); switch_assert(call_id_condition);
if ((sql = switch_mprintf( if ((sql = switch_mprintf(
"UPDATE skinny_active_lines " "UPDATE skinny_active_lines "
"SET call_state=%d " "SET call_state=%d "
"WHERE device_name='%s' AND device_instance=%d " "WHERE device_name='%s' AND device_instance=%d "
"AND %s AND %s", "AND %s AND %s",
call_state, call_state,
listener->device_name, listener->device_instance, listener->device_name, listener->device_instance,
line_instance_condition, call_id_condition line_instance_condition, call_id_condition
))) { ))) {
skinny_execute_sql(listener->profile, sql, listener->profile->sql_mutex); skinny_execute_sql(listener->profile, sql, listener->profile->sql_mutex);
switch_safe_free(sql); switch_safe_free(sql);
send_call_state(listener, call_state, line_instance, call_id); send_call_state(listener, call_state, line_instance, call_id);
} }
switch_safe_free(line_instance_condition); switch_safe_free(line_instance_condition);
switch_safe_free(call_id_condition); switch_safe_free(call_id_condition);
} }
} }
} }
} }
@ -1627,20 +1628,20 @@ static void event_handler(switch_event_t *event)
SWITCH_MODULE_LOAD_FUNCTION(mod_skinny_load) SWITCH_MODULE_LOAD_FUNCTION(mod_skinny_load)
{ {
switch_hash_index_t *hi; switch_hash_index_t *hi;
/* globals init */ /* globals init */
memset(&globals, 0, sizeof(globals)); memset(&globals, 0, sizeof(globals));
if (switch_core_new_memory_pool(&globals.pool) != SWITCH_STATUS_SUCCESS) { if (switch_core_new_memory_pool(&globals.pool) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "OH OH no pool\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "OH OH no pool\n");
return SWITCH_STATUS_TERM; return SWITCH_STATUS_TERM;
} }
switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, globals.pool); switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, globals.pool);
switch_core_hash_init(&globals.profile_hash, globals.pool); switch_core_hash_init(&globals.profile_hash, globals.pool);
globals.running = 1; globals.running = 1;
load_skinny_config(); load_skinny_config();
/* bind to events */ /* bind to events */
if ((switch_event_bind_removable(modname, SWITCH_EVENT_HEARTBEAT, NULL, event_handler, NULL, &globals.heartbeat_node) != SWITCH_STATUS_SUCCESS)) { if ((switch_event_bind_removable(modname, SWITCH_EVENT_HEARTBEAT, NULL, event_handler, NULL, &globals.heartbeat_node) != SWITCH_STATUS_SUCCESS)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind our heartbeat handler!\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind our heartbeat handler!\n");
/* Not such severe to prevent loading */ /* Not such severe to prevent loading */
@ -1650,7 +1651,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_skinny_load)
return SWITCH_STATUS_TERM; return SWITCH_STATUS_TERM;
} }
/* reserve events */ /* reserve events */
if (switch_event_reserve_subclass(SKINNY_EVENT_REGISTER) != SWITCH_STATUS_SUCCESS) { if (switch_event_reserve_subclass(SKINNY_EVENT_REGISTER) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", SKINNY_EVENT_REGISTER); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", SKINNY_EVENT_REGISTER);
return SWITCH_STATUS_TERM; return SWITCH_STATUS_TERM;
@ -1679,23 +1680,23 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_skinny_load)
skinny_endpoint_interface->io_routines = &skinny_io_routines; skinny_endpoint_interface->io_routines = &skinny_io_routines;
skinny_endpoint_interface->state_handler = &skinny_state_handlers; skinny_endpoint_interface->state_handler = &skinny_state_handlers;
skinny_api_register(module_interface); skinny_api_register(module_interface);
/* launch listeners */ /* launch listeners */
switch_mutex_lock(globals.mutex); switch_mutex_lock(globals.mutex);
for (hi = switch_hash_first(NULL, globals.profile_hash); hi; hi = switch_hash_next(hi)) { for (hi = switch_hash_first(NULL, globals.profile_hash); hi; hi = switch_hash_next(hi)) {
void *val; void *val;
skinny_profile_t *profile; skinny_profile_t *profile;
switch_thread_t *thread; switch_thread_t *thread;
switch_threadattr_t *thd_attr = NULL; switch_threadattr_t *thd_attr = NULL;
switch_hash_this(hi, NULL, NULL, &val); switch_hash_this(hi, NULL, NULL, &val);
profile = (skinny_profile_t *) val; profile = (skinny_profile_t *) val;
switch_threadattr_create(&thd_attr, profile->pool); switch_threadattr_create(&thd_attr, profile->pool);
switch_threadattr_detach_set(thd_attr, 1); switch_threadattr_detach_set(thd_attr, 1);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
switch_thread_create(&thread, thd_attr, skinny_profile_run, profile, profile->pool); switch_thread_create(&thread, thd_attr, skinny_profile_run, profile, profile->pool);
} }
switch_mutex_unlock(globals.mutex); switch_mutex_unlock(globals.mutex);
@ -1711,7 +1712,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skinny_shutdown)
switch_mutex_t *mutex = globals.mutex; switch_mutex_t *mutex = globals.mutex;
int sanity = 0; int sanity = 0;
/* release events */ /* release events */
switch_event_unbind(&globals.heartbeat_node); switch_event_unbind(&globals.heartbeat_node);
switch_event_unbind(&globals.call_state_node); switch_event_unbind(&globals.call_state_node);
switch_event_free_subclass(SKINNY_EVENT_REGISTER); switch_event_free_subclass(SKINNY_EVENT_REGISTER);
@ -1730,7 +1731,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skinny_shutdown)
/* close sockets */ /* close sockets */
switch_mutex_lock(globals.mutex); switch_mutex_lock(globals.mutex);
for (hi = switch_hash_first(NULL, globals.profile_hash); hi; hi = switch_hash_next(hi)) { for (hi = switch_hash_first(NULL, globals.profile_hash); hi; hi = switch_hash_next(hi)) {
skinny_profile_t *profile; skinny_profile_t *profile;
switch_hash_this(hi, NULL, NULL, &val); switch_hash_this(hi, NULL, NULL, &val);
profile = (skinny_profile_t *) val; profile = (skinny_profile_t *) val;
@ -1743,7 +1744,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skinny_shutdown)
break; break;
} }
} }
switch_core_destroy_memory_pool(&profile->pool); switch_core_destroy_memory_pool(&profile->pool);
} }
switch_mutex_unlock(globals.mutex); switch_mutex_unlock(globals.mutex);

View File

@ -45,51 +45,51 @@
#define SKINNY_EVENT_CALL_STATE "skinny::call_state" #define SKINNY_EVENT_CALL_STATE "skinny::call_state"
struct skinny_globals { struct skinny_globals {
int running; int running;
switch_memory_pool_t *pool; switch_memory_pool_t *pool;
switch_mutex_t *mutex; switch_mutex_t *mutex;
switch_hash_t *profile_hash; switch_hash_t *profile_hash;
switch_event_node_t *heartbeat_node; switch_event_node_t *heartbeat_node;
switch_event_node_t *call_state_node; switch_event_node_t *call_state_node;
}; };
typedef struct skinny_globals skinny_globals_t; typedef struct skinny_globals skinny_globals_t;
skinny_globals_t globals; skinny_globals_t globals;
struct skinny_profile { struct skinny_profile {
/* prefs */ /* prefs */
char *name; char *name;
char *domain; char *domain;
char *ip; char *ip;
unsigned int port; unsigned int port;
char *dialplan; char *dialplan;
char *context; char *context;
uint32_t keep_alive; uint32_t keep_alive;
char date_format[6]; char date_format[6];
int debug; int debug;
/* db */ /* db */
char *dbname; char *dbname;
char *odbc_dsn; char *odbc_dsn;
char *odbc_user; char *odbc_user;
char *odbc_pass; char *odbc_pass;
switch_odbc_handle_t *master_odbc; switch_odbc_handle_t *master_odbc;
switch_mutex_t *sql_mutex; switch_mutex_t *sql_mutex;
/* stats */ /* stats */
uint32_t ib_calls; uint32_t ib_calls;
uint32_t ob_calls; uint32_t ob_calls;
uint32_t ib_failed_calls; uint32_t ib_failed_calls;
uint32_t ob_failed_calls; uint32_t ob_failed_calls;
/* listener */ /* listener */
int listener_threads; int listener_threads;
switch_mutex_t *listener_mutex; switch_mutex_t *listener_mutex;
switch_socket_t *sock; switch_socket_t *sock;
switch_mutex_t *sock_mutex; switch_mutex_t *sock_mutex;
struct listener *listeners; struct listener *listeners;
uint8_t listener_ready; uint8_t listener_ready;
/* call id */ /* call id */
uint32_t next_call_id; uint32_t next_call_id;
/* others */ /* others */
switch_memory_pool_t *pool; switch_memory_pool_t *pool;
}; };
typedef struct skinny_profile skinny_profile_t; typedef struct skinny_profile skinny_profile_t;
@ -99,26 +99,26 @@ typedef struct skinny_profile skinny_profile_t;
/*****************************************************************************/ /*****************************************************************************/
typedef enum { typedef enum {
LFLAG_RUNNING = (1 << 0), LFLAG_RUNNING = (1 << 0),
} event_flag_t; } event_flag_t;
#define SKINNY_MAX_LINES 42 #define SKINNY_MAX_LINES 42
struct listener { struct listener {
skinny_profile_t *profile; skinny_profile_t *profile;
char device_name[16]; char device_name[16];
uint32_t device_instance; uint32_t device_instance;
switch_socket_t *sock; switch_socket_t *sock;
switch_memory_pool_t *pool; switch_memory_pool_t *pool;
switch_thread_rwlock_t *rwlock; switch_thread_rwlock_t *rwlock;
switch_sockaddr_t *sa; switch_sockaddr_t *sa;
char remote_ip[50]; char remote_ip[50];
switch_mutex_t *flag_mutex; switch_mutex_t *flag_mutex;
uint32_t flags; uint32_t flags;
switch_port_t remote_port; switch_port_t remote_port;
uint32_t id; uint32_t id;
time_t expire_time; time_t expire_time;
struct listener *next; struct listener *next;
}; };
typedef struct listener listener_t; typedef struct listener listener_t;
@ -129,54 +129,54 @@ typedef switch_status_t (*skinny_listener_callback_func_t) (listener_t *listener
/* CHANNEL TYPES */ /* CHANNEL TYPES */
/*****************************************************************************/ /*****************************************************************************/
typedef enum { typedef enum {
TFLAG_IO = (1 << 0), TFLAG_IO = (1 << 0),
TFLAG_INBOUND = (1 << 1), TFLAG_INBOUND = (1 << 1),
TFLAG_OUTBOUND = (1 << 2), TFLAG_OUTBOUND = (1 << 2),
TFLAG_DTMF = (1 << 3), TFLAG_DTMF = (1 << 3),
TFLAG_VOICE = (1 << 4), TFLAG_VOICE = (1 << 4),
TFLAG_HANGUP = (1 << 5), TFLAG_HANGUP = (1 << 5),
TFLAG_LINEAR = (1 << 6), TFLAG_LINEAR = (1 << 6),
TFLAG_CODEC = (1 << 7), TFLAG_CODEC = (1 << 7),
TFLAG_READING = (1 << 9), TFLAG_READING = (1 << 9),
TFLAG_WRITING = (1 << 10) TFLAG_WRITING = (1 << 10)
} TFLAGS; } TFLAGS;
typedef enum { typedef enum {
GFLAG_MY_CODEC_PREFS = (1 << 0) GFLAG_MY_CODEC_PREFS = (1 << 0)
} GFLAGS; } GFLAGS;
struct private_object { struct private_object {
unsigned int flags; unsigned int flags;
switch_frame_t read_frame; switch_frame_t read_frame;
unsigned char databuf[SWITCH_RECOMMENDED_BUFFER_SIZE]; unsigned char databuf[SWITCH_RECOMMENDED_BUFFER_SIZE];
switch_core_session_t *session; switch_core_session_t *session;
switch_caller_profile_t *caller_profile; switch_caller_profile_t *caller_profile;
switch_mutex_t *mutex; switch_mutex_t *mutex;
switch_mutex_t *flag_mutex; switch_mutex_t *flag_mutex;
/* identification */ /* identification */
uint32_t call_id; uint32_t call_id;
uint32_t party_id; uint32_t party_id;
skinny_profile_t *profile; skinny_profile_t *profile;
/* codec */ /* codec */
char *iananame; char *iananame;
switch_codec_t read_codec; switch_codec_t read_codec;
switch_codec_t write_codec; switch_codec_t write_codec;
switch_codec_implementation_t read_impl; switch_codec_implementation_t read_impl;
switch_codec_implementation_t write_impl; switch_codec_implementation_t write_impl;
unsigned long rm_rate; unsigned long rm_rate;
uint32_t codec_ms; uint32_t codec_ms;
char *rm_encoding; char *rm_encoding;
char *rm_fmtp; char *rm_fmtp;
switch_payload_t agreed_pt; switch_payload_t agreed_pt;
/* RTP */ /* RTP */
switch_rtp_t *rtp_session; switch_rtp_t *rtp_session;
char *local_sdp_audio_ip; char *local_sdp_audio_ip;
switch_port_t local_sdp_audio_port; switch_port_t local_sdp_audio_port;
char *remote_sdp_audio_ip; char *remote_sdp_audio_ip;
switch_port_t remote_sdp_audio_port; switch_port_t remote_sdp_audio_port;
}; };
typedef struct private_object private_t; typedef struct private_object private_t;
@ -197,7 +197,7 @@ switch_status_t dump_device(skinny_profile_t *profile, const char *device_name,
/*****************************************************************************/ /*****************************************************************************/
void skinny_execute_sql(skinny_profile_t *profile, char *sql, switch_mutex_t *mutex); void skinny_execute_sql(skinny_profile_t *profile, char *sql, switch_mutex_t *mutex);
switch_bool_t skinny_execute_sql_callback(skinny_profile_t *profile, switch_bool_t skinny_execute_sql_callback(skinny_profile_t *profile,
switch_mutex_t *mutex, char *sql, switch_core_db_callback_func_t callback, void *pdata); switch_mutex_t *mutex, char *sql, switch_core_db_callback_func_t callback, void *pdata);
/*****************************************************************************/ /*****************************************************************************/
/* LISTENER FUNCTIONS */ /* LISTENER FUNCTIONS */
@ -222,8 +222,8 @@ switch_status_t channel_on_routing(switch_core_session_t *session);
switch_status_t channel_on_exchange_media(switch_core_session_t *session); switch_status_t channel_on_exchange_media(switch_core_session_t *session);
switch_status_t channel_on_soft_execute(switch_core_session_t *session); switch_status_t channel_on_soft_execute(switch_core_session_t *session);
switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event, switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event,
switch_caller_profile_t *outbound_profile, switch_caller_profile_t *outbound_profile,
switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause); switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause);
switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id); switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id);
switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id); switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id);
switch_status_t channel_kill_channel(switch_core_session_t *session, int sig); switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);

File diff suppressed because it is too large Load Diff

View File

@ -49,60 +49,60 @@
/* RegisterMessage */ /* RegisterMessage */
#define REGISTER_MESSAGE 0x0001 #define REGISTER_MESSAGE 0x0001
struct register_message { struct register_message {
char device_name[16]; char device_name[16];
uint32_t user_id; uint32_t user_id;
uint32_t instance; uint32_t instance;
struct in_addr ip; struct in_addr ip;
uint32_t device_type; uint32_t device_type;
uint32_t max_streams; uint32_t max_streams;
}; };
/* PortMessage */ /* PortMessage */
#define PORT_MESSAGE 0x0002 #define PORT_MESSAGE 0x0002
struct port_message { struct port_message {
uint16_t port; uint16_t port;
}; };
/* KeypadButtonMessage */ /* KeypadButtonMessage */
#define KEYPAD_BUTTON_MESSAGE 0x0003 #define KEYPAD_BUTTON_MESSAGE 0x0003
struct keypad_button_message { struct keypad_button_message {
uint32_t button; uint32_t button;
uint32_t line_instance; uint32_t line_instance;
uint32_t call_id; uint32_t call_id;
}; };
/* StimulusMessage */ /* StimulusMessage */
#define STIMULUS_MESSAGE 0x0005 #define STIMULUS_MESSAGE 0x0005
struct stimulus_message { struct stimulus_message {
uint32_t instance_type; /* See enum skinny_button_definition */ uint32_t instance_type; /* See enum skinny_button_definition */
uint32_t instance; uint32_t instance;
uint32_t call_id; uint32_t call_id;
}; };
/* OffHookMessage */ /* OffHookMessage */
#define OFF_HOOK_MESSAGE 0x0006 #define OFF_HOOK_MESSAGE 0x0006
struct off_hook_message { struct off_hook_message {
uint32_t line_instance; uint32_t line_instance;
uint32_t call_id; uint32_t call_id;
}; };
/* OnHookMessage */ /* OnHookMessage */
#define ON_HOOK_MESSAGE 0x0007 #define ON_HOOK_MESSAGE 0x0007
struct on_hook_message { struct on_hook_message {
uint32_t line_instance; uint32_t line_instance;
uint32_t call_id; uint32_t call_id;
}; };
/* SpeedDialStatReqMessage */ /* SpeedDialStatReqMessage */
#define SPEED_DIAL_STAT_REQ_MESSAGE 0x000A #define SPEED_DIAL_STAT_REQ_MESSAGE 0x000A
struct speed_dial_stat_req_message { struct speed_dial_stat_req_message {
uint32_t number; uint32_t number;
}; };
/* LineStatReqMessage */ /* LineStatReqMessage */
#define LINE_STAT_REQ_MESSAGE 0x000B #define LINE_STAT_REQ_MESSAGE 0x000B
struct line_stat_req_message { struct line_stat_req_message {
uint32_t number; uint32_t number;
}; };
/* ConfigStatReqMessage */ /* ConfigStatReqMessage */
@ -117,32 +117,32 @@ struct line_stat_req_message {
/* CapabilitiesResMessage */ /* CapabilitiesResMessage */
#define CAPABILITIES_RES_MESSAGE 0x0010 #define CAPABILITIES_RES_MESSAGE 0x0010
struct station_capabilities { struct station_capabilities {
uint32_t codec; uint32_t codec;
uint16_t frames; uint16_t frames;
char reserved[10]; char reserved[10];
}; };
struct capabilities_res_message { struct capabilities_res_message {
uint32_t count; uint32_t count;
struct station_capabilities caps[SWITCH_MAX_CODECS]; struct station_capabilities caps[SWITCH_MAX_CODECS];
}; };
/* AlarmMessage */ /* AlarmMessage */
#define ALARM_MESSAGE 0x0020 #define ALARM_MESSAGE 0x0020
struct alarm_message { struct alarm_message {
uint32_t alarm_severity; uint32_t alarm_severity;
char display_message[80]; char display_message[80];
uint32_t alarm_param1; uint32_t alarm_param1;
uint32_t alarm_param2; uint32_t alarm_param2;
}; };
/* OpenReceiveChannelAck */ /* OpenReceiveChannelAck */
#define OPEN_RECEIVE_CHANNEL_ACK_MESSAGE 0x0022 #define OPEN_RECEIVE_CHANNEL_ACK_MESSAGE 0x0022
struct open_receive_channel_ack_message { struct open_receive_channel_ack_message {
uint32_t status; uint32_t status;
struct in_addr ip; struct in_addr ip;
uint32_t port; uint32_t port;
uint32_t pass_thru_party_id; uint32_t pass_thru_party_id;
}; };
/* SoftKeySetReqMessage */ /* SoftKeySetReqMessage */
@ -151,9 +151,9 @@ struct open_receive_channel_ack_message {
/* SoftKeyEventMessage */ /* SoftKeyEventMessage */
#define SOFT_KEY_EVENT_MESSAGE 0x0026 #define SOFT_KEY_EVENT_MESSAGE 0x0026
struct soft_key_event_message { struct soft_key_event_message {
uint32_t event; uint32_t event;
uint32_t line_instance; uint32_t line_instance;
uint32_t call_id; uint32_t call_id;
}; };
/* UnregisterMessage */ /* UnregisterMessage */
@ -165,182 +165,182 @@ struct soft_key_event_message {
/* ServiceUrlStatReqMessage */ /* ServiceUrlStatReqMessage */
#define SERVICE_URL_STAT_REQ_MESSAGE 0x0033 #define SERVICE_URL_STAT_REQ_MESSAGE 0x0033
struct service_url_stat_req_message { struct service_url_stat_req_message {
uint32_t service_url_index; uint32_t service_url_index;
}; };
/* FeatureStatReqMessage */ /* FeatureStatReqMessage */
#define FEATURE_STAT_REQ_MESSAGE 0x0034 #define FEATURE_STAT_REQ_MESSAGE 0x0034
struct feature_stat_req_message { struct feature_stat_req_message {
uint32_t feature_index; uint32_t feature_index;
}; };
/* HeadsetStatusMessage */ /* HeadsetStatusMessage */
#define HEADSET_STATUS_MESSAGE 0x002B #define HEADSET_STATUS_MESSAGE 0x002B
struct headset_status_message { struct headset_status_message {
uint32_t mode; uint32_t mode;
}; };
/* RegisterAvailableLinesMessage */ /* RegisterAvailableLinesMessage */
#define REGISTER_AVAILABLE_LINES_MESSAGE 0x002D #define REGISTER_AVAILABLE_LINES_MESSAGE 0x002D
struct register_available_lines_message { struct register_available_lines_message {
uint32_t count; uint32_t count;
}; };
/* RegisterAckMessage */ /* RegisterAckMessage */
#define REGISTER_ACK_MESSAGE 0x0081 #define REGISTER_ACK_MESSAGE 0x0081
struct register_ack_message { struct register_ack_message {
uint32_t keep_alive; uint32_t keep_alive;
char date_format[6]; char date_format[6];
char reserved[2]; char reserved[2];
uint32_t secondary_keep_alive; uint32_t secondary_keep_alive;
char reserved2[4]; char reserved2[4];
}; };
/* StartToneMessage */ /* StartToneMessage */
#define START_TONE_MESSAGE 0x0082 #define START_TONE_MESSAGE 0x0082
struct start_tone_message { struct start_tone_message {
uint32_t tone; /* see enum skinny_tone */ uint32_t tone; /* see enum skinny_tone */
uint32_t reserved; uint32_t reserved;
uint32_t line_instance; uint32_t line_instance;
uint32_t call_id; uint32_t call_id;
}; };
/* StopToneMessage */ /* StopToneMessage */
#define STOP_TONE_MESSAGE 0x0083 #define STOP_TONE_MESSAGE 0x0083
struct stop_tone_message { struct stop_tone_message {
uint32_t line_instance; uint32_t line_instance;
uint32_t call_id; uint32_t call_id;
}; };
/* SetRingerMessage */ /* SetRingerMessage */
#define SET_RINGER_MESSAGE 0x0085 #define SET_RINGER_MESSAGE 0x0085
struct set_ringer_message { struct set_ringer_message {
uint32_t ring_type; /* See enum skinny_ring_type */ uint32_t ring_type; /* See enum skinny_ring_type */
uint32_t ring_mode; /* See enum skinny_ring_mode */ uint32_t ring_mode; /* See enum skinny_ring_mode */
uint32_t line_instance; uint32_t line_instance;
uint32_t call_id; uint32_t call_id;
}; };
/* SetLampMessage */ /* SetLampMessage */
#define SET_LAMP_MESSAGE 0x0086 #define SET_LAMP_MESSAGE 0x0086
struct set_lamp_message { struct set_lamp_message {
uint32_t stimulus; /* See enum skinny_button_definition */ uint32_t stimulus; /* See enum skinny_button_definition */
uint32_t stimulus_instance; uint32_t stimulus_instance;
uint32_t mode; /* See enum skinny_lamp_mode */ uint32_t mode; /* See enum skinny_lamp_mode */
}; };
/* SetSpeakerModeMessage */ /* SetSpeakerModeMessage */
#define SET_SPEAKER_MODE_MESSAGE 0x0088 #define SET_SPEAKER_MODE_MESSAGE 0x0088
struct set_speaker_mode_message { struct set_speaker_mode_message {
uint32_t mode; /* See enum skinny_speaker_mode */ uint32_t mode; /* See enum skinny_speaker_mode */
}; };
/* StartMediaTransmissionMessage */ /* StartMediaTransmissionMessage */
#define START_MEDIA_TRANSMISSION_MESSAGE 0x008A #define START_MEDIA_TRANSMISSION_MESSAGE 0x008A
struct start_media_transmission_message { struct start_media_transmission_message {
uint32_t conference_id; uint32_t conference_id;
uint32_t pass_thru_party_id; uint32_t pass_thru_party_id;
uint32_t remote_ip; uint32_t remote_ip;
uint32_t remote_port; uint32_t remote_port;
uint32_t ms_per_packet; uint32_t ms_per_packet;
uint32_t payload_capacity; uint32_t payload_capacity;
uint32_t precedence; uint32_t precedence;
uint32_t silence_suppression; uint32_t silence_suppression;
uint16_t max_frames_per_packet; uint16_t max_frames_per_packet;
uint32_t g723_bitrate; uint32_t g723_bitrate;
/* ... */ /* ... */
}; };
/* StopMediaTransmissionMessage */ /* StopMediaTransmissionMessage */
#define STOP_MEDIA_TRANSMISSION_MESSAGE 0x008B #define STOP_MEDIA_TRANSMISSION_MESSAGE 0x008B
struct stop_media_transmission_message { struct stop_media_transmission_message {
uint32_t conference_id; uint32_t conference_id;
uint32_t pass_thru_party_id; uint32_t pass_thru_party_id;
uint32_t conference_id2; uint32_t conference_id2;
/* ... */ /* ... */
}; };
/* CallInfoMessage */ /* CallInfoMessage */
#define CALL_INFO_MESSAGE 0x008F #define CALL_INFO_MESSAGE 0x008F
struct call_info_message { struct call_info_message {
char calling_party_name[40]; char calling_party_name[40];
char calling_party[24]; char calling_party[24];
char called_party_name[40]; char called_party_name[40];
char called_party[24]; char called_party[24];
uint32_t line_instance; uint32_t line_instance;
uint32_t call_id; uint32_t call_id;
uint32_t call_type; /* See enum skinny_call_type */ uint32_t call_type; /* See enum skinny_call_type */
char original_called_party_name[40]; char original_called_party_name[40];
char original_called_party[24]; char original_called_party[24];
char last_redirecting_party_name[40]; char last_redirecting_party_name[40];
char last_redirecting_party[24]; char last_redirecting_party[24];
uint32_t original_called_party_redirect_reason; uint32_t original_called_party_redirect_reason;
uint32_t last_redirecting_reason; uint32_t last_redirecting_reason;
char calling_party_voice_mailbox[24]; char calling_party_voice_mailbox[24];
char called_party_voice_mailbox[24]; char called_party_voice_mailbox[24];
char original_called_party_voice_mailbox[24]; char original_called_party_voice_mailbox[24];
char last_redirecting_voice_mailbox[24]; char last_redirecting_voice_mailbox[24];
uint32_t call_instance; uint32_t call_instance;
uint32_t call_security_status; uint32_t call_security_status;
uint32_t party_pi_restriction_bits; uint32_t party_pi_restriction_bits;
}; };
/* SpeedDialStatMessage */ /* SpeedDialStatMessage */
#define SPEED_DIAL_STAT_RES_MESSAGE 0x0091 #define SPEED_DIAL_STAT_RES_MESSAGE 0x0091
struct speed_dial_stat_res_message { struct speed_dial_stat_res_message {
uint32_t number; uint32_t number;
char line[24]; char line[24];
char label[40]; char label[40];
}; };
/* LineStatMessage */ /* LineStatMessage */
#define LINE_STAT_RES_MESSAGE 0x0092 #define LINE_STAT_RES_MESSAGE 0x0092
struct line_stat_res_message { struct line_stat_res_message {
uint32_t number; uint32_t number;
char name[24]; char name[24];
char shortname[40]; char shortname[40];
char displayname[44]; char displayname[44];
}; };
/* ConfigStatMessage */ /* ConfigStatMessage */
#define CONFIG_STAT_RES_MESSAGE 0x0093 #define CONFIG_STAT_RES_MESSAGE 0x0093
struct config_stat_res_message { struct config_stat_res_message {
char device_name[16]; char device_name[16];
uint32_t user_id; uint32_t user_id;
uint32_t instance; uint32_t instance;
char user_name[40]; char user_name[40];
char server_name[40]; char server_name[40];
uint32_t number_lines; uint32_t number_lines;
uint32_t number_speed_dials; uint32_t number_speed_dials;
}; };
/* DefineTimeDate */ /* DefineTimeDate */
#define DEFINE_TIME_DATE_MESSAGE 0x0094 #define DEFINE_TIME_DATE_MESSAGE 0x0094
struct define_time_date_message { struct define_time_date_message {
uint32_t year; uint32_t year;
uint32_t month; uint32_t month;
uint32_t day_of_week; /* monday = 1 */ uint32_t day_of_week; /* monday = 1 */
uint32_t day; uint32_t day;
uint32_t hour; uint32_t hour;
uint32_t minute; uint32_t minute;
uint32_t seconds; uint32_t seconds;
uint32_t milliseconds; uint32_t milliseconds;
uint32_t timestamp; uint32_t timestamp;
}; };
/* ButtonTemplateMessage */ /* ButtonTemplateMessage */
#define BUTTON_TEMPLATE_RES_MESSAGE 0x0097 #define BUTTON_TEMPLATE_RES_MESSAGE 0x0097
struct button_definition { struct button_definition {
uint8_t instance_number; uint8_t instance_number;
uint8_t button_definition; /* See enum skinny_button_definition */ uint8_t button_definition; /* See enum skinny_button_definition */
}; };
#define SKINNY_MAX_BUTTON_COUNT 42 #define SKINNY_MAX_BUTTON_COUNT 42
struct button_template_message { struct button_template_message {
uint32_t button_offset; uint32_t button_offset;
uint32_t button_count; uint32_t button_count;
uint32_t total_button_count; uint32_t total_button_count;
struct button_definition btn[SKINNY_MAX_BUTTON_COUNT]; struct button_definition btn[SKINNY_MAX_BUTTON_COUNT];
}; };
/* CapabilitiesReqMessage */ /* CapabilitiesReqMessage */
@ -349,13 +349,13 @@ struct button_template_message {
/* RegisterRejectMessage */ /* RegisterRejectMessage */
#define REGISTER_REJ_MESSAGE 0x009D #define REGISTER_REJ_MESSAGE 0x009D
struct register_rej_message { struct register_rej_message {
char error[33]; char error[33];
}; };
/* ResetMessage */ /* ResetMessage */
#define RESET_MESSAGE 0x009F #define RESET_MESSAGE 0x009F
struct reset_message { struct reset_message {
uint32_t reset_type; /* See enum skinny_device_reset_types */ uint32_t reset_type; /* See enum skinny_device_reset_types */
}; };
/* KeepAliveAckMessage */ /* KeepAliveAckMessage */
@ -364,130 +364,130 @@ struct reset_message {
/* OpenReceiveChannelMessage */ /* OpenReceiveChannelMessage */
#define OPEN_RECEIVE_CHANNEL_MESSAGE 0x0105 #define OPEN_RECEIVE_CHANNEL_MESSAGE 0x0105
struct open_receive_channel_message { struct open_receive_channel_message {
uint32_t conference_id; uint32_t conference_id;
uint32_t pass_thru_party_id; uint32_t pass_thru_party_id;
uint32_t packets; uint32_t packets;
uint32_t payload_capacity; uint32_t payload_capacity;
uint32_t echo_cancel_type; uint32_t echo_cancel_type;
uint32_t g723_bitrate; uint32_t g723_bitrate;
uint32_t conference_id2; uint32_t conference_id2;
uint32_t reserved[10]; uint32_t reserved[10];
}; };
/* CloseReceiveChannelMessage */ /* CloseReceiveChannelMessage */
#define CLOSE_RECEIVE_CHANNEL_MESSAGE 0x0106 #define CLOSE_RECEIVE_CHANNEL_MESSAGE 0x0106
struct close_receive_channel_message { struct close_receive_channel_message {
uint32_t conference_id; uint32_t conference_id;
uint32_t pass_thru_party_id; uint32_t pass_thru_party_id;
uint32_t conference_id2; uint32_t conference_id2;
}; };
/* SoftKeyTemplateResMessage */ /* SoftKeyTemplateResMessage */
#define SOFT_KEY_TEMPLATE_RES_MESSAGE 0x0108 #define SOFT_KEY_TEMPLATE_RES_MESSAGE 0x0108
struct soft_key_template_definition { struct soft_key_template_definition {
char soft_key_label[16]; char soft_key_label[16];
uint32_t soft_key_event; uint32_t soft_key_event;
}; };
struct soft_key_template_res_message { struct soft_key_template_res_message {
uint32_t soft_key_offset; uint32_t soft_key_offset;
uint32_t soft_key_count; uint32_t soft_key_count;
uint32_t total_soft_key_count; uint32_t total_soft_key_count;
struct soft_key_template_definition soft_key[32]; struct soft_key_template_definition soft_key[32];
}; };
/* SoftKeySetResMessage */ /* SoftKeySetResMessage */
#define SOFT_KEY_SET_RES_MESSAGE 0x0109 #define SOFT_KEY_SET_RES_MESSAGE 0x0109
struct soft_key_set_definition { struct soft_key_set_definition {
uint8_t soft_key_template_index[16]; /* See enum skinny_soft_key_event */ uint8_t soft_key_template_index[16]; /* See enum skinny_soft_key_event */
uint16_t soft_key_info_index[16]; uint16_t soft_key_info_index[16];
}; };
struct soft_key_set_res_message { struct soft_key_set_res_message {
uint32_t soft_key_set_offset; uint32_t soft_key_set_offset;
uint32_t soft_key_set_count; uint32_t soft_key_set_count;
uint32_t total_soft_key_set_count; uint32_t total_soft_key_set_count;
struct soft_key_set_definition soft_key_set[16]; struct soft_key_set_definition soft_key_set[16];
uint32_t res; uint32_t res;
}; };
/* SelectSoftKeysMessage */ /* SelectSoftKeysMessage */
#define SELECT_SOFT_KEYS_MESSAGE 0x0110 #define SELECT_SOFT_KEYS_MESSAGE 0x0110
struct select_soft_keys_message { struct select_soft_keys_message {
uint32_t line_instance; uint32_t line_instance;
uint32_t call_id; uint32_t call_id;
uint32_t soft_key_set; /* See enum skinny_key_set */ uint32_t soft_key_set; /* See enum skinny_key_set */
uint32_t valid_key_mask; uint32_t valid_key_mask;
}; };
/* CallStateMessage */ /* CallStateMessage */
#define CALL_STATE_MESSAGE 0x0111 #define CALL_STATE_MESSAGE 0x0111
struct call_state_message { struct call_state_message {
uint32_t call_state; /* See enum skinny_call_state */ uint32_t call_state; /* See enum skinny_call_state */
uint32_t line_instance; uint32_t line_instance;
uint32_t call_id; uint32_t call_id;
}; };
/* DisplayPromptStatusMessage */ /* DisplayPromptStatusMessage */
#define DISPLAY_PROMPT_STATUS_MESSAGE 0x0112 #define DISPLAY_PROMPT_STATUS_MESSAGE 0x0112
struct display_prompt_status_message { struct display_prompt_status_message {
uint32_t timeout; uint32_t timeout;
char display[32]; char display[32];
uint32_t line_instance; uint32_t line_instance;
uint32_t call_id; uint32_t call_id;
}; };
/* ClearPromptStatusMessage */ /* ClearPromptStatusMessage */
#define CLEAR_PROMPT_STATUS_MESSAGE 0x0113 #define CLEAR_PROMPT_STATUS_MESSAGE 0x0113
struct clear_prompt_status_message { struct clear_prompt_status_message {
uint32_t line_instance; uint32_t line_instance;
uint32_t call_id; uint32_t call_id;
}; };
/* ActivateCallPlaneMessage */ /* ActivateCallPlaneMessage */
#define ACTIVATE_CALL_PLANE_MESSAGE 0x0116 #define ACTIVATE_CALL_PLANE_MESSAGE 0x0116
struct activate_call_plane_message { struct activate_call_plane_message {
uint32_t line_instance; uint32_t line_instance;
}; };
/* UnregisterAckMessage */ /* UnregisterAckMessage */
#define UNREGISTER_ACK_MESSAGE 0x0118 #define UNREGISTER_ACK_MESSAGE 0x0118
struct unregister_ack_message { struct unregister_ack_message {
uint32_t unregister_status; uint32_t unregister_status;
}; };
/* DialedNumberMessage */ /* DialedNumberMessage */
#define DIALED_NUMBER_MESSAGE 0x011D #define DIALED_NUMBER_MESSAGE 0x011D
struct dialed_number_message { struct dialed_number_message {
char called_party[24]; char called_party[24];
uint32_t line_instance; uint32_t line_instance;
uint32_t call_id; uint32_t call_id;
}; };
/* FeatureStatMessage */ /* FeatureStatMessage */
#define FEATURE_STAT_RES_MESSAGE 0x011F #define FEATURE_STAT_RES_MESSAGE 0x011F
struct feature_stat_res_message { struct feature_stat_res_message {
uint32_t index; uint32_t index;
uint32_t id; uint32_t id;
char text_label[40]; char text_label[40];
uint32_t status; uint32_t status;
}; };
/* DisplayPriNotifyMessage */ /* DisplayPriNotifyMessage */
#define DISPLAY_PRI_NOTIFY_MESSAGE 0x0120 #define DISPLAY_PRI_NOTIFY_MESSAGE 0x0120
struct display_pri_notify_message { struct display_pri_notify_message {
uint32_t message_timeout; uint32_t message_timeout;
uint32_t priority; uint32_t priority;
char notify[32]; char notify[32];
}; };
/* ServiceUrlStatMessage */ /* ServiceUrlStatMessage */
#define SERVICE_URL_STAT_RES_MESSAGE 0x012F #define SERVICE_URL_STAT_RES_MESSAGE 0x012F
struct service_url_stat_res_message { struct service_url_stat_res_message {
uint32_t index; uint32_t index;
char url[256]; char url[256];
char display_name[40]; char display_name[40];
}; };
/*****************************************************************************/ /*****************************************************************************/
@ -498,56 +498,56 @@ struct service_url_stat_res_message {
#define SKINNY_MESSAGE_MAXSIZE 1000 #define SKINNY_MESSAGE_MAXSIZE 1000
union skinny_data { union skinny_data {
struct register_message reg; struct register_message reg;
struct port_message port; struct port_message port;
struct keypad_button_message keypad_button; struct keypad_button_message keypad_button;
struct stimulus_message stimulus; struct stimulus_message stimulus;
struct off_hook_message off_hook; struct off_hook_message off_hook;
struct on_hook_message on_hook; struct on_hook_message on_hook;
struct speed_dial_stat_req_message speed_dial_req; struct speed_dial_stat_req_message speed_dial_req;
struct line_stat_req_message line_req; struct line_stat_req_message line_req;
struct capabilities_res_message cap_res; struct capabilities_res_message cap_res;
struct alarm_message alarm; struct alarm_message alarm;
struct open_receive_channel_ack_message open_receive_channel_ack; struct open_receive_channel_ack_message open_receive_channel_ack;
struct soft_key_event_message soft_key_event; struct soft_key_event_message soft_key_event;
struct service_url_stat_req_message service_url_req; struct service_url_stat_req_message service_url_req;
struct feature_stat_req_message feature_req; struct feature_stat_req_message feature_req;
struct headset_status_message headset_status; struct headset_status_message headset_status;
struct register_available_lines_message reg_lines; struct register_available_lines_message reg_lines;
struct register_ack_message reg_ack; struct register_ack_message reg_ack;
struct start_tone_message start_tone; struct start_tone_message start_tone;
struct stop_tone_message stop_tone; struct stop_tone_message stop_tone;
struct set_ringer_message ringer; struct set_ringer_message ringer;
struct set_lamp_message lamp; struct set_lamp_message lamp;
struct set_speaker_mode_message speaker_mode; struct set_speaker_mode_message speaker_mode;
struct start_media_transmission_message start_media; struct start_media_transmission_message start_media;
struct stop_media_transmission_message stop_media; struct stop_media_transmission_message stop_media;
struct call_info_message call_info; struct call_info_message call_info;
struct speed_dial_stat_res_message speed_dial_res; struct speed_dial_stat_res_message speed_dial_res;
struct line_stat_res_message line_res; struct line_stat_res_message line_res;
struct config_stat_res_message config_res; struct config_stat_res_message config_res;
struct define_time_date_message define_time_date; struct define_time_date_message define_time_date;
struct button_template_message button_template; struct button_template_message button_template;
struct register_rej_message reg_rej; struct register_rej_message reg_rej;
struct reset_message reset; struct reset_message reset;
struct open_receive_channel_message open_receive_channel; struct open_receive_channel_message open_receive_channel;
struct close_receive_channel_message close_receive_channel; struct close_receive_channel_message close_receive_channel;
struct soft_key_template_res_message soft_key_template; struct soft_key_template_res_message soft_key_template;
struct soft_key_set_res_message soft_key_set; struct soft_key_set_res_message soft_key_set;
struct select_soft_keys_message select_soft_keys; struct select_soft_keys_message select_soft_keys;
struct call_state_message call_state; struct call_state_message call_state;
struct display_prompt_status_message display_prompt_status; struct display_prompt_status_message display_prompt_status;
struct clear_prompt_status_message clear_prompt_status; struct clear_prompt_status_message clear_prompt_status;
struct activate_call_plane_message activate_call_plane; struct activate_call_plane_message activate_call_plane;
struct unregister_ack_message unregister_ack; struct unregister_ack_message unregister_ack;
struct dialed_number_message dialed_number; struct dialed_number_message dialed_number;
struct feature_stat_res_message feature_res; struct feature_stat_res_message feature_res;
struct display_pri_notify_message display_pri_notify; struct display_pri_notify_message display_pri_notify;
struct service_url_stat_res_message service_url_res; struct service_url_stat_res_message service_url_res;
uint16_t as_uint16; uint16_t as_uint16;
char as_char; char as_char;
void *raw; void *raw;
}; };
/* /*
@ -555,10 +555,10 @@ union skinny_data {
* body is type+data * body is type+data
*/ */
struct skinny_message { struct skinny_message {
uint32_t length; uint32_t length;
uint32_t reserved; uint32_t reserved;
uint32_t type; uint32_t type;
union skinny_data data; union skinny_data data;
}; };
typedef struct skinny_message skinny_message_t; typedef struct skinny_message skinny_message_t;
@ -566,40 +566,40 @@ typedef struct skinny_message skinny_message_t;
/* SKINNY TYPES */ /* SKINNY TYPES */
/*****************************************************************************/ /*****************************************************************************/
enum skinny_codecs { enum skinny_codecs {
SKINNY_CODEC_ALAW_64K = 2, SKINNY_CODEC_ALAW_64K = 2,
SKINNY_CODEC_ALAW_56K = 3, SKINNY_CODEC_ALAW_56K = 3,
SKINNY_CODEC_ULAW_64K = 4, SKINNY_CODEC_ULAW_64K = 4,
SKINNY_CODEC_ULAW_56K = 5, SKINNY_CODEC_ULAW_56K = 5,
SKINNY_CODEC_G722_64K = 6, SKINNY_CODEC_G722_64K = 6,
SKINNY_CODEC_G722_56K = 7, SKINNY_CODEC_G722_56K = 7,
SKINNY_CODEC_G722_48K = 8, SKINNY_CODEC_G722_48K = 8,
SKINNY_CODEC_G723_1 = 9, SKINNY_CODEC_G723_1 = 9,
SKINNY_CODEC_G728 = 10, SKINNY_CODEC_G728 = 10,
SKINNY_CODEC_G729 = 11, SKINNY_CODEC_G729 = 11,
SKINNY_CODEC_G729A = 12, SKINNY_CODEC_G729A = 12,
SKINNY_CODEC_IS11172 = 13, SKINNY_CODEC_IS11172 = 13,
SKINNY_CODEC_IS13818 = 14, SKINNY_CODEC_IS13818 = 14,
SKINNY_CODEC_G729B = 15, SKINNY_CODEC_G729B = 15,
SKINNY_CODEC_G729AB = 16, SKINNY_CODEC_G729AB = 16,
SKINNY_CODEC_GSM_FULL = 18, SKINNY_CODEC_GSM_FULL = 18,
SKINNY_CODEC_GSM_HALF = 19, SKINNY_CODEC_GSM_HALF = 19,
SKINNY_CODEC_GSM_EFULL = 20, SKINNY_CODEC_GSM_EFULL = 20,
SKINNY_CODEC_WIDEBAND_256K = 25, SKINNY_CODEC_WIDEBAND_256K = 25,
SKINNY_CODEC_DATA_64K = 32, SKINNY_CODEC_DATA_64K = 32,
SKINNY_CODEC_DATA_56K = 33, SKINNY_CODEC_DATA_56K = 33,
SKINNY_CODEC_GSM = 80, SKINNY_CODEC_GSM = 80,
SKINNY_CODEC_ACTIVEVOICE = 81, SKINNY_CODEC_ACTIVEVOICE = 81,
SKINNY_CODEC_G726_32K = 82, SKINNY_CODEC_G726_32K = 82,
SKINNY_CODEC_G726_24K = 83, SKINNY_CODEC_G726_24K = 83,
SKINNY_CODEC_G726_16K = 84, SKINNY_CODEC_G726_16K = 84,
SKINNY_CODEC_G729B_BIS = 85, SKINNY_CODEC_G729B_BIS = 85,
SKINNY_CODEC_G729B_LOW = 86, SKINNY_CODEC_G729B_LOW = 86,
SKINNY_CODEC_H261 = 100, SKINNY_CODEC_H261 = 100,
SKINNY_CODEC_H263 = 101, SKINNY_CODEC_H263 = 101,
SKINNY_CODEC_VIDEO = 102, SKINNY_CODEC_VIDEO = 102,
SKINNY_CODEC_T120 = 105, SKINNY_CODEC_T120 = 105,
SKINNY_CODEC_H224 = 106, SKINNY_CODEC_H224 = 106,
SKINNY_CODEC_RFC2833_DYNPAYLOAD = 257 SKINNY_CODEC_RFC2833_DYNPAYLOAD = 257
}; };
typedef switch_status_t (*skinny_command_t) (char **argv, int argc, switch_stream_handle_t *stream); typedef switch_status_t (*skinny_command_t) (char **argv, int argc, switch_stream_handle_t *stream);
@ -608,10 +608,10 @@ typedef switch_status_t (*skinny_command_t) (char **argv, int argc, switch_strea
/* SKINNY FUNCTIONS */ /* SKINNY FUNCTIONS */
/*****************************************************************************/ /*****************************************************************************/
#define skinny_check_data_length(message, len) \ #define skinny_check_data_length(message, len) \
if (message->length < len+4) {\ if (message->length < len+4) {\
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Received Too Short Skinny Message (Expected %" SWITCH_SIZE_T_FMT ", got %d).\n", len+4, message->length);\ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Received Too Short Skinny Message (Expected %" SWITCH_SIZE_T_FMT ", got %d).\n", len+4, message->length);\
return SWITCH_STATUS_FALSE;\ return SWITCH_STATUS_FALSE;\
} }
#define skinny_check_data_length_soft(message, len) \ #define skinny_check_data_length_soft(message, len) \
(message->length >= len+4) (message->length >= len+4)
@ -643,102 +643,102 @@ switch_status_t skinny_handle_request(listener_t *listener, skinny_message_t *re
/* SKINNY MESSAGE HELPER */ /* SKINNY MESSAGE HELPER */
/*****************************************************************************/ /*****************************************************************************/
switch_status_t start_tone(listener_t *listener, switch_status_t start_tone(listener_t *listener,
uint32_t tone, uint32_t tone,
uint32_t reserved, uint32_t reserved,
uint32_t line_instance, uint32_t line_instance,
uint32_t call_id); uint32_t call_id);
switch_status_t stop_tone(listener_t *listener, switch_status_t stop_tone(listener_t *listener,
uint32_t line_instance, uint32_t line_instance,
uint32_t call_id); uint32_t call_id);
switch_status_t set_ringer(listener_t *listener, switch_status_t set_ringer(listener_t *listener,
uint32_t ring_type, uint32_t ring_type,
uint32_t ring_mode, uint32_t ring_mode,
uint32_t line_instance, uint32_t line_instance,
uint32_t call_id); uint32_t call_id);
switch_status_t set_lamp(listener_t *listener, switch_status_t set_lamp(listener_t *listener,
uint32_t stimulus, uint32_t stimulus,
uint32_t stimulus_instance, uint32_t stimulus_instance,
uint32_t mode); uint32_t mode);
switch_status_t set_speaker_mode(listener_t *listener, switch_status_t set_speaker_mode(listener_t *listener,
uint32_t mode); uint32_t mode);
switch_status_t start_media_transmission(listener_t *listener, switch_status_t start_media_transmission(listener_t *listener,
uint32_t conference_id, uint32_t conference_id,
uint32_t pass_thru_party_id, uint32_t pass_thru_party_id,
uint32_t remote_ip, uint32_t remote_ip,
uint32_t remote_port, uint32_t remote_port,
uint32_t ms_per_packet, uint32_t ms_per_packet,
uint32_t payload_capacity, uint32_t payload_capacity,
uint32_t precedence, uint32_t precedence,
uint32_t silence_suppression, uint32_t silence_suppression,
uint16_t max_frames_per_packet, uint16_t max_frames_per_packet,
uint32_t g723_bitrate); uint32_t g723_bitrate);
switch_status_t stop_media_transmission(listener_t *listener, switch_status_t stop_media_transmission(listener_t *listener,
uint32_t conference_id, uint32_t conference_id,
uint32_t pass_thru_party_id, uint32_t pass_thru_party_id,
uint32_t conference_id2); uint32_t conference_id2);
switch_status_t send_call_info(listener_t *listener, switch_status_t send_call_info(listener_t *listener,
char calling_party_name[40], char calling_party_name[40],
char calling_party[24], char calling_party[24],
char called_party_name[40], char called_party_name[40],
char called_party[24], char called_party[24],
uint32_t line_instance, uint32_t line_instance,
uint32_t call_id, uint32_t call_id,
uint32_t call_type, uint32_t call_type,
char original_called_party_name[40], char original_called_party_name[40],
char original_called_party[24], char original_called_party[24],
char last_redirecting_party_name[40], char last_redirecting_party_name[40],
char last_redirecting_party[24], char last_redirecting_party[24],
uint32_t original_called_party_redirect_reason, uint32_t original_called_party_redirect_reason,
uint32_t last_redirecting_reason, uint32_t last_redirecting_reason,
char calling_party_voice_mailbox[24], char calling_party_voice_mailbox[24],
char called_party_voice_mailbox[24], char called_party_voice_mailbox[24],
char original_called_party_voice_mailbox[24], char original_called_party_voice_mailbox[24],
char last_redirecting_voice_mailbox[24], char last_redirecting_voice_mailbox[24],
uint32_t call_instance, uint32_t call_instance,
uint32_t call_security_status, uint32_t call_security_status,
uint32_t party_pi_restriction_bits); uint32_t party_pi_restriction_bits);
switch_status_t open_receive_channel(listener_t *listener, switch_status_t open_receive_channel(listener_t *listener,
uint32_t conference_id, uint32_t conference_id,
uint32_t pass_thru_party_id, uint32_t pass_thru_party_id,
uint32_t packets, uint32_t packets,
uint32_t payload_capacity, uint32_t payload_capacity,
uint32_t echo_cancel_type, uint32_t echo_cancel_type,
uint32_t g723_bitrate, uint32_t g723_bitrate,
uint32_t conference_id2, uint32_t conference_id2,
uint32_t reserved[10]); uint32_t reserved[10]);
switch_status_t close_receive_channel(listener_t *listener, switch_status_t close_receive_channel(listener_t *listener,
uint32_t conference_id, uint32_t conference_id,
uint32_t pass_thru_party_id, uint32_t pass_thru_party_id,
uint32_t conference_id2); uint32_t conference_id2);
switch_status_t send_select_soft_keys(listener_t *listener, switch_status_t send_select_soft_keys(listener_t *listener,
uint32_t line_instance, uint32_t line_instance,
uint32_t call_id, uint32_t call_id,
uint32_t soft_key_set, uint32_t soft_key_set,
uint32_t valid_key_mask); uint32_t valid_key_mask);
switch_status_t send_call_state(listener_t *listener, switch_status_t send_call_state(listener_t *listener,
uint32_t call_state, uint32_t call_state,
uint32_t line_instance, uint32_t line_instance,
uint32_t call_id); uint32_t call_id);
switch_status_t display_prompt_status(listener_t *listener, switch_status_t display_prompt_status(listener_t *listener,
uint32_t timeout, uint32_t timeout,
char display[32], char display[32],
uint32_t line_instance, uint32_t line_instance,
uint32_t call_id); uint32_t call_id);
switch_status_t clear_prompt_status(listener_t *listener, switch_status_t clear_prompt_status(listener_t *listener,
uint32_t line_instance, uint32_t line_instance,
uint32_t call_id); uint32_t call_id);
switch_status_t activate_call_plane(listener_t *listener, switch_status_t activate_call_plane(listener_t *listener,
uint32_t line_instance); uint32_t line_instance);
switch_status_t send_dialed_number(listener_t *listener, switch_status_t send_dialed_number(listener_t *listener,
char called_party[24], char called_party[24],
uint32_t line_instance, uint32_t line_instance,
uint32_t call_id); uint32_t call_id);
switch_status_t send_display_pri_notify(listener_t *listener, switch_status_t send_display_pri_notify(listener_t *listener,
uint32_t message_timeout, uint32_t message_timeout,
uint32_t priority, uint32_t priority,
char *notify); char *notify);
switch_status_t send_reset(listener_t *listener, switch_status_t send_reset(listener_t *listener,
uint32_t reset_type); uint32_t reset_type);
#endif /* _SKINNY_PROTOCOL_H */ #endif /* _SKINNY_PROTOCOL_H */

View File

@ -35,157 +35,157 @@
/* Translation tables */ /* Translation tables */
struct skinny_table SKINNY_MESSAGE_TYPES[] = { struct skinny_table SKINNY_MESSAGE_TYPES[] = {
{"KeepAliveMessage", KEEP_ALIVE_MESSAGE}, {"KeepAliveMessage", KEEP_ALIVE_MESSAGE},
{"RegisterMessage", REGISTER_MESSAGE}, {"RegisterMessage", REGISTER_MESSAGE},
{"PortMessage", PORT_MESSAGE}, {"PortMessage", PORT_MESSAGE},
{"KeypadButtonMessage", KEYPAD_BUTTON_MESSAGE}, {"KeypadButtonMessage", KEYPAD_BUTTON_MESSAGE},
{"StimulusMessage", STIMULUS_MESSAGE}, {"StimulusMessage", STIMULUS_MESSAGE},
{"OffHookMessage", OFF_HOOK_MESSAGE}, {"OffHookMessage", OFF_HOOK_MESSAGE},
{"OnHookMessage", ON_HOOK_MESSAGE}, {"OnHookMessage", ON_HOOK_MESSAGE},
{"SpeedDialStatReqMessage", SPEED_DIAL_STAT_REQ_MESSAGE}, {"SpeedDialStatReqMessage", SPEED_DIAL_STAT_REQ_MESSAGE},
{"LineStatReqMessage", LINE_STAT_REQ_MESSAGE}, {"LineStatReqMessage", LINE_STAT_REQ_MESSAGE},
{"ConfigStatReqMessage", CONFIG_STAT_REQ_MESSAGE}, {"ConfigStatReqMessage", CONFIG_STAT_REQ_MESSAGE},
{"TimeDateReqMessage", TIME_DATE_REQ_MESSAGE}, {"TimeDateReqMessage", TIME_DATE_REQ_MESSAGE},
{"ButtonTemplateReqMessage", BUTTON_TEMPLATE_REQ_MESSAGE}, {"ButtonTemplateReqMessage", BUTTON_TEMPLATE_REQ_MESSAGE},
{"CapabilitiesReqMessage", CAPABILITIES_RES_MESSAGE}, {"CapabilitiesReqMessage", CAPABILITIES_RES_MESSAGE},
{"AlarmMessage", ALARM_MESSAGE}, {"AlarmMessage", ALARM_MESSAGE},
{"OpenReceiveChannelAckMessage", OPEN_RECEIVE_CHANNEL_ACK_MESSAGE}, {"OpenReceiveChannelAckMessage", OPEN_RECEIVE_CHANNEL_ACK_MESSAGE},
{"SoftKeySetReqMessage", SOFT_KEY_SET_REQ_MESSAGE}, {"SoftKeySetReqMessage", SOFT_KEY_SET_REQ_MESSAGE},
{"SoftKeyEventMessage", SOFT_KEY_EVENT_MESSAGE}, {"SoftKeyEventMessage", SOFT_KEY_EVENT_MESSAGE},
{"UnregisterMessage", UNREGISTER_MESSAGE}, {"UnregisterMessage", UNREGISTER_MESSAGE},
{"SoftKeyTemplateReqMessage", SOFT_KEY_TEMPLATE_REQ_MESSAGE}, {"SoftKeyTemplateReqMessage", SOFT_KEY_TEMPLATE_REQ_MESSAGE},
{"ServiceUrlStatReqMessage", SERVICE_URL_STAT_REQ_MESSAGE}, {"ServiceUrlStatReqMessage", SERVICE_URL_STAT_REQ_MESSAGE},
{"FeatureStatReqMessage", FEATURE_STAT_REQ_MESSAGE}, {"FeatureStatReqMessage", FEATURE_STAT_REQ_MESSAGE},
{"HeadsetStatusMessage", HEADSET_STATUS_MESSAGE}, {"HeadsetStatusMessage", HEADSET_STATUS_MESSAGE},
{"RegisterAvailableLinesMessage", REGISTER_AVAILABLE_LINES_MESSAGE}, {"RegisterAvailableLinesMessage", REGISTER_AVAILABLE_LINES_MESSAGE},
{"RegisterAckMessage", REGISTER_ACK_MESSAGE}, {"RegisterAckMessage", REGISTER_ACK_MESSAGE},
{"StartToneMessage", START_TONE_MESSAGE}, {"StartToneMessage", START_TONE_MESSAGE},
{"StopToneMessage", STOP_TONE_MESSAGE}, {"StopToneMessage", STOP_TONE_MESSAGE},
{"SetRingerMessage", SET_RINGER_MESSAGE}, {"SetRingerMessage", SET_RINGER_MESSAGE},
{"SetLampMessage", SET_LAMP_MESSAGE}, {"SetLampMessage", SET_LAMP_MESSAGE},
{"SetSpeakerModeMessage", SET_SPEAKER_MODE_MESSAGE}, {"SetSpeakerModeMessage", SET_SPEAKER_MODE_MESSAGE},
{"StartMediaTransmissionMessage", START_MEDIA_TRANSMISSION_MESSAGE}, {"StartMediaTransmissionMessage", START_MEDIA_TRANSMISSION_MESSAGE},
{"StopMediaTransmissionMessage", STOP_MEDIA_TRANSMISSION_MESSAGE}, {"StopMediaTransmissionMessage", STOP_MEDIA_TRANSMISSION_MESSAGE},
{"CallInfoMessage", CALL_INFO_MESSAGE}, {"CallInfoMessage", CALL_INFO_MESSAGE},
{"SpeedDialStatResMessage", SPEED_DIAL_STAT_RES_MESSAGE}, {"SpeedDialStatResMessage", SPEED_DIAL_STAT_RES_MESSAGE},
{"LineStatResMessage", LINE_STAT_RES_MESSAGE}, {"LineStatResMessage", LINE_STAT_RES_MESSAGE},
{"ConfigStatResMessage", CONFIG_STAT_RES_MESSAGE}, {"ConfigStatResMessage", CONFIG_STAT_RES_MESSAGE},
{"DefineTimeDateMessage", DEFINE_TIME_DATE_MESSAGE}, {"DefineTimeDateMessage", DEFINE_TIME_DATE_MESSAGE},
{"ButtonTemplateResMessage", BUTTON_TEMPLATE_RES_MESSAGE}, {"ButtonTemplateResMessage", BUTTON_TEMPLATE_RES_MESSAGE},
{"CapabilitiesReqMessage", CAPABILITIES_REQ_MESSAGE}, {"CapabilitiesReqMessage", CAPABILITIES_REQ_MESSAGE},
{"RegisterRejMessage", REGISTER_REJ_MESSAGE}, {"RegisterRejMessage", REGISTER_REJ_MESSAGE},
{"ResetMessage", RESET_MESSAGE}, {"ResetMessage", RESET_MESSAGE},
{"KeepAliveAckMessage", KEEP_ALIVE_ACK_MESSAGE}, {"KeepAliveAckMessage", KEEP_ALIVE_ACK_MESSAGE},
{"OpenReceiveChannelMessage", OPEN_RECEIVE_CHANNEL_MESSAGE}, {"OpenReceiveChannelMessage", OPEN_RECEIVE_CHANNEL_MESSAGE},
{"CloseReceiveChannelMessage", CLOSE_RECEIVE_CHANNEL_MESSAGE}, {"CloseReceiveChannelMessage", CLOSE_RECEIVE_CHANNEL_MESSAGE},
{"SoftKeyTemplateResMessage", SOFT_KEY_TEMPLATE_RES_MESSAGE}, {"SoftKeyTemplateResMessage", SOFT_KEY_TEMPLATE_RES_MESSAGE},
{"SoftKeySetResMessage", SOFT_KEY_SET_RES_MESSAGE}, {"SoftKeySetResMessage", SOFT_KEY_SET_RES_MESSAGE},
{"SelectSoftKeysMessage", SELECT_SOFT_KEYS_MESSAGE}, {"SelectSoftKeysMessage", SELECT_SOFT_KEYS_MESSAGE},
{"CallStateMessage", CALL_STATE_MESSAGE}, {"CallStateMessage", CALL_STATE_MESSAGE},
{"DisplayPromptStatusMessage", DISPLAY_PROMPT_STATUS_MESSAGE}, {"DisplayPromptStatusMessage", DISPLAY_PROMPT_STATUS_MESSAGE},
{"ClearPromptStatusMessage", CLEAR_PROMPT_STATUS_MESSAGE}, {"ClearPromptStatusMessage", CLEAR_PROMPT_STATUS_MESSAGE},
{"ActivateCallPlaneMessage", ACTIVATE_CALL_PLANE_MESSAGE}, {"ActivateCallPlaneMessage", ACTIVATE_CALL_PLANE_MESSAGE},
{"UnregisterAckMessage", UNREGISTER_ACK_MESSAGE}, {"UnregisterAckMessage", UNREGISTER_ACK_MESSAGE},
{"DialedNumberMessage", DIALED_NUMBER_MESSAGE}, {"DialedNumberMessage", DIALED_NUMBER_MESSAGE},
{"FeatureResMessage", FEATURE_STAT_RES_MESSAGE}, {"FeatureResMessage", FEATURE_STAT_RES_MESSAGE},
{"DisplayPriNotifyMessage", DISPLAY_PRI_NOTIFY_MESSAGE}, {"DisplayPriNotifyMessage", DISPLAY_PRI_NOTIFY_MESSAGE},
{"ServiceUrlStatMessage", SERVICE_URL_STAT_RES_MESSAGE}, {"ServiceUrlStatMessage", SERVICE_URL_STAT_RES_MESSAGE},
{NULL, 0} {NULL, 0}
}; };
SKINNY_DECLARE_ID2STR(skinny_message_type2str, SKINNY_MESSAGE_TYPES, "UnknownMessage") SKINNY_DECLARE_ID2STR(skinny_message_type2str, SKINNY_MESSAGE_TYPES, "UnknownMessage")
SKINNY_DECLARE_STR2ID(skinny_str2message_type, SKINNY_MESSAGE_TYPES, -1) SKINNY_DECLARE_STR2ID(skinny_str2message_type, SKINNY_MESSAGE_TYPES, -1)
struct skinny_table SKINNY_RING_TYPES[] = { struct skinny_table SKINNY_RING_TYPES[] = {
{"RingOff", SKINNY_RING_OFF}, {"RingOff", SKINNY_RING_OFF},
{"RingInside", SKINNY_RING_INSIDE}, {"RingInside", SKINNY_RING_INSIDE},
{"RingOutside", SKINNY_RING_OUTSIDE}, {"RingOutside", SKINNY_RING_OUTSIDE},
{"RingFeature", SKINNY_RING_FEATURE}, {"RingFeature", SKINNY_RING_FEATURE},
{NULL, 0} {NULL, 0}
}; };
SKINNY_DECLARE_ID2STR(skinny_ring_type2str, SKINNY_RING_TYPES, "RingTypeUnknown") SKINNY_DECLARE_ID2STR(skinny_ring_type2str, SKINNY_RING_TYPES, "RingTypeUnknown")
SKINNY_DECLARE_STR2ID(skinny_str2ring_type, SKINNY_RING_TYPES, -1) SKINNY_DECLARE_STR2ID(skinny_str2ring_type, SKINNY_RING_TYPES, -1)
struct skinny_table SKINNY_RING_MODES[] = { struct skinny_table SKINNY_RING_MODES[] = {
{"RingForever", SKINNY_RING_FOREVER}, {"RingForever", SKINNY_RING_FOREVER},
{"RingOnce", SKINNY_RING_ONCE}, {"RingOnce", SKINNY_RING_ONCE},
{NULL, 0} {NULL, 0}
}; };
SKINNY_DECLARE_ID2STR(skinny_ring_mode2str, SKINNY_RING_MODES, "RingModeUnknown") SKINNY_DECLARE_ID2STR(skinny_ring_mode2str, SKINNY_RING_MODES, "RingModeUnknown")
SKINNY_DECLARE_STR2ID(skinny_str2ring_mode, SKINNY_RING_MODES, -1) SKINNY_DECLARE_STR2ID(skinny_str2ring_mode, SKINNY_RING_MODES, -1)
struct skinny_table SKINNY_BUTTONS[] = { struct skinny_table SKINNY_BUTTONS[] = {
{"Unknown", SKINNY_BUTTON_UNKNOWN}, {"Unknown", SKINNY_BUTTON_UNKNOWN},
{"LastNumberRedial", SKINNY_BUTTON_LAST_NUMBER_REDIAL}, {"LastNumberRedial", SKINNY_BUTTON_LAST_NUMBER_REDIAL},
{"SpeedDial", SKINNY_BUTTON_SPEED_DIAL}, {"SpeedDial", SKINNY_BUTTON_SPEED_DIAL},
{"Line", SKINNY_BUTTON_LINE}, {"Line", SKINNY_BUTTON_LINE},
{"Voicemail", SKINNY_BUTTON_VOICEMAIL}, {"Voicemail", SKINNY_BUTTON_VOICEMAIL},
{"Privacy", SKINNY_BUTTON_PRIVACY}, {"Privacy", SKINNY_BUTTON_PRIVACY},
{"ServiceUrl", SKINNY_BUTTON_SERVICE_URL}, {"ServiceUrl", SKINNY_BUTTON_SERVICE_URL},
{"Undefined", SKINNY_BUTTON_UNDEFINED}, {"Undefined", SKINNY_BUTTON_UNDEFINED},
{NULL, 0} {NULL, 0}
}; };
SKINNY_DECLARE_ID2STR(skinny_button2str, SKINNY_BUTTONS, "Unknown") SKINNY_DECLARE_ID2STR(skinny_button2str, SKINNY_BUTTONS, "Unknown")
SKINNY_DECLARE_STR2ID(skinny_str2button, SKINNY_BUTTONS, -1) SKINNY_DECLARE_STR2ID(skinny_str2button, SKINNY_BUTTONS, -1)
struct skinny_table SKINNY_LAMP_MODES[] = { struct skinny_table SKINNY_LAMP_MODES[] = {
{"Off", SKINNY_LAMP_OFF}, {"Off", SKINNY_LAMP_OFF},
{"On", SKINNY_LAMP_ON}, {"On", SKINNY_LAMP_ON},
{"Wink", SKINNY_LAMP_WINK}, {"Wink", SKINNY_LAMP_WINK},
{"Flash", SKINNY_LAMP_FLASH}, {"Flash", SKINNY_LAMP_FLASH},
{"Blink", SKINNY_LAMP_BLINK}, {"Blink", SKINNY_LAMP_BLINK},
{NULL, 0} {NULL, 0}
}; };
SKINNY_DECLARE_ID2STR(skinny_lamp_mode2str, SKINNY_LAMP_MODES, "Unknown") SKINNY_DECLARE_ID2STR(skinny_lamp_mode2str, SKINNY_LAMP_MODES, "Unknown")
SKINNY_DECLARE_STR2ID(skinny_str2lamp_mode, SKINNY_LAMP_MODES, -1) SKINNY_DECLARE_STR2ID(skinny_str2lamp_mode, SKINNY_LAMP_MODES, -1)
struct skinny_table SKINNY_SPEAKER_MODES[] = { struct skinny_table SKINNY_SPEAKER_MODES[] = {
{"SpeakerOn", SKINNY_SPEAKER_ON}, {"SpeakerOn", SKINNY_SPEAKER_ON},
{"SpeakerOff", SKINNY_SPEAKER_OFF}, {"SpeakerOff", SKINNY_SPEAKER_OFF},
{NULL, 0} {NULL, 0}
}; };
SKINNY_DECLARE_ID2STR(skinny_speaker_mode2str, SKINNY_SPEAKER_MODES, "Unknown") SKINNY_DECLARE_ID2STR(skinny_speaker_mode2str, SKINNY_SPEAKER_MODES, "Unknown")
SKINNY_DECLARE_STR2ID(skinny_str2speaker_mode, SKINNY_SPEAKER_MODES, -1) SKINNY_DECLARE_STR2ID(skinny_str2speaker_mode, SKINNY_SPEAKER_MODES, -1)
struct skinny_table SKINNY_KEY_SETS[] = { struct skinny_table SKINNY_KEY_SETS[] = {
{"KeySetOnHook", SKINNY_KEY_SET_ON_HOOK}, {"KeySetOnHook", SKINNY_KEY_SET_ON_HOOK},
{"KeySetConnected", SKINNY_KEY_SET_CONNECTED}, {"KeySetConnected", SKINNY_KEY_SET_CONNECTED},
{"KeySetOnHold", SKINNY_KEY_SET_ON_HOLD}, {"KeySetOnHold", SKINNY_KEY_SET_ON_HOLD},
{"KeySetRingIn", SKINNY_KEY_SET_RING_IN}, {"KeySetRingIn", SKINNY_KEY_SET_RING_IN},
{"KeySetOffHook", SKINNY_KEY_SET_OFF_HOOK}, {"KeySetOffHook", SKINNY_KEY_SET_OFF_HOOK},
{"KeySetConnectedWithTransfer", SKINNY_KEY_SET_CONNECTED_WITH_TRANSFER}, {"KeySetConnectedWithTransfer", SKINNY_KEY_SET_CONNECTED_WITH_TRANSFER},
{"KeySetDigitsAfterDialingFirstDigit", SKINNY_KEY_SET_DIGITS_AFTER_DIALING_FIRST_DIGIT}, {"KeySetDigitsAfterDialingFirstDigit", SKINNY_KEY_SET_DIGITS_AFTER_DIALING_FIRST_DIGIT},
{"KeySetConnectedWithConference", SKINNY_KEY_SET_CONNECTED_WITH_CONFERENCE}, {"KeySetConnectedWithConference", SKINNY_KEY_SET_CONNECTED_WITH_CONFERENCE},
{"KeySetRingOut", SKINNY_KEY_SET_RING_OUT}, {"KeySetRingOut", SKINNY_KEY_SET_RING_OUT},
{"KeySetOffHookWithFeatures", SKINNY_KEY_SET_OFF_HOOK_WITH_FEATURES}, {"KeySetOffHookWithFeatures", SKINNY_KEY_SET_OFF_HOOK_WITH_FEATURES},
{NULL, 0} {NULL, 0}
}; };
SKINNY_DECLARE_ID2STR(skinny_soft_key_set2str, SKINNY_KEY_SETS, "UNKNOWN_SOFT_KEY_SET") SKINNY_DECLARE_ID2STR(skinny_soft_key_set2str, SKINNY_KEY_SETS, "UNKNOWN_SOFT_KEY_SET")
SKINNY_DECLARE_STR2ID(skinny_str2soft_key_set, SKINNY_KEY_SETS, -1) SKINNY_DECLARE_STR2ID(skinny_str2soft_key_set, SKINNY_KEY_SETS, -1)
struct skinny_table SKINNY_CALL_STATES[] = { struct skinny_table SKINNY_CALL_STATES[] = {
{"OffHook", SKINNY_OFF_HOOK}, {"OffHook", SKINNY_OFF_HOOK},
{"OnHook", SKINNY_ON_HOOK}, {"OnHook", SKINNY_ON_HOOK},
{"RingOut", SKINNY_RING_OUT}, {"RingOut", SKINNY_RING_OUT},
{"RingIn", SKINNY_RING_IN}, {"RingIn", SKINNY_RING_IN},
{"Connected", SKINNY_CONNECTED}, {"Connected", SKINNY_CONNECTED},
{"Busy", SKINNY_BUSY}, {"Busy", SKINNY_BUSY},
{"LineInUse", SKINNY_LINE_IN_USE}, {"LineInUse", SKINNY_LINE_IN_USE},
{"Hold", SKINNY_HOLD}, {"Hold", SKINNY_HOLD},
{"CallWaiting", SKINNY_CALL_WAITING}, {"CallWaiting", SKINNY_CALL_WAITING},
{"CallTransfer", SKINNY_CALL_TRANSFER}, {"CallTransfer", SKINNY_CALL_TRANSFER},
{"CallPark", SKINNY_CALL_PARK}, {"CallPark", SKINNY_CALL_PARK},
{"Proceed", SKINNY_PROCEED}, {"Proceed", SKINNY_PROCEED},
{"InUseRemotely", SKINNY_IN_USE_REMOTELY}, {"InUseRemotely", SKINNY_IN_USE_REMOTELY},
{"InvalidNumber", SKINNY_INVALID_NUMBER}, {"InvalidNumber", SKINNY_INVALID_NUMBER},
{NULL, 0} {NULL, 0}
}; };
SKINNY_DECLARE_ID2STR(skinny_call_state2str, SKINNY_CALL_STATES, "CallStateUnknown") SKINNY_DECLARE_ID2STR(skinny_call_state2str, SKINNY_CALL_STATES, "CallStateUnknown")
SKINNY_DECLARE_STR2ID(skinny_str2call_state, SKINNY_CALL_STATES, -1) SKINNY_DECLARE_STR2ID(skinny_str2call_state, SKINNY_CALL_STATES, -1)
struct skinny_table SKINNY_DEVICE_RESET_TYPES[] = { struct skinny_table SKINNY_DEVICE_RESET_TYPES[] = {
{"DeviceReset", SKINNY_DEVICE_RESET}, {"DeviceReset", SKINNY_DEVICE_RESET},
{"DeviceRestart", SKINNY_DEVICE_RESTART}, {"DeviceRestart", SKINNY_DEVICE_RESTART},
{NULL, 0} {NULL, 0}
}; };
SKINNY_DECLARE_ID2STR(skinny_device_reset_type2str, SKINNY_DEVICE_RESET_TYPES, "DeviceResetTypeUnknown") SKINNY_DECLARE_ID2STR(skinny_device_reset_type2str, SKINNY_DEVICE_RESET_TYPES, "DeviceResetTypeUnknown")
SKINNY_DECLARE_STR2ID(skinny_str2device_reset_type, SKINNY_DEVICE_RESET_TYPES, -1) SKINNY_DECLARE_STR2ID(skinny_str2device_reset_type, SKINNY_DEVICE_RESET_TYPES, -1)

View File

@ -36,52 +36,52 @@
/* SKINNY TABLES */ /* SKINNY TABLES */
/*****************************************************************************/ /*****************************************************************************/
struct skinny_table { struct skinny_table {
const char *name; const char *name;
uint32_t id; uint32_t id;
}; };
#define SKINNY_DECLARE_ID2STR(func, TABLE, DEFAULT_STR) \ #define SKINNY_DECLARE_ID2STR(func, TABLE, DEFAULT_STR) \
const char *func(uint32_t id) \ const char *func(uint32_t id) \
{ \ { \
const char *str = DEFAULT_STR; \ const char *str = DEFAULT_STR; \
\ \
for (uint8_t x = 0; x < (sizeof(TABLE) / sizeof(struct skinny_table)) - 1; x++) {\ for (uint8_t x = 0; x < (sizeof(TABLE) / sizeof(struct skinny_table)) - 1; x++) {\
if (TABLE[x].id == id) {\ if (TABLE[x].id == id) {\
str = TABLE[x].name;\ str = TABLE[x].name;\
break;\ break;\
}\ }\
}\ }\
\ \
return str;\ return str;\
} }
#define SKINNY_DECLARE_STR2ID(func, TABLE, DEFAULT_ID) \ #define SKINNY_DECLARE_STR2ID(func, TABLE, DEFAULT_ID) \
uint32_t func(const char *str)\ uint32_t func(const char *str)\
{\ {\
uint32_t id = DEFAULT_ID;\ uint32_t id = DEFAULT_ID;\
\ \
if (*str > 47 && *str < 58) {\ if (*str > 47 && *str < 58) {\
id = atoi(str);\ id = atoi(str);\
} else {\ } else {\
for (uint8_t x = 0; x < (sizeof(TABLE) / sizeof(struct skinny_table)) - 1 && TABLE[x].name; x++) {\ for (uint8_t x = 0; x < (sizeof(TABLE) / sizeof(struct skinny_table)) - 1 && TABLE[x].name; x++) {\
if (!strcasecmp(TABLE[x].name, str)) {\ if (!strcasecmp(TABLE[x].name, str)) {\
id = TABLE[x].id;\ id = TABLE[x].id;\
break;\ break;\
}\ }\
}\ }\
}\ }\
return id;\ return id;\
} }
#define SKINNY_DECLARE_PUSH_MATCH(TABLE) \ #define SKINNY_DECLARE_PUSH_MATCH(TABLE) \
switch_console_callback_match_t *my_matches = NULL;\ switch_console_callback_match_t *my_matches = NULL;\
for (uint8_t x = 0; x < (sizeof(TABLE) / sizeof(struct skinny_table)) - 1; x++) {\ for (uint8_t x = 0; x < (sizeof(TABLE) / sizeof(struct skinny_table)) - 1; x++) {\
switch_console_push_match(&my_matches, TABLE[x].name);\ switch_console_push_match(&my_matches, TABLE[x].name);\
}\ }\
if (my_matches) {\ if (my_matches) {\
*matches = my_matches;\ *matches = my_matches;\
status = SWITCH_STATUS_SUCCESS;\ status = SWITCH_STATUS_SUCCESS;\
} }
struct skinny_table SKINNY_MESSAGE_TYPES[56]; struct skinny_table SKINNY_MESSAGE_TYPES[56];
@ -90,20 +90,20 @@ uint32_t skinny_str2message_type(const char *str);
#define SKINNY_PUSH_MESSAGE_TYPES SKINNY_DECLARE_PUSH_MATCH(SKINNY_MESSAGE_TYPES) #define SKINNY_PUSH_MESSAGE_TYPES SKINNY_DECLARE_PUSH_MATCH(SKINNY_MESSAGE_TYPES)
enum skinny_tone { enum skinny_tone {
SKINNY_TONE_SILENCE = 0x00, SKINNY_TONE_SILENCE = 0x00,
SKINNY_TONE_DIALTONE = 0x21, SKINNY_TONE_DIALTONE = 0x21,
SKINNY_TONE_BUSYTONE = 0x23, SKINNY_TONE_BUSYTONE = 0x23,
SKINNY_TONE_ALERT = 0x24, SKINNY_TONE_ALERT = 0x24,
SKINNY_TONE_REORDER = 0x25, SKINNY_TONE_REORDER = 0x25,
SKINNY_TONE_CALLWAITTONE = 0x2D, SKINNY_TONE_CALLWAITTONE = 0x2D,
SKINNY_TONE_NOTONE = 0x7F, SKINNY_TONE_NOTONE = 0x7F,
}; };
enum skinny_ring_type { enum skinny_ring_type {
SKINNY_RING_OFF = 1, SKINNY_RING_OFF = 1,
SKINNY_RING_INSIDE = 2, SKINNY_RING_INSIDE = 2,
SKINNY_RING_OUTSIDE = 3, SKINNY_RING_OUTSIDE = 3,
SKINNY_RING_FEATURE = 4 SKINNY_RING_FEATURE = 4
}; };
struct skinny_table SKINNY_RING_TYPES[5]; struct skinny_table SKINNY_RING_TYPES[5];
const char *skinny_ring_type2str(uint32_t id); const char *skinny_ring_type2str(uint32_t id);
@ -111,8 +111,8 @@ uint32_t skinny_str2ring_type(const char *str);
#define SKINNY_PUSH_RING_TYPES SKINNY_DECLARE_PUSH_MATCH(SKINNY_RING_TYPES) #define SKINNY_PUSH_RING_TYPES SKINNY_DECLARE_PUSH_MATCH(SKINNY_RING_TYPES)
enum skinny_ring_mode { enum skinny_ring_mode {
SKINNY_RING_FOREVER = 1, SKINNY_RING_FOREVER = 1,
SKINNY_RING_ONCE = 2, SKINNY_RING_ONCE = 2,
}; };
struct skinny_table SKINNY_RING_MODES[3]; struct skinny_table SKINNY_RING_MODES[3];
const char *skinny_ring_mode2str(uint32_t id); const char *skinny_ring_mode2str(uint32_t id);
@ -121,11 +121,11 @@ uint32_t skinny_str2ring_mode(const char *str);
enum skinny_lamp_mode { enum skinny_lamp_mode {
SKINNY_LAMP_OFF = 1, SKINNY_LAMP_OFF = 1,
SKINNY_LAMP_ON = 2, SKINNY_LAMP_ON = 2,
SKINNY_LAMP_WINK = 3, SKINNY_LAMP_WINK = 3,
SKINNY_LAMP_FLASH = 4, SKINNY_LAMP_FLASH = 4,
SKINNY_LAMP_BLINK = 5, SKINNY_LAMP_BLINK = 5,
}; };
struct skinny_table SKINNY_LAMP_MODES[6]; struct skinny_table SKINNY_LAMP_MODES[6];
const char *skinny_lamp_mode2str(uint32_t id); const char *skinny_lamp_mode2str(uint32_t id);
@ -133,8 +133,8 @@ uint32_t skinny_str2lamp_mode(const char *str);
#define SKINNY_PUSH_LAMP_MODES SKINNY_DECLARE_PUSH_MATCH(SKINNY_LAMP_MODES) #define SKINNY_PUSH_LAMP_MODES SKINNY_DECLARE_PUSH_MATCH(SKINNY_LAMP_MODES)
enum skinny_speaker_mode { enum skinny_speaker_mode {
SKINNY_SPEAKER_ON = 1, SKINNY_SPEAKER_ON = 1,
SKINNY_SPEAKER_OFF = 2, SKINNY_SPEAKER_OFF = 2,
}; };
struct skinny_table SKINNY_SPEAKER_MODES[3]; struct skinny_table SKINNY_SPEAKER_MODES[3];
const char *skinny_speaker_mode2str(uint32_t id); const char *skinny_speaker_mode2str(uint32_t id);
@ -142,20 +142,20 @@ uint32_t skinny_str2speaker_mode(const char *str);
#define SKINNY_PUSH_SPEAKER_MODES SKINNY_DECLARE_PUSH_MATCH(SKINNY_SPEAKER_MODES) #define SKINNY_PUSH_SPEAKER_MODES SKINNY_DECLARE_PUSH_MATCH(SKINNY_SPEAKER_MODES)
enum skinny_call_type { enum skinny_call_type {
SKINNY_INBOUND_CALL = 1, SKINNY_INBOUND_CALL = 1,
SKINNY_OUTBOUND_CALL = 2, SKINNY_OUTBOUND_CALL = 2,
SKINNY_FORWARD_CALL = 3, SKINNY_FORWARD_CALL = 3,
}; };
enum skinny_button_definition { enum skinny_button_definition {
SKINNY_BUTTON_UNKNOWN = 0x00, SKINNY_BUTTON_UNKNOWN = 0x00,
SKINNY_BUTTON_LAST_NUMBER_REDIAL = 0x01, SKINNY_BUTTON_LAST_NUMBER_REDIAL = 0x01,
SKINNY_BUTTON_SPEED_DIAL = 0x02, SKINNY_BUTTON_SPEED_DIAL = 0x02,
SKINNY_BUTTON_LINE = 0x09, SKINNY_BUTTON_LINE = 0x09,
SKINNY_BUTTON_VOICEMAIL = 0x0F, SKINNY_BUTTON_VOICEMAIL = 0x0F,
SKINNY_BUTTON_PRIVACY = 0x13, SKINNY_BUTTON_PRIVACY = 0x13,
SKINNY_BUTTON_SERVICE_URL = 0x14, SKINNY_BUTTON_SERVICE_URL = 0x14,
SKINNY_BUTTON_UNDEFINED = 0xFF, SKINNY_BUTTON_UNDEFINED = 0xFF,
}; };
struct skinny_table SKINNY_BUTTONS[9]; struct skinny_table SKINNY_BUTTONS[9];
const char *skinny_button2str(uint32_t id); const char *skinny_button2str(uint32_t id);
@ -163,39 +163,39 @@ uint32_t skinny_str2button(const char *str);
#define SKINNY_PUSH_STIMULI SKINNY_DECLARE_PUSH_MATCH(SKINNY_BUTTONS) #define SKINNY_PUSH_STIMULI SKINNY_DECLARE_PUSH_MATCH(SKINNY_BUTTONS)
enum skinny_soft_key_event { enum skinny_soft_key_event {
SOFTKEY_REDIAL = 0x01, SOFTKEY_REDIAL = 0x01,
SOFTKEY_NEWCALL = 0x02, SOFTKEY_NEWCALL = 0x02,
SOFTKEY_HOLD = 0x03, SOFTKEY_HOLD = 0x03,
SOFTKEY_TRANSFER = 0x04, SOFTKEY_TRANSFER = 0x04,
SOFTKEY_CFWDALL = 0x05, SOFTKEY_CFWDALL = 0x05,
SOFTKEY_CFWDBUSY = 0x06, SOFTKEY_CFWDBUSY = 0x06,
SOFTKEY_CFWDNOANSWER = 0x07, SOFTKEY_CFWDNOANSWER = 0x07,
SOFTKEY_BACKSPACE = 0x08, SOFTKEY_BACKSPACE = 0x08,
SOFTKEY_ENDCALL = 0x09, SOFTKEY_ENDCALL = 0x09,
SOFTKEY_RESUME = 0x0A, SOFTKEY_RESUME = 0x0A,
SOFTKEY_ANSWER = 0x0B, SOFTKEY_ANSWER = 0x0B,
SOFTKEY_INFO = 0x0C, SOFTKEY_INFO = 0x0C,
SOFTKEY_CONFRM = 0x0D, SOFTKEY_CONFRM = 0x0D,
SOFTKEY_PARK = 0x0E, SOFTKEY_PARK = 0x0E,
SOFTKEY_JOIN = 0x0F, SOFTKEY_JOIN = 0x0F,
SOFTKEY_MEETMECONFRM = 0x10, SOFTKEY_MEETMECONFRM = 0x10,
SOFTKEY_CALLPICKUP = 0x11, SOFTKEY_CALLPICKUP = 0x11,
SOFTKEY_GRPCALLPICKUP = 0x12, SOFTKEY_GRPCALLPICKUP = 0x12,
SOFTKEY_DND = 0x13, SOFTKEY_DND = 0x13,
SOFTKEY_IDIVERT = 0x14, SOFTKEY_IDIVERT = 0x14,
}; };
enum skinny_key_set { enum skinny_key_set {
SKINNY_KEY_SET_ON_HOOK = 0, SKINNY_KEY_SET_ON_HOOK = 0,
SKINNY_KEY_SET_CONNECTED = 1, SKINNY_KEY_SET_CONNECTED = 1,
SKINNY_KEY_SET_ON_HOLD = 2, SKINNY_KEY_SET_ON_HOLD = 2,
SKINNY_KEY_SET_RING_IN = 3, SKINNY_KEY_SET_RING_IN = 3,
SKINNY_KEY_SET_OFF_HOOK = 4, SKINNY_KEY_SET_OFF_HOOK = 4,
SKINNY_KEY_SET_CONNECTED_WITH_TRANSFER = 5, SKINNY_KEY_SET_CONNECTED_WITH_TRANSFER = 5,
SKINNY_KEY_SET_DIGITS_AFTER_DIALING_FIRST_DIGIT = 6, SKINNY_KEY_SET_DIGITS_AFTER_DIALING_FIRST_DIGIT = 6,
SKINNY_KEY_SET_CONNECTED_WITH_CONFERENCE = 7, SKINNY_KEY_SET_CONNECTED_WITH_CONFERENCE = 7,
SKINNY_KEY_SET_RING_OUT = 8, SKINNY_KEY_SET_RING_OUT = 8,
SKINNY_KEY_SET_OFF_HOOK_WITH_FEATURES = 9, SKINNY_KEY_SET_OFF_HOOK_WITH_FEATURES = 9,
}; };
struct skinny_table SKINNY_KEY_SETS[11]; struct skinny_table SKINNY_KEY_SETS[11];
const char *skinny_soft_key_set2str(uint32_t id); const char *skinny_soft_key_set2str(uint32_t id);
@ -204,20 +204,20 @@ uint32_t skinny_str2soft_key_set(const char *str);
enum skinny_call_state { enum skinny_call_state {
SKINNY_OFF_HOOK = 1, SKINNY_OFF_HOOK = 1,
SKINNY_ON_HOOK = 2, SKINNY_ON_HOOK = 2,
SKINNY_RING_OUT = 3, SKINNY_RING_OUT = 3,
SKINNY_RING_IN = 4, SKINNY_RING_IN = 4,
SKINNY_CONNECTED = 5, SKINNY_CONNECTED = 5,
SKINNY_BUSY = 6, SKINNY_BUSY = 6,
SKINNY_LINE_IN_USE = 7, SKINNY_LINE_IN_USE = 7,
SKINNY_HOLD = 8, SKINNY_HOLD = 8,
SKINNY_CALL_WAITING = 9, SKINNY_CALL_WAITING = 9,
SKINNY_CALL_TRANSFER = 10, SKINNY_CALL_TRANSFER = 10,
SKINNY_CALL_PARK = 11, SKINNY_CALL_PARK = 11,
SKINNY_PROCEED = 12, SKINNY_PROCEED = 12,
SKINNY_IN_USE_REMOTELY = 13, SKINNY_IN_USE_REMOTELY = 13,
SKINNY_INVALID_NUMBER = 14 SKINNY_INVALID_NUMBER = 14
}; };
struct skinny_table SKINNY_CALL_STATES[15]; struct skinny_table SKINNY_CALL_STATES[15];
const char *skinny_call_state2str(uint32_t id); const char *skinny_call_state2str(uint32_t id);