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

📄 net_buf.h

📁 ucos的tcpip协议占
💻 H
📖 第 1 页 / 共 3 页
字号:
*                                          |-------------|
*                                          |             |
*                                          |  Protocol   |
*                                          |  Controls   |
*                                          |             |
*                                          | ----------- |
*                                          |     ARP     |
*                                          | ----------- |
*                                          |     IP      |
*                                          | ----------- |
*                                          |   TCP/UDP   |
*                                          | ----------- |
*                                          |     TCP     |
*                                          | ----------- |
*                                          |    Conn     |
*                                          |-------------|
*
*$PAGE*
* Note(s) : (1) (a) 'PrevPrimListPtr'/'NextPrimListPtr'/'PrevSecListPtr'/'NextSecListPtr'/'PrevBufPtr'/
*                   'NextBufPtr'/'IP_OptPtr' ideally declared as 'NET_BUF' pointers; declared as 'void'
*                   pointers because 'NET_BUF' NOT defined at time of declaration.
*
*               (b) 'UnlinkFnctPtr' ideally declared as pointer to a function whose argument is a pointer
*                   to a 'NET_BUF'; declared as a function whose argument is a pointer to a 'void' object
*                   because 'NET_BUF' NOT defined at time of declaration.
*
*           (2) Protocol Header & Data indices into DATA area declared as 'CPU_INT16U' because current 
*               TCP/IPv4 header sizes do NOT exceed 'CPU_INT16U' index space.
*
*           (3) 'TotLen'/'DataLen' calculate total buffer data length & 'Application' data length.
*
*               For received buffers, total buffer data length is set to the incoming packet length; 
*               'Application' data length (& index) is calculated as total buffer data lengths minus
*               all protocol header lengths found in the buffer.
*
*               For transmitted buffers, 'Application' data length (& index) is set by higher-layer
*               network protocols or the application layer; total buffer data length is calculated 
*               as the 'Application' data length plus all protocol header lengths inserted into the
*               buffer.
*
*           (4) The following variables ideally declared as specific IP data types; declared as CPU 
*               data types because IP data types NOT defined until 'net_ip.h' (see 'net.h  NETWORK
*               INCLUDE FILES') :
*
*               (a) IP address variables ideally declared as 'NET_IP_ADDR'; declared as 'CPU_INT32U'.
*
*           (5) The following variables ideally declared as specific TCP data types; declared as CPU 
*               data types because TCP data types NOT defined until 'net_tcp.h' (see 'net.h  NETWORK
*               INCLUDE FILES') :
*
*               (a) TCP segment size                  variables ideally declared as 'NET_TCP_SEG_SIZE';
*                       declared as 'CPU_INT16U'.
*
*               (b) TCP window  size                  variables ideally declared as 'NET_TCP_WIN_SIZE';
*                       declared as 'CPU_INT16U'.
*
*               (c) TCP sequence                      variables ideally declared as 'NET_TCP_SEQ_NBR'; 
*                       declared as 'CPU_INT32U'.
*
*               (d) TCP transmit acknowledgement code variables ideally declared as 'NET_TCP_ACK_CODE';
*                       declared as 'CPU_INT08U'.
*
*               (e) TCP transmit RTT timestamp        variables ideally declared as 'NET_TCP_TX_RTT_TS_MS';
*                       declared as 'CPU_INT32U'.
*
*           (6) The following variables ideally declared as specific network connection data types;
*               declared as CPU data types because network connection data types NOT defined until
*               'net_conn.h' (see 'net.h  NETWORK INCLUDE FILES') :
*
*               (a) Connection identification variables ideally declared as 'NET_CONN_ID';
*                       declared as 'CPU_INT16S'.
*********************************************************************************************************
*/
/*$PAGE*/
                                                    /* ------------------------- NET BUF HDR -------------------------- */
typedef  struct  net_buf_hdr {
    NET_TYPE            Type;                       /* Buf type cfg'd @ init : NET_BUF_TYPE_SMALL / NET_BUF_TYPE_LARGE. */
    NET_BUF_SIZE        Size;                       /* Buf size cfg'd @ init : NET_BUF_SIZE_SMALL / NET_BUF_SIZE_LARGE. */
    CPU_INT16U          Flags;                      /* Buf flags.                                                       */


    void               *PrevPrimListPtr;            /* Ptr to PREV prim list.                                           */
    void               *NextPrimListPtr;            /* Ptr to NEXT prim list.                                           */

    void               *PrevSecListPtr;             /* Ptr to PREV sec  list.                                           */
    void               *NextSecListPtr;             /* Ptr to NEXT sec  list.                                           */

    void               *PrevBufPtr;                 /* Ptr to PREV buf.                                                 */
    void               *NextBufPtr;                 /* Ptr to NEXT buf.                                                 */

    NET_TMR            *TmrPtr;                     /* Ptr to buf TMR.                                                  */

    CPU_FNCT_PTR        UnlinkFnctPtr;              /* Ptr to fnct used to unlink buf from multiple refs (see Note #1b).*/
    void               *UnlinkObjPtr;               /* Ptr to obj       to unlink buf from.                             */


    NET_BUF_QTY         ID;                         /* Buf id.                                                          */
    CPU_INT08U          RefCtr;                     /* Nbr of external references pointing to this buf.                 */



    NET_PROTOCOL_TYPE   ProtocolHdrType;            /* Hdr protocol type.                                               */

    CPU_INT16U          IF_HdrIx;                   /* IF      hdr  ix  (in DATA area).                                 */
    CPU_INT16U          IF_HdrLen;                  /* IF      hdr  len (in octets   ).                                 */
    CPU_INT16U          IF_DataLenMin;              /* IF      data len min.                                            */

#ifdef  NET_ARP_MODULE_PRESENT
    CPU_INT16U          ARP_MsgIx;                  /* ARP     msg  ix  (in DATA area).                                 */
    CPU_INT16U          ARP_MsgLen;                 /* ARP     msg  len (in octets   ).                                 */
#endif

    CPU_INT16U          IP_HdrIx;                   /* IP      hdr  ix  (in DATA area).                                 */
    CPU_INT16U          IP_HdrLen;                  /* IP      hdr  len (in octets   ).                                 */

    CPU_INT16U          ICMP_MsgIx;                 /* ICMP    msg  ix  (in DATA area).                                 */
    CPU_INT16U          ICMP_MsgLen;                /* ICMP    msg  len (in octets   ).                                 */
    CPU_INT16U          ICMP_HdrLen;                /* ICMP    hdr  len (in octets   ).                                 */

    CPU_INT16U          TCP_UDP_HdrDataIx;          /* TCP/UDP pkt  ix  (in DATA area).                                 */
    CPU_INT16U          TCP_UDP_HdrLen;             /* TCP/UDP hdr  len (in octets   ).                                 */

    CPU_INT16U          DataIx;                     /* App     DATA ix.                                                 */
    NET_BUF_SIZE        DataLen;                    /* App     DATA len (in octets   ).                                 */

    NET_BUF_SIZE        TotLen;                     /* ALL     DATA len (in DATA area).                                 */



#ifdef  NET_ARP_MODULE_PRESENT
    CPU_INT08U         *ARP_AddrHW_Ptr;             /* Ptr to ARP hw       addr.                                        */
    CPU_INT08U         *ARP_AddrProtocolPtr;        /* Ptr to ARP protocol addr.                                        */
#endif


    CPU_INT16U          IP_TotLen;                  /* IP                   tot  len.                                   */
    CPU_INT16U          IP_DataLen;                 /* IP                   data len.                                   */
    CPU_INT16U          IP_DatagramLen;             /* IP complete datagram data len.                                   */

    CPU_INT16U          IP_ID;                      /* IP datagram id.                                                  */

    CPU_INT16U          IP_Flags_FragOffset;        /* IP rx flags/frag offset.                                         */

    CPU_INT16U          IP_FragSizeTot;             /* Tot IP rx frag size.                                             */
    CPU_INT16U          IP_FragSizeCur;             /* Cur IP rx frag size.                                             */
                                                    /* IP               addrs (see Note #4a) :                          */
    CPU_INT32U          IP_AddrSrc;                 /* IP src           addr.                                           */
    CPU_INT32U          IP_AddrDest;                /* IP dest          addr.                                           */
    CPU_INT32U          IP_AddrNextHop;             /* IP tx 'Next-Hop' addr.                                           */
    CPU_INT32U          IP_AddrNextHopNetOrder;     /* IP tx 'Next-Hop' addr in net-order.                              */

    void               *IP_OptPtr;                  /* Ptr to IP rx opts.                                               */


/*$PAGE*/
    CPU_INT16U          TCP_UDP_TotLen;             /* TCP/UDP tot      len.                                            */
    CPU_INT16U          TCP_UDP_DataLen;            /* TCP/UDP tot data len.                                            */

    NET_PORT_NBR        TCP_UDP_PortSrc;            /* TCP/UDP rx src  port.                                            */
    NET_PORT_NBR        TCP_UDP_PortDest;           /* TCP/UDP rx dest port.                                            */


#ifdef  NET_TCP_MODULE_PRESENT
    CPU_INT16U          TCP_HdrLen_Flags;           /* TCP hdr len/flags.                                               */

    CPU_INT16U          TCP_SegLenInit;             /* TCP init seg len (see Note #5a).                                 */
    CPU_INT16U          TCP_SegLen;                 /* TCP      seg len [i.e. data len & possible sync/close ctrl(s)].  */
    CPU_INT16U          TCP_SegLenLast;             /* TCP last seg len [i.e. last len tx'd].                           */
    CPU_INT16U          TCP_SegLenData;             /* TCP data seg len [i.e. data len].                                */
    CPU_INT16U          TCP_SegReTxCtr;             /* Indicates nbr seg re-tx's.                                       */
    CPU_BOOLEAN         TCP_SegSync;                /* Indicates TCP sync  seg.                                         */
    CPU_BOOLEAN         TCP_SegClose;               /* Indicates TCP close seg.                                         */
    CPU_BOOLEAN         TCP_SegReset;               /* Indicates TCP reset seg.                                         */
    CPU_BOOLEAN         TCP_SegAck;                 /* Indicates TCP ack   seg.                                         */
    CPU_BOOLEAN         TCP_SegAckTxd;              /* Indicates TCP ack tx'd        for rx'd seg.                      */
    CPU_INT08U          TCP_SegAckTxReqCode;        /* Indicates TCP ack tx req code for rx'd seg (see Note #5d).       */

    CPU_INT32U          TCP_SeqNbrInit;             /* TCP init seq nbr  (see Note #5c).                                */
    CPU_INT32U          TCP_SeqNbrLast;             /* TCP last seq nbr                                                 */
    CPU_INT32U          TCP_SeqNbr;                 /* TCP      seq nbr                                                 */
    CPU_INT32U          TCP_AckNbr;                 /* TCP      ack nbr                                                 */
    CPU_INT32U          TCP_AckNbrLast;             /* TCP last ack nbr                                                 */
    CPU_INT16U          TCP_MaxSegSize;             /* TCP max  seg size (see Note #5a).                                */
    CPU_INT16U          TCP_WinSize;                /* TCP      win size (see Note #5b).                                */
    CPU_INT16U          TCP_WinSizeLast;            /* TCP last win size.                                               */

    CPU_INT32U          TCP_RTT_TS_Rxd_ms;          /* TCP RTT TS @ seg rx'd (in ms) [see Note #5e].                    */
    CPU_INT32U          TCP_RTT_TS_Txd_ms;          /* TCP RTT TS @ seg tx'd (in ms).                                   */

    CPU_INT16U          TCP_Flags;                  /* TCP tx flags.                                                    */
#endif


#ifdef  NET_CONN_MODULE_PRESENT
    CPU_INT16S          Conn_ID;                    /*                 Conn id (see Note #6a).                          */
    CPU_INT16S          Conn_ID_Transport;          /* Transport layer conn id.                                         */
    CPU_INT16S          Conn_ID_App;                /* App       layer conn id.                                         */

    CPU_INT08U          ConnType;                   /* Conn type.                                                       */
#endif


} NET_BUF_HDR;


/*$PAGE*/
/*
*********************************************************************************************************
*                                      NETWORK BUFFER DATA TYPE
*
*                                              NET_BUF
*                                          |-------------|
*                                          |             |
*                                          |             |
*                                          |   Buffer    |
*                                          |   Header    |
*                                          |             |
*                                          |             |
*                                          |-------------|
*                                          |  Alignment  |
*                                          |    Word     |
*                                          |-------------|
*                                          |             |
*                                          |             |
*                                          |             |
*                                          |   Buffer    |
*                                          |    Data     |
*                                          |             |
*                                          |             |
*                                          |             |
*                                          |             |
*                                          |-------------|
*
*
* Note(s) : (1) Forced word-alignment at start of network buffer NOT required since first data member 
*               'Hdr.Type' is declared as 'CPU_INT32U'.
*
*           (2) 'Dummy' declared to force 'Data' buffer word-alignment.
*
*           (3) NET_BUF_CFG_DATA_SIZE_SMALL & NET_BUF_CFG_DATA_SIZE_LARGE  MUST be declared with values ...
*
*               (a) that are greater than or equal to NET_BUF_DATA_SIZE_MIN (see 'NETWORK BUFFER INDEX & SIZE DEFINES')
*               (b) such that NET_BUF_CFG_DATA_SIZE_LARGE has a value greater than NET_BUF_CFG_DATA_SIZE_SMALL
*
*               ... and SHOULD be declared with values ...
*
*               (c) that are integer multiples of 'CPU_ALIGN' word size (to force word-alignment of buffer arrays)
*
*           (4) (a) 'Data' buffer is storage for both Protocol Headers & Application data.

⌨️ 快捷键说明

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