Logo
~Sockets~
~Examples~
~Contact~


Ipv6Address.h

Go to the documentation of this file.
00001 
00006 /*
00007 Copyright (C) 2007  Anders Hedstrom
00008 
00009 This program is free software; you can redistribute it and/or
00010 modify it under the terms of the GNU General Public License
00011 as published by the Free Software Foundation; either version 2
00012 of the License, or (at your option) any later version.
00013 
00014 This program is distributed in the hope that it will be useful,
00015 but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 GNU General Public License for more details.
00018 
00019 You should have received a copy of the GNU General Public License
00020 along with this program; if not, write to the Free Software
00021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 */
00023 #ifndef _SOCKETS_Ipv6Address_H
00024 #define _SOCKETS_Ipv6Address_H
00025 #include "sockets-config.h"
00026 #ifdef ENABLE_IPV6
00027 
00028 #include "SocketAddress.h"
00029 #ifdef IPPROTO_IPV6
00030 #if defined( _WIN32) && !defined(__CYGWIN__)
00031 typedef unsigned __int32 uint32_t;
00032 #endif
00033 
00034 #ifdef SOCKETS_NAMESPACE
00035 namespace SOCKETS_NAMESPACE {
00036 #endif
00037 
00038 
00041 class Ipv6Address : public SocketAddress
00042 {
00043 public:
00046         Ipv6Address(port_t port = 0);
00050         Ipv6Address(struct in6_addr& a,port_t port);
00054         Ipv6Address(const std::string& host,port_t port);
00055         Ipv6Address(struct sockaddr_in6&);
00056         ~Ipv6Address();
00057 
00058         // SocketAddress implementation
00059 
00060         operator struct sockaddr *();
00061         operator socklen_t();
00062         bool operator==(SocketAddress&);
00063 
00064         void SetPort(port_t port);
00065         port_t GetPort();
00066 
00067         void SetAddress(struct sockaddr *sa);
00068         int GetFamily();
00069 
00070         bool IsValid();
00071         std::auto_ptr<SocketAddress> GetCopy();
00072 
00074         std::string Convert(bool include_port = false);
00075         std::string Reverse();
00076 
00078 static  bool Resolve(const std::string& hostname,struct in6_addr& a);
00080 static  bool Reverse(struct in6_addr& a,std::string& name);
00082 static  std::string Convert(struct in6_addr& a,bool mixed = false);
00083 
00084         void SetFlowinfo(uint32_t);
00085         uint32_t GetFlowinfo();
00086 #ifndef _WIN32
00087         void SetScopeId(uint32_t);
00088         uint32_t GetScopeId();
00089 #endif
00090 
00091 private:
00092         Ipv6Address(const Ipv6Address& ) {} // copy constructor
00093         Ipv6Address& operator=(const Ipv6Address& ) { return *this; } // assignment operator
00094         struct sockaddr_in6 m_addr;
00095         bool m_valid;
00096 };
00097 
00098 
00099 
00100 
00101 #ifdef SOCKETS_NAMESPACE
00102 } // namespace SOCKETS_NAMESPACE {
00103 #endif
00104 #endif // IPPROTO_IPV6
00105 #endif // ENABLE_IPV6
00106 #endif // _SOCKETS_Ipv6Address_H
Page, code, and content Copyright (C) 2007 by Anders Hedström
Generated for C++ Sockets by  doxygen 1.4.4