pktdescr.h

Reference Documentation

product_line_custom
Napatech SmartNIC
category
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 packet macros available.\n 8 * See the @ref PacketMacros for details. 9 */ 10 11#ifndef __PKT_DESCR_H__ 12#define __PKT_DESCR_H__ 13 14#ifndef DOXYGEN_INTERNAL_ONLY 15 16/* In debug mode add assert to all general RX macros */ 17#ifdef NDEBUG 18#define _NT_NET_ASSERT(x) (x) 19#define _NT_NET_DESCR_CAST_ASSERT(x) (x) 20#else 21#define _NT_NET_ASSERT(x) (assert(0 && "macro argument: unsupported descriptor type"), x) 22#define _NT_NET_DESCR_CAST_ASSERT(x) (assert(0 && "descriptor cast error."), x) 23#endif 24 25#include "pktdescr_std0.h" 26#include "pktdescr_ext7.h" 27#include "pktdescr_ext8.h" 28#include "pktdescr_ext9.h" 29#include "pktdescr_dyn.h" 30#include "pktdescr_dyn1.h" 31#include "pktdescr_dyn2.h" 32#include "pktdescr_dyn3.h" 33#include "pktdescr_dyn4.h" 34 35// Ensure that the following is packed. 36#pragma pack(push, 1) 37 38typedef union { 39 NtStd0Descr_t std0; //!< Standard descriptor v0 40 NtExt7Descr_t ext7; //!< Only valid for extended descriptor format 7 41 NtExt8Descr_t ext8; //!< Only valid for extended descriptor format 8 42 NtExt9Descr_t ext9; //!< Only valid for extended descriptor format 9 43} NtPktDescr_t; 44 45// Disable 1-byte packing 46#pragma pack(pop) 47 48#endif // DOXYGEN_INTERNAL_ONLY 49 50/** @addtogroup DataMacros 51 * @{ 52 */ 53 54/** @defgroup PacketMacros Packet macros 55 * @{ 56 * The following is only possible on packet-based streams. 57 * 58 * Unless specified otherwise, the NT_NET_GET_PKT_XYZ macros will return 59 * integer type values. 60 * 61 * In debug mode some packet macros contain an assert which asserts 62 * that the descriptor is supported for a given macro. Define the macro 63 * NDEBUG to remove the assert or use the build option -DNDEBUG. When 64 * the assert is removed the unsupported descriptors cause macros to return -1. 65 * 66 * The descriptor support for the various macros is as follows: 67 * 68 * <table border="1"> 69 * <tr> 70 * <th>Macro group</th> 71 * <th>NT</th><th>Ext7</th><th>Ext8</th><th>Ext9</th><th>Dyn</th> 72 * </tr> 73 * <tr><td>Basic descriptor macros</td> 74 * <td> X </td><td> X </td><td> X </td><td> X </td><td> X </td></tr> 75 * <tr><td>NT descriptor macros</td> 76 * <td> X </td><td> X </td><td> X </td><td> X </td><td> </td></tr> 77 * <tr><td>Extended NT descriptor macros</td> 78 * <td> </td><td> X </td><td> X </td><td> X </td><td> </td></tr> 79 * <tr><td>Extended NT descriptor IPF macros</td> 80 * <td> </td><td> </td><td> X </td><td> X </td><td> </td></tr> 81 * <tr><td>Extended NT descriptor Tunneling macros</td> 82 * <td> </td><td> </td><td> </td><td> X </td><td> </td></tr> 83 * <tr><td>TX macros</td> 84 * <td> X </td><td> X </td><td> X </td><td> X </td><td> </td></tr> 85 * </table> 86 * 87 * Note that some macros may exist in different variants for each descriptor 88 * type. In that case, the supported descriptor is part of the macro name. 89 * 90 */ 91 92/** @defgroup BasicDescriptorMacros Basic descriptor macros 93 * @{ 94 * The following macros are always available. 95 */ 96 97/** @def NT_NET_GET_PKT_DESCRIPTOR_TYPE 98 * @brief Get the packet descriptor type. 99 * @param[in] "_hNetBuf_" Packet container reference 100 * @return Returns the packet descriptor type. See @ref NtPacketDescriptorType_e for values. 101 * @hideinitializer 102 */ 103#define NT_NET_GET_PKT_DESCRIPTOR_TYPE(_hNetBuf_) _NT_NET_GET_PKT_DESCRIPTOR_TYPE(_hNetBuf_) 104 105/** @def NT_NET_GET_PKT_DESCR_PTR 106 * @brief Get packet descriptor pointer 107 * @param[in] "_hNetBuf_" Packet container reference 108 * @return Returns a pointer to the packet descriptor of the received frame. 109 * @hideinitializer 110 */ 111#define NT_NET_GET_PKT_DESCR_PTR(_hNetBuf_) _NT_NET_GET_PKT_DESCR_PTR(_hNetBuf_) 112#if !defined(_NT_NTAPI_NO_COMPAT) 113#define NT_NET_GET_PKT_DESCR(_hNetBuf_) _NT_NET_GET_PKT_DESCR_PTR(_hNetBuf_) 114#endif 115 116/** @def NT_NET_GET_PKT_L2_PTR 117 * @brief A pointer to the L2 packet data. If an ISL header is present it will point to the ISL header. 118 * @param[in] "_hNetBuf_" Packet container reference 119 * @return Returns a void pointer to L2 packet data. 120 * @hideinitializer 121 */ 122#define NT_NET_GET_PKT_L2_PTR(_hNetBuf_) _NT_NET_GET_PKT_L2_PTR(_hNetBuf_) 123 124/** @def NT_NET_UPDATE_PKT_L2_PTR 125 * @brief When creating packets within a segment it is required to update the L2 pointer using this macro after applying the descriptor info 126 * @param[in] "_hNetBuf_" Packet container reference 127 * @hideinitializer 128 */ 129#define NT_NET_UPDATE_PKT_L2_PTR(_hNetBuf_) _NT_NET_UPDATE_PKT_L2_PTR(_hNetBuf_) 130 131 132/** @def NT_NET_GET_PKT_DESCR_LENGTH 133 * @brief Get the length of the packet descriptor 134 * @param[in] "_hNetBuf_" Packet container reference 135 * @return Return the length of the packet descriptor in bytes 136 * @hideinitializer 137 */ 138#define NT_NET_GET_PKT_DESCR_LENGTH(_hNetBuf_) _NT_NET_GET_PKT_DESCR_LENGTH(_hNetBuf_) 139 140/** @def NT_NET_GET_PKT_DESCRIPTOR_FORMAT 141 * @brief Indicates if extended packet descriptor 7, 8 or 9 is used, if only the 142 * standard packet descriptor is used, or what dynamic packet descriptor type is used. 143 * @param[in] "_hNetBuf_" Packet container reference 144 * @return Returns the packet descriptor format used 145 * @hideinitializer 146 */ 147#define NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_) _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_) 148 149/** @} */ 150 151/** @defgroup NtDescriptorMacros NT descriptor macros 152 * @{ 153 154 * The following is only available if "PacketDescriptor = NT or Ext7 or Ext8 or Ext9" has been selected in the ntservice.ini file 155 * and if @ref NT_NET_GET_PKT_DESCRIPTOR_TYPE returns @ref NT_PACKET_DESCRIPTOR_TYPE_NT || @ref NT_PACKET_DESCRIPTOR_TYPE_NT_EXTENDED. 156 * The following macros constitute the collection extracting data from the "NT" descriptor. 157 */ 158 159/** @def NT_NET_GET_PKT_TIMESTAMP 160 * @brief Get the packet timestamp 161 * @param[in] "_hNetBuf_" Packet container reference 162 * @return Returns the time when the packet was captured as an 64bit unsigned value 163 * @hideinitializer 164 */ 165#define NT_NET_GET_PKT_TIMESTAMP(_hNetBuf_) _NT_NET_GET_PKT_TIMESTAMP(_hNetBuf_) 166 167/** @def NT_NET_GET_PKT_TIMESTAMP_TYPE 168 * @brief Get the packet time stamp type. See @ref NtTimestampType_e 169 * @param[in] "_hNetBuf_" Packet container reference 170 * @return Returns the packet time stamp type. See @ref NtTimestampType_e for values 171 * @hideinitializer 172 */ 173#define NT_NET_GET_PKT_TIMESTAMP_TYPE(_hNetBuf_) _NT_NET_GET_PKT_TIMESTAMP_TYPE(_hNetBuf_) 174 175/** @def NT_NET_GET_PKT_CAP_LENGTH 176 * @brief Returns the total stored length of the received frame including 177 * packet descriptors, in bytes, after any slicing. The value is always a 178 * multiple of 8, and is rounded up for unsliced frames with wire lengths 179 * that are not multiples of 8 bytes 180 * @param[in] "_hNetBuf_" Packet container reference 181 * @return Returns the total stored length of the received frame 182 * @hideinitializer 183 */ 184#define NT_NET_GET_PKT_CAP_LENGTH(_hNetBuf_) _NT_NET_GET_PKT_CAP_LENGTH(_hNetBuf_) 185 186/** @def NT_NET_GET_PKT_WIRE_LENGTH 187 * @brief Returns the wire length of the received frame, in bytes, with the 188 * value saturated at 16,383 for longer frames 189 * @param[in] "_hNetBuf_" Packet container reference 190 * @return Returns the packet wire length 191 * @hideinitializer 192 */ 193#define NT_NET_GET_PKT_WIRE_LENGTH(_hNetBuf_) _NT_NET_GET_PKT_WIRE_LENGTH(_hNetBuf_) 194 195/** @def NT_DESCR_NT_LENGTH 196 * @brief Get length of the NT standard descriptor 197 * @param[in] "_hNetBuf_" Packet container reference 198 * @return Returns the length of the NT standard descriptor 199 * @hideinitializer 200 */ 201#define NT_DESCR_NT_LENGTH (sizeof(NtStd0Descr_t)) 202 203/** @def NT_DESCR_EXT7_LENGTH 204 * @brief Length of the NT Extended 7 descriptor 205 * @param[in] "_hNetBuf_" Packet container reference 206 * @return Returns the length of the NT Extended 7 descriptor 207 * @hideinitializer 208 */ 209#define NT_DESCR_EXT7_LENGTH (sizeof(NtExt7Descr_t)) 210 211/** @def NT_DESCR_EXT8_LENGTH 212 * @brief Length of the NT Extended 8 descriptor 213 * @param[in] "_hNetBuf_" Packet container reference 214 * @return Returns the length of the NT Extended 8 descriptor 215 * @hideinitializer 216 */ 217#define NT_DESCR_EXT8_LENGTH (sizeof(NtExt8Descr_t)) 218 219/** @def NT_DESCR_EXT9_LENGTH 220 * @brief Length of the NT Extended 9 descriptor 221 * @param[in] "_hNetBuf_" Packet container reference 222 * @return Returns the length of the NT Extended 9 descriptor 223 * @hideinitializer 224 */ 225#define NT_DESCR_EXT9_LENGTH (sizeof(NtExt9Descr_t)) 226 227/** @def NT_NET_GET_PKT_CRC_ERROR 228 * @brief Indicates if the received frame has a layer 2 CRC error. 229 * @param[in] "_hNetBuf_" Packet container reference 230 * @return Returns 1 if the packet has a L2 CRC error - If no L2 CRC error this is 0. 231 * @hideinitializer 232 */ 233#define NT_NET_GET_PKT_CRC_ERROR(_hNetBuf_) _NT_NET_GET_PKT_CRC_ERROR(_hNetBuf_) 234 235/** @def NT_NET_GET_PKT_TCP_CSUM_OK 236 * @brief Indicates if the received TCP checksum is correct 237 * @param[in] "_hNetBuf_" Packet container reference 238 * @return Returns 1 if the packet has a valid TCP checksum - if not a TCP packet this is 0 239 * @hideinitializer 240 */ 241#define NT_NET_GET_PKT_TCP_CSUM_OK(_hNetBuf_) _NT_NET_GET_PKT_TCP_CSUM_OK(_hNetBuf_) 242 243/** @def NT_NET_GET_PKT_UDP_CSUM_OK 244 * @brief Indicates if the received UDP checksum is correct 245 * @param[in] "_hNetBuf_" Packet container reference 246 * @return Returns 1 if the packet has a valid UDP checksum - if not a UDP packet this is 0 247 * @hideinitializer 248 */ 249#define NT_NET_GET_PKT_UDP_CSUM_OK(_hNetBuf_) _NT_NET_GET_PKT_UDP_CSUM_OK(_hNetBuf_) 250 251/** @def NT_NET_GET_PKT_IP_CSUM_OK 252 * @brief Indicates if the received IP checksum is correct 253 * @param[in] "_hNetBuf_" Packet container reference 254 * @return Returns 1 if the packet has a valid IP checksum - if not an IP packet this is 0 255 * @hideinitializer 256 */ 257#define NT_NET_GET_PKT_IP_CSUM_OK(_hNetBuf_) _NT_NET_GET_PKT_IP_CSUM_OK(_hNetBuf_) 258 259/** @def NT_NET_GET_PKT_CV_ERROR 260 * @brief Indicates if the frame has any coding violations errors. 261 * @param[in] "_hNetBuf_" Packet container reference 262 * @return Returns 1 if the packet has coding violations - If no coding violations this is 0. 263 * @hideinitializer 264 */ 265#define NT_NET_GET_PKT_CV_ERROR(_hNetBuf_) _NT_NET_GET_PKT_CV_ERROR(_hNetBuf_) 266 267/** @def NT_NET_GET_PKT_SLICED 268 * @brief Indicates if the frame has been sliced 269 * @param[in] "_hNetBuf_" Packet container reference 270 * @return Returns 1 if the packet has been sliced - If no slicing has occured this is 0 271 * @hideinitializer 272 */ 273#define NT_NET_GET_PKT_SLICED(_hNetBuf_) _NT_NET_GET_PKT_SLICED(_hNetBuf_) 274 275/** @def NT_NET_GET_PKT_HARD_SLICED 276 * @brief Indicates if the frame has been hard sliced. 277 * @param[in] "_hNetBuf_" Packet container reference 278 * @return Returns 1 if the packet has been hard sliced - If no hard slicing has occured this is 0 279 * @hideinitializer 280 */ 281#define NT_NET_GET_PKT_HARD_SLICED(_hNetBuf_) _NT_NET_GET_PKT_HARD_SLICED(_hNetBuf_) 282 283/** @def NT_NET_GET_PKT_RXPORT 284 * @brief Specifies the port number where the frame was received. 285 * @param[in] "_hNetBuf_" Packet container reference 286 * @return Returns the port that received this packet 287 * @hideinitializer 288 */ 289#define NT_NET_GET_PKT_RXPORT(_hNetBuf_) _NT_NET_GET_PKT_RXPORT(_hNetBuf_) 290 291/** @def NT_NET_GET_PKT_IS_TCP 292 * @brief Indicates if the received frame is a TCP frame. 293 * @param[in] "_hNetBuf_" Packet container reference 294 * @return Returns 1 if the packet has a TCP header - returns 0 if the packet does not have a TCP header 295 * @hideinitializer 296 */ 297#define NT_NET_GET_PKT_IS_TCP(_hNetBuf_) _NT_NET_GET_PKT_IS_TCP(_hNetBuf_) 298 299/** @def NT_NET_GET_PKT_IS_UDP 300 * @brief Indicates if the received frame is a UDP frame. 301 * @param[in] "_hNetBuf_" Packet container reference 302 * @return Returns 1 if the packet has an UDP header - returns 0 if the packet does not have an UDP header 303 * @hideinitializer 304 */ 305#define NT_NET_GET_PKT_IS_UDP(_hNetBuf_) _NT_NET_GET_PKT_IS_UDP(_hNetBuf_) 306 307/** @def NT_NET_GET_PKT_IS_IP 308 * @brief Indicates if the received frame is an IP frame 309 * @param[in] "_hNetBuf_" Packet container reference 310 * @return Returns 1 if the packet has an IP header - returns 0 if the packet does not have an IP header 311 * @hideinitializer 312 */ 313#define NT_NET_GET_PKT_IS_IP(_hNetBuf_) _NT_NET_GET_PKT_IS_IP(_hNetBuf_) 314 315/** @def NT_NET_GET_PKT_TXPORT 316 * @brief Get TX port 317 * @param[in] "_hNetBuf_" Packet container reference 318 * @return Returns the port number where the frame is to be transmitted. 319 * @hideinitializer 320 */ 321#define NT_NET_GET_PKT_TXPORT(_hNetBuf_) _NT_NET_GET_PKT_TXPORT(_hNetBuf_) 322 323/** @def NT_NET_GET_PKT_RECALC_L2_CRC 324 * @brief Indicates if the original CRC in the received frame will be recalculated and overwritten in the transmitted frame. 325 * @param[in] "_hNetBuf_" Packet container reference 326 * @return Returns 1 if the packet has L2 CRC recalc/override set - Returns 0 if L2 CRC recalc/override is not set 327 * @hideinitializer 328 */ 329#define NT_NET_GET_PKT_RECALC_L2_CRC(_hNetBuf_) _NT_NET_GET_PKT_RECALC_L2_CRC(_hNetBuf_) 330#if !defined(_NT_NTAPI_NO_COMPAT) 331#define NT_NET_GET_PKT_CALC_L2_CRC(_hNetBuf_) _NT_NET_GET_PKT_RECALC_L2_CRC(_hNetBuf_) 332#endif 333 334/** @def NT_NET_GET_PKT_TXNOW 335 * @brief Indicates if the frame is to be transmitted according to time stamp or as fast as possible. 336 * @param[in] "_hNetBuf_" Packet container reference 337 * @return Returns 1 if the packet has TxNow set - Returns 0 if TxNow is not set 338 * @hideinitializer 339 */ 340#define NT_NET_GET_PKT_TXNOW(_hNetBuf_) _NT_NET_GET_PKT_TXNOW(_hNetBuf_) 341 342/** @def NT_NET_GET_PKT_TXIGNORE 343 * @brief Indicates if the frame is to be transmitted or not. 344 * @param[in] "_hNetBuf_" Packet container reference 345 * @return Returns 1 if the packet has TxIgnore set - Returns 0 if TxIgnore is not set 346 * @hideinitializer 347 */ 348#define NT_NET_GET_PKT_TXIGNORE(_hNetBuf_) _NT_NET_GET_PKT_TXIGNORE(_hNetBuf_) 349 350/** @} */ 351 352#if !defined(_NTAPI_EXTDESCR_7_) && !defined(_NTAPI_EXTDESCR_8_) && !defined(_NTAPI_EXTDESCR_9_) 353 354/** @defgroup ExtendedNtDescriptorMacros Extended NT descriptor macros 355 * @{ 356 * The following is only available if "PacketDescriptor = Ext7, Ext8 or Ext9" has been set in the ntservice.ini 357 * file and if @ref NT_NET_GET_PKT_DESCRIPTOR_TYPE returns @ref NT_PACKET_DESCRIPTOR_TYPE_NT_EXTENDED 358 */ 359 360/** @def NT_NET_GET_PKT_HASH 361 * @brief Get the packet hash value 362 * @param[in] "_hNetBuf_" Packet container reference 363 * @return Returns the packet hash value. If the hash calculation is invalid, the value is 0x00. 364 * @hideinitializer 365 */ 366#define NT_NET_GET_PKT_HASH(_hNetBuf_) \ 367 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 368 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 369 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 370 _NT_NET_GET_PKT_HASH_EXT7(_hNetBuf_) : _NT_NET_ASSERT(~0)) 371 372/** @def NT_NET_GET_PKT_HASH_TYPE 373 * @brief Get the number of the used hash key type 374 * @param[in] "_hNetBuf_" Packet container reference 375 * @return Returns the number of the used hash key type. 376 * @hideinitializer 377 */ 378#define NT_NET_GET_PKT_HASH_TYPE(_hNetBuf_) \ 379 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 380 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 381 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 382 _NT_NET_GET_PKT_HASH_TYPE_EXT7(_hNetBuf_) : _NT_NET_ASSERT(~0)) 383 384/** @def NT_NET_GET_PKT_HASH_VALID 385 * @brief Indicates if the hash calculation is valid. 386 * @param[in] "_hNetBuf_" Packet container reference 387 * @return Returns 1 if the hash value/type is valid - Returns 0 if the hash value/type is invalid 388 * @hideinitializer 389 */ 390#define NT_NET_GET_PKT_HASH_VALID(_hNetBuf_) \ 391 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 392 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 393 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 394 _NT_NET_GET_PKT_HASH_VALID_EXT7(_hNetBuf_) : _NT_NET_ASSERT(~0)) 395 396/** @def NT_NET_GET_PKT_JUMBO 397 * @brief Indicates if the frame is a jumbo frame. 398 * @param[in] "_hNetBuf_" Packet container reference 399 * @return Returns 1 if the packet has a jumbo frame - Returns 0 if the packet does not have a jumbo frame 400 * @hideinitializer 401 */ 402#define NT_NET_GET_PKT_JUMBO(_hNetBuf_) \ 403 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 404 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 405 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 406 _NT_NET_GET_PKT_JUMBO_EXT7(_hNetBuf_) : _NT_NET_ASSERT(~0)) 407 408/** @def NT_NET_GET_PKT_BROADCAST 409 * @brief Indicates if the destination MAC address is broadcast. 410 * @param[in] "_hNetBuf_" Packet container reference 411 * @return Returns 1 if the destination MAC is a broadcast address - Returns 0 if the destination MAC is not a broadcast address 412 * @hideinitializer 413 */ 414#define NT_NET_GET_PKT_BROADCAST(_hNetBuf_) \ 415 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 416 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 417 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 418 _NT_NET_GET_PKT_BROADCAST_EXT7(_hNetBuf_) : _NT_NET_ASSERT(~0)) 419 420/** @def NT_NET_GET_PKT_L4_PORT_TYPE 421 * @brief Get the layer 4 port type 422 * When using extended descriptor 9 it is advised to use @ref NT_NET_GET_PKT_TUNNEL_TYPE instead. 423 * @param[in] "_hNetBuf_" Packet container reference 424 * @return Return the layer 4 port type - see @ref NtL4PortType_e for values 425 * @hideinitializer 426 */ 427#define NT_NET_GET_PKT_L4_PORT_TYPE(_hNetBuf_) \ 428 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 429 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8) ? _NT_NET_GET_PKT_L4_PORT_TYPE_EXT7(_hNetBuf_) : \ 430 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? _NT_NET_GET_PKT_L4_PORT_TYPE_EXT9(_hNetBuf_) : _NT_NET_ASSERT(~0))) 431 432/** @def NT_NET_GET_PKT_L4_FRAME_TYPE 433 * @brief Get layer 4 frame type 434 * @param[in] "_hNetBuf_" Packet container reference 435 * @return Returns layer 4 frame type - see @ref NtL4FrameType_e for values 436 * @hideinitializer 437 */ 438#define NT_NET_GET_PKT_L4_FRAME_TYPE(_hNetBuf_) \ 439 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 440 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 441 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 442 _NT_NET_GET_PKT_L4_FRAME_TYPE_EXT7(_hNetBuf_) : _NT_NET_ASSERT(~0)) 443 444/** @def NT_NET_GET_PKT_L3_FRAME_TYPE 445 * @brief Get layer 3 frame type 446 * @param[in] "_hNetBuf_" Packet container reference 447 * @return Returns layer 3 frame type - see @ref NtL3FrameType_e for values 448 * @hideinitializer 449 */ 450#define NT_NET_GET_PKT_L3_FRAME_TYPE(_hNetBuf_) \ 451 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 452 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 453 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 454 _NT_NET_GET_PKT_L3_FRAME_TYPE_EXT7(_hNetBuf_) : _NT_NET_ASSERT(~0)) 455 456/** @def NT_NET_GET_PKT_L2_FRAME_TYPE 457 * @brief Get layer 2 frame type 458 * @param[in] "_hNetBuf_" Packet container reference 459 * @return Returns layer 2 frame type - see @ref NtL2FrameType_e for values 460 * @hideinitializer 461 */ 462#define NT_NET_GET_PKT_L2_FRAME_TYPE(_hNetBuf_) \ 463 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 464 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 465 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 466 _NT_NET_GET_PKT_L2_FRAME_TYPE_EXT7(_hNetBuf_) : _NT_NET_ASSERT(~0)) 467 468/** @def NT_NET_GET_PKT_L4_LENGTH 469 * @brief Get layer 4 header length (valid for L4 = UDP/TCP only) 470 * @param[in] "_hNetBuf_" Packet container reference 471 * @return Returns layer 4 header length in units of 32 bits 472 * @hideinitializer 473 */ 474#define NT_NET_GET_PKT_L4_LENGTH(_hNetBuf_) \ 475 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 476 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 477 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 478 _NT_NET_GET_PKT_L4_LENGTH_EXT7(_hNetBuf_) : _NT_NET_ASSERT(~0)) 479 480/** @def NT_NET_GET_PKT_L3_LENGTH 481 * @brief Get layer 3 header length (valid for L3 = IPv4/IPv6 only) 482 * @param[in] "_hNetBuf_" Packet container reference 483 * @return Returns layer 3 header length in units of 32 bits 484 * @hideinitializer 485 */ 486#define NT_NET_GET_PKT_L3_LENGTH(_hNetBuf_) \ 487 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 488 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 489 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 490 _NT_NET_GET_PKT_L3_LENGTH_EXT7(_hNetBuf_) : _NT_NET_ASSERT(~0)) 491 492/** @def NT_NET_GET_PKT_MPLS_COUNT 493 * @brief Get the number of MPLS shim labels present 494 * @param[in] "_hNetBuf_" Packet container reference 495 * @return Returns the number of MPLS shim labels present 496 * @hideinitializer 497 */ 498#define NT_NET_GET_PKT_MPLS_COUNT(_hNetBuf_) \ 499 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 500 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 501 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 502 _NT_NET_GET_PKT_MPLS_COUNT_EXT7(_hNetBuf_) : _NT_NET_ASSERT(~0)) 503 504/** @def NT_NET_GET_PKT_VLAN_COUNT 505 * @brief Get the number of VLANs present 506 * @param[in] "_hNetBuf_" Packet container reference 507 * @return Returns the number of VLANs present 508 * @hideinitializer 509 */ 510#define NT_NET_GET_PKT_VLAN_COUNT(_hNetBuf_) \ 511 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 512 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 513 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 514 _NT_NET_GET_PKT_VLAN_COUNT_EXT7(_hNetBuf_) : _NT_NET_ASSERT(~0)) 515 516/** @def NT_NET_GET_PKT_ISL 517 * @brief Indicates if ISL encapsulation is present. 518 * @param[in] "_hNetBuf_" Packet container reference 519 * @return Returns 1 if ISL encapsulation is present - Returns 0 if ISL encapsulation is not present 520 * @hideinitializer 521 */ 522#define NT_NET_GET_PKT_ISL(_hNetBuf_) \ 523 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 524 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 525 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 526 _NT_NET_GET_PKT_ISL_EXT7(_hNetBuf_) : _NT_NET_ASSERT(~0)) 527 528/** @def NT_NET_GET_PKT_DECODE_ERROR 529 * @brief Indicates if a frame decoding error is present. 530 * @param[in] "_hNetBuf_" Packet container reference 531 * @return Returns 1 if the frame could not be decoded correctly - Returns 0 otherwise 532 * @hideinitializer 533 */ 534#define NT_NET_GET_PKT_DECODE_ERROR(_hNetBuf_) \ 535 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 536 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 537 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 538 _NT_NET_GET_PKT_DECODE_ERROR_EXT7(_hNetBuf_) : _NT_NET_ASSERT(~0)) 539#if !defined(_NT_NTAPI_NO_COMPAT) 540#define NT_NET_GET_PKT_PROT_SMALL(_hNetBuf_) NT_NET_GET_PKT_DECODE_ERROR(_hNetBuf_) 541#endif 542 543 544/** @def NT_NET_GET_PKT_FRAME_LARGE 545 * @brief Indicates if the frame is a large frame. 546 * @param[in] "_hNetBuf_" Packet container reference 547 * @return - Returns 1 when FrameSize > MaxFrameSize. MaxFrameSize is set in ntservice.ini. Returns 0 when FrameSize <= MaxFrameSize 548 * @hideinitializer 549 */ 550#define NT_NET_GET_PKT_FRAME_LARGE(_hNetBuf_) \ 551 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 552 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 553 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 554 _NT_NET_GET_PKT_FRAME_LARGE_EXT7(_hNetBuf_) : _NT_NET_ASSERT(~0)) 555 556/** @def NT_NET_GET_PKT_FRAME_SMALL 557 * @brief Indicates if the frame is a small frame. 558 * @param[in] "_hNetBuf_" Packet container reference 559 * @return Returns 1 when PktSz < 64 (+ISL and/or VLAN) - Returns 0 when PktSz >= 64 560 * @hideinitializer 561 */ 562#define NT_NET_GET_PKT_FRAME_SMALL(_hNetBuf_) \ 563 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 564 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 565 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 566 _NT_NET_GET_PKT_FRAME_SMALL_EXT7(_hNetBuf_) : _NT_NET_ASSERT(~0)) 567 568/** @def NT_NET_GET_PKT_IPV6_FR_HEADER 569 * @brief Indicates if an IPv6 fragment header is present. 570 * @param[in] "_hNetBuf_" Packet container reference 571 * @return Returns 1 if IPv6 fragment header is present - Returns 0 if no IPv6 fragment header is present 572 * @hideinitializer 573 */ 574#define NT_NET_GET_PKT_IPV6_FR_HEADER(_hNetBuf_) \ 575 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 576 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 577 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 578 _NT_NET_GET_PKT_IPV6_FR_HEADER_EXT7(_hNetBuf_) : _NT_NET_ASSERT(~0)) 579 580/** @def NT_NET_GET_PKT_IPV6_RT_HEADER 581 * @brief Indicates if an IPv6 routing header is present. 582 * @param[in] "_hNetBuf_" Packet container reference 583 * @return Returns 1 if IPv6 routing header is present - Returns 0 if no IPv6 routing header is present 584 * @hideinitializer 585 */ 586#define NT_NET_GET_PKT_IPV6_RT_HEADER(_hNetBuf_) \ 587 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 588 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 589 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 590 _NT_NET_GET_PKT_IPV6_RT_HEADER_EXT7(_hNetBuf_) : _NT_NET_ASSERT(~0)) 591 592/** @def NT_NET_GET_PKT_L4_PROTOCOL_NUM 593 * @brief Get layer 4 protocol number (TCP, UDP, SCTP etc.) - if not an IP packet this is 0 594 * @param[in] "_hNetBuf_" Packet container reference 595 * @return Returns the layer 4 protocol number / next header. 596 * @hideinitializer 597 */ 598#define NT_NET_GET_PKT_L4_PROTOCOL_NUM(_hNetBuf_) \ 599 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 600 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 601 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 602 _NT_NET_GET_PKT_L4_PROTOCOL_NUM_EXT7(_hNetBuf_) : _NT_NET_ASSERT(~0)) 603 604/** @def NT_NET_GET_PKT_L3_FRAGMENTED 605 * @brief Indicates if the packet is part of a layer 3 fragmented datagram. Only valid for IPv4 if more fragments bit = 1 or fragment offset not equal to 0 606 * @param[in] "_hNetBuf_" Packet container reference 607 * @return Returns 1 if fragmented layer 3 - Returns 0 otherwise 608 * @hideinitializer 609 */ 610#define NT_NET_GET_PKT_L3_FRAGMENTED(_hNetBuf_) \ 611 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 612 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 613 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 614 _NT_NET_GET_PKT_L3_FRAGMENTED_EXT7(_hNetBuf_) : _NT_NET_ASSERT(~0)) 615 616/** @def NT_NET_GET_PKT_L3_FIRST_FRAG 617 * @brief Layer 3 First fragment (offset = 0) Note: Only valid for IPv4 - always set on IPv6 so use IPV6_FR_HEADER instead 618 * @param[in] "_hNetBuf_" Packet container reference 619 * @return Returns 1 if first fragment or not fragmented - Returns 0 otherwise 620 * @hideinitializer 621 */ 622#define NT_NET_GET_PKT_L3_FIRST_FRAG(_hNetBuf_) \ 623 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 624 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 625 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 626 _NT_NET_GET_PKT_L3_FIRST_FRAG_EXT7(_hNetBuf_) : _NT_NET_ASSERT(~0)) 627 628/** @def NT_NET_GET_PKT_COLOR 629 * @brief Returns the packet color of the frame, if the frame matches a 630 * filter. The color is automatically assigned as a 6bit color ID when the 631 * filter is defined. If the frame matches more than one filter, the packet 632 * color of the frame is the one from the filter with the highest priority. 633 * @param[in] "_hNetBuf_" Packet container reference 634 * @return Returns the color of the packet as an integer value 635 * @hideinitializer 636 */ 637#define NT_NET_GET_PKT_COLOR(_hNetBuf_) \ 638 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 639 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 640 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 641 _NT_NET_GET_PKT_COLOR_EXT7(_hNetBuf_) : _NT_NET_ASSERT(~0)) 642 643/** @def NT_NET_GET_PKT_L5_OFFSET 644 * @brief Returns the offset in bytes (0x00 - 0x1FF) from the start of the 645 * frame to the start of layer 5. The value 0x00 indicates an invalid offset. 646 * @param[in] "_hNetBuf_" Packet container reference 647 * @return Returns layer 5 offset as an integer value 648 * @hideinitializer 649 */ 650#define NT_NET_GET_PKT_L5_OFFSET(_hNetBuf_) \ 651 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 652 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 653 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 654 _NT_NET_GET_PKT_L5_OFFSET_EXT7(_hNetBuf_) : _NT_NET_ASSERT(~0)) 655 656/** @def NT_NET_GET_PKT_L4_OFFSET 657 * @brief Returns the offset in bytes (0x00 - 0x1FF) from the start of the 658 * frame to the start of layer 4. The value 0x00 indicates an invalid offset. 659 * @param[in] "_hNetBuf_" Packet container reference 660 * @return Returns layer 4 offset as an integer value 661 * @hideinitializer 662 */ 663#define NT_NET_GET_PKT_L4_OFFSET(_hNetBuf_) \ 664 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 665 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 666 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 667 _NT_NET_GET_PKT_L4_OFFSET_EXT7(_hNetBuf_) : _NT_NET_ASSERT(~0)) 668 669/** @def NT_NET_GET_PKT_L3_OFFSET 670 * @brief Returns the offset in bytes (0x00 - 0x1FF) from the start of the 671 * frame to the start of layer 3. The value 0x00 indicates an invalid offset. 672 * @param[in] "_hNetBuf_" Packet container reference 673 * @return Returns layer 3 offset as an integer value 674 * @hideinitializer 675 */ 676#define NT_NET_GET_PKT_L3_OFFSET(_hNetBuf_) \ 677 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 678 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 679 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 680 _NT_NET_GET_PKT_L3_OFFSET_EXT7(_hNetBuf_) : _NT_NET_ASSERT(~0)) 681 682/** @def NT_NET_GET_PKT_DEDUPLICATION_CRC 683 * @brief The packet deduplication CRC value. Only available on extended descriptor 9. 684 * @param[in] "_hNetBuf_" Packet container reference 685 * @return Returns the 24bit packet deduplication CRC value. 686 * @hideinitializer 687 */ 688#define NT_NET_GET_PKT_DEDUPLICATION_CRC(_hNetBuf_) \ 689 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 690 _NT_NET_GET_PKT_DEDUPLICATION_CRC_EXT9(_hNetBuf_) : _NT_NET_ASSERT(~0)) 691 692/** @} */ 693 694/** @defgroup ExtendedNtDescriptorIPFMacros Extended NT descriptor IPF macros 695 * @{ 696 * The following are used to help collect IP fragmented data. With theses 697 * macros it is possible to de-fragment IP fragmented data in a 698 * multi-processing application using 5-tuple hashing. It is only available if 699 * "PacketDescriptor" in the ntservice.ini file has been set to "Ext8" or 700 * "Ext9" and if @ref NT_NET_GET_PKT_DESCRIPTOR_TYPE returns @ref 701 * NT_PACKET_DESCRIPTOR_TYPE_NT_EXTENDED @note: These macros do not return 702 * valid values if the IPF engine is not turned on see @ref NtplIPFMode 703 */ 704 705/** @def NT_NET_GET_PKT_IPF_UNMATCHED_STREAMID 706 * @brief Stream ID where unmatched fragments are stored 707 * @param[in] "_hNetBuf_" Packet container reference 708 * @return Returns the stream ID where unmatched fragments are stored 709 * @hideinitializer 710 */ 711#define NT_NET_GET_PKT_IPF_UNMATCHED_STREAMID(_hNetBuf_) \ 712 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 713 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 714 _NT_NET_GET_PKT_IPF_UNMATCHED_STREAMID_EXT8(_hNetBuf_) : _NT_NET_ASSERT(~0)) 715 716/** @def NT_NET_GET_PKT_IPF_UNMATCHED_FLAG 717 * @brief Indicates if no entry corresponding to the packet was allocated or 718 * found in the datagram lookup table. 719 * @param[in] "_hNetBuf_" Packet container reference 720 * @return Returns 1 if unmatched - Returns 0 otherwise 721 * @hideinitializer 722 */ 723#define NT_NET_GET_PKT_IPF_UNMATCHED_FLAG(_hNetBuf_) \ 724 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 725 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 726 _NT_NET_GET_PKT_IPF_UNMATCHED_FLAG_EXT8(_hNetBuf_) : _NT_NET_ASSERT(~0)) 727 728/** @def NT_NET_GET_PKT_IPF_LAST_FRAGMENT 729 * @brief Indicates if the packet is the last fragment of a layer 3 730 * fragmented datagram. (More fragment bit = 0 && offset != 0) 731 * @param[in] "_hNetBuf_" Packet container reference 732 * @return Returns 1 if last fragment - Returns 0 otherwise 733 * @hideinitializer 734 */ 735#define NT_NET_GET_PKT_IPF_LAST_FRAGMENT(_hNetBuf_) \ 736 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 737 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 738 _NT_NET_GET_PKT_IPF_LAST_FRAGMENT_EXT8(_hNetBuf_) : _NT_NET_ASSERT(~0)) 739 740/** @} */ 741 742/** @defgroup ExtendedNtDescriptorTunnelMacros Extended NT descriptor Tunneling macros 743 * @{ 744 * 745 * The following are used to help accessing GTPv1 and IP-in-IP tunneled 746 * data. With theses macros it is possible to determine the tunnel type, 747 * retrieve the frame types and get direct offsets to the layers 3, 4 and 5 748 * inside the tunnel. Only the first tunnel is decoded, hence a tunnel inside 749 * a tunnel is not decoded. The following macros are only available if 750 * "PacketDescriptor" in the ntservice.ini file has been set to "Ext9" or if 751 * "Ext9" is configured as the descriptor type in the NTPL "assign" statement 752 * matching the received packet. 753 */ 754 755/** @def NT_NET_GET_PKT_INNER_L3_OFFSET 756 * @brief Returns the offset in bytes (0x00 - 0x1FF) from the start of the 757 * frame to the start of inner layer 3. The value 0x00 indicates an invalid 758 * offset. 759 * @param[in] "_hNetBuf_" Packet container reference 760 * @return Returns inner layer 3 offset as an integer value 761 * @hideinitializer 762 */ 763#define NT_NET_GET_PKT_INNER_L3_OFFSET(_hNetBuf_) \ 764 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 765 _NT_NET_GET_PKT_INNER_L3_OFFSET_EXT9(_hNetBuf_) : _NT_NET_ASSERT(~0)) 766 767/** @def NT_NET_GET_PKT_INNER_L4_OFFSET 768 * @brief Returns the offset in bytes (0x00 - 0x1FF) from the start of the 769 * frame to the start of inner layer 4. The value 0x00 indicates an invalid 770 * offset. 771 * @param[in] "_hNetBuf_" Packet container reference 772 * @return Returns inner layer 4 offset as an integer value 773 * @hideinitializer 774 */ 775#define NT_NET_GET_PKT_INNER_L4_OFFSET(_hNetBuf_) \ 776 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 777 _NT_NET_GET_PKT_INNER_L4_OFFSET_EXT9(_hNetBuf_) : _NT_NET_ASSERT(~0)) 778 779/** @def NT_NET_GET_PKT_INNER_L5_OFFSET 780 * @brief Returns the offset in bytes (0x00 - 0x1FF) from the start of the 781 * frame to the start of inner layer 5. The value 0x00 indicates an invalid 782 * offset. 783 * @param[in] "_hNetBuf_" Packet container reference 784 * @return Returns inner layer 5 offset as an integer value 785 * @hideinitializer 786 */ 787#define NT_NET_GET_PKT_INNER_L5_OFFSET(_hNetBuf_) \ 788 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 789 _NT_NET_GET_PKT_INNER_L5_OFFSET_EXT9(_hNetBuf_) : _NT_NET_ASSERT(~0)) 790 791/** @def NT_NET_GET_PKT_INNER_L3_FRAME_TYPE 792 * @brief Get the inner tunnel layer 3 frame type 793 * @param[in] "_hNetBuf_" Packet container reference 794 * @return Returns the inner tunnel layer 3 frame type - see @ref NtL3FrameType_e for values 795 * @hideinitializer 796 */ 797#define NT_NET_GET_PKT_INNER_L3_FRAME_TYPE(_hNetBuf_) \ 798 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 799 _NT_NET_GET_PKT_INNER_L3_FRAME_TYPE_EXT9(_hNetBuf_) : _NT_NET_ASSERT(~0)) 800 801/** @def NT_NET_GET_PKT_INNER_L4_FRAME_TYPE 802 * @brief Get the inner tunnel layer 4 frame type 803 * @param[in] "_hNetBuf_" Packet container reference 804 * @return Returns the inner tunnel layer 4 frame type - see @ref NtL4FrameType_e for values 805 * @hideinitializer 806 */ 807#define NT_NET_GET_PKT_INNER_L4_FRAME_TYPE(_hNetBuf_) \ 808 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 809 _NT_NET_GET_PKT_INNER_L4_FRAME_TYPE_EXT9(_hNetBuf_) : _NT_NET_ASSERT(~0)) 810 811/** @def NT_NET_GET_PKT_INNER_L3_FRAGMENT_TYPE 812 * @brief Get inner layer 3 fragment type 813 * @param[in] "_hNetBuf_" Packet container reference 814 * @return Returns inner layer 3 fragment type - see @ref NtL3FragmentType_e for values 815 * @hideinitializer 816 */ 817#define NT_NET_GET_PKT_INNER_L3_FRAGMENT_TYPE(_hNetBuf_) \ 818 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 819 _NT_NET_GET_PKT_INNER_L3_FRAGMENT_TYPE_EXT9(_hNetBuf_) : _NT_NET_ASSERT(~0)) 820 821/** @def NT_NET_GET_PKT_TUNNEL_TYPE 822 * @brief Get the tunnel type 823 * @param[in] "_hNetBuf_" Packet container reference 824 * @return Returns the tunnel type - see @ref NtTunnelType_e for values 825 * @hideinitializer 826 */ 827#define NT_NET_GET_PKT_TUNNEL_TYPE(_hNetBuf_) \ 828 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 829 _NT_NET_GET_PKT_TUNNEL_TYPE_EXT9(_hNetBuf_) : _NT_NET_ASSERT(~0)) 830 831/** @def NT_NET_GET_PKT_TUNNEL_HDR_LENGTH 832 * @brief Get the tunnel header length 833 * @param[in] "_hNetBuf_" Packet container reference 834 * @return Returns the tunnel header length in units of 32 bits 835 * @hideinitializer 836 */ 837#define NT_NET_GET_PKT_TUNNEL_HDR_LENGTH(_hNetBuf_) \ 838 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 839 _NT_NET_GET_PKT_TUNNEL_HDR_LENGTH_EXT9(_hNetBuf_) : _NT_NET_ASSERT(~0)) 840 841/** @def NT_NET_GET_PKT_INNER_DECODE_ERROR 842 * @brief Indicates if a inner tunnel frame decoding error is present. 843 * @param[in] "_hNetBuf_" Packet container reference 844 * @return Returns 1 if the inner tunnel frame could not be decoded correctly - Returns 0 otherwise 845 * @hideinitializer 846 */ 847#define NT_NET_GET_PKT_INNER_DECODE_ERROR(_hNetBuf_) \ 848 ((_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) ? \ 849 _NT_NET_GET_PKT_INNER_DECODE_ERROR_EXT9(_hNetBuf_) : _NT_NET_ASSERT(~0)) 850 851/** @} */ 852 853#endif /* !defined(_NTAPI_EXTDESCR_7_) && !defined(_NTAPI_EXTDESCR_8_) && !defined(_NTAPI_EXTDESCR_9_) */ 854 855/** @defgroup TxMacros TX macros 856 * @{ 857 * The following can only be used on TX or in-line based streams 858 * 859 */ 860 861/** @def NT_NET_SET_PKT_CLEAR_DESCR_NT 862 * @brief Clears the NT descriptor 863 * @param[in] "_hNetBuf_" Packet container reference 864 * @hideinitializer 865 */ 866#define NT_NET_SET_PKT_CLEAR_DESCR_NT(_hNetBuf_) do{ memset((_hNetBuf_)->hHdr, 0, sizeof(NtStd0Descr_t)); } while(0) 867 868/** @def NT_NET_SET_PKT_DESCR_TYPE_NT 869 * @brief Sets the packet descriptor type to NT 870 * @param[in] "_hNetBuf_" Packet container reference 871 * @hideinitializer 872 */ 873#define NT_NET_SET_PKT_DESCR_TYPE_NT(_hNetBuf_) do{ _NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->descriptorType = 1; } while(0) 874 875/** @def NT_NET_SET_PKT_CLEAR_DESCR_EXT7 876 * @brief Clears the EXT7 descriptor 877 * @param[in] "_hNetBuf_" Packet container reference 878 * @hideinitializer 879 */ 880#define NT_NET_SET_PKT_CLEAR_DESCR_EXT7(_hNetBuf_) do{ memset((_hNetBuf_)->hHdr, 0, sizeof(NtExt7Descr_t)); } while(0) 881 882/** @def NT_NET_SET_PKT_DESCR_TYPE_EXT7 883 * @brief Sets the packet descriptor type to EXT7 884 * @param[in] "_hNetBuf_" Packet container reference 885 * @hideinitializer 886 */ 887#ifndef DOXYGEN_INTERNAL_ONLY 888#define NT_EXTENDED_DESCRIPTOR_07_LENGTH 2 889#define NT_EXTENDED_DESCRIPTOR_07_TYPE 7 890#endif // DOXYGEN_INTERNAL_ONLY 891#define NT_NET_SET_PKT_DESCR_TYPE_EXT7(_hNetBuf_) \ 892 do{ _NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->descriptorType = 1; \ 893 _NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->extensionFormat = NT_EXTENDED_DESCRIPTOR_07_TYPE; \ 894 _NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->extensionLength = NT_EXTENDED_DESCRIPTOR_07_LENGTH; } while(0) 895 896/** @def NT_NET_SET_PKT_CLEAR_DESCR_EXT8 897 * @brief Clears the EXT8 descriptor 898 * @param[in] "_hNetBuf_" Packet container reference 899 * @hideinitializer 900 */ 901#define NT_NET_SET_PKT_CLEAR_DESCR_EXT8(_hNetBuf_) do{ memset((_hNetBuf_)->hHdr, 0, sizeof(NtExt8Descr_t)); } while(0) 902 903/** @def NT_NET_SET_PKT_DESCR_TYPE_EXT8 904 * @brief Sets the packet descriptor type to EXT8 905 * @param[in] "_hNetBuf_" Packet container reference 906 * @hideinitializer 907 */ 908#ifndef DOXYGEN_INTERNAL_ONLY 909#define NT_EXTENDED_DESCRIPTOR_08_LENGTH 2 910#define NT_EXTENDED_DESCRIPTOR_08_TYPE 8 911#endif // DOXYGEN_INTERNAL_ONLY 912#define NT_NET_SET_PKT_DESCR_TYPE_EXT8(_hNetBuf_) \ 913 do{ _NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->descriptorType = 1; \ 914 _NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->extensionFormat = NT_EXTENDED_DESCRIPTOR_08_TYPE; \ 915 _NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->extensionLength = NT_EXTENDED_DESCRIPTOR_08_LENGTH; } while(0) 916 917/** @def NT_NET_SET_PKT_CLEAR_DESCR_EXT9 918 * @brief Clears the EXT9 descriptor 919 * @param[in] "_hNetBuf_" Packet container reference 920 * @hideinitializer 921 */ 922#define NT_NET_SET_PKT_CLEAR_DESCR_EXT9(_hNetBuf_) do{ memset((_hNetBuf_)->hHdr, 0, sizeof(NtExt9Descr_t)); } while(0) 923 924/** @def NT_NET_SET_PKT_DESCR_TYPE_EXT9 925 * @brief Sets the packet descriptor type to EXT9 926 * @param[in] "_hNetBuf_" Packet container reference 927 * @hideinitializer 928 */ 929#ifndef DOXYGEN_INTERNAL_ONLY 930#define NT_EXTENDED_DESCRIPTOR_09_LENGTH 3 931#define NT_EXTENDED_DESCRIPTOR_09_TYPE 9 932#endif // DOXYGEN_INTERNAL_ONLY 933#define NT_NET_SET_PKT_DESCR_TYPE_EXT9(_hNetBuf_) \ 934 do{ _NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->descriptorType = 1; \ 935 _NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->extensionFormat = NT_EXTENDED_DESCRIPTOR_09_TYPE; \ 936 _NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->extensionLength = NT_EXTENDED_DESCRIPTOR_09_LENGTH; } while(0) 937 938/** @def NT_NET_SET_PKT_CAP_LENGTH 939 * @brief Calculates and sets the packet capture length. Input is wire length. Capture length is calculated from the value. 940 * @param[in] "_hNetBuf_" Packet container reference 941 * @param[in] "_Length_" The length value 942 * @hideinitializer 943 */ 944#define NT_NET_SET_PKT_CAP_LENGTH(_hNetBuf_, _Length_) _NT_NET_SET_PKT_CAP_LENGTH(_hNetBuf_, _Length_) 945 946/** @def NT_NET_SET_PKT_CAP_LENGTH_NOALIGN 947 * @brief Calculates and sets the packet capture length. Input is wire length. Capture length is calculated from the value - no alignment is applied 948 * @param[in] "_hNetBuf_" Packet container reference 949 * @param[in] "_Length_" The length value 950 * @hideinitializer 951 */ 952#define NT_NET_SET_PKT_CAP_LENGTH_NOALIGN(_hNetBuf_, _Length_) _NT_NET_SET_PKT_CAP_LENGTH_NOALIGN(_hNetBuf_, _Length_) 953 954/** @def NT_NET_SET_PKT_WIRE_LENGTH 955 * @brief Sets the packet wire length 956 * @param[in] "_hNetBuf_" Packet container reference 957 * @param[in] "_Length_" The length value 958 * @hideinitializer 959 */ 960#define NT_NET_SET_PKT_WIRE_LENGTH(_hNetBuf_, _Length_) _NT_NET_SET_PKT_WIRE_LENGTH(_hNetBuf_, _Length_) 961 962/** @def NT_NET_SET_PKT_RECALC_L2_CRC 963 * @brief Asks the adapter to re-generate the CRC 964 * @param[in] "_hNetBuf_" Packet container reference 965 * @param[in] "_bval_" Set to 1 if CRC should be re-generated, 0 otherwise 966 * @hideinitializer 967 */ 968#define NT_NET_SET_PKT_RECALC_L2_CRC(_hNetBuf_, _bval_) _NT_NET_SET_PKT_RECALC_L2_CRC(_hNetBuf_, _bval_) 969#if !defined(_NT_NTAPI_NO_COMPAT) 970#define NT_NET_SET_PKT_CALC_L2_CRC(_hNetBuf_, _bval_) NT_NET_SET_PKT_RECALC_L2_CRC(_hNetBuf_, _bval_) 971#endif 972 973/** @def NT_NET_SET_PKT_TIMESTAMP 974 * @brief Sets the packet time stamp - useful when controlling the traffic rate 975 * @param[in] "_hNetBuf_" Packet container reference 976 * @param[in] "_ts_" The timestamp value in 10ns resolution NATIVE format 977 * @hideinitializer 978 */ 979#define NT_NET_SET_PKT_TIMESTAMP(_hNetBuf_, _ts_) _NT_NET_SET_PKT_TIMESTAMP(_hNetBuf_, _ts_) 980 981/** @def NT_NET_SET_PKT_TXNOW 982 * @brief If set the IPG is ignored - this will result in line rate TX 983 * @param[in] "_hNetBuf_" Packet container reference 984 * @param[in] "_bval_" Set to 1 if line rate, 0 otherwise 985 * @hideinitializer 986 */ 987#define NT_NET_SET_PKT_TXNOW(_hNetBuf_, _bval_) _NT_NET_SET_PKT_TXNOW(_hNetBuf_, _bval_) 988 989/** @def NT_NET_SET_PKT_TXSETCLOCK 990 * @brief Cause the adapter transmission delta to by incremented by the configured delta adjustment before transmitting the packet 991 * @param[in] "_hNetBuf_" Packet container reference 992 * @param[in] "_bval_" Set to 1 to increment delta before transmitting this packet, 0 otherwise 993 * @hideinitializer 994 */ 995#define NT_NET_SET_PKT_TXSETCLOCK(_hNetBuf_, _bval_) _NT_NET_SET_PKT_TXSETCLOCK(_hNetBuf_, _bval_) 996 997/** @def NT_NET_SET_PKT_TXIGNORE 998 * @brief Marks the packet not to be sent - useful in in-line scenarios where some packets should not be retransmitted 999 * @param[in] "_hNetBuf_" Packet container reference 1000 * @param[in] "_bval_" Set to 1 to not transmit the packet, 0 otherwise 1001 * @hideinitializer 1002 */ 1003#define NT_NET_SET_PKT_TXIGNORE(_hNetBuf_, _bval_) _NT_NET_SET_PKT_TXIGNORE(_hNetBuf_, _bval_) 1004 1005/** @def NT_NET_SET_PKT_IS_IP 1006 * @brief Sets if the packet is IP 1007 * @param[in] "_hNetBuf_" Packet container reference 1008 * @param[in] "_bval_" Set to 1 if IP packet, 0 otherwise 1009 * @hideinitializer 1010 */ 1011#define NT_NET_SET_PKT_IS_IP(_hNetBuf_, _bval_) _NT_NET_SET_PKT_IS_IP(_hNetBuf_, _bval_) 1012 1013/** @def NT_NET_SET_PKT_IS_UDP 1014 * @brief Sets if the packet is UDP 1015 * @param[in] "_hNetBuf_" Packet container reference 1016 * @param[in] "_bval_" Set to 1 if UDP packet, 0 otherwise 1017 * @hideinitializer 1018 */ 1019#define NT_NET_SET_PKT_IS_UDP(_hNetBuf_, _bval_) _NT_NET_SET_PKT_IS_UDP(_hNetBuf_, _bval_) 1020 1021/** @def NT_NET_SET_PKT_IS_TCP 1022 * @brief Sets if the packet is TCP 1023 * @param[in] "_hNetBuf_" Packet container reference 1024 * @param[in] "_bval_" Set to 1 if TCP packet, 0 otherwise 1025 * @hideinitializer 1026 */ 1027#define NT_NET_SET_PKT_IS_TCP(_hNetBuf_, _bval_) _NT_NET_SET_PKT_IS_TCP(_hNetBuf_, _bval_) 1028 1029/** @def NT_NET_SET_PKT_CRC_ERROR 1030 * @brief Sets if the packet has a CRC error 1031 * @param[in] "_hNetBuf_" Packet container reference 1032 * @param[in] "_bval_" Set to 1 if packet has a CRC error, 0 otherwise 1033 * @hideinitializer 1034 */ 1035#define NT_NET_SET_PKT_CRC_ERROR(_hNetBuf_, _bval_) _NT_NET_SET_PKT_CRC_ERROR(_hNetBuf_, _bval_) 1036 1037/** @def NT_NET_SET_PKT_IP_CSUM_OK 1038 * @brief Sets if the packet has an OK IP checksum 1039 * @param[in] "_hNetBuf_" Packet container reference 1040 * @param[in] "_bval_" Set to 1 if packet packet has an OK IP checksum, 0 otherwise 1041 * @hideinitializer 1042 */ 1043#define NT_NET_SET_PKT_IP_CSUM_OK(_hNetBuf_, _bval_) _NT_NET_SET_PKT_IP_CSUM_OK(_hNetBuf_, _bval_) 1044 1045/** @def NT_NET_SET_PKT_TCP_CSUM_OK 1046 * @brief Sets if the packet has an OK TCP checksum 1047 * @param[in] "_hNetBuf_" Packet container reference 1048 * @param[in] "_bval_" Set to 1 if packet packet has an OK TCP checksum, 0 otherwise 1049 * @hideinitializer 1050 */ 1051#define NT_NET_SET_PKT_TCP_CSUM_OK(_hNetBuf_, _bval_) _NT_NET_SET_PKT_TCP_CSUM_OK(_hNetBuf_, _bval_) 1052 1053/** @def NT_NET_SET_PKT_UDP_CSUM_OK 1054 * @brief Sets if the packet has an OK UDP checksum 1055 * @param[in] "_hNetBuf_" Packet container reference 1056 * @param[in] "_bval_" Set to 1 if packet packet has an OK UDP checksum, 0 otherwise 1057 * @hideinitializer 1058 */ 1059#define NT_NET_SET_PKT_UDP_CSUM_OK(_hNetBuf_, _bval_) _NT_NET_SET_PKT_UDP_CSUM_OK(_hNetBuf_, _bval_) 1060 1061/** @def NT_NET_SET_PKT_TXPORT 1062 * @brief Sets the packet port where the packets should be transmitted @note This feature only works on the CaptureReplay profile and the TX port can only be within the range of one adapter 1063 * @param[in] "_hNetBuf_" Packet container reference 1064 * @param[in] "_Port_" Port number 1065 * @hideinitializer 1066 */ 1067#define NT_NET_SET_PKT_TXPORT(_hNetBuf_, _Port_) _NT_NET_SET_PKT_TXPORT(_hNetBuf_, _Port_) 1068 1069#if !defined(_NTAPI_EXTDESCR_7_) && !defined(_NTAPI_EXTDESCR_8_) && !defined(_NTAPI_EXTDESCR_9_) 1070 1071/** @defgroup ExtendedTxMacros Extended TX macros 1072 * @{ 1073 * The following can only be used if the TX buffer has an extended NT descriptor 1074 */ 1075 1076/** @def NT_NET_SET_PKT_INJECT_TIMESTAMP 1077 * @brief Injects a time stamp on TX 1078 * 1079 * The time stamp is injected into the payload at the offset 1080 * provided. Offset range: 0-512. See @ref TimeStampInject "Time 1081 * Stamp Injection" for further information 1082 * @param[in] "_hNetBuf_" Packet container reference 1083 * @param[in] "_offset_" Offset to inject timestamp at 1084 * @hideinitializer 1085 */ 1086#define NT_NET_SET_PKT_INJECT_TIMESTAMP(_hNetBuf_, _offset_) \ 1087 do { if(_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 1088 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 1089 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) \ 1090 _NT_NET_SET_PKT_INJECT_TIMESTAMP_EXT7(_hNetBuf_, _offset_); \ 1091 else assert(0); } while(0) 1092 1093/** @def NT_NET_SET_PKT_ISL 1094 * @brief Sets if the frame is ISL encapsulated 1095 * @param[in] "_hNetBuf_" Packet container reference 1096 * @param[in] "_bval_" Set 1 if ISL encapsulated, 0 otherwise 1097 * @hideinitializer 1098 */ 1099#define NT_NET_SET_PKT_ISL(_hNetBuf_, _bval_) \ 1100 do { if(_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 1101 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 1102 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) \ 1103 _NT_NET_SET_PKT_ISL_EXT7(_hNetBuf_, _bval_); \ 1104 else assert(0); } while(0) 1105 1106/** @def NT_NET_SET_PKT_VLAN_COUNT 1107 * @brief Sets the number of VLAN tags 1108 * @param[in] "_hNetBuf_" Packet container reference 1109 * @param[in] "_count_" The VLAN tag count 1110 * @hideinitializer 1111 */ 1112#define NT_NET_SET_PKT_VLAN_COUNT(_hNetBuf_, _count_) \ 1113 do { if(_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 1114 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 1115 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) \ 1116 _NT_NET_SET_PKT_VLAN_COUNT_EXT7(_hNetBuf_, _count_); \ 1117 else assert(0); } while(0) 1118 1119/** @def NT_NET_SET_PKT_MPLS_COUNT 1120 * @brief Sets the number of MPLS shim labels 1121 * @param[in] "_hNetBuf_" Packet container reference 1122 * @param[in] "_count_" The MPLS shim labels count 1123 * @hideinitializer 1124 */ 1125#define NT_NET_SET_PKT_MPLS_COUNT(_hNetBuf_, _count_) \ 1126 do { if(_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 1127 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 1128 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) \ 1129 _NT_NET_SET_PKT_MPLS_COUNT_EXT7(_hNetBuf_, _count_); \ 1130 else assert(0); } while(0) 1131 1132/** @def NT_NET_SET_PKT_L2_FRAME_TYPE 1133 * @brief Sets the L2 frame type, see @ref NtL2FrameType_e 1134 * @param[in] "_hNetBuf_" Packet container reference 1135 * @param[in] "_type_" The L2 frame type 1136 * @hideinitializer 1137 */ 1138#define NT_NET_SET_PKT_L2_FRAME_TYPE(_hNetBuf_, _type_) \ 1139 do { if(_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 1140 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 1141 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) \ 1142 _NT_NET_SET_PKT_L2_FRAME_TYPE_EXT7(_hNetBuf_, _type_); \ 1143 else assert(0); } while(0) 1144 1145/** @def NT_NET_SET_PKT_L3_FRAME_TYPE 1146 * @brief Sets the L3 frame type, see @ref NtL3FrameType_e 1147 * @param[in] "_hNetBuf_" Packet container reference 1148 * @param[in] "_type_" The L3 frame type 1149 * @hideinitializer 1150 */ 1151#define NT_NET_SET_PKT_L3_FRAME_TYPE(_hNetBuf_, _type_) \ 1152 do { if(_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 1153 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 1154 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) \ 1155 _NT_NET_SET_PKT_L3_FRAME_TYPE_EXT7(_hNetBuf_, _type_); \ 1156 else assert(0); } while(0) 1157 1158/** @def NT_NET_SET_PKT_L4_FRAME_TYPE 1159 * @brief Sets the L4 frame type, see @ref NtL4FrameType_e 1160 * @param[in] "_hNetBuf_" Packet container reference 1161 * @param[in] "_type_" The L4 frame type 1162 * @hideinitializer 1163 */ 1164#define NT_NET_SET_PKT_L4_FRAME_TYPE(_hNetBuf_, _type_) \ 1165 do { if(_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 1166 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 1167 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) \ 1168 _NT_NET_SET_PKT_L4_FRAME_TYPE_EXT7(_hNetBuf_, _type_); \ 1169 else assert(0); } while(0) 1170 1171/** @def NT_NET_SET_PKT_L3_LENGTH 1172 * @brief L3 length in 32-bit units 1173 * @param[in] "_hNetBuf_" Packet container reference 1174 * @param[in] "_u32len_" The L3 length in 32-bit units 1175 * @hideinitializer 1176 */ 1177#define NT_NET_SET_PKT_L3_LENGTH(_hNetBuf_, _u32len_) \ 1178 do { if(_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 1179 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 1180 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) \ 1181 _NT_NET_SET_PKT_L3_LENGTH_EXT7(_hNetBuf_, _u32len_); \ 1182 else assert(0); } while(0) 1183 1184/** @def NT_NET_SET_PKT_L4_LENGTH 1185 * @brief L4 length in 32-bit units 1186 * @param[in] "_hNetBuf_" Packet container reference 1187 * @param[in] "_u32len_" The L4 length in 32-bit units 1188 * @hideinitializer 1189 */ 1190#define NT_NET_SET_PKT_L4_LENGTH(_hNetBuf_, _u32len_) \ 1191 do { if(_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 1192 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 1193 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) \ 1194 _NT_NET_SET_PKT_L4_LENGTH_EXT7(_hNetBuf_, _u32len_); \ 1195 else assert(0); } while(0) 1196 1197/** @def NT_NET_SET_PKT_CALC_L3_CHECKSUM 1198 * @brief If set, the adapter will calculate an IPv4 checksum on transmit 1199 * @param[in] "_hNetBuf_" Packet container reference 1200 * @param[in] "_bval_" Set to 1 calculate an IPv4 checksum on transmit, 0 otherwise 1201 * @hideinitializer 1202 */ 1203#define NT_NET_SET_PKT_CALC_L3_CHECKSUM(_hNetBuf_, _bval_) \ 1204 do { if(_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 1205 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 1206 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) \ 1207 _NT_NET_SET_PKT_CALC_L3_CHECKSUM_EXT7(_hNetBuf_, _bval_); \ 1208 else assert(0); } while(0) 1209 1210/** @def NT_NET_SET_PKT_CALC_L4_CHECKSUM 1211 * @brief If set, the adapter will calculate an TCP/UDP checksum on transmit 1212 * @param[in] "_hNetBuf_" Packet container reference 1213 * @param[in] "_bval_" Set to 1 calculate an TCP/UDP checksum on transmit, 0 otherwise 1214 * @hideinitializer 1215 */ 1216#define NT_NET_SET_PKT_CALC_L4_CHECKSUM(_hNetBuf_, _bval_) \ 1217 do { if(_NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==7 || \ 1218 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==8 || \ 1219 _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_)==9) \ 1220 _NT_NET_SET_PKT_CALC_L4_CHECKSUM_EXT7(_hNetBuf_, _bval_); \ 1221 else assert(0); } while(0) 1222 1223#if !defined(_NT_NTAPI_NO_COMPAT) 1224#define NT_NET_SET_PKT_L3_OFFSET(_hNetBuf_, _offset_) 1225#define NT_NET_SET_PKT_L4_OFFSET(_hNetBuf_, _offset_) 1226#endif 1227 1228/** @} */ 1229 1230#endif /* !defined(_NTAPI_EXTDESCR_7_) && !defined(_NTAPI_EXTDESCR_8_) && !defined(_NTAPI_EXTDESCR_9_) */ 1231 1232/** @} */ 1233/** @} */ 1234/** @} */ 1235 1236#endif /* __PKT_DESCR_H__ */