src/applications/radvd/radvd-prefix.h
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Thu Nov 12 13:01:01 2009 +0100 (2009-11-12)
changeset 5505 c0ac392289c3
parent 4763 19573adf3665
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) 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 RADVD_PREFIX_H
    22 #define RADVD_PREFIX_H 
    23 
    24 #include <stdint.h>
    25 
    26 #include "ns3/ipv6-address.h"
    27 #include "ns3/simple-ref-count.h"
    28 
    29 namespace ns3
    30 {
    31 
    32 /**
    33  * \ingroup radvd
    34  * \class RadvdPrefix
    35  * \brief Router prefix for radvd application.
    36  */
    37 class RadvdPrefix : public SimpleRefCount<RadvdPrefix>
    38 {
    39   public:
    40     /**
    41      * \brief Constructor.
    42      * \param network network prefix advertised
    43      * \param prefixLength prefix length ( 0 < x <= 128)
    44      * \param preferredLifeTime preferred life time in seconds (default 7 days)
    45      * \param validLifeTime valid life time in seconds (default 30 days)
    46      * \param onLinkFlag on link flag
    47      * \param autonomousFlag autonomous link flag
    48      * \param routerAddrFlag router address flag (for Mobile IPv6)
    49      */
    50     RadvdPrefix (Ipv6Address network, uint8_t prefixLength, uint32_t preferredLifeTime = 604800, uint32_t validLifeTime = 2592000, bool onLinkFlag = true, bool autonomousFlag = true, bool routerAddrFlag = false);
    51 
    52     /**
    53      * \brief Destructor.
    54      */
    55     ~RadvdPrefix ();
    56 
    57     /**
    58      * \brief Get network prefix.
    59      * \return network prefix
    60      */
    61     Ipv6Address GetNetwork () const;
    62 
    63     /**
    64      * \brief Set network prefix.
    65      * \param network network prefix
    66      */
    67     void SetNetwork (Ipv6Address network);
    68 
    69     /**
    70      * \brief Get prefix length.
    71      * \return prefix length
    72      */
    73     uint8_t GetPrefixLength () const;
    74 
    75     /**
    76      * \brief Set prefix length.
    77      * \param prefixLength prefix length
    78      */
    79     void SetPrefixLength (uint8_t prefixLength);
    80 
    81     /**
    82      * \brief Get preferred lifetime.
    83      * \return lifetime
    84      */
    85     uint32_t GetPreferredLifeTime () const;
    86 
    87     /**
    88      * \brief Set preferred lifetime.
    89      * \param preferredLifeTime lifetime
    90      */
    91     void SetPreferredLifeTime (uint32_t preferredLifeTime);
    92 
    93     /**
    94      * \brief Get valid lifetime.
    95      * \return lifetime
    96      */
    97     uint32_t GetValidLifeTime () const;
    98 
    99     /**
   100      * \brief Set valid lifetime.
   101      * \param validLifeTime lifetime
   102      */
   103     void SetValidLifeTime (uint32_t validLifeTime);
   104 
   105     /**
   106      * \brief Is on-link flag ?
   107      * \return true if on-link is activated, false otherwise
   108      */
   109     bool IsOnLinkFlag () const;
   110 
   111     /**
   112      * \brief Set on-link flag.
   113      * \param onLinkFlag value
   114      */
   115     void SetOnLinkFlag (bool onLinkFlag);
   116 
   117     /**
   118      * \brief Is autonomous flag ?
   119      * \return true if autonomous is activated, false otherwise
   120      */
   121     bool IsAutonomousFlag () const;
   122 
   123     /**
   124      * \brief Set autonomous flag.
   125      * \param autonomousFlag value
   126      */
   127     void SetAutonomousFlag (bool autonomousFlag);
   128 
   129     /**
   130      * \brief Is router address flag ?
   131      * \return true if router address is activated, false otherwise
   132      */
   133     bool IsRouterAddrFlag () const;
   134 
   135     /**
   136      * \brief Set router address flag.
   137      * \param routerAddrFlag value
   138      */
   139     void SetRouterAddrFlag (bool routerAddrFlag);
   140 
   141   private:
   142     /**
   143      * \brief Network prefix.
   144      */
   145     Ipv6Address m_network;
   146 
   147     /**
   148      * \brief Prefix length.
   149      */
   150     uint8_t m_prefixLength;
   151 
   152     /**
   153      * \brief Preferred time.
   154      */
   155     uint32_t m_preferredLifeTime;
   156 
   157     /**
   158      * \brief Valid time.
   159      */
   160     uint32_t m_validLifeTime;
   161 
   162     /**
   163      * \brief On link flag, indicates that this prefix can be used for on-link determination.
   164      */
   165     bool m_onLinkFlag;
   166 
   167     /**
   168      * \brief Autonomous flag, it is used for autonomous address configuration (RFC 2462).
   169      */
   170     bool m_autonomousFlag;
   171 
   172     /**
   173      * \brief Router address flag, indicates that router address is sent instead 
   174      * of network prefix as is required by Mobile IPv6.
   175      */
   176     bool m_routerAddrFlag;
   177 };
   178 
   179 } /* namespace ns3 */
   180 
   181 #endif /* RADVD_PREFIX_H */
   182