Changeset 9385 in orxonox.OLD for branches/proxy/src/lib/network
- Timestamp:
- Jul 21, 2006, 1:09:19 PM (18 years ago)
- Location:
- branches/proxy/src/lib/network
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/proxy/src/lib/network/ip.cc
r9383 r9385 32 32 IP::IP() 33 33 { 34 this->_ ip= 0;34 this->_host = 0; 35 35 this->_port = IP::_defaultPort; 36 36 } … … 45 45 IP::IP(int ip, int port) 46 46 { 47 this->_ ip= ip;47 this->_host = ip; 48 48 if (port != -1) 49 49 this->_port = port; … … 84 84 IP::IP(const IPaddress& ip) 85 85 { 86 this->_ ip= ip.host;86 this->_host = ip.host; 87 87 this->_port = ip.port; 88 88 } … … 98 98 *this = ip; 99 99 } 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 */ 111 IP::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 100 120 101 121 /** … … 106 126 const IP& IP::operator=(const IP& ip) 107 127 { 108 this->_ ip= ip.host();128 this->_host = ip.host(); 109 129 this->_port = ip.port(); 110 130 return *this; … … 119 139 const IP& IP::operator=(const IPaddress& ip) 120 140 { 121 this->_ ip= ip.host;141 this->_host = ip.host; 122 142 this->_port = ip.port; 123 143 return *this; … … 132 152 bool IP::operator==(const IP& ip) const 133 153 { 134 return (this->_ ip== ip.host() &&154 return (this->_host == ip.host() && 135 155 this->_port == ip.port()); 136 156 } … … 144 164 bool IP::operator!=(const IP& ip) const 145 165 { 146 return (this->_ ip!= ip.host() ||147 this->_port != ip.port());166 return (this->_host != ip.host() || 167 this->_port != ip.port()); 148 168 } 149 169 … … 199 219 { 200 220 case 0: 201 return (_ ip& 0xFF000000) >> 24;221 return (_host & 0xFF000000) >> 24; 202 222 case 1: 203 return (_ ip& 0x00FF0000) >> 16;223 return (_host & 0x00FF0000) >> 16; 204 224 case 2: 205 return (_ ip& 0x0000FF00) >> 8;225 return (_host & 0x0000FF00) >> 8; 206 226 case 3: 207 return (_ ip& 0x000000FF);227 return (_host & 0x000000FF); 208 228 default: 209 229 return -1; … … 217 237 std::string IP::ipString() const 218 238 { 219 return IP::ipToString(this->_ ip, this->_port);239 return IP::ipToString(this->_host, this->_port); 220 240 } 221 241 -
branches/proxy/src/lib/network/ip.h
r9383 r9385 26 26 IP(const IPaddress& ip); 27 27 IP(const IP& ip); 28 IP(unsigned int first, unsigned int second, unsigned int third, unsigned int fourth, int port = IP::_defaultPort); 28 29 29 30 /// OPERATORS … … 35 36 /// RETRIVEAL 36 37 /** @returns the IP */ 37 int host() const { return this->_ ip; };38 int* hostRef() { return &this->_ ip; }38 int host() const { return this->_host; }; 39 int* hostRef() { return &this->_host; } 39 40 /** @returns the Port */ 40 41 int port() const { return this->_port; }; 41 42 int* portRef() { return &this->_port; }; 42 43 43 inline IPaddress getSDLNotation() { IPaddress sdlIP; sdlIP.host = this->_ ip; sdlIP.port = this->_port; return sdlIP; }44 inline IPaddress getSDLNotation() { IPaddress sdlIP; sdlIP.host = this->_host; sdlIP.port = this->_port; return sdlIP; } 44 45 45 46 int ipPart(unsigned int part) const; … … 59 60 60 61 private: 61 int _ ip; //!< The IP in int form.62 int _port; //!< The Port number of the IP62 int _host; //!< The IP in int form. 63 int _port; //!< The Port number of the IP 63 64 64 static int _defaultPort; //!< Default Port65 static int _defaultPort; //!< Default Port 65 66 }; 66 67
Note: See TracChangeset
for help on using the changeset viewer.