fretdm: remove m3ua unused stuff
This commit is contained in:
parent
568013bc60
commit
cd28c4fc98
|
@ -1,38 +0,0 @@
|
||||||
;M3UA SS7 Links Config
|
|
||||||
;
|
|
||||||
;ss7box-m3ua_mode => true
|
|
||||||
;local_sctp_ip => localhost
|
|
||||||
;local sctp_port => 30000
|
|
||||||
;remote_sctp_ip => localhost
|
|
||||||
;remote_sctp_port => 30001
|
|
||||||
;opc => 0-0-0
|
|
||||||
;dpc => 0-0-0
|
|
||||||
|
|
||||||
|
|
||||||
; AP Specific Stuff. This will likely move later.
|
|
||||||
|
|
||||||
; CNAM Gateways
|
|
||||||
cnam1_dpc => 0-0-0
|
|
||||||
cnam1_ssn => 253
|
|
||||||
cnam2_dpc => 0-0-0
|
|
||||||
cnam2_ssn => 253
|
|
||||||
cnam3_dpc => 0-0-0
|
|
||||||
cnam3_ssn => 253
|
|
||||||
|
|
||||||
;LNP Gateways
|
|
||||||
lnp1_dpc => 0-0-0
|
|
||||||
lnp1_ssn => 253
|
|
||||||
lnp2_dpc => 0-0-0
|
|
||||||
lnp2_ssn => 253
|
|
||||||
lnp3_dpc => 0-0-0
|
|
||||||
lnp3_ssn => 253
|
|
||||||
|
|
||||||
;LNP Gateways
|
|
||||||
sms8001_dpc => 0-0-0
|
|
||||||
sms8001_ssn => 253
|
|
||||||
sms8002_dpc => 0-0-0
|
|
||||||
sms8002_ssn => 253
|
|
||||||
sms8003_dpc => 0-0-0
|
|
||||||
sms8003_ssn => 253
|
|
||||||
|
|
||||||
|
|
|
@ -1,692 +0,0 @@
|
||||||
/*
|
|
||||||
* ftdm_m3ua.c
|
|
||||||
* freetdm
|
|
||||||
*
|
|
||||||
* Created by Shane Burrell on 4/3/08.
|
|
||||||
* Copyright 2008 Shane Burrell. All rights reserved.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Copyright (c) 2007, Anthony Minessale II, Nenad Corbic *
|
|
||||||
*
|
|
||||||
* 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 "freetdm.h"
|
|
||||||
#include "m3ua_client.h"
|
|
||||||
#include "ftdm_m3ua.h"
|
|
||||||
|
|
||||||
#define MAX_REQ_ID MAX_PENDING_CALLS
|
|
||||||
typedef uint16_t m3ua_request_id_t;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
BST_FREE,
|
|
||||||
BST_WAITING,
|
|
||||||
BST_READY,
|
|
||||||
BST_FAIL
|
|
||||||
} m3ua_request_status_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
m3ua_request_status_t status;
|
|
||||||
m3uac_event_t event;
|
|
||||||
ftdm_span_t *span;
|
|
||||||
ftdm_channel_t *ftdmchan;
|
|
||||||
} m3ua_request_t;
|
|
||||||
|
|
||||||
|
|
||||||
struct general_config {
|
|
||||||
uint32_t region;
|
|
||||||
};
|
|
||||||
typedef struct general_config general_config_t;
|
|
||||||
|
|
||||||
|
|
||||||
struct m3ua_channel_profile {
|
|
||||||
char name[80];
|
|
||||||
int cust_span;
|
|
||||||
unsigned char opc[3];
|
|
||||||
unsigned char dpc[3];
|
|
||||||
int local_ip[4];
|
|
||||||
int local_port;
|
|
||||||
int remote_ip[4];
|
|
||||||
int remote_port;
|
|
||||||
int m3ua_mode;
|
|
||||||
};
|
|
||||||
typedef struct m3ua_channel_profile m3ua_channel_profile_t;
|
|
||||||
|
|
||||||
static struct {
|
|
||||||
ftdm_hash_t *profile_hash;
|
|
||||||
general_config_t general_config;
|
|
||||||
} globals;
|
|
||||||
|
|
||||||
struct m3ua_span_data {
|
|
||||||
uint32_t boardno;
|
|
||||||
uint32_t flags;
|
|
||||||
};
|
|
||||||
typedef struct m3ua_span_data m3ua_span_data_t;
|
|
||||||
|
|
||||||
struct m3ua_chan_data {
|
|
||||||
ftdm_buffer_t *digit_buffer;
|
|
||||||
ftdm_mutex_t *digit_mutex;
|
|
||||||
ftdm_size_t dtmf_len;
|
|
||||||
uint32_t flags;
|
|
||||||
uint32_t hdlc_bytes;
|
|
||||||
};
|
|
||||||
typedef struct m3ua_chan_data m3ua_chan_data_t;
|
|
||||||
|
|
||||||
static ftdm_mutex_t *request_mutex = NULL;
|
|
||||||
static ftdm_mutex_t *signal_mutex = NULL;
|
|
||||||
|
|
||||||
static uint8_t req_map[MAX_REQ_ID+1] = { 0 };
|
|
||||||
|
|
||||||
static void release_request_id(m3ua_request_id_t r)
|
|
||||||
{
|
|
||||||
ftdm_mutex_lock(request_mutex);
|
|
||||||
req_map[r] = 0;
|
|
||||||
ftdm_mutex_unlock(request_mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*static m3ua_request_id_t next_request_id(void)
|
|
||||||
{
|
|
||||||
m3ua_request_id_t r = 0;
|
|
||||||
int ok = 0;
|
|
||||||
|
|
||||||
while(!ok) {
|
|
||||||
ftdm_mutex_lock(request_mutex);
|
|
||||||
for (r = 1; r <= MAX_REQ_ID; r++) {
|
|
||||||
if (!req_map[r]) {
|
|
||||||
ok = 1;
|
|
||||||
req_map[r] = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ftdm_mutex_unlock(request_mutex);
|
|
||||||
if (!ok) {
|
|
||||||
ftdm_sleep(5);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
static __inline__ void state_advance(ftdm_channel_t *ftdmchan)
|
|
||||||
{
|
|
||||||
|
|
||||||
m3ua_data_t *m3ua_data = ftdmchan->span->signal_data;
|
|
||||||
m3uac_connection_t *mcon = &m3ua_data->mcon;
|
|
||||||
ftdm_sigmsg_t sig;
|
|
||||||
ftdm_status_t status;
|
|
||||||
|
|
||||||
ftdm_log(FTDM_LOG_DEBUG, "%d:%d STATE [%s]\n", ftdmchan->span_id, ftdmchan->chan_id, ftdm_channel_state2str(ftdmchan->state));
|
|
||||||
|
|
||||||
memset(&sig, 0, sizeof(sig));
|
|
||||||
sig.chan_id = ftdmchan->chan_id;
|
|
||||||
sig.span_id = ftdmchan->span_id;
|
|
||||||
sig.channel = ftdmchan;
|
|
||||||
|
|
||||||
switch (ftdmchan->state) {
|
|
||||||
case FTDM_CHANNEL_STATE_DOWN:
|
|
||||||
{
|
|
||||||
if (ftdmchan->extra_id) {
|
|
||||||
release_request_id((m3ua_request_id_t)ftdmchan->extra_id);
|
|
||||||
ftdmchan->extra_id = 0;
|
|
||||||
}
|
|
||||||
ftdm_channel_close(&ftdmchan);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case FTDM_CHANNEL_STATE_PROGRESS_MEDIA:
|
|
||||||
case FTDM_CHANNEL_STATE_PROGRESS:
|
|
||||||
{
|
|
||||||
if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) {
|
|
||||||
sig.event_id = FTDM_SIGEVENT_PROGRESS_MEDIA;
|
|
||||||
if ((status = m3ua_data->signal_cb(&sig) != FTDM_SUCCESS)) {
|
|
||||||
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_HANGUP);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
m3uac_exec_command(mcon,
|
|
||||||
ftdmchan->physical_span_id-1,
|
|
||||||
ftdmchan->physical_chan_id-1,
|
|
||||||
0,
|
|
||||||
SIGBOOST_EVENT_CALL_START_ACK,
|
|
||||||
0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case FTDM_CHANNEL_STATE_RING:
|
|
||||||
{
|
|
||||||
if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) {
|
|
||||||
sig.event_id = FTDM_SIGEVENT_START;
|
|
||||||
if ((status = m3ua_data->signal_cb(&sig) != FTDM_SUCCESS)) {
|
|
||||||
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_HANGUP);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case FTDM_CHANNEL_STATE_RESTART:
|
|
||||||
{
|
|
||||||
if (ftdmchan->last_state != FTDM_CHANNEL_STATE_HANGUP && ftdmchan->last_state != FTDM_CHANNEL_STATE_DOWN) {
|
|
||||||
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_HANGUP);
|
|
||||||
} else {
|
|
||||||
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case FTDM_CHANNEL_STATE_UP:
|
|
||||||
{
|
|
||||||
if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) {
|
|
||||||
sig.event_id = FTDM_SIGEVENT_UP;
|
|
||||||
if ((status = m3ua_data->signal_cb(&sig) != FTDM_SUCCESS)) {
|
|
||||||
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_HANGUP);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!(ftdm_test_flag(ftdmchan, FTDM_CHANNEL_PROGRESS) || ftdm_test_flag(ftdmchan, FTDM_CHANNEL_MEDIA))) {
|
|
||||||
m3uac_exec_command(mcon,
|
|
||||||
ftdmchan->physical_span_id-1,
|
|
||||||
ftdmchan->physical_chan_id-1,
|
|
||||||
0,
|
|
||||||
SIGBOOST_EVENT_CALL_START_ACK,
|
|
||||||
0);
|
|
||||||
}
|
|
||||||
|
|
||||||
m3uac_exec_command(mcon,
|
|
||||||
ftdmchan->physical_span_id-1,
|
|
||||||
ftdmchan->physical_chan_id-1,
|
|
||||||
0,
|
|
||||||
SIGBOOST_EVENT_CALL_ANSWERED,
|
|
||||||
0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case FTDM_CHANNEL_STATE_DIALING:
|
|
||||||
{
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case FTDM_CHANNEL_STATE_HANGUP_COMPLETE:
|
|
||||||
{
|
|
||||||
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case FTDM_CHANNEL_STATE_HANGUP:
|
|
||||||
{
|
|
||||||
if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_ANSWERED) || ftdm_test_flag(ftdmchan, FTDM_CHANNEL_PROGRESS) || ftdm_test_flag(ftdmchan, FTDM_CHANNEL_MEDIA)) {
|
|
||||||
m3uac_exec_command(mcon,
|
|
||||||
ftdmchan->physical_span_id-1,
|
|
||||||
ftdmchan->physical_chan_id-1,
|
|
||||||
0,
|
|
||||||
SIGBOOST_EVENT_CALL_STOPPED,
|
|
||||||
ftdmchan->caller_data.hangup_cause);
|
|
||||||
} else {
|
|
||||||
m3uac_exec_command(mcon,
|
|
||||||
ftdmchan->physical_span_id-1,
|
|
||||||
ftdmchan->physical_chan_id-1,
|
|
||||||
0,
|
|
||||||
SIGBOOST_EVENT_CALL_START_NACK,
|
|
||||||
ftdmchan->caller_data.hangup_cause);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case FTDM_CHANNEL_STATE_CANCEL:
|
|
||||||
{
|
|
||||||
sig.event_id = FTDM_SIGEVENT_STOP;
|
|
||||||
status = m3ua_data->signal_cb(&sig);
|
|
||||||
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN);
|
|
||||||
m3uac_exec_command(mcon,
|
|
||||||
ftdmchan->physical_span_id-1,
|
|
||||||
ftdmchan->physical_chan_id-1,
|
|
||||||
0,
|
|
||||||
SIGBOOST_EVENT_CALL_START_NACK_ACK,
|
|
||||||
0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case FTDM_CHANNEL_STATE_TERMINATING:
|
|
||||||
{
|
|
||||||
sig.event_id = FTDM_SIGEVENT_STOP;
|
|
||||||
status = m3ua_data->signal_cb(&sig);
|
|
||||||
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN);
|
|
||||||
m3uac_exec_command(mcon,
|
|
||||||
ftdmchan->physical_span_id-1,
|
|
||||||
ftdmchan->physical_chan_id-1,
|
|
||||||
0,
|
|
||||||
SIGBOOST_EVENT_CALL_STOPPED_ACK,
|
|
||||||
0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static __inline__ void check_state(ftdm_span_t *span)
|
|
||||||
{
|
|
||||||
if (ftdm_test_flag(span, FTDM_SPAN_STATE_CHANGE)) {
|
|
||||||
uint32_t j;
|
|
||||||
ftdm_clear_flag_locked(span, FTDM_SPAN_STATE_CHANGE);
|
|
||||||
for(j = 1; j <= span->chan_count; j++) {
|
|
||||||
if (ftdm_test_flag((&span->channels[j]), FTDM_CHANNEL_STATE_CHANGE)) {
|
|
||||||
ftdm_clear_flag_locked((&span->channels[j]), FTDM_CHANNEL_STATE_CHANGE);
|
|
||||||
state_advance(&span->channels[j]);
|
|
||||||
ftdm_channel_complete_state(&span->channels[j]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int parse_ss7_event(ftdm_span_t *span, m3uac_connection_t *mcon, m3uac_event_t *event)
|
|
||||||
{
|
|
||||||
ftdm_mutex_lock(signal_mutex);
|
|
||||||
|
|
||||||
if (!ftdm_running()) {
|
|
||||||
ftdm_log(FTDM_LOG_WARNING, "System is shutting down.\n");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (ftdm_test_flag(span, FTDM_SPAN_SUSPENDED) &&
|
|
||||||
event->event_id != SIGBOOST_EVENT_SYSTEM_RESTART_ACK && event->event_id != SIGBOOST_EVENT_HEARTBEAT) {
|
|
||||||
|
|
||||||
ftdm_log(FTDM_LOG_WARNING,
|
|
||||||
"INVALID EVENT: %s:(%X) [w%dg%d] Rc=%i CSid=%i Seq=%i Cd=[%s] Ci=[%s]\n",
|
|
||||||
m3uac_event_id_name(event->event_id),
|
|
||||||
event->event_id,
|
|
||||||
event->span+1,
|
|
||||||
event->chan+1,
|
|
||||||
event->release_cause,
|
|
||||||
event->call_setup_id,
|
|
||||||
event->fseqno,
|
|
||||||
(event->called_number_digits_count ? (char *) event->called_number_digits : "N/A"),
|
|
||||||
(event->calling_number_digits_count ? (char *) event->calling_number_digits : "N/A")
|
|
||||||
);
|
|
||||||
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ftdm_log(FTDM_LOG_DEBUG,
|
|
||||||
"RX EVENT: %s:(%X) [w%dg%d] Rc=%i CSid=%i Seq=%i Cd=[%s] Ci=[%s]\n",
|
|
||||||
m3uac_event_id_name(event->event_id),
|
|
||||||
event->event_id,
|
|
||||||
event->span+1,
|
|
||||||
event->chan+1,
|
|
||||||
event->release_cause,
|
|
||||||
event->call_setup_id,
|
|
||||||
event->fseqno,
|
|
||||||
(event->called_number_digits_count ? (char *) event->called_number_digits : "N/A"),
|
|
||||||
(event->calling_number_digits_count ? (char *) event->calling_number_digits : "N/A")
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
switch(event->event_id) {
|
|
||||||
|
|
||||||
case SIGBOOST_EVENT_CALL_START:
|
|
||||||
//handle_call_start(span, mcon, event);
|
|
||||||
break;
|
|
||||||
case SIGBOOST_EVENT_CALL_STOPPED:
|
|
||||||
//handle_call_stop(span, mcon, event);
|
|
||||||
break;
|
|
||||||
case SIGBOOST_EVENT_CALL_START_ACK:
|
|
||||||
//handle_call_start_ack(mcon, event);
|
|
||||||
break;
|
|
||||||
case SIGBOOST_EVENT_CALL_START_NACK:
|
|
||||||
//handle_call_start_nack(span, mcon, event);
|
|
||||||
break;
|
|
||||||
case SIGBOOST_EVENT_CALL_ANSWERED:
|
|
||||||
//handle_call_answer(span, mcon, event);
|
|
||||||
break;
|
|
||||||
case SIGBOOST_EVENT_HEARTBEAT:
|
|
||||||
//handle_heartbeat(mcon, event);
|
|
||||||
break;
|
|
||||||
case SIGBOOST_EVENT_CALL_STOPPED_ACK:
|
|
||||||
case SIGBOOST_EVENT_CALL_START_NACK_ACK:
|
|
||||||
//handle_call_done(span, mcon, event);
|
|
||||||
break;
|
|
||||||
case SIGBOOST_EVENT_INSERT_CHECK_LOOP:
|
|
||||||
//handle_call_loop_start(event);
|
|
||||||
break;
|
|
||||||
case SIGBOOST_EVENT_REMOVE_CHECK_LOOP:
|
|
||||||
//handle_call_stop(event);
|
|
||||||
break;
|
|
||||||
case SIGBOOST_EVENT_SYSTEM_RESTART_ACK:
|
|
||||||
//handle_restart_ack(mcon, span, event);
|
|
||||||
break;
|
|
||||||
case SIGBOOST_EVENT_AUTO_CALL_GAP_ABATE:
|
|
||||||
//handle_gap_abate(event);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ftdm_log(FTDM_LOG_WARNING, "No handler implemented for [%s]\n", m3uac_event_id_name(event->event_id));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
end:
|
|
||||||
|
|
||||||
ftdm_mutex_unlock(signal_mutex);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FIO_CONFIGURE_FUNCTION(m3ua_configure)
|
|
||||||
{
|
|
||||||
m3ua_channel_profile_t *profile = NULL;
|
|
||||||
|
|
||||||
int ok = 1;
|
|
||||||
|
|
||||||
if (!(profile = (m3ua_channel_profile_t *) hashtable_search(globals.profile_hash, (char *)category))) {
|
|
||||||
profile = ftdm_malloc(sizeof(*profile));
|
|
||||||
memset(profile, 0, sizeof(*profile));
|
|
||||||
ftdm_set_string(profile->name, category);
|
|
||||||
hashtable_insert(globals.profile_hash, (void *)profile->name, profile);
|
|
||||||
ftdm_log(FTDM_LOG_INFO, "creating profile [%s]\n", category);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ftdm_set_string(m3ua_data->mcon. cfg.local_ip, local_ip);
|
|
||||||
if (!strcasecmp(var, "local_sctp_port")) {
|
|
||||||
profile->local_port = 30000 ;
|
|
||||||
profile->remote_port = 30000;
|
|
||||||
profile->cust_span++;
|
|
||||||
}
|
|
||||||
ok = 1;
|
|
||||||
|
|
||||||
|
|
||||||
if (ok) {
|
|
||||||
ftdm_log(FTDM_LOG_INFO, "setting param [%s]=[%s] for profile [%s]\n", var, val, category);
|
|
||||||
} else {
|
|
||||||
ftdm_log(FTDM_LOG_ERROR, "unknown param [%s]\n", var);
|
|
||||||
}
|
|
||||||
|
|
||||||
return FTDM_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FIO_CONFIGURE_SPAN_FUNCTION(m3ua_configure_span)
|
|
||||||
{
|
|
||||||
|
|
||||||
return FTDM_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FIO_OPEN_FUNCTION(m3ua_open)
|
|
||||||
{
|
|
||||||
|
|
||||||
return FTDM_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FIO_CLOSE_FUNCTION(m3ua_close)
|
|
||||||
{
|
|
||||||
|
|
||||||
return FTDM_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*static FIO_SET_INTERVAL_FUNCTION(m3ua_set_interval)
|
|
||||||
{
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
static FIO_WAIT_FUNCTION(m3ua_wait)
|
|
||||||
{
|
|
||||||
|
|
||||||
return FTDM_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FIO_READ_FUNCTION(m3ua_read)
|
|
||||||
{
|
|
||||||
|
|
||||||
return FTDM_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FIO_WRITE_FUNCTION(m3ua_write)
|
|
||||||
{
|
|
||||||
|
|
||||||
return FTDM_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FIO_COMMAND_FUNCTION(m3ua_command)
|
|
||||||
{
|
|
||||||
return FTDM_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FIO_SPAN_POLL_EVENT_FUNCTION(m3ua_poll_event)
|
|
||||||
{
|
|
||||||
return FTDM_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FIO_SPAN_NEXT_EVENT_FUNCTION(m3ua_next_event)
|
|
||||||
{
|
|
||||||
return FTDM_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static FIO_SPAN_DESTROY_FUNCTION(m3ua_span_destroy)
|
|
||||||
{
|
|
||||||
m3ua_span_data_t *span_data = (m3ua_span_data_t *) span->io_data;
|
|
||||||
|
|
||||||
if (span_data) {
|
|
||||||
ftdm_safe_free(span_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
return FTDM_SUCCESS;
|
|
||||||
}
|
|
||||||
static FIO_CHANNEL_DESTROY_FUNCTION(m3ua_channel_destroy)
|
|
||||||
{
|
|
||||||
m3ua_chan_data_t *chan_data = (m3ua_chan_data_t *) ftdmchan->io_data;
|
|
||||||
m3ua_span_data_t *span_data = (m3ua_span_data_t *) ftdmchan->span->io_data;
|
|
||||||
|
|
||||||
if (!chan_data) {
|
|
||||||
return FTDM_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ftdm_mutex_destroy(&chan_data->digit_mutex);
|
|
||||||
ftdm_buffer_destroy(&chan_data->digit_buffer);
|
|
||||||
|
|
||||||
|
|
||||||
ftdm_safe_free(chan_data);
|
|
||||||
|
|
||||||
if (span_data) {
|
|
||||||
ftdm_safe_free(span_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return FTDM_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static FIO_GET_ALARMS_FUNCTION(m3ua_get_alarms)
|
|
||||||
{
|
|
||||||
return FTDM_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ftdm_io_interface_t m3ua_interface;
|
|
||||||
|
|
||||||
ftdm_status_t m3ua_init(ftdm_io_interface_t **zint)
|
|
||||||
{
|
|
||||||
assert(zint != NULL);
|
|
||||||
memset(&m3ua_interface, 0, sizeof(m3ua_interface));
|
|
||||||
|
|
||||||
m3ua_interface.name = "m3ua";
|
|
||||||
m3ua_interface.configure = m3ua_configure;
|
|
||||||
m3ua_interface.configure_span = m3ua_configure_span;
|
|
||||||
m3ua_interface.open = m3ua_open;
|
|
||||||
m3ua_interface.close = m3ua_close;
|
|
||||||
m3ua_interface.wait = m3ua_wait;
|
|
||||||
m3ua_interface.read = m3ua_read;
|
|
||||||
m3ua_interface.write = m3ua_write;
|
|
||||||
m3ua_interface.command = m3ua_command;
|
|
||||||
m3ua_interface.poll_event = m3ua_poll_event;
|
|
||||||
m3ua_interface.next_event = m3ua_next_event;
|
|
||||||
m3ua_interface.channel_destroy = m3ua_channel_destroy;
|
|
||||||
m3ua_interface.span_destroy = m3ua_span_destroy;
|
|
||||||
m3ua_interface.get_alarms = m3ua_get_alarms;
|
|
||||||
*zint = &m3ua_interface;
|
|
||||||
|
|
||||||
return FTDM_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ftdm_status_t m3ua_destroy(void)
|
|
||||||
{
|
|
||||||
return FTDM_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void *m3ua_run(ftdm_thread_t *me, void *obj)
|
|
||||||
{
|
|
||||||
ftdm_span_t *span = (ftdm_span_t *) obj;
|
|
||||||
m3ua_data_t *m3ua_data = span->signal_data;
|
|
||||||
m3uac_connection_t *mcon, *pcon;
|
|
||||||
uint32_t ms = 10, too_long = 60000;
|
|
||||||
|
|
||||||
|
|
||||||
m3ua_data->pcon = m3ua_data->mcon;
|
|
||||||
|
|
||||||
if (m3uac_connection_open(&m3ua_data->mcon,
|
|
||||||
m3ua_data->mcon.cfg.local_ip,
|
|
||||||
m3ua_data->mcon.cfg.local_port,
|
|
||||||
m3ua_data->mcon.cfg.remote_ip,
|
|
||||||
m3ua_data->mcon.cfg.remote_port) < 0) {
|
|
||||||
ftdm_log(FTDM_LOG_DEBUG, "Error: Opening MCON Socket [%d] %s\n", m3ua_data->mcon.socket, strerror(errno));
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m3uac_connection_open(&m3ua_data->pcon,
|
|
||||||
m3ua_data->pcon.cfg.local_ip,
|
|
||||||
++m3ua_data->pcon.cfg.local_port,
|
|
||||||
m3ua_data->pcon.cfg.remote_ip,
|
|
||||||
m3ua_data->pcon.cfg.remote_port) < 0) {
|
|
||||||
ftdm_log(FTDM_LOG_DEBUG, "Error: Opening PCON Socket [%d] %s\n", m3ua_data->pcon.socket, strerror(errno));
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
mcon = &m3ua_data->mcon;
|
|
||||||
pcon = &m3ua_data->pcon;
|
|
||||||
|
|
||||||
top:
|
|
||||||
|
|
||||||
//init_outgoing_array();
|
|
||||||
|
|
||||||
m3uac_exec_command(mcon,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
-1,
|
|
||||||
SIGBOOST_EVENT_SYSTEM_RESTART,
|
|
||||||
0);
|
|
||||||
|
|
||||||
while (ftdm_test_flag(m3ua_data, FTDM_M3UA_RUNNING)) {
|
|
||||||
fd_set rfds, efds;
|
|
||||||
struct timeval tv = { 0, ms * 1000 };
|
|
||||||
int max, activity, i = 0;
|
|
||||||
m3uac_event_t *event = NULL;
|
|
||||||
|
|
||||||
if (!ftdm_running()) {
|
|
||||||
m3uac_exec_command(mcon,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
-1,
|
|
||||||
SIGBOOST_EVENT_SYSTEM_RESTART,
|
|
||||||
0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
FD_ZERO(&rfds);
|
|
||||||
FD_ZERO(&efds);
|
|
||||||
FD_SET(mcon->socket, &rfds);
|
|
||||||
FD_SET(mcon->socket, &efds);
|
|
||||||
FD_SET(pcon->socket, &rfds);
|
|
||||||
FD_SET(pcon->socket, &efds);
|
|
||||||
|
|
||||||
max = ((pcon->socket > mcon->socket) ? pcon->socket : mcon->socket) + 1;
|
|
||||||
|
|
||||||
if ((activity = select(max, &rfds, NULL, &efds, &tv)) < 0) {
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (activity) {
|
|
||||||
if (FD_ISSET(pcon->socket, &efds) || FD_ISSET(mcon->socket, &efds)) {
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (FD_ISSET(pcon->socket, &rfds)) {
|
|
||||||
if ((event = m3uac_connection_readp(pcon, i))) {
|
|
||||||
parse_ss7_event(span, mcon, event);
|
|
||||||
} else goto top;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (FD_ISSET(mcon->socket, &rfds)) {
|
|
||||||
if ((event = m3uac_connection_read(mcon, i))) {
|
|
||||||
parse_ss7_event(span, mcon, event);
|
|
||||||
} else goto top;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
check_state(span);
|
|
||||||
mcon->hb_elapsed += ms;
|
|
||||||
|
|
||||||
if (mcon->hb_elapsed >= too_long && (mcon->up || !ftdm_test_flag(span, FTDM_SPAN_SUSPENDED))) {
|
|
||||||
ftdm_set_state_all(span, FTDM_CHANNEL_STATE_RESTART);
|
|
||||||
ftdm_set_flag_locked(span, FTDM_SPAN_SUSPENDED);
|
|
||||||
mcon->up = 0;
|
|
||||||
ftdm_log(FTDM_LOG_CRIT, "Lost Heartbeat!\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
goto end;
|
|
||||||
|
|
||||||
error:
|
|
||||||
ftdm_log(FTDM_LOG_CRIT, "Socket Error!\n");
|
|
||||||
|
|
||||||
end:
|
|
||||||
|
|
||||||
m3uac_connection_close(&m3ua_data->mcon);
|
|
||||||
m3uac_connection_close(&m3ua_data->pcon);
|
|
||||||
|
|
||||||
ftdm_clear_flag(m3ua_data, FTDM_M3UA_RUNNING);
|
|
||||||
|
|
||||||
ftdm_log(FTDM_LOG_DEBUG, "M3UA thread ended.\n");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
ftdm_status_t m3ua_start(ftdm_span_t *span)
|
|
||||||
{
|
|
||||||
m3ua_data_t *m3ua_data = span->signal_data;
|
|
||||||
ftdm_set_flag(m3ua_data, FTDM_M3UA_RUNNING);
|
|
||||||
return ftdm_thread_create_detached(m3ua_run, span);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* For Emacs:
|
|
||||||
* Local Variables:
|
|
||||||
* mode:c
|
|
||||||
* indent-tabs-mode:t
|
|
||||||
* tab-width:4
|
|
||||||
* c-basic-offset:4
|
|
||||||
* End:
|
|
||||||
*/
|
|
|
@ -1,134 +0,0 @@
|
||||||
/*
|
|
||||||
* ftdm_m3ua.h
|
|
||||||
* freetdm
|
|
||||||
*
|
|
||||||
* Created by Shane Burrell on 4/3/08.
|
|
||||||
* Copyright 2008 Shane Burrell. All rights reserved.
|
|
||||||
*
|
|
||||||
* Copyright (c) 2007, Anthony Minessale II, Nenad Corbic
|
|
||||||
*
|
|
||||||
* 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 "m3ua_client.h"
|
|
||||||
#include "freetdm.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
enum e_sigboost_event_id_values
|
|
||||||
{
|
|
||||||
SIGBOOST_EVENT_CALL_START = 0x80, /*128*/
|
|
||||||
SIGBOOST_EVENT_CALL_START_ACK = 0x81, /*129*/
|
|
||||||
SIGBOOST_EVENT_CALL_START_NACK = 0x82, /*130*/
|
|
||||||
SIGBOOST_EVENT_CALL_START_NACK_ACK = 0x83, /*131*/
|
|
||||||
SIGBOOST_EVENT_CALL_ANSWERED = 0x84, /*132*/
|
|
||||||
SIGBOOST_EVENT_CALL_STOPPED = 0x85, /*133*/
|
|
||||||
SIGBOOST_EVENT_CALL_STOPPED_ACK = 0x86, /*134*/
|
|
||||||
SIGBOOST_EVENT_SYSTEM_RESTART = 0x87, /*135*/
|
|
||||||
SIGBOOST_EVENT_SYSTEM_RESTART_ACK = 0x88, /*136*/
|
|
||||||
/* Following IDs are ss7boost to sangoma_mgd only. */
|
|
||||||
SIGBOOST_EVENT_HEARTBEAT = 0x89, /*137*/
|
|
||||||
SIGBOOST_EVENT_INSERT_CHECK_LOOP = 0x8a, /*138*/
|
|
||||||
SIGBOOST_EVENT_REMOVE_CHECK_LOOP = 0x8b, /*139*/
|
|
||||||
SIGBOOST_EVENT_AUTO_CALL_GAP_ABATE = 0x8c, /*140*/
|
|
||||||
};
|
|
||||||
enum e_sigboost_release_cause_values
|
|
||||||
{
|
|
||||||
SIGBOOST_RELEASE_CAUSE_UNDEFINED = 0,
|
|
||||||
SIGBOOST_RELEASE_CAUSE_NORMAL = 16,
|
|
||||||
SIGBOOST_RELEASE_CAUSE_BUSY = 17,
|
|
||||||
/* probable elimination */
|
|
||||||
//SIGBOOST_RELEASE_CAUSE_BUSY = 0x91, /* 145 */
|
|
||||||
//SIGBOOST_RELEASE_CAUSE_CALLED_NOT_EXIST = 0x92, /* 146 */
|
|
||||||
//SIGBOOST_RELEASE_CAUSE_CIRCUIT_RESET = 0x93, /* 147 */
|
|
||||||
//SIGBOOST_RELEASE_CAUSE_NOANSWER = 0x94, /* 148 */
|
|
||||||
};
|
|
||||||
|
|
||||||
enum e_sigboost_call_setup_ack_nack_cause_values
|
|
||||||
{
|
|
||||||
SIGBOOST_CALL_SETUP_NACK_ALL_CKTS_BUSY = 117, /* unused Q.850 value */
|
|
||||||
SIGBOOST_CALL_SETUP_NACK_TEST_CKT_BUSY = 118, /* unused Q.850 value */
|
|
||||||
SIGBOOST_CALL_SETUP_NACK_INVALID_NUMBER = 28,
|
|
||||||
/* probable elimination */
|
|
||||||
//SIGBOOST_CALL_SETUP_RESERVED = 0x00,
|
|
||||||
//SIGBOOST_CALL_SETUP_CIRCUIT_RESET = 0x10,
|
|
||||||
//SIGBOOST_CALL_SETUP_NACK_CKT_START_TIMEOUT = 0x11,
|
|
||||||
//SIGBOOST_CALL_SETUP_NACK_AUTO_CALL_GAP = 0x17,
|
|
||||||
};
|
|
||||||
typedef enum {
|
|
||||||
M3UA_SPAN_SIGNALING_M3UA,
|
|
||||||
M3UA_SPAN_SIGNALING_SS7BOX,
|
|
||||||
|
|
||||||
} M3UA_TSpanSignaling;
|
|
||||||
#define M3UA_SPAN_STRINGS "M3UA", "SS7BOX"
|
|
||||||
FTDM_STR2ENUM_P(m3ua_str2span, m3ua_span2str, M3UA_TSpanSignaling)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
FTDM_M3UA_RUNNING = (1 << 0)
|
|
||||||
} ftdm_m3uat_flag_t;
|
|
||||||
|
|
||||||
/*typedef struct m3ua_data {
|
|
||||||
m3uac_connection_t mcon;
|
|
||||||
m3uac_connection_t pcon;
|
|
||||||
fio_signal_cb_t signal_cb;
|
|
||||||
uint32_t flags;
|
|
||||||
} m3ua_data_t;
|
|
||||||
|
|
||||||
*/
|
|
||||||
/*typedef struct mu3a_link {
|
|
||||||
ss7bc_connection_t mcon;
|
|
||||||
ss7bc_connection_t pcon;
|
|
||||||
fio_signal_cb_t signal_cb;
|
|
||||||
uint32_t flags;
|
|
||||||
} ftdm_m3ua_data_t;
|
|
||||||
*/
|
|
||||||
|
|
||||||
ftdm_status_t m3ua_init(ftdm_io_interface_t **zint);
|
|
||||||
ftdm_status_t m3ua_destroy(void);
|
|
||||||
ftdm_status_t m3ua_start(ftdm_span_t *span);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* 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:
|
|
||||||
*/
|
|
||||||
|
|
|
@ -1,62 +0,0 @@
|
||||||
/* WARNING WORK IN PROGRESS
|
|
||||||
* mstm3ua.c
|
|
||||||
* mstss7d port
|
|
||||||
*
|
|
||||||
* Created by Shane Burrell on 2/2/08.
|
|
||||||
* Copyright 2008 Shane Burrell. 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 "mstm3ua.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int build_m3ua_hdr(unsigned char len,unsigned char *bytemsg)
|
|
||||||
|
|
||||||
{
|
|
||||||
|
|
||||||
*bytemsg++ = M_VERSION_REL1; // 1 Verison
|
|
||||||
//bytemsg[1] = 0x00; // 2 RESERVED
|
|
||||||
//bytemsg[2] = M_CLASS_XFER; // 3 Msg Class
|
|
||||||
//SS7 BOX Kludge
|
|
||||||
*bytemsg++ = 0x01; // 2 RESERVED
|
|
||||||
*bytemsg++ = 0x00; // 2 RESERVED
|
|
||||||
|
|
||||||
*bytemsg++ = M_TYPE_DATA ; // 4 Msg Type
|
|
||||||
|
|
||||||
*bytemsg++ = len; // 5 Msg LENGTH 81 32bit field
|
|
||||||
*bytemsg++ = 0x00; // 6
|
|
||||||
*bytemsg++ = 0x00; // 7
|
|
||||||
*bytemsg++ = 0x00; // 8
|
|
||||||
return(0);
|
|
||||||
|
|
||||||
};
|
|
|
@ -1,96 +0,0 @@
|
||||||
/*
|
|
||||||
* mstm3ua.h
|
|
||||||
* mstss7d
|
|
||||||
*
|
|
||||||
* Created by Shane Burrell on 3/2/08.
|
|
||||||
* Copyright 2008 Shane Burrell. 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.
|
|
||||||
*/
|
|
||||||
typedef unsigned long m3ua_ulong;
|
|
||||||
typedef unsigned short m3ua_ushort;
|
|
||||||
typedef unsigned char m3ua_uchar;
|
|
||||||
|
|
||||||
typedef unsigned char u8;
|
|
||||||
typedef unsigned short u16; /* Note: multi-byte values are little-endian */
|
|
||||||
typedef unsigned long u32;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define M_TAG_NETWORK_APPEARANCE 1
|
|
||||||
#define M_TAG_PROTOCOL_DATA 3
|
|
||||||
#define M_TAG_INFO_STRING 4
|
|
||||||
#define M_TAG_AFFECTED_DPC 5
|
|
||||||
#define M_TAG_ROUTING_CONTEXT 6
|
|
||||||
#define M_TAG_DIAGNOSTIC_INFORMATION 7
|
|
||||||
#define M_TAG_HEARTBEAT_DATA 8
|
|
||||||
#define M_TAG_UNAVAILABILITY_CAUSE 9
|
|
||||||
#define M_TAG_REASON 10
|
|
||||||
#define M_TAG_TRAFFIC_MODE_TYPE 11
|
|
||||||
#define M_TAG_ERROR_CODE 12
|
|
||||||
#define M_TAG_STATUS_TYPE 13
|
|
||||||
#define M_TAG_CONGESTED_INDICATIONS 14
|
|
||||||
|
|
||||||
#define M_VERSION_REL1 1
|
|
||||||
|
|
||||||
#define M_CLASS_MGMT 0x00
|
|
||||||
#define M_CLASS_XFER 0x01
|
|
||||||
#define M_CLASS_SSNM 0x02
|
|
||||||
#define M_CLASS_ASPSM 0x03
|
|
||||||
#define M_CLASS_ASPTM 0x04
|
|
||||||
#define M_CLASS_RKM 0x09
|
|
||||||
|
|
||||||
#define M_TYPE_ERR (0|M_CLASS_MGMT
|
|
||||||
|
|
||||||
#define M_TYPE_NTFY (1|M_CLASS_XFER)
|
|
||||||
#define M_TYPE_DATA (1|M_CLASS_XFER)
|
|
||||||
|
|
||||||
#define M_TYPE_DUNA (1|M_CLASS_SSNM)
|
|
||||||
#define M_TYPE_DAVA (2|M_CLASS_SSNM)
|
|
||||||
#define M_TYPE_DUAD (3|M_CLASS_SSNM)
|
|
||||||
#define M_TYPE_SCON (4|M_CLASS_SSNM)
|
|
||||||
#define M_TYPE_DUPU (5|M_CLASS_SSNM)
|
|
||||||
|
|
||||||
#define M_TYPE_UP (1|M_CLASS_ASPSM)
|
|
||||||
#define M_TYPE_DOWN (2|M_CLASS_ASPSM)
|
|
||||||
#define M_TYPE_BEAT (3|M_CLASS_ASPSM)
|
|
||||||
#define M_TYPE_UP_ACK (4|M_CLASS_ASPSM)
|
|
||||||
#define M_TYPE_DOWN_ACK (5|M_CLASS_ASPSM)
|
|
||||||
#define M_TYPE_BEAT_ACK (6|M_CLASS_ASPSM)
|
|
||||||
|
|
||||||
#define M_TYPE_ACTIVE (1|M_CLASS_ASPTM)
|
|
||||||
#define M_TYPE_INACTIVE (2|M_CLASS_ASPTM)
|
|
||||||
#define M_TYPE_ACTIVE_ACK (3|M_CLASS_ASPTM)
|
|
||||||
#define M_TYPE_INACTIVE_ACK (4|M_CLASS_ASPTM)
|
|
||||||
|
|
||||||
#define M_CLASS_MASK 0xff00
|
|
||||||
#define M_TYPE_MASK 0x00ff
|
|
||||||
|
|
|
@ -1,333 +0,0 @@
|
||||||
/*
|
|
||||||
* m3ua_client.c
|
|
||||||
* freetdm
|
|
||||||
*
|
|
||||||
* Created by Shane Burrell on 4/3/08.
|
|
||||||
* Copyright 2008 Shane Burrell. All rights reserved.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Copyright (c) 2007, Anthony Minessale II, Nenad Corbic
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if HAVE_NETDB_H
|
|
||||||
#include <netdb.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "freetdm.h"
|
|
||||||
#include <m3ua_client.h>
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef HAVE_GETHOSTBYNAME_R
|
|
||||||
extern int gethostbyname_r (const char *__name,
|
|
||||||
struct hostent *__result_buf,
|
|
||||||
char *__buf, size_t __buflen,
|
|
||||||
struct hostent **__result,
|
|
||||||
int *__h_errnop);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct m3uac_map {
|
|
||||||
uint32_t event_id;
|
|
||||||
const char *name;
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct m3uac_map m3uac_table[] = {
|
|
||||||
{M3UA_EVENT_CALL_START, "CALL_START"},
|
|
||||||
{M3UA_EVENT_CALL_START_ACK, "CALL_START_ACK"},
|
|
||||||
{M3UA_EVENT_CALL_START_NACK, "CALL_START_NACK"},
|
|
||||||
{M3UA_EVENT_CALL_START_NACK_ACK, "CALL_START_NACK_ACK"},
|
|
||||||
{M3UA_EVENT_CALL_ANSWERED, "CALL_ANSWERED"},
|
|
||||||
{M3UA_EVENT_CALL_STOPPED, "CALL_STOPPED"},
|
|
||||||
{M3UA_EVENT_CALL_STOPPED_ACK, "CALL_STOPPED_ACK"},
|
|
||||||
{M3UA_EVENT_SYSTEM_RESTART, "SYSTEM_RESTART"},
|
|
||||||
{M3UA_EVENT_SYSTEM_RESTART_ACK, "SYSTEM_RESTART_ACK"},
|
|
||||||
{M3UA_EVENT_HEARTBEAT, "HEARTBEAT"},
|
|
||||||
{M3UA_EVENT_INSERT_CHECK_LOOP, "LOOP START"},
|
|
||||||
{M3UA_EVENT_REMOVE_CHECK_LOOP, "LOOP STOP"}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int create_conn_socket(m3uac_connection_t *mcon, char *local_ip, int local_port, char *ip, int port)
|
|
||||||
{
|
|
||||||
int rc;
|
|
||||||
struct hostent *result, *local_result;
|
|
||||||
char buf[512], local_buf[512];
|
|
||||||
int err = 0;
|
|
||||||
|
|
||||||
memset(&mcon->remote_hp, 0, sizeof(mcon->remote_hp));
|
|
||||||
memset(&mcon->local_hp, 0, sizeof(mcon->local_hp));
|
|
||||||
mcon->socket = socket(AF_INET, SOCK_SEQPACKET, IPPROTO_SCTP);
|
|
||||||
|
|
||||||
ftdm_log(FTDM_LOG_DEBUG, "Creating L=%s:%d R=%s:%d\n",
|
|
||||||
local_ip,local_port,ip,port);
|
|
||||||
|
|
||||||
if (mcon->socket >= 0) {
|
|
||||||
int flag;
|
|
||||||
|
|
||||||
flag = 1;
|
|
||||||
gethostbyname_r(ip, &mcon->remote_hp, buf, sizeof(buf), &result, &err);
|
|
||||||
gethostbyname_r(local_ip, &mcon->local_hp, local_buf, sizeof(local_buf), &local_result, &err);
|
|
||||||
if (result && local_result) {
|
|
||||||
mcon->remote_addr.sin_family = mcon->remote_hp.h_addrtype;
|
|
||||||
memcpy((char *) &mcon->remote_addr.sin_addr.s_addr, mcon->remote_hp.h_addr_list[0], mcon->remote_hp.h_length);
|
|
||||||
mcon->remote_addr.sin_port = htons(port);
|
|
||||||
|
|
||||||
mcon->local_addr.sin_family = mcon->local_hp.h_addrtype;
|
|
||||||
memcpy((char *) &mcon->local_addr.sin_addr.s_addr, mcon->local_hp.h_addr_list[0], mcon->local_hp.h_length);
|
|
||||||
mcon->local_addr.sin_port = htons(local_port);
|
|
||||||
|
|
||||||
|
|
||||||
setsockopt(mcon->socket, IPPROTO_SCTP, SCTP_NODELAY, (char *)&flag, sizeof(int));
|
|
||||||
|
|
||||||
rc=listen(mcon->socket,100);
|
|
||||||
if (rc) {
|
|
||||||
close(mcon->socket);
|
|
||||||
mcon->socket = -1;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ftdm_mutex_create(&mcon->mutex);
|
|
||||||
|
|
||||||
return mcon->socket;
|
|
||||||
}
|
|
||||||
|
|
||||||
int m3uac_connection_close(m3uac_connection_t *mcon)
|
|
||||||
{
|
|
||||||
if (mcon->socket > -1) {
|
|
||||||
close(mcon->socket);
|
|
||||||
}
|
|
||||||
|
|
||||||
ftdm_mutex_lock(mcon->mutex);
|
|
||||||
ftdm_mutex_unlock(mcon->mutex);
|
|
||||||
ftdm_mutex_destroy(&mcon->mutex);
|
|
||||||
memset(mcon, 0, sizeof(*mcon));
|
|
||||||
mcon->socket = -1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int m3uac_connection_open(m3uac_connection_t *mcon, char *local_ip, int local_port, char *ip, int port)
|
|
||||||
{
|
|
||||||
create_conn_socket(mcon, local_ip, local_port, ip, port);
|
|
||||||
return mcon->socket;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int m3uac_exec_command(m3uac_connection_t *mcon, int span, int chan, int id, int cmd, int cause)
|
|
||||||
{
|
|
||||||
m3uac_event_t oevent;
|
|
||||||
int retry = 5;
|
|
||||||
|
|
||||||
m3uac_event_init(&oevent, cmd, chan, span);
|
|
||||||
oevent.release_cause = cause;
|
|
||||||
|
|
||||||
if (cmd == SIGBOOST_EVENT_SYSTEM_RESTART) {
|
|
||||||
mcon->rxseq_reset = 1;
|
|
||||||
mcon->txseq = 0;
|
|
||||||
mcon->rxseq = 0;
|
|
||||||
mcon->txwindow = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (id >= 0) {
|
|
||||||
oevent.call_setup_id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (m3uac_connection_write(mcon, &oevent) <= 0) {
|
|
||||||
if (--retry <= 0) {
|
|
||||||
ftdm_log(FTDM_LOG_CRIT, "Failed to tx on M3UA socket: %s\n", strerror(errno));
|
|
||||||
return -1;
|
|
||||||
} else {
|
|
||||||
ftdm_log(FTDM_LOG_WARNING, "Failed to tx on M3UA socket: %s :retry %i\n", strerror(errno), retry);
|
|
||||||
ftdm_sleep(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
m3uac_event_t *m3uac_connection_read(m3uac_connection_t *mcon, int iteration)
|
|
||||||
{
|
|
||||||
unsigned int fromlen = sizeof(struct sockaddr_in);
|
|
||||||
int bytes = 0;
|
|
||||||
|
|
||||||
bytes = recvfrom(mcon->socket, &mcon->event, sizeof(mcon->event), MSG_DONTWAIT,
|
|
||||||
(struct sockaddr *) &mcon->local_addr, &fromlen);
|
|
||||||
|
|
||||||
if (bytes == sizeof(mcon->event) || bytes == (sizeof(mcon->event)-sizeof(uint32_t))) {
|
|
||||||
|
|
||||||
if (mcon->rxseq_reset) {
|
|
||||||
if (mcon->event.event_id == SIGBOOST_EVENT_SYSTEM_RESTART_ACK) {
|
|
||||||
ftdm_log(FTDM_LOG_DEBUG, "Rx sync ok\n");
|
|
||||||
mcon->rxseq = mcon->event.fseqno;
|
|
||||||
return &mcon->event;
|
|
||||||
}
|
|
||||||
errno=EAGAIN;
|
|
||||||
ftdm_log(FTDM_LOG_DEBUG, "Waiting for rx sync...\n");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
mcon->txwindow = mcon->txseq - mcon->event.bseqno;
|
|
||||||
mcon->rxseq++;
|
|
||||||
|
|
||||||
if (mcon->rxseq != mcon->event.fseqno) {
|
|
||||||
ftdm_log(FTDM_LOG_CRIT, "Invalid Sequence Number Expect=%i Rx=%i\n", mcon->rxseq, mcon->event.fseqno);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return &mcon->event;
|
|
||||||
} else {
|
|
||||||
if (iteration == 0) {
|
|
||||||
ftdm_log(FTDM_LOG_CRIT, "Invalid Event length from boost rxlen=%i evsz=%i\n", bytes, sizeof(mcon->event));
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
m3uac_event_t *m3uac_connection_readp(m3uac_connection_t *mcon, int iteration)
|
|
||||||
{
|
|
||||||
unsigned int fromlen = sizeof(struct sockaddr_in);
|
|
||||||
int bytes = 0;
|
|
||||||
|
|
||||||
bytes = recvfrom(mcon->socket, &mcon->event, sizeof(mcon->event), MSG_DONTWAIT, (struct sockaddr *) &mcon->local_addr, &fromlen);
|
|
||||||
|
|
||||||
if (bytes == sizeof(mcon->event) || bytes == (sizeof(mcon->event)-sizeof(uint32_t))) {
|
|
||||||
return &mcon->event;
|
|
||||||
} else {
|
|
||||||
if (iteration == 0) {
|
|
||||||
ftdm_log(FTDM_LOG_CRIT, "Critical Error: PQ Invalid Event lenght from boost rxlen=%i evsz=%i\n", bytes, sizeof(mcon->event));
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int m3uac_connection_write(m3uac_connection_t *mcon, ss7bc_event_t *event)
|
|
||||||
{
|
|
||||||
int err;
|
|
||||||
|
|
||||||
if (!event || mcon->socket < 0 || !mcon->mutex) {
|
|
||||||
ftdm_log(FTDM_LOG_DEBUG, "Critical Error: No Event Device\n");
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event->span > 16 || event->chan > 31) {
|
|
||||||
ftdm_log(FTDM_LOG_CRIT, "Critical Error: TX Cmd=%s Invalid Span=%i Chan=%i\n", m3uac_event_id_name(event->event_id), event->span,event->chan);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
gettimeofday(&event->tv,NULL);
|
|
||||||
|
|
||||||
ftdm_mutex_lock(mcon->mutex);
|
|
||||||
event->fseqno = mcon->txseq++;
|
|
||||||
event->bseqno = mcon->rxseq;
|
|
||||||
err = sendto(mcon->socket, event, sizeof(m3uac_event_t), 0, (struct sockaddr *) &mcon->remote_addr, sizeof(mcon->remote_addr));
|
|
||||||
ftdm_mutex_unlock(mcon->mutex);
|
|
||||||
|
|
||||||
if (err != sizeof(m3uac_event_t)) {
|
|
||||||
err = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ftdm_log(FTDM_LOG_DEBUG, "TX EVENT: %s:(%X) [w%dg%d] Rc=%i CSid=%i Seq=%i Cd=[%s] Ci=[%s]\n",
|
|
||||||
m3uac_event_id_name(event->event_id),
|
|
||||||
event->event_id,
|
|
||||||
event->span+1,
|
|
||||||
event->chan+1,
|
|
||||||
event->release_cause,
|
|
||||||
event->call_setup_id,
|
|
||||||
event->fseqno,
|
|
||||||
(event->called_number_digits_count ? (char *) event->called_number_digits : "N/A"),
|
|
||||||
(event->calling_number_digits_count ? (char *) event->calling_number_digits : "N/A")
|
|
||||||
);
|
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
void m3uac_call_init(m3uac_event_t *event, const char *calling, const char *called, int setup_id)
|
|
||||||
{
|
|
||||||
memset(event, 0, sizeof(m3uac_event_t));
|
|
||||||
event->event_id = M3UA_EVENT_CALL_START;
|
|
||||||
|
|
||||||
if (calling) {
|
|
||||||
strncpy((char*)event->calling_number_digits, calling, sizeof(event->calling_number_digits)-1);
|
|
||||||
event->calling_number_digits_count = strlen(calling);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (called) {
|
|
||||||
strncpy((char*)event->called_number_digits, called, sizeof(event->called_number_digits)-1);
|
|
||||||
event->called_number_digits_count = strlen(called);
|
|
||||||
}
|
|
||||||
|
|
||||||
event->call_setup_id = setup_id;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void m3uac_event_init(m3uac_event_t *event, m3uac_event_id_t event_id, int chan, int span)
|
|
||||||
{
|
|
||||||
memset(event, 0, sizeof(ss7bc_event_t));
|
|
||||||
event->event_id = event_id;
|
|
||||||
event->chan = chan;
|
|
||||||
event->span = span;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *m3uac_event_id_name(uint32_t event_id)
|
|
||||||
{
|
|
||||||
unsigned int x;
|
|
||||||
const char *ret = NULL;
|
|
||||||
|
|
||||||
for (x = 0 ; x < sizeof(m3uac_table)/sizeof(struct m3uac_map); x++) {
|
|
||||||
if (m3uac_table[x].event_id == event_id) {
|
|
||||||
ret = m3uac_table[x].name;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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:
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
|
@ -1,164 +0,0 @@
|
||||||
/*
|
|
||||||
* m3ua_client.h
|
|
||||||
* freetdm
|
|
||||||
*
|
|
||||||
* Created by Shane Burrell on 4/3/08.
|
|
||||||
* Copyright 2008 Shane Burrell. All rights reserved.
|
|
||||||
*
|
|
||||||
* Copyright (c) 2007, Anthony Minessale II, Nenad Corbic
|
|
||||||
*
|
|
||||||
* 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 <ctype.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
|
|
||||||
// Fix this for portability
|
|
||||||
#include <sctp.h>
|
|
||||||
//#include <netinet/sctp.h>
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <netdb.h>
|
|
||||||
//#include <sigboost.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
|
|
||||||
#define MAX_DIALED_DIGITS 31
|
|
||||||
#define MAX_CALLING_NAME 31
|
|
||||||
|
|
||||||
/* Next two defines are used to create the range of values for call_setup_id
|
|
||||||
* in the t_sigboost structure.
|
|
||||||
* 0..((CORE_MAX_SPANS * CORE_MAX_CHAN_PER_SPAN) - 1) */
|
|
||||||
#define CORE_MAX_SPANS 200
|
|
||||||
#define CORE_MAX_CHAN_PER_SPAN 30
|
|
||||||
#define MAX_PENDING_CALLS CORE_MAX_SPANS * CORE_MAX_CHAN_PER_SPAN
|
|
||||||
/* 0..(MAX_PENDING_CALLS-1) is range of call_setup_id below */
|
|
||||||
#define SIZE_RDNIS 80
|
|
||||||
|
|
||||||
//#undef MSGWINDOW
|
|
||||||
#define MSGWINDOW
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
uint32_t event_id;
|
|
||||||
uint32_t fseqno;
|
|
||||||
#ifdef MSGWINDOW
|
|
||||||
uint32_t bseqno;
|
|
||||||
#endif
|
|
||||||
uint16_t call_setup_id;
|
|
||||||
uint32_t trunk_group;
|
|
||||||
uint32_t span;
|
|
||||||
uint32_t chan;
|
|
||||||
uint8_t called_number_digits_count;
|
|
||||||
char called_number_digits [MAX_DIALED_DIGITS + 1]; /* it's a null terminated string */
|
|
||||||
uint8_t calling_number_digits_count; /* it's an array */
|
|
||||||
char calling_number_digits [MAX_DIALED_DIGITS + 1]; /* it's a null terminated string */
|
|
||||||
uint8_t release_cause;
|
|
||||||
struct timeval tv;
|
|
||||||
/* ref. Q.931 Table 4-11 and Q.951 Section 3 */
|
|
||||||
uint8_t calling_number_screening_ind;
|
|
||||||
uint8_t calling_number_presentation;
|
|
||||||
char redirection_string [SIZE_RDNIS]; /* it's a null terminated string */
|
|
||||||
|
|
||||||
} t_m3ua;
|
|
||||||
|
|
||||||
typedef t_m3ua m3uac_event_t;
|
|
||||||
typedef uint32_t m3uac_event_id_t;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct m3uac_ip_cfg
|
|
||||||
{
|
|
||||||
char local_ip[25];
|
|
||||||
int local_port;
|
|
||||||
char remote_ip[25];
|
|
||||||
int remote_port;
|
|
||||||
}m3uac_ip_cfg_t;
|
|
||||||
|
|
||||||
struct m3uac_connection {
|
|
||||||
ftdm_socket_t socket;
|
|
||||||
struct sockaddr_in local_addr;
|
|
||||||
struct sockaddr_in remote_addr;
|
|
||||||
m3uac_event_t event;
|
|
||||||
struct hostent remote_hp;
|
|
||||||
struct hostent local_hp;
|
|
||||||
unsigned int flags;
|
|
||||||
ftdm_mutex_t *mutex;
|
|
||||||
FILE *log;
|
|
||||||
unsigned int txseq;
|
|
||||||
unsigned int rxseq;
|
|
||||||
unsigned int txwindow;
|
|
||||||
unsigned int rxseq_reset;
|
|
||||||
m3uac_ip_cfg_t cfg;
|
|
||||||
uint32_t hb_elapsed;
|
|
||||||
int up;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
MSU_FLAG_EVENT = (1 << 0)
|
|
||||||
} m3uac_flag_t;
|
|
||||||
|
|
||||||
typedef struct m3uac_connection m3uac_connection_t;
|
|
||||||
|
|
||||||
static inline void sctp_no_nagle(int socket)
|
|
||||||
{
|
|
||||||
//int flag = 1;
|
|
||||||
//setsockopt(socket, IPPROTO_SCTP, SCTP_NODELAY, (char *) &flag, sizeof(int));
|
|
||||||
}
|
|
||||||
|
|
||||||
int m3uac_connection_close(m3uac_connection_t *mcon);
|
|
||||||
int m3uac_connection_open(m3uac_connection_t *mcon, char *local_ip, int local_port, char *ip, int port);
|
|
||||||
m3uac_event_t *m3uac_connection_read(m3uac_connection_t *mcon, int iteration);
|
|
||||||
m3uac_event_t *m3uac_connection_readp(m3uac_connection_t *mcon, int iteration);
|
|
||||||
int m3uac_connection_write(m3uac_connection_t *mcon, m3uac_event_t *event);
|
|
||||||
void m3uac_event_init(m3uac_event_t *event, m3uac_event_id_t event_id, int chan, int span);
|
|
||||||
void m3uac_call_init(m3uac_event_t *event, const char *calling, const char *called, int setup_id);
|
|
||||||
const char *m3uac_event_id_name(uint32_t event_id);
|
|
||||||
int m3uac_exec_command(m3uac_connection_t *mcon, int span, int chan, int id, int cmd, int cause);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* 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:
|
|
||||||
*/
|
|
|
@ -1,60 +0,0 @@
|
||||||
/*
|
|
||||||
* testm3ua.c
|
|
||||||
* freetdm
|
|
||||||
*
|
|
||||||
* Created by Shane Burrell on 4/8/08.
|
|
||||||
* Copyright 2008 __MyCompanyName__. All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "testm3ua.h"
|
|
||||||
#include "freetdm.h"
|
|
||||||
#include "ftdm_m3ua.h"
|
|
||||||
|
|
||||||
static FIO_SIGNAL_CB_FUNCTION(on_signal)
|
|
||||||
{
|
|
||||||
return FTDM_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
ftdm_span_t *span;
|
|
||||||
//m3ua_data_t *data;
|
|
||||||
|
|
||||||
ftdm_global_set_default_logger(FTDM_LOG_LEVEL_DEBUG);
|
|
||||||
|
|
||||||
if (argc < 5) {
|
|
||||||
printf("more args needed\n");
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ftdm_global_init() != FTDM_SUCCESS) {
|
|
||||||
fprintf(stderr, "Error loading FreeTDM\n");
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("FreeTDM loaded\n");
|
|
||||||
|
|
||||||
if (ftdm_span_find(atoi(argv[1]), &span) != FTDM_SUCCESS) {
|
|
||||||
fprintf(stderr, "Error finding FreeTDM span\n");
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (ftdm_m3ua_configure_span(span) == FTDM_SUCCESS) {
|
|
||||||
//data = span->signal_data;
|
|
||||||
ftdm_m3ua_start(span);
|
|
||||||
} else {
|
|
||||||
fprintf(stderr, "Error starting M3UA\n");
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
//while(ftdm_test_flag(data, FTDM_M3UA_RUNNING)) {
|
|
||||||
// ftdm_sleep(1 * 1000);
|
|
||||||
//}
|
|
||||||
|
|
||||||
done:
|
|
||||||
|
|
||||||
ftdm_global_destroy();
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue