📄 test-q784.c
字号:
/***************************************************************************** @(#) test-q784.c,v strss7-0_9a_4(0.9.2.7) 2006/03/07 01:16:08 ----------------------------------------------------------------------------- Copyright (c) 2001-2006 OpenSS7 Corporation <http://www.openss7.com/> Copyright (c) 1997-2000 Brian F. G. Bidulock <bidulock@openss7.org> All Rights Reserved. Unauthorized distribution or duplication is prohibited.//CHECK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! This software and related documentation is protected by copyright and distributed under licenses restricting its use, copying, distribution and decompilation. No part of this software or related documentation may be reproduced in any form by any means without the prior written authorization of the copyright holder, and licensors, if any. The recipient of this document, by its retention and use, warrants that the recipient will protect this information and keep it confidential, and will not disclose the information contained in this document without the written permission of its owner. The author reserves the right to revise this software and documentation for any reason, including but not limited to, conformity with standards promulgated by various agencies, utilization of advances in the state of the technical arts, or the reflection of changes in the design of any techniques, or procedures embodied, described, or referred to herein. The author is under no obligation to provide any feature listed herein. ----------------------------------------------------------------------------- As an exception to the above, this software may be distributed under the GNU General Public License (GPL) Version 2, so long as the software is distributed with, and only used for the testing of, OpenSS7 modules, drivers, and libraries. ----------------------------------------------------------------------------- U.S. GOVERNMENT RESTRICTED RIGHTS. If you are licensing this Software on behalf of the U.S. Government ("Government"), the following provisions apply to you. If the Software is supplied by the Department of Defense ("DoD"), it is classified as "Commercial Computer Software" under paragraph 252.227-7014 of the DoD Supplement to the Federal Acquisition Regulations ("DFARS") (or any successor regulations) and the Government is acquiring only the license rights granted herein (the license rights customarily provided to non-Government users). If the Software is supplied to any unit or agency of the Government other than DoD, it is classified as "Restricted Computer Software" and the Government's rights in the Software are defined in paragraph 52.227-19 of the Federal Acquisition Regulations ("FAR") (or any successor regulations) or, in the cases of NASA, in paragraph 18.52.227-86 of the NASA Supplement to the FAR (or any successor regulations). ----------------------------------------------------------------------------- Commercial licensing and support of this software is available from OpenSS7 Corporation at a fee. See http://www.openss7.com/ ----------------------------------------------------------------------------- Last Modified 2006/03/07 01:16:08 by brian ----------------------------------------------------------------------------- test-q784.c,v Revision 0.9.2.7 2006/03/07 01:16:08 brian - 64bit issues Revision 0.9.2.6 2006/03/04 13:00:36 brian - FC4 x86_64 gcc 4.0.4 2.6.15 changes *****************************************************************************/#ident "@(#) test-q784.c,v strss7-0_9a_4(0.9.2.7) 2006/03/07 01:16:08"static char const ident[] = "test-q784.c,v strss7-0_9a_4(0.9.2.7) 2006/03/07 01:16:08";/* * This is a ferry-clip Q.784 conformance test program for testing the * OpenSS7 ISUP multiplexing driver. * * GENERAL OPERATION: * * The test program opens a management stream to the ISUP multiplexing * driver, configures the driver for a single signalling point, single * signalling relation, and single trunk group. It then opens a pipe and * links one end of the pipe underneath the ISUP driver as the MTP Level 3 * stream. * * The test program opens an ISUP stream and feeds ISUP primitives to and * from that stream. On the open end of the pipe it feeds MTP Level 3 * primitives into the bottom of the ISUP multiplexing driver. This is the * ferry-clip test arrangement as follows: * * * USER SPACE * TEST PROGRAM * * ___________________________________________________ * \ / | \ / | * \ / | \ / | * | / \ | | * _________|__/___\_______ | | * | | | | * | | | | * | | | | * | ISUP | | | * | | | | * | | | | * |________________________| | | * \ / | | | * \ / | | | * | | | | * | / \ | / \ * _________|__/___\__________________|__/___\________ * | | * | | * | PIPE | * | | * |___________________________________________________| */#include <stropts.h>#include <stdlib.h>#include <unistd.h>#include <sys/ioctl.h>#include <sys/time.h>#include <sys/poll.h>#include <stdio.h>#include <sys/stat.h>#include <fcntl.h>#include <errno.h>#include <string.h>#include <signal.h>#ifdef _GNU_SOURCE#include <getopt.h>#endif#include <ss7/lmi.h>#include <ss7/lmi_ioctl.h>#include <ss7/mtpi.h>#include <ss7/mtpi_ioctl.h>#include <ss7/cci.h>#include <ss7/isupi.h>#include <ss7/isupi_ioctl.h>#define FFLUSH(stream) fflush(stream)enum { TIMEOUT = -5, UNKNOWN = -4, DECODEERROR = -3, SCRIPTERROR = -2, INCONCLUSIVE = -1, SUCCESS = 0, FAILURE = 1,};/* * ------------------------------------------------------------------------- * * Configuration * * ------------------------------------------------------------------------- */struct mtp_addr loc_addr = { ni:1, pc:0x00112233, si:5};struct mtp_addr rem_addr = { ni:1, pc:0x00223344, si:6};struct isup_addr iut_cpc_addr = { scope:ISUP_SCOPE_TG, id:1, cic:0,};struct isup_addr iut_tst_addr = { scope:ISUP_SCOPE_SR, id:1, cic:0,};struct isup_addr iut_mgm_addr = { scope:ISUP_SCOPE_SR, id:1, cic:0,};struct isup_addr iut_mnt_addr = { scope:ISUP_SCOPE_SR, id:1, cic:0,};#undef HZ#define HZ 100static struct isup_opt_conf_ct iut_ct_opt = {};static struct isup_opt_conf_cg iut_cg_opt = {};static struct isup_opt_conf_tg iut_tg_opt = { flags:ISUP_TGF_CONTROLLING_EXCHANGE, /* configuration flags */ type:ISUP_TG_TYPE_2W, /* trunk group type */ exchange_type:ISUP_XCHG_TYPE_B, /* exchange type */ select_type:ISUP_SELECTION_TYPE_DSEQ, /* circuit selection type */ t1:20 * HZ, /* waiting for RLC retry */ t2:3 * 60 * HZ, /* waiting for RES */ t3:2 * 60 * HZ, /* waiting OVL timeout */ t5:8 * 60 * HZ, /* waiting for RLC maintenance */ t6:20 * HZ, /* waiting for RES */ t7:25 * HZ, /* waiting for ACM/ANM/CON */ t8:12 * HZ, /* waiting for COT */ t9:3 * 60 * HZ, /* waiting for ANM/CON */ t10:5 * HZ, /* waiting more information. Interworking */ t11:17 * HZ, /* waiting for ACM, Interworking */ t12:55 * HZ, /* waiting for BLA retry */ t13:8 * 60 * HZ, /* waiting for BLA maintenance */ t14:55 * HZ, /* waiting for UBA retry */ t15:8 * 60 * HZ, /* waiting for UBA maintenance */ t16:55 * HZ, /* waiting for RLC retry */ t17:8 * 60 * HZ, /* waiting for RLC maintenance */ t24:1 * HZ, /* waiting for continuity IAM */ t25:5 * HZ, /* waiting for continuity CCR retry */ t26:2 * 60 * HZ, /* waiting for continuity CCR maintenance */ t27:4 * 60 * HZ, /* waiting for COT reset */ t31:7 * 60 * HZ, /* call reference guard */ t32:4 * HZ, /* waiting to send E2E message */ t33:13 * HZ, /* waiting for INF */ t34:13 * HZ, /* waiting for SEG */ t35:17 * HZ, /* waiting more information. */ t36:17 * HZ, /* waiting for COT/REL */ t37:3 * HZ, /* waiting echo control device */ t38:17 * HZ, /* waiting for RES */ tacc_r:0, /* */ tccr:0, /* */ tccr_r:0, /* */ tcra:0, /* */ tcrm:0, /* */ tcvt:0, /* */ texm_d:0, /* */};static struct isup_opt_conf_sr iut_sr_opt = { t4:8 * 60 * HZ, /* waiting for UPA/other */ t18:55 * HZ, /* waiting CGBA retry */ t19:8 * 60 * HZ, /* waiting CGBA maintenance */ t20:55 * HZ, /* waiting CGUA retry */ t21:8 * 60 * HZ, /* waiting CGUA maintenance */ t22:55 * HZ, /* waiting GRA retry */ t23:8 * 60 * HZ, /* waiting GRA maintenance */ t28:10 * HZ, /* waiting CQR */ t29:450 * 1000 / HZ, /* congestion attack timer */ t30:7 * HZ, /* congestion decay timer */ tcgb:0, /* */ tgrs:0, /* */ thga:0, /* */ tscga:0, /* */ tscga_d:0, /* */};static struct isup_opt_conf_sp iut_sp_opt = {};static struct isup_opt_conf_mtp iut_mtp_opt = {};static struct isup_opt_conf_df iut_df_opt = {};/* * ------------------------------------------------------------------------- * * Messages * * ------------------------------------------------------------------------- */struct numb { char num[200]; size_t len; ulong nai;};struct var { unsigned char buf[100]; size_t len;};struct msg { ulong cic; struct numb cdpn; struct numb cgpn; struct numb subn; ulong nci; ulong fci; ulong cpc; ulong tmr; ulong inri; ulong infi; ulong coti; ulong bci; ulong sris; ulong cgi; ulong cmi; ulong faci; struct var pam; struct var rs; struct var csi; ulong evnt; struct var uui; struct var caus; ulong cvri; ulong cgri; ulong ton; ulong cri; struct var opt;};struct msg pmsg = { 12, {"17804901140", 11, 0}, {"17804901241", 11, 0}, {"555", 3, 0}, 0, (ISUP_FCI_INTERNATIONAL_CALL | ISUP_FCI_ISDN_USER_PART_ALL_THE_WAY | ISUP_FCI_ORIGINATING_ACCESS_ISDN) >> 8, (ISUP_CPC_SUBSCRIBER_ORDINARY) >> 24, ISUP_CALL_TYPE_SPEECH, 0, 0, ISUP_COT_SUCCESS, 0, 0, 0, 0, 0, {{0,}, 0}, {{0,}, 0}, {{0,}, 0}, 0, {{0,}, 0}, {{0x80, 0x90}, 0}, 0, 0, 0, 0, {{0,}, 0}};struct msg imsg = { 12, {{0,}, 24, 0}, {{0,}, 24, 0}, {{0,}, 24, 0}, 0, (ISUP_FCI_INTERNATIONAL_CALL | ISUP_FCI_ISDN_USER_PART_ALL_THE_WAY | ISUP_FCI_ORIGINATING_ACCESS_ISDN) >> 8, (ISUP_CPC_SUBSCRIBER_ORDINARY) >> 24, ISUP_CALL_TYPE_SPEECH, 0, 0, ISUP_COT_SUCCESS, 0, 0, 0, 0, 0, {{0,}, 0}, {{0,}, 0}, {{0,}, 0}, 0, {{0,}, 0}, {{0x80, 0x90}, 0}, 0, 0, 0, 0, {{0,}, 0}};struct iaddr { struct isup_addr add; size_t len;};static ulong user_ref = 0;struct prim { ulong bind_flags; ulong setup_ind; ulong opt_flags; ulong call_type; ulong call_flags; ulong call_ref; ulong user_ref; ulong token_value; ulong result; ulong flags; ulong event; ulong cause; ulong reason; struct var subn; struct iaddr addr; struct var opt; struct var cdpn;};struct prim cprim = { CC_TOKEN_REQUEST, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {{0,}, 0}, {{0,}, 0}, {{0,}, 0}, {{0,}, 0}};struct prim mprim = { CC_TOKEN_REQUEST | CC_MANAGEMENT,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -