/usr/include/ns3.26/ns3/ipv6-extension.h is in libns3-dev 3.26+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 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2007-2009 Strasbourg University
*
* 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
*
* Author: David Gross <gdavid.devel@gmail.com>
*/
#ifndef IPV6_EXTENSION_H
#define IPV6_EXTENSION_H
#include <map>
#include <list>
#include "ns3/object.h"
#include "ns3/node.h"
#include "ns3/ptr.h"
#include "ipv6-interface.h"
#include "ns3/ipv6-header.h"
#include "ns3/buffer.h"
#include "ns3/packet.h"
#include "ns3/random-variable-stream.h"
#include "ns3/ipv6-address.h"
#include "ns3/ipv6-l3-protocol.h"
#include "ns3/traced-callback.h"
namespace ns3 {
/**
* \ingroup ipv6
* \defgroup ipv6HeaderExt IPV6 Header extension system.
*/
/**
* \ingroup ipv6HeaderExt
*
* \brief IPv6 Extension base
* If you want to implement a new IPv6 extension, all you have to do is
* implement a subclass of this class and add it to an Ipv6ExtensionDemux.
*/
class Ipv6Extension : public Object
{
public:
/**
* \brief Get the type identificator.
* \return type identificator
*/
static TypeId GetTypeId ();
/**
* \brief Constructor.
*/
Ipv6Extension ();
/**
* \brief Destructor.
*/
virtual ~Ipv6Extension ();
/**
* \brief Set the node.
* \param node the node to set
*/
void SetNode (Ptr<Node> node);
/**
* \brief Get the node.
* \return the node
*/
Ptr<Node> GetNode () const;
/**
* \brief Get the extension number.
* \return extension number
*/
virtual uint8_t GetExtensionNumber () const = 0;
/**
* \brief Process method
* Called from Ipv6L3Protocol::Receive.
*
* \param packet the packet
* \param offset the offset of the extension to process
* \param ipv6Header the IPv6 header of packet received
* \param dst destination address of the packet received (i.e. us)
* \param nextHeader the next header
* \param stopProcessing true if the packet must not be further processed
* \param isDropped true if the packet must be dropped
* \param dropReason dropping reason
* \return the size processed
*/
virtual uint8_t Process (Ptr<Packet>& packet,
uint8_t offset,
Ipv6Header const& ipv6Header,
Ipv6Address dst,
uint8_t *nextHeader,
bool& stopProcessing,
bool& isDropped,
Ipv6L3Protocol::DropReason& dropReason) = 0;
/**
* \brief Process options
* Called by implementing classes to process the options
*
* \param packet the packet
* \param offset the offset of the first option to process
* \param length the total length of all options (as specified in the extension header)
* \param ipv6Header the IPv6 header of packet received
* \param dst destination address of the packet received (i.e. us)
* \param nextHeader the next header
* \param stopProcessing true if the packet must not be further processed
* \param isDropped true if the packet must be dropped
* \param dropReason dropping reason
* \return the size processed
*/
virtual uint8_t ProcessOptions (Ptr<Packet>& packet,
uint8_t offset,
uint8_t length,
Ipv6Header const& ipv6Header,
Ipv6Address dst,
uint8_t *nextHeader,
bool& stopProcessing,
bool& isDropped,
Ipv6L3Protocol::DropReason& dropReason
);
/**
* Assign a fixed random variable stream number to the random variables
* used by this model. Return the number of streams (possibly zero) that
* have been assigned.
*
* \param stream first stream index to use
* \return the number of stream indices assigned by this model
*/
int64_t AssignStreams (int64_t stream);
protected:
/**
* \brief Provides uniform random variables.
*/
Ptr<UniformRandomVariable> m_uvar;
private:
/**
* \brief The node.
*/
Ptr<Node> m_node;
};
/**
* \ingroup ipv6HeaderExt
*
* \brief IPv6 Extension "Hop By Hop"
*/
class Ipv6ExtensionHopByHop : public Ipv6Extension
{
public:
/**
* \brief Hop-by-hop extension number.
*/
static const uint8_t EXT_NUMBER = 0;
/**
* \brief Get the type identificator.
* \return type identificator
*/
static TypeId GetTypeId ();
/**
* \brief Constructor.
*/
Ipv6ExtensionHopByHop ();
/**
* \brief Destructor.
*/
~Ipv6ExtensionHopByHop ();
/**
* \brief Get the extension number.
* \return extension number
*/
virtual uint8_t GetExtensionNumber () const;
virtual uint8_t Process (Ptr<Packet>& packet,
uint8_t offset,
Ipv6Header const& ipv6Header,
Ipv6Address dst,
uint8_t *nextHeader,
bool& stopProcessing,
bool& isDropped,
Ipv6L3Protocol::DropReason& dropReason);
};
/**
* \ingroup ipv6HeaderExt
*
* \brief IPv6 Extension Destination
*/
class Ipv6ExtensionDestination : public Ipv6Extension
{
public:
/**
* \brief Destination extension number.
*/
static const uint8_t EXT_NUMBER = 60;
/**
* \brief Get the type identificator.
* \return type identificator
*/
static TypeId GetTypeId ();
/**
* \brief Constructor.
*/
Ipv6ExtensionDestination ();
/**
* \brief Destructor.
*/
~Ipv6ExtensionDestination ();
/**
* \brief Get the extension number.
* \return extension number
*/
virtual uint8_t GetExtensionNumber () const;
virtual uint8_t Process (Ptr<Packet>& packet,
uint8_t offset,
Ipv6Header const& ipv6Header,
Ipv6Address dst,
uint8_t *nextHeader,
bool& stopProcessing,
bool& isDropped,
Ipv6L3Protocol::DropReason& dropReason);
};
/**
* \ingroup ipv6HeaderExt
*
* \brief IPv6 Extension Fragment
*/
class Ipv6ExtensionFragment : public Ipv6Extension
{
public:
/**
* \brief Fragmentation extension number.
*/
static const uint8_t EXT_NUMBER = 44;
/**
* \brief Get the type identificator.
* \return type identificator
*/
static TypeId GetTypeId ();
/**
* \brief Constructor.
*/
Ipv6ExtensionFragment ();
/**
* \brief Destructor.
*/
~Ipv6ExtensionFragment ();
/**
* \brief Get the extension number.
* \return extension number
*/
virtual uint8_t GetExtensionNumber () const;
virtual uint8_t Process (Ptr<Packet>& packet,
uint8_t offset,
Ipv6Header const& ipv6Header,
Ipv6Address dst,
uint8_t *nextHeader,
bool& stopProcessing,
bool& isDropped,
Ipv6L3Protocol::DropReason& dropReason);
/**
* \brief Pair of a packet and an Ipv6 header.
*/
typedef std::pair<Ptr<Packet>, Ipv6Header> Ipv6PayloadHeaderPair;
/**
* \brief Fragment a packet.
*
* \param packet the packet.
* \param ipv6Header the IPv6 header.
* \param fragmentSize the maximal size of the fragment (unfragmentable part + fragmentation header + fragmentable part).
* \param listFragments the list of fragments.
*/
void GetFragments (Ptr<Packet> packet, Ipv6Header ipv6Header, uint32_t fragmentSize, std::list<Ipv6PayloadHeaderPair>& listFragments);
protected:
/**
* \brief Dispose this object.
*/
virtual void DoDispose ();
private:
/**
* \ingroup ipv6HeaderExt
*
* \brief This class stores the fragments of a packet waiting to be rebuilt.
*/
class Fragments : public SimpleRefCount<Fragments>
{
public:
/**
* \brief Constructor.
*/
Fragments ();
/**
* \brief Destructor.
*/
~Fragments ();
/**
* \brief Add a fragment.
* \param fragment the fragment
* \param fragmentOffset the offset of the fragment
* \param moreFragment the bit "More Fragment"
*/
void AddFragment (Ptr<Packet> fragment, uint16_t fragmentOffset, bool moreFragment);
/**
* \brief Set the unfragmentable part of the packet.
* \param unfragmentablePart the unfragmentable part
*/
void SetUnfragmentablePart (Ptr<Packet> unfragmentablePart);
/**
* \brief If all fragments have been added.
* \returns true if the packet is entire
*/
bool IsEntire () const;
/**
* \brief Get the entire packet.
* \return the entire packet
*/
Ptr<Packet> GetPacket () const;
/**
* \brief Get the packet parts so far received.
* \return the partial packet
*/
Ptr<Packet> GetPartialPacket () const;
/**
* \brief Set the Timeout EventId.
*/
void SetTimeoutEventId (EventId event);
/**
* \brief Cancel the timeout event
*/
void CancelTimeout ();
private:
/**
* \brief If other fragments will be sent.
*/
bool m_moreFragment;
/**
* \brief The current fragments.
*/
std::list<std::pair<Ptr<Packet>, uint16_t> > m_packetFragments;
/**
* \brief The unfragmentable part.
*/
Ptr<Packet> m_unfragmentable;
/**
* \brief Timeout handler event
*/
EventId m_timeoutEventId;
};
/**
* \brief Process the timeout for packet fragments
* \param key representing the packet fragments
* \param ipHeader the IP header of the original packet
*/
void HandleFragmentsTimeout (std::pair<Ipv6Address, uint32_t> key, Ipv6Header ipHeader);
/**
* \brief Get the packet parts so far received.
* \return the partial packet
*/
Ptr<Packet> GetPartialPacket () const;
/**
* \brief Set the Timeout EventId.
*/
void SetTimeoutEventId (EventId event);
/**
* \brief Cancel the timeout event
*/
void CancelTimeout ();
/**
* \brief Container for the packet fragments.
*/
typedef std::map<std::pair<Ipv6Address, uint32_t>, Ptr<Fragments> > MapFragments_t;
/**
* \brief The hash of fragmented packets.
*/
MapFragments_t m_fragments;
};
/**
* \ingroup ipv6HeaderExt
*
* \brief IPv6 Extension Routing.
*
* If you want to implement a new IPv6 routing extension, all you have to do is
* implement a subclass of this class and add it to an Ipv6ExtensionRoutingDemux.
*/
class Ipv6ExtensionRouting : public Ipv6Extension
{
public:
/**
* \brief Routing extension number.
*/
static const uint8_t EXT_NUMBER = 43;
/**
* \brief Get the type identificator.
* \return type identificator
*/
static TypeId GetTypeId ();
/**
* \brief Constructor.
*/
Ipv6ExtensionRouting ();
/**
* \brief Destructor.
*/
~Ipv6ExtensionRouting ();
/**
* \brief Get the extension number.
* \return extension number
*/
virtual uint8_t GetExtensionNumber () const;
/**
* \brief Get the type of routing.
* \return type of routing
*/
virtual uint8_t GetTypeRouting () const;
virtual uint8_t Process (Ptr<Packet>& packet,
uint8_t offset,
Ipv6Header const& ipv6Header,
Ipv6Address dst,
uint8_t *nextHeader,
bool& stopProcessing,
bool& isDropped,
Ipv6L3Protocol::DropReason& dropReason);
};
/**
* \ingroup ipv6HeaderExt
*
* \brief IPv6 Extension Routing Demux.
*/
class Ipv6ExtensionRoutingDemux : public Object
{
public:
/**
* \brief The interface ID.
* \return type ID
*/
static TypeId GetTypeId ();
/**
* \brief Constructor.
*/
Ipv6ExtensionRoutingDemux ();
/**
* \brief Destructor.
*/
virtual ~Ipv6ExtensionRoutingDemux ();
/**
* \brief Set the node.
* \param node the node to set
*/
void SetNode (Ptr<Node> node);
/**
* \brief Insert a new IPv6 Routing Extension.
* \param extensionRouting the routing extension to insert
*/
void Insert (Ptr<Ipv6ExtensionRouting> extensionRouting);
/**
* \brief Get the routing extension corresponding to typeRouting.
* \param typeRouting the number of the routing extension to retrieve
* \return a matching IPv6 routing extension
*/
Ptr<Ipv6ExtensionRouting> GetExtensionRouting (uint8_t typeRouting);
/**
* \brief Remove a routing extension from this demux.
* \param extensionRouting pointer on the extension to remove
*/
void Remove (Ptr<Ipv6ExtensionRouting> extensionRouting);
protected:
/**
* \brief Dispose this object.
*/
virtual void DoDispose ();
private:
/**
* \brief Container for the extension routing.
*/
typedef std::list<Ptr<Ipv6ExtensionRouting> > Ipv6ExtensionRoutingList_t;
/**
* \brief List of IPv6 Routing Extensions supported.
*/
Ipv6ExtensionRoutingList_t m_extensionsRouting;
/**
* \brief The node.
*/
Ptr<Node> m_node;
};
/**
* \ingroup ipv6HeaderExt
*
* \brief IPv6 Extension Loose Routing
*/
class Ipv6ExtensionLooseRouting : public Ipv6ExtensionRouting
{
public:
/**
* \brief Routing type.
*/
static const uint8_t TYPE_ROUTING = 0;
/**
* \brief Get the type identificator.
* \return type identificator
*/
static TypeId GetTypeId ();
/**
* \brief Constructor.
*/
Ipv6ExtensionLooseRouting ();
/**
* \brief Destructor.
*/
~Ipv6ExtensionLooseRouting ();
/**
* \brief Get the type of routing.
* \return type of routing
*/
virtual uint8_t GetTypeRouting () const;
virtual uint8_t Process (Ptr<Packet>& packet,
uint8_t offset,
Ipv6Header const& ipv6Header,
Ipv6Address dst,
uint8_t *nextHeader,
bool& stopProcessing,
bool& isDropped,
Ipv6L3Protocol::DropReason& dropReason);
};
/**
* \ingroup ipv6HeaderExt
*
* \brief IPv6 Extension ESP (Encapsulating Security Payload)
*/
class Ipv6ExtensionESP : public Ipv6Extension
{
public:
/**
* \brief ESP extension number.
*/
static const uint8_t EXT_NUMBER = 50;
/**
* \brief Get the type identificator.
* \return type identificator
*/
static TypeId GetTypeId ();
/**
* \brief Constructor.
*/
Ipv6ExtensionESP ();
/**
* \brief Destructor.
*/
~Ipv6ExtensionESP ();
/**
* \brief Get the extension number.
* \return extension number
*/
virtual uint8_t GetExtensionNumber () const;
virtual uint8_t Process (Ptr<Packet>& packet,
uint8_t offset,
Ipv6Header const& ipv6Header,
Ipv6Address dst,
uint8_t *nextHeader,
bool& stopProcessing,
bool& isDropped,
Ipv6L3Protocol::DropReason& dropReason);
};
/**
* \ingroup ipv6HeaderExt
*
* \brief IPv6 Extension AH (Authentication Header)
*/
class Ipv6ExtensionAH : public Ipv6Extension
{
public:
/**
* \brief AH extension number.
*/
static const uint8_t EXT_NUMBER = 51;
/**
* \brief Get the type identificator.
* \return type identificator
*/
static TypeId GetTypeId ();
/**
* \brief Constructor.
*/
Ipv6ExtensionAH ();
/**
* \brief Destructor.
*/
~Ipv6ExtensionAH ();
/**
* \brief Get the extension number.
* \return extension number
*/
virtual uint8_t GetExtensionNumber () const;
virtual uint8_t Process (Ptr<Packet>& packet,
uint8_t offset,
Ipv6Header const& ipv6Header,
Ipv6Address dst,
uint8_t *nextHeader,
bool& stopProcessing,
bool& isDropped,
Ipv6L3Protocol::DropReason& dropReason);
};
} /* namespace ns3 */
#endif /* IPV6_EXTENSION_H */
|