src/internet/model/ipv6-option-demux.cc
author Brian Swenson <bswenson3@gatech.edu>
Tue, 22 Apr 2014 11:52:55 -0400
changeset 10694 4af272d94cfd
parent 10652 dc18deba4502
child 11259 ea2f6a3ed14e
permissions -rw-r--r--
Bug 1791
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7385
10beb0e53130 standardize emacs c++ mode comments
Vedran Miletić <rivanvx@gmail.com>
parents: 7176
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
5782
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
     2
/*
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
     3
 * Copyright (c) 2007-2009 Strasbourg University
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
     4
 *
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
     8
 *
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    12
 * GNU General Public License for more details.
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    13
 *
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    17
 *
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    18
 * Author: David Gross <gdavid.devel@gmail.com>
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    19
 */
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    20
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    21
#include <sstream>
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    22
#include "ns3/node.h"
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    23
#include "ns3/ptr.h"
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    24
#include "ns3/object-vector.h"
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    25
#include "ipv6-option-demux.h"
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    26
#include "ipv6-option.h"
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    27
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    28
namespace ns3
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    29
{
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    30
10652
dc18deba4502 [doxygen] Revert r10410, r10411, r10412
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10410
diff changeset
    31
NS_OBJECT_ENSURE_REGISTERED (Ipv6OptionDemux);
5782
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    32
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    33
TypeId Ipv6OptionDemux::GetTypeId ()
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    34
{
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    35
  static TypeId tid = TypeId ("ns3::Ipv6OptionDemux")
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    36
    .SetParent<Object> ()
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    37
    .AddAttribute ("Options", "The set of IPv6 options registered with this demux.",
5809
597070be3549 Coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5782
diff changeset
    38
                   ObjectVectorValue (),
597070be3549 Coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5782
diff changeset
    39
                   MakeObjectVectorAccessor (&Ipv6OptionDemux::m_options),
597070be3549 Coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5782
diff changeset
    40
                   MakeObjectVectorChecker<Ipv6Option> ())
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6834
diff changeset
    41
  ;
5782
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    42
  return tid;
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    43
}
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    44
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    45
Ipv6OptionDemux::Ipv6OptionDemux ()
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    46
{
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    47
}
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    48
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    49
Ipv6OptionDemux::~Ipv6OptionDemux ()
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    50
{
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    51
}
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    52
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    53
void Ipv6OptionDemux::DoDispose ()
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    54
{
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    55
  for (Ipv6OptionList_t::iterator it = m_options.begin (); it != m_options.end (); it++)
5809
597070be3549 Coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5782
diff changeset
    56
    {
597070be3549 Coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5782
diff changeset
    57
      (*it)->Dispose ();
597070be3549 Coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5782
diff changeset
    58
      *it = 0;
597070be3549 Coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5782
diff changeset
    59
    }
5782
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    60
  m_options.clear ();
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    61
  m_node = 0;
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    62
  Object::DoDispose ();
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    63
}
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    64
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    65
void Ipv6OptionDemux::SetNode (Ptr<Node> node)
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    66
{
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    67
  m_node = node;
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    68
}
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    69
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    70
void Ipv6OptionDemux::Insert (Ptr<Ipv6Option> option)
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    71
{
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    72
  m_options.push_back (option);
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    73
}
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    74
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    75
Ptr<Ipv6Option> Ipv6OptionDemux::GetOption (int optionNumber)
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    76
{
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    77
  for (Ipv6OptionList_t::iterator i = m_options.begin (); i != m_options.end (); ++i)
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    78
    {
5809
597070be3549 Coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5782
diff changeset
    79
      if ((*i)->GetOptionNumber () == optionNumber)
597070be3549 Coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5782
diff changeset
    80
        {
597070be3549 Coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5782
diff changeset
    81
          return *i;
597070be3549 Coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5782
diff changeset
    82
        }
5782
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    83
    }
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    84
  return 0;
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    85
}
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    86
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    87
void Ipv6OptionDemux::Remove (Ptr<Ipv6Option> option)
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    88
{
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    89
  m_options.remove (option);
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    90
}
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    91
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    92
} /* namespace ns3 */
f5299c974f1b Add IPv6 extension files from old ns-3-ipv6 repository (not working yet).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff changeset
    93