IP_Address now handle IPv4 and IPv6 transparently
IP_Address changes: - Converts to and from String transparently while handling IPv4 as IPv6 mapped (::ffff:[IP]) address internally. - Completely remove AddrType enum. - Setting/Getting of ip array is now only possible through dedicated functions (ie. set_ipv4, get_ipv4, set_ipv6, get_ipv6) - Add function to know if the address is a valid IPv4 (for IP implementation and enet)
This commit is contained in:
parent
a77a0118f6
commit
1aff508dd9
11 changed files with 112 additions and 101 deletions
|
|
@ -33,16 +33,7 @@
|
|||
|
||||
struct IP_Address {
|
||||
|
||||
public:
|
||||
enum AddrType {
|
||||
TYPE_NONE = 0,
|
||||
TYPE_IPV4 = 1,
|
||||
TYPE_IPV6 = 2,
|
||||
|
||||
TYPE_ANY = 3,
|
||||
};
|
||||
|
||||
AddrType type;
|
||||
private:
|
||||
|
||||
union {
|
||||
uint8_t field8[16];
|
||||
|
|
@ -70,11 +61,17 @@ public:
|
|||
}
|
||||
|
||||
void clear();
|
||||
bool is_ipv4() const;
|
||||
const uint8_t *get_ipv4() const;
|
||||
void set_ipv4(const uint8_t *p_ip);
|
||||
|
||||
const uint8_t *get_ipv6() const;
|
||||
void set_ipv6(const uint8_t *buf);
|
||||
|
||||
operator String() const;
|
||||
IP_Address(const String& p_string);
|
||||
IP_Address(uint32_t p_a,uint32_t p_b,uint32_t p_c,uint32_t p_d, AddrType p_type=TYPE_IPV4);
|
||||
IP_Address() { clear(); type=TYPE_NONE; }
|
||||
IP_Address(uint32_t p_a,uint32_t p_b,uint32_t p_c,uint32_t p_d, bool is_v6=false);
|
||||
IP_Address() { clear(); }
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue