Helper Reference Manual
1.7.1
|
TCP/UDP/SCTP checksum.
Enumerations | |
enum | odph_chksum_op_t { ODPH_CHKSUM_GENERATE , ODPH_CHKSUM_VERIFY , ODPH_CHKSUM_RETURN } |
Chksum Operation Code. More... | |
Functions | |
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. More... | |
static int | odph_tcp_chksum_set (odp_packet_t odp_pkt) |
Generate TCP checksum. More... | |
static int | odph_udp_chksum_set (odp_packet_t odp_pkt) |
Generate UDP checksum. More... | |
static int | odph_tcp_chksum_verify (odp_packet_t odp_pkt) |
Verify TCP checksum. More... | |
static int | odph_udp_chksum_verify (odp_packet_t odp_pkt) |
Verify UDP checksum. More... | |
int | odph_sctp_chksum_set (odp_packet_t odp_pkt) |
Generate SCTP checksum. More... | |
int | odph_sctp_chksum_verify (odp_packet_t odp_pkt) |
Verify SCTP checksum. More... | |
enum odph_chksum_op_t |
Chksum Operation Code.
This enumeration type is used to tell odph_udp_tcp_chksum what to do once it has calculated the TCP/UDP check sum.
Enumerator | |
---|---|
ODPH_CHKSUM_GENERATE | Set TCP/UDP header chksum field. |
ODPH_CHKSUM_VERIFY | See if TCP/UDP header chksum is correct. |
ODPH_CHKSUM_RETURN | Don't generate or verify chksum. |
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.
This function handles all the different checksum operations like ODPH_CHKSUM_GENERATE, ODPH_CHKSUM_VERIFY and ODPH_CHKSUM_RETURN for both TCP and UDP pkts over either IPv4 or IPv6. Note that the packet will be modified only if op==ODPH_CHKSUM_GENERATE. In the case of ODPH_CHKSUM_RETURN, the checksum will be calculated, but will neither be written or compared, but just returned via the chksum_ptr parameter (assuming that chksum_ptr is non NULL). Because the code doesn't know whether a GENERATE or VERIFY is occurring, when using ODPH_CHKSUM_RETURN it is important that the chksum field be well defined (either the value as received or set to 0 when created). Note that for ODPH_CHKSUM_GENERATE, the existing chksum field is ignored (i.e. the code will zero it out before computing the chksum). See also comments in the convenience functions below.
odp_pkt | Calculate the chksum for this pkt and based on the op parameter either replace the existing chksum field, or verify that it is correct or just return it. |
op | What is to be done with the calculated chksum. doesn't handle tunnels of multiple IPv4/IPv6 headers. |
chksum_ptr | Pointer to a 16 bit field where the checksum will be written. Note that if this pointer is non NULL, the calculated checksum will always be returned regardless of op. Note that the calculated chksum always includes the chksum in the TCP or UDP header. |
Referenced by odph_ipv4_udp_chksum(), odph_tcp_chksum_set(), odph_tcp_chksum_verify(), odph_udp_chksum_set(), and odph_udp_chksum_verify().
|
inlinestatic |
Generate TCP checksum.
This function supports TCP over either IPv4 or IPV6 - including handling any IPv4 header options and any IPv6 extension headers. However it does not handle tunneled pkts (i.e. any case where there is more than one IPv4/IPv6 header). This function also handles non-contiguous pkts. In particular it can handle arbitrary packet segmentation, including cases where the segments are not 2 byte aligned, nor have a length that is a multiple of 2. This function also can handle jumbo frames (at least up to 10K).
This function will insert the calculated IP checksum into the proper location in the TCP header.
odp_pkt | Calculate and insert chksum for this TCP pkt, which can be over IPv4 or IPv6. |
Definition at line 99 of file chksum.h.
References ODPH_CHKSUM_GENERATE, and odph_udp_tcp_chksum().
|
inlinestatic |
Generate UDP checksum.
This function supports UDP over either IPv4 or IPV6 - including handling any IPv4 header options and any IPv6 extension headers. However it does not handle tunneled pkts (i.e. any case where there is more than one IPv4/IPv6 header). This function also handles non-contiguous pkts. In particular it can handle arbitrary packet segmentation, including cases where the segments are not 2 byte aligned, nor have a length that is a multiple of 2. This function also can handle jumbo frames (at least up to 10K).
This function will insert the calculated IP checksum into the proper location in the UDP header.
odp_pkt | Calculate and insert chksum for this UDP pkt, which can be over IPv4 or IPv6. |
Definition at line 126 of file chksum.h.
References ODPH_CHKSUM_GENERATE, and odph_udp_tcp_chksum().
|
inlinestatic |
Verify TCP checksum.
This function supports TCP over either IPv4 or IPV6 - including handling any IPv4 header options and any IPv6 extension headers. However it does not handle tunneled pkts (i.e. any case where there is more than one IPv4/IPv6 header). This function also handles non-contiguous pkts. In particular it can handle arbitrary packet segmentation, including cases where the segments are not 2 byte aligned, nor have a length that is a multiple of 2. This function also can handle jumbo frames (at least up to 10K). Note that since TCP checksums cannot be turned off, an incoming TCP checksum of 0 will return an "incorrect" indication (the value 2).
odp_pkt | Calculate and compare the chksum for this TCP pkt, which can be over IPv4 or IPv6. |
Definition at line 154 of file chksum.h.
References ODPH_CHKSUM_VERIFY, and odph_udp_tcp_chksum().
|
inlinestatic |
Verify UDP checksum.
This function supports UDP over either IPv4 or IPV6 - including handling any IPv4 header options and any IPv6 extension headers. However it does not handle tunneled pkts (i.e. any case where there is more than one IPv4/IPv6 header). This function also handles non-contiguous pkts. In particular it can handle arbitrary packet segmentation, including cases where the segments are not 2 byte aligned, nor have a length that is a multiple of 2. This function also can handle jumbo frames (at least up to 10K). Note that UDP checksums can be disabled by setting the incoming UDP chksum field to 0. In this case this function will return the value 1 - indicating neither a correct or incorrect chksum.
odp_pkt | Calculate and compare the chksum for this UDP pkt, which can be over IPv4 or IPv6. |
Definition at line 184 of file chksum.h.
References ODPH_CHKSUM_VERIFY, and odph_udp_tcp_chksum().
int odph_sctp_chksum_set | ( | odp_packet_t | odp_pkt | ) |
Generate SCTP checksum.
This function supports SCTP over either IPv4 or IPV6 - including handling any IPv4 header options and any IPv6 extension headers. However it does not handle tunneled pkts (i.e. any case where there is more than one IPv4/IPv6 header). This function also handles non-contiguous pkts. In particular it can handle arbitrary packet segmentation, including cases where the segments are not 2 byte aligned, nor have a length that is a multiple of 2. This function also can handle jumbo frames (at least up to 10K).
This function will insert the calculated CRC32-c checksum into the proper location in the SCTP header.
odp_pkt | Calculate and insert chksum for this SCTP pkt, which can be over IPv4 or IPv6. |
0 | on success |
<0 | on failure |
int odph_sctp_chksum_verify | ( | odp_packet_t | odp_pkt | ) |
Verify SCTP checksum.
This function supports SCTP over either IPv4 or IPV6 - including handling any IPv4 header options and any IPv6 extension headers. However it does not handle tunneled pkts (i.e. any case where there is more than one IPv4/IPv6 header). This function also handles non-contiguous pkts. In particular it can handle arbitrary packet segmentation, including cases where the segments are not 2 byte aligned, nor have a length that is a multiple of 2. This function also can handle jumbo frames (at least up to 10K).
odp_pkt | Calculate and compare the chksum for this SCTP pkt, which can be over IPv4 or IPv6. |
<0 | on failure |
0 | if the incoming chksum field is correct |
2 | when the chksum field is incorrect |