📄 test-x400p.c
字号:
/***************************************************************************** @(#) test-x400p.c,v openss7-0_9_2_E(0.9.2.19) 2007/03/15 10:15:11 ----------------------------------------------------------------------------- Copyright (c) 2001-2007 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. 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 2007/03/15 10:15:11 by brian ----------------------------------------------------------------------------- test-x400p.c,v Revision 0.9.2.19 2007/03/15 10:15:11 brian - test case reporting and release date Revision 0.9.2.18 2007/03/13 19:49:40 brian - test case timing tweaks Revision 0.9.2.17 2007/03/12 10:19:27 brian - corrections Revision 0.9.2.16 2007/03/12 09:34:09 brian - boosted default test port numbers from 10000 to 18000 Revision 0.9.2.15 2006/12/18 10:51:39 brian - subpackaging changes for release Revision 0.9.2.14 2006/12/11 12:31:44 brian - testcase timing tweaks Revision 0.9.2.13 2006/12/11 11:57:51 brian - T1 works correctly, almost all test cases pass Revision 0.9.2.12 2006/12/11 07:40:18 brian - corrections from testing Revision 0.9.2.11 2006/12/09 10:40:26 brian - corrections from testing Revision 0.9.2.10 2006/12/08 11:46:35 brian - a few more corrections from testing Revision 0.9.2.9 2006/12/08 05:32:11 brian - changes from testing of X400P-SS7 driver Revision 0.9.2.8 2006/12/06 11:45:33 brian - updated X400P driver and test suites Revision 0.9.2.7 2006/10/31 21:04:54 brian - changes for 32-bit compatibility and remove HZ dependency Revision 0.9.2.6 2006/10/27 22:56:39 brian - changes for 32-bit compatibility Revision 0.9.2.5 2005/06/22 07:58:44 brian - unsigned/signed pointer corrections for gcc4 on FC4 Revision 0.9.2.4 2005/05/14 08:31:40 brian - copyright header correction *****************************************************************************/#ident "@(#) test-x400p.c,v openss7-0_9_2_E(0.9.2.19) 2007/03/15 10:15:11"static char const ident[] = "test-x400p.c,v openss7-0_9_2_E(0.9.2.19) 2007/03/15 10:15:11";#define TEST_M2PA 0#define TEST_X400 1#include <sys/types.h>#include <stropts.h>#include <stdlib.h>#ifdef HAVE_INTTYPES_H# include <inttypes.h>#else# ifdef HAVE_STDINT_H# include <stdint.h># endif#endif#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>#include <sys/uio.h>#include <time.h>#ifdef HAVE_SYS_WAIT_H# include <sys/wait.h>#endif#ifdef _GNU_SOURCE#include <getopt.h>#endif#if TEST_M2PA#include <sys/socket.h>#include <netinet/in.h>#include <arpa/inet.h>#include <netdb.h>#endif /* TEST_M2PA */#include <ss7/lmi.h>#include <ss7/lmi_ioctl.h>#include <ss7/sdli.h>#include <ss7/sdli_ioctl.h>#if 0#include <ss7/devi.h>#include <ss7/devi_ioctl.h>#endif#include <ss7/sdti.h>#include <ss7/sdti_ioctl.h>#include <ss7/sli.h>#include <ss7/sli_ioctl.h>#if TEST_M2PA#include <sys/npi.h>#include <sys/npi_sctp.h>#endif /* TEST_M2PA */#if __BYTE_ORDER == __BIG_ENDIAN# define __constant_ntohl(x) (x)# define __constant_ntohs(x) (x)# define __constant_htonl(x) (x)# define __constant_htons(x) (x)#else#if __BYTE_ORDER == __LITTLE_ENDIAN# define __constant_ntohl(x) __bswap_constant_32(x)# define __constant_ntohs(x) __bswap_constant_16(x)# define __constant_htonl(x) __bswap_constant_32(x)# define __constant_htons(x) __bswap_constant_16(x)#endif#endif/* * The following test configuration is for use with a loopback cable between * span 0 and span 1 on the first E/T400P-SS7 in a host. The E1/T1 loopback * cable is built as follows: * * * JACK 1 JACK 2 * _________________ __________________ * | | | | | | | | | | | | | | | | | | | | * | | | | | | | | | | | | | | | | | | | | * | | | | | | | | | | | | | | | | | | | | * | | | | | | | | | | | | | | | | | | | | * | | | | | | | | | | | | | | | | | | | | * | | | | | | | | | | | | | | | | | | | | * | | | | * | 1 2 3 4 5 6 7 8 | | 1 2 3 4 5 6 7 8 | * | | | | | | | | | | | | * | | | | | | | | | * X X X X * | | | | | | | | * X X X X * | | | | | | | | * X X X X * | | | | | | | | * X X X X * | | | | | | | | * X X X X * | | | |_ _ _ _ _ _ _ _ _ _ _| | | | * X |___X_X_X_X_X_X_X_X_X_X___| X * | | | | * X X * | |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _| | * |___X_X_X_X_X_X_X_X_X_X_X_X_X_X_X_X___| * * * The above arrangement will allow the settings below where the PT is on * span 0 (Jack 1) and the IUT is no span 1 (Jack 2). Channel 19 is used * rather arbitrarily (its a big prime number). This allows a single card to * be used to test itself. */#define PTU_TEST_SLOT 0#define PTU_TEST_SPAN 0#define PTU_TEST_CHAN 19#define IUT_TEST_SLOT 0#define IUT_TEST_SPAN 1#define IUT_TEST_CHAN 19/* * ------------------------------------------------------------------------- * * Configuration * * ------------------------------------------------------------------------- */static const char *lpkgname = "SS7 MTP Level 2";/* static const char *spkgname = "SIGTRAN"; */static const char *lstdname = "Q.703/ANSI T1.111.3/JQ.703";static const char *sstdname = "Q.781";static const char *shortname = "MTP2";static char devname[256] = "/dev/x400p-sl";static int repeat_verbose = 0;static int repeat_on_success = 0;static int repeat_on_failure = 0;static int exit_on_failure = 0;#if TEST_M2PAstatic int client_port_specified = 0;static int server_port_specified = 0;static int client_host_specified = 0;static int server_host_specified = 0;#endifstatic int verbose = 1;static int client_exec = 0; /* execute client side */static int server_exec = 0; /* execute server side */static int show_msg = 0;static int show_acks = 0;static int show_timeout = 0;static int show_fisus = 1;#if TEST_X400static int show_msus = 1;#endif//static int show_data = 1;static int last_prim = 0;static int last_event = 0;static int last_errno = 0;static int last_retval = 0;static int last_prio = 0;#if TEST_M2PAstatic int PRIM_type = 0;static int NPI_error = 0;static int CONIND_number = 2;static int TOKEN_value = 0;static int SEQ_number = 1;static int SERV_type = N_CLNS;static int CURRENT_state = NS_UNBND;N_info_ack_t last_info = { 0, };static int DATA_xfer_flags = 0;static int BIND_flags = 0;static int RESET_orig = N_UNDEFINED;static int RESET_reason = 0;static int DISCON_reason = 0;static int CONN_flags = 0;static int ERROR_type = 0;static int RESERVED_field[2] = { 0, 0 };#endif#define TEST_PROTOCOL 132#define CHILD_PTU 0#define CHILD_IUT 1int test_fd[3] = { 0, 0, 0 };uint32_t bsn[3] = { 0, 0, 0 };uint32_t fsn[3] = { 0, 0, 0 };uint8_t fib[3] = { 0, 0, 0, };uint8_t bib[3] = { 0, 0, 0, };uint8_t li[3] = { 0, 0, 0, };uint8_t sio[3] = { 0, 0, 0, };static int iut_connects = 1;#define MSU_LEN 35static int msu_len = MSU_LEN;/* some globals for compressing events */static int oldact = 0; /* previous action */static int cntact = 0; /* repeats of previous action */static int oldevt = 0;static int cntevt = 0;static int count = 0;static int tries = 0;#define BUFSIZE 32*4096#define SHORT_WAIT 20 // 100 // 10#define NORMAL_WAIT 100 // 500 // 100#define LONG_WAIT 500 // 5000 // 500#define LONGER_WAIT 1000 // 10000 // 5000#define LONGEST_WAIT 5000 // 20000 // 10000#define TEST_DURATION 20000#define INFINITE_WAIT -1static ulong test_duration = TEST_DURATION; /* wait on other side */ulong seq[10] = { 0, };ulong tok[10] = { 0, };ulong tsn[10] = { 0, };ulong sid[10] = { 0, };ulong ssn[10] = { 0, };ulong ppi[10] = { 0, };ulong exc[10] = { 0, };char cbuf[BUFSIZE];char dbuf[BUFSIZE];struct strbuf ctrl = { BUFSIZE, -1, cbuf };struct strbuf data = { BUFSIZE, -1, dbuf };static int test_pflags = MSG_BAND; /* MSG_BAND | MSG_HIPRI */static int test_pband = 0;static int test_gflags = 0; /* MSG_BAND | MSG_HIPRI */static int test_gband = 0;static int test_timout = 200;#if TEST_M2PAstatic int test_bufsize = 256;static int test_nidu = 256;static int OPTMGMT_flags = 0;static struct sockaddr_in *ADDR_buffer = NULL;static socklen_t ADDR_length = sizeof(*ADDR_buffer);static struct sockaddr_in *DEST_buffer = NULL;static socklen_t DEST_length = 0;static struct sockaddr_in *SRC_buffer = NULL;static socklen_t SRC_length = 0;static unsigned char *PROTOID_buffer = NULL;static size_t PROTOID_length = 0;static char *DATA_buffer = NULL;static size_t DATA_length = 0;static int test_resfd = -1;static void *QOS_buffer = NULL;static int QOS_length = 0;#elsestatic unsigned short addrs[3][1] = { {(PTU_TEST_SLOT << 12) | (PTU_TEST_SPAN << 8) | (PTU_TEST_CHAN << 0)}, {(IUT_TEST_SLOT << 12) | (IUT_TEST_SPAN << 8) | (IUT_TEST_CHAN << 0)}, {(IUT_TEST_SLOT << 12) | (IUT_TEST_SPAN << 8) | (IUT_TEST_CHAN << 0)}};static int anums[3] = { 1, 1, 1 };static unsigned short *ADDR_buffer = NULL;static size_t ADDR_length = sizeof(unsigned short);#endifstruct strfdinsert fdi = { {BUFSIZE, 0, cbuf}, {BUFSIZE, 0, dbuf}, 0, 0, 0};int flags = 0;int dummy = 0;#if TEST_M2PA#ifndef SCTP_VERSION_2#define SCTP_VERSION_2#endif#if 1#ifndef SCTP_VERSION_2typedef struct addr { uint16_t port __attribute__ ((packed)); struct in_addr addr[3] __attribute__ ((packed));} addr_t;#endif /* SCTP_VERSION_2 */#endif#elsetypedef unsigned short ppa_t;#endifstruct timeval when;/* * ------------------------------------------------------------------------- * * Events and Actions * * ------------------------------------------------------------------------- */enum { __EVENT_EOF = -7, __EVENT_NO_MSG = -6, __EVENT_TIMEOUT = -5, __EVENT_UNKNOWN = -4, __RESULT_DECODE_ERROR = -3, __RESULT_SCRIPT_ERROR = -2, __RESULT_INCONCLUSIVE = -1, __RESULT_SUCCESS = 0, __RESULT_FAILURE = 1, __RESULT_NOTAPPL = 3, __RESULT_SKIPPED = 77,};/* * ------------------------------------------------------------------------- */int show = 1;enum { __TEST_CONN_REQ = 100, __TEST_CONN_RES, __TEST_DISCON_REQ, __TEST_DATA_REQ, __TEST_EXDATA_REQ, __TEST_INFO_REQ, __TEST_BIND_REQ, __TEST_UNBIND_REQ, __TEST_UNITDATA_REQ, __TEST_OPTMGMT_REQ, __TEST_ORDREL_REQ, __TEST_OPTDATA_REQ, __TEST_ADDR_REQ, __TEST_CAPABILITY_REQ, __TEST_CONN_IND, __TEST_CONN_CON, __TEST_DISCON_IND, __TEST_DATA_IND, __TEST_EXDATA_IND, __TEST_INFO_ACK, __TEST_BIND_ACK, __TEST_ERROR_ACK, __TEST_OK_ACK, __TEST_UNITDATA_IND, __TEST_UDERROR_IND, __TEST_OPTMGMT_ACK, __TEST_ORDREL_IND, __TEST_NRM_OPTDATA_IND, __TEST_EXP_OPTDATA_IND, __TEST_ADDR_ACK, __TEST_CAPABILITY_ACK, __TEST_WRITE, __TEST_WRITEV, __TEST_PUTMSG_DATA, __TEST_PUTPMSG_DATA, __TEST_PUSH, __TEST_POP, __TEST_READ, __TEST_READV, __TEST_GETMSG, __TEST_GETPMSG, __TEST_DATA, __TEST_DATACK_REQ, __TEST_DATACK_IND, __TEST_RESET_REQ, __TEST_RESET_IND, __TEST_RESET_RES, __TEST_RESET_CON, __TEST_O_TI_GETINFO, __TEST_O_TI_OPTMGMT, __TEST_O_TI_BIND, __TEST_O_TI_UNBIND, __TEST__O_TI_GETINFO, __TEST__O_TI_OPTMGMT, __TEST__O_TI_BIND, __TEST__O_TI_UNBIND, __TEST__O_TI_GETMYNAME, __TEST__O_TI_GETPEERNAME, __TEST__O_TI_XTI_HELLO, __TEST__O_TI_XTI_GET_STATE,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -