-> adding ftmod_sangoma_ss7 support

This commit is contained in:
Konrad Hammel 2010-06-05 18:23:39 -04:00 committed by Moises Silva
parent fabaa4a28e
commit 9428335522
11 changed files with 7514 additions and 1 deletions

View File

@ -37,7 +37,10 @@ libdir = @libdir@
library_includedir = $(PREFIX)/include
INCS = -I$(FT_SRCDIR)/$(SRC)/include -I$(FT_SRCDIR)/$(SRC)/isdn/include -I$(FT_SRCDIR)/$(SRC)/include/private
INCS += -I$(FT_SRCDIR)/$(SRC)/ftmod/ftmod_sangoma_boost
INCS += -I$(FT_SRCDIR)/$(SRC)/ftmod/ftmod_sangoma_boost
if SNGSS7
INCS += -I/usr/include/wanpipe/sng_ss7/
endif
MY_CFLAGS = $(INCS) $(FTDM_CFLAGS) -DFTDM_CONFIG_DIR=\"@confdir@\" -DFTDM_MOD_DIR=\"$(moddir)\" @COMP_VENDOR_CFLAGS@ @DEFS@
COMPILE = $(CC) $(MY_CFLAGS) $(INCS)
LTCOMPILE = $(LIBTOOL) --mode=compile --tag=CC $(COMPILE)
@ -164,6 +167,10 @@ if LIBPRI
mod_LTLIBRARIES += ftmod_libpri.la
endif
if SNGSS7
mod_LTLIBRARIES += ftmod_sangoma_ss7.la
endif
if OPENR2
mod_LTLIBRARIES += ftmod_r2.la
endif
@ -236,6 +243,20 @@ ftmod_libpri_la_LDFLAGS = -module -avoid-version -lpri
ftmod_libpri_la_LIBADD = $(MYLIB)
endif
if SNGSS7
ftmod_sangoma_ss7_la_SOURCES = $(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c \
$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c \
$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_in.c \
$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c \
$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cntrl.c \
$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c \
$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_timers.c \
$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c
ftmod_sangoma_ss7_la_CFLAGS = $(AM_CFLAGS) $(MY_CFLAGS) -D_GNU_SOURCE
ftmod_sangoma_ss7_la_LDFLAGS = -module -avoid-version -lsng_ss7
ftmod_sangoma_ss7_la_LIBADD = $(MYLIB)
endif
if OPENR2
ftmod_r2_la_SOURCES = $(SRC)/ftmod/ftmod_r2/ftmod_r2.c
ftmod_r2_la_CFLAGS = $(AM_CFLAGS) $(MY_CFLAGS)

View File

@ -170,6 +170,9 @@ AM_CONDITIONAL([LIBSANGOMA],[test "${have_libsangoma}" = "yes"])
AM_CONDITIONAL([LIBPRI],[test "${enable_libpri}" = "yes"])
AC_CHECK_LIB([sng_ss7], [sng_isup_init], [have_sng_ss7="yes"])
AM_CONDITIONAL([SNGSS7],[test "${have_sng_ss7}" = "yes"])
AC_CHECK_LIB([openr2], [openr2_context_set_io_type], [have_openr2="yes"])
AM_CONDITIONAL([OPENR2],[test "${have_openr2}" = "yes"])

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,732 @@
/*
* Copyright (c) 2009, Konrad Hammel <konrad@sangoma.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "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,
* 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
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* INCLUDE ********************************************************************/
#include "ftmod_sangoma_ss7_main.h"
/******************************************************************************/
/* DEFINES ********************************************************************/
/******************************************************************************/
/* GLOBALS ********************************************************************/
/******************************************************************************/
/* PROTOTYPES *****************************************************************/
void handle_sng_log(uint8_t level, char *fmt,...);
void handle_sng_alarm(sng_alrm_t t_alarm);
static void handle_entsi_alarm(sng_alrm_t t_alarm);
int ft_to_sngss7_cfg(void);
int ft_to_sngss7_activate_all(void);
static int ftmod_ss7_general_configuration(void);
static int ftmod_ss7_configure_mtp1_link(int id);
static int ftmod_ss7_configure_mtp2_link(int id);
static int ftmod_ss7_configure_mtp3_link(int id);
static int ftmod_ss7_configure_mtp3_linkset(int id);
static int ftmod_ss7_configure_mtp3_route(int id);
static int ftmod_ss7_configure_mtp3_isup(int id);
static int ftmod_ss7_configure_isup_mtp3(int id);
static int ftmod_ss7_configure_isup_interface(int id);
static int ftmod_ss7_configure_isup_circuit(int id);
static int ftmod_ss7_configure_isup_cc(int id);
static int ftmod_ss7_configure_cc_isup(int id);
/******************************************************************************/
/* FUNCTIONS ******************************************************************/
/* LOGGIGING ******************************************************************/
void handle_sng_log(uint8_t level, char *fmt,...)
{
char *data;
int ret;
va_list ap;
va_start(ap, fmt);
ret = vasprintf(&data, fmt, ap);
if (ret == -1) {
return;
}
switch (level) {
/**************************************************************************/
case SNG_LOGLEVEL_DEBUG:
ftdm_log(FTDM_LOG_DEBUG, "sng_ss7->%s", data);
break;
/**************************************************************************/
case SNG_LOGLEVEL_WARN:
ftdm_log(FTDM_LOG_INFO, "sng_ss7->%s", data);
break;
/**************************************************************************/
case SNG_LOGLEVEL_INFO:
ftdm_log(FTDM_LOG_INFO, "sng_ss7->%s", data);
break;
/**************************************************************************/
case SNG_LOGLEVEL_STATS:
ftdm_log(FTDM_LOG_INFO, "sng_ss7->%s", data);
break;
/**************************************************************************/
case SNG_LOGLEVEL_ERROR:
ftdm_log(FTDM_LOG_ERROR, "sng_ss7->%s", data);
break;
/**************************************************************************/
case SNG_LOGLEVEL_CRIT:
printf("%s",data);
/*ftdm_log(FTDM_LOG_CRIT, "sng_ss7->%s", data);*/
break;
/**************************************************************************/
default:
ftdm_log(FTDM_LOG_INFO, "sng_ss7->%s", data);
break;
/**************************************************************************/
}
return;
}
/******************************************************************************/
void handle_sng_alarm(sng_alrm_t t_alarm)
{
switch (t_alarm.entity) {
/**************************************************************************/
case (ENTL1):
ftdm_log(FTDM_LOG_WARNING,"[SNG-MTP1] %s : %s : %s \n",
DECODE_LL1_EVENT(t_alarm.event),
DECODE_LL1_CAUSE(t_alarm.cause),
DECODE_LL1_PARM(t_alarm.eventParm[0]));
break;
/**************************************************************************/
case (ENTSD):
ftdm_log(FTDM_LOG_WARNING,"[SNG-MTP2] %s : %s \n",
DECODE_LSD_EVENT(t_alarm.event),
DECODE_LSD_CAUSE(t_alarm.cause));
break;
/**************************************************************************/
case (ENTSN):
ftdm_log(FTDM_LOG_WARNING,"[SNG-MTP3] %s on %d: %s \n",
DECODE_LSN_EVENT(t_alarm.event),
t_alarm.id,
DECODE_LSN_CAUSE(t_alarm.cause));
break;
/**************************************************************************/
case (ENTSI):
handle_entsi_alarm(t_alarm);
break;
/**************************************************************************/
case (ENTCC):
ftdm_log(FTDM_LOG_DEBUG,"[SNG-CC] %s : %s \n",
DECODE_LCC_EVENT(t_alarm.event),
DECODE_LCC_CAUSE(t_alarm.cause));
break;
/**************************************************************************/
default:
ftdm_log(FTDM_LOG_WARNING,"Received alarm from unknown entity");
break;
/**************************************************************************/
} /* switch (t_alarm.entity) */
return;
}
/******************************************************************************/
static void handle_entsi_alarm(sng_alrm_t alarm)
{
switch (alarm.event) {
/**************************************************************************/
case (LCM_EVENT_TIMEOUT):
/* this event always has the circuit value embedded */
SS7_WARN("[ISUP] Timer %d expired on CIC %d\n",
(alarm.eventParm[1] > 0 ) ? alarm.eventParm[1] : alarm.eventParm[8],
g_ftdm_sngss7_data.cfg.isupCircuit[alarm.eventParm[0]].cic);
break;
/**************************************************************************/
case (LSI_EVENT_REMOTE):
SS7_WARN("[ISUP] %s received on CIC %d\n",
DECODE_LSI_CAUSE(alarm.cause),
g_ftdm_sngss7_data.cfg.isupCircuit[alarm.eventParm[0]].cic);
break;
/**************************************************************************/
case (LSI_EVENT_LOCAL):
SS7_WARN("[ISUP] %s transmitted on CIC %d\n",
DECODE_LSI_CAUSE(alarm.cause),
g_ftdm_sngss7_data.cfg.isupCircuit[alarm.eventParm[0]].cic);
break;
/**************************************************************************/
case (LSI_EVENT_MTP):
SS7_WARN("[ISUP] Received %s on %d\n",
DECODE_LSI_CAUSE(alarm.cause),
g_ftdm_sngss7_data.cfg.mtp3_isup[alarm.eventParm[2]].id);
break;
/**************************************************************************/
case (LCM_EVENT_UI_INV_EVT):
switch (alarm.cause) {
/**********************************************************************/
case (LSI_CAUSE_INV_CIRCUIT):
SS7_WARN("[ISUP] Invalid circuit = %d (CIC = %d)\n",
alarm.eventParm[0],
g_ftdm_sngss7_data.cfg.isupCircuit[alarm.eventParm[0]].cic);
break;
/**********************************************************************/
}
break;
/**************************************************************************/
case (LCM_EVENT_LI_INV_EVT):
switch (alarm.cause) {
/**********************************************************************/
case (LCM_CAUSE_INV_SAP):
SS7_WARN("[ISUP] Invalid spId = %d\n",
alarm.eventParm[3]);
break;
/**********************************************************************/
}
break;
/**************************************************************************/
default:
SS7_WARN("[ISUP] %s : %s \n", DECODE_LSI_EVENT(alarm.event), DECODE_LSI_CAUSE(alarm.cause));
break;
/**************************************************************************/
} /* switch (alarm.event) */
return;
}
/* ACTIVATION *****************************************************************/
int ft_to_sngss7_activate_all(void)
{
sng_isup_cc_t *cc_isup = NULL;
sng_mtp3_isup_t *isup_mtp3 = NULL;
sng_mtp3LinkSet_t *mtp3_linkset = NULL;
int x;
/* CC to ISUP *************************************************************/
x = 1;
cc_isup = &g_ftdm_sngss7_data.cfg.isup_cc[x];
while (cc_isup->id != 0) {
if (sngss7_test_flag(cc_isup, SNGSS7_FLAG_ACTIVE)) {
SS7_DEBUG("CC-ISUP interface already active = %d\n", cc_isup->id);
} else {
if (sng_activate_cc_isup_inf(cc_isup->ccId)) {
SS7_ERROR("Failed to activate CC-ISUP = %d\n",cc_isup->id);
return FTDM_FAIL;
} else {
SS7_INFO("Started CC-ISUP interface = %d\n", cc_isup->id);
sngss7_set_flag(cc_isup, SNGSS7_FLAG_ACTIVE);
}
} /* if (sngss7_test_flag(cc_isup, SNGSS7_FLAG_ACTIVE) */
x++;
cc_isup = &g_ftdm_sngss7_data.cfg.isup_cc[x];
} /* while (cc_isup->id != 0) */
/* ISUP - MTP3 ************************************************************/
x = 1;
isup_mtp3 = &g_ftdm_sngss7_data.cfg.mtp3_isup[x];
while (isup_mtp3->id != 0) {
if (sngss7_test_flag(isup_mtp3, SNGSS7_FLAG_ACTIVE)) {
SS7_DEBUG("ISUP-MTP3 interface already active = %d\n", isup_mtp3->id);
} else {
if (sng_activate_isup_mtp3_inf(isup_mtp3->id)) {
SS7_ERROR("Failed to activate ISUP-MTP3 = %d\n",isup_mtp3->id);
return FTDM_FAIL;
} else {
SS7_INFO("Started ISUP-MTP3interface = %d\n", isup_mtp3->id);
sngss7_set_flag(isup_mtp3, SNGSS7_FLAG_ACTIVE);
}
} /* if (sngss7_test_flag(isup_mtp3, SNGSS7_FLAG_ACTIVE) */
x++;
isup_mtp3 = &g_ftdm_sngss7_data.cfg.mtp3_isup[x];
} /* while (isup_mtp3->id != 0) */
/* MTP3 Linkset (MTP3 - MTP2 - MTP1) **************************************/
x = 1;
mtp3_linkset = &g_ftdm_sngss7_data.cfg.mtp3LinkSet[x];
while (mtp3_linkset->id != 0) {
if (sngss7_test_flag(mtp3_linkset, SNGSS7_FLAG_ACTIVE)) {
SS7_DEBUG("MTP3 Linkset already active = %s\n", mtp3_linkset->name);
} else {
if (sng_activate_mtp3_linkset(mtp3_linkset->id)) {
SS7_ERROR("Failed to activate MTP3 Linkset = %s\n",mtp3_linkset->name);
return FTDM_FAIL;
} else {
SS7_INFO("Started MTP3 Linkset = %s\n", mtp3_linkset->name);
sngss7_set_flag(mtp3_linkset, SNGSS7_FLAG_ACTIVE);
}
} /* if (sngss7_test_flag(mtp3_linkset, SNGSS7_FLAG_ACTIVE) */
x++;
mtp3_linkset = &g_ftdm_sngss7_data.cfg.mtp3LinkSet[x];
} /* while (mtp3_linkset->id != 0) */
return FTDM_SUCCESS;
}
/* CONFIGURATION **************************************************************/
int ft_to_sngss7_cfg(void)
{
sng_mtp1Link_t *mtp1_link = NULL;
sng_mtp2Link_t *mtp2_link = NULL;
sng_mtp3Link_t *mtp3_link = NULL;
sng_mtp3LinkSet_t *mtp3_linkset = NULL;
sng_mtp3Route_t *mtp3_route = NULL;
sng_mtp3_isup_t *mtp3_isup = NULL;
sng_mtp3_isup_t *isup_mtp3 = NULL;
sng_isupInterface_t *isup_interface = NULL;
sng_isupCircuit_t *isup_circuit = NULL;
sng_isup_cc_t *isup_cc = NULL;
sng_isup_cc_t *cc_isup = NULL;
int x;
SS7_DEBUG("Starting LibSngSS7 configuration...\n");
if (g_ftdm_sngss7_data.gen_config_done == 0) {
/* perform general configuration */
if(ftmod_ss7_general_configuration()) {
SS7_ERROR("Failed to run general configuration!\n");
return FTDM_FAIL;
} else {
SS7_INFO("General Configuration was successful\n");
g_ftdm_sngss7_data.gen_config_done = 1;
}
} else {
SS7_DEBUG("General configuration already done.\n");
}
/* MTP1 *******************************************************************/
x=1;
mtp1_link = &g_ftdm_sngss7_data.cfg.mtp1Link[x];
while (mtp1_link->id != 0) {
if (sngss7_test_flag(mtp1_link, SNGSS7_FLAG_CONFIGURED)) {
SS7_DEBUG("MTP1 Link already configured = %s\n",mtp1_link->name);
} else {
if (ftmod_ss7_configure_mtp1_link(x)) {
SS7_ERROR("Failed to configure MTP1 link = %s\n!", mtp1_link->name);
return FTDM_FAIL;
} else {
SS7_INFO("Successfully configured MTP1 link = %s\n", mtp1_link->name);
sngss7_set_flag(mtp1_link, SNGSS7_FLAG_CONFIGURED);
}
}
/* next link */
x++;
mtp1_link = &g_ftdm_sngss7_data.cfg.mtp1Link[x];
} /* while (g_ftdm_sngss7_data.cfg.mtp1Link[x]->id != 0) */
/* MTP2 *******************************************************************/
x=1;
mtp2_link = &g_ftdm_sngss7_data.cfg.mtp2Link[x];
while (mtp2_link->id != 0) {
if (sngss7_test_flag(mtp2_link, SNGSS7_FLAG_CONFIGURED)) {
SS7_DEBUG("MTP2 Link already configured = %s\n",mtp2_link->name);
} else {
if (ftmod_ss7_configure_mtp2_link(x)) {
SS7_ERROR("Failed to configure MTP2 link = %s\n!", mtp2_link->name);
return FTDM_FAIL;
} else {
SS7_INFO("Successfully configured MTP2 link = %s\n", mtp2_link->name);
sngss7_set_flag(mtp2_link, SNGSS7_FLAG_CONFIGURED);
}
}
/* next link */
x++;
mtp2_link = &g_ftdm_sngss7_data.cfg.mtp2Link[x];
} /* while (g_ftdm_sngss7_data.cfg.mtp2Link[x]->id != 0) */
/* MTP3 *******************************************************************/
x=1;
mtp3_link = &g_ftdm_sngss7_data.cfg.mtp3Link[x];
while (mtp3_link->id != 0) {
if (sngss7_test_flag(mtp3_link, SNGSS7_FLAG_CONFIGURED)) {
SS7_DEBUG("MTP3 Link already configured = %s\n", mtp3_link->name);
} else {
if (ftmod_ss7_configure_mtp3_link(x)) {
SS7_ERROR("Failed to configure MTP3 link = %s\n!", mtp3_link->name);
return FTDM_FAIL;
} else {
SS7_INFO("Successfully configured MTP3 link = %s\n", mtp3_link->name);
sngss7_set_flag(mtp3_link, SNGSS7_FLAG_CONFIGURED);
}
}
/* next link */
x++;
mtp3_link = &g_ftdm_sngss7_data.cfg.mtp3Link[x];
} /* while (g_ftdm_sngss7_data.cfg.mtp3Link[x]->id != 0) */
x=1;
mtp3_linkset = &g_ftdm_sngss7_data.cfg.mtp3LinkSet[x];
while (mtp3_linkset->id != 0) {
if (sngss7_test_flag(mtp3_linkset, SNGSS7_FLAG_CONFIGURED)) {
SS7_DEBUG("MTP3 LinkSet already configured = %s\n", mtp3_linkset->name);
} else {
if (ftmod_ss7_configure_mtp3_linkset(x)) {
SS7_ERROR("Failed to configure MTP3 link = %s\n!", mtp3_linkset->name);
return FTDM_FAIL;
} else {
SS7_INFO("Successfully configured MTP3 link = %s\n", mtp3_linkset->name);
sngss7_set_flag(mtp3_linkset, SNGSS7_FLAG_CONFIGURED);
}
}
/* next link */
x++;
mtp3_linkset = &g_ftdm_sngss7_data.cfg.mtp3LinkSet[x];
} /* while (g_ftdm_sngss7_data.cfg.mtp1Link[x]->id != 0) */
x=1;
mtp3_route = &g_ftdm_sngss7_data.cfg.mtp3Route[x];
while (mtp3_route->id != 0) {
if (sngss7_test_flag(mtp3_route, SNGSS7_FLAG_CONFIGURED)) {
SS7_DEBUG("MTP3 Route already configured = %s\n", mtp3_route->name);
} else {
if (ftmod_ss7_configure_mtp3_route(x)) {
SS7_ERROR("Failed to configure MTP3 route = %s\n!", mtp3_route->name);
return FTDM_FAIL;
} else {
SS7_INFO("Successfully configured MTP3 route = %s\n", mtp3_route->name);
sngss7_set_flag(mtp3_route, SNGSS7_FLAG_CONFIGURED);
}
}
/* next link */
x++;
mtp3_route = &g_ftdm_sngss7_data.cfg.mtp3Route[x];
} /* while (g_ftdm_sngss7_data.cfg.mtp3Route[x]->id != 0) */
mtp3_route = &g_ftdm_sngss7_data.cfg.mtp3Route[0];
if (sngss7_test_flag(mtp3_route, SNGSS7_FLAG_CONFIGURED)) {
SS7_DEBUG("MTP3 Self Route already configured\n");
} else {
if (ftmod_ss7_configure_mtp3_route(0)) {
SS7_ERROR("Failed to configure MTP3 Route = SelfRoute\n!");
return FTDM_FAIL;
} else {
SS7_INFO("Successfully configured MTP3 Route = SelfRoute\n");
sngss7_set_flag(mtp3_route, SNGSS7_FLAG_CONFIGURED);
}
}
x=1;
mtp3_isup = &g_ftdm_sngss7_data.cfg.mtp3_isup[x];
while (mtp3_isup->id != 0) {
if (sngss7_test_flag(mtp3_isup, SNGSS7_FLAG_CONFIGURED)) {
SS7_DEBUG("MTP3-ISUP interface already configured = %d\n", mtp3_isup->id);
} else {
if (ftmod_ss7_configure_mtp3_isup(x)) {
SS7_ERROR("Failed to configure MTP3-ISUP interface = %d\n!", mtp3_isup->id);
return FTDM_FAIL;
} else {
SS7_INFO("Successfully configured MTP3-ISUP interface = %d\n", mtp3_isup->id);
}
}
/* next link */
x++;
mtp3_isup = &g_ftdm_sngss7_data.cfg.mtp3_isup[x];
} /* while (g_ftdm_sngss7_data.cfg.mtp3_isup[x]->id != 0) */
/* ISUP *******************************************************************/
x=1;
isup_mtp3 = &g_ftdm_sngss7_data.cfg.mtp3_isup[x];
while (isup_mtp3->id != 0) {
if (sngss7_test_flag(isup_mtp3, SNGSS7_FLAG_CONFIGURED)) {
SS7_DEBUG("ISUP-MTP3 interface already configured = %d\n", isup_mtp3->id);
} else {
if (ftmod_ss7_configure_isup_mtp3(x)) {
SS7_ERROR("Failed to configure ISUP-MTP3 interface = %d\n!", isup_mtp3->id);
return FTDM_FAIL;
} else {
SS7_INFO("Successfully configured ISUP-MTP3 interface = %d\n", isup_mtp3->id);
sngss7_set_flag(isup_mtp3, SNGSS7_FLAG_CONFIGURED);
}
}
/* next link */
x++;
isup_mtp3 = &g_ftdm_sngss7_data.cfg.mtp3_isup[x];
} /* while (g_ftdm_sngss7_data.cfg.isup_mtp3[x]->id != 0) */
x=1;
isup_cc = &g_ftdm_sngss7_data.cfg.isup_cc[x];
while (isup_cc->id != 0) {
if (sngss7_test_flag(isup_cc, SNGSS7_FLAG_CONFIGURED)) {
SS7_DEBUG("ISUP-CC interface already configured = %d\n", isup_cc->id);
} else {
if (ftmod_ss7_configure_isup_cc(x)) {
SS7_ERROR("Failed to configure ISUP-CC interface = %d\n!", isup_cc->id);
return FTDM_FAIL;
} else {
SS7_INFO("Successfully configured ISUP-CC interface = %d\n", isup_cc->id);
}
}
/* next link */
x++;
isup_cc = &g_ftdm_sngss7_data.cfg.isup_cc[x];
} /* while (g_ftdm_sngss7_data.cfg.isup_cc[x]->id != 0) */
x=1;
isup_interface = &g_ftdm_sngss7_data.cfg.isupInterface[x];
while (isup_interface->id != 0) {
if (sngss7_test_flag(isup_interface, SNGSS7_FLAG_CONFIGURED)) {
SS7_DEBUG("ISUP interface already configured = %s\n", isup_interface->name);
} else {
if (ftmod_ss7_configure_isup_interface(x)) {
SS7_ERROR("Failed to configure ISUP interface = %s\n!", isup_interface->name);
return FTDM_FAIL;
} else {
SS7_INFO("Successfully configured ISUP interface = %s\n", isup_interface->name);
sngss7_set_flag(isup_interface, SNGSS7_FLAG_CONFIGURED);
}
}
/* next link */
x++;
isup_interface = &g_ftdm_sngss7_data.cfg.isupInterface[x];
} /* while (g_ftdm_sngss7_data.cfg.isup_interface[x]->id != 0) */
x=1;
isup_circuit = &g_ftdm_sngss7_data.cfg.isupCircuit[x];
while (isup_circuit->id != 0) {
if (isup_circuit->cic != 0) {
if (sngss7_test_flag(isup_circuit, SNGSS7_FLAG_CONFIGURED)) {
SS7_DEBUG("ISUP Circuit already configured = %d\n", isup_circuit->id);
} else {
if (ftmod_ss7_configure_isup_circuit(x)) {
SS7_ERROR("Failed to configure ISUP circuit = %d\n!", isup_circuit->id);
return FTDM_FAIL;
} else {
SS7_INFO("Successfully configured ISUP circuit = %d\n", isup_circuit->id);
sngss7_set_flag(isup_circuit, SNGSS7_FLAG_CONFIGURED);
}
}
}
/* next link */
x++;
isup_circuit = &g_ftdm_sngss7_data.cfg.isupCircuit[x];
} /* while (g_ftdm_sngss7_data.cfg.isup_circuit[x]->id != 0) */
/* CC *********************************************************************/
x=1;
cc_isup = &g_ftdm_sngss7_data.cfg.isup_cc[x];
while (cc_isup->id != 0) {
if (sngss7_test_flag(cc_isup, SNGSS7_FLAG_CONFIGURED)) {
SS7_DEBUG("CC-ISUP interface already configured = %d\n", cc_isup->id);
} else {
if (ftmod_ss7_configure_cc_isup(x)) {
SS7_ERROR("Failed to configure CC-ISUP interface = %d\n!", cc_isup->id);
return FTDM_FAIL;
} else {
SS7_INFO("Successfully configured CC-ISUP interface = %d\n", cc_isup->id);
sngss7_set_flag(cc_isup, SNGSS7_FLAG_CONFIGURED);
}
}
/* next link */
x++;
cc_isup = &g_ftdm_sngss7_data.cfg.isup_cc[x];
} /* while (g_ftdm_sngss7_data.cfg.cc_isup[x]->id != 0) */
SS7_DEBUG("Finished LibSngSS7 configuration...\n");
return FTDM_SUCCESS;
}
/******************************************************************************/
static int ftmod_ss7_general_configuration(void)
{
if(sng_cfg_mtp1_gen(&g_ftdm_sngss7_data.cfg)) {
SS7_ERROR("General configuration for MTP1 failed!\n");
return FTDM_FAIL;
} else {
SS7_INFO("General configuration for MTP1 was successful\n");
}
if(sng_cfg_mtp2_gen(&g_ftdm_sngss7_data.cfg)) {
SS7_ERROR("General configuration for MTP2 failed!\n");
return FTDM_FAIL;
} else {
SS7_INFO("General configuration for MTP2 was successful\n");
}
if(sng_cfg_mtp3_gen(&g_ftdm_sngss7_data.cfg)) {
SS7_ERROR("General configuration for MTP3 failed!\n");
return FTDM_FAIL;
} else {
SS7_INFO("General configuration for MTP3 was successful\n");
}
if(sng_cfg_isup_gen(&g_ftdm_sngss7_data.cfg)) {
SS7_ERROR("General configuration for ISUP failed!\n");
return FTDM_FAIL;
} else {
SS7_INFO("General configuration for ISUP was successful\n");
}
if(sng_cfg_cc_gen(&g_ftdm_sngss7_data.cfg)) {
SS7_ERROR("General configuration for Call-Control failed!\n");
return FTDM_FAIL;
} else {
SS7_INFO("General configuration for Call-Control was successful\n");
}
return FTDM_SUCCESS;
}
/******************************************************************************/
static int ftmod_ss7_configure_mtp1_link(int id)
{
if(sng_cfg_mtp1_link(&g_ftdm_sngss7_data.cfg, id)){
return FTDM_FAIL;
} else {
return FTDM_SUCCESS;
}
}
/******************************************************************************/
static int ftmod_ss7_configure_mtp2_link(int id)
{
if(sng_cfg_mtp2_link(&g_ftdm_sngss7_data.cfg, id)){
return FTDM_FAIL;
} else {
return FTDM_SUCCESS;
}
}
/******************************************************************************/
static int ftmod_ss7_configure_mtp3_link(int id)
{
if(sng_cfg_mtp3_link(&g_ftdm_sngss7_data.cfg, id)){
return FTDM_FAIL;
} else {
return FTDM_SUCCESS;
}
}
/******************************************************************************/
static int ftmod_ss7_configure_mtp3_linkset(int id)
{
if(sng_cfg_mtp3_linkset(&g_ftdm_sngss7_data.cfg, id)){
return FTDM_FAIL;
} else {
return FTDM_SUCCESS;
}
}
/******************************************************************************/
static int ftmod_ss7_configure_mtp3_route(int id)
{
if(sng_cfg_mtp3_route(&g_ftdm_sngss7_data.cfg, id)){
return FTDM_FAIL;
} else {
return FTDM_SUCCESS;
}
}
/******************************************************************************/
static int ftmod_ss7_configure_mtp3_isup(int id)
{
if(sng_cfg_mtp3_isup_interface(&g_ftdm_sngss7_data.cfg, id)){
return FTDM_FAIL;
} else {
return FTDM_SUCCESS;
}
}
/******************************************************************************/
static int ftmod_ss7_configure_isup_mtp3(int id)
{
if(sng_cfg_isup_mtp3_interface(&g_ftdm_sngss7_data.cfg, id)){
return FTDM_FAIL;
} else {
return FTDM_SUCCESS;
}
}
/******************************************************************************/
static int ftmod_ss7_configure_isup_interface(int id)
{
if(sng_cfg_isup_interface(&g_ftdm_sngss7_data.cfg, id)){
return FTDM_FAIL;
} else {
return FTDM_SUCCESS;
}
}
/******************************************************************************/
static int ftmod_ss7_configure_isup_circuit(int id)
{
if(sng_cfg_isup_circuit(&g_ftdm_sngss7_data.cfg, id)){
return FTDM_FAIL;
} else {
return FTDM_SUCCESS;
}
}
/******************************************************************************/
static int ftmod_ss7_configure_isup_cc(int id)
{
if(sng_cfg_isup_cc_interface(&g_ftdm_sngss7_data.cfg, id)){
return FTDM_FAIL;
} else {
return FTDM_SUCCESS;
}
}
/******************************************************************************/
static int ftmod_ss7_configure_cc_isup(int id)
{
if(sng_cfg_cc_isup_interface(&g_ftdm_sngss7_data.cfg, id)){
return FTDM_FAIL;
} else {
return FTDM_SUCCESS;
}
}
/******************************************************************************/
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4:
*/
/******************************************************************************/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,307 @@
/*
* Copyright (c) 2009, Konrad Hammel <konrad@sangoma.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "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,
* 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
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/******************************************************************************/
#ifndef __FTMOD_SNG_SS7_H__
#define __FTMOD_SNG_SS7_H__
/******************************************************************************/
/* INCLUDE ********************************************************************/
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <stdint.h>
#include <unistd.h>
#include <ctype.h>
#include "private/ftdm_core.h"
#include "sng_sit.h"
#include "sng_ss7.h"
#include "sng_ss7_error.h"
/******************************************************************************/
/* DEFINES ********************************************************************/
#define MAX_CIC_LENGTH 5
#define MAX_CIC_MAP_LENGTH 256
#define MAX_MTP_LINKS MAX_SN_LINKSETS
#if 0
#define SS7_HARDCODED
#endif
#define SNG_BASE 1
typedef enum {
SNG_IAM = 1,
SNG_ACM,
SNG_CPG,
SNG_ANM,
SNG_REL,
SNG_RLC
}sng_msg_type_t;
typedef struct ftdm_sngss7_data {
sng_config_t cfg;
int gen_config_done;
int min_digits;
int function_trace;
int function_trace_level;
int message_trace;
int message_trace_level;
fio_signal_cb_t sig_cb;
}ftdm_sngss7_data_t;
typedef struct sngss7_timer_data {
ftdm_timer_t *heartbeat_timer;
int beat;
int counter;
ftdm_sched_callback_t callback;
ftdm_sched_t *sched;
void *sngss7_info;
}sngss7_timer_data_t;
typedef struct sngss7_glare_data {
uint32_t suInstId;
uint32_t spInstId;
uint32_t circuit;
SiConEvnt iam;
}sngss7_glare_data_t;
typedef struct sngss7_chan_data {
ftdm_channel_t *ftdmchan;
sng_isupCircuit_t *circuit;
uint32_t suInstId;
uint32_t spInstId;
uint32_t spId;
uint8_t globalFlg;
uint32_t flags;
sngss7_glare_data_t glare;
sngss7_timer_data_t t35;
}sngss7_chan_data_t;
typedef enum {
FLAG_RESET_RX = (1 << 0),
FLAG_RESET_TX = (1 << 1),
FLAG_REMOTE_REL = (1 << 2),
FLAG_LOCAL_REL = (1 << 3),
FLAG_GLARE = (1 << 4),
FLAG_INFID_RESUME = (1 << 17),
FLAG_INFID_PAUSED = (1 << 18),
FLAG_CKT_MN_BLOCK_RX = (1 << 19),
FLAG_CKT_MN_BLOCK_TX = (1 << 20),
FLAG_CKT_MN_UNBLK_RX = (1 << 21),
FLAG_CKT_MN_UNBLK_TX = (1 << 22),
FLAG_GRP_HW_BLOCK_RX = (1 << 23),
FLAG_GRP_HW_BLOCK_TX = (1 << 24),
FLAG_GRP_MN_BLOCK_RX = (1 << 25),
FLAG_GRP_MN_BLOCK_TX = (1 << 28),
FLAG_GRP_HW_UNBLK_RX = (1 << 27),
FLAG_GRP_HW_UNBLK_TX = (1 << 28),
FLAG_GRP_MN_UNBLK_RX = (1 << 29),
FLAG_GRP_MN_UNBLK_TX = (1 << 30)
} flag_t;
/******************************************************************************/
/* GLOBALS ********************************************************************/
extern ftdm_sngss7_data_t g_ftdm_sngss7_data;
extern uint32_t sngss7_id;
extern ftdm_sched_t *sngss7_sched;
/******************************************************************************/
/* PROTOTYPES *****************************************************************/
extern void handle_sng_log(uint8_t level, char *fmt,...);
extern void handle_sng_alarm(sng_alrm_t t_alarm);
extern int ft_to_sngss7_cfg(void);
extern int ft_to_sngss7_activate_all(void);
extern void ft_to_sngss7_iam(ftdm_channel_t *ftdmchan);
extern void ft_to_sngss7_acm(ftdm_channel_t *ftdmchan);
extern void ft_to_sngss7_anm(ftdm_channel_t *ftdmchan);
extern void ft_to_sngss7_rel(ftdm_channel_t *ftdmchan);
extern void ft_to_sngss7_rlc(ftdm_channel_t *ftdmchan);
extern void ft_to_sngss7_rsc(ftdm_channel_t *ftdmchan);
extern void ft_to_sngss7_rsca(ftdm_channel_t *ftdmchan);
extern void ft_to_sngss7_blo(ftdm_channel_t *ftdmchan);
extern void ft_to_sngss7_bla(ftdm_channel_t *ftdmchan);
extern void ft_to_sngss7_ubl(ftdm_channel_t *ftdmchan);
extern void ft_to_sngss7_uba(ftdm_channel_t *ftdmchan);
extern void ft_to_sngss7_lpa(ftdm_channel_t *ftdmchan);
extern void sngss7_sta_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
extern void sngss7_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiConEvnt *siConEvnt);
extern void sngss7_con_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiConEvnt *siConEvnt);
extern void sngss7_con_sta(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiCnStEvnt *siCnStEvnt, uint8_t evntType);
extern void sngss7_rel_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiRelEvnt *siRelEvnt);
extern void sngss7_rel_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiRelEvnt *siRelEvnt);
extern void sngss7_dat_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiInfoEvnt *siInfoEvnt);
extern void sngss7_fac_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t evntType, SiFacEvnt *siFacEvnt);
extern void sngss7_fac_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t evntType, SiFacEvnt *siFacEvnt);
extern void sngss7_sta_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
extern void sngss7_umsg_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit);
extern uint8_t copy_cgPtyNum_from_sngss7(ftdm_caller_data_t *ftdm, SiCgPtyNum *cgPtyNum);
extern uint8_t copy_cgPtyNum_to_sngss7(ftdm_caller_data_t *ftdm, SiCgPtyNum *cgPtyNum);
extern uint8_t copy_cdPtyNum_from_sngss7(ftdm_caller_data_t *ftdm, SiCdPtyNum *cdPtyNum);
extern uint8_t copy_cdPtyNum_to_sngss7(ftdm_caller_data_t *ftdm, SiCdPtyNum *cdPtyNum);
extern uint8_t copy_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven);
extern int check_for_state_change(ftdm_channel_t *ftdmchan);
extern ftdm_status_t extract_chan_data(uint32_t circuit, sngss7_chan_data_t **sngss7_info, ftdm_channel_t **ftdmchan);
extern unsigned long get_unique_id(void);
extern int ftmod_ss7_parse_xml(ftdm_conf_parameter_t *ftdm_parameters, ftdm_span_t *span);
extern void handle_isup_t35(void *userdata);
extern ftdm_status_t ftdm_sngss7_handle_cli_cmd(ftdm_stream_handle_t *stream, const char *data);
/******************************************************************************/
/* MACROS *********************************************************************/
#define SS7_DEBUG(a,...) ftdm_log(FTDM_LOG_DEBUG,a,##__VA_ARGS__ );
#define SS7_INFO(a,...) ftdm_log(FTDM_LOG_INFO,a,##__VA_ARGS__ );
#define SS7_WARN(a,...) ftdm_log(FTDM_LOG_WARNING,a,##__VA_ARGS__ );
#define SS7_ERROR(a,...) ftdm_log(FTDM_LOG_ERROR,a,##__VA_ARGS__ );
#define SS7_CRITICAL(a,...) ftdm_log(FTDM_LOG_CRIT,a,##__VA_ARGS__ );
#ifdef KONRAD_DEVEL
#define SS7_DEVEL_DEBUG(a,...) ftdm_log(FTDM_LOG_DEBUG,a,##__VA_ARGS__ );
#else
#define SS7_DEVEL_DEBUG(a,...)
#endif
#define SS7_FUNC_TRACE_ENTER(a) if (g_ftdm_sngss7_data.function_trace) { \
switch (g_ftdm_sngss7_data.function_trace_level) { \
case 0: \
ftdm_log(FTDM_LOG_EMERG,"Entering %s\n", a); \
break; \
case 1: \
ftdm_log(FTDM_LOG_ALERT,"Entering %s\n", a); \
break; \
case 2: \
ftdm_log(FTDM_LOG_CRIT,"Entering %s\n", a); \
break; \
case 3: \
ftdm_log(FTDM_LOG_ERROR,"Entering %s\n", a); \
break; \
case 4: \
ftdm_log(FTDM_LOG_WARNING,"Entering %s\n", a); \
break; \
case 5: \
ftdm_log(FTDM_LOG_NOTICE,"Entering %s\n", a); \
break; \
case 6: \
ftdm_log(FTDM_LOG_INFO,"Entering %s\n", a); \
break; \
case 7: \
ftdm_log(FTDM_LOG_DEBUG,"Entering %s\n", a); \
break; \
default: \
ftdm_log(FTDM_LOG_INFO,"Entering %s\n", a); \
break; \
} /* switch (g_ftdm_sngss7_data.function_trace_level) */ \
} /* if(g_ftdm_sngss7_data.function_trace) */
#define SS7_FUNC_TRACE_EXIT(a) if (g_ftdm_sngss7_data.function_trace) { \
switch (g_ftdm_sngss7_data.function_trace_level) { \
case 0: \
ftdm_log(FTDM_LOG_EMERG,"Exitting %s\n", a); \
break; \
case 1: \
ftdm_log(FTDM_LOG_ALERT,"Exitting %s\n", a); \
break; \
case 2: \
ftdm_log(FTDM_LOG_CRIT,"Exitting %s\n", a); \
break; \
case 3: \
ftdm_log(FTDM_LOG_ERROR,"Exitting %s\n", a); \
break; \
case 4: \
ftdm_log(FTDM_LOG_WARNING,"Exitting %s\n", a); \
break; \
case 5: \
ftdm_log(FTDM_LOG_NOTICE,"Exitting %s\n", a); \
break; \
case 6: \
ftdm_log(FTDM_LOG_INFO,"Exitting %s\n", a); \
break; \
case 7: \
ftdm_log(FTDM_LOG_DEBUG,"Exitting %s\n", a); \
break; \
default: \
ftdm_log(FTDM_LOG_INFO,"Exitting %s\n", a); \
break; \
} /* switch (g_ftdm_sngss7_data.function_trace_level) */ \
} /* if(g_ftdm_sngss7_data.function_trace) */
#define SS7_MSG_TRACE(a,...) if (g_ftdm_sngss7_data.message_trace) { \
switch (g_ftdm_sngss7_data.message_trace_level) { \
case 0: \
ftdm_log(FTDM_LOG_EMERG,a,##__VA_ARGS__ ); \
break; \
case 1: \
ftdm_log(FTDM_LOG_ALERT,a,##__VA_ARGS__ ); \
break; \
case 2: \
ftdm_log(FTDM_LOG_CRIT,a,##__VA_ARGS__ ); \
break; \
case 3: \
ftdm_log(FTDM_LOG_ERROR,a,##__VA_ARGS__ ); \
break; \
case 4: \
ftdm_log(FTDM_LOG_WARNING,a,##__VA_ARGS__ ); \
break; \
case 5: \
ftdm_log(FTDM_LOG_NOTICE,a,##__VA_ARGS__ ); \
break; \
case 6: \
ftdm_log(FTDM_LOG_INFO,a,##__VA_ARGS__ ); \
break; \
case 7: \
ftdm_log(FTDM_LOG_DEBUG,a,##__VA_ARGS__ ); \
break; \
default: \
ftdm_log(FTDM_LOG_INFO,a,##__VA_ARGS__ ); \
break; \
} /* switch (g_ftdm_sngss7_data.message_trace_level) */ \
} /* if(g_ftdm_sngss7_data.message_trace) */
#define sngss7_test_flag(obj, flag) ((obj)->flags & flag)
#define sngss7_clear_flag(obj, flag) ((obj)->flags &= ~(flag))
#define sngss7_set_flag(obj, flag) ((obj)->flags |= (flag))
/******************************************************************************/
/******************************************************************************/
#endif /* __FTMOD_SNG_SS7_H__ */
/******************************************************************************/

View File

@ -0,0 +1,419 @@
/*
* Copyright (c) 2009, Konrad Hammel <konrad@sangoma.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "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,
* 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
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* INCLUDE ********************************************************************/
#include "ftmod_sangoma_ss7_main.h"
/******************************************************************************/
/* DEFINES ********************************************************************/
/******************************************************************************/
/* GLOBALS ********************************************************************/
/******************************************************************************/
/* PROTOTYPES *****************************************************************/
void ft_to_sngss7_iam(ftdm_channel_t *ftdmchan);
void ft_to_sngss7_acm(ftdm_channel_t *ftdmchan);
void ft_to_sngss7_anm(ftdm_channel_t *ftdmchan);
void ft_to_sngss7_rel(ftdm_channel_t *ftdmchan);
void ft_to_sngss7_rlc(ftdm_channel_t *ftdmchan);
void ft_to_sngss7_rsc(ftdm_channel_t *ftdmchan);
void ft_to_sngss7_rsca(ftdm_channel_t *ftdmchan);
void ft_to_sngss7_blo(ftdm_channel_t *ftdmchan);
void ft_to_sngss7_bla(ftdm_channel_t *ftdmchan);
void ft_to_sngss7_ubl(ftdm_channel_t *ftdmchan);
void ft_to_sngss7_uba(ftdm_channel_t *ftdmchan);
void ft_to_sngss7_lpa(ftdm_channel_t *ftdmchan);
/* FUNCTIONS ******************************************************************/
void ft_to_sngss7_iam(ftdm_channel_t *ftdmchan)
{
SS7_FUNC_TRACE_ENTER(__FUNCTION__);
sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;;
SiConEvnt iam;
sngss7_info->suInstId = get_unique_id();
sngss7_info->spInstId = 0;
sngss7_info->spId = 1;
memset(&iam, 0x0, sizeof(iam));
/* copy down the nature of connection indicators */
iam.natConInd.eh.pres = PRSNT_NODEF;
iam.natConInd.satInd.pres = PRSNT_NODEF;
iam.natConInd.satInd.val = 0;
iam.natConInd.contChkInd.pres = PRSNT_NODEF;
iam.natConInd.contChkInd.val = 0x00;
iam.natConInd.echoCntrlDevInd.pres = PRSNT_NODEF;
iam.natConInd.echoCntrlDevInd.val = 0x01;
/* copy down the forward call indicators */
iam.fwdCallInd.eh.pres = PRSNT_NODEF;
iam.fwdCallInd.natIntCallInd.pres = PRSNT_NODEF;
iam.fwdCallInd.natIntCallInd.val = 0x00;
iam.fwdCallInd.end2EndMethInd.pres = PRSNT_NODEF;
iam.fwdCallInd.end2EndMethInd.val = 0x00;
iam.fwdCallInd.intInd.pres = PRSNT_NODEF;
iam.fwdCallInd.intInd.val = 0x01;
iam.fwdCallInd.end2EndInfoInd.pres = PRSNT_NODEF;
iam.fwdCallInd.end2EndInfoInd.val = 0x00;
iam.fwdCallInd.isdnUsrPrtInd.pres = PRSNT_NODEF;
iam.fwdCallInd.isdnUsrPrtInd.val = 0x01;
iam.fwdCallInd.isdnUsrPrtPrfInd.pres = PRSNT_NODEF;
iam.fwdCallInd.isdnUsrPrtPrfInd.val = 0x02;
iam.fwdCallInd.isdnAccInd.pres = PRSNT_NODEF;
iam.fwdCallInd.isdnAccInd.val = 0x01;
iam.fwdCallInd.sccpMethInd.pres = PRSNT_NODEF;
iam.fwdCallInd.sccpMethInd.val = 0x00;
/* copy down the calling number information */
iam.cgPtyCat.eh.pres = PRSNT_NODEF;
iam.cgPtyCat.cgPtyCat.pres = PRSNT_NODEF;
iam.cgPtyCat.cgPtyCat.val = 0x0a;
/* copy down the transmission medium requirements */
iam.txMedReq.eh.pres = PRSNT_NODEF;
iam.txMedReq.trMedReq.pres = PRSNT_NODEF;
iam.txMedReq.trMedReq.val = 0; /* SPEECH = 0, 3.1Khz = 3, 64k unres = 2 */
/* copy down the called number information */
copy_cdPtyNum_to_sngss7(&ftdmchan->caller_data, &iam.cdPtyNum);
/* copy down the calling number information */
copy_cgPtyNum_to_sngss7(&ftdmchan->caller_data, &iam.cgPtyNum);
sng_cc_con_request(sngss7_info->spId,
sngss7_info->suInstId,
sngss7_info->spInstId,
sngss7_info->circuit->id,
&iam,
0);
SS7_MSG_TRACE("Transmitted IAM on CIC # %d\n", sngss7_info->circuit->cic);
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return;
}
/******************************************************************************/
void ft_to_sngss7_acm(ftdm_channel_t *ftdmchan)
{
SS7_FUNC_TRACE_ENTER(__FUNCTION__);
sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
SiCnStEvnt acm;
memset(&acm, 0x0, sizeof(acm));
/* fill in the needed information for the ACM */
acm.bckCallInd.eh.pres = PRSNT_NODEF;
acm.bckCallInd.chrgInd.pres = PRSNT_NODEF;
acm.bckCallInd.chrgInd.val = 0x00;
acm.bckCallInd.cadPtyStatInd.pres = PRSNT_NODEF;
acm.bckCallInd.cadPtyStatInd.val = 0x01;
acm.bckCallInd.cadPtyCatInd.pres = PRSNT_NODEF;
acm.bckCallInd.cadPtyCatInd.val = 0x00;
acm.bckCallInd.end2EndMethInd.pres = PRSNT_NODEF;
acm.bckCallInd.end2EndMethInd.val = 0x00;
acm.bckCallInd.intInd.pres = PRSNT_NODEF;
acm.bckCallInd.intInd.val = 0x00;
acm.bckCallInd.end2EndInfoInd.pres = PRSNT_NODEF;
acm.bckCallInd.end2EndInfoInd.val = 0x00;
acm.bckCallInd.isdnUsrPrtInd.pres = PRSNT_NODEF;
acm.bckCallInd.isdnUsrPrtInd.val = 0x0;
acm.bckCallInd.holdInd.pres = PRSNT_NODEF;
acm.bckCallInd.holdInd.val = 0x00;
acm.bckCallInd.isdnAccInd.pres = PRSNT_NODEF;
acm.bckCallInd.isdnAccInd.val = 0x0;
acm.bckCallInd.echoCtrlDevInd.pres = PRSNT_NODEF;
acm.bckCallInd.echoCtrlDevInd.val = 0x0;
acm.bckCallInd.sccpMethInd.pres = PRSNT_NODEF;
acm.bckCallInd.sccpMethInd.val = 0x00;
/* send the ACM request to LibSngSS7 */
sng_cc_con_status(1,
sngss7_info->suInstId,
sngss7_info->spInstId,
sngss7_info->circuit->id,
&acm,
ADDRCMPLT);
SS7_MSG_TRACE("Transmitted ACM on CIC # %d\n", sngss7_info->circuit->cic);
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return;
}
/******************************************************************************/
void ft_to_sngss7_anm(ftdm_channel_t *ftdmchan)
{
SS7_FUNC_TRACE_ENTER(__FUNCTION__);
sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
SiConEvnt anm;
memset(&anm, 0x0, sizeof(anm));
/* send the ANM request to LibSngSS7 */
sng_cc_con_response(1,
sngss7_info->suInstId,
sngss7_info->spInstId,
sngss7_info->circuit->id,
&anm,
5);
SS7_MSG_TRACE("Transmitted ANM on CIC # %d\n", sngss7_info->circuit->cic);
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return;
}
/******************************************************************************/
void ft_to_sngss7_rel(ftdm_channel_t *ftdmchan)
{
SS7_FUNC_TRACE_ENTER(__FUNCTION__);
sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
SiRelEvnt rel;
memset(&rel, 0x0, sizeof(rel));
rel.causeDgn.eh.pres = PRSNT_NODEF;
rel.causeDgn.location.pres = PRSNT_NODEF;
rel.causeDgn.location.val = 0x01;
rel.causeDgn.cdeStand.pres = PRSNT_NODEF;
rel.causeDgn.cdeStand.val = 0x00;
rel.causeDgn.recommend.pres = NOTPRSNT;
rel.causeDgn.causeVal.pres = PRSNT_NODEF;
rel.causeDgn.causeVal.val = (uint8_t)ftdmchan->caller_data.hangup_cause;
rel.causeDgn.dgnVal.pres = NOTPRSNT;
/* send the REL request to LibSngSS7 */
sng_cc_rel_request(1,
sngss7_info->suInstId,
sngss7_info->spInstId,
sngss7_info->circuit->id,
&rel);
SS7_MSG_TRACE("Transmitted REL on CIC # %d\n", sngss7_info->circuit->cic);
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return;
}
/******************************************************************************/
void ft_to_sngss7_rlc(ftdm_channel_t *ftdmchan)
{
SS7_FUNC_TRACE_ENTER(__FUNCTION__);
sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
SiRelEvnt rlc;
memset(&rlc, 0x0, sizeof(rlc));
/* send the RLC request to LibSngSS7 */
sng_cc_rel_response(1,
sngss7_info->suInstId,
sngss7_info->spInstId,
sngss7_info->circuit->id,
&rlc);
SS7_MSG_TRACE("Transmitted RLC on CIC # %d\n", sngss7_info->circuit->cic);
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return;
}
/******************************************************************************/
void ft_to_sngss7_rsc(ftdm_channel_t *ftdmchan)
{
SS7_FUNC_TRACE_ENTER(__FUNCTION__);
sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
sng_cc_sta_request(1,
sngss7_info->suInstId,
sngss7_info->spInstId,
sngss7_info->circuit->id,
sngss7_info->globalFlg,
SIT_STA_CIRRESREQ,
NULL);
SS7_MSG_TRACE("Transmitted RSC on CIC # %d\n", sngss7_info->circuit->cic);
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return;
}
/******************************************************************************/
void ft_to_sngss7_rsca(ftdm_channel_t *ftdmchan)
{
SS7_FUNC_TRACE_ENTER(__FUNCTION__);
sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
sng_cc_sta_request(1,
sngss7_info->suInstId,
sngss7_info->spInstId,
sngss7_info->circuit->id,
sngss7_info->globalFlg,
SIT_STA_CIRRESRSP,
NULL);
SS7_MSG_TRACE("Transmitted RSC-RLC on CIC # %d\n", sngss7_info->circuit->cic);
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return;
}
/******************************************************************************/
void ft_to_sngss7_blo(ftdm_channel_t *ftdmchan)
{
SS7_FUNC_TRACE_ENTER(__FUNCTION__);
sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
sng_cc_sta_request(1,
0,
0,
sngss7_info->circuit->id,
sngss7_info->globalFlg,
SIT_STA_CIRBLOREQ,
NULL);
SS7_MSG_TRACE("Transmitted BLO on CIC # %d\n", sngss7_info->circuit->cic);
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return;
}
/******************************************************************************/
void ft_to_sngss7_bla(ftdm_channel_t *ftdmchan)
{
SS7_FUNC_TRACE_ENTER(__FUNCTION__);
sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
sng_cc_sta_request(1,
0,
0,
sngss7_info->circuit->id,
sngss7_info->globalFlg,
SIT_STA_CIRBLORSP,
NULL);
SS7_MSG_TRACE("Transmitted BLA on CIC # %d\n", sngss7_info->circuit->cic);
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return;
}
/******************************************************************************/
void ft_to_sngss7_ubl(ftdm_channel_t *ftdmchan)
{
SS7_FUNC_TRACE_ENTER(__FUNCTION__);
sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
sng_cc_sta_request(1,
0,
0,
sngss7_info->circuit->id,
sngss7_info->globalFlg,
SIT_STA_CIRUBLREQ,
NULL);
SS7_MSG_TRACE("Transmitted UBL on CIC # %d\n", sngss7_info->circuit->cic);
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return;
}
/******************************************************************************/
void ft_to_sngss7_uba(ftdm_channel_t *ftdmchan)
{
SS7_FUNC_TRACE_ENTER(__FUNCTION__);
sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
sng_cc_sta_request(1,
0,
0,
sngss7_info->circuit->id,
sngss7_info->globalFlg,
SIT_STA_CIRUBLRSP,
NULL);
SS7_MSG_TRACE("Transmitted UBA on CIC # %d\n", sngss7_info->circuit->cic);
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return;
}
/******************************************************************************/
void ft_to_sngss7_lpa(ftdm_channel_t *ftdmchan)
{
SS7_FUNC_TRACE_ENTER(__FUNCTION__);
sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
sng_cc_sta_request(1,
sngss7_info->suInstId,
sngss7_info->spInstId,
sngss7_info->circuit->id,
sngss7_info->globalFlg,
SIT_STA_LOOPBACKACK,
NULL);
SS7_MSG_TRACE("Transmitted LPA on CIC # %d\n", sngss7_info->circuit->cic);
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return;
}
/******************************************************************************/
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4:
*/
/******************************************************************************/

View File

@ -0,0 +1,381 @@
/*
* Copyright (c) 2009, Konrad Hammel <konrad@sangoma.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "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,
* 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
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* INCLUDE ********************************************************************/
#include "ftmod_sangoma_ss7_main.h"
/******************************************************************************/
/* DEFINES ********************************************************************/
/******************************************************************************/
/* GLOBALS ********************************************************************/
uint32_t sngss7_id;
/******************************************************************************/
/* PROTOTYPES *****************************************************************/
uint8_t copy_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven);
uint8_t copy_cgPtyNum_from_sngss7(ftdm_caller_data_t *ftdm, SiCgPtyNum *cgPtyNum);
uint8_t copy_cgPtyNum_to_sngss7(ftdm_caller_data_t *ftdm, SiCgPtyNum *cgPtyNum);
uint8_t copy_cdPtyNum_from_sngss7(ftdm_caller_data_t *ftdm, SiCdPtyNum *cdPtyNum);
uint8_t copy_cdPtyNum_to_sngss7(ftdm_caller_data_t *ftdm, SiCdPtyNum *cdPtyNum);
int check_for_state_change(ftdm_channel_t *ftdmchan);
unsigned long get_unique_id(void);
ftdm_status_t extract_chan_data(uint32_t circuit, sngss7_chan_data_t **sngss7_info, ftdm_channel_t **ftdmchan);
/******************************************************************************/
/* FUNCTIONS ******************************************************************/
uint8_t copy_cgPtyNum_from_sngss7(ftdm_caller_data_t *ftdm, SiCgPtyNum *cgPtyNum)
{
return 0;
}
/******************************************************************************/
uint8_t copy_cgPtyNum_to_sngss7(ftdm_caller_data_t *ftdm, SiCgPtyNum *cgPtyNum)
{
int k;
int j;
int flag;
char tmp;
unsigned char lower;
unsigned char upper;
/**************************************************************************/
cgPtyNum->eh.pres = PRSNT_NODEF;
/**************************************************************************/
cgPtyNum->natAddrInd.pres = PRSNT_NODEF;
cgPtyNum->natAddrInd.val = 0x03;
/**************************************************************************/
cgPtyNum->scrnInd.pres = PRSNT_NODEF;
cgPtyNum->scrnInd.val = ftdm->screen;
/**************************************************************************/
cgPtyNum->presRest.pres = PRSNT_NODEF;
cgPtyNum->presRest.val = ftdm->pres;
/**************************************************************************/
cgPtyNum->numPlan.pres = PRSNT_NODEF;
cgPtyNum->numPlan.val = 0x01;
/**************************************************************************/
cgPtyNum->niInd.pres = PRSNT_NODEF;
cgPtyNum->niInd.val = 0x00;
/**************************************************************************/
cgPtyNum->addrSig.pres = PRSNT_NODEF;
k = 0;
j = 0;
flag = 0;
while (1) {
tmp = ftdm->cid_num.digits[k];
if (tmp != '\0') {
if (isdigit(tmp)) {
lower = atoi(&tmp);
k++;
tmp = ftdm->cid_num.digits[k];
} else {
while (!(isdigit(tmp)) && (tmp != '\0')) {
k++;
tmp = ftdm->cid_num.digits[k];
} /* while(!(isdigit(tmp))) */
if (tmp != '\0') {
lower = atoi(&tmp);
k++;
tmp = ftdm->cid_num.digits[k];
} else {
flag = 1;
lower = 0xf;
} /* if (tmp != '\0') */
} /* (isdigit(tmp)) */
} else {
flag = 1;
lower = 0xf;
} /* if (tmp != '\0') */
tmp = ftdm->cid_num.digits[k];
if (tmp != '\0') {
if (isdigit(tmp)) {
upper = (atoi(&tmp)) << 4;
} else {
while (!(isdigit(tmp)) && (tmp != '\0')) {
k++;
tmp = ftdm->cid_num.digits[k];
} /* while(!(isdigit(tmp))) */
if (tmp != '\0') {
upper = (atoi(&tmp)) << 4;
k++;
} else {
flag = 1;
upper = 0xf;
} /* if (tmp != '\0') */
} /* if (isdigit(tmp)) */
} else {
if (flag == 1){
upper = 0x0;
} else {
flag = 1;
upper = 0xf;
} /* if (flag == 1) */
} /* if (tmp != '\0') */
cgPtyNum->addrSig.val[j] = upper | lower;
j++;
if (flag) {
break;
} else {
k++;
}
} /* while(1) */
cgPtyNum->addrSig.len = j;
/**************************************************************************/
cgPtyNum->oddEven.pres = PRSNT_NODEF;
cgPtyNum->oddEven.val = ((cgPtyNum->addrSig.val[j] >>4) == 0x0 ) ? 0x01 : 0x00;
/**************************************************************************/
return 0;
}
/******************************************************************************/
uint8_t copy_cdPtyNum_from_sngss7(ftdm_caller_data_t *ftdm, SiCdPtyNum *cdPtyNum)
{
return 0;
}
/******************************************************************************/
uint8_t copy_cdPtyNum_to_sngss7(ftdm_caller_data_t *ftdm, SiCdPtyNum *cdPtyNum)
{
int k;
int j;
int flag;
char tmp;
unsigned char lower;
unsigned char upper;
/**************************************************************************/
cdPtyNum->eh.pres = PRSNT_NODEF;
/**************************************************************************/
cdPtyNum->natAddrInd.pres = PRSNT_NODEF;
cdPtyNum->natAddrInd.val = 0x03;
/**************************************************************************/
cdPtyNum->numPlan.pres = PRSNT_NODEF;
cdPtyNum->numPlan.val = 0x01;
/**************************************************************************/
cdPtyNum->innInd.pres = PRSNT_NODEF;
cdPtyNum->innInd.val = 0x01;
/**************************************************************************/
cdPtyNum->addrSig.pres = PRSNT_NODEF;
k = 0;
j = 0;
flag = 0;
while (1) {
tmp = ftdm->dnis.digits[k];
if (tmp != '\0') {
if (isdigit(tmp)) {
lower = atoi(&tmp);
k++;
tmp = ftdm->dnis.digits[k];
} else {
while (!(isdigit(tmp)) && (tmp != '\0')) {
k++;
tmp = ftdm->dnis.digits[k];
} /* while(!(isdigit(tmp))) */
if (tmp != '\0') {
lower = atoi(&tmp);
k++;
tmp = ftdm->dnis.digits[k];
} else {
flag = 1;
lower = 0xf;
} /* if (tmp != '\0') */
} /* (isdigit(tmp)) */
} else {
flag = 1;
lower = 0xf;
} /* if (tmp != '\0') */
tmp = ftdm->dnis.digits[k];
if (tmp != '\0') {
if (isdigit(tmp)) {
upper = (atoi(&tmp)) << 4;
} else {
while (!(isdigit(tmp)) && (tmp != '\0')) {
k++;
tmp = ftdm->dnis.digits[k];
} /* while(!(isdigit(tmp))) */
if (tmp != '\0') {
upper = (atoi(&tmp)) << 4;
k++;
} else {
flag = 1;
upper = 0xf;
} /* if (tmp != '\0') */
} /* if (isdigit(tmp)) */
} else {
if (flag == 1){
upper = 0x0;
} else {
flag = 1;
upper = 0xf;
} /* if (flag == 1) */
} /* if (tmp != '\0') */
cdPtyNum->addrSig.val[j] = upper | lower;
j++;
if (flag) {
break;
} else {
k++;
}
} /* while(1) */
cdPtyNum->addrSig.len = j;
/**************************************************************************/
cdPtyNum->oddEven.pres = PRSNT_NODEF;
cdPtyNum->oddEven.val = ((cdPtyNum->addrSig.val[j] >>4) == 0x0 ) ? 0x01 : 0x00;
/**************************************************************************/
return 0;
}
/******************************************************************************/
uint8_t copy_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven)
{
uint8_t i;
uint8_t j;
/* check if the token string is present */
if (str.pres == 1) {
j=0;
for (i=0; i < str.len; i++) {
sprintf(&ftdm[j], "%d", (str.val[i] & 0x0F));
j++;
sprintf(&ftdm[j], "%d", ((str.val[i] & 0xF0) >> 4));
j++;
}
/* if the odd flag is up the last digit is a fake "0" */
if ((oddEven.pres == 1) && (oddEven.val == 1)) {
ftdm[j-1] = '\0';
} else {
ftdm[j] = '\0';
}
} else {
SS7_ERROR("Asked to copy tknStr that is not present!\n");
return 1;
}
return 0;
}
/******************************************************************************/
int check_for_state_change(ftdm_channel_t *ftdmchan)
{
#if 0
SS7_DEBUG("Checking for pending state change on span: %d, chan: %d\n!",
ftdmchan->physical_span_id,
ftdmchan->physical_chan_id);
#endif
/* check to see if there are any pending state changes on the channel and give them a sec to happen*/
ftdm_wait_for_flag_cleared(ftdmchan, FTDM_CHANNEL_STATE_CHANGE, 5000);
/* check the flag to confirm it is clear now */
if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_STATE_CHANGE)) {
/* the flag is still up...so we have a problem */
SS7_ERROR("FTDM_CHANNEL_STATE_CHANGE set for over 500ms on span: %d, chan: %d\n",
ftdmchan->physical_span_id,
ftdmchan->physical_chan_id);
/* move the state of the channel to RESTART to force a reset */
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_RESTART);
return 1;
}
return 0;
}
/******************************************************************************/
ftdm_status_t extract_chan_data(uint32_t circuit, sngss7_chan_data_t **sngss7_info, ftdm_channel_t **ftdmchan)
{
SS7_FUNC_TRACE_ENTER(__FUNCTION__);
if (g_ftdm_sngss7_data.cfg.isupCircuit[circuit].obj == NULL) {
SS7_ERROR("sngss7_info is Null for circuit #%d\n", circuit);
return FTDM_FAIL;
}
ftdm_assert_return(g_ftdm_sngss7_data.cfg.isupCircuit[circuit].obj,FTDM_FAIL,"received message on signalling link or non-configured cic\n");
*sngss7_info = g_ftdm_sngss7_data.cfg.isupCircuit[circuit].obj;
ftdm_assert_return((*sngss7_info)->ftdmchan,FTDM_FAIL,"received message on signalling link or non-configured cic\n");
*ftdmchan = (*sngss7_info)->ftdmchan;
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return FTDM_SUCCESS;
}
/******************************************************************************/
unsigned long get_unique_id(void)
{
if (sngss7_id < 420000000) {
sngss7_id++;
} else {
sngss7_id = 1;
}
return(sngss7_id);
}
/******************************************************************************/
/******************************************************************************/
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4:
*/
/******************************************************************************/

View File

@ -0,0 +1,90 @@
/*
* Copyright (c) 2009, Konrad Hammel <konrad@sangoma.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "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,
* 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
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* INCLUDE ********************************************************************/
#include "ftmod_sangoma_ss7_main.h"
/******************************************************************************/
/* DEFINES ********************************************************************/
/******************************************************************************/
/* GLOBALS ********************************************************************/
/******************************************************************************/
/* PROTOTYPES *****************************************************************/
void handle_isup_t35(void *userdata);
/******************************************************************************/
/* FUNCTIONS ******************************************************************/
void handle_isup_t35(void *userdata)
{
SS7_FUNC_TRACE_ENTER(__FUNCTION__);
sngss7_timer_data_t *timer = userdata;
sngss7_chan_data_t *sngss7_info = timer->sngss7_info;
ftdm_channel_t *ftdmchan = sngss7_info->ftdmchan;
/* now that we have the right channel...put a lock on it so no-one else can use it */
ftdm_mutex_lock(ftdmchan->mutex);
SS7_ERROR("[Call-Control] Timer 35 expired on CIC = %d\n", sngss7_info->circuit->cic);
/* set the flag to indicate this hangup is started from the local side */
sngss7_set_flag(sngss7_info, FLAG_LOCAL_REL);
/* hang up on timer expiry */
ftdmchan->caller_data.hangup_cause = 102;
/* end the call */
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_CANCEL);
/*unlock*/
ftdm_mutex_unlock(ftdmchan->mutex);
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return;
}
/******************************************************************************/
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4:
*/
/******************************************************************************/

File diff suppressed because it is too large Load Diff