Moved more functionality from net_server to NetworkSettings.
* Added (still incomplete) helper classes for the settings messages. * The net_server now uses these classes for its interfaces, and services. * Renamed service_address to service_connection, as that better matches what it is used for.
This commit is contained in:
@@ -9,9 +9,13 @@
|
||||
#define SETTINGS_H
|
||||
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <Message.h>
|
||||
#include <Messenger.h>
|
||||
#include <NetworkAddress.h>
|
||||
#include <Path.h>
|
||||
#include <StringList.h>
|
||||
|
||||
|
||||
namespace BNetworkKit {
|
||||
@@ -20,6 +24,7 @@ namespace BNetworkKit {
|
||||
class BNetworkSettings {
|
||||
public:
|
||||
static const uint32 kMsgInterfaceSettingsUpdated = 'SUif';
|
||||
static const uint32 kMsgNetworkSettingsUpdated = 'SUnw';
|
||||
static const uint32 kMsgServiceSettingsUpdated = 'SUsv';
|
||||
|
||||
public:
|
||||
@@ -88,7 +93,109 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class BNetworkInterfaceAddressSettings {
|
||||
public:
|
||||
BNetworkInterfaceAddressSettings(
|
||||
const BMessage& data);
|
||||
~BNetworkInterfaceAddressSettings();
|
||||
|
||||
int Family() const;
|
||||
bool AutoConfigure() const;
|
||||
|
||||
const BNetworkAddress&
|
||||
Address() const;
|
||||
const BNetworkAddress&
|
||||
Mask() const;
|
||||
const BNetworkAddress&
|
||||
Peer() const;
|
||||
const BNetworkAddress&
|
||||
Broadcast() const;
|
||||
const BNetworkAddress&
|
||||
Gateway() const;
|
||||
|
||||
private:
|
||||
int32 fFamily;
|
||||
bool fAutoConfigure;
|
||||
BNetworkAddress fAddress;
|
||||
BNetworkAddress fMask;
|
||||
BNetworkAddress fPeer;
|
||||
BNetworkAddress fBroadcast;
|
||||
BNetworkAddress fGateway;
|
||||
};
|
||||
|
||||
|
||||
class BNetworkInterfaceSettings {
|
||||
public:
|
||||
BNetworkInterfaceSettings(
|
||||
const BMessage& message);
|
||||
~BNetworkInterfaceSettings();
|
||||
|
||||
const char* Name() const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // namespace BNetworkKit
|
||||
|
||||
|
||||
class BNetworkServiceAddressSettings {
|
||||
public:
|
||||
BNetworkServiceAddressSettings();
|
||||
BNetworkServiceAddressSettings(
|
||||
const BMessage& data, int family = -1,
|
||||
int type = -1, int protocol = -1,
|
||||
int port = -1);
|
||||
~BNetworkServiceAddressSettings();
|
||||
|
||||
int Family() const;
|
||||
void SetFamily(int family);
|
||||
int Protocol() const;
|
||||
void SetProtocol(int protocol);
|
||||
int Type() const;
|
||||
void SetType(int type);
|
||||
|
||||
const BNetworkAddress&
|
||||
Address() const;
|
||||
BNetworkAddress& Address();
|
||||
|
||||
status_t GetMessage(BMessage& data);
|
||||
|
||||
bool operator==(
|
||||
const BNetworkServiceAddressSettings& other)
|
||||
const;
|
||||
|
||||
private:
|
||||
int32 fFamily;
|
||||
int fProtocol;
|
||||
int fType;
|
||||
BNetworkAddress fAddress;
|
||||
};
|
||||
|
||||
|
||||
class BNetworkServiceSettings {
|
||||
public:
|
||||
BNetworkServiceSettings(
|
||||
const BMessage& message);
|
||||
~BNetworkServiceSettings();
|
||||
|
||||
status_t InitCheck() const;
|
||||
|
||||
const char* Name() const;
|
||||
bool IsStandAlone() const;
|
||||
|
||||
int32 CountArguments() const;
|
||||
const char* ArgumentAt(int32 index) const;
|
||||
|
||||
int32 CountAddresses() const;
|
||||
const BNetworkServiceAddressSettings&
|
||||
AddressAt(int32 index) const;
|
||||
|
||||
private:
|
||||
const BMessage& fData;
|
||||
BStringList fArguments;
|
||||
std::vector<BNetworkServiceAddressSettings>
|
||||
fAddresses;
|
||||
};
|
||||
|
||||
|
||||
#endif // SETTINGS_H
|
||||
|
||||
Reference in New Issue
Block a user