mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-13 17:38:59 +00:00
initial addition of ss7boost client code
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@392 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
104
libs/freetdm/src/include/sigboost.h
Normal file
104
libs/freetdm/src/include/sigboost.h
Normal file
@@ -0,0 +1,104 @@
|
||||
/****************************************************************************
|
||||
* sigboost.h $Revision: 1.3 $
|
||||
*
|
||||
* Definitions for the sigboost interface.
|
||||
*
|
||||
* WARNING WARNING WARNING
|
||||
*
|
||||
* This file is used by sangoma_mgd and perhaps other programs. Any changes
|
||||
* to this file must be coordinated with other user programs,
|
||||
*
|
||||
* Copyright (C) 2005 Xygnada Technology, Inc.
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef _SIGBOOST_H_
|
||||
#define _SIGBOOST_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
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,
|
||||
};
|
||||
|
||||
#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
|
||||
|
||||
#pragma pack(1)
|
||||
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 */
|
||||
/* redir string format:
|
||||
* http://www.ss7box.com/wiki/tiki-index.php?page=Call+Redirection
|
||||
* */
|
||||
} t_sigboost;
|
||||
#pragma pack()
|
||||
|
||||
#endif
|
137
libs/freetdm/src/include/ss7_boost_client.h
Normal file
137
libs/freetdm/src/include/ss7_boost_client.h
Normal file
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Copyright (c) 2007, Anthony Minessale II, Nenad Corbic
|
||||
* 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 _SS7BC_H
|
||||
#define _SS7BC_H
|
||||
|
||||
#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>
|
||||
#include <netinet/sctp.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <stdarg.h>
|
||||
#include <netdb.h>
|
||||
#include <sigboost.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
|
||||
|
||||
|
||||
#define ss7bc_test_flag(p,flag) ({ \
|
||||
((p)->flags & (flag)); \
|
||||
})
|
||||
|
||||
#define ss7bc_set_flag(p,flag) do { \
|
||||
((p)->flags |= (flag)); \
|
||||
} while (0)
|
||||
|
||||
#define ss7bc_clear_flag(p,flag) do { \
|
||||
((p)->flags &= ~(flag)); \
|
||||
} while (0)
|
||||
|
||||
#define ss7bc_copy_flags(dest,src,flagz) do { \
|
||||
(dest)->flags &= ~(flagz); \
|
||||
(dest)->flags |= ((src)->flags & (flagz)); \
|
||||
} while (0)
|
||||
|
||||
typedef t_sigboost ss7bc_event_t;
|
||||
typedef uint32_t ss7bc_event_id_t;
|
||||
|
||||
typedef struct smg_ip_cfg
|
||||
{
|
||||
char local_ip[25];
|
||||
int local_port;
|
||||
char remote_ip[25];
|
||||
int remote_port;
|
||||
}smg_ip_cfg_t;
|
||||
|
||||
struct ss7bc_connection {
|
||||
zap_socket_t socket;
|
||||
struct sockaddr_in local_addr;
|
||||
struct sockaddr_in remote_addr;
|
||||
ss7bc_event_t event;
|
||||
struct hostent remote_hp;
|
||||
struct hostent local_hp;
|
||||
unsigned int flags;
|
||||
pthread_mutex_t lock;
|
||||
FILE *log;
|
||||
unsigned int txseq;
|
||||
unsigned int rxseq;
|
||||
unsigned int txwindow;
|
||||
unsigned int rxseq_reset;
|
||||
smg_ip_cfg_t cfg;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
MSU_FLAG_EVENT = (1 << 0)
|
||||
} ss7bc_flag_t;
|
||||
|
||||
typedef struct ss7bc_connection ss7bc_connection_t;
|
||||
|
||||
/* disable nagle's algorythm */
|
||||
static inline void sctp_no_nagle(int socket)
|
||||
{
|
||||
int flag = 1;
|
||||
setsockopt(socket, IPPROTO_SCTP, SCTP_NODELAY, (char *) &flag, sizeof(int));
|
||||
}
|
||||
|
||||
int ss7bc_connection_close(ss7bc_connection_t *mcon);
|
||||
int ss7bc_connection_open(ss7bc_connection_t *mcon, char *local_ip, int local_port, char *ip, int port);
|
||||
ss7bc_event_t *ss7bc_connection_read(ss7bc_connection_t *mcon, int iteration);
|
||||
ss7bc_event_t *ss7bc_connection_readp(ss7bc_connection_t *mcon, int iteration);
|
||||
int ss7bc_connection_write(ss7bc_connection_t *mcon, ss7bc_event_t *event);
|
||||
void ss7bc_event_init(ss7bc_event_t *event, ss7bc_event_id_t event_id, int chan, int span);
|
||||
void ss7bc_call_init(ss7bc_event_t *event, char *calling, char *called, int setup_id);
|
||||
char *ss7bc_event_id_name(uint32_t event_id);
|
||||
|
||||
#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 expandtab:
|
||||
*/
|
Reference in New Issue
Block a user