提交 29436b8c authored 作者: David Yat Sin's avatar David Yat Sin

Support for huntgroups


git-svn-id: http://svn.openzap.org/svn/openzap/branches/sangoma_boost@944 a93c3328-9c30-0410-af19-c9cd2b2d52af
上级 b4331759
......@@ -1033,7 +1033,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
const char *dest = NULL;
char *data = NULL;
int span_id = -1, chan_id = 0;
int span_id = -1, group_id = -1,chan_id = 0;
zap_channel_t *zchan = NULL;
switch_call_cause_t cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
char name[128];
......@@ -1085,7 +1085,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
if (span_id == 0 && chan_id != 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Span 0 is used to pick the first available span, selecting a channel is not supported (and doesn't make sense)\n");
return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
}
if (span_id == -1 && !zstr(span_name)) {
......@@ -1097,11 +1097,18 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
}
if (span_id == -1) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing span\n");
return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
//Look for a group
zap_group_t *group;
zap_status_t zstatus = zap_group_find_by_name(span_name, &group);
if (zstatus == ZAP_SUCCESS && group) {
group_id = group->group_id;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing span\n");
return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
}
}
if (chan_id < 0) {
if (group_id < 0 && chan_id < 0) {
direction = ZAP_BOTTOM_UP;
chan_id = 0;
}
......@@ -1143,11 +1150,13 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
zap_set_string(caller_data.cid_name, outbound_profile->caller_id_name);
zap_set_string(caller_data.cid_num.digits, outbound_profile->caller_id_number);
if (chan_id) {
if (group_id >= 0) {
status = zap_channel_open_by_group(group_id, direction, &caller_data, &zchan);
} else if (chan_id) {
status = zap_channel_open(span_id, chan_id, &zchan);
} else {
status = zap_channel_open_any(span_id, direction, &caller_data, &zchan);
status = zap_channel_open_by_span(span_id, direction, &caller_data, &zchan);
}
if (status != ZAP_SUCCESS) {
......@@ -1753,7 +1762,7 @@ static ZIO_SIGNAL_CB_FUNCTION(on_clear_channel_signal)
}
}
break;
case ZAP_SIGEVENT_PROGRESS:
case ZAP_SIGEVENT_PROGRESS:
{
if ((session = zap_channel_get_session(sigmsg->channel, 0))) {
channel = switch_core_session_get_channel(session);
......@@ -1766,8 +1775,6 @@ static ZIO_SIGNAL_CB_FUNCTION(on_clear_channel_signal)
sigmsg->channel->span_id, sigmsg->channel->chan_id, (uuid) ? uuid : "N/A");
}
}
break;
default:
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unhandled msg type %d for channel %d:%d\n",
......
......@@ -195,6 +195,9 @@ extern "C" {
#define ZAP_MAX_CHANNELS_SPAN ZAP_MAX_CHANNELS_PHYSICAL_SPAN * ZAP_MAX_PHYSICAL_SPANS_PER_LOGICAL_SPAN
#define ZAP_MAX_SPANS_INTERFACE 128
#define ZAP_MAX_CHANNELS_GROUP 1024
#define ZAP_MAX_GROUPS_INTERFACE ZAP_MAX_SPANS_INTERFACE
#define GOTO_STATUS(label,st) status = st; goto label ;
#define zap_copy_string(x,y,z) strncpy(x, y, z - 1)
......@@ -578,6 +581,16 @@ struct zap_span {
struct zap_span *next;
};
struct zap_group {
char *name;
uint32_t group_id;
uint32_t chan_count;
zap_channel_t *channels[ZAP_MAX_CHANNELS_GROUP];
uint32_t last_used_index;
zap_mutex_t *mutex;
struct zap_group *next;
};
OZ_DECLARE_DATA extern zap_logger_t zap_log;
typedef enum {
......@@ -706,11 +719,19 @@ OZ_DECLARE(zap_status_t) zap_span_create(zap_io_interface_t *zio, zap_span_t **s
OZ_DECLARE(zap_status_t) zap_span_close_all(void);
OZ_DECLARE(zap_status_t) zap_span_add_channel(zap_span_t *span, zap_socket_t sockfd, zap_chan_type_t type, zap_channel_t **chan);
OZ_DECLARE(zap_status_t) zap_span_set_event_callback(zap_span_t *span, zio_event_cb_t event_callback);
OZ_DECLARE(zap_status_t) zap_channel_add_to_group(const char* name, zap_channel_t* zchan);
OZ_DECLARE(zap_status_t) zap_group_add_channels(const char* name, zap_span_t* span, const char* val);
OZ_DECLARE(zap_status_t) zap_channel_remove_from_group(zap_group_t* group, zap_channel_t* zchan);
OZ_DECLARE(zap_status_t) zap_group_find(uint32_t id, zap_group_t **group);
OZ_DECLARE(zap_status_t) zap_group_find_by_name(const char *name, zap_group_t **group);
OZ_DECLARE(zap_status_t) zap_group_create(zap_group_t **group, const char *name);
OZ_DECLARE(zap_status_t) zap_channel_set_event_callback(zap_channel_t *zchan, zio_event_cb_t event_callback);
OZ_DECLARE(zap_status_t) zap_channel_open(uint32_t span_id, uint32_t chan_id, zap_channel_t **zchan);
OZ_DECLARE(zap_status_t) zap_channel_open_chan(zap_channel_t *zchan);
OZ_DECLARE(zap_status_t) zap_span_channel_use_count(zap_span_t *span, uint32_t *count);
OZ_DECLARE(zap_status_t) zap_channel_open_any(uint32_t span_id, zap_direction_t direction, zap_caller_data_t *caller_data, zap_channel_t **zchan);
OZ_DECLARE(zap_status_t) zap_group_channel_use_count(zap_group_t *group, uint32_t *count);
OZ_DECLARE(zap_status_t) zap_channel_open_by_span(uint32_t span_id, zap_direction_t direction, zap_caller_data_t *caller_data, zap_channel_t **zchan);
OZ_DECLARE(zap_status_t) zap_channel_open_by_group(uint32_t group_id, zap_direction_t direction, zap_caller_data_t *caller_data, zap_channel_t **zchan);
OZ_DECLARE(zap_status_t) zap_channel_close(zap_channel_t **zchan);
OZ_DECLARE(zap_status_t) zap_channel_done(zap_channel_t *zchan);
OZ_DECLARE(zap_status_t) zap_channel_use(zap_channel_t *zchan);
......
......@@ -458,6 +458,7 @@ typedef struct zap_channel zap_channel_t;
typedef struct zap_event zap_event_t;
typedef struct zap_sigmsg zap_sigmsg_t;
typedef struct zap_span zap_span_t;
typedef struct zap_group zap_group_t;
typedef struct zap_caller_data zap_caller_data_t;
typedef struct zap_io_interface zap_io_interface_t;
......
......@@ -36,6 +36,8 @@
#include "sangoma_boost_client.h"
#include "openzap.h"
#define MAX_CHANS_PER_TRUNKGROUP 1024
typedef enum {
ZAP_SANGOMA_BOOST_RUNNING = (1 << 0),
ZAP_SANGOMA_BOOST_RESTARTING = (1 << 1)
......@@ -50,9 +52,16 @@ typedef struct zap_sangoma_boost_data {
zio_signal_cb_t signal_cb;
uint32_t flags;
boost_sigmod_interface_t *sigmod;
zap_queue_t *boost_queue;
zap_queue_t *boost_queue;
} zap_sangoma_boost_data_t;
typedef struct zap_sangoma_boost_trunkgroup {
zap_mutex_t *mutex;
zap_size_t size; /* Number of b-channels in group */
unsigned int last_used_index; /* index of last b-channel used */
zap_channel_t* zchans[MAX_CHANS_PER_TRUNKGROUP];
//DAVIDY need to merge congestion timeouts to this struct
} zap_sangoma_boost_trunkgroup_t;
#endif
/* For Emacs:
......
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论