//=========================================================================== // $Name: $ // $Id: ArtsSelectedPortTableEntry.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 _ARTSPORTTABLEENTRY_HH_ #define _ARTSPORTTABLEENTRY_HH_ extern "C" { #include #include "caida_t.h" } #include #include //--------------------------------------------------------------------------- // class ArtsPortTableEntry //--------------------------------------------------------------------------- // Class representing a port table entry. //--------------------------------------------------------------------------- class ArtsPortTableEntry { public: //------------------------------------------------------------------------- // ArtsPortTableEntry() //......................................................................... // constructor //------------------------------------------------------------------------- ArtsPortTableEntry(); //------------------------------------------------------------------------- // ~ArtsPortTableEntry() //......................................................................... // destructor //------------------------------------------------------------------------- ~ArtsPortTableEntry(); //------------------------------------------------------------------------- // uint16_t PortNumber() const; //......................................................................... // Returns the port number for the port entry. //------------------------------------------------------------------------- uint16_t PortNumber() const; //------------------------------------------------------------------------- // uint16_t PortNumber(uint16_t portNum) //......................................................................... // Sets and returns the port number for the port entry. //------------------------------------------------------------------------- uint16_t PortNumber(uint16_t portNum); //------------------------------------------------------------------------- // uint64_t InPkts() const //......................................................................... // Returns the input packet count for the port entry. This is // the number of packets received by the port. For example, InPkts() // for port 80 would represent the number of packets sent to HTTP // servers from HTTP clients. //------------------------------------------------------------------------- uint64_t InPkts() const; //------------------------------------------------------------------------- // uint64_t InPkts(uint64_t pkts) //......................................................................... // Sets and returns the input packet count for the port entry. This // is the number of packets received by the port. For example, // InPkts() for port 80 would represent the number of packets sent to // HTTP servers from HTTP clients. //------------------------------------------------------------------------- uint64_t InPkts(uint64_t pkts); //------------------------------------------------------------------------- // inline uint64_t InBytes() const //......................................................................... // Returns the input byte count for the port entry. This is the // number of bytes received by the port. For example, InBytes() for // port 80 would represent the number of bytes sent to HTTP servers // from HTTP clients. //------------------------------------------------------------------------- uint64_t InBytes() const; //------------------------------------------------------------------------- // inline uint64_t InBytes(uint64_t bytes) //......................................................................... // Sets and returns the input byte count for the port entry. This is // the number of bytes received by the port. For example, InBytes() // for port 80 would represent the number of bytes sent to HTTP // servers from HTTP clients. //------------------------------------------------------------------------- uint64_t InBytes(uint64_t bytes); //------------------------------------------------------------------------- // uint64_t OutPkts() const //......................................................................... // Returns the output packet count for the port entry. This is // the number of packets sent from the port. For example, OutPkts() // for port 80 would represent the number of packets sent from HTTP // servers to HTTP clients. //------------------------------------------------------------------------- uint64_t OutPkts() const; //------------------------------------------------------------------------- // uint64_t OutPkts(uint64_t pkts) //......................................................................... // Sets and returns the output packet count for the port entry. This // is the number of packets sent from the port. For example, // OutPkts() for port 80 would represent the number of packets sent // from HTTP servers to HTTP clients. //------------------------------------------------------------------------- uint64_t OutPkts(uint64_t pkts); //------------------------------------------------------------------------- // uint64_t OutBytes() const //......................................................................... // Returns the output byte count for the port entry. This is the // number of bytes sent from the port. For example, OutBytes() for // port 80 would represent the number of bytes sent from HTTP // servers to HTTP clients. //------------------------------------------------------------------------- uint64_t OutBytes() const; //------------------------------------------------------------------------- // inline uint64_t OutBytes(uint64_t bytes) //......................................................................... // Sets and returns the output byte count for the port entry. This // is the number of bytes sent from the port. For example, // OutBytes() for port 80 would represent the number of bytes sent // from HTTP servers to HTTP clients. //------------------------------------------------------------------------- uint64_t OutBytes(uint64_t bytes); //------------------------------------------------------------------------- // uint8_t Descriptor() const //......................................................................... // Returns the descriptor for the port entry. The Descriptor is a // bitmask containing encoded lengths for the packet and byte // counters. Currently its use is mostly internal to this class. //------------------------------------------------------------------------- uint8_t Descriptor() const; //------------------------------------------------------------------------- // uint8_t Descriptor(uint8_t descriptor) //......................................................................... // Sets and returns the descriptor for the port entry. The // Descriptor is a bitmask containing encoded lengths for the packet // and byte counters. Currently its use is mostly internal to this // class (hence this particular member function could be private?). //------------------------------------------------------------------------- uint8_t Descriptor(uint8_t descriptor); //------------------------------------------------------------------------- // uint32_t Length(uint8_t version = 0) const //......................................................................... // Returns the number of bytes needed to store the port entry in a // file. //------------------------------------------------------------------------- uint32_t Length(uint8_t version = 0) const; //------------------------------------------------------------------------- // istream& read(istream& is, uint8_t version = 0) //......................................................................... // Reads an ArtsPortTableEntry from an istream. Returns the istream. //------------------------------------------------------------------------- istream& read(istream& is, uint8_t version = 0); //------------------------------------------------------------------------- // int read(int fd, uint8_t version = 0) //......................................................................... // Reads an ArtsPortTableEntry 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 ArtsPortTableEntry 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 ArtsPortTableEntry to a file descriptor. Returns the // number of bytes written on success, -1 on failure. //------------------------------------------------------------------------- int write(int fd, uint8_t version = 0) const; //------------------------------------------------------------------------- // ArtsPortTableEntry & // operator = (const ArtsPortTableEntry & artsPortTableEntry) //......................................................................... // Overloaded '=' operator. //------------------------------------------------------------------------- ArtsPortTableEntry & operator = (const ArtsPortTableEntry & artsPortTableEntry); //------------------------------------------------------------------------- // friend ostream & // operator << (ostream& os, // const ArtsPortTableEntry & artsPortTableEntry) //......................................................................... // Overloaded ostream '<<' operator to dump the contents of an // ArtsPortTableEntry to an ostream in a human-readable form. // Returns the ostream. //------------------------------------------------------------------------- friend ostream & operator << (ostream& os, const ArtsPortTableEntry & artsPortTableEntry); private: uint16_t _portNum; uint8_t _descriptor; uint64_t _inPkts; uint64_t _inBytes; uint64_t _outPkts; uint64_t _outBytes; }; //--------------------------------------------------------------------------- // class ArtsPortEntryGreaterBytes //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- class ArtsPortEntryGreaterBytes { public: bool operator()(const ArtsPortTableEntry & portEntry1, const ArtsPortTableEntry & portEntry2) const; }; //--------------------------------------------------------------------------- // class ArtsPortEntryGreaterPkts //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- class ArtsPortEntryGreaterPkts { public: bool operator()(const ArtsPortTableEntry & portEntry1, const ArtsPortTableEntry & portEntry2) const; }; #endif // _ARTSPORTENTRY_HH_