xref: /haiku/headers/os/net/NetworkDevice.h (revision 1294543de9ac0eff000eaea1b18368c36435d08e)
1 /*
2  * Copyright 2010, Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _NETWORK_DEVICE_H
6 #define _NETWORK_DEVICE_H
7 
8 
9 #include <net/if.h>
10 
11 #include <NetworkAddress.h>
12 
13 
14 class BNetworkAddress;
15 
16 
17 struct wireless_network {
18 	char				name[32];
19 	BNetworkAddress		address;
20 	uint8				noise_level;
21 	uint8				signal_strength;
22 };
23 
24 class BNetworkDevice {
25 public:
26 								BNetworkDevice();
27 								BNetworkDevice(const char* name);
28 								~BNetworkDevice();
29 
30 			void				Unset();
31 			void				SetTo(const char* name);
32 
33 			const char*			Name() const;
34 
35 			uint32				Flags() const;
36 			bool				HasLink() const;
37 
38 			int32				CountMedia() const;
39 			int32				GetMediaAt(int32 index) const;
40 
41 			int32				Media() const;
42 			status_t			SetMedia(int32 media);
43 
44 			status_t			GetHardwareAddress(BNetworkAddress& address);
45 
46 			bool				IsEthernet();
47 			bool				IsWireless();
48 
49 			status_t			Scan(bool wait = true,
50 									bool forceRescan = true);
51 			ssize_t				CountScanResults();
52 			status_t			GetScanResultAt(int32 index,
53 									wireless_network& network);
54 
55 			status_t			JoinNetwork(const BNetworkAddress& address,
56 									const char* password = NULL);
57 			status_t			LeaveNetwork();
58 			status_t			GetCurrentNetwork(wireless_network& network);
59 			status_t			GetCurrentNetwork(BNetworkAddress& address);
60 
61 private:
62 			char				fName[IF_NAMESIZE];
63 };
64 
65 
66 #endif	// _NETWORK_DEVICE_H
67