00001 // Copyright (C) 2006 Institut fuer Telematik, Universitaet Karlsruhe (TH) 00002 // 00003 // This program is free software; you can redistribute it and/or 00004 // modify it under the terms of the GNU General Public License 00005 // as published by the Free Software Foundation; either version 2 00006 // of the License, or (at your option) any later version. 00007 // 00008 // This program is distributed in the hope that it will be useful, 00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 // GNU General Public License for more details. 00012 // 00013 // You should have received a copy of the GNU General Public License 00014 // along with this program; if not, write to the Free Software 00015 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00016 // 00017 00024 #include "I3IPAddress.h" 00025 00026 I3IPAddress::I3IPAddress() 00027 { 00028 port = 0; 00029 } 00030 00031 I3IPAddress::I3IPAddress(IPvXAddress add, int p) 00032 { 00033 ip = add; 00034 port = p; 00035 } 00036 00037 bool I3IPAddress::operator<(const I3IPAddress &a) const 00038 { 00039 return ip < a.ip || (ip == a.ip && port < a.port); 00040 } 00041 00042 bool I3IPAddress::operator==(const I3IPAddress &a) const 00043 { 00044 return ip == a.ip && port == a.port; 00045 } 00046 00047 bool I3IPAddress::operator>(const I3IPAddress &a) const 00048 { 00049 return a < *this; 00050 } 00051 00052 int I3IPAddress::length() const { 00053 //return sizeof(address) + sizeof(port); 00054 return (ip.isIPv6() ? 128 : 32) + 16; // 16 = port length 00055 } 00056 00057 std::ostream& operator<<(std::ostream& os, const I3IPAddress& ip) { 00058 os << ip.ip << ':' << ip.port; 00059 return os; 00060 }