//=========================================================================== // $Name: arts++-1-1-a12 $ // $Id: ArtsBgp4Prefix.hh,v 1.1.1.1 2002/11/16 00:46:40 rkoga Exp $ //=========================================================================== // Copyright Notice // // By accessing this software, arts++, you are duly informed // of and agree to be bound by the conditions described below in this // notice: // // This software product, arts++, is developed by Daniel W. McRobb, and // copyrighted(C) 1998 by the University of California, San Diego // (UCSD), with all rights reserved. UCSD administers the CAIDA grant, // NCR-9711092, under which part of this code was developed. // // There is no charge for arts++ software. You can redistribute it // and/or modify it under the terms of the GNU Lesser General Public // License, Version 2.1, February 1999, which is incorporated by // reference herein. // // arts++ is distributed WITHOUT ANY WARRANTY, IMPLIED OR EXPRESS, OF // MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE or that the use // of it will not infringe on any third party's intellectual // property rights. // // You should have received a copy of the GNU Lesser General Public // License along with arts++. Copies can also be obtained from: // // http://www.gnu.org/copyleft/lesser.html // // or by writing to: // // Free Software Foundation, Inc. // 59 Temple Place, Suite 330 // Boston, MA 02111-1307 // USA // // Or contact: // // info@caida.org //=========================================================================== #ifndef _ARTSBGP4PREFIX_HH_ #define _ARTSBGP4PREFIX_HH_ extern "C" { #include #include #include "caida_t.h" } //---------------------------------------------------------------------------- //! Used to hold an IP network address. //---------------------------------------------------------------------------- typedef struct { union { ipv4addr_t ipv4addr; #ifdef HAVE_IPV6 ipv6addr_t ipv6addr; #endif } network; } ArtsBgp4NetworkPrefix_t; //------------------------------------------------------------------------- // class ArtsBgp4Prefix //------------------------------------------------------------------------- //! This class abstracts an IPv4 or IPv6 network prefix. It contains //! an IP address and a netmask length. In the case of a host address, //! the netmask length is equal to the length of the address (in bits). //------------------------------------------------------------------------- class ArtsBgp4Prefix { public: //------------------------------------------------------------------------- // uint8_t AddressFamily() const //......................................................................... //! Returns the address family for the ArtsBgp4Prefix (AF_INET or //! AF_INET6). //------------------------------------------------------------------------- uint8_t AddressFamily() const; //------------------------------------------------------------------------- // uint8_t AddressFamily(uint8_t addressFamily) //......................................................................... //! Sets and returns the address family for the ArtsBgp4Prefix. //------------------------------------------------------------------------- uint8_t AddressFamily(uint8_t addressFamily); //------------------------------------------------------------------------- // uint8_t MaskLength() const //......................................................................... //! Returns the length of the netmask for the ArtsBgp4Prefix. //------------------------------------------------------------------------- uint8_t MaskLength() const; //------------------------------------------------------------------------- // uint8_t MaskLength(uint8_t maskLength) //......................................................................... //! Sets and returns the length of the netmask for the ArtsBgp4Prefix. //------------------------------------------------------------------------- uint8_t MaskLength(uint8_t maskLength); //------------------------------------------------------------------------- // ipv4addr_t Ipv4Network() const //......................................................................... //! If the ArtsBgp4Prefix holds an IPv4 prefix, returns the IPv4 //! address in the ArtsBgp4Prefix. //------------------------------------------------------------------------- ipv4addr_t Ipv4Network() const; //------------------------------------------------------------------------- // ipv4addr_t Ipv4Network(ipv4addr_t ipv4Network) //......................................................................... //! Sets and returns the IPv4 address in the ArtsBgp4Prefix. //------------------------------------------------------------------------- ipv4addr_t Ipv4Network(ipv4addr_t ipv4Network); #ifdef HAVE_IPV6 //------------------------------------------------------------------------- // ipv6addr_t Ipv6Network() const //......................................................................... //! If the ArtsBgp4Prefix holds an IPv6 prefix, returns the IPv6 //! address in the ArtsBgp4Prefix. //------------------------------------------------------------------------- ipv6addr_t Ipv6Network() const; //------------------------------------------------------------------------- // ipv6addr_t Ipv6Network(ipv6addr_t ipv6Network) //......................................................................... //! Sets and returns the IPv6 address in the ArtsBgp4Prefix. //------------------------------------------------------------------------- ipv6addr_t Ipv6Network(ipv6addr_t ipv6Network); #endif // HAVE_IPV6 //------------------------------------------------------------------------- // operator = (const ArtsBgp4Prefix & bgp4prefix) //......................................................................... //! Overloaded '=' operator for assigning the value of an //! ArtsBgp4Prefix from another ArtsBgp4Prefix. //------------------------------------------------------------------------- ArtsBgp4Prefix & operator = (const ArtsBgp4Prefix & bgp4prefix); #ifndef NDEBUG //------------------------------------------------------------------------ // static uint32_t NumObjects() //........................................................................ // //------------------------------------------------------------------------ static uint32_t NumObjects() { return(_numObjects); } #endif // NDEBUG private: uint8_t _addressFamily; // AF_INET or AF_INET6 ArtsBgp4NetworkPrefix_t _network; // network address uint8_t _maskLength; // network mask length static uint32_t _numObjects; }; #endif // _ARTSBGP4PREFIX_HH_