Helper Reference Manual 1.7.1
Loading...
Searching...
No Matches
udp.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2014-2018 Linaro Limited
3 */
4
11#ifndef ODPH_UDP_H_
12#define ODPH_UDP_H_
13
14#include <odp_api.h>
15#include <odp/helper/chksum.h>
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
27#define ODPH_UDPHDR_LEN 8
28
30typedef struct ODP_PACKED {
31 odp_u16be_t src_port;
32 odp_u16be_t dst_port;
33 odp_u16be_t length;
34 odp_u16be_t chksum;
36
45static inline uint16_t odph_ipv4_udp_chksum(odp_packet_t pkt)
46{
47 uint16_t chksum;
48 int rc;
49
50 rc = odph_udp_tcp_chksum(pkt, ODPH_CHKSUM_RETURN, &chksum);
51 return (rc == 0) ? chksum : 0;
52}
53
55ODP_STATIC_ASSERT(sizeof(odph_udphdr_t) == ODPH_UDPHDR_LEN,
56 "ODPH_UDPHDR_T__SIZE_ERROR");
63#ifdef __cplusplus
64}
65#endif
66
67#endif
ODP checksum helper.
int odph_udp_tcp_chksum(odp_packet_t odp_pkt, odph_chksum_op_t op, uint16_t *chksum_ptr)
General Purpose TCP/UDP checksum function.
@ ODPH_CHKSUM_RETURN
Don't generate or verify chksum.
Definition chksum.h:34
#define ODPH_UDPHDR_LEN
UDP header length.
Definition udp.h:27
struct ODP_PACKED odph_udphdr_t
UDP header.
static uint16_t odph_ipv4_udp_chksum(odp_packet_t pkt)
UDP checksum.
Definition udp.h:45
Ethernet MAC address.
Definition eth.h:54
odp_u16be_t dst_port
Destination port.
Definition sctp.h:31
odp_u16be_t length
UDP datagram length in bytes (header+data)
Definition udp.h:33
odp_u16be_t src_port
Source port.
Definition sctp.h:30
odp_u16be_t chksum
UDP header and data checksum (0 if not used)
Definition udp.h:34