• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

ibrcommon/ibrcommon/net/vaddress.h

Go to the documentation of this file.
00001 /*
00002  * vaddress.h
00003  *
00004  *  Created on: 14.12.2010
00005  *      Author: morgenro
00006  */
00007 
00008 #ifndef VADDRESS_H_
00009 #define VADDRESS_H_
00010 
00011 #include "ibrcommon/Exceptions.h"
00012 #include <sys/socket.h>
00013 #include <netdb.h>
00014 
00015 namespace ibrcommon
00016 {
00017         class vaddress
00018         {
00019                 public:
00020                         class address_not_set : public Exception
00021                         {
00022                         public:
00023                                 address_not_set(string error = "address is not specified") : Exception(error)
00024                                 {};
00025                         };
00026 
00027                         class family_not_set : public Exception
00028                         {
00029                         public:
00030                                 family_not_set(string error = "family is not specified") : Exception(error)
00031                                 {};
00032                         };
00033 
00034 
00035                         enum Family
00036                         {
00037                                 VADDRESS_UNSPEC = AF_UNSPEC,
00038                                 VADDRESS_INET = AF_INET,
00039                                 VADDRESS_INET6 = AF_INET6,
00040                                 VADDRESS_UNIX = AF_UNIX
00041                         };
00042 
00043                         vaddress(const std::string &address);
00044                         vaddress(const Family &family = VADDRESS_INET);
00045                         vaddress(const Family &family, const std::string &address, const bool broadcast = false);
00046                         vaddress(const Family &family, const std::string &address, const int iface, const bool broadcast = false);
00047                         virtual ~vaddress();
00048 
00049                         Family getFamily() const;
00050                         const std::string get(bool internal = true) const;
00051                         bool isBroadcast() const;
00052 
00058                         bool isMulticast() const;
00059 
00060                         bool operator!=(const vaddress &obj) const;
00061 
00062                         const std::string toString() const;
00063 
00064                         struct addrinfo* addrinfo(struct addrinfo *hints) const;
00065                         struct addrinfo* addrinfo(struct addrinfo *hints, unsigned int port) const;
00066 
00067                 private:
00068                         const Family _family;
00069                         const std::string _address;
00070                         const bool _broadcast;
00071                         const int _iface;
00072         };
00073 }
00074 
00075 #endif /* VADDRESS_H_ */

Generated on Thu Mar 10 2011 15:44:03 for IBR-DTNSuite by  doxygen 1.7.1