3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #define _WIN32_WINNT 0x0501
30 #include <netinet/in.h>
35 #include "irrlichttypes.h"
36 #include "networkexceptions.h"
38 class IPv6AddressBytes
42 IPv6AddressBytes() { memset(bytes, 0, 16); }
49 Address(u32 address, u16 port);
50 Address(u8 a, u8 b, u8 c, u8 d, u16 port);
51 Address(const IPv6AddressBytes *ipv6_bytes, u16 port);
52 bool operator==(const Address &address);
53 bool operator!=(const Address &address);
54 // Resolve() may throw ResolveError (address is unchanged in this case)
55 void Resolve(const char *name);
56 struct sockaddr_in getAddress() const;
57 unsigned short getPort() const;
58 void setAddress(u32 address);
59 void setAddress(u8 a, u8 b, u8 c, u8 d);
60 void setAddress(const IPv6AddressBytes *ipv6_bytes);
61 struct sockaddr_in6 getAddress6() const;
62 int getFamily() const;
65 void setPort(unsigned short port);
66 void print(std::ostream *s) const;
67 std::string serializeString() const;
70 unsigned int m_addr_family = 0;
73 struct sockaddr_in ipv4;
74 struct sockaddr_in6 ipv6;
76 u16 m_port = 0; // Port is separate from sockaddr structures