dhcp6_srv.cc 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright (C) 2011 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. #include "dhcp6/pkt6.h"
  15. #include "dhcp6/iface_mgr.h"
  16. #include "dhcp6/dhcp6_srv.h"
  17. using namespace std;
  18. using namespace isc;
  19. Dhcpv6Srv::Dhcpv6Srv() {
  20. cout << "Initialization" << endl;
  21. // first call to instance() will create IfaceMgr (it's a singleton)
  22. // it may throw something if things go wrong
  23. IfaceMgr::instance();
  24. }
  25. Dhcpv6Srv::~Dhcpv6Srv() {
  26. cout << "DHCPv6 Srv shutdown." << endl;
  27. }
  28. bool
  29. Dhcpv6Srv::run() {
  30. while (true) {
  31. Pkt6* pkt;
  32. pkt = IfaceMgr::instance().receive();
  33. if (pkt) {
  34. cout << "Received " << pkt->data_len_ << " bytes, echoing back."
  35. << endl;
  36. IfaceMgr::instance().send(*pkt);
  37. delete pkt;
  38. }
  39. // TODO add support for config session (see src/bin/auth/main.cc)
  40. // so this daemon can be controlled from bob
  41. sleep(1);
  42. }
  43. return (true);
  44. }