120 * ns3::Chunk::addTo method to request the chunk to serialize |
119 * ns3::Chunk::addTo method to request the chunk to serialize |
121 * itself in the packet buffer. |
120 * itself in the packet buffer. |
122 * |
121 * |
123 * \param chunk a pointer to the chunk to add to this packet. |
122 * \param chunk a pointer to the chunk to add to this packet. |
124 */ |
123 */ |
125 void add (Chunk *chunk); |
124 void add (Chunk const&chunk); |
126 /** |
125 /** |
127 * Deserialize chunk from this packet. This method invokes the |
126 * Deserialize chunk from this packet. This method invokes the |
128 * ns3::Chunk::peekFrom method to request the chunk to deserialize |
127 * ns3::Chunk::peekFrom method to request the chunk to deserialize |
129 * itself from the packet buffer. This method does not remove |
128 * itself from the packet buffer. This method does not remove |
130 * the chunk from the buffer. |
129 * the chunk from the buffer. |
131 * |
130 * |
132 * \param chunk a pointer to the chunk to deserialize from the buffer |
131 * \param chunk a pointer to the chunk to deserialize from the buffer |
133 */ |
132 */ |
134 void peek (Chunk *chunk) const; |
133 void peek (Chunk &chunk) const; |
135 /** |
134 /** |
136 * Remove a deserialized chunk from the internal buffer. |
135 * Remove a deserialized chunk from the internal buffer. |
137 * This method invokes ns3::Chunk::removeFrom to complete |
136 * This method invokes ns3::Chunk::removeFrom to complete |
138 * the work initiated by Packet::peek and ns3::Chunk::peekFrom. |
137 * the work initiated by Packet::peek and ns3::Chunk::peekFrom. |
139 * |
138 * |
140 * \param chunk a pointer to the chunk to remove from the internal buffer. |
139 * \param chunk a pointer to the chunk to remove from the internal buffer. |
141 */ |
140 */ |
142 void remove (Chunk *chunk); |
141 void remove (Chunk &chunk); |
143 /** |
142 /** |
144 * Attach a tag to this packet. The tag is fully copied |
143 * Attach a tag to this packet. The tag is fully copied |
145 * in a packet-specific internal buffer. This operation |
144 * in a packet-specific internal buffer. This operation |
146 * is expected to be really fast. |
145 * is expected to be really fast. |
147 * |
146 * |
148 * \param tag a pointer to the tag to attach to this packet. |
147 * \param tag a pointer to the tag to attach to this packet. |
149 */ |
148 */ |
150 template <typename T> |
149 template <typename T> |
151 void addTag (T const *tag); |
150 void addTag (T const &tag); |
152 /** |
151 /** |
153 * Remove a tag from this packet. The data stored internally |
152 * Remove a tag from this packet. The data stored internally |
154 * for this tag is copied in the input tag if an instance |
153 * for this tag is copied in the input tag if an instance |
155 * of this tag type is present in the internal buffer. If this |
154 * of this tag type is present in the internal buffer. If this |
156 * tag type is not present, the input tag is not modified. |
155 * tag type is not present, the input tag is not modified. |
164 * \param tag a pointer to the tag to remove from this packet |
163 * \param tag a pointer to the tag to remove from this packet |
165 * \returns true if an instance of this tag type is stored |
164 * \returns true if an instance of this tag type is stored |
166 * in this packet, false otherwise. |
165 * in this packet, false otherwise. |
167 */ |
166 */ |
168 template <typename T> |
167 template <typename T> |
169 bool removeTag (T *tag); |
168 bool removeTag (T &tag); |
170 /** |
169 /** |
171 * Copy a tag stored internally to the input tag. If no instance |
170 * Copy a tag stored internally to the input tag. If no instance |
172 * of this tag is present internally, the input tag is not modified. |
171 * of this tag is present internally, the input tag is not modified. |
173 * |
172 * |
174 * \param tag a pointer to the tag to read from this packet |
173 * \param tag a pointer to the tag to read from this packet |
175 * \returns true if an instance of this tag type is stored |
174 * \returns true if an instance of this tag type is stored |
176 * in this packet, false otherwise. |
175 * in this packet, false otherwise. |
177 */ |
176 */ |
178 template <typename T> |
177 template <typename T> |
179 bool peekTag (T *tag) const; |
178 bool peekTag (T &tag) const; |
180 /** |
179 /** |
181 * Remove all the tags stored in this packet. This operation is |
180 * Remove all the tags stored in this packet. This operation is |
182 * much much faster than invoking removeTag n times. |
181 * much much faster than invoking removeTag n times. |
183 */ |
182 */ |
184 void removeAllTags (void); |
183 void removeAllTags (void); |
185 void write (PacketReadWriteCallback callback) const; |
|
186 /** |
184 /** |
187 * Concatenate the input packet at the end of the current |
185 * Concatenate the input packet at the end of the current |
188 * packet. |
186 * packet. |
189 * |
187 * |
190 * \param packet packet to concatenate |
188 * \param packet packet to concatenate |
214 * the packet. |
212 * the packet. |
215 * |
213 * |
216 * \param size number of bytes from remove |
214 * \param size number of bytes from remove |
217 */ |
215 */ |
218 void removeAtStart (uint32_t size); |
216 void removeAtStart (uint32_t size); |
219 |
217 |
|
218 /** |
|
219 * If you try to change the content of the buffer |
|
220 * returned by this method, you will die. |
|
221 * |
|
222 * \returns a pointer to the internal buffer of the packet. |
|
223 */ |
|
224 uint8_t const *peekData (void) const; |
220 private: |
225 private: |
221 Packet (Buffer buffer, Tags tags); |
226 Packet (Buffer buffer, Tags tags); |
222 Buffer m_buffer; |
227 Buffer m_buffer; |
223 Tags m_tags; |
228 Tags m_tags; |
224 }; |
229 }; |
232 *************************************************/ |
237 *************************************************/ |
233 |
238 |
234 namespace ns3 { |
239 namespace ns3 { |
235 |
240 |
236 template <typename T> |
241 template <typename T> |
237 void Packet::addTag (T const*tag) |
242 void Packet::addTag (T const& tag) |
238 { |
243 { |
239 m_tags.add (tag); |
244 m_tags.add (tag); |
240 } |
245 } |
241 template <typename T> |
246 template <typename T> |
242 bool Packet::removeTag (T *tag) |
247 bool Packet::removeTag (T & tag) |
243 { |
248 { |
244 return m_tags.remove (tag); |
249 return m_tags.remove (tag); |
245 } |
250 } |
246 template <typename T> |
251 template <typename T> |
247 bool Packet::peekTag (T *tag) const |
252 bool Packet::peekTag (T & tag) const |
248 { |
253 { |
249 return m_tags.peek (tag); |
254 return m_tags.peek (tag); |
250 } |
255 } |
251 }; // namespace ns3 |
256 }; // namespace ns3 |
252 |
257 |