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

📄 net_ip.h

📁 ucos的tcpip协议占
💻 H
📖 第 1 页 / 共 4 页
字号:
/*
*********************************************************************************************************
*                                              uC/TCP-IP
*                                      The Embedded TCP/IP Suite
*
*                          (c) Copyright 2003-2006; Micrium, Inc.; Weston, FL
*
*               All rights reserved.  Protected by international copyright laws.
*
*               uC/TCP-IP is provided in source form for FREE evaluation, for educational
*               use or peaceful research.  If you plan on using uC/TCP-IP in a commercial
*               product you need to contact Micrium to properly license its use in your
*               product.  We provide ALL the source code for your convenience and to help
*               you experience uC/TCP-IP.  The fact that the source code is provided does
*               NOT mean that you can use it without paying a licensing fee.
*
*               Knowledge of the source code may NOT be used to develop a similar product.
*
*               Please help us continue to provide the Embedded community with the finest
*               software available.  Your honesty is greatly appreciated.
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*
*                                          NETWORK IP LAYER
*                                         (INTERNET PROTOCOL)
*
* Filename      : net_ip.h
* Version       : V1.87
* Programmer(s) : ITJ
*********************************************************************************************************
* Note(s)       : (1) Supports Internet Protocol as described in RFC #791, also known as IPv4, with the
*                     following restrictions/constraints :
*
*                     (a) ONLY supports a single network interface/            RFC # 791, Section 2.3
*                            host IP address                                                'Addressing'
*
*                     (b) ONLY supports a single default gateway               RFC #1122, Section 3.3.1
*
*                     (c) IP forwarding/routing  NOT           supported       RFC #1122, Sections 3.3.1,
*                                                                                            3.3.4 & 3.3.5
*
*                     (d) IP multicasting        NOT           supported       RFC #1122, Section 3.3.7
*
*                     (e) Transmit fragmentation NOT currently supported       RFC # 791, Section 2.3
*                                                                                           'Fragmentation & 
*                                                                                              Reassembly'
*                     (f) IP Security options    NOT currently supported       RFC #1108
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*                                               EXTERNS
*********************************************************************************************************
*/

#ifdef   NET_IP_MODULE
#define  NET_IP_EXT
#else
#define  NET_IP_EXT  extern
#endif


/*$PAGE*/
/*
*********************************************************************************************************
*                                               DEFINES
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*                                          IP HEADER DEFINES
*
* Note(s) : (1) The following IP value MUST be pre-#define'd in 'net_def.h' PRIOR to 'net_buf.h' so that
*               the Network Buffer Module can configure maximum buffer header size (see 'net_def.h  IP
*               LAYER DEFINES' & 'net_buf.h  NETWORK BUFFER INDEX & SIZE DEFINES  Note #1') :
*
*               (a) NET_IP_HDR_SIZE_MAX                   60        (NET_IP_HDR_LEN_MAX         
*                                                                  * NET_IP_HDR_LEN_WORD_SIZE)
*********************************************************************************************************
*/

#define  NET_IP_HDR_VER_MASK                            0xF0
#define  NET_IP_HDR_VER_SHIFT                              4
#define  NET_IP_HDR_VER                                    4    /* Supports IPv4 ONLY (see 'net_ip.h  Note #1').        */


#define  NET_IP_HDR_LEN_MASK                            0x0F
#define  NET_IP_HDR_LEN_MIN                                5
#define  NET_IP_HDR_LEN_MAX                               15
#define  NET_IP_HDR_LEN_WORD_SIZE                        CPU_WORD_SIZE_32

#define  NET_IP_HDR_SIZE_MIN                            (NET_IP_HDR_LEN_MIN * NET_IP_HDR_LEN_WORD_SIZE)
#if 0                                                           /* See Note #1a.                                        */
#define  NET_IP_HDR_SIZE_MAX                            (NET_IP_HDR_LEN_MAX * NET_IP_HDR_LEN_WORD_SIZE)
#endif

#define  NET_IP_HDR_SIZE_TOT_MIN                        (NET_IF_HDR_SIZE_TOT_MIN + NET_IP_HDR_SIZE_MIN)
#define  NET_IP_HDR_SIZE_TOT_MAX                        (NET_IF_HDR_SIZE_TOT_MAX + NET_IP_HDR_SIZE_MAX)


#define  NET_IP_ID_NONE                                    0
#define  NET_IP_ID_INIT                                  NET_IP_ID_NONE


#define  NET_IP_HDR_TTL_NONE                               0    /* On IP Tx, subst _DFLT for _NONE.                     */
#define  NET_IP_HDR_TTL_MIN                                1
#define  NET_IP_HDR_TTL_MAX                              255
#define  NET_IP_HDR_TTL_DFLT                             128

#define  NET_IP_TTL_NONE                                 NET_IP_HDR_TTL_NONE
#define  NET_IP_TTL_DFLT                                 NET_IP_HDR_TTL_DFLT


/*$PAGE*/
/*
*********************************************************************************************************
*                               IP HEADER TYPE OF SERVICE (TOS) DEFINES
*
* Note(s) : (1) See 'IP HEADER  Note #3'                     for TOS            fields.
*
*           (2) See RFC #791,  Section 3.1 'Type of Service' for TOS Precedence values.
*
*           (3) See RFC #1349, Section 4                     for TOS            values.
*********************************************************************************************************
*/

#define  NET_IP_HDR_TOS_PRECEDNCE_ROUTINE               0x00
#define  NET_IP_HDR_TOS_PRECEDNCE_PRIO                  0x20
#define  NET_IP_HDR_TOS_PRECEDNCE_IMMED                 0x40
#define  NET_IP_HDR_TOS_PRECEDNCE_FLASH                 0x60
#define  NET_IP_HDR_TOS_PRECEDNCE_FLASH_OVERRIDE        0x80
#define  NET_IP_HDR_TOS_PRECEDNCE_CRITIC_ECP            0xA0
#define  NET_IP_HDR_TOS_PRECEDNCE_INTERNET_CTRL         0xC0
#define  NET_IP_HDR_TOS_PRECEDNCE_NET_CTRL              0xE0

#define  NET_IP_HDR_TOS_PRECEDNCE_MASK                  0xE0
#define  NET_IP_HDR_TOS_PRECEDNCE_DFLT                   NET_IP_HDR_TOS_PRECEDNCE_ROUTINE


#define  NET_IP_HDR_TOS_NONE                            0x00
#define  NET_IP_HDR_TOS_LO_DLY                          0x10
#define  NET_IP_HDR_TOS_HI_THRUPUT                      0x08
#define  NET_IP_HDR_TOS_HI_RELIABILITY                  0x04
#define  NET_IP_HDR_TOS_LO_COST                         0x02

#define  NET_IP_HDR_TOS_MASK                            0x1E
#define  NET_IP_HDR_TOS_DFLT                             NET_IP_HDR_TOS_NONE


#define  NET_IP_HDR_TOS_MBZ_MASK                        0x01
#define  NET_IP_HDR_TOS_MBZ_DFLT                        0x00

#define  NET_IP_HDR_TOS_RESERVED                         NET_IP_HDR_TOS_MBZ_DFLT


#define  NET_IP_TOS_DFLT                                (NET_IP_HDR_TOS_PRECEDNCE_DFLT | \
                                                         NET_IP_HDR_TOS_DFLT           | \
                                                         NET_IP_HDR_TOS_MBZ_DFLT)

/*$PAGE*/
/*
*********************************************************************************************************
*                   IP DATA/TOTAL LENGTH & MAXIMUM TRANSMISSION UNIT (MTU) DEFINES
*
* Note(s) : (1) (a) IP total length #define's (NET_IP_TOT_LEN)  relate to the total size of a complete IP
*                   datagram, including the packet's IP header.  Note that a complete IP datagram MAY be
*                   fragmented in multiple IP packets.
*
*               (b) IP data  length #define's (NET_IP_DATA_LEN) relate to the data  size of a complete IP
*                   datagram, equal to the total IP datagram length minus its IP header size.  Note that
*                   a complete IP datagram MAY be fragmented in multiple IP packets.
*
*               (c) IP MTU #define's (NET_IP_MTU) relate to the data size for any single, non-fragmented
*                   IP packet, equal to a packet's Network Interface MTU minus its IP header size.
*
*           (2) RFC #791, Section 3.1 'Total Length' "recommend[s] that hosts only send datagrams larger
*               than 576 octets if ... the destination is prepared to accept the larger datagrams"; while
*               RFC #879, Section 1 requires that "HOSTS MUST NOT SEND DATAGRAMS LARGER THAN 576 OCTETS
*               UNLESS ... THE DESTINATION HOST IS PREPARED TO ACCEPT LARGER DATAGRAMS".
*********************************************************************************************************
*/

                                                                                /* See Notes #1a & #1b.                 */
#define  NET_IP_DATA_LEN_MIN                               0

#define  NET_IP_TOT_LEN_MIN                             (NET_IP_HDR_SIZE_MIN + NET_IP_DATA_LEN_MIN)
#define  NET_IP_TOT_LEN_MAX                            65535

#define  NET_IP_DATA_LEN_MAX                            (NET_IP_TOT_LEN_MAX  - NET_IP_HDR_SIZE_MIN)


                                                                                /* See Note #1c.                        */
#define  NET_IP_MTU_MIN                                 (NET_IF_MTU          - NET_IP_HDR_SIZE_MAX)
#define  NET_IP_MTU_MAX                                 (NET_IF_MTU          - NET_IP_HDR_SIZE_MIN)
#define  NET_IP_MTU                                      NET_IP_MTU_MIN



#define  NET_IP_MAX_DATAGRAM_SIZE_DFLT                   576                    /* See Note #2.                         */


/*$PAGE*/
/*
*********************************************************************************************************
*                                       IP HEADER FLAG DEFINES
*
* Note(s) : (1) See 'IP HEADER  Note #4' for flag fields.
*********************************************************************************************************
*/

#define  NET_IP_HDR_FLAG_MASK                         0xE000

#define  NET_IP_HDR_FLAG_NONE                     DEF_BIT_NONE
#define  NET_IP_HDR_FLAG_RESERVED                 DEF_BIT_15    /* MUST be '0'.                                         */
#define  NET_IP_HDR_FLAG_FRAG_DONT                DEF_BIT_14
#define  NET_IP_HDR_FLAG_FRAG_MORE                DEF_BIT_13


/*
*********************************************************************************************************
*                                      IP FRAGMENTATION DEFINES
*********************************************************************************************************
*/

#define  NET_IP_HDR_FRAG_OFFSET_MASK                  0x1FFF
#define  NET_IP_HDR_FRAG_OFFSET_NONE                       0
#define  NET_IP_HDR_FRAG_OFFSET_MIN                        0
#define  NET_IP_HDR_FRAG_OFFSET_MAX                     8191

#define  NET_IP_HDR_FRAG_OFFSET_SIZE                       8    /* Frag offset size = 8 octets.                         */
#define  NET_IP_HDR_FRAG_OFFSET_SIZE_MIN                   1    /* Min nbr of frag octets (last frag ONLY).             */
#define  NET_IP_HDR_FRAG_OFFSET_SIZE_MAX               ((NET_IP_TOT_LEN_MAX - NET_IP_HDR_SIZE_MIN) \
                                                       / NET_IP_HDR_FRAG_OFFSET_SIZE)

#define  NET_IP_FRAG_SIZE_NONE                         65535


#define  NET_IP_FRAG_REASM_TIMEOUT_MIN_SEC                 1    /* IP frag reasm timeout min  =  1 seconds              */
#define  NET_IP_FRAG_REASM_TIMEOUT_MAX_SEC                10    /* IP frag reasm timeout max  = 10 seconds              */
#define  NET_IP_FRAG_REASM_TIMEOUT_DFLT_SEC                5    /* IP frag reasm timeout dflt =  5 seconds              */


/*
*********************************************************************************************************
*                                  IP HEADER PROTOCOL FIELD DEFINES
*
* Note(s) : (1) See 'IP HEADER  Note #5'.
*********************************************************************************************************
*/

#define  NET_IP_HDR_PROTOCOL_ICMP                          1
#define  NET_IP_HDR_PROTOCOL_TCP                           6
#define  NET_IP_HDR_PROTOCOL_UDP                          17

⌨️ 快捷键说明

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