DPDK  19.08.0-rc0
Data Structures | Macros | Functions
rte_ip.h File Reference
#include <stdint.h>
#include <netinet/in.h>
#include <rte_byteorder.h>
#include <rte_mbuf.h>

Go to the source code of this file.

Data Structures

struct  rte_ipv4_hdr
 
struct  rte_ipv6_hdr
 

Macros

#define RTE_IPV4(a, b, c, d)
 
#define RTE_IPV4_MAX_PKT_LEN   65535
 
#define RTE_IPV4_HDR_IHL_MASK   (0x0f)
 
#define RTE_IPV4_IHL_MULTIPLIER   (4)
 
#define RTE_IPV4_ANY   ((uint32_t)0x00000000)
 
#define RTE_IPV4_LOOPBACK   ((uint32_t)0x7f000001)
 
#define RTE_IPV4_BROADCAST   ((uint32_t)0xe0000000)
 
#define RTE_IPV4_ALLHOSTS_GROUP   ((uint32_t)0xe0000001)
 
#define RTE_IPV4_ALLRTRS_GROUP   ((uint32_t)0xe0000002)
 
#define RTE_IPV4_MAX_LOCAL_GROUP   ((uint32_t)0xe00000ff)
 
#define RTE_IPV4_MIN_MCAST   RTE_IPV4(224, 0, 0, 0)
 
#define RTE_IPV4_MAX_MCAST   RTE_IPV4(239, 255, 255, 255)
 
#define RTE_IS_IPV4_MCAST(x)   ((x) >= RTE_IPV4_MIN_MCAST && (x) <= RTE_IPV4_MAX_MCAST)
 

Functions

static uint16_t rte_raw_cksum (const void *buf, size_t len)
 
static int rte_raw_cksum_mbuf (const struct rte_mbuf *m, uint32_t off, uint32_t len, uint16_t *cksum)
 
static uint16_t rte_ipv4_cksum (const struct rte_ipv4_hdr *ipv4_hdr)
 
static uint16_t rte_ipv4_phdr_cksum (const struct rte_ipv4_hdr *ipv4_hdr, uint64_t ol_flags)
 
static uint16_t rte_ipv4_udptcp_cksum (const struct rte_ipv4_hdr *ipv4_hdr, const void *l4_hdr)
 
static uint16_t rte_ipv6_phdr_cksum (const struct rte_ipv6_hdr *ipv6_hdr, uint64_t ol_flags)
 
static uint16_t rte_ipv6_udptcp_cksum (const struct rte_ipv6_hdr *ipv6_hdr, const void *l4_hdr)
 

Detailed Description

IP-related defines

Definition in file rte_ip.h.

Macro Definition Documentation

◆ RTE_IPV4

#define RTE_IPV4 (   a,
  b,
  c,
 
)

◆ RTE_IPV4_MAX_PKT_LEN

#define RTE_IPV4_MAX_PKT_LEN   65535

Maximal IPv4 packet length (including a header)

Definition at line 51 of file rte_ip.h.

◆ RTE_IPV4_HDR_IHL_MASK

#define RTE_IPV4_HDR_IHL_MASK   (0x0f)

Internet header length mask for version_ihl field

Examples
examples/l2fwd-crypto/main.c, and examples/l3fwd/l3fwd_em.c.

Definition at line 54 of file rte_ip.h.

◆ RTE_IPV4_IHL_MULTIPLIER

#define RTE_IPV4_IHL_MULTIPLIER   (4)

Internet header length field multiplier (IHL field specifies overall header length in number of 4-byte words)

Examples
examples/ipsec-secgw/sa.c, examples/l2fwd-crypto/main.c, and examples/l3fwd/l3fwd_em.c.

Definition at line 59 of file rte_ip.h.

◆ RTE_IPV4_ANY

#define RTE_IPV4_ANY   ((uint32_t)0x00000000)

0.0.0.0

Definition at line 76 of file rte_ip.h.

◆ RTE_IPV4_LOOPBACK

#define RTE_IPV4_LOOPBACK   ((uint32_t)0x7f000001)

127.0.0.1

Definition at line 77 of file rte_ip.h.

◆ RTE_IPV4_BROADCAST

#define RTE_IPV4_BROADCAST   ((uint32_t)0xe0000000)

224.0.0.0

Definition at line 78 of file rte_ip.h.

◆ RTE_IPV4_ALLHOSTS_GROUP

#define RTE_IPV4_ALLHOSTS_GROUP   ((uint32_t)0xe0000001)

224.0.0.1

Definition at line 79 of file rte_ip.h.

◆ RTE_IPV4_ALLRTRS_GROUP

#define RTE_IPV4_ALLRTRS_GROUP   ((uint32_t)0xe0000002)

224.0.0.2

Definition at line 80 of file rte_ip.h.

◆ RTE_IPV4_MAX_LOCAL_GROUP

#define RTE_IPV4_MAX_LOCAL_GROUP   ((uint32_t)0xe00000ff)

224.0.0.255

Definition at line 81 of file rte_ip.h.

◆ RTE_IPV4_MIN_MCAST

#define RTE_IPV4_MIN_MCAST   RTE_IPV4(224, 0, 0, 0)

Minimal IPv4-multicast address

Definition at line 86 of file rte_ip.h.

◆ RTE_IPV4_MAX_MCAST

#define RTE_IPV4_MAX_MCAST   RTE_IPV4(239, 255, 255, 255)

Maximum IPv4 multicast address

Definition at line 88 of file rte_ip.h.

◆ RTE_IS_IPV4_MCAST

#define RTE_IS_IPV4_MCAST (   x)    ((x) >= RTE_IPV4_MIN_MCAST && (x) <= RTE_IPV4_MAX_MCAST)

check if IPv4 address is multicast

Examples
examples/ipv4_multicast/main.c.

Definition at line 91 of file rte_ip.h.

Function Documentation

◆ rte_raw_cksum()

static uint16_t rte_raw_cksum ( const void *  buf,
size_t  len 
)
inlinestatic

Process the non-complemented checksum of a buffer.

Parameters
bufPointer to the buffer.
lenLength of the buffer.
Returns
The non-complemented checksum.

Definition at line 167 of file rte_ip.h.

◆ rte_raw_cksum_mbuf()

static int rte_raw_cksum_mbuf ( const struct rte_mbuf m,
uint32_t  off,
uint32_t  len,
uint16_t *  cksum 
)
inlinestatic

Compute the raw (non complemented) checksum of a packet.

Parameters
mThe pointer to the mbuf.
offThe offset in bytes to start the checksum.
lenThe length in bytes of the data to checksum.
cksumA pointer to the checksum, filled on success.
Returns
0 on success, -1 on error (bad length or offset).

Definition at line 190 of file rte_ip.h.

◆ rte_ipv4_cksum()

static uint16_t rte_ipv4_cksum ( const struct rte_ipv4_hdr ipv4_hdr)
inlinestatic

Process the IPv4 checksum of an IPv4 header.

The checksum field must be set to 0 by the caller.

Parameters
ipv4_hdrThe pointer to the contiguous IPv4 header.
Returns
The complemented checksum to set in the IP packet.
Examples
examples/ipsec-secgw/ipsec-secgw.c.

Definition at line 257 of file rte_ip.h.

◆ rte_ipv4_phdr_cksum()

static uint16_t rte_ipv4_phdr_cksum ( const struct rte_ipv4_hdr ipv4_hdr,
uint64_t  ol_flags 
)
inlinestatic

Process the pseudo-header checksum of an IPv4 header.

The checksum field must be set to 0 by the caller.

Depending on the ol_flags, the pseudo-header checksum expected by the drivers is not the same. For instance, when TSO is enabled, the IP payload length must not be included in the packet.

When ol_flags is 0, it computes the standard pseudo-header checksum.

Parameters
ipv4_hdrThe pointer to the contiguous IPv4 header.
ol_flagsThe ol_flags of the associated mbuf.
Returns
The non-complemented checksum to set in the L4 header.
Examples
examples/tep_termination/vxlan.c, and examples/vhost/main.c.

Definition at line 283 of file rte_ip.h.

◆ rte_ipv4_udptcp_cksum()

static uint16_t rte_ipv4_udptcp_cksum ( const struct rte_ipv4_hdr ipv4_hdr,
const void *  l4_hdr 
)
inlinestatic

Process the IPv4 UDP or TCP checksum.

The IPv4 header should not contains options. The IP and layer 4 checksum must be set to 0 in the packet by the caller.

Parameters
ipv4_hdrThe pointer to the contiguous IPv4 header.
l4_hdrThe pointer to the beginning of the L4 header.
Returns
The complemented checksum to set in the IP packet or 0 on error

Definition at line 322 of file rte_ip.h.

◆ rte_ipv6_phdr_cksum()

static uint16_t rte_ipv6_phdr_cksum ( const struct rte_ipv6_hdr ipv6_hdr,
uint64_t  ol_flags 
)
inlinestatic

Process the pseudo-header checksum of an IPv6 header.

Depending on the ol_flags, the pseudo-header checksum expected by the drivers is not the same. For instance, when TSO is enabled, the IPv6 payload length must not be included in the packet.

When ol_flags is 0, it computes the standard pseudo-header checksum.

Parameters
ipv6_hdrThe pointer to the contiguous IPv6 header.
ol_flagsThe ol_flags of the associated mbuf.
Returns
The non-complemented checksum to set in the L4 header.
Examples
examples/tep_termination/vxlan.c, and examples/vhost/main.c.

Definition at line 379 of file rte_ip.h.

◆ rte_ipv6_udptcp_cksum()

static uint16_t rte_ipv6_udptcp_cksum ( const struct rte_ipv6_hdr ipv6_hdr,
const void *  l4_hdr 
)
inlinestatic

Process the IPv6 UDP or TCP checksum.

The IPv4 header should not contains options. The layer 4 checksum must be set to 0 in the packet by the caller.

Parameters
ipv6_hdrThe pointer to the contiguous IPv6 header.
l4_hdrThe pointer to the beginning of the L4 header.
Returns
The complemented checksum to set in the IP packet.

Definition at line 415 of file rte_ip.h.