|
@@ -37,6 +37,7 @@
|
|
|
|
|
|
#include <dhcp4/spec_config.h>
|
|
|
#include <dhcp4/dhcp4_srv.h>
|
|
|
+#include <dhcp/dhcp4.h>
|
|
|
|
|
|
using namespace std;
|
|
|
using namespace isc::util;
|
|
@@ -53,33 +54,45 @@ usage() {
|
|
|
cerr << "Usage: b10-dhcp4 [-v]"
|
|
|
<< endl;
|
|
|
cerr << "\t-v: verbose output" << endl;
|
|
|
- exit(1);
|
|
|
+ cerr << "\t-p number: specify non-standard port number 1-65535 (useful for testing only)" << endl;
|
|
|
+ exit(EXIT_FAILURE);
|
|
|
}
|
|
|
} // end of anonymous namespace
|
|
|
|
|
|
int
|
|
|
main(int argc, char* argv[]) {
|
|
|
int ch;
|
|
|
+ int port_number = DHCP4_SERVER_PORT; // the default. any other values are
|
|
|
+ // useful for testing only
|
|
|
|
|
|
- while ((ch = getopt(argc, argv, ":v")) != -1) {
|
|
|
+ while ((ch = getopt(argc, argv, "vp:")) != -1) {
|
|
|
switch (ch) {
|
|
|
case 'v':
|
|
|
verbose_mode = true;
|
|
|
isc::log::denabled = true;
|
|
|
break;
|
|
|
+ case 'p':
|
|
|
+ port_number = strtol(optarg, NULL, 10);
|
|
|
+ if (port_number == 0) {
|
|
|
+ cerr << "Failed to parse port number: [" << optarg
|
|
|
+ << "], 1-65535 allowed." << endl;
|
|
|
+ usage();
|
|
|
+ }
|
|
|
+ break;
|
|
|
case ':':
|
|
|
default:
|
|
|
usage();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- cout << "My pid=" << getpid() << endl;
|
|
|
+ cout << "My pid=" << getpid() << ", binding to port " << port_number
|
|
|
+ << ", verbose " << (verbose_mode?"yes":"no") << endl;
|
|
|
|
|
|
if (argc - optind > 0) {
|
|
|
usage();
|
|
|
}
|
|
|
|
|
|
- int ret = 0;
|
|
|
+ int ret = EXIT_SUCCESS;
|
|
|
|
|
|
// TODO remainder of auth to dhcp4 code copy. We need to enable this in
|
|
|
// dhcp4 eventually
|
|
@@ -99,13 +112,13 @@ main(int argc, char* argv[]) {
|
|
|
|
|
|
cout << "[b10-dhcp4] Initiating DHCPv4 server operation." << endl;
|
|
|
|
|
|
- Dhcpv4Srv* srv = new Dhcpv4Srv();
|
|
|
+ Dhcpv4Srv* srv = new Dhcpv4Srv(port_number);
|
|
|
|
|
|
srv->run();
|
|
|
|
|
|
} catch (const std::exception& ex) {
|
|
|
cerr << "[b10-dhcp4] Server failed: " << ex.what() << endl;
|
|
|
- ret = 1;
|
|
|
+ ret = EXIT_FAILURE;
|
|
|
}
|
|
|
|
|
|
return (ret);
|