Thu, 11 Dec 2014 07:18:11 +0200
- added huffman lib, now capable of initializing an rcon connection!
5 | 1 | #pragma once |
2 | #include "../main.h" | |
3 | ||
4 | struct sockaddr; | |
7
01e4e9ae323a
- fixed some problems with the ip address
Teemu Piippo <crimsondusk64@gmail.com>
parents:
5
diff
changeset
|
5 | struct sockaddr_in; |
5 | 6 | |
7 | enum WithPort { IP_WITH_PORT, IP_NO_PORT }; | |
8 | ||
9 | struct IPAddress | |
10 | { | |
11 | unsigned long host; | |
12 | unsigned short port; | |
13 | static bool sink; | |
14 | ||
15 | IPAddress(); | |
16 | IPAddress (unsigned long host, unsigned short port); | |
17 | IPAddress (const IPAddress& other); | |
18 | ||
19 | METHOD compare (const IPAddress& other) const -> bool; | |
20 | METHOD octet (int n) const -> unsigned char; | |
21 | METHOD set_octet (int n, unsigned char oct) -> void; | |
22 | METHOD to_string (WithPort withport = IP_NO_PORT) const -> String; | |
23 | METHOD to_sockaddr_in() const -> sockaddr_in; | |
24 | METHOD operator< (const IPAddress& other) const -> bool; | |
25 | inline METHOD operator== (const IPAddress& other) const -> bool; | |
26 | inline METHOD operator!= (const IPAddress& other) const -> bool; | |
27 | inline METHOD operator[] (int n) const -> unsigned char; | |
28 | ||
29 | static METHOD from_string (String input, bool* ok = &sink) -> IPAddress; | |
30 | static METHOD resolve (String node, bool* ok = &sink) -> IPAddress; | |
31 | }; | |
32 | ||
8
8b697d30c49f
- added huffman lib, now capable of initializing an rcon connection!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
33 | static const unsigned long localhost = 0x7F000001; |
5 | 34 | |
35 | inline METHOD | |
36 | IPAddress::operator[] (int n) const -> unsigned char | |
37 | { | |
38 | return octet (n); | |
39 | } | |
40 | ||
41 | inline METHOD | |
42 | IPAddress::operator== (const IPAddress& other) const -> bool | |
43 | { | |
44 | return compare (other); | |
45 | } | |
46 | ||
47 | inline METHOD | |
48 | IPAddress::operator!= (const IPAddress& other) const -> bool | |
49 | { | |
50 | return not operator== (other); | |
51 | } |