return SWITCH_STATUS_SUCCESS;
}
-void add_cli_api(switch_loadable_module_interface_t **module_interface, switch_api_interface_t *api_interface)
+void add_cli_api(switch_loadable_module_interface_t **module_interface)
{
+ switch_api_interface_t *api_interface = NULL;
SWITCH_ADD_API(api_interface, "erlang", KAZOO_DESC, exec_api_cmd, KAZOO_SYNTAX);
switch_console_set_complete("add erlang status");
switch_console_set_complete("add erlang event_filter");
switch_safe_free(item);
}
-SWITCH_STANDARD_API(kz_json_history) {
+SWITCH_STANDARD_API(kz_json_history)
+{
char *mycmd = NULL, *argv[MAX_HISTORY] = { 0 };
int n, argc = 0;
cJSON *json = cJSON_CreateObject();
return SWITCH_STATUS_SUCCESS;
}
-SWITCH_STANDARD_API(kz_first_of) {
+SWITCH_STANDARD_API(kz_first_of)
+{
char delim = '|';
char *mycmd = NULL, *argv[MAX_FIRST_OF] = { 0 };
int n, argc = 0;
return status;
}
-void add_kz_commands(switch_loadable_module_interface_t **module_interface, switch_api_interface_t *api_interface) {
+SWITCH_STANDARD_API(kz_expand_api)
+{
+ if (!zstr(cmd)) {
+ char * val = kz_expand(cmd);
+ stream->write_function(stream, "+OK %s", val);
+ switch_safe_free(val);
+ } else {
+ stream->write_function(stream, "ERR invalid input");
+ }
+ return SWITCH_STATUS_SUCCESS;
+}
+
+void add_kz_commands(switch_loadable_module_interface_t **module_interface) {
+ switch_api_interface_t *api_interface = NULL;
SWITCH_ADD_API(api_interface, "kz_uuid_setvar_multi", UUID_SET_DESC, uuid_setvar_multi_function, UUID_MULTISET_SYNTAX);
SWITCH_ADD_API(api_interface, "kz_uuid_setvar_multi_encoded", UUID_SET_DESC, uuid_setvar_multi_encoded_function, UUID_MULTISET_SYNTAX);
switch_console_set_complete("add kz_uuid_setvar_multi ::console::list_uuid");
SWITCH_ADD_API(api_interface, "kz_http_put", KZ_HTTP_PUT_DESC, kz_http_put, KZ_HTTP_PUT_SYNTAX);
SWITCH_ADD_API(api_interface, "first-of", KZ_FIRST_OF_DESC, kz_first_of, KZ_FIRST_OF_SYNTAX);
SWITCH_ADD_API(api_interface, "kz_json_history", KZ_FIRST_OF_DESC, kz_json_history, KZ_FIRST_OF_SYNTAX);
+ SWITCH_ADD_API(api_interface, "kz_expand", KZ_FIRST_OF_DESC, kz_expand_api, KZ_FIRST_OF_SYNTAX);
}
--- /dev/null
+#ifndef KAZOO_DEFS_H_
+#define KAZOO_DEFS_H_
+
+#define INTERACTION_VARIABLE "Call-Interaction-ID"
+
+#define UNIX_EPOCH_IN_GREGORIAN 62167219200
+#define UNIX_EPOCH_IN_GREGORIAN_STR "62167219200"
+
+#endif /* KAZOO_DEFS_H_ */
}
}
-void add_kz_dptools(switch_loadable_module_interface_t **module_interface, switch_application_interface_t *app_interface) {
+void add_kz_dptools(switch_loadable_module_interface_t **module_interface) {
+ switch_application_interface_t *app_interface = NULL;
SWITCH_ADD_APP(app_interface, "kz_set", SET_SHORT_DESC, SET_LONG_DESC, set_function, SET_SYNTAX, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC);
SWITCH_ADD_APP(app_interface, "kz_set_encoded", SET_SHORT_DESC, SET_LONG_DESC, set_encoded_function, SET_SYNTAX, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC);
SWITCH_ADD_APP(app_interface, "kz_multiset", MULTISET_SHORT_DESC, MULTISET_LONG_DESC, multiset_function, MULTISET_SYNTAX, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC);
#define VERSION "mod_kazoo v1.5.0-1 community"
#define KZ_MAX_SEPARATE_STRINGS 10
+#define HOSTNAME_MAX 1024
+#define NODENAME_MAX 1024
typedef enum {KAZOO_FETCH_PROFILE, KAZOO_EVENT_PROFILE} kazoo_profile_type;
};
-typedef enum {
- KZ_TWEAK_INTERACTION_ID,
- KZ_TWEAK_EXPORT_VARS,
- KZ_TWEAK_SWITCH_URI,
- KZ_TWEAK_REPLACES_CALL_ID,
- KZ_TWEAK_LOOPBACK_VARS,
- KZ_TWEAK_CALLER_ID,
- KZ_TWEAK_TRANSFERS,
- KZ_TWEAK_BRIDGE,
- KZ_TWEAK_BRIDGE_REPLACES_ALEG,
- KZ_TWEAK_BRIDGE_REPLACES_CALL_ID,
- KZ_TWEAK_BRIDGE_VARIABLES,
- KZ_TWEAK_RESTORE_CALLER_ID_ON_BLIND_XFER,
-
- /* No new flags below this line */
- KZ_TWEAK_MAX
-} kz_tweak_t;
-
-struct globals_s {
+struct kz_globals_s {
switch_memory_pool_t *pool;
switch_atomic_t threads;
switch_socket_t *acceptor;
int ei_compat_rel;
char *ip;
char *hostname;
+ struct hostent* hostname_ent;
char *ei_cookie;
char *ei_nodename;
uint32_t flags;
};
-typedef struct globals_s globals_t;
-extern globals_t kazoo_globals;
+typedef struct kz_globals_s kz_globals_t;
+extern kz_globals_t kazoo_globals;
/* kazoo_event_stream.c */
ei_event_stream_t *find_event_stream(ei_event_stream_t *event_streams, const erlang_pid *from);
}
}
+void kz_set_hostname()
+{
+ if (kazoo_globals.hostname == NULL) {
+ char hostname[NODENAME_MAX];
+ memcpy(hostname, switch_core_get_hostname(), NODENAME_MAX);
+ kazoo_globals.hostname_ent = gethostbyname(hostname);
+ if(kazoo_globals.hostname_ent != NULL) {
+ kazoo_globals.hostname = switch_core_strdup(kazoo_globals.pool, kazoo_globals.hostname_ent->h_name);
+ } else {
+ kazoo_globals.hostname = switch_core_strdup(kazoo_globals.pool, hostname);
+ }
+ }
+}
switch_status_t kazoo_ei_config(switch_xml_t cfg) {
switch_xml_t child, param;
kazoo_globals.receive_msg_preallocate = 2000;
kazoo_globals.event_stream_preallocate = KZ_DEFAULT_STREAM_PRE_ALLOCATE;
kazoo_globals.send_msg_batch = 10;
- kazoo_globals.event_stream_framing = 2;
+ kazoo_globals.event_stream_framing = 4;
kazoo_globals.port = 0;
kazoo_globals.io_fault_tolerance = 10;
kazoo_globals.json_encoding = ERLANG_TUPLE;
}
if ((child = switch_xml_child(cfg, "tweaks"))) {
+ char *default_tweaks = (char *) switch_xml_attr_soft(param, "default");
+ if (default_tweaks) {
+ int i, v = switch_true(default_tweaks) ? 1 : 0;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set tweak default : %s\n", default_tweaks);
+ for (i = 0; i < KZ_TWEAK_MAX; i++) kazoo_globals.tweaks[i] = v;
+ }
for (param = switch_xml_child(child, "tweak"); param; param = param->next) {
kz_tweak_t tweak = KZ_TWEAK_MAX;
char *var = (char *) switch_xml_attr_soft(param, "name");
char *val = (char *) switch_xml_attr_soft(param, "value");
if(var && val && kz_name_tweak(var, &tweak) == SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set tweak %s : %s\n", var, val);
if(switch_true(val)) {
kz_set_tweak(tweak);
} else {
char *var = (char *) switch_xml_attr_soft(param, "name");
char *val = (char *) switch_xml_attr_soft(param, "value");
if(var && val) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set core variable %s : %s\n", var, val);
switch_core_set_variable(var, val);
}
}
return NULL;
}
- switch_getnameinfo(&kazoo_globals.hostname, sa, 0);
-
if (kazoo_globals.nat_map && switch_nat_get_type()) {
switch_nat_add_mapping(port, SWITCH_NAT_TCP, NULL, SWITCH_FALSE);
}
*/
#include "mod_kazoo.h"
+#define INTERACTION_VARIABLE "Call-Interaction-ID"
+
+static const char *x_bridge_variables[] = {
+ "Call-Control-Queue",
+ "Call-Control-PID",
+ "Call-Control-Node",
+ INTERACTION_VARIABLE,
+ "ecallmgr_Ecallmgr-Node",
+ "sip_h_k-cid",
+ "Switch-URI",
+ "Switch-URL",
+ NULL
+};
+
+static void kz_tweaks_variables_to_event(switch_core_session_t *session, switch_event_t *event)
+{
+ int i;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ for(i = 0; x_bridge_variables[i] != NULL; i++) {
+ const char *val = switch_channel_get_variable_dup(channel, x_bridge_variables[i], SWITCH_FALSE, -1);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, x_bridge_variables[i], val);
+ }
+}
+
/* kazoo endpoint */
switch_endpoint_interface_t *kz_endpoint_interface;
static switch_call_cause_t kz_endpoint_outgoing_channel(switch_core_session_t *session,
- switch_event_t *var_event,
- 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_event_t *var_event,
+ 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_io_routines_t kz_endpoint_io_routines = {
/*.outgoing_channel */ kz_endpoint_outgoing_channel
};
static switch_call_cause_t kz_endpoint_outgoing_channel(switch_core_session_t *session,
- switch_event_t *var_event,
- 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_event_t *var_event,
+ 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_xml_t x_user = NULL, x_param, x_params;
char *user = NULL, *domain = NULL, *dup_domain = NULL, *dialed_user = NULL;
switch_event_t *params = NULL, *var_event_orig = var_event;
char stupid[128] = "";
const char *skip = NULL, *var = NULL;
+ switch_core_session_t *a_session = NULL, *e_session = NULL;
if (zstr(outbound_profile->destination_number)) {
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "NO DESTINATION NUMBER\n");
goto done;
}
switch_assert(params);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "as_channel", "true");
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "action", "user_call");
+ if (session) {
+ switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "Unique-ID", switch_core_session_get_uuid(session));
+ }
if (var_event) {
switch_event_merge(params, var_event);
goto done;
}
+ if ((x_params = switch_xml_child(x_user, "variables"))) {
+ for (x_param = switch_xml_child(x_params, "variable"); x_param; x_param = x_param->next) {
+ const char *pvar = switch_xml_attr_soft(x_param, "name");
+ const char *val = switch_xml_attr(x_param, "value");
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "adding variable to var_event => %s = %s\n", pvar, val);
+ if (!var_event) {
+ switch_event_create(&var_event, SWITCH_EVENT_GENERAL);
+ } else {
+ switch_event_del_header(var_event, pvar);
+ }
+ switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, pvar, val);
+ }
+ }
+
if ((x_params = switch_xml_child(x_user, "params"))) {
for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) {
const char *pvar = switch_xml_attr_soft(x_param, "name");
} else {
switch_event_del_header(var_event, pvar + 9);
}
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG1, "adding variable to var_event => %s = %s\n", pvar + 9, val);
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "adding dialog var to var_event => %s = %s\n", pvar + 9, val);
switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, pvar + 9, val);
}
}
if (var_event) {
switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "dialed_user", dialed_user);
switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "dialed_domain", domain);
- if (!zstr(dest) && !strstr(dest, "presence_id=")) {
- switch_event_add_header(var_event, SWITCH_STACK_BOTTOM, "presence_id", "%s@%s", dialed_user, domain);
- }
}
if (!dest) {
switch_originate_flag_t myflags = SOF_NONE;
char *cid_name_override = NULL;
char *cid_num_override = NULL;
+ switch_event_t *event = NULL;
if (var_event) {
cid_name_override = switch_event_get_header(var_event, "origination_caller_id_name");
cid_num_override = switch_event_get_header(var_event, "origination_caller_id_number");
}
- if (session) {
- switch_event_t *event = NULL;
+ if(session) {
+ a_session = session;
+ } else if(var_event) {
+ const char* uuid_e_session = switch_event_get_header(var_event, "ent_originate_aleg_uuid");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHECKING ORIGINATE-UUID : %s\n", uuid_e_session);
+ if (uuid_e_session && (e_session = switch_core_session_force_locate(uuid_e_session)) != NULL) {
+ a_session = e_session;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "FOUND ORIGINATE-UUID : %s\n", uuid_e_session);
+ }
+ }
+
+ if (a_session) {
switch_event_create(&event, SWITCH_EVENT_GENERAL);
- channel = switch_core_session_get_channel(session);
+ channel = switch_core_session_get_channel(a_session);
if ((varval = switch_channel_get_variable(channel, SWITCH_CALL_TIMEOUT_VARIABLE))
|| (var_event && (varval = switch_event_get_header(var_event, "leg_timeout")))) {
timelimit = atoi(varval);
switch_channel_set_variable(channel, "dialed_user", dialed_user);
switch_channel_set_variable(channel, "dialed_domain", domain);
- d_dest = switch_event_expand_headers(event, dest);
-
- switch_event_destroy(&event);
-
} else {
- switch_event_t *event = NULL;
-
if (var_event) {
switch_event_dup(&event, var_event);
switch_event_del_header(event, "dialed_user");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "dialed_user", dialed_user);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "dialed_domain", domain);
- d_dest = switch_event_expand_headers(event, dest);
- switch_event_destroy(&event);
}
+ if ((x_params = switch_xml_child(x_user, "profile-variables"))) {
+ for (x_param = switch_xml_child(x_params, "variable"); x_param; x_param = x_param->next) {
+ const char *pvar = switch_xml_attr_soft(x_param, "name");
+ const char *val = switch_xml_attr(x_param, "value");
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "adding profile variable to event => %s = %s\n", pvar, val);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, pvar, val);
+ }
+ }
+
+ if ((x_params = switch_xml_child(x_user, "variables"))) {
+ for (x_param = switch_xml_child(x_params, "variable"); x_param; x_param = x_param->next) {
+ const char *pvar = switch_xml_attr_soft(x_param, "name");
+ const char *val = switch_xml_attr(x_param, "value");
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "adding variable to event => %s = %s\n", pvar, val);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, pvar, val);
+ }
+ }
+
+ if ((x_params = switch_xml_child(x_user, "params"))) {
+ for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) {
+ const char *pvar = switch_xml_attr_soft(x_param, "name");
+ const char *val = switch_xml_attr(x_param, "value");
+
+ if (!strncasecmp(pvar, "dial-var-", 9)) {
+ switch_event_del_header(event, pvar + 9);
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "adding dialog var to event => %s = %s\n", pvar + 9, val);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, pvar + 9, val);
+ }
+ }
+ }
+
+ d_dest = kz_event_expand_headers(event, dest);
+
+ if (var_event) {
+ kz_expand_headers(event, var_event);
+ }
+
+ switch_event_destroy(&event);
+
+
if ((flags & SOF_NO_LIMITS)) {
myflags |= SOF_NO_LIMITS;
}
myflags |= SOF_NOBLOCK;
}
+ if ( a_session ) {
+ if(var_event) {
+ kz_tweaks_variables_to_event(a_session, var_event);
+ }
+ }
+
+ if(e_session) {
+ switch_core_session_rwunlock(e_session);
+ }
+
switch_snprintf(stupid, sizeof(stupid), "kz/%s", dialed_user);
if (switch_stristr(stupid, d_dest)) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Waddya Daft? You almost called '%s' in an infinate loop!\n",
- stupid);
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Waddya Daft? You almost called '%s' in an infinate loop!\n", stupid);
cause = SWITCH_CAUSE_INVALID_IE_CONTENTS;
} else if (switch_ivr_originate(session, new_session, &cause, d_dest, timelimit, NULL,
cid_name_override, cid_num_override, outbound_profile, var_event, myflags,
}
}
+ /*
if ((x_params = switch_xml_child(x_user, "variables"))) {
for (x_param = switch_xml_child(x_params, "variable"); x_param; x_param = x_param->next) {
const char *pvar = switch_xml_attr(x_param, "name");
switch_channel_set_variable(new_channel, pvar, val);
}
}
+ */
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_DEBUG1, "CHECKING CALLER-ID\n");
if ((x_params = switch_xml_child(x_user, "profile-variables"))) {
switch_safe_free(user);
switch_safe_free(dup_domain);
-
return cause;
}
expanded = kz_event_expand_headers(src, field->value);
if(expanded != NULL && !zstr(expanded)) {
item = kazoo_event_add_json_value(dst, field, field->as ? field->as : field->name, expanded);
- free(expanded);
+ if(expanded != field->value) {
+ free(expanded);
+ }
}
break;
return SWITCH_STATUS_SUCCESS;
}
+#define EVENT_TIMESTAMP_FIELD "Event-Date-Timestamp"
+#define JSON_TIMESTAMP_FIELD "Event-Timestamp"
+
+static switch_status_t kazoo_event_add_timestamp(switch_event_t* evt, cJSON* JObj)
+{
+ switch_event_header_t *header;
+ cJSON *item = NULL;
+ if((header = switch_event_get_header_ptr(evt, EVENT_TIMESTAMP_FIELD)) != NULL) {
+ if ((item = kazoo_event_json_value(JSON_NUMBER, header->value)) != NULL) {
+ kazoo_cJSON_AddItemToObject(JObj, JSON_TIMESTAMP_FIELD, item);
+ return SWITCH_STATUS_SUCCESS;
+ }
+ }
+ return SWITCH_STATUS_NOTFOUND;
+}
kazoo_message_ptr kazoo_message_create_event(switch_event_t* evt, kazoo_event_ptr event, kazoo_event_profile_ptr profile)
{
kazoo_event_init_json(profile->fields, event ? event->fields : NULL, evt, &JObj);
+ kazoo_event_add_timestamp(evt, JObj);
+
if(profile->fields)
kazoo_event_add_fields_to_json(&logging, JObj, evt, profile->fields->head);
kazoo_event_init_json(profile->fields, NULL, evt, &JObj);
+ kazoo_event_add_timestamp(evt, JObj);
+
if(profile->fields)
kazoo_event_add_fields_to_json(&logging, JObj, evt, profile->fields->head);
*/
#include "mod_kazoo.h"
-#define INTERACTION_VARIABLE "Call-Interaction-ID"
-#define BRIDGE_INTERCEPT_VARIABLE "Bridge-Intercepted"
-
static char *TWEAK_NAMES[] = {
"interaction-id",
"export-vars",
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "tweak signal bridge on hangup: %s , %s\n", switch_core_session_get_uuid(session), peer_uuid);
-
if (switch_event_create(&my_event, SWITCH_EVENT_CHANNEL_UNBRIDGE) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(my_event, SWITCH_STACK_BOTTOM, "Bridge-A-Unique-ID", switch_core_session_get_uuid(session));
switch_event_add_header_string(my_event, SWITCH_STACK_BOTTOM, "Bridge-B-Unique-ID", peer_uuid);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "tweak bridge event handler: variables : %s , %s\n", a_leg, b_leg);
-
if (a_leg && (a_session = switch_core_session_force_locate(a_leg)) != NULL) {
switch_channel_t *a_channel = switch_core_session_get_channel(a_session);
if(switch_channel_get_variable_dup(a_channel, bridge_variables[0], SWITCH_FALSE, -1) == NULL) {
}
-static void kz_tweaks_handle_bridge_intercepted(switch_event_t *event)
+static void kz_tweaks_handle_bridge_replaces_aleg(switch_event_t *event)
{
switch_event_t *my_event;
- switch_core_session_t *a_session = NULL;
- switch_core_session_t *b_session = NULL;
- const char *uuid = switch_event_get_header(event, "Unique-ID");
- const char *a_leg = switch_event_get_header(event, "Bridge-A-Unique-ID");
- const char *b_leg = switch_event_get_header(event, "Bridge-B-Unique-ID");
- const char *bridge_intercepted = NULL;
+ const char *replaced_call_id = switch_event_get_header(event, "variable_sip_replaces_call_id");
+ const char *a_leg_call_id = switch_event_get_header(event, "variable_sip_replaces_a-leg");
+ const char *peer_uuid = switch_event_get_header(event, "Unique-ID");
+ int processed = 0;
if (!kz_test_tweak(KZ_TWEAK_BRIDGE_REPLACES_ALEG)) return;
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "tweak bridge event handler: intercepted : %s , %s, %s\n", uuid, a_leg, b_leg);
+ if(a_leg_call_id && replaced_call_id) {
+ const char *call_id = switch_event_get_header(event, "Bridge-B-Unique-ID");
+ switch_core_session_t *session = NULL;
+ if ((session = switch_core_session_locate(peer_uuid)) != NULL) {
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ processed = switch_true(switch_channel_get_variable_dup(channel, "Bridge-Event-Processed", SWITCH_FALSE, -1));
+ switch_channel_set_variable(channel, "Bridge-Event-Processed", "true");
+ switch_core_session_rwunlock(session);
+ }
- if ((a_session = switch_core_session_locate(a_leg)) != NULL) {
- switch_channel_t *a_channel = switch_core_session_get_channel(a_session);
- bridge_intercepted = switch_channel_get_variable_dup(a_channel, BRIDGE_INTERCEPT_VARIABLE, SWITCH_TRUE, -1);
- switch_channel_set_variable(a_channel, BRIDGE_INTERCEPT_VARIABLE, NULL);
- if (bridge_intercepted && switch_true(bridge_intercepted)) {
- switch_channel_set_variable(a_channel, "Bridge-B-Unique-ID", b_leg);
- switch_channel_add_state_handler(a_channel, &kz_tweaks_signal_bridge_state_handlers);
-
- if ((b_session = switch_core_session_locate(b_leg)) != NULL) {
- switch_channel_t *b_channel = switch_core_session_get_channel(b_session);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "creating channel_bridge event A - %s , B - %s\n", switch_core_session_get_uuid(b_session), uuid);
- if (switch_event_create(&my_event, SWITCH_EVENT_CHANNEL_BRIDGE) == SWITCH_STATUS_SUCCESS) {
- switch_event_add_header_string(my_event, SWITCH_STACK_BOTTOM, "Bridge-A-Unique-ID", switch_core_session_get_uuid(b_session));
- switch_event_add_header_string(my_event, SWITCH_STACK_BOTTOM, "Bridge-B-Unique-ID", uuid);
- switch_channel_event_set_data(b_channel, my_event);
- switch_event_fire(&my_event);
+ if(processed) {
+ if(call_id) {
+ if((session = switch_core_session_locate(call_id)) != NULL) {
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ switch_channel_set_variable(channel, "Bridge-Event-Processed", "true");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "creating channel_bridge event A - %s , B - %s\n", switch_core_session_get_uuid(session), peer_uuid);
+ if (switch_event_create(&my_event, SWITCH_EVENT_CHANNEL_BRIDGE) == SWITCH_STATUS_SUCCESS) {
+ switch_event_add_header_string(my_event, SWITCH_STACK_BOTTOM, "Bridge-A-Unique-ID", switch_core_session_get_uuid(session));
+ switch_event_add_header_string(my_event, SWITCH_STACK_BOTTOM, "Bridge-B-Unique-ID", peer_uuid);
+ switch_channel_event_set_data(channel, my_event);
+ switch_event_fire(&my_event);
+ }
+ switch_channel_set_variable(channel, "Bridge-B-Unique-ID", peer_uuid);
+ switch_channel_add_state_handler(channel, &kz_tweaks_signal_bridge_state_handlers);
+ switch_core_session_rwunlock(session);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "invalid session : %s\n", call_id);
+ DUMP_EVENT(event);
}
- switch_core_session_rwunlock(b_session);
}
}
- switch_core_session_rwunlock(a_session);
+
}
- switch_safe_strdup(bridge_intercepted);
+
}
-static void kz_tweaks_channel_bridge_event_handler(switch_event_t *event)
+static void kz_tweaks_handle_bridge_replaces_call_id(switch_event_t *event)
{
- const char *uuid = switch_event_get_header(event, "Unique-ID");
+ switch_event_t *my_event;
- if (!kz_test_tweak(KZ_TWEAK_BRIDGE)) return;
+ const char *replaced_call_id = switch_event_get_header(event, "variable_sip_replaces_call_id");
+ const char *a_leg_call_id = switch_event_get_header(event, "variable_sip_replaces_a-leg");
+ const char *peer_uuid = switch_event_get_header(event, "Unique-ID");
+
+ if (!kz_test_tweak(KZ_TWEAK_BRIDGE_REPLACES_CALL_ID)) return;
+
+ if(a_leg_call_id && replaced_call_id) {
+ switch_core_session_t *call_session = NULL;
+ const char *call_id = switch_event_get_header(event, "Bridge-B-Unique-ID");
+ if (call_id && (call_session = switch_core_session_force_locate(call_id)) != NULL) {
+ switch_channel_t *call_channel = switch_core_session_get_channel(call_session);
+ if (switch_event_create(&my_event, SWITCH_EVENT_CHANNEL_BRIDGE) == SWITCH_STATUS_SUCCESS) {
+ switch_event_add_header_string(my_event, SWITCH_STACK_BOTTOM, "Bridge-A-Unique-ID", switch_core_session_get_uuid(call_session));
+ switch_event_add_header_string(my_event, SWITCH_STACK_BOTTOM, "Bridge-B-Unique-ID", peer_uuid);
+ switch_channel_event_set_data(call_channel, my_event);
+ switch_event_fire(&my_event);
+ }
+ switch_channel_set_variable(call_channel, "Bridge-B-Unique-ID", peer_uuid);
+ switch_channel_add_state_handler(call_channel, &kz_tweaks_signal_bridge_state_handlers);
+ switch_core_session_rwunlock(call_session);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "NOT FOUND : %s\n", call_id);
+ }
+ }
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "tweak bridge event handler: %s\n", uuid);
+}
+
+static void kz_tweaks_channel_bridge_event_handler(switch_event_t *event)
+{
+ if (!kz_test_tweak(KZ_TWEAK_BRIDGE)) return;
- kz_tweaks_handle_bridge_intercepted(event);
+ kz_tweaks_handle_bridge_replaces_call_id(event);
+ kz_tweaks_handle_bridge_replaces_aleg(event);
kz_tweaks_handle_bridge_variables(event);
}
static void kz_tweaks_channel_intercepted_event_handler(switch_event_t *event)
{
- switch_core_session_t *uuid_session = NULL;
const char *uuid = switch_event_get_header(event, "Unique-ID");
const char *peer_uuid = switch_event_get_header(event, "intercepted_by");
if (!kz_test_tweak(KZ_TWEAK_TRANSFERS)) return;
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "tweak intercepted handler : %s was intercepted by %s\n", uuid, peer_uuid);
-
- if ((uuid_session = switch_core_session_force_locate(peer_uuid)) != NULL) {
- switch_channel_t *uuid_channel = switch_core_session_get_channel(uuid_session);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "marking %s for channel_bridge handling\n", peer_uuid);
- switch_channel_set_variable(uuid_channel, BRIDGE_INTERCEPT_VARIABLE, "true");
- switch_core_session_rwunlock(uuid_session);
- }
-
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "INTERCEPTED : %s => %s\n", uuid, peer_uuid);
}
static void kz_tweaks_channel_transferor_event_handler(switch_event_t *event)
}
}
-/*
-static switch_status_t kz_tweaks_handle_auth_token(switch_core_session_t *session)
-{
- switch_channel_t *channel = switch_core_session_get_channel(session);
- switch_event_t *event;
- const char *token = switch_channel_get_variable(channel, "sip_h_X-FS-Auth-Token");
- if(token) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Authenticating user for nightmare xfer %s\n", token);
- if (switch_ivr_set_user(session, token) == SWITCH_STATUS_SUCCESS) {
- if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_DATA) == SWITCH_STATUS_SUCCESS) {
- switch_channel_event_set_data(channel, event);
- switch_event_fire(&event);
- }
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Authenticated user from nightmare xfer %s\n", token);
- } else {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Error Authenticating user for nightmare xfer %s\n", token);
- }
- }
-
- return SWITCH_STATUS_SUCCESS;
-
-}
-*/
-
static switch_status_t kz_tweaks_handle_nightmare_xfer_interaction_id(switch_core_session_t *session)
{
if (kz_test_tweak(KZ_TWEAK_INTERACTION_ID)) {
}
+static char * kz_tweaks_new_interaction_id()
+{
+ long int first = (switch_micro_time_now() / 1000000) + UNIX_EPOCH_IN_GREGORIAN;
+ char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
+ switch_uuid_t uuid;
+ switch_uuid_get(&uuid);
+ switch_uuid_format(uuid_str, &uuid);
+ uuid_str[8] = '\0';
+ return switch_mprintf("%ld-%s", first, uuid_str);
+}
+
static void kz_tweaks_handle_interaction_id(switch_core_session_t *session)
{
- const char *expr = "${expr(ceil((${Event-Date-Timestamp} / 1000000) + $${UNIX_EPOCH_IN_GREGORIAN}))}-${regex(${create_uuid()}|^([^-]*)|%1)}";
switch_channel_t *channel = switch_core_session_get_channel(session);
char * val = NULL;
switch_core_session_t *peer_session = NULL;
const char* peer_interaction_id = NULL;
if (kz_test_tweak(KZ_TWEAK_INTERACTION_ID)) {
- val = kz_expand(expr);
+ val = kz_tweaks_new_interaction_id();
if (val) {
switch_channel_set_variable(channel, "Original-"INTERACTION_VARIABLE, val);
if(switch_core_session_get_partner(session, &peer_session) == SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_SUCCESS;
}
-static switch_status_t kz_tweaks_set_export_vars(switch_core_session_t *session)
-{
- switch_channel_t *channel = switch_core_session_get_channel(session);
- const char *exports;
- char *var, *new_exports, *new_exports_d = NULL;
-
- if (kz_test_tweak(KZ_TWEAK_EXPORT_VARS)) {
- exports = switch_channel_get_variable(channel, SWITCH_EXPORT_VARS_VARIABLE);
- var = switch_core_session_strdup(session, "Switch-URI,Switch-URL");
-
- if (exports) {
- new_exports_d = switch_mprintf("%s,%s", exports, var);
- new_exports = new_exports_d;
- } else {
- new_exports = var;
- }
-
- switch_channel_set_variable(channel, SWITCH_EXPORT_VARS_VARIABLE, new_exports);
-
- switch_safe_free(new_exports_d);
- }
-
-
- return SWITCH_STATUS_SUCCESS;
-}
-
static switch_status_t kz_tweaks_on_init(switch_core_session_t *session)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
kz_tweaks_handle_interaction_id(session);
kz_tweaks_handle_switch_uri(session);
kz_tweaks_handle_caller_id(session);
-// kz_tweaks_handle_auth_token(session);
kz_tweaks_handle_nightmare_xfer_interaction_id(session);
kz_tweaks_handle_replaces_call_id(session);
kz_tweaks_handle_loopback(session);
kz_tweaks_register_handle_blind_xfer(session);
- kz_tweaks_set_export_vars(session);
return SWITCH_STATUS_SUCCESS;
}
void kz_tweaks_add_core_variables()
{
- switch_core_set_variable("UNIX_EPOCH_IN_GREGORIAN", "62167219200");
+ switch_core_set_variable("UNIX_EPOCH_IN_GREGORIAN", UNIX_EPOCH_IN_GREGORIAN_STR);
}
void kz_tweaks_start()
--- /dev/null
+#pragma once
+
+#include <switch.h>
+
+typedef enum {
+ KZ_TWEAK_INTERACTION_ID,
+ KZ_TWEAK_EXPORT_VARS,
+ KZ_TWEAK_SWITCH_URI,
+ KZ_TWEAK_REPLACES_CALL_ID,
+ KZ_TWEAK_LOOPBACK_VARS,
+ KZ_TWEAK_CALLER_ID,
+ KZ_TWEAK_TRANSFERS,
+ KZ_TWEAK_BRIDGE,
+ KZ_TWEAK_BRIDGE_REPLACES_ALEG,
+ KZ_TWEAK_BRIDGE_REPLACES_CALL_ID,
+ KZ_TWEAK_BRIDGE_VARIABLES,
+ KZ_TWEAK_RESTORE_CALLER_ID_ON_BLIND_XFER,
+
+ /* No new flags below this line */
+ KZ_TWEAK_MAX
+} kz_tweak_t;
+
+void kz_tweaks_start();
+void kz_tweaks_stop();
+SWITCH_DECLARE(const char *) kz_tweak_name(kz_tweak_t tweak);
+SWITCH_DECLARE(switch_status_t) kz_name_tweak(const char *name, kz_tweak_t *type);
+
+
+#define kz_test_tweak(flag) (kazoo_globals.tweaks[flag] ? 1 : 0)
+#define kz_set_tweak(flag) kazoo_globals.tweaks[flag] = 1
+#define kz_clear_tweak(flag) kazoo_globals.tweaks[flag] = 0
+
switch_assert(stream->data != NULL);
switch_assert(stream->write_function != NULL);
- if (strcasecmp(cmd, "console_complete")) {
- cmd_used = switch_strip_whitespace(cmd);
- arg_used = switch_strip_whitespace(arg);
- } else {
- cmd_used = (char *) cmd;
- arg_used = (char *) arg;
- }
+ cmd_used = switch_strip_whitespace(cmd);
+ arg_used = switch_strip_whitespace(arg);
if (cmd_used && (api = switch_loadable_module_get_api_interface(cmd_used)) != 0) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "executing [%s] => [%s]\n", cmd_used, arg_used);
if ((status = api->function(arg_used, session, stream)) != SWITCH_STATUS_SUCCESS) {
stream->write_function(stream, "COMMAND RETURNED ERROR!\n");
}
nv = 0;
olen = strlen(in) + 1;
indup = strdup(in);
+ switch_assert(indup);
endof_indup = end_of_p(indup) + 1;
if ((data = malloc(olen))) {
} else {
switch_stream_handle_t stream = { 0 };
char *expanded = NULL;
+ char *expanded_vname = NULL;
SWITCH_STANDARD_STREAM(stream);
- if (stream.data) {
- char *expanded_vname = NULL;
-
- if ((expanded_vname = kz_event_expand_headers_check(event, (char *) vname, var_list, api_list, recur+1)) == vname) {
- expanded_vname = NULL;
- } else {
- vname = expanded_vname;
- }
+ if ((expanded_vname = kz_event_expand_headers_check(event, (char *) vname, var_list, api_list, recur+1)) == vname) {
+ expanded_vname = NULL;
+ } else {
+ vname = expanded_vname;
+ }
- if ((expanded = kz_event_expand_headers_check(event, vval, var_list, api_list, recur+1)) == vval) {
- expanded = NULL;
- } else {
- vval = expanded;
- }
+ if ((expanded = kz_event_expand_headers_check(event, vval, var_list, api_list, recur+1)) == vval) {
+ expanded = NULL;
+ } else {
+ vval = expanded;
+ }
- if (!switch_core_test_flag(SCF_API_EXPANSION) || (api_list && !switch_event_check_permission_list(api_list, vname))) {
- func_val = NULL;
- sub_val = "<API execute Permission Denied>";
+ if (!switch_core_test_flag(SCF_API_EXPANSION) || (api_list && !switch_event_check_permission_list(api_list, vname))) {
+ func_val = NULL;
+ sub_val = "<API execute Permission Denied>";
+ } else {
+ stream.param_event = event;
+ if (kz_expand_api_execute(vname, vval, NULL, &stream) == SWITCH_STATUS_SUCCESS) {
+ func_val = stream.data;
+ sub_val = func_val;
} else {
- stream.param_event = event;
- if (kz_expand_api_execute(vname, vval, NULL, &stream) == SWITCH_STATUS_SUCCESS) {
- func_val = stream.data;
- sub_val = func_val;
- } else {
- free(stream.data);
- }
+ free(stream.data);
}
-
- switch_safe_free(expanded);
- switch_safe_free(expanded_vname);
-
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
- free(data);
- free(indup);
- return (char *) in;
}
+
+ switch_safe_free(expanded);
+ switch_safe_free(expanded_vname);
}
if ((nlen = sub_val ? strlen(sub_val) : 0)) {
if (len + nlen >= olen) {
return kz_event_expand_headers_check(event, in, NULL, NULL, 0);
}
+SWITCH_DECLARE(char *) kz_event_expand_headers_pool(switch_memory_pool_t *pool, switch_event_t *event, char *val)
+{
+ char *expanded;
+ char *dup = NULL;
+
+ expanded = kz_event_expand_headers(event, val);
+ dup = switch_core_strdup(pool, expanded);
+
+ if (expanded != val) {
+ free(expanded);
+ }
+
+ return dup;
+}
+
SWITCH_DECLARE(char *) kz_event_expand(const char *in)
{
switch_event_t *event = NULL;
}
}
+void kz_expand_headers(switch_event_t *resolver, switch_event_t *event) {
+ switch_event_t *clone = NULL;
+ switch_event_header_t *header = NULL;
+ switch_event_create_plain(&clone, event->event_id);
+
+ for(header = event->headers; header; header = header->next) {
+ char *expanded = kz_event_expand_headers(resolver, header->value);
+ if (expanded != header->value) {
+ switch_event_add_header_string(clone, SWITCH_STACK_BOTTOM, header->name, expanded);
+ switch_safe_free(expanded);
+ }
+ }
+
+ /* we don't want to force unique headers
+ * so we delete and then merge
+ */
+ for(header = clone->headers; header; header = header->next) {
+ switch_event_del_header(event, header->name);
+ }
+
+ switch_event_merge(event, clone);
+
+ switch_event_destroy(&clone);
+}
+
+void kz_expand_headers_self(switch_event_t *event) {
+ kz_expand_headers(event, event);
+}
+
char * kz_expand_vars(char *xml_str) {
return kz_expand_vars_pool(xml_str, NULL);
}
--- /dev/null
+#pragma once
+
+#include <switch.h>
+
+#ifdef __cplusplus
+#define KZ_BEGIN_EXTERN_C extern "C" {
+#define KZ_END_EXTERN_C }
+#else
+#define KZ_BEGIN_EXTERN_C
+#define KZ_END_EXTERN_C
+#endif
+
+KZ_BEGIN_EXTERN_C
+
+void kz_check_set_profile_var(switch_channel_t *channel, char* var, char *val);
+
+SWITCH_DECLARE(switch_status_t) kz_switch_core_merge_variables(switch_event_t *event);
+
+SWITCH_DECLARE(switch_status_t) kz_switch_core_base_headers_for_expand(switch_event_t **event);
+
+SWITCH_DECLARE(switch_status_t) kz_expand_api_execute(const char *cmd, const char *arg, switch_core_session_t *session, switch_stream_handle_t *stream);
+
+SWITCH_DECLARE(char *) kz_event_expand_headers_check(switch_event_t *event, const char *in, switch_event_t *var_list, switch_event_t *api_list, uint32_t recur);
+
+SWITCH_DECLARE(char *) kz_event_expand_headers(switch_event_t *event, const char *in);
+
+SWITCH_DECLARE(char *) kz_event_expand_headers_pool(switch_memory_pool_t *pool, switch_event_t *event, char *val);
+
+SWITCH_DECLARE(char *) kz_event_expand(const char *in);
+
+SWITCH_DECLARE(char *) kz_expand(const char *in);
+
+SWITCH_DECLARE(char *) kz_expand_pool(switch_memory_pool_t *pool, const char *in);
+
+char* kz_switch_event_get_first_of(switch_event_t *event, const char *list[]);
+
+SWITCH_DECLARE(switch_status_t) kz_switch_event_add_variable_name_printf(switch_event_t *event, switch_stack_t stack, const char *val, const char *fmt, ...);
+
+SWITCH_DECLARE(switch_xml_t) kz_xml_child(switch_xml_t xml, const char *name);
+
+void kz_xml_process(switch_xml_t cfg);
+void kz_event_decode(switch_event_t *event);
+
+char * kz_expand_vars(char *xml_str);
+void kz_expand_headers(switch_event_t *resolver, switch_event_t *event);
+void kz_expand_headers_self(switch_event_t *event);
+
+char * kz_expand_vars_pool(char *xml_str, switch_memory_pool_t *pool);
+switch_status_t kz_json_api(const char * command, cJSON *args, cJSON **res);
+
+KZ_END_EXTERN_C
void add_kz_node(switch_loadable_module_interface_t **module_interface)
{
- switch_json_api_interface_t *json_api_interface = NULL;
+ switch_json_api_interface_t *json_api_interface = NULL;
SWITCH_ADD_JSON_API(json_api_interface, "node.info", "JSON node API", kz_node_info_json_function, "");
}
*/
#include "mod_kazoo.h"
-globals_t kazoo_globals = {0};
+kz_globals_t kazoo_globals = {0};
SWITCH_MODULE_DEFINITION(mod_kazoo, mod_kazoo_load, mod_kazoo_shutdown, mod_kazoo_runtime);
SWITCH_MODULE_LOAD_FUNCTION(mod_kazoo_load) {
- switch_api_interface_t *api_interface = NULL;
- switch_application_interface_t *app_interface = NULL;
memset(&kazoo_globals, 0, sizeof(kazoo_globals));
-
kazoo_globals.pool = pool;
- kazoo_globals.ei_nodes = NULL;
-
- // ensure epmd is running
-
if(kazoo_load_config() != SWITCH_STATUS_SUCCESS) {
// TODO: what would we need to clean up here?
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Improper configuration!\n");
bind_fetch_agents();
/* create an api for cli debug commands */
- add_cli_api(module_interface, api_interface);
+ add_cli_api(module_interface);
/* add our modified commands */
- add_kz_commands(module_interface, api_interface);
+ add_kz_commands(module_interface);
/* add our modified dptools */
- add_kz_dptools(module_interface, app_interface);
+ add_kz_dptools(module_interface);
/* add our endpoints */
add_kz_endpoints(module_interface);
extern const char kz_default_config[];
extern const int kz_default_config_size;
+#include "kazoo_defs.h"
+#include "kazoo_tweaks.h"
#include "kazoo_ei.h"
#include "kazoo_message.h"
+#include "kazoo_utils.h"
typedef enum {
LFLAG_RUNNING = (1 << 0)
/* kazoo_commands.c */
-void add_kz_commands(switch_loadable_module_interface_t **module_interface, switch_api_interface_t *api_interface);
+void add_kz_commands(switch_loadable_module_interface_t **module_interface);
/* kazoo_dptools.c */
-void add_kz_dptools(switch_loadable_module_interface_t **module_interface, switch_application_interface_t *app_interface);
+void add_kz_dptools(switch_loadable_module_interface_t **module_interface);
/* kazoo_api.c */
-void add_cli_api(switch_loadable_module_interface_t **module_interface, switch_api_interface_t *api_interface);
+void add_cli_api(switch_loadable_module_interface_t **module_interface);
void remove_cli_api();
/* kazoo_utils.c */
+/*
SWITCH_DECLARE(switch_status_t) kz_switch_core_merge_variables(switch_event_t *event);
SWITCH_DECLARE(switch_status_t) kz_switch_core_base_headers_for_expand(switch_event_t **event);
void kz_check_set_profile_var(switch_channel_t *channel, char* var, char *val);
SWITCH_DECLARE(char *) kz_expand(const char *in);
SWITCH_DECLARE(char *) kz_expand_pool(switch_memory_pool_t *pool, const char *in);
switch_status_t kz_json_api(const char * command, cJSON *args, cJSON **res);
+*/
/* kazoo_endpoints.c */
void add_kz_endpoints(switch_loadable_module_interface_t **module_interface);