diff options
Diffstat (limited to 'src/libwifi/core/core.c')
-rw-r--r-- | src/libwifi/core/core.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/libwifi/core/core.c b/src/libwifi/core/core.c new file mode 100644 index 0000000..0340a82 --- /dev/null +++ b/src/libwifi/core/core.c | |||
@@ -0,0 +1,46 @@ | |||
1 | /* Copyright 2021 The libwifi Authors | ||
2 | * | ||
3 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
4 | * you may not use this file except in compliance with the License. | ||
5 | * You may obtain a copy of the License at | ||
6 | * | ||
7 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
8 | * | ||
9 | * Unless required by applicable law or agreed to in writing, software | ||
10 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
12 | * See the License for the specific language governing permissions and | ||
13 | * limitations under the License. | ||
14 | */ | ||
15 | |||
16 | #include "core.h" | ||
17 | #include <stdlib.h> | ||
18 | #include <string.h> | ||
19 | #include <sys/random.h> | ||
20 | |||
21 | /** | ||
22 | * Random MAC addresses, achieved by obtaining 6 bytes of /dev/urandom via getrandom() | ||
23 | */ | ||
24 | void libwifi_random_mac(unsigned char buf[6], unsigned char prefix[3]) { | ||
25 | memset(buf, 0, 6); | ||
26 | if (prefix != NULL) { | ||
27 | memcpy(buf, prefix, 3); | ||
28 | getrandom(buf + 3, 3, 0); | ||
29 | } else { | ||
30 | getrandom(buf, 6, 0); | ||
31 | } | ||
32 | } | ||
33 | |||
34 | /** | ||
35 | * Dummy linker test function | ||
36 | */ | ||
37 | void libwifi_dummy(void) { | ||
38 | return; | ||
39 | } | ||
40 | |||
41 | /** | ||
42 | * Version | ||
43 | */ | ||
44 | const char *libwifi_get_version(void) { | ||
45 | return LIBWIFI_VERSION; | ||
46 | } | ||