Line | |
---|
1 | /** |
---|
2 | * @file ip.cc |
---|
3 | * @brief A IP class, that handles all about time. |
---|
4 | * |
---|
5 | * code taken from audiere. |
---|
6 | */ |
---|
7 | |
---|
8 | #include "ip.h" |
---|
9 | #include "multi_type.h" |
---|
10 | |
---|
11 | IP::IP() |
---|
12 | {} |
---|
13 | |
---|
14 | |
---|
15 | IP::IP(int ip) |
---|
16 | { |
---|
17 | this->_ip = ip; |
---|
18 | } |
---|
19 | |
---|
20 | IP::IP(const std::string& ip) |
---|
21 | { |
---|
22 | this->_ip = IP::stringToIP(ip); |
---|
23 | } |
---|
24 | |
---|
25 | |
---|
26 | |
---|
27 | |
---|
28 | int IP::stringToIP(const std::string& ip) |
---|
29 | { |
---|
30 | |
---|
31 | } |
---|
32 | |
---|
33 | std::string IP::ipToString(const IPaddress& ipaddr) |
---|
34 | { |
---|
35 | int ip = SDLNet_Read32 (ipaddr.host); |
---|
36 | return ipToString(ip); |
---|
37 | } |
---|
38 | |
---|
39 | |
---|
40 | std::string IP::ipToString(int ip) |
---|
41 | { |
---|
42 | MultiType part0( (ip & 0xFF000000) >> 24); |
---|
43 | MultiType part1( (ip & 0x00FF0000) >> 16); |
---|
44 | MultiType part2( (ip & 0x0000FF00) >> 8); |
---|
45 | MultiType part3( (ip & 0x000000FF) ); |
---|
46 | |
---|
47 | |
---|
48 | return part0.getString() + "." + part1.getString() + "." + |
---|
49 | part2.getString() + "." + part3.getString(); |
---|
50 | } |
---|
51 | |
---|
Note: See
TracBrowser
for help on using the repository browser.