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

[master] Finished merge of trac5491 (duplicate comment tests)

parents 2a604994 539645e6
......@@ -2,9 +2,9 @@
Added support for generalized UDP Source Port for DHCP Relay
(RFC 8357) for DHCPv4, DHCPv6 and DHCPv4-over-DHCPv6. Note
this required changes to the inter-server protocol used by
our 4o6 implementation, and is therefore not backwardly
our 4o6 implementation, and is therefore not backward
compatible.
(Trac #5404, git xxx)
(Trac #5404, git 2a6049947ad4caaaa697dba8cb7669a09264f0bc)
1381. [bug] marcin
Corrected a bug in the libkea-asiolink library which caused
......
......@@ -8,7 +8,9 @@ EXTRA_DIST += devel/mainpage.dox
EXTRA_DIST += devel/terminology.dox
EXTRA_DIST += devel/unit-tests.dox
nobase_dist_doc_DATA = examples/agent/simple.json
nobase_dist_doc_DATA = examples/agent/comments.json
nobase_dist_doc_DATA += examples/agent/simple.json
nobase_dist_doc_DATA += examples/ddns/comments.json
nobase_dist_doc_DATA += examples/ddns/sample1.json
nobase_dist_doc_DATA += examples/ddns/template.json
nobase_dist_doc_DATA += examples/https/httpd2/kea-httpd2.conf
......
// This is a example of a configuration for Control-Agent (CA) or simply Agent.
// It uses embedded (i.e., which will be included in configuration objects
// and not stripped by at lexical analysis) comments.
{
"Control-agent":
{
// Global scope
"comment": "A Control Agent",
"http-host": "127.0.0.1",
"http-port": 8000,
// In control socket
"control-sockets":
{
"dhcp4":
{
"comment": "control socket for DHCP4 server",
"socket-type": "unix",
"socket-name": "/path/to/the/unix/socket-v4"
}
}
},
"Logging":
{
// In loggers
"loggers": [
{
"comment": "A logger",
"name": "kea-ctrl-agent"
}
]
}
}
......@@ -3,73 +3,84 @@
{
"Control-agent":
{
// We need to specify where the agent should listen to incoming HTTP
// queries. Note that agent does not provide SSL or TLS protection
// on its own, so limiting the traffic to localhost is a good idea.
"http-host": "127.0.0.1",
// We need to specify where the agent should listen to incoming HTTP
// queries. Note that agent does not provide SSL or TLS protection
// on its own, so limiting the traffic to localhost is a good idea.
"http-host": "127.0.0.1",
// Another mandatory parameter is the HTTP port.
"http-port": 8000,
// Another mandatory parameter is the HTTP port.
"http-port": 8000,
// This map specifies where control channel of each server is configured
// to listen on. See 'control-socket' object in the respective
// servers. At this time the only supported socket type is "unix".
// Make sure that the Agent and respective servers configuration
// matches exactly, otherwise they won't be able to communicate.
"control-sockets":
{
// This is how the Agent can communicate with the DHCPv4 server.
"dhcp4":
{
"socket-type": "unix",
"socket-name": "/path/to/the/unix/socket-v4"
},
// This map specifies where control channel of each server is configured
// to listen on. See 'control-socket' object in the respective
// servers. At this time the only supported socket type is "unix".
// Make sure that the Agent and respective servers configuration
// matches exactly, otherwise they won't be able to communicate.
// One extra feature that requires some explanation is
// user-context. This is a structure that you can define at
// global scope, in control sockets and others. It is parsed by
// Kea, but not used directly. It is intended to keep anything
// you may want to put there - comments, extra designations,
// floor or department names etc. These structures will be made
// available to Kea hooks. A comment entry is translated into a
// user-context with a "comment" property so you can include
// comments inside the configuration itself.
"control-sockets":
{
// This is how the Agent can communicate with the DHCPv4 server.
"dhcp4":
{
"comment": "socket to DHCP4 server",
"socket-type": "unix",
"socket-name": "/path/to/the/unix/socket-v4"
},
// Location of the DHCPv6 command channel socket.
"dhcp6":
{
"socket-type": "unix",
"socket-name": "/path/to/the/unix/socket-v6"
},
// Location of the DHCPv6 command channel socket.
"dhcp6":
{
"socket-type": "unix",
"socket-name": "/path/to/the/unix/socket-v6"
},
// Currently DHCP-DDNS (nicknamed D2) does not support
// command channel yet, but we hope this will change in the
// future.
"d2":
{
"socket-type": "unix",
"socket-name": "/path/to/the/unix/socket-d2"
}
},
// Currently DHCP-DDNS (nicknamed D2) does not support
// command channel yet, but we hope this will change in the
// future.
"d2":
{
"socket-type": "unix",
"socket-name": "/path/to/the/unix/socket-d2",
"user-context": { "in-use": false }
}
},
// CA is able to load hook libraries that augment its operation.
// The primary functionality is the ability to add new commands.
"hooks-libraries": [
// Hook libraries list may contain more than one library.
{
// The only necessary parameter is the library filename.
"library": "/opt/local/control-agent-commands.so",
// CA is able to load hook libraries that augment its operation.
// The primary functionality is the ability to add new commands.
"hooks-libraries": [
// Hook libraries list may contain more than one library.
{
// The only necessary parameter is the library filename.
"library": "/opt/local/control-agent-commands.so",
// Some libraries may support parameters. Make sure you
// type this section carefully, as the CA does not validate
// it (because the format is library specific).
"parameters": {
"param1": "foo"
}
}
]
// Some libraries may support parameters. Make sure you
// type this section carefully, as the CA does not validate
// it (because the format is library specific).
"parameters": {
"param1": "foo"
}
}
]
},
// Similar to other Kea components, CA also uses logging.
"Logging":
{
"loggers": [
{
"name": "kea-ctrl-agent",
"output_options": [
{
"output": "/var/log/kea-ctrl-agent.log",
"loggers": [
{
"name": "kea-ctrl-agent",
"output_options": [
{
"output": "/var/log/kea-ctrl-agent.log",
// Several additional parameters are possible in addition
// to the typical output. Flush determines whether logger
// flushes output to a file. Maxsize determines maximum
......@@ -79,11 +90,11 @@
"flush": true,
"maxsize": 204800,
"maxver": 4
}
],
"severity": "INFO",
"debuglevel": 0
}
]
}
],
"severity": "INFO",
"debuglevel": 0
}
]
}
}
// This is an example configuration file for D2, Kea's DHCP-DDNS processor.
// It uses embedded (i.e., which will be included in configuration objects
// and not stripped by at lexical analysis) comments.
{
"DhcpDdns":
{
// Global scope
"comment": "A DHCP-DDNS server",
"ip-address": "172.16.1.10",
"port": 53001,
"dns-server-timeout" : 1000,
"forward-ddns":
{
"ddns-domains":
[
// In DDNS domain
{
"comment": "DdnsDomain for zone 'four.example.com.'",
"name": "four.example.com.",
"key-name": "d2.md5.key",
// In DNS server
"dns-servers":
[
{
"comment": "four.example.com. server",
"ip-address": "172.16.1.1"
}
]
}
]
},
// In TSIG key
"tsig-keys":
[
{
"comment": "four.example.com. key",
"name": "d2.md5.key",
"algorithm": "HMAC-MD5",
"secret": "LSWXnfkKZjdPJI5QxlpnfQ=="
}
]
},
"Logging": {
// In loggers
"loggers": [
{
"comment": "A logger",
"name": "kea-dhcp-ddns"
}
]
}
}
......@@ -18,6 +18,18 @@
"port": 53001,
"dns-server-timeout" : 1000,
// One extra feature that requires some explanation is
// user-context. This is a structure that you can define at global scope,
// in ddns domain, dns server, tsig key and others. It is parsed by
// Kea, but not used directly. It is intended to keep anything you
// may want to put there - comments, extra designations, floor or
// department names etc.
// A comment entry is translated into a user-context with a "comment"
// property so you can include comments inside the configuration itself.
"user-context": { "version": 1 },
//
// ----------------- Forward DDNS ------------------
//
......@@ -36,6 +48,7 @@
[
// DdnsDomain for zone "four.example.com."
{
"comment": "DdnsDomain example",
"name": "four.example.com.",
"key-name": "d2.md5.key",
"dns-servers":
......
......@@ -69,12 +69,14 @@
"control-sockets": {
"dhcp4": {
"comment": "main server",
"socket-type": "unix",
"socket-name": "/path/to/the/unix/socket-v4"
},
"dhcp6": {
"socket-type": "unix",
"socket-name": "/path/to/the/unix/socket-v4"
"socket-name": "/path/to/the/unix/socket-v4",
"user-context": { "version": 3 }
}
},
......@@ -148,6 +150,22 @@
</simpara>
</warning>
<para>
User contexts can store arbitrary data as long as it is valid JSON
syntax and its top level element is a map (i.e. the data must be
enclosed in curly brackets). Some hook libraries may expect specific
formatting, though. Please consult specific hook library
documentation for details.
</para>
<para>
User contexts can be specified on either global scope, control
socket and loggers. One other useful usage is the ability to
store comments or descriptions: the parser translates a
"comment" entry into a user-context with the entry, this allows
to attach a comment inside the configuration itself.
</para>
<para>
Hooks libraries can be attached to the Control Agent just like to
DHCPv4 and DHCPv6 servers. It currently supports one hook point
......
......@@ -772,6 +772,30 @@ corresponding values in the DHCP servers' "dhcp-ddns" configuration section.
</section> <!-- "d2-reverse-ddns-config" -->
<section xml:id="d2-user-contexts">
<title>User context in DDNS</title>
<note>
<para>User contexts were designed for hook libraries which
are not yet supported for DHCP-DDNS server configuration.</para>
</note>
<para>
User contexts can store arbitrary data as long as it is valid JSON
syntax and its top level element is a map (i.e. the data must be
enclosed in curly brackets).
</para>
<para>
User contexts can be specified on either global scope, ddns
domain, dns server, tsig key and loggers. One other useful
usage is the ability to store comments or descriptions: the
parser translates a "comment" entry into a user-context with
the entry, this allows to attach a comment inside the
configuration itself.
</para>
</section> <!-- "d2-user-contexts" -->
<section xml:id="d2-example-config">
<title>Example DHCP-DDNS Server Configuration</title>
<para>
......@@ -862,6 +886,7 @@ corresponding values in the DHCP servers' "dhcp-ddns" configuration section.
The following example configuration specified the Forward DDNS Domains.
<screen><userinput>
"DhcpDdns": {
"comment": "example configuration: forward part",
"forward-ddns": {
"ddns-domains": [
{
......@@ -884,7 +909,8 @@ corresponding values in the DHCP servers' "dhcp-ddns" configuration section.
"key-name": "",
"dns-servers": [
{ "ip-address": "172.16.2.5" }
]
],
"user-context": { "backup": false }
},
]
......@@ -936,6 +962,7 @@ corresponding values in the DHCP servers' "dhcp-ddns" configuration section.
<screen><userinput>
"DhcpDdns": {
"comment": "example configuration: reverse part",
"reverse-ddns": {
"ddns-domains": [
{
......
This diff is collapsed.
/* Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC")
/* Copyright (C) 2017-2018 Internet Systems Consortium, Inc. ("ISC")
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
......@@ -200,6 +200,28 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
}
}
\"user-context\" {
switch(driver.ctx_) {
case ParserContext::AGENT:
case ParserContext::SERVER:
case ParserContext::LOGGERS:
return AgentParser::make_USER_CONTEXT(driver.loc_);
default:
return AgentParser::make_STRING("user-context", driver.loc_);
}
}
\"comment\" {
switch(driver.ctx_) {
case ParserContext::AGENT:
case ParserContext::SERVER:
case ParserContext::LOGGERS:
return AgentParser::make_COMMENT(driver.loc_);
default:
return AgentParser::make_STRING("comment", driver.loc_);
}
}
\"control-sockets\" {
switch(driver.ctx_) {
case ParserContext::AGENT:
......
This diff is collapsed.
......@@ -304,6 +304,7 @@ namespace isc { namespace agent {
union union_type
{
// value
// map_value
// socket_type_value
char dummy1[sizeof(ElementPtr)];
......@@ -351,36 +352,38 @@ namespace isc { namespace agent {
TOKEN_CONTROL_AGENT = 265,
TOKEN_HTTP_HOST = 266,
TOKEN_HTTP_PORT = 267,
TOKEN_CONTROL_SOCKETS = 268,
TOKEN_DHCP4_SERVER = 269,
TOKEN_DHCP6_SERVER = 270,
TOKEN_D2_SERVER = 271,
TOKEN_SOCKET_NAME = 272,
TOKEN_SOCKET_TYPE = 273,
TOKEN_UNIX = 274,
TOKEN_HOOKS_LIBRARIES = 275,
TOKEN_LIBRARY = 276,
TOKEN_PARAMETERS = 277,
TOKEN_LOGGING = 278,
TOKEN_LOGGERS = 279,
TOKEN_NAME = 280,
TOKEN_OUTPUT_OPTIONS = 281,
TOKEN_OUTPUT = 282,
TOKEN_DEBUGLEVEL = 283,
TOKEN_SEVERITY = 284,
TOKEN_FLUSH = 285,
TOKEN_MAXSIZE = 286,
TOKEN_MAXVER = 287,
TOKEN_DHCP4 = 288,
TOKEN_DHCP6 = 289,
TOKEN_DHCPDDNS = 290,
TOKEN_START_JSON = 291,
TOKEN_START_AGENT = 292,
TOKEN_START_SUB_AGENT = 293,
TOKEN_STRING = 294,
TOKEN_INTEGER = 295,
TOKEN_FLOAT = 296,
TOKEN_BOOLEAN = 297
TOKEN_USER_CONTEXT = 268,
TOKEN_COMMENT = 269,
TOKEN_CONTROL_SOCKETS = 270,
TOKEN_DHCP4_SERVER = 271,
TOKEN_DHCP6_SERVER = 272,
TOKEN_D2_SERVER = 273,
TOKEN_SOCKET_NAME = 274,
TOKEN_SOCKET_TYPE = 275,
TOKEN_UNIX = 276,
TOKEN_HOOKS_LIBRARIES = 277,
TOKEN_LIBRARY = 278,
TOKEN_PARAMETERS = 279,
TOKEN_LOGGING = 280,
TOKEN_LOGGERS = 281,
TOKEN_NAME = 282,
TOKEN_OUTPUT_OPTIONS = 283,
TOKEN_OUTPUT = 284,
TOKEN_DEBUGLEVEL = 285,
TOKEN_SEVERITY = 286,
TOKEN_FLUSH = 287,
TOKEN_MAXSIZE = 288,
TOKEN_MAXVER = 289,
TOKEN_DHCP4 = 290,
TOKEN_DHCP6 = 291,
TOKEN_DHCPDDNS = 292,
TOKEN_START_JSON = 293,
TOKEN_START_AGENT = 294,
TOKEN_START_SUB_AGENT = 295,
TOKEN_STRING = 296,
TOKEN_INTEGER = 297,
TOKEN_FLOAT = 298,
TOKEN_BOOLEAN = 299
};
};
......@@ -539,6 +542,14 @@ namespace isc { namespace agent {
symbol_type
make_HTTP_PORT (const location_type& l);
static inline
symbol_type
make_USER_CONTEXT (const location_type& l);
static inline
symbol_type
make_COMMENT (const location_type& l);
static inline
symbol_type
make_CONTROL_SOCKETS (const location_type& l);
......@@ -864,12 +875,12 @@ namespace isc { namespace agent {
enum
{
yyeof_ = 0,
yylast_ = 172, ///< Last index in yytable_.
yynnts_ = 92, ///< Number of nonterminal symbols.
yylast_ = 190, ///< Last index in yytable_.
yynnts_ = 97, ///< Number of nonterminal symbols.
yyfinal_ = 8, ///< Termination state number.
yyterror_ = 1,
yyerrcode_ = 256,
yyntokens_ = 43 ///< Number of tokens.
yyntokens_ = 45 ///< Number of tokens.
};
......@@ -915,9 +926,9 @@ namespace isc { namespace agent {
5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
35, 36, 37, 38, 39, 40, 41, 42
35, 36, 37, 38, 39, 40, 41, 42, 43, 44
};
const unsigned int user_token_number_max_ = 297;
const unsigned int user_token_number_max_ = 299;
const token_number_type undef_token_ = 2;
if (static_cast<int>(t) <= yyeof_)
......@@ -950,24 +961,25 @@ namespace isc { namespace agent {
{
switch (other.type_get ())
{
case 51: // value
case 100: // socket_type_value
case 53: // value
case 56: // map_value
case 107: // socket_type_value
value.copy< ElementPtr > (other.value);
break;
case 42: // "boolean"
case 44: // "boolean"
value.copy< bool > (other.value);
break;
case 41: // "floating point"
case 43: // "floating point"
value.copy< double > (other.value);
break;
case 40: // "integer"
case 42: // "integer"
value.copy< int64_t > (other.value);
break;
case 39: // "constant string"
case 41: // "constant string"
value.copy< std::string > (other.value);
break;
......@@ -988,24 +1000,25 @@ namespace isc { namespace agent {
(void) v;
switch (this->type_get ())
{
case 51: // value
case 100: // socket_type_value
case 53: // value
case 56: // map_value
case 107: // socket_type_value
value.copy< ElementPtr > (v);
break;
case 42: // "boolean"
case 44: // "boolean"