conexus/ipv4_udp.h

00001 /***************************************************************************
00002  *   Copyright (C) 2001 by Rick L. Vinyard, Jr.                            *
00003  *   rvinyard@cs.nmsu.edu                                                  *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU Lesser General Public License as        *
00007  *   published by the Free Software Foundation version 2.1.                *
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 Lesser General Public      *
00015  *   License along with this library; if not, write to the                 *
00016  *   Free Software Foundation, Inc.,                                       *
00017  *   51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA              *
00018  ***************************************************************************/
00019 #ifndef CONEXUS_IPV4UDP_H
00020 #define CONEXUS_IPV4UDP_H
00021 
00022 #include <set>
00023 
00024 #include <conexus/ipv4_ip.h>
00025 
00042 namespace Conexus
00043 {
00044 
00045   namespace IPv4
00046   {
00047 
00054     class UDP : public IP
00055     {
00056       protected:
00057 
00058         UDP( uint32_t local_if, uint16_t localport, uint16_t remoteport );
00059 
00060         UDP( const std::string& local_if, uint16_t localport, uint16_t remoteport );
00061 
00062       public:
00063 
00064         typedef ConexusPointer<UDP> pointer;
00065 
00066         static pointer create( uint16_t localport = 0, uint16_t remoteport = 0 );
00067 
00068         static pointer create( uint32_t local_if, uint16_t localport, uint16_t remoteport );
00069 
00070         static pointer create( const std::string& local_if, uint16_t localport = 0, uint16_t remoteport = 0 );
00071 
00072         virtual ~UDP() throw();
00073 
00074         virtual ssize_t input_available();
00075 
00076         virtual void bind() throw ( bind_exception );
00077 
00078         virtual void bind( const Conexus::Address& a ) throw ( bind_exception );
00079 
00080         virtual void close() throw ( close_exception );
00081 
00085         virtual int output_pending();
00086 
00087         virtual void connect() throw ( connect_exception );
00088 
00089         virtual void connect( const Address& a ) throw ( connect_exception );
00090 
00108         virtual void set_write_without_connect( bool value = true );
00109 
00110         virtual bool write_without_connect() const;
00111 
00112         void add_multicast_interface( unsigned iface_index );
00113 
00114         void add_multicast_interface( const std::string& iface_name );
00115 
00116         void remove_multicast_interface( unsigned iface_index );
00117 
00118         void remove_multicast_interface( const std::string& iface_name );
00119 
00120         bool is_multicast_interface( unsigned iface_index );
00121 
00122         bool is_multicast_interface( const std::string& iface_name );
00123 
00124         virtual bool suppress_multicast_join() const;
00125 
00126         virtual void set_suppress_multicast_join( bool value = true );
00127 
00131         virtual unsigned multicast_hops();
00132 
00136         virtual void set_multicast_hops( unsigned hops );
00137 
00138         static unsigned int default_multicast_hops();
00139 
00140         static void set_default_multicast_hops(unsigned int hops);
00141 
00145         virtual bool multicast_loopback();
00146 
00150         virtual void set_multicast_loopback( bool loopback );
00151 
00152         static bool default_multicast_loopback();
00153 
00154         static void set_default_multicast_loopback(bool loopback);
00155 
00160         //       void cork();
00161 
00166         //       void uncork();
00167 
00168         //       bool is_corked();
00169 
00170       protected:
00171 
00172         static unsigned int m_default_hops;
00173         static bool m_default_loopback;
00174 
00175         bool m_write_without_connect;
00176         bool m_suppress_multicast_join;
00177         std::set<unsigned> m_multicast_interfaces;
00178         unsigned m_multicast_hops;
00179         bool m_multicast_loopback;
00180 
00181         virtual void on_local_address_changed( );
00182         virtual void on_remote_address_changed( );
00183 
00189         virtual void join();
00190 
00194         virtual void join(unsigned interface);
00195 
00201         virtual void leave();
00202 
00206         virtual void leave(unsigned interface);
00207 
00212         virtual ssize_t write_data( long int timeout, const Data data ) throw ( write_exception );
00213 
00220         // virtual Data::pointer read_data(long int timeout, size_t s = 0) throw (read_exception);
00221     };
00222 
00223   }
00224 
00225 }
00226 
00227 #endif

Generated on Tue Mar 13 19:54:44 2007 by  doxygen 1.5.1