src/node/ipv6-route.h
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Thu Nov 12 13:01:01 2009 +0100 (2009-11-12)
changeset 5505 c0ac392289c3
parent 5225 9c612cb88d6b
child 5891 09a575cdf8db
permissions -rw-r--r--
replace RefCountBase with SimpleRefCount<> to avoid duplicate refcounting implementations.
     1 /* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
     2 /*
     3  * Copyright (c) 2007-2009 Strasbourg University
     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  * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
    19  */
    20 
    21 #ifndef IPV6_ROUTE_H
    22 #define IPV6_ROUTE_H
    23 
    24 #include <list>
    25 #include <vector>
    26 #include <ostream>
    27 
    28 #include "ns3/simple-ref-count.h"
    29 
    30 #include "ipv6-address.h"
    31 
    32 namespace ns3
    33 {
    34 
    35 class NetDevice;
    36 
    37 /**
    38  * \ingroup ipv6Routing
    39  * \class Ipv6Route
    40  * \brief IPv6 route cache entry.
    41  */
    42 class Ipv6Route : public SimpleRefCount<Ipv6Route>
    43 {
    44   public:
    45     /**
    46      * \brief Constructor.
    47      */
    48     Ipv6Route ();
    49 
    50     /**
    51      * \brief Destructor.
    52      */
    53     virtual ~Ipv6Route ();
    54 
    55     /**
    56      * \brief Set destination address.
    57      * \param dest IPv6 destination address
    58      */
    59     void SetDestination (Ipv6Address dest);
    60 
    61     /**
    62      * \brief Get destination address.
    63      * \return destination address
    64      */
    65     Ipv6Address GetDestination () const;
    66 
    67     /**
    68      * \brief Set source address.
    69      * \param src IPv6 source address
    70      */
    71     void SetSource (Ipv6Address src);
    72 
    73     /**
    74      * \brief Get source address.
    75      * \return source address
    76      */
    77     Ipv6Address GetSource () const;
    78 
    79     /**
    80      * \brief Set gateway address.
    81      * \param gw IPv6 gateway address
    82      */
    83     void SetGateway (Ipv6Address gw);
    84 
    85     /**
    86      * \brief Get gateway address.
    87      * \return gateway address
    88      */
    89     Ipv6Address GetGateway () const;
    90 
    91     /**
    92      * \brief Set output device for outgoing packets.
    93      * \param outputDevice output device
    94      */
    95     void SetOutputDevice (Ptr<NetDevice> outputDevice);
    96 
    97     /**
    98      * \brief Get output device.
    99      * \return output device
   100      */
   101     Ptr<NetDevice> GetOutputDevice () const;
   102 
   103   private:
   104     /**
   105      * \brief Destination address.
   106      */
   107     Ipv6Address m_dest;
   108 
   109     /**
   110      * \brief source address.
   111      */
   112     Ipv6Address m_source;
   113 
   114     /**
   115      * \brief Gateway address.
   116      */
   117     Ipv6Address m_gateway;
   118 
   119     /**
   120      * \brief Output device.
   121      */
   122     Ptr<NetDevice> m_outputDevice;
   123 };
   124 
   125 std::ostream& operator<< (std::ostream& os, Ipv6Route const& route);
   126 
   127 /**
   128  * \ingroup ipv6Routing
   129  * \class Ipv6MulticastRoute
   130  * \brief IPv6 multicast route entry.
   131  */
   132 class Ipv6MulticastRoute : public SimpleRefCount<Ipv6MulticastRoute>
   133 {
   134   public:
   135     /**
   136      * \brief Maximum number of multicast interfaces on a router.
   137      */
   138     static const uint32_t MAX_INTERFACES = 16;
   139 
   140     /**
   141      * \brief Maximum Time-To-Live (TTL).
   142      */
   143     static const uint32_t MAX_TTL = 255;
   144 
   145     /**
   146      * \brief Constructor.
   147      */
   148     Ipv6MulticastRoute ();
   149 
   150     /**
   151      * \brief Destructor.
   152      */
   153     virtual ~Ipv6MulticastRoute ();
   154 
   155     /**
   156      * \brief Set IPv6 group.
   157      * \param group Ipv6Address of the multicast group
   158      */
   159     void SetGroup (const Ipv6Address group);
   160 
   161     /**
   162      * \brief Get IPv6 group.
   163      * \return Ipv6Address of the multicast group
   164      */
   165     Ipv6Address GetGroup (void) const;
   166 
   167     /**
   168      * \brief Set origin address.
   169      * \param origin Ipv6Address of the origin address
   170      */
   171     void SetOrigin (const Ipv6Address origin);
   172 
   173     /**
   174      * \brief Get source address.
   175      * \return Ipv6Address of the origin address
   176      */
   177     Ipv6Address GetOrigin (void) const;
   178 
   179     /**
   180      * \brief Set parent for this route.
   181      * \param iif Parent (input interface) for this route
   182      */
   183     void SetParent (uint32_t iif);
   184 
   185     /**
   186      * \brief Get parent for this route.
   187      * \return Parent (input interface) for this route
   188      */
   189     uint32_t GetParent (void) const;
   190 
   191     /**
   192      * \brief set output TTL for this route.
   193      * \param oif Outgoing interface index
   194      * \param ttl time-to-live for this route
   195      */
   196     void SetOutputTtl (uint32_t oif, uint32_t ttl);
   197 
   198     /**
   199      * \brief Get output TTL for this route.
   200      * \param oif outgoing interface
   201      * \return TTL for this route
   202      */
   203     uint32_t GetOutputTtl (uint32_t oif) const;
   204 
   205   private:
   206     /**
   207      * \brief IPv6 group.
   208      */
   209     Ipv6Address m_group;
   210 
   211     /**
   212      * \brief IPv6 origin (source).
   213      */
   214     Ipv6Address m_origin;
   215 
   216     /**
   217      * \brief Source interface.
   218      */
   219     uint32_t m_parent;
   220 
   221     /**
   222      * \brief TTLs.
   223      */
   224     std::vector<uint32_t> m_ttls;
   225 };
   226 
   227 std::ostream& operator<< (std::ostream& os, Ipv6MulticastRoute const& route);
   228 
   229 } /* namespace ns3 */
   230 
   231 #endif /* IPV6_ROUTE_H */
   232