git-svn-id: http://svn.openzap.org/svn/openzap/trunk@824 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
parent
e3022ee6b6
commit
fd17b6ba5d
|
@ -32,8 +32,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "openzap.h"
|
#include "openzap.h"
|
||||||
#include "ss7_boost_client.h"
|
#include "sangoma_boost_client.h"
|
||||||
#include "zap_ss7_boost.h"
|
#include "zap_sangoma_boost.h"
|
||||||
#ifdef HAVE_SYS_SELECT_H
|
#ifdef HAVE_SYS_SELECT_H
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -49,34 +49,34 @@ typedef enum {
|
||||||
SFLAG_SENT_FINAL_RESPONSE = (1 << 1)
|
SFLAG_SENT_FINAL_RESPONSE = (1 << 1)
|
||||||
} sflag_t;
|
} sflag_t;
|
||||||
|
|
||||||
typedef uint16_t ss7_boost_request_id_t;
|
typedef uint16_t sangoma_boost_request_id_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief SS7 boost request status
|
* \brief SANGOMA boost request status
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
BST_FREE,
|
BST_FREE,
|
||||||
BST_WAITING,
|
BST_WAITING,
|
||||||
BST_READY,
|
BST_READY,
|
||||||
BST_FAIL
|
BST_FAIL
|
||||||
} ss7_boost_request_status_t;
|
} sangoma_boost_request_status_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief SS7 boost request structure
|
* \brief SANGOMA boost request structure
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
ss7_boost_request_status_t status;
|
sangoma_boost_request_status_t status;
|
||||||
ss7bc_short_event_t event;
|
sangomabc_short_event_t event;
|
||||||
zap_span_t *span;
|
zap_span_t *span;
|
||||||
zap_channel_t *zchan;
|
zap_channel_t *zchan;
|
||||||
} ss7_boost_request_t;
|
} sangoma_boost_request_t;
|
||||||
|
|
||||||
//#define MAX_REQ_ID ZAP_MAX_PHYSICAL_SPANS_PER_LOGICAL_SPAN * ZAP_MAX_CHANNELS_PHYSICAL_SPAN
|
//#define MAX_REQ_ID ZAP_MAX_PHYSICAL_SPANS_PER_LOGICAL_SPAN * ZAP_MAX_CHANNELS_PHYSICAL_SPAN
|
||||||
#define MAX_REQ_ID 6000
|
#define MAX_REQ_ID 6000
|
||||||
|
|
||||||
static uint16_t SETUP_GRID[ZAP_MAX_PHYSICAL_SPANS_PER_LOGICAL_SPAN+1][ZAP_MAX_CHANNELS_PHYSICAL_SPAN+1] = {{ 0 }};
|
static uint16_t SETUP_GRID[ZAP_MAX_PHYSICAL_SPANS_PER_LOGICAL_SPAN+1][ZAP_MAX_CHANNELS_PHYSICAL_SPAN+1] = {{ 0 }};
|
||||||
|
|
||||||
static ss7_boost_request_t OUTBOUND_REQUESTS[MAX_REQ_ID+1] = {{ 0 }};
|
static sangoma_boost_request_t OUTBOUND_REQUESTS[MAX_REQ_ID+1] = {{ 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;
|
||||||
|
@ -112,7 +112,7 @@ static void __release_request_id_span_chan(int span, int chan, const char *func,
|
||||||
* \param line Line number on request
|
* \param line Line number on request
|
||||||
* \return NULL if not found, channel otherwise
|
* \return NULL if not found, channel otherwise
|
||||||
*/
|
*/
|
||||||
static void __release_request_id(ss7_boost_request_id_t r, const char *func, int line)
|
static void __release_request_id(sangoma_boost_request_id_t r, const char *func, int line)
|
||||||
{
|
{
|
||||||
assert(r <= MAX_REQ_ID);
|
assert(r <= MAX_REQ_ID);
|
||||||
zap_mutex_lock(request_mutex);
|
zap_mutex_lock(request_mutex);
|
||||||
|
@ -121,7 +121,7 @@ static void __release_request_id(ss7_boost_request_id_t r, const char *func, int
|
||||||
}
|
}
|
||||||
#define release_request_id(r) __release_request_id(r, __FUNCTION__, __LINE__)
|
#define release_request_id(r) __release_request_id(r, __FUNCTION__, __LINE__)
|
||||||
|
|
||||||
static ss7_boost_request_id_t last_req = 0;
|
static sangoma_boost_request_id_t last_req = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Gets the first available tank request ID
|
* \brief Gets the first available tank request ID
|
||||||
|
@ -129,9 +129,9 @@ static ss7_boost_request_id_t last_req = 0;
|
||||||
* \param line Line number on request
|
* \param line Line number on request
|
||||||
* \return 0 on failure, request ID on success
|
* \return 0 on failure, request ID on success
|
||||||
*/
|
*/
|
||||||
static ss7_boost_request_id_t __next_request_id(const char *func, int line)
|
static sangoma_boost_request_id_t __next_request_id(const char *func, int line)
|
||||||
{
|
{
|
||||||
ss7_boost_request_id_t r = 0, i = 0;
|
sangoma_boost_request_id_t r = 0, i = 0;
|
||||||
int found=0;
|
int found=0;
|
||||||
|
|
||||||
zap_mutex_lock(request_mutex);
|
zap_mutex_lock(request_mutex);
|
||||||
|
@ -170,11 +170,11 @@ static ss7_boost_request_id_t __next_request_id(const char *func, int line)
|
||||||
/**
|
/**
|
||||||
* \brief Finds the channel that triggered an event
|
* \brief Finds the channel that triggered an event
|
||||||
* \param span Span where to search the channel
|
* \param span Span where to search the channel
|
||||||
* \param event SS7 event
|
* \param event SANGOMA event
|
||||||
* \param force Do not wait for the channel to be available if in use
|
* \param force Do not wait for the channel to be available if in use
|
||||||
* \return NULL if not found, channel otherwise
|
* \return NULL if not found, channel otherwise
|
||||||
*/
|
*/
|
||||||
static zap_channel_t *find_zchan(zap_span_t *span, ss7bc_short_event_t *event, int force)
|
static zap_channel_t *find_zchan(zap_span_t *span, sangomabc_short_event_t *event, int force)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
zap_channel_t *zchan = NULL;
|
zap_channel_t *zchan = NULL;
|
||||||
|
@ -219,7 +219,7 @@ static int check_congestion(int trunk_group)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Requests an ss7 boost channel on a span (outgoing call)
|
* \brief Requests an sangoma boost channel on a span (outgoing call)
|
||||||
* \param span Span where to get a channel
|
* \param span Span where to get a channel
|
||||||
* \param chan_id Specific channel to get (0 for any)
|
* \param chan_id Specific channel to get (0 for any)
|
||||||
* \param direction Call direction
|
* \param direction Call direction
|
||||||
|
@ -227,14 +227,14 @@ static int check_congestion(int trunk_group)
|
||||||
* \param zchan Channel to initialise
|
* \param zchan Channel to initialise
|
||||||
* \return Success or failure
|
* \return Success or failure
|
||||||
*/
|
*/
|
||||||
static ZIO_CHANNEL_REQUEST_FUNCTION(ss7_boost_channel_request)
|
static ZIO_CHANNEL_REQUEST_FUNCTION(sangoma_boost_channel_request)
|
||||||
{
|
{
|
||||||
zap_ss7_boost_data_t *ss7_boost_data = span->signal_data;
|
zap_sangoma_boost_data_t *sangoma_boost_data = span->signal_data;
|
||||||
zap_status_t status = ZAP_FAIL;
|
zap_status_t status = ZAP_FAIL;
|
||||||
ss7_boost_request_id_t r;
|
sangoma_boost_request_id_t r;
|
||||||
ss7bc_event_t event = {0};
|
sangomabc_event_t event = {0};
|
||||||
int sanity = 5000;
|
int sanity = 5000;
|
||||||
ss7_boost_request_status_t st;
|
sangoma_boost_request_status_t st;
|
||||||
char ani[128] = "";
|
char ani[128] = "";
|
||||||
char *gr = NULL;
|
char *gr = NULL;
|
||||||
uint32_t count = 0;
|
uint32_t count = 0;
|
||||||
|
@ -281,7 +281,7 @@ static ZIO_CHANNEL_REQUEST_FUNCTION(ss7_boost_channel_request)
|
||||||
return ZAP_FAIL;
|
return ZAP_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ss7bc_call_init(&event, caller_data->cid_num.digits, ani, r);
|
sangomabc_call_init(&event, caller_data->cid_num.digits, ani, r);
|
||||||
|
|
||||||
if (gr && *(gr+1)) {
|
if (gr && *(gr+1)) {
|
||||||
|
|
||||||
|
@ -316,7 +316,7 @@ static ZIO_CHANNEL_REQUEST_FUNCTION(ss7_boost_channel_request)
|
||||||
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 (sangomabc_connection_write(&sangoma_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;
|
*zchan = NULL;
|
||||||
|
@ -352,7 +352,7 @@ static ZIO_CHANNEL_REQUEST_FUNCTION(ss7_boost_channel_request)
|
||||||
} else if (st != BST_READY) {
|
} else if (st != BST_READY) {
|
||||||
assert(r <= MAX_REQ_ID);
|
assert(r <= MAX_REQ_ID);
|
||||||
nack_map[r] = 1;
|
nack_map[r] = 1;
|
||||||
ss7bc_exec_command(&ss7_boost_data->mcon,
|
sangomabc_exec_command(&sangoma_boost_data->mcon,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
r,
|
r,
|
||||||
|
@ -364,11 +364,11 @@ static ZIO_CHANNEL_REQUEST_FUNCTION(ss7_boost_channel_request)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Starts an ss7 boost channel (outgoing call)
|
* \brief Starts an sangoma boost channel (outgoing call)
|
||||||
* \param zchan Channel to initiate call on
|
* \param zchan Channel to initiate call on
|
||||||
* \return Success
|
* \return Success
|
||||||
*/
|
*/
|
||||||
static ZIO_CHANNEL_OUTGOING_CALL_FUNCTION(ss7_boost_outgoing_call)
|
static ZIO_CHANNEL_OUTGOING_CALL_FUNCTION(sangoma_boost_outgoing_call)
|
||||||
{
|
{
|
||||||
zap_status_t status = ZAP_SUCCESS;
|
zap_status_t status = ZAP_SUCCESS;
|
||||||
|
|
||||||
|
@ -377,10 +377,10 @@ static ZIO_CHANNEL_OUTGOING_CALL_FUNCTION(ss7_boost_outgoing_call)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Handler for call start ack event
|
* \brief Handler for call start ack event
|
||||||
* \param mcon ss7 boost connection
|
* \param mcon sangoma boost connection
|
||||||
* \param event Event to handle
|
* \param event Event to handle
|
||||||
*/
|
*/
|
||||||
static void handle_call_start_ack(ss7bc_connection_t *mcon, ss7bc_short_event_t *event)
|
static void handle_call_start_ack(sangomabc_connection_t *mcon, sangomabc_short_event_t *event)
|
||||||
{
|
{
|
||||||
zap_channel_t *zchan;
|
zap_channel_t *zchan;
|
||||||
|
|
||||||
|
@ -413,7 +413,7 @@ static void handle_call_start_ack(ss7bc_connection_t *mcon, ss7bc_short_event_t
|
||||||
|
|
||||||
|
|
||||||
zap_log(ZAP_LOG_CRIT, "START ACK CANT FIND A CHAN %d:%d\n", event->span+1,event->chan+1);
|
zap_log(ZAP_LOG_CRIT, "START ACK CANT FIND A CHAN %d:%d\n", event->span+1,event->chan+1);
|
||||||
ss7bc_exec_command(mcon,
|
sangomabc_exec_command(mcon,
|
||||||
event->span,
|
event->span,
|
||||||
event->chan,
|
event->chan,
|
||||||
event->call_setup_id,
|
event->call_setup_id,
|
||||||
|
@ -426,10 +426,10 @@ static void handle_call_start_ack(ss7bc_connection_t *mcon, ss7bc_short_event_t
|
||||||
/**
|
/**
|
||||||
* \brief Handler for call done event
|
* \brief Handler for call done event
|
||||||
* \param span Span where event was fired
|
* \param span Span where event was fired
|
||||||
* \param mcon ss7 boost connection
|
* \param mcon sangoma boost connection
|
||||||
* \param event Event to handle
|
* \param event Event to handle
|
||||||
*/
|
*/
|
||||||
static void handle_call_done(zap_span_t *span, ss7bc_connection_t *mcon, ss7bc_short_event_t *event)
|
static void handle_call_done(zap_span_t *span, sangomabc_connection_t *mcon, sangomabc_short_event_t *event)
|
||||||
{
|
{
|
||||||
zap_channel_t *zchan;
|
zap_channel_t *zchan;
|
||||||
int r = 0;
|
int r = 0;
|
||||||
|
@ -466,10 +466,10 @@ static void handle_call_done(zap_span_t *span, ss7bc_connection_t *mcon, ss7bc_s
|
||||||
/**
|
/**
|
||||||
* \brief Handler for call start nack event
|
* \brief Handler for call start nack event
|
||||||
* \param span Span where event was fired
|
* \param span Span where event was fired
|
||||||
* \param mcon ss7 boost connection
|
* \param mcon sangoma boost connection
|
||||||
* \param event Event to handle
|
* \param event Event to handle
|
||||||
*/
|
*/
|
||||||
static void handle_call_start_nack(zap_span_t *span, ss7bc_connection_t *mcon, ss7bc_short_event_t *event)
|
static void handle_call_start_nack(zap_span_t *span, sangomabc_connection_t *mcon, sangomabc_short_event_t *event)
|
||||||
{
|
{
|
||||||
zap_channel_t *zchan;
|
zap_channel_t *zchan;
|
||||||
|
|
||||||
|
@ -502,7 +502,7 @@ static void handle_call_start_nack(zap_span_t *span, ss7bc_connection_t *mcon, s
|
||||||
|
|
||||||
if (event->call_setup_id) {
|
if (event->call_setup_id) {
|
||||||
|
|
||||||
ss7bc_exec_command(mcon,
|
sangomabc_exec_command(mcon,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
event->call_setup_id,
|
event->call_setup_id,
|
||||||
|
@ -535,7 +535,7 @@ static void handle_call_start_nack(zap_span_t *span, ss7bc_connection_t *mcon, s
|
||||||
|
|
||||||
|
|
||||||
/* nobody else will do it so we have to do it ourselves */
|
/* nobody else will do it so we have to do it ourselves */
|
||||||
ss7bc_exec_command(mcon,
|
sangomabc_exec_command(mcon,
|
||||||
event->span,
|
event->span,
|
||||||
event->chan,
|
event->chan,
|
||||||
0,
|
0,
|
||||||
|
@ -546,10 +546,10 @@ static void handle_call_start_nack(zap_span_t *span, ss7bc_connection_t *mcon, s
|
||||||
/**
|
/**
|
||||||
* \brief Handler for call stop event
|
* \brief Handler for call stop event
|
||||||
* \param span Span where event was fired
|
* \param span Span where event was fired
|
||||||
* \param mcon ss7 boost connection
|
* \param mcon sangoma boost connection
|
||||||
* \param event Event to handle
|
* \param event Event to handle
|
||||||
*/
|
*/
|
||||||
static void handle_call_stop(zap_span_t *span, ss7bc_connection_t *mcon, ss7bc_short_event_t *event)
|
static void handle_call_stop(zap_span_t *span, sangomabc_connection_t *mcon, sangomabc_short_event_t *event)
|
||||||
{
|
{
|
||||||
zap_channel_t *zchan;
|
zap_channel_t *zchan;
|
||||||
|
|
||||||
|
@ -578,7 +578,7 @@ static void handle_call_stop(zap_span_t *span, ss7bc_connection_t *mcon, ss7bc_s
|
||||||
zap_set_sflag_locked(zchan, SFLAG_SENT_FINAL_RESPONSE);
|
zap_set_sflag_locked(zchan, SFLAG_SENT_FINAL_RESPONSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
ss7bc_exec_command(mcon,
|
sangomabc_exec_command(mcon,
|
||||||
event->span,
|
event->span,
|
||||||
event->chan,
|
event->chan,
|
||||||
0,
|
0,
|
||||||
|
@ -591,10 +591,10 @@ static void handle_call_stop(zap_span_t *span, ss7bc_connection_t *mcon, ss7bc_s
|
||||||
/**
|
/**
|
||||||
* \brief Handler for call answer event
|
* \brief Handler for call answer event
|
||||||
* \param span Span where event was fired
|
* \param span Span where event was fired
|
||||||
* \param mcon ss7 boost connection
|
* \param mcon sangoma boost connection
|
||||||
* \param event Event to handle
|
* \param event Event to handle
|
||||||
*/
|
*/
|
||||||
static void handle_call_answer(zap_span_t *span, ss7bc_connection_t *mcon, ss7bc_short_event_t *event)
|
static void handle_call_answer(zap_span_t *span, sangomabc_connection_t *mcon, sangomabc_short_event_t *event)
|
||||||
{
|
{
|
||||||
zap_channel_t *zchan;
|
zap_channel_t *zchan;
|
||||||
|
|
||||||
|
@ -624,14 +624,14 @@ static void handle_call_answer(zap_span_t *span, ss7bc_connection_t *mcon, ss7bc
|
||||||
/**
|
/**
|
||||||
* \brief Handler for call start event
|
* \brief Handler for call start event
|
||||||
* \param span Span where event was fired
|
* \param span Span where event was fired
|
||||||
* \param mcon ss7 boost connection
|
* \param mcon sangoma boost connection
|
||||||
* \param event Event to handle
|
* \param event Event to handle
|
||||||
*/
|
*/
|
||||||
static void handle_call_start(zap_span_t *span, ss7bc_connection_t *mcon, ss7bc_event_t *event)
|
static void handle_call_start(zap_span_t *span, sangomabc_connection_t *mcon, sangomabc_event_t *event)
|
||||||
{
|
{
|
||||||
zap_channel_t *zchan;
|
zap_channel_t *zchan;
|
||||||
|
|
||||||
if (!(zchan = find_zchan(span, (ss7bc_short_event_t*)event, 0))) {
|
if (!(zchan = find_zchan(span, (sangomabc_short_event_t*)event, 0))) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -659,7 +659,7 @@ static void handle_call_start(zap_span_t *span, ss7bc_connection_t *mcon, ss7bc_
|
||||||
|
|
||||||
zap_log(ZAP_LOG_CRIT, "START CANT FIND A CHAN %d:%d\n", event->span+1,event->chan+1);
|
zap_log(ZAP_LOG_CRIT, "START CANT FIND A CHAN %d:%d\n", event->span+1,event->chan+1);
|
||||||
|
|
||||||
ss7bc_exec_command(mcon,
|
sangomabc_exec_command(mcon,
|
||||||
event->span,
|
event->span,
|
||||||
event->chan,
|
event->chan,
|
||||||
0,
|
0,
|
||||||
|
@ -670,14 +670,14 @@ static void handle_call_start(zap_span_t *span, ss7bc_connection_t *mcon, ss7bc_
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Handler for heartbeat event
|
* \brief Handler for heartbeat event
|
||||||
* \param mcon ss7 boost connection
|
* \param mcon sangoma boost connection
|
||||||
* \param event Event to handle
|
* \param event Event to handle
|
||||||
*/
|
*/
|
||||||
static void handle_heartbeat(ss7bc_connection_t *mcon, ss7bc_short_event_t *event)
|
static void handle_heartbeat(sangomabc_connection_t *mcon, sangomabc_short_event_t *event)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = ss7bc_connection_writep(mcon, (ss7bc_event_t*)event);
|
err = sangomabc_connection_writep(mcon, (sangomabc_event_t*)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));
|
||||||
|
@ -690,45 +690,45 @@ static void handle_heartbeat(ss7bc_connection_t *mcon, ss7bc_short_event_t *even
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Handler for restart ack event
|
* \brief Handler for restart ack event
|
||||||
* \param mcon ss7 boost connection
|
* \param mcon sangoma boost connection
|
||||||
* \param span Span where event was fired
|
* \param span Span where event was fired
|
||||||
* \param event Event to handle
|
* \param event Event to handle
|
||||||
*/
|
*/
|
||||||
static void handle_restart_ack(ss7bc_connection_t *mcon, zap_span_t *span, ss7bc_short_event_t *event)
|
static void handle_restart_ack(sangomabc_connection_t *mcon, zap_span_t *span, sangomabc_short_event_t *event)
|
||||||
{
|
{
|
||||||
zap_log(ZAP_LOG_DEBUG, "RECV RESTART ACK\n");
|
zap_log(ZAP_LOG_DEBUG, "RECV RESTART ACK\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Handler for restart event
|
* \brief Handler for restart event
|
||||||
* \param mcon ss7 boost connection
|
* \param mcon sangoma boost connection
|
||||||
* \param span Span where event was fired
|
* \param span Span where event was fired
|
||||||
* \param event Event to handle
|
* \param event Event to handle
|
||||||
*/
|
*/
|
||||||
static void handle_restart(ss7bc_connection_t *mcon, zap_span_t *span, ss7bc_short_event_t *event)
|
static void handle_restart(sangomabc_connection_t *mcon, zap_span_t *span, sangomabc_short_event_t *event)
|
||||||
{
|
{
|
||||||
zap_ss7_boost_data_t *ss7_boost_data = span->signal_data;
|
zap_sangoma_boost_data_t *sangoma_boost_data = span->signal_data;
|
||||||
|
|
||||||
mcon->rxseq_reset = 0;
|
mcon->rxseq_reset = 0;
|
||||||
zap_set_flag((&ss7_boost_data->mcon), MSU_FLAG_DOWN);
|
zap_set_flag((&sangoma_boost_data->mcon), MSU_FLAG_DOWN);
|
||||||
zap_set_flag_locked(span, ZAP_SPAN_SUSPENDED);
|
zap_set_flag_locked(span, ZAP_SPAN_SUSPENDED);
|
||||||
zap_set_flag(ss7_boost_data, ZAP_SS7_BOOST_RESTARTING);
|
zap_set_flag(sangoma_boost_data, ZAP_SANGOMA_BOOST_RESTARTING);
|
||||||
|
|
||||||
mcon->hb_elapsed = 0;
|
mcon->hb_elapsed = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Handler for incoming digit event
|
* \brief Handler for incoming digit event
|
||||||
* \param mcon ss7 boost connection
|
* \param mcon sangoma boost connection
|
||||||
* \param span Span where event was fired
|
* \param span Span where event was fired
|
||||||
* \param event Event to handle
|
* \param event Event to handle
|
||||||
*/
|
*/
|
||||||
static void handle_incoming_digit(ss7bc_connection_t *mcon, zap_span_t *span, ss7bc_event_t *event)
|
static void handle_incoming_digit(sangomabc_connection_t *mcon, zap_span_t *span, sangomabc_event_t *event)
|
||||||
{
|
{
|
||||||
zap_channel_t *zchan = NULL;
|
zap_channel_t *zchan = NULL;
|
||||||
char digits[MAX_DIALED_DIGITS + 2] = "";
|
char digits[MAX_DIALED_DIGITS + 2] = "";
|
||||||
|
|
||||||
if (!(zchan = find_zchan(span, (ss7bc_short_event_t *)event, 1))) {
|
if (!(zchan = find_zchan(span, (sangomabc_short_event_t *)event, 1))) {
|
||||||
zap_log(ZAP_LOG_ERROR, "Invalid channel\n");
|
zap_log(ZAP_LOG_ERROR, "Invalid channel\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -753,12 +753,12 @@ static void handle_incoming_digit(ss7bc_connection_t *mcon, zap_span_t *span, ss
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Handler for ss7 boost event
|
* \brief Handler for sangoma boost event
|
||||||
* \param span Span where event was fired
|
* \param span Span where event was fired
|
||||||
* \param mcon ss7 boost connection
|
* \param mcon sangoma boost connection
|
||||||
* \param event Event to handle
|
* \param event Event to handle
|
||||||
*/
|
*/
|
||||||
static int parse_ss7_event(zap_span_t *span, ss7bc_connection_t *mcon, ss7bc_short_event_t *event)
|
static int parse_sangoma_event(zap_span_t *span, sangomabc_connection_t *mcon, sangomabc_short_event_t *event)
|
||||||
{
|
{
|
||||||
zap_mutex_lock(signal_mutex);
|
zap_mutex_lock(signal_mutex);
|
||||||
|
|
||||||
|
@ -772,7 +772,7 @@ static int parse_ss7_event(zap_span_t *span, ss7bc_connection_t *mcon, ss7bc_sho
|
||||||
switch(event->event_id) {
|
switch(event->event_id) {
|
||||||
|
|
||||||
case SIGBOOST_EVENT_CALL_START:
|
case SIGBOOST_EVENT_CALL_START:
|
||||||
handle_call_start(span, mcon, (ss7bc_event_t*)event);
|
handle_call_start(span, mcon, (sangomabc_event_t*)event);
|
||||||
break;
|
break;
|
||||||
case SIGBOOST_EVENT_CALL_STOPPED:
|
case SIGBOOST_EVENT_CALL_STOPPED:
|
||||||
handle_call_stop(span, mcon, event);
|
handle_call_stop(span, mcon, event);
|
||||||
|
@ -812,10 +812,10 @@ static int parse_ss7_event(zap_span_t *span, ss7bc_connection_t *mcon, ss7bc_sho
|
||||||
//handle_gap_abate(event);
|
//handle_gap_abate(event);
|
||||||
break;
|
break;
|
||||||
case SIGBOOST_EVENT_DIGIT_IN:
|
case SIGBOOST_EVENT_DIGIT_IN:
|
||||||
handle_incoming_digit(mcon, span, (ss7bc_event_t*)event);
|
handle_incoming_digit(mcon, span, (sangomabc_event_t*)event);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
zap_log(ZAP_LOG_WARNING, "No handler implemented for [%s]\n", ss7bc_event_id_name(event->event_id));
|
zap_log(ZAP_LOG_WARNING, "No handler implemented for [%s]\n", sangomabc_event_id_name(event->event_id));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -833,8 +833,8 @@ static int parse_ss7_event(zap_span_t *span, ss7bc_connection_t *mcon, ss7bc_sho
|
||||||
static __inline__ void state_advance(zap_channel_t *zchan)
|
static __inline__ void state_advance(zap_channel_t *zchan)
|
||||||
{
|
{
|
||||||
|
|
||||||
zap_ss7_boost_data_t *ss7_boost_data = zchan->span->signal_data;
|
zap_sangoma_boost_data_t *sangoma_boost_data = zchan->span->signal_data;
|
||||||
ss7bc_connection_t *mcon = &ss7_boost_data->mcon;
|
sangomabc_connection_t *mcon = &sangoma_boost_data->mcon;
|
||||||
zap_sigmsg_t sig;
|
zap_sigmsg_t sig;
|
||||||
zap_status_t status;
|
zap_status_t status;
|
||||||
|
|
||||||
|
@ -865,11 +865,11 @@ static __inline__ void state_advance(zap_channel_t *zchan)
|
||||||
{
|
{
|
||||||
if (zap_test_flag(zchan, ZAP_CHANNEL_OUTBOUND)) {
|
if (zap_test_flag(zchan, ZAP_CHANNEL_OUTBOUND)) {
|
||||||
sig.event_id = ZAP_SIGEVENT_PROGRESS_MEDIA;
|
sig.event_id = ZAP_SIGEVENT_PROGRESS_MEDIA;
|
||||||
if ((status = ss7_boost_data->signal_cb(&sig) != ZAP_SUCCESS)) {
|
if ((status = sangoma_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 {
|
||||||
ss7bc_exec_command(mcon,
|
sangomabc_exec_command(mcon,
|
||||||
zchan->physical_span_id-1,
|
zchan->physical_span_id-1,
|
||||||
zchan->physical_chan_id-1,
|
zchan->physical_chan_id-1,
|
||||||
0,
|
0,
|
||||||
|
@ -882,7 +882,7 @@ static __inline__ void state_advance(zap_channel_t *zchan)
|
||||||
{
|
{
|
||||||
if (!zap_test_flag(zchan, ZAP_CHANNEL_OUTBOUND)) {
|
if (!zap_test_flag(zchan, ZAP_CHANNEL_OUTBOUND)) {
|
||||||
sig.event_id = ZAP_SIGEVENT_START;
|
sig.event_id = ZAP_SIGEVENT_START;
|
||||||
if ((status = ss7_boost_data->signal_cb(&sig) != ZAP_SUCCESS)) {
|
if ((status = sangoma_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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -892,7 +892,7 @@ static __inline__ void state_advance(zap_channel_t *zchan)
|
||||||
case ZAP_CHANNEL_STATE_RESTART:
|
case ZAP_CHANNEL_STATE_RESTART:
|
||||||
{
|
{
|
||||||
sig.event_id = ZAP_SIGEVENT_RESTART;
|
sig.event_id = ZAP_SIGEVENT_RESTART;
|
||||||
status = ss7_boost_data->signal_cb(&sig);
|
status = sangoma_boost_data->signal_cb(&sig);
|
||||||
zap_set_sflag_locked(zchan, SFLAG_SENT_FINAL_RESPONSE);
|
zap_set_sflag_locked(zchan, SFLAG_SENT_FINAL_RESPONSE);
|
||||||
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_DOWN);
|
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_DOWN);
|
||||||
|
|
||||||
|
@ -902,12 +902,12 @@ static __inline__ void state_advance(zap_channel_t *zchan)
|
||||||
{
|
{
|
||||||
if (zap_test_flag(zchan, ZAP_CHANNEL_OUTBOUND)) {
|
if (zap_test_flag(zchan, ZAP_CHANNEL_OUTBOUND)) {
|
||||||
sig.event_id = ZAP_SIGEVENT_UP;
|
sig.event_id = ZAP_SIGEVENT_UP;
|
||||||
if ((status = ss7_boost_data->signal_cb(&sig) != ZAP_SUCCESS)) {
|
if ((status = sangoma_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 {
|
||||||
if (!(zap_test_flag(zchan, ZAP_CHANNEL_PROGRESS) || zap_test_flag(zchan, ZAP_CHANNEL_MEDIA))) {
|
if (!(zap_test_flag(zchan, ZAP_CHANNEL_PROGRESS) || zap_test_flag(zchan, ZAP_CHANNEL_MEDIA))) {
|
||||||
ss7bc_exec_command(mcon,
|
sangomabc_exec_command(mcon,
|
||||||
zchan->physical_span_id-1,
|
zchan->physical_span_id-1,
|
||||||
zchan->physical_chan_id-1,
|
zchan->physical_chan_id-1,
|
||||||
0,
|
0,
|
||||||
|
@ -915,7 +915,7 @@ static __inline__ void state_advance(zap_channel_t *zchan)
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ss7bc_exec_command(mcon,
|
sangomabc_exec_command(mcon,
|
||||||
zchan->physical_span_id-1,
|
zchan->physical_span_id-1,
|
||||||
zchan->physical_chan_id-1,
|
zchan->physical_chan_id-1,
|
||||||
0,
|
0,
|
||||||
|
@ -941,14 +941,14 @@ static __inline__ void state_advance(zap_channel_t *zchan)
|
||||||
|
|
||||||
zap_set_sflag_locked(zchan, SFLAG_SENT_FINAL_RESPONSE);
|
zap_set_sflag_locked(zchan, SFLAG_SENT_FINAL_RESPONSE);
|
||||||
if (zap_test_flag(zchan, ZAP_CHANNEL_ANSWERED) || zap_test_flag(zchan, ZAP_CHANNEL_PROGRESS) || zap_test_flag(zchan, ZAP_CHANNEL_MEDIA)) {
|
if (zap_test_flag(zchan, ZAP_CHANNEL_ANSWERED) || zap_test_flag(zchan, ZAP_CHANNEL_PROGRESS) || zap_test_flag(zchan, ZAP_CHANNEL_MEDIA)) {
|
||||||
ss7bc_exec_command(mcon,
|
sangomabc_exec_command(mcon,
|
||||||
zchan->physical_span_id-1,
|
zchan->physical_span_id-1,
|
||||||
zchan->physical_chan_id-1,
|
zchan->physical_chan_id-1,
|
||||||
0,
|
0,
|
||||||
SIGBOOST_EVENT_CALL_STOPPED,
|
SIGBOOST_EVENT_CALL_STOPPED,
|
||||||
zchan->caller_data.hangup_cause);
|
zchan->caller_data.hangup_cause);
|
||||||
} else {
|
} else {
|
||||||
ss7bc_exec_command(mcon,
|
sangomabc_exec_command(mcon,
|
||||||
zchan->physical_span_id-1,
|
zchan->physical_span_id-1,
|
||||||
zchan->physical_chan_id-1,
|
zchan->physical_chan_id-1,
|
||||||
0,
|
0,
|
||||||
|
@ -961,10 +961,10 @@ static __inline__ void state_advance(zap_channel_t *zchan)
|
||||||
case ZAP_CHANNEL_STATE_CANCEL:
|
case ZAP_CHANNEL_STATE_CANCEL:
|
||||||
{
|
{
|
||||||
sig.event_id = ZAP_SIGEVENT_STOP;
|
sig.event_id = ZAP_SIGEVENT_STOP;
|
||||||
status = ss7_boost_data->signal_cb(&sig);
|
status = sangoma_boost_data->signal_cb(&sig);
|
||||||
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_DOWN);
|
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_DOWN);
|
||||||
zap_set_sflag_locked(zchan, SFLAG_SENT_FINAL_RESPONSE);
|
zap_set_sflag_locked(zchan, SFLAG_SENT_FINAL_RESPONSE);
|
||||||
ss7bc_exec_command(mcon,
|
sangomabc_exec_command(mcon,
|
||||||
zchan->physical_span_id-1,
|
zchan->physical_span_id-1,
|
||||||
zchan->physical_chan_id-1,
|
zchan->physical_chan_id-1,
|
||||||
0,
|
0,
|
||||||
|
@ -975,10 +975,10 @@ static __inline__ void state_advance(zap_channel_t *zchan)
|
||||||
case ZAP_CHANNEL_STATE_TERMINATING:
|
case ZAP_CHANNEL_STATE_TERMINATING:
|
||||||
{
|
{
|
||||||
sig.event_id = ZAP_SIGEVENT_STOP;
|
sig.event_id = ZAP_SIGEVENT_STOP;
|
||||||
status = ss7_boost_data->signal_cb(&sig);
|
status = sangoma_boost_data->signal_cb(&sig);
|
||||||
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_HANGUP_COMPLETE);
|
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_HANGUP_COMPLETE);
|
||||||
zap_set_sflag_locked(zchan, SFLAG_SENT_FINAL_RESPONSE);
|
zap_set_sflag_locked(zchan, SFLAG_SENT_FINAL_RESPONSE);
|
||||||
ss7bc_exec_command(mcon,
|
sangomabc_exec_command(mcon,
|
||||||
zchan->physical_span_id-1,
|
zchan->physical_span_id-1,
|
||||||
zchan->physical_chan_id-1,
|
zchan->physical_chan_id-1,
|
||||||
0,
|
0,
|
||||||
|
@ -1007,7 +1007,7 @@ static __inline__ void init_outgoing_array(void)
|
||||||
*/
|
*/
|
||||||
static __inline__ void check_state(zap_span_t *span)
|
static __inline__ void check_state(zap_span_t *span)
|
||||||
{
|
{
|
||||||
zap_ss7_boost_data_t *ss7_boost_data = span->signal_data;
|
zap_sangoma_boost_data_t *sangoma_boost_data = span->signal_data;
|
||||||
int susp = zap_test_flag(span, ZAP_SPAN_SUSPENDED);
|
int susp = zap_test_flag(span, ZAP_SPAN_SUSPENDED);
|
||||||
|
|
||||||
if (susp && zap_check_state_all(span, ZAP_CHANNEL_STATE_DOWN)) {
|
if (susp && zap_check_state_all(span, ZAP_CHANNEL_STATE_DOWN)) {
|
||||||
|
@ -1031,18 +1031,18 @@ static __inline__ void check_state(zap_span_t *span)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zap_test_flag(ss7_boost_data, ZAP_SS7_BOOST_RESTARTING)) {
|
if (zap_test_flag(sangoma_boost_data, ZAP_SANGOMA_BOOST_RESTARTING)) {
|
||||||
if (zap_check_state_all(span, ZAP_CHANNEL_STATE_DOWN)) {
|
if (zap_check_state_all(span, ZAP_CHANNEL_STATE_DOWN)) {
|
||||||
ss7bc_exec_command(&ss7_boost_data->mcon,
|
sangomabc_exec_command(&sangoma_boost_data->mcon,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
-1,
|
-1,
|
||||||
SIGBOOST_EVENT_SYSTEM_RESTART_ACK,
|
SIGBOOST_EVENT_SYSTEM_RESTART_ACK,
|
||||||
0);
|
0);
|
||||||
zap_clear_flag(ss7_boost_data, ZAP_SS7_BOOST_RESTARTING);
|
zap_clear_flag(sangoma_boost_data, ZAP_SANGOMA_BOOST_RESTARTING);
|
||||||
zap_clear_flag_locked(span, ZAP_SPAN_SUSPENDED);
|
zap_clear_flag_locked(span, ZAP_SPAN_SUSPENDED);
|
||||||
zap_clear_flag((&ss7_boost_data->mcon), MSU_FLAG_DOWN);
|
zap_clear_flag((&sangoma_boost_data->mcon), MSU_FLAG_DOWN);
|
||||||
ss7_boost_data->mcon.hb_elapsed = 0;
|
sangoma_boost_data->mcon.hb_elapsed = 0;
|
||||||
init_outgoing_array();
|
init_outgoing_array();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1083,16 +1083,16 @@ static __inline__ void check_events(zap_span_t *span, int ms_timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Main thread function for ss7 boost span (monitor)
|
* \brief Main thread function for sangoma boost span (monitor)
|
||||||
* \param me Current thread
|
* \param me Current thread
|
||||||
* \param obj Span to run in this thread
|
* \param obj Span to run in this thread
|
||||||
*/
|
*/
|
||||||
static void *zap_ss7_events_run(zap_thread_t *me, void *obj)
|
static void *zap_sangoma_events_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_sangoma_boost_data_t *sangoma_boost_data = span->signal_data;
|
||||||
|
|
||||||
while (zap_test_flag(ss7_boost_data, ZAP_SS7_BOOST_RUNNING) && zap_running()) {
|
while (zap_test_flag(sangoma_boost_data, ZAP_SANGOMA_BOOST_RUNNING) && zap_running()) {
|
||||||
check_events(span,100);
|
check_events(span,100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1100,44 +1100,44 @@ static void *zap_ss7_events_run(zap_thread_t *me, void *obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Main thread function for ss7 boost span (monitor)
|
* \brief Main thread function for sangoma boost span (monitor)
|
||||||
* \param me Current thread
|
* \param me Current thread
|
||||||
* \param obj Span to run in this thread
|
* \param obj Span to run in this thread
|
||||||
*/
|
*/
|
||||||
static void *zap_ss7_boost_run(zap_thread_t *me, void *obj)
|
static void *zap_sangoma_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_sangoma_boost_data_t *sangoma_boost_data = span->signal_data;
|
||||||
ss7bc_connection_t *mcon, *pcon;
|
sangomabc_connection_t *mcon, *pcon;
|
||||||
uint32_t ms = 10; //, too_long = 20000;
|
uint32_t ms = 10; //, too_long = 20000;
|
||||||
|
|
||||||
|
|
||||||
ss7_boost_data->pcon = ss7_boost_data->mcon;
|
sangoma_boost_data->pcon = sangoma_boost_data->mcon;
|
||||||
|
|
||||||
if (ss7bc_connection_open(&ss7_boost_data->mcon,
|
if (sangomabc_connection_open(&sangoma_boost_data->mcon,
|
||||||
ss7_boost_data->mcon.cfg.local_ip,
|
sangoma_boost_data->mcon.cfg.local_ip,
|
||||||
ss7_boost_data->mcon.cfg.local_port,
|
sangoma_boost_data->mcon.cfg.local_port,
|
||||||
ss7_boost_data->mcon.cfg.remote_ip,
|
sangoma_boost_data->mcon.cfg.remote_ip,
|
||||||
ss7_boost_data->mcon.cfg.remote_port) < 0) {
|
sangoma_boost_data->mcon.cfg.remote_port) < 0) {
|
||||||
zap_log(ZAP_LOG_DEBUG, "Error: Opening MCON Socket [%d] %s\n", ss7_boost_data->mcon.socket, strerror(errno));
|
zap_log(ZAP_LOG_DEBUG, "Error: Opening MCON Socket [%d] %s\n", sangoma_boost_data->mcon.socket, strerror(errno));
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ss7bc_connection_open(&ss7_boost_data->pcon,
|
if (sangomabc_connection_open(&sangoma_boost_data->pcon,
|
||||||
ss7_boost_data->pcon.cfg.local_ip,
|
sangoma_boost_data->pcon.cfg.local_ip,
|
||||||
++ss7_boost_data->pcon.cfg.local_port,
|
++sangoma_boost_data->pcon.cfg.local_port,
|
||||||
ss7_boost_data->pcon.cfg.remote_ip,
|
sangoma_boost_data->pcon.cfg.remote_ip,
|
||||||
++ss7_boost_data->pcon.cfg.remote_port) < 0) {
|
++sangoma_boost_data->pcon.cfg.remote_port) < 0) {
|
||||||
zap_log(ZAP_LOG_DEBUG, "Error: Opening PCON Socket [%d] %s\n", ss7_boost_data->pcon.socket, strerror(errno));
|
zap_log(ZAP_LOG_DEBUG, "Error: Opening PCON Socket [%d] %s\n", sangoma_boost_data->pcon.socket, strerror(errno));
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
mcon = &ss7_boost_data->mcon;
|
mcon = &sangoma_boost_data->mcon;
|
||||||
pcon = &ss7_boost_data->pcon;
|
pcon = &sangoma_boost_data->pcon;
|
||||||
|
|
||||||
init_outgoing_array();
|
init_outgoing_array();
|
||||||
|
|
||||||
ss7bc_exec_commandp(pcon,
|
sangomabc_exec_commandp(pcon,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
-1,
|
-1,
|
||||||
|
@ -1145,14 +1145,14 @@ static void *zap_ss7_boost_run(zap_thread_t *me, void *obj)
|
||||||
0);
|
0);
|
||||||
zap_set_flag(mcon, MSU_FLAG_DOWN);
|
zap_set_flag(mcon, MSU_FLAG_DOWN);
|
||||||
|
|
||||||
while (zap_test_flag(ss7_boost_data, ZAP_SS7_BOOST_RUNNING)) {
|
while (zap_test_flag(sangoma_boost_data, ZAP_SANGOMA_BOOST_RUNNING)) {
|
||||||
fd_set rfds, efds;
|
fd_set rfds, efds;
|
||||||
struct timeval tv = { 0, ms * 1000 };
|
struct timeval tv = { 0, ms * 1000 };
|
||||||
int max, activity, i = 0;
|
int max, activity, i = 0;
|
||||||
ss7bc_event_t *event = NULL;
|
sangomabc_event_t *event = NULL;
|
||||||
|
|
||||||
if (!zap_running()) {
|
if (!zap_running()) {
|
||||||
ss7bc_exec_commandp(pcon,
|
sangomabc_exec_commandp(pcon,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
-1,
|
-1,
|
||||||
|
@ -1181,16 +1181,16 @@ static void *zap_ss7_boost_run(zap_thread_t *me, void *obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FD_ISSET(pcon->socket, &rfds)) {
|
if (FD_ISSET(pcon->socket, &rfds)) {
|
||||||
while ((event = ss7bc_connection_readp(pcon, i))) {
|
while ((event = sangomabc_connection_readp(pcon, i))) {
|
||||||
parse_ss7_event(span, pcon, (ss7bc_short_event_t*)event);
|
parse_sangoma_event(span, pcon, (sangomabc_short_event_t*)event);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i=0;
|
i=0;
|
||||||
|
|
||||||
if (FD_ISSET(mcon->socket, &rfds)) {
|
if (FD_ISSET(mcon->socket, &rfds)) {
|
||||||
if ((event = ss7bc_connection_read(mcon, i))) {
|
if ((event = sangomabc_connection_read(mcon, i))) {
|
||||||
parse_ss7_event(span, mcon, (ss7bc_short_event_t*)event);
|
parse_sangoma_event(span, mcon, (sangomabc_short_event_t*)event);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1210,7 +1210,7 @@ static void *zap_ss7_boost_run(zap_thread_t *me, void *obj)
|
||||||
zap_log(ZAP_LOG_CRIT, "Lost Heartbeat!\n");
|
zap_log(ZAP_LOG_CRIT, "Lost Heartbeat!\n");
|
||||||
zap_set_flag_locked(span, ZAP_SPAN_SUSPENDED);
|
zap_set_flag_locked(span, ZAP_SPAN_SUSPENDED);
|
||||||
zap_set_flag(mcon, MSU_FLAG_DOWN);
|
zap_set_flag(mcon, MSU_FLAG_DOWN);
|
||||||
ss7bc_exec_commandp(pcon,
|
sangomabc_exec_commandp(pcon,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
-1,
|
-1,
|
||||||
|
@ -1231,21 +1231,21 @@ static void *zap_ss7_boost_run(zap_thread_t *me, void *obj)
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
|
||||||
ss7bc_connection_close(&ss7_boost_data->mcon);
|
sangomabc_connection_close(&sangoma_boost_data->mcon);
|
||||||
ss7bc_connection_close(&ss7_boost_data->pcon);
|
sangomabc_connection_close(&sangoma_boost_data->pcon);
|
||||||
|
|
||||||
zap_clear_flag(ss7_boost_data, ZAP_SS7_BOOST_RUNNING);
|
zap_clear_flag(sangoma_boost_data, ZAP_SANGOMA_BOOST_RUNNING);
|
||||||
|
|
||||||
zap_log(ZAP_LOG_DEBUG, "SS7_BOOST thread ended.\n");
|
zap_log(ZAP_LOG_DEBUG, "SANGOMA_BOOST thread ended.\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Loads ss7 boost signaling module
|
* \brief Loads sangoma boost signaling module
|
||||||
* \param zio Openzap IO interface
|
* \param zio Openzap IO interface
|
||||||
* \return Success
|
* \return Success
|
||||||
*/
|
*/
|
||||||
static ZIO_SIG_LOAD_FUNCTION(zap_ss7_boost_init)
|
static ZIO_SIG_LOAD_FUNCTION(zap_sangoma_boost_init)
|
||||||
{
|
{
|
||||||
zap_mutex_create(&request_mutex);
|
zap_mutex_create(&request_mutex);
|
||||||
zap_mutex_create(&signal_mutex);
|
zap_mutex_create(&signal_mutex);
|
||||||
|
@ -1253,21 +1253,21 @@ static ZIO_SIG_LOAD_FUNCTION(zap_ss7_boost_init)
|
||||||
return ZAP_SUCCESS;
|
return ZAP_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static zap_status_t zap_ss7_boost_start(zap_span_t *span)
|
static zap_status_t zap_sangoma_boost_start(zap_span_t *span)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
zap_ss7_boost_data_t *ss7_boost_data = span->signal_data;
|
zap_sangoma_boost_data_t *sangoma_boost_data = span->signal_data;
|
||||||
zap_set_flag(ss7_boost_data, ZAP_SS7_BOOST_RUNNING);
|
zap_set_flag(sangoma_boost_data, ZAP_SANGOMA_BOOST_RUNNING);
|
||||||
err=zap_thread_create_detached(zap_ss7_boost_run, span);
|
err=zap_thread_create_detached(zap_sangoma_boost_run, span);
|
||||||
if (err) {
|
if (err) {
|
||||||
zap_clear_flag(ss7_boost_data, ZAP_SS7_BOOST_RUNNING);
|
zap_clear_flag(sangoma_boost_data, ZAP_SANGOMA_BOOST_RUNNING);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
// launch the events thread to handle HW DTMF and possibly
|
// launch the events thread to handle HW DTMF and possibly
|
||||||
// other events in the future
|
// other events in the future
|
||||||
err=zap_thread_create_detached(zap_ss7_events_run, span);
|
err=zap_thread_create_detached(zap_sangoma_events_run, span);
|
||||||
if (err) {
|
if (err) {
|
||||||
zap_clear_flag(ss7_boost_data, ZAP_SS7_BOOST_RUNNING);
|
zap_clear_flag(sangoma_boost_data, ZAP_SANGOMA_BOOST_RUNNING);
|
||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -1372,15 +1372,15 @@ static zap_state_map_t boost_state_map = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Initialises an ss7 boost span from configuration variables
|
* \brief Initialises an sangoma boost span from configuration variables
|
||||||
* \param span Span to configure
|
* \param span Span to configure
|
||||||
* \param sig_cb Callback function for event signals
|
* \param sig_cb Callback function for event signals
|
||||||
* \param ap List of configuration variables
|
* \param ap List of configuration variables
|
||||||
* \return Success or failure
|
* \return Success or failure
|
||||||
*/
|
*/
|
||||||
static ZIO_SIG_CONFIGURE_FUNCTION(zap_ss7_boost_configure_span)
|
static ZIO_SIG_CONFIGURE_FUNCTION(zap_sangoma_boost_configure_span)
|
||||||
{
|
{
|
||||||
zap_ss7_boost_data_t *ss7_boost_data = NULL;
|
zap_sangoma_boost_data_t *sangoma_boost_data = NULL;
|
||||||
const char *local_ip = "127.0.0.65", *remote_ip = "127.0.0.66";
|
const char *local_ip = "127.0.0.65", *remote_ip = "127.0.0.66";
|
||||||
int local_port = 53000, remote_port = 53000;
|
int local_port = 53000, remote_port = 53000;
|
||||||
char *var, *val;
|
char *var, *val;
|
||||||
|
@ -1419,20 +1419,20 @@ static ZIO_SIG_CONFIGURE_FUNCTION(zap_ss7_boost_configure_span)
|
||||||
return ZAP_FAIL;
|
return ZAP_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ss7_boost_data = malloc(sizeof(*ss7_boost_data));
|
sangoma_boost_data = malloc(sizeof(*sangoma_boost_data));
|
||||||
assert(ss7_boost_data);
|
assert(sangoma_boost_data);
|
||||||
memset(ss7_boost_data, 0, sizeof(*ss7_boost_data));
|
memset(sangoma_boost_data, 0, sizeof(*sangoma_boost_data));
|
||||||
|
|
||||||
zap_set_string(ss7_boost_data->mcon.cfg.local_ip, local_ip);
|
zap_set_string(sangoma_boost_data->mcon.cfg.local_ip, local_ip);
|
||||||
ss7_boost_data->mcon.cfg.local_port = local_port;
|
sangoma_boost_data->mcon.cfg.local_port = local_port;
|
||||||
zap_set_string(ss7_boost_data->mcon.cfg.remote_ip, remote_ip);
|
zap_set_string(sangoma_boost_data->mcon.cfg.remote_ip, remote_ip);
|
||||||
ss7_boost_data->mcon.cfg.remote_port = remote_port;
|
sangoma_boost_data->mcon.cfg.remote_port = remote_port;
|
||||||
ss7_boost_data->signal_cb = sig_cb;
|
sangoma_boost_data->signal_cb = sig_cb;
|
||||||
span->start = zap_ss7_boost_start;
|
span->start = zap_sangoma_boost_start;
|
||||||
span->signal_data = ss7_boost_data;
|
span->signal_data = sangoma_boost_data;
|
||||||
span->signal_type = ZAP_SIGTYPE_SS7BOOST;
|
span->signal_type = ZAP_SIGTYPE_SANGOMABOOST;
|
||||||
span->outgoing_call = ss7_boost_outgoing_call;
|
span->outgoing_call = sangoma_boost_outgoing_call;
|
||||||
span->channel_request = ss7_boost_channel_request;
|
span->channel_request = sangoma_boost_channel_request;
|
||||||
span->state_map = &boost_state_map;
|
span->state_map = &boost_state_map;
|
||||||
zap_set_flag_locked(span, ZAP_SPAN_SUSPENDED);
|
zap_set_flag_locked(span, ZAP_SPAN_SUSPENDED);
|
||||||
|
|
||||||
|
@ -1440,14 +1440,14 @@ static ZIO_SIG_CONFIGURE_FUNCTION(zap_ss7_boost_configure_span)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Openzap ss7 boost signaling module definition
|
* \brief Openzap sangoma boost signaling module definition
|
||||||
*/
|
*/
|
||||||
zap_module_t zap_module = {
|
zap_module_t zap_module = {
|
||||||
"ss7_boost",
|
"sangoma_boost",
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
zap_ss7_boost_init,
|
zap_sangoma_boost_init,
|
||||||
zap_ss7_boost_configure_span,
|
zap_sangoma_boost_configure_span,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "openzap.h"
|
#include "openzap.h"
|
||||||
#include <ss7_boost_client.h>
|
#include <sangoma_boost_client.h>
|
||||||
|
|
||||||
|
|
||||||
#ifndef HAVE_GETHOSTBYNAME_R
|
#ifndef HAVE_GETHOSTBYNAME_R
|
||||||
|
@ -47,12 +47,12 @@ extern int gethostbyname_r (const char *__name,
|
||||||
int *__h_errnop);
|
int *__h_errnop);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct ss7bc_map {
|
struct sangomabc_map {
|
||||||
uint32_t event_id;
|
uint32_t event_id;
|
||||||
const char *name;
|
const char *name;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct ss7bc_map ss7bc_table[] = {
|
static struct sangomabc_map sangomabc_table[] = {
|
||||||
{SIGBOOST_EVENT_CALL_START, "CALL_START"},
|
{SIGBOOST_EVENT_CALL_START, "CALL_START"},
|
||||||
{SIGBOOST_EVENT_CALL_START_ACK, "CALL_START_ACK"},
|
{SIGBOOST_EVENT_CALL_START_ACK, "CALL_START_ACK"},
|
||||||
{SIGBOOST_EVENT_CALL_START_NACK, "CALL_START_NACK"},
|
{SIGBOOST_EVENT_CALL_START_NACK, "CALL_START_NACK"},
|
||||||
|
@ -71,13 +71,13 @@ static struct ss7bc_map ss7bc_table[] = {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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 sangomabc_print_event_call(sangomabc_connection_t *mcon, sangomabc_event_t *event, int priority, int dir, const char *file, const char *func, int line)
|
||||||
{
|
{
|
||||||
if (event->event_id == SIGBOOST_EVENT_HEARTBEAT)
|
if (event->event_id == SIGBOOST_EVENT_HEARTBEAT)
|
||||||
return;
|
return;
|
||||||
zap_log(file, func, line, ZAP_LOG_LEVEL_WARNING, "%s EVENT: %s:(%X) [w%dg%d] CSid=%i Seq=%i Cn=[%s] Cd=[%s] Ci=[%s]\n",
|
zap_log(file, func, line, ZAP_LOG_LEVEL_WARNING, "%s EVENT: %s:(%X) [w%dg%d] CSid=%i Seq=%i Cn=[%s] Cd=[%s] Ci=[%s]\n",
|
||||||
dir ? "TX":"RX",
|
dir ? "TX":"RX",
|
||||||
ss7bc_event_id_name(event->event_id),
|
sangomabc_event_id_name(event->event_id),
|
||||||
event->event_id,
|
event->event_id,
|
||||||
event->span+1,
|
event->span+1,
|
||||||
event->chan+1,
|
event->chan+1,
|
||||||
|
@ -89,14 +89,14 @@ static void ss7bc_print_event_call(ss7bc_connection_t *mcon, ss7bc_event_t *even
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
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 sangomabc_print_event_short(sangomabc_connection_t *mcon, sangomabc_short_event_t *event, int priority, int dir, const char *file, const char *func, int line)
|
||||||
{
|
{
|
||||||
if (event->event_id == SIGBOOST_EVENT_HEARTBEAT)
|
if (event->event_id == SIGBOOST_EVENT_HEARTBEAT)
|
||||||
return;
|
return;
|
||||||
zap_log(file, func, line, ZAP_LOG_LEVEL_WARNING, "%s EVENT (%s): %s:(%X) [w%dg%d] Rc=%i CSid=%i Seq=%i \n",
|
zap_log(file, func, line, ZAP_LOG_LEVEL_WARNING, "%s EVENT (%s): %s:(%X) [w%dg%d] Rc=%i CSid=%i Seq=%i \n",
|
||||||
dir ? "TX":"RX",
|
dir ? "TX":"RX",
|
||||||
priority ? "P":"N",
|
priority ? "P":"N",
|
||||||
ss7bc_event_id_name(event->event_id),
|
sangomabc_event_id_name(event->event_id),
|
||||||
event->event_id,
|
event->event_id,
|
||||||
event->span+1,
|
event->span+1,
|
||||||
event->chan+1,
|
event->chan+1,
|
||||||
|
@ -106,7 +106,7 @@ static void ss7bc_print_event_short(ss7bc_connection_t *mcon, ss7bc_short_event_
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int create_conn_socket(ss7bc_connection_t *mcon, char *local_ip, int local_port, char *ip, int port)
|
static int create_conn_socket(sangomabc_connection_t *mcon, char *local_ip, int local_port, char *ip, int port)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
struct hostent *result, *local_result;
|
struct hostent *result, *local_result;
|
||||||
|
@ -172,7 +172,7 @@ static int create_conn_socket(ss7bc_connection_t *mcon, char *local_ip, int loca
|
||||||
return mcon->socket;
|
return mcon->socket;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ss7bc_connection_close(ss7bc_connection_t *mcon)
|
int sangomabc_connection_close(sangomabc_connection_t *mcon)
|
||||||
{
|
{
|
||||||
if (mcon->socket > -1) {
|
if (mcon->socket > -1) {
|
||||||
close(mcon->socket);
|
close(mcon->socket);
|
||||||
|
@ -189,19 +189,19 @@ int ss7bc_connection_close(ss7bc_connection_t *mcon)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ss7bc_connection_open(ss7bc_connection_t *mcon, char *local_ip, int local_port, char *ip, int port)
|
int sangomabc_connection_open(sangomabc_connection_t *mcon, char *local_ip, int local_port, char *ip, int port)
|
||||||
{
|
{
|
||||||
create_conn_socket(mcon, local_ip, local_port, ip, port);
|
create_conn_socket(mcon, local_ip, local_port, ip, port);
|
||||||
return mcon->socket;
|
return mcon->socket;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ss7bc_exec_command(ss7bc_connection_t *mcon, int span, int chan, int id, int cmd, int cause)
|
int sangomabc_exec_command(sangomabc_connection_t *mcon, int span, int chan, int id, int cmd, int cause)
|
||||||
{
|
{
|
||||||
ss7bc_short_event_t oevent;
|
sangomabc_short_event_t oevent;
|
||||||
int retry = 5;
|
int retry = 5;
|
||||||
|
|
||||||
ss7bc_event_init(&oevent, cmd, chan, span);
|
sangomabc_event_init(&oevent, cmd, chan, span);
|
||||||
oevent.release_cause = cause;
|
oevent.release_cause = cause;
|
||||||
|
|
||||||
if (cmd == SIGBOOST_EVENT_SYSTEM_RESTART || cmd == SIGBOOST_EVENT_SYSTEM_RESTART_ACK) {
|
if (cmd == SIGBOOST_EVENT_SYSTEM_RESTART || cmd == SIGBOOST_EVENT_SYSTEM_RESTART_ACK) {
|
||||||
|
@ -215,7 +215,7 @@ int ss7bc_exec_command(ss7bc_connection_t *mcon, int span, int chan, int id, int
|
||||||
oevent.call_setup_id = id;
|
oevent.call_setup_id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (ss7bc_connection_write(mcon, (ss7bc_event_t*)&oevent) <= 0) {
|
while (sangomabc_connection_write(mcon, (sangomabc_event_t*)&oevent) <= 0) {
|
||||||
if (--retry <= 0) {
|
if (--retry <= 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));
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -229,19 +229,19 @@ int ss7bc_exec_command(ss7bc_connection_t *mcon, int span, int chan, int id, int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ss7bc_exec_commandp(ss7bc_connection_t *pcon, int span, int chan, int id, int cmd, int cause)
|
int sangomabc_exec_commandp(sangomabc_connection_t *pcon, int span, int chan, int id, int cmd, int cause)
|
||||||
{
|
{
|
||||||
ss7bc_short_event_t oevent;
|
sangomabc_short_event_t oevent;
|
||||||
int retry = 5;
|
int retry = 5;
|
||||||
|
|
||||||
ss7bc_event_init(&oevent, cmd, chan, span);
|
sangomabc_event_init(&oevent, cmd, chan, span);
|
||||||
oevent.release_cause = cause;
|
oevent.release_cause = cause;
|
||||||
|
|
||||||
if (id >= 0) {
|
if (id >= 0) {
|
||||||
oevent.call_setup_id = id;
|
oevent.call_setup_id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (ss7bc_connection_writep(pcon, (ss7bc_event_t*)&oevent) <= 0) {
|
while (sangomabc_connection_writep(pcon, (sangomabc_event_t*)&oevent) <= 0) {
|
||||||
if (--retry <= 0) {
|
if (--retry <= 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));
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -254,7 +254,7 @@ int ss7bc_exec_commandp(ss7bc_connection_t *pcon, int span, int chan, int id, in
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ss7bc_event_t *__ss7bc_connection_read(ss7bc_connection_t *mcon, int iteration, const char *file, const char *func, int line)
|
sangomabc_event_t *__sangomabc_connection_read(sangomabc_connection_t *mcon, int iteration, const char *file, const char *func, int line)
|
||||||
{
|
{
|
||||||
unsigned int fromlen = sizeof(struct sockaddr_in);
|
unsigned int fromlen = sizeof(struct sockaddr_in);
|
||||||
int bytes = 0;
|
int bytes = 0;
|
||||||
|
@ -278,7 +278,7 @@ ss7bc_event_t *__ss7bc_connection_read(ss7bc_connection_t *mcon, int iteration,
|
||||||
} else if ((bytes >= MIN_SIZE_CALLSTART_MSG) && boost_full_event(mcon->event.event_id)) {
|
} else if ((bytes >= MIN_SIZE_CALLSTART_MSG) && boost_full_event(mcon->event.event_id)) {
|
||||||
msg_ok=1;
|
msg_ok=1;
|
||||||
|
|
||||||
} else if (bytes == sizeof(ss7bc_short_event_t)) {
|
} else if (bytes == sizeof(sangomabc_short_event_t)) {
|
||||||
msg_ok=1;
|
msg_ok=1;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -287,20 +287,20 @@ ss7bc_event_t *__ss7bc_connection_read(ss7bc_connection_t *mcon, int iteration,
|
||||||
|
|
||||||
if (msg_ok){
|
if (msg_ok){
|
||||||
|
|
||||||
if (ss7bc_test_flag(mcon, MSU_FLAG_DOWN)) {
|
if (sangomabc_test_flag(mcon, MSU_FLAG_DOWN)) {
|
||||||
if (mcon->event.event_id != SIGBOOST_EVENT_SYSTEM_RESTART &&
|
if (mcon->event.event_id != SIGBOOST_EVENT_SYSTEM_RESTART &&
|
||||||
mcon->event.event_id != SIGBOOST_EVENT_SYSTEM_RESTART_ACK &&
|
mcon->event.event_id != SIGBOOST_EVENT_SYSTEM_RESTART_ACK &&
|
||||||
mcon->event.event_id != SIGBOOST_EVENT_HEARTBEAT) {
|
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",
|
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));
|
sangomabc_event_id_name(mcon->event.event_id));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (boost_full_event(mcon->event.event_id)) {
|
if (boost_full_event(mcon->event.event_id)) {
|
||||||
ss7bc_print_event_call(mcon, &mcon->event, 0, 0, file, func, line);
|
sangomabc_print_event_call(mcon, &mcon->event, 0, 0, file, func, line);
|
||||||
} else {
|
} else {
|
||||||
ss7bc_print_event_short(mcon, (ss7bc_short_event_t*)&mcon->event, 0, 0, file, func, line);
|
sangomabc_print_event_short(mcon, (sangomabc_short_event_t*)&mcon->event, 0, 0, file, func, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -338,7 +338,7 @@ ss7bc_event_t *__ss7bc_connection_read(ss7bc_connection_t *mcon, int iteration,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ss7bc_event_t *__ss7bc_connection_readp(ss7bc_connection_t *mcon, int iteration, const char *file, const char *func, int line)
|
sangomabc_event_t *__sangomabc_connection_readp(sangomabc_connection_t *mcon, int iteration, const char *file, const char *func, int line)
|
||||||
{
|
{
|
||||||
unsigned int fromlen = sizeof(struct sockaddr_in);
|
unsigned int fromlen = sizeof(struct sockaddr_in);
|
||||||
int bytes = 0;
|
int bytes = 0;
|
||||||
|
@ -353,12 +353,12 @@ ss7bc_event_t *__ss7bc_connection_readp(ss7bc_connection_t *mcon, int iteration,
|
||||||
zap_log(ZAP_LOG_CRIT, "Invalid Boost Version %i Expecting %i\n",mcon->event.version, SIGBOOST_VERSION);
|
zap_log(ZAP_LOG_CRIT, "Invalid Boost Version %i Expecting %i\n",mcon->event.version, SIGBOOST_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bytes == sizeof(ss7bc_short_event_t)) {
|
if (bytes == sizeof(sangomabc_short_event_t)) {
|
||||||
|
|
||||||
if (boost_full_event(mcon->event.event_id)) {
|
if (boost_full_event(mcon->event.event_id)) {
|
||||||
ss7bc_print_event_call(mcon, &mcon->event, 1, 0, file, func, line);
|
sangomabc_print_event_call(mcon, &mcon->event, 1, 0, file, func, line);
|
||||||
} else {
|
} else {
|
||||||
ss7bc_print_event_short(mcon, (ss7bc_short_event_t*)&mcon->event, 1, 0, file, func, line);
|
sangomabc_print_event_short(mcon, (sangomabc_short_event_t*)&mcon->event, 1, 0, file, func, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
return &mcon->event;
|
return &mcon->event;
|
||||||
|
@ -373,7 +373,7 @@ ss7bc_event_t *__ss7bc_connection_readp(ss7bc_connection_t *mcon, int iteration,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int __ss7bc_connection_write(ss7bc_connection_t *mcon, ss7bc_event_t *event, const char *file, const char *func, int line)
|
int __sangomabc_connection_write(sangomabc_connection_t *mcon, sangomabc_event_t *event, const char *file, const char *func, int line)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
int event_size=MIN_SIZE_CALLSTART_MSG+event->isup_in_rdnis_size;
|
int event_size=MIN_SIZE_CALLSTART_MSG+event->isup_in_rdnis_size;
|
||||||
|
@ -385,21 +385,21 @@ int __ss7bc_connection_write(ss7bc_connection_t *mcon, ss7bc_event_t *event, con
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event->span >= ZAP_MAX_PHYSICAL_SPANS_PER_LOGICAL_SPAN || event->chan >= ZAP_MAX_CHANNELS_PHYSICAL_SPAN ) {
|
if (event->span >= ZAP_MAX_PHYSICAL_SPANS_PER_LOGICAL_SPAN || event->chan >= ZAP_MAX_CHANNELS_PHYSICAL_SPAN ) {
|
||||||
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", sangomabc_event_id_name(event->event_id), event->span, event->chan);
|
||||||
abort();
|
abort();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!boost_full_event(event->event_id)) {
|
if (!boost_full_event(event->event_id)) {
|
||||||
event_size=sizeof(ss7bc_short_event_t);
|
event_size=sizeof(sangomabc_short_event_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ss7bc_test_flag(mcon, MSU_FLAG_DOWN)) {
|
if (sangomabc_test_flag(mcon, MSU_FLAG_DOWN)) {
|
||||||
if (event->event_id != SIGBOOST_EVENT_SYSTEM_RESTART &&
|
if (event->event_id != SIGBOOST_EVENT_SYSTEM_RESTART &&
|
||||||
event->event_id != SIGBOOST_EVENT_SYSTEM_RESTART_ACK &&
|
event->event_id != SIGBOOST_EVENT_SYSTEM_RESTART_ACK &&
|
||||||
event->event_id != SIGBOOST_EVENT_HEARTBEAT) {
|
event->event_id != SIGBOOST_EVENT_HEARTBEAT) {
|
||||||
zap_log(file, func, line, ZAP_LOG_LEVEL_WARNING, "Not writing packets when connection is down. [%s]\n",
|
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));
|
sangomabc_event_id_name(event->event_id));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -424,19 +424,19 @@ int __ss7bc_connection_write(ss7bc_connection_t *mcon, ss7bc_event_t *event, con
|
||||||
}
|
}
|
||||||
|
|
||||||
if (boost_full_event(event->event_id)) {
|
if (boost_full_event(event->event_id)) {
|
||||||
ss7bc_print_event_call(mcon, event, 0, 1, file, func, line);
|
sangomabc_print_event_call(mcon, event, 0, 1, file, func, line);
|
||||||
} else {
|
} else {
|
||||||
ss7bc_print_event_short(mcon, (ss7bc_short_event_t*)event, 0, 1, file, func, line);
|
sangomabc_print_event_short(mcon, (sangomabc_short_event_t*)event, 0, 1, file, func, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int __ss7bc_connection_writep(ss7bc_connection_t *mcon, ss7bc_event_t *event, const char *file, const char *func, int line)
|
int __sangomabc_connection_writep(sangomabc_connection_t *mcon, sangomabc_event_t *event, const char *file, const char *func, int line)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
int event_size=sizeof(ss7bc_event_t);
|
int event_size=sizeof(sangomabc_event_t);
|
||||||
|
|
||||||
if (!event || mcon->socket < 0 || !mcon->mutex) {
|
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");
|
||||||
|
@ -445,7 +445,7 @@ int __ss7bc_connection_writep(ss7bc_connection_t *mcon, ss7bc_event_t *event, co
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!boost_full_event(event->event_id)) {
|
if (!boost_full_event(event->event_id)) {
|
||||||
event_size=sizeof(ss7bc_short_event_t);
|
event_size=sizeof(sangomabc_short_event_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
zap_mutex_lock(mcon->mutex);
|
zap_mutex_lock(mcon->mutex);
|
||||||
|
@ -459,18 +459,18 @@ int __ss7bc_connection_writep(ss7bc_connection_t *mcon, ss7bc_event_t *event, co
|
||||||
}
|
}
|
||||||
|
|
||||||
if (boost_full_event(event->event_id)) {
|
if (boost_full_event(event->event_id)) {
|
||||||
ss7bc_print_event_call(mcon, event, 1, 1, file, func, line);
|
sangomabc_print_event_call(mcon, event, 1, 1, file, func, line);
|
||||||
} else {
|
} else {
|
||||||
ss7bc_print_event_short(mcon, (ss7bc_short_event_t*)event, 1, 1, file, func, line);
|
sangomabc_print_event_short(mcon, (sangomabc_short_event_t*)event, 1, 1, file, func, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ss7bc_call_init(ss7bc_event_t *event, const char *calling, const char *called, int setup_id)
|
void sangomabc_call_init(sangomabc_event_t *event, const char *calling, const char *called, int setup_id)
|
||||||
{
|
{
|
||||||
memset(event, 0, sizeof(ss7bc_event_t));
|
memset(event, 0, sizeof(sangomabc_event_t));
|
||||||
event->event_id = SIGBOOST_EVENT_CALL_START;
|
event->event_id = SIGBOOST_EVENT_CALL_START;
|
||||||
|
|
||||||
if (calling) {
|
if (calling) {
|
||||||
|
@ -487,22 +487,22 @@ void ss7bc_call_init(ss7bc_event_t *event, const char *calling, const char *call
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ss7bc_event_init(ss7bc_short_event_t *event, ss7bc_event_id_t event_id, int chan, int span)
|
void sangomabc_event_init(sangomabc_short_event_t *event, sangomabc_event_id_t event_id, int chan, int span)
|
||||||
{
|
{
|
||||||
memset(event, 0, sizeof(ss7bc_short_event_t));
|
memset(event, 0, sizeof(sangomabc_short_event_t));
|
||||||
event->event_id = event_id;
|
event->event_id = event_id;
|
||||||
event->chan = chan;
|
event->chan = chan;
|
||||||
event->span = span;
|
event->span = span;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *ss7bc_event_id_name(uint32_t event_id)
|
const char *sangomabc_event_id_name(uint32_t event_id)
|
||||||
{
|
{
|
||||||
unsigned int x;
|
unsigned int x;
|
||||||
const char *ret = NULL;
|
const char *ret = NULL;
|
||||||
|
|
||||||
for (x = 0 ; x < sizeof(ss7bc_table)/sizeof(struct ss7bc_map); x++) {
|
for (x = 0 ; x < sizeof(sangomabc_table)/sizeof(struct sangomabc_map); x++) {
|
||||||
if (ss7bc_table[x].event_id == event_id) {
|
if (sangomabc_table[x].event_id == event_id) {
|
||||||
ret = ss7bc_table[x].name;
|
ret = sangomabc_table[x].name;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,8 +31,8 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _SS7BC_H
|
#ifndef _SANGOMABC_H
|
||||||
#define _SS7BC_H
|
#define _SANGOMABC_H
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -53,46 +53,46 @@
|
||||||
#include <sigboost.h>
|
#include <sigboost.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
#define ss7bc_test_flag(p,flag) ({ \
|
#define sangomabc_test_flag(p,flag) ({ \
|
||||||
((p)->flags & (flag)); \
|
((p)->flags & (flag)); \
|
||||||
})
|
})
|
||||||
|
|
||||||
#define ss7bc_set_flag(p,flag) do { \
|
#define sangomabc_set_flag(p,flag) do { \
|
||||||
((p)->flags |= (flag)); \
|
((p)->flags |= (flag)); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define ss7bc_clear_flag(p,flag) do { \
|
#define sangomabc_clear_flag(p,flag) do { \
|
||||||
((p)->flags &= ~(flag)); \
|
((p)->flags &= ~(flag)); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define ss7bc_copy_flags(dest,src,flagz) do { \
|
#define sangomabc_copy_flags(dest,src,flagz) do { \
|
||||||
(dest)->flags &= ~(flagz); \
|
(dest)->flags &= ~(flagz); \
|
||||||
(dest)->flags |= ((src)->flags & (flagz)); \
|
(dest)->flags |= ((src)->flags & (flagz)); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
typedef t_sigboost_callstart ss7bc_event_t;
|
typedef t_sigboost_callstart sangomabc_event_t;
|
||||||
typedef t_sigboost_short ss7bc_short_event_t;
|
typedef t_sigboost_short sangomabc_short_event_t;
|
||||||
typedef uint32_t ss7bc_event_id_t;
|
typedef uint32_t sangomabc_event_id_t;
|
||||||
|
|
||||||
typedef struct ss7bc_ip_cfg
|
typedef struct sangomabc_ip_cfg
|
||||||
{
|
{
|
||||||
char local_ip[25];
|
char local_ip[25];
|
||||||
int local_port;
|
int local_port;
|
||||||
char remote_ip[25];
|
char remote_ip[25];
|
||||||
int remote_port;
|
int remote_port;
|
||||||
}ss7bc_ip_cfg_t;
|
}sangomabc_ip_cfg_t;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
MSU_FLAG_EVENT = (1 << 0),
|
MSU_FLAG_EVENT = (1 << 0),
|
||||||
MSU_FLAG_DOWN = (1 << 1)
|
MSU_FLAG_DOWN = (1 << 1)
|
||||||
} ss7bc_flag_t;
|
} sangomabc_flag_t;
|
||||||
|
|
||||||
|
|
||||||
struct ss7bc_connection {
|
struct sangomabc_connection {
|
||||||
zap_socket_t socket;
|
zap_socket_t socket;
|
||||||
struct sockaddr_in local_addr;
|
struct sockaddr_in local_addr;
|
||||||
struct sockaddr_in remote_addr;
|
struct sockaddr_in remote_addr;
|
||||||
ss7bc_event_t event;
|
sangomabc_event_t event;
|
||||||
struct hostent remote_hp;
|
struct hostent remote_hp;
|
||||||
struct hostent local_hp;
|
struct hostent local_hp;
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
|
@ -102,11 +102,11 @@ struct ss7bc_connection {
|
||||||
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;
|
sangomabc_ip_cfg_t cfg;
|
||||||
uint32_t hb_elapsed;
|
uint32_t hb_elapsed;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct ss7bc_connection ss7bc_connection_t;
|
typedef struct sangomabc_connection sangomabc_connection_t;
|
||||||
|
|
||||||
/* disable nagle's algorythm */
|
/* disable nagle's algorythm */
|
||||||
static inline void sctp_no_nagle(int socket)
|
static inline void sctp_no_nagle(int socket)
|
||||||
|
@ -117,21 +117,21 @@ static inline void sctp_no_nagle(int socket)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int ss7bc_connection_close(ss7bc_connection_t *mcon);
|
int sangomabc_connection_close(sangomabc_connection_t *mcon);
|
||||||
int ss7bc_connection_open(ss7bc_connection_t *mcon, char *local_ip, int local_port, char *ip, int port);
|
int sangomabc_connection_open(sangomabc_connection_t *mcon, char *local_ip, int local_port, char *ip, int port);
|
||||||
ss7bc_event_t *__ss7bc_connection_read(ss7bc_connection_t *mcon, int iteration, const char *file, const char *func, int line);
|
sangomabc_event_t *__sangomabc_connection_read(sangomabc_connection_t *mcon, int iteration, const char *file, const char *func, int line);
|
||||||
ss7bc_event_t *__ss7bc_connection_readp(ss7bc_connection_t *mcon, int iteration, const char *file, const char *func, int line);
|
sangomabc_event_t *__sangomabc_connection_readp(sangomabc_connection_t *mcon, int iteration, const char *file, const char *func, int line);
|
||||||
int __ss7bc_connection_write(ss7bc_connection_t *mcon, ss7bc_event_t *event, const char *file, const char *func, int line);
|
int __sangomabc_connection_write(sangomabc_connection_t *mcon, sangomabc_event_t *event, const char *file, const char *func, int line);
|
||||||
int __ss7bc_connection_writep(ss7bc_connection_t *mcon, ss7bc_event_t *event, const char *file, const char *func, int line);
|
int __sangomabc_connection_writep(sangomabc_connection_t *mcon, sangomabc_event_t *event, const char *file, const char *func, int line);
|
||||||
#define ss7bc_connection_write(_m,_e) __ss7bc_connection_write(_m, _e, __FILE__, __func__, __LINE__)
|
#define sangomabc_connection_write(_m,_e) __sangomabc_connection_write(_m, _e, __FILE__, __func__, __LINE__)
|
||||||
#define ss7bc_connection_writep(_m,_e) __ss7bc_connection_writep(_m, _e, __FILE__, __func__, __LINE__)
|
#define sangomabc_connection_writep(_m,_e) __sangomabc_connection_writep(_m, _e, __FILE__, __func__, __LINE__)
|
||||||
#define ss7bc_connection_read(_m,_e) __ss7bc_connection_read(_m, _e, __FILE__, __func__, __LINE__)
|
#define sangomabc_connection_read(_m,_e) __sangomabc_connection_read(_m, _e, __FILE__, __func__, __LINE__)
|
||||||
#define ss7bc_connection_readp(_m,_e) __ss7bc_connection_readp(_m, _e, __FILE__, __func__, __LINE__)
|
#define sangomabc_connection_readp(_m,_e) __sangomabc_connection_readp(_m, _e, __FILE__, __func__, __LINE__)
|
||||||
void ss7bc_event_init(ss7bc_short_event_t *event, ss7bc_event_id_t event_id, int chan, int span);
|
void sangomabc_event_init(sangomabc_short_event_t *event, sangomabc_event_id_t event_id, int chan, int span);
|
||||||
void ss7bc_call_init(ss7bc_event_t *event, const char *calling, const char *called, int setup_id);
|
void sangomabc_call_init(sangomabc_event_t *event, const char *calling, const char *called, int setup_id);
|
||||||
const char *ss7bc_event_id_name(uint32_t event_id);
|
const char *sangomabc_event_id_name(uint32_t event_id);
|
||||||
int ss7bc_exec_command(ss7bc_connection_t *mcon, int span, int chan, int id, int cmd, int cause);
|
int sangomabc_exec_command(sangomabc_connection_t *mcon, int span, int chan, int id, int cmd, int cause);
|
||||||
int ss7bc_exec_commandp(ss7bc_connection_t *pcon, int span, int chan, int id, int cmd, int cause);
|
int sangomabc_exec_commandp(sangomabc_connection_t *pcon, int span, int chan, int id, int cmd, int cause);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -31,22 +31,22 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef ZAP_SS7_BOOST_H
|
#ifndef ZAP_SANGOMA_BOOST_H
|
||||||
#define ZAP_SS7_BOOST_H
|
#define ZAP_SANGOMA_BOOST_H
|
||||||
#include "ss7_boost_client.h"
|
#include "sangoma_boost_client.h"
|
||||||
#include "openzap.h"
|
#include "openzap.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ZAP_SS7_BOOST_RUNNING = (1 << 0),
|
ZAP_SANGOMA_BOOST_RUNNING = (1 << 0),
|
||||||
ZAP_SS7_BOOST_RESTARTING = (1 << 1)
|
ZAP_SANGOMA_BOOST_RESTARTING = (1 << 1)
|
||||||
} zap_ss7_boost_flag_t;
|
} zap_sangoma_boost_flag_t;
|
||||||
|
|
||||||
typedef struct zap_ss7_boost_data {
|
typedef struct zap_sangoma_boost_data {
|
||||||
ss7bc_connection_t mcon;
|
sangomabc_connection_t mcon;
|
||||||
ss7bc_connection_t pcon;
|
sangomabc_connection_t pcon;
|
||||||
zio_signal_cb_t signal_cb;
|
zio_signal_cb_t signal_cb;
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
} zap_ss7_boost_data_t;
|
} zap_sangoma_boost_data_t;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue