//=========================================================================== // $Name: $ // $Id: ArtsBgp4Attribute.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 _ARTSBGP4ATTRIBUTE_HH_ #define _ARTSBGP4ATTRIBUTE_HH_ extern "C" { #include "caida_t.h" } #include #include "ArtsBgp4AsPathAttribute.hh" #include "ArtsBgp4AggregatorAttribute.hh" #include "ArtsBgp4DPAttribute.hh" //--------------------------------------------------------------------------- // origin (IGP, EGP, incomplete) attribute //--------------------------------------------------------------------------- const uint16_t Bgp4_Attribute_Origin(); #define Bgp4_Attribute_Origin 1 //--------------------------------------------------------------------------- // AS path attribute //--------------------------------------------------------------------------- const uint16_t Bgp4_Attribute_AsPath(); #define Bgp4_Attribute_AsPath 2 //--------------------------------------------------------------------------- // next hop attribute //--------------------------------------------------------------------------- const uint16_t Bgp4_Attribute_NextHop(); #define Bgp4_Attribute_NextHop 3 //--------------------------------------------------------------------------- // M.E.D. attribute //--------------------------------------------------------------------------- const uint16_t Bgp4_Attribute_MultiExitDisc(); #define Bgp4_Attribute_MultiExitDisc 4 //--------------------------------------------------------------------------- // local preference attribute //--------------------------------------------------------------------------- const uint16_t Bgp4_Attribute_LocalPref(); #define Bgp4_Attribute_LocalPref 5 //--------------------------------------------------------------------------- // atomic aggregate attribute //--------------------------------------------------------------------------- const uint16_t Bgp4_Attribute_AtomicAggregate(); #define Bgp4_Attribute_AtomicAggregate 6 //--------------------------------------------------------------------------- // aggregator attribute //--------------------------------------------------------------------------- const uint16_t Bgp4_Attribute_Aggregator(); #define Bgp4_Attribute_Aggregator 7 //--------------------------------------------------------------------------- // community attribute //--------------------------------------------------------------------------- const uint16_t Bgp4_Attribute_Community(); #define Bgp4_Attribute_Community 8 //--------------------------------------------------------------------------- // DPA attribute //--------------------------------------------------------------------------- const uint16_t Bgp4_Attribute_DPA(); #define Bgp4_Attribute_DPA 11 //--------------------------------------------------------------------------- // Multiprotocol Reachable attribute //--------------------------------------------------------------------------- const uint16_t Bgp4_Attribute_MPReachNLRI(); #define Bgp4_Attribute_MPReachNLRI 14 //--------------------------------------------------------------------------- // Multiprotocol Unreachable attribute //--------------------------------------------------------------------------- const uint16_t Bgp4_Attribute_MPUnreachNLRI(); #define Bgp4_Attribute_MPUnreachNLRI 15 //--------------------------------------------------------------------------- // class ArtsBgp4Attribute //--------------------------------------------------------------------------- // This class abstracts a BGP4 attribute. This is a container class // for a discriminate union that lets us store any type of BGP4 attribute // from the set of supported BGP attributes (all the required attributes // plus community, DPA, Aggregator and MED). Note that this class does // *not* abstract any 0-length attributes like Atomic Aggregate. //--------------------------------------------------------------------------- class ArtsBgp4Attribute { public: //------------------------------------------------------------------------- // ArtsBgp4Attribute() //......................................................................... // constructor //------------------------------------------------------------------------- ArtsBgp4Attribute(); //------------------------------------------------------------------------- // ~ArtsBgp4Attribute() //......................................................................... // destructor //------------------------------------------------------------------------- ~ArtsBgp4Attribute(); //------------------------------------------------------------------------- // uint8_t Flags() const //......................................................................... // Returns the flags in the attribute. //------------------------------------------------------------------------- uint8_t Flags() const; //------------------------------------------------------------------------- // uint8_t Flags(uint8_t flags) //......................................................................... // Sets and returns the flags in the attribute. //------------------------------------------------------------------------- uint8_t Flags(uint8_t flags); //------------------------------------------------------------------------- // uint8_t Type() const //......................................................................... // Returns the type of the attribute (Bgp4_Attribute_NextHop, // Bgp4_Attribute_Community, ...). //------------------------------------------------------------------------- uint8_t Type() const; //------------------------------------------------------------------------- // uint8_t Type(uint8_t attrType) //......................................................................... // Sets and returns the type of the attribute (Bgp4_Attribute_NextHop, // Bgp4_Attribute_Community, ...). //------------------------------------------------------------------------- uint8_t Type(uint8_t attrType); //------------------------------------------------------------------------- // uint16_t Length() const //......................................................................... // Returns the attribute length. Note this is an attribute-type // dependent value. //------------------------------------------------------------------------- uint16_t Length() const; //------------------------------------------------------------------------- // uint16_t Length(uint16_t length) //......................................................................... // //------------------------------------------------------------------------- uint16_t Length(uint16_t length); //------------------------------------------------------------------------- // uint8_t Origin() const //......................................................................... // //------------------------------------------------------------------------- uint8_t Origin() const; //------------------------------------------------------------------------- // uint8_t Origin(uint8_t origin) //......................................................................... // //------------------------------------------------------------------------- uint8_t Origin(uint8_t origin); //------------------------------------------------------------------------- // const ArtsBgp4AsPathAttribute * AsPath() const //......................................................................... // //------------------------------------------------------------------------- const ArtsBgp4AsPathAttribute * AsPath() const; //------------------------------------------------------------------------- // const ArtsBgp4AsPathAttribute * // AsPath(const ArtsBgp4AsPathAttribute & asPath) //......................................................................... // //------------------------------------------------------------------------- const ArtsBgp4AsPathAttribute * AsPath(const ArtsBgp4AsPathAttribute & asPath); //------------------------------------------------------------------------- // const ArtsBgp4Prefix * NextHop() const //......................................................................... // //------------------------------------------------------------------------- const ArtsBgp4Prefix * NextHop() const; //------------------------------------------------------------------------- // const ArtsBgp4Prefix * NextHop(const ArtsBgp4Prefix & nextHop) //......................................................................... // //------------------------------------------------------------------------- const ArtsBgp4Prefix * NextHop(const ArtsBgp4Prefix & nextHop); //------------------------------------------------------------------------- // uint32_t MED() const //......................................................................... // //------------------------------------------------------------------------- uint32_t MED() const; //------------------------------------------------------------------------- // uint32_t MED(uint32_t med) //......................................................................... // //------------------------------------------------------------------------- uint32_t MED(uint32_t med); //------------------------------------------------------------------------- // uint32_t LocalPref() const //......................................................................... // //------------------------------------------------------------------------- uint32_t LocalPref() const; //------------------------------------------------------------------------- // uint32_t LocalPref(uint32_t localPref) //......................................................................... // //------------------------------------------------------------------------- uint32_t LocalPref(uint32_t localPref); //------------------------------------------------------------------------- // const ArtsBgp4AggregatorAttribute * Aggregator() const //......................................................................... // //------------------------------------------------------------------------- const ArtsBgp4AggregatorAttribute * Aggregator() const; //------------------------------------------------------------------------- // const ArtsBgp4AggregatorAttribute * // Aggregator(const ArtsBgp4AggregatorAttribute & aggregator) //......................................................................... // //------------------------------------------------------------------------- const ArtsBgp4AggregatorAttribute * Aggregator(const ArtsBgp4AggregatorAttribute & aggregator); //------------------------------------------------------------------------- // const deque * Community() const //......................................................................... // //------------------------------------------------------------------------- const deque * Community() const; //------------------------------------------------------------------------- // const deque * Community(const deque & community) //......................................................................... // //------------------------------------------------------------------------- const deque * Community(const deque & community); //------------------------------------------------------------------------- // const ArtsBgp4DPAttribute * DP() const //......................................................................... // //------------------------------------------------------------------------- const ArtsBgp4DPAttribute * DP() const; //------------------------------------------------------------------------- // const ArtsBgp4DPAttribute * DP(const ArtsBgp4DPAttribute & dp) //......................................................................... // //------------------------------------------------------------------------- const ArtsBgp4DPAttribute * DP(const ArtsBgp4DPAttribute & dp); void DeleteValue(); private: uint8_t _flags; uint8_t _type; uint16_t _length; union { uint8_t _origin; ArtsBgp4AsPathAttribute *_asPath; ArtsBgp4Prefix *_nextHop; uint32_t _MED; uint32_t _localPref; ArtsBgp4AggregatorAttribute *_aggregator; deque *_community; ArtsBgp4DPAttribute *_dp; } _value; }; #endif // _ARTSBGP4ATTRIBUTE_HH_