From 7cb5a6d24f9c5e79117e3be745392d1a73c27cbe Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Wed, 8 Jun 2022 23:14:01 -0400 Subject: [PATCH] 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. --- headers/os/net/NetworkDevice.h | 68 +++++++++++++++++----------------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/headers/os/net/NetworkDevice.h b/headers/os/net/NetworkDevice.h index c44072d017..addac3414d 100644 --- a/headers/os/net/NetworkDevice.h +++ b/headers/os/net/NetworkDevice.h @@ -9,39 +9,6 @@ #include #include -#include - - -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 + + +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