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

📄 nettcp.h

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

        u_int32_t nxt;  /* Next sequence num to be sent for the first time */  

        u_int32_t ptr;  /* Working transmission pointer */

        u_int16_t wnd;  /* Other end's offered receive window */

        u_int32_t wl1;  /* Sequence number used for last window update */

        u_int32_t wl2;  /* Ack number used for last window update */

    } snd;                                                                   

    u_int32_t iss;          /* Initial send sequence number */

    u_int16_t cwind;        /* Congestion window */

    u_int16_t ssthresh;     /* Slow-start threshold */

    u_int32_t resent;       /* Count of bytes retransmitted */



    /* Receive sequence variables */

    struct {

        u_int32_t nxt;      /* Incoming sequence number expected next */

//        u_int16_t wnd;      /* Our offered receive window */

        short wnd;          /* Our offered receive window */

        u_int16_t up;       /* Receive urgent pointer */

    } rcv;                                        

    u_int32_t irs;          /* Initial receive sequence number */

    u_int16_t mss;          /* Maximum segment size */

    u_int32_t rerecv;       /* Count of duplicate bytes received */

   

    int minFreeBufs;    /* Minimum free buffers before we'll queue something. */



    char backoff;       /* Backoff interval */

    char flags;         /* Control flags */



    int listenQOpen;    /* Max queued listen connections. */

    int listenQHead;    /* Head of cloned TCB queue. */

    int listenQTail;    /* Tail of cloned TCB queue. */

    struct TCPCB_s 

        *listenQ[MAXLISTEN + 1];    /* Circular queue of clones. */

    

    NBufQHdr rcvq;      /* Receive queue */

    u_int16_t rcvcnt;       /* Bytes on receive queue. */

    NBuf *rcvBuf;       /* Hold one buffer while we trim it. */



    NBufQHdr sndq;      /* Send queue */

    u_int16_t sndcnt;       /* Number of unacknowledged sequence numbers on

                         * send queue. NB: includes SYN and FIN, which don't

                         * actually appear on sndq!

                         */



    NBufQHdr *reseq;        /* Out-of-order segment queue */

    Timer resendTimer;          /* Timeout timer */

    u_int32 retransTime;    /* Retransmission time - 0 for none. */

    u_int retransCnt;       /* Retransmission count at current wl2. */

    u_int32 rttStart;       /* Start time for round trip measurement. */

    u_int32_t rttseq;           /* Sequence number being timed */

    u_int32_t srtt;             /* Smoothed round trip time, milliseconds */

    u_int32_t mdev;             /* Mean deviation, milliseconds */

    

    u_long keepAlive;       /* Keepalive in Jiffys - 0 for none. */

    int keepProbes;         /* Number of keepalive probe timeouts. */

    u_long keepTime;        /* Jiffy time of keepalive timeout. */

    Timer keepTimer;        /* Keep alive timer */

        

//    OS_EVENT *connectSem;   /* Semaphore for connect requests. */
//    OS_EVENT *readSem;      /* Semaphore for read function. */
//    OS_EVENT *writeSem;     /* Semaphore for write function. */
//    OS_EVENT *mutex;        /* Mutex for tcpOutput TCB variables. */

    u_long	connectSem;   /* Semaphore for connect requests. */
    u_long	readSem;      /* Semaphore for read function. */
    u_long	writeSem;     /* Semaphore for write function. */
    u_long	mutex;        /* Mutex for tcpOutput TCB variables. */

    

    TCPIPHdr hdrCache;      /* Cached TCP/IP header. */

    char *optionsPtr;       /* Ptr into TCP options area. */



#if ONETASK_SUPPORT > 0

  // When running in a single task, we want to use callback functions...

  void (*receiveEvent)(int td, u_long cnt);               /* Called when new data has arrived */

  void (*transmitEvent)(int td, u_long cnt);              /* Called when ready to transmit more data */

  void (*stateEvent)(int td, TCPState oldState, TCPState newState); /* Called when connection state changes */

#endif



} TCPCB;





#if STATS_SUPPORT > 0

extern TCPStats tcpStats;

#endif









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

*** PUBLIC FUNCTIONS ***

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



/* The tcpecho task entrance */

extern void tcpEcho(void);





/*

 * Initialize the TCP subsystem.

 */

void tcpInit(void);



/* 

 * Return a new TCP descriptor on success or an error code (negative) on 

 * failure. 

 */



#if ONETASK_SUPPORT > 0

  int tcpOpen(

    void (*receiveEvent)(int, u_long),               

    void (*transmitEvent)(int, u_long),              

    void (*stateEvent)(int, TCPState, TCPState)      

  );

#else

int tcpOpen(void);

#endif



/* 

 * Close a TCP connection and release the descriptor. 

 * Any outstanding packets in the queues are dropped.

 * Return 0 on success, an error code on failure. 

 */

int tcpClose(u_int td);



/*

 * Bind an IP address and port number in the sockaddr structure as our

 * address on a TCP connection.

 * Note: Currently the IP address must equal ourAddress since that is all

 * that ipDispatch() will recognize.

 * Return 0 on success, an error code on failure.

 */

int tcpBind(u_int td, struct sockaddr_in *myAddr);



/*

 * Establish a connection with a remote host.  Unless tcpBind() has been called,

 * the local IP address and port number are generated automatically.  

 * tcpConnect() blocks until the connection request either succeeds or fails.

 * tcpConnectMs() blocks up to the specified number of milliseconds.  

 * tcpConnectJiffy() blocks up to the specified number of Jiffies (OS timer 

 * ticks).

 * Return 0 on success, an error code on failure.

 */

#define tcpConnect(td, remoteAddr, tos) \
	tcpConnectJiffy(td, remoteAddr, tos, 0)

#define tcpConnectMs(td, remoteAddr, tos, t) \
	tcpConnectJiffy(td, remoteAddr, tos, (t + MSPERJIFFY - 1) / MSPERJIFFY)

int tcpConnectJiffy(u_int td, const struct sockaddr_in *remoteAddr, u_char tos, u_int timeout);



/*

 * tcpDisconnect - Tell the peer that we will not be sending any more data

 * (i.e. perform a half close on a connection).  tcpRead() will then

 * wait until the connection closes.

 * Return 0 when the peer acknowledges our message or an error code on

 * failure.

 */

int tcpDisconnect(u_int td);



/*

 * Set the number of backLog connections which will be queued to be picked up

 * by calls to accept.  Without this call, no connection will be opened until

 * tcpAccept() or tcpConnect() is called.

 * Return 0 on success, an error code on failure.

 */

int tcpListen(u_int td, int backLog);



/*

 * Pick up a connection opened by a remote host.  tcpBind() must be used to

 * specify the local address and port number for the connection.  Unless 

 * tcpListen() has been called, no connection will be accepted until this

 * is called.

 * Return a new TCP descriptor for the opened connection on success, an

 * error code on failure.

 */

#define tcpAccept(td, peerAddr) \
	tcpAcceptJiffy(td, peerAddr, 0)

#define tcpAcceptMs(td, peerAddr, t) \
	tcpReadJiffy(td, peerAddr, (t + MSPERJIFFY - 1) / MSPERJIFFY)

int tcpAcceptJiffy(u_int td, struct sockaddr_in *peerAddr, u_int timeout);



/*

 * Read from a connected TCP connection.  tcpRead() blocks until at least

 * one character is read or an error occurs.  tcpReadMs() blocks at most

 * the specified number of milliseconds.  tcpReadJiffy() blocks at most

 * the specified number of Jiffies (OS timer ticks).

 * Return the number of bytes read on success or timeout, an error code on

 * failure. 

 */

int tcpRead(u_int td, void *s, u_int len);

#define tcpReadMs(td, s, len, t) \
	tcpReadJiffy(td, s, len, (t + MSPERJIFFY - 1) / MSPERJIFFY)

int tcpReadJiffy(u_int td, void *s, u_int len, u_int timeout);



/*

 * Write to a connected TCP connection.  tcpWrite() blocks until all bytes

 * have been queued or an error occurs.  tcpWriteMs() blocks at most the

 * specified number of milliseconds.  tcpWriteJiffy() blocks at most the

 * specified number of Jiffies (OS timer ticks).

 * Return the number of bytes written on success or timeout, an error code

 * on failure.

 */

int tcpWrite(u_int td, const void *s, u_int n);

#define tcpWriteMs(td, s, n, t) \
	tcpWriteJiffy(td, s, n, (t + MSPERJIFFY - 1) / MSPERJIFFY)

int tcpWriteJiffy(u_int td, const void *s, u_int n, u_int timeout);



/*

 * tcpWait - Wait for the connection to be closed.  Normally this will be

 * done after a disconnect before trying to reuse the TCB.  This will fail

 * if the connection is not closing.

 * Returns 0 on success or an error code if the connection is not

 * closing.

 */

int tcpWait(u_int td);



/* 

 * Receive an incoming datagram.  This is called from IP.

 */

void tcpInput(NBuf *inBuf, u_int ipHeadLen);



/* 

 * Get and set parameters for the given connection.

 * Return 0 on success, an error code on failure. 

 */

int  tcpIOCtl(u_int td, int cmd, void *arg);



#endif

⌨️ 快捷键说明

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