stream_net.h Source File

Reference Documentation

Platform
Intel® PAC
Napatech SmartNIC
Content Type
Reference Information
Capture Software Version
Link™ Capture Software 12.10
Napatech Software Suite: include/ntapi/stream_net.h Source File
stream_net.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (C) 2023 Napatech A/S.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Napatech A/S nor the
14  * names of its contributors may be used to endorse or promote products
15  * derived from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED. IN NO EVENT SHALL NAPATECH A/S BE LIABLE FOR ANY
21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  *
29 
30  */
31 
32 /**
33  * @file
34  *
35  * This is header file of the network stream interface
36  */
37 #ifndef __STREAM_NET_H__
38 #define __STREAM_NET_H__
39 
40 #if !defined(__NT_H__)
41  #error: My interface file is 'nt.h'. Please include that via #include "nt.h" directly.
42 #endif
43 
44 /** @addtogroup NetworkStream
45  *
46  * Network streams are used to receive and transmit data packets to
47  * and from the adapters. They are an extension build on top of the
48  * hardware-based host buffers.
49  * Three types of network streams exist:
50  * @li @ref StreamRx is used to receive data
51  * @li @ref StreamTx is used to transmit data
52  * @li @ref StreamFile is used to receive data to a file
53  *
54  * @note The streams are not thread safe so using the network stream API
55  * must be performed without concurrent access to the stream.
56  */
57 
58 /** @addtogroup StreamRx
59  * The RX network stream is used for both capture and in-line
60  * scenarios. The capture scenarios can deliver packets either
61  * packet-by-packet or as segments. The segment delivery is used for
62  * store to disk scenarios followed by offline analysis via the
63  * file-based network stream.
64  *
65  * @section PacketInterface Packet Interface
66  *
67  * The main interface is the packet interface. The packet interface is
68  * an interface for applications to do packet-by-packet
69  * processing. Please note that this approach will move some CPU load
70  * from the application to the driver compared to the segment
71  * interface. To open an RX network stream using the packet interface,
72  * call the @ref NT_NetRxOpen function with the interface type set to
73  * @ref NtNetInterface_e::NT_NET_INTERFACE_PACKET
74  * "NT_NET_INTERFACE_PACKET". To receive a packet, call @ref NT_NetRxGet
75  * and use the @ref PacketMacros "packet macros" to access the
76  * data. When finished with the packet, call @ref NT_NetRxRelease to release
77  * it again. When finished with the stream, call @ref NT_NetRxClose to close
78  * it.
79  *
80  * For an example on how to use the packet interface see @ref
81  * net/analysis/analysis_example.c "net/analysis/analysis_example.c".
82  *
83  * @section SegmentInterface Segment Interface
84  *
85  * The segment interface is only intended to be used for writing data
86  * to the disc and to do this the application will have to add a file
87  * header, provided by the system, to the beginning of the file. To read
88  * back data from the file, the application will have to use the
89  * @ref StreamFile to open the file and process the saved data packet
90  * by packet. To open an RX network stream using the segment interface,
91  * call the @ref NT_NetRxOpen function with the interface type set to
92  * @ref NtNetInterface_e::NT_NET_INTERFACE_SEGMENT
93  * "NT_NET_INTERFACE_SEGMENT". To receive a segment, call @ref NT_NetRxGet
94  * and use the @ref SegmentMacros "segment macros" to access the
95  * data. When finished with the segment, call @ref NT_NetRxRelease to release
96  * it again. When finished with the stream, call @ref NT_NetRxClose to
97  * close it.
98  *
99  * For an example on how to use the segment interface see @ref
100  * net/capture/capture_example.c "net/capture/capture_example.c".
101  *
102  * @section DataSharing Data Sharing
103  *
104  * Data sharing is a feature that will allow multiple applications to
105  * access the same shared host buffer.
106  *
107  * Data sharing is supported at the host buffer level. This allows
108  * multiple applications to access the same host buffer, at the
109  * same time, and individually decide if they want to use the packet
110  * interface or the segment interface. Data sharing is zero copy but
111  * will take up some extra CPU power to handle the synchronization of
112  * the host buffers. The service daemon is responsible for handling the
113  * host buffer exchange with the hardware and the data sharing is
114  * transparent to the application.
115  *
116  * In-line network streams cannot be shared and any attempt to open an
117  * existing in-line stream fails with an error return value.
118  *
119  * @note Be aware that the slowest application sets the speed. This
120  * means that a packet/segment will not be returned to the hardware
121  * before all applications that share the host buffer have
122  * processed it. To avoid this use @ref MainDocMainFeaturesTraffic_ReceiveHb_HostBufferAllowance
123  *
124  * @section DataMerging Data Merging
125  *
126  * Data merging is used for merging data packets received from
127  * multiple host buffers into one stream. This feature is used to merge
128  * data from multiple ports on multiple adapters, or multiple host buffers from one
129  * in-line adapter. The Napatech Software Suite supports
130  * merging of data from up to 42 host buffers, making it possible to
131  * merge data from 42 NT adapters. See the @ref NtplOverview "NTPL" for a
132  * description on how to configure data merging.
133  *
134  * @note Data merging is only possible for packet streams.
135  * @par
136  * @note Timesynchronisation is required when merging from different adapters (see @ref MainDocMainFeaturesVirtPort_AdapterMerge).
137  */
138 
139 /** @addtogroup StreamTx
140  * The TX network stream is used for transmitting data. Packets sent
141  * via this stream will be interleaved with traffic from in-line
142  * streams or other transmit streams.
143  *
144  * To open a TX network stream, call the @ref NT_NetTxOpen function. To
145  * get an empty packet, call the @ref NT_NetTxGet function with the
146  * desired length of the packet. The length includes the 4 bytes for
147  * the Ethernet CRC. Now fill data into the buffer and use the
148  * @ref TxMacros "TX Macros" for setting the desired time stamp, force CRC
149  * generation, etc. When finished with the packet, call @ref NT_NetTxRelease
150  * to release and transmit it. When finished with the stream, call @ref
151  * NT_NetTxClose to close it.
152  *
153  * For an example on how to use the packet interface, see @ref
154  * net/transmit_packet/transmit_packet_example.c "net/transmit/transmit_example.c".
155  *
156  * With NT3GA FPGAs Tx mode selection is an adapter global configuration - controlled by the actual FPGA image functionality and the profile ini-option.\n
157  * With NT4GA FPGAs the configuration granularity has changed - Tx mode selection can be set up/configured dynamically on individual streams.\n
158  * To facilitate this change - new options have been introduced into NTAPI (NT_NetTxOpen).
159  *
160  * Tx streams are normally "per port Tx mode" - meaning that one host buffer is allocated per (Tx) port set in the (Tx) portMask specfied to NT_NetTxOpen.
161  * Each allocated host buffer will be paired to a specific Tx port and the txPort field in the standard packet descriptor will have no meaning/effect.
162  *
163  * Adapter-based multi-port transmit buffer mode (named after its option/flag) will allocate one host buffer per adapter that has (Tx) ports set in the (Tx) portMask specified to NetTxOpen.
164  * Each host buffer allocated will be paired to a specific adapter - and that host buffer will be able to transmit on all the ports mentioned in the portMask on the adapter it is paired with.
165  * The Tx port will be selected by the txPort field in each packet descriptor.
166  *
167  * Adapter-based multi-port transmit buffer mode is selected by a new option (called flags) that is introduced to the attributes used by NTAPI function NT_NetTxOpen_Attr().
168  * The new NT_NETTX_OPEN_FLAGS_ADAPTER_MULTI_PORT_BUFFER flag/attribute is set up using NT_NetTxOpenAttrSetFlags().
169  *
170  * With NT4GA Test & Measurement FPGAs the following can be controlled per transmitted packet: timestamp injection, FCS calculation, Layer 3 checksum calculation and Layer 4 checksum calculation.
171  * See @ref test_and_measurement_4ga_introduction "4GA Test and Measurement features" for a detailed description.
172  */
173 
174 /** @addtogroup StreamFile
175  * The File network stream is used for packet-by-packet offline
176  * analysis of the packets captured with the segment RX interface. See
177  * @ref SegmentInterface "Segment interface" for a description of how
178  * to accomplish this.
179  *
180  * To open a file network stream, call the @ref NT_NetFileOpen with the
181  * name of the captured file as argument. To get the next packet from
182  * the file network stream, call the @ref NT_NetFileGet. Use the
183  * @ref PacketMacros "packet macros" to access the packet data. When
184  * finished with the packet, call @ref NT_NetFileRelease to release it
185  * again. When finished with the stream, call @ref NT_NetFileClose to close
186  * it.
187  *
188  * Supported files are native NT captured files, pcap and pcap-ng files.
189  * When using pcap or pcap-ng files, the received port information is always
190  * set to 0.
191  *
192  * For an example on how to use the file network stream interface, see
193  * @ref net/replay/replay_example.c "net/replay/replay_example.c".
194  *
195  */
196 
197 /**
198  * The network interface types.
199  * Used to select PACKET or NETWORK interface.
200  */
202  NT_NET_INTERFACE_UNKNOWN=0, //!< Unknown interface
203  NT_NET_INTERFACE_PACKET, //!< Packet interface
204  NT_NET_INTERFACE_SEGMENT //!< Segment interface
205 };
206 
207 
208 #ifndef DOXYGEN_INTERNAL_ONLY
209 /**
210  * Internal structures used in @ref NtNetBuf_s
211  */
212 typedef struct NtNetBufData_s* NtNetBufData_t; //!< Confidential data
213 typedef struct NtNetBufPkt_s* NtNetBufPkt_t; //!< Packet data
214 typedef struct NtNetBufHdr_s* NtNetBufHdr_t; //!< Header data
215 #endif
216 
217 
218 /**
219  * This structure is used by the @ref NetworkStream Get/Release functions and provides a handle to the returned data.
220  * The layout of the structure is confidential and must only be accessed via @ref DataMacros.
221  * The layout of the structure might change between major releases of NTAPI.
222  */
223 typedef struct NtNetBuf_s {
224 #ifndef DOXYGEN_INTERNAL_ONLY
225  int version; //!< The version of the NetworkData header
226  NtNetBufData_t hData; //!< A handle to confidential data
227  NtNetBufPkt_t hPkt; //!< A handle to packet data
228  NtNetBufHdr_t hHdr; //!< A handle to header data
229  uint64_t length; //!< Data field length
230  enum NtNetInterface_e netIf; //!< The network interface
231  enum NtTimestampType_e tsType; //!< The time stamp type
232 #endif
233  uint8_t portOffset; //!< The port offset - used to identify logical ports
234 #ifndef DOXYGEN_INTERNAL_ONLY
235  uint8_t Reserved1[3];
236  uint8_t adapterNo; //!< The adapter from which the data originated
237  uint8_t Reserved2[3];
238  int8_t egressPort; //!< The destination port (in-line)
239  uint8_t Reserved3[3];
240  uint8_t* colorMap; //!< The filter color map table
241 #define _FEED2STREAM_SHL_ 4
242  int* streamInfo; //!< A pointer to indexed stream IDs - used by macros
243  uint32_t pkts;
244 #endif
245  uintptr_t arg0; //!< User specific meta data container 0
246  uintptr_t arg1; //!< User specific meta data container 1
247  uintptr_t arg2; //!< User specific meta data container 2
248 } *NtNetBuf_t;
249 
250 /** @addtogroup StreamRx
251  *@{
252  */
253 
254 /**
255  * Possible NetRx stream commands
256  */
258  NT_NETRX_READ_CMD_UNKNOWN=0, //!< Unknown read command
259  NT_NETRX_READ_CMD_GET_FILE_HEADER, //!< Gets the file header for the stream
260  NT_NETRX_READ_CMD_STREAM_DROP, //!< Returns the drop counters for each stream - the counters increment when packets are dropped because of the host buffer allowance (hysteresis) being activated
261  NT_NETRX_READ_CMD_STREAM_TIME, //!< Returns the current stream time
262  NT_NETRX_READ_CMD_PCAP_FCS, //!< Returns whether packets with pcap descriptors include ethernet FCS
263  NT_NETRX_READ_CMD_GET_RING_CONTROL, //!< Return control of the host buffer ring of a stream Dangerous!! (Napatech internal use only - may change without further notice)
264  NT_NETRX_READ_CMD_GET_HB_INFO //!< Gets the info on the host buffers used by the stream
265 };
266 
267 /**
268  * TX stream descriptor modes.
269  * Used for configuring required variables for TX.
270  */
272  NT_NETTX_DESCRIPTOR_MODE_STD, //!< TX with standard descriptors
273  NT_NETTX_DESCRIPTOR_MODE_DYN1, //!< TX with DYN1 descriptors
274  NT_NETTX_DESCRIPTOR_MODE_DYN2, //!< TX with DYN2 descriptors
275  NT_NETTX_DESCRIPTOR_MODE_DYN3, //!< TX with DYN3 descriptors
276  NT_NETTX_DESCRIPTOR_MODE_DYN4, //!< TX with DYN4 descriptors
277 };
278 
279 /**
280  * File header return structure.
281  * Note: This header can only be read when all NTPL assignments have completed.
282  */
284  uint8_t data[128]; //!< The actual file header
285  int32_t size; //!< The size of the file header
286 };
287 
288 /**
289  * Stream drop counter return structure
290  */
292  uint64_t pktsDropped; //!< Packets dropped because the application is affected by the host buffer allowance (hysteresis)
293  uint64_t octetsDropped; //!< Bytes dropped because the application is affected by the host buffer allowance (hysteresis)
294 };
295 
296 /**
297  * Stream time
298  */
300  uint64_t ts; //!< Current stream time. Can be used when NT_NetRxGet() returns timeout to get the time of the stream.
301 };
302 
303 /**
304  * PCAP information
305  */
307  uint32_t fcs; //!< Returns non-zero if FCS is included in packets with PCAP descriptors.
308 };
309 
310 /**
311  * Expose buffer info to the user (Napatech internal use only - may change without further notice)
312  */
314  volatile uint64_t* pRead;
315  volatile uint64_t* pWrite;
316  uint8_t* ring;
317  uint64_t size;
318  uint64_t mask;
319 };
320 
321 /**
322  * RX Host buffer info
323  */
325  uint32_t numAddedHostBuffers; //!< The number of host buffers added by the driver
326  uint32_t numAssignedHostBuffers; //!< The number of host buffers assigned and also the depth of the array
327  struct NtNetRxHb_s {
328  uint64_t timestamp; //!< The current host buffer time
329  size_t size; //!< The size of the host buffer (4GA only)
330  size_t available; //!< Amount of the host buffer available to the adapter (4GA only)
331  size_t dequeued; //!< Reserved for future use
332  size_t pending; //!< Amount of the host buffer pending for the application to read (4GA only)
333  size_t inlinePending; //!< Reserved for future use
334  enum NtNetHostBufferLayout_e layout; //!< The host buffer layout
335  int index; //!< The host buffer index. Unique throughout the system
336  } aHostBuffer[128];
337 };
338 
339 /**
340  * NetRx structure. Network RX data is read via this structure via @ref NT_NetRxRead().
341  */
342 typedef struct NtNetRx_s {
343  enum NtNetRxCmd_e cmd; //!< The read command - specified what to read from NetRx
344  /**
345  * Union of all possible return structures from NetRxRead()
346  */
347  union NtNetRx_u {
348  struct NtNetRxFileHeader_s fileheader; //!< The structure to use for @ref NtNetRx_s::cmd==NT_NETRX_READ_CMD_GET_FILE_HEADER
349  struct NtNetRxStreamDrop_s streamDrop; //!< The structure to use for @ref NtNetRx_s::cmd==NT_NETRX_READ_CMD_STREAM_DROP
350  struct NtNetRxStreamTime_s streamTime; //!< The structure to use for @ref NtNetRx_s::cmd==NT_NETRX_READ_CMD_STREAM_TIME
351  struct NtNetRxPcapInfo_s pcap; //!< The structure to use for @ref NtNetRx_s::cmd==NT_NETRX_READ_CMD_PCAP_INFO
352  struct NtNetRxHbRing_s ringControl; //!< The structure to use for @ref NtNetRx_s::cmd==NT_NETRX_READ_CMD_GET_RING_CONTROL
353  struct NtNetRxHbInfo_s hbInfo; //!< The structure to use for @ref NtNetRx_s::cmd==NT_NETRX_READ_CMD_GET_HB_INFO
354  } u ;
355 } NtNetRx_t;
356 
357 /**
358  * Possible NetTx stream commands
359  */
361  NT_NETTX_READ_CMD_UNKNOWN=0, //!< Unknown read command
362  NT_NETTX_READ_CMD_GET_HB_INFO, //!< Gets the info on the host buffers used by the stream
363  NT_NETTX_READ_CMD_GET_RING_CONTROL, //!< Get the control of the host buffer ring. Dangerous!! (Napatech internal use only - may change without further notice)
364 };
365 
366 /**
367  * TX Host buffer info
368  */
370  unsigned int numHostBuffers; //!< The number of host buffers used by the stream and also the depth of the array
371  struct NtNetTxHb_s {
372  size_t size; //!< The size of the host buffer
373  size_t available; //!< Amount of the host buffer available to the application
374  size_t dequeued; //!< Amount of the host buffer dequeued by the application
375  size_t released; //!< Amount of the host buffer released waiting to be transmitted
376  enum NtNetHostBufferLayout_e layout; //!< The host buffer layout
377  int index; //!< The host buffer index. Unique throughout the system.
378  uint64_t portMask; //!< The port-mask the host buffer can utilize
379  } aHostBuffer[128];
380 };
381 
382 /**
383  * Expose host buffer info (Napatech internal use only - may change without further notice)
384  */
386  volatile uint64_t* pRead;
387  volatile uint64_t* pWrite;
388  uint8_t* ring;
389  uint64_t size;
390  uint16_t minTxPktSize; //!< The min transmit packet size of this port
391  uint16_t maxTxPktSize; //!< The max transmit packet size of this port
392  uint8_t port; //!< The port this ring is attached to
393  //TODO: Maybe expose what descriptors can be used?
394 };
395 
396 /**
397  * NetTx structure. Network TX data is read via this structure via @ref NT_NetTxRead().
398  */
399 typedef struct NtNetTx_s {
400  enum NtNetTxCmd_e cmd; //!< The read command - specified what to read from NetTx
401  /**
402  * Union of all possible return structures from NetTxRead()
403  */
404  union NtNetTx_u {
405  struct NtNetTxHbInfo_s hbInfo; //!< Information about the host buffers used
406  struct NtNetTxHbRing_s ringControl; //!< Control of the host buffer ring (Napatech internal use only - may change without further notice)
407  } u ;
408 } NtNetTx_t;
409 
410 
411 /**
412  * NtNetTxFragment structure. A TX packet may be scattered in a list of fragments,
413  * which is put together and added to the TX hostbuffer via @ref NT_NetTxAddPacket().
414  */
415 typedef struct NtNetTxFragment_s
416 {
417  uint8_t* data;
418  uint16_t size;
420 
421 /**
422  * Possible NetFileRead commands
423  */
425  NT_NETFILE_READ_INFO_UNKNOWN_CMD=0, //!< Unknown read command
426  NT_NETFILE_READ_COMPAT_0, //!< Read information about the NetFile stream
427  NT_NETFILE_READ_FILETYPE_CMD, //!< Read information about the opened file type
428  NT_NETFILE_READ_DESCRIPTOR_CMD, //!< Read information about the descriptor and timestamp format used
429  NT_NETFILE_READ_INFO_CMD_V1, //!< Read information about the NetFile stream
430 };
431 
432 /**
433  * NetFile stream Info return structure
434  */
435 
436 typedef struct NtNetFileReadInfo_v1_s {
437  uint64_t lastTimestamp; //!< The time stamp in the last packet in last segment read using the function @ref NT_NetFileGet
438  uint64_t numberOfOctets; //!< Number of octets read from Netfile so far
439  uint32_t numberOfPackets; //!< Number of packets read from Netfile so far
440  uint64_t firstTimestamp; //!< The time stamp in the first packet in first segment read using the function @ref NT_NetFileGet
442 
443 typedef enum {
444  NT_NETFILE_TYPE_UNKNOWN, //!< The opened file is a unknown
445  NT_NETFILE_TYPE_NT, //!< The opened file is a Napatech capture file
446  NT_NETFILE_TYPE_PCAP, //!< The opened file is a PCAP capture file
447  NT_NETFILE_TYPE_PCAP_NG, //!< The opened file is a PCAP NG capture file
449 
450 typedef struct NtNetFileReadDesc_s
451 {
452  enum NtTimestampType_e tsType; //!< Timestamp format used in packet data
453  enum NtPacketDescriptorType_e desc; //!< Descriptor used in packet data
455 
456 /* Include commands for backward compatibility */
457 #if !defined(_NT_NTAPI_NO_COMPAT)
458 #include "stream_net_compat.h"
459 #endif
460 
461 /**
462  * NetFileRead stream structure - network File data is read via this structure via @ref NT_NetFileRead()
463  */
464 typedef struct NtNetFileRead_s {
465  enum NtNetFileReadCmd_e cmd; //!< The read command - specified what to read from NetFile
466  /**
467  * Union of all possible return structures from NT_NetFileRead()
468  */
470  struct NtNetFileReadInfo_v1_s info_v1; //!< Information about the NetFile. Used by NT_NETFILE_READ_INFO_CMD
471  struct NtNetFileReadDesc_s desc; //!< Information about the descriptor and timestamp format used. Used by NT_NETFILE_READ_DESCRIPTOR_CMD
472  NtNetFileType_e fileType; //!< Information about the type of the opened file
473 #if !defined(_NT_NTAPI_NO_COMPAT)
474  /* Commands for backward compatibility */
475  struct NtNetFileReadInfo_s info; //!< Information about the NetFile. Used by NT_NETFILE_READ_INFO_CMD
476 #endif
477  } u ;
479 
480 /**
481  * The Network RX stream handle - used for both in-line and capture streams
482  */
483 typedef struct NtNetStreamRx_s* NtNetStreamRx_t;
484 
485 /**
486  * Parameter structure for NT_NetRxOpen_Attr/NT_NetRxOpen_v3/NT_NetRxOpenMulti_v3.
487  * Use NT_NetRxOpenAttrInit() and NT_NetRxOpenAttrSet*() functions to define content.
488  */
489 #define __SIZEOF_NT_NETRX_ATTR (128)
492  long int __align;
493 };
495 
496 /**
497  * Parameter structure for NT_NetTxOpen_Attr/NT_NetTxOpen_v3/NT_NetTxOpenMulti_v3.
498  * Use NT_NetTxOpenAttrInit() and NT_NetTxOpenAttrSet*() functions to define content.
499  */
500 #define __SIZEOF_NT_NETTX_ATTR (128)
503  long int __align;
504 };
506 
507 /**
508  * Parameter structure for NT_NetFileOpen_Attr.
509  * Use NT_NetFileOpenAttrInit() and NT_NetFileOpenAttrSet*()
510  * functions to define content.
511  */
512 #define __SIZEOF_NT_NETFILE_ATTR (128)
515  long int __align;
516 };
518 
519 /**
520  * Flags for NT_NetRxOpen_v2+/NT_NetRxOpenMulti_v2+
521  *
522  * Obsolete: please use enum NtNetRxOpenFlags_e below
523  */
524 #define NT_NETRX_NONE (0)
525 #define NT_NETRX_READONLY_STREAM (1LL<<0)
526 
527 /**
528  *
529  */
533 };
534 
535 /**
536  * @brief Opens in-line or capture host buffer(s) and returns a NtNetStreamRx_t handle
537  *
538  * This function is called to retrieve a handle to an in-line or capture network stream.
539  *
540  * In-line network streams cannot be shared and any attempt to open an existing in-line stream fails with an error return value.
541  *
542  * @note It is important to start calling NT_NetRxGet() and NT_NetRxRelease() soon
543  * after this call to avoid packet drop. Host buffers are assigned/released to the streamid within
544  * NT_NetRxGet() and NT_NetRxRelease().
545  *
546  * @param[out] hStream Reference to a NtNetStreamRx_t stream pointer
547  * @param[in] name Stream friendly name - used in, for example, logging statements
548  * @param[in] netIntf Interface type - segment or packet
549  * @param[in] streamId The network stream ID to open - can be opened a number of times which will cause sharing of the host buffers in the streamId
550  * @param[in] hostBufferAllowance Drop level for the host buffer allowance (hysteresis), -1 means disabled
551  *
552  * @retval NT_SUCCESS Success
553  * @retval !=NT_SUCCESS Error - use @ref NT_ExplainError for an error description
554  */
555 int NT_NetRxOpen(NtNetStreamRx_t* hStream, const char* name, enum NtNetInterface_e netIntf, uint32_t streamId, int hostBufferAllowance);
556 
557 /**
558  * @brief Opens in-line or capture host buffer(s) and returns a NtNetStreamRx_t handle
559  *
560  * This function is called to retrieve a handle to an in-line or capture network stream with flags.
561  *
562  * In-line network streams cannot be shared and any attempt to open an existing in-line stream fails with an error return value.
563  *
564  * @note It is important to start calling NT_NetRxGet() and NT_NetRxRelease() soon
565  * after this call to avoid packet drop. Host buffers are assigned/released to the streamid within
566  * NT_NetRxGet() and NT_NetRxRelease().
567  *
568  * The flags shall be either NT_NETRX_OPEN_FLAGS_NONE or the bitwise-inclusive OR of one or more of the other
569  * flags in the following table:
570  *
571  * Flag | Description
572  * ------------------------------------|-------------
573  * NT_NETRX_OPEN_FLAGS_NONE | No flags set, equivalent to passing '0' as flag.
574  * NT_NETRX_OPEN_FLAGS_READONLY_STREAM | Using this option will cause a write to data returned by NT_NetRxGet to fail with a segmentation fault.
575  *
576  * @param[out] hStream Reference to a NtNetStreamRx_t stream pointer
577  * @param[in] name Stream friendly name - used in, for example, logging statements
578  * @param[in] netIntf Interface type - segment or packet
579  * @param[in] streamId The network stream ID to open - can be opened a number of times which will cause sharing of the host buffers in the streamId
580  * @param[in] hostBufferAllowance Drop level for the host buffer allowance (hysteresis), -1 means disabled
581  * @param[in] flags Flags for the stream OR'd together, or zero for no flags.
582  *
583  * @retval NT_SUCCESS Success
584  * @retval !=NT_SUCCESS Error - use @ref NT_ExplainError for an error description
585  */
586 int NT_NetRxOpen_v2(NtNetStreamRx_t* hStream, const char* name, enum NtNetInterface_e netIntf, uint32_t streamId, int hostBufferAllowance, int flags);
587 
588 /**
589  * @brief Initialize RX stream attributes
590  *
591  * The attributes are initialized to the following default values: \n
592  * name = NULL \n
593  * netIntf = NT_NET_INTERFACE_UNKNOWN \n
594  * hostBufferAllowance = -1 \n
595  * flags = NT_NETRX_OPEN_FLAGS_NONE \n
596  *
597  * @param[out] attr Pointer to the attributes structure
598  */
600 
601 /**
602  * @brief Sets the stream name attribute
603  *
604  * @param[in] attr Pointer to the attributes structure
605  * @param[in] name Stream friendly name - used in, for example, logging statements
606  */
607 void NT_NetRxOpenAttrSetName(NtNetRxAttr_t* attr, const char* name);
608 
609 /**
610  * @brief Returns the name attribute
611  * @return The name attribute
612  */
613 const char* NT_NetRxOpenAttrGetName(const NtNetRxAttr_t* attr);
614 
615 /**
616  * @brief Sets the interface type attribute
617  *
618  * @param[in] attr Pointer to the attributes structure
619  * @param[in] netIntf Interface type - segment or packet
620  */
622 
623 /**
624  * @brief Returns the interface type attribute
625  * @return The interface type attribute
626  */
628 
629 /**
630  * @brief Sets the host buffer allowance attribute
631  *
632  * @param[in] attr Pointer to the attributes structure
633  * @param[in] hostBufferAllowance Drop level for the host buffer allowance (hysteresis), -1 means disabled
634  */
635 void NT_NetRxOpenAttrSetHostBufferAllowance(NtNetRxAttr_t* attr, int hostBufferAllowance);
636 
637 /**
638  * @brief Returns the buffer allowance attribute
639  * @return The buffer allowance attribute
640  */
642 
643 /**
644  * @brief Sets the flags attribute
645  *
646  * The flags shall be either NT_NETRX_NONE or the bitwise-inclusive OR of one or more of the other
647  * flags in the following table - see enum ::NtNetRxOpenFlags_e
648  *
649  * Flag | Description
650  * -------------------------|-------------
651  * NT_NETRX_NONE | No flags set, equivalent to passing '0' as flag.
652  * NT_NETRX_READONLY_STREAM | Using this option will cause a write to data returned by NT_NetRxGet to fail with a segmentation fault.
653  *
654  * @param[in] attr Pointer to the attributes structure
655  * @param[in] flags Drop level for the host buffer allowance (hysteresis), -1 means disabled
656  */
657 void NT_NetRxOpenAttrSetFlags(NtNetRxAttr_t* attr, int flags);
658 
659 /**
660  * @brief Returns the flags attribute
661  * @return The flags attribute - see enum ::NtNetRxOpenFlags_e
662  */
663 int NT_NetRxOpenAttrGetFlags(const NtNetRxAttr_t* attr);
664 
665 /**
666  * @brief Opens in-line or capture host buffer(s) and returns a NtNetStreamRx_t handle
667  *
668  * This function is called to retrieve a handle to an in-line or capture network stream with flags.
669  * @note It is important to start calling NT_NetRxGet() and NT_NetRxRelease() soon
670  * after this call to avoid packet drop. Host buffers are assigned/released to the streamid within
671  * NT_NetRxGet() and NT_NetRxRelease().
672  *
673  * @param[out] hStream Reference to a NtNetStreamRx_t stream pointer
674  * @param[in] streamId The network stream ID to open - can be opened a number of times which will cause sharing of the host buffers in the streamId
675  * @param[in] attr Attributes of the stream
676  *
677  * @retval NT_SUCCESS Success
678  * @retval !=NT_SUCCESS Error - use @ref NT_ExplainError for an error description
679  */
680 int NT_NetRxOpen_Attr(NtNetStreamRx_t* hStream, uint32_t streamId, const NtNetRxAttr_t* attr);
681 
682 /**
683  * @brief Opens in-line or capture host buffer(s) and returns a NtNetStreamRx_t handle
684  *
685  * This function is called to retrieve a handle to an in-line or capture network streams. If
686  * multiple stream-ids are opened the data from them will be time stamp merged. Note multiple
687  * stream-ids can only be used with the packet interface.
688  * @note It is important to start calling NT_NetRxGet() and NT_NetRxRelease() soon
689  * after this call to avoid packet drop. Host buffers are assigned/released to the streamid within
690  * NT_NetRxGet() and NT_NetRxRelease().
691  *
692  * @param[out] hStream Reference to a NtNetStreamRx_t stream pointer
693  * @param[in] name Stream friendly name - used in, for example, logging statements
694  * @param[in] netIntf Interface type - Can only be packet if multiple are opened
695  * @param[in] paStreamId Array containing the network stream IDs to open. A maximum of 8 streams can be specified.
696  * @param[in] numStreamIds The number of stream-ids in the paStreamId array
697  * @param[in] hostBufferAllowance Drop level for the host buffer allowance (hysteresis), -1 means disabled
698  *
699  * @retval NT_SUCCESS Success
700  * @retval !=NT_SUCCESS Error - use @ref NT_ExplainError for an error description
701  */
702 int NT_NetRxOpenMulti(NtNetStreamRx_t* hStream, const char* name, enum NtNetInterface_e netIntf, uint32_t* paStreamId, unsigned int numStreamIds, int hostBufferAllowance);
703 
704 /**
705  * @brief Opens in-line or capture host buffer(s) and returns a NtNetStreamRx_t handle
706  *
707  * This function is called to retrieve a handle to an in-line or capture network streams with flags.
708  * If multiple stream-ids are opened the data from them will be time stamp merged. Note multiple
709  * stream-ids can only be used with the packet interface.
710  * @note It is important to start calling NT_NetRxGet() and NT_NetRxRelease() soon
711  * after this call to avoid packet drop. Host buffers are assigned/released to the streamid within
712  * NT_NetRxGet() and NT_NetRxRelease().
713  *
714  * The flags shall be either NT_NETRX_NONE or the bitwise-inclusive OR of one or more of the other
715  * flags in the following table (see enum ::NtNetRxOpenFlags_e):
716  *
717  * Flag | Description
718  * -------------------------|-------------
719  * NT_NETRX_NONE | No flags set, equivalent to passing '0' as flag.
720  * NT_NETRX_READONLY_STREAM | Using this option will cause a write to data returned by NT_NetRxGet to fail with a segmentation fault.
721  *
722  * @param[out] hStream Reference to a NtNetStreamRx_t stream pointer
723  * @param[in] name Stream friendly name - used in, for example, logging statements
724  * @param[in] netIntf Interface type - Can only be packet if multiple are opened
725  * @param[in] paStreamId Array containing the network stream IDs to open. A maximum of 8 streams can be specified.
726  * @param[in] numStreamIds The number of stream-ids in the paStreamId array
727  * @param[in] hostBufferAllowance Drop level for the host buffer allowancei (hysteresis), -1 means disabled
728  * @param[in] flags Flags for the stream OR'd together, or zero for no flags.
729  *
730  * @retval NT_SUCCESS Success
731  * @retval !=NT_SUCCESS Error - use @ref NT_ExplainError for an error description
732  */
733 int NT_NetRxOpenMulti_v2(NtNetStreamRx_t* hStream, const char* name, enum NtNetInterface_e netIntf, uint32_t* paStreamId, unsigned int numStreamIds, int hostBufferAllowance, int flags);
734 
735 /**
736  * @brief Opens in-line or capture host buffer(s) and returns a NtNetStreamRx_t handle
737  *
738  * This function is called to retrieve a handle to an in-line or capture network streams with flags.
739  * If multiple stream-ids are opened the data from them will be time stamp merged. Note multiple
740  * stream-ids can only be used with the packet interface.
741  * @note It is important to start calling NT_NetRxGet() and NT_NetRxRelease() soon
742  * after this call to avoid packet drop. Host buffers are assigned/released to the streamid within
743  * NT_NetRxGet() and NT_NetRxRelease().
744  *
745  * @param[out] hStream Reference to a NtNetStreamRx_t stream pointer
746  * @param[in] paStreamId Array containing the network stream IDs to open. A maximum of 8 streams can be specified.
747  * @param[in] numStreamIds The number of stream-ids in the paStreamId array
748  * @param[in] attr Attributes of the stream(s)
749  *
750  * @retval NT_SUCCESS Success
751  * @retval !=NT_SUCCESS Error - use @ref NT_ExplainError for an error description
752  */
753 int NT_NetRxOpenMulti_Attr(NtNetStreamRx_t* hStream, uint32_t* paStreamId, unsigned int numStreamIds, const NtNetRxAttr_t* attr);
754 
755 /**
756  * @brief Gets data from an in-line or capture stream
757  *
758  * This function is called to retrieve packets/segments from a in-line or capture stream.
759  *
760  * The calling process is suspended when no data is immediately available.
761  * The suspension is done in one of two ways, depending on the system clock resolution:
762 
763  * 1) If the system clock resolution is <= 1 uSec, sleep calls are used. The timeout value
764  * is divided into sleep intervals (with intervals approximating the segment timeout on the adapter).
765  * It then periodically polls for data.
766 
767  * 2) using events. If the system cannot do uSec sleeps, then the suspension mechanism used is event
768  * based. It puts the calling process to sleep waiting for an event. On data receival an event is sent
769  * and the process is woken up.
770  *
771  * @param[in] hStream Network RX stream handle
772  * @param[out] netBuf Segment/packet container reference, is set to NULL if return value is not NT_SUCCESS
773  * @param[in] timeout The timeout in milliseconds. The call will return when any data is available, or when the timeout is reached.
774  * A timeout of -1 will wait indefinitely if using the packet mode. In segment mode the waiting is always capped
775  * to the next HostBufferPollInterval (ntservice.ini), which is 100 usecs by default, at which point an empty
776  * segment is returned, if no data arrived. So in segment mode, any timeout larger than HostBufferPollInterval
777  * (including -1) has no effect.
778  *
779  * @note This function has no mutex protection, therefore the same hStream cannot be used by multiple threads
780  * @note When the segment interface is used this function can return empty segments only containing a time stamp update, hence if NT_NET_GET_SEGMENT_LENGTH() return 0 only NT_NET_GET_SEGMENT_TIMESTAMP() can be used.
781  * The time stamp update will make it possible for users to merge packets in segments from different stream ids.
782  *
783  * @retval NT_SUCCESS Data has been returned and must be released again via NT_NetRxRelease()
784  * @retval NT_STATUS_TIMEOUT No data has been returned and a timeout has occured
785  * @retval NT_STATUS_TRYAGAIN The resource is temporarily unavailable because of reconfiguration - call NT_NetRxGet() again
786  * @retval Error Use @ref NT_ExplainError for an error description
787  */
788 int NT_NetRxGet(NtNetStreamRx_t hStream, NtNetBuf_t* netBuf, int timeout);
789 
790 /**
791  * @brief Gets data from an in-line or capture stream
792  *
793  * This function is called to retrieve packets from a in-line or capture stream. The function will
794  * automatically release the previous packet when called, hence it is not possible to keep packets and if necessary
795  * the packets must be copied to a safe buffer before calling the function to get the next packet.
796  *
797  * @param[in] hStream Network RX stream handle
798  * @param[out] netBuf Segment/packet container reference, is set to NULL if return value is not NT_SUCCESS
799  * @param[in] timeout The timeout in milliseconds. The call will return when this timeout is reached unless data is available. A timeout of -1 will wait indefinitely for a new buffer.
800  *
801  * @note This function has no mutex protection, therefore the same hStream cannot be used by multiple threads
802  *
803  * @retval NT_SUCCESS Data has been returned and will be valid until the next @ref NT_NetRxGetNextPacket() call
804  * @retval NT_STATUS_TIMEOUT No data has been returned and a timeout has occured
805  * @retval NT_STATUS_TRYAGAIN The resource is temporarily unavailable because of reconfiguration - call NT_NetRxGetNextPacket() again
806  * @retval Error Use @ref NT_ExplainError for an error description
807  */
808 int NT_NetRxGetNextPacket(NtNetStreamRx_t hStream, NtNetBuf_t* netBuf, int timeout);
809 
810 /**
811  * @brief Reads data from the stream
812  *
813  * This function will read on-line generated data from the stream, for example, a file header
814  *
815  * @param[in] hStream NetRx stream handle
816  * @param[in] cmd NetRx read structure
817  *
818  * @retval NT_SUCCESS Success
819  * @retval !=NT_SUCCESS Error - use @ref NT_ExplainError for an error description
820  */
821 int NT_NetRxRead(NtNetStreamRx_t hStream, NtNetRx_t* cmd);
822 
823 
824 /**
825  * @brief Releases network buffer
826  *
827  * This function will release the netBuf data obtained via NT_NetRxGet(). The data within
828  * netBuf will on an in-line profile be sent to the adapter upon release even in the case where
829  * the NTPL assignment has been terminated.
830  *
831  * @note This function has no mutex protection, therefore the same hStream cannot be used by multiple threads
832  *
833  * @param[in] hStream NetRx stream handle
834  * @param[in] netBuf Net buffer received via NT_NetRxGet()
835  *
836  * @retval NT_SUCCESS Success
837  * @retval !=NT_SUCCESS Error - use @ref NT_ExplainError for an error description
838  */
839 int NT_NetRxRelease(NtNetStreamRx_t hStream, NtNetBuf_t netBuf);
840 
841 /**
842  * @brief Closes an in-line or capture stream
843  *
844  * This function is called to close an in-line or capture stream
845  *
846  * @param[in] hStream In-line or capture stream handle to close
847  *
848  * @retval NT_SUCCESS Success
849  * @retval !=NT_SUCCESS Error - use @ref NT_ExplainError for an error description
850  */
851 int NT_NetRxClose(NtNetStreamRx_t hStream);
852 
853 /** @} */
854 
855 
856 /** @addtogroup StreamTx
857  *@{
858  */
859 /**
860  * Network TX stream handle - used for TX streams
861  */
862 typedef struct NtNetStreamTx_s* NtNetStreamTx_t;
863 
864 /**
865  * Network TX packet options
866  */
868  NT_NETTX_PACKET_OPTION_UNKNOWN=0, //!< Unknown option
869  NT_NETTX_PACKET_OPTION_DEFAULT, //!< Gets a TX buffer with a pre-configured packet descriptor. Use this option to transmit L2 data. This option uses packetSize as wire length.
871  NT_NETTX_PACKET_OPTION_RAW, //!< Gets a raw TX packet buffer without packet descriptor. Care needs to be taken when using this option. Use this option in replay scenarios where packets already have a correct descriptor, e.g. data recorded using @ref StreamFile. Uses packetSize as the stored length. With this option packetSize must be a multiple of 8 (NT3GA only).
872  NT_NETTX_SEGMENT_OPTION_RAW, //!< Gets a raw TX segment buffer. Care needs to be taken when using this option. Use this option in replay scenarios where the segment length is known prior to calling @ref NT_NetTxGet. Use packetSize as the segment length. The port parameter in @ref NT_NetTxGet is used to control that the segment returned belongs to the adapter on which the port resides. It is required that the txPort in the packet descriptors within the segment are set before releasing the segment. If the host buffer layout is NT_NET_HOSTBUFFER_LAYOUT_SLABS, the slabs are automatically terminated when this option is used.
873  NT_NETTX_PACKET_OPTION_DYN, //!< Gets a TX buffer with a pre-configured dynamic packet descriptor. Use this option to transmit L2 data. This option uses packetSize as wire length. Set DescriptorMode before using this option.
874 };
875 
876 /**
877  * Network TX NUMA HB options for NUMA-parameter in NT_NetTxOpen()
878  */
880  NT_NETTX_NUMA_ANY_HB=0xFFFFFFFE, //!< (=-2) Allocate TX host buffer from any TX host buffer pool
881  NT_NETTX_NUMA_ADAPTER_HB=0xFFFFFFFF, //!< (=-1) Allocate TX host buffer from TX-host buffer pool on that NUMA node where the adapter of the TX-port is located
882 };
883 
884 /**
885  * Flags for NT_NetTxOpen_Attr()
886  */
888  NT_NETTX_OPEN_NONE=0, //!< No NtNetTxOpen flags (Obsolete)
889  NT_NETTX_OPEN_FLAGS_NONE=0, //!< No NtNetTxOpen flags
890  NT_NETTX_OPEN_FLAGS_ADAPTER_MULTI_PORT_BUFFER=(1LL<<0), //!< Allocate one TX host buffer per adapter that has ports set in NT_NetTXOpen portmask - if unset allocate one TX host buffer per port that is set in NT_NetTXOpen portmask
891 };
892 
893 /**
894  * @brief Opens a TX host buffer and returns a NtNetStreamTx_t handle
895  *
896  * This function, which is superseded by NT_NetTxOpen_v3(), is called
897  * to retrieve a TX stream handle.
898  *
899  * Note that the TX stream on capture-only adapters (NT4E Capture, NT4E_STD Capture and NT20E Capture)
900  * will have very limited transmit capabilities. They will not be able to transmit at line rate
901  * and their transmit sizes and statistics will also be limited. Packets larger than 2000 bytes
902  * will sliced to the size of 2000 bytes.
903  *
904  * @param[out] hStream Reference to a NtNetStreamTx_t stream pointer
905  * @param[in] name Stream friendly name - used in, for example, logging statements
906  * @param[in] portMask Bitmask for ports this stream will use for transmitting
907  * @param[in] NUMA NUMA node on which the host buffer is be located (NOTE: Special options in NtNetTxOpenNumaOption_e)
908  * @param[in] minHostBufferSize Minimum size of host buffer needed in <em>MBytes</em>. The
909  * smallest host buffer found that is larger or equal to minHostBufferSize
910  * is used and the size of the host buffer is set to minHostBufferSize. If
911  * set to 0, the first host buffer found is used regardsless of the size.
912  *
913  * @retval NT_SUCCESS Success
914  * @retval !=NT_SUCCESS Error - use @ref NT_ExplainError for an error description
915  */
916 int NT_NetTxOpen(NtNetStreamTx_t* hStream, const char* name, uint64_t portMask, uint32_t NUMA, uint32_t minHostBufferSize);
917 
918 /**
919  * @brief Opens a TX host buffer and returns a NtNetStreamTx_t handle (extended version)
920  *
921  * This function, which is superseded by NT_NetTxOpen_v3(), is similar
922  * to the NT_NetTxOpen() function. The main difference is that it has
923  * two additional parameters, the descriptor type and the timestamp
924  * format.
925  *
926  * This function will only work with 4GA adapters.
927  *
928  * @param[out] hStream Reference to a NtNetStreamTx_t stream pointer
929  * @param[in] name Stream friendly name - used in, for example, logging statements
930  * @param[in] portMask Bitmask for ports this stream will use for transmitting
931  * @param[in] NUMA NUMA node on which the host buffer is be located (NOTE: Special options in NtNetTxOpenNumaOption_e)
932  * @param[in] minHostBufferSize Minimum size of host buffer needed in <em>MBytes</em>. The smallest host
933  * buffer found that is larger or equal to minHostBufferSize is used and the
934  * size of the host buffer is set to minHostBufferSize. If set to 0, the
935  * first host buffer found is used regardsless of the size.
936  * @param[in] descriptor Descriptor type to use when transmitting.
937  * @param[in] ts Timestamp format to use when transmitting.
938  *
939  * @retval NT_SUCCESS Success
940  * @retval !=NT_SUCCESS Error - use @ref NT_ExplainError for an error description
941  */
942 int NT_NetTxOpen_v2(NtNetStreamTx_t* hStream, const char* name, uint64_t portMask, uint32_t NUMA, uint32_t minHostBufferSize, enum NtPacketDescriptorType_e descriptor, enum NtTimestampType_e ts);
943 
944 /**
945  * @brief Opens a TX host buffer and returns a NtNetStreamTx_t handle (extended version)
946  *
947  * This function is similar to the NT_NetTxOpen_v2() function. The
948  * main difference is that the minimum hostbuffer size is specified in
949  * bytes to support a hostbuffer size less than one megabyte.
950  *
951  * This function will only work with 4GA adapters.
952  *
953  * @param[out] hStream Reference to a NtNetStreamTx_t stream pointer
954  * @param[in] name Stream friendly name - used in, for example, logging statements
955  * @param[in] portMask Bitmask for ports this stream will use for transmitting
956  * @param[in] NUMA NUMA node on which the host buffer is be located (NOTE: Special options in NtNetTxOpenNumaOption_e)
957  * @param[in] minHostBufferSize Minimum size of host buffer needed in <em>bytes</em>. The smallest host
958  * buffer found that is larger or equal to minHostBufferSize is used and the
959  * size of the host buffer is set to minHostBufferSize. If set to 0, the
960  * first host buffer found is used regardsless of the size.
961  * @param[in] descriptor Descriptor type to use when transmitting.
962  * @param[in] ts Timestamp format to use when transmitting.
963  *
964  * @retval NT_SUCCESS Success
965  * @retval !=NT_SUCCESS Error - use @ref NT_ExplainError for an error description
966  *
967  * NOTE:
968  * When using NT_NetTxOpen() >= 3: ntservice ini-option System.NtapiNetTxSegmentRawAlignMode can be used to control NT_NetTxGet()/NT_NetTxRelease() behaviour for NT_NETTX_SEGMENT_OPTION_RAW mode.
969  * System.NtapiNetTxSegmentRawAlignMode = 1 will retain previous NTAPI default behaviour where RAW segment mode always operates on a whole (aligned) underlying slab (segment) typically (1,2,4 MB - dictated by FPGA)
970  * System.NtapiNetTxSegmentRawAlignMode = 0 will enable NT4GA to operate on arbitrary raw segment sizes that will be placed back to back
971  * System.NtapiNetTxSegmentRawAlignMode = -1 will apply the decided default value for the current driver release. This default value (applied with -1) can change across driver releases.
972  */
973 int NT_NetTxOpen_v3(NtNetStreamTx_t* hStream, const char* name, uint64_t portMask, uint32_t NUMA, uint64_t minHostBufferSize, enum NtPacketDescriptorType_e descriptor, enum NtTimestampType_e ts);
974 
975 /**
976  * @brief Initialize TX stream attributes
977  *
978  * The attributes are initialized to the following default values: \n
979  * name = NULL \n
980  * portMask = 0 \n
981  * NUMA = NT_NETTX_NUMA_ADAPTER_HB \n
982  * minHostBufferSize = 0 \n
983  * descriptor = NT_PACKET_DESCRIPTOR_TYPE_NT \n
984  * timestampType = NT_TIMESTAMP_TYPE_NATIVE_UNIX \n
985  *
986  * @param[out] attr Pointer to the attributes structure
987  */
989 
990 /**
991  * @brief Sets the stream name attribute
992  *
993  * @param[in] attr Pointer to the attributes structure
994  * @param[in] name Stream friendly name - used in, for example, logging statements
995  */
996 void NT_NetTxOpenAttrSetName(NtNetTxAttr_t* attr, const char* name);
997 
998 /**
999  * @brief Returns the name attribute
1000  * @return The name attribute
1001  */
1002 const char* NT_NetTxOpenAttrGetName(const NtNetTxAttr_t* attr);
1003 
1004 /**
1005  * @brief Sets the descriptor mode attribute
1006  *
1007  * @param[in] attr Pointer to the attributes structure
1008  * @param[in] portMask Descriptor mode
1009  *
1010  * @retval NT_SUCCESS Success
1011  * @retval !=NT_SUCCESS Error - use @ref NT_ExplainError for an error description
1012  */
1014 
1015 /**
1016  * @brief Returns the descriptor mode attribute
1017  * @return The descriptor mode attribute
1018  */
1020 
1021 /**
1022  * @brief Sets the port mask attribute
1023  *
1024  * @param[in] attr Pointer to the attributes structure
1025  * @param[in] portMask Bitmask for ports this stream will use for transmitting
1026  */
1027 void NT_NetTxOpenAttrSetPortMask(NtNetTxAttr_t* attr, uint64_t portMask);
1028 
1029 /**
1030  * @brief Returns the port mask attribute
1031  * @return The port mask attribute
1032  */
1034 
1035 /**
1036  * @brief Sets the numa attribute
1037  *
1038  * @param[in] attr Pointer to the attributes structure
1039  * @param[in] NUMA NUMA node on which the host buffer is be located (NOTE: Special options in enum ::NtNetTxOpenNumaOption_e)
1040  */
1041 void NT_NetTxOpenAttrSetNUMA(NtNetTxAttr_t* attr, uint32_t NUMA);
1042 
1043 /**
1044  * @brief Returns the numa attribute
1045  * @return The numa attribute
1046  */
1047 uint32_t NT_NetTxOpenAttrGetNUMA(NtNetTxAttr_t* attr);
1048 
1049 /**
1050  * @brief Sets the flags attribute
1051  *
1052  * @param[in] attr Pointer to the attributes structure
1053  * @param[in] flags Flags - see enum ::NtNetTxOpenFlags_e
1054  *
1055  * flags shall be either NT_NETTX_OPEN_FLAGS_NONE (0) or the bitwise-inclusive OR of one or more of the other flags in enum ::NtNetTxOpenFlags_e
1056  */
1057 void NT_NetTxOpenAttrSetFlags(NtNetTxAttr_t* attr, uint32_t flags);
1058 
1059 /**
1060  * @brief Returns the flags attribute
1061  * @return The flags attribute - see enum ::NtNetTxOpenFlags_e
1062  */
1063 uint32_t NT_NetTxOpenAttrGetFlags(NtNetTxAttr_t* attr);
1064 
1065 /**
1066  * @brief Sets the minimum host buffer size attribute
1067  *
1068  * @param[in] attr Pointer to the attributes structure
1069  * @param[in] minHostBufferSize Minimum size of host buffer needed in bytes. The smallest host buffer found that is larger or equal to minHostBufferSize is used and the size of the host buffer is set to minHostBufferSize. If set to 0, the first host buffer found is used regardsless of the size.
1070  */
1071 void NT_NetTxOpenAttrSetMinHostbufferSize(NtNetTxAttr_t* attr, uint64_t minHostBufferSize);
1072 
1073 /**
1074  * @brief Returns the minimum host buffer size attribute
1075  * @return The minimum host buffer size attribute
1076  */
1078 
1079 /**
1080  * @brief Sets the descriptor type attribute
1081  *
1082  * @param[in] attr Pointer to the attributes structure
1083  * @param[in] descriptor Descriptor type to use when transmitting.
1084  */
1086 
1087 /**
1088  * @brief Returns the descriptor type attribute
1089  * @return The descriptor type attribute
1090  */
1092 
1093 /**
1094  * @brief Sets bit position in packet descriptor for the Timestamp Inject command bit
1095  *
1096  * @param[in] attr Pointer to the attributes structure
1097  * @param[in] enable Enable/disable use of bits in packet descriptor.
1098  * @param[in] pos Position of bit. Maximum value is 191.
1099 
1100  *
1101  * @retval NT_SUCCESS Success
1102  * @retval !=NT_SUCCESS Error - use @ref NT_ExplainError for an error description
1103  */
1104 int NT_NetTxOpenAttrSetTxtDescriptorPosTimestampInject(NtNetTxAttr_t* attr, bool enable, uint32_t pos);
1105 
1106 /**
1107  * @brief Gets bit position in packet descriptor for the Timestamp Inject command bit
1108  *
1109  * @param[in] attr Pointer to the attributes structure
1110  * @param[in] enable Output pointer to enable/disable use of bit in packet descriptor.
1111  * @param[in] pos Output pointer to position of bits. Value will not be set if disabled.
1112  */
1113 void NT_NetTxOpenAttrGetTxtDescriptorPosTimestampInject(NtNetTxAttr_t* attr, bool* enable, uint32_t* pos);
1114 
1115 //-----------
1116 /**
1117  * @brief Sets bit position in packet descriptor for the FCS control command bit
1118  *
1119  * @param[in] attr Pointer to the attributes structure
1120  * @param[in] enable Enable/disable use of bits in packet descriptor.
1121  * When disabled all FCS is recalculated for packets.
1122  * When enabled FCS recalculation is controlled by
1123  * the packet descriptor bit in position pos.
1124  * @param[in] pos Position of bit. Maximum value is 191.
1125 
1126  *
1127  * @retval NT_SUCCESS Success
1128  * @retval !=NT_SUCCESS Error - use @ref NT_ExplainError for an error description
1129  */
1130 int NT_NetTxOpenAttrSetTxtDescriptorPosFcs(NtNetTxAttr_t* attr, bool enable, uint32_t pos);
1131 
1132 /**
1133  * @brief Gets bit position in packet descriptor for the FCS control command bit
1134  *
1135  * @param[in] attr Pointer to the attributes structure
1136  * @param[in] enable Output pointer to enable/disable use of bit in packet descriptor.
1137  * @param[in] pos Output pointer to position of bits. Value will not be set if disabled.
1138  */
1139 void NT_NetTxOpenAttrGetTxtDescriptorPosFcs(NtNetTxAttr_t* attr, bool* enable, uint32_t* pos);
1140 
1141 //-----------
1142 /**
1143  * @brief Sets the timestamp type attribute
1144  *
1145  * @param[in] attr Pointer to the attributes structure
1146  * @param[in] timestampType Timestamp format to use when transmitting.
1147  */
1148 void NT_NetTxOpenAttrSetTimestampType(NtNetTxAttr_t* attr, enum NtTimestampType_e timestampType);
1149 
1150 /**
1151  * @brief Returns the timestamp type attribute
1152  * @return The timestamp type attribute
1153  */
1155 
1156 /**
1157  * @brief Set bit position in packet descriptor for layer 3 offset bits.
1158  *
1159  * @param[in] attr Pointer to the attributes structure.
1160  * @param[in] enable Enable/disable use of bits in packet descriptor.
1161  * @param[in] pos Position of bits. Maximum value is 191.
1162  *
1163  * @retval NT_SUCCESS Success
1164  * @retval !=NT_SUCCESS Error - use @ref NT_ExplainError for an error description
1165  */
1166 int NT_NetTxOpenAttrSetDescriptorPosLayer3Offset(NtNetTxAttr_t* attr, bool enable, uint32_t pos);
1167 
1168 /**
1169  * @brief Get bit position in packet descriptor for layer 3 offset bits.
1170  *
1171  * @param[in] attr Pointer to the attributes structure.
1172  * @param[in] enable Output pointer to enable/disable use of bits in packet descriptor.
1173  * @param[in] pos Output pointer to position of bits. Value will not be set if disabled.
1174  */
1175 void NT_NetTxOpenAttrGetDescriptorPosLayer3Offset(const NtNetTxAttr_t* attr, bool* enable, uint32_t* pos);
1176 
1177 /**
1178  * @brief Set bit position in packet descriptor for layer 4 offset bits.
1179  *
1180  * @param[in] attr Pointer to the attributes structure.
1181  * @param[in] enable Enable/disable use of bits in packet descriptor.
1182  * @param[in] pos Position of bits. Maximum value is 191.
1183  *
1184  * @retval NT_SUCCESS Success
1185  * @retval !=NT_SUCCESS Error - use @ref NT_ExplainError for an error description
1186  */
1187 int NT_NetTxOpenAttrSetDescriptorPosLayer4Offset(NtNetTxAttr_t* attr, bool enable, uint32_t pos);
1188 
1189 /**
1190  * @brief Get bit position in packet descriptor for layer 4 offset bits.
1191  *
1192  * @param[in] attr Pointer to the attributes structure.
1193  * @param[in] enable Output pointer to enable/disable use of bits in packet descriptor.
1194  * @param[in] pos Output pointer to position of bits. Value will not be set if disabled.
1195  */
1196 void NT_NetTxOpenAttrGetDescriptorPosLayer4Offset(const NtNetTxAttr_t* attr, bool* enable, uint32_t* pos);
1197 
1198 /**
1199  * @brief Set bit position in packet descriptor for frame type bits.
1200  *
1201  * @param[in] attr Pointer to the attributes structure.
1202  * @param[in] enable Enable/disable use of bits in packet descriptor.
1203  * @param[in] pos Position of bits. Maximum value is 191.
1204  *
1205  * @retval NT_SUCCESS Success
1206  * @retval !=NT_SUCCESS Error - use @ref NT_ExplainError for an error description
1207  */
1208 int NT_NetTxOpenAttrSetDescriptorPosFrameType(NtNetTxAttr_t* attr, bool enable, uint32_t pos);
1209 
1210 /**
1211  * @brief Get bit position in packet descriptor for frame type bits.
1212  *
1213  * @param[in] attr Pointer to the attributes structure.
1214  * @param[in] enable Output pointer to enable/disable use of bits in packet descriptor.
1215  * @param[in] pos Output pointer to position of bits. Value will not be set if disabled.
1216  */
1217 void NT_NetTxOpenAttrGetDescriptorPosFrameType(const NtNetTxAttr_t* attr, bool* enable, uint32_t* pos);
1218 
1219 /**
1220  * @brief Set bit position in packet descriptor for checksum command bits.
1221  *
1222  * @param[in] attr Pointer to the attributes structure.
1223  * @param[in] enable Enable/disable use of bits in packet descriptor.
1224  * @param[in] pos Position of bits. Maximum value is 191.
1225  *
1226  * @retval NT_SUCCESS Success
1227  * @retval !=NT_SUCCESS Error - use @ref NT_ExplainError for an error description
1228  */
1229 int NT_NetTxOpenAttrSetDescriptorPosChecksumCmd(NtNetTxAttr_t* attr, bool enable, uint32_t pos);
1230 
1231 /**
1232  * @brief Get bit position in packet descriptor for checksum command bits.
1233  *
1234  * @param[in] attr Pointer to the attributes structure.
1235  * @param[in] enable Output pointer to enable/disable use of bits in packet descriptor.
1236  * @param[in] pos Output pointer to position of bits. Value will not be set if disabled.
1237  */
1238 void NT_NetTxOpenAttrGetDescriptorPosChecksumCmd(const NtNetTxAttr_t* attr, bool* enable, uint32_t* pos);
1239 
1240 /**
1241  * @brief Set bit position in packet descriptor for TX ignore bit.
1242  *
1243  * See Standard Descriptor for "TX ignore bit" description.
1244  *
1245  * @param[in] attr Pointer to the attributes structure.
1246  * @param[in] enable Enable/disable use of bit in packet descriptor.
1247  * @param[in] pos Position of bits. Maximum value is 191.
1248  *
1249  * @retval NT_SUCCESS Success
1250  * @retval !=NT_SUCCESS Error - use @ref NT_ExplainError for an error description
1251  */
1252 int NT_NetTxOpenAttrSetDescriptorPosIgnoreBit(NtNetTxAttr_t* attr, bool enable, uint32_t pos);
1253 
1254 /**
1255  * @brief Get bit position in packet descriptor for TX ignore bit.
1256  *
1257  * @param[in] attr Pointer to the attributes structure.
1258  * @param[in] enable Output pointer to enable/disable use of bits in packet descriptor.
1259  * @param[in] pos Output pointer to position of bits. Value will not be set if disabled.
1260  */
1261 void NT_NetTxOpenAttrGetDescriptorPosIgnoreBit(const NtNetTxAttr_t* attr, bool* enable, uint32_t* pos);
1262 
1263 /**
1264  * @brief Set bit position in packet descriptor for TX now bit.
1265  *
1266  * See Standard Descriptor for "TX now bit" description.
1267  *
1268  * @param[in] attr Pointer to the attributes structure.
1269  * @param[in] enable Enable/disable use of bit in packet descriptor.
1270  * @param[in] pos Position of bits. Maximum value is 191.
1271  *
1272  * @retval NT_SUCCESS Success
1273  * @retval !=NT_SUCCESS Error - use @ref NT_ExplainError for an error description
1274  */
1275 int NT_NetTxOpenAttrSetDescriptorPosTxNowBit(NtNetTxAttr_t* attr, bool enable, uint32_t pos);
1276 
1277 /**
1278  * @brief Get bit position in packet descriptor for TX now bit.
1279  *
1280  * @param[in] attr Pointer to the attributes structure.
1281  * @param[in] enable Output pointer to enable/disable use of bits in packet descriptor.
1282  * @param[in] pos Output pointer to position of bits. Value will not be set if disabled.
1283  */
1284 void NT_NetTxOpenAttrGetDescriptorPosTxNowBit(const NtNetTxAttr_t* attr, bool* enable, uint32_t* pos);
1285 
1286 /**
1287  * @brief Set bit position in packet descriptor for TX set clock bit.
1288  *
1289  * See Standard Descriptor for "TX set clock bit" description.
1290  *
1291  * @param[in] attr Pointer to the attributes structure.
1292  * @param[in] enable Enable/disable use of bit in packet descriptor.
1293  * @param[in] pos Position of bits. Maximum value is 191.
1294  *
1295  * @retval NT_SUCCESS Success
1296  * @retval !=NT_SUCCESS Error - use @ref NT_ExplainError for an error description
1297  */
1298 int NT_NetTxOpenAttrSetDescriptorPosClockBit(NtNetTxAttr_t* attr, bool enable, uint32_t pos);
1299 
1300 /**
1301  * @brief Get bit position in packet descriptor for TX set clock bit.
1302  *
1303  * @param[in] attr Pointer to the attributes structure.
1304  * @param[in] enable Output pointer to enable/disable use of bits in packet descriptor.
1305  * @param[in] pos Output pointer to position of bits. Value will not be set if disabled.
1306  */
1307 void NT_NetTxOpenAttrGetDescriptorPosClockBit(const NtNetTxAttr_t* attr, bool* enable, uint32_t* pos);
1308 
1309 /**
1310  * @brief Set mode for use of wire length in packet descriptor
1311  *
1312  * @param[in] attr Pointer to the attributes structure.
1313  * @param[in] enable flag to enable/disable use wire length in packet descriptor.
1314  */
1316 
1317 /**
1318  * @brief get mode for use of wire length in packet descriptor
1319  *
1320  * @param[in] attr Pointer to the attributes structure.
1321  * @param[in] enable Output pointer flag indicating use of wire length in packet descriptor.
1322  */
1323 int NT_NetTxOpenAttrGetDescriptorUseWireLength(const NtNetTxAttr_t* attr, bool* enable);
1324 
1325 
1326 /**
1327  * @brief Opens a TX host buffer and returns a NtNetStreamTx_t handle (extended version)
1328  *
1329  * This function is called to retrieve a TX stream handle.
1330  * This function will only work with 4GA adapters.
1331  *
1332  * @param[out] hStream Reference to a NtNetStreamTx_t stream pointer
1333  * @param[in] attr Pointer to stream attributes
1334  *
1335  * @retval NT_SUCCESS Success
1336  * @retval !=NT_SUCCESS Error - use @ref NT_ExplainError for an error description
1337  */
1338 int NT_NetTxOpen_Attr(NtNetStreamTx_t* hStream, const NtNetTxAttr_t* attr);
1339 /**
1340  * @brief Gets a TX port buffer
1341  *
1342  * This function is called to acquire a TX buffer
1343  *
1344  * @note This function has no mutex protection, therefore the same hStream cannot be used by multiple threads
1345  *
1346  * @param[in] hStream Network TX stream handle
1347  * @param[out] netBuf Segment/packet container reference
1348  * @param[in] port Port to receive a TX buffer from
1349  * @param[in] packetSize Size of the packet to transmit including 4-byte CRC.
1350  * @param[in] packetOption Option to control the properties of the buffer, see @ref NtNetTxPacketOption_e for details
1351  * @param[in] timeout Time in milliseconds to wait for a new buffer - a timeout of -1 will wait indefinitely for a new buffer
1352  *
1353  * @retval NT_SUCCESS Success
1354  * @retval !=NT_SUCCESS Error - use @ref NT_ExplainError for an error description
1355  */
1356 int NT_NetTxGet(NtNetStreamTx_t hStream, NtNetBuf_t* netBuf, uint32_t port, size_t packetSize, enum NtNetTxPacketOption_e packetOption, int timeout);
1357 
1358 /**
1359  * @brief Releases the network buffer
1360  *
1361  * This function releases the netBuf data obtained via NT_TxGet
1362  *
1363  * @note This function has no mutex protection and can therefore the same hStream cannot be used by multiple threads
1364  *
1365  * @param[in] hStream Network TX stream handle
1366  * @param[in] netBuf Net buffer is received via NT_TxGet
1367  *
1368  * @retval NT_SUCCESS Success
1369  * @retval !=NT_SUCCESS Error - use @ref NT_ExplainError for an error description
1370  */
1371 int NT_NetTxRelease(NtNetStreamTx_t hStream, NtNetBuf_t netBuf);
1372 
1373 /**
1374  * @brief Reads data from the stream
1375  *
1376  * This function will read Tx related info
1377  *
1378  * @param[in] hStream NetTx stream handle
1379  * @param[in] cmd NetTx read structure
1380  *
1381  * @retval NT_SUCCESS Success
1382  * @retval !=NT_SUCCESS Error - use @ref NT_ExplainError for an error description
1383  */
1384 int NT_NetTxRead(NtNetStreamTx_t hStream, NtNetTx_t* cmd);
1385 
1386 /**
1387  * @brief Closes a TX stream
1388  *
1389  * This function is called to close a TX stream
1390  *
1391  * @param[in] hStream The TX stream handle to close
1392  *
1393  * @retval NT_SUCCESS Success
1394  * @retval !=NT_SUCCESS Error - use @ref NT_ExplainError for an error description
1395  */
1396 int NT_NetTxClose(NtNetStreamTx_t hStream);
1397 
1398 /**
1399  * @brief AddPacket to a TX stream
1400  *
1401  * This function is called to put together scattered fragments of a packet and add it to a TX stream
1402  *
1403  * @note This function has no mutex protection and cannot be used by multiple threads on the same stream, hStream.
1404  *
1405  * @param[in] hStream Network TX stream handle
1406  * @param[in] port Port to add packet into host buffer
1407  * @param[in] fragments The scattered list of packet fragments
1408  * @param[in] fragmentCount The number of scattered fragments in the list
1409  * @param[in] timeout Time in milliseconds to wait for a packet buffer - a timeout of -1 will wait indefinitely for a packet buffer
1410  *
1411  * @retval NT_SUCCESS Success
1412  * @retval !=NT_SUCCESS Error - use @ref NT_ExplainError for an error description
1413  */
1414 int NT_NetTxAddPacket(NtNetStreamTx_t hStream, uint32_t port, NtNetTxFragment_t* fragments, uint32_t fragmentCount, int timeout );
1415 
1416 //
1417 
1418 
1419 /** @page HwL3L4Checksum HW IP/UDP/TCP checksum
1420  * @{
1421  * The NT40E2-4, NT20E2, NT4E2 adapters and NT4E in-line adapters support IPv4, UDP and TCP
1422  * calculations in hardware on transmit.\n
1423  * In order to use the feature, the packet descriptor must be configured prior to calling
1424  * @ref NT_NetTxRelease().\n
1425  * <b>Note:</b> The feature only works on non-fragmented packets.\n\n
1426  * Here is an example on the configuration required before transmitting a packet.
1427  *
1428  @verbatim
1429 
1430  struct IPv4Header_s {
1431  uint16_t ip_hl: 4;
1432  uint16_t ip_v: 4;
1433  uint16_t ip_tos: 8;
1434  uint16_t ip_len;
1435 
1436  uint32_t ip_id:16;
1437  uint32_t ip_frag_off:16;
1438 #define IP_DONT_FRAGMENT 0x4000
1439 #define IP_MORE_FRAGMENTS 0x2000
1440 
1441  uint32_t ip_ttl:8;
1442  uint32_t ip_prot:8;
1443  uint32_t ip_crc:16;
1444 
1445  uint32_t ip_src;
1446  uint32_t ip_dest;
1447 }; //20 bytes
1448 
1449 struct UDPHeader_s {
1450  uint32_t udp_src:16;
1451  uint32_t udp_dest:16;
1452 
1453  uint32_t udp_len:16;
1454  uint32_t udp_crc:16;
1455 }; // 8 bytes
1456 
1457 
1458  NT_NET_SET_PKT_IS_IP(hNetBuf, 1);
1459  NT_NET_SET_PKT_IS_UDP(hNetBuf, 1);
1460  NT_NET_SET_PKT_IP_CSUM_OK(hNetBuf, 1);
1461  NT_NET_SET_PKT_UDP_CSUM_OK(hNetBuf, 1);
1462  if(NT_NET_GET_PKT_DESCRIPTOR_TYPE(hNetBuf) == NT_PACKET_DESCRIPTOR_TYPE_NT_EXTENDED) {
1463  NT_NET_SET_PKT_ISL(hNetBuf, 0);
1464  NT_NET_SET_PKT_VLAN_COUNT(hNetBuf, 0);
1465  NT_NET_SET_PKT_MPLS_COUNT(hNetBuf, 0);
1466  NT_NET_SET_PKT_L2_FRAME_TYPE(hNetBuf, NT_L2_FRAME_TYPE_ETHER_II);
1467  NT_NET_SET_PKT_L3_FRAME_TYPE(hNetBuf, NT_L3_FRAME_TYPE_IPv4);
1468  NT_NET_SET_PKT_L4_FRAME_TYPE(hNetBuf, NT_L4_FRAME_TYPE_UDP);
1469  NT_NET_SET_PKT_L3_LENGTH(hNetBuf, sizeof(struct IPv4Header_s)>>2);
1470  NT_NET_SET_PKT_L4_LENGTH(hNetBuf, sizeof(struct UDPHeader_s)>>2);
1471  NT_NET_SET_PKT_CALC_L3_CHECKSUM(hNetBuf, 1);
1472  NT_NET_SET_PKT_CALC_L4_CHECKSUM(hNetBuf, 1);
1473  }
1474  @endverbatim
1475 
1476  @} */
1477 
1478 /** @page PacketBasedTransmit Packet based transmit
1479  * @{
1480  *
1481  * For packet based transmit see the example @ref transmit_packet_example.c "net/transmit/transmit_packet_example.c"
1482  @} */
1483 
1484 /** @page SegmentBasedTransmit Segment based transmit
1485  * @{
1486  *
1487  * For segment based transmit see the example @ref transmit_segment_example.c "net/transmit_segment/transmit_segment_example.c"
1488  @} */
1489 
1490 /** @} */
1491 
1492 
1493 /** @addtogroup StreamFile
1494  *@{
1495  */
1496 /**
1497  * Network file stream handle - used for file streams
1498  */
1499 typedef struct NtNetStreamFile_s* NtNetStreamFile_t;
1500 
1501 /**
1502  * @brief Opens a capture file
1503  *
1504  * This function is called to open a capture file, captured with a segment-based stream.
1505  * The capture file must have an NT, PCAP or PCAP-NG file header otherwise it will fail
1506  * when opening the capture file.
1507  *
1508  * @param[out] hStream Reference to a NetFile_t stream pointer
1509  * @param[in] name A stream friendly name - used in, for example, logging statements
1510  * @param[in] netIntf Deliver packets or segments
1511  * @param[in] file The capture file to open
1512  *
1513  * @retval NT_SUCCESS Success
1514  * @retval !=NT_SUCCESS Error - use @ref NT_ExplainError for an error description
1515  */
1516 int NT_NetFileOpen(NtNetStreamFile_t* hStream, const char* name, enum NtNetInterface_e netIntf, const char* file);
1517 
1518 /**
1519 * @brief Opens a capture file (extended version)
1520 *
1521 * This function is called to open a capture file, captured with a segment-based stream.
1522 * The capture file must have an NT, PCAP or PCAP-NG file header otherwise it will fail
1523 * when opening the capture file.
1524 *
1525 * @param[out] hStream Reference to a NetFile_t stream pointer
1526 * @param[in] name A stream friendly name - used in, for example, logging statements
1527 * @param[in] netIntf Deliver packets or segments
1528 * @param[in] file The capture file to open
1529 * @param[in] noConvert Do not convert PCAP files (Native PCAP tx for 4GA)
1530 *
1531 * @retval NT_SUCCESS Success
1532 * @retval !=NT_SUCCESS Error - use @ref NT_ExplainError for an error description
1533 */
1534 int NT_NetFileOpen_v2(NtNetStreamFile_t* hStream, const char* name, enum NtNetInterface_e netIntf, const char* file, bool noConvert);
1535 
1536 /**
1537  * @brief Gets packets/segments from a file stream
1538  *
1539  * This function is called to retrieve packets or segments from a capture file
1540  *
1541  * @note This function has no mutex protection, therefore the same hStream cannot be used by multiple threads
1542  *
1543  * @param[in] hStream NetFile stream handle
1544  * @param[out] netBuf Packet/segment container reference
1545  *
1546  * @retval NT_SUCCESS (0) Success
1547  * @retval NT_STATUS_END_OF_FILE EOF indicator - See note
1548  * @retval otherwise Error - use @ref NT_ExplainError for an error description
1549  * @note When NT_STATUS_END_OF_FILE is returned the internal file offset that been reset making it possible to
1550  * call NT_NetFileGet() again without having to close and open the file, which improves performance when
1551  * replaying a file continuously.
1552  */
1553 int NT_NetFileGet(NtNetStreamFile_t hStream, NtNetBuf_t* netBuf);
1554 
1555 /**
1556  * @brief Releases the network buffer
1557  *
1558  * This function will release the netBuf data obtained via NT_FileGet
1559  *
1560  * @note This function has no mutex protection, therefore the same hStream cannot be used by multiple threads
1561  *
1562  * @param[in] hStream NetStreamFile stream handle
1563  * @param[in] netBuf The network buffer is received via NT_FileGet
1564  *
1565  * @retval NT_SUCCESS Success
1566  * @retval !=NT_SUCCESS Error - use @ref NT_ExplainError for an error description
1567  */
1568 int NT_NetFileRelease(NtNetStreamFile_t hStream, NtNetBuf_t netBuf);
1569 
1570 /**
1571  * @brief Closes a file stream
1572  *
1573  * This function is called to close a file stream
1574  *
1575  * @param[in] hStream The file stream handle to close
1576  *
1577  * @retval NT_SUCCESS Success
1578  * @retval !=NT_SUCCESS Error - use @ref NT_ExplainError for an error description
1579  */
1580 int NT_NetFileClose(NtNetStreamFile_t hStream);
1581 
1582 /**
1583  * @brief Read information about a file stream
1584  *
1585  * This function is called to read information about a file stream
1586  *
1587  * @param[in] hStream The file stream handle
1588  * @param[in,out] data Structure containing command and returned data
1589  *
1590  * @retval NT_SUCCESS Success
1591  * @retval !=NT_SUCCESS Error - use @ref NT_ExplainError for an error description
1592  */
1594 
1595 /**
1596 * @brief Opens a capture file
1597 *
1598 * This function is called to open a capture file, captured with a segment-based stream.
1599 * The capture file must have an NT, PCAP or PCAP-NG file header otherwise it will fail
1600 * when opening the capture file.
1601 *
1602 * @param[out] hStream Reference to a NetFile_t stream pointer
1603 * @param[in] file The capture file to open
1604 * @param[in] attr Attributes of the stream
1605 *
1606 * @retval NT_SUCCESS Success
1607 * @retval !=NT_SUCCESS Error - use @ref NT_ExplainError for an error description
1608 */
1609 int NT_NetFileOpen_Attr(NtNetStreamFile_t* hStream, const char* file, const NtNetFileAttr_t* attr);
1610 
1611 /**
1612  * @brief Initialize NetFile stream attributes
1613  *
1614  * The attributes are initialized to the following default values: \n
1615  * name = NULL \n
1616  * netIntf = NT_NET_INTERFACE_SEGMENT \n
1617  * pcapToNtConversion = True \n
1618  * convertedTsType = NT_TIMESTAMP_TYPE_NATIVE_UNIX \n
1619  *
1620  * @param[in] attr Pointer to the attributes structure
1621  *
1622  */
1624 
1625 /**
1626  * @brief Sets the stream name attribute
1627  *
1628  * @param[in] attr Pointer to the attributes structure
1629  * @param[in] name Stream friendly name - used in, for example, logging statements
1630  */
1631 void NT_NetFileOpenAttrSetName(NtNetFileAttr_t* attr, const char* name);
1632 
1633 /**
1634  * @brief Returns the name attribute
1635  *
1636  * @param[in] attr Pointer to the attributes structure
1637  *
1638  * @return The name attribute
1639  */
1640 const char* NT_NetFileOpenAttrGetName(const NtNetFileAttr_t* attr);
1641 
1642 /**
1643  * @brief Sets the interface type attribute
1644  *
1645  * @param[in] attr Pointer to the attributes structure
1646  * @param[in] netIntf Interface type - segment or packet
1647  */
1649 
1650 /**
1651  * @brief Returns the interface type attribute
1652  *
1653  * @param[in] attr Pointer to the attributes structure
1654  *
1655  * @return The interface type attribute
1656  */
1658 
1659 
1660 /**
1661  * @brief Enable or disable automatic conversion from PCAP to NT format
1662  *
1663  * @param[in] attr Pointer to the attributes structure
1664  * @param[in] enableFlag True enables automatic conversion from PCAP to NT
1665  * format for 3GA. Automatic conversion does not
1666  * apply to 4GA, which has native support for PCAP.
1667  */
1669  bool enableFlag);
1670 
1671 /**
1672  * @brief Returns whether automatic conversion from PCAP to NT format is enabled
1673  *
1674  * @param[in] attr Pointer to the attributes structure
1675  *
1676  * @return A boolean where True denotes that automatic conversion from
1677  * PCAP to NT format is enabled (only applicable to 3GA).
1678  */
1680 
1681 /**
1682  * @brief Sets the converted timstamp type attribute
1683  *
1684  * This attribute is only used, when a PCAP file is converted to
1685  * an NT capture file.
1686  *
1687  * Valid values are:
1688  * NT_TIMESTAMP_TYPE_NATIVE_UNIX
1689  * NT_TIMESTAMP_TYPE_UNIX_NANOTIME
1690  *
1691  * @param[in] attr Pointer to the attributes structure
1692  * @param[in] convertedTsType Converted timestamp type
1693  */
1695 
1696 /**
1697  * @brief Gets the converted timstamp type attribute
1698  *
1699  * @param[in] attr Pointer to the attributes structure
1700  *
1701  * @return the converted Timestamp Type attribute
1702  */
1704 
1705 /** @} */
1706 
1707 /**
1708  * MACROs to access network data
1709  */
1710 
1711 /**
1712  * Layer 2 types
1713  */
1715  NT_L2_FRAME_TYPE_ETHER_II=0, //!< Ether type II frame
1716  NT_L2_FRAME_TYPE_LLC, //!< LLC frame
1717  NT_L2_FRAME_TYPE_SNAP, //!< SNAP frame
1718  NT_L2_FRAME_TYPE_NOVELL_RAW //!< Novell Raw frame
1719 };
1720 
1721 /**
1722  * Layer 3 types
1723  */
1725  NT_L3_FRAME_TYPE_IPv4=0, //!< IPv4 frame
1726  NT_L3_FRAME_TYPE_IPv6, //!< IPV6 frame
1727  NT_L3_FRAME_TYPE_IPX, //!< IPX frame
1728  NT_L3_FRAME_TYPE_OTHER, //!< Other frame
1729 };
1730 
1731 /**
1732  * Layer 4 frame types
1733  */
1735  NT_L4_FRAME_TYPE_TCP=0, //!< TCP frame
1736  NT_L4_FRAME_TYPE_UDP, //!< UDP frame
1737  NT_L4_FRAME_TYPE_ICMP, //!< ICMP frame
1738  NT_L4_FRAME_TYPE_OTHER, //!< Other frame
1739  NT_L4_FRAME_TYPE_GRE, //!< GRE frame
1740  NT_L4_FRAME_TYPE_SCTP, //!< SCTP frame
1741  NT_L4_FRAME_TYPE_IPV4, //!< IPV4 in IP frame
1742  NT_L4_FRAME_TYPE_IPV6, //!< IPV6 in IP frame
1743 };
1744 
1745 /**
1746  * Layer 4 port types
1747  */
1749  NT_L4_PORT_OTHER=0, //!< Other port
1750  NT_L4_PORT_GTPV0_U, //!< GTPV0_U port
1751  NT_L4_PORT_GTPV1V2_C, //!< GTPV1V2_C port
1752  NT_L4_PORT_GTPV1_U //!< GTPV1_U port
1753 };
1754 
1755 /**
1756  * Frame tunnel types
1757  */
1759  NT_TUNNELTYPE_OTHER=0, //!< Other data type
1760  NT_TUNNELTYPE_GTPV0_U, //!< GTPV0_U data type
1761  NT_TUNNELTYPE_GTPV1V2_C, //!< GTPV1V2_C data type
1762  NT_TUNNELTYPE_GTPV1_U_SIGNAL, //!< GTPV1_U_SIGNAL type
1763  NT_TUNNELTYPE_GTPV1_U_GPDU, //!< GTPV1_U_GPDU data type
1764  NT_TUNNELTYPE_IPINIP, //!< IPINIP data type
1765 };
1766 
1767 /**
1768  * L3 fragmentation
1769  */
1771  NT_L3_FRAGMENT_TYPE_NONE, //!< L3 not fragmented
1772  NT_L3_FRAGMENT_TYPE_FIRST, //!< L3 first fragment
1773  NT_L3_FRAGMENT_TYPE_MIDDLE, //!< L3 middle fragment
1774  NT_L3_FRAGMENT_TYPE_LAST, //!< L3 last fragment
1775 };
1776 
1777 /** @addtogroup NetworkStream
1778  *@{
1779  */
1780 
1781 /**
1782  * @defgroup MetaDataMacros User meta data container
1783  * @{
1784  * The following macros get and set user defined meta data.
1785  * Use these fields as house-keeping storage. No NTAPI function use these meta containers for anything.
1786  *
1787  */
1788 
1789 /** @def NT_NET_GET_USER_META_ARG0
1790  * @brief Returns the meta data arg0 uintptr_t value
1791  * @param[in] "_hNetBuf_" NetBuf pointer
1792  * @hideinitializer
1793  */
1794 #define NT_NET_GET_USER_META_ARG0(_hNetBuf_) ((_hNetBuf_)->arg0)
1795 
1796 /** @def NT_NET_GET_USER_META_ARG1
1797  * @brief Returns the meta data arg1 uintptr_t value
1798  * @param[in] "_hNetBuf_" NetBuf pointer
1799  * @hideinitializer
1800  */
1801 #define NT_NET_GET_USER_META_ARG1(_hNetBuf_) ((_hNetBuf_)->arg1)
1802 
1803 /** @def NT_NET_GET_USER_META_ARG2
1804  * @brief Returns the meta data arg2 uintptr_t value
1805  * @param[in] "_hNetBuf_" NetBuf pointer
1806  * @hideinitializer
1807  */
1808 #define NT_NET_GET_USER_META_ARG2(_hNetBuf_) ((_hNetBuf_)->arg2)
1809 
1810 /** @def NT_NET_SET_USER_META_ARG0
1811  * @brief Set the meta data arg0 uintptr_t value
1812  * @param[in] "_hNetBuf_" NetBuf pointer
1813  * @param[in] value An uintptr_t sized value
1814  * @hideinitializer
1815  */
1816 #define NT_NET_SET_USER_META_ARG0(_hNetBuf_, value) ((_hNetBuf_)->arg0 = (value))
1817 
1818 /** @def NT_NET_SET_USER_META_ARG1
1819  * @brief Set the meta data arg1 uintptr_t value
1820  * @param[in] "_hNetBuf_" NetBuf pointer
1821  * @param[in] value An uintptr_t sized value
1822  * @hideinitializer
1823  */
1824 #define NT_NET_SET_USER_META_ARG1(_hNetBuf_, value) ((_hNetBuf_)->arg1 = (value))
1825 
1826 /** @def NT_NET_SET_USER_META_ARG2
1827  * @brief Set the meta data arg2 uintptr_t value
1828  * @param[in] "_hNetBuf_" NetBuf pointer
1829  * @param[in] value An uintptr_t sized value
1830  * @hideinitializer
1831  */
1832 #define NT_NET_SET_USER_META_ARG2(_hNetBuf_, value) ((_hNetBuf_)->arg2 = (value))
1833 
1834 /** @} */
1835 
1836 /** @defgroup DataMacros Network macros
1837  * @{
1838  * The network stream delivers data to the application. In order to access data
1839  * content, such as packet length or packet receive time stamp, a set of macros is
1840  * provided. These macros are divided into 2 major groups:
1841  * - @ref SegmentMacros
1842  * - @ref PacketMacros
1843  *
1844  * The @ref SegmentMacros are used with the segment-based interface
1845  * The @ref PacketMacros are used with the packet-based interface
1846  */
1847 
1848 /** @defgroup SegmentMacros Segment macros
1849  * @{
1850  * The following is only possible on segment-based streams
1851  */
1852 
1853 /** @def NT_NET_GET_SEGMENT_PTR
1854  * @brief Returns the segment pointer
1855  * @param[in] "_hNetBuf_" Segment container reference
1856  * @hideinitializer
1857  */
1858 #define NT_NET_GET_SEGMENT_PTR(_hNetBuf_) ((_hNetBuf_)->hHdr)
1859 
1860 /** @def NT_NET_GET_SEGMENT_LENGTH
1861  * @brief Returns the segment length
1862  * @param[in] "_hNetBuf_" Segment container reference
1863  * @hideinitializer
1864  */
1865 #define NT_NET_GET_SEGMENT_LENGTH(_hNetBuf_) ((size_t)(_hNetBuf_)->length)
1866 
1867 /** @def NT_NET_GET_SEGMENT_PKTS
1868  * @brief Returns the number of packets in a segment
1869  *
1870  * This macro is only supported on NT4GA adapters configured to static segment
1871  * size emulation mode. On NT4GA adapters configured to dynamic segment size
1872  * this macro will always return 0.
1873  * @param[in] "_hNetBuf_" Segment container reference
1874  * @hideinitializer
1875  */
1876 #define NT_NET_GET_SEGMENT_PKTS(_hNetBuf_) ((size_t)(_hNetBuf_)->pkts)
1877 
1878 /** @def NT_NET_GET_SEGMENT_TIMESTAMP
1879  * @brief The time stamp of the first packet in the segment
1880  * @param[in] "_hNetBuf_" Segment container reference
1881  * @hideinitializer
1882  */
1883 #define NT_NET_GET_SEGMENT_TIMESTAMP(_hNetBuf_) NT_NetGetSegmentTimestamp((_hNetBuf_)->hHdr)
1884 uint64_t NT_NetGetSegmentTimestamp(void* pDescr);
1885 
1886 /** @def NT_NET_GET_SEGMENT_TIMESTAMP_TYPE
1887  * @brief The time stamp type
1888  * @param[in] "_hNetBuf_" Segment container reference
1889  * @hideinitializer
1890  */
1891 #define NT_NET_GET_SEGMENT_TIMESTAMP_TYPE(_hNetBuf_) ((_hNetBuf_)->tsType)
1892 
1893 /** @def NT_NET_SET_SEGMENT_LENGTH
1894  * @brief Sets the segment length
1895  *
1896  * This is used when generating a TX segment and should be used with care.
1897  * @param[in,out] "_hNetBuf_" Segment container reference
1898  * @param[in] "_length_" Length of the segment
1899  * @hideinitializer
1900  */
1901 #define NT_NET_SET_SEGMENT_LENGTH(_hNetBuf_, _length_) do {(_hNetBuf_)->length=_length_;} while(0)
1902 
1903 
1904 /** @defgroup SegmentFunctions Functions to handle segment data
1905  * @{
1906  * These inline C functions are only valid when "PacketDescriptor" in ntservice.ini file has been set to any value than PCAP
1907  * and @ref NT_NET_GET_PKT_DESCRIPTOR_TYPE returns @ref NT_PACKET_DESCRIPTOR_TYPE_NT_EXTENDED or @ref NT_PACKET_DESCRIPTOR_TYPE_NT
1908  */
1909 /**
1910  * @brief Inline C function to create a segment NtNetBuf_t
1911  *
1912  * This function is used when creating segments in application memory, e.g.
1913  * when constructing a transmit segment
1914  *
1915  * @param[in] size Size of the memory provided by the "mem" pointer
1916  * @param[in] mem Pointer to the segment memory allocated
1917  * @param[in] portOffset Segments are per adapter and ports are relative to the port offset. The port offset can be found in @ref NtInfoAdapter_v6_s::portOffset. If 0 is provided then the possible values in @ref NT_NET_SET_PKT_TXPORT can only be from 0 to 3.
1918  * @param[out] segNetBuf Destination segment NtNetBuf_t structure
1919  *
1920  */
1921 static NT_INLINE void _nt_net_create_segment_netbuf(uint64_t size, void* mem, uint8_t portOffset, struct NtNetBuf_s* segNetBuf)
1922 {
1923  memset(segNetBuf, 0, sizeof(struct NtNetBuf_s));
1924  segNetBuf->length=size;
1925  segNetBuf->portOffset=portOffset;
1926  segNetBuf->hHdr=(NtNetBufHdr_t)(mem);
1927  segNetBuf->hPkt=(NtNetBufPkt_t)(mem);
1928  *((uint64_t*)mem+0)=0;
1929  *((uint64_t*)mem+1)=0;
1930  *((uint64_t*)mem+2)=0;
1931  *((uint64_t*)mem+3)=0;
1932 }
1933 
1934 /**
1935  * @brief Inline C function to use when traversing segments. The
1936  * function will update the NetBuf to the next packet
1937  * in the segment.
1938  *
1939  * @param[in] segNetBuf Segment NtNetBuf_s * structure
1940  * @param[in] segLength Length of the segment - used to know when there is no more data
1941  * @param[out] pktNetBuf Packet NtNetBuf_s * structure
1942  *
1943  * @retval Returns the amount of data left in the segment
1944  */
1945 static NT_INLINE uint64_t _nt_net_get_next_packet(struct NtNetBuf_s* segNetBuf, uint64_t segLength, struct NtNetBuf_s* pktNetBuf)
1946 {
1947  if(segLength) {
1948  uint8_t* nextPacket = (uint8_t*)pktNetBuf->hHdr + NT_NET_GET_PKT_CAP_LENGTH(pktNetBuf);
1949  uint8_t* endSegm = (uint8_t*)segNetBuf->hHdr + segLength;
1950  // If this was the last packet then do not traverse any further
1951  if (nextPacket >= endSegm) {
1952  return 0;
1953  }
1954  pktNetBuf->hHdr=(NtNetBufHdr_t)nextPacket;
1955  pktNetBuf->hPkt=(NtNetBufPkt_t)(nextPacket + NT_NET_GET_PKT_DESCR_LENGTH(pktNetBuf));
1956  return (uint64_t)(endSegm - nextPacket);
1957  } else {
1958  return 0;
1959  }
1960 }
1961 
1962 /**
1963  * @brief Inline C function to build a packet based NtNetBuf_t
1964  * from a segment based NtNetBuf_t
1965  *
1966  * @param[in] segNetBuf Segment NtNetBuf_t structure
1967  * @param[out] pktNetBuf Destination packet NtNetBuf_t structure
1968  *
1969  */
1970 static NT_INLINE void _nt_net_build_pkt_netbuf(struct NtNetBuf_s* segNetBuf, struct NtNetBuf_s* pktNetBuf)
1971 {
1972  memcpy((void*)pktNetBuf, (void*)segNetBuf, sizeof(struct NtNetBuf_s));
1973  pktNetBuf->hHdr=(NtNetBufHdr_t)(segNetBuf->hHdr);
1974  pktNetBuf->hPkt=(NtNetBufPkt_t)((uint8_t*)segNetBuf->hHdr+NT_NET_GET_PKT_DESCR_LENGTH(segNetBuf));
1975 }
1976 
1977 /**
1978  * @brief Inline C function to initialize a segment NtNetBuf_t structure
1979  * using any received segment buffer.
1980  *
1981  * This function is used when a new NtNetBuf_t handle is needed for a provided segment
1982  * buffer, e.g. when copying segments
1983  *
1984  * @param[in] size Size of the segment pointed to by the "segment" pointer
1985  * @param[in] segment Pointer to the segment
1986  * @param[in] portOffset Segments are per adapter and ports are relative to the port offset. The port offset of the adapter of which the segment originates from most be copied/stored in parallel, or known by some other means, and specified here. If 0 is used here local ports will be seen as logical ports.
1987  * @param[out] segNetBuf Segment NtNetBuf_t structure to initialize
1988  *
1989  */
1990 static NT_INLINE void _nt_net_initialize_segment_netbuf(uint64_t size, void* segment, uint8_t portOffset, struct NtNetBuf_s* segNetBuf)
1991 {
1992  memset(segNetBuf, 0, sizeof(struct NtNetBuf_s));
1993  segNetBuf->length=size;
1994  segNetBuf->portOffset=portOffset;
1995  segNetBuf->hHdr=(NtNetBufHdr_t)(segment);
1996  segNetBuf->hPkt=(NtNetBufPkt_t)(segment);
1997 }
1998 
1999 
2000 /** @} */
2001 
2002 /** @} */
2003 
2004 /** @} */
2005 /** @} */
2006 /** @} */
2007 
2008 
2009 #ifndef DOXYGEN_INTERNAL_ONLY
2010 #define NT_MAKE_STRUCTURE_ID( __structureType, __structureName ) \
2011  ((uint32_t)((__structureType << 16) | sizeof(__structureName)))
2012 
2013 /**
2014  * File header. This data must be placed in the beginning of a
2015  * file when storing data to disk.
2016  */
2017 #define NT_FILE_HEADER0_COOKIE 0xDEADBEAF
2018 // Ensure that the following is packed equally on 32 and 64bit
2019 #pragma pack(push, 1)
2020 typedef struct NtFileHeader0_s {
2021  /**
2022  * StructureID is used to identify the header structure type
2023  */
2024  uint32_t structid; //!< The segment descriptor version
2025  uint64_t align; //!< Alignment to ensure the cookie is located at offset 12
2026  /**
2027  * Cookie to validate the header
2028  */
2029  uint32_t cookie; //!< Cookie = 0xDEADBEAF. Must be located at offset 12 to be able to detect if the file starts with a packet. The cookie will be located where storedLength is found in a packet.
2030  /**
2031  * The time stamp type used to time stamp the segments - very useful in offline mode
2032  */
2033  uint8_t tsType; //!< Timestamp type that is supplied with 'TimeValidAt'
2034  /**
2035  * Port offset. All packets in the segment have a per adapter specific port index
2036  * and by adding this portOffset, the system-wide port is retrieved.
2037  */
2038  uint8_t portOffset; //!< Port offset - use to calculate the logical port number
2039  /**
2040  * Color lookup.
2041  * Contains the customer color ID mapping to HW IDs.
2042  */
2043  uint8_t colorMap[64]; //!< Filter color map table
2044  uint8_t reserved[46]; //!< Reserved. Total structure size must be 128 bytes.
2045 } NtFileHeader0_t;
2046 
2047 // Disable packing
2048 #pragma pack(pop)
2049 #define NT_STID_FILE_HEADER0 NT_MAKE_STRUCTURE_ID(1, NtFileHeader0_t)
2050 #endif
2051 #endif /* __STREAM_NET_H__ */
2052 
2053 //
2054 // EOF
2055 //