|
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
|
2 // |
|
3 // Copyright (c) 2006 Georgia Tech Research Corporation |
|
4 // |
|
5 // This program is free software; you can redistribute it and/or modify |
|
6 // it under the terms of the GNU General Public License version 2 as |
|
7 // published by the Free Software Foundation; |
|
8 // |
|
9 // This program is distributed in the hope that it will be useful, |
|
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 // GNU General Public License for more details. |
|
13 // |
|
14 // You should have received a copy of the GNU General Public License |
|
15 // along with this program; if not, write to the Free Software |
|
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 // |
|
18 // Author: Rajib Bhattacharjea<raj.b@gatech.edu> |
|
19 // |
|
20 |
|
21 // Georgia Tech Network Simulator - Data Descriptors |
|
22 // George F. Riley. Georgia Tech, Spring 2002 |
|
23 |
|
24 #ifndef __datapdu_h__ |
|
25 #define __datapdu_h__ |
|
26 |
|
27 #include "ns3/packet.h" |
|
28 #include "pending-data.h" |
|
29 #include "sequence-number.h" |
|
30 |
|
31 #include "ns3/ptr.h" |
|
32 namespace ns3 |
|
33 { |
|
34 class Packet; |
|
35 //Doc:ClassXRef |
|
36 class PendingData { |
|
37 public: |
|
38 PendingData (); |
|
39 PendingData (uint32_t s, uint8_t* d = NULL, uint32_t msg = 0, uint32_t resp = 0); |
|
40 PendingData (const std::string&); // Construct from string |
|
41 PendingData (uint8_t*, uint32_t&, Packet*); // Construct from serialized buffer |
|
42 PendingData (const PendingData&); // Copy constructor |
|
43 virtual ~PendingData (); // Destructor |
|
44 uint32_t Size () const { return size;} |
|
45 // Serialization |
|
46 uint32_t SSize (); // Size needed for serialization |
|
47 uint8_t* Serialize (uint8_t*, uint32_t&); // Serialize to a buffer |
|
48 uint8_t* Construct (uint8_t*, uint32_t&); // Construct from buffer |
|
49 virtual void Clear ();// Remove all associated data |
|
50 virtual void Add (uint32_t s, const uint8_t* d = 0);// Add some data to end |
|
51 virtual void Add (Ptr<Packet> p); |
|
52 // Inquire available data from (f,o) sequence pair |
|
53 virtual uint32_t SizeFromSeq (const SequenceNumber&, const SequenceNumber&); |
|
54 // Inquire available data from offset |
|
55 virtual uint32_t SizeFromOffset (uint32_t); |
|
56 // Available size from sequence difference |
|
57 virtual uint32_t OffsetFromSeq (const SequenceNumber&, const SequenceNumber&); |
|
58 virtual Ptr<Packet> CopyFromOffset (uint32_t, uint32_t); // Size, offset, ret packet |
|
59 // Copy data, size, offset specified by sequence difference |
|
60 virtual Ptr<Packet> CopyFromSeq (uint32_t, const SequenceNumber&, const SequenceNumber&); |
|
61 PendingData* Copy () const; // Create a copy of this header |
|
62 PendingData* CopyS (uint32_t); // Copy with new size |
|
63 PendingData* CopySD (uint32_t, uint8_t*); // Copy with new size, new data |
|
64 public: |
|
65 uint32_t size; // Number of data bytes |
|
66 std::vector<Ptr<Packet> > data; // Corresponding data (may be null) |
|
67 // The next two fields allow simulated applications to exchange some info |
|
68 uint32_t msgSize; // Total size of message |
|
69 uint32_t responseSize;// Size of response requested |
|
70 }; |
|
71 |
|
72 }//namepsace ns3 |
|
73 #endif |
|
74 |