pktdescr_dyn2.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_DYN2 variable packet descriptor.\n 8 */ 9 10#ifndef __PKT_DESCR_DYN2_H__ 11#define __PKT_DESCR_DYN2_H__ 12 13/** @addtogroup PacketDescriptorDyn2 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. This descriptor 18 * offers a 38-bit color field, which is useful when identifying billions of flows or 19 * alternatively holding the hash value.<br/> 20 * Note: The wireLength field has been sacrificed so in case of slicing the 21 * original packet length is unknown. 22 */ 23 24// Ensure that the following is packed. 25#pragma pack(push, 1) 26 27/** 28 * @brief NT Variable descriptor 2 29 */ 30typedef struct NtDyn2Descr_s { 31 uint64_t capLength:14; /**< The length of the packet incl. descriptor. */ /* 0*/ 32 uint64_t offset0:10; /**< Programmable offset into the packet. Default is outer L3. */ /* 14*/ 33 uint64_t offset1:10; /**< Programmable offset into the packet. Default is outer L4. */ /* 24*/ 34 uint64_t ipProtocol:8; /**< Select-able IP protocol. Default is outer IP Protocol field. */ /* 34*/ 35 uint64_t rxPort:6; /**< The port that received the frame. */ /* 42*/ 36 uint64_t descrFormat:8; /**< The descriptor type. */ /* 48*/ 37 uint64_t descrLength:6; /**< The length of the descriptor in bytes. */ /* 56*/ 38 uint64_t tsColor:1; /**< Timestamp color. */ /* 62*/ 39 uint64_t ntDynDescr:1; /**< Set to 1 to identify this descriptor as a dynamic descriptor. */ /* 63*/ 40 uint64_t timestamp; /**< The time of arrival of the packet. */ /* 64*/ 41 uint64_t offset2:10; /**< Programmable offset into the packet. Default is outer L4 payload. */ /*128*/ 42 uint64_t color:38; /**< 24 bit hash and 14 bit traditional color. */ /*138*/ 43} NtDyn2Descr_t; // descrFormat = 2, descrLength = 22 44 45// Disable 1-byte packing 46#pragma pack(pop) 47 48#ifndef DOXYGEN_INTERNAL_ONLY 49#define _NT_NET_GET_PKT_DESCR_PTR_DYN2(_hNetBuf_) ((NtDyn2Descr_t*)(_hNetBuf_)->hHdr) 50#endif // DOXYGEN_INTERNAL_ONLY 51 52/** @def NT_NET_DESCR_PTR_DYN2 53 * @brief Get a pointer to the packet descriptor 54 * @param[in] "_hNetBuf_" Packet container reference 55 * @return Returns a pointer of type NtDyn2Descr_t* 56 * @hideinitializer 57 */ 58#define NT_NET_DESCR_PTR_DYN2(_hNetBuf_) ((_NT_NET_GET_PKT_DESCR_PTR_DYN2(_hNetBuf_)->descrFormat==2 ? \ 59 (NtDyn2Descr_t*)(_hNetBuf_->hHdr) : (NtDyn2Descr_t*)_NT_NET_DESCR_CAST_ASSERT(NULL))) 60 61 62#ifdef DEBUG 63//Guards against misconfigurations 64#ifdef _MSC_VER 65static void __nt_dyn2_check__(void); 66#else 67static void __nt_dyn2_check__(void) __attribute__ ((unused)); 68#endif 69static void __nt_dyn2_check__(void) { 70 //Compile-time check to avoid sizeof(NtDyn2Descr_t) != 22 71#ifdef WIN32 72 // Windows will always allocate 3 * 64 bit = 24 bytes 73 switch (0) { case 0: case sizeof(NtDyn2Descr_t) == 24:; } 74#else 75 switch (0) { case 0: case sizeof (NtDyn2Descr_t) == 22: ; } 76#endif 77} 78#endif // DEBUG 79 80/** @} */ 81 82#endif // __PKT_DESCR_DYN2_H__ 83