main.cc 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // Copyright (C) 2009-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 <config.h>
  15. #include <sys/types.h>
  16. #include <sys/socket.h>
  17. #include <sys/select.h>
  18. #include <netdb.h>
  19. #include <netinet/in.h>
  20. #include <stdlib.h>
  21. #include <errno.h>
  22. #include <cassert>
  23. #include <iostream>
  24. #include <exceptions/exceptions.h>
  25. #if 0
  26. // TODO cc is not used yet. It should be eventually
  27. #include <cc/session.h>
  28. #include <config/ccsession.h>
  29. #endif
  30. #include <util/buffer.h>
  31. #include <log/dummylog.h>
  32. #include <dhcp6/spec_config.h>
  33. #include "dhcp6/dhcp6_srv.h"
  34. using namespace std;
  35. using namespace isc::util;
  36. using namespace isc;
  37. using namespace isc::dhcp;
  38. namespace {
  39. bool verbose_mode = false;
  40. void
  41. usage() {
  42. cerr << "Usage: b10-dhcp6 [-v]"
  43. << endl;
  44. cerr << "\t-v: verbose output" << endl;
  45. exit(1);
  46. }
  47. } // end of anonymous namespace
  48. int
  49. main(int argc, char* argv[]) {
  50. int ch;
  51. while ((ch = getopt(argc, argv, ":v")) != -1) {
  52. switch (ch) {
  53. case 'v':
  54. verbose_mode = true;
  55. isc::log::denabled = true;
  56. break;
  57. case ':':
  58. default:
  59. usage();
  60. }
  61. }
  62. cout << "My pid=" << getpid() << endl;
  63. if (argc - optind > 0) {
  64. usage();
  65. }
  66. int ret = 0;
  67. // TODO remainder of auth to dhcp6 code copy. We need to enable this in
  68. // dhcp6 eventually
  69. #if 0
  70. Session* cc_session = NULL;
  71. Session* statistics_session = NULL;
  72. ModuleCCSession* config_session = NULL;
  73. #endif
  74. try {
  75. string specfile;
  76. if (getenv("B10_FROM_BUILD")) {
  77. specfile = string(getenv("B10_FROM_BUILD")) +
  78. "/src/bin/auth/dhcp6.spec";
  79. } else {
  80. specfile = string(DHCP6_SPECFILE_LOCATION);
  81. }
  82. cout << "[b10-dhcp6] Initiating DHCPv6 operation." << endl;
  83. Dhcpv6Srv* srv = new Dhcpv6Srv();
  84. srv->run();
  85. } catch (const std::exception& ex) {
  86. cerr << "[b10-dhcp6] Server failed: " << ex.what() << endl;
  87. ret = 1;
  88. }
  89. return (ret);
  90. }