Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

ipaddress.hh

Go to the documentation of this file.
00001 // Copyright (C) 2003, 2004, 2005 Laboratoire de Recherche en Informatique
00002 
00003 // This file is part of Qolyester.
00004 
00005 // Qolyester is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
00009 
00010 // Qolyester is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00018 
00030 
00031 #ifndef QOLYESTER_NET_IPADDRESS_HH
00032 # define QOLYESTER_NET_IPADDRESS_HH 1
00033 
00034 # include "config.hh"
00035 
00036 # if !defined QOLYESTER_FAMILY_INET
00037 #  define QOLYESTER_FAMILY_INET 6
00038 # endif
00039 
00040 # if QOLYESTER_FAMILY_INET == 4
00041 
00042 #  include "ipv4.hh"
00043 
00044 namespace olsr {
00045 
00046   typedef net::IPv4Address      address_t;
00047 
00048 } // namespace olsr
00049 
00050 # elif QOLYESTER_FAMILY_INET == 6
00051 
00052 #  include "ipv6.hh"
00053 
00054 namespace olsr {
00055 
00056   typedef net::IPv6Address      address_t;
00057 
00058 } // namespace olsr
00059 
00060 # endif
00061 
00062 namespace olsr {
00063 
00064 # define ADDRESS_SIZE   (address_t::address_size)
00065 
00066   address_t             main_addr;
00067 
00077   namespace concept_check {
00078 
00079     typedef address_t::sockaddr_t       tdcheck0;
00080     typedef address_t::addr_t           tdcheck1;
00081 
00082     enum {
00083       echeck0 = address_t::address_size,
00084       echeck1 = address_t::proto,
00085       echeck2 = address_t::family
00086     };
00087 
00088     struct address_check {
00089     protected:
00090       address_check() {
00091         // checking constructors
00092         address_t       dummy0;
00093         address_t       dummy1(*(const address_t::addr_t*) 0);
00094         address_t       dummy2(*(const address_t::sockaddr_t*) 0);
00095         address_t       dummy3(reinterpret_cast<const u_int8_t*>(""), 0U);
00096         address_t       dummy4(std::string(""));
00097 
00098         // checking methods
00099         const std::string (address_t::* pdummy0)() const =
00100           &address_t::to_string;
00101 
00102         const address_t::sockaddr_t (address_t::* pdummy1)(u_int16_t) const =
00103           &address_t::make_sockaddr;
00104 
00105         void (address_t::* pdummy2)(u_int8_t*) const = &address_t::dump;
00106 
00107         const address_t*        pdummy3 = &address_t::addr_any;
00108 
00109         const address_t (*pdummy4)(const address_t&, unsigned) =
00110           &address_t::network;
00111 
00112         const address_t (*pdummy5)(const std::string&) = &address_t::resolve;
00113 
00114         bool (address_t::* pdummy6)(const address_t&) const =
00115           &address_t::operator<;
00116 
00117         bool (address_t::* pdummy7)(const address_t&) const =
00118           &address_t::operator==;
00119 
00120         bool (address_t::* pdummy8)(const address_t&) const =
00121           &address_t::operator!=;
00122 
00123         unsigned long (address_t::* pdummy9)() const = &address_t::hash;
00124 
00125         void (*pdummy10)(address_t::sockaddr_t&, unsigned) =
00126           &address_t::set_scope_index;
00127 
00128         bool (address_t::* pdummy11)() const = &address_t::is_linklocal;
00129 
00130         unsigned (*pdummy12)(const address_t&) = &address_t::netmask_to_prefix;
00131 
00132         const unsigned char* (address_t::* pdummy13)() const =
00133           &address_t::bytes;
00134 
00135         address_t (*pdummy14)(unsigned) = &address_t::netmask;
00136 
00137         // Shut the fcsk up GCC
00138         (void) dummy0;
00139         (void) dummy1;
00140         (void) dummy2;
00141         (void) dummy3;
00142         (void) dummy4;
00143         (void) pdummy0;
00144         (void) pdummy1;
00145         (void) pdummy2;
00146         (void) pdummy3;
00147         (void) pdummy4;
00148         (void) pdummy5;
00149         (void) pdummy6;
00150         (void) pdummy7;
00151         (void) pdummy8;
00152         (void) pdummy9;
00153         (void) pdummy10;
00154         (void) pdummy11;
00155         (void) pdummy12;
00156         (void) pdummy13;
00157         (void) pdummy14;
00158       }
00159     };
00160 
00161   } // concept_check
00162 
00163 } // namespace olsr
00164 
00165 # if defined __GNUC__ && __GNUC__ >= 3
00166 #  if __GNUC__ >= 4 || __GNUC_MINOR__ >= 2
00167 namespace __gnu_cxx {
00168 #  else
00169 namespace std {
00170 #  endif
00171 # endif
00172 
00173   template <>
00174   struct hash<olsr::address_t> {
00175     size_t operator()(const olsr::address_t& a) const {
00176       return a.hash();
00177     }
00178   };
00179 
00180 # if defined __GNUC__ && __GNUC__ >= 3
00181 #  if __GNUC__ >= 4 || __GNUC_MINOR__ >= 2
00182 } // namespace __gnu_cxx
00183 #  else
00184 } // namespace std
00185 #  endif
00186 # endif
00187 
00188 #endif // ! QOLYESTER_NET_IPADDRESS_HH

Generated on Thu Jul 28 21:21:47 2005 for Qolyester daemon by  doxygen 1.4.1