//=========================================================================== // @(#) $Name: arts++-1-1-a12 $ // @(#) $Id: ArtsProtocolTable.cc,v 1.2 2004/04/21 23:51:34 kkeys Exp $ //=========================================================================== // 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 Lesser General Public // License, Version 2.1, February 1999, 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 Lesser General Public // License along with arts++. Copies can also be obtained from: // // http://www.gnu.org/copyleft/lesser.html // // or by writing to: // // Free Software Foundation, Inc. // 59 Temple Place, Suite 330 // Boston, MA 02111-1307 // USA // // Or contact: // // info@caida.org //=========================================================================== #include #include "Arts.hh" #include "ArtsProtocolTable.hh" using namespace std; static const std::string rcsid = "@(#) $Name: arts++-1-1-a12 $ $Id: ArtsProtocolTable.cc,v 1.2 2004/04/21 23:51:34 kkeys Exp $"; //------------------------------------------------------------------------- // ArtsProtocolTable::ArtsProtocolTable() //......................................................................... // //------------------------------------------------------------------------- ArtsProtocolTable::ArtsProtocolTable() { this->Header().Identifier(artsC_OBJECT_PROTO); this->_data._protocolTable = new ArtsProtocolTableData(); } //------------------------------------------------------------------------- // ArtsProtocolTable::~ArtsProtocolTable() //......................................................................... // //------------------------------------------------------------------------- ArtsProtocolTable::~ArtsProtocolTable() { } //------------------------------------------------------------------------- // uint16_t ArtsProtocolTable::SampleInterval() const //......................................................................... // //------------------------------------------------------------------------- uint16_t ArtsProtocolTable::SampleInterval() const { return(this->_data._protocolTable->SampleInterval()); } //------------------------------------------------------------------------- // uint16_t ArtsProtocolTable::SampleInterval(uint16_t sampleInterval) //......................................................................... // //------------------------------------------------------------------------- uint16_t ArtsProtocolTable::SampleInterval(uint16_t sampleInterval) { return(this->_data._protocolTable->SampleInterval(sampleInterval)); } //------------------------------------------------------------------------- // uint64_t ArtsProtocolTable::TotalPkts() const //......................................................................... // //------------------------------------------------------------------------- uint64_t ArtsProtocolTable::TotalPkts() const { return(this->_data._protocolTable->TotalPkts()); } //------------------------------------------------------------------------- // uint64_t ArtsProtocolTable::TotalPkts(uint64_t totalPkts) //......................................................................... // //------------------------------------------------------------------------- uint64_t ArtsProtocolTable::TotalPkts(uint64_t totalPkts) { return(this->_data._protocolTable->TotalPkts(totalPkts)); } //------------------------------------------------------------------------- // uint64_t ArtsProtocolTable::TotalBytes() const //......................................................................... // //------------------------------------------------------------------------- uint64_t ArtsProtocolTable::TotalBytes() const { return(this->_data._protocolTable->TotalBytes()); } //------------------------------------------------------------------------- // uint64_t ArtsProtocolTable::TotalBytes(uint64_t totalBytes) //......................................................................... // //------------------------------------------------------------------------- uint64_t ArtsProtocolTable::TotalBytes(uint64_t totalBytes) { return(this->_data._protocolTable->TotalBytes(totalBytes)); } //------------------------------------------------------------------------- // vector & // ArtsProtocolTable::ProtocolEntries() const //......................................................................... // //------------------------------------------------------------------------- vector & ArtsProtocolTable::ProtocolEntries() const { return(this->_data._protocolTable->ProtocolEntries()); } //---------------------------------------------------------------------------- // istream & operator >> (istream & is, // ArtsProtocolTable & artsProtocolTable) //............................................................................ // //---------------------------------------------------------------------------- istream & operator >> (istream & is, ArtsProtocolTable & artsProtocolTable) { streampos streamPosition; ArtsHeader artsHeader; // save our stream position streamPosition = is.tellg(); // read the object header artsHeader.read(is); if (is.eof()) { return(is); } // skip over objects that are not protocol table objects while (artsHeader.Identifier() != artsC_OBJECT_PROTO) { is.seekg(artsHeader.AttrLength() + artsHeader.DataLength(),ios::cur); streamPosition = is.tellg(); artsHeader.read(is); if (is.eof()) { break; } } // if we reached the end of the file before finding a protocol // table object, just return the istream and don't touch // artsProtocolTable if (is.eof()) { return(is); } // back up to the start of the header and read the entire protocol // table object, then return the istream. is.seekg(streamPosition,ios::beg); artsProtocolTable.read(is); return(is); }