//=========================================================================== // @(#) $Name: $ // @(#) $Id: ArtsIpPathData.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 _ARTSIPPATHDATA_HH_ #define _ARTSIPPATHDATA_HH_ extern "C" { #include #include "caida_t.h" } #include #include "ArtsIpPathEntry.hh" //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // class ArtsIpPathData //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ class ArtsIpPathData { public: //------------------------------------------------------------------------ // ArtsIpPathData(ipv4addr_t src, ipv4addr_t dst) //........................................................................ // constructor //------------------------------------------------------------------------ ArtsIpPathData(ipv4addr_t src, ipv4addr_t dst); //------------------------------------------------------------------------- // ArtsIpPathData(const ArtsIpPathData & artsIpPathData) //......................................................................... // copy constructor //------------------------------------------------------------------------- ArtsIpPathData(const ArtsIpPathData & artsIpPathData); //------------------------------------------------------------------------ // ArtsIpPathData() //........................................................................ // default constructor //------------------------------------------------------------------------ ArtsIpPathData(); //------------------------------------------------------------------------ // ~ArtsIpPathData() //........................................................................ // destructor //------------------------------------------------------------------------ ~ArtsIpPathData(); //------------------------------------------------------------------------- // ostream& write(ostream& os, uint8_t version = 0) //......................................................................... // Writes IP path data to an ostream. //------------------------------------------------------------------------- ostream& write(ostream& os, uint8_t version = 0); //------------------------------------------------------------------------- // int write(int fd, uint8_t version = 0) //......................................................................... // Writes IP path data to a file descriptor. Returns the number of // bytes written on success, -1 on failure. //------------------------------------------------------------------------- int write(int fd, uint8_t version = 0); //------------------------------------------------------------------------- // istream& read(istream& is, uint8_t version = 0) //......................................................................... // Reads IP path data from an istream. //------------------------------------------------------------------------- istream& read(istream& is, uint8_t version = 0); //------------------------------------------------------------------------- // int read(int fd, uint8_t version = 0) //......................................................................... // UNTESTED //------------------------------------------------------------------------- int read(int fd, uint8_t version = 0); // UNTESTED //------------------------------------------------------------------------- // inline ipv4addr_t Src() const //......................................................................... // Returns the source address of the IP path. //------------------------------------------------------------------------- inline ipv4addr_t Src() const { return(this->_src); } //------------------------------------------------------------------------- // inline ipv4addr_t Src(ipv4addr_t src) //......................................................................... // Sets and returns the source address of the IP path. //------------------------------------------------------------------------- inline ipv4addr_t Src(ipv4addr_t src) { this->_src = src; return(this->_src); } //------------------------------------------------------------------------- // inline ipv4addr_t Dst() const //......................................................................... // Returns the path destination IP address. //------------------------------------------------------------------------- inline ipv4addr_t Dst() const { return(this->_dst); } //------------------------------------------------------------------------- // inline ipv4addr_t Dst(ipv4addr_t dst) //......................................................................... // Sets and returns the path destination IP address. //------------------------------------------------------------------------- inline ipv4addr_t Dst(ipv4addr_t dst) { this->_dst = dst; return(this->_dst); } //------------------------------------------------------------------------- // inline const struct timeval & Rtt() const //......................................................................... // Returns the round-trip time from the source to the destination and // back. //------------------------------------------------------------------------- inline const struct timeval & Rtt() const { return(this->_rtt); } //------------------------------------------------------------------------- // inline const struct timeval & Rtt(const struct timeval & rtt) //......................................................................... // Sets and returns the round-trip time from the source to the // destination and back. //------------------------------------------------------------------------- inline const struct timeval & Rtt(const struct timeval & rtt) { this->_rtt.tv_sec = rtt.tv_sec; this->_rtt.tv_usec = rtt.tv_usec; return(this->_rtt); } //------------------------------------------------------------------------- // inline uint8_t HopDistance() const //......................................................................... // Returns the hop distance from the source to the destination. //------------------------------------------------------------------------- inline uint8_t HopDistance() const { return(this->_hopDistance); } //------------------------------------------------------------------------- // inline uint8_t HopDistance(uint8_t hopDistance) //......................................................................... // Sets and returns the hop distance from the source to the destination. //------------------------------------------------------------------------- inline uint8_t HopDistance(uint8_t hopDistance) { this->_hopDistance = hopDistance; return(this->_hopDistance); } //------------------------------------------------------------------------- // inline uint8_t IsComplete() const //......................................................................... // Returns 1 if path is complete (destination reached), else returns 0. //------------------------------------------------------------------------- inline uint8_t IsComplete() const { return(this->_isComplete); } //------------------------------------------------------------------------- // inline uint8_t IsComplete(uint8_t isComplete) //......................................................................... // Sets and returns path complete indicator. //------------------------------------------------------------------------- inline uint8_t IsComplete(uint8_t isComplete) { this->_isComplete = isComplete; return(this->_isComplete); } //------------------------------------------------------------------------- // inline uint8_t NumHops() const //......................................................................... // Returns the number of hops stored in the path vector. //------------------------------------------------------------------------- inline uint8_t NumHops() const { return(this->_numHops); } //------------------------------------------------------------------------- // inline uint8_t NumHops(uint8_t numHops) //......................................................................... // Sets and returns the number of hops stored in the path vector. //------------------------------------------------------------------------- inline uint8_t NumHops(uint8_t numHops) { this->_numHops = numHops; return(this->_numHops); } //------------------------------------------------------------------------- // inline vector & Path() const //......................................................................... // Returns a reference to the path vector. //------------------------------------------------------------------------- inline vector & Path() const { return(this->_path); } //------------------------------------------------------------------------- // void AddHop(ipv4addr_t ipAddr, uint8_t hopNum) //......................................................................... // Appends a hop to the path. Assigns an IP address of ipAddr and // a hop number of hopNum to the new hop. Note we *always* tack the // new hop on the end of the path, and do *not* use hopNum to determine // the location. //------------------------------------------------------------------------- void AddHop(ipv4addr_t ipAddr, uint8_t hopNum); //------------------------------------------------------------------------- // uint32_t Length(uint8_t version = 0) const //......................................................................... // Returns the number of bytes required to store object contents on disk. //------------------------------------------------------------------------- uint32_t Length(uint8_t version = 0) const { return(this->_bytes); } //------------------------------------------------------------------------- // ArtsIpPathData & operator = (const ArtsIpPathData & artsIpPathData) //......................................................................... // Overloaded '=' operator for assigning the value of one // ArtsIpPathData object to another. //------------------------------------------------------------------------- ArtsIpPathData & operator = (const ArtsIpPathData & artsIpPathData); //------------------------------------------------------------------------- // friend ostream& operator << (ostream& os, // const ArtsIpPathData & artsIpPathData) //......................................................................... // Overloaded ostream '<<' operator to print contents of object. //------------------------------------------------------------------------- friend ostream& operator << (ostream& os, const ArtsIpPathData & artsIpPathData); private: ipv4addr_t _src; ipv4addr_t _dst; struct timeval _rtt; uint8_t _hopDistance; uint8_t _isComplete; uint8_t _numHops; mutable vector _path; uint32_t _bytes; }; #endif /* _ARTSIPPATHDATA_HH_ */