00001 // GENERAL PUBLIC LICENSE AGREEMENT 00002 // 00003 // PLEASE READ THIS DOCUMENT CAREFULLY BEFORE UTILIZING THE PROGRAM 00004 // 00005 // BY UTILIZING THIS PROGRAM, YOU AGREE TO BECOME BOUND BY THE TERMS OF 00006 // THIS LICENSE. IF YOU DO NOT AGREE TO THE TERMS OF THIS LICENSE, DO 00007 // NOT USE THIS PROGRAM OR ANY PORTION THEREOF IN ANY FORM OR MANNER. 00008 // 00009 // This Program is licensed, not sold to you by GEORGIA TECH RESEARCH 00010 // CORPORATION ("GTRC"), owner of all code and accompanying documentation 00011 // (hereinafter "Program"), for use only under the terms of this License, 00012 // and GTRC reserves any rights not expressly granted to you. 00013 // 00014 // 1. This License allows you to: 00015 // 00016 // (a) make copies and distribute copies of the Program's source code 00017 // provide that any such copy clearly displays any and all appropriate 00018 // copyright notices and disclaimer of warranty as set forth in Article 5 00019 // and 6 of this License. All notices that refer to this License and to 00020 // the absence of any warranty must be kept intact at all times. A copy 00021 // of this License must accompany any and all copies of the Program 00022 // distributed to third parties. 00023 // 00024 // A fee may be charged to cover the cost associated with the physical 00025 // act of transferring a copy to a third party. At no time shall the 00026 // program be sold for commercial gain either alone or incorporated with 00027 // other program(s) without entering into a separate agreement with GTRC. 00028 // 00029 // 00030 // (b) modify the original copy or copies of the Program or any portion 00031 // thereof ("Modification(s)"). Modifications may be copied and 00032 // distributed under the terms and conditions as set forth above, 00033 // provided the following conditions are met: 00034 // 00035 // i) any and all modified files must be affixed with prominent 00036 // notices that you have changed the files and the date that the changes 00037 // occurred. 00038 // 00039 // ii) any work that you distribute, publish, or make available, that 00040 // in whole or in part contains portions of the Program or derivative 00041 // work thereof, must be licensed at no charge to all third parties under 00042 // the terms of this License. 00043 // 00044 // iii) if the modified program normally reads commands interactively 00045 // when run, you must cause it, when started running for such interactive 00046 // use in the most ordinary way, to display and/or print an announcement 00047 // with all appropriate copyright notices and disclaimer of warranty as 00048 // set forth in Article 5 and 6 of this License to be clearly displayed. 00049 // In addition, you must provide reasonable access to this License to the 00050 // user. 00051 // 00052 // Any portion of a Modification that can be reasonably considered 00053 // independent of the Program and separate work in and of itself is not 00054 // subject to the terms and conditions set forth in this License as long 00055 // as it is not distributed with the Program or any portion thereof. 00056 // 00057 // 00058 // 2. This License further allows you to copy and distribute the Program 00059 // or a work based on it, as set forth in Article 1 Section b in 00060 // object code or executable form under the terms of Article 1 above 00061 // provided that you also either: 00062 // 00063 // i) accompany it with complete corresponding machine-readable source 00064 // code, which must be distributed under the terms of Article 1, on a 00065 // medium customarily used for software interchange; or, 00066 // 00067 // ii) accompany it with a written offer, valid for no less than three 00068 // (3) years from the time of distribution, to give any third party, for 00069 // no consideration greater than the cost of physical transfer, a 00070 // complete machine-readable copy of the corresponding source code, to be 00071 // distributed under the terms of Article 1 on a medium customarily used 00072 // for software interchange; or, 00073 // 00074 // 00075 // 3. Export Law Assurance. 00076 // 00077 // You agree that the Software will not be shipped, transferred or 00078 // exported, directly into any country prohibited by the United States 00079 // Export Administration Act and the regulations thereunder nor will be 00080 // used for any purpose prohibited by the Act. 00081 // 00082 // 4. Termination. 00083 // 00084 // If at anytime you are unable to comply with any portion of this 00085 // License you must immediately cease use of the Program and all 00086 // distribution activities involving the Program or any portion thereof. 00087 // 00088 // 00089 // 5. Disclaimer of Warranties and Limitation on Liability. 00090 // 00091 // YOU ACCEPT THE PROGRAM ON AN "AS IS" BASIS. GTRC MAKES NO WARRANTY 00092 // THAT ALL ERRORS CAN BE OR HAVE BEEN ELIMINATED FROM PROGRAM. GTRC 00093 // SHALL NOT BE RESPONSIBLE FOR LOSSES OF ANY KIND RESULTING FROM THE USE 00094 // OF PROGRAM AND ITS ACCOMPANYING DOCUMENT(S), AND CAN IN NO WAY PROVIDE 00095 // COMPENSATION FOR ANY LOSSES SUSTAINED, INCLUDING BUT NOT LIMITED TO 00096 // ANY OBLIGATION, LIABILITY, RIGHT, CLAIM OR REMEDY FOR TORT, OR FOR ANY 00097 // ACTUAL OR ALLEGED INFRINGEMENT OF PATENTS, COPYRIGHTS, TRADE SECRETS, 00098 // OR SIMILAR RIGHTS OF THIRD PARTIES, NOR ANY BUSINESS EXPENSE, MACHINE 00099 // DOWNTIME OR DAMAGES CAUSED TO YOU BY ANY DEFICIENCY, DEFECT OR ERROR 00100 // IN PROGRAM OR MALFUNCTION THEREOF, NOR ANY INCIDENTAL OR CONSEQUENTIAL 00101 // DAMAGES, HOWEVER CAUSED. GTRC DISCLAIMS ALL WARRANTIES, BOTH EXPRESS 00102 // AND IMPLIED RESPECTING THE USE AND OPERATION OF PROGRAM AND ITS 00103 // ACCOMPANYING DOCUMENTATION, INCLUDING ALL IMPLIED WARRANTIES OF 00104 // MERCHANTABILITY AND FITNESS FOR PARTICULAR PURPOSE AND ANY IMPLIED 00105 // WARRANTY ARISING FROM COURSE OF PERFORMANCE, COURSE OF DEALING OR 00106 // USAGE OF TRADE. GTRC MAKES NO WARRANTY THAT PROGRAM IS ADEQUATELY OR 00107 // COMPLETELY DESCRIBED IN, OR BEHAVES IN ACCORDANCE WITH ANY 00108 // ACCOMPANYING DOCUMENTATION. THE USER OF PROGRAM IS EXPECTED TO MAKE 00109 // THE FINAL EVALUATION OF PROGRAM'S USEFULNESS IN USER'S OWN 00110 // ENVIRONMENT. 00111 // 00112 // GTRC represents that, to the best of its knowledge, the software 00113 // furnished hereunder does not infringe any copyright or patent. 00114 // 00115 // GTRC shall have no obligation for support or maintenance of Program. 00116 // 00117 // 6. Copyright Notice. 00118 // 00119 // THE SOFTWARE AND ACCOMPANYING DOCUMENTATION ARE COPYRIGHTED WITH ALL 00120 // RIGHTS RESERVED BY GTRC. UNDER UNITED STATES COPYRIGHT LAWS, THE 00121 // SOFTWARE AND ITS ACCOMPANYING DOCUMENTATION MAY NOT BE COPIED EXCEPT 00122 // AS GRANTED HEREIN. 00123 // 00124 // You acknowledge that GTRC is the sole owner of Program, including all 00125 // copyrights subsisting therein. Any and all copies or partial copies 00126 // of Program made by you shall bear the copyright notice set forth below 00127 // and affixed to the original version or such other notice as GTRC shall 00128 // designate. Such notice shall also be affixed to all improvements or 00129 // enhancements of Program made by you or portions thereof in such a 00130 // manner and location as to give reasonable notice of GTRC's copyright 00131 // as set forth in Article 1. 00132 // 00133 // Said copyright notice shall read as follows: 00134 // 00135 // Copyright 2004 00136 // Dr. George F. Riley 00137 // Georgia Tech Research Corporation 00138 // Atlanta, Georgia 30332-0415 00139 // All Rights Reserved 00140 // 00141 // $Id: pdu.h 446 2005-11-15 20:48:03Z riley $ 00142 00143 00144 00145 // Georgia Tech Network Simulator - Protocol Data Unit base class 00146 // George F. Riley. Georgia Tech, Spring 2002 00147 00148 // Class PDU is the base class for all packet headers 00149 00150 #ifndef __pdh_h__ 00151 #define __pdh_h__ 00152 00153 #include <vector> 00154 00155 #include "debug.h" 00156 #include "common-defs.h" 00157 #include "tfstream.h" 00158 #include "globalstats.h" 00159 #include "serializable.h" 00160 #include "memreuse.h" 00161 00162 //Doc:ClassXRef 00163 class PDU : public Serializable, public ReuseBase { 00164 //Doc:Class Class {\tt PDU} serves as the base class for all the 00165 //Doc:Class protocol data units. Protocol headers and data chunks that 00166 //Doc:Class that form the packets are derived from this class. 00167 00168 public: 00169 //Doc:Method 00170 PDU() { DBG((Stats::pdusAllocated++));} 00171 //Doc:Desc This method is the default constructor for this class. It 00172 //Doc:Desc updates a static variable to reflect the number of PDUs 00173 //Doc:Desc allocated 00174 00175 //Doc:Method 00176 PDU(const PDU&) { DBG((Stats::pdusAllocated++));} 00177 //Doc:Desc This constructs a PDU from the reference to an already existing 00178 //Doc:Desc PDU. 00179 //Doc:Arg1 The const reference to the existing PDU 00180 00181 //Doc:Method 00182 virtual ~PDU() { DBG((Stats::pdusDeleted++));} 00183 00184 public: 00185 //Doc:Method 00186 virtual Size_t Size() const = 0; // PDU's must have a size 00187 //Doc:Desc This method returns the size of the PDU 00188 //Doc:Return the size of the PDU 00189 00190 //Doc:Method 00191 virtual PDU* Copy() const = 0; // Create a copy of this header 00192 //Doc:Desc This method creates a copy of this PDU 00193 //Doc:Return A pointer to the copy of this PDU 00194 00195 //Doc:Method 00196 virtual Layer_t Layer() { return 0;}// Some PDU's specify their layer 00197 //Doc:Desc Each PDU must also return a layer numer as to which protocol layer 00198 //Doc:Desc it belongs to according to the ISO model 00199 //Doc:Return the layer number 00200 00201 //Doc:Method 00202 virtual Layer_t SubLayer() { return 0;}// Some layers have sublayers 00203 //Doc:Desc Each PDU may be part of a sub-layer. For example, LLCSNAP 00204 //Doc:Desc is layer "2a", sitting between the real layer 2 and l3 PDUs. 00205 //Doc:Return The sub-layer number 00206 00207 //Doc:Method 00208 virtual Count_t Version() { return 0;} // Some PDU's report version number 00209 //Doc:Desc If we are using multiple versions of the same PDU we may want 00210 //Doc:Desc to return the version number of the PDU we are using. Also useful 00211 //Doc:Desc when tracing 00212 //Doc:Return the version number 00213 00214 //Doc:Method 00215 virtual Proto_t Proto() { return 0;} // Some PDU's report protocol number 00216 //Doc:Desc Most of the protocols are identified by the numeric values as 00217 //Doc:Desc listed by IANA. thie method returns that protocol number 00218 //Doc:Return the protocol number 00219 00220 //Doc:Method 00221 virtual Priority_t Priority() { return 0;} // Some PDU's have priority 00222 //Doc:Desc For queues that support priorities, packets need some way to 00223 //Doc:Desc claim what the priority is. This is done by querying the 00224 //Doc:Desc PDU list. When a non-zero priority is found, that 00225 //Doc:Desc is the claimed priority. 00226 //Doc:Return Priority associated with this PDU (zero if none. 00227 00228 // Trace the contents of this pdu 00229 //Doc:Method 00230 virtual void Trace(Tfstream&, Bitmap_t, 00231 Packet* = nil, const char* = nil) { } 00232 //Doc:Desc This method traces the contents of the PDU 00233 //Doc:Arg1 File output stream descriptor 00234 //Doc:Arg2 Bitmap that specifies the level of detail of the trace 00235 //Doc:Arg3 Packet that contains this PDU (optional) 00236 //Doc:Arg4 Extra text information for trace file (optional) 00237 00238 //Doc:Method 00239 unsigned long Detail(Bitmap_t d, Bitmap_t b) { return ((1L << d) & b);} 00240 // Include the serializable interface here as a temporary patch 00241 // until all PDU subclasses implement this 00242 //Doc:Method 00243 virtual Size_t SSize() { return 0;} // Size needed for serialization 00244 //Doc:Desc The actual size of all the PDU contents in terms of bytes for 00245 //Doc:Desc serialization of the contents. 00246 //Doc:Return the size 00247 00248 //Doc:Method 00249 virtual char* Serialize(char* b, Size_t&) { return b;}// Serialize to buffer 00250 //Doc:Desc This method is used to serialize the contents of the PDU 00251 //Doc:Desc into a serialized character buffer b . the size of this buffer is 00252 //Doc:Desc in the size arguement 00253 //Doc:Arg1 This is the pointer to the character buffer 00254 //Doc:Arg2 a reference to the size variable 00255 //Doc:Return the pointer to the updated character buffer 00256 00257 //Doc:Method 00258 virtual char* Construct(char* b, Size_t&) { return b;}// Const. from buffer 00259 //Doc:Desc This method is the reverse of the Serialize . It constructs the 00260 //Doc:Desc PDU object from the character buffer that has been received over 00261 //Doc:Desc the network 00262 //Doc:Arg1 This is the pointer to the character buffer 00263 //Doc:Arg2 a reference to the size variable 00264 //Doc:Return the pointer to the character buffer of the remaining data 00265 }; 00266 00267 typedef std::vector<PDU*> PDUVec_t; // Vector of packet headers 00268 00269 #endif 00270 00271
1.3.9.1