ipaddress.hh

Go to the documentation of this file.
00001 // Copyright (C) 2003-2006 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,
00018 // Boston, MA  02110-1301, USA.
00019 
00031 
00032 #ifndef QOLYESTER_NET_IPADDRESS_HH
00033 # define QOLYESTER_NET_IPADDRESS_HH 1
00034 
00035 # include "config.hh"
00036 
00037 # if !defined QOLYESTER_FAMILY_INET
00038 #  define QOLYESTER_FAMILY_INET 6
00039 # endif
00040 
00041 # if QOLYESTER_FAMILY_INET == 4
00042 
00043 #  include "ipv4.hh"
00044 
00045 namespace olsr {
00046 
00047   typedef net::IPv4Address      address_t;
00048 
00049 } // namespace olsr
00050 
00051 # elif QOLYESTER_FAMILY_INET == 6
00052 
00053 #  include "ipv6.hh"
00054 
00055 namespace olsr {
00056 
00057   typedef net::IPv6Address      address_t;
00058 
00059 } // namespace olsr
00060 
00061 # endif
00062 
00063 namespace olsr {
00064 
00065 # define ADDRESS_SIZE   (address_t::address_size)
00066 
00067   address_t             main_addr;
00068 
00078   namespace concept_check {
00079 
00080     typedef address_t::sockaddr_t       tdcheck0;
00081     typedef address_t::addr_t           tdcheck1;
00082 
00083     enum {
00084       echeck0 = address_t::address_size,
00085       echeck1 = address_t::proto,
00086       echeck2 = address_t::family
00087     };
00088 
00089     struct address_check {
00090     protected:
00091       address_check() {
00092         // checking constructors
00093         address_t       dummy0;
00094         address_t       dummy1(*(const address_t::addr_t*) 0);
00095         address_t       dummy2(*(const address_t::sockaddr_t*) 0);
00096         address_t       dummy3(reinterpret_cast<const u_int8_t*>(""), 0U);
00097         address_t       dummy4(std::string(""));
00098 
00099         // checking methods
00100         const std::string (address_t::* pdummy0)() const =
00101           &address_t::to_string;
00102 
00103         const address_t::sockaddr_t (address_t::* pdummy1)(u_int16_t) const =
00104           &address_t::make_sockaddr;
00105 
00106         void (address_t::* pdummy2)(void*) const = &address_t::dump;
00107 
00108         const address_t*        pdummy3 = &address_t::addr_any;
00109 
00110         const address_t (*pdummy4)(const address_t&, unsigned) =
00111           &address_t::network;
00112 
00113         const address_t (*pdummy5)(const std::string&) = &address_t::resolve;
00114 
00115         bool (address_t::* pdummy6)(const address_t&) const =
00116           &address_t::operator<;
00117 
00118         bool (address_t::* pdummy7)(const address_t&) const =
00119           &address_t::operator==;
00120 
00121         bool (address_t::* pdummy8)(const address_t&) const =
00122           &address_t::operator!=;
00123 
00124         unsigned long (address_t::* pdummy9)() const = &address_t::hash;
00125 
00126         void (*pdummy10)(address_t::sockaddr_t&, unsigned) =
00127           &address_t::set_scope_index;
00128 
00129         bool (address_t::* pdummy11)() const = &address_t::is_linklocal;
00130 
00131         unsigned (*pdummy12)(const address_t&) = &address_t::netmask_to_prefix;
00132 
00133         const unsigned char* (address_t::* pdummy13)() const =
00134           &address_t::bytes;
00135 
00136         address_t (*pdummy14)(unsigned) = &address_t::netmask;
00137 
00138         // Shut the fcsk up GCC
00139         (void) dummy0;
00140         (void) dummy1;
00141         (void) dummy2;
00142         (void) dummy3;
00143         (void) dummy4;
00144         (void) pdummy0;
00145         (void) pdummy1;
00146         (void) pdummy2;
00147         (void) pdummy3;
00148         (void) pdummy4;
00149         (void) pdummy5;
00150         (void) pdummy6;
00151         (void) pdummy7;
00152         (void) pdummy8;
00153         (void) pdummy9;
00154         (void) pdummy10;
00155         (void) pdummy11;
00156         (void) pdummy12;
00157         (void) pdummy13;
00158         (void) pdummy14;
00159       }
00160     };
00161 
00162   } // concept_check
00163 
00164 } // namespace olsr
00165 
00166 # if defined __GNUC__ && __GNUC__ >= 3
00167 #  if __GNUC__ >= 4 || __GNUC_MINOR__ >= 2
00168 namespace __gnu_cxx {
00169 #  else
00170 namespace std {
00171 #  endif
00172 # endif
00173 
00174   template <>
00175   struct hash<olsr::address_t> {
00176     size_t operator()(const olsr::address_t& a) const {
00177       return a.hash();
00178     }
00179   };
00180 
00181 # if defined __GNUC__ && __GNUC__ >= 3
00182 #  if __GNUC__ >= 4 || __GNUC_MINOR__ >= 2
00183 } // namespace __gnu_cxx
00184 #  else
00185 } // namespace std
00186 #  endif
00187 # endif
00188 
00189 #endif // ! QOLYESTER_NET_IPADDRESS_HH

Generated on Mon Sep 10 17:02:12 2007 for Qolyester daemon by  doxygen 1.5.1