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

📄 nettcp.h

📁 基于东南大学开发的SEP3203的ARM7中的所有驱动
💻 H
📖 第 1 页 / 共 2 页
字号:
/*****************************************************************************

* nettcp.h - Network Transmission Control Protocol header file.

*

* Copyright (c) 1998 Global Election Systems Inc.

*

* The authors hereby grant permission to use, copy, modify, distribute,

* and license this software and its documentation for any purpose, provided

* that existing copyright notices are retained in all copies and that this

* notice and the following disclaimer are included verbatim in any 

* distributions. No written agreement, license, or royalty fee is required

* for any of the authorized uses.

*

* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR

* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES

* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 

* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,

* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT

* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,

* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY

* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT

* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF

* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

*

******************************************************************************

* REVISION HISTORY

*

* 98-02-02 Guy Lancaster <glanca@gesn.com>, Global Election Systems Inc.

*	Original based on ka9q and BSD codes.

* 2001-05-18 Mads Christiansen <mads@mogi.dk>, Partner Voxtream 

*       Added support for running uC/IP in a single proces and on ethernet.

******************************************************************************

* THEORY OF OPERATION

*

*****************************************************************************/



#ifndef NETTCP_H

#define NETTCP_H



#include <..\include\limits.h>

#include <..\syssrc\net\nettcphd.h>

#include <..\syssrc\net\netiphdr.h>

#include "nettimer.h"

#include "netconf.h"

#include "netbuf.h"



/*************************

*** PUBLIC DEFINITIONS ***

**************************/

/*

 * TCP configuration. 

 */

#if ETHER_SUPPORT

#define	TCP_DEFMSS	1460		/* Default maximum TCP segment size. */

#define TCP_MINMSS  256 		/* Minimum MSS - interfaces must handle. I'm not sure about this! */

#define	TCP_DEFWND	1460		/* Default receiver window. 

                               Changed this to 1460 bytes (instead of 512) for ethernet.

                               This will allow use of a whole ethernet packet.

                               You will achieve much better performance on file transfers if this 

                               was set higher, but this might be overkill for an embedded system.

                               For better perfomance set this to 4096 and allocate more memory for the

                               buffer system. */

#endif



#if PPP_SUPPORT

#define	TCP_DEFMSS	256			/* Default maximum TCP segment size. */

#define TCP_MINMSS 256			/* Minimum MSS - interfaces must handle 296 - 40. */

#define	TCP_DEFWND	512			/* Default receiver window. */

#endif



#define	TCP_DEFRTT	500			/* Initial guess at round trip time (ms) */

#define TCP_ISSTHRESH 64*KILOBYTE-1	/* Initial slow start threshhold. */

#define TCP_DEFPORT 5000		/* Initial local port. */



#define TCP_MAXQUEUE 8			/* Maximum packets to allow in queue. */

#define TCP_MINSEG 80			/* Minimum sized segment for modified Nagle. */





/*

 * TCP Error codes.

 */

#define TCPERR_EOF -1			/* End of data. */

#define TCPERR_ALLOC -2			/* Unable to allocate a control block. */

#define TCPERR_PARAM -3			/* Invalid parameters. */

#define TCPERR_INVADDR -4		/* Invalid address. */

#define TCPERR_CONFIG -5		/* Invalid configuration. */

#define TCPERR_CONNECT -6		/* No connection. */

#define TCPERR_RESET -7			/* Connection reset received. */

#define TCPERR_TIMEOUT -8		/* Timeout on transmission. */

#define TCPERR_NETWORK -9		/* Network error - unreachable? */

#define TCPERR_PREC -10			/* IP Precedence error. */

#define TCPERR_PROTOCOL -11		/* Protocol error. */



/*

 * TCP IOCTL commands.

 */

/* Get an up status value - non-zero if connection is up. */

#define TCPCTLG_UPSTATUS 100

/* Get the bytes in the receive queue. */

#define TCPCTLG_RCVCNT 101

/*

 * Get/set the keepalive value in seconds - 0 for none.  The argument must

 * point to an int.  Note that if the connection is already established,

 * the keep alive timer won't be started until after the next transmission.

 */

#define TCPCTLG_KEEPALIVE 102

#define TCPCTLS_KEEPALIVE 103

/* Get/set the trace level.  For debugging use only. */

#define TCPCTLG_TRACELEVEL 104

#define TCPCTLS_TRACELEVEL 105





/*

 * TCP port numbers.

 */

#define	TCPPORT_ECHO		7		/* Echo data port */

#define	TCPPORT_DISCARD		9		/* Discard data port */

#define TCPPORT_TELNET		23		/* Telnet port */

#define TCPPORT_FINGER		79		/* Finger port */





/*

 * TCP option codes and lengths. 

 */

#define	TCPOPT_EOL				0

#define	TCPOPT_NOP				1

#define	TCPOPT_MAXSEG			2

#define TCPOLEN_MAXSEG			4

#define TCPOPT_WINDOW			3

#define TCPOLEN_WINDOW			3

#define TCPOPT_TIMESTAMP		8

#define TCPOLEN_TIMESTAMP		10







#define MAXLISTEN 2         /* Maximum queued cloned listen connections. */

#define OPTSPACE 5*4        /* TCP options space - must be a multiple of 4. */





/************************

*** PUBLIC DATA TYPES ***

*************************/

typedef u_int32_t TCPAddress;

typedef u_int16_t TCPPort;



/* TCP statistics counters */

typedef struct TCPStats_s {

	DiagStat headLine;		/* Head line for display. */

	DiagStat curFree;		/* Current number of free control blocks. */

	DiagStat minFree;		/* Minimum number of free CB's during operation. */

	DiagStat runt;			/* Smaller than minimum size */

	DiagStat checksum;		/* TCP header checksum errors */

	DiagStat conout;		/* Outgoing connection attempts */

	DiagStat conin;			/* Incoming connection attempts */

	DiagStat resetOut;		/* Resets generated */

	DiagStat resetIn;		/* Resets received */

	DiagStat endRec;

} TCPStats;





/* TCP connection states. */



typedef enum {

	CLOSED = 0,		/* Must be 0 */

	LISTEN = 1,

	SYN_SENT= 2,

	SYN_RECEIVED = 3,

	ESTABLISHED = 4,

	FINWAIT1 = 5,

	FINWAIT2 = 6,

	CLOSE_WAIT = 7,

	CLOSING= 8,

	LAST_ACK = 9,

	TIME_WAIT = 10

} TCPState;









/* TCB state labels (for debugging.) */

extern char *tcbStates[];







/*

 * Combined TCP/IP headers with no options.  Used to cached the headers.

 */

typedef struct TcpIPHdr_s {

    IPHdr  ipHdr;       /* IP header - no options. */

    TCPHdr tcpHdr;      /* TCP header.  tcpSeq, ack, off, & win

                         * are in host byte order.

                         */

    char options[OPTSPACE]; /* Cache for TCP options. */

} TCPIPHdr;





/*****************************

*** PUBLIC DATA STRUCTURES ***

*****************************/

//extern const DevDef tcpdef;

/* The TCP connection interface. */



/*

 * TCP connection control block.

 */

typedef struct TCPCB_s {

    struct TCPCB_s *prev;   /* Linked list pointers for hash table */

    struct TCPCB_s *next;

    Connection conn;        /* Connection struct for hash lookup. */    



    TCPState state;         /* Connection state */



    int freeOnClose;        /* Flag set to free TCB on close. */

    int closeReason;        /* Reason for closing - TCPERR_ or 0 */

    int traceLevel;         /* Trace level this connection. */



    /*

     * Send sequence variables.

     */

    struct {                                         

⌨️ 快捷键说明

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