📄 tcpport.h
字号:
/*
* FILENAME: tcpport.h
*
* Copyright 1997 - 2000 By InterNiche Technologies Inc. All rights reserved
*
* TCP port dependent definitions.
*
* MODULE: INET
*
*
* PORTABLE: usually
*/
/* Additional Copyrights: */
/* Portions Copyright 1996 by NetPort Software. All rights reserved. */
#ifndef _TCPPORT_H
#define _TCPPORT_H 1
#ifndef _IPPORT_H_
#error You must first include ipport.h
#endif /* _IPPORT_H_ */
#ifdef MINI_TCP
#error This file only for use with full-size TCP
#endif
#include "q.h"
#include "netbuf.h"
#include "net.h"
#include "ip.h"
/* Define a default TCP MSS *Max. Segment Size) which will allow us to send
* efficiently over our interface(s) without IP fragmenting. We default to
* regular ethernet, and reduce the size if we have to deal with slower (PPP) or
* badly designed legacy (802.3) links.
*/
#ifndef TCP_MSS /* allow override in ipport.h */
#ifdef IEEE_802_3
#define TCP_MSS 0x05ac /* reduce for extra overhead of SNAP */
#elif defined(USE_PPP)
#define TCP_MSS 0x05b0 /* reduce to avoid fragments on PPP */
#else
#define TCP_MSS 0x05b4 /* assume normal ethernet */
#endif /* media type */
#endif /* TCP_MSS */
/* TCP code options - these need to preceed the nptcp.h include */
#define UDP_SOCKETS 1 /* support UDP (DGRAM) under sockets API */
#define SO_SELECT 1 /* support select() call */
#define BSDTCP_STATS 1 /* printfs for extensive BSD statistics */
#ifdef NOTDEF
TCP options not used in this build:
#define DO_TCPTRACE 1 /* copius debug tracing of TCP logic */
#endif
#include "nptcp.h" /* InterNIche<->BSD mappings */
#include "mbuf.h" /* BSD-ish Sockets includes */
#ifndef CADDRT_ALREADY
typedef char * caddr_t;
#endif
#ifdef INCLUDE_SNMP
struct variable;
#include "snmpport.h"
#include "rfc1213-.h" /* for MIB2 TCP structures */
extern struct tcp_mib tcpmib;
#else /* no SNMP, support tcp_mib locally for tcp_stats() */
struct TcpMib
{
long tcpRtoAlgorithm;
long tcpRtoMin;
long tcpRtoMax;
long tcpMaxConn;
u_long tcpActiveOpens;
u_long tcpPassiveOpens;
u_long tcpAttemptFails;
u_long tcpEstabResets;
u_long tcpCurrEstab;
u_long tcpInSegs;
u_long tcpOutSegs;
u_long tcpRetransSegs;
void * tcpConnTable; /*32 bit ptr */
u_long tcpInErrs;
u_long tcpOutRsts;
};
extern struct TcpMib tcpmib;
#endif /* INCLUDE_SNMP */
#define TCP_MIB_INC(varname) {tcpmib.varname++;}
#ifdef CRUDE_ALLOCS
/* prototype TCP ALLOC and FREE routines */
struct inpcb * INP_ALLOC(int size); /* alloc internet control block "inpcb" */
void INP_FREE(struct inpcb *); /* free internet control block */
struct mbuf * MBU_ALLOC(int size); /* alloc mbuf struct */
struct socket * SOC_ALLOC(int size); /* alloc a socket structure */
void SOC_FREE(struct socket *); /* free a socket structure */
struct tcpiphdr * TPH_ALLOC(int size); /* alloc a TCP/IP header buffer */
void TPH_FREE(struct tcpiphdr *); /* free a TCP/IP header buffer */
struct tcpcb * TCB_ALLOC(int size); /* ... tcp connection structure */
void TCB_FREE(struct tcpcb *);
#else /* not so CRUDE_ALLOCS */
/* MAP ALLOC and FREE calls to port's memory manager */
#define INP_ALLOC(size) (struct inpcb *)npalloc(size)
#define INP_FREE(ptr) npfree((void*)ptr)
#define MBU_ALLOC(size) (struct mbuf *)npalloc(size)
#define SOC_ALLOC(size) (struct socket *)npalloc(size)
#define SOC_FREE(ptr) npfree((void*)ptr)
#define TPH_ALLOC(size) (struct tcpiphdr *)npalloc(size)
#define TPH_FREE(ptr) npfree((void*)ptr)
#define TCB_ALLOC(size) (struct tcpcb *)npalloc(size)
#define TCB_FREE(ptr) npfree((void*)ptr)
#endif /* alloc macros */
#ifdef WEBPORT
extern int http_init(void);
#endif
#ifdef SO_SELECT
/* define the size of the sockets arrays passed to select(). On UNIX
* and winsock this is usually 64, but most embedded systems don't
* need more than 1 or 2, and can't always afford to waste the space.
* NOTE: These determine the size of set_fd structs, which are often
*/
#ifndef FD_SETSIZE /* let h_h files override */
#define FD_SETSIZE 12
#endif /* FD_SETSIZE */
#endif /* SO_SELECT */
#ifdef DO_TCPTRACE
/* void tcp_trace(char *, ...); */
#define tcp_trace printf
#endif
/* Calculate mbuf reserved space for MAC + IP + TCP + OPTIONS.
* This is based on ethernet, 802.3 and and PPPoE since they are the
* largest of our default MAC header sizes.
*/
#ifndef ETHHDR_BIAS
#define ETHHDR_BIAS 0
#endif
/* If we are using RFC-1323 TCP timestamp feature allow space for the
* option in each packet
*/
#ifdef TCP_TIMESTAMP
#define RTTMOPT_SIZE 12 /* Actual size plus alignment pad */
#else
#define RTTMOPT_SIZE 0
#endif /* TCP_TIMESTAMP */
/* Figure out a minimum value */
#ifdef USE_PPPOE
#define HDRSMINLEN (64 + ETHHDR_BIAS + RTTMOPT_SIZE)
#elif defined(IEEE_802_3)
#define HDRSMINLEN (62 + ETHHDR_BIAS + RTTMOPT_SIZE)
#else
#define HDRSMINLEN (54 + ETHHDR_BIAS + RTTMOPT_SIZE)
#endif
/* Figure out the actual value: minimum value padded out to
* a multiple of ALIGN_TYPE
*/
#if ((HDRSMINLEN & (ALIGN_TYPE - 1)) == 0)
#define HDRSLEN HDRSMINLEN
#else
#define HDRSLEN (HDRSMINLEN + ALIGN_TYPE - (HDRSMINLEN & (ALIGN_TYPE - 1)))
#endif
/* macros to convert between 32-bit long socket descriptors and the
* actual socket structure pointers. On most systems they just cast
* the values. They are provided to support 48 bit "large model"
* 386/pentium builds, which
*/
#ifndef LONG2SO
#define LONG2SO(ln) ((struct socket *)ln)
#define SO2LONG(so) ((long)so)
#define LONG2MBUF(ln) ((struct mbuf *)ln)
#define MBUF2LONG(mb) ((long)mb)
#endif
/* Now that TCP options are set up, include the sockets definitions */
#include "socket.h"
#include "sockvar.h"
#include "sockcall.h"
/* map protable "sys_" calls to InterNiche Sockets library */
#ifdef INTEGRITY /* Intergrity has it's own legacy mapping */
#include "../ghsintl/isockmap.h"
#else /* InterNiche full-size stack BSD-ish sockets calls */
#ifndef SYSMACRO_ALREADY /* Allow override from ipport.h */
#define sys_closesocket(sock) t_socketclose(sock)
#define sys_send(sock, buf, len, flags) t_send(sock, buf, len, flags)
#define sys_recv(sock, buf, len, flags) t_recv(sock, buf, len, flags)
#define sys_accept(X,Y,Z) t_accept(X,Y)
#define sys_bind(X,Y,Z) t_bind(X,Y)
#define sys_socket t_socket
#define sys_listen t_listen
#define sys_errno(sock) t_errno(sock)
#define sys_connect(X,Y,Z) t_connect(X,Y)
#define sys_shutdown t_shutdown
#define SYS_EWOULDBLOCK EWOULDBLOCK
#endif /* SYSMACRO_ALREADY */
#endif /* sockets mapping */
#define WP_SOCKTYPE long /* WebPort saocket type */
#define SOCKTYPE long /* preferred generic socket type */
#endif /* _TCPPORT_H */
/* end of file tcpport.h */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -