bRAWcap 1.0.1
b-plus Technologies - Ethernet Performance Transmitter Receiver
Loading...
Searching...
No Matches
04_version_comparator.c

This example shows how to read library (/API) and driver version of bRAWcap. After reading the versions it will check if both versions match.

1/**
2 * @file 04_version_comparator.c
3 *
4 * @brief bRAWcap Example - Demonstrates how to use the bRAWcap version.
5 *
6 * It shows how to:
7 * - Read library and driver version
8 * - Print readable versions
9 * - Do a version compare
10 *
11 * This example makes use of C only.
12 *
13 * @version 1.0
14 *
15 * @date 2023-03-28
16 *
17 * @copyright
18 * <b> © 2021 - b-plus technologies GmbH. All rights reserved!</b>
19 *
20 * All rights exclusively reserved for b-plus GmbH, unless expressly otherwise agreed.
21 *
22 * Redistribution in source or any other form, with or without modification, is not permitted.
23 *
24 * You may use this code under the according license terms of b-plus.
25 * Please contact b-plus at services@b-plus.com to get the appropriate terms and conditions.
26 */
27// Include bRAWcap
28#include "libbrawcap.h"
29
30// C STD
31#include <stdio.h> // for printf
32
33int main(int argc, char** argv)
34{
35 // Set console title
36 SetConsoleTitleA("bRAWcap Example - Version Comparator");
37
39 brawcap_adapter_count_t numberAdapters = 0;
40 brawcap_version_t apiVersion = {0};
41 brawcap_version_t driverVersion = {0};
42
43 status = brawcap_version_api(&apiVersion);
44 if(!BRAWCAP_SUCCESS(status))
45 printf("Unexpected status (%d) while reading API(/library) version.\n", status);
46 else
47 printf("Loaded library/API version is: %u.%u.%u.%u\n", apiVersion.fragments.major, apiVersion.fragments.minor,
48 apiVersion.fragments.patch, apiVersion.fragments.build);
49
50 status = brawcap_adapter_list_count(&numberAdapters);
51 if(!BRAWCAP_SUCCESS(status))
52 printf("Unexpected status (%d) while reading number of available adapters.\n", status);
53 else if(!numberAdapters)
54 printf("No adapter available to read driver version.\n");
55 else
56 {
57 brawcap_adapter_name_t name = { '\0' };
58 status = brawcap_adapter_list_at(0, name);
59 if(!BRAWCAP_SUCCESS(status))
60 printf("Unexpected status (%d) while reading adapter name.", status);
61 else
62 {
63 brawcap_handle_t* handle = 0;
64 status = brawcap_open(name, &handle);
65 if(!BRAWCAP_SUCCESS(status))
66 printf("Unexpected status (%d) while handle opening.", status);
67 else
68 {
69 status = brawcap_version_driver(handle, &driverVersion);
70 if(!BRAWCAP_SUCCESS(status))
71 printf("Unexpected status (%d) while reading driver version.\n", status);
72 else
73 {
74 printf("Loaded driver version is: %u.%u.%u.%u\n", driverVersion.fragments.major,
75 driverVersion.fragments.minor, driverVersion.fragments.patch, driverVersion.fragments.build);
76
77 if(driverVersion.complete == apiVersion.complete)
78 printf("Driver and API version MATCH. :-)\n");
79 else
80 printf("Driver and API version does NOT MATCH. :-(\n");
81 }
82 brawcap_close(handle);
83 }
84 }
85 }
86 return 0;
87}
bRAWcap main header.
struct _brawcap_handle brawcap_handle_t
A bRAWcap handle.
Definition: brawcap_types_um.h:173
brawcap_status_t brawcap_close(brawcap_handle_t *pHandle)
Closes the specified bRAWcap handle.
brawcap_status_t brawcap_open(const brawcap_adapter_name_t name, brawcap_handle_t **const pHandle)
Opens a new bRAWcap handle on the adapter, specified by it´s name.
brawcap_status_t
bRAWcap status/return codes.
Definition: brawcap_types_shared.h:150
#define BRAWCAP_SUCCESS(status)
Checks if the returned status indicates a success with no additional info.
Definition: brawcap_types_shared.h:122
@ BRAWCAP_STATUS_SUCCESS
Definition: brawcap_types_shared.h:152
bRAWcap version.
Definition: brawcap_types_shared.h:426
UINT16 minor
Minor version.
Definition: brawcap_types_shared.h:407
UINT16 major
Major version.
Definition: brawcap_types_shared.h:416
UINT16 patch
Patch version.
Definition: brawcap_types_shared.h:399
UINT16 build
Build version.
Definition: brawcap_types_shared.h:390
UINT64 complete
Definition: brawcap_types_shared.h:428
brawcap_version_fragments_t fragments
Definition: brawcap_types_shared.h:427
brawcap_status_t brawcap_version_api(brawcap_version_t *const pVersion)
Returns loaded bRAWcap library version.
brawcap_status_t brawcap_version_driver(brawcap_handle_t *const pHandle, brawcap_version_t *const pVersion)
Reads current version of loaded bRAWcap driver.
brawcap_status_t brawcap_adapter_list_at(const brawcap_adapter_count_t index, brawcap_adapter_name_t name)
Reads out the adapter name of the adapter at the adapter list index.
brawcap_status_t brawcap_adapter_list_count(brawcap_adapter_count_t *const pCount)
Reads out the current number of supported adapters in the adapter list.
char brawcap_adapter_name_t[BRAWCAP_ADAPTER_NAME_LENGTH]
Fixed size array containing a adapter name.
Definition: brawcap_types_um.h:257
UINT8 brawcap_adapter_count_t
Type used for counting the available/supported adapters on a machine.
Definition: brawcap_types_um.h:242