1 #ifndef NDNDPDK_ETHFACE_HDR_IMPL_H
2 #define NDNDPDK_ETHFACE_HDR_IMPL_H
6 #include "../ndni/an.h"
12 GTP_INNER_LEN =
sizeof(
struct rte_ipv4_hdr) + sizeof(struct rte_udp_hdr),
15 __attribute__((nonnull))
static inline uint8_t
16 PutEtherHdr(uint8_t* buffer,
const struct rte_ether_addr src,
const struct rte_ether_addr dst,
17 uint16_t vid, uint16_t etherType) {
18 struct rte_ether_hdr* ether = (
struct rte_ether_hdr*)buffer;
19 ether->dst_addr = dst;
20 ether->src_addr = src;
21 ether->ether_type = rte_cpu_to_be_16(vid == 0 ? etherType : RTE_ETHER_TYPE_VLAN);
22 return RTE_ETHER_HDR_LEN;
25 __attribute__((nonnull))
static inline uint8_t
26 PutVlanHdr(uint8_t* buffer, uint16_t vid, uint16_t etherType) {
27 struct rte_vlan_hdr* vlan = (
struct rte_vlan_hdr*)buffer;
28 vlan->vlan_tci = rte_cpu_to_be_16(vid);
29 vlan->eth_proto = rte_cpu_to_be_16(etherType);
33 __attribute__((nonnull))
static inline uint8_t
34 PutEtherVlanHdr(uint8_t* buffer,
const struct rte_ether_addr src,
const struct rte_ether_addr dst,
35 uint16_t vid, uint16_t etherType) {
36 uint8_t off = PutEtherHdr(buffer, src, dst, vid, etherType);
38 off += PutVlanHdr(RTE_PTR_ADD(buffer, off), vid, etherType);
43 __attribute__((nonnull))
static inline uint8_t
44 PutIpv4Hdr(uint8_t* buffer,
const struct rte_ipv6_addr src,
const struct rte_ipv6_addr dst) {
45 struct rte_ipv4_hdr* ip = (
struct rte_ipv4_hdr*)buffer;
46 ip->version_ihl = RTE_IPV4_VHL_DEF;
47 ip->fragment_offset = rte_cpu_to_be_16(RTE_IPV4_HDR_DF_FLAG);
49 ip->next_proto_id = IPPROTO_UDP;
55 __attribute__((nonnull))
static inline uint8_t
56 PutIpv6Hdr(uint8_t* buffer,
const struct rte_ipv6_addr src,
const struct rte_ipv6_addr dst) {
57 struct rte_ipv6_hdr* ip = (
struct rte_ipv6_hdr*)buffer;
59 ip->proto = IPPROTO_UDP;
66 __attribute__((nonnull))
static inline uint16_t
67 PutUdpHdr(uint8_t* buffer, uint16_t src, uint16_t dst) {
68 struct rte_udp_hdr* udp = (
struct rte_udp_hdr*)buffer;
69 udp->src_port = rte_cpu_to_be_16(src);
70 udp->dst_port = rte_cpu_to_be_16(dst);
74 __attribute__((nonnull))
static __rte_always_inline
void
75 PutVxlanVni(uint8_t vni[3], uint32_t vniH) {
76 rte_be32_t vniB = rte_cpu_to_be_32(vniH);
77 rte_memcpy(vni, RTE_PTR_ADD(&vniB, 1), 3);
80 __attribute__((nonnull))
static inline uint8_t
81 PutVxlanHdr(uint8_t* buffer, uint32_t vni) {
82 struct rte_vxlan_hdr* vxlan = (
struct rte_vxlan_hdr*)buffer;
84 PutVxlanVni(vxlan->vni, vni);
85 return sizeof(*vxlan);
88 __attribute__((nonnull))
static inline uint8_t
89 PutGtpHdr(uint8_t* buffer,
bool ul, uint32_t teid, uint8_t qfi) {
91 static_assert(
sizeof(*gtp) == 16,
"");
95 gtp->
hdr.msg_type = 0xFF;
96 gtp->
hdr.teid = rte_cpu_to_be_32(teid);
98 gtp->
psc.ext_hdr_len = 1;
99 gtp->
psc.type = (int)ul;
@ IP_HOPLIMIT_VALUE
Definition: hdr-impl.h:10
@ GTP_INNER_LEN
Definition: hdr-impl.h:12
@ V4_IN_V6_PREFIX_OCTETS
Definition: hdr-impl.h:11
GTP-U header with PDU session container.
Definition: xdp-locator.h:46
struct rte_gtp_psc_generic_hdr psc
Definition: xdp-locator.h:49
struct rte_gtp_hdr_ext_word ext
Definition: xdp-locator.h:48
struct rte_gtp_hdr hdr
Definition: xdp-locator.h:47
@ EthGtpExtTypePsc
Value of EthGtpHdr.ext.next_ext .
Definition: xdp-locator.h:55