⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test-m2pa.c

📁 OpenSS7 This the fourth public release of the OpenSS7 Master Package. See README in the release for
💻 C
📖 第 1 页 / 共 5 页
字号:
/***************************************************************************** @(#) test-m2pa.c,v openss7-0_9_2_E(0.9.2.24) 2007/03/15 10:14:51 ----------------------------------------------------------------------------- Copyright (c) 2001-2007  OpenSS7 Corporation <http://www.openss7.com/> Copyright (c) 1997-2000  Brian F. G. Bidulock <bidulock@openss7.org> All Rights Reserved. This program 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; version 2 of the License. This program 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 this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ----------------------------------------------------------------------------- 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:14:51 by brian ----------------------------------------------------------------------------- test-m2pa.c,v Revision 0.9.2.24  2007/03/15 10:14:51  brian - test case reporting and release date Revision 0.9.2.23  2007/03/12 09:33:53  brian - boosted default test port numbers from 10000 to 18000 Revision 0.9.2.22  2007/03/12 02:23:19  brian - updating tests Revision 0.9.2.21  2006/12/18 10:51:34  brian - subpackaging changes for release Revision 0.9.2.20  2006/12/11 11:57:44  brian - T1 works correctly, almost all test cases pass Revision 0.9.2.19  2006/12/11 07:40:15  brian - corrections from testing Revision 0.9.2.18  2006/12/06 11:45:26  brian - updated X400P driver and test suites Revision 0.9.2.17  2006/10/31 21:04:43  brian - changes for 32-bit compatibility and remove HZ dependency Revision 0.9.2.16  2006/10/27 22:56:34  brian - changes for 32-bit compatibility Revision 0.9.2.15  2006/03/03 12:06:12  brian - 32/64-bit compatibility Revision 0.9.2.14  2005/12/29 21:36:09  brian - a few idiosynchrasies for PPC, old 2.95 compiler, and 2.6.14 builds Revision 0.9.2.13  2005/12/28 09:58:32  brian - remove warnings on FC4 compile Revision 0.9.2.12  2005/06/23 22:09:55  brian - changes to pass _FORTIFY_SOURCE=2 on gcc 4 testing on FC4 Revision 0.9.2.11  2005/06/22 07:58:43  brian - unsigned/signed pointer corrections for gcc4 on FC4 Revision 0.9.2.10  2005/05/14 08:31:31  brian - copyright header correction *****************************************************************************/#ident "@(#) test-m2pa.c,v openss7-0_9_2_E(0.9.2.24) 2007/03/15 10:14:51"static char const ident[] = "test-m2pa.c,v openss7-0_9_2_E(0.9.2.24) 2007/03/15 10:14:51";#define TEST_M2PA   1#define TEST_X400   0#define TEST_M2UA   0#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 || TEST_M2UA#include <sys/socket.h>#include <netinet/in.h>#include <arpa/inet.h>#include <netdb.h>#endif				/* TEST_M2PA || TEST_M2UA */#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 || TEST_M2UA#include <sys/npi.h>#include <sys/npi_sctp.h>#endif				/* TEST_M2PA || TEST_M2UA */#if TEST_M2UA#include <xti.h>#include <tihdr.h>#include <timod.h>#include <xti_inet.h>#include <sys/xti_sctp.h>#endif				/* TEST_M2UA */#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/* *  ------------------------------------------------------------------------- * *  Configuration * *  ------------------------------------------------------------------------- */static const char *lpkgname = "SIGnalling TRANsport";/* static const char *spkgname = "SIGTRAN"; */static const char *lstdname = "draft-bidulock-sigtran-m2pa-test";static const char *sstdname = "Q.781";static const char *shortname = "M2PA";#ifdef LFSstatic char devname[256] = "/dev/streams/clone/sctp_n";#elsestatic char devname[256] = "/dev/sctp_n";#endifstatic int repeat_verbose = 0;static int repeat_on_success = 0;static int repeat_on_failure = 0;static int exit_on_failure = 0;#if TEST_M2PA || TEST_M2UAstatic 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 */#if TEST_M2UAstatic uint32_t aspid = 0;struct {	uint32_t num;	char text[32];} iids[2] = { {0,},};#endif				/* TEST_M2UA */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				/* TEST_M2PA */#if TEST_M2UAstatic int PRIM_type = 0;static int CONIND_number = 2;static int TOKEN_value = 0;static int SEQ_number = 1;static int SERV_type = T_COTS_ORD;static int CURRENT_state = TS_UNBND;struct T_info_ack_t last_info = { 0, };static int DATA_xfer_flags = 0;static int BIND_flags = 0;static int DISCONN_reason = 0;static int CONN_flags = 0;static int ERROR_type = 0;static int RESERVED_field[2] = { 0, 0 };#endif				/* TEST_M2UA */#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_M2PA || TEST_M2UAstatic 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 || TEST_M2UA#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,	__TEST__O_TI_XTI_CLEAR_EVENT, __TEST__O_TI_XTI_MODE,	__TEST__O_TI_TLI_MODE,	__TEST_TI_GETINFO, __TEST_TI_OPTMGMT, __TEST_TI_BIND,	__TEST_TI_UNBIND, __TEST_TI_GETMYNAME, __TEST_TI_GETPEERNAME,	__TEST_TI_SETMYNAME, __TEST_TI_SETPEERNAME, __TEST_TI_SYNC,	__TEST_TI_GETADDRS, __TEST_TI_CAPABILITY,	__TEST_TI_SETMYNAME_DATA, __TEST_TI_SETPEERNAME_DATA,	__TEST_TI_SETMYNAME_DISC, __TEST_TI_SETPEERNAME_DISC,	__TEST_TI_SETMYNAME_DISC_DATA, __TEST_TI_SETPEERNAME_DISC_DATA,	__TEST_PRIM_TOO_SHORT, __TEST_PRIM_WAY_TOO_SHORT,};enum {	__STATUS_OUT_OF_SERVICE = 200, __STATUS_ALIGNMENT, __STATUS_PROVING_NORMAL, __STATUS_PROVING_EMERG,	__STATUS_IN_SERVICE, __STATUS_PROCESSOR_OUTAGE, __STATUS_PROCESSOR_ENDED, __STATUS_BUSY,	__STATUS_BUSY_ENDED, __STATUS_INVALID_STATUS, __STATUS_SEQUENCE_SYNC, __MSG_PROVING,	__TEST_ACK, __TEST_TX_BREAK, __TEST_TX_MAKE, __TEST_BAD_ACK, __TEST_MSU_TOO_SHORT,	__TEST_FISU, __TEST_FISU_S, __TEST_FISU_CORRUPT, __TEST_FISU_CORRUPT_S,	__TEST_MSU_SEVEN_ONES, __TEST_MSU_TOO_LONG, __TEST_FISU_FISU_1FLAG, __TEST_FISU_FISU_2FLAG,	__TEST_MSU_MSU_1FLAG, __TEST_MSU_MSU_2FLAG, __TEST_COUNT, __TEST_TRIES,	__TEST_ETC, __TEST_SIB_S,	__TEST_FISU_BAD_FIB, __TEST_LSSU_CORRUPT, __TEST_LSSU_CORRUPT_S,	__TEST_MSU, __TEST_MSU_S,	__TEST_SIO, __TEST_SIN, __TEST_SIE, __TEST_SIOS, __TEST_SIPO, __TEST_SIB, __TEST_SIX,	__TEST_SIO2, __TEST_SIN2, __TEST_SIE2, __TEST_SIOS2, __TEST_SIPO2, __TEST_SIB2, __TEST_SIX2,};#define __EVENT_IUT_IN_SERVICE	    __STATUS_IN_SERVICE#define __EVENT_IUT_OUT_OF_SERVICE  __STATUS_OUT_OF_SERVICE#define __EVENT_IUT_RPO		    __STATUS_PROCESSOR_OUTAGE#define __EVENT_IUT_RPR		    __STATUS_PROCESSOR_ENDED#define __EVENT_IUT_DATA	    __TEST_DATAenum {	__TEST_POWER_ON = 300, __TEST_START, __TEST_STOP, __TEST_LPO, __TEST_LPR, __TEST_EMERG,	__TEST_CEASE, __TEST_SEND_MSU, __TEST_SEND_MSU_S, __TEST_CONG_A, __TEST_CONG_D,	__TEST_NO_CONG, __TEST_CLEARB, __TEST_SYNC, __TEST_CONTINUE,};enum {	__TEST_ATTACH_REQ = 400, __TEST_DETACH_REQ, __TEST_ENABLE_REQ, __TEST_ENABLE_CON,	__TEST_DISABLE_REQ, __TEST_DISABLE_CON, __TEST_ERROR_IND, __TEST_SDL_OPTIONS,	__TEST_SDL_CONFIG, __TEST_SDT_OPTIONS, __TEST_SDT_CONFIG, __TEST_SL_OPTIONS,	__TEST_SL_CONFIG, __TEST_SDL_STATS, __TEST_SDT_STATS, __TEST_SL_STATS,};/* *  -------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -