Helper Reference Manual  1.7.1
ip.h File Reference

ODP IP header. More...

#include <odp_api.h>
#include <odp/helper/chksum.h>
#include <string.h>
Include dependency graph for ip.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ODP_PACKED
 Ethernet MAC address. More...
 

Macros

#define ODPH_IPV4   4
 IP version 4.
 
#define ODPH_IPV4HDR_LEN   20
 Min length of IP header (no options)
 
#define ODPH_IPV4HDR_IHL_MIN   5
 Minimum IHL value.
 
#define ODPH_IPV4ADDR_LEN   4
 IPv4 address length in bytes.
 
#define ODPH_IP_TOS_MAX_DSCP   63
 The one byte IPv4 tos or IPv6 tc field is composed of the following two subfields - a six bit Differentiated Service Code Point (DSCP) and a two bit Explicit Congestion Notification (ECN) subfield. More...
 
#define ODPH_IP_TOS_DSCP_MASK   0xFC
 DSCP field is in bits <7:2>

 
#define ODPH_IP_TOS_DSCP_SHIFT   2
 DSCP field is shifted letf by 2

 
#define ODPH_IP_TOS_MAX_ECN   3
 2-bit ECN field has max value 3

 
#define ODPH_IP_TOS_ECN_MASK   0x03
 ECN field is in bits <1:0>

 
#define ODPH_IP_TOS_ECN_SHIFT   0
 ECN field is not shifted. More...
 
#define ODPH_IP_ECN_NOT_ECT   0
 The following constants give names to the four possible ECN values, as described in RFC 3168. More...
 
#define ODPH_IP_ECN_ECT1   1
 Indicates no congestion seen yet.
 
#define ODPH_IP_ECN_ECT0   2
 Indicates no congestion seen yet.
 
#define ODPH_IP_ECN_CE   3
 Used to signal Congestion Experienced.
 
#define ODPH_IPV4HDR_VER(ver_ihl)   (((ver_ihl) & 0xf0) >> 4)
 
#define ODPH_IPV4HDR_IHL(ver_ihl)   ((ver_ihl) & 0x0f)
 
#define ODPH_IPV4HDR_DSCP(tos)   (((tos) & 0xfc) >> 2)
 
#define ODPH_IPV4HDR_FLAGS_DONT_FRAG(frag_offset)   ((frag_offset) & 0x4000)
 
#define ODPH_IPV4HDR_FLAGS_MORE_FRAGS(frag_offset)   ((frag_offset) & 0x2000)
 
#define ODPH_IPV4HDR_FRAG_OFFSET(frag_offset)   ((frag_offset) & 0x1fff)
 
#define ODPH_IPV4HDR_IS_FRAGMENT(frag_offset)   ((frag_offset) & 0x3fff)
 
#define ODPH_IPV4HDR_CSUM_OFFSET   10
 
#define ODPH_IPV6   6
 IPv6 version.
 
#define ODPH_IPV6HDR_LEN   40
 IPv6 header length.
 
#define ODPH_IPV6ADDR_LEN   16
 IPv6 address length in bytes.
 
#define ODPH_IPV6HDR_VERSION_MASK   0xF0000000
 The following constants can be used to access the three subfields of the 4 byte ver_tc_flow field - namely the four bit Version subfield, the eight bit Traffic Class subfield (TC) and the twenty bit Flow Label subfield. More...
 
#define ODPH_IPV6HDR_VERSION_SHIFT   28
 Version field shift.
 
#define ODPH_IPV6HDR_TC_MASK   0x0FF00000
 TC field bit mask.
 
#define ODPH_IPV6HDR_TC_SHIFT   20
 TC field shift.
 
#define ODPH_IPV6HDR_FLOW_LABEL_MASK   0x000FFFFF
 Flow Label bit mask.
 
#define ODPH_IPV6HDR_FLOW_LABEL_SHIFT   0
 Flow Label shift.
 
#define ODPH_IPV6HDR_DSCP(ver_tc_flow)    (uint8_t)((((ver_tc_flow) & 0x0fc00000) >> 22) & 0xff)
 
#define ODPH_IPPROTO_HOPOPTS   0x00
 IPv6 hop-by-hop options.
 
#define ODPH_IPPROTO_ICMPV4   0x01
 Internet Control Message Protocol (1)
 
#define ODPH_IPPROTO_IGMP   0x02
 Internet Group Message Protocol (1)
 
#define ODPH_IPPROTO_TCP   0x06
 Transmission Control Protocol (6)
 
#define ODPH_IPPROTO_UDP   0x11
 User Datagram Protocol (17)
 
#define ODPH_IPPROTO_ROUTE   0x2B
 IPv6 Routing header (43)
 
#define ODPH_IPPROTO_FRAG   0x2C
 IPv6 Fragment (44)
 
#define ODPH_IPPROTO_AH   0x33
 Authentication Header (51)
 
#define ODPH_IPPROTO_ESP   0x32
 Encapsulating Security Payload (50)
 
#define ODPH_IPPROTO_ICMPV6   0x3A
 Internet Control Message Protocol (58)
 
#define ODPH_IPPROTO_SCTP   0x84
 Stream Control Transmission protocol (132)
 
#define ODPH_IPPROTO_INVALID   0xFF
 Reserved invalid by IANA.
 

Typedefs

typedef struct ODP_PACKED odph_ipv4hdr_t
 IPv4 header.
 
typedef struct ODP_PACKED odph_ipv6hdr_t
 IPv6 header.
 
typedef struct ODP_PACKED odph_ipv6hdr_ext_t
 IPv6 Header extensions.
 

Functions

static int odph_ipv4_csum (odp_packet_t pkt, uint32_t offset, odph_ipv4hdr_t *ip, odp_u16sum_t *chksum)
 Calculate IPv4 header checksum. More...
 
static int odph_ipv4_csum_valid (odp_packet_t pkt)
 Check if IPv4 checksum is valid. More...
 
static int odph_ipv4_csum_update (odp_packet_t pkt)
 Calculate and fill in IPv4 checksum. More...
 
int odph_ipv4_addr_parse (uint32_t *ip_addr, const char *str)
 Parse IPv4 address from a string. More...
 

Detailed Description

ODP IP header.

Definition in file ip.h.