* Work in progress network API changes.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39147 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright 2010, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _NETWORK_DEVICE_H
|
||||
#define _NETWORK_DEVICE_H
|
||||
|
||||
|
||||
#include <net/if.h>
|
||||
|
||||
#include <NetworkAddress.h>
|
||||
|
||||
|
||||
class BNetworkAddress;
|
||||
|
||||
|
||||
struct wireless_network {
|
||||
char name[32];
|
||||
BNetworkAddress address;
|
||||
uint8 noise_level;
|
||||
uint8 signal_strength;
|
||||
};
|
||||
|
||||
class BNetworkDevice {
|
||||
public:
|
||||
BNetworkDevice();
|
||||
BNetworkDevice(const char* name);
|
||||
~BNetworkDevice();
|
||||
|
||||
void Unset();
|
||||
void SetTo(const char* name);
|
||||
|
||||
const char* Name() const;
|
||||
|
||||
uint32 Flags() const;
|
||||
bool HasLink() const;
|
||||
|
||||
int32 CountMedia() const;
|
||||
int32 GetMediaAt(int32 index) const;
|
||||
|
||||
int32 Media() const;
|
||||
status_t SetMedia(int32 media);
|
||||
|
||||
status_t GetHardwareAddress(BNetworkAddress& address);
|
||||
|
||||
bool IsEthernet();
|
||||
bool IsWireless();
|
||||
|
||||
status_t Scan(bool wait = true,
|
||||
bool forceRescan = true);
|
||||
ssize_t CountScanResults();
|
||||
status_t GetScanResultAt(int32 index,
|
||||
wireless_network& network);
|
||||
|
||||
status_t JoinNetwork(const BNetworkAddress& address,
|
||||
const char* password = NULL);
|
||||
status_t LeaveNetwork();
|
||||
status_t GetCurrentNetwork(wireless_network& network);
|
||||
status_t GetCurrentNetwork(BNetworkAddress& address);
|
||||
|
||||
private:
|
||||
char fName[IF_NAMESIZE];
|
||||
};
|
||||
|
||||
|
||||
#endif // _NETWORK_DEVICE_H
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2010, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _NETWORK_NOTIFICATIONS_H
|
||||
#define _NETWORK_NOTIFICATIONS_H
|
||||
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
|
||||
class BHandler;
|
||||
class BLooper;
|
||||
class BMessenger;
|
||||
|
||||
|
||||
#define B_NETWORK_INTERFACE_ADDED 0x0001
|
||||
#define B_NETWORK_INTERFACE_REMOVED 0x0002
|
||||
#define B_NETWORK_INTERFACE_CHANGED 0x0003
|
||||
#define B_NETWORK_DEVICE_LINK_CHANGED 0x0010
|
||||
#define B_NETWORK_WLAN_JOINED 0x0100
|
||||
#define B_NETWORK_WLAN_LEFT 0x0200
|
||||
#define B_NETWORK_WLAN_SCANNED 0x0300
|
||||
#define B_NETWORK_WLAN_MESSAGE_INTEGRITY_FAILED 0x0400
|
||||
|
||||
// TODO: add routes, stack unloaded/loaded, ... events
|
||||
|
||||
enum {
|
||||
B_WATCH_NETWORK_INTERFACE_CHANGES = 0x000f,
|
||||
B_WATCH_NETWORK_LINK_CHANGES = 0x00f0,
|
||||
B_WATCH_NETWORK_WLAN_CHANGES = 0x0f00
|
||||
};
|
||||
|
||||
#define B_NETWORK_MONITOR '_NTN'
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
status_t start_watching_network(uint32 flags, const BMessenger& target);
|
||||
status_t start_watching_network(uint32 flags, const BHandler* handler,
|
||||
const BLooper* looper = NULL);
|
||||
|
||||
status_t stop_watching_network(const BMessenger& target);
|
||||
status_t stop_watching_network(const BHandler* handler,
|
||||
const BLooper* looper = NULL);
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
|
||||
#endif // _NETWORK_NOTIFICATIONS_H
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
|
||||
#include <Locker.h>
|
||||
#include <NetworkNotifications.h>
|
||||
|
||||
|
||||
class BMessenger;
|
||||
|
||||
Reference in New Issue
Block a user