Commit decb4105 authored by Francis Dupont's avatar Francis Dupont
Browse files

[master] Finished merge of trac5033 (migrate D2client)

parents d1a9fbee f09449b3
......@@ -20,6 +20,7 @@ nobase_dist_doc_DATA += examples/kea4/pgsql-reservations.json
nobase_dist_doc_DATA += examples/kea4/reservations.json
nobase_dist_doc_DATA += examples/kea4/several-subnets.json
nobase_dist_doc_DATA += examples/kea4/single-subnet.json
nobase_dist_doc_DATA += examples/kea4/with-ddns.json
nobase_dist_doc_DATA += examples/kea6/advanced.json
nobase_dist_doc_DATA += examples/kea6/backends.json
nobase_dist_doc_DATA += examples/kea6/classify.json
......@@ -35,6 +36,7 @@ nobase_dist_doc_DATA += examples/kea6/several-subnets.json
nobase_dist_doc_DATA += examples/kea6/simple.json
nobase_dist_doc_DATA += examples/kea6/softwire46.json
nobase_dist_doc_DATA += examples/kea6/stateless.json
nobase_dist_doc_DATA += examples/kea6/with-ddns.json
devel:
mkdir -p html
......
# This is an example configuration file for the DHCPv4 server in Kea.
# It is a basic scenario with one IPv4 subnet configured but with DDNS
# enabled.
{ "Dhcp4":
{
# Kea is told to listen on ethX interface only.
"interfaces-config": {
"interfaces": [ "ethX" ]
},
# We need to specify the the database used to store leases. As of
# September 2016, four database backends are supported: MySQL,
# PostgreSQL, Cassandra, and the in-memory database, Memfile.
# We'll use memfile because it doesn't require any prior set up.
"lease-database": {
"type": "memfile",
"lfc-interval": 3600
},
# Addresses will be assigned with a lifetime of 4000 seconds.
"valid-lifetime": 4000,
# Renew and rebind timers are commented out. This implies that options
# 58 and 59 will not be sent to the client. In this case it is up to
# the client to pick the timer values according to RFC2131. Uncomment the
# timers to send these options to the client.
# "renew-timer": 1000,
# "rebind-timer": 2000,
# The following list defines subnets. We have only one subnet
# here. We tell Kea that it is directly available over local interface.
"subnet4": [
{
"pools": [ { "pool": "192.0.2.1 - 192.0.2.200" } ],
"subnet": "192.0.2.0/24",
"interface": "ethX"
}
],
# Enable dynamic DNS updates
"dhcp-ddns" : {
"enable-updates" : true,
"server-ip" : "192.0.2.0",
"server-port" : 3432,
"sender-ip" : "192.0.2.1",
"sender-port" : 3433,
"max-queue-size" : 2048,
"ncr-protocol" : "UDP",
"ncr-format" : "JSON",
"always-include-fqdn" : true,
"override-no-update" : true,
"override-client-update" : true,
"replace-client-name" : "when-present",
"generated-prefix" : "test.prefix",
"qualifying-suffix" : "test.suffix."
}
},
# The following configures logging. It assumes that messages with at least
# informational level (info, warn, error and fatal) should be logged to stdout.
"Logging": {
"loggers": [
{
"name": "kea-dhcp4",
"output_options": [
{
"output": "stdout"
}
],
"severity": "INFO"
}
]
}
}
# This is an example configuration file for DHCPv6 server in Kea.
# It's a basic scenario with one IPv6 subnet configured. It is
# assumed that one subnet (2001:db8:1::/64 is available directly
# over ethX interface.
{ "Dhcp6":
{
# Kea is told to listen on ethX interface only.
"interfaces-config": {
"interfaces": [ "ethX" ]
},
# We need to specify the the database used to store leases. As of
# September 2016, four database backends are supported: MySQL,
# PostgreSQL, Cassandra, and the in-memory database, Memfile.
# We'll use memfile because it doesn't require any prior set up.
"lease-database": {
"type": "memfile",
"lfc-interval": 3600
},
# Addresses will be assigned with preferred and valid lifetimes
# being 3000 and 4000, respectively. Client is told to start
# renewing after 1000 seconds. If the server does not respond
# after 2000 seconds since the lease was granted, client is supposed
# to start REBIND procedure (emergency renewal that allows switching
# to a different server).
"preferred-lifetime": 3000,
"valid-lifetime": 4000,
"renew-timer": 1000,
"rebind-timer": 2000,
# The following list defines subnets. Each subnet consists of at
# least subnet and pool entries.
"subnet6": [
{
"pools": [ { "pool": "2001:db8:1::/80" } ],
"subnet": "2001:db8:1::/64",
"interface": "ethX"
}
],
# Enable dynamic DNS updates
"dhcp-ddns" : {
"enable-updates" : true,
"server-ip" : "3001::1",
"server-port" : 3432,
"sender-ip" : "3001::2",
"sender-port" : 3433,
"max-queue-size" : 2048,
"ncr-protocol" : "UDP",
"ncr-format" : "JSON",
"always-include-fqdn" : true,
"override-no-update" : true,
"override-client-update" : true,
"replace-client-name" : "when-present",
"generated-prefix" : "test.prefix",
"qualifying-suffix" : "test.suffix."
}
},
# The following configures logging. It assumes that messages with at least
# informational level (info, warn, error and fatal) should be logged to stdout.
"Logging": {
"loggers": [
{
"name": "kea-dhcp6",
"output_options": [
{
"output": "stdout"
}
],
"debuglevel": 0,
"severity": "INFO"
}
]
}
}
......@@ -2174,9 +2174,10 @@ It is merely echoed by the server
<note>
Note that formerly, this parameter was a boolean and permitted only values
of <command>true</command> and <command>false</command>. Boolean values
will still be accepted but may eventually be deprecated. A value of
<command>true</command> equates to <command>when-present</command>,
<command>false</command> equates to <command>never</command>.
have been deprecated and are no longer accepted. If you are currently using
booleans, you must replace them with the desired mode name. A value of
<command>true</command> maps to <command>"when-present"</command>, while
<command>false</command> maps to <command>"never"</command>.
</note>
For example, To instruct kea-dhcp4 to always generate the FQDN for a
......
......@@ -2372,9 +2372,10 @@ should include options from the isc option space:
<note>
Note that formerly, this parameter was a boolean and permitted only values
of <command>true</command> and <command>false</command>. Boolean values
will still be accepted but may eventually be deprecated. A value of
<command>true</command> equates to <command>when-present</command>,
<command>false</command> equates to <command>never</command>.
have been deprecated and are no longer accepted. If you are currently using
booleans, you must replace them with the desired mode name. A value of
<command>true</command> maps to <command>"when-present"</command>, while
<command>false</command> maps to <command>"never"</command>.
</note>
For example, To instruct kea-dhcp6 to always generate the FQDN for a
......
This diff is collapsed.
......@@ -121,6 +121,8 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
return isc::dhcp::Dhcp4Parser::make_SUB_OPTION_DATA(driver.loc_);
case Parser4Context::PARSER_HOOKS_LIBRARY:
return isc::dhcp::Dhcp4Parser::make_SUB_HOOKS_LIBRARY(driver.loc_);
case Parser4Context::PARSER_DHCP_DDNS:
return isc::dhcp::Dhcp4Parser::make_SUB_DHCP_DDNS(driver.loc_);
}
}
%}
......@@ -887,6 +889,231 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
}
}
\"enable-updates\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::DHCP_DDNS:
return isc::dhcp::Dhcp4Parser::make_ENABLE_UPDATES(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("enable-updates", driver.loc_);
}
}
\"qualifying-suffix\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::DHCP_DDNS:
return isc::dhcp::Dhcp4Parser::make_QUALIFYING_SUFFIX(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("qualifying-suffix", driver.loc_);
}
}
\"server-ip\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::DHCP_DDNS:
return isc::dhcp::Dhcp4Parser::make_SERVER_IP(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("server-ip", driver.loc_);
}
}
\"server-port\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::DHCP_DDNS:
return isc::dhcp::Dhcp4Parser::make_SERVER_PORT(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("server-port", driver.loc_);
}
}
\"sender-ip\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::DHCP_DDNS:
return isc::dhcp::Dhcp4Parser::make_SENDER_IP(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("sender-ip", driver.loc_);
}
}
\"sender-port\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::DHCP_DDNS:
return isc::dhcp::Dhcp4Parser::make_SENDER_PORT(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("sender-port", driver.loc_);
}
}
\"max-queue-size\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::DHCP_DDNS:
return isc::dhcp::Dhcp4Parser::make_MAX_QUEUE_SIZE(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("max-queue-size", driver.loc_);
}
}
\"ncr-protocol\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::DHCP_DDNS:
return isc::dhcp::Dhcp4Parser::make_NCR_PROTOCOL(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("ncr-protocol", driver.loc_);
}
}
\"ncr-format\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::DHCP_DDNS:
return isc::dhcp::Dhcp4Parser::make_NCR_FORMAT(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("ncr-format", driver.loc_);
}
}
\"always-include-fqdn\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::DHCP_DDNS:
return isc::dhcp::Dhcp4Parser::make_ALWAYS_INCLUDE_FQDN(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("always-include-fqdn", driver.loc_);
}
}
\"allow-client-update\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::DHCP_DDNS:
return isc::dhcp::Dhcp4Parser::make_ALLOW_CLIENT_UPDATE(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("allow-client-update", driver.loc_);
}
}
\"override-no-update\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::DHCP_DDNS:
return isc::dhcp::Dhcp4Parser::make_OVERRIDE_NO_UPDATE(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("override-no-update", driver.loc_);
}
}
\"override-client-update\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::DHCP_DDNS:
return isc::dhcp::Dhcp4Parser::make_OVERRIDE_CLIENT_UPDATE(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("override-client-update", driver.loc_);
}
}
\"replace-client-name\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::DHCP_DDNS:
return isc::dhcp::Dhcp4Parser::make_REPLACE_CLIENT_NAME(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("replace-client-name", driver.loc_);
}
}
\"generated-prefix\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::DHCP_DDNS:
return isc::dhcp::Dhcp4Parser::make_GENERATED_PREFIX(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("generated-prefix", driver.loc_);
}
}
(?i:\"UDP\") {
/* dhcp-ddns value keywords are case insensitive */
if (driver.ctx_ == isc::dhcp::Parser4Context::NCR_PROTOCOL) {
return isc::dhcp::Dhcp4Parser::make_UDP(driver.loc_);
}
std::string tmp(yytext+1);
tmp.resize(tmp.size() - 1);
return isc::dhcp::Dhcp4Parser::make_STRING(tmp, driver.loc_);
}
(?i:\"TCP\") {
/* dhcp-ddns value keywords are case insensitive */
if (driver.ctx_ == isc::dhcp::Parser4Context::NCR_PROTOCOL) {
return isc::dhcp::Dhcp4Parser::make_TCP(driver.loc_);
}
std::string tmp(yytext+1);
tmp.resize(tmp.size() - 1);
return isc::dhcp::Dhcp4Parser::make_STRING(tmp, driver.loc_);
}
(?i:\"JSON\") {
/* dhcp-ddns value keywords are case insensitive */
if (driver.ctx_ == isc::dhcp::Parser4Context::NCR_FORMAT) {
return isc::dhcp::Dhcp4Parser::make_JSON(driver.loc_);
}
std::string tmp(yytext+1);
tmp.resize(tmp.size() - 1);
return isc::dhcp::Dhcp4Parser::make_STRING(tmp, driver.loc_);
}
(?i:\"when-present\") {
/* dhcp-ddns value keywords are case insensitive */
if (driver.ctx_ == isc::dhcp::Parser4Context::REPLACE_CLIENT_NAME) {
return isc::dhcp::Dhcp4Parser::make_WHEN_PRESENT(driver.loc_);
}
std::string tmp(yytext+1);
tmp.resize(tmp.size() - 1);
return isc::dhcp::Dhcp4Parser::make_STRING(tmp, driver.loc_);
}
(?i:\"true\") {
/* dhcp-ddns value keywords are case insensitive */
if (driver.ctx_ == isc::dhcp::Parser4Context::REPLACE_CLIENT_NAME) {
return isc::dhcp::Dhcp4Parser::make_WHEN_PRESENT(driver.loc_);
}
std::string tmp(yytext+1);
tmp.resize(tmp.size() - 1);
return isc::dhcp::Dhcp4Parser::make_STRING(tmp, driver.loc_);
}
(?i:\"never\") {
/* dhcp-ddns value keywords are case insensitive */
if (driver.ctx_ == isc::dhcp::Parser4Context::REPLACE_CLIENT_NAME) {
return isc::dhcp::Dhcp4Parser::make_NEVER(driver.loc_);
}
std::string tmp(yytext+1);
tmp.resize(tmp.size() - 1);
return isc::dhcp::Dhcp4Parser::make_STRING(tmp, driver.loc_);
}
(?i:\"false\") {
/* dhcp-ddns value keywords are case insensitive */
if (driver.ctx_ == isc::dhcp::Parser4Context::REPLACE_CLIENT_NAME) {
return isc::dhcp::Dhcp4Parser::make_NEVER(driver.loc_);
}
std::string tmp(yytext+1);
tmp.resize(tmp.size() - 1);
return isc::dhcp::Dhcp4Parser::make_STRING(tmp, driver.loc_);
}
(?i:\"always\") {
/* dhcp-ddns value keywords are case insensitive */
if (driver.ctx_ == isc::dhcp::Parser4Context::REPLACE_CLIENT_NAME) {
return isc::dhcp::Dhcp4Parser::make_ALWAYS(driver.loc_);
}
std::string tmp(yytext+1);
tmp.resize(tmp.size() - 1);
return isc::dhcp::Dhcp4Parser::make_STRING(tmp, driver.loc_);
}
(?i:\"when-not-present\") {
/* dhcp-ddns value keywords are case insensitive */
if (driver.ctx_ == isc::dhcp::Parser4Context::REPLACE_CLIENT_NAME) {
return isc::dhcp::Dhcp4Parser::make_WHEN_NOT_PRESENT(driver.loc_);
}
std::string tmp(yytext+1);
tmp.resize(tmp.size() - 1);
return isc::dhcp::Dhcp4Parser::make_STRING(tmp, driver.loc_);
}
\"Dhcp6\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::CONFIG:
......
This diff is collapsed.
This diff is collapsed.
......@@ -142,26 +142,28 @@ using namespace std;
SOCKET_NAME "socket-name"
DHCP_DDNS "dhcp-ddns"
/// @todo: Implement proper parsing for those parameters in Dhcp4/dhcp-ddns/*.
/// This should be part of the #5043 ticket. Listing the keywords here for
/// completeness.
// These are tokens defined in Dhcp4/dhcp-ddns/*
// They're not
// ENABLE_UPDATES "enable-updates"
// SERVER_IP "server-ip"
// SENDER_IP "sender-ip"
// SENDER_PORT "sender-port"
// MAX_QUEUE_SIZE "max-queue-size"
// NCR_PROTOCOL "ncr-protocol"
// NCR_FORMAT "ncr-format"
// ALWAYS_INCLUDE_FQDN "always-include-fqdn"
// OVERRDIDE_NO_UPDATE "override-no-update"
// OVERRDIDE_CLIENT_UPDATE "override-client-update"
// REPLACE_CLIENT_NAME "replace-client-name"
// GENERATED_PREFIX "generated-prefix"
// QUALIFYING_SUFFIX "qualifying-suffix"
ENABLE_UPDATES "enable-updates"
QUALIFYING_SUFFIX "qualifying-suffix"
SERVER_IP "server-ip"
SERVER_PORT "server-port"
SENDER_IP "sender-ip"
SENDER_PORT "sender-port"
MAX_QUEUE_SIZE "max-queue-size"
NCR_PROTOCOL "ncr-protocol"
NCR_FORMAT "ncr-format"
ALWAYS_INCLUDE_FQDN "always-include-fqdn"
ALLOW_CLIENT_UPDATE "allow-client-update"
OVERRIDE_NO_UPDATE "override-no-update"
OVERRIDE_CLIENT_UPDATE "override-client-update"
REPLACE_CLIENT_NAME "replace-client-name"
GENERATED_PREFIX "generated-prefix"
UDP "UDP"
TCP "TCP"
JSON "JSON"
WHEN_PRESENT "when-present"
NEVER "never"
ALWAYS "always"
WHEN_NOT_PRESENT "when-not-present"
LOGGING "Logging"
LOGGERS "loggers"
......@@ -185,6 +187,7 @@ using namespace std;
SUB_OPTION_DEF
SUB_OPTION_DATA
SUB_HOOKS_LIBRARY
SUB_DHCP_DDNS
;
%token <std::string> STRING "constant string"
......@@ -194,6 +197,8 @@ using namespace std;
%type <ElementPtr> value
%type <ElementPtr> socket_type
%type <ElementPtr> ncr_protocol_value
%type <ElementPtr> replace_client_name_value
%printer { yyoutput << $$; } <*>;
......@@ -214,6 +219,7 @@ start: TOPLEVEL_JSON { ctx.ctx_ = ctx.NO_KEYWORD; } sub_json
| SUB_OPTION_DEF { ctx.ctx_ = ctx.OPTION_DEF; } sub_option_def
| SUB_OPTION_DATA { ctx.ctx_ = ctx.OPTION_DATA; } sub_option_data
| SUB_HOOKS_LIBRARY { ctx.ctx_ = ctx.HOOKS_LIBRARIES; } sub_hooks_library
| SUB_DHCP_DDNS { ctx.ctx_ = ctx.DHCP_DDNS; } sub_dhcp_ddns
;
// ---- generic JSON parser ---------------------------------
......@@ -1431,12 +1437,160 @@ dhcp_ddns: DHCP_DDNS {
ElementPtr m(new MapElement(ctx.loc2pos(@1)));
ctx.stack_.back()->set("dhcp-ddns", m);
ctx.stack_.push_back(m);
ctx.enter(ctx.NO_KEYWORD);
} COLON LCURLY_BRACKET not_empty_map RCURLY_BRACKET {
ctx.enter(ctx.DHCP_DDNS);
} COLON LCURLY_BRACKET dhcp_ddns_params RCURLY_BRACKET {
ctx.stack_.pop_back();
ctx.leave();
};
sub_dhcp_ddns: LCURLY_BRACKET {
// Parse the dhcp-ddns map
ElementPtr m(new MapElement(ctx.loc2pos(@1)));
ctx.stack_.push_back(m);
} dhcp_ddns_params RCURLY_BRACKET {
// parsing completed
};
dhcp_ddns_params: dhcp_ddns_param
| dhcp_ddns_params COMMA dhcp_ddns_param
;
dhcp_ddns_param: enable_updates
| qualifying_suffix
| server_ip
| server_port
| sender_ip
| sender_port
| max_queue_size
| ncr_protocol
| ncr_format
| always_include_fqdn
| allow_client_update
| override_no_update
| override_client_update
| replace_client_name
| generated_prefix
| unknown_map_entry
;
enable_updates: ENABLE_UPDATES COLON BOOLEAN {
ElementPtr b(new BoolElement($3, ctx.loc2pos(@3)));
ctx.stack_.back()->set("enable-updates", b);
};
qualifying_suffix: QUALIFYING_SUFFIX {
ctx.enter(ctx.NO_KEYWORD);
} COLON STRING {
ElementPtr s(new StringElement($4, ctx.loc2pos(@4)));
ctx.stack_.back()->set("qualifying-suffix", s);
ctx.leave();
};
server_ip: SERVER_IP {
ctx.enter(ctx.NO_KEYWORD);
} COLON STRING {
ElementPtr s(new StringElement($4, ctx.loc2pos(@4)));
ctx.stack_.back()->set("server-ip", s);
ctx.leave();
};
server_port: SERVER_PORT COLON INTEGER {
ElementPtr i(new IntElement($3, ctx.loc2pos(@3)));
ctx.stack_.back()->set("server-port", i);
};
sender_ip: SENDER_IP {
ctx.enter(ctx.NO_KEYWORD);
} COLON STRING {
ElementPtr s(new StringElement($4, ctx.loc2pos(@4)));
ctx.stack_.back()->set("sender-ip", s);
ctx.leave();
};
sender_port: SENDER_PORT COLON INTEGER {
ElementPtr i(new IntElement($3, ctx.loc2pos(@3)));
ctx.stack_.back()->set("sender-port", i);
};
max_queue_size: MAX_QUEUE_SIZE COLON INTEGER {
ElementPtr i(new IntElement($3, ctx.loc2pos(@3)));<