A Discrete-Event Network Simulator
API
wimax-tlv.h
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2009 INRIA, UDcast
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 * Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
19 *
20 */
21
22#ifndef WIMAX_TLV_H
23#define WIMAX_TLV_H
24
25#define WIMAX_TLV_EXTENDED_LENGTH_MASK 0x80
26
27#include "ns3/ipv4-address.h"
28#include <cstdlib>
29#include "ns3/log.h"
30#include "ns3/assert.h"
31#include "ns3/uinteger.h"
32#include "ns3/header.h"
33#include <vector>
34
35namespace ns3 {
36
44{
45public:
46 virtual ~TlvValue ()
47 {
48 }
53 virtual uint32_t GetSerializedSize (void) const = 0;
58 virtual void Serialize (Buffer::Iterator start) const = 0;
65 virtual uint32_t Deserialize (Buffer::Iterator start, uint64_t valueLen ) = 0;
70 virtual TlvValue * Copy (void) const = 0;
71private:
72};
73
74
75// =============================================================================
83class Tlv : public Header
84{
85public:
88 {
96 };
104 Tlv (uint8_t type, uint64_t length, const TlvValue & value);
105 Tlv (void);
106 ~Tlv (void);
111 static TypeId GetTypeId (void);
112 virtual TypeId GetInstanceTypeId (void) const;
113 virtual void Print (std::ostream &os) const;
114 virtual uint32_t GetSerializedSize (void) const;
115 virtual void Serialize (Buffer::Iterator start) const;
121 uint8_t GetSizeOfLen (void) const;
126 uint8_t GetType (void) const;
131 uint64_t GetLength (void) const;
136 TlvValue* PeekValue (void);
141 Tlv * Copy (void) const;
146 TlvValue * CopyValue (void) const;
152 Tlv &operator = (Tlv const& o);
157 Tlv (const Tlv & tlv);
158
159private:
160 uint8_t m_type;
161 uint64_t m_length;
163};
164
165// ==============================================================================
170class U8TlvValue : public TlvValue
171{
172public:
178 U8TlvValue (uint8_t value);
179 U8TlvValue ();
180 ~U8TlvValue (void);
181 virtual uint32_t GetSerializedSize (void) const;
182 virtual void Serialize (Buffer::Iterator start) const;
183 virtual uint32_t Deserialize (Buffer::Iterator start,uint64_t valueLen);
194 uint8_t GetValue (void) const;
199 U8TlvValue * Copy (void) const;
200private:
201 uint8_t m_value;
202};
203
204// ==============================================================================
209class U16TlvValue : public TlvValue
210{
211public:
217 U16TlvValue (uint16_t value);
218 U16TlvValue ();
219 ~U16TlvValue (void);
220 virtual uint32_t GetSerializedSize (void) const;
221 virtual void Serialize (Buffer::Iterator start) const;
222 virtual uint32_t Deserialize (Buffer::Iterator start,uint64_t valueLen);
233 uint16_t GetValue (void) const;
238 virtual U16TlvValue * Copy (void) const;
239private:
240 uint16_t m_value;
241};
242
243// ==============================================================================
248class U32TlvValue : public TlvValue
249{
250public:
256 U32TlvValue (uint32_t value);
257 U32TlvValue ();
258 ~U32TlvValue (void);
259
260 virtual uint32_t GetSerializedSize (void) const;
261 virtual void Serialize (Buffer::Iterator start) const;
262 virtual uint32_t Deserialize (Buffer::Iterator start, uint64_t valueLen);
273 uint32_t GetValue (void) const;
278 virtual U32TlvValue * Copy (void) const;
279private:
281};
282
283// ==============================================================================
284
290{
291public:
293 typedef std::vector<Tlv*>::const_iterator Iterator;
294 VectorTlvValue (void);
295 ~VectorTlvValue (void);
296 virtual uint32_t GetSerializedSize (void) const;
297 virtual void Serialize (Buffer::Iterator start) const;
298 virtual uint32_t Deserialize (Buffer::Iterator start, uint64_t valueLength) = 0;
303 Iterator Begin () const;
308 Iterator End () const;
313 void Add (const Tlv & val);
318 virtual VectorTlvValue * Copy (void) const = 0;
319private:
320 std::vector<Tlv*> * m_tlvList;
321};
322
323// ==============================================================================
329{
330
331public:
333 enum Type
334 {
335 SFID = 1,
336 CID = 2,
364 };
366 virtual uint32_t Deserialize (Buffer::Iterator start, uint64_t valueLength);
367 virtual SfVectorTlvValue * Copy (void) const;
368
369};
370// ==============================================================================
371
377{
378public:
380 enum Type
381 {
384 };
386 virtual uint32_t Deserialize (Buffer::Iterator start, uint64_t valueLength);
387 virtual CsParamVectorTlvValue * Copy (void) const;
388private:
389};
390
391// ==============================================================================
392
398{
399public:
402 {
404 ToS = 2,
410 Index = 14,
411 };
413 virtual uint32_t Deserialize (Buffer::Iterator start, uint64_t valueLength);
414 virtual ClassificationRuleVectorTlvValue * Copy (void) const;
415private:
416};
417
418// ==============================================================================
423class TosTlvValue : public TlvValue
424{
425public:
426 TosTlvValue ();
434 TosTlvValue (uint8_t low, uint8_t high, uint8_t mask);
435 ~TosTlvValue ();
436 virtual uint32_t GetSerializedSize (void) const;
437 virtual void Serialize (Buffer::Iterator start) const;
438 virtual uint32_t Deserialize (Buffer::Iterator start, uint64_t valueLength);
443 uint8_t GetLow (void) const;
448 uint8_t GetHigh (void) const;
453 uint8_t GetMask (void) const;
458 virtual TosTlvValue * Copy () const;
459private:
460 uint8_t m_low;
461 uint8_t m_high;
462 uint8_t m_mask;
463};
464
465// ==============================================================================
471{
472public:
475 {
476 uint16_t PortLow;
477 uint16_t PortHigh;
478 };
480 typedef std::vector<struct PortRange>::const_iterator Iterator;
483 virtual uint32_t GetSerializedSize (void) const;
484 virtual void Serialize (Buffer::Iterator start) const;
485 virtual uint32_t Deserialize (Buffer::Iterator start, uint64_t valueLength);
491 void Add (uint16_t portLow, uint16_t portHigh);
496 Iterator Begin () const;
501 Iterator End () const;
506 virtual PortRangeTlvValue * Copy (void) const;
507private:
508 std::vector<struct PortRange> * m_portRange;
509};
510
511// ==============================================================================
517{
518public:
522 typedef std::vector<uint8_t>::const_iterator Iterator;
523 virtual uint32_t GetSerializedSize (void) const;
524 virtual void Serialize (Buffer::Iterator start) const;
525 virtual uint32_t Deserialize (Buffer::Iterator start, uint64_t valueLength);
530 void Add (uint8_t protocol);
535 Iterator Begin () const;
540 Iterator End () const;
545 virtual ProtocolTlvValue * Copy (void) const;
546private:
547 std::vector<uint8_t> * m_protocol;
548};
549
550// ==============================================================================
551
557{
558public:
560 struct ipv4Addr
561 {
564 };
566 typedef std::vector<struct ipv4Addr>::const_iterator Iterator;
569 virtual uint32_t GetSerializedSize (void) const;
570 virtual void Serialize (Buffer::Iterator start) const;
571 virtual uint32_t Deserialize (Buffer::Iterator start, uint64_t valueLength);
577 void Add (Ipv4Address address, Ipv4Mask Mask);
582 Iterator Begin () const;
587 Iterator End () const;
588 virtual Ipv4AddressTlvValue * Copy () const;
589private:
590 std::vector<struct ipv4Addr> * m_ipv4Addr;
591};
592
593}
594
595#endif /* WIMAX_TLV_H */
iterator in a Buffer instance
Definition: buffer.h:99
this class implements the classifier descriptor as a tlv vector
Definition: wimax-tlv.h:398
ClassificationRuleTlvType
ClassificationRuleTlvType enumeration.
Definition: wimax-tlv.h:402
virtual ClassificationRuleVectorTlvValue * Copy(void) const
Copy.
Definition: wimax-tlv.cc:719
virtual uint32_t Deserialize(Buffer::Iterator start, uint64_t valueLength)
Deserialize from a buffer.
Definition: wimax-tlv.cc:730
this class implements the convergence sub-layer descriptor as a tlv vector
Definition: wimax-tlv.h:377
virtual CsParamVectorTlvValue * Copy(void) const
Copy.
Definition: wimax-tlv.cc:702
Type
Type enumeration.
Definition: wimax-tlv.h:381
virtual uint32_t Deserialize(Buffer::Iterator start, uint64_t valueLength)
Deserialize from a buffer.
Definition: wimax-tlv.cc:648
Protocol header serialization and deserialization.
Definition: header.h:43
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
Ipv4AddressTlvValue class.
Definition: wimax-tlv.h:557
Iterator End() const
End iterator.
Definition: wimax-tlv.cc:1083
std::vector< struct ipv4Addr > * m_ipv4Addr
ipv4 addr
Definition: wimax-tlv.h:590
std::vector< structipv4Addr >::const_iterator Iterator
IPv4 address vector iterator typedef.
Definition: wimax-tlv.h:566
virtual uint32_t Deserialize(Buffer::Iterator start, uint64_t valueLength)
Deserialize from a buffer.
Definition: wimax-tlv.cc:1054
virtual uint32_t GetSerializedSize(void) const
Get serialized size in bytes.
Definition: wimax-tlv.cc:1038
Iterator Begin() const
Begin iterator.
Definition: wimax-tlv.cc:1077
void Add(Ipv4Address address, Ipv4Mask Mask)
Add IPv4 address and mask.
Definition: wimax-tlv.cc:1068
virtual void Serialize(Buffer::Iterator start) const
Serialize to a buffer.
Definition: wimax-tlv.cc:1044
virtual Ipv4AddressTlvValue * Copy() const
Copy function.
Definition: wimax-tlv.cc:1089
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:256
PortRangeTlvValue class.
Definition: wimax-tlv.h:471
virtual PortRangeTlvValue * Copy(void) const
Copy.
Definition: wimax-tlv.cc:938
virtual uint32_t GetSerializedSize(void) const
Get serialized size in bytes.
Definition: wimax-tlv.cc:891
virtual uint32_t Deserialize(Buffer::Iterator start, uint64_t valueLength)
Deserialize from a buffer.
Definition: wimax-tlv.cc:905
std::vector< structPortRange >::const_iterator Iterator
PortRange vector iterator typedef.
Definition: wimax-tlv.h:480
virtual void Serialize(Buffer::Iterator start) const
Serialize to a buffer.
Definition: wimax-tlv.cc:896
Iterator End() const
End iterator.
Definition: wimax-tlv.cc:932
std::vector< struct PortRange > * m_portRange
port range
Definition: wimax-tlv.h:508
Iterator Begin() const
Begin iterator.
Definition: wimax-tlv.cc:926
void Add(uint16_t portLow, uint16_t portHigh)
Add a range.
Definition: wimax-tlv.cc:918
ProtocolTlvValue class.
Definition: wimax-tlv.h:517
virtual ProtocolTlvValue * Copy(void) const
Copy.
Definition: wimax-tlv.cc:1010
std::vector< uint8_t > * m_protocol
protocol
Definition: wimax-tlv.h:547
void Add(uint8_t protocol)
Add protocol number.
Definition: wimax-tlv.cc:992
virtual uint32_t Deserialize(Buffer::Iterator start, uint64_t valueLength)
Deserialize from a buffer.
Definition: wimax-tlv.cc:980
Iterator Begin() const
Begin iterator.
Definition: wimax-tlv.cc:998
virtual uint32_t GetSerializedSize(void) const
Get serialized size in bytes.
Definition: wimax-tlv.cc:965
std::vector< uint8_t >::const_iterator Iterator
Iterator typedef.
Definition: wimax-tlv.h:522
Iterator End() const
End iterator.
Definition: wimax-tlv.cc:1004
virtual void Serialize(Buffer::Iterator start) const
Serialize to a buffer.
Definition: wimax-tlv.cc:971
SfVectorTlvValue class.
Definition: wimax-tlv.h:329
Type
Type enumeration.
Definition: wimax-tlv.h:334
@ Fixed_length_versus_Variable_length_SDU_Indicator
Definition: wimax-tlv.h:349
@ ARQ_RETRY_TIMEOUT_Transmitter_Delay
Definition: wimax-tlv.h:354
virtual SfVectorTlvValue * Copy(void) const
Copy.
Definition: wimax-tlv.cc:296
virtual uint32_t Deserialize(Buffer::Iterator start, uint64_t valueLength)
Deserialize from a buffer.
Definition: wimax-tlv.cc:307
This class implements the Type-Len-Value structure channel encodings as described by "IEEE Standard f...
Definition: wimax-tlv.h:84
virtual void Print(std::ostream &os) const
Definition: wimax-tlv.cc:47
uint8_t m_type
type
Definition: wimax-tlv.h:160
uint64_t m_length
length
Definition: wimax-tlv.h:161
Tlv & operator=(Tlv const &o)
assignment operator
Definition: wimax-tlv.cc:89
uint8_t GetType(void) const
Get type value.
Definition: wimax-tlv.cc:214
Tlv * Copy(void) const
Copy TLV.
Definition: wimax-tlv.cc:230
TlvValue * PeekValue(void)
Peek value.
Definition: wimax-tlv.cc:224
TlvValue * CopyValue(void) const
Copy TlvValue.
Definition: wimax-tlv.cc:76
virtual void Serialize(Buffer::Iterator start) const
Definition: wimax-tlv.cc:127
CommonTypes
CommonTypes enumeration.
Definition: wimax-tlv.h:88
@ UPLINK_SERVICE_FLOW
Definition: wimax-tlv.h:93
@ VENDOR_ID_EMCODING
Definition: wimax-tlv.h:94
@ DOWNLINK_SERVICE_FLOW
Definition: wimax-tlv.h:92
@ CURRENT_TRANSMIT_POWER
Definition: wimax-tlv.h:91
@ HMAC_TUPLE
Definition: wimax-tlv.h:89
@ MAC_VERSION_ENCODING
Definition: wimax-tlv.h:90
@ VENDOR_SPECIFIC_INFORMATION
Definition: wimax-tlv.h:95
uint64_t GetLength(void) const
Get length value.
Definition: wimax-tlv.cc:219
virtual uint32_t Deserialize(Buffer::Iterator start)
Definition: wimax-tlv.cc:147
static TypeId GetTypeId(void)
Register this type.
Definition: wimax-tlv.cc:32
virtual uint32_t GetSerializedSize(void) const
Definition: wimax-tlv.cc:103
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
Definition: wimax-tlv.cc:42
uint8_t GetSizeOfLen(void) const
Get size of length field.
Definition: wimax-tlv.cc:109
~Tlv(void)
Definition: wimax-tlv.cc:66
TlvValue * m_value
value
Definition: wimax-tlv.h:162
Tlv(void)
Definition: wimax-tlv.cc:59
The value field of a tlv can take different values (uint8_t, uint16, vector, ...).
Definition: wimax-tlv.h:44
virtual ~TlvValue()
Definition: wimax-tlv.h:46
virtual uint32_t Deserialize(Buffer::Iterator start, uint64_t valueLen)=0
Deserialize from a buffer.
virtual uint32_t GetSerializedSize(void) const =0
Get serialized size in bytes.
virtual void Serialize(Buffer::Iterator start) const =0
Serialize to a buffer.
virtual TlvValue * Copy(void) const =0
Copy function.
TosTlvValue class.
Definition: wimax-tlv.h:424
uint8_t GetMask(void) const
Get the mask.
Definition: wimax-tlv.cc:868
uint8_t m_high
high
Definition: wimax-tlv.h:461
virtual uint32_t Deserialize(Buffer::Iterator start, uint64_t valueLength)
Deserialize from a buffer.
Definition: wimax-tlv.cc:850
virtual uint32_t GetSerializedSize(void) const
Get serialized size in bytes.
Definition: wimax-tlv.cc:838
uint8_t GetLow(void) const
Get low part.
Definition: wimax-tlv.cc:858
virtual TosTlvValue * Copy() const
Copy.
Definition: wimax-tlv.cc:874
virtual void Serialize(Buffer::Iterator start) const
Serialize to a buffer.
Definition: wimax-tlv.cc:843
uint8_t m_mask
mask
Definition: wimax-tlv.h:462
uint8_t m_low
low
Definition: wimax-tlv.h:460
uint8_t GetHigh(void) const
Get high part.
Definition: wimax-tlv.cc:863
a unique identifier for an interface.
Definition: type-id.h:59
U16TlvValue class.
Definition: wimax-tlv.h:210
virtual uint32_t Deserialize(Buffer::Iterator start, uint64_t valueLen)
Deserialize from a buffer.
Definition: wimax-tlv.cc:574
virtual U16TlvValue * Copy(void) const
Copy.
Definition: wimax-tlv.cc:593
uint16_t GetValue(void) const
Get value.
Definition: wimax-tlv.cc:587
uint16_t m_value
value
Definition: wimax-tlv.h:240
virtual uint32_t GetSerializedSize(void) const
Get serialized size in bytes.
Definition: wimax-tlv.cc:564
virtual void Serialize(Buffer::Iterator start) const
Serialize to a buffer.
Definition: wimax-tlv.cc:569
U32TlvValue class.
Definition: wimax-tlv.h:249
uint32_t GetValue(void) const
Get value.
Definition: wimax-tlv.cc:635
virtual uint32_t Deserialize(Buffer::Iterator start, uint64_t valueLen)
Deserialize from a buffer.
Definition: wimax-tlv.cc:623
virtual uint32_t GetSerializedSize(void) const
Get serialized size in bytes.
Definition: wimax-tlv.cc:613
virtual U32TlvValue * Copy(void) const
Copy.
Definition: wimax-tlv.cc:641
virtual void Serialize(Buffer::Iterator start) const
Serialize to a buffer.
Definition: wimax-tlv.cc:618
uint32_t m_value
value
Definition: wimax-tlv.h:280
U8TlvValue class.
Definition: wimax-tlv.h:171
virtual void Serialize(Buffer::Iterator start) const
Serialize to a buffer.
Definition: wimax-tlv.cc:519
virtual uint32_t Deserialize(Buffer::Iterator start, uint64_t valueLen)
Deserialize from a buffer.
Definition: wimax-tlv.cc:524
U8TlvValue * Copy(void) const
Copy.
Definition: wimax-tlv.cc:543
virtual uint32_t GetSerializedSize(void) const
Get serialized size in bytes.
Definition: wimax-tlv.cc:514
uint8_t m_value
value
Definition: wimax-tlv.h:201
uint8_t GetValue(void) const
Get value.
Definition: wimax-tlv.cc:537
this class is used to implement a vector of values in one tlv value field
Definition: wimax-tlv.h:290
virtual uint32_t Deserialize(Buffer::Iterator start, uint64_t valueLength)=0
Deserialize from a buffer.
std::vector< Tlv * >::const_iterator Iterator
TLV vector iterator typedef.
Definition: wimax-tlv.h:293
Iterator End() const
End iterator.
Definition: wimax-tlv.cc:278
Iterator Begin() const
Begin iterator.
Definition: wimax-tlv.cc:272
void Add(const Tlv &val)
Add a TLV.
Definition: wimax-tlv.cc:284
std::vector< Tlv * > * m_tlvList
tlv list
Definition: wimax-tlv.h:320
virtual void Serialize(Buffer::Iterator start) const
Serialize to a buffer.
Definition: wimax-tlv.cc:262
virtual uint32_t GetSerializedSize(void) const
Get serialized size in bytes.
Definition: wimax-tlv.cc:251
virtual VectorTlvValue * Copy(void) const =0
Copy.
address
Definition: first.py:40
Every class exported by the ns3 library is enclosed in the ns3 namespace.
def start()
Definition: core.py:1852
PortRange structure.
Definition: wimax-tlv.h:475