The IPv4 packet header has the following content:
ip_vhl (1 byte): // IP ver/hdrlen (version << 4 | header length >> 2) ip_tos (1 byte): // Type of service ip_len (2 bytes): // Total length ip_id (2 bytes): // Identification ip_off (2 bytes): // Fragment offset field (least-significant 13 bits) ip_ttl (1 byte): // Time to live ip_p (1 byte): // Protocol ip_sum (2 bytes): // Checksum ip_src (4 bytes): // Source address ip_dst (4 bytes): // Destination address
IpHeader4 (const uint8_t* data)
| IpHeader4 |
static const size_t SIZE | SIZE |
static const uint8_t IP_VERSION | IP_VERSION |
size_t size ()
| size |
[static]
Get the IPv4 packet header size.
Note that this is the header size only without any header options.
Returns: the IPv4 packet header size.
const uint8_t* data ()
| data |
[const]
Get the buffer data.
Returns: the buffer data.
uint8_t ip_vhl ()
| ip_vhl |
[const]
Methods to get various IP header fields.
uint8_t ip_tos ()
| ip_tos |
[const]
uint16_t ip_len ()
| ip_len |
[const]
uint16_t ip_id ()
| ip_id |
[const]
uint16_t ip_off ()
| ip_off |
[const]
uint8_t ip_ttl ()
| ip_ttl |
[const]
uint8_t ip_p ()
| ip_p |
[const]
uint16_t ip_sum ()
| ip_sum |
[const]
IPv4 ip_src ()
| ip_src |
[const]
IPv4 ip_dst ()
| ip_dst |
[const]
uint16_t ip_len_host ()
| ip_len_host |
[const]
uint8_t ip_version ()
| ip_version |
[const]
Get the IP protocol version of the header.
Returns: the IP protocol version of the header.
uint8_t ip_header_len ()
| ip_header_len |
[const]
Get the IPv4 packet header size (including any header options).
Returns: the IPv4 packet header size (including any header options).
uint16_t ip_fragment_offset ()
| ip_fragment_offset |
[const]
Get the IPv4 fragment offset (excluding the fragment flags).
Returns: the IPv4 fragment offset (excluding the fragment flags).
uint16_t ip_fragment_flags ()
| ip_fragment_flags |
[const]
Get the IPv4 fragment flags.
Returns: the IPv4 fragment flags.
bool is_valid_version ()
| is_valid_version |
[const]
Test whether the IP header version is valid.
Returns: true if the IP header version is valid, otherwise false.
int fragment (size_t mtu, list<vector<uint8_t> >& fragments,
bool do_checksum, string& error_msg)
| fragment |
[const]
Fragment an IPv4 packet.
Note: If the original packet is not larger than the MTU, then the packet is not fragmented (i.e., fragments is empty), and the return value is XORP_OK.
Parameters:
mtu | the MTU for fragmenting the packet. |
fragments | the return-by-reference fragments of the IPv4 packet. |
do_checksum | if true, compute and set the checksum in the IPv4 header, otherwise reset it to zero. |
error_msg | the error message (if error). |
Returns: XORP_OK on success, otherwise XORP_ERROR.
static const uint16_t FRAGMENT_OFFSET_MASK | FRAGMENT_OFFSET_MASK |
[protected]
static const uint16_t FRAGMENT_FLAGS_MASK | FRAGMENT_FLAGS_MASK |
[protected]
static const uint16_t FRAGMENT_FLAGS_IP_DF | FRAGMENT_FLAGS_IP_DF |
[protected]
static const uint16_t FRAGMENT_FLAGS_IP_MF | FRAGMENT_FLAGS_IP_MF |
[protected]
static const uint8_t OPTIONS_IPOPT_EOL | OPTIONS_IPOPT_EOL |
[protected]
static const uint8_t OPTIONS_IPOPT_NOP | OPTIONS_IPOPT_NOP |
[protected]
static const size_t OPTIONS_IPOPT_OLEN | OPTIONS_IPOPT_OLEN |
[protected]
static const uint8_t OPTIONS_COPIED_FLAG | OPTIONS_COPIED_FLAG |
[protected]
static const size_t _ip_vhl_sizeof | _ip_vhl_sizeof |
[protected]
static const size_t _ip_tos_sizeof | _ip_tos_sizeof |
[protected]
static const size_t _ip_len_sizeof | _ip_len_sizeof |
[protected]
static const size_t _ip_id_sizeof | _ip_id_sizeof |
[protected]
static const size_t _ip_off_sizeof | _ip_off_sizeof |
[protected]
static const size_t _ip_ttl_sizeof | _ip_ttl_sizeof |
[protected]
static const size_t _ip_p_sizeof | _ip_p_sizeof |
[protected]
static const size_t _ip_sum_sizeof | _ip_sum_sizeof |
[protected]
static const size_t _ip_src_sizeof | _ip_src_sizeof |
[protected]
static const size_t _ip_dst_sizeof | _ip_dst_sizeof |
[protected]
static const size_t _ip_vhl_offset | _ip_vhl_offset |
[protected]
static const size_t _ip_tos_offset | _ip_tos_offset |
[protected]
static const size_t _ip_len_offset | _ip_len_offset |
[protected]
static const size_t _ip_id_offset | _ip_id_offset |
[protected]
static const size_t _ip_off_offset | _ip_off_offset |
[protected]
static const size_t _ip_ttl_offset | _ip_ttl_offset |
[protected]
static const size_t _ip_p_offset | _ip_p_offset |
[protected]
static const size_t _ip_sum_offset | _ip_sum_offset |
[protected]
static const size_t _ip_src_offset | _ip_src_offset |
[protected]
static const size_t _ip_dst_offset | _ip_dst_offset |
[protected]