//=========================================================================== // $Name: arts++-1-1-a12 $ // $Id: ArtsBgp4DPAttribute.cc,v 1.2 2004/04/21 23:51:31 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 "ArtsPrimitive.hh" #include "ArtsBgp4DPAttribute.hh" using namespace std; static const std::string rcsid = "@(#) $Name: arts++-1-1-a12 $ $Id: ArtsBgp4DPAttribute.cc,v 1.2 2004/04/21 23:51:31 kkeys Exp $"; //---------------------------------------------------------------------------- // ArtsBgp4DPAttribute::ArtsBgp4DPAttribute() //............................................................................ // //---------------------------------------------------------------------------- ArtsBgp4DPAttribute::ArtsBgp4DPAttribute() { #ifndef NDEBUG ++this->_numObjects; #endif } //---------------------------------------------------------------------------- // ArtsBgp4DPAttribute::~ArtsBgp4DPAttribute() //............................................................................ // //---------------------------------------------------------------------------- ArtsBgp4DPAttribute::~ArtsBgp4DPAttribute() { #ifndef NDEBUG --this->_numObjects; #endif } //------------------------------------------------------------------------- // uint16_t ArtsBgp4DPAttribute::AS() const //......................................................................... // //------------------------------------------------------------------------- uint16_t ArtsBgp4DPAttribute::AS() const { return(this->_as); } //------------------------------------------------------------------------- // uint16_t ArtsBgp4DPAttribute::AS(uint16_t as) //......................................................................... // //------------------------------------------------------------------------- uint16_t ArtsBgp4DPAttribute::AS(uint16_t as) { this->_as = as; return(this->_as); } //------------------------------------------------------------------------- // uint32_t ArtsBgp4DPAttribute::Value() const //......................................................................... // //------------------------------------------------------------------------- uint32_t ArtsBgp4DPAttribute::Value() const { return(this->_value); } //------------------------------------------------------------------------- // uint32_t ArtsBgp4DPAttribute::Value(uint32_t value) //......................................................................... // //------------------------------------------------------------------------- uint32_t ArtsBgp4DPAttribute::Value(uint32_t value) { this->_value = value; return(this->_value); } //------------------------------------------------------------------------- // ArtsBgp4DPAttribute & // ArtsBgp4DPAttribute::operator = (const ArtsBgp4DPAttribute & attribute) //......................................................................... // //------------------------------------------------------------------------- ArtsBgp4DPAttribute & ArtsBgp4DPAttribute::operator = (const ArtsBgp4DPAttribute & attribute) { this->AS(attribute.AS()); this->Value(attribute.Value()); return(*this); } //---------------------------------------------------------------------------- // istream & ArtsBgp4DPAttribute::read(istream & is, uint8_t version) //............................................................................ // //---------------------------------------------------------------------------- istream & ArtsBgp4DPAttribute::read(istream & is, uint8_t version) { g_ArtsLibInternal_Primitive.ReadUint16(is,this->_as,sizeof(this->_as)); g_ArtsLibInternal_Primitive.ReadUint32(is,this->_value, sizeof(this->_value)); return(is); } //---------------------------------------------------------------------------- // int ArtsBgp4DPAttribute::read(int fd, uint8_t version) //............................................................................ // //---------------------------------------------------------------------------- int ArtsBgp4DPAttribute::read(int fd, uint8_t version) { int rc; int bytesRead = 0; rc = g_ArtsLibInternal_Primitive.ReadUint16(fd,this->_as, sizeof(this->_as)); if (rc < sizeof(this->_as)) return(-1); bytesRead += rc; rc = g_ArtsLibInternal_Primitive.ReadUint32(fd,this->_value, sizeof(this->_value)); if (rc < sizeof(this->_value)) return(-1); bytesRead += rc; return(bytesRead); } //---------------------------------------------------------------------------- // ostream & ArtsBgp4DPAttribute::write(ostream & os, // uint8_t version) const //............................................................................ // //---------------------------------------------------------------------------- ostream & ArtsBgp4DPAttribute::write(ostream & os, uint8_t version) const { g_ArtsLibInternal_Primitive.WriteUint16(os,this->_as,sizeof(this->_as)); g_ArtsLibInternal_Primitive.WriteUint32(os,this->_value, sizeof(this->_value)); return(os); } //---------------------------------------------------------------------------- // int ArtsBgp4DPAttribute::write(int fd, uint8_t version) const //............................................................................ // //---------------------------------------------------------------------------- int ArtsBgp4DPAttribute::write(int fd, uint8_t version) const { int rc; int bytesWritten = 0; rc = g_ArtsLibInternal_Primitive.WriteUint16(fd,this->_as, sizeof(this->_as)); if (rc < sizeof(this->_as)) return(-1); bytesWritten += rc; rc = g_ArtsLibInternal_Primitive.WriteUint32(fd,this->_value, sizeof(this->_value)); if (rc < sizeof(this->_value)) return(-1); bytesWritten += rc; return(bytesWritten); } uint32_t ArtsBgp4DPAttribute::_numObjects = 0;