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

📄 sctp_t.c

📁 No7信令,我需要交换类似的代码, 请店长审核,谢谢了,急着交换,谢谢
💻 C
📖 第 1 页 / 共 5 页
字号:
/***************************************************************************** @(#) sctp_t.c,v 0.7.8.1 2001/12/11 13:26:34 brian Exp ----------------------------------------------------------------------------- Copyright (C) 2001  OpenSS7 Corporation <http://www.openss7.com> 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; either version 2 of the License, or (at your option) any later version. 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 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). ----------------------------------------------------------------------------- Last Modified 2001/12/11 13:26:34 by brian *****************************************************************************/#ident "@(#) sctp_t.c,v 0.7.8.1 2001/12/11 13:26:34 brian Exp"static char const ident[] = "SS7AlphaRelease(0.7.8.1) 2001/12/11 13:26:34";#define __NO_VERSION__#include <linux/config.h>#include <linux/version.h>#include <linux/modversions.h>#include <linux/module.h>#include <sys/stream.h>#include <sys/stropts.h>#include <sys/cmn_err.h>#include <sys/dki.h>#include <sys/tpi.h>#include <sys/tpi_sctp.h>#include <sys/xti_ip.h>#include <sys/xti_sctp.h>#include "sctp_debug.h"#include "sctp_bufq.h"#include "sctp.h"#include "sctp_defs.h"#include "sctp_hash.h"#include "sctp_cache.h"#include "sctp_msg.h"#include "sctp_t.h"#ifndef SCTP_T_CMAJOR#define SCTP_T_CMAJOR 231#endif#define SCTP_NMINOR 255#ifndef INT#define INT void#endiftypedef void (*bufcall_fnc_t)(long);/* *  ========================================================================= * *  STREAMS Definitions * *  ========================================================================= *  This driver defines two user interfaces: one NPI, the other TPI. */static struct module_info sctp_minfo ={	0,		/* Module ID number		*/	"sctp",		/* Module name			*/	0,		/* Min packet size accepted	*/	INFPSZ,		/* Max packet size accepted	*/	1<<15,		/* Hi water mark		*/	1<<10		/* Lo water mark		*/};static int sctp_open (queue_t *, dev_t *, int, int, cred_t *);static int sctp_close(queue_t *, int, cred_t *);static INT sctp_rput (queue_t *, mblk_t *);static INT sctp_rsrv (queue_t *);static struct qinit sctp_rinit ={	sctp_rput,	/* Read put (msg from below)	*/	sctp_rsrv,	/* Read queue service		*/	sctp_open,	/* Each open			*/	sctp_close,	/* Last close			*/	NULL,		/* Admin (not used)		*/	&sctp_minfo,	/* Information			*/	NULL		/* Statistics			*/};static INT sctp_wput (queue_t *, mblk_t *);static INT sctp_wsrv (queue_t *);static struct qinit sctp_winit ={	sctp_wput,	/* Write put (msg from above)	*/	sctp_wsrv,	/* Write queue service		*/	NULL,		/* Each open			*/	NULL,		/* Last close			*/	NULL,		/* Admin (not used)		*/	&sctp_minfo,	/* Information			*/	NULL		/* Statistics			*/};static struct streamtab sctp_info ={	&sctp_rinit,	/* Upper read  queue		*/	&sctp_winit,	/* Upper write queue		*/	NULL,		/* Lower read  queue		*/	NULL		/* Lower write queue		*/};/* *  ========================================================================= * *  Option handling functions * *  ========================================================================= */typedef struct sctp_opts{	uint		flags;	struct t_opthdr	*bcast;	  /* T_IP_BROADCAST		*/	struct t_opthdr	*norte;	  /* T_IP_DONTROUTE		*/	struct t_opthdr	*opts;	  /* T_IP_OPTIONS		*/	struct t_opthdr	*reuse;	  /* T_IP_REUSEADDR		*/	struct t_opthdr	*tos;	  /* T_IP_TOS			*/	struct t_opthdr	*ttl;	  /* T_IP_TTL			*/	struct t_opthdr	*nd;	  /* T_SCTP_NODELAY		*/	struct t_opthdr	*cork;	  /* T_SCTP_CORK		*/	struct t_opthdr	*ppi;	  /* T_SCTP_PPI			*/	struct t_opthdr	*sid;	  /* T_SCTP_SID			*/	struct t_opthdr	*ssn;	  /* T_SCTP_SSN			*/	struct t_opthdr	*tsn;	  /* T_SCTP_TSN			*/	struct t_opthdr	*ropt;	  /* T_SCTP_RECVOPT		*/	struct t_opthdr	*cklife;  /* T_SCTP_COOKIE_LIFE		*/	struct t_opthdr	*sack;	  /* T_SCTP_SACK_DELAY		*/	struct t_opthdr	*path;	  /* T_SCTP_PATH_MAX_RETRANS	*/	struct t_opthdr	*assoc;	  /* T_SCTP_ASSOC_MAX_RETRANS	*/	struct t_opthdr	*init;	  /* T_SCTP_MAX_INIT_RETRIES	*/	struct t_opthdr	*hbitvl;  /* T_SCTP_HEARTBEAT_ITVL	*/	struct t_opthdr	*rtoinit; /* T_SCTP_RTO_INITIAL		*/	struct t_opthdr	*rtomin;  /* T_SCTP_RTO_MIN		*/	struct t_opthdr	*rtomax;  /* T_SCTP_RTO_MAX		*/	struct t_opthdr	*ostr;	  /* T_SCTP_OSTREAMS		*/	struct t_opthdr	*istr;	  /* T_SCTP_ISTREAMS		*/	struct t_opthdr	*ckinc;	  /* T_SCTP_COOKIE_INC		*/	struct t_opthdr	*titvl;	  /* T_SCTP_THROTTLE_ITVL	*/	struct t_opthdr	*hmac;	  /* T_SCTP_MAC_TYPE		*/	struct t_opthdr	*hb;	  /* T_SCTP_HB			*/	struct t_opthdr	*rto;	  /* T_SCTP_RTO			*/	struct t_opthdr	*mseg;	  /* T_SCTP_MAXSEG		*/	struct t_opthdr	*status;  /* T_SCTP_STATUS		*/	struct t_opthdr *debug;	  /* T_SCTP_DEBUG		*/} sctp_opts_t;/* *  Size and Build Default options *  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *  Either builds the default options requested or builds all default options. */static size_t sctp_default_opts_size(sctp_t *sp, sctp_opts_t *ops){	size_t len = 0;	const size_t hlen = sizeof(struct t_opthdr);	const size_t olen = hlen + sizeof(t_scalar_t);	if ( !ops || ops->bcast   ) { len += olen; }	if ( !ops || ops->norte   ) { len += olen; }	if ( !ops || ops->opts    ) { len += olen; }	if ( !ops || ops->reuse   ) { len += olen; }	if ( !ops || ops->tos     ) { len += olen; }	if ( !ops || ops->ttl     ) { len += olen; }	if ( !ops || ops->nd      ) { len += olen; }	if ( !ops || ops->cork    ) { len += olen; }	if ( !ops || ops->ppi     ) { len += olen; }	if ( !ops || ops->sid     ) { len += olen; }	if ( !ops || ops->ropt    ) { len += olen; }	if ( !ops || ops->cklife  ) { len += olen; }	if ( !ops || ops->sack    ) { len += olen; }	if ( !ops || ops->path    ) { len += olen; }	if ( !ops || ops->assoc   ) { len += olen; }	if ( !ops || ops->init    ) { len += olen; }	if ( !ops || ops->hbitvl  ) { len += olen; }	if ( !ops || ops->rtoinit ) { len += olen; }	if ( !ops || ops->rtomin  ) { len += olen; }	if ( !ops || ops->rtomax  ) { len += olen; }	if ( !ops || ops->ostr    ) { len += olen; }	if ( !ops || ops->istr    ) { len += olen; }	if ( !ops || ops->ckinc   ) { len += olen; }	if ( !ops || ops->titvl   ) { len += olen; }	if ( !ops || ops->hmac    ) { len += olen; }	if ( !ops || ops->mseg    ) { len += olen; }	if ( !ops || ops->debug   ) { len += olen; }	return(len);}static void sctp_build_default_opts(sctp_t *sp, sctp_opts_t *ops, unsigned char **p){        struct t_opthdr *oh;	const size_t hlen = sizeof(*oh);	const size_t olen = hlen + sizeof(t_scalar_t);	if ( !ops || ops->bcast ) {		oh = ((struct t_opthdr *)*p)++;		oh->len	    = olen;		oh->level   = T_INET_IP;		oh->name    = T_IP_BROADCAST;		oh->status  = T_SUCCESS;		*((t_scalar_t *)*p)++ = T_NO;	}	if ( !ops || ops->norte ) {		oh = ((struct t_opthdr *)*p)++;		oh->len	    = olen;		oh->level   = T_INET_IP;		oh->name    = T_IP_DONTROUTE;		oh->status  = T_SUCCESS;		*((t_scalar_t *)*p)++ = T_NO;	}	if ( !ops || ops->opts ) {		oh = ((struct t_opthdr *)*p)++;		oh->len	    = olen;		oh->level   = T_INET_IP;		oh->name    = T_IP_OPTIONS;		oh->status  = T_SUCCESS;		*((t_scalar_t *)*p)++ = 0;	}	if ( !ops || ops->reuse ) {		oh = ((struct t_opthdr *)*p)++;		oh->len	    = olen;		oh->level   = T_INET_IP;		oh->name    = T_IP_REUSEADDR;		oh->status  = T_SUCCESS;		*((t_scalar_t *)*p)++ = T_NO;	}	if ( !ops || ops->tos ) {		oh = ((struct t_opthdr *)*p)++;		oh->len	    = olen;		oh->level   = T_INET_IP;		oh->name    = T_IP_TOS;		oh->status  = T_SUCCESS;		*((t_scalar_t *)*p)++ = sctp_default_ip_tos;	}	if ( !ops || ops->ttl ) {		oh = ((struct t_opthdr *)*p)++;		oh->len	    = olen;		oh->level   = T_INET_IP;		oh->name    = T_IP_TTL;		oh->status  = T_SUCCESS;		*((t_scalar_t *)*p)++ = sctp_default_ip_ttl;	}	if ( !ops || ops->nd ) {		oh = ((struct t_opthdr *)*p)++;		oh->len	    = olen;		oh->level   = T_INET_SCTP;		oh->name    = T_SCTP_NODELAY;		oh->status  = T_SUCCESS;		*((t_scalar_t *)*p)++ = T_YES;	}	if ( !ops || ops->cork ) {		oh = ((struct t_opthdr *)*p)++;		oh->len	    = olen;		oh->level   = T_INET_SCTP;		oh->name    = T_SCTP_CORK;		oh->status  = T_SUCCESS;		*((t_scalar_t *)*p)++ = T_NO;	}	if ( !ops || ops->ppi ) {		oh = ((struct t_opthdr *)*p)++;		oh->len	    = olen;		oh->level   = T_INET_SCTP;		oh->name    = T_SCTP_PPI;		oh->status  = T_SUCCESS;		*((t_scalar_t *)*p)++ = sctp_default_ppi;	}	if ( !ops || ops->sid ) {		oh = ((struct t_opthdr *)*p)++;		oh->len	    = olen;		oh->level   = T_INET_SCTP;		oh->name    = T_SCTP_SID;		oh->status  = T_SUCCESS;		*((t_scalar_t *)*p)++ = sctp_default_sid;	}	/* note ssn and tsn are per-packet */	if ( !ops || ops->ropt ) {		oh = ((struct t_opthdr *)*p)++;		oh->len	    = olen;		oh->level   = T_INET_SCTP;		oh->name    = T_SCTP_RECVOPT;		oh->status  = T_SUCCESS;		*((t_scalar_t *)*p)++ = T_NO;	}	if ( !ops || ops->cklife ) {		oh = ((struct t_opthdr *)*p)++;		oh->len	    = olen;		oh->level   = T_INET_SCTP;		oh->name    = T_SCTP_COOKIE_LIFE;		oh->status  = T_SUCCESS;		*((t_scalar_t *)*p)++ = sctp_default_valid_cookie_life*1000/HZ;	}	if ( !ops || ops->sack ) {		oh = ((struct t_opthdr *)*p)++;		oh->len	    = olen;		oh->level   = T_INET_SCTP;		oh->name    = T_SCTP_SACK_DELAY;		oh->status  = T_SUCCESS;		*((t_scalar_t *)*p)++ = sctp_default_max_sack_delay*1000/HZ;	}	if ( !ops || ops->path ) {		oh = ((struct t_opthdr *)*p)++;		oh->len	    = olen;		oh->level   = T_INET_SCTP;		oh->name    = T_SCTP_PATH_MAX_RETRANS;		oh->status  = T_SUCCESS;		*((t_scalar_t *)*p)++ = sctp_default_path_max_retrans;	}	if ( !ops || ops->assoc ) {		oh = ((struct t_opthdr *)*p)++;		oh->len	    = olen;		oh->level   = T_INET_SCTP;		oh->name    = T_SCTP_ASSOC_MAX_RETRANS;		oh->status  = T_SUCCESS;		*((t_uscalar_t *)*p)++ = sctp_default_assoc_max_retrans;	}	if ( !ops || ops->init ) {		oh = ((struct t_opthdr *)*p)++;		oh->len	    = olen;		oh->level   = T_INET_SCTP;		oh->name    = T_SCTP_MAX_INIT_RETRIES;		oh->status  = T_SUCCESS;		*((t_scalar_t *)*p)++ = sctp_default_max_init_retries;	}	if ( !ops || ops->hbitvl ) {		oh = ((struct t_opthdr *)*p)++;		oh->len	    = olen;		oh->level   = T_INET_SCTP;		oh->name    = T_SCTP_HEARTBEAT_ITVL;		oh->status  = T_SUCCESS;		*((t_scalar_t *)*p)++ = sctp_default_heartbeat_itvl*1000/HZ;	}	if ( !ops || ops->rtoinit ) {		oh = ((struct t_opthdr *)*p)++;		oh->len	    = olen;		oh->level   = T_INET_SCTP;		oh->name    = T_SCTP_RTO_INITIAL;		oh->status  = T_SUCCESS;		*((t_scalar_t *)*p)++ = sctp_default_rto_initial*1000/HZ;	}	if ( !ops || ops->rtomin ) {		oh = ((struct t_opthdr *)*p)++;		oh->len	    = olen;		oh->level   = T_INET_SCTP;		oh->name    = T_SCTP_RTO_MIN;		oh->status  = T_SUCCESS;		*((t_scalar_t *)*p)++ = sctp_default_rto_min*1000/HZ;	}	if ( !ops || ops->rtomax ) {		oh = ((struct t_opthdr *)*p)++;		oh->len	    = olen;		oh->level   = T_INET_SCTP;		oh->name    = T_SCTP_RTO_MAX;		oh->status  = T_SUCCESS;		*((t_scalar_t *)*p)++ = sctp_default_rto_max*1000/HZ;	}	if ( !ops || ops->ostr ) {		oh = ((struct t_opthdr *)*p)++;		oh->len	    = olen;		oh->level   = T_INET_SCTP;		oh->name    = T_SCTP_OSTREAMS;		oh->status  = T_SUCCESS;		*((t_scalar_t *)*p)++ = sctp_default_req_ostreams;	}	if ( !ops || ops->istr ) {		oh = ((struct t_opthdr *)*p)++;		oh->len	    = olen;		oh->level   = T_INET_SCTP;		oh->name    = T_SCTP_ISTREAMS;		oh->status  = T_SUCCESS;		*((t_scalar_t *)*p)++ = sctp_default_max_istreams;	}	if ( !ops || ops->ckinc ) {		oh = ((struct t_opthdr *)*p)++;		oh->len	    = olen;		oh->level   = T_INET_SCTP;		oh->name    = T_SCTP_COOKIE_INC;		oh->status  = T_SUCCESS;		*((t_scalar_t *)*p)++ = sctp_default_cookie_inc*1000/HZ;	}

⌨️ 快捷键说明

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