checksum_example.cpp

Reference Documentation

Platform
Intel® PAC
Napatech SmartNIC
Content Type
Reference Information
Capture Software Version
Link™ Capture Software 12.10
Napatech Software Suite: examples/net/checksum/checksum_example.cpp File Reference
checksum_example.cpp File Reference
#include <nt.h>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <iostream>

Go to the source code of this file.

Data Structures

struct  Dyn3_checksum_overlay
 

Enumerations

enum  ChecksumCmdLayer3 { CHECKSUM_LAYER3_DO_NOTHING = 0, CHECKSUM_LAYER3_BAD = 2, CHECKSUM_LAYER3_GOOD = 3 }
 
enum  ChecksumCmdLayer4 {
  CHECKSUM_LAYER4_DO_NOTHING = 0, CHECKSUM_LAYER4_BAD = 2, CHECKSUM_LAYER4_GOOD = 3, CHECKSUM_LAYER4_GOOD_TCP_ZERO_UDP = 4,
  CHECKSUM_LAYER4_GOOD_TCP_ZERO_UDP_IPV4 = 5, CHECKSUM_LAYER4_GOOD_TCP_UDP_ZERO_UDP_TUNNEL = 6, CHECKSUM_LAYER4_GOOD_TCP_UDP_ZERO_UDP_IPV4_TUNNEL = 7
}
 
enum  FrameType {
  FRAME_TYPE_IPV4_TCP = 0x0 | 0x0 | 0x4, FRAME_TYPE_IPV4_UDP = 0x0 | 0x0 | 0x8, FRAME_TYPE_IPV6_TCP = 0x0 | 0x2 | 0x4, FRAME_TYPE_IPV6_UDP = 0x0 | 0x2 | 0x8,
  FRAME_TYPE_IPV4_TCP_TUNNELED = 0x1 | 0x0 | 0x4, FRAME_TYPE_IPV4_UDP_TUNNELED = 0x1 | 0x0 | 0x8, FRAME_TYPE_IPV6_TCP_TUNNELED = 0x1 | 0x2 | 0x4, FRAME_TYPE_IPV6_UDP_TUNNELED = 0x1 | 0x2 | 0x8
}
 

Functions

static uint64_t checksum_command (ChecksumCmdLayer3 l3, ChecksumCmdLayer4 l4)
 
static void handle_error_status (int status, const char *message)
 
int main (int, char **)
 

Variables

static constexpr uint8_t Test_packet []
 

Enumeration Type Documentation

Valid values for layer 3 checksum command.

Enumerator
CHECKSUM_LAYER3_DO_NOTHING 
CHECKSUM_LAYER3_BAD 
CHECKSUM_LAYER3_GOOD 

Definition at line 136 of file checksum_example.cpp.

Valid values for layer 4 checksum command.

Enumerator
CHECKSUM_LAYER4_DO_NOTHING 
CHECKSUM_LAYER4_BAD 
CHECKSUM_LAYER4_GOOD 
CHECKSUM_LAYER4_GOOD_TCP_ZERO_UDP 
CHECKSUM_LAYER4_GOOD_TCP_ZERO_UDP_IPV4 
CHECKSUM_LAYER4_GOOD_TCP_UDP_ZERO_UDP_TUNNEL 
CHECKSUM_LAYER4_GOOD_TCP_UDP_ZERO_UDP_IPV4_TUNNEL 

Definition at line 145 of file checksum_example.cpp.

enum FrameType

Valid values for a descriptor frame type.

Bit [ 0]: Value 0: Not tunneled Value 1: Tunneled

Bit [ 1]: Value 0: IPv4 or other Value 1: IPv6

Bit [3:2]: Value 0: Other Value 1: TCP Value 2: UDP Value 3: Reserved

Enumerator
FRAME_TYPE_IPV4_TCP 
FRAME_TYPE_IPV4_UDP 
FRAME_TYPE_IPV6_TCP 
FRAME_TYPE_IPV6_UDP 
FRAME_TYPE_IPV4_TCP_TUNNELED 
FRAME_TYPE_IPV4_UDP_TUNNELED 
FRAME_TYPE_IPV6_TCP_TUNNELED 
FRAME_TYPE_IPV6_UDP_TUNNELED 

Definition at line 169 of file checksum_example.cpp.

Function Documentation

static uint64_t checksum_command ( ChecksumCmdLayer3  l3,
ChecksumCmdLayer4  l4 
)
inlinestatic

Correctly combines layer 3 checksum command and layer 4 checksum command.

Examples:
net/checksum/checksum_example.cpp.

Definition at line 183 of file checksum_example.cpp.

Referenced by main().

static void handle_error_status ( int  status,
const char *  message 
)
inlinestatic

Handles and prints NT error messages, and the terminates the program.

Definition at line 191 of file checksum_example.cpp.

Referenced by main().

int main ( int  ,
char **   
)

Definition at line 201 of file checksum_example.cpp.

Variable Documentation

constexpr uint8_t Test_packet[]
static
Initial value:
{
0x42, 0xb3, 0xbb, 0x9b, 0x7b, 0x6b, 0x02, 0xe1,
0x27, 0xc4, 0x33, 0x0f, 0x08, 0x00, 0x45, 0x00,
0x00, 0x52, 0x00, 0x01, 0x00, 0x00, 0x40, 0x11,
0x79, 0x2c, 0x73, 0x35, 0xd7, 0xbe, 0x18, 0xdf,
0x1a, 0x71, 0x34, 0x8b, 0xcf, 0x5f, 0x00, 0x3e,
0xce, 0xe8, 0x70, 0x69, 0x7a, 0x7a, 0x61, 0x70,
0x69, 0x7a, 0x7a, 0x61, 0x70, 0x69, 0x7a, 0x7a,
0x61, 0x70, 0x69, 0x7a, 0x7a, 0x61, 0x70, 0x69,
0x7a, 0x7a, 0x61, 0x70, 0x69, 0x7a, 0x7a, 0x61,
0x70, 0x69, 0x7a, 0x7a, 0x61, 0x70, 0x69, 0x7a,
0x7a, 0x61, 0x70, 0x69, 0x7a, 0x7a, 0x61, 0x70,
0x69, 0x7a, 0x7a, 0x61, 0x70, 0x69, 0x7a, 0x7a
}

IPv4 UDP packet with IPv4 checksum error and UDP checksum error. No FCS included. Size: 96 byte.

Examples:
net/checksum/checksum_example.cpp, and net/transmit_segment_dyn_descr/transmit_segment_dyn_descr_example.cpp.

Definition at line 105 of file checksum_example.cpp.

Referenced by main().