network.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this
  5. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
  6. #ifndef NETWORK_H
  7. #define NETWORK_H
  8. #include <boost/shared_ptr.hpp>
  9. #include <string>
  10. namespace isc {
  11. namespace dhcp {
  12. /// @brief Common interface representing a network to which the DHCP clients
  13. /// are connected.
  14. ///
  15. /// The most common type of network, in Kea's terminology, is a subnet. The
  16. /// @ref Subnet implements this interface. Another types of objects implementing
  17. /// this interface are @ref SharedNetwork objects. They group multiple subnets
  18. /// together to provide means for extending available address pools (a single
  19. /// client may obtain IP address from any of the pools belonging to subnets in
  20. /// the shared network), or for selecting a subnet on a given link, depending
  21. /// on the class of the client (e.g. cable network case: different subnet is
  22. /// selected for cable modems, different one for routers).
  23. ///
  24. /// The subnets and shared networks share many data structures, e.g. DHCP
  25. /// options, local interface name, address manipulation methods, thus this
  26. /// class provides an abstract interface that must be implemented by derived
  27. /// classes and, where appropriate, implements common methods used by the
  28. /// derived classes.
  29. class Network {
  30. public:
  31. /// @brief Virtual destructor.
  32. ///
  33. /// Does nothing at the moment.
  34. virtual ~Network() { };
  35. /// @brief Sets local name of the interface for which this network is
  36. /// selected.
  37. ///
  38. /// If the interface is specified, the server will use the network
  39. /// associated with this local interface to allocate IP addresses and
  40. /// other resources to a client.
  41. ///
  42. /// @param iface_name Interface name.
  43. void setIface(const std::string& iface_name) {
  44. iface_name_ = iface_name;
  45. }
  46. /// @brief Returns name of the local interface for which this network is
  47. /// selected.
  48. ///
  49. /// @return Interface name as text.
  50. std::string getIface() const {
  51. return (iface_name_);
  52. };
  53. protected:
  54. /// @brief Holds interface name for which this network is selected.
  55. std::string iface_name_;
  56. };
  57. /// @brief Pointer to the @ref Network object.
  58. typedef boost::shared_ptr<Network> NetworkPtr;
  59. } // end of namespace isc::dhcp
  60. } // end of namespace isc
  61. #endif // NETWORK_H