//=========================================================================== // $Name: $ // $Id: ArtsBgp4Prefix.hh,v 1.1.1.1 2000/03/29 22:53:56 kkeys Exp $ //=========================================================================== // CAIDA 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 General Public License, // v. 2 dated June 1991 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 GPL along with arts++. // Copies can also be obtained from: // // http://www.gnu.org/copyleft/gpl.html // // or by writing to: // // University of California, San Diego // // SDSC/CAIDA // 9500 Gilman Dr., MS-0505 // La Jolla, CA 92093 - 0505 USA // // Or contact: // // info@caida.org //=========================================================================== #ifndef _ARTSBGP4PREFIX_HH_ #define _ARTSBGP4PREFIX_HH_ extern "C" { #include #include #include "caida_t.h" } 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); private: uint8_t _addressFamily; // AF_INET or AF_INET6 ArtsBgp4NetworkPrefix_t _network; // network address uint8_t _maskLength; // network mask length }; #endif // _ARTSBGP4PREFIX_HH_