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

📄 test-sctp_t.c

📁 No7信令,我需要交换类似的代码, 请店长审核,谢谢了,急着交换,谢谢
💻 C
📖 第 1 页 / 共 5 页
字号:
/***************************************************************************** @(#) test-sctp_t.c,v 0.7.8.1 2001/12/11 13:26:38 brian Exp ----------------------------------------------------------------------------- Copyright (C) 2001  OpenSS7 Corporation <http://www.openss7.com/> 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. OpenSS7 Corporation 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. OpenSS7 Corporation is under no obligation to provide any feature listed herein. ----------------------------------------------------------------------------- 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 success regulations) or, in the cases of NASA, in paragraph 18.52.227-86 of the NASA Supplement to the FAR (or any successor regulations). ----------------------------------------------------------------------------- Modified 2001/12/11 13:26:38 by brian *****************************************************************************/#ident "@(#) test-sctp_t.c,v 0.7.8.1 2001/12/11 13:26:38 brian Exp"static char const ident[] = "test-sctp_t.c,v 0.7.8.1 2001/12/11 13:26:38 brian Exp";/* *  This file is for testing the sctp_t driver.  It is provided for the *  purpose of testing the OpenSS7 sctp_t driver only. */#include <stropts.h>#include <stdlib.h>#include <unistd.h>#include <sys/ioctl.h>#include <sys/time.h>#include <sys/poll.h>#include <linux/poll.h>#include <stdio.h>#include <sys/stat.h>#include <fcntl.h>#include <errno.h>#include <string.h>#include <sys/socket.h>#include <netinet/in.h>#include <arpa/inet.h>#if 0#include "../include/sys/tpi.h"#include "../include/sys/tpi_sctp.h"#include "../include/sys/xti_ip.h"#include "../include/sys/xti_sctp.h"#else#include <sys/tpi.h>#include <sys/tpi_sctp.h>#include <sys/xti_ip.h>#include <sys/xti_sctp.h>#endif#define BUFSIZE 4096#define FFLUSH(stream)#define SHORT_WAIT 10#define NORMAL_WAIT 100#define LONG_WAIT 500ulong seq[10] = { 0, };ulong tok[10] = { 0, };ulong tsn[10] = { 0, };ulong sid[10] = { 0, };union {	union T_primitives  tpi;	char		    cbuf[BUFSIZE];} cmd;char dbuf[BUFSIZE];struct strbuf ctrl = { BUFSIZE, 0, cmd.cbuf };struct strbuf data = { BUFSIZE, 0, dbuf };struct strfdinsert fdi = {	{ BUFSIZE, 0, cmd.cbuf },	{ BUFSIZE, 0, dbuf     },	0,	0,	0};typedef struct addr {	uint16_t	port	__attribute__((packed));	struct in_addr	addr[3]	__attribute__((packed));} addr_t;struct timeval when;#define INCONCLUSIVE -2#define FAILURE -1#define SUCCESS 0int show = 1;int state;int fd1, fd2, fd3;addr_t addr1, addr2, addr3;/* *  Options *//* data options */struct {	struct t_opthdr	ppi_hdr __attribute__((packed));	t_scalar_t	ppi_val __attribute__((packed));	struct t_opthdr	sid_hdr __attribute__((packed));	t_scalar_t	sid_val __attribute__((packed));}opt_data ={	{		sizeof(struct t_opthdr)+sizeof(t_scalar_t),		T_INET_SCTP,		T_SCTP_PPI,		T_SUCCESS	},	10,	{		sizeof(struct t_opthdr)+sizeof(t_scalar_t),		T_INET_SCTP,		T_SCTP_SID,		T_SUCCESS	},	0};/* receive data options */typedef struct rdat_opt {	struct t_opthdr	ppi_hdr __attribute__((packed));	t_scalar_t	ppi_val __attribute__((packed));	struct t_opthdr	sid_hdr __attribute__((packed));	t_scalar_t	sid_val __attribute__((packed));	struct t_opthdr	ssn_hdr __attribute__((packed));	t_scalar_t	ssn_val __attribute__((packed));	struct t_opthdr	tsn_hdr __attribute__((packed));	t_scalar_t	tsn_val __attribute__((packed));} rdat_opt_t;/* connect options */struct {	struct t_opthdr	ist_hdr __attribute__((packed));	t_scalar_t	ist_val __attribute__((packed));	struct t_opthdr	ost_hdr __attribute__((packed));	t_scalar_t	ost_val __attribute__((packed));}opt_conn ={	{		sizeof(struct t_opthdr)+sizeof(t_scalar_t),		T_INET_SCTP,		T_SCTP_ISTREAMS,		T_SUCCESS	},	1,	{		sizeof(struct t_opthdr)+sizeof(t_scalar_t),		T_INET_SCTP,		T_SCTP_OSTREAMS,		T_SUCCESS	},	1};/* management options */struct {	struct t_opthdr	nod_hdr __attribute__((packed));	t_scalar_t	nod_val __attribute__((packed));	struct t_opthdr	crk_hdr __attribute__((packed));	t_scalar_t	crk_val __attribute__((packed));	struct t_opthdr	ppi_hdr __attribute__((packed));	t_scalar_t	ppi_val __attribute__((packed));	struct t_opthdr	sid_hdr __attribute__((packed));	t_scalar_t	sid_val __attribute__((packed));	struct t_opthdr	rcv_hdr __attribute__((packed));	t_scalar_t	rcv_val __attribute__((packed));	struct t_opthdr	ckl_hdr __attribute__((packed));	t_scalar_t	ckl_val __attribute__((packed));	struct t_opthdr	skd_hdr __attribute__((packed));	t_scalar_t	skd_val __attribute__((packed));	struct t_opthdr	prt_hdr __attribute__((packed));	t_scalar_t	prt_val __attribute__((packed));	struct t_opthdr	art_hdr __attribute__((packed));	t_scalar_t	art_val __attribute__((packed));	struct t_opthdr	irt_hdr __attribute__((packed));	t_scalar_t	irt_val __attribute__((packed));	struct t_opthdr	hbi_hdr __attribute__((packed));	t_scalar_t	hbi_val __attribute__((packed));	struct t_opthdr	rin_hdr __attribute__((packed));	t_scalar_t	rin_val __attribute__((packed));	struct t_opthdr	rmn_hdr __attribute__((packed));	t_scalar_t	rmn_val __attribute__((packed));	struct t_opthdr	rmx_hdr __attribute__((packed));	t_scalar_t	rmx_val __attribute__((packed));	struct t_opthdr	ist_hdr __attribute__((packed));	t_scalar_t	ist_val __attribute__((packed));	struct t_opthdr	ost_hdr __attribute__((packed));	t_scalar_t	ost_val __attribute__((packed));	struct t_opthdr	cin_hdr __attribute__((packed));	t_scalar_t	cin_val __attribute__((packed));	struct t_opthdr	tin_hdr __attribute__((packed));	t_scalar_t	tin_val __attribute__((packed));	struct t_opthdr	mac_hdr __attribute__((packed));	t_scalar_t	mac_val __attribute__((packed));	struct t_opthdr	dbg_hdr __attribute__((packed));	t_scalar_t	dbg_val __attribute__((packed));}opt_optm ={	{		sizeof(struct t_opthdr)+sizeof(t_scalar_t),		T_INET_SCTP,		T_SCTP_NODELAY,		T_SUCCESS	},	T_YES,	{		sizeof(struct t_opthdr)+sizeof(t_scalar_t),		T_INET_SCTP,		T_SCTP_CORK,		T_SUCCESS	},	T_YES,	{		sizeof(struct t_opthdr)+sizeof(t_scalar_t),		T_INET_SCTP,		T_SCTP_PPI,		T_SUCCESS	},	10,	{		sizeof(struct t_opthdr)+sizeof(t_scalar_t),		T_INET_SCTP,		T_SCTP_SID,		T_SUCCESS	},	0,	{		sizeof(struct t_opthdr)+sizeof(t_scalar_t),		T_INET_SCTP,		T_SCTP_RECVOPT,		T_SUCCESS	},	T_NO,	{		sizeof(struct t_opthdr)+sizeof(t_scalar_t),		T_INET_SCTP,		T_SCTP_COOKIE_LIFE,		T_SUCCESS	},	60000,	{		sizeof(struct t_opthdr)+sizeof(t_scalar_t),		T_INET_SCTP,		T_SCTP_SACK_DELAY,		T_SUCCESS	},	0,	{		sizeof(struct t_opthdr)+sizeof(t_scalar_t),		T_INET_SCTP,		T_SCTP_PATH_MAX_RETRANS,		T_SUCCESS	},	0,	{		sizeof(struct t_opthdr)+sizeof(t_scalar_t),		T_INET_SCTP,		T_SCTP_ASSOC_MAX_RETRANS,		T_SUCCESS	},	12,	{		sizeof(struct t_opthdr)+sizeof(t_scalar_t),		T_INET_SCTP,		T_SCTP_MAX_INIT_RETRIES,		T_SUCCESS	},	12,	{		sizeof(struct t_opthdr)+sizeof(t_scalar_t),		T_INET_SCTP,		T_SCTP_HEARTBEAT_ITVL,		T_SUCCESS	},	200,	{		sizeof(struct t_opthdr)+sizeof(t_scalar_t),		T_INET_SCTP,		T_SCTP_RTO_INITIAL,		T_SUCCESS	},	0,	{		sizeof(struct t_opthdr)+sizeof(t_scalar_t),		T_INET_SCTP,		T_SCTP_RTO_MIN,		T_SUCCESS	},	0,	{		sizeof(struct t_opthdr)+sizeof(t_scalar_t),		T_INET_SCTP,		T_SCTP_RTO_MAX,		T_SUCCESS	},	0,	{		sizeof(struct t_opthdr)+sizeof(t_scalar_t),		T_INET_SCTP,		T_SCTP_OSTREAMS,		T_SUCCESS	},	1,	{		sizeof(struct t_opthdr)+sizeof(t_scalar_t),		T_INET_SCTP,		T_SCTP_ISTREAMS,		T_SUCCESS	},	1,	{		sizeof(struct t_opthdr)+sizeof(t_scalar_t),		T_INET_SCTP,		T_SCTP_COOKIE_INC,		T_SUCCESS	},	1000,	{		sizeof(struct t_opthdr)+sizeof(t_scalar_t),		T_INET_SCTP,		T_SCTP_THROTTLE_ITVL,		T_SUCCESS	},	50,	{		sizeof(struct t_opthdr)+sizeof(t_scalar_t),		T_INET_SCTP,		T_SCTP_MAC_TYPE,		T_SUCCESS	},	SCTP_HMAC_NONE,	{		sizeof(struct t_opthdr)+sizeof(t_scalar_t),		T_INET_SCTP,		T_SCTP_DEBUG,		T_SUCCESS	},	0};char *err_string(ulong error){	switch ( error )	{		case TBADADDR:		return("TBADADDR");		case TBADOPT:		return("TBADOPT");		case TACCES:		return("TACCES");		case TBADF:		return("TBADF");		case TNOADDR:		return("TNOADDR");		case TOUTSTATE:		return("TOUTSTATE");		case TBADSEQ:		return("TBADSEQ");		case TSYSERR:		return("TSYSERR");		case TLOOK:		return("TLOOK");		case TBADDATA:		return("TBADDATA");		case TBUFOVFLW:		return("TBUFOVFLW");		case TFLOW:		return("TFLOW");		case TNODATA:		return("TNODATA");		case TNODIS:		return("TNODIS");		case TNOUDERR:		return("TNOUDERR");		case TBADFLAG:		return("TBADFLAG");		case TNOREL:		return("TNOREL");		case TNOTSUPPORT:	return("TNOTSUPPORT");		case TSTATECHNG:	return("TSTATECHNG");		case TNOSTRUCTYPE:	return("TNOSTRUCTTYPE");		case TBADNAME:		return("TBADNAME");		case TBADQLEN:		return("TBADQLEN");		case TADDRBUSY:		return("TADDRBUSY");		case TINDOUT:		return("TINDOUT");		case TPROVMISMATCH:	return("TPROVMISMATCH");		case TRESQLEN:		return("TRESQLEN");		case TRESADDR:		return("TRESADDR");		case TQFULL:		return("TQFULL");		case TPROTO:		return("TPROTO");		default:		return("(unknown)");	}}void print_error(ulong error){

⌨️ 快捷键说明

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