return skinny_endpoint_interface;
}
-static void skinny_profile_set(skinny_profile_t *profile, char *var, char *val)
+switch_status_t skinny_profile_set(skinny_profile_t *profile, const char *var, const char *val)
{
if (!var)
- return;
+ return SWITCH_STATUS_FALSE;
+
+ if (profile->sock && (!strcasecmp(var, "ip") || !strcasecmp(var, "port") || !strcasecmp(var, "odbc-dsn"))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "Skinny profile settings 'ip', 'port' and 'odbc-dsn' can't be changed while running\n");
+ return SWITCH_STATUS_FALSE;
+ }
if (!strcasecmp(var, "domain")) {
profile->domain = switch_core_strdup(profile->pool, val);
} else if (!strcasecmp(var, "ip")) {
profile->ip = switch_core_strdup(profile->pool, val);
- } else if (!strcasecmp(var, "dialplan")) {
- profile->dialplan = switch_core_strdup(profile->pool, val);
- } else if (!strcasecmp(var, "context")) {
- profile->context = switch_core_strdup(profile->pool, val);
+ } else if (!strcasecmp(var, "port")) {
+ profile->port = atoi(val);
} else if (!strcasecmp(var, "patterns-dialplan")) {
profile->patterns_dialplan = switch_core_strdup(profile->pool, val);
} else if (!strcasecmp(var, "patterns-context")) {
profile->patterns_context = switch_core_strdup(profile->pool, val);
+ } else if (!strcasecmp(var, "dialplan")) {
+ profile->dialplan = switch_core_strdup(profile->pool, val);
+ } else if (!strcasecmp(var, "context")) {
+ profile->context = switch_core_strdup(profile->pool, val);
+ } else if (!strcasecmp(var, "keep-alive")) {
+ profile->keep_alive = atoi(val);
} else if (!strcasecmp(var, "date-format")) {
strncpy(profile->date_format, val, 6);
- } else if (!strcasecmp(var, "odbc-dsn") && !zstr(val)) {
- if (switch_odbc_available()) {
- profile->odbc_dsn = switch_core_strdup(profile->pool, val);
- if ((profile->odbc_user = strchr(profile->odbc_dsn, ':'))) {
- *profile->odbc_user++ = '\0';
- if ((profile->odbc_pass = strchr(profile->odbc_user, ':'))) {
- *profile->odbc_pass++ = '\0';
+ } else if (!strcasecmp(var, "odbc-dsn")) {
+ if (!zstr(val)) {
+ if (switch_odbc_available()) {
+ profile->odbc_dsn = switch_core_strdup(profile->pool, val);
+ if ((profile->odbc_user = strchr(profile->odbc_dsn, ':'))) {
+ *profile->odbc_user++ = '\0';
+ if ((profile->odbc_pass = strchr(profile->odbc_user, ':'))) {
+ *profile->odbc_pass++ = '\0';
+ }
}
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
}
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
}
+ } else if (!strcasecmp(var, "debug")) {
+ profile->debug = atoi(val);
+ } else {
+ return SWITCH_STATUS_FALSE;
}
+ return SWITCH_STATUS_SUCCESS;
}
static switch_status_t load_skinny_config(void)
char *var = (char *) switch_xml_attr_soft(param, "name");
char *val = (char *) switch_xml_attr_soft(param, "value");
- if (!strcmp(var, "domain")) {
- skinny_profile_set(profile, "domain", val);
- } else if (!strcmp(var, "ip")) {
- skinny_profile_set(profile, "ip", val);
- } else if (!strcmp(var, "port")) {
- profile->port = atoi(val);
- } else if (!strcmp(var, "dialplan")) {
- skinny_profile_set(profile, "dialplan", val);
- } else if (!strcmp(var, "context")) {
- skinny_profile_set(profile, "context", val);
- } else if (!strcmp(var, "patterns-dialplan")) {
- skinny_profile_set(profile, "patterns-dialplan", val);
- } else if (!strcmp(var, "patterns-context")) {
- skinny_profile_set(profile, "patterns-context", val);
- } else if (!strcmp(var, "keep-alive")) {
- profile->keep_alive = atoi(val);
- } else if (!strcmp(var, "date-format")) {
- skinny_profile_set(profile, "date-format", val);
- } else if (!strcmp(var, "odbc-dsn")) {
- skinny_profile_set(profile, "odbc-dsn", val);
- } else if (!strcmp(var, "debug")) {
- profile->debug = atoi(val);
+ if (skinny_profile_set(profile, var, val) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+ "Unable to set skinny setting '%s'. Does it exists?\n", var);
}
} /* param */
/* MODULE FUNCTIONS */
/*****************************************************************************/
switch_endpoint_interface_t *skinny_get_endpoint_interface();
+switch_status_t skinny_profile_set(skinny_profile_t *profile, const char *var, const char *val);
#endif /* _MOD_SKINNY_H */
return status;
}
+static switch_status_t skinny_api_list_settings(const char *line, const char *cursor, switch_console_callback_match_t **matches)
+{
+ switch_status_t status = SWITCH_STATUS_FALSE;
+ switch_console_callback_match_t *my_matches = NULL;
+
+ switch_console_push_match(&my_matches, "domain");
+ switch_console_push_match(&my_matches, "ip");
+ switch_console_push_match(&my_matches, "port");
+ switch_console_push_match(&my_matches, "patterns-dialplan");
+ switch_console_push_match(&my_matches, "patterns-context");
+ switch_console_push_match(&my_matches, "dialplan");
+ switch_console_push_match(&my_matches, "context");
+ switch_console_push_match(&my_matches, "keep-alive");
+ switch_console_push_match(&my_matches, "date-format");
+ switch_console_push_match(&my_matches, "odbc-dsn");
+ switch_console_push_match(&my_matches, "debug");
+
+ if (my_matches) {
+ *matches = my_matches;
+ status = SWITCH_STATUS_SUCCESS;
+ }
+ return status;
+}
+
/*****************************************************************************/
/* skinny_api_cmd_* */
/*****************************************************************************/
return SWITCH_STATUS_SUCCESS;
}
+static switch_status_t skinny_api_cmd_profile_set(const char *profile_name, const char *name, const char *value, switch_stream_handle_t *stream)
+{
+ skinny_profile_t *profile;
+
+ if ((profile = skinny_find_profile(profile_name))) {
+ if (skinny_profile_set(profile, name, value) != SWITCH_STATUS_SUCCESS) {
+ stream->write_function(stream, "Unable to set skinny setting '%s'. Does it exists?\n", name);
+ }
+ } else {
+ stream->write_function(stream, "Profile not found!\n");
+ }
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
/*****************************************************************************/
/* API */
/*****************************************************************************/
"skinny profile <profile_name> device <device_name> send SetLampMessage <stimulus> <instance> <lamp_mode>\n"
"skinny profile <profile_name> device <device_name> send SetSpeakerModeMessage <speaker_mode>\n"
"skinny profile <profile_name> device <device_name> send CallStateMessage <call_state> <line_instance> <call_id>\n"
+ "skinny profile <profile_name> set <name> <value>\n"
"--------------------------------------------------------------------------------\n";
if (session) {
return SWITCH_STATUS_FALSE;
if (!strcasecmp(argv[0], "help")) {/* skinny help */
stream->write_function(stream, "%s", usage_string);
- goto done;
} else if (argc == 3 && !strcasecmp(argv[0], "status") && !strcasecmp(argv[1], "profile")) {
/* skinny status profile <profile_name> */
status = skinny_api_cmd_status_profile(argv[2], stream);
default:
stream->write_function(stream, "Unhandled message %s\n", argv[5]);
}
+ } else if (argc == 5 && !strcasecmp(argv[0], "profile") && !strcasecmp(argv[2], "set")) {
+ /* skinny profile <profile_name> set <name> <value> */
+ status = skinny_api_cmd_profile_set(argv[1], argv[3], argv[4], stream);
} else {
- stream->write_function(stream, "Unknown Command [%s]\n", argv[0]);
+ stream->write_function(stream, "%s", usage_string);
}
done:
switch_console_set_complete("add skinny profile ::skinny::list_profiles device ::skinny::list_devices send SetLampMessage ::skinny::list_stimuli ::skinny::list_stimulus_instances ::skinny::list_stimulus_modes");
switch_console_set_complete("add skinny profile ::skinny::list_profiles device ::skinny::list_devices send SetSpeakerModeMessage ::skinny::list_speaker_modes");
switch_console_set_complete("add skinny profile ::skinny::list_profiles device ::skinny::list_devices send CallStateMessage ::skinny::list_call_states ::skinny::list_line_instances ::skinny::list_call_ids");
+ switch_console_set_complete("add skinny profile ::skinny::list_profiles set ::skinny::list_settings");
switch_console_add_complete_func("::skinny::list_profiles", skinny_api_list_profiles);
switch_console_add_complete_func("::skinny::list_devices", skinny_api_list_devices);
switch_console_add_complete_func("::skinny::list_call_states", skinny_api_list_call_states);
switch_console_add_complete_func("::skinny::list_line_instances", skinny_api_list_line_instances);
switch_console_add_complete_func("::skinny::list_call_ids", skinny_api_list_call_ids);
+ switch_console_add_complete_func("::skinny::list_settings", skinny_api_list_settings);
return SWITCH_STATUS_SUCCESS;
}
ptr = (char *) reply;
if (listener_is_ready(listener)) {
- switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG,
- "Sending %s (type=%x,length=%d) to %s:%d.\n",
- skinny_message_type2str(reply->type), reply->type, reply->length,
- listener->device_name, listener->device_instance);
+ if (listener->profile->debug >= 10 || reply->type != KEEP_ALIVE_ACK_MESSAGE) {
+ switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG,
+ "Sending %s (type=%x,length=%d) to %s:%d.\n",
+ skinny_message_type2str(reply->type), reply->type, reply->length,
+ listener->device_name, listener->device_instance);
+ }
return switch_socket_send(listener->sock, ptr, &len);
} else {
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_WARNING,
switch_status_t skinny_handle_request(listener_t *listener, skinny_message_t *request)
{
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
- "Received %s (type=%x,length=%d) from %s:%d.\n", skinny_message_type2str(request->type), request->type, request->length,
- listener->device_name, listener->device_instance);
+ if (listener->profile->debug >= 10 || request->type != KEEP_ALIVE_MESSAGE) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+ "Received %s (type=%x,length=%d) from %s:%d.\n", skinny_message_type2str(request->type), request->type, request->length,
+ listener->device_name, listener->device_instance);
+ }
if(zstr(listener->device_name) && request->type != REGISTER_MESSAGE && request->type != ALARM_MESSAGE) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"Device should send a register message first.\n");