• Main Page
  • Classes
  • Files
  • File List

/Users/yzchen/ns/ns-allinone-2.33/ns-2.33/diffusion3/lib/main/attrs.hh

00001 //
00002 // attrs.hh        : Attribute Functions Definitions
00003 // authors         : John Heidemann and Fabio Silva
00004 //
00005 // Copyright (C) 2000-2002 by the University of Southern California
00006 // $Id: attrs.hh,v 1.7 2005/09/13 04:53:49 tomh Exp $
00007 //
00008 // This program is free software; you can redistribute it and/or
00009 // modify it under the terms of the GNU General Public License,
00010 // version 2, as published by the Free Software Foundation.
00011 //
00012 // This program is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU General Public License along
00018 // with this program; if not, write to the Free Software Foundation, Inc.,
00019 // 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00020 //
00021 // Linking this file statically or dynamically with other modules is making
00022 // a combined work based on this file.  Thus, the terms and conditions of
00023 // the GNU General Public License cover the whole combination.
00024 //
00025 // In addition, as a special exception, the copyright holders of this file
00026 // give you permission to combine this file with free software programs or
00027 // libraries that are released under the GNU LGPL and with code included in
00028 // the standard release of ns-2 under the Apache 2.0 license or under
00029 // otherwise-compatible licenses with advertising requirements (or modified
00030 // versions of such code, with unchanged license).  You may copy and
00031 // distribute such a system following the terms of the GNU GPL for this
00032 // file and the licenses of the other code concerned, provided that you
00033 // include the source code of that other code when and as the GNU GPL
00034 // requires distribution of source code.
00035 //
00036 // Note that people who make modified versions of this file are not
00037 // obligated to grant this special exception for their modified versions;
00038 // it is their choice whether to do so.  The GNU General Public License
00039 // gives permission to release a modified version without this exception;
00040 // this exception also makes it possible to release a modified version
00041 // which carries forward this exception.
00042 
00043 #ifndef _ATTRS_HH_
00044 #define _ATTRS_HH_
00045 
00046 #ifdef HAVE_CONFIG_H
00047 #include "config.h"
00048 #endif // HAVE_CONFIG_H
00049 
00050 #include <unistd.h>
00051 #include <netinet/in.h>
00052 
00053 #include "nr/nr.hh"
00054 #include "header.hh"
00055 #include "tools.hh"
00056 
00057 // Here we define a few functions that will help developers create
00058 // and manipulate attribute sets.
00059 
00060 // CopyAttrs returns a NRAttrVec containing a copy of the attributes
00061 // given in 'src_attrs' (which are not changed).
00062 NRAttrVec * CopyAttrs(NRAttrVec *src_attrs);
00063 
00064 // AddAttrs adds all attributes from 'attr_vec2' to 'attr_vec1. The
00065 // attributes from 'attr_vec2' remain intact and its attributes are
00066 // copied and added to 'attr_vec1'
00067 void AddAttrs(NRAttrVec *attr_vec1, NRAttrVec *attr_vec2);
00068 
00069 // ClearAttrs deletes all attributes from 'attr_vec'. The result is an
00070 // empty NRAttrVec
00071 void ClearAttrs(NRAttrVec *attr_vec);
00072 
00073 // PrintAttrs prints the contents of all attributes given in
00074 // 'attr_vec' to stderr. The attribute vector is not changed
00075 void PrintAttrs(NRAttrVec *attr_vec);
00076 
00077 // AllocateBuffer returns a buffer (DiffPacket) with sufficient space
00078 // for the attributes in 'attr_vec' to be packaged by the function
00079 // PackAttrs. The attribute vector is not changed
00080 DiffPacket AllocateBuffer(NRAttrVec *attr_vec);
00081 
00082 // CalculateSize returns the buffer size necessary to hold all the
00083 // attributes from 'attr_vec' if the PackAttrs function is used
00084 int CalculateSize(NRAttrVec *attr_vec);
00085 
00086 // PackAttrs packs all attributes given in 'attr_vec' on the buffer
00087 // starting at 'start_pos'. It assumes there is enough space in the
00088 // buffer to accomodate all attributes
00089 int PackAttrs(NRAttrVec *attr_vec, char *start_pos);
00090 
00091 // UnpackAttrs returns an attribute vector containing 'num_attr'
00092 // attributes, which are unpacked from 'pkt'
00093 NRAttrVec * UnpackAttrs(DiffPacket pkt, int num_attr);
00094 
00095 // PerfectMatch returns TRUE if the attributes from 'attr_vec1' and
00096 // 'attr_vec2' are identical. For each attribute in each vector, there
00097 // must be the same attribute in the other vector
00098 bool PerfectMatch(NRAttrVec *attr_vec1, NRAttrVec *attr_vec2);
00099 
00100 // OneWayPerfectMatch returns TRUE if each attribute in 'attr_vec1' is
00101 // also present (identical attribute) in 'attr_vec2'
00102 bool OneWayPerfectMatch(NRAttrVec *attr_vec1, NRAttrVec *attr_vec2);
00103 
00104 // MatchAttrs returns TRUE if the attributes from 'attr_vec1' and
00105 // 'attr_vec2' match each other (Please refer to the API document for
00106 // a complete description of the matching rules).
00107 bool MatchAttrs(NRAttrVec *attr_vec1, NRAttrVec *attr_vec2);
00108 
00109 // OneWayMatch returns TRUE if the attributes from 'attr_vec2' match
00110 // the attributes in 'attr_vec1'. (I.E. For each attribute in
00111 // 'attr_vec1' that has an operator different than 'IS', we need to
00112 // find a match in 'attr_vec2'
00113 bool OneWayMatch(NRAttrVec *attr_vec1, NRAttrVec *attr_vec2);
00114 
00115 #endif // !_ATTRS_HH_

Generated on Tue Aug 10 2010 16:16:06 for ns-2.33 by  doxygen 1.7.1