conexus logo

ipv6_udp.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2001,2002,2003,2004,2005,2006,2007,2008,2009            *
00003  *   by Rick L. Vinyard, Jr.                                               *
00004  *   rvinyard@cs.nmsu.edu                                                  *
00005  *                                                                         *
00006  *   This file is part of the conexus library.                             *
00007  *                                                                         *
00008  *   The conexus library is free software; you can redistribute it and/or  *
00009  *   modify it under the terms of the GNU General Public License           *
00010  *   version 3 as published by the Free Software Foundation.               *
00011  *                                                                         *
00012  *   The conexus library is distributed in the hope that it will be        *
00013  *   useful, but WITHOUT ANY WARRANTY; without even the implied warranty   *
00014  *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU   *
00015  *   General Public License for more details.                              *
00016  *                                                                         *
00017  *   You should have received a copy of the GNU General Public License     *
00018  *   along with this software. If not see <http://www.gnu.org/licenses/>.  *
00019  ***************************************************************************/
00020 #ifndef CONEXUS_IPV6UDP_H
00021 #define CONEXUS_IPV6UDP_H
00022 
00023 #include <set>
00024 
00025 #ifdef CONEXUS_HAVE_LINUX_UDP_H
00026 #include <linux/udp.h>
00027 #endif
00028 
00029 #include <conexus/ipv6_ip.h>
00030 
00046 namespace Conexus
00047 {
00048 
00049   namespace IPv6
00050   {
00051 
00061     class UDP : public IP
00062     {
00063       protected:
00064 
00065         UDP( const struct in6_addr& local_if, uint16_t localport, uint16_t remoteport, int proto = IPPROTO_UDP );
00066 
00067         UDP( const std::string& local_if, uint16_t localport, uint16_t remoteport, int proto = IPPROTO_UDP );
00068 
00069       public:
00070 
00071         typedef ConexusPointer<UDP> pointer;
00072 
00073         CONEXUS_ENDPOINT_GENERIC_CREATE();
00074 
00079         static pointer create( uint16_t localport = 0, uint16_t remoteport = 0 );
00080 
00085         static pointer create( const struct in6_addr& local_if, uint16_t localport = 0, uint16_t remoteport = 0 );
00086 
00091         static pointer create( const std::string& local_if, uint16_t localport = 0, uint16_t remoteport = 0 );
00092 
00094         virtual ~UDP() throw();
00095 
00097         virtual size_t input_available() throw();
00098 
00100         virtual void bind() throw ( bind_exception );
00101 
00103         virtual void bind( const Conexus::Address& a ) throw ( bind_exception );
00104 
00106         virtual void close() throw ( close_exception );
00107 
00111         virtual int output_pending();
00112 
00116         virtual void connect() throw ( connect_exception );
00117 
00121         virtual void connect( const Address& a ) throw ( connect_exception );
00122 
00139         virtual void set_write_without_connect( bool value = true );
00140 
00141         virtual bool write_without_connect() const;
00142 
00143         void add_multicast_interface( unsigned iface_index );
00144 
00145         void add_multicast_interface( const std::string& iface_name );
00146 
00147         void remove_multicast_interface( unsigned iface_index );
00148 
00149         void remove_multicast_interface( const std::string& iface_name );
00150 
00151         bool is_multicast_interface( unsigned iface_index );
00152 
00153         bool is_multicast_interface( const std::string& iface_name );
00154 
00155         virtual bool suppress_multicast_join() const;
00156 
00157         virtual void set_suppress_multicast_join( bool value = true );
00158 
00162         virtual int multicast_hop_limit();
00163 
00167         virtual void set_multicast_hop_limit( int hop_limit );
00168 
00169         static unsigned int default_multicast_hop_limit();
00170 
00171         static void set_default_multicast_hop_limit(unsigned int hop_limit);
00172 
00176         virtual bool is_multicast_loopback_enabled();
00177 
00181         virtual void enable_multicast_loopback( bool enable );
00182 
00183         static bool is_default_multicast_loopback_enabled();
00184 
00185         static void enable_default_multicast_loopback(bool enable);
00186 
00187         #ifdef UDP_CORK
00188 
00192         void cork();
00193 
00198         void uncork();
00199 
00200         bool is_corked();
00201         #endif
00202 
00203       protected:
00204 
00205         static unsigned int m_default_hop_limit;
00206         static bool m_default_loopback_enabled;
00207 
00208         bool m_write_without_connect;
00209         bool m_suppress_multicast_join;
00210         std::set<unsigned> m_multicast_interfaces;
00211 
00212         virtual void on_local_address_changed( );
00213         virtual void on_remote_address_changed( );
00214 
00220         virtual void join();
00221 
00225         virtual void join(unsigned interface);
00226 
00232         virtual void leave();
00233 
00237         virtual void leave(unsigned interface);
00238 
00243         virtual size_t write_data( const Data data, Timeout timeout ) throw ( write_exception );
00244     };
00245 
00246   }
00247 
00248 }
00249 
00250 #endif

Generated on Wed Jul 8 15:50:07 2009 for conexus by doxygen 1.5.8