}
}
-switch_socket_t *create_socket(switch_memory_pool_t *pool) {
+switch_socket_t *create_socket_with_port(switch_memory_pool_t *pool, switch_port_t port) {
switch_sockaddr_t *sa;
switch_socket_t *socket;
- if(switch_sockaddr_info_get(&sa, globals.ip, SWITCH_UNSPEC, 0, 0, pool)) {
+ if(switch_sockaddr_info_get(&sa, globals.ip, SWITCH_UNSPEC, port, 0, pool)) {
return NULL;
}
return socket;
}
+switch_socket_t *create_socket(switch_memory_pool_t *pool) {
+ return create_socket_with_port(pool, 0);
+
+}
+
switch_status_t create_ei_cnode(const char *ip_addr, const char *name, struct ei_cnode_s *ei_cnode) {
struct hostent *nodehost;
char hostname[EI_MAXHOSTNAMELEN + 1] = "";
switch_core_hash_insert(filter, "Hangup-Cause", "1");
switch_core_hash_insert(filter, "Unique-ID", "1");
switch_core_hash_insert(filter, "variable_switch_r_sdp", "1");
- switch_core_hash_insert(filter, "variable_sip_local_sdp_str", "1");
+ switch_core_hash_insert(filter, "variable_rtp_local_sdp_str", "1");
switch_core_hash_insert(filter, "variable_sip_to_uri", "1");
switch_core_hash_insert(filter, "variable_sip_from_uri", "1");
switch_core_hash_insert(filter, "variable_sip_user_agent", "1");
globals.event_stream_preallocate = 4000;
globals.send_msg_batch = 10;
globals.event_stream_framing = 2;
+ globals.port = 0;
if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to open configuration file %s\n", cf);
if (!strcmp(var, "listen-ip")) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set bind ip address: %s\n", val);
set_pref_ip(val);
+ } else if (!strcmp(var, "listen-port")) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set bind port: %s\n", val);
+ globals.port = atoi(val);
} else if (!strcmp(var, "cookie")) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set cookie: %s\n", val);
set_pref_ei_cookie(val);
ei_set_compat_rel(globals.ei_compat_rel);
}
- if (!(globals.acceptor = create_socket(globals.pool))) {
+ if (!(globals.acceptor = create_socket_with_port(globals.pool, globals.port))) {
return SWITCH_STATUS_SOCKERR;
}
switch_socket_t *socket;
switch_mutex_t *socket_mutex;
switch_bool_t connected;
- char remote_ip[25];
+ char remote_ip[48];
uint16_t remote_port;
- char local_ip[25];
+ char local_ip[48];
uint16_t local_port;
erlang_pid pid;
uint32_t flags;
int event_stream_preallocate;
int send_msg_batch;
short event_stream_framing;
+ switch_port_t port;
};
typedef struct globals_s globals_t;
extern globals_t globals;
/* kazoo_utils.c */
void close_socket(switch_socket_t **sock);
void close_socketfd(int *sockfd);
+switch_socket_t *create_socket_with_port(switch_memory_pool_t *pool, switch_port_t port);
switch_socket_t *create_socket(switch_memory_pool_t *pool);
switch_status_t create_ei_cnode(const char *ip_addr, const char *name, struct ei_cnode_s *ei_cnode);
switch_status_t ei_compare_pids(const erlang_pid *pid1, const erlang_pid *pid2);