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/enums.h>
00031 #include <conexus/address.h>
00032 #include <conexus/error.h>
00033 
00034 namespace Conexus
00035   {
00036 
00043   namespace IPBase
00044     {
00045 
00055     class AddressBase: public Conexus::Address
00056       {
00057       public:
00058         typedef boost::shared_ptr<AddressBase> pointer;
00059         
00060         AddressBase() { }
00061 
00062         AddressBase(const struct sockaddr_storage& addr): Conexus::Address(addr) { }
00063 
00064         virtual ~AddressBase() { }
00065 
00067         virtual std::string address_string() const = 0;
00068 
00070         virtual std::string subnet_mask_string() const = 0;
00071 
00073         virtual unsigned prefix_length() const = 0;
00074 
00076         virtual std::string prefix_length_string() const = 0;
00077 
00079         virtual std::string address_subnet_mask_string() const = 0;
00080 
00082         virtual std::string cidr_address_string() const = 0;
00083 
00085         virtual std::string prefix_string() const = 0;
00086 
00088         virtual std::string local_address_string() const = 0;
00089 
00091         virtual uint16_t port() const = 0;
00092 
00094         virtual std::string port_string() const = 0;
00095 
00097         virtual void set_address(std::string address) = 0;
00098 
00100         virtual void set_address(std::string address, uint16_t port) = 0;
00101 
00103         virtual void set_prefix_length(unsigned prefix_length) = 0;
00104 
00106         virtual void set_prefix_length(std::string prefix_length) = 0;
00107 
00109         virtual void set_port(uint16_t port) = 0;
00110 
00112         virtual void set_port(std::string port) = 0;
00113 
00115         virtual std::string hostname() const = 0;
00116 
00118         virtual std::string servicename() const = 0;
00119 
00121         virtual bool is_multicast() const = 0;
00122 
00124         virtual bool is_any() const = 0;
00125 
00127         virtual bool is_loopback() const = 0;
00128 
00129         sigc::signal<void, unsigned> signal_address_port_changed( )  { return m_signal_address_port_changed; }
00130         sigc::signal<void> signal_prefix_changed( ) { return m_signal_prefix_changed; }
00131         
00132         virtual const std::string& object_type() { static std::string s("Conexus::IP::Address"); return s; }
00133         
00134         virtual bool is_ipv4() = 0;
00135         
00136         virtual bool is_ipv6() = 0;
00137 
00138         protected:
00139           sigc::signal<void, unsigned> m_signal_address_port_changed;
00140           sigc::signal<void> m_signal_prefix_changed;
00141           
00142       };
00143 
00144   }
00145 
00146 }
00147 
00148 #endif

Generated on Sat Aug 26 17:34:53 2006 by  doxygen 1.4.6