/* l4isup.c - ISUP protocol
*
* Copyright (C) 2006, Sifira A/S.
*
* Author: Anders Baekgaard <ab@sifira.dk>
* Anders Baekgaard <ab@dicea.dk>
* Based on work by: Kristian Nielsen <kn@sifira.dk>,
*
* This file is part of chan_ss7.
*
* chan_ss7 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* chan_ss7 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with chan_ss7; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <time.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <unistd.h>
#include <fcntl.h>
#include <netdb.h>
#include <netinet/in.h>
#include <pthread.h>
#include <signal.h>
#include <sys/poll.h>
#include <sys/ioctl.h>
#include "asterisk/logger.h"
#include "asterisk/options.h"
#include "asterisk/channel.h"
#include "asterisk/frame.h"
#include "asterisk/utils.h"
#include "asterisk/sched.h"
#include "asterisk/cli.h"
#include "asterisk/lock.h"
#include "asterisk/causes.h"
#include "asterisk/pbx.h"
#include "asterisk/dsp.h"
#include "asterisk/callerid.h"
#include "asterisk/indications.h"
#include "asterisk/module.h"
#include "zaptel.h"
#include "astversion.h"
#include "config.h"
#include "lffifo.h"
#include "utils.h"
#include "mtp.h"
#include "transport.h"
#include "isup.h"
#include "l4isup.h"
#include "cluster.h"
#include "mtp3io.h"
#ifdef MODULETEST
#include "moduletest.h"
#endif
enum circuit_states {
/* Circuit idle, ready to accept or initiate calls. */
ST_IDLE,
/* An IAM has been received, but no ACM or CON has been sent back yet. */
ST_GOT_IAM,
/* An IAM has been sent to initiate a call, but no ACM or CON has been
received back yet. */
ST_SENT_IAM,
/* We have sent an ACM and have to send an ANM now */
ST_SENT_ACM,
/* We have sent IAM and received ACM, so waiting for ANM. */
ST_GOT_ACM,
/* A call is connected (incoming or outgoing). */
ST_CONNECTED,
/* A continuity check is ongoing */
ST_CONCHECK,
/* A REL message has been received, but RLC has not been sent
yet. ast_softhangup() has been called on the channel.*/
ST_GOT_REL,
/* A REL has been sent (from ss7_hangup), and so the struct ast_channel *
has been deallocated, but the circuit is still waiting for RLC to be
received before being able to initiate new calls. If timer T16 or T17
is running, this state instead means that a "circuit reset" has been
sent, and we are waiting for RLC. If a REL is received in this state,
send RLC and stay in this state, still waiting for RLC */
ST_SENT_REL,
};
struct ss7_chan {
/* The first few fields of this struct are protected by the global lock
mutex, not by the ss7_chan->lock mutex embedded in the struct. This is
necessary to preserve locking order and avoid deadlocks. */
struct ast_channel *owner;
struct ss7_chan *next_idle; /* Linked list of idle CICs */
struct link* link; /* Link carrying circuit */
int cic;
int reset_done; /* False until circuit has been init reset */
int hangupcause;
int dohangup;
int has_inband_ind;
/* Circuit blocking status: {local,remote} {maintenance,hardware}. */
enum { BL_LM=1, BL_LH=2, BL_RM=4, BL_RH=8, BL_UNEQUIPPED=0x10, BL_LINKDOWN=0x20 } blocked;
/* Circuit equipped */
int equipped;
ast_mutex_t lock; /* Protects rest of this struct */
enum circuit_states state;
int zaptel_fd;
int t1;
int t2;
int t5;
int t6;
int t7;
int t9;
int t16;
int t17;
int t18;
int t19;
int t20;
int t21;
int t22;
int t23;
int t35;
int t36;
struct iam iam; /* Last incoming IAM parameters */
char* addr; /* called addr */
int attempts; /* Number of outgoing call attempts on addr */
int echocan_start;
int echocancel;
struct timeval lastread;
unsigned char buffer[AST_FRIENDLY_OFFSET + AUDIO_READSIZE];
struct ast_frame frame;
int sending_dtmf;
struct ast_dsp *dsp;
int grs_count; /* Count of CICs in ISUP GRS message */
int cgb_mask; /* Mask of CICs in ISUP CGB message */
char context[AST_MAX_CONTEXT];
char language[MAX_LANGUAGE];
};
/* Locking order (deadlock avoidance): global lock, chan->lock, pvt->lock
*/
/* Global list of idle CICs, sorted in order of "time free". Linked through
the ss7_chan->next_idle pointers. Protected by global lock. */
static struct timeval now;
static struct timeval mtp_fifo_full_report;
/* used by moduletest.c */
int isup_called_party_num_encode(char *number, unsigned char *param, int plen);
int isup_called_party_num_encode_no_st(char *number, unsigned char *param, int plen);
int isup_calling_party_num_encode(char *number, int pres_restr, unsigned char *param, int plen);
static pthread_t continuity_check_thread = AST_PTHREADT_NULL;
static int continuity_check_thread_running = 0;
AST_MUTEX_DEFINE_STATIC(continuity_check_lock);
static int continuity_check_changes = 0;
static int must_stop_continuity_check_thread = 0;
static struct ss7_chan dummy_pvt;
static void isup_send_grs(struct ss7_chan *pvt, int count, int do_timers);
static struct ast_channel *ss7_requester(const char *type, int format,
void *data, int *cause);
static int ss7_send_digit_begin(struct ast_channel *chan, char digit);
static int ss7_send_digit_end(struct ast_channel *chan, char digit, unsigned int duration);
static int ss7_call(struct ast_channel *chan, char *addr, int timeout);
static int ss7_hangup(struct ast_channel *chan);
static int ss7_answer(struct ast_channel *chan);
static struct ast_frame *ss7_read(struct ast_channel * chan);
static int ss7_write(struct ast_channel * chan, struct ast_frame *frame);
static struct ast_frame *ss7_exception(struct ast_channel *chan);
static int ss7_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
#ifdef USE_ASTERISK_1_2
static int ss7_indicate(struct ast_channel *chan, int condition);
#else
static int ss7_indicate(struct ast_channel *chan, int condition, const void* data, size_t datalen);
#endif
static void t7_clear(struct ss7_chan *pvt);
static void t1_start(struct ss7_chan *pvt);
static void t5_start(struct ss7_chan *pvt);
static void t16_start(struct ss7_chan *pvt);
static void t16_clear(struct ss7_chan *pvt);
static void t17_start(struct ss7_chan *pvt);
static void t19_start(struct ss7_chan *pvt);
static void t21_start(struct ss7_chan *pvt);
static int do_group_circuit_block_unblock(struct linkset* linkset, int firstcic, unsigned long cgb_mask, int sup_type_ind, int own_cics_only, int do_timers, int do_block);
static struct ss7_chan* reattempt_call(struct ss7_chan *pvt);
static void *continuity_check_thread_main(void *data);
static void handle_complete_address(struct ss7_chan *pvt);
static const char type[] = "SS7";
static const char tdesc[] = "SS7 Protocol Driver";
static const struct ast_channel_tech ss7_tech = {
.type = type,
.description = tdesc,
.capabilities = AST_FORMAT_ALAW,
.requester = ss7_requester,
#ifdef USE_ASTERISK_1_2
.send_digit = ss7_send_digit_begin,
#else
.send_digit_begin = ss7_send_digit_begin,
.send_digit_end = ss7_send_digit_end,
#endif
.call = ss7_call,
.hangup = ss7_hangup,
.answer = ss7_answer,
.read = ss7_read,
.write = ss7_write,
.exception = ss7_exception,
.fixup = ss7_fixup,
.indicate = ss7_indicate,
};
/* Send fifo for sending protocol requests to the MTP thread.
The fifo is lock-free (one thread may put and another g
没有合适的资源?快使用搜索试试~ 我知道了~
chan_ss7-1.0.0.tar.gz_asterisk_chan_ss7_ss7
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 152 浏览量
2022-09-22
18:10:37
上传
评论 1
收藏 115KB GZ 举报
温馨提示
共37个文件
c:13个
h:11个
conf:1个
asterisk 的7号信令处理模块,生成的SO直接就可调用
资源推荐
资源详情
资源评论
收起资源包目录
chan_ss7-1.0.0.tar.gz (37个子文件)
chan_ss7-1.0.0
config.h 4KB
mtp3io.c 6KB
aststubs.c 10KB
transport.c 10KB
ss7.conf.template.two-links 384B
mtp.h 4KB
mtp3d.rc 2KB
mtp3io.h 1KB
aststubs.h 3KB
safe_mtp3d 2KB
astversion.h 1KB
cluster.c 31KB
mtp3d.c 21KB
asterisk_safe 6KB
l4isup.h 1KB
ss7.conf 2KB
cluster.h 1KB
transport.h 2KB
README 4KB
isup.c 28KB
astconfig.c 36KB
INSTALL 1KB
utils.c 4KB
lffifo.c 6KB
isup.h 9KB
ss7.conf.template.two-hosts 1KB
utils.h 2KB
Makefile 4KB
l4isup.c 129KB
config.c 33KB
ss7.conf.template.single-link 2KB
NEWS 819B
chan_ss7.c 25KB
ss7.conf.template.two-linksets 737B
COPYING 18KB
mtp.c 68KB
lffifo.h 2KB
共 37 条
- 1
资源评论
刘良运
- 粉丝: 66
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功