39,7 → 39,7 |
#define __NET_IP_HEADER_H__ |
|
#include <byteorder.h> |
#include <types.h> |
#include <sys/types.h> |
|
/** Type definition of the internet header. |
* @see ip_header |
58,19 → 58,19 |
#ifdef ARCH_IS_BIG_ENDIAN |
/** The Version field indicates the format of the internet header. |
*/ |
uint8_t:4 version; |
uint8_t version:4; |
/** Internet Header Length is the length of the internet header in 32~bit words, and thus points to the beginning of the data. |
* Note that the minimum value for a~correct header is~5. |
*/ |
uint8_t:4 ihl; |
uint8_t ihl:4; |
#else |
/** Internet Header Length is the length of the internet header in 32~bit words, and thus points to the beginning of the data. |
* Note that the minimum value for a~correct header is~5. |
*/ |
uint8_t:4 ihl; |
uint8_t ihl:4; |
/** The Version field indicates the format of the internet header. |
*/ |
uint8_t:4 version; |
uint8_t version:4; |
#endif |
/** The Type of Service provides an indication of the abstract parameters of the quality of service desired. |
* These parameters are to be used to guide the selection of the actual service parameters when transmitting a~datagram through a~particular network. |
84,21 → 84,21 |
uint16_t total_length; |
/** An identifying value assigned by the sender to aid in assembling the fragments of a~datagram. |
*/ |
unit16_t identification; |
uint16_t identification; |
#ifdef ARCH_IS_BIG_ENDIAN |
/** Various control flags. |
*/ |
uint_16:3 flags; |
uint16_t flags:3; |
/** This field indicates where in the datagram this fragment belongs. |
*/ |
uint_16:13 fragment_offset; |
uint16_t fragment_offset:3; |
#else |
/** This field indicates where in the datagram this fragment belongs. |
*/ |
uint_16:13 fragment_offset; |
uint16_t fragment_offset:13; |
/** Various control flags. |
*/ |
uint_16:3 flags; |
uint16_t flags:3; |
#endif |
/** This field indicates the maximum time the datagram is allowed to remain in the internet system. |
* If this field contains the value zero, then the datagram must be destroyed. |
132,7 → 132,7 |
/** Type definition of the internet option header pointer. |
* @see ip_header |
*/ |
typedef ip_option * ip_option_ref; |
typedef ip_option_t * ip_option_ref; |
|
/** Internet option header. |
* Only type field is always valid. |
151,49 → 151,20 |
#ifdef ARCH_IS_BIG_ENDIAN |
/** The number of IP modules that cannot register timestamps due to lack of space. |
*/ |
uint8_t:4 overflow; |
uint8_t overflow:4; |
/** Various internet timestamp control flags. |
*/ |
uint8_t:4 flags; |
uint8_t flags:4; |
#else |
/** Various internet timestamp control flags. |
*/ |
uint8_t:4 flags; |
uint8_t flags:4; |
/** The number of IP modules that cannot register timestamps due to lack of space. |
*/ |
uint8_t:4 overflow; |
uint8_t overflow:4; |
#endif |
} __attribute__ ((packed)); |
|
#define IPTOS_TOS_MASK 0x1E |
#define IPTOS_PRECEDENCE_SHIFT 5 |
#define IPTOS_DELAY_SHIFT 4 |
#define IPTOS_THROUGHPUT_SHIFT 3 |
#define IPTOS_RELIABILITY_SHIFT 2 |
#define IPTOS_COST_SHIFT 1 |
|
#define IPTOS_NORMALDELAY ( 0x0 << IPTOS_DELAY_SHIFT ) |
#define IPTOS_LOWDELAY ( 0x1 << IPTOS_DELAY_SHIFT ) |
|
#define IPTOS_NORMALTHROUGHPUT ( 0x0 << IPTOS_THROUGHPUT_SHIFT ) |
#define IPTOS_THROUGHPUT ( 0x1 << IPTOS_THROUGHPUT_SHIFT ) |
|
#define IPTOS_NORMALRELIABILITY ( 0x0 << IPTOS_RELIABILITY_SHIFT ) |
#define IPTOS_RELIABILITY ( 0x1 << IPTOS_RELIABILITY_SHIFT ) |
|
#define IPTOS_NORMALCOST ( 0x0 << IPTOS_COST_SHIFT ) |
#define IPTOS_MICNCOST ( 0x1 << IPTOS_COST_SHIFT ) |
|
#define IPTOS_PREC_MASK 0xE0 |
#define IPTOS_PREC_ROUTINE ( 0x0 << IPTOS_PRECEDENCE_SHIFT ) |
#define IPTOS_PREC_PRIORITY ( 0x1 << IPTOS_PRECEDENCE_SHIFT ) |
#define IPTOS_PREC_IMMEDIATE ( 0x2 << IPTOS_PRECEDENCE_SHIFT ) |
#define IPTOS_PREC_FLASH ( 0x3 << IPTOS_PRECEDENCE_SHIFT ) |
#define IPTOS_PREC_FLASHOVERRIDE ( 0x4 << IPTOS_PRECEDENCE_SHIFT ) |
#define IPTOS_PREC_CRITIC_ECP ( 0x5 << IPTOS_PRECEDENCE_SHIFT ) |
#define IPTOS_PREC_INTERNETCONTROL ( 0x6 << IPTOS_PRECEDENCE_SHIFT ) |
#define IPTOS_PREC_NETCONTROL ( 0x7 << IPTOS_PRECEDENCE_SHIFT ) |
|
#define IPFLAG_FRAGMENT_SHIFT 1 |
#define IPFLAG_FRAGMENTED_SHIFT 0 |
|
203,70 → 174,14 |
#define IPFLAG_LAST_FRAGMENT ( 0x0 << IPFLAG_FRAGMENTED_SHIFT ) |
#define IPFLAG_MORE_FRAGMENTS ( 0x1 << IPFLAG_FRAGMENTED_SHIFT ) |
|
#define IPOPT_COPY_SHIFT 7 |
#define IPOPT_CLASS_SHIFT 5 |
#define IPOPT_NUMBER_SHIFT 0 |
#define IPOPT_CLASS_MASK 0x60 |
#define IPOPT_NUMBER_MASK 0x1F |
|
#define IPOPT_COPY ( 1 << IPOPT_COPY_SHIFT ) |
|
#define IPOPT_TYPE( copy, class, number ) ((( copy ) & IPOPT_COPY ) | (( class ) & IPOPT_CLASS_MASK ) | (( number << IPOPT_NUMBER_SHIFT ) & IPOPT_NUMBER_MASK )) |
|
#define IPOPT_COPIED( o ) (( o ) & IPOPT_COPY ) |
#define IPOPT_CLASS( o ) (( o ) & IPOPT_CLASS_MASK ) |
#define IPOPT_NUMBER( o ) (( o ) & IPOPT_NUMBER_MASK ) |
|
#define IPOPT_CONTROL ( 1 << IPOPT_CLASS_SHIFT ) |
#define IPOPT_RESERVED1 ( 2 << IPOPT_CLASS_SHIFT ) |
#define IPOPT_MEASUREMENT ( 3 << IPOPT_CLASS_SHIFT ) |
#define IPOPT_RESERVED2 ( 4 << IPOPT_CLASS_SHIFT ) |
|
//#define IPOPT_END_OF_LIST 0x0 |
#define IPOPT_END IPOPT_TYPE( 0, IPOPT_CONTROL, 0 ) |
//#define IPOPT_NO_OPERATION 0x1 |
#define IPOPT_NOOP IPOPT_TYPE( 0, IPOPT_CONTROL, 1 ) |
//#define IPOPT_SECURITY 0x82 |
#define IPOPT_SEC IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 2 ) |
#define IPOPT_SEC_LENGTH 11 |
#define IPOPT_SEC_UNCLASIFIED 0x0 |
#define IPOPT_SEC_CONFIDENTIAL 0xF035 |
#define IPOPT_SEC_EFTO 0x789A |
#define IPOPT_SEC_MMMM 0xBC4D |
#define IPOPT_SEC_PROG 0x5E26 |
#define IPOPT_SEC_RESTRICTED 0xAF13 |
#define IPOPT_SEC_SECRET 0xD788 |
#define IPOPT_SEC_TOP_SECRET 0x6BC5 |
//#define IPOPT_LOOSE_SOURCE 0x83 |
#define IPOPT_LSRR IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 3 ) |
//#define IPOPT_STRICT_SOURCE 0x89 |
#define IPOPT_SSRR IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 9 ) |
//#define IPOPT_RECORD_ROUTE 0x07 |
#define IPOPT_RR IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 7 ) |
//#define IPOPT_STREAM_IDENTIFIER 0x88 |
#define IPOPT_SID IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 8 ) |
#define IPOPT_SID_LENGTH 4 |
//#define IPOPT_INTERNET_TIMESTAMP 0x44 |
#define IPOPT_TIMESTAMP IPOPT_TYPE( IPOPT_COPY, IPOPT_MEASUREMENT, 4 ) |
#define IPOPT_CIPSO IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 5 ) |
|
#define IPVERSION 4 |
#define MAXTTL 255 |
#define IPDEFTTL 64 |
|
/* |
#define IPOPT_OPTVAL 0 |
#define IPOPT_OLEN 1 |
#define IPOPT_OFFSET 2 |
#define IPOPT_MINOFF 4 |
#define MAX_IPOPTLEN 40 |
#define IPOPT_NOP IPOPT_NOOP |
#define IPOPT_EOL IPOPT_END |
#define IPOPT_TS IPOPT_TIMESTAMP |
*/ |
|
#define IPOPT_TS_TSONLY 0 /* timestamps only */ |
#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ |
#define IPOPT_TS_PRESPEC 3 /* specified modules only */ |
|
#endif |
|
/** @} |