//=========================================================================== // $Name: arts++-1-1-a12 $ // $Id: ArtsBgp4RouteTableData.hh,v 1.2 2004/04/21 23:51:26 kkeys 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 _ARTSBGP4ROUTETABLEDATA_HH_ #define _ARTSBGP4ROUTETABLEDATA_HH_ #include "ArtsBgp4RouteEntry.hh" #include "Ipv4PrefixPatricia.hh" //--------------------------------------------------------------------------- // class ArtsBgp4RouteTableData //--------------------------------------------------------------------------- //! This class abstracts a BGP4 route table, but for selected routes //! only (1 entry per IPv4 network prefix). //--------------------------------------------------------------------------- class ArtsBgp4RouteTableData { public: //-------------------------------------------------------------------------- // ArtsBgp4RouteTableData() //.......................................................................... //! constructor //-------------------------------------------------------------------------- ArtsBgp4RouteTableData(); //-------------------------------------------------------------------------- // ~ArtsBgp4RouteTableData() //.......................................................................... //! destructor //-------------------------------------------------------------------------- ~ArtsBgp4RouteTableData(); //------------------------------------------------------------------------- // uint32_t NumRoutes() const //......................................................................... //! Returns the number of prefixes (routes) stored in the table. //------------------------------------------------------------------------- uint32_t NumRoutes() const; //-------------------------------------------------------------------------- // ArtsBgp4RouteEntry & // AddRoute(const Ipv4Network & prefix, // const ArtsBgp4RouteEntry & routeEntry) //.......................................................................... //! Adds routeEntry for prefix to the route table. Returns a reference //! to the inserted ArtsBgp4RouteEntry. //-------------------------------------------------------------------------- ArtsBgp4RouteEntry & AddRoute(const Ipv4Network & prefix, const ArtsBgp4RouteEntry & routeEntry); //-------------------------------------------------------------------------- // bool DeleteRoute(const Ipv4Network & prefix) //.......................................................................... //! Deletes the route for prefix. Returns true if route was deleted, //! false if route wasn't in table before calling. //-------------------------------------------------------------------------- bool DeleteRoute(const Ipv4Network & prefix); //------------------------------------------------------------------------- // Ipv4PrefixPatricia & Routes() const //......................................................................... //! Returns a reference to the encapsulated //! Ipv4PrefixPatricia holding the route data. //------------------------------------------------------------------------- Ipv4PrefixPatricia & Routes() const; //-------------------------------------------------------------------------- // std::istream & read(std::istream & is, uint8_t version = 0) //.......................................................................... //! Reads an ArtsBgp4RouteTableData from an istream. Returns the //! istream. //-------------------------------------------------------------------------- std::istream & read(std::istream & is, uint8_t version = 0); //-------------------------------------------------------------------------- // int read(int fd, uint8_t version = 0) //.......................................................................... //! UNTESTED!!! //! Reads an ArtsBgp4RouteTableData from a file descriptor. Returns //! the number of bytes read on success, -1 on failure. //-------------------------------------------------------------------------- int read(int fd, uint8_t version = 0); //-------------------------------------------------------------------------- // std::ostream & write(std::ostream & os, uint8_t version = 0) const; //.......................................................................... //! Writes an ArtsBgp4RouteTableData to an ostream. Returns the //! ostream. //-------------------------------------------------------------------------- std::ostream & write(std::ostream & os, uint8_t version = 0) const; //-------------------------------------------------------------------------- // int write(int fd, uint8_t version = 0) const //.......................................................................... //! UNTESTED!!! //! Writes an ArtsBgp4RouteTableData to a file descriptor. Returns the //! number of bytes written on success, -1 on failure. //-------------------------------------------------------------------------- int write(int fd, uint8_t version = 0) const; //-------------------------------------------------------------------------- // uint32_t Length(uint8_t version = 0) const //.......................................................................... //! Returns the bytes required to store the ArtsBgp4RouteTableData //! object in a file. //-------------------------------------------------------------------------- uint32_t Length(uint8_t version = 0) const; //-------------------------------------------------------------------------- // friend std::ostream & // operator << (std::ostream & os, // const ArtsBgp4RouteTableData & bgp4RouteTable) //.......................................................................... //! Overloaded ostream '<<' operator to dump the contents of an //! ArtsBgp4RouteTableData object to an ostream in a human-readable //! form. Returns the ostream. //-------------------------------------------------------------------------- friend std::ostream & operator << (std::ostream & os, const ArtsBgp4RouteTableData & bgp4RouteTable); private: mutable Ipv4PrefixPatricia _routes; static uint32_t _numObjects; }; #endif // _ARTSBGP4ROUTETABLEDATA_HH_