Changeset 9305 in orxonox.OLD for branches/proxy/src/lib/util/ip.cc
- Timestamp:
- Jul 17, 2006, 1:54:36 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/proxy/src/lib/util/ip.cc
r9304 r9305 7 7 8 8 #include "ip.h" 9 #include "multi_type.h" 9 10 10 11 IP::IP() … … 23 24 24 25 26 27 25 28 int IP::stringToIP(const std::string& ip) 26 29 { 27 30 28 29 31 } 30 32 31 const std::string& IP::ipToString(int ip)33 std::string IP::ipToString(const IPaddress& ipaddr) 32 34 { 33 std::string ipaddr; 34 35 number = SDLNet_Read32 (&addr.host); 36 printf ("Host-Reihenfolge: %d.%d.%d.%d\n", 37 (number & 0xFF000000)>>24, (number & 0x00FF0000)>>16, 38 (number & 0x0000FF00)>>8, (number & 0x000000FF)); 35 int ip = SDLNet_Read32 (ipaddr.host); 36 return ipToString(ip); 39 37 } 40 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 TracChangeset
for help on using the changeset viewer.