32 #ifndef _NPT_NETWORK_H_ 33 #define _NPT_NETWORK_H_ 39 #include "NptConstants.h" 40 #include "NptStrings.h" 46 const unsigned int NPT_NETWORK_MAX_MAC_ADDRESS_LENGTH = 8;
51 #define NPT_NETWORK_INTERFACE_FLAG_LOOPBACK 0x01 52 #define NPT_NETWORK_INTERFACE_FLAG_PROMISCUOUS 0x02 53 #define NPT_NETWORK_INTERFACE_FLAG_BROADCAST 0x04 54 #define NPT_NETWORK_INTERFACE_FLAG_MULTICAST 0x08 55 #define NPT_NETWORK_INTERFACE_FLAG_POINT_TO_POINT 0x10 69 typedef unsigned int NPT_IpPort;
91 NPT_IpAddress(
unsigned char a,
unsigned char b,
unsigned char c,
unsigned char d);
92 NPT_IpAddress(Type type,
const unsigned char* address,
unsigned int size, NPT_UInt32 scope_id = 0);
95 Type GetType()
const {
return m_Type; }
96 NPT_UInt32 GetScopeId()
const {
return m_ScopeId; }
99 NPT_Result ResolveName(
const char* name,
100 NPT_Timeout timeout = NPT_TIMEOUT_INFINITE);
101 NPT_Result Parse(
const char* name);
102 NPT_Result Set(
unsigned long address);
103 NPT_Result Set(
const unsigned char bytes[4]);
104 NPT_Result Set(
const unsigned char* bytes,
unsigned int size, NPT_UInt32 scope_id = 0);
105 const unsigned char* AsBytes()
const;
106 unsigned long AsLong()
const;
111 bool IsUnspecified()
const;
112 bool IsLooppack()
const;
113 bool IsV4Compatible()
const;
114 bool IsV4Mapped()
const;
115 bool IsLinkLocal()
const;
116 bool IsSiteLocal()
const;
117 bool IsUniqueLocal()
const;
118 bool IsMulticast()
const;
129 unsigned char m_Address[16];
130 NPT_UInt32 m_ScopeId;
151 const unsigned char* addr,
152 unsigned int length);
155 void SetAddress(Type type,
const unsigned char* addr,
156 unsigned int length);
157 Type GetType()
const {
return m_Type; }
158 const unsigned char* GetAddress()
const {
return m_Address; }
159 unsigned int GetLength()
const {
return m_Length; }
165 unsigned char m_Address[NPT_NETWORK_MAX_MAC_ADDRESS_LENGTH];
166 unsigned int m_Length;
180 m_PrimaryAddress(primary),
181 m_BroadcastAddress(broadcast),
182 m_DestinationAddress(destination),
183 m_NetMask(netmask) {}
187 return m_PrimaryAddress;
190 return m_BroadcastAddress;
193 return m_DestinationAddress;
200 if (m_PrimaryAddress.AsLong() == address.AsLong())
return true;
201 if (m_NetMask.AsLong() == 0)
return false;
202 return (m_PrimaryAddress.AsLong() & m_NetMask.AsLong()) == (address.AsLong() & m_NetMask.AsLong());
238 void SetMacAddress(NPT_MacAddress::Type type,
239 const unsigned char* addr,
240 unsigned int length) {
241 m_MacAddress.SetAddress(type, addr, length);
243 NPT_Flags GetFlags()
const {
return m_Flags; }
251 if ((*iter).IsAddressInNetwork(address))
return true;
272 static NPT_Result Resolve(
const char* name,
274 NPT_Timeout timeout = NPT_TIMEOUT_INFINITE);
277 #endif // _NPT_NETWORK_H_ Definition: NptNetwork.h:216
Definition: NptNetwork.h:136
Definition: NptNetwork.h:74
Definition: NptNetwork.h:268
Definition: NptNetwork.h:172
Definition: NptStrings.h:57