main.cc 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. #include <cc/session.h>
  26. #include <config/ccsession.h>
  27. #include <util/buffer.h>
  28. #include <log/dummylog.h>
  29. #include <dhcp6/spec_config.h>
  30. #include "dhcp6/dhcp6_srv.h"
  31. using namespace std;
  32. using namespace isc::util;
  33. using namespace isc::data;
  34. using namespace isc::cc;
  35. using namespace isc::config;
  36. using namespace isc::util;
  37. using namespace isc;
  38. namespace {
  39. bool verbose_mode = false;
  40. void
  41. usage() {
  42. cerr << "Usage: b10-dhcp6 [-u user] [-v]"
  43. << endl;
  44. cerr << "\t-u: change process UID to the specified user" << endl;
  45. cerr << "\t-v: verbose output" << endl;
  46. exit(1);
  47. }
  48. } // end of anonymous namespace
  49. int
  50. main(int argc, char* argv[]) {
  51. int ch;
  52. while ((ch = getopt(argc, argv, ":v")) != -1) {
  53. switch (ch) {
  54. case 'v':
  55. verbose_mode = true;
  56. isc::log::denabled = true;
  57. break;
  58. case ':':
  59. default:
  60. usage();
  61. }
  62. }
  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. // auth_server = new AuthSrv(cache, xfrout_client);
  83. // auth_server->setVerbose(verbose_mode);
  84. cout << "[b10-dhcp6] Initiating DHCPv6 operation." << endl;
  85. Dhcpv6Srv* srv = new Dhcpv6Srv();
  86. srv->run();
  87. } catch (const std::exception& ex) {
  88. cerr << "[b10-dhcp6] Server failed: " << ex.what() << endl;
  89. ret = 1;
  90. }
  91. return (ret);
  92. }