author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Wed, 06 Sep 2006 16:46:26 +0200 | |
changeset 79 | 84f791c00aa5 |
parent 77 | 926e17b61dfb |
child 80 | 3706b1172ab9 |
permissions | -rw-r--r-- |
54
f860e6f94787
change indent to be 4 spaces
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
53
diff
changeset
|
1 |
/* -*- Mode:C++; c-basic-offset:4; tab-width:4; indent-tabs-mode:f -*- */ |
9
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
2 |
/* |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
3 |
* Copyright (c) 2005,2006 INRIA |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
4 |
* All rights reserved. |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
5 |
* |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
6 |
* This program is free software; you can redistribute it and/or modify |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
7 |
* it under the terms of the GNU General Public License version 2 as |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
8 |
* published by the Free Software Foundation; |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
9 |
* |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
10 |
* This program is distributed in the hope that it will be useful, |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
13 |
* GNU General Public License for more details. |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
14 |
* |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
16 |
* along with this program; if not, write to the Free Software |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
17 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
18 |
* |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
19 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
20 |
*/ |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
21 |
#ifndef PACKET_H |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
22 |
#define PACKET_H |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
23 |
|
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
24 |
#include <stdint.h> |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
25 |
#include "buffer.h" |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
26 |
#include "chunk.h" |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
27 |
#include "tags.h" |
14
6dd7d31c6fc3
replace yans include with ns3 include
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
9
diff
changeset
|
28 |
#include "ns3/callback.h" |
9
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
29 |
|
16
99e833adbb46
change yans namespace to ns3
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
14
diff
changeset
|
30 |
namespace ns3 { |
9
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
31 |
|
79
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
32 |
/** |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
33 |
* \brief network packets |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
34 |
*/ |
9
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
35 |
class Packet { |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
36 |
public: |
54
f860e6f94787
change indent to be 4 spaces
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
53
diff
changeset
|
37 |
typedef Callback<void,uint8_t *,uint32_t> PacketReadWriteCallback; |
79
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
38 |
/** |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
39 |
* Create an empty packet. |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
40 |
*/ |
54
f860e6f94787
change indent to be 4 spaces
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
53
diff
changeset
|
41 |
Packet (); |
79
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
42 |
/** |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
43 |
* Create a packet with a zero-filled payload. |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
44 |
* The memory necessary for the payload is not allocated: |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
45 |
* it will be allocated at any later point if you attempt |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
46 |
* to fragment this packet or to access the zero-filled |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
47 |
* bytes. |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
48 |
* |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
49 |
* \param size the size of the zero-filled payload |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
50 |
*/ |
54
f860e6f94787
change indent to be 4 spaces
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
53
diff
changeset
|
51 |
Packet (uint32_t size); |
79
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
52 |
/** |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
53 |
* Create a new packet which contains a fragment of the original |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
54 |
* packet. |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
55 |
* |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
56 |
* \param start offset from start of packet to start of fragment to create |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
57 |
* \param length length of fragment to create |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
58 |
* \returns a fragment of the original packet |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
59 |
*/ |
54
f860e6f94787
change indent to be 4 spaces
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
53
diff
changeset
|
60 |
Packet createFragment (uint32_t start, uint32_t length) const; |
79
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
61 |
/** |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
62 |
* \returns the size in bytes of the packet (including the zero-filled |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
63 |
* initial payload) |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
64 |
*/ |
54
f860e6f94787
change indent to be 4 spaces
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
53
diff
changeset
|
65 |
uint32_t getSize (void) const; |
79
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
66 |
/** |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
67 |
* Add chunk to this packet. This method invokes the |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
68 |
* ns3::Chunk::addTo method to request the chunk to serialize |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
69 |
* itself in the packet buffer. |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
70 |
* |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
71 |
* \param chunk a pointer to the chunk to add to this packet. |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
72 |
*/ |
54
f860e6f94787
change indent to be 4 spaces
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
53
diff
changeset
|
73 |
void add (Chunk *chunk); |
79
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
74 |
/** |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
75 |
* Deserialize chunk from this packet. This method invokes the |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
76 |
* ns3::Chunk::peekFrom method to request the chunk to deserialize |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
77 |
* itself from the packet buffer. This method does not remove |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
78 |
* the chunk from the buffer. |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
79 |
* |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
80 |
* \param chunk a pointer to the chunk to deserialize from the buffer |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
81 |
*/ |
54
f860e6f94787
change indent to be 4 spaces
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
53
diff
changeset
|
82 |
void peek (Chunk *chunk) const; |
79
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
83 |
/** |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
84 |
* Remove a deserialized chunk from the internal buffer. |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
85 |
* This method invokes ns3::Chunk::removeFrom to complete |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
86 |
* the work initiated by Packet::peek and ns3::Chunk::peekFrom. |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
87 |
* |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
88 |
* \param chunk a pointer to the chunk to remove from the internal buffer. |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
89 |
*/ |
54
f860e6f94787
change indent to be 4 spaces
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
53
diff
changeset
|
90 |
void remove (Chunk *chunk); |
79
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
91 |
/** |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
92 |
* Attach a tag to this packet. The tag is fully copied |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
93 |
* in a packet-specific internal buffer. This operation |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
94 |
* is expected to be really fast. |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
95 |
* |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
96 |
* \param tag a pointer to the tag to attach to this packet. |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
97 |
*/ |
54
f860e6f94787
change indent to be 4 spaces
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
53
diff
changeset
|
98 |
template <typename T> |
f860e6f94787
change indent to be 4 spaces
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
53
diff
changeset
|
99 |
void addTag (T const *tag); |
79
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
100 |
/** |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
101 |
* Remove a tag from this packet. The data stored internally |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
102 |
* for this tag is copied in the input tag if an instance |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
103 |
* of this tag type is present in the internal buffer. If this |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
104 |
* tag type is not present, the input tag is not modified. |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
105 |
* |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
106 |
* This operation can be potentially slow and might trigger |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
107 |
* unexpectedly large memory allocations. It is thus |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
108 |
* usually a better idea to create a copy of this packet, |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
109 |
* and invoke removeAllTags on the copy to remove all |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
110 |
* tags rather than remove the tags one by one from a packet. |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
111 |
* |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
112 |
* \param tag a pointer to the tag to remove from this packet |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
113 |
* \returns true if an instance of this tag type is stored |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
114 |
* in this packet, false otherwise. |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
115 |
*/ |
54
f860e6f94787
change indent to be 4 spaces
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
53
diff
changeset
|
116 |
template <typename T> |
f860e6f94787
change indent to be 4 spaces
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
53
diff
changeset
|
117 |
bool removeTag (T *tag); |
79
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
118 |
/** |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
119 |
* Copy a tag stored internally to the input tag. If no instance |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
120 |
* of this tag is present internally, the input tag is not modified. |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
121 |
* |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
122 |
* \param tag a pointer to the tag to read from this packet |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
123 |
* \returns true if an instance of this tag type is stored |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
124 |
* in this packet, false otherwise. |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
125 |
*/ |
54
f860e6f94787
change indent to be 4 spaces
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
53
diff
changeset
|
126 |
template <typename T> |
f860e6f94787
change indent to be 4 spaces
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
53
diff
changeset
|
127 |
bool peekTag (T *tag) const; |
79
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
128 |
/** |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
129 |
* Remove all the tags stored in this packet. This operation is |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
130 |
* much much faster than invoking removeTag n times. |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
131 |
*/ |
54
f860e6f94787
change indent to be 4 spaces
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
53
diff
changeset
|
132 |
void removeAllTags (void); |
f860e6f94787
change indent to be 4 spaces
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
53
diff
changeset
|
133 |
void write (PacketReadWriteCallback callback) const; |
79
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
134 |
/** |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
135 |
* Concatenate the input packet at the end of the current |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
136 |
* packet. |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
137 |
* |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
138 |
* \param packet packet to concatenate |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
139 |
*/ |
54
f860e6f94787
change indent to be 4 spaces
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
53
diff
changeset
|
140 |
void addAtEnd (Packet packet); |
79
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
141 |
/** |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
142 |
* Concatenate the fragment of the input packet identified |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
143 |
* by the offset and size parameters at the end of the current |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
144 |
* packet. |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
145 |
* |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
146 |
* \param packet to concatenate |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
147 |
* \param offset offset of fragment to copy from the start of the input packet |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
148 |
* \param size size of fragment of input packet to copy. |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
149 |
*/ |
54
f860e6f94787
change indent to be 4 spaces
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
53
diff
changeset
|
150 |
void addAtEnd (Packet packet, uint32_t offset, uint32_t size); |
79
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
151 |
/** |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
152 |
* Remove size bytes from the end of the current packet |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
153 |
* It is safe to remove more bytes that what is present in |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
154 |
* the packet. |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
155 |
* |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
156 |
* \param size number of bytes from remove |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
157 |
*/ |
54
f860e6f94787
change indent to be 4 spaces
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
53
diff
changeset
|
158 |
void removeAtEnd (uint32_t size); |
79
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
159 |
/** |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
160 |
* Remove size bytes from the start of the current packet. |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
161 |
* It is safe to remove more bytes that what is present in |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
162 |
* the packet. |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
163 |
* |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
164 |
* \param size number of bytes from remove |
84f791c00aa5
improve documentation and remove updateTag method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
77
diff
changeset
|
165 |
*/ |
54
f860e6f94787
change indent to be 4 spaces
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
53
diff
changeset
|
166 |
void removeAtStart (uint32_t size); |
9
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
167 |
|
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
168 |
private: |
54
f860e6f94787
change indent to be 4 spaces
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
53
diff
changeset
|
169 |
Packet (Buffer buffer, Tags tags); |
f860e6f94787
change indent to be 4 spaces
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
53
diff
changeset
|
170 |
Buffer m_buffer; |
f860e6f94787
change indent to be 4 spaces
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
53
diff
changeset
|
171 |
Tags m_tags; |
9
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
172 |
}; |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
173 |
|
16
99e833adbb46
change yans namespace to ns3
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
14
diff
changeset
|
174 |
}; // namespace ns3 |
9
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
175 |
|
77
926e17b61dfb
add comment on implementation location
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
54
diff
changeset
|
176 |
|
926e17b61dfb
add comment on implementation location
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
54
diff
changeset
|
177 |
/************************************************** |
926e17b61dfb
add comment on implementation location
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
54
diff
changeset
|
178 |
Start of implementation of templates defined |
926e17b61dfb
add comment on implementation location
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
54
diff
changeset
|
179 |
above |
926e17b61dfb
add comment on implementation location
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
54
diff
changeset
|
180 |
*************************************************/ |
926e17b61dfb
add comment on implementation location
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
54
diff
changeset
|
181 |
|
16
99e833adbb46
change yans namespace to ns3
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
14
diff
changeset
|
182 |
namespace ns3 { |
9
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
183 |
|
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
184 |
template <typename T> |
53
ae406f4957d5
variable/method/function coding style update
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
16
diff
changeset
|
185 |
void Packet::addTag (T const*tag) |
9
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
186 |
{ |
54
f860e6f94787
change indent to be 4 spaces
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
53
diff
changeset
|
187 |
m_tags.add (tag); |
9
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
188 |
} |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
189 |
template <typename T> |
53
ae406f4957d5
variable/method/function coding style update
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
16
diff
changeset
|
190 |
bool Packet::removeTag (T *tag) |
9
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
191 |
{ |
54
f860e6f94787
change indent to be 4 spaces
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
53
diff
changeset
|
192 |
return m_tags.remove (tag); |
9
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
193 |
} |
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
194 |
template <typename T> |
53
ae406f4957d5
variable/method/function coding style update
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
16
diff
changeset
|
195 |
bool Packet::peekTag (T *tag) const |
9
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
196 |
{ |
54
f860e6f94787
change indent to be 4 spaces
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
53
diff
changeset
|
197 |
return m_tags.peek (tag); |
9
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
198 |
} |
16
99e833adbb46
change yans namespace to ns3
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
14
diff
changeset
|
199 |
}; // namespace ns3 |
9
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
200 |
|
2c31ae7c94db
import from yans
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
201 |
#endif /* PACKET_H */ |