some changes
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@420 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
parent
7cd6d9f30f
commit
532de2fb08
|
@ -848,9 +848,26 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
||||||
chan_id = 0;
|
chan_id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
zap_set_string(caller_data.ani, dest);
|
if (switch_test_flag(outbound_profile, SWITCH_CPF_SCREEN)) {
|
||||||
|
caller_data.screen = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (switch_test_flag(outbound_profile, SWITCH_CPF_HIDE_NUMBER)) {
|
||||||
|
caller_data.pres = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!switch_strlen_zero(dest)) {
|
||||||
|
zap_set_string(caller_data.ani.digits, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (!switch_strlen_zero(outbound_profile->rdnis)) {
|
||||||
|
zap_set_string(caller_data.rdnis.digits, outbound_profile->rdnis);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
zap_set_string(caller_data.cid_name, outbound_profile->caller_id_name);
|
zap_set_string(caller_data.cid_name, outbound_profile->caller_id_name);
|
||||||
zap_set_string(caller_data.cid_num, outbound_profile->caller_id_number);
|
zap_set_string(caller_data.cid_num.digits, outbound_profile->caller_id_number);
|
||||||
|
|
||||||
if (chan_id) {
|
if (chan_id) {
|
||||||
status = zap_channel_open(span_id, chan_id, &zchan);
|
status = zap_channel_open(span_id, chan_id, &zchan);
|
||||||
|
@ -952,11 +969,11 @@ zap_status_t zap_channel_from_event(zap_sigmsg_t *sigmsg, switch_core_session_t
|
||||||
switch_set_string(sigmsg->channel->caller_data.cid_name, sigmsg->channel->chan_name);
|
switch_set_string(sigmsg->channel->caller_data.cid_name, sigmsg->channel->chan_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_strlen_zero(sigmsg->channel->caller_data.cid_num)) {
|
if (switch_strlen_zero(sigmsg->channel->caller_data.cid_num.digits)) {
|
||||||
if (!switch_strlen_zero(sigmsg->channel->caller_data.ani)) {
|
if (!switch_strlen_zero(sigmsg->channel->caller_data.ani.digits)) {
|
||||||
switch_set_string(sigmsg->channel->caller_data.cid_num, sigmsg->channel->caller_data.ani);
|
switch_set_string(sigmsg->channel->caller_data.cid_num.digits, sigmsg->channel->caller_data.ani.digits);
|
||||||
} else {
|
} else {
|
||||||
switch_set_string(sigmsg->channel->caller_data.cid_num, sigmsg->channel->chan_number);
|
switch_set_string(sigmsg->channel->caller_data.cid_num.digits, sigmsg->channel->chan_number);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -964,16 +981,25 @@ zap_status_t zap_channel_from_event(zap_sigmsg_t *sigmsg, switch_core_session_t
|
||||||
"OpenZAP",
|
"OpenZAP",
|
||||||
SPAN_CONFIG[sigmsg->channel->span_id].dialplan,
|
SPAN_CONFIG[sigmsg->channel->span_id].dialplan,
|
||||||
sigmsg->channel->caller_data.cid_name,
|
sigmsg->channel->caller_data.cid_name,
|
||||||
sigmsg->channel->caller_data.cid_num,
|
sigmsg->channel->caller_data.cid_num.digits,
|
||||||
NULL,
|
NULL,
|
||||||
sigmsg->channel->caller_data.ani,
|
sigmsg->channel->caller_data.ani.digits,
|
||||||
sigmsg->channel->caller_data.aniII,
|
sigmsg->channel->caller_data.aniII,
|
||||||
sigmsg->channel->caller_data.rdnis,
|
sigmsg->channel->caller_data.rdnis.digits,
|
||||||
(char *) modname,
|
(char *) modname,
|
||||||
SPAN_CONFIG[sigmsg->channel->span_id].context,
|
SPAN_CONFIG[sigmsg->channel->span_id].context,
|
||||||
sigmsg->channel->caller_data.dnis);
|
sigmsg->channel->caller_data.dnis.digits);
|
||||||
|
|
||||||
assert(tech_pvt->caller_profile != NULL);
|
assert(tech_pvt->caller_profile != NULL);
|
||||||
|
|
||||||
|
if (sigmsg->channel->caller_data.screen == 1 || sigmsg->channel->caller_data.screen == 3) {
|
||||||
|
switch_set_flag(tech_pvt->caller_profile, SWITCH_CPF_SCREEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sigmsg->channel->caller_data.pres) {
|
||||||
|
switch_set_flag(tech_pvt->caller_profile, SWITCH_CPF_HIDE_NAME | SWITCH_CPF_HIDE_NUMBER);
|
||||||
|
}
|
||||||
|
|
||||||
snprintf(name, sizeof(name), "OpenZAP/%s", tech_pvt->caller_profile->destination_number);
|
snprintf(name, sizeof(name), "OpenZAP/%s", tech_pvt->caller_profile->destination_number);
|
||||||
switch_channel_set_name(channel, name);
|
switch_channel_set_name(channel, name);
|
||||||
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
|
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
|
||||||
|
@ -1254,12 +1280,12 @@ static ZIO_SIGNAL_CB_FUNCTION(on_fxs_signal)
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ZIO_SIGNAL_CB_FUNCTION(on_isdn_signal)
|
static ZIO_SIGNAL_CB_FUNCTION(on_clear_channel_signal)
|
||||||
{
|
{
|
||||||
switch_core_session_t *session = NULL;
|
switch_core_session_t *session = NULL;
|
||||||
switch_channel_t *channel = NULL;
|
switch_channel_t *channel = NULL;
|
||||||
|
|
||||||
zap_log(ZAP_LOG_DEBUG, "got ISDN sig [%s]\n", zap_signal_event2str(sigmsg->event_id));
|
zap_log(ZAP_LOG_DEBUG, "got clear channel sig [%s]\n", zap_signal_event2str(sigmsg->event_id));
|
||||||
|
|
||||||
switch(sigmsg->event_id) {
|
switch(sigmsg->event_id) {
|
||||||
case ZAP_SIGEVENT_START:
|
case ZAP_SIGEVENT_START:
|
||||||
|
@ -1553,7 +1579,7 @@ static switch_status_t load_config(void)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zap_isdn_configure_span(span, mode, dialect, on_isdn_signal) != ZAP_SUCCESS) {
|
if (zap_isdn_configure_span(span, mode, dialect, on_clear_channel_signal) != ZAP_SUCCESS) {
|
||||||
zap_log(ZAP_LOG_ERROR, "Error starting OpenZAP span %d mode: %d dialect: %d error: %s\n", span_id, mode, dialect, span->last_error);
|
zap_log(ZAP_LOG_ERROR, "Error starting OpenZAP span %d mode: %d dialect: %d error: %s\n", span_id, mode, dialect, span->last_error);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1616,7 +1642,7 @@ static switch_status_t load_config(void)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zap_ss7_boost_configure_span(span, local_ip, local_port, remote_ip, remote_port, on_isdn_signal) != ZAP_SUCCESS) {
|
if (zap_ss7_boost_configure_span(span, local_ip, local_port, remote_ip, remote_port, on_clear_channel_signal) != ZAP_SUCCESS) {
|
||||||
zap_log(ZAP_LOG_ERROR, "Error starting OpenZAP span %d error: %s\n", span_id, span->last_error);
|
zap_log(ZAP_LOG_ERROR, "Error starting OpenZAP span %d error: %s\n", span_id, span->last_error);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -307,14 +307,22 @@ struct zap_fsk_modulator {
|
||||||
int16_t sample_buffer[64];
|
int16_t sample_buffer[64];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char digits[25];
|
||||||
|
uint8_t type;
|
||||||
|
uint8_t plan;
|
||||||
|
} zap_number_t;
|
||||||
|
|
||||||
struct zap_caller_data {
|
struct zap_caller_data {
|
||||||
char cid_name[80];
|
|
||||||
char cid_num[80];
|
|
||||||
char cid_date[8];
|
char cid_date[8];
|
||||||
char ani[25];
|
char cid_name[80];
|
||||||
|
zap_number_t cid_num;
|
||||||
|
zap_number_t ani;
|
||||||
|
zap_number_t dnis;
|
||||||
|
zap_number_t rdnis;
|
||||||
char aniII[25];
|
char aniII[25];
|
||||||
char dnis[25];
|
uint8_t screen;
|
||||||
char rdnis[25];
|
uint8_t pres;
|
||||||
char collected[25];
|
char collected[25];
|
||||||
int CRV;
|
int CRV;
|
||||||
int hangup_cause;
|
int hangup_cause;
|
||||||
|
@ -413,6 +421,7 @@ struct zap_span {
|
||||||
zap_data_type_t data_type;
|
zap_data_type_t data_type;
|
||||||
uint32_t span_id;
|
uint32_t span_id;
|
||||||
uint32_t chan_count;
|
uint32_t chan_count;
|
||||||
|
uint32_t active_count;
|
||||||
zap_span_flag_t flags;
|
zap_span_flag_t flags;
|
||||||
struct zap_io_interface *zio;
|
struct zap_io_interface *zio;
|
||||||
zio_event_cb_t event_callback;
|
zio_event_cb_t event_callback;
|
||||||
|
@ -455,6 +464,7 @@ struct zap_io_interface {
|
||||||
zio_span_next_event_t next_event;
|
zio_span_next_event_t next_event;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
zap_size_t zap_fsk_modulator_generate_bit(zap_fsk_modulator_t *fsk_trans, int8_t bit, int16_t *buf, zap_size_t buflen);
|
zap_size_t zap_fsk_modulator_generate_bit(zap_fsk_modulator_t *fsk_trans, int8_t bit, int16_t *buf, zap_size_t buflen);
|
||||||
int32_t zap_fsk_modulator_generate_carrier_bits(zap_fsk_modulator_t *fsk_trans, uint32_t bits);
|
int32_t zap_fsk_modulator_generate_carrier_bits(zap_fsk_modulator_t *fsk_trans, uint32_t bits);
|
||||||
void zap_fsk_modulator_generate_chan_sieze(zap_fsk_modulator_t *fsk_trans);
|
void zap_fsk_modulator_generate_chan_sieze(zap_fsk_modulator_t *fsk_trans);
|
||||||
|
@ -545,6 +555,27 @@ ZIO_CODEC_FUNCTION(zio_alaw2ulaw);
|
||||||
#define zap_mutex_unlock(_x) _zap_mutex_unlock(_x)
|
#define zap_mutex_unlock(_x) _zap_mutex_unlock(_x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
static __inline__ void zap_set_state_all(zap_span_t *span, zap_channel_state_t state)
|
||||||
|
{
|
||||||
|
uint32_t j;
|
||||||
|
zap_mutex_lock(span->mutex);
|
||||||
|
for(j = 1; j <= span->chan_count; j++) {
|
||||||
|
zap_set_state_locked((&span->channels[j]), state);
|
||||||
|
}
|
||||||
|
zap_mutex_unlock(span->mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static __inline__ void zap_set_flag_all(zap_span_t *span, uint32_t flag)
|
||||||
|
{
|
||||||
|
uint32_t j;
|
||||||
|
zap_mutex_lock(span->mutex);
|
||||||
|
for(j = 1; j <= span->chan_count; j++) {
|
||||||
|
zap_set_flag_locked((&span->channels[j]), flag);
|
||||||
|
}
|
||||||
|
zap_mutex_unlock(span->mutex);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* For Emacs:
|
/* For Emacs:
|
||||||
|
|
|
@ -51,12 +51,8 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <sigboost.h>
|
#include <sigboost.h>
|
||||||
#include <pthread.h>
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define ss7bc_test_flag(p,flag) ({ \
|
#define ss7bc_test_flag(p,flag) ({ \
|
||||||
((p)->flags & (flag)); \
|
((p)->flags & (flag)); \
|
||||||
})
|
})
|
||||||
|
@ -93,13 +89,15 @@ struct ss7bc_connection {
|
||||||
struct hostent remote_hp;
|
struct hostent remote_hp;
|
||||||
struct hostent local_hp;
|
struct hostent local_hp;
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
pthread_mutex_t lock;
|
zap_mutex_t *mutex;
|
||||||
FILE *log;
|
FILE *log;
|
||||||
unsigned int txseq;
|
unsigned int txseq;
|
||||||
unsigned int rxseq;
|
unsigned int rxseq;
|
||||||
unsigned int txwindow;
|
unsigned int txwindow;
|
||||||
unsigned int rxseq_reset;
|
unsigned int rxseq_reset;
|
||||||
ss7bc_ip_cfg_t cfg;
|
ss7bc_ip_cfg_t cfg;
|
||||||
|
uint32_t hb_elapsed;
|
||||||
|
int up;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
|
@ -261,7 +261,8 @@ typedef enum {
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ZAP_SPAN_CONFIGURED = (1 << 0),
|
ZAP_SPAN_CONFIGURED = (1 << 0),
|
||||||
ZAP_SPAN_READY = (1 << 1),
|
ZAP_SPAN_READY = (1 << 1),
|
||||||
ZAP_SPAN_STATE_CHANGE = (1 << 2)
|
ZAP_SPAN_STATE_CHANGE = (1 << 2),
|
||||||
|
ZAP_SPAN_SUSPENDED = (1 << 3)
|
||||||
} zap_span_flag_t;
|
} zap_span_flag_t;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -329,7 +330,10 @@ typedef enum {
|
||||||
ZAP_CHANNEL_CALLERID_DETECT = (1 << 17),
|
ZAP_CHANNEL_CALLERID_DETECT = (1 << 17),
|
||||||
ZAP_CHANNEL_OUTBOUND = (1 << 18),
|
ZAP_CHANNEL_OUTBOUND = (1 << 18),
|
||||||
ZAP_CHANNEL_SUSPENDED = (1 << 19),
|
ZAP_CHANNEL_SUSPENDED = (1 << 19),
|
||||||
ZAP_CHANNEL_3WAY = (1 << 20)
|
ZAP_CHANNEL_3WAY = (1 << 20),
|
||||||
|
ZAP_CHANNEL_PROGRESS = (1 << 21),
|
||||||
|
ZAP_CHANNEL_MEDIA = (1 << 22),
|
||||||
|
ZAP_CHANNEL_ANSWERED = (1 << 23)
|
||||||
} zap_channel_flag_t;
|
} zap_channel_flag_t;
|
||||||
|
|
||||||
typedef struct zap_channel zap_channel_t;
|
typedef struct zap_channel zap_channel_t;
|
||||||
|
@ -489,6 +493,7 @@ typedef enum {
|
||||||
ZAP_CAUSE_MEDIA_TIMEOUT = 604
|
ZAP_CAUSE_MEDIA_TIMEOUT = 604
|
||||||
} zap_call_cause_t;
|
} zap_call_cause_t;
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* For Emacs:
|
/* For Emacs:
|
||||||
|
|
|
@ -118,6 +118,8 @@ static int create_conn_socket(ss7bc_connection_t *mcon, char *local_ip, int loca
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
zap_mutex_create(&mcon->mutex);
|
||||||
|
|
||||||
return mcon->socket;
|
return mcon->socket;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,6 +128,8 @@ int ss7bc_connection_close(ss7bc_connection_t *mcon)
|
||||||
if (mcon->socket > -1) {
|
if (mcon->socket > -1) {
|
||||||
close(mcon->socket);
|
close(mcon->socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
zap_mutex_destroy(&mcon->mutex);
|
||||||
memset(mcon, 0, sizeof(*mcon));
|
memset(mcon, 0, sizeof(*mcon));
|
||||||
mcon->socket = -1;
|
mcon->socket = -1;
|
||||||
|
|
||||||
|
@ -147,25 +151,25 @@ int ss7bc_exec_command(ss7bc_connection_t *mcon, int span, int chan, int id, int
|
||||||
ss7bc_event_init(&oevent, cmd, chan, span);
|
ss7bc_event_init(&oevent, cmd, chan, span);
|
||||||
oevent.release_cause = cause;
|
oevent.release_cause = cause;
|
||||||
|
|
||||||
|
if (cmd == SIGBOOST_EVENT_SYSTEM_RESTART) {
|
||||||
|
mcon->rxseq_reset = 1;
|
||||||
|
mcon->txseq = 0;
|
||||||
|
mcon->rxseq = 0;
|
||||||
|
mcon->txwindow = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (id >= 0) {
|
if (id >= 0) {
|
||||||
oevent.call_setup_id = id;
|
oevent.call_setup_id = id;
|
||||||
}
|
}
|
||||||
isup_exec_cmd_retry:
|
|
||||||
if (ss7bc_connection_write(mcon, &oevent) <= 0){
|
|
||||||
|
|
||||||
--retry;
|
while (ss7bc_connection_write(mcon, &oevent) <= 0) {
|
||||||
if (retry <= 0) {
|
if (--retry <= 0) {
|
||||||
zap_log(ZAP_LOG_WARNING,
|
zap_log(ZAP_LOG_CRIT, "Failed to tx on ISUP socket: %s\n", strerror(errno));
|
||||||
"Critical System Error: Failed to tx on ISUP socket: %s\n",
|
|
||||||
strerror(errno));
|
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
zap_log(ZAP_LOG_WARNING,
|
zap_log(ZAP_LOG_WARNING, "Failed to tx on ISUP socket: %s :retry %i\n", strerror(errno), retry);
|
||||||
"System Warning: Failed to tx on ISUP socket: %s :retry %i\n",
|
zap_sleep(1);
|
||||||
strerror(errno),retry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
goto isup_exec_cmd_retry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -176,16 +180,12 @@ int ss7bc_exec_command(ss7bc_connection_t *mcon, int span, int chan, int id, int
|
||||||
ss7bc_event_t *ss7bc_connection_read(ss7bc_connection_t *mcon, int iteration)
|
ss7bc_event_t *ss7bc_connection_read(ss7bc_connection_t *mcon, int iteration)
|
||||||
{
|
{
|
||||||
unsigned int fromlen = sizeof(struct sockaddr_in);
|
unsigned int fromlen = sizeof(struct sockaddr_in);
|
||||||
#if 0
|
|
||||||
ss7bc_event_t *event = &mcon->event;
|
|
||||||
#endif
|
|
||||||
int bytes = 0;
|
int bytes = 0;
|
||||||
|
|
||||||
bytes = recvfrom(mcon->socket, &mcon->event, sizeof(mcon->event), MSG_DONTWAIT,
|
bytes = recvfrom(mcon->socket, &mcon->event, sizeof(mcon->event), MSG_DONTWAIT,
|
||||||
(struct sockaddr *) &mcon->local_addr, &fromlen);
|
(struct sockaddr *) &mcon->local_addr, &fromlen);
|
||||||
|
|
||||||
if (bytes == sizeof(mcon->event) ||
|
if (bytes == sizeof(mcon->event) || bytes == (sizeof(mcon->event)-sizeof(uint32_t))) {
|
||||||
bytes == (sizeof(mcon->event)-sizeof(uint32_t))) {
|
|
||||||
|
|
||||||
if (mcon->rxseq_reset) {
|
if (mcon->rxseq_reset) {
|
||||||
if (mcon->event.event_id == SIGBOOST_EVENT_SYSTEM_RESTART_ACK) {
|
if (mcon->event.event_id == SIGBOOST_EVENT_SYSTEM_RESTART_ACK) {
|
||||||
|
@ -202,44 +202,15 @@ ss7bc_event_t *ss7bc_connection_read(ss7bc_connection_t *mcon, int iteration)
|
||||||
mcon->rxseq++;
|
mcon->rxseq++;
|
||||||
|
|
||||||
if (mcon->rxseq != mcon->event.fseqno) {
|
if (mcon->rxseq != mcon->event.fseqno) {
|
||||||
zap_log(ZAP_LOG_DEBUG,
|
zap_log(ZAP_LOG_CRIT, "Invalid Sequence Number Expect=%i Rx=%i\n", mcon->rxseq, mcon->event.fseqno);
|
||||||
"------------------------------------------\n");
|
|
||||||
zap_log(ZAP_LOG_DEBUG,
|
|
||||||
"Critical Error: Invalid Sequence Number Expect=%i Rx=%i\n",
|
|
||||||
mcon->rxseq,mcon->event.fseqno);
|
|
||||||
zap_log(ZAP_LOG_DEBUG,
|
|
||||||
"------------------------------------------\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* Debugging only not to be used in production because span/chan can be invalid */
|
|
||||||
if (mcon->event.span < 0 || mcon->event.chan < 0 || mcon->event.span > 16 || mcon->event.chan > 31) {
|
|
||||||
zap_log(ZAP_LOG_DEBUG,
|
|
||||||
"------------------------------------------\n");
|
|
||||||
zap_log(ZAP_LOG_DEBUG,
|
|
||||||
"Critical Error: RX Cmd=%s Invalid Span=%i Chan=%i\n",
|
|
||||||
ss7bc_event_id_name(event->event_id), event->span,event->chan);
|
|
||||||
zap_log(ZAP_LOG_DEBUG,
|
|
||||||
"------------------------------------------\n");
|
|
||||||
|
|
||||||
errno=EAGAIN;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return &mcon->event;
|
return &mcon->event;
|
||||||
} else {
|
} else {
|
||||||
if (iteration == 0) {
|
if (iteration == 0) {
|
||||||
zap_log(ZAP_LOG_DEBUG,
|
zap_log(ZAP_LOG_CRIT, "Invalid Event length from boost rxlen=%i evsz=%i\n", bytes, sizeof(mcon->event));
|
||||||
"------------------------------------------\n");
|
return NULL;
|
||||||
zap_log(ZAP_LOG_DEBUG,
|
|
||||||
"Critical Error: Invalid Event lenght from boost rxlen=%i evsz=%i\n",
|
|
||||||
bytes, sizeof(mcon->event));
|
|
||||||
zap_log(ZAP_LOG_DEBUG,
|
|
||||||
"------------------------------------------\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,43 +220,16 @@ ss7bc_event_t *ss7bc_connection_read(ss7bc_connection_t *mcon, int iteration)
|
||||||
ss7bc_event_t *ss7bc_connection_readp(ss7bc_connection_t *mcon, int iteration)
|
ss7bc_event_t *ss7bc_connection_readp(ss7bc_connection_t *mcon, int iteration)
|
||||||
{
|
{
|
||||||
unsigned int fromlen = sizeof(struct sockaddr_in);
|
unsigned int fromlen = sizeof(struct sockaddr_in);
|
||||||
#if 0
|
|
||||||
ss7bc_event_t *event = &mcon->event;
|
|
||||||
#endif
|
|
||||||
int bytes = 0;
|
int bytes = 0;
|
||||||
|
|
||||||
bytes = recvfrom(mcon->socket, &mcon->event, sizeof(mcon->event), MSG_DONTWAIT,
|
bytes = recvfrom(mcon->socket, &mcon->event, sizeof(mcon->event), MSG_DONTWAIT, (struct sockaddr *) &mcon->local_addr, &fromlen);
|
||||||
(struct sockaddr *) &mcon->local_addr, &fromlen);
|
|
||||||
|
|
||||||
if (bytes == sizeof(mcon->event) ||
|
|
||||||
bytes == (sizeof(mcon->event)-sizeof(uint32_t))) {
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* Debugging only not to be used in production because span/chan can be invalid */
|
|
||||||
if (mcon->event.span < 0 || mcon->event.chan < 0 || mcon->event.span > 16 || mcon->event.chan > 31) {
|
|
||||||
zap_log(ZAP_LOG_DEBUG,
|
|
||||||
"------------------------------------------\n");
|
|
||||||
zap_log(ZAP_LOG_DEBUG,
|
|
||||||
"Critical Error: RXp Cmd=%s Invalid Span=%i Chan=%i\n",
|
|
||||||
ss7bc_event_id_name(event->event_id), event->span,event->chan);
|
|
||||||
zap_log(ZAP_LOG_DEBUG,
|
|
||||||
"------------------------------------------\n");
|
|
||||||
|
|
||||||
errno=EAGAIN;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
if (bytes == sizeof(mcon->event) || bytes == (sizeof(mcon->event)-sizeof(uint32_t))) {
|
||||||
return &mcon->event;
|
return &mcon->event;
|
||||||
} else {
|
} else {
|
||||||
if (iteration == 0) {
|
if (iteration == 0) {
|
||||||
zap_log(ZAP_LOG_DEBUG,
|
zap_log(ZAP_LOG_CRIT, "Critical Error: PQ Invalid Event lenght from boost rxlen=%i evsz=%i\n", bytes, sizeof(mcon->event));
|
||||||
"------------------------------------------\n");
|
return NULL;
|
||||||
zap_log(ZAP_LOG_DEBUG,
|
|
||||||
"Critical Error: PQ Invalid Event lenght from boost rxlen=%i evsz=%i\n",
|
|
||||||
bytes, sizeof(mcon->event));
|
|
||||||
zap_log(ZAP_LOG_DEBUG,
|
|
||||||
"------------------------------------------\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,58 +240,30 @@ ss7bc_event_t *ss7bc_connection_readp(ss7bc_connection_t *mcon, int iteration)
|
||||||
int ss7bc_connection_write(ss7bc_connection_t *mcon, ss7bc_event_t *event)
|
int ss7bc_connection_write(ss7bc_connection_t *mcon, ss7bc_event_t *event)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (!event) {
|
if (!event) {
|
||||||
zap_log(ZAP_LOG_DEBUG, "Critical Error: No Event Device\n");
|
zap_log(ZAP_LOG_DEBUG, "Critical Error: No Event Device\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event->span > 16 || event->chan > 31) {
|
if (event->span > 16 || event->chan > 31) {
|
||||||
zap_log(ZAP_LOG_DEBUG,
|
zap_log(ZAP_LOG_CRIT, "Critical Error: TX Cmd=%s Invalid Span=%i Chan=%i\n", ss7bc_event_id_name(event->event_id), event->span,event->chan);
|
||||||
"------------------------------------------\n");
|
|
||||||
zap_log(ZAP_LOG_DEBUG,
|
|
||||||
"Critical Error: TX Cmd=%s Invalid Span=%i Chan=%i\n",
|
|
||||||
ss7bc_event_id_name(event->event_id), event->span,event->chan);
|
|
||||||
zap_log(ZAP_LOG_DEBUG,
|
|
||||||
"------------------------------------------\n");
|
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
gettimeofday(&event->tv,NULL);
|
gettimeofday(&event->tv,NULL);
|
||||||
|
|
||||||
pthread_mutex_lock(&mcon->lock);
|
zap_mutex_lock(mcon->mutex);
|
||||||
event->fseqno = mcon->txseq++;
|
event->fseqno = mcon->txseq++;
|
||||||
event->bseqno = mcon->rxseq;
|
event->bseqno = mcon->rxseq;
|
||||||
err=sendto(mcon->socket, event, sizeof(ss7bc_event_t), 0,
|
err = sendto(mcon->socket, event, sizeof(ss7bc_event_t), 0, (struct sockaddr *) &mcon->remote_addr, sizeof(mcon->remote_addr));
|
||||||
(struct sockaddr *) &mcon->remote_addr, sizeof(mcon->remote_addr));
|
zap_mutex_unlock(mcon->mutex);
|
||||||
pthread_mutex_unlock(&mcon->lock);
|
|
||||||
|
|
||||||
if (err != sizeof(ss7bc_event_t)) {
|
if (err != sizeof(ss7bc_event_t)) {
|
||||||
err = -1;
|
err = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
zap_log(ZAP_LOG_DEBUG, "TX EVENT: %s:(%X) [w%dg%d] Rc=%i CSid=%i Seq=%i Cd=[%s] Ci=[%s]\n",
|
||||||
zap_log(ZAP_LOG_DEBUG, "TX EVENT\n");
|
|
||||||
zap_log(ZAP_LOG_DEBUG, "===================================\n");
|
|
||||||
zap_log(ZAP_LOG_DEBUG, " tType: %s (%0x HEX)\n",
|
|
||||||
ss7bc_event_id_name(event->event_id),event->event_id);
|
|
||||||
zap_log(ZAP_LOG_DEBUG, " tSpan: [%d]\n",event->span+1);
|
|
||||||
zap_log(ZAP_LOG_DEBUG, " tChan: [%d]\n",event->chan+1);
|
|
||||||
zap_log(ZAP_LOG_DEBUG, " tCalledNum: %s\n",
|
|
||||||
(event->called_number_digits_count ? (char *) event->called_number_digits : "N/A"));
|
|
||||||
zap_log(ZAP_LOG_DEBUG, " tCallingNum: %s\n",
|
|
||||||
(event->calling_number_digits_count ? (char *) event->calling_number_digits : "N/A"));
|
|
||||||
zap_log(ZAP_LOG_DEBUG, " tCause: %d\n",event->release_cause);
|
|
||||||
zap_log(ZAP_LOG_DEBUG, " tInterface: [w%dg%d]\n",event->span+1,event->chan+1);
|
|
||||||
zap_log(ZAP_LOG_DEBUG, " tEvent ID: [%d]\n",event->event_id);
|
|
||||||
zap_log(ZAP_LOG_DEBUG, " tSetup ID: [%d]\n",event->call_setup_id);
|
|
||||||
zap_log(ZAP_LOG_DEBUG, " tSeq: [%d]\n",event->fseqno);
|
|
||||||
zap_log(ZAP_LOG_DEBUG, "===================================\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if 1
|
|
||||||
zap_log(ZAP_LOG_DEBUG,
|
|
||||||
"TX EVENT: %s:(%X) [w%dg%d] Rc=%i CSid=%i Seq=%i Cd=[%s] Ci=[%s]\n",
|
|
||||||
ss7bc_event_id_name(event->event_id),
|
ss7bc_event_id_name(event->event_id),
|
||||||
event->event_id,
|
event->event_id,
|
||||||
event->span+1,
|
event->span+1,
|
||||||
|
@ -358,41 +274,6 @@ int ss7bc_connection_write(ss7bc_connection_t *mcon, ss7bc_event_t *event)
|
||||||
(event->called_number_digits_count ? (char *) event->called_number_digits : "N/A"),
|
(event->called_number_digits_count ? (char *) event->called_number_digits : "N/A"),
|
||||||
(event->calling_number_digits_count ? (char *) event->calling_number_digits : "N/A")
|
(event->calling_number_digits_count ? (char *) event->calling_number_digits : "N/A")
|
||||||
);
|
);
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
|
|
||||||
zap_log(ZAP_LOG_DEBUG,
|
|
||||||
"\nTX EVENT\n"
|
|
||||||
"===================================\n"
|
|
||||||
" tType: %s (%0x HEX)\n"
|
|
||||||
" tSpan: [%d]\n"
|
|
||||||
" tChan: [%d]\n"
|
|
||||||
" tCalledNum: %s\n"
|
|
||||||
" tCallingNum: %s\n"
|
|
||||||
" tCause: %d\n"
|
|
||||||
" tInterface: [w%dg%d]\n"
|
|
||||||
" tEvent ID: [%d]\n"
|
|
||||||
" tSetup ID: [%d]\n"
|
|
||||||
" tSeq: [%d]\n"
|
|
||||||
"===================================\n"
|
|
||||||
"\n",
|
|
||||||
ss7bc_event_id_name(event->event_id),
|
|
||||||
event->event_id,
|
|
||||||
event->span+1,
|
|
||||||
event->chan+1,
|
|
||||||
(event->called_number_digits_count ? (char *) event->called_number_digits : "N/A"),
|
|
||||||
(event->calling_number_digits_count ? (char *) event->calling_number_digits : "N/A"),
|
|
||||||
event->release_cause,
|
|
||||||
event->span+1,
|
|
||||||
event->chan+1,
|
|
||||||
event->event_id,
|
|
||||||
event->call_setup_id,
|
|
||||||
event->fseqno
|
|
||||||
);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,15 +138,15 @@ static void send_caller_id(zap_channel_t *zchan)
|
||||||
zap_fsk_data_init(&fsk_data, databuf, sizeof(databuf));
|
zap_fsk_data_init(&fsk_data, databuf, sizeof(databuf));
|
||||||
zap_fsk_data_add_mdmf(&fsk_data, MDMF_DATETIME, (uint8_t *) time_str, 8);
|
zap_fsk_data_add_mdmf(&fsk_data, MDMF_DATETIME, (uint8_t *) time_str, 8);
|
||||||
|
|
||||||
if (zap_strlen_zero(zchan->caller_data.cid_num)) {
|
if (zap_strlen_zero(zchan->caller_data.cid_num.digits)) {
|
||||||
mt = MDMF_NO_NUM;
|
mt = MDMF_NO_NUM;
|
||||||
zap_set_string(zchan->caller_data.cid_num, "O");
|
zap_set_string(zchan->caller_data.cid_num.digits, "O");
|
||||||
} else if (!strcasecmp(zchan->caller_data.cid_num, "P") || !strcasecmp(zchan->caller_data.cid_num, "O")) {
|
} else if (!strcasecmp(zchan->caller_data.cid_num.digits, "P") || !strcasecmp(zchan->caller_data.cid_num.digits, "O")) {
|
||||||
mt = MDMF_NO_NUM;
|
mt = MDMF_NO_NUM;
|
||||||
} else {
|
} else {
|
||||||
mt = MDMF_PHONE_NUM;
|
mt = MDMF_PHONE_NUM;
|
||||||
}
|
}
|
||||||
zap_fsk_data_add_mdmf(&fsk_data, mt, (uint8_t *) zchan->caller_data.cid_num, (uint8_t)strlen(zchan->caller_data.cid_num));
|
zap_fsk_data_add_mdmf(&fsk_data, mt, (uint8_t *) zchan->caller_data.cid_num.digits, (uint8_t)strlen(zchan->caller_data.cid_num.digits));
|
||||||
|
|
||||||
if (zap_strlen_zero(zchan->caller_data.cid_name)) {
|
if (zap_strlen_zero(zchan->caller_data.cid_name)) {
|
||||||
mt = MDMF_NO_NAME;
|
mt = MDMF_NO_NAME;
|
||||||
|
@ -396,9 +396,9 @@ static void *zap_analog_channel_run(zap_thread_t *me, void *obj)
|
||||||
sig.event_id = ZAP_SIGEVENT_START;
|
sig.event_id = ZAP_SIGEVENT_START;
|
||||||
|
|
||||||
if (zchan->type == ZAP_CHAN_TYPE_FXO) {
|
if (zchan->type == ZAP_CHAN_TYPE_FXO) {
|
||||||
zap_set_string(zchan->caller_data.dnis, zchan->chan_number);
|
zap_set_string(zchan->caller_data.dnis.digits, zchan->chan_number);
|
||||||
} else {
|
} else {
|
||||||
zap_set_string(zchan->caller_data.dnis, dtmf);
|
zap_set_string(zchan->caller_data.dnis.digits, dtmf);
|
||||||
}
|
}
|
||||||
|
|
||||||
analog_data->sig_cb(&sig);
|
analog_data->sig_cb(&sig);
|
||||||
|
@ -556,11 +556,11 @@ static void *zap_analog_channel_run(zap_thread_t *me, void *obj)
|
||||||
zap_log(ZAP_LOG_ERROR, "Failure indication detected!\n");
|
zap_log(ZAP_LOG_ERROR, "Failure indication detected!\n");
|
||||||
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_BUSY);
|
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_BUSY);
|
||||||
} else if (zchan->detected_tones[ZAP_TONEMAP_DIAL]) {
|
} else if (zchan->detected_tones[ZAP_TONEMAP_DIAL]) {
|
||||||
if (zap_strlen_zero(zchan->caller_data.ani)) {
|
if (zap_strlen_zero(zchan->caller_data.ani.digits)) {
|
||||||
zap_log(ZAP_LOG_ERROR, "No Digits to send!\n");
|
zap_log(ZAP_LOG_ERROR, "No Digits to send!\n");
|
||||||
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_BUSY);
|
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_BUSY);
|
||||||
} else {
|
} else {
|
||||||
if (zap_channel_command(zchan, ZAP_COMMAND_SEND_DTMF, zchan->caller_data.ani) != ZAP_SUCCESS) {
|
if (zap_channel_command(zchan, ZAP_COMMAND_SEND_DTMF, zchan->caller_data.ani.digits) != ZAP_SUCCESS) {
|
||||||
zap_log(ZAP_LOG_ERROR, "Send Digits Failed [%s]\n", zchan->last_error);
|
zap_log(ZAP_LOG_ERROR, "Send Digits Failed [%s]\n", zchan->last_error);
|
||||||
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_BUSY);
|
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_BUSY);
|
||||||
} else {
|
} else {
|
||||||
|
@ -570,7 +570,7 @@ static void *zap_analog_channel_run(zap_thread_t *me, void *obj)
|
||||||
zchan->needed_tones[ZAP_TONEMAP_FAIL1] = 1;
|
zchan->needed_tones[ZAP_TONEMAP_FAIL1] = 1;
|
||||||
zchan->needed_tones[ZAP_TONEMAP_FAIL2] = 1;
|
zchan->needed_tones[ZAP_TONEMAP_FAIL2] = 1;
|
||||||
zchan->needed_tones[ZAP_TONEMAP_FAIL3] = 1;
|
zchan->needed_tones[ZAP_TONEMAP_FAIL3] = 1;
|
||||||
dial_timeout = ((zchan->dtmf_on + zchan->dtmf_off) * strlen(zchan->caller_data.ani)) + 2000;
|
dial_timeout = ((zchan->dtmf_on + zchan->dtmf_off) * strlen(zchan->caller_data.ani.digits)) + 2000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (zchan->detected_tones[ZAP_TONEMAP_RING]) {
|
} else if (zchan->detected_tones[ZAP_TONEMAP_RING]) {
|
||||||
|
|
|
@ -669,6 +669,23 @@ zap_status_t zap_channel_set_state(zap_channel_t *zchan, zap_channel_state_t sta
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ok) {
|
if (ok) {
|
||||||
|
if (state == ZAP_CHANNEL_STATE_PROGRESS) {
|
||||||
|
zap_set_flag(zchan, ZAP_CHANNEL_PROGRESS);
|
||||||
|
} else if (state == ZAP_CHANNEL_STATE_UP) {
|
||||||
|
zap_set_flag(zchan, ZAP_CHANNEL_PROGRESS);
|
||||||
|
zap_set_flag(zchan, ZAP_CHANNEL_MEDIA);
|
||||||
|
zap_set_flag(zchan, ZAP_CHANNEL_ANSWERED);
|
||||||
|
} else if (state == ZAP_CHANNEL_STATE_PROGRESS_MEDIA) {
|
||||||
|
zap_set_flag(zchan, ZAP_CHANNEL_PROGRESS);
|
||||||
|
zap_set_flag(zchan, ZAP_CHANNEL_MEDIA);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (zchan->state == ZAP_CHANNEL_STATE_DOWN) {
|
||||||
|
zchan->span->active_count++;
|
||||||
|
} else if (state == ZAP_CHANNEL_STATE_DOWN) {
|
||||||
|
zchan->span->active_count--;
|
||||||
|
}
|
||||||
|
|
||||||
zap_set_flag(zchan, ZAP_CHANNEL_STATE_CHANGE);
|
zap_set_flag(zchan, ZAP_CHANNEL_STATE_CHANGE);
|
||||||
zap_set_flag(zchan->span, ZAP_SPAN_STATE_CHANGE);
|
zap_set_flag(zchan->span, ZAP_SPAN_STATE_CHANGE);
|
||||||
zchan->last_state = zchan->state;
|
zchan->last_state = zchan->state;
|
||||||
|
@ -690,6 +707,12 @@ zap_status_t zap_channel_open_any(uint32_t span_id, zap_direction_t direction, c
|
||||||
|
|
||||||
zap_mutex_lock(globals.mutex);
|
zap_mutex_lock(globals.mutex);
|
||||||
|
|
||||||
|
if (globals.spans[span_id].active_count >= globals.spans[span_id].chan_count) {
|
||||||
|
zap_log(ZAP_LOG_CRIT, "All circuits are busy.\n");
|
||||||
|
*zchan = NULL;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
if (span_id && globals.spans[span_id].channel_request) {
|
if (span_id && globals.spans[span_id].channel_request) {
|
||||||
status = globals.spans[span_id].channel_request(&globals.spans[span_id], direction, caller_data, zchan);
|
status = globals.spans[span_id].channel_request(&globals.spans[span_id], direction, caller_data, zchan);
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -1587,14 +1610,14 @@ zap_status_t zap_channel_read(zap_channel_t *zchan, void *data, zap_size_t *data
|
||||||
if (mlen > sizeof(zchan->caller_data.ani)) {
|
if (mlen > sizeof(zchan->caller_data.ani)) {
|
||||||
mlen = sizeof(zchan->caller_data.ani);
|
mlen = sizeof(zchan->caller_data.ani);
|
||||||
}
|
}
|
||||||
zap_set_string(zchan->caller_data.ani, str);
|
zap_set_string(zchan->caller_data.ani.digits, str);
|
||||||
zap_set_string(zchan->caller_data.cid_num, zchan->caller_data.ani);
|
zap_set_string(zchan->caller_data.cid_num.digits, zchan->caller_data.ani.digits);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MDMF_NO_NUM:
|
case MDMF_NO_NUM:
|
||||||
{
|
{
|
||||||
zap_set_string(zchan->caller_data.ani, *str == 'P' ? "private" : "unknown");
|
zap_set_string(zchan->caller_data.ani.digits, *str == 'P' ? "private" : "unknown");
|
||||||
zap_set_string(zchan->caller_data.cid_name, zchan->caller_data.ani);
|
zap_set_string(zchan->caller_data.cid_name, zchan->caller_data.ani.digits);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MDMF_PHONE_NAME:
|
case MDMF_PHONE_NAME:
|
||||||
|
|
|
@ -220,10 +220,10 @@ static L3INT zap_isdn_931_34(void *pvt, L2UCHAR *msg, L2INT mlen)
|
||||||
zchan->span->channels_remote_crv[gen->CRV] = zchan;
|
zchan->span->channels_remote_crv[gen->CRV] = zchan;
|
||||||
memset(&zchan->caller_data, 0, sizeof(zchan->caller_data));
|
memset(&zchan->caller_data, 0, sizeof(zchan->caller_data));
|
||||||
|
|
||||||
zap_set_string(zchan->caller_data.cid_num, (char *)callingnum->Digit);
|
zap_set_string(zchan->caller_data.cid_num.digits, (char *)callingnum->Digit);
|
||||||
zap_set_string(zchan->caller_data.cid_name, (char *)callingnum->Digit);
|
zap_set_string(zchan->caller_data.cid_name, (char *)callingnum->Digit);
|
||||||
zap_set_string(zchan->caller_data.ani, (char *)callingnum->Digit);
|
zap_set_string(zchan->caller_data.ani.digits, (char *)callingnum->Digit);
|
||||||
zap_set_string(zchan->caller_data.dnis, (char *)callednum->Digit);
|
zap_set_string(zchan->caller_data.dnis.digits, (char *)callednum->Digit);
|
||||||
|
|
||||||
zchan->caller_data.CRV = gen->CRV;
|
zchan->caller_data.CRV = gen->CRV;
|
||||||
if (cplen > sizeof(zchan->caller_data.raw_data)) {
|
if (cplen > sizeof(zchan->caller_data.raw_data)) {
|
||||||
|
@ -472,17 +472,17 @@ static __inline__ void state_advance(zap_channel_t *zchan)
|
||||||
/* 10 User-provided, verified and failed */
|
/* 10 User-provided, verified and failed */
|
||||||
/* 11 Network provided */
|
/* 11 Network provided */
|
||||||
CallingNum.ScreenInd = 0;
|
CallingNum.ScreenInd = 0;
|
||||||
CallingNum.Size = CallingNum.Size + (unsigned char)strlen(zchan->caller_data.cid_num);
|
CallingNum.Size = CallingNum.Size + (unsigned char)strlen(zchan->caller_data.cid_num.digits);
|
||||||
gen->CallingNum = Q931AppendIE((L3UCHAR *) gen, (L3UCHAR *) &CallingNum);
|
gen->CallingNum = Q931AppendIE((L3UCHAR *) gen, (L3UCHAR *) &CallingNum);
|
||||||
ptrCallingNum = Q931GetIEPtr(gen->CallingNum, gen->buf);
|
ptrCallingNum = Q931GetIEPtr(gen->CallingNum, gen->buf);
|
||||||
zap_copy_string((char *)ptrCallingNum->Digit, zchan->caller_data.cid_num, strlen(zchan->caller_data.cid_num)+1);
|
zap_copy_string((char *)ptrCallingNum->Digit, zchan->caller_data.cid_num.digits, strlen(zchan->caller_data.cid_num.digits)+1);
|
||||||
|
|
||||||
CalledNum.TypNum = 2;
|
CalledNum.TypNum = 2;
|
||||||
CalledNum.NumPlanID = 1;
|
CalledNum.NumPlanID = 1;
|
||||||
CalledNum.Size = CalledNum.Size + (unsigned char)strlen(zchan->caller_data.ani);
|
CalledNum.Size = CalledNum.Size + (unsigned char)strlen(zchan->caller_data.ani.digits);
|
||||||
gen->CalledNum = Q931AppendIE((L3UCHAR *) gen, (L3UCHAR *) &CalledNum);
|
gen->CalledNum = Q931AppendIE((L3UCHAR *) gen, (L3UCHAR *) &CalledNum);
|
||||||
ptrCalledNum = Q931GetIEPtr(gen->CalledNum, gen->buf);
|
ptrCalledNum = Q931GetIEPtr(gen->CalledNum, gen->buf);
|
||||||
zap_copy_string((char *)ptrCalledNum->Digit, zchan->caller_data.ani, strlen(zchan->caller_data.ani)+1);
|
zap_copy_string((char *)ptrCalledNum->Digit, zchan->caller_data.ani.digits, strlen(zchan->caller_data.ani.digits)+1);
|
||||||
|
|
||||||
Q931Rx43(&isdn_data->q931, (L3UCHAR *) gen, gen->Size);
|
Q931Rx43(&isdn_data->q931, (L3UCHAR *) gen, gen->Size);
|
||||||
zchan->span->channels_local_crv[gen->CRV] = zchan;
|
zchan->span->channels_local_crv[gen->CRV] = zchan;
|
||||||
|
|
|
@ -53,7 +53,7 @@ typedef struct {
|
||||||
|
|
||||||
static ss7_boost_request_id_t current_request = 0;
|
static ss7_boost_request_id_t current_request = 0;
|
||||||
|
|
||||||
static ss7_boost_request_t OUTBOUND_REQUESTS[ZAP_MAX_CHANNELS_SPAN] = {{ 0 }};
|
static ss7_boost_request_t OUTBOUND_REQUESTS[MAX_PENDING_CALLS] = {{ 0 }};
|
||||||
|
|
||||||
static zap_mutex_t *request_mutex = NULL;
|
static zap_mutex_t *request_mutex = NULL;
|
||||||
static zap_mutex_t *signal_mutex = NULL;
|
static zap_mutex_t *signal_mutex = NULL;
|
||||||
|
@ -63,7 +63,7 @@ static ss7_boost_request_id_t next_request_id(void)
|
||||||
ss7_boost_request_id_t r;
|
ss7_boost_request_id_t r;
|
||||||
|
|
||||||
zap_mutex_lock(request_mutex);
|
zap_mutex_lock(request_mutex);
|
||||||
if (current_request == ZAP_MAX_CHANNELS_SPAN) {
|
if (current_request == MAX_PENDING_CALLS) {
|
||||||
current_request = 0;
|
current_request = 0;
|
||||||
}
|
}
|
||||||
r = current_request++;
|
r = current_request++;
|
||||||
|
@ -90,31 +90,51 @@ static zap_channel_t *find_zchan(zap_span_t *span, ss7bc_event_t *event)
|
||||||
static ZIO_CHANNEL_REQUEST_FUNCTION(ss7_boost_channel_request)
|
static ZIO_CHANNEL_REQUEST_FUNCTION(ss7_boost_channel_request)
|
||||||
{
|
{
|
||||||
zap_ss7_boost_data_t *ss7_boost_data = span->signal_data;
|
zap_ss7_boost_data_t *ss7_boost_data = span->signal_data;
|
||||||
zap_status_t status = ZAP_SUCCESS;
|
zap_status_t status = ZAP_FAIL;
|
||||||
ss7_boost_request_id_t r = next_request_id();
|
ss7_boost_request_id_t r;
|
||||||
ss7bc_event_t event = {0};
|
ss7bc_event_t event = {0};
|
||||||
int sanity = 60000;
|
int sanity = 60000;
|
||||||
|
|
||||||
ss7bc_call_init(&event, caller_data->cid_num, caller_data->ani, r);
|
if (zap_test_flag(span, ZAP_SPAN_SUSPENDED)) {
|
||||||
|
zap_log(ZAP_LOG_CRIT, "SPAN is not online.\n");
|
||||||
|
*zchan = NULL;
|
||||||
|
return ZAP_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (span->active_count >= span->chan_count) {
|
||||||
|
zap_log(ZAP_LOG_CRIT, "All circuits are busy.\n");
|
||||||
|
*zchan = NULL;
|
||||||
|
return ZAP_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
r = next_request_id();
|
||||||
|
|
||||||
|
ss7bc_call_init(&event, caller_data->cid_num.digits, caller_data->ani.digits, r);
|
||||||
|
zap_set_string(event.redirection_string, caller_data->rdnis.digits);
|
||||||
|
|
||||||
|
|
||||||
OUTBOUND_REQUESTS[r].status = BST_WAITING;
|
OUTBOUND_REQUESTS[r].status = BST_WAITING;
|
||||||
OUTBOUND_REQUESTS[r].span = span;
|
OUTBOUND_REQUESTS[r].span = span;
|
||||||
|
|
||||||
if (ss7bc_connection_write(&ss7_boost_data->mcon, &event) <= 0) {
|
if (ss7bc_connection_write(&ss7_boost_data->mcon, &event) <= 0) {
|
||||||
zap_log(ZAP_LOG_CRIT, "Failed to tx on ISUP socket [%s]\n", strerror(errno));
|
zap_log(ZAP_LOG_CRIT, "Failed to tx on ISUP socket [%s]\n", strerror(errno));
|
||||||
status = ZAP_FAIL;
|
status = ZAP_FAIL;
|
||||||
|
*zchan = NULL;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(OUTBOUND_REQUESTS[r].status == BST_WAITING) {
|
while(zap_running() && OUTBOUND_REQUESTS[r].status == BST_WAITING) {
|
||||||
zap_sleep(1);
|
zap_sleep(1);
|
||||||
if (!--sanity) {
|
if (!--sanity) {
|
||||||
status = ZAP_FAIL;
|
status = ZAP_FAIL;
|
||||||
|
*zchan = NULL;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OUTBOUND_REQUESTS[r].status == BST_READY) {
|
if (OUTBOUND_REQUESTS[r].status == BST_READY) {
|
||||||
*zchan = OUTBOUND_REQUESTS[r].zchan;
|
*zchan = OUTBOUND_REQUESTS[r].zchan;
|
||||||
|
status = ZAP_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
@ -141,7 +161,7 @@ static void handle_call_start_ack(ss7bc_connection_t *mcon, ss7bc_event_t *event
|
||||||
if (zap_channel_open_chan(zchan) != ZAP_SUCCESS) {
|
if (zap_channel_open_chan(zchan) != ZAP_SUCCESS) {
|
||||||
zap_log(ZAP_LOG_ERROR, "OPEN ERROR [%s]\n", zchan->last_error);
|
zap_log(ZAP_LOG_ERROR, "OPEN ERROR [%s]\n", zchan->last_error);
|
||||||
} else {
|
} else {
|
||||||
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_DIALING);
|
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_PROGRESS_MEDIA);
|
||||||
OUTBOUND_REQUESTS[event->call_setup_id].zchan = zchan;
|
OUTBOUND_REQUESTS[event->call_setup_id].zchan = zchan;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -152,7 +172,7 @@ static void handle_call_start_ack(ss7bc_connection_t *mcon, ss7bc_event_t *event
|
||||||
event->chan,
|
event->chan,
|
||||||
event->call_setup_id,
|
event->call_setup_id,
|
||||||
SIGBOOST_EVENT_CALL_STOPPED,
|
SIGBOOST_EVENT_CALL_STOPPED,
|
||||||
0);
|
ZAP_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||||
OUTBOUND_REQUESTS[event->call_setup_id].status = BST_FAIL;
|
OUTBOUND_REQUESTS[event->call_setup_id].status = BST_FAIL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -175,14 +195,23 @@ static void handle_call_stop(zap_span_t *span, ss7bc_connection_t *mcon, ss7bc_e
|
||||||
zap_channel_t *zchan;
|
zap_channel_t *zchan;
|
||||||
|
|
||||||
if ((zchan = find_zchan(span, event))) {
|
if ((zchan = find_zchan(span, event))) {
|
||||||
|
zchan->caller_data.hangup_cause = event->release_cause;
|
||||||
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_TERMINATING);
|
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_TERMINATING);
|
||||||
|
|
||||||
|
ss7bc_exec_command(mcon,
|
||||||
|
event->span,
|
||||||
|
event->chan,
|
||||||
|
0,
|
||||||
|
SIGBOOST_EVENT_CALL_STOPPED_ACK,
|
||||||
|
0);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ss7bc_exec_command(mcon,
|
ss7bc_exec_command(mcon,
|
||||||
event->span,
|
event->span,
|
||||||
event->chan,
|
event->chan,
|
||||||
0,
|
0,
|
||||||
SIGBOOST_EVENT_CALL_STOPPED,
|
SIGBOOST_EVENT_CALL_STOPPED,
|
||||||
0);
|
ZAP_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,7 +227,7 @@ static void handle_call_answer(zap_span_t *span, ss7bc_connection_t *mcon, ss7bc
|
||||||
event->chan,
|
event->chan,
|
||||||
0,
|
0,
|
||||||
SIGBOOST_EVENT_CALL_STOPPED,
|
SIGBOOST_EVENT_CALL_STOPPED,
|
||||||
0);
|
ZAP_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,7 +235,14 @@ static void handle_call_start(zap_span_t *span, ss7bc_connection_t *mcon, ss7bc_
|
||||||
{
|
{
|
||||||
zap_channel_t *zchan;
|
zap_channel_t *zchan;
|
||||||
|
|
||||||
if ((zchan = find_zchan(span, event))) {
|
if (!(zchan = find_zchan(span, event))) {
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (zap_channel_open_chan(zchan) != ZAP_SUCCESS) {
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
ss7bc_exec_command(mcon,
|
ss7bc_exec_command(mcon,
|
||||||
event->span,
|
event->span,
|
||||||
event->chan,
|
event->chan,
|
||||||
|
@ -214,38 +250,77 @@ static void handle_call_start(zap_span_t *span, ss7bc_connection_t *mcon, ss7bc_
|
||||||
SIGBOOST_EVENT_CALL_START_ACK,
|
SIGBOOST_EVENT_CALL_START_ACK,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
|
zap_set_string(zchan->caller_data.cid_num.digits, (char *)event->calling_number_digits);
|
||||||
|
zap_set_string(zchan->caller_data.cid_name, (char *)event->calling_number_digits);
|
||||||
|
zap_set_string(zchan->caller_data.ani.digits, (char *)event->calling_number_digits);
|
||||||
|
zap_set_string(zchan->caller_data.dnis.digits, (char *)event->called_number_digits);
|
||||||
|
zap_set_string(zchan->caller_data.rdnis.digits, (char *)event->redirection_string);
|
||||||
|
zchan->caller_data.screen = event->calling_number_screening_ind;
|
||||||
|
zchan->caller_data.pres = event->calling_number_presentation;
|
||||||
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_RING);
|
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_RING);
|
||||||
} else {
|
return;
|
||||||
|
|
||||||
|
error:
|
||||||
|
|
||||||
ss7bc_exec_command(mcon,
|
ss7bc_exec_command(mcon,
|
||||||
event->span,
|
event->span,
|
||||||
event->chan,
|
event->chan,
|
||||||
0,
|
0,
|
||||||
SIGBOOST_EVENT_CALL_START_NACK,
|
SIGBOOST_EVENT_CALL_START_NACK,
|
||||||
0);
|
0);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void handle_heartbeat(ss7bc_connection_t *mcon, ss7bc_event_t *event)
|
static void handle_heartbeat(ss7bc_connection_t *mcon, ss7bc_event_t *event)
|
||||||
{
|
{
|
||||||
int err = ss7bc_connection_write(mcon, event);
|
int err;
|
||||||
|
|
||||||
|
|
||||||
|
err = ss7bc_connection_write(mcon, event);
|
||||||
|
|
||||||
if (err <= 0) {
|
if (err <= 0) {
|
||||||
zap_log(ZAP_LOG_CRIT, "Failed to tx on ISUP socket [%s]: %s\n", strerror(errno));
|
zap_log(ZAP_LOG_CRIT, "Failed to tx on ISUP socket [%s]: %s\n", strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mcon->hb_elapsed = 0;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_restart_ack(ss7bc_connection_t *mcon, ss7bc_event_t *event)
|
static void handle_restart_ack(ss7bc_connection_t *mcon, zap_span_t *span, ss7bc_event_t *event)
|
||||||
{
|
{
|
||||||
mcon->rxseq_reset = 0;
|
mcon->rxseq_reset = 0;
|
||||||
|
mcon->up = 1;
|
||||||
|
zap_set_state_all(span, ZAP_CHANNEL_STATE_RESTART);
|
||||||
|
zap_clear_flag_locked(span, ZAP_SPAN_SUSPENDED);
|
||||||
|
mcon->hb_elapsed = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int parse_ss7_event(zap_span_t *span, ss7bc_connection_t *mcon, ss7bc_event_t *event)
|
static int parse_ss7_event(zap_span_t *span, ss7bc_connection_t *mcon, ss7bc_event_t *event)
|
||||||
{
|
{
|
||||||
zap_mutex_lock(signal_mutex);
|
zap_mutex_lock(signal_mutex);
|
||||||
|
|
||||||
|
if (zap_test_flag(span, ZAP_SPAN_SUSPENDED) &&
|
||||||
|
event->event_id != SIGBOOST_EVENT_SYSTEM_RESTART_ACK && event->event_id != SIGBOOST_EVENT_HEARTBEAT) {
|
||||||
|
|
||||||
|
zap_log(ZAP_LOG_WARNING,
|
||||||
|
"INVALID EVENT: %s:(%X) [w%dg%d] Rc=%i CSid=%i Seq=%i Cd=[%s] Ci=[%s]\n",
|
||||||
|
ss7bc_event_id_name(event->event_id),
|
||||||
|
event->event_id,
|
||||||
|
event->span+1,
|
||||||
|
event->chan+1,
|
||||||
|
event->release_cause,
|
||||||
|
event->call_setup_id,
|
||||||
|
event->fseqno,
|
||||||
|
(event->called_number_digits_count ? (char *) event->called_number_digits : "N/A"),
|
||||||
|
(event->calling_number_digits_count ? (char *) event->calling_number_digits : "N/A")
|
||||||
|
);
|
||||||
|
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
zap_log(ZAP_LOG_DEBUG,
|
zap_log(ZAP_LOG_DEBUG,
|
||||||
"RX EVENT: %s:(%X) [w%dg%d] Rc=%i CSid=%i Seq=%i Cd=[%s] Ci=[%s]\n",
|
"RX EVENT: %s:(%X) [w%dg%d] Rc=%i CSid=%i Seq=%i Cd=[%s] Ci=[%s]\n",
|
||||||
ss7bc_event_id_name(event->event_id),
|
ss7bc_event_id_name(event->event_id),
|
||||||
|
@ -260,6 +335,7 @@ static int parse_ss7_event(zap_span_t *span, ss7bc_connection_t *mcon, ss7bc_eve
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
switch(event->event_id) {
|
switch(event->event_id) {
|
||||||
|
|
||||||
case SIGBOOST_EVENT_CALL_START:
|
case SIGBOOST_EVENT_CALL_START:
|
||||||
|
@ -293,7 +369,7 @@ static int parse_ss7_event(zap_span_t *span, ss7bc_connection_t *mcon, ss7bc_eve
|
||||||
//handle_call_stop(event);
|
//handle_call_stop(event);
|
||||||
break;
|
break;
|
||||||
case SIGBOOST_EVENT_SYSTEM_RESTART_ACK:
|
case SIGBOOST_EVENT_SYSTEM_RESTART_ACK:
|
||||||
handle_restart_ack(mcon,event);
|
handle_restart_ack(mcon, span, event);
|
||||||
break;
|
break;
|
||||||
case SIGBOOST_EVENT_AUTO_CALL_GAP_ABATE:
|
case SIGBOOST_EVENT_AUTO_CALL_GAP_ABATE:
|
||||||
//handle_gap_abate(event);
|
//handle_gap_abate(event);
|
||||||
|
@ -303,6 +379,8 @@ static int parse_ss7_event(zap_span_t *span, ss7bc_connection_t *mcon, ss7bc_eve
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
end:
|
||||||
|
|
||||||
zap_mutex_unlock(signal_mutex);
|
zap_mutex_unlock(signal_mutex);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -316,8 +394,7 @@ static __inline__ void state_advance(zap_channel_t *zchan)
|
||||||
zap_sigmsg_t sig;
|
zap_sigmsg_t sig;
|
||||||
zap_status_t status;
|
zap_status_t status;
|
||||||
|
|
||||||
zap_log(ZAP_LOG_ERROR, "%d:%d STATE [%s]\n",
|
zap_log(ZAP_LOG_DEBUG, "%d:%d STATE [%s]\n", zchan->span_id, zchan->chan_id, zap_channel_state2str(zchan->state));
|
||||||
zchan->span_id, zchan->chan_id, zap_channel_state2str(zchan->state));
|
|
||||||
|
|
||||||
memset(&sig, 0, sizeof(sig));
|
memset(&sig, 0, sizeof(sig));
|
||||||
sig.chan_id = zchan->chan_id;
|
sig.chan_id = zchan->chan_id;
|
||||||
|
@ -330,15 +407,16 @@ static __inline__ void state_advance(zap_channel_t *zchan)
|
||||||
zap_channel_done(zchan);
|
zap_channel_done(zchan);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case ZAP_CHANNEL_STATE_PROGRESS_MEDIA:
|
||||||
case ZAP_CHANNEL_STATE_PROGRESS:
|
case ZAP_CHANNEL_STATE_PROGRESS:
|
||||||
{
|
{
|
||||||
if (zap_test_flag(zchan, ZAP_CHANNEL_OUTBOUND)) {
|
if (zap_test_flag(zchan, ZAP_CHANNEL_OUTBOUND)) {
|
||||||
sig.event_id = ZAP_SIGEVENT_PROGRESS;
|
sig.event_id = ZAP_SIGEVENT_PROGRESS_MEDIA;
|
||||||
if ((status = ss7_boost_data->signal_cb(&sig) != ZAP_SUCCESS)) {
|
if ((status = ss7_boost_data->signal_cb(&sig) != ZAP_SUCCESS)) {
|
||||||
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_HANGUP);
|
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_HANGUP);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//send progress
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -357,18 +435,8 @@ static __inline__ void state_advance(zap_channel_t *zchan)
|
||||||
{
|
{
|
||||||
if (zchan->last_state > ZAP_CHANNEL_STATE_HANGUP) {
|
if (zchan->last_state > ZAP_CHANNEL_STATE_HANGUP) {
|
||||||
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_HANGUP);
|
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_HANGUP);
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ZAP_CHANNEL_STATE_PROGRESS_MEDIA:
|
|
||||||
{
|
|
||||||
if (zap_test_flag(zchan, ZAP_CHANNEL_OUTBOUND)) {
|
|
||||||
sig.event_id = ZAP_SIGEVENT_PROGRESS_MEDIA;
|
|
||||||
if ((status = ss7_boost_data->signal_cb(&sig) != ZAP_SUCCESS)) {
|
|
||||||
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_HANGUP);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// send alerting
|
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_DOWN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -380,7 +448,12 @@ static __inline__ void state_advance(zap_channel_t *zchan)
|
||||||
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_HANGUP);
|
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_HANGUP);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// send connect
|
ss7bc_exec_command(mcon,
|
||||||
|
zchan->physical_span_id-1,
|
||||||
|
zchan->physical_chan_id-1,
|
||||||
|
0,
|
||||||
|
SIGBOOST_EVENT_CALL_ANSWERED,
|
||||||
|
0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -395,7 +468,7 @@ static __inline__ void state_advance(zap_channel_t *zchan)
|
||||||
zchan->physical_chan_id-1,
|
zchan->physical_chan_id-1,
|
||||||
0,
|
0,
|
||||||
SIGBOOST_EVENT_CALL_STOPPED,
|
SIGBOOST_EVENT_CALL_STOPPED,
|
||||||
0);
|
zchan->caller_data.hangup_cause);
|
||||||
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_DOWN);
|
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_DOWN);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -410,6 +483,10 @@ static __inline__ void state_advance(zap_channel_t *zchan)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static __inline__ void init_outgoing_array(void)
|
||||||
|
{
|
||||||
|
memset(&OUTBOUND_REQUESTS, 0, sizeof(OUTBOUND_REQUESTS));
|
||||||
|
}
|
||||||
|
|
||||||
static __inline__ void check_state(zap_span_t *span)
|
static __inline__ void check_state(zap_span_t *span)
|
||||||
{
|
{
|
||||||
|
@ -429,12 +506,12 @@ static __inline__ void check_state(zap_span_t *span)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void *zap_ss7_boost_run(zap_thread_t *me, void *obj)
|
static void *zap_ss7_boost_run(zap_thread_t *me, void *obj)
|
||||||
{
|
{
|
||||||
zap_span_t *span = (zap_span_t *) obj;
|
zap_span_t *span = (zap_span_t *) obj;
|
||||||
zap_ss7_boost_data_t *ss7_boost_data = span->signal_data;
|
zap_ss7_boost_data_t *ss7_boost_data = span->signal_data;
|
||||||
ss7bc_connection_t *mcon, *pcon;
|
ss7bc_connection_t *mcon, *pcon;
|
||||||
|
uint32_t ms = 10, too_long = 60000;
|
||||||
|
|
||||||
|
|
||||||
ss7_boost_data->pcon = ss7_boost_data->mcon;
|
ss7_boost_data->pcon = ss7_boost_data->mcon;
|
||||||
|
@ -460,7 +537,9 @@ static void *zap_ss7_boost_run(zap_thread_t *me, void *obj)
|
||||||
mcon = &ss7_boost_data->mcon;
|
mcon = &ss7_boost_data->mcon;
|
||||||
pcon = &ss7_boost_data->pcon;
|
pcon = &ss7_boost_data->pcon;
|
||||||
|
|
||||||
mcon->rxseq_reset = 1;
|
top:
|
||||||
|
|
||||||
|
init_outgoing_array();
|
||||||
|
|
||||||
ss7bc_exec_command(mcon,
|
ss7bc_exec_command(mcon,
|
||||||
0,
|
0,
|
||||||
|
@ -471,7 +550,7 @@ static void *zap_ss7_boost_run(zap_thread_t *me, void *obj)
|
||||||
|
|
||||||
while (zap_running() && zap_test_flag(ss7_boost_data, ZAP_SS7_BOOST_RUNNING)) {
|
while (zap_running() && zap_test_flag(ss7_boost_data, ZAP_SS7_BOOST_RUNNING)) {
|
||||||
fd_set rfds, efds;
|
fd_set rfds, efds;
|
||||||
struct timeval tv = { 0, 100000 };
|
struct timeval tv = { 0, ms * 1000 };
|
||||||
int max, activity, i = 0;
|
int max, activity, i = 0;
|
||||||
ss7bc_event_t *event = NULL;
|
ss7bc_event_t *event = NULL;
|
||||||
|
|
||||||
|
@ -488,10 +567,7 @@ static void *zap_ss7_boost_run(zap_thread_t *me, void *obj)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!activity) {
|
if (activity) {
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (FD_ISSET(pcon->socket, &efds) || FD_ISSET(mcon->socket, &efds)) {
|
if (FD_ISSET(pcon->socket, &efds) || FD_ISSET(mcon->socket, &efds)) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -499,16 +575,25 @@ static void *zap_ss7_boost_run(zap_thread_t *me, void *obj)
|
||||||
if (FD_ISSET(pcon->socket, &rfds)) {
|
if (FD_ISSET(pcon->socket, &rfds)) {
|
||||||
if ((event = ss7bc_connection_readp(pcon, i))) {
|
if ((event = ss7bc_connection_readp(pcon, i))) {
|
||||||
parse_ss7_event(span, pcon, event);
|
parse_ss7_event(span, pcon, event);
|
||||||
}
|
} else goto top;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FD_ISSET(mcon->socket, &rfds)) {
|
if (FD_ISSET(mcon->socket, &rfds)) {
|
||||||
if ((event = ss7bc_connection_read(mcon, i))) {
|
if ((event = ss7bc_connection_read(mcon, i))) {
|
||||||
parse_ss7_event(span, mcon, event);
|
parse_ss7_event(span, mcon, event);
|
||||||
|
} else goto top;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
check_state(span);
|
check_state(span);
|
||||||
|
mcon->hb_elapsed += ms;
|
||||||
|
|
||||||
|
if (mcon->hb_elapsed >= too_long && (mcon->up || !zap_test_flag(span, ZAP_SPAN_SUSPENDED))) {
|
||||||
|
zap_set_state_all(span, ZAP_CHANNEL_STATE_RESTART);
|
||||||
|
zap_set_flag_locked(span, ZAP_SPAN_SUSPENDED);
|
||||||
|
mcon->up = 0;
|
||||||
|
zap_log(ZAP_LOG_CRIT, "Lost Heartbeat!\n");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -568,6 +653,7 @@ zap_status_t zap_ss7_boost_configure_span(zap_span_t *span,
|
||||||
span->signal_type = ZAP_SIGTYPE_SS7BOOST;
|
span->signal_type = ZAP_SIGTYPE_SS7BOOST;
|
||||||
span->outgoing_call = ss7_boost_outgoing_call;
|
span->outgoing_call = ss7_boost_outgoing_call;
|
||||||
span->channel_request = ss7_boost_channel_request;
|
span->channel_request = ss7_boost_channel_request;
|
||||||
|
zap_set_flag_locked(span, ZAP_SPAN_SUSPENDED);
|
||||||
|
|
||||||
return ZAP_SUCCESS;
|
return ZAP_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue