NetworkDevice.h: Make it possible to include from _KERNEL_MODE and/or non-C++.

This file contains a set of constants and flags which are already passed
between applications, net_server, and wpa_supplicant to indicate network
security, connection modes, and a variety of other things.

As the OpenBSD net80211 stack does not need wpa_supplicant for WPA2/PSK,
it only makes sense that we would pass the same information we pass
to wpa_supplicant into the stack instead. Rather than expose yet another
set of constants and flags to userland besides the FreeBSD and these
Haiku native ones, just make it so this file can be included in the kernel,
and the constants thus used directly.
This commit is contained in:
Augustin Cavalier
2022-06-09 01:28:56 -04:00
parent bcb089f6c3
commit 7cb5a6d24f
+35 -33
View File
@@ -9,39 +9,6 @@
#include <net/if.h>
#include <string.h>
#include <NetworkAddress.h>
class BNetworkAddress;
struct wireless_network {
char name[32];
BNetworkAddress address;
uint8 noise_level;
uint8 signal_strength;
uint32 flags;
uint32 authentication_mode;
uint32 cipher;
uint32 group_cipher;
uint32 key_mode;
bool operator==(const wireless_network& other) {
return strncmp(name, other.name, 32) == 0
// ignore address difference
&& noise_level == other.noise_level
&& signal_strength == other.signal_strength
&& flags == other.flags
&& authentication_mode == other.authentication_mode
&& cipher == other.cipher
&& group_cipher == other.group_cipher
&& key_mode == other.key_mode;
}
};
// flags
#define B_NETWORK_IS_ENCRYPTED 0x01
#define B_NETWORK_IS_PERSISTENT 0x02
// authentication modes
enum {
@@ -82,6 +49,40 @@ enum {
};
#if defined(__cplusplus) && !defined(_KERNEL_MODE)
#include <NetworkAddress.h>
struct wireless_network {
char name[32];
BNetworkAddress address;
uint8 noise_level;
uint8 signal_strength;
uint32 flags;
uint32 authentication_mode;
uint32 cipher;
uint32 group_cipher;
uint32 key_mode;
bool operator==(const wireless_network& other) {
return strncmp(name, other.name, 32) == 0
// ignore address difference
&& noise_level == other.noise_level
&& signal_strength == other.signal_strength
&& flags == other.flags
&& authentication_mode == other.authentication_mode
&& cipher == other.cipher
&& group_cipher == other.group_cipher
&& key_mode == other.key_mode;
}
};
// flags
#define B_NETWORK_IS_ENCRYPTED 0x01
#define B_NETWORK_IS_PERSISTENT 0x02
class BNetworkDevice {
public:
BNetworkDevice();
@@ -141,5 +142,6 @@ private:
char fName[IF_NAMESIZE];
};
#endif // __cplusplus && !_KERNEL_MODE
#endif // _NETWORK_DEVICE_H