00001 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ 00002 /* 00003 * Copyright (c) 2007-2008 Louis Pasteur University 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License version 2 as 00007 * published by the Free Software Foundation; 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr> 00019 */ 00020 00021 #ifndef INET6_SOCKET_ADDRESS_H 00022 #define INET6_SOCKET_ADDRESS_H 00023 00024 #include "address.h" 00025 #include "ipv6-address.h" 00026 #include <stdint.h> 00027 00028 namespace ns3 { 00029 00030 /** 00031 * \class Inet6SocketAddress 00032 * \brief An Inet6 address class. 00033 */ 00034 class Inet6SocketAddress 00035 { 00036 public: 00037 /** 00038 * \brief Constructor. 00039 * \param ipv6 the IPv6 address 00040 * \param port the port 00041 */ 00042 Inet6SocketAddress (Ipv6Address ipv6, uint16_t port); 00043 00044 /** 00045 * \brief Constructor (the port is set to zero). 00046 * \param ipv6 the IPv6 address 00047 */ 00048 Inet6SocketAddress (Ipv6Address ipv6); 00049 00050 /** 00051 * \brief Constructor (the address is set to "any"). 00052 * \param port the port 00053 */ 00054 Inet6SocketAddress (uint16_t port); 00055 00056 /** 00057 * \brief Constructor. 00058 * \param ipv6 string which represents an IPv6 address 00059 * \param port the port 00060 */ 00061 Inet6SocketAddress (const char* ipv6, uint16_t port); 00062 00063 /** 00064 * \brief Constructor. 00065 * \param ipv6 string which represents an IPv6 address 00066 */ 00067 Inet6SocketAddress (const char* ipv6); 00068 00069 /** 00070 * \brief Get the port. 00071 * \return the port 00072 */ 00073 uint16_t GetPort (void) const; 00074 00075 /** 00076 * \brief Set the port 00077 * \param port the port 00078 */ 00079 void SetPort (uint16_t port); 00080 00081 /** 00082 * \brief Get the IPv6 address. 00083 * \return the IPv6 address 00084 */ 00085 Ipv6Address GetIpv6 (void) const; 00086 00087 /** 00088 * \brief Set the IPv6 address. 00089 * \param ipv6 the address 00090 */ 00091 void SetIpv6 (Ipv6Address ipv6); 00092 00093 /** 00094 * \brief If the address match. 00095 * \param addr the address to test 00096 * \return true if the address match, false otherwise 00097 */ 00098 static bool IsMatchingType (const Address &addr); 00099 00100 /** 00101 * \brief Get an Address instance which represents this 00102 * Inet6SocketAddress instance. 00103 */ 00104 operator Address (void) const; 00105 00106 /** 00107 * \brief Convert the address to a InetSocketAddress. 00108 * \param addr the address to convert 00109 * \return an Inet6SocketAddress instance corresponding to address 00110 */ 00111 static Inet6SocketAddress ConvertFrom (const Address &addr); 00112 00113 private: 00114 /** 00115 * \brief Convert to Address. 00116 * \return Address instance 00117 */ 00118 Address ConvertTo (void) const; 00119 00120 /** 00121 * \brief Get the type. 00122 * \return the type of Inet6SocketAddress 00123 */ 00124 static uint8_t GetType (void); 00125 00126 /** 00127 * \brief The IPv6 address. 00128 */ 00129 Ipv6Address m_ipv6; 00130 00131 /** 00132 * \brief The port. 00133 */ 00134 uint16_t m_port; 00135 }; 00136 00137 } /* namespace ns3 */ 00138 00139 #endif /* INET6_SOCKET_ADDRESS_H */ 00140