//=========================================================================== // @(#) $Name: $ // @(#) $Id: ArtsPortMatrixEntry.hh,v 1.1.1.1 2000/03/29 22:54:00 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 _ARTSPORTMATRIXENTRY_HH_ #define _ARTSPORTMATRIXENTRY_HH_ extern "C" { #include #include "caida_t.h" } #include #include //--------------------------------------------------------------------------- // class ArtsPortMatrixEntry //--------------------------------------------------------------------------- // Class representing a single port matrix entry. This class holds a // source port number, a destination port number, and the packets and bytes // sent from the source port to the destination port. //--------------------------------------------------------------------------- class ArtsPortMatrixEntry { public: //------------------------------------------------------------------------- // ArtsPortMatrixEntry() //......................................................................... // constructor //------------------------------------------------------------------------- ArtsPortMatrixEntry(); //------------------------------------------------------------------------- // inline uint8_t Descriptor() const //......................................................................... // Returns the descriptor field of the object. The descriptor field // is a bitfield containing indicators of the length of the Src(), // Dst(), Pkts() and Bytes() fields when stored on disk or sent via a // socket. //------------------------------------------------------------------------- inline uint8_t Descriptor() const { return(this->_descriptor); } //------------------------------------------------------------------------- // inline uint8_t Descriptor(uint8_t descriptor) //......................................................................... // Sets and returns the descriptor field of the object. //------------------------------------------------------------------------- inline uint8_t Descriptor(uint8_t descriptor) { this->_descriptor = descriptor; return(this->_descriptor); } //------------------------------------------------------------------------- // inline uint16_t Src() const //......................................................................... // Returns the source port number. //------------------------------------------------------------------------- inline uint16_t Src() const { return(this->_src); } //------------------------------------------------------------------------- // uint16_t Src(uint16_t src) //......................................................................... // Sets and returns the source port number. //------------------------------------------------------------------------- uint16_t Src(uint16_t src); //------------------------------------------------------------------------- // inline uint16_t Dst() const //......................................................................... // Returns the destination port number. //------------------------------------------------------------------------- inline uint16_t Dst() const { return(this->_dst); } //------------------------------------------------------------------------- // uint16_t Dst(uint16_t dst) //......................................................................... // Sets and returns the source port number. //------------------------------------------------------------------------- uint16_t Dst(uint16_t dst); //------------------------------------------------------------------------- // inline uint64_t Pkts() const //......................................................................... // Returns the number of packets sent from the source port to the // destination port. //------------------------------------------------------------------------- inline uint64_t Pkts() const { return(this->_pkts); } //------------------------------------------------------------------------- // uint64_t Pkts(uint64_t pkts) //......................................................................... // Sets and returns the number of packets sent from the source port // to the destination port. //------------------------------------------------------------------------- uint64_t Pkts(uint64_t pkts); //------------------------------------------------------------------------- // inline uint64_t Bytes() const //......................................................................... // Returns the number of bytes sent from the source port to the // destination port. //------------------------------------------------------------------------- inline uint64_t Bytes() const { return(this->_bytes); } //------------------------------------------------------------------------- // uint64_t Bytes(uint64_t bytes) //......................................................................... // Sets and returns the number of bytes sent from the source port to // the destination port. //------------------------------------------------------------------------- uint64_t Bytes(uint64_t bytes); //------------------------------------------------------------------------- // uint32_t Length(uint8_t version = 0) const //......................................................................... // Returns the bytes of space required to store the // ArtsPortMatrixEntry on disk. //------------------------------------------------------------------------- uint32_t Length(uint8_t version = 0) const; //------------------------------------------------------------------------- // istream& read(istream& is, uint8_t version = 0) //......................................................................... // Reads an ArtsPortMatrixEntry from an istream. Returns the // istream. //------------------------------------------------------------------------- istream& read(istream& is, uint8_t version = 0); //------------------------------------------------------------------------- // int read(int fd, uint8_t version = 0) //......................................................................... // Reads an ArtsPortMatrixEntry from a file descriptor. Returns the // number of bytes read on success, -1 on failure. //------------------------------------------------------------------------- int read(int fd, uint8_t version = 0); //------------------------------------------------------------------------- // ostream& write(ostream& os, uint8_t version = 0) const //......................................................................... // Writes an ArtsPortMatrixEntry to an ostream. Returns the ostream. //------------------------------------------------------------------------- ostream& write(ostream& os, uint8_t version = 0) const; //------------------------------------------------------------------------- // int write(int fd, uint8_t version = 0) const //......................................................................... // Writes an ArtsPortMatrixEntry to a file descriptor. Returns the // number of bytes written on success, -1 on failure. //------------------------------------------------------------------------- int write(int fd, uint8_t version = 0) const; //------------------------------------------------------------------------- // ostream & operator << (ostream& os, // const ArtsPortMatrixEntry & artsPortMatrixEntry) //......................................................................... // Overloaded '<<' operator to dump the contents of an // ArtsPortMatrixEntry to an ostream in a human-readable form. // Returns the ostream. //------------------------------------------------------------------------- friend ostream & operator << (ostream& os, const ArtsPortMatrixEntry & artsPortMatrixEntry); private: uint8_t _descriptor; uint16_t _src; uint16_t _dst; uint64_t _pkts; uint64_t _bytes; }; //--------------------------------------------------------------------------- // class ArtsPortMatrixEntryGreaterBytes //--------------------------------------------------------------------------- // //--------------------------------------------------------------------------- class ArtsPortMatrixEntryGreaterBytes { public: //--------------------------------------------------------------------------- // bool operator () (const ArtsPortMatrixEntry & portEntry1, // const ArtsPortMatrixEntry & portEntry2) const //........................................................................... // //--------------------------------------------------------------------------- bool operator () (const ArtsPortMatrixEntry & portEntry1, const ArtsPortMatrixEntry & portEntry2) const; }; //--------------------------------------------------------------------------- // class ArtsPortMatrixEntryGreaterPkts //--------------------------------------------------------------------------- // //--------------------------------------------------------------------------- class ArtsPortMatrixEntryGreaterPkts { public: //--------------------------------------------------------------------------- // bool operator () (const ArtsPortMatrixEntry & portEntry1, // const ArtsPortMatrixEntry & portEntry2) const //........................................................................... // //--------------------------------------------------------------------------- bool operator () (const ArtsPortMatrixEntry & portEntry1, const ArtsPortMatrixEntry & portEntry2) const; }; #endif // _ARTSPORTMATRIXENTRY_HH_