bRAWcap 1.1.0
b-plus Technologies - Ethernet Performance Transmitter Receiver
Loading...
Searching...
No Matches
brawcap_types_shared.h
Go to the documentation of this file.
1/**
2 * @file brawcap_types_shared.h
3 *
4 * @brief bRAWcap API - Shared types.
5 *
6 * The file includes all (data)types and defines used for bRAWcap (kernel and user space).
7 *
8 * @copyright
9 * <b> © 2021 - b-plus technologies GmbH. All rights reserved!</b>
10 *
11 * All rights exclusively reserved for b-plus GmbH, unless expressly otherwise agreed.
12 *
13 * Redistribution in source or any other form, with or without modification, is not permitted.
14 *
15 *
16 * You may use this code under the according license terms of b-plus.
17 * Please contact b-plus at services@b-plus.com to get the appropriate terms and conditions.
18 */
19#ifndef BRAWCAP_TYPES_SHARED_H
20#define BRAWCAP_TYPES_SHARED_H
21
22// Include required Windows headers for datatypes.
23#if 1
24#if !defined(_WIN64)
25 #error Architecture not defined (please define "_WIN64").
26#else
27 #ifdef WINNT
28 #include <sdkddkver.h>
29 #include <basetsd.h>
30 #include <minwindef.h>
31 #else
32 #define WIN32_LEAN_AND_MEAN
33 #include <Windows.h>
34 #endif
35#endif
36#endif
37
38/************************************************ GENERIC ************************************************************/
39#if 1
40/**
41 * @example{lineno} 03_generic_handle_opener_f.c
42 *
43 * This example shows how to open and close bRAWcap handles to each available adapter on the machine.
44 * If any unexpected status is returned, it will close all handles and print the unexpected status to console.
45 * Therefore @ref brawcap_last_status is used.
46 */
47
48/**
49 * @defgroup brawcap_generics Generics
50 * @brief Contains generic types and functions of bRAWcap.
51 *
52 * Everything in here is not part of any specific module, instead those types and functions are relevant for many
53 * other modules. It contains for example functions to @ref brawcap_open "open/create" and @ref brawcap_close "close"
54 * a @ref brawcap_handle_t "bRAWcap handle".
55 *
56 * List of examples:
57 * 1. @ref 03_generic_handle_opener_f.c "Handle Opener"
58 * @{
59 */
60
61/**
62 * @brief Specifies the maximum supported bRAWcap handles per adapter.
63 *
64 * @attention If this number of handles is reached (for a specific adapter) each additional @ref brawcap_open "open"
65 * will fail.
66 */
67#define BRAWCAP_HANDLES_PER_ADAPTER_MAX 5
68
69/**
70 * @brief The number of packets which can be (temporary) buffered by the bRAWcap driver queue.
71 *
72 * The total number of packets which can be buffered by the driver queue is limited to:
73 * - receive: @ref BRAWCAP_RX_DRIVER_QUEUE_SIZE_MAX
74 * - transmit: @ref BRAWCAP_TX_DRIVER_QUEUE_SIZE_MAX
75 *
76 * @note Each bRAWcap handle has it´s own driver queue. Therefore the total memory consumption by the driver
77 * depends on the number of adapters and handles to each adapter, and also on how large the driver queue is specified.
78 *
79 * @attention Larger driver queues can minimize packet drops due to more resources. Especially in cases where the user
80 * application requires longer than expected to pick up (call receive) on the handle. But it has to be said that
81 * large queues shouldn´t be required in optimized configurations and that they can consume a lot of memory if they
82 * are not configured with care.
83 */
84typedef UINT32 brawcap_queue_size_t;
85
86/**@}*/
87#endif
88
89/************************************************** STATUS ***********************************************************/
90#if 1
91/**
92 * @defgroup brawcap_status Status
93 * @brief Contains all status/return codes of bRAWcap.
94 *
95 * If a bRAWcap function completed successfully and with no additional information it will indicate
96 * @ref BRAWCAP_STATUS_SUCCESS.
97 *
98 * If an error occurs the status code will always be negative.
99 *
100 * A status which indicates a warning, will always have a positive value (range 1 to 1999).
101 *
102 * While a status with additional information is always represented by high positive value (range 2000 to 4000).
103 *
104 * It is also possible to request the last "non successful" status for the current thread again with
105 * @ref brawcap_last_status. This function works similar to the one defined by the Windows API (GetLastError()).
106 * @{
107 */
108
109/**
110 * @brief Checks if the returned status indicates a success with no additional info.
111 */
112#define BRAWCAP_SUCCESS(status) (status == 0)
113
114/**
115 * @brief Checks if the returned status is a error.
116 */
117#define BRAWCAP_ERROR(status) (status < 0)
118
119/**
120 * @brief Checks if the returned status is a warning.
121 */
122#define BRAWCAP_WARNING(status) (status > 0 && status < 2000)
123
124/**
125 * @brief Checks if the returned status is a info.
126 */
127#define BRAWCAP_INFO(status) (status >= 2000 && status < 4000)
128
129/**
130 * @brief bRAWcap status/return codes.
131 *
132 * Each status is defined with a descriptive name, which indicates it´s reason.
133 * To check for the status code type use one of the defined macros:
134 * - Status indicates @ref BRAWCAP_SUCCESS "success"
135 * - Status indicates @ref BRAWCAP_ERROR "error"
136 * - Status indicates @ref BRAWCAP_WARNING "warning"
137 * - Status indicates @ref BRAWCAP_INFO "info"
138 */
139typedef enum _brawcap_status
140{
141 // SUCCESS (== 0)
142 BRAWCAP_STATUS_SUCCESS = 0, /*!< Executed successfully, with no additional information. */
143
144 // ERROR (< 0)
145 #if 1
146 /**
147 * @brief Detected a - not further specified - failure.
148 *
149 * This shouldn´t happen at all and mostly indicates a issue in OS abstraction.
150 * If it happens in a specific situation, please check the system resources (CPU load, memory usage...).
151 * If the issue can not be located, feel free to contact our support.
152 */
154 /**
155 * @brief Function is not available.
156 *
157 * This may be returned due to several conditions:
158 * - bRAWcap license does not include the requested feature.
159 * - The current machine does not support the feature.
160 * - Higher API registration privilege is required.
161 */
163 /**
164 * @brief At least one specified pointer parameter was invalid.
165 *
166 * This is a caller issue.
167 * Please check the provided pointers to solve this issue.
168 */
170 /**
171 * @brief At least one parameter content is invalid.
172 *
173 * This is a caller issue.
174 * Please check the provided parameters and their contents to solve this issue.
175 */
177 /**
178 * @brief At least one parameter is out of bounds.
179 *
180 * This is a caller issue.
181 * Please check if the provided parameters fit to the given parameter limitations.
182 */
184 /**
185 * @brief Given parameter not found.
186 *
187 * This is in general a caller issue.
188 * For example it can occur if the function expects a local adapter name and the
189 * provided name did not match any of the currently available adapters.
190 */
192 /**
193 * @brief Indicates that operation failed because the provided object is still in use.
194 *
195 * This may happen if another thread uses the same object or another operation for the object is still outstanding.
196 */
198 /**
199 * @brief The packet size is beyond adapter MTU.
200 *
201 * This status is especially for transmitted packets.
202 * It will be applied if the packet could not be transmitted because
203 * it´s length is beyond the configured adapter MTU.
204 */
206 /**
207 * @brief Communication with the driver failed.
208 *
209 * This indicates an error between library and driver communication.
210 *
211 * To fix such issues, make sure that the loaded library version matches with the driver version.
212 *
213 * In general it is not allowed to mix up library and driver versions.
214 * Applications shall always use the deployed bRAWcap library from the system
215 * and not deploy it´s own copy of it.
216 *
217 * If driver and library version matches and this error still occurs, please contact our support.
218 */
220 /**
221 * @brief bRAWcap is not activated (on a specific adapter).
222 *
223 * This will be returned if bRAWcap driver is not available (anymore)
224 * for the specified bRAWcap handle.
225 * For example if the driver was deactivated meanwhile.
226 */
228 /**
229 * @brief A buffer overrun was detected.
230 *
231 * This is the case if:
232 * - The provided buffer length was to short for the content.
233 * - A bRAWcap packet buffer has reached it´s "packet" capacity.
234 */
236 /**
237 * @brief Indicates that the BPF filter compilation failed.
238 *
239 * This can occur if the provided BPF filter string is invalid or cannot be compiled.
240 */
242 #endif
243
244 // WARNING (1 to 1999)
245 #if 1
246 /**
247 * @brief The operation was not executed due to demo mode limitations.
248 *
249 * This should only be returned if there is no valid license for the requested feature.
250 * For more information about demo limitation see chapter @ref demo-mode "Demo Mode" in the manual.
251 */
253 /**
254 * @brief Will be returned if another operation for the same resource is pending.
255 *
256 * This could be the case for functions which will initiate a receive/transmit while another
257 * receive/transmit is already pending on the specified handle.
258 * In general it is not allowed to use receive/transmits in parallel on the same handle.
259 * For example if a receive is @ref brawcap_rx_start "started", @ref brawcap_rx_packet cannot be used until the
260 * receive is @ref brawcap_rx_stop "stopped". Same applies to transmissions.
261 */
263 /**
264 * @brief Indicates that a bRAWcap limitation is reached.
265 *
266 * This could be the case if there are already max supported number of handles to the same adapter
267 * and the caller tries to open another one.
268 */
270 /**
271 * @brief Indicates that a operation was canceled.
272 *
273 * For example if a packet transmission was initiated and it is somehow canceled.
274 * This could be the case due to bRAWcap driver deactivation.
275 * If so this status will be applied for each packet which was canceled (not transmitted).
276 */
278 /**
279 * @brief Indicates that not all of the specified content/payload was processed.
280 *
281 * It will be returned for example if not all packets of a bRAWcap packet buffer was transmitted.
282 * If so the user should check the status of each packet inside the buffer for further information.
283 */
285 /**
286 * @brief Indicates that there is currently no uplink on the given adapter.
287 *
288 * It will be returned if the user tries to send packets to a adapter which has currently no uplink.
289 */
291 #endif
292
293 // INFO (2000 - 3999)
294 #if 1
295 /**
296 * @brief No operation running.
297 *
298 * This will be returned if the user tries to stop something which is currently not running.
299 * For example when trying to stop receiving while it is not running.
300 */
302 /**
303 * @brief Indicates that the given object is not attached.
304 *
305 * Will be returned for example if the user tries to detach a packet buffer
306 * which is currently not attached to a handle.
307 */
309 /**
310 * @brief Indicates that the given object is not registered.
311 *
312 * Will be returned if user tries to unregister from a bRAWcap notification
313 * which was not registered before.
314 */
316 /**
317 * @brief Indicates that the given object was already registered.
318 *
319 * Will be returned if user tries to register for something again
320 * which is already registered.
321 */
323 /**
324 * @brief Indicates that a function returns without any data.
325 *
326 * This could be the case if a receive function returns without any received packet.
327 * For example if the configured receive timeout is reached.
328 */
330 /**
331 * @brief Indicates that a function returned because of a timeout.
332 *
333 * This could be the case if a function has not finished it´s processing until a configured timeout is reached.
334 */
336 #endif
338
339/**@}*/
340#endif
341
342/************************************************* VERSION ***********************************************************/
343#if 1
344/**
345 * @example{lineno} 04_version_comparator_f.c
346 *
347 * This example shows how to read library (/API) and driver version of bRAWcap.
348 * After reading the versions it will check if both versions match.
349 */
350
351/**
352 * @defgroup brawcap_version Version
353 * @brief Types and functions for operating with bRAWcap version(s).
354 *
355 * Here our bRAWcap version structure is defined. This structure allows easy access to each part of the version
356 * and due to it´s union the complete value can be used for easy version compares.
357 *
358 * There are currently two functions to retrieve a version.
359 * One for the @ref brawcap_version_api "version of the loaded library" and another one for the
360 * @ref brawcap_version_driver "version of the loaded bRAWcap driver" on the machine.
361 *
362 * @attention In general both versions shall be equal.
363 * This means it is not allowed to deploy copys of the bRAWcap library with any application.
364 * Instead always the bRAWcap library from system path shall be used (which will be deployed by the bRAWcap setup).
365 * This avoids communication issues between the driver and the library.
366 * If there are any issues with driver communication, please check that the driver and library version matches.
367 *
368 * List of examples:
369 * 1. @ref 04_version_comparator_f.c "Version Comparator"
370 * @{
371 */
372
373/**
374 * @brief Struct containing the separated version parts.
375 */
376typedef struct _brawcap_version_fragments
377{
378 /**
379 * @brief Build version.
380 *
381 * Different for each build.
382 * Releases will always have different version by the upper three values.
383 * Versions with different build versions only should not appear.
384 * API and ABI always stays compatible between different build versions.
385 */
386 UINT16 build;
387 /**
388 * @brief Patch version.
389 *
390 * Different for each bugfix release.
391 * Will be increased if the release contains bugfixes only.
392 * API and ABI always stays compatible between different patch versions.
393 *
394 */
395 UINT16 patch;
396 /**
397 * @brief Minor version.
398 *
399 * Different for each minor release.
400 * Will be increased if the release contains new features (and maybe some bugfixes).
401 * API always stays compatible between different minor versions.
402 */
403 UINT16 minor;
404 /**
405 * @brief Major version.
406 *
407 * Different for each major release.
408 * Will be increased if for example some features have removed or changed in a way which would
409 * break the API compatibility.
410 * API compatibility between different major versions is not guaranteed.
411 */
412 UINT16 major;
414
415/**
416 * @brief bRAWcap version.
417 *
418 * The version is implemented as a union. The complete member allows easy compare between versions.
419 * While the fragments allow easy access to each version part (major, minor, patch, build).
420 */
421typedef union _brawcap_version
422{
423 brawcap_version_fragments_t fragments; /*!< Separated parts of the version.*/
424 UINT64 complete; /*!< Complete version as integer. Use this for comparing versions. */
426
427/**@}*/
428#endif
429
430/*********************************************** TIMESTAMP ***********************************************************/
431#if 1
432/**
433 * @defgroup brawcap_timestamp Timestamp
434 * @brief Types and functions for operating with bRAWcap timestamps.
435 *
436 * At the moment it is not possible to create a standalone @ref brawcap_timestamp_t "timestamp object".
437 * Instead a timestamp is always part of a @ref brawcap_packet "packet".
438 * To get the timestamp object use @ref brawcap_packet_timestamp_get on a specific packet.
439 * This object can be used than for all functions in this module.
440 *
441 * @attention The user application shall never store a timestamp, instead it should always request it from
442 * a packet and only use it as long as the packet itself is valid.
443 *
444 * List of examples:
445 * 1. @ref 08_receive_timestamp_inspector_f.c "Receive Timestamp Inspector"
446 * 2. @ref 05_receive_simple_packet_receiver_f.c "Simple Packet Receiver"
447 * @{
448 */
449
450/**
451 * @brief Checks if timestamp mode @ref BRAWCAP_TIMESTAMP_MODE_SYSTEM_LOWPREC "system low precision" is supported.
452 */
453#define BRAWCAP_TIMESTAMP_MODE_SYSL_AVAILABLE(_capabilities) (_capabilities & 0x01)
454
455/**
456 * @brief Checks if timestamp mode @ref BRAWCAP_TIMESTAMP_MODE_SYSTEM_HIGHPREC "system high precision" is supported.
457 */
458#define BRAWCAP_TIMESTAMP_MODE_SYSH_AVAILABLE(_capabilities) (_capabilities & 0x02)
459
460/**
461 * @brief Checks if timestamp mode @ref BRAWCAP_TIMESTAMP_MODE_SOFTWARE "software" is supported.
462 */
463#define BRAWCAP_TIMESTAMP_MODE_SW_AVAILABLE(_capabilities) (_capabilities & 0x04)
464
465/**
466 * @brief Checks if timestamp mode @ref BRAWCAP_TIMESTAMP_MODE_ADAPTER_SYSTEM "adapter system" is supported.
467 */
468#define BRAWCAP_TIMESTAMP_MODE_ADAPTER_SYS_AVAILABLE(_capabilities) (_capabilities & 0x08)
469
470/**
471 * @brief Checks if timestamp mode @ref BRAWCAP_TIMESTAMP_MODE_ADAPTER_SOFTWARE "adapter software" is supported.
472 */
473#define BRAWCAP_TIMESTAMP_MODE_ADAPTER_SW_AVAILABLE(_capabilities) (_capabilities & 0x10)
474
475/**
476 * @brief Checks if timestamp mode @ref BRAWCAP_TIMESTAMP_MODE_ADAPTER_HARDWARE "adapter hardware" is supported.
477 */
478#define BRAWCAP_TIMESTAMP_MODE_ADAPTER_HW_AVAILABLE(_capabilities) (_capabilities & 0x20)
479
480/**
481 * @brief If a timestamp resolution is set to this value,
482 * it´s resolution is unknown - could not be resolved.
483 *
484 * For example this can be the case for adapter hardware timestamps,
485 * if the adapter does not report it´s clock frequency.
486 */
487#define BRAWCAP_TIMESTAMP_RESOLUTION_UNKNOWN 0
488
489/**
490 * @brief Number of nanoseconds per second.
491 */
492#define BRAWCAP_TIMESTAMP_NS_PER_SEC 1000000000
493
494/**
495 * @brief Number of microseconds per second.
496 */
497#define BRAWCAP_TIMESTAMP_US_PER_SEC 1000000
498
499/**
500 * @brief Number of milliseconds per second.
501 */
502#define BRAWCAP_TIMESTAMP_MS_PER_SEC 1000
503
504/**
505 * @brief Number of nanoseconds per microsecond.
506 */
507#define BRAWCAP_TIMESTAMP_NS_PER_US 1000
508
509/**
510 * @brief Number of nanoseconds per millisecond.
511 */
512#define BRAWCAP_TIMESTAMP_NS_PER_MS 1000000
513
514
515/**
516 * @brief Type used for indicating the supported timestamp modes.
517 *
518 * It has to be interpreted as bitfield.
519 */
521
522/**
523 * @brief Represents the timestamp resolution in nanoseconds.
524 *
525 * The resolution can be used to check how accurate a timestamp is.
526 * For example if it is set to 1.000.000 ns the timestamp has a accuracy of "only" one millisecond.
527 * If it is set to 1 ns instead, it would indicate a very precise timestamp with a resolution of one nanosecond.
528 */
530
531/**
532 * @brief List of different timestamp modes.
533 *
534 * The mode of a timestamp can be used to check when the timestamp is generated (time of trigger).
535 * It can also indicate how accurate a timestamp is.
536 *
537 * Description for the different timestamp types:
538 * - System timestamps:
539 * - Less accurate
540 * - Jumps if the system time itself is jumping.
541 * - Source is the system time
542 * - Software timestamps:
543 * - Good accuracy
544 * - Guaranteed to not jump.
545 * - Source is almost ever the local TSC (if the CPU supports it).
546 * If not Windows will take the next accurate source for it.
547 * For more information on QPC, please see the official
548 * <a href=https://learn.microsoft.com/en-us/windows/win32/sysinfo/acquiring-high-resolution-time-stamps> Microsoft documentation </a>.
549 * - They will always start from zero and increase with system up time.
550 * - Hardware timestamps:
551 * - Highest accuracy because they are not influenced by the system.
552 * - Only jumps if the adapter hardware clock jumps.
553 * - Source is the adapter hardware clock.
554 *
555 * @note Adapter timestamps are features provided by the underlying adapter and not part of bRAWcap.
556 * bRAWcap only provides those timestamps if the underlying adapter supports it.
557 * To check if the underlying adapter supports them use
558 * - @ref brawcap_rx_timestamp_capabilities for receive timestamps
559 * - @ref brawcap_tx_timestamp_capabilities for transmit timestamps
560 *
561 * @note More accurate system or software timestamps can increase the overall CPU load a bit.
562 * These differences can be neglected in most cases, but if the user is not interested in high-precision timestamps,
563 * always timestamps that require less effort should be preferred.
564 *
565 * @note Trigger position for timestamps created by bRAWcap driver:
566 * - Receive: When the packet is recognized by the bRAWcap driver (forwarded from the underlying driver)
567 * - Transmit: When the transmission complete event is recognized by the bRAWcap driver
568 */
569typedef enum _brawcap_timestamp_mode
570{
571 /**
572 * @brief No timestamp.
573 */
575 /**
576 * @brief A low precision system timestamp created by bRAWcap driver.
577 */
579 /**
580 * @brief A high precision system timestamp created by bRAWcap driver.
581 */
583 /**
584 * @brief A software timestamp created by bRAWcap driver.
585 */
587 /**
588 * @brief A system timestamp created by the network adapter driver.
589 */
591 /**
592 * @brief A software timestamp created by the network adapter driver.
593 */
595 /**
596 * @brief A hardware timestamp created by the network adapter hardware/firmware.
597 */
600
601/**
602 * @brief bRAWcap timestamp object.
603 *
604 * The timestamp object is part of each @ref brawcap_packet "packet" and
605 * has to be used for each timestamp module function.
606 * To get a timestamp object from a packet use @ref brawcap_packet_timestamp_get.
607 */
608typedef struct _brawcap_timestamp brawcap_timestamp_t;
609
610/**@}*/
611#endif
612
613/************************************************ PACKET *************************************************************/
614#if 1
615/**
616 * @defgroup brawcap_packet Packet
617 * @brief Types and functions for operating with bRAWcap packets.
618 *
619 * To create a packet use @ref brawcap_packet_create.
620 * If a packet is not required anymore it shall be deleted with @ref brawcap_packet_free.
621 *
622 * @note It is also possible to use "buffered" packets. Those packets must not be created and freed on their one.
623 * Instead they are part of a @ref brawcap_buffer "packet buffer". To access buffered packets use
624 * @ref brawcap_buffer_at_index to get a packet on a specific position of the buffer or
625 * @ref brawcap_buffer_iterator_eval on a @ref brawcap_buffer_iterator_t "packet buffer iterator".
626 * The second one is especially useful while iterating the buffer.
627 *
628 * @attention The user application shall never store buffered packets separately.
629 * Instead it should always request packets directly from the packet buffer and only use them as long as the packet
630 * buffer itself is valid.
631 *
632 * List of examples:
633 * 1. @ref 05_receive_simple_packet_receiver_f.c "Simple Packet Receiver"
634 * 2. @ref 07_receive_buffered_receiver_f.c "Buffered Receiver"
635 * 3. @ref 08_receive_timestamp_inspector_f.c "Receive Timestamp Inspector"
636 *
637 * @{
638 */
639
640/**
641 * @brief The maximum supported (byte) size for a single packet payload.
642 *
643 * This value corresponds to jumbo frame size (9000 Bytes) + Ethernet header (14 Bytes) + single VLAN header (4 Bytes).
644 */
645#define BRAWCAP_PACKET_SIZE_MAX 9018
646
647/**
648 * @brief The minimum required (byte) size for a single packet payload.
649 *
650 * This corresponds to Ethernet header size.
651 *
652 * @note The Ethernet standard defines a minimum packet length of 64 Bytes (including 4 Byte for Ethernet FCS).
653 * If smaller packets are sent the network adapter will automatically add some padding at the end of the payload.
654 * The padding contains zeros only and after the last padding/payload byte the Ethernet FCS will be added.
655 */
656#define BRAWCAP_PACKET_SIZE_MIN 14
657
658/**
659 * @brief Type for handling the number of payload bytes per packet.
660 *
661 * Typically the packet payload size is set to the adapters max transmission unit (MTU) size + Ethernet header size
662 * and maybe a single VLAN header.
663 * Packet payload sizes have to be between @ref BRAWCAP_PACKET_SIZE_MIN and @ref BRAWCAP_PACKET_SIZE_MAX,
664 * values below/beyond are not accepted.
665 */
667
668/**
669 * @brief bRAWcap packet object.
670 *
671 * The packet object has to be used for each packet module function.
672 * Packet objects can be @ref brawcap_packet_create "created" and @ref brawcap_packet_free "freed"
673 * or retrieved from a @ref brawcap_buffer "packet buffer".
674 */
675typedef struct _brawcap_packet brawcap_packet_t;
676
677/**@}*/
678#endif
679
680/************************************************* BUFFER *************************************************************/
681#if 1
682/**
683 * @example{lineno} 12_buffer_sorting_f.c
684 *
685 * This example shows how to create a bRAWcap packet buffer, fill it with packets,
686 * sort the packets inside the buffer by their timestamp or payload and verify the sorting.
687 */
688
689/**
690 * @defgroup brawcap_buffer Packet Buffer
691 * @brief Types and functions for operating with bRAWcap packet buffers.
692 *
693 * To create a new packet buffer use @ref brawcap_buffer_create.
694 * If a packet buffer is not required anymore it shall be deleted with @ref brawcap_buffer_free.
695 *
696 * Packet buffers can be used for
697 * - Receiving:
698 * To use a buffer for receiving on a bRAWcap handle it has to be @ref brawcap_rx_buffer_attach "attached" to it.
699 * If it shall not be used anymore for receiving it should be @ref brawcap_rx_buffer_detach "detached".
700 *
701 * - Transmitting:
702 * For transmitting a packet buffer, fill up the buffer with packets and than @ref brawcap_tx_buffer_send "send"
703 * it on a handle. This will place the buffer into the transmission queue of the specified handle.
704 *
705 * @attention The packet buffer will be locked down after attaching/sending to a specific handle.
706 * This means that it cannot be accessed by user application as long as it is pending for transmission or attached for
707 * receiving. If the user application tries to access a locked buffer a error will be returned by the specific
708 * packet buffer function.
709 *
710 * A packet buffer can be accessed if:
711 * - It is not attached for receiving.
712 * - No transmission is pending.
713 * - While receiving - from inside the @ref brawcap_rx_callback_t "receive callback".
714 * - While transmitting - from inside the @ref brawcap_tx_callback_t "transmit callback".
715 *
716 * List of examples:
717 * 1. @ref 07_receive_buffered_receiver_f.c "Buffered Receiver"
718 * 2. @ref 12_buffer_sorting_f.c "Buffer Sorting"
719 * @{
720 */
721
722/**
723 * @brief The maximum amount of packets, which can be stored in a packet buffer.
724 */
725#define BRAWCAP_BUFFER_PACKETS_MAX 100000
726
727/**
728 * @brief The minimum amount of packets, which a packet buffer must have.
729 */
730#define BRAWCAP_BUFFER_PACKETS_MIN 1
731
732/**
733 * @brief Type for handling the number of packets which can be stored in a packet buffer.
734 *
735 * The total amount of packets per packet buffer has to be between @ref BRAWCAP_BUFFER_PACKETS_MIN -
736 * @ref BRAWCAP_BUFFER_PACKETS_MAX.
737 */
739
740/**
741 * @brief bRAWcap packet buffer object.
742 *
743 * The packet buffer object has to be used for each packet buffer module function.
744 * Packet buffers can be @ref brawcap_buffer_create "created" and @ref brawcap_buffer_free "freed".
745 */
746typedef struct _brawcap_buffer brawcap_buffer_t;
747
748/********************************************* BUFFER ITERATOR ********************************************************/
749#if 1
750/**
751 * @defgroup brawcap_buffer_iterator Packet Buffer Iterator
752 * @brief bRAWcap packet buffer iterators.
753 *
754 * To create a new packet buffer iterator use @ref brawcap_buffer_iterator_create.
755 * If a packet buffer iterator is not required anymore it shall be deleted with @ref brawcap_buffer_iterator_free.
756 *
757 * @note Iterators should only be used as long as the packet buffer for which it was created is still available.
758 *
759 * @attention Packet buffer iterators are not synchronized. This means that if the packet buffer for which the iterator
760 * was created is modified meanwhile, the iterator is not updated.
761 *
762 * List of examples:
763 * 1. @ref 07_receive_buffered_receiver_f.c "Buffered Receiver"
764 * @{
765 */
766
767/**
768 * @brief bRAWcap packet buffer iterator object.
769 *
770 * The packet buffer object has to be used for each packet buffer iterator module function.
771 * Packet buffer iterators can be @ref brawcap_buffer_iterator_create "created" and @ref brawcap_buffer_iterator_free
772 * "freed".
773 */
774typedef struct _brawcap_buffer_iterator brawcap_buffer_iterator_t;
775
776/**@}*/
777#endif
778
779/**@}*/
780#endif
781
782/************************************************** ADAPTER **********************************************************/
783#if 1
784/**
785 * @example{lineno} 01_adapter_property_reader_f.c
786 *
787 * This example shows how to get all currently available adapters on the machine.
788 * And how to get the properties for each adapter.
789 * The adapters and their properties will be printed to command line output.
790 *
791 * @attention This example requires a valid bRAWcap license.
792 * Reading adapter properties is not part of the demo.
793 */
794
795/**
796 * @example{lineno} 02_adapter_change_notifier_f.c
797 *
798 * This example shows how to register and handle adapter change notifications.
799 * It will print each received notification to command line.
800 * Each output will also include the change reason and the new adapter property value.
801 *
802 * @attention This example requires a valid bRAWcap license.
803 * Reading adapter properties is not part of the demo.
804 */
805
806/**
807 * @defgroup brawcap_adapter Adapter
808 * @brief Types and functions for handling bRAWcap (Ethernet) adapters.
809 *
810 * This module provides many features that facilitate the detection of bRAWcap (Ethernet) adapters.
811 * It allows to scan the local machine for available and supported adapters,
812 * to resolve many useful adapter properties for each adapter and also an adapter change notification.
813 *
814 * Adapter change notifications inform your application directly when any of the available properties have changed,
815 * or when a new adapter has been found or an existing one has been removed (e.g. by disabling the interface).
816 *
817 * When you use these functions, they make all calls to the Windows API - related to adapter handling - obsolete.
818 *
819 * List of examples:
820 * 1. @ref 01_adapter_property_reader_f.c "Adapter Property Reader"
821 * 2. @ref 02_adapter_change_notifier_f.c "Adapter Change Notifier"
822 * @{
823 */
824
825/**@}*/
826#endif
827
828/************************************************** RECEIVE **********************************************************/
829#if 1
830/**
831 * @example{lineno} 05_receive_simple_packet_receiver_f.c
832 *
833 * This example shows how to use the bRAWcap single packet receive feature.
834 * It opens a handle to the first available bRAWcap adapter, creates a bRAWcap packet
835 * to store received data to. For each received packet it will print the packet information to console.
836 */
837
838/**
839 * @example{lineno} 07_receive_buffered_receiver_f.c
840 *
841 * This example shows how to use the bRAWcap single packet receive feature.
842 * It opens a handle to the first available bRAWcap adapter, creates a bRAWcap packet
843 * to store received data to. For each received packet it will print the packet information to console.
844 */
845
846/**
847 * @example{lineno} 08_receive_timestamp_inspector_f.c
848 *
849 * This example shows how to configure the different timestamp modes and read timestamp information from single
850 * received packets.
851 * It opens a handle to the first available bRAWcap adapter, creates a bRAWcap packet
852 * to store received data to and applies the configured timestamp mode. For each received packet it will print
853 * it´s applied timestamp info.
854 */
855
856/**
857 * @defgroup brawcap_receive Receive
858 * @brief Types and functions for bRAWcap receiving.
859 *
860 * List of examples:
861 * 1. @ref 05_receive_simple_packet_receiver_f.c "Simple Packet Receiver"
862 * 2. @ref 07_receive_buffered_receiver_f.c "Buffered Receiver"
863 * 3. @ref 08_receive_timestamp_inspector_f.c "Timestamp Inspector"
864 * @{
865 */
866
867/********************************************** RECEIVE FILTER *******************************************************/
868#if 1
869/**
870 * @example{lineno} 06_filter_firewall_f.c
871 *
872 * This example shows how bRAWcap can be used to filter (discard) specific packets by using a byte filter.
873 */
874
875/**
876 * @example{lineno} 11_filter_bpf_f.c
877 *
878 * This example shows how bRAWcap can be used to filter (discard) specific packets by using a BPF (Berkley Packet Filter).
879 */
880
881/**
882 * @defgroup brawcap_filter Receive Filter
883 * @brief Types and functions for operating with bRAWcap receive filters.
884 *
885 * To create a new filter use @ref brawcap_filter_create.
886 * If a filter is not required anymore it shall be deleted with @ref brawcap_filter_free.
887 *
888 * @note Applying filters to handles:<br>
889 * Each bRAWcap handle has it´s own filter instance.
890 * Therefore after applying the filter to a bRAWcap handle the filter may be reused to apply the
891 * same (or a different) filter to another handle or freed if not required anymore.
892 *
893 * List of examples:
894 * 1. @ref 06_filter_firewall_f.c "Firewall"
895 * 2. @ref 11_filter_bpf_f.c "BPF"
896 * @{
897 */
898
899/**
900 * @brief The maximum supported filter byte mask length in bytes.
901 */
902#define BRAWCAP_FILTER_BYTE_MAX_LENGTH 64U
903
904/**
905 * @brief Fixed size array for storing a filter byte mask.
906 *
907 * @note It is not necessary to set all bytes.
908 * If the used filter does not require the complete mask length.
909 * bRAWcap evaluates only the bytes up to the specified filter length.
910 */
912
913/**
914 * @brief Fixed size array for storing a byte wise bitfield.
915 *
916 * This allows to ignore specific bits in the specified filter byte mask.
917 * Each bit which is set to one is ignored in the filter byte mask.
918 *
919 * @note It is not necessary to set all bytes.
920 * If the used filter does not require the complete mask length.
921 * bRAWcap evaluates only the bytes up to the specified filter length.
922 */
924
925/**
926 * @brief Type for specifying the byte filter length.
927 */
929
930/**
931 * @brief List of filter types.
932 *
933 * @note Currently only the byte filter is supported.
934 * A BPF (Berkley Packet Filter) filter, which is equivalent to the one which libpcap uses,
935 * may be added in the future.
936 */
937typedef enum _brawcap_filter_type
938{
939 /**
940 * @brief A bRAWcap byte filter.
941 */
943 /**
944 * @brief A Berkley Packet Filter.
945 */
947 /**
948 * @brief No filter.
949 */
952
953/**
954 * @brief bRAWcap filter object.
955 *
956 * The filter object can be accessed with the bRAWcap filter functions.
957 * Filters can be @ref brawcap_filter_create "created" and @ref brawcap_filter_free "freed".
958 */
959typedef struct _brawcap_filter brawcap_filter_t;
960
961/**@}*/
962#endif
963
964/**
965 * @brief Default minimum packets to copy value which has to be received before any receive function return
966 * even if configured timeout exceeds.
967 *
968 * @note bRAWcap waits at least up to 10 times the configured timeout before finally returning if
969 * the minimum number of packets has not yet been received.
970 *
971 * @warning If a timeout of zero which is equivalent to infinite wait is configured it blocks until
972 * the minimum amount of packets are received and will not return earlier.
973 */
974#define BRAWCAP_RX_COPY_PACKETS_DEFAULT 0
975
976/**
977 * @brief Default timeout in milliseconds after which a bRAWcap receive returns,
978 * even if buffer is not yet full but the configured receive min packets to copy must be reached.
979 */
980#define BRAWCAP_RX_TIMEOUT_MS_DEFAULT 10
981
982/**
983 * @brief Default receive timestamp mode which will be used.
984 */
985#define BRAWCAP_RX_TIMESTAMP_MODE_DEFAULT BRAWCAP_TIMESTAMP_MODE_SYSTEM_LOWPREC
986
987/**
988 * @brief Default VLAN tagging mode which will be used.
989 */
990#define BRAWCAP_RX_VLAN_TAGGING_DEFAULT FALSE
991
992/**
993 * @brief Default size for driver receive queues in number of packets.
994 */
995#define BRAWCAP_RX_DRIVER_QUEUE_SIZE_DEFAULT 4096
996
997/**
998 * @brief Maximum supported receive timeout in number of milliseconds.
999 */
1000#define BRAWCAP_RX_TIMEOUT_MS_MAX 5000
1001
1002/**
1003 * @brief Maximum size (in number of packets) supported for driver receive queues.
1004 */
1005#define BRAWCAP_RX_DRIVER_QUEUE_SIZE_MAX 40000
1006
1007/**
1008 * @brief Default receive direction which will be used.
1009 */
1010#define BRAWCAP_RX_DIRECTION_DEFAULT BRAWCAP_RX_DIRECTION_BOTH
1011
1012/**
1013 * @brief Type for handling receive timeouts in number of milliseconds.
1014 * The timeout specifies the maximum blocking time in milliseconds for pending bRAWcap receives.
1015 * If a packet is received or the receive buffer is full before the timeout is reached, receive will return earlier.
1016 *
1017 * @attention A receive timeout value of zero corresponds to an infinite wait.
1018 * This means that bRAWcap receive will only return if
1019 * - @ref brawcap_rx_packet - a packet is received,
1020 * - @ref brawcap_rx_start - the minimum amount of packets to copy is reached (see @ref brawcap_rx_min_packets_t)
1021 * or the attached buffer is full - whichever comes first.
1022 */
1024
1025/**
1026 * @brief Type for handling the minimum amount of packets to copy before a bRAWcap receive will return.
1027 * It specifies how many packets should be received before a pending receive returns.
1028 * Reading more packets in a single call can improve the performance but leads to higher latency.
1029 *
1030 * @note This setting is only used with looped receive (@ref brawcap_rx_start) and has no impact on single packet
1031 * reception (@ref brawcap_rx_packet).
1032 */
1034
1035/**
1036 * @brief List of receive modes.
1037 */
1038typedef enum _brawcap_rx_mode
1039{
1040 /**
1041 * @brief Received packets are stored in a user created bRAWcap packet (buffer) and provided to the
1042 * calling application for processing.
1043 */
1045 /**
1046 * @brief Received packets are directly written to disk.
1047 *
1048 * @note Dumping mode is not yet supported and may be added to later releases.
1049 */
1052
1053/**
1054 * @brief List of supported receive directions.
1055 *
1056 * The receive direction allows the select for which direction (transmit/receive) the packets shall be captured.
1057 * This setting can be seen as some kind of generic receive filter.
1058 */
1059typedef enum _brawcap_rx_direction
1060{
1061 /**
1062 * @brief Stops to receive packets of any direction.
1063 */
1065 /**
1066 * @brief Only received packets by the network adapter will be received.
1067 */
1069 /**
1070 * @brief Only transmitted packets by bRAWcap or upper network stack drivers will be received.
1071 * This allows some kind of loopback for packets which are transmitted to the network.
1072 *
1073 * @note This currently does not include packets sent to localhost (IP 127.0.0.1), because they are
1074 * not transmitted/received via a real network adapter. Instead Windows creates a separate "virtual" adapter
1075 * for localhost communication. This adapter is currently not supported by bRAWcap.
1076 */
1078 /**
1079 * @brief Both transmitted packets by bRAWcap or upper network stack drivers and received packets from the
1080 * underlying network adapter will be received.
1081 */
1084
1085/**@}*/
1086#endif
1087
1088/************************************************* TRANSMIT **********************************************************/
1089#if 1
1090/**
1091 * @example{lineno} 10_transmit_buffered_transmitter_f.c
1092 *
1093 * This example shows how to use bRAWcap to transmit packets using a buffered approach.
1094 *
1095 * The example demonstrates how to create a buffer, fill it with packets, and transmit the entire buffer over the network.
1096 * The buffered approach allows for more efficient transmission of multiple packets at once.
1097 */
1098
1099
1100/**
1101 * @defgroup brawcap_transmit Transmit
1102 * @brief Types and functions for bRAWcap transmitting.
1103 *
1104 * List of examples:
1105 * 2. @ref 10_transmit_buffered_transmitter_f.c "Buffered Packet Transmitter"
1106 * @{
1107 */
1108
1109/**
1110 * @brief Default size in number of packets for driver transmit queues.
1111 */
1112#define BRAWCAP_TX_DRIVER_QUEUE_SIZE_DEFAULT 512
1113
1114/**
1115 * @brief Minimum size in number of packets supported for driver transmit queues.
1116 */
1117#define BRAWCAP_TX_DRIVER_QUEUE_SIZE_MIN 256
1118
1119/**
1120 * @brief Maximum size in number of packets supported for driver transmit queues.
1121 */
1122#define BRAWCAP_TX_DRIVER_QUEUE_SIZE_MAX 4096
1123
1124/**
1125 * @brief Default timestamp mode for transmitted packets.
1126 */
1127#define BRAWCAP_TX_TIMESTAMP_MODE_DEFAULT BRAWCAP_TIMESTAMP_MODE_NO_TIMESTAMP
1128
1129/**@}*/
1130#endif
1131
1132/*************************************************** STATS ***********************************************************/
1133#if 1
1134/**
1135 * @defgroup brawcap_stats Statistics
1136 * @brief Types and functions for bRAWcap statistics.
1137 * @{
1138 */
1139
1140/**
1141 * @internal
1142 * @brief Returns the offset from the first member to the last member in number of bytes.
1143*/
1144#define _BRAWCAP_LAST_M_OFFSET(type, lastMember) ((LONG)(LONG_PTR)&(((type *)0)->lastMember))
1145/**
1146 * @internal
1147 * @brief Returns the size of the last member in number of bytes.
1148 */
1149#define _BRAWCAP_LAST_M_SIZE(type, lastMember) (sizeof(((type *)0)->lastMember))
1150/**
1151 * @internal
1152 * @brief Returns the total byte size of the structure, depending on the structure and its last member.
1153 * @warning It is very important to always update the lastMember if the struct is going to be extended.
1154 */
1155#define _BRAWCAP_SIZEOF_STRUCT(type, lastMember) \
1156 (_BRAWCAP_LAST_M_OFFSET(type, lastMember) + _BRAWCAP_LAST_M_SIZE(type, lastMember))
1157
1158/**
1159 * @internal
1160 * @brief Indicates if the @ref brawcap_stats_rx_t.adapterReceivedPacketsTotal member of the receive stats is valid.
1161 * @endinternal
1162 */
1163#define _BRAWCAP_STATS_RX_ADAPTER_RECEIVED_PACKETS_TOTAL_VALID 0x00000001
1164/**
1165 * @brief Indicates if the @ref brawcap_stats_rx_t.adapterReceivedPacketsTotal member of the given receive stats is
1166 * valid. This statistic is provided from the underlying network adapter driver and may be supported or not.
1167 */
1168#define BRAWCAP_STATS_RX_ADAPTER_RECEIVED_PACKETS_TOTAL_VALID(__stats_rx) \
1169 (__stats_rx.adapterValid & _BRAWCAP_STATS_RX_ADAPTER_RECEIVED_PACKETS_TOTAL_VALID)
1170/**
1171 * @internal
1172 * @brief Indicates if the @ref brawcap_stats_rx_t.adapterReceivedBytesTotal member of the receive stats is valid.
1173 * @endinternal
1174 */
1175#define _BRAWCAP_STATS_RX_ADAPTER_RECEIVED_BYTES_TOTAL_VALID 0x00000002
1176/**
1177 * @brief Indicates if the @ref brawcap_stats_rx_t.adapterReceivedBytesTotal member of the given receive stats is valid.
1178 * This statistic is provided from the underlying network adapter driver and may be supported or not.
1179 */
1180#define BRAWCAP_STATS_RX_ADAPTER_RECEIVED_BYTES_TOTAL_VALID(__stats_rx) \
1181 (__stats_rx.adapterValid & _BRAWCAP_STATS_RX_ADAPTER_RECEIVED_BYTES_TOTAL_VALID)
1182/**
1183 * @internal
1184 * @brief Indicates if the @ref brawcap_stats_rx_t.adapterDroppedPacketsTotal member of the receive stats is valid.
1185 * @endinternal
1186 */
1187#define _BRAWCAP_STATS_RX_ADAPTER_DROPPED_PACKETS_TOTAL_VALID 0x00000004
1188/**
1189 * @brief Indicates if the @ref brawcap_stats_rx_t.adapterDroppedPacketsTotal member of the given receive stats is
1190 * valid. This statistic is provided from the underlying network adapter driver and may be supported or not.
1191 */
1192#define BRAWCAP_STATS_RX_ADAPTER_DROPPED_PACKETS_TOTAL_VALID(__stats_rx) \
1193 (__stats_rx.adapterValid & _BRAWCAP_STATS_RX_ADAPTER_DROPPED_PACKETS_TOTAL_VALID)
1194
1195/**
1196 * @internal
1197 * @brief Indicates if the @ref brawcap_stats_tx_t.adapterCompletedPacketsTotal member of the transmit stats is valid.
1198 * @endinternal
1199 */
1200#define _BRAWCAP_STATS_TX_ADAPTER_COMPLETED_PACKETS_TOTAL_VALID 0x00000001
1201/**
1202 * @brief Indicates if the @ref brawcap_stats_tx_t.adapterCompletedPacketsTotal member of the given transmit stats is
1203 * valid. This statistic is provided from the underlying network adapter driver and may be supported or not.
1204 */
1205#define BRAWCAP_STATS_TX_ADAPTER_COMPLETED_PACKETS_TOTAL_VALID(__stats_tx) \
1206 (__stats_tx.adapterValid & _BRAWCAP_STATS_TX_ADAPTER_COMPLETED_PACKETS_TOTAL_VALID)
1207/**
1208 * @internal
1209 * @brief Indicates if the @ref brawcap_stats_tx_t.adapterCompletedBytesTotal member of the transmit stats is valid.
1210 * @endinternal
1211 */
1212#define _BRAWCAP_STATS_TX_ADAPTER_COMPLETED_BYTES_TOTAL_VALID 0x00000002
1213/**
1214 * @brief Indicates if the @ref brawcap_stats_tx_t.adapterCompletedBytesTotal member of the given transmit stats is
1215 * valid. This statistic is provided from the underlying network adapter driver and may be supported or not.
1216 */
1217#define BRAWCAP_STATS_TX_ADAPTER_COMPLETED_BYTES_TOTAL_VALID(__stats_tx) \
1218 (__stats_tx.adapterValid & _BRAWCAP_STATS_TX_ADAPTER_COMPLETED_BYTES_TOTAL_VALID)
1219/**
1220 * @internal
1221 * @brief Indicates if the @ref brawcap_stats_tx_t.adapterCanceledPacketsTotal member of the transmit stats is valid.
1222 * @endinternal
1223 */
1224#define _BRAWCAP_STATS_TX_ADAPTER_CANCELED_PACKETS_TOTAL_VALID 0x00000004
1225/**
1226 * @brief Indicates if the @ref brawcap_stats_tx_t.adapterCanceledPacketsTotal member of the given transmit stats is
1227 * valid. This statistic is provided from the underlying network adapter driver and may be supported or not.
1228 */
1229#define BRAWCAP_STATS_TX_ADAPTER_CANCELED_PACKETS_TOTAL_VALID(__stats_tx) \
1230 (__stats_tx.adapterValid & _BRAWCAP_STATS_TX_ADAPTER_CANCELED_PACKETS_TOTAL_VALID )
1231
1232/**
1233 * @brief Header describing given bRAWcap stats structure.
1234 *
1235 * @attention If your create a new bRAWcap stats structure you must always initialize
1236 * the header first before make use of it.
1237 * This is required to allow backward compatibility for applications using older versions.
1238 */
1239typedef struct _brawcap_stats_header
1240{
1241 /**
1242 * @brief Indicates which type of stats it is.
1243 */
1244 BYTE type;
1245 /**
1246 * @brief Indicates the revision of the stats.
1247 * @note It is preferred to always use the latest version available in your bRAWcap header file.
1248 * But you can also use older versions if you dont want to access members added in the newer versions.
1249 */
1251 /**
1252 * @brief Should be set to the size of the structure depending on it´s type and revision.
1253 * You should use the BRAWCAP_STATS_..._SIZEOF_REVISION_X macros for initializing this member.
1254 */
1255 UINT16 size;
1257
1258/**
1259 * @brief List of all available statistic types.
1260 */
1261typedef enum _brawcap_stats_type
1262{
1263 /**
1264 * @brief Type for receive stats.
1265 */
1267 /**
1268 * @brief Type for transmit stats.
1269 */
1272
1273/**
1274 * @brief List of all available receive statistic revisions.
1275 */
1276typedef enum _brawcap_stats_rx_revision
1277{
1278 /**
1279 * @brief Revision 1 for receive stats.
1280 */
1283
1284/**
1285 * @brief The bRAWcap receive statistics.
1286 *
1287 * This can be used to retrieve all available bRAWcap statistics and counters related to receive path.
1288 * After creating the structure, its header has to be initialized.
1289 *
1290 * The @ref brawcap_stats_header_t.type shall be set to @ref BRAWCAP_STATS_TYPE_RX.
1291 *
1292 * The @ref brawcap_stats_header_t.revision shall be set to one of the following values:
1293 * - @ref BRAWCAP_STATS_RX_REVISION_1
1294 *
1295 * The @ref brawcap_stats_header_t.size shall be set depending on your selected version by using the macro:
1296 * - @ref BRAWCAP_STATS_RX_SIZEOF_REVISION_1 (if selected revision is @ref BRAWCAP_STATS_RX_REVISION_1)
1297 *
1298 * @attention User is responsible for initializing the structure header before using it.
1299 * Otherwise it may lead to undefined behaviour.
1300 */
1301typedef struct _brawcap_stats_rx
1302{
1303 /**
1304 * @brief Header for receive statistics.
1305 * This has to be always initialized by the user after creation before using it.
1306 */
1308 /**
1309 * @brief Bitfield indicating which counters provided by the underlying network adapter driver are valid.
1310 */
1312 /**
1313 * @brief Total number of received packets by the underlying network adapter.
1314 * @note You should check if the network adapter supports this counter with
1315 * @ref BRAWCAP_STATS_RX_ADAPTER_RECEIVED_PACKETS_TOTAL_VALID.
1316 * If the counter is not supported it will be always zero.
1317 */
1319 /**
1320 * @brief Total number of received bytes by the underlying network adapter.
1321 * @note You should check if the network adapter supports this counter with
1322 * @ref BRAWCAP_STATS_RX_ADAPTER_RECEIVED_BYTES_TOTAL_VALID.
1323 * If the counter is not supported it will be always zero.
1324 */
1326 /**
1327 * @brief Total number of received bytes by the underlying network adapter.
1328 * @note You should check if the network adapter supports this counter with
1329 * @ref BRAWCAP_STATS_RX_ADAPTER_DROPPED_PACKETS_TOTAL_VALID.
1330 * If the counter is not supported it will be always zero.
1331 */
1333 /**
1334 * @brief The total number of indicated packets to the upper network stack by bRAWcap on the corresponding adapter.
1335 * @note This counter will reset if bRAWcap driver is restarted, or it is deactivated on the adapter.
1336 */
1338 /**
1339 * @brief The total number of received packets by bRAWcap on the corresponding adapter.
1340 * @note This counter will reset if bRAWcap driver is restarted, or it is deactivated on the adapter..
1341 */
1343 /**
1344 * @brief The total number of received packets by the given bRAWcap handle.
1345 * @note This counter relates to a handle and will be deleted when the handle is closed.
1346 */
1348 /**
1349 * @brief The total number of packets which have matched the given bRAWcap handle filter.
1350 * @note This counter relates to a handle and will be deleted when the handle is closed.
1351 */
1353 /**
1354 * @brief The total number of packets which was queued to the handles driver queue.
1355 * @note This counter relates to a handle and will be deleted when the handle is closed.
1356 */
1358 /**
1359 * @brief The total number of packets which could be directly delivered to user space memory.
1360 * @note This counter relates to a handle and will be deleted when the handle is closed.
1361 */
1363 /**
1364 * @brief The total number of received bytes by the given bRAWcap handle.
1365 * @note This counter relates to a handle and will be deleted when the handle is closed
1366 */
1368 /**
1369 * @brief The total number of packets which was dropped for the handle (sum of all reasons).
1370 * @note This counter relates to a handle and will be deleted when the handle is closed.
1371 */
1373 /**
1374 * @brief The total number of packets which was dropped for the handle because of resources (driver queue overrun).
1375 * @note This counter relates to a handle and will be deleted when the handle is closed.
1376 */
1378 /**
1379 * @brief The total number of packets which was dropped for the handle their length exceeds the handles configured max
1380 * packet size.
1381 * @note This counter relates to a handle and will be deleted when the handle is closed.
1382 */
1385
1386/**
1387 * @brief Returns the size of receive statistics revision 1.
1388 */
1389#define BRAWCAP_STATS_RX_SIZEOF_REVISION_1 _BRAWCAP_SIZEOF_STRUCT(brawcap_stats_rx_t, handleDroppedPacketsToLong)
1390
1391/**
1392 * @brief List of all available transmit statistic revisions.
1393 */
1394typedef enum _brawcap_stats_tx_revision
1395{
1396 /**
1397 * @brief Revision 1 for transmit stats.
1398 */
1401
1402/**
1403 * @brief The bRAWcap transmit statistics.
1404 *
1405 * This can be used to retrieve all available bRAWcap statistics and counters related to transmit path.
1406 * After creating the structure, its header has to be initialized.
1407 *
1408 * The @ref brawcap_stats_header_t.type shall be set to @ref BRAWCAP_STATS_TYPE_TX.
1409 *
1410 * The @ref brawcap_stats_header_t.revision shall be set to one of the following values:
1411 * - @ref BRAWCAP_STATS_TX_REVISION_1
1412 *
1413 * The @ref brawcap_stats_header_t.size shall be set depending on your selected version by using the macro:
1414 * - @ref BRAWCAP_STATS_TX_SIZEOF_REVISION_1 (if selected revision is @ref BRAWCAP_STATS_TX_REVISION_1)
1415 *
1416 * @attention User is responsible for initializing the structure header before using it.
1417 * Otherwise it may lead to undefined behaviour.
1418 */
1419typedef struct _brawcap_stats_tx
1420{
1421 /**
1422 * @brief Header for transmit statistics.
1423 * This has to be always initialized by the user after creation before using it.
1424 */
1426 /**
1427 * @brief Bitfield indicating which counters provided by the underlying network adapter driver are valid.
1428 *
1429 */
1431 /**
1432 * @brief Total number of (completed) transmitted packets by the underlying network adapter.
1433 * @note You should check if the network adapter supports this counter with
1434 * @ref BRAWCAP_STATS_TX_ADAPTER_COMPLETED_PACKETS_TOTAL_VALID.
1435 * If the counter is not supported it will be always zero.
1436 */
1438 /**
1439 * @brief Total number of (completed) transmitted bytes by the underlying network adapter.
1440 * @note You should check if the network adapter supports this counter with
1441 * @ref BRAWCAP_STATS_TX_ADAPTER_COMPLETED_BYTES_TOTAL_VALID.
1442 * If the counter is not supported it will be always zero.
1443 */
1445 /**
1446 * @brief Total number of canceled transmitted packets by the underlying network adapter.
1447 * @note You should check if the network adapter supports this counter with
1448 * @ref BRAWCAP_STATS_TX_ADAPTER_CANCELED_PACKETS_TOTAL_VALID.
1449 * If the counter is not supported it will be always zero.
1450 */
1452 /**
1453 * @brief Total number of initiated packets to transmit by the bRAWcap driver on the corresponding adapter.
1454 * @note This counter will reset if bRAWcap driver is restarted, or it is deactivated on the adapter.
1455 */
1457 /**
1458 * @brief Initiated packets to transmit from upper network stack detected by bRAWcap driver on
1459 * the corresponding adapter.
1460 * @note This counter will reset if bRAWcap driver is restarted, or it is deactivated on the adapter.
1461 */
1463 /**
1464 * @brief Initiated packets to transmit from bRAWcap driver itself on the corresponding adapter.
1465 * @note This counter will reset if bRAWcap driver is restarted, or it is deactivated on the adapter.
1466 */
1468 /**
1469 * @brief Total number of canceled packets to transmit by the bRAWcap driver on the corresponding adapter.
1470 * @note This counter will reset if bRAWcap driver is restarted, or it is deactivated on the adapter.
1471 */
1473 /**
1474 * @brief Canceled packets to transmit from the upper network stack detected by bRAWcap driver on the
1475 * corresponding adapter.
1476 * @note This counter will reset if bRAWcap driver is restarted, or it is deactivated on the adapter.
1477 */
1479 /**
1480 * @brief Canceled packets to transmit from bRAWcap driver itself on the corresponding adapter.
1481 * @note This counter will reset if bRAWcap driver is restarted, or it is deactivated on the adapter.
1482 */
1484 /**
1485 * @brief Total number of completed transmitted packets detected by bRAWcap driver on the corresponding adapter.
1486 * @note This counter will reset if bRAWcap driver is restarted, or it is deactivated on the adapter.
1487 */
1489 /**
1490 * @brief Completed packets to transmit from the upper network stack detected by bRAWcap driver on the corresponding
1491 * adapter.
1492 * @note This counter will reset if bRAWcap driver is restarted, or it is deactivated on the adapter.
1493 */
1495 /**
1496 * @brief Completed packets to transmit from the bRAWcap driver itself on the corresponding adapter.
1497 * @note This counter will reset if bRAWcap driver is restarted, or it is deactivated on the adapter.
1498 */
1500 /**
1501 * @brief Total number of initiated packets to transmit for the handle.
1502 * @note This counter relates to a handle and will be deleted when the handle is closed.
1503 */
1505 /**
1506 * @brief Total number of canceled packets to transmit for the handle.
1507 * @note This counter relates to a handle and will be deleted when the handle is closed.
1508 */
1510 /**
1511 * @brief Total number of completed transmitted packets for the handle.
1512 * @note This counter relates to a handle and will be deleted when the handle is closed.
1513 */
1515
1516 UINT64 handleCompletedBytesTotal;
1518
1519/**
1520 * @brief Returns the size of transmit statistics revision 1.
1521 */
1522#define BRAWCAP_STATS_TX_SIZEOF_REVISION_1 _BRAWCAP_SIZEOF_STRUCT(brawcap_stats_tx_t, handleCompletedBytesTotal)
1523
1524/**@}*/
1525#endif
1526
1527#endif // BRAWCAP_TYPES_SHARED_H
UINT32 brawcap_queue_size_t
The number of packets which can be (temporary) buffered by the bRAWcap driver queue.
Definition: brawcap_types_shared.h:84
brawcap_status_t
bRAWcap status/return codes.
Definition: brawcap_types_shared.h:140
@ BRAWCAP_STATUS_INFO_NOT_ATTACHED
Indicates that the given object is not attached.
Definition: brawcap_types_shared.h:308
@ BRAWCAP_STATUS_ERROR_IN_USE
Indicates that operation failed because the provided object is still in use.
Definition: brawcap_types_shared.h:197
@ BRAWCAP_STATUS_ERROR_DRIVER_NOT_AVAILABLE
bRAWcap is not activated (on a specific adapter).
Definition: brawcap_types_shared.h:227
@ BRAWCAP_STATUS_ERROR_FAILED
Detected a - not further specified - failure.
Definition: brawcap_types_shared.h:153
@ BRAWCAP_STATUS_SUCCESS
Definition: brawcap_types_shared.h:142
@ BRAWCAP_STATUS_ERROR_INVALID_PARAM
At least one parameter content is invalid.
Definition: brawcap_types_shared.h:176
@ BRAWCAP_STATUS_ERROR_OVERRUN
A buffer overrun was detected.
Definition: brawcap_types_shared.h:235
@ BRAWCAP_STATUS_ERROR_DRIVER_IO_FAILED
Communication with the driver failed.
Definition: brawcap_types_shared.h:219
@ BRAWCAP_STATUS_WARNING_LIMIT_REACHED
Indicates that a bRAWcap limitation is reached.
Definition: brawcap_types_shared.h:269
@ BRAWCAP_STATUS_ERROR_NOT_FOUND
Given parameter not found.
Definition: brawcap_types_shared.h:191
@ BRAWCAP_STATUS_INFO_ALREADY_REGISTERED
Indicates that the given object was already registered.
Definition: brawcap_types_shared.h:322
@ BRAWCAP_STATUS_ERROR_PARAM_OUT_OF_RANGE
At least one parameter is out of bounds.
Definition: brawcap_types_shared.h:183
@ BRAWCAP_STATUS_WARNING_NO_UPLINK
Indicates that there is currently no uplink on the given adapter.
Definition: brawcap_types_shared.h:290
@ BRAWCAP_STATUS_INFO_TIMEOUT
Indicates that a function returned because of a timeout.
Definition: brawcap_types_shared.h:335
@ BRAWCAP_STATUS_ERROR_INVALID_POINTER
At least one specified pointer parameter was invalid.
Definition: brawcap_types_shared.h:169
@ BRAWCAP_STATUS_INFO_NOT_REGISTERED
Indicates that the given object is not registered.
Definition: brawcap_types_shared.h:315
@ BRAWCAP_STATUS_WARNING_PENDING
Will be returned if another operation for the same resource is pending.
Definition: brawcap_types_shared.h:262
@ BRAWCAP_STATUS_ERROR_BEYOND_MTU
The packet size is beyond adapter MTU.
Definition: brawcap_types_shared.h:205
@ BRAWCAP_STATUS_WARNING_CANCELED
Indicates that a operation was canceled.
Definition: brawcap_types_shared.h:277
@ BRAWCAP_STATUS_INFO_NOT_RUNNING
No operation running.
Definition: brawcap_types_shared.h:301
@ BRAWCAP_STATUS_ERROR_NOT_AVAILABLE
Function is not available.
Definition: brawcap_types_shared.h:162
@ BRAWCAP_STATUS_INFO_NO_DATA
Indicates that a function returns without any data.
Definition: brawcap_types_shared.h:329
@ BRAWCAP_STATUS_ERROR_BPF_COMPILE_FAILED
Indicates that the BPF filter compilation failed.
Definition: brawcap_types_shared.h:241
@ BRAWCAP_STATUS_WARNING_DEMO_MODE
The operation was not executed due to demo mode limitations.
Definition: brawcap_types_shared.h:252
@ BRAWCAP_STATUS_WARNING_NOT_ALL_PROCESSED
Indicates that not all of the specified content/payload was processed.
Definition: brawcap_types_shared.h:284
Struct containing the separated version parts.
Definition: brawcap_types_shared.h:377
bRAWcap version.
Definition: brawcap_types_shared.h:422
UINT16 minor
Minor version.
Definition: brawcap_types_shared.h:403
UINT16 major
Major version.
Definition: brawcap_types_shared.h:412
UINT16 patch
Patch version.
Definition: brawcap_types_shared.h:395
UINT16 build
Build version.
Definition: brawcap_types_shared.h:386
UINT64 complete
Definition: brawcap_types_shared.h:424
brawcap_version_fragments_t fragments
Definition: brawcap_types_shared.h:423
UINT32 brawcap_timestamp_capabilities_t
Type used for indicating the supported timestamp modes.
Definition: brawcap_types_shared.h:520
struct _brawcap_timestamp brawcap_timestamp_t
bRAWcap timestamp object.
Definition: brawcap_types_shared.h:608
UINT32 brawcap_timestamp_resolution_ns_t
Represents the timestamp resolution in nanoseconds.
Definition: brawcap_types_shared.h:529
brawcap_timestamp_mode_t
List of different timestamp modes.
Definition: brawcap_types_shared.h:570
@ BRAWCAP_TIMESTAMP_MODE_SYSTEM_HIGHPREC
A high precision system timestamp created by bRAWcap driver.
Definition: brawcap_types_shared.h:582
@ BRAWCAP_TIMESTAMP_MODE_ADAPTER_HARDWARE
A hardware timestamp created by the network adapter hardware/firmware.
Definition: brawcap_types_shared.h:598
@ BRAWCAP_TIMESTAMP_MODE_SOFTWARE
A software timestamp created by bRAWcap driver.
Definition: brawcap_types_shared.h:586
@ BRAWCAP_TIMESTAMP_MODE_ADAPTER_SYSTEM
A system timestamp created by the network adapter driver.
Definition: brawcap_types_shared.h:590
@ BRAWCAP_TIMESTAMP_MODE_ADAPTER_SOFTWARE
A software timestamp created by the network adapter driver.
Definition: brawcap_types_shared.h:594
@ BRAWCAP_TIMESTAMP_MODE_NO_TIMESTAMP
No timestamp.
Definition: brawcap_types_shared.h:574
@ BRAWCAP_TIMESTAMP_MODE_SYSTEM_LOWPREC
A low precision system timestamp created by bRAWcap driver.
Definition: brawcap_types_shared.h:578
UINT16 brawcap_packet_size_t
Type for handling the number of payload bytes per packet.
Definition: brawcap_types_shared.h:666
struct _brawcap_packet brawcap_packet_t
bRAWcap packet object.
Definition: brawcap_types_shared.h:675
struct _brawcap_buffer brawcap_buffer_t
bRAWcap packet buffer object.
Definition: brawcap_types_shared.h:746
UINT32 brawcap_buffer_packet_count_t
Type for handling the number of packets which can be stored in a packet buffer.
Definition: brawcap_types_shared.h:738
struct _brawcap_buffer_iterator brawcap_buffer_iterator_t
bRAWcap packet buffer iterator object.
Definition: brawcap_types_shared.h:774
brawcap_rx_mode_t
List of receive modes.
Definition: brawcap_types_shared.h:1039
UINT32 brawcap_rx_min_packets_t
Type for handling the minimum amount of packets to copy before a bRAWcap receive will return....
Definition: brawcap_types_shared.h:1033
UINT16 brawcap_rx_timeout_t
Type for handling receive timeouts in number of milliseconds. The timeout specifies the maximum block...
Definition: brawcap_types_shared.h:1023
brawcap_rx_direction_t
List of supported receive directions.
Definition: brawcap_types_shared.h:1060
@ BRAWCAP_RX_MODE_LIVE
Received packets are stored in a user created bRAWcap packet (buffer) and provided to the calling app...
Definition: brawcap_types_shared.h:1044
@ BRAWCAP_RX_MODE_DUMP
Received packets are directly written to disk.
Definition: brawcap_types_shared.h:1050
@ BRAWCAP_RX_DIRECTION_UNKNOWN
Stops to receive packets of any direction.
Definition: brawcap_types_shared.h:1064
@ BRAWCAP_RX_DIRECTION_IN
Only received packets by the network adapter will be received.
Definition: brawcap_types_shared.h:1068
@ BRAWCAP_RX_DIRECTION_OUT
Only transmitted packets by bRAWcap or upper network stack drivers will be received....
Definition: brawcap_types_shared.h:1077
@ BRAWCAP_RX_DIRECTION_BOTH
Both transmitted packets by bRAWcap or upper network stack drivers and received packets from the unde...
Definition: brawcap_types_shared.h:1082
#define BRAWCAP_FILTER_BYTE_MAX_LENGTH
The maximum supported filter byte mask length in bytes.
Definition: brawcap_types_shared.h:902
UINT8 brawcap_filter_mask_array_t[BRAWCAP_FILTER_BYTE_MAX_LENGTH]
Fixed size array for storing a filter byte mask.
Definition: brawcap_types_shared.h:911
struct _brawcap_filter brawcap_filter_t
bRAWcap filter object.
Definition: brawcap_types_shared.h:959
brawcap_filter_type_t
List of filter types.
Definition: brawcap_types_shared.h:938
UINT8 brawcap_filter_ignore_bits_array_t[BRAWCAP_FILTER_BYTE_MAX_LENGTH]
Fixed size array for storing a byte wise bitfield.
Definition: brawcap_types_shared.h:923
brawcap_packet_size_t brawcap_filter_byte_length_t
Type for specifying the byte filter length.
Definition: brawcap_types_shared.h:928
@ BRAWCAP_FILTER_TYPE_BPF
A Berkley Packet Filter.
Definition: brawcap_types_shared.h:946
@ BRAWCAP_FILTER_TYPE_NONE
No filter.
Definition: brawcap_types_shared.h:950
@ BRAWCAP_FILTER_TYPE_BYTE_MASK
A bRAWcap byte filter.
Definition: brawcap_types_shared.h:942
Header describing given bRAWcap stats structure.
Definition: brawcap_types_shared.h:1240
The bRAWcap receive statistics.
Definition: brawcap_types_shared.h:1302
The bRAWcap transmit statistics.
Definition: brawcap_types_shared.h:1420
UINT64 driverInitiatedPacketsHandles
Initiated packets to transmit from bRAWcap driver itself on the corresponding adapter.
Definition: brawcap_types_shared.h:1467
UINT64 handleDroppedPacketsTotal
The total number of packets which was dropped for the handle (sum of all reasons).
Definition: brawcap_types_shared.h:1372
UINT64 driverCompletedPacketsStack
Completed packets to transmit from the upper network stack detected by bRAWcap driver on the correspo...
Definition: brawcap_types_shared.h:1494
UINT64 driverReceivedPacketsTotal
The total number of received packets by bRAWcap on the corresponding adapter.
Definition: brawcap_types_shared.h:1342
UINT64 handleReceivedPacketsMatched
The total number of packets which have matched the given bRAWcap handle filter.
Definition: brawcap_types_shared.h:1352
UINT64 handleCompletedPacketsTotal
Total number of completed transmitted packets for the handle.
Definition: brawcap_types_shared.h:1514
BYTE revision
Indicates the revision of the stats.
Definition: brawcap_types_shared.h:1250
UINT64 adapterDroppedPacketsTotal
Total number of received bytes by the underlying network adapter.
Definition: brawcap_types_shared.h:1332
UINT64 adapterReceivedPacketsTotal
Total number of received packets by the underlying network adapter.
Definition: brawcap_types_shared.h:1318
UINT64 adapterCanceledPacketsTotal
Total number of canceled transmitted packets by the underlying network adapter.
Definition: brawcap_types_shared.h:1451
UINT64 handleReceivedPacketsDirect
The total number of packets which could be directly delivered to user space memory.
Definition: brawcap_types_shared.h:1362
UINT64 handleReceivedPacketsQueued
The total number of packets which was queued to the handles driver queue.
Definition: brawcap_types_shared.h:1357
UINT64 handleDroppedPacketsToLong
The total number of packets which was dropped for the handle their length exceeds the handles configu...
Definition: brawcap_types_shared.h:1383
UINT64 driverCompletedPacketsHandles
Completed packets to transmit from the bRAWcap driver itself on the corresponding adapter.
Definition: brawcap_types_shared.h:1499
UINT64 adapterCompletedBytesTotal
Total number of (completed) transmitted bytes by the underlying network adapter.
Definition: brawcap_types_shared.h:1444
UINT16 size
Should be set to the size of the structure depending on it´s type and revision. You should use the BR...
Definition: brawcap_types_shared.h:1255
UINT64 driverInitiatedPacketsStack
Initiated packets to transmit from upper network stack detected by bRAWcap driver on the correspondin...
Definition: brawcap_types_shared.h:1462
UINT64 driverInitiatedPacketsTotal
Total number of initiated packets to transmit by the bRAWcap driver on the corresponding adapter.
Definition: brawcap_types_shared.h:1456
UINT64 adapterCompletedPacketsTotal
Total number of (completed) transmitted packets by the underlying network adapter.
Definition: brawcap_types_shared.h:1437
UINT64 handleCanceledPacketsTotal
Total number of canceled packets to transmit for the handle.
Definition: brawcap_types_shared.h:1509
BYTE type
Indicates which type of stats it is.
Definition: brawcap_types_shared.h:1244
UINT64 handleDroppedPacketsQueue
The total number of packets which was dropped for the handle because of resources (driver queue overr...
Definition: brawcap_types_shared.h:1377
UINT64 driverCanceledPacketsTotal
Total number of canceled packets to transmit by the bRAWcap driver on the corresponding adapter.
Definition: brawcap_types_shared.h:1472
UINT32 adapterValid
Bitfield indicating which counters provided by the underlying network adapter driver are valid.
Definition: brawcap_types_shared.h:1311
UINT64 handleReceivedPacketsTotal
The total number of received packets by the given bRAWcap handle.
Definition: brawcap_types_shared.h:1347
UINT64 driverCanceledPacketsHandles
Canceled packets to transmit from bRAWcap driver itself on the corresponding adapter.
Definition: brawcap_types_shared.h:1483
brawcap_stats_header_t header
Header for receive statistics. This has to be always initialized by the user after creation before us...
Definition: brawcap_types_shared.h:1307
UINT64 handleInitiatedPacketsTotal
Total number of initiated packets to transmit for the handle.
Definition: brawcap_types_shared.h:1504
UINT64 driverIndicatedPacketsTotal
The total number of indicated packets to the upper network stack by bRAWcap on the corresponding adap...
Definition: brawcap_types_shared.h:1337
UINT64 driverCanceledPacketsStack
Canceled packets to transmit from the upper network stack detected by bRAWcap driver on the correspon...
Definition: brawcap_types_shared.h:1478
UINT64 adapterReceivedBytesTotal
Total number of received bytes by the underlying network adapter.
Definition: brawcap_types_shared.h:1325
UINT64 handleReceivedBytesTotal
The total number of received bytes by the given bRAWcap handle.
Definition: brawcap_types_shared.h:1367
UINT64 driverCompletedPacketsTotal
Total number of completed transmitted packets detected by bRAWcap driver on the corresponding adapter...
Definition: brawcap_types_shared.h:1488
brawcap_stats_rx_revision_t
List of all available receive statistic revisions.
Definition: brawcap_types_shared.h:1277
brawcap_stats_tx_revision_t
List of all available transmit statistic revisions.
Definition: brawcap_types_shared.h:1395
brawcap_stats_type_t
List of all available statistic types.
Definition: brawcap_types_shared.h:1262
@ BRAWCAP_STATS_RX_REVISION_1
Revision 1 for receive stats.
Definition: brawcap_types_shared.h:1281
@ BRAWCAP_STATS_TX_REVISION_1
Revision 1 for transmit stats.
Definition: brawcap_types_shared.h:1399
@ BRAWCAP_STATS_TYPE_RX
Type for receive stats.
Definition: brawcap_types_shared.h:1266
@ BRAWCAP_STATS_TYPE_TX
Type for transmit stats.
Definition: brawcap_types_shared.h:1270