ipv4_udp.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef CONEXUS_IPV4UDP_H
00021 #define CONEXUS_IPV4UDP_H
00022
00023 #include <set>
00024
00025 #ifdef CONEXUS_HAVE_LINUX_UDP_H
00026 #include <linux/udp.h>
00027 #endif
00028
00029 #include <conexus/ipv4_ip.h>
00030
00046 namespace Conexus
00047 {
00048
00049 namespace IPv4
00050 {
00051
00059 class UDP : public IP
00060 {
00061 protected:
00062
00063 UDP( uint32_t local_if, uint16_t localport, uint16_t remoteport, int proto=IPPROTO_UDP );
00064
00065 UDP( const std::string& local_if, uint16_t localport, uint16_t remoteport, int proto=IPPROTO_UDP );
00066
00067 public:
00068
00069 typedef ConexusPointer<UDP> pointer;
00070
00071 CONEXUS_ENDPOINT_GENERIC_CREATE();
00072
00077 static pointer create( uint16_t localport = 0, uint16_t remoteport = 0 );
00078
00083 static pointer create( uint32_t local_if, uint16_t localport, uint16_t remoteport );
00084
00089 static pointer create( const std::string& local_if, uint16_t localport = 0, uint16_t remoteport = 0 );
00090
00092 virtual ~UDP() throw();
00093
00095 virtual size_t input_available() throw();
00096
00098 virtual void bind() throw ( bind_exception );
00099
00101 virtual void bind( const Conexus::Address& a ) throw ( bind_exception );
00102
00104 virtual void close() throw ( close_exception );
00105
00109 virtual int output_pending();
00110
00114 virtual void connect() throw ( connect_exception );
00115
00119 virtual void connect( const Address& a ) throw ( connect_exception );
00120
00137 virtual void set_write_without_connect( bool value = true );
00138
00139 virtual bool write_without_connect() const;
00140
00141 void add_multicast_interface( unsigned iface_index );
00142
00143 void add_multicast_interface( const std::string& iface_name );
00144
00145 void remove_multicast_interface( unsigned iface_index );
00146
00147 void remove_multicast_interface( const std::string& iface_name );
00148
00149 bool is_multicast_interface( unsigned iface_index );
00150
00151 bool is_multicast_interface( const std::string& iface_name );
00152
00153 virtual bool suppress_multicast_join() const;
00154
00155 virtual void set_suppress_multicast_join( bool value = true );
00156
00160 virtual unsigned multicast_hop_limit();
00161
00165 virtual void set_multicast_hop_limit( unsigned hop_limit );
00166
00167 static unsigned int default_multicast_hop_limit();
00168
00169 static void set_default_multicast_hop_limit(unsigned int hop_limit);
00170
00174 virtual bool is_multicast_loopback_enabled();
00175
00179 virtual void enable_multicast_loopback( bool enable );
00180
00181 static bool is_default_multicast_loopback_enabled();
00182
00183 static void enable_default_multicast_loopback(bool loopback);
00184
00185 #ifdef UDP_CORK
00186
00190 void cork();
00191
00196 void uncork();
00197
00198 bool is_corked();
00199 #endif
00200
00201 protected:
00202
00203 static unsigned int m_default_hop_limit;
00204 static bool m_default_loopback_enabled;
00205
00206 bool m_write_without_connect;
00207 bool m_suppress_multicast_join;
00208 std::set<unsigned> m_multicast_interfaces;
00209 unsigned m_multicast_hop_limit;
00210 bool m_multicast_loopback_enabled;
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
00251 #endif