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

📄 net_ip.h

📁 ucos的tcpip协议占
💻 H
📖 第 1 页 / 共 4 页
字号:
#elif   (CPU_CFG_DATA_SIZE   == CPU_WORD_SIZE_16)
#define  NET_IP_OPT_CFG_TYPE_NONE                 0x4F4E454E    /* "NONE" in ASCII.                                     */
#define  NET_IP_OPT_CFG_TYPE_ROUTE_STRICT         0x54525453    /* "RTST" in ASCII.                                     */
#define  NET_IP_OPT_CFG_TYPE_ROUTE_LOOSE          0x5452534C    /* "RTLS" in ASCII.                                     */
#define  NET_IP_OPT_CFG_TYPE_ROUTE_REC            0x54524352    /* "RTRC" in ASCII.                                     */
#define  NET_IP_OPT_CFG_TYPE_TS_ONLY              0x53542020    /* "TS  " in ASCII.                                     */
#define  NET_IP_OPT_CFG_TYPE_TS_ROUTE_REC         0x53544352    /* "TSRC" in ASCII.                                     */
#define  NET_IP_OPT_CFG_TYPE_TS_ROUTE_SPEC        0x53545452    /* "TSRT" in ASCII.                                     */
#define  NET_IP_OPT_CFG_TYPE_SECURITY             0x45532043    /* "SEC " in ASCII (see 'net_ip.h  Note #1f').          */
#define  NET_IP_OPT_CFG_TYPE_SECURITY_EXTENDED    0x45535843    /* "SECX" in ASCII (see 'net_ip.h  Note #1f').          */

#else                                                           /* Dflt CPU_WORD_SIZE_08.                               */
#define  NET_IP_OPT_CFG_TYPE_NONE                 0x4E4F4E45    /* "NONE" in ASCII.                                     */
#define  NET_IP_OPT_CFG_TYPE_ROUTE_STRICT         0x52545354    /* "RTST" in ASCII.                                     */
#define  NET_IP_OPT_CFG_TYPE_ROUTE_LOOSE          0x52544C53    /* "RTLS" in ASCII.                                     */
#define  NET_IP_OPT_CFG_TYPE_ROUTE_REC            0x52545243    /* "RTRC" in ASCII.                                     */
#define  NET_IP_OPT_CFG_TYPE_TS_ONLY              0x54532020    /* "TS  " in ASCII.                                     */
#define  NET_IP_OPT_CFG_TYPE_TS_ROUTE_REC         0x54535243    /* "TSRC" in ASCII.                                     */
#define  NET_IP_OPT_CFG_TYPE_TS_ROUTE_SPEC        0x54535254    /* "TSRT" in ASCII.                                     */
#define  NET_IP_OPT_CFG_TYPE_SECURITY             0x53454320    /* "SEC " in ASCII (see 'net_ip.h  Note #1f').          */
#define  NET_IP_OPT_CFG_TYPE_SECURITY_EXTENDED    0x53454358    /* "SECX" in ASCII (see 'net_ip.h  Note #1f').          */

#endif
#endif


/*
*********************************************************************************************************
*                                           IP FLAG DEFINES
*********************************************************************************************************
*/

                                                                /* ------------------- NET IP FLAGS ------------------- */
#define  NET_IP_FLAG_NONE                             0x0000

                                                                /* IP tx flags copied from IP hdr flags.                */
#define  NET_IP_FLAG_TX_DONT_FRAG                     NET_IP_HDR_FLAG_FRAG_DONT


/*
*********************************************************************************************************
*                                    IP INTERNET TIMESTAMP DEFINES
*********************************************************************************************************
*/

#define  NET_IP_TS_NONE                           ((NET_TS)0)


/*$PAGE*/
/*
*********************************************************************************************************
*                                             DATA TYPES
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*                                 IP TYPE OF SERVICE (TOS) DATA TYPE
*********************************************************************************************************
*/

typedef  CPU_INT08U  NET_IP_TOS;


/*
*********************************************************************************************************
*                                   IP TIME TO LIVE (TTL) DATA TYPE
*********************************************************************************************************
*/

typedef  CPU_INT08U  NET_IP_TTL;


/*
*********************************************************************************************************
*                                        IP ADDRESS DATA TYPE
*********************************************************************************************************
*/

typedef  CPU_INT32U  NET_IP_ADDR;                               /* Defines IPv4 IP addr size.                           */


/*$PAGE*/
/*
*********************************************************************************************************
*                                             IP HEADER
*
* Note(s) : (1) See RFC #791, Section 3.1 for IP datagram header format.
*
*           (2) IP Version Number & Header Length are coded in the first octet of an IP header as follows :
*
*                         7 6 5 4   3 2 1 0
*                       ---------------------
*                       |  V E R  | H L E N |
*                       ---------------------
*
*                   where
*                           VER         IP version; currently 4 (see 'net_ip.h  Note #1')
*                           HLEN        IP Headers' length in 32-bit words; MUST be at least 5 (20-octet header) 
*                                           & MUST be less than or equal to 15 (60-octet header)
*
*           (3) Type of Service (TOS) is coded in the second octet of an IP header as follows (see 'RFC #1349
*               Type of Service in the Internet Protocol Suite' for required TOS implementation) :
*
*                        7   6   5   4   3   2   1   0
*                       --------------------------------
*                       |PRECEDENCE| D | T | R | C | 0 |
*                       --------------------------------
*
*                   where
*                           PRECEDENCE      Datagram Priority (see 'IP HEADER TYPE OF SERVICE (TOS) DEFINES') :
*                                               '000' - Lowest  "Routine"         Priority (default)
*                                               '111' - Highest "Network Control" Priority
*                           D               Datagram Delay Request :
*                                               '0' - Normal Delay       requested (default)
*                                               '1' - Low    Delay       requested
*                           T               Datagram Throughput Request :
*                                               '0' - Normal Throughput  requested (default)
*                                               '1' - High   Throughput  requested
*                           R               Datagram Reliability Request :
*                                               '0' - Normal Reliability requested (default)
*                                               '1' - High   Reliability requested
*                           C               Datagram Cost Request :
*                                               '0' - Normal Cost        requested (default)
*                                               '1' - Low    Cost        requested
*                           0               MUST be zero; i.e. '0'
*
*           (4) Flags & Fragment Offset are coded in the seventh & eighth octets of an IP header as follows :
*
*                        15 14 13  12 11 10 9 8 7 6 5 4 3 2 1 0
*                       ----------------------------------------
*                       | 0 DF MF |      FRAGMENT OFFSET       |
*                       ----------------------------------------
*
*                   where
*                           0                   MUST be zero; i.e. '0'
*                           DF                  'Do Not Fragment' Flag :
*                                                   '0' - Datagram fragmentation     allowed
*                                                   '1' - Datagram fragmentation NOT allowed
*                           MF                  'More Fragments' Flag :
*                                                   '0' - No more fragments for datagram; i.e. last fragment
*                                                   '1' -    More fragments for datagram
*                           FRAGMENT OFFSET     Offset of fragment in original datagram, measured in units of
*                                                   8 octets (64 bits)
*
*           (5) Supports ONLY a sub-set of allowed protocol numbers :
*
*               (a) ICMP
*               (b) UDP
*               (c) TCP
*
*               See also 'net.h  Note #1a';
*                  & see 'RFC #1340  Assigned Numbers' for a complete list of protocol numbers.
*********************************************************************************************************
*/

                                                                /* -------------------- NET IP HDR -------------------- */
typedef  struct  net_ip_hdr {
    CPU_INT08U          Ver_HdrLen;                             /* IP datagram ver nbr/hdr len   (see Note #2).         */
    NET_IP_TOS          TOS;                                    /* IP datagram TOS               (see Note #3).         */
    CPU_INT16U          TotLen;                                 /* IP datagram tot len.                                 */
    CPU_INT16U          ID;                                     /* IP datagram ID.                                      */
    CPU_INT16U          Flags_FragOffset;                       /* IP datagram flags/frag offset (see Note #4).         */
    NET_IP_TTL          TTL;                                    /* IP datagram TTL.                                     */
    CPU_INT08U          Protocol;                               /* IP datagram protocol          (see Note #5).         */
    NET_CHK_SUM         ChkSum;                                 /* IP datagram chk sum.                                 */
    NET_IP_ADDR         AddrSrc;                                /* IP datagram src  addr.                               */
    NET_IP_ADDR         AddrDest;                               /* IP datagram dest addr.                               */
    NET_IP_OPT_SIZE     Opts[NET_IP_HDR_OPT_NBR_MAX];           /* IP datagram opts (if any).                           */
} NET_IP_HDR;


/*$PAGE*/
/*
*********************************************************************************************************
*                                     IP HEADER OPTION DATA TYPES
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*                                  IP SOURCE ROUTE OPTION DATA TYPE
*
* Note(s) : (1) See the following RFC's for Source Route options summary :
*
*               (a) RFC # 791, Section 3.1         'Options : Loose/Strict Source & Record Route'
*               (b) RFC #1122, Section 3.2.1.8.(c)
*
*           (2) Used for both Source Route options & Record Route options :
*
*               (a) NET_IP_HDR_OPT_ROUTE_SRC_LOOSE
*               (b) NET_IP_HDR_OPT_ROUTE_SRC_STRICT
*               (c) NET_IP_HDR_OPT_ROUTE_REC
*
*           (3) 'Route' declared with 1 entry; prevents removal by compiler optimization.
*********************************************************************************************************
*/

typedef  struct  net_ip_opt_src_route {
    CPU_INT08U          Type;                                   /* Src route type (see Note #2).                        */
    CPU_INT08U          Len;                                    /* Len of   src route opt (in octets).                  */
    CPU_INT08U          Ptr;                                    /* Ptr into src route opt (octet-ix'd).                 */
    CPU_INT08U          Pad;                                    /* ???? Forced word-alignment pad octet.                */
    NET_IP_ADDR         Route[1];                               /* Src route IP addrs (see Note #3).                    */
} NET_IP_OPT_SRC_ROUTE;


/*$PAGE*/
/*
*********************************************************************************************************
*                               IP INTERNET TIMESTAMP OPTION DATA TYPE
*
* Note(s) : (1) See the following RFC's for Internet Timestamp option summary :
*
*               (a) RFC # 791, Section 3.1         'Options : Internet Timestamp'
*               (b) RFC #1122, Section 3.2.1.8.(e)
*
*           (2) 'TS'/'Route'/'Route_TS' declared with 1 entry; prevents removal by compiler optimization.
*********************************************************************************************************
*/

typedef  struct  net_ip_opt_ts {
    CPU_INT08U          Type;                                   /* TS type.                                             */
    CPU_INT08U          Len;                                    /* Len of   src route opt (in octets).                  */
    CPU_INT08U          Ptr;                                    /* Ptr into src route opt (octet-ix'd).                 */
    CPU_INT08U          Ovf_Flags;                              /* Ovf/Flags.                                           */
    NET_TS              TS[1];                                  /* Timestamps (see Note #2).                            */
} NET_IP_OPT_TS;



typedef  struct  net_ip_route_ts {
    NET_IP_ADDR         Route[1];                               /* Route IP addrs (see Note #2).                        */
    NET_TS              TS[1];                                  /* Timestamps     (see Note #2).                        */
} NET_IP_ROUTE_TS;

#define  NET_IP_OPT_TS_ROUTE_SIZE                (sizeof(NET_IP_ROUTE_TS))


typedef  struct  net_ip_opt_ts_route {
    CPU_INT08U          Type;                                   /* TS type.                                             */
    CPU_INT08U          Len;                                    /* Len of   src route opt (in octets).                  */
    CPU_INT08U          Ptr;                                    /* Ptr into src route opt (octet-ix'd).                 */
    CPU_INT08U          Ovf_Flags;                              /* Ovf/Flags.                                           */
    NET_IP_ROUTE_TS     Route_TS[1];                            /* Route IP addrs / TS (see Note #2).                   */
} NET_IP_OPT_TS_ROUTE;


/*$PAGE*/
/*
*********************************************************************************************************
*                              IP HEADER OPTION CONFIGURATION DATA TYPES
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*                    IP ROUTE & INTERNET TIMESTAMP OPTIONS CONFIGURATION DATA TYPE

⌨️ 快捷键说明

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