pktdescr_dyn1.h

Reference Documentation

Platform
Napatech SmartNIC
Content Type
Reference Information

Go to the documentation of this file.

1/* 2 * %NT_SOFTWARE_LICENSE% 3 */ 4 5/** 6 * @file 7 * This source file contains the NT_DYN1 variable packet descriptor.\n 8 */ 9 10#ifndef __PKT_DESCR_DYN1_H__ 11#define __PKT_DESCR_DYN1_H__ 12 13/** @addtogroup PacketDescriptorDyn1 14 * @{ 15 * 16 * This descriptor offers 3 dynamic offsets, IP protocol field and a 6-bit color field. 17 * The packet descriptor is suited for applications doing NetFlow and IDS. <br/> 18 * Note: The wireLength field has been sacrificed so in case of slicing the 19 * original packet length is unknown. 20 */ 21 22// Ensure that the following is packed. 23#pragma pack(push, 1) 24 25/** 26 * @brief NT Variable descriptor 1 27 */ 28typedef struct NtDyn1Descr_s { 29 uint64_t capLength:14; /**< The length of the packet incl. descriptor. */ /* 0*/ 30 uint64_t offset0:10; /**< Programmable offset into the packet. Default is outer L3. */ /* 14*/ 31 uint64_t offset1:10; /**< Programmable offset into the packet. Default is outer L4. */ /* 24*/ 32 uint64_t ipProtocol:8; /**< Select-able IP protocol. Default is outer IP Protocol field. */ /* 34*/ 33 uint64_t rxPort:6; /**< The port that received the frame. */ /* 42*/ 34 uint64_t descrFormat:8; /**< The descriptor type. */ /* 48*/ 35 uint64_t descrLength:6; /**< The length of the descriptor in bytes. */ /* 56*/ 36 uint64_t tsColor:1; /**< Timestamp color. */ /* 62*/ 37 uint64_t ntDynDescr:1; /**< Set to 1 to identify this descriptor as a dynamic descriptor. */ /* 63*/ 38 uint64_t timestamp; /**< The time of arrival of the packet. */ /* 64*/ 39 uint16_t offset2:10; /**< Programmable offset into the packet. Default is outer L4 payload. */ /*128*/ 40 uint16_t color:6; /**< Programmable packet color. */ /*138*/ 41} NtDyn1Descr_t; // descrFormat = 1, descrLength = 18 42 43// Disable 1-byte packing 44#pragma pack(pop) 45 46#ifndef DOXYGEN_INTERNAL_ONLY 47#define _NT_NET_GET_PKT_DESCR_PTR_DYN1(_hNetBuf_) ((NtDyn1Descr_t*)(_hNetBuf_)->hHdr) 48#endif // DOXYGEN_INTERNAL_ONLY 49 50/** @def NT_NET_DESCR_PTR_DYN1 51 * @brief Get a pointer to the packet descriptor 52 * @param[in] "_hNetBuf_" Packet container reference 53 * @return Returns a pointer of type NtDyn1Descr_t* 54 * @hideinitializer 55 */ 56#define NT_NET_DESCR_PTR_DYN1(_hNetBuf_) ((_NT_NET_GET_PKT_DESCR_PTR_DYN1(_hNetBuf_)->descrFormat==1 ? \ 57 (NtDyn1Descr_t*)(_hNetBuf_->hHdr) : (NtDyn1Descr_t*)_NT_NET_DESCR_CAST_ASSERT(NULL))) 58 59 60#ifdef DEBUG 61//Guards against misconfigurations 62#ifdef _MSC_VER 63static void __nt_dyn1_check__(void); 64#else 65static void __nt_dyn1_check__(void) __attribute__ ((unused)); 66#endif 67static void __nt_dyn1_check__(void) { 68 //Compile-time check to avoid sizeof(NtDyn1Descr_t) != 18 69 switch (0) { case 0: case sizeof (NtDyn1Descr_t) == 18: ; } 70} 71#endif // DEBUG 72 73/** @} */ 74 75#endif // __PKT_DESCR_DYN1_H__ 76