summaryrefslogtreecommitdiffstats
path: root/core/io/ip_address.h
diff options
context:
space:
mode:
authorAriel Manzur <ariel@godotengine.org>2016-10-18 18:53:18 -0300
committerAriel Manzur <ariel@godotengine.org>2016-10-18 18:53:18 -0300
commit887a897c02144f2d01896d3112bdae5ce7d6df5c (patch)
tree5557c275d7cf9d32312b66db8f1003676e318d16 /core/io/ip_address.h
parent048bffd13a49067e646f65152c3cc6b87bacc1c3 (diff)
downloadredot-engine-887a897c02144f2d01896d3112bdae5ce7d6df5c.tar.gz
adding ipv6
Diffstat (limited to 'core/io/ip_address.h')
-rw-r--r--core/io/ip_address.h38
1 files changed, 32 insertions, 6 deletions
diff --git a/core/io/ip_address.h b/core/io/ip_address.h
index 1292311729..fe13d70611 100644
--- a/core/io/ip_address.h
+++ b/core/io/ip_address.h
@@ -33,22 +33,48 @@
struct IP_Address {
+public:
+ enum AddrType {
+ TYPE_NONE = 0,
+ TYPE_IPV4 = 1,
+ TYPE_IPV6 = 2,
+
+ TYPE_ANY = 3,
+ };
+
+ AddrType type;
+
union {
- uint8_t field[4];
- uint32_t host;
+ uint8_t field8[16];
+ uint16_t field16[8];
+ uint32_t field32[4];
};
+protected:
+ void _parse_ipv6(const String& p_string);
+ void _parse_ipv4(const String& p_string, int p_start, uint8_t* p_ret);
+
+public:
//operator Variant() const;
bool operator==(const IP_Address& p_ip) const {
- return host==p_ip.host;
+ for (int i=0; i<4; i++)
+ if (field32[i] != p_ip.field32[i])
+ return false;
+ return true;
}
bool operator!=(const IP_Address& p_ip) const {
- return host!=p_ip.host;
+ for (int i=0; i<4; i++)
+ if (field32[i] != p_ip.field32[i])
+ return true;
+ return false;
}
+
+ void clear();
+
operator String() const;
IP_Address(const String& p_string);
- IP_Address(uint8_t p_a,uint8_t p_b,uint8_t p_c,uint8_t p_d);
- IP_Address() { host=0; }
+ 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; }
};