From: Tomek Mrugalski Date: Fri, 11 May 2012 15:39:47 +0000 (+0200) Subject: [1651] Small command handling improvements. X-Git-Tag: trac2351_base~238 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=977c4a2b576986ab0e7402cb0ade14244bf90ca2;p=thirdparty%2Fkea.git [1651] Small command handling improvements. --- diff --git a/doc/guide/bind10-guide.xml b/doc/guide/bind10-guide.xml index 630c0c4b7b..85b3909dbe 100644 --- a/doc/guide/bind10-guide.xml +++ b/doc/guide/bind10-guide.xml @@ -2037,21 +2037,22 @@ then change those defaults with config set Resolver/forward_addresses[0]/address - The DHCPv4 server is implemented as b10-dhcp4 - daemon. As it is not configurable yet, it is fully autonomous, - that is it does not interact with b10-cfgmgr. - To start DHCPv4 server, simply input: - - -#cd src/bin/dhcp4 -#./b10-dhcp4 - + b10-dhcp4 is a BIND10 component and is being + run under BIND10 framework. To add a DHCPv4 process to the set of running + BIND10 services, you can use following commands in bindctl: + > config add Boss/components b10-dhcp4 +> config set Boss/components/b10-resolver/kind dispensable +> config commit - Depending on your installation, b10-dhcp4 - binary may reside in src/bin/dhcp4 in your source code - directory, in /usr/local/bin/b10-dhcp4 or other directory - you specified during compilation. + + To shutdown running b10-dhcp4, please use the + following command: + > dhcp4 shutdown + or + > config remove Boss/components b10-dhcp4 +> config commit + At start, the server will detect available network interfaces and will attempt to open UDP sockets on all interfaces that are up, running, are not loopback, and have IPv4 address diff --git a/src/bin/dhcp4/dhcp4.spec b/src/bin/dhcp4/dhcp4.spec index 98df3a9cab..7584b48e78 100644 --- a/src/bin/dhcp4/dhcp4.spec +++ b/src/bin/dhcp4/dhcp4.spec @@ -1,6 +1,6 @@ { "module_spec": { - "module_name": "dhcp4", + "module_name": "Dhcp4", "module_description": "DHCPv4 server daemon", "config_data": [ { "item_name": "interface", @@ -12,8 +12,14 @@ "commands": [ { "command_name": "shutdown", - "command_description": "Shut down DHCPv4 server", - "command_args": [] + "command_description": "Shuts down DHCPv4 server.", + "command_args": [ + { + "item_name": "pid", + "item_type": "integer", + "item_optional": true + } + ] } ] } diff --git a/src/bin/dhcp4/main.cc b/src/bin/dhcp4/main.cc index cdd920c369..1f8f7a0925 100644 --- a/src/bin/dhcp4/main.cc +++ b/src/bin/dhcp4/main.cc @@ -65,11 +65,13 @@ usage() { } } // end of anonymous namespace +IOService io_service; + ConstElementPtr dhcp4_config_handler(ConstElementPtr new_config) { cout << "b10-dhcp4: Received new config:" << new_config->str() << endl; ConstElementPtr answer = isc::config::createAnswer(0, - "All good here. Thanks for sending config."); + "Thanks for sending config."); return (answer); } @@ -77,8 +79,16 @@ ConstElementPtr dhcp4_command_handler(const string& command, ConstElementPtr args) { cout << "b10-dhcp4: Received new command: [" << command << "], args=" << args->str() << endl; - ConstElementPtr answer = isc::config::createAnswer(0, - "All good here. Thanks for asking."); + if (command == "shutdown") { + io_service.stop(); + ConstElementPtr answer = isc::config::createAnswer(0, + "Shutting down."); + return (answer); + } + + ConstElementPtr answer = isc::config::createAnswer(1, + "Unrecognized command."); + return (answer); } @@ -98,8 +108,6 @@ void establish_session() { cout << "b10-dhcp4: my specfile is " << specfile << endl; - IOService io_service; - cc_session = new Session(io_service.get_io_service()); config_session = new ModuleCCSession(specfile, *cc_session,