FS-9924: Removed extra space in source files

This commit is contained in:
Sergey Safarov committed 2017-02-09 23:59:49 -05:00
1 parent 60d4e87487
commit df1ab07ca4
455 files changed
+9699 -9698

No files matched your search

@@ -22,7 +22,7 @@
<!-- optional: if not present we do log the b leg -->
<!-- true or false if we should create a cdr for the b leg of a call-->
<param name="log-b-leg" value="false"/>
<!-- optional: if not present, all filenames are the uuid of the call -->
<!-- true or false if a leg files are prefixed "a_" -->
<param name="prefix-a-leg" value="true"/>
@@ -30,15 +30,15 @@
<!-- encode the post data may be 'true' for url encoding, 'false' for no encoding, 'base64' for base64 encoding or 'textxml' for text/xml -->
<param name="encode" value="true"/>
<!-- optional: set to true to disable Expect: 100-continue lighttpd requires this setting -->
<!--<param name="disable-100-continue" value="true"/>-->
<!-- optional: set to true to disable Expect: 100-continue lighttpd requires this setting -->
<!--<param name="disable-100-continue" value="true"/>-->
<!-- optional: full path to the error log dir for failed web posts if not specified its the same as log-dir -->
<!-- either an absolute path, a relative path assuming ${prefix}/logs or a blank or omitted value will default to ${prefix}/logs/xml_cdr -->
<!-- <param name="err-log-dir" value="/tmp"/> -->
<!-- which auhtentification scheme to use. Supported values are: basic, digest, NTLM, GSS-NEGOTIATE or "any" for automatic detection -->
<!--<param name="auth-scheme" value="basic"/>-->
<!--<param name="auth-scheme" value="basic"/>-->
<!-- optional: this will enable the CA root certificate check by libcurl to
verify that the certificate was issued by a major Certificate Authority.
+6 -6
View File
@@ -1,4 +1,4 @@
/*
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
@@ -22,7 +22,7 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Brian West <brian@freeswitch.org>
* Bret McDanel <trixter AT 0xdecafbad.com>
* Justin Cassidy <xachenant@hotmail.com>
@@ -79,7 +79,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_xml_cdr_load);
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_xml_cdr_shutdown);
SWITCH_MODULE_DEFINITION(mod_xml_cdr, mod_xml_cdr_load, mod_xml_cdr_shutdown, NULL);
/* this function would have access to the HTML returned by the webserver, we don't need it
/* this function would have access to the HTML returned by the webserver, we don't need it
* and the default curl activity is to print to stdout, something not as desirable
* so we have a dummy function here
*/
@@ -347,7 +347,7 @@ static switch_status_t my_on_reporting(switch_core_session_t *session)
if (globals.ssl_cacert_file) {
switch_curl_easy_setopt(curl_handle, CURLOPT_CAINFO, globals.ssl_cacert_file);
}
if (globals.cookie_file) {
switch_curl_easy_setopt(curl_handle, CURLOPT_COOKIEJAR, globals.cookie_file);
switch_curl_easy_setopt(curl_handle, CURLOPT_COOKIEFILE, globals.cookie_file);
@@ -622,7 +622,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_xml_cdr_load)
globals.cookie_file = switch_core_strdup(globals.pool, val);
}
}
if (zstr(globals.base_err_log_dir)) {
if (!zstr(globals.base_log_dir)) {
globals.base_err_log_dir = switch_core_strdup(globals.pool, globals.base_log_dir);
@@ -630,7 +630,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_xml_cdr_load)
globals.base_err_log_dir = switch_core_sprintf(globals.pool, "%s%sxml_cdr", SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR);
}
}
}
if (globals.retries && globals.delay == 0) {
+2 -2
View File
@@ -1,4 +1,4 @@
/*
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
@@ -22,7 +22,7 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Anthony Minessale II <anthm@freeswitch.org>
* Bret McDanel <trixter AT 0xdecafbad.com>
* Justin Cassidy <xachenant@hotmail.com>
+13 -13
View File
@@ -27,7 +27,7 @@
* Bret McDanel <trixter AT 0xdecafbad.com>
* Justin Cassidy <xachenant@hotmail.com>
* John Skopis <john+fs@skopis.com>
*
*
* mod_xml_ldap.c -- LDAP XML Gateway
*
*/
@@ -125,7 +125,7 @@ struct xml_ldap_attribute {
char *val;
xml_ldap_attribute_t *next;
};
SWITCH_MODULE_LOAD_FUNCTION(mod_xml_ldap_load);
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_xml_ldap_shutdown);
SWITCH_MODULE_DEFINITION(mod_xml_ldap, mod_xml_ldap_load, mod_xml_ldap_shutdown, NULL);
@@ -145,7 +145,7 @@ SWITCH_STANDARD_API(xml_ldap_function)
{
return SWITCH_STATUS_FALSE;
}
SWITCH_MODULE_LOAD_FUNCTION(mod_xml_ldap_load)
{
switch_api_interface_t *xml_ldap_api_interface;
@@ -495,13 +495,13 @@ static switch_status_t trydir(switch_xml_t *pxml, int *xoff, LDAP * ld, char *di
"vm-skip-instructions", "vm-cc", "vm-disk-quota", "accountcode", "user_context",
"vm_mailbox", "callgroup", "effective_caller_id_number", "effective_caller_id_name",
"outbound_caller_id_number", "outbound_caller_id_name", "toll_allow", NULL };
basedn = switch_mprintf(binding->basedn, dir_domain);
filter = switch_mprintf(binding->filter, dir_exten);
if (param_event) {
char *expanded = switch_event_expand_headers(param_event, filter);
if (expanded != filter) {
free(filter);
filter = expanded;
@@ -509,7 +509,7 @@ static switch_status_t trydir(switch_xml_t *pxml, int *xoff, LDAP * ld, char *di
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "searching in basedn %s with filter %s\n", basedn, filter);
if ((ldap_search_s(ld, basedn, LDAP_SCOPE_SUB, filter, NULL, 0, &msg) != LDAP_SUCCESS))
goto cleanup;
@@ -614,15 +614,15 @@ static switch_status_t trysearch(switch_xml_t *pxml, int *xoff, LDAP * ld, char
val = ldap_get_values(ld, entry, key);
switch_xml_set_attr_d(xml, key, val[0]);
ldap_memfree(key);
ldap_value_free(val);
}
ber_free(ber, 0);
dn = ldap_get_dn(ld, entry);
rec(&xml, &off, ld, dn);
*xoff = 1;
}
@@ -661,7 +661,7 @@ void rec(switch_xml_t *pxml, int *xoff, LDAP * ld, char *dn)
ldap_value_free(val);
for (key = ldap_first_attribute(ld, entry, &ber); key != NULL; key = ldap_next_attribute(ld, entry, ber)) {
if (!strncasecmp("fstag", key, 5) || !strncasecmp("objectclass", key, 10)) {
ldap_memfree(key);
continue;
@@ -713,7 +713,7 @@ static switch_xml_t xml_ldap_search(const char *section, const char *tag_name, c
switch (binding->bt) {
case XML_LDAP_CONFIG:
break;
case XML_LDAP_DIRECTORY:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "from cb got %s=%s\n", hi->name, hi->value);
if (!strncmp(hi->name, "user", strlen(hi->name))) {
@@ -722,7 +722,7 @@ static switch_xml_t xml_ldap_search(const char *section, const char *tag_name, c
dir_domain = strdup(hi->value);
}
break;
case XML_LDAP_DIALPLAN:
case XML_LDAP_PHRASE:
break;
@@ -8,7 +8,7 @@
<extension name="rejections">
<condition field="${radius_auth_result}" expression="^2$">
<action application="hangup" data="CALL_REJECTED"/>
<action application="hangup" data="CALL_REJECTED"/>
</condition>
</extension>
+152 -152
View File
@@ -1,4 +1,4 @@
/*
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
@@ -22,7 +22,7 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* William King <william.king@quentustech.com>
*
* mod_xml_radius.c -- Radius authentication and authorization
@@ -75,31 +75,31 @@ switch_status_t mod_xml_radius_new_handle(rc_handle **new_handle, switch_xml_t x
*new_handle = NULL;
goto err;
}
if (rc_add_config(*new_handle, "auth_order", "radius", "mod_radius_cdr.c", 0) != 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error adding auth_order\n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error adding auth_order\n");
goto err;
}
if ((server = switch_xml_child(xml, "connection")) == NULL ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'connection' section in config file.\n");
goto err;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'connection' section in config file.\n");
goto err;
}
for (param = switch_xml_child(server, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr_soft(param, "name");
char *val = (char *) switch_xml_attr_soft(param, "value");
if ( GLOBAL_DEBUG ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Attempting to add param '%s' with value '%s' \n", var, val);
}
if (strncmp(var, "dictionary", 10) == 0) {
if ( rc_read_dictionary(*new_handle, val) != 0) {
goto err;
}
} else if (rc_add_config(*new_handle, var, val, "mod_xml_radius", 0) != 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error adding param '%s' with value '%s' \n", var, val);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error adding param '%s' with value '%s' \n", var, val);
goto err;
}
}
@@ -114,7 +114,7 @@ switch_status_t mod_xml_radius_new_handle(rc_handle **new_handle, switch_xml_t x
return SWITCH_STATUS_GENERR;
}
switch_status_t do_config()
switch_status_t do_config()
{
char *conf = "xml_radius.conf";
switch_xml_t xml, cfg, tmp, server, param;
@@ -155,7 +155,7 @@ switch_status_t do_config()
seq = 1;
}
}
if ( serv && timeout && deadtime && retries && dict && seq ) {
globals.auth_invite_configs = tmp;
} else {
@@ -165,11 +165,11 @@ switch_status_t do_config()
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'connection' section for auth_invite\n");
goto err;
}
}
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Could not find 'auth_invite' section in config file.\n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Could not find 'auth_invite' section in config file.\n");
}
serv = timeout = deadtime = retries = dict = seq = 0;
if ((tmp = switch_xml_dup(switch_xml_child(cfg, "auth_reg"))) != NULL ) {
if ( (server = switch_xml_child(tmp, "connection")) != NULL) {
@@ -189,7 +189,7 @@ switch_status_t do_config()
seq = 1;
}
}
if ( serv && timeout && deadtime && retries && dict && seq ) {
globals.auth_reg_configs = tmp;
} else {
@@ -199,9 +199,9 @@ switch_status_t do_config()
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'connection' section for auth_invite\n");
goto err;
}
}
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Could not find 'auth_reg' section in config file.\n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Could not find 'auth_reg' section in config file.\n");
}
if ((tmp = switch_xml_child(cfg, "global")) != NULL ) {
@@ -242,7 +242,7 @@ switch_status_t do_config()
seq = 1;
}
}
if ( serv && timeout && deadtime && retries && dict && seq ) {
globals.auth_app_configs = tmp;
} else {
@@ -252,11 +252,11 @@ switch_status_t do_config()
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'connection' section for auth_app\n");
goto err;
}
}
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Could not find 'auth_app' section in config file.\n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Could not find 'auth_app' section in config file.\n");
}
serv = timeout = deadtime = retries = dict = seq = 0;
if (( tmp = switch_xml_dup(switch_xml_child(cfg, "acct_start"))) != NULL ) {
if ( (server = switch_xml_child(tmp, "connection")) != NULL) {
@@ -276,7 +276,7 @@ switch_status_t do_config()
seq = 1;
}
}
if ( serv && timeout && deadtime && retries && dict && seq ) {
globals.acct_start_configs = tmp;
} else {
@@ -286,11 +286,11 @@ switch_status_t do_config()
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'connection' section for acct_start\n");
goto err;
}
}
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Could not find 'acct_start' section in config file.\n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Could not find 'acct_start' section in config file.\n");
}
serv = timeout = deadtime = retries = dict = seq = 0;
if (( tmp = switch_xml_dup(switch_xml_child(cfg, "acct_end"))) != NULL ) {
if ( (server = switch_xml_child(tmp, "connection")) != NULL) {
@@ -310,7 +310,7 @@ switch_status_t do_config()
seq = 1;
}
}
if ( serv && timeout && deadtime && retries && dict && seq ) {
globals.acct_end_configs = tmp;
} else {
@@ -320,43 +320,43 @@ switch_status_t do_config()
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'connection' section for acct_end\n");
goto err;
}
}
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Could not find 'acct_end' section in config file.\n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Could not find 'acct_end' section in config file.\n");
}
if ( xml ) {
switch_xml_free(xml);
xml = NULL;
}
return SWITCH_STATUS_SUCCESS;
err:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: Configuration error\n");
if ( xml ) {
switch_xml_free(xml);
xml = NULL;
}
return SWITCH_STATUS_GENERR;
}
switch_status_t mod_xml_radius_add_params(switch_core_session_t *session, switch_event_t *params, rc_handle *handle, VALUE_PAIR **send, switch_xml_t fields)
switch_status_t mod_xml_radius_add_params(switch_core_session_t *session, switch_event_t *params, rc_handle *handle, VALUE_PAIR **send, switch_xml_t fields)
{
switch_xml_t param;
void *av_value = NULL;
if ( (param = switch_xml_child(fields, "param")) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to locate a param under the fields section\n");
goto err;
goto err;
}
for (; param; param = param->next) {
DICT_ATTR *attribute = NULL;
DICT_VENDOR *vendor = NULL;
int attr_num = 0, vend_num = 0;
char *var = (char *) switch_xml_attr(param, "name");
char *vend = (char *) switch_xml_attr(param, "vendor");
char *variable = (char *) switch_xml_attr(param, "variable");
@@ -368,55 +368,55 @@ switch_status_t mod_xml_radius_add_params(switch_core_session_t *session, switch
char *regex = (char *) switch_xml_attr(param, "regex");
attribute = rc_dict_findattr(handle, var);
if ( attribute == NULL ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: Could not locate attribute '%s' in the configured dictionary\n", var);
goto err;
}
if ( GLOBAL_DEBUG ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: dict attr '%s' value '%d' type '%d'\n",
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: dict attr '%s' value '%d' type '%d'\n",
attribute->name, attribute->value, attribute->type);
}
attr_num = attribute->value;
if ( vend ) {
vendor = rc_dict_findvend(handle, vend);
if ( vendor == NULL ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: Could not locate vendor '%s' in the configured dictionary %p\n",
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: Could not locate vendor '%s' in the configured dictionary %p\n",
vend, vend);
goto err;
}
}
if ( GLOBAL_DEBUG ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: dict vend name '%s' vendorpec '%d'\n",
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: dict vend name '%s' vendorpec '%d'\n",
vendor->vendorname, vendor->vendorpec);
}
vend_num = vendor->vendorpec;
}
}
if ( var ) {
if ( session ) {
switch_channel_t *channel = switch_core_session_get_channel(session);
if ( skip_if_set && switch_channel_get_variable(channel, skip_if_set) ) {
goto end_loop;
}
/* Accounting only */
if ( strncmp( var, "h323-setup-time", 15) == 0 ) {
switch_caller_profile_t *profile = switch_channel_get_caller_profile(channel);
switch_time_t time = profile->times->created;
switch_time_exp_t tm;
if ( !time ) {
goto end_loop;
}
switch_time_exp_lt(&tm, time);
if ( GLOBAL_TIME_FORMAT == 1 ) {
av_value = switch_mprintf("%02u:%02u:%02u.%03u %s %s %s %02u %04u",
tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_usec/1000,
@@ -432,7 +432,7 @@ switch_status_t mod_xml_radius_add_params(switch_core_session_t *session, switch
if (rc_avpair_add(handle, send, attr_num, av_value, -1, vend_num) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: failed to add option to handle\n");
goto err;
}
}
if ( GLOBAL_DEBUG ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: value: %s\n", (char *) av_value);
}
@@ -444,7 +444,7 @@ switch_status_t mod_xml_radius_add_params(switch_core_session_t *session, switch
if ( !time ) {
goto end_loop;
}
switch_time_exp_lt(&tm, time);
if ( GLOBAL_TIME_FORMAT == 1 ) {
@@ -462,7 +462,7 @@ switch_status_t mod_xml_radius_add_params(switch_core_session_t *session, switch
if (rc_avpair_add(handle, send, attr_num, av_value, -1, vend_num) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: failed to add option to handle\n");
goto err;
}
}
if ( GLOBAL_DEBUG ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: value: %s\n", (char *) av_value);
}
@@ -478,7 +478,7 @@ switch_status_t mod_xml_radius_add_params(switch_core_session_t *session, switch
goto end_loop;
}
}
switch_time_exp_lt(&tm, time);
if ( GLOBAL_TIME_FORMAT == 1 ) {
@@ -496,7 +496,7 @@ switch_status_t mod_xml_radius_add_params(switch_core_session_t *session, switch
if (rc_avpair_add(handle, send, attr_num, av_value, -1, vend_num) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: failed to add option to handle\n");
goto err;
}
}
if ( GLOBAL_DEBUG ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: value: %s\n", (char *) av_value);
}
@@ -506,8 +506,8 @@ switch_status_t mod_xml_radius_add_params(switch_core_session_t *session, switch
if (rc_avpair_add(handle, send, 30, av_value, -1, 9) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: failed to add disconnect cause \n");
goto err;
}
}
} else {
if ( format == NULL ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing format attribute for %s variable\n", variable);
@@ -516,7 +516,7 @@ switch_status_t mod_xml_radius_add_params(switch_core_session_t *session, switch
if ( attribute->type == 0 ) {
const char *val = NULL;
if ( other_leg ) {
val = switch_channel_get_variable_partner(channel, variable);
if ( val == NULL && variable_secondary != NULL) {
@@ -528,7 +528,7 @@ switch_status_t mod_xml_radius_add_params(switch_core_session_t *session, switch
val = switch_channel_get_variable(channel, variable_secondary);
}
}
if ( regex && val ) {
switch_regex_t *re = NULL;
int ovector[30];
@@ -546,37 +546,37 @@ switch_status_t mod_xml_radius_add_params(switch_core_session_t *session, switch
}
switch_regex_safe_free(re);
}
if ( val == NULL && val_default != NULL) {
av_value = switch_mprintf(format, val_default);
av_value = switch_mprintf(format, val_default);
} else {
av_value = switch_mprintf(format, val);
}
if ( GLOBAL_DEBUG ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: value: %s\n", (char *) av_value);
}
if (rc_avpair_add(handle, send, attr_num, av_value, -1, vend_num) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"mod_xml_radius: failed to add option with val '%s' to handle\n", (char *) av_value);
goto err;
}
}
} else if ( attribute->type == 1 ) {
const char *data = switch_channel_get_variable(channel, variable);
int number = 0;
if ( data ) {
number = atoi(data);
}
if (rc_avpair_add(handle, send, attr_num, &number, -1, vend_num) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"mod_xml_radius: failed to add option with value '%d' to handle\n", number);
goto err;
}
}
}
}
}
} else if ( params ) {
/* Auth only */
char *tmp = switch_event_get_header(params, variable);
@@ -584,17 +584,17 @@ switch_status_t mod_xml_radius_add_params(switch_core_session_t *session, switch
if ( GLOBAL_DEBUG ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: param var '%s' val: %s\n", variable, tmp);
}
if ( tmp == NULL ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: Unable to locate '%s' on the event\n", variable);
goto err;
goto err;
}
av_value = switch_mprintf(format, tmp);
if (rc_avpair_add(handle, send, attr_num, av_value, -1, vend_num) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: failed to add option to handle\n");
goto err;
}
}
} else {
goto err;
}
@@ -609,7 +609,7 @@ switch_status_t mod_xml_radius_add_params(switch_core_session_t *session, switch
av_value = NULL;
}
}
return SWITCH_STATUS_SUCCESS;
err:
if ( av_value != NULL ) {
@@ -617,7 +617,7 @@ switch_status_t mod_xml_radius_add_params(switch_core_session_t *session, switch
av_value = NULL;
}
return SWITCH_STATUS_GENERR;
}
/* static switch_status_t name (_In_opt_z_ const char *cmd, _In_opt_ switch_core_session_t *session, _In_ switch_stream_handle_t *stream) */
@@ -647,37 +647,37 @@ switch_xml_t mod_xml_radius_auth_invite(switch_event_t *params) {
if (GLOBAL_DEBUG ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: starting invite authentication\n");
}
if ( mod_xml_radius_new_handle(&new_handle, globals.auth_invite_configs) != SWITCH_STATUS_SUCCESS ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to load radius handle for digest invite authentication\n");
goto err;
goto err;
}
if ( new_handle == NULL ) {
goto err;
}
if ((fields = switch_xml_child(globals.auth_invite_configs, "fields")) == NULL ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'fields' section in config file.\n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'fields' section in config file.\n");
goto err;
}
if ( mod_xml_radius_add_params(NULL, params, new_handle, &send, fields) != SWITCH_STATUS_SUCCESS ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to add params to rc_handle\n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to add params to rc_handle\n");
goto err;
}
if (rc_avpair_add(new_handle, &send, PW_SERVICE_TYPE, &service, -1, 0) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: failed to add option to handle\n");
goto err;
}
result = rc_auth(new_handle, 0, send, &recv, msg);
if ( GLOBAL_DEBUG ){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: result(RC=%d) %s \n", result, msg);
}
if ( result != 0 ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: Failed to authenticate\n");
goto err;
@@ -691,9 +691,9 @@ switch_xml_t mod_xml_radius_auth_invite(switch_event_t *params) {
switch_xml_set_attr_d(dom, "name", switch_event_get_header(params, "domain"));
usr = switch_xml_add_child_d(dom, "user", 0);
vars = switch_xml_add_child_d(usr, "variables", 0);
switch_xml_set_attr_d(usr, "id", switch_event_get_header(params, "user"));
var = switch_xml_add_child_d(vars, "variable", param_idx++);
switch_xml_set_attr_d(var, "name", "radius_auth_result");
switch_xml_set_attr_d(var, "value", "0");
@@ -716,7 +716,7 @@ switch_xml_t mod_xml_radius_auth_invite(switch_event_t *params) {
if ( GLOBAL_DEBUG ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "XML: %s \n", switch_xml_toxml(xml, 1));
}
if ( recv ) {
rc_avpair_free(recv);
recv = NULL;
@@ -743,7 +743,7 @@ switch_xml_t mod_xml_radius_auth_invite(switch_event_t *params) {
rc_destroy(new_handle);
new_handle = NULL;
}
return NULL;
}
@@ -759,37 +759,37 @@ switch_xml_t mod_xml_radius_auth_reg(switch_event_t *params) {
if (GLOBAL_DEBUG ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: starting registration authentication\n");
}
if ( mod_xml_radius_new_handle(&new_handle, globals.auth_reg_configs) != SWITCH_STATUS_SUCCESS ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to load radius handle for registration authentication\n");
goto err;
goto err;
}
if ( new_handle == NULL ) {
goto err;
}
if ((fields = switch_xml_child(globals.auth_reg_configs, "fields")) == NULL ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'fields' section in config file.\n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'fields' section in config file.\n");
goto err;
}
if ( mod_xml_radius_add_params(NULL, params, new_handle, &send, fields) != SWITCH_STATUS_SUCCESS ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to add params to rc_handle\n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to add params to rc_handle\n");
goto err;
}
if (rc_avpair_add(new_handle, &send, PW_SERVICE_TYPE, &service, -1, 0) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: failed to add option to handle\n");
goto err;
}
result = rc_auth(new_handle, 0, send, &recv, msg);
if ( GLOBAL_DEBUG ){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: result(RC=%d) %s \n", result, msg);
}
if ( result != 0 ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: Failed to authenticate\n");
goto err;
@@ -803,9 +803,9 @@ switch_xml_t mod_xml_radius_auth_reg(switch_event_t *params) {
switch_xml_set_attr_d(dom, "name", switch_event_get_header(params, "domain"));
usr = switch_xml_add_child_d(dom, "user", 0);
vars = switch_xml_add_child_d(usr, "variables", 0);
switch_xml_set_attr_d(usr, "id", switch_event_get_header(params, "user"));
service_vp = recv;
while (service_vp != NULL) {
rc_avpair_tostr(new_handle, service_vp, name, 512, value, 512);
@@ -824,7 +824,7 @@ switch_xml_t mod_xml_radius_auth_reg(switch_event_t *params) {
if ( GLOBAL_DEBUG ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "XML: %s \n", switch_xml_toxml(xml, 1));
}
if ( recv ) {
rc_avpair_free(recv);
recv = NULL;
@@ -852,30 +852,30 @@ switch_xml_t mod_xml_radius_auth_reg(switch_event_t *params) {
rc_destroy(new_handle);
new_handle = NULL;
}
return NULL;
}
static switch_xml_t mod_xml_radius_directory_search(const char *section, const char *tag_name, const char *key_name, const char *key_value,
static switch_xml_t mod_xml_radius_directory_search(const char *section, const char *tag_name, const char *key_name, const char *key_value,
switch_event_t *params, void *user_data)
{
char *event_buf = NULL;
switch_xml_t xml = NULL;
char *auth_method = switch_event_get_header(params,"sip_auth_method");
if ( GLOBAL_DEBUG ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: starting authentication\n");
switch_event_serialize(params, &event_buf, SWITCH_TRUE);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Event: %s \n", event_buf);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "\nSection: %s \nTag: %s\nKey_name: %s\nKey_value: %s\n",
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "\nSection: %s \nTag: %s\nKey_name: %s\nKey_value: %s\n",
section, tag_name, key_name, key_value);
}
if ( auth_method == NULL) {
return NULL;
}
if ( strncmp( "INVITE", auth_method, 6) == 0) {
xml = mod_xml_radius_auth_invite(params);
} else if ( strncmp( "REGISTER", auth_method, 8) == 0) {
@@ -895,32 +895,32 @@ switch_status_t mod_xml_radius_check_conditions(switch_channel_t *channel, switc
char *anti = NULL;
int all_matched = 1;
int result = 0;
if ( (condition = switch_xml_child(conditions, "condition")) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to locate a condition under the conditions section\n");
return SWITCH_STATUS_FALSE;
}
for (; condition; condition = condition->next) {
if ( (param = switch_xml_child(condition, "param")) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to locate a param under this condition\n");
return SWITCH_STATUS_FALSE;
}
all_matched = 1;
for (; param && all_matched; param = param->next) {
channel_var = (char *) switch_xml_attr(param, "var");
regex = (char *) switch_xml_attr(param, "regex");
anti = (char *) switch_xml_attr(param, "anti");
if ( channel_var == NULL || regex == NULL ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Improperly constructed mod_radius condition: %s %s\n", channel_var, regex);
continue;
}
if ( ( channel_val = switch_channel_get_variable(channel, channel_var) ) == NULL ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"Improperly constructed mod_radius condition, no such channel variable: %s %s\n", channel_var, regex);
continue;
}
@@ -930,7 +930,7 @@ switch_status_t mod_xml_radius_check_conditions(switch_channel_t *channel, switc
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Didn't match: %s == %s \n", switch_channel_get_variable(channel, channel_var), regex);
all_matched = 0;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Result of %s match: %s == %s \n",
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Result of %s match: %s == %s \n",
anti, switch_channel_get_variable(channel, channel_var), regex);
}
}
@@ -939,7 +939,7 @@ switch_status_t mod_xml_radius_check_conditions(switch_channel_t *channel, switc
return SWITCH_STATUS_SUCCESS;
}
}
return SWITCH_STATUS_FALSE;
}
@@ -960,27 +960,27 @@ switch_status_t mod_xml_radius_accounting_start(switch_core_session_t *session){
mod_xml_radius_check_conditions(channel, conditions) != SWITCH_STATUS_SUCCESS ) {
goto end;
}
if ( mod_xml_radius_new_handle(&new_handle, globals.acct_start_configs) != SWITCH_STATUS_SUCCESS || new_handle == NULL ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create new accounting_start handle for call: %s\n",
switch_channel_get_variable(channel, "uuid"));
goto end;
goto end;
}
if ((fields = switch_xml_child(globals.acct_start_configs, "fields")) == NULL ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'fields' section in config file.\n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'fields' section in config file.\n");
goto end;
}
if ( mod_xml_radius_add_params(session, NULL, new_handle, &send, fields) != SWITCH_STATUS_SUCCESS ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to add params to rc_handle\n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to add params to rc_handle\n");
goto end;
}
if (rc_avpair_add(new_handle, &send, PW_ACCT_STATUS_TYPE, &service, -1, 0) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: failed to add option to handle\n");
goto end;
}
}
if (rc_acct(new_handle, 0, send) == OK_RC) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "mod_xml_radius: Accounting Start success\n");
@@ -1007,38 +1007,38 @@ switch_status_t mod_xml_radius_accounting_end(switch_core_session_t *session){
rc_handle *new_handle = NULL;
switch_xml_t fields = NULL, conditions = NULL;
switch_channel_t *channel = switch_core_session_get_channel(session);
if (GLOBAL_DEBUG ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: starting accounting stop\n");
switch_core_session_execute_application(session, "info", NULL);
}
/* If there are conditions defined, and none of them pass, then skip this accounting */
if ((conditions = switch_xml_child(globals.acct_end_configs, "conditions")) != NULL &&
mod_xml_radius_check_conditions(channel, conditions) != SWITCH_STATUS_SUCCESS ) {
goto end;
}
if ( mod_xml_radius_new_handle(&new_handle, globals.acct_end_configs) != SWITCH_STATUS_SUCCESS || new_handle == NULL ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create new accounting_end handle for call: %s\n",
switch_channel_get_variable(channel, "uuid"));
goto end;
goto end;
}
if ((fields = switch_xml_child(globals.acct_end_configs, "fields")) == NULL ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'fields' section in config file.\n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'fields' section in config file.\n");
goto end;
}
if ( mod_xml_radius_add_params(session, NULL, new_handle, &send, fields) != SWITCH_STATUS_SUCCESS ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to add params to rc_handle\n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to add params to rc_handle\n");
goto end;
}
if (rc_avpair_add(new_handle, &send, PW_ACCT_STATUS_TYPE, &service, -1, 0) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: failed to add option to handle\n");
goto end;
}
}
if (rc_acct(new_handle, 0, send) == OK_RC) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "mod_xml_radius: Accounting Stop success\n");
@@ -1055,7 +1055,7 @@ switch_status_t mod_xml_radius_accounting_end(switch_core_session_t *session){
rc_destroy(new_handle);
new_handle = NULL;
}
return SWITCH_STATUS_SUCCESS;
}
@@ -1079,28 +1079,28 @@ SWITCH_STANDARD_APP(radius_auth_handle)
switch_channel_get_variable(channel, "uuid"));
goto err;
}
if ((fields = switch_xml_child(globals.auth_app_configs, "fields")) == NULL ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'fields' section in config file.\n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'fields' section in config file.\n");
goto err;
}
if ( mod_xml_radius_add_params(session, NULL, new_handle, &send, fields) != SWITCH_STATUS_SUCCESS ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to add params to rc_handle\n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to add params to rc_handle\n");
goto err;
}
if (rc_avpair_add(new_handle, &send, PW_SERVICE_TYPE, &service, -1, 0) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: failed to add option to handle\n");
goto err;
}
result = rc_auth(new_handle, 0, send, &recv, msg);
if ( GLOBAL_DEBUG ){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: result(RC=%d) %s \n", result, msg);
}
temp = switch_mprintf("%d",result);
temp = switch_mprintf("%d",result);
switch_channel_set_variable(channel, "radius_auth_result", temp);
free(temp);
temp = NULL;
@@ -1133,7 +1133,7 @@ SWITCH_STANDARD_APP(radius_auth_handle)
rc_destroy(new_handle);
new_handle = NULL;
}
return;
err:
if ( recv ) {
@@ -1175,7 +1175,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_xml_radius_load)
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
memset(&globals, 0, sizeof(globals));
globals.pool = pool;
@@ -1187,17 +1187,17 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_xml_radius_load)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: Failed to load configs\n");
return SWITCH_STATUS_TERM;
}
if ( globals.auth_invite_configs && globals.auth_reg_configs ) {
status = switch_xml_bind_search_function(mod_xml_radius_directory_search, switch_xml_parse_section_string("directory"), NULL);
}
SWITCH_ADD_API(mod_xml_radius_api_interface, "xml_radius_debug", "mod_xml_radius toggle debug", mod_xml_radius_debug_api, NULL);
switch_core_add_state_handler(&state_handlers);
SWITCH_ADD_APP(app_interface, "radius_auth", NULL, NULL, radius_auth_handle, "radius_auth", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
@@ -1,12 +1,12 @@
<configuration name="xml_radius.conf" description="Radius XML Gateway">
<!--
auth_invite is only called when a directory lookup is done on an inbound invite. Usually that means a digest auth challenge on the invite.
auth_reg is only called on the actual registration.
auth_reg is only called on the actual registration.
auth_app is used when an invite is in the dialplan. If your profile requires digest auth then this isn't needed.
but if your profile is doing only ip authentication this allows you to authenticate the call without the need for digest auth.
acct_start happens when the call goes into the state 'routing' which means it is starting the dialplan
-->
<auth_invite>
@@ -29,13 +29,13 @@
<param name="Digest-Response" variable="sip_auth_response" format="%s"/>
<param name="Digest-Realm" variable="sip_auth_realm" format="%s"/>
<param name="Digest-Nonce" variable="sip_auth_nonce" format="%s"/>
<param name="Digest-Username" variable="sip_auth_username" format="%s"/>
<param name="Digest-Username" variable="sip_auth_username" format="%s"/>
<param name="Digest-URI" variable="sip_auth_uri" format="%s"/>
<param name="Digest-Method" variable="sip_auth_method" format="%s"/>
<param name="Digest-Algorithm" variable="sip_auth_method" format="MD5"/>
<param name="Digest-Qop" variable="sip_auth_qop" format="%s"/>
<param name="Digest-CNonce" variable="sip_auth_cnonce" format="%s"/>
<param name="Digest-Nonce-Count" variable="sip_auth_nc" format="%s"/>
<param name="Digest-Nonce-Count" variable="sip_auth_nc" format="%s"/>
</fields>
</auth_invite>
<auth_reg>
@@ -93,7 +93,7 @@
<param name="dictionary" value="/usr/share/freeradius/dictionary.cisco"/>
<param name="seqfile" value="/var/run/radius.seq"/>
</connection>
<fields>
<fields>
</fields>
</auth_reg>
<acct_start>
@@ -114,7 +114,7 @@
<param vendor="Cisco" name="Cisco-AVPair" variable="sip_from_user" variable_secondary="ani" format="src-number-in=%s" />
<param vendor="Cisco" name="Cisco-AVPair" variable="sip_from_user" variable_secondary="ani" format="src-number-out=%s" />
<param name="Calling-Station-Id" variable="sip_from_user" variable_secondary="ani" format="%s"/>
<param vendor="Cisco" name="Cisco-AVPair" variable="sip_to_host" format="dst-gw-ip=%s"/>
<param vendor="Cisco" name="Cisco-AVPair" variable="sip_to_host" format="dst-gw-ip=%s"/>
<param vendor="Cisco" name="Cisco-AVPair" variable="destination_number" format="dst-gw-name=%s"/>
<param vendor="Cisco" name="Cisco-AVPair" variable="destination_number" format="dst-number-in=%s" />
<param vendor="Cisco" name="Cisco-AVPair" variable="destination_number" format="dst-number-out=%s" />
@@ -146,7 +146,7 @@
<param vendor="Cisco" name="Cisco-AVPair" variable="sip_from_user" variable_secondary="ani" format="src-number-in=%s" />
<param vendor="Cisco" name="Cisco-AVPair" variable="sip_from_user" variable_secondary="ani" format="src-number-out=%s" />
<param name="Calling-Station-Id" variable="sip_from_user" variable_secondary="ani" format="%s"/>
<param vendor="Cisco" name="Cisco-AVPair" variable="sip_to_host" format="dst-gw-ip=%s"/>
<param vendor="Cisco" name="Cisco-AVPair" variable="sip_to_host" format="dst-gw-ip=%s"/>
<param vendor="Cisco" name="Cisco-AVPair" variable="sip_to_user" variable_secondary="dialed_extension" format="dst-gw-name=%s"/>
<param vendor="Cisco" name="Cisco-AVPair" variable="sip_to_user" variable_secondary="dialed_extension" format="dst-number-in=%s" />
<param name="Called-Station-Id" variable="destination_number" format="%s"/>
+3 -3
View File
@@ -165,7 +165,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_xml_rpc_load)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", "websocket::stophook");
return SWITCH_STATUS_TERM;
}
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
@@ -1077,7 +1077,7 @@ abyss_bool handler_hook(TSession * r)
/* fs api command will write to stream, calling http_stream_write / http_stream_raw_write */
/* switch_api_execute will stream INVALID COMMAND before it fails */
switch_api_execute(command, api_str, NULL, &stream);
if (globals.commands_to_log != NULL) {
full_command = switch_mprintf("%s%s%s", command, (api_str==NULL ? "" : " "), api_str);
@@ -1286,7 +1286,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_xml_rpc_shutdown)
{
switch_event_free_subclass("websocket::stophook");
/* Cann't find a way to stop the websockets, use this for a workaround before finding the real one that works */
stop_all_websockets();
+25 -25
View File
@@ -9,11 +9,11 @@ static struct globals_s globals;
#ifndef WSS_STANDALONE
void init_ssl(void)
void init_ssl(void)
{
// SSL_library_init();
}
void deinit_ssl(void)
void deinit_ssl(void)
{
return;
}
@@ -85,7 +85,7 @@ void init_ssl(void) {
globals.ssl_method = TLSv1_server_method(); /* create server instance */
globals.ssl_ctx = SSL_CTX_new(globals.ssl_method); /* create context */
assert(globals.ssl_ctx);
/* set the local certificate from CertFile */
SSL_CTX_use_certificate_file(globals.ssl_ctx, globals.cert, SSL_FILETYPE_PEM);
/* set the private key from KeyFile */
@@ -138,28 +138,28 @@ static int cheezy_get_var(char *data, char *name, char *buf, size_t buflen)
e = strchr(v, '\n');
}
}
if (v && e) {
size_t cplen;
size_t len = e - v;
if (len > buflen - 1) {
cplen = buflen -1;
} else {
cplen = len;
}
strncpy(buf, v, cplen);
*(buf+cplen) = '\0';
return 1;
}
}
}
return 0;
}
static int b64encode(unsigned char *in, size_t ilen, unsigned char *out, size_t olen)
static int b64encode(unsigned char *in, size_t ilen, unsigned char *out, size_t olen)
{
int y=0,bytes=0;
size_t x=0;
@@ -203,7 +203,7 @@ static void sha1_digest(char *digest, unsigned char *in)
SHA1Update(&sha, in, strlen(in));
SHA1Final(&sha, digest);
}
#else
#else
static void sha1_digest(unsigned char *digest, char *in)
{
@@ -236,7 +236,7 @@ int ws_handshake_kvp(wsh_t *wsh, char *key, char *version, char *proto)
sha1_digest(output, input);
b64encode((unsigned char *)output, SHA1_HASH_SIZE, (unsigned char *)b64, sizeof(b64));
snprintf(respond, sizeof(respond),
snprintf(respond, sizeof(respond),
"HTTP/1.1 101 Switching Protocols\r\n"
"Upgrade: websocket\r\n"
"Connection: Upgrade\r\n"
@@ -358,7 +358,7 @@ void ws_destroy(wsh_t *wsh)
if (wsh->down > 1) {
return;
}
wsh->down = 2;
if (wsh->ssl) {
@@ -372,9 +372,9 @@ void ws_destroy(wsh_t *wsh)
}
}
issize_t ws_close(wsh_t *wsh, int16_t reason)
issize_t ws_close(wsh_t *wsh, int16_t reason)
{
if (wsh->down) {
return -1;
}
@@ -386,7 +386,7 @@ issize_t ws_close(wsh_t *wsh, int16_t reason)
issize_t ws_read_frame(wsh_t *wsh, ws_opcode_t *oc, uint8_t **data)
{
issize_t need = 2;
char *maskp;
@@ -435,7 +435,7 @@ issize_t ws_read_frame(wsh_t *wsh, ws_opcode_t *oc, uint8_t **data)
if (mask) {
need += 4;
if (need > wsh->datalen) {
/* too small - protocol err */
*oc = WSOC_CLOSE;
@@ -445,7 +445,7 @@ issize_t ws_read_frame(wsh_t *wsh, ws_opcode_t *oc, uint8_t **data)
wsh->plen = wsh->buffer[1] & 0x7f;
wsh->payload = &wsh->buffer[2];
if (wsh->plen == 127) {
uint64_t *u64;
@@ -488,7 +488,7 @@ issize_t ws_read_frame(wsh_t *wsh, ws_opcode_t *oc, uint8_t **data)
if ((need + wsh->datalen) > (issize_t)wsh->buflen) {
/* too big - Ain't nobody got time fo' dat */
*oc = WSOC_CLOSE;
return ws_close(wsh, WS_DATA_TOO_BIG);
return ws_close(wsh, WS_DATA_TOO_BIG);
}
wsh->rplen = wsh->plen - need;
@@ -506,7 +506,7 @@ issize_t ws_read_frame(wsh_t *wsh, ws_opcode_t *oc, uint8_t **data)
wsh->rplen += r;
need -= r;
}
if (mask && maskp) {
issize_t i;
@@ -514,13 +514,13 @@ issize_t ws_read_frame(wsh_t *wsh, ws_opcode_t *oc, uint8_t **data)
wsh->payload[i] ^= maskp[i % 4];
}
}
if (*oc == WSOC_PING) {
ws_write_frame(wsh, WSOC_PONG, wsh->payload, wsh->rplen);
goto again;
}
*(wsh->payload+wsh->rplen) = '\0';
*data = (uint8_t *)wsh->payload;
@@ -549,7 +549,7 @@ issize_t ws_feed_buf(wsh_t *wsh, void *data, size_t bytes)
}
memcpy(wsh->wbuffer + wsh->wdatalen, data, bytes);
wsh->wdatalen += (issize_t)bytes;
return (issize_t)bytes;
@@ -562,9 +562,9 @@ issize_t ws_send_buf(wsh_t *wsh, ws_opcode_t oc)
if (!wsh->wdatalen) {
return -1;
}
r = ws_write_frame(wsh, oc, wsh->wbuffer, wsh->wdatalen);
wsh->wdatalen = 0;
return r;
@@ -600,7 +600,7 @@ issize_t ws_write_frame(wsh_t *wsh, ws_opcode_t oc, void *data, size_t bytes)
hdr[1] = 127;
hlen += 8;
u64 = (uint64_t *) &hdr[2];
*u64 = htonl((unsigned long)bytes);
}
@@ -612,7 +612,7 @@ issize_t ws_write_frame(wsh_t *wsh, ws_opcode_t oc, void *data, size_t bytes)
if (ws_raw_write(wsh, data, bytes) != (issize_t)bytes) {
return -2;
}
return (issize_t)bytes;
}
+2 -2
View File
@@ -9,7 +9,7 @@
#include <sys/types.h>
#ifndef _MSC_VER
#include <arpa/inet.h>
#include <sys/wait.h>
#include <sys/wait.h>
#include <sys/socket.h>
#else
#pragma warning(disable:4996)
@@ -95,7 +95,7 @@ int ws_handshake_kvp(wsh_t *wsh, char *key, char *version, char *proto);
#ifndef _MSC_VER
static inline uint64_t get_unaligned_uint64(const void *p)
{
{
const struct { uint64_t d; } __attribute__((packed)) *pp = p;
return pp->d;
}
+17 -17
View File
@@ -1,4 +1,4 @@
/*
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
@@ -22,7 +22,7 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Anthony Minessale II <anthm@freeswitch.org>
*
* mod_xml_scgi.c -- SCGI XML Gateway
@@ -46,7 +46,7 @@ struct xml_binding {
int timeout;
switch_hash_t *vars_map;
char *bindings;
char *server;
switch_thread_t *thread;
struct xml_binding *next;
@@ -116,7 +116,7 @@ void *SWITCH_THREAD_FUNC monitor_thread_run(switch_thread_t *thread, void *obj)
switch_yield(10000000);
}
}
return NULL;
}
@@ -170,7 +170,7 @@ static switch_xml_t xml_url_fetch(const char *section, const char *tag_name, con
while((len = scgi_recv(&handle, buf, sizeof(buf))) > 0) {
char *expanded = switch_event_expand_headers(params, (char *)buf);
bytes += len;
if (bytes > XML_SCGI_MAX_BYTES) {
@@ -185,7 +185,7 @@ static switch_xml_t xml_url_fetch(const char *section, const char *tag_name, con
if (expanded != (char *)buf) {
free(expanded);
}
memset(buf, 0, sizeof(buf));
}
@@ -201,32 +201,32 @@ static switch_xml_t xml_url_fetch(const char *section, const char *tag_name, con
goto end;
}
if (GLOBAL_DEBUG) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "DEBUG:\nURL: %s\nPOST_DATA:\n%s\n\nRESPONSE:\n-----\n%s\n-----\n",
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "DEBUG:\nURL: %s\nPOST_DATA:\n%s\n\nRESPONSE:\n-----\n%s\n-----\n",
binding->url, data, switch_str_nil(txt));
}
if (bytes && txt) {
if (!(xml = switch_xml_parse_str_dynamic(txt, FALSE))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Parsing Result! [%s]\ndata: [%s] RESPONSE[%s]\n",
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Parsing Result! [%s]\ndata: [%s] RESPONSE[%s]\n",
binding->url, data, switch_str_nil(txt));
}
txt = NULL;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Received error trying to fetch %s\ndata: [%s] RESPONSE [%s]\n",
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Received error trying to fetch %s\ndata: [%s] RESPONSE [%s]\n",
binding->url, data, switch_str_nil(txt));
}
end:
switch_safe_free(data);
switch_safe_free(txt);
return xml;
}
@@ -329,7 +329,7 @@ static switch_status_t do_config(void)
if (bind_mask) {
binding->bindings = switch_core_strdup(globals.pool, bind_mask);
}
}
if (vars_map) {
switch_zmalloc(hash_node, sizeof(hash_node_t));
@@ -351,14 +351,14 @@ static switch_status_t do_config(void)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Binding [%s] XML Fetch Function [%s] [%s]\n",
zstr(bname) ? "N/A" : bname, binding->url, binding->bindings ? binding->bindings : "all");
switch_xml_bind_search_function(xml_url_fetch, switch_xml_parse_section_string(binding->bindings), binding);
if (binding->server) {
launch_monitor_thread(binding);
}
binding->next = globals.bindings;
globals.bindings = binding;
x++;
binding = NULL;
@@ -423,7 +423,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_xml_scgi_shutdown)
}
break;
}
switch_yield(5000000);
}