ip_address.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_IPADDRESS_H
00020 #define CONEXUS_IPADDRESS_H
00021 
00022 #include <string>
00023 
00024 #include <sys/socket.h>
00025 #include <netinet/in.h>
00026 #include <arpa/inet.h>
00027 
00028 #include <sigc++/sigc++.h>
00029 
00030 #include <conexus/address.h>
00031 #include <conexus/error.h>
00032 
00033 namespace Conexus
00034   {
00035 
00036     typedef enum IP_ADDRESS_PORT { IP_ADDRESS=0x01, IP_PORT=0x02 } IP_ADDRESS_PORT;
00037 
00044   namespace IPBase
00045     {
00046 
00056     class AddressBase: public Conexus::Address
00057       {
00058       public:
00059         typedef boost::shared_ptr<AddressBase> pointer;
00060         
00061         AddressBase() { }
00062 
00063         AddressBase(const struct sockaddr_storage& addr): Conexus::Address(addr) { }
00064 
00065         virtual ~AddressBase() { }
00066 
00068         virtual std::string address_string() const = 0;
00069 
00071         virtual std::string subnet_mask_string() const = 0;
00072 
00074         virtual unsigned prefix_length() const = 0;
00075 
00077         virtual std::string prefix_length_string() const = 0;
00078 
00080         virtual std::string address_subnet_mask_string() const = 0;
00081 
00083         virtual std::string cidr_address_string() const = 0;
00084 
00086         virtual std::string prefix_string() const = 0;
00087 
00089         virtual std::string local_address_string() const = 0;
00090 
00092         virtual uint16_t port() const = 0;
00093 
00095         virtual std::string port_string() const = 0;
00096 
00098         virtual void set_address(std::string address) = 0;
00099 
00101         virtual void set_address(std::string address, uint16_t port) = 0;
00102 
00104         virtual void set_prefix_length(unsigned prefix_length) = 0;
00105 
00107         virtual void set_prefix_length(std::string prefix_length) = 0;
00108 
00110         virtual void set_port(uint16_t port) = 0;
00111 
00113         virtual void set_port(std::string port) = 0;
00114 
00116         virtual std::string hostname() const = 0;
00117 
00119         virtual std::string servicename() const = 0;
00120 
00122         virtual bool is_multicast() const = 0;
00123 
00125         virtual bool is_any() const = 0;
00126 
00128         virtual bool is_loopback() const = 0;
00129 
00130         sigc::signal<void, unsigned> signal_address_port_changed( )  { return m_signal_address_port_changed; }
00131         sigc::signal<void> signal_prefix_changed( ) { return m_signal_prefix_changed; }
00132         
00133         virtual const std::string& object_type() { static std::string s("Conexus::IP::Address"); return s; }
00134         
00135         virtual bool is_ipv4() = 0;
00136         
00137         virtual bool is_ipv6() = 0;
00138 
00139         protected:
00140           sigc::signal<void, unsigned> m_signal_address_port_changed;
00141           sigc::signal<void> m_signal_prefix_changed;
00142           
00143       };
00144 
00145   }
00146 
00147 }
00148 
00149 #endif

Generated on Sun Aug 6 12:16:57 2006 by  doxygen 1.4.6