/usr/include/ns3.27/ns3/wimax-tlv.h is in libns3-dev 3.27+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2009 INRIA, UDcast
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
*
*/
#ifndef WIMAX_TLV_H
#define WIMAX_TLV_H
#define WIMAX_TLV_EXTENDED_LENGTH_MASK 0x80
#include "ns3/ipv4-address.h"
#include <cstdlib>
#include "ns3/log.h"
#include "ns3/assert.h"
#include "ns3/uinteger.h"
#include "ns3/header.h"
#include <vector>
namespace ns3 {
/**
* \ingroup wimax
* The value field of a tlv can take different values (uint8_t, uint16,
* vector, ...). This class is a virtual interface
* from which all the types of tlv values should derive
*/
class TlvValue
{
public:
virtual ~TlvValue ()
{
}
/**
* Get serialized size in bytes
* \returns the serialized size
*/
virtual uint32_t GetSerializedSize (void) const = 0;
/**
* Serialize to a buffer
* \param start the iterator
*/
virtual void Serialize (Buffer::Iterator start) const = 0;
/**
* Deserialize from a buffer
* \param start the iterator
* \param valueLen the maximum length of the value
* \returns the
*/
virtual uint32_t Deserialize (Buffer::Iterator start, uint64_t valueLen ) = 0;
/**
* Copy function
* \returns the TLV value
*/
virtual TlvValue * Copy (void) const = 0;
private:
};
// =============================================================================
/**
* \ingroup wimax
* \brief This class implements the Type-Len-Value structure channel encodings as described by "IEEE Standard for
* Local and metropolitan area networks Part 16: Air Interface for Fixed Broadband Wireless Access Systems"
* 11. TLV encodings, page 645
*
*/
class Tlv : public Header
{
public:
/// CommonTypes enumeration
enum CommonTypes
{
HMAC_TUPLE = 149,
MAC_VERSION_ENCODING = 148,
CURRENT_TRANSMIT_POWER = 147,
DOWNLINK_SERVICE_FLOW = 146,
UPLINK_SERVICE_FLOW = 145,
VENDOR_ID_EMCODING = 144,
VENDOR_SPECIFIC_INFORMATION = 143
};
/**
* Constructor
*
* \param type type
* \param length the length
* \param value TLV value
*/
Tlv (uint8_t type, uint64_t length, const TlvValue & value);
Tlv (void);
~Tlv (void);
/**
* Register this type.
* \return the TypeId.
*/
static TypeId GetTypeId (void);
virtual TypeId GetInstanceTypeId (void) const;
virtual void Print (std::ostream &os) const;
virtual uint32_t GetSerializedSize (void) const;
virtual void Serialize (Buffer::Iterator start) const;
virtual uint32_t Deserialize (Buffer::Iterator start);
/**
* Get size of length field
* \returns the size of length field
*/
uint8_t GetSizeOfLen (void) const;
/**
* Get type value
* \returns the type
*/
uint8_t GetType (void) const;
/**
* Get length value
* \returns the length
*/
uint64_t GetLength (void) const;
/**
* Peek value
* \returns the TLV value
*/
TlvValue* PeekValue (void);
/**
* Copy TLV
* \returns a pointer to a TLV copy
*/
Tlv * Copy (void) const;
/**
* Copy TlvValue
* \returns the TLV value
*/
TlvValue * CopyValue (void) const;
/**
* assignment operator
* \param o the TLV to assign
* \returns the TLV
*/
Tlv &operator = (Tlv const& o);
/**
* type conversion operator
* \param tlv the TLV
*/
Tlv (const Tlv & tlv);
private:
uint8_t m_type; ///< type
uint64_t m_length; ///< length
TlvValue * m_value; ///< value
};
// ==============================================================================
/**
* \ingroup wimax
* \brief U8TlvValue class
*/
class U8TlvValue : public TlvValue
{
public:
/**
* Constructor
*
* \param value value to encode
*/
U8TlvValue (uint8_t value);
U8TlvValue ();
~U8TlvValue (void);
virtual uint32_t GetSerializedSize (void) const;
virtual void Serialize (Buffer::Iterator start) const;
virtual uint32_t Deserialize (Buffer::Iterator start,uint64_t valueLen);
/**
* Deserialize from a buffer
* \param start the iterator
* \returns the size of the item
*/
uint32_t Deserialize (Buffer::Iterator start);
/**
* Get value
* \returns the value
*/
uint8_t GetValue (void) const;
/**
* Copy
* \returns a U8 TLV value
*/
U8TlvValue * Copy (void) const;
private:
uint8_t m_value; ///< value
};
// ==============================================================================
/**
* \ingroup wimax
* \brief U16TlvValue class
*/
class U16TlvValue : public TlvValue
{
public:
/**
* Constructor
*
* \param value value to encode
*/
U16TlvValue (uint16_t value);
U16TlvValue ();
~U16TlvValue (void);
virtual uint32_t GetSerializedSize (void) const;
virtual void Serialize (Buffer::Iterator start) const;
virtual uint32_t Deserialize (Buffer::Iterator start,uint64_t valueLen);
/**
* Deserialize from a buffer
* \param start the iterator
* \returns the size
*/
uint32_t Deserialize (Buffer::Iterator start);
/**
* Get value
* \returns the value
*/
uint16_t GetValue (void) const;
/**
* Copy
* \returns the U16 TLV value
*/
virtual U16TlvValue * Copy (void) const;
private:
uint16_t m_value; ///< value
};
// ==============================================================================
/**
* \ingroup wimax
* \brief U32TlvValue class
*/
class U32TlvValue : public TlvValue
{
public:
/**
* Constructor
*
* \param value to encode
*/
U32TlvValue (uint32_t value);
U32TlvValue ();
~U32TlvValue (void);
virtual uint32_t GetSerializedSize (void) const;
virtual void Serialize (Buffer::Iterator start) const;
virtual uint32_t Deserialize (Buffer::Iterator start, uint64_t valueLen);
/**
* Deserialize from a buffer
* \param start the iterator
* \returns the size
*/
uint32_t Deserialize (Buffer::Iterator start);
/**
* Get value
* \returns the value
*/
uint32_t GetValue (void) const;
/**
* Copy
* \returns the U32 TLV Value
*/
virtual U32TlvValue * Copy (void) const;
private:
uint32_t m_value; ///< value
};
// ==============================================================================
/**
* \ingroup wimax
* \brief this class is used to implement a vector of values in one tlv value field
*/
class VectorTlvValue : public TlvValue
{
public:
/// TLV vector iterator typedef
typedef std::vector<Tlv*>::const_iterator Iterator;
VectorTlvValue (void);
~VectorTlvValue (void);
virtual uint32_t GetSerializedSize (void) const;
virtual void Serialize (Buffer::Iterator start) const;
virtual uint32_t Deserialize (Buffer::Iterator start, uint64_t valueLength) = 0;
/**
* Begin iterator
* \returns the beginning element
*/
Iterator Begin () const;
/**
* End iterator
* \returns the ending element
*/
Iterator End () const;
/**
* Add a TLV
* \param val the TLV value
*/
void Add (const Tlv & val);
/**
* Copy
* \returns the vector TLV value
*/
virtual VectorTlvValue * Copy (void) const = 0;
private:
std::vector<Tlv*> * m_tlvList; ///< tlv list
};
// ==============================================================================
/**
* \ingroup wimax
* \brief SfVectorTlvValue class
*/
class SfVectorTlvValue : public VectorTlvValue
{
public:
/// Type enumeration
enum Type
{
SFID = 1,
CID = 2,
Service_Class_Name = 3,
reserved1 = 4,
QoS_Parameter_Set_Type = 5,
Traffic_Priority = 6,
Maximum_Sustained_Traffic_Rate = 7,
Maximum_Traffic_Burst = 8,
Minimum_Reserved_Traffic_Rate = 9,
Minimum_Tolerable_Traffic_Rate = 10,
Service_Flow_Scheduling_Type = 11,
Request_Transmission_Policy = 12,
Tolerated_Jitter = 13,
Maximum_Latency = 14,
Fixed_length_versus_Variable_length_SDU_Indicator = 15,
SDU_Size = 16,
Target_SAID = 17,
ARQ_Enable = 18,
ARQ_WINDOW_SIZE = 19,
ARQ_RETRY_TIMEOUT_Transmitter_Delay = 20,
ARQ_RETRY_TIMEOUT_Receiver_Delay = 21,
ARQ_BLOCK_LIFETIME = 22,
ARQ_SYNC_LOSS = 23,
ARQ_DELIVER_IN_ORDER = 24,
ARQ_PURGE_TIMEOUT = 25,
ARQ_BLOCK_SIZE = 26,
reserved2 = 27,
CS_Specification = 28,
IPV4_CS_Parameters = 100
};
SfVectorTlvValue ();
virtual uint32_t Deserialize (Buffer::Iterator start, uint64_t valueLength);
virtual SfVectorTlvValue * Copy (void) const;
};
// ==============================================================================
/**
* \ingroup wimax
* \brief this class implements the convergence sub-layer descriptor as a tlv vector
*/
class CsParamVectorTlvValue : public VectorTlvValue
{
public:
/// Type enumeration
enum Type
{
Classifier_DSC_Action = 1,
Packet_Classification_Rule = 3,
};
CsParamVectorTlvValue ();
virtual uint32_t Deserialize (Buffer::Iterator start, uint64_t valueLength);
virtual CsParamVectorTlvValue * Copy (void) const;
private:
};
// ==============================================================================
/**
* \ingroup wimax
* \brief this class implements the classifier descriptor as a tlv vector
*/
class ClassificationRuleVectorTlvValue : public VectorTlvValue
{
public:
/// ClassificationRuleTlvType enumeration
enum ClassificationRuleTlvType
{
Priority = 1,
ToS = 2,
Protocol = 3,
IP_src = 4,
IP_dst = 5,
Port_src = 6,
Port_dst = 7,
Index = 14,
};
ClassificationRuleVectorTlvValue ();
virtual uint32_t Deserialize (Buffer::Iterator start, uint64_t valueLength);
virtual ClassificationRuleVectorTlvValue * Copy (void) const;
private:
};
// ==============================================================================
/**
* \ingroup wimax
* \brief TosTlvValue class
*/
class TosTlvValue : public TlvValue
{
public:
TosTlvValue ();
/**
* Constructor
*
* \param low low value
* \param high high value
* \param mask the mask
*/
TosTlvValue (uint8_t low, uint8_t high, uint8_t mask);
~TosTlvValue ();
virtual uint32_t GetSerializedSize (void) const;
virtual void Serialize (Buffer::Iterator start) const;
virtual uint32_t Deserialize (Buffer::Iterator start, uint64_t valueLength);
/**
* Get low part
* \returns the low part
*/
uint8_t GetLow (void) const;
/**
* Get high part
* \returns the high part
*/
uint8_t GetHigh (void) const;
/**
* Get the mask
* \returns the mask
*/
uint8_t GetMask (void) const;
/**
* Copy
* \returns the TOS TLV value
*/
virtual TosTlvValue * Copy () const;
private:
uint8_t m_low; ///< low
uint8_t m_high; ///< high
uint8_t m_mask; ///< mask
};
// ==============================================================================
/**
* \ingroup wimax
* \brief PortRangeTlvValue class
*/
class PortRangeTlvValue : public TlvValue
{
public:
/// PortRange structure
struct PortRange
{
uint16_t PortLow; ///< low
uint16_t PortHigh; ///< high
};
/// PortRange vector iterator typedef
typedef std::vector<struct PortRange>::const_iterator Iterator;
PortRangeTlvValue ();
~PortRangeTlvValue ();
virtual uint32_t GetSerializedSize (void) const;
virtual void Serialize (Buffer::Iterator start) const;
virtual uint32_t Deserialize (Buffer::Iterator start, uint64_t valueLength);
/**
* Add a range
* \param portLow the low port of the range
* \param portHigh the high port of the range
*/
void Add (uint16_t portLow, uint16_t portHigh);
/**
* Begin iterator
* \returns the beginning element
*/
Iterator Begin () const;
/**
* End iterator
* \returns the ending element
*/
Iterator End () const;
/**
* Copy
* \returns the port range tlv value
*/
virtual PortRangeTlvValue * Copy (void) const;
private:
std::vector<struct PortRange> * m_portRange; ///< port range
};
// ==============================================================================
/**
* \ingroup wimax
* \brief ProtocolTlvValue class
*/
class ProtocolTlvValue : public TlvValue
{
public:
ProtocolTlvValue ();
~ProtocolTlvValue ();
/// Iterator typedef
typedef std::vector<uint8_t>::const_iterator Iterator;
virtual uint32_t GetSerializedSize (void) const;
virtual void Serialize (Buffer::Iterator start) const;
virtual uint32_t Deserialize (Buffer::Iterator start, uint64_t valueLength);
/**
* Add protocol number
* \param protocol the protocol number
*/
void Add (uint8_t protocol);
/**
* Begin iterator
* \returns the beginning element
*/
Iterator Begin () const;
/**
* End iterator
* \return the ending element
*/
Iterator End () const;
/**
* Copy
* \returns the protocol tlv value
*/
virtual ProtocolTlvValue * Copy (void) const;
private:
std::vector<uint8_t> * m_protocol; ///< protocol
};
// ==============================================================================
/**
* \ingroup wimax
* \brief Ipv4AddressTlvValue class
*/
class Ipv4AddressTlvValue : public TlvValue
{
public:
///ipv4Addr structure
struct ipv4Addr
{
Ipv4Address Address; ///< address
Ipv4Mask Mask; ///< mask
};
/// IPv4 address vector iterator typedef
typedef std::vector<struct ipv4Addr>::const_iterator Iterator;
Ipv4AddressTlvValue ();
~Ipv4AddressTlvValue ();
virtual uint32_t GetSerializedSize (void) const;
virtual void Serialize (Buffer::Iterator start) const;
virtual uint32_t Deserialize (Buffer::Iterator start, uint64_t valueLength);
/**
* Add IPv4 address and mask
* \param address the IPv4 address
* \param Mask the IPv4 mask
*/
void Add (Ipv4Address address, Ipv4Mask Mask);
/**
* Begin iterator
* \returns the beginning element
*/
Iterator Begin () const;
/**
* End iterator
* \returns the ending element
*/
Iterator End () const;
virtual Ipv4AddressTlvValue * Copy () const;
private:
std::vector<struct ipv4Addr> * m_ipv4Addr; ///< ipv4 addr
};
}
#endif /* WIMAX_TLV_H */
|