📄 inet.c
字号:
/***************************************************************************** @(#) inet.c,v strxnet-0_9_2-4(0.9.2.5) 2004/05/27 02:17:14 ----------------------------------------------------------------------------- Copyright (c) 2001-2004 OpenSS7 Corporation <http://www.openss7.com> Copyright (c) 1997-2000 Brian F. G. Bidulock <bidulock@dallas.net> 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). ----------------------------------------------------------------------------- Commercial licensing and support of this software is available from OpenSS7 Corporation at a fee. See http://www.openss7.com/ ----------------------------------------------------------------------------- Last Modified 2004/05/27 02:17:14 by brian *****************************************************************************/#ident "@(#) inet.c,v strxnet-0_9_2-4(0.9.2.5) 2004/05/27 02:17:14"static char const ident[] = "inet.c,v strxnet-0_9_2-4(0.9.2.5) 2004/05/27 02:17:14";/* This driver provides the functionality of IP (Internet Protocol) over a connectionless network provider (NPI). It provides a STREAMS-based encapsulation of the Linux IP stack. */#if defined LIS && !defined _LIS_SOURCE#define _LIS_SOURCE#endif#if !defined _LIS_SOURCE && !defined _LFS_SOURCE# error ****# error **** One of _LFS_SOURCE or _LIS_SOURCE must be defined# error **** to compile the inet driver.# error ****#endif#ifdef LINUX# include <linux/config.h># include <linux/version.h># ifndef HAVE_SYS_LIS_MODULE_H# ifdef MODVERSIONS# include <linux/modversions.h># endif# include <linux/module.h># include <linux/modversions.h># ifndef __GENKSYMS__# if defined HAVE_SYS_LIS_MOVERSIONS_H# include <sys/LiS/modversions.h># elif defined HAVE_SYS_STREAMS_MODVERSIONS_H# include <sys/streams/modversions.h># endif# endif# include <linux/init.h># else# include <sys/LiS/module.h># endif#endif#if defined HAVE_OPENSS7_SCTP#if !defined CONFIG_SCTP && !defined CONFIG_SCTP_MODULE#undef HAVE_OPENSS7_SCTP#endif#endif#if !defined HAVE_OPENSS7_SCTP#undef sctp_addr#define sctp_addr stupid_sctp_addr_in_the_wrong_place#endif#include <linux/bitops.h>#define ss_tst_bit(nr,addr) test_bit(nr,addr)#define ss_set_bit(nr,addr) __set_bit(nr,addr)#define ss_clr_bit(nr,addr) __clear_bit(nr,addr)#include <linux/net.h>#include <linux/in.h>#include <linux/un.h>#include <linux/ip.h>#include <net/sock.h>#include <net/udp.h>#include <net/tcp.h>#if defined HAVE_OPENSS7_SCTP#undef STATIC#undef INLINE#include <net/sctp.h>#endif#ifndef SK_WMEM_MAX#define SK_WMEM_MAX 65535#endif#ifndef SK_RMEM_MAX#define SK_RMEM_MAX 65535#endif#if !defined HAVE_OPENSS7_SCTP#undef sctp_addr#endif#ifndef tcp_openreq_cachep#ifdef HAVE_TCP_OPENREQ_CACHEP_ADDR#include <linux/slab.h>static kmem_cache_t **const _tcp_openreq_cachep_location = (typeof(_tcp_openreq_cachep_location)) (HAVE_TCP_OPENREQ_CACHEP_ADDR);#define tcp_openreq_cachep (*_tcp_openreq_cachep_location)#endif#endif#ifndef tcp_set_keepalive#ifdef HAVE_TCP_SET_KEEPALIVE_ADDRvoidtcp_set_keepalive(struct sock *sk, int val){ static void (*func) (struct sock *, int) = (typeof(func)) HAVE_TCP_SET_KEEPALIVE_ADDR; return func(sk, val);}#endif#endif#ifndef tcp_sync_mss#ifdef HAVE_TCP_SYNC_MSS_ADDRinttcp_sync_mss(struct sock *sk, u32 pmtu){ static int (*func)(struct sock *, u32) = (typeof(func)) HAVE_TCP_SYNC_MSS_ADDR; return func(sk, pmtu);}#endif#endif#ifndef tcp_write_xmit#ifdef HAVE_TCP_WRITE_XMIT_ADDRinttcp_write_xmit(struct sock *sk, int nonagle){ static int (*func)(struct sock *, int) = (typeof(func)) HAVE_TCP_WRITE_XMIT_ADDR; return func(sk, nonagle);}#endif#endif#ifndef tcp_cwnd_application_limited#ifdef HAVE_TCP_CWND_APPLICATION_LIMITED_ADDRvoidtcp_cwnd_application_limited(struct sock *sk){ static void (*func)(struct sock *) = (typeof(func)) HAVE_TCP_CWND_APPLICATION_LIMITED_ADDR; return func(sk);}#endif#endif/* recreate this structure because it is used by an inline */__u8 ip_tos2prio[16] = { 0, 1, 0, 0, 2, 2, 2, 2, 6, 6, 6, 6, 4, 4, 4, 4 };#ifndef sysctl_rmem_default#ifdef HAVE_SYSCTL_RMEM_DEFAULT_ADDRstatic __u32 *const _sysctl_rmem_default_location = (typeof(_sysctl_rmem_default_location)) (HAVE_SYSCTL_RMEM_DEFAULT_ADDR);#define sysctl_rmem_default (*_sysctl_rmem_default_location)#else#define sysctl_rmem_default SK_RMEM_MAX#endif#endif#ifndef sysctl_wmem_default#ifdef HAVE_SYSCTL_WMEM_DEFAULT_ADDRstatic __u32 *const _sysctl_wmem_default_location = (typeof(_sysctl_wmem_default_location)) (HAVE_SYSCTL_WMEM_DEFAULT_ADDR);#define sysctl_wmem_default (*_sysctl_wmem_default_location)#else#define sysctl_wmem_default SK_WMEM_MAX#endif#endif#ifndef sysctl_tcp_fin_timeout#ifdef HAVE_SYSCTL_TCP_FIN_TIMEOUT_ADDRstatic __u32 *const _sysctl_tcp_fin_timeout_location = (typeof(_sysctl_tcp_fin_timeout_location)) (HAVE_SYSCTL_TCP_FIN_TIMEOUT_ADDR);#define sysctl_tcp_fin_timeout (*_sysctl_tcp_fin_timeout_location)#else#define sysctl_tcp_fin_timeout TCP_FIN_TIMEOUT#endif#endif#ifdef USING_AF_INET_TTL_MEMBER_NAME#undef ttl#define ttl USING_AF_INET_TTL_MEMBER_NAME#endif#include <sys/kmem.h>#include <sys/cmn_err.h>#include <sys/stream.h>#ifdef _LFS_SOURCE#include <sys/strconf.h>#include <sys/strsubr.h>#include <sys/ddi.h>#endif#if defined HAVE_TIHDR_H# include <tihdr.h>#else# include <sys/tihdr.h>#endif#include <sys/xti.h>#include <sys/xti_inet.h>#include <sys/xti_sctp.h>#define T_ALLLEVELS -1UL#define LINUX_2_4 1#include "debug.h"#include "bufq.h"#define SS_DESCRIP "UNIX SYSTEM V RELEASE 4.2 FAST STREAMS FOR LINUX"#define SS_COPYRIGHT "Copyright (c) 1997-2004 OpenSS7 Corporation. All Rights Reserved."#define SS_REVISION "LfS inet.c,v strxnet-0_9_2-4(0.9.2.5) 2004/05/27 02:17:14"#define SS_DEVICE "SVR 4.2 STREAMS INET Drivers (NET4)"#define SS_CONTACT "Brian Bidulock <bidulock@openss7.org>"#define SS_LICENSE "GPL"#define SS_BANNER SS_DESCRIP "\n" \ SS_COPYRIGHT "\n" \ SS_REVISION "\n" \ SS_DEVICE "\n" \ SS_CONTACT "\n"#define SS_SPLASH SS_DEVICE " - " \ SS_REVISION "\n"MODULE_AUTHOR(SS_CONTACT);MODULE_DESCRIPTION(SS_DESCRIP);MODULE_SUPPORTED_DEVICE(SS_DEVICE);MODULE_LICENSE(SS_LICENSE);#ifndef SS_MOD_NAME# ifdef CONFIG_STREAMS_INET_NAME# define SS_MOD_NAME CONFIG_STREAMS_INET_NAME# else# define SS_MOD_NAME "inet"# endif#endif#ifndef SS_CMAJOR# ifdef CONFIG_STREAMS_INET_MAJOR# define SS_CMAJOR CONFIG_STREAMS_INET_MAJOR# else# define SS_CMAJOR 30# endif#endifunsigned short major = SS_CMAJOR;MODULE_PARM(major, "h");MODULE_PARM_DESC(major, "Major device number for STREAMS NET4 driver (0 for allocation).");#ifndef SS_CMAJOR#define SS_CMAJOR 30#endif#define IP_CMINOR 32#define FIRST_CMINOR 33#define ICMP_CMINOR 33#define GGP_CMINOR 34#define IPIP_CMINOR 35#define TCP_CMINOR 36#define EGP_CMINOR 37#define PUP_CMINOR 38#define UDP_CMINOR 39#define IDP_CMINOR 40#define RAWIP_CMINOR 41#define TICOTS_ORD_CMINOR 42#define TICOTS_CMINOR 43#define TICLTS_CMINOR 44#if defined HAVE_OPENSS7_SCTP#define SCTP_CMINOR 45#define LAST_CMINOR 45#else /* defined HAVE_OPENSS7_SCTP */#define LAST_CMINOR 44#endif /* defined HAVE_OPENSS7_SCTP */#define FREE_CMINOR 50#ifndef SS_NMAJOR#define SS_NMAJOR 4#define SS_NMINOR 256#endif/* * ========================================================================= * * STREAMS Definitions * * ========================================================================= */STATIC struct module_info ss_minfo = { mi_idnum:SS_CMAJOR, /* Module ID number */ mi_idname:SS_MOD_NAME, /* Module name */ mi_minpsz:0, /* Min packet size accepted */ mi_maxpsz:INFPSZ, /* Max packet size accepted */ mi_hiwat:1 << 15, /* Hi water mark */ mi_lowat:1 << 10, /* Lo water mark */};STATIC int ss_open(queue_t *, dev_t *, int, int, cred_t *);STATIC int ss_close(queue_t *, int, cred_t *);STATIC int ss_rput(queue_t *, mblk_t *);STATIC int ss_rsrv(queue_t *);STATIC struct qinit ss_rinit = { qi_putp:ss_rput, /* Read put (msg from below) */ qi_srvp:ss_rsrv, /* Read queue service */ qi_qopen:ss_open, /* Each open */ qi_qclose:ss_close, /* Last close */ qi_minfo:&ss_minfo, /* Information */};STATIC int ss_wput(queue_t *, mblk_t *);STATIC int ss_wsrv(queue_t *);STATIC struct qinit ss_winit = { qi_putp:ss_wput, /* Write put (msg from above) */ qi_srvp:ss_wsrv, /* Write queue service */ qi_minfo:&ss_minfo, /* Information */};STATIC struct streamtab ss_info = { st_rdinit:&ss_rinit, /* Upper read queue */ st_wrinit:&ss_winit, /* Lower read queue */};/* Queue put and service return values */#define QR_DONE 0#define QR_ABSORBED 1#define QR_TRIMMED 2#define QR_LOOP 3#define QR_PASSALONG 4#define QR_PASSFLOW 5#define QR_DISABLE 6#define QR_STRIP 7/* TLI interface state flags */#define TSF_UNBND ( 1 << TS_UNBND )#define TSF_WACK_BREQ ( 1 << TS_WACK_BREQ )#define TSF_WACK_UREQ ( 1 << TS_WACK_UREQ )#define TSF_IDLE ( 1 << TS_IDLE )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -