merge in some boost changes
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@511 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
parent
0fd7cd7b7b
commit
a0d9ff1e56
|
@ -82,6 +82,12 @@ typedef struct ss7bc_ip_cfg
|
|||
int remote_port;
|
||||
}ss7bc_ip_cfg_t;
|
||||
|
||||
typedef enum {
|
||||
MSU_FLAG_EVENT = (1 << 0),
|
||||
MSU_FLAG_DOWN = (1 << 1)
|
||||
} ss7bc_flag_t;
|
||||
|
||||
|
||||
struct ss7bc_connection {
|
||||
zap_socket_t socket;
|
||||
struct sockaddr_in local_addr;
|
||||
|
@ -98,13 +104,8 @@ struct ss7bc_connection {
|
|||
unsigned int rxseq_reset;
|
||||
ss7bc_ip_cfg_t cfg;
|
||||
uint32_t hb_elapsed;
|
||||
int up;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
MSU_FLAG_EVENT = (1 << 0)
|
||||
} ss7bc_flag_t;
|
||||
|
||||
typedef struct ss7bc_connection ss7bc_connection_t;
|
||||
|
||||
/* disable nagle's algorythm */
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
|
@ -40,10 +40,10 @@
|
|||
|
||||
|
||||
#ifndef HAVE_GETHOSTBYNAME_R
|
||||
extern int gethostbyname_r (const char *__name,
|
||||
struct hostent *__result_buf,
|
||||
char *__buf, size_t __buflen,
|
||||
struct hostent **__result,
|
||||
extern int gethostbyname_r (const char *__name,
|
||||
struct hostent *__result_buf,
|
||||
char *__buf, size_t __buflen,
|
||||
struct hostent **__result,
|
||||
int *__h_errnop);
|
||||
#endif
|
||||
|
||||
|
@ -53,53 +53,53 @@ struct ss7bc_map {
|
|||
};
|
||||
|
||||
static struct ss7bc_map ss7bc_table[] = {
|
||||
{SIGBOOST_EVENT_CALL_START, "CALL_START"},
|
||||
{SIGBOOST_EVENT_CALL_START_ACK, "CALL_START_ACK"},
|
||||
{SIGBOOST_EVENT_CALL_START_NACK, "CALL_START_NACK"},
|
||||
{SIGBOOST_EVENT_CALL_START_NACK_ACK, "CALL_START_NACK_ACK"},
|
||||
{SIGBOOST_EVENT_CALL_ANSWERED, "CALL_ANSWERED"},
|
||||
{SIGBOOST_EVENT_CALL_STOPPED, "CALL_STOPPED"},
|
||||
{SIGBOOST_EVENT_CALL_STOPPED_ACK, "CALL_STOPPED_ACK"},
|
||||
{SIGBOOST_EVENT_SYSTEM_RESTART, "SYSTEM_RESTART"},
|
||||
{SIGBOOST_EVENT_SYSTEM_RESTART_ACK, "SYSTEM_RESTART_ACK"},
|
||||
{SIGBOOST_EVENT_HEARTBEAT, "HEARTBEAT"},
|
||||
{SIGBOOST_EVENT_INSERT_CHECK_LOOP, "LOOP START"},
|
||||
{SIGBOOST_EVENT_CALL_START, "CALL_START"},
|
||||
{SIGBOOST_EVENT_CALL_START_ACK, "CALL_START_ACK"},
|
||||
{SIGBOOST_EVENT_CALL_START_NACK, "CALL_START_NACK"},
|
||||
{SIGBOOST_EVENT_CALL_START_NACK_ACK, "CALL_START_NACK_ACK"},
|
||||
{SIGBOOST_EVENT_CALL_ANSWERED, "CALL_ANSWERED"},
|
||||
{SIGBOOST_EVENT_CALL_STOPPED, "CALL_STOPPED"},
|
||||
{SIGBOOST_EVENT_CALL_STOPPED_ACK, "CALL_STOPPED_ACK"},
|
||||
{SIGBOOST_EVENT_SYSTEM_RESTART, "SYSTEM_RESTART"},
|
||||
{SIGBOOST_EVENT_SYSTEM_RESTART_ACK, "SYSTEM_RESTART_ACK"},
|
||||
{SIGBOOST_EVENT_HEARTBEAT, "HEARTBEAT"},
|
||||
{SIGBOOST_EVENT_INSERT_CHECK_LOOP, "LOOP START"},
|
||||
{SIGBOOST_EVENT_REMOVE_CHECK_LOOP, "LOOP STOP"}
|
||||
};
|
||||
|
||||
|
||||
|
||||
static void ss7bc_print_event_call(ss7bc_connection_t *mcon, ss7bc_event_t *event, int priority, int dir,const char *file, const char *func, int line)
|
||||
static void ss7bc_print_event_call(ss7bc_connection_t *mcon, ss7bc_event_t *event, int priority, int dir, const char *file, const char *func, int line)
|
||||
{
|
||||
if (event->event_id == SIGBOOST_EVENT_HEARTBEAT)
|
||||
return;
|
||||
zap_log(file, func, line, ZAP_LOG_LEVEL_DEBUG, "%s EVENT: %s:(%X) [w%dg%d] CSid=%i Seq=%i Cn=[%s] Cd=[%s] Ci=[%s]\n",
|
||||
dir ? "TX":"RX",
|
||||
ss7bc_event_id_name(event->event_id),
|
||||
event->event_id,
|
||||
event->span+1,
|
||||
event->chan+1,
|
||||
event->call_setup_id,
|
||||
event->fseqno,
|
||||
strlen(event->calling_name)?event->calling_name:"N/A",
|
||||
(event->called_number_digits_count ? (char *) event->called_number_digits : "N/A"),
|
||||
zap_log(file, func, line, ZAP_LOG_LEVEL_DEBUG, "%s EVENT: %s:(%X) [w%dg%d] CSid=%i Seq=%i Cn=[%s] Cd=[%s] Ci=[%s]\n",
|
||||
dir ? "TX":"RX",
|
||||
ss7bc_event_id_name(event->event_id),
|
||||
event->event_id,
|
||||
event->span+1,
|
||||
event->chan+1,
|
||||
event->call_setup_id,
|
||||
event->fseqno,
|
||||
strlen(event->calling_name)?event->calling_name:"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")
|
||||
);
|
||||
|
||||
}
|
||||
static void ss7bc_print_event_short(ss7bc_connection_t *mcon,ss7bc_short_event_t *event, int priority, int dir,const char *file, const char *func, int line)
|
||||
static void ss7bc_print_event_short(ss7bc_connection_t *mcon, ss7bc_short_event_t *event, int priority, int dir, const char *file, const char *func, int line)
|
||||
{
|
||||
if (event->event_id == SIGBOOST_EVENT_HEARTBEAT)
|
||||
return;
|
||||
zap_log(file, func, line, ZAP_LOG_LEVEL_DEBUG, "%s EVENT (%s): %s:(%X) [w%dg%d] Rc=%i CSid=%i Seq=%i \n",
|
||||
dir ? "TX":"RX",
|
||||
priority ? "P":"N",
|
||||
ss7bc_event_id_name(event->event_id),
|
||||
event->event_id,
|
||||
event->span+1,
|
||||
event->chan+1,
|
||||
event->release_cause,
|
||||
event->call_setup_id,
|
||||
zap_log(file, func, line, ZAP_LOG_LEVEL_DEBUG, "%s EVENT (%s): %s:(%X) [w%dg%d] Rc=%i CSid=%i Seq=%i \n",
|
||||
dir ? "TX":"RX",
|
||||
priority ? "P":"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);
|
||||
}
|
||||
|
||||
|
@ -119,8 +119,8 @@ static int create_conn_socket(ss7bc_connection_t *mcon, char *local_ip, int loca
|
|||
mcon->socket = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
#endif
|
||||
|
||||
zap_log(ZAP_LOG_DEBUG, "Creating L=%s:%d R=%s:%d\n",
|
||||
local_ip,local_port,ip,port);
|
||||
zap_log(ZAP_LOG_DEBUG, "Creating L=%s:%d R=%s:%d\n",
|
||||
local_ip, local_port, ip, port);
|
||||
|
||||
if (mcon->socket >= 0) {
|
||||
int flag;
|
||||
|
@ -149,13 +149,13 @@ static int create_conn_socket(ss7bc_connection_t *mcon, char *local_ip, int loca
|
|||
#endif
|
||||
|
||||
if ((rc = bind(mcon->socket,
|
||||
(struct sockaddr *) &mcon->local_addr,
|
||||
(struct sockaddr *) &mcon->local_addr,
|
||||
sizeof(mcon->local_addr))) < 0) {
|
||||
close(mcon->socket);
|
||||
mcon->socket = -1;
|
||||
} else {
|
||||
#ifdef HAVE_NETINET_SCTP_H
|
||||
rc=listen(mcon->socket,100);
|
||||
rc=listen(mcon->socket, 100);
|
||||
if (rc) {
|
||||
close(mcon->socket);
|
||||
mcon->socket = -1;
|
||||
|
@ -252,8 +252,6 @@ int ss7bc_exec_commandp(ss7bc_connection_t *pcon, int span, int chan, int id, in
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ss7bc_event_t *__ss7bc_connection_read(ss7bc_connection_t *mcon, int iteration, const char *file, const char *func, int line)
|
||||
{
|
||||
unsigned int fromlen = sizeof(struct sockaddr_in);
|
||||
|
@ -279,20 +277,30 @@ ss7bc_event_t *__ss7bc_connection_read(ss7bc_connection_t *mcon, int iteration,
|
|||
|
||||
if (msg_ok){
|
||||
|
||||
if (boost_full_event(mcon->event.event_id)) {
|
||||
ss7bc_print_event_call(mcon,&mcon->event, 0, 0, file,func,line);
|
||||
} else {
|
||||
ss7bc_print_event_short(mcon,(ss7bc_short_event_t*)&mcon->event, 0, 0, file,func,line);
|
||||
if (ss7bc_test_flag(mcon, MSU_FLAG_DOWN)) {
|
||||
if (mcon->event.event_id != SIGBOOST_EVENT_SYSTEM_RESTART &&
|
||||
mcon->event.event_id != SIGBOOST_EVENT_SYSTEM_RESTART_ACK &&
|
||||
mcon->event.event_id != SIGBOOST_EVENT_HEARTBEAT) {
|
||||
zap_log(file, func, line, ZAP_LOG_LEVEL_WARNING, "Not reading packets when connection is down. [%s]\n",
|
||||
ss7bc_event_id_name(mcon->event.event_id));
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (boost_full_event(mcon->event.event_id)) {
|
||||
ss7bc_print_event_call(mcon, &mcon->event, 0, 0, file, func, line);
|
||||
} else {
|
||||
ss7bc_print_event_short(mcon, (ss7bc_short_event_t*)&mcon->event, 0, 0, file, func, line);
|
||||
}
|
||||
|
||||
#if 1
|
||||
/* NC: NOT USED ANY MORE */
|
||||
if (mcon->rxseq_reset) {
|
||||
if (mcon->event.event_id == SIGBOOST_EVENT_SYSTEM_RESTART_ACK) {
|
||||
//if (mcon->event.event_id == SIGBOOST_EVENT_SYSTEM_RESTART_ACK) {
|
||||
zap_log(ZAP_LOG_DEBUG, "Rx sync ok\n");
|
||||
mcon->rxseq = mcon->event.fseqno;
|
||||
return &mcon->event;
|
||||
}
|
||||
//}
|
||||
errno=EAGAIN;
|
||||
zap_log(ZAP_LOG_DEBUG, "Waiting for rx sync...\n");
|
||||
return NULL;
|
||||
|
@ -328,9 +336,9 @@ ss7bc_event_t *__ss7bc_connection_readp(ss7bc_connection_t *mcon, int iteration,
|
|||
if (bytes == sizeof(ss7bc_short_event_t)) {
|
||||
|
||||
if (boost_full_event(mcon->event.event_id)) {
|
||||
ss7bc_print_event_call(mcon,&mcon->event, 1, 0, file,func,line);
|
||||
ss7bc_print_event_call(mcon, &mcon->event, 1, 0, file, func, line);
|
||||
} else {
|
||||
ss7bc_print_event_short(mcon,(ss7bc_short_event_t*)&mcon->event, 1, 0, file,func,line);
|
||||
ss7bc_print_event_short(mcon, (ss7bc_short_event_t*)&mcon->event, 1, 0, file, func, line);
|
||||
}
|
||||
|
||||
return &mcon->event;
|
||||
|
@ -349,15 +357,15 @@ int __ss7bc_connection_write(ss7bc_connection_t *mcon, ss7bc_event_t *event, con
|
|||
{
|
||||
int err;
|
||||
int event_size=sizeof(ss7bc_event_t);
|
||||
|
||||
|
||||
if (!event || mcon->socket < 0 || !mcon->mutex) {
|
||||
zap_log(file, func, line, ZAP_LOG_LEVEL_CRIT, "Critical Error: No Event Device\n");
|
||||
zap_log(file, func, line, ZAP_LOG_LEVEL_CRIT, "Critical Error: No Event Device\n");
|
||||
return -EINVAL;
|
||||
abort();
|
||||
}
|
||||
|
||||
if (event->span > 16 || event->chan > 31) {
|
||||
zap_log(file, func, line, ZAP_LOG_LEVEL_CRIT, "Critical Error: TX Cmd=%s Invalid Span=%i Chan=%i\n", ss7bc_event_id_name(event->event_id), event->span,event->chan);
|
||||
zap_log(file, func, line, ZAP_LOG_LEVEL_CRIT, "Critical Error: TX Cmd=%s Invalid Span=%i Chan=%i\n", ss7bc_event_id_name(event->event_id), event->span, event->chan);
|
||||
abort();
|
||||
return -1;
|
||||
}
|
||||
|
@ -366,7 +374,17 @@ int __ss7bc_connection_write(ss7bc_connection_t *mcon, ss7bc_event_t *event, con
|
|||
event_size=sizeof(ss7bc_short_event_t);
|
||||
}
|
||||
|
||||
gettimeofday(&event->tv,NULL);
|
||||
if (ss7bc_test_flag(mcon, MSU_FLAG_DOWN)) {
|
||||
if (event->event_id != SIGBOOST_EVENT_SYSTEM_RESTART &&
|
||||
event->event_id != SIGBOOST_EVENT_SYSTEM_RESTART_ACK &&
|
||||
event->event_id != SIGBOOST_EVENT_HEARTBEAT) {
|
||||
zap_log(file, func, line, ZAP_LOG_LEVEL_WARNING, "Not writing packets when connection is down. [%s]\n",
|
||||
ss7bc_event_id_name(event->event_id));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
gettimeofday(&event->tv, NULL);
|
||||
|
||||
zap_mutex_lock(mcon->mutex);
|
||||
if (event->event_id == SIGBOOST_EVENT_SYSTEM_RESTART_ACK) {
|
||||
|
@ -387,9 +405,9 @@ int __ss7bc_connection_write(ss7bc_connection_t *mcon, ss7bc_event_t *event, con
|
|||
}
|
||||
|
||||
if (boost_full_event(event->event_id)) {
|
||||
ss7bc_print_event_call(mcon,event, 0, 1,file,func,line);
|
||||
ss7bc_print_event_call(mcon, event, 0, 1, file, func, line);
|
||||
} else {
|
||||
ss7bc_print_event_short(mcon,(ss7bc_short_event_t*)event, 0, 1,file,func,line);
|
||||
ss7bc_print_event_short(mcon, (ss7bc_short_event_t*)event, 0, 1, file, func, line);
|
||||
}
|
||||
|
||||
return err;
|
||||
|
@ -402,7 +420,7 @@ int __ss7bc_connection_writep(ss7bc_connection_t *mcon, ss7bc_event_t *event, co
|
|||
int event_size=sizeof(ss7bc_event_t);
|
||||
|
||||
if (!event || mcon->socket < 0 || !mcon->mutex) {
|
||||
zap_log(file, func, line, ZAP_LOG_LEVEL_CRIT, "Critical Error: No Event Device\n");
|
||||
zap_log(file, func, line, ZAP_LOG_LEVEL_CRIT, "Critical Error: No Event Device\n");
|
||||
return -EINVAL;
|
||||
abort();
|
||||
}
|
||||
|
@ -411,7 +429,7 @@ int __ss7bc_connection_writep(ss7bc_connection_t *mcon, ss7bc_event_t *event, co
|
|||
event_size=sizeof(ss7bc_short_event_t);
|
||||
}
|
||||
|
||||
gettimeofday(&event->tv,NULL);
|
||||
gettimeofday(&event->tv, NULL);
|
||||
|
||||
zap_mutex_lock(mcon->mutex);
|
||||
err = sendto(mcon->socket, event, event_size, 0, (struct sockaddr *) &mcon->remote_addr, sizeof(mcon->remote_addr));
|
||||
|
@ -423,9 +441,9 @@ int __ss7bc_connection_writep(ss7bc_connection_t *mcon, ss7bc_event_t *event, co
|
|||
}
|
||||
|
||||
if (boost_full_event(event->event_id)) {
|
||||
ss7bc_print_event_call(mcon,event, 1, 1,file,func,line);
|
||||
ss7bc_print_event_call(mcon, event, 1, 1, file, func, line);
|
||||
} else {
|
||||
ss7bc_print_event_short(mcon,(ss7bc_short_event_t*)event, 1, 1,file,func,line);
|
||||
ss7bc_print_event_short(mcon, (ss7bc_short_event_t*)event, 1, 1, file, func, line);
|
||||
}
|
||||
|
||||
return err;
|
||||
|
|
|
@ -675,6 +675,12 @@ zap_status_t zap_channel_set_state(zap_channel_t *zchan, zap_channel_state_t sta
|
|||
return ZAP_FAIL;
|
||||
}
|
||||
|
||||
if (zap_test_flag(zchan->span, ZAP_SPAN_SUSPENDED)) {
|
||||
if (state != ZAP_CHANNEL_STATE_RESTART && state != ZAP_CHANNEL_STATE_DOWN) {
|
||||
return ZAP_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
if (lock) {
|
||||
zap_mutex_lock(zchan->mutex);
|
||||
}
|
||||
|
|
|
@ -518,14 +518,7 @@ static void handle_heartbeat(ss7bc_connection_t *mcon, ss7bc_short_event_t *even
|
|||
|
||||
static void handle_restart_ack(ss7bc_connection_t *mcon, zap_span_t *span, ss7bc_short_event_t *event)
|
||||
{
|
||||
#if 0
|
||||
/* NC: Clear suspended on RESTART ACK */
|
||||
mcon->rxseq_reset = 0;
|
||||
mcon->up = 1;
|
||||
zap_set_state_all(span, ZAP_CHANNEL_STATE_RESTART);
|
||||
zap_clear_flag_locked(span, ZAP_SPAN_SUSPENDED);
|
||||
#endif
|
||||
mcon->hb_elapsed = 0;
|
||||
zap_log(ZAP_LOG_DEBUG, "RECV RESTART ACK\n");
|
||||
}
|
||||
|
||||
|
||||
|
@ -534,10 +527,8 @@ static void handle_restart(ss7bc_connection_t *mcon, zap_span_t *span, ss7bc_sho
|
|||
zap_ss7_boost_data_t *ss7_boost_data = span->signal_data;
|
||||
|
||||
mcon->rxseq_reset = 0;
|
||||
mcon->up = 1;
|
||||
|
||||
zap_set_flag((&ss7_boost_data->mcon), MSU_FLAG_DOWN);
|
||||
zap_set_flag_locked(span, ZAP_SPAN_SUSPENDED);
|
||||
zap_set_state_all(span, ZAP_CHANNEL_STATE_RESTART);
|
||||
zap_set_flag(ss7_boost_data, ZAP_SS7_BOOST_RESTARTING);
|
||||
|
||||
mcon->hb_elapsed = 0;
|
||||
|
@ -572,7 +563,6 @@ static void handle_incoming_digit(ss7bc_connection_t *mcon, zap_span_t *span, ss
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
static int parse_ss7_event(zap_span_t *span, ss7bc_connection_t *mcon, ss7bc_short_event_t *event)
|
||||
{
|
||||
zap_mutex_lock(signal_mutex);
|
||||
|
@ -582,13 +572,6 @@ static int parse_ss7_event(zap_span_t *span, ss7bc_connection_t *mcon, ss7bc_sho
|
|||
goto end;
|
||||
}
|
||||
|
||||
if (zap_test_flag(span, ZAP_SPAN_SUSPENDED) &&
|
||||
event->event_id != SIGBOOST_EVENT_SYSTEM_RESTART_ACK &&
|
||||
event->event_id != SIGBOOST_EVENT_HEARTBEAT &&
|
||||
event->event_id != SIGBOOST_EVENT_SYSTEM_RESTART) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
assert(event->call_setup_id <= MAX_REQ_ID);
|
||||
|
||||
switch(event->event_id) {
|
||||
|
@ -709,7 +692,11 @@ static __inline__ void state_advance(zap_channel_t *zchan)
|
|||
break;
|
||||
case ZAP_CHANNEL_STATE_RESTART:
|
||||
{
|
||||
sig.event_id = ZAP_SIGEVENT_RESTART;
|
||||
status = ss7_boost_data->signal_cb(&sig);
|
||||
zap_set_sflag_locked(zchan, SFLAG_SENT_FINAL_RESPONSE);
|
||||
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_DOWN);
|
||||
|
||||
}
|
||||
break;
|
||||
case ZAP_CHANNEL_STATE_UP:
|
||||
|
@ -814,14 +801,22 @@ static __inline__ void init_outgoing_array(void)
|
|||
static __inline__ void check_state(zap_span_t *span)
|
||||
{
|
||||
zap_ss7_boost_data_t *ss7_boost_data = span->signal_data;
|
||||
int susp = zap_test_flag(span, ZAP_SPAN_SUSPENDED);
|
||||
|
||||
if (zap_test_flag(span, ZAP_SPAN_STATE_CHANGE)) {
|
||||
if (susp && zap_check_state_all(span, ZAP_CHANNEL_STATE_DOWN)) {
|
||||
susp = 0;
|
||||
}
|
||||
|
||||
if (zap_test_flag(span, ZAP_SPAN_STATE_CHANGE) || susp) {
|
||||
uint32_t j;
|
||||
zap_clear_flag_locked(span, ZAP_SPAN_STATE_CHANGE);
|
||||
for(j = 1; j <= span->chan_count; j++) {
|
||||
if (zap_test_flag((&span->channels[j]), ZAP_CHANNEL_STATE_CHANGE)) {
|
||||
if (zap_test_flag((&span->channels[j]), ZAP_CHANNEL_STATE_CHANGE) || susp) {
|
||||
zap_mutex_lock(span->channels[j].mutex);
|
||||
zap_clear_flag((&span->channels[j]), ZAP_CHANNEL_STATE_CHANGE);
|
||||
if (susp && span->channels[j].state != ZAP_CHANNEL_STATE_DOWN) {
|
||||
zap_channel_set_state(&span->channels[j], ZAP_CHANNEL_STATE_RESTART, 0);
|
||||
}
|
||||
state_advance(&span->channels[j]);
|
||||
zap_channel_complete_state(&span->channels[j]);
|
||||
zap_mutex_unlock(span->channels[j].mutex);
|
||||
|
@ -839,7 +834,9 @@ static __inline__ void check_state(zap_span_t *span)
|
|||
0);
|
||||
zap_clear_flag(ss7_boost_data, ZAP_SS7_BOOST_RESTARTING);
|
||||
zap_clear_flag_locked(span, ZAP_SPAN_SUSPENDED);
|
||||
zap_clear_flag((&ss7_boost_data->mcon), MSU_FLAG_DOWN);
|
||||
ss7_boost_data->mcon.hb_elapsed = 0;
|
||||
init_outgoing_array();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -852,7 +849,7 @@ static void *zap_ss7_boost_run(zap_thread_t *me, void *obj)
|
|||
zap_span_t *span = (zap_span_t *) obj;
|
||||
zap_ss7_boost_data_t *ss7_boost_data = span->signal_data;
|
||||
ss7bc_connection_t *mcon, *pcon;
|
||||
uint32_t ms = 10, too_long = 5000;
|
||||
uint32_t ms = 10, too_long = 20000;
|
||||
|
||||
|
||||
ss7_boost_data->pcon = ss7_boost_data->mcon;
|
||||
|
@ -878,10 +875,7 @@ static void *zap_ss7_boost_run(zap_thread_t *me, void *obj)
|
|||
mcon = &ss7_boost_data->mcon;
|
||||
pcon = &ss7_boost_data->pcon;
|
||||
|
||||
//top:
|
||||
|
||||
|
||||
init_outgoing_array();
|
||||
init_outgoing_array();
|
||||
|
||||
ss7bc_exec_commandp(pcon,
|
||||
0,
|
||||
|
@ -889,7 +883,8 @@ static void *zap_ss7_boost_run(zap_thread_t *me, void *obj)
|
|||
-1,
|
||||
SIGBOOST_EVENT_SYSTEM_RESTART,
|
||||
0);
|
||||
|
||||
zap_set_flag(mcon, MSU_FLAG_DOWN);
|
||||
|
||||
while (zap_test_flag(ss7_boost_data, ZAP_SS7_BOOST_RUNNING)) {
|
||||
fd_set rfds, efds;
|
||||
struct timeval tv = { 0, ms * 1000 };
|
||||
|
@ -903,6 +898,7 @@ static void *zap_ss7_boost_run(zap_thread_t *me, void *obj)
|
|||
-1,
|
||||
SIGBOOST_EVENT_SYSTEM_RESTART,
|
||||
0);
|
||||
zap_set_flag(mcon, MSU_FLAG_DOWN);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -927,24 +923,37 @@ static void *zap_ss7_boost_run(zap_thread_t *me, void *obj)
|
|||
if (FD_ISSET(pcon->socket, &rfds)) {
|
||||
if ((event = ss7bc_connection_readp(pcon, i))) {
|
||||
parse_ss7_event(span, pcon, (ss7bc_short_event_t*)event);
|
||||
} //else goto top;
|
||||
}
|
||||
}
|
||||
|
||||
if (FD_ISSET(mcon->socket, &rfds)) {
|
||||
if ((event = ss7bc_connection_read(mcon, i))) {
|
||||
parse_ss7_event(span, mcon, (ss7bc_short_event_t*)event);
|
||||
} //else goto top;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
check_state(span);
|
||||
|
||||
pcon->hb_elapsed += ms;
|
||||
|
||||
if (pcon->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;
|
||||
if (zap_test_flag(span, ZAP_SPAN_SUSPENDED) || zap_test_flag(mcon, MSU_FLAG_DOWN)) {
|
||||
pcon->hb_elapsed = 0;
|
||||
}
|
||||
|
||||
if (pcon->hb_elapsed >= too_long) {
|
||||
zap_log(ZAP_LOG_CRIT, "Lost Heartbeat!\n");
|
||||
zap_set_flag_locked(span, ZAP_SPAN_SUSPENDED);
|
||||
zap_set_flag(mcon, MSU_FLAG_DOWN);
|
||||
ss7bc_exec_commandp(pcon,
|
||||
0,
|
||||
0,
|
||||
-1,
|
||||
SIGBOOST_EVENT_SYSTEM_RESTART,
|
||||
0);
|
||||
}
|
||||
|
||||
if (zap_running()) {
|
||||
check_state(span);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue