Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9385 in orxonox.OLD for branches/proxy/src/lib/network/ip.cc


Ignore:
Timestamp:
Jul 21, 2006, 1:09:19 PM (18 years ago)
Author:
bensch
Message:

orxonox/proxy: better proxy-width approximation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/proxy/src/lib/network/ip.cc

    r9383 r9385  
    3232IP::IP()
    3333{
    34   this->_ip = 0;
     34  this->_host = 0;
    3535  this->_port = IP::_defaultPort;
    3636}
     
    4545IP::IP(int ip, int port)
    4646{
    47   this->_ip = ip;
     47  this->_host = ip;
    4848  if (port != -1)
    4949    this->_port = port;
     
    8484IP::IP(const IPaddress& ip)
    8585{
    86   this->_ip = ip.host;
     86  this->_host = ip.host;
    8787  this->_port = ip.port;
    8888}
     
    9898  *this = ip;
    9999}
     100
     101
     102/**
     103 * @brief constructs an IP out of the four pairs and a Port.
     104 * @param first The first octal.
     105 * @param second The second octal.
     106 * @param third The third octal.
     107 * @param fourth The fourth octal.
     108 * @param port The Port.
     109 * @return self.
     110 */
     111IP::IP(unsigned int first, unsigned int second, unsigned int third, unsigned int fourth, int port)
     112{
     113  this->_host = (first << 24) +
     114                (second << 16) +
     115                (third <<  8) +
     116                fourth;
     117  this->_port = port;
     118}
     119
    100120
    101121/**
     
    106126const IP& IP::operator=(const IP& ip)
    107127{
    108   this->_ip = ip.host();
     128  this->_host = ip.host();
    109129  this->_port = ip.port();
    110130  return *this;
     
    119139const IP& IP::operator=(const IPaddress& ip)
    120140{
    121   this->_ip = ip.host;
     141  this->_host = ip.host;
    122142  this->_port = ip.port;
    123143  return *this;
     
    132152bool IP::operator==(const IP& ip) const
    133153{
    134   return (this->_ip == ip.host() &&
     154  return (this->_host == ip.host() &&
    135155          this->_port == ip.port());
    136156}
     
    144164bool IP::operator!=(const IP& ip) const
    145165{
    146   return (this->_ip != ip.host() ||
    147       this->_port != ip.port());
     166  return (this->_host != ip.host() ||
     167          this->_port != ip.port());
    148168}
    149169
     
    199219  {
    200220    case 0:
    201       return  (_ip & 0xFF000000) >> 24;
     221      return  (_host & 0xFF000000) >> 24;
    202222    case 1:
    203       return  (_ip & 0x00FF0000) >> 16;
     223      return  (_host & 0x00FF0000) >> 16;
    204224    case 2:
    205       return  (_ip & 0x0000FF00) >> 8;
     225      return  (_host & 0x0000FF00) >> 8;
    206226    case 3:
    207       return  (_ip & 0x000000FF);
     227      return  (_host & 0x000000FF);
    208228    default:
    209229      return -1;
     
    217237std::string IP::ipString() const
    218238{
    219   return IP::ipToString(this->_ip, this->_port);
     239  return IP::ipToString(this->_host, this->_port);
    220240}
    221241
Note: See TracChangeset for help on using the changeset viewer.