Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/proxy/src/lib/util/ip.cc @ 9305

Last change on this file since 9305 was 9305, checked in by bensch, 18 years ago

compiles again

File size: 827 bytes
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
11IP::IP()
12{}
13
14
15IP::IP(int ip)
16{
17  this->_ip = ip;
18}
19
20IP::IP(const std::string& ip)
21{
22  this->_ip = IP::stringToIP(ip);
23}
24
25
26
27
28int IP::stringToIP(const std::string& ip)
29{
30
31}
32
33std::string IP::ipToString(const IPaddress& ipaddr)
34{
35  int ip = SDLNet_Read32 (ipaddr.host);
36  return ipToString(ip);
37}
38
39
40std::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.