asiolink.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. // $Id$
  15. #ifndef __ASIOLINK_H
  16. #define __ASIOLINK_H
  17. #include <string>
  18. #include <sys/socket.h>
  19. namespace asiolink {
  20. /// \brief IO Address Dummy Class
  21. ///
  22. /// As part of ther resolver, Evan has written the asiolink.h file, which
  23. /// encapsulates some of the boost::asio classes. Until these are checked
  24. /// into trunk and merged with this branch, these dummy classes should fulfill
  25. /// their function.
  26. class IOAddress {
  27. public:
  28. /// \param address_str String representing the address
  29. IOAddress(const std::string& address_str) : address_(address_str)
  30. {}
  31. /// \param Just a virtual destructor
  32. virtual ~ IOAddress() { }
  33. /// \return Textual representation of the address
  34. std::string toText() const
  35. {return address_;}
  36. /// \return Address family of the address
  37. virtual short getFamily() const {
  38. return ((address_.find(".") != std::string::npos) ? AF_INET : AF_INET6);
  39. }
  40. /// \return true if two addresses are equal
  41. bool equal(const IOAddress& address)
  42. {return (toText() == address.toText());}
  43. private:
  44. std::string address_; ///< Address represented
  45. };
  46. } // namespace asiolink
  47. #endif // __ASIOLINK_H