ofs | hex dump | ascii |
---|
0000 | 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 04 00 00 00 04 00 08 03 00 00 00 48 c3 db | .PNG........IHDR.............H.. |
0020 | b1 00 00 01 b9 50 4c 54 45 00 00 00 01 01 01 02 02 02 03 03 03 04 04 04 05 05 05 06 06 06 07 07 | .....PLTE....................... |
0040 | 07 08 08 08 09 09 09 0a 0a 0a 0b 0b 0b 0c 0c 0c 0d 0d 0d 0e 0e 0e 0f 0f 0f 10 10 10 11 11 11 12 | ................................ |
0060 | 12 12 13 13 13 14 14 14 15 15 15 16 16 16 17 17 17 18 18 18 19 19 19 1a 1a 1a 1b 1b 1b 1c 1c 1c | ................................ |
0080 | 1d 1d 1d 1e 1e 1e 1f 1f 1f 20 20 20 21 21 21 22 22 22 23 23 23 24 24 24 25 25 25 26 26 26 27 27 | ............!!!"""###$$$%%%&&&'' |
00a0 | 27 28 28 28 29 29 29 2a 2a 2a 2b 2b 2b 2c 2c 2c 2d 2d 2d 2e 2e 2e 2f 2f 2f 30 30 30 31 31 31 32 | '((()))***+++,,,---...///0001112 |
00c0 | 32 32 33 33 33 34 34 34 35 35 35 36 36 36 ff 00 00 37 37 37 38 38 38 39 39 39 3a 3a 3a 3b 3b 3b | 22333444555666...777888999:::;;; |
00e0 | 3c 3c 3c 3d 3d 3d 3e 3e 3e 3f 3f 3f 40 40 40 41 41 41 42 42 42 43 43 43 44 44 44 45 45 45 46 46 | <<<===>>>???@@@AAABBBCCCDDDEEEFF |
0100 | 46 47 47 47 48 48 48 49 49 49 4a 4a 4a 4b 4b 4b 4c 4c 4c 4d 4d 4d 4e 4e 4e 4f 4f 4f 50 50 50 51 | FGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQ |
0120 | 51 51 52 52 52 53 53 53 54 54 54 55 55 55 56 56 56 57 57 57 58 58 58 59 59 59 5a 5a 5a 5b 5b 5b | QQRRRSSSTTTUUUVVVWWWXXXYYYZZZ[[[ |
0140 | 5c 5c 5c 5d 5d 5d 5e 5e 5e 5f 5f 5f 60 60 60 61 61 61 62 62 62 63 63 63 64 64 64 65 65 65 66 66 | \\\]]]^^^___```aaabbbcccdddeeeff |
0160 | 66 67 67 67 68 68 68 69 69 69 6a 6a 6a 6b 6b 6b 6c 6c 6c 6d 6d 6d 6e 6e 6e 6f 6f 6f 70 70 70 71 | fggghhhiiijjjkkklllmmmnnnooopppq |
0180 | 71 71 72 72 72 73 73 73 74 74 74 75 75
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#pragma once
#ifdef _WIN32
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0501
#endif
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#else
#include <netinet/in.h>
#include <sys/socket.h>
#endif
#include <ostream>
#include <cstring>
#include "irrlichttypes.h"
#include "networkexceptions.h"
struct IPv6AddressBytes
{
u8 bytes[16];
IPv6AddressBytes() { memset(bytes, 0, 16); }
};
class Address
{
public:
Address();
Address(u32 address, u16 port);
Address(u8 a, u8 b, u8 c, u8 d, u16 port);
Address(const IPv6AddressBytes *ipv6_bytes, u16 port);
bool operator==(const Address &address);
bool operator!=(const Address &address) { return !(*this == address); }
struct in_addr getAddress() const;
struct in6_addr getAddress6() const;
u16 getPort() const;
int getFamily() const { return m_addr_family; }
bool isIPv6() const { return m_addr_family == AF_INET6; }
bool isZero() const;
void print(std::ostream *s) const;
std::string serializeString() const;
bool isLocalhost() const;
// Resolve() may throw ResolveError (address is unchanged in this case)
void Resolve(const char *name);
void setAddress(u32 address);
void setAddress(u8 a, u8 b, u8 c, u8 d);
void setAddress(const IPv6AddressBytes *ipv6_bytes);
void setPort(u16 port);
private:
unsigned short m_addr_family = 0;
union
{
struct in_addr ipv4;
struct in6_addr ipv6;
} m_address;
u16 m_port = 0; // Port is separate from sockaddr structures
};
|