//=========================================================================== // $Name: $ // $Id: ArtsProtocolTableEntry.hh,v 1.1.1.1 2000/03/29 22:53:59 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 _ARTSPROTOCOLTABLEENTRY_HH_ #define _ARTSPROTOCOLTABLEENTRY_HH_ extern "C" { #include #include "caida_t.h" } #include #include //--------------------------------------------------------------------------- // class ArtsProtocolTableEntry //--------------------------------------------------------------------------- // Class representing a protocol table entry. This class is used to hold // IP traffic counters (number of packets and bytes) per protocol (TCP, // UDP, ICMP, et. al.). //--------------------------------------------------------------------------- class ArtsProtocolTableEntry { public: //------------------------------------------------------------------------- // ArtsProtocolTableEntry() //......................................................................... // constructor //------------------------------------------------------------------------- ArtsProtocolTableEntry(); //------------------------------------------------------------------------- // ~ArtsProtocolTableEntry() //......................................................................... // destructor //------------------------------------------------------------------------- ~ArtsProtocolTableEntry(); //------------------------------------------------------------------------- // uint8_t ProtocolNumber() const //......................................................................... // Returns the protocol number for the protocol entry. //------------------------------------------------------------------------- uint8_t ProtocolNumber() const; //------------------------------------------------------------------------- // uint8_t ProtocolNumber(uint8_t protocol) //......................................................................... // Sets and returns the protocol number for the protocol entry. //------------------------------------------------------------------------- uint8_t ProtocolNumber(uint8_t protocol); //------------------------------------------------------------------------- // uint64_t Pkts() const //......................................................................... // Returns the packet count for the protocol entry. //------------------------------------------------------------------------- uint64_t Pkts() const; //------------------------------------------------------------------------- // uint64_t Pkts(uint64_t pkts) //......................................................................... // Sets and returns the packet count for the protocol entry. //------------------------------------------------------------------------- uint64_t Pkts(uint64_t pkts); //------------------------------------------------------------------------- // inline uint64_t Bytes() const //......................................................................... // Returns the byte count for the protocol entry. //------------------------------------------------------------------------- uint64_t Bytes() const; //------------------------------------------------------------------------- // inline uint64_t Bytes(uint64_t bytes) //......................................................................... // Sets and returns the byte count for the protocol entry. //------------------------------------------------------------------------- uint64_t Bytes(uint64_t bytes); //------------------------------------------------------------------------- // uint32_t Length(uint8_t version = 0) const //......................................................................... // Returns the number of bytes needed to store the protocol entry in a // file. //------------------------------------------------------------------------- uint32_t Length(uint8_t version = 0) const; //------------------------------------------------------------------------- // uint8_t Descriptor() const //......................................................................... // Returns the descriptor field. //------------------------------------------------------------------------- uint8_t Descriptor() const; //------------------------------------------------------------------------- // uint8_t Descriptor(uint8_t descriptor) //......................................................................... // Sets and returns the descriptor field. //------------------------------------------------------------------------- uint8_t Descriptor(uint8_t descriptor); //------------------------------------------------------------------------- // istream& read(istream& is, uint8_t version = 0) //......................................................................... // Reads an ArtsProtocolTableEntry from an istream. Returns the istream. //------------------------------------------------------------------------- istream& read(istream& is, uint8_t version = 0); //------------------------------------------------------------------------- // int read(int fd, uint8_t version = 0) //......................................................................... // Reads an ArtsProtocolTableEntry 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 ArtsProtocolTableEntry 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 ArtsProtocolTableEntry to a file descriptor. Returns the // number of bytes written on success, -1 on failure. //------------------------------------------------------------------------- int write(int fd, uint8_t version = 0) const; //------------------------------------------------------------------------- // ArtsProtocolTableEntry & // operator = (const ArtsProtocolTableEntry & artsProtocolTableEntry) //......................................................................... // Overloaded '=' operator to assign one ArtsProtocolTableEntry to // another. //------------------------------------------------------------------------- ArtsProtocolTableEntry & operator = (const ArtsProtocolTableEntry & artsProtocolTableEntry); //------------------------------------------------------------------------- // friend ostream & // operator << (ostream& os, // const ArtsProtocolTableEntry & artsProtocolTableEntry) //......................................................................... // Overloaded '<<' operator to dump the contents of an // ArtsProtocolTableEntry to an ostream in a human-readable form. // Returns the ostream. //------------------------------------------------------------------------- friend ostream & operator << (ostream& os, const ArtsProtocolTableEntry & artsProtocolTableEntry); private: uint8_t _protocolNum; uint8_t _descriptor; uint64_t _pkts; uint64_t _bytes; }; //--------------------------------------------------------------------------- // class ArtsPortEntryGreaterBytes //--------------------------------------------------------------------------- // class ArtsProtocolEntryGreaterBytes //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- class ArtsProtocolEntryGreaterBytes { public: bool operator()(const ArtsProtocolTableEntry & protoEntry1, const ArtsProtocolTableEntry & protoEntry2) const; }; //--------------------------------------------------------------------------- // class ArtsProtocolEntryGreaterPkts //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- class ArtsProtocolEntryGreaterPkts { public: bool operator()(const ArtsProtocolTableEntry & protoEntry1, const ArtsProtocolTableEntry & protoEntry2) const; }; #endif // _ARTSPROTOCOLTABLEENTRY_HH_