src/node/inet6-socket-address.h
author vincent@clarinet.u-strasbg.fr
Fri Nov 07 11:36:15 2008 -0800 (2008-11-07)
changeset 3852 9cf7ad0cac85
child 4761 8c0b3a413f4b
permissions -rw-r--r--
Initial IPv6 capability
     1 /* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
     2 /*
     3  * Copyright (c) 2007-2008 Louis Pasteur 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 INET6_SOCKET_ADDRESS_H 
    22 #define INET6_SOCKET_ADDRESS_H
    23 
    24 #include "address.h"
    25 #include "ipv6-address.h"
    26 #include <stdint.h>
    27 
    28 namespace ns3 {
    29 
    30 /**
    31  * \class Inet6SocketAddress
    32  * \brief An Inet6 address class.
    33  */
    34 class Inet6SocketAddress
    35 {
    36   public:
    37     /**
    38      * \brief Constructor.
    39      * \param ipv6 the IPv6 address
    40      * \param port the port
    41      */
    42     Inet6SocketAddress (Ipv6Address ipv6, uint16_t port);
    43 
    44     /**
    45      * \brief Constructor (the port is set to zero).
    46      * \param ipv6 the IPv6 address
    47      */
    48     Inet6SocketAddress (Ipv6Address ipv6);
    49 
    50     /**
    51      * \brief Constructor (the address is set to "any").
    52      * \param port the port
    53      */
    54     Inet6SocketAddress (uint16_t port);
    55 
    56     /**
    57      * \brief Constructor.
    58      * \param ipv6 string which represents an IPv6 address
    59      * \param port the port
    60      */
    61     Inet6SocketAddress (const char* ipv6, uint16_t port);
    62 
    63     /**
    64      * \brief Constructor.
    65      * \param ipv6 string which represents an IPv6 address
    66      */
    67     Inet6SocketAddress (const char* ipv6);
    68 
    69     /**
    70      * \brief Get the port.
    71      * \return the port
    72      */
    73     uint16_t GetPort (void) const;
    74 
    75     /**
    76      * \brief Set the port
    77      * \param port the port
    78      */
    79     void SetPort (uint16_t port);
    80 
    81     /**
    82      * \brief Get the IPv6 address.
    83      * \return the IPv6 address
    84      */
    85     Ipv6Address GetIpv6 (void) const;
    86 
    87     /**
    88      * \brief Set the IPv6 address.
    89      * \param ipv6 the address
    90      */
    91     void SetIpv6 (Ipv6Address ipv6);
    92 
    93     /**
    94      * \brief If the address match.
    95      * \param addr the address to test
    96      * \return true if the address match, false otherwise
    97      */
    98     static bool IsMatchingType (const Address &addr);
    99 
   100     /**
   101      * \brief Get an Address instance which represents this
   102      * Inet6SocketAddress instance.
   103      */
   104     operator Address (void) const;
   105 
   106     /**
   107      * \brief Convert the address to a InetSocketAddress.
   108      * \param addr the address to convert
   109      * \return an Inet6SocketAddress instance corresponding to address
   110      */
   111     static Inet6SocketAddress ConvertFrom (const Address &addr);
   112 
   113   private:
   114     /**
   115      * \brief Convert to Address.
   116      * \return Address instance
   117      */
   118     Address ConvertTo (void) const;
   119 
   120     /**
   121      * \brief Get the type.
   122      * \return the type of Inet6SocketAddress
   123      */
   124     static uint8_t GetType (void);
   125 
   126     /**
   127      * \brief The IPv6 address.
   128      */
   129     Ipv6Address m_ipv6;
   130 
   131     /**
   132      * \brief The port.
   133      */
   134     uint16_t m_port;
   135 };
   136 
   137 } /* namespace ns3 */
   138 
   139 #endif /* INET6_SOCKET_ADDRESS_H */
   140