Commit 7b41e8f4 authored by Francis Dupont's avatar Francis Dupont
Browse files

[master] Finished merge of trac4272a (meta-info in classification)

parents bdb43930 d9d2ae2b
1148. [func] fdupont
Added the pkt classification token to extract incoming packet
meta-data (receiving interface name, source and destination
address, length).
(Trac #4272, git ...)
1147. [func] stephen
-Werror is no longer the default for compilation. Promotion of all
compilation warnings to errors now requires the --with-werror switch
to be specified when running configure.
(Trac #4533 git 874e3a3f5cb10313856284646fcee7cf86e4fcce)
(Trac #4533, git 874e3a3f5cb10313856284646fcee7cf86e4fcce)
1146. [func] sar
Add the forensic hook library documentation to the admin guide.
(Trac #4511 git 0bb39840a3cbdaf815819f846120c90d9ca038ff)
(Trac #4511, git 0bb39840a3cbdaf815819f846120c90d9ca038ff)
1145. [func] tmark
The Postgresql backend now supports host reservations for both DHCPv4 and
DHCPv6, with options and IPv6 reservations.
The Postgresql backend now supports host reservations for both
DHCPv4 and DHCPv6, with options and IPv6 reservations.
(Trac #4277 git ac1eaa1026987c2d86d57b4aa0dc9a4d093787f0)
1144. [bug] mihu
......
......@@ -217,7 +217,7 @@
<row>
<entry>DHCPv6 Relay Options</entry>
<entry>relay6[nest].option[code].hex</entry>
<entry>Value of the option</entry>
<entry>(value of the option)</entry>
<entry>The value of the option with code "code" from the
relay encapsulation "nest"</entry>
</row>
......@@ -235,6 +235,30 @@
<entry>The value of the link address field from the
relay encapsulation "nest"</entry>
</row>
<row>
<entry>Interface name of packet</entry>
<entry>pkt.iface</entry>
<entry>eth0</entry>
<entry>The name of the incoming interface of a DHCP packet.</entry>
</row>
<row>
<entry>Source address of packet</entry>
<entry>pkt.src</entry>
<entry>10.1.2.3</entry>
<entry>The IP source address of a DHCP packet.</entry>
</row>
<row>
<entry>Destination address of packet</entry>
<entry>pkt.dst</entry>
<entry>10.1.2.3</entry>
<entry>The IP destination address of a DHCP packet.</entry>
</row>
<row>
<entry>Length of packet</entry>
<entry>pkt.len</entry>
<entry>0x00000100</entry>
<entry>The length of a DHCP packet (UDP header field) padded to 4 bytes.</entry>
</row>
<row>
<entry>Hardware address in DHCPv4 packet</entry>
<entry>pkt4.mac</entry>
......@@ -351,7 +375,8 @@
</para>
<para>
Expressions starting with pkt4 can be used only in DHCPv4.
Expressions starting with "pkt4" can be used only in DHCPv4.
They allows access to DHCPv4 message fields.
</para>
<para>
......
......@@ -126,7 +126,7 @@ instantiated with the appropriate value and put onto the expression vector.
are mandatory. If either tool is missing or at too early a version, the
configure process will terminate with an error.
@section dhcpEcalToken Supported tokens
@section dhcpEvalToken Supported tokens
There are a number of tokens implemented. Each token is derived from
isc::eval::Token class and represents a certain expression primitive.
......@@ -135,12 +135,28 @@ instantiated with the appropriate value and put onto the expression vector.
- isc::dhcp::TokenString - represents a constant string, e.g. "MSFT";
- isc::dhcp::TokenHexString - represents a constant string, encoded as
hex string, e.g. 0x666f6f which is actually "foo";
- isc::dhcp::TokenIpAddress -- represents a constant IP address, encoded as
a 4 or 16 byte binary string, e.g., 10.0.0.1 is 0x10000001.
- isc::dhcp::TokenOption - represents an option in a packet, e.g.
option[123].text;
- isc::dhcp::TokenEqual - represents the equal (==) operator;
- isc::dhcp::TokenSubstring - represents the substring(text, start, length) operator;
- isc::dhcp::TokenRelay4Option - represents a sub-option inserted by the
DHCPv4 relay, e.g. relay[123].text or relay[123].hex
- isc::dhcp::TokenRelay6Option -- represents a sub-option inserted by
a DHCPv6 relay
- isc::dhcp::TokenPkt -- represents a DHCP packet meta data (incoming
interface name, source/remote or destination/local IP address, length).
- isc::dhcp::TokenPkt4 -- represents a DHCPv4 packet field.
- isc::dhcp::TokenPkt6 -- represents a DHCPv6 packet field (message type
or transaction id).
- isc::dhcp::TokenRelay6Field -- represents a DHCPv6 relay information field.
- isc::dhcp::TokenEqual - represents the equal (==) operator;
- isc::dhcp::TokenSubstring - represents the substring(text, start, length) operator;
- isc::dhcp::TokenConcat -- represents the concat operator which
concatenate two other tokens.
- isc::dhcp::TokenNot -- the logical not operator.
- isc::dhcp::TokenAnd -- the logical and (strict) operator.
- isc::dhcp::TokenOr -- the logical or (strict) operator (strict means
it always evaluates its operands).
More operators are expected to be implemented in upcoming releases.
......
......@@ -107,7 +107,7 @@ EvalContext::convertNestLevelNumber(const std::string& nest_level,
if (n < 0 || n >= HOP_COUNT_LIMIT) {
error(loc, "Nest level has invalid value in "
+ nest_level + ". Allowed range: 0..31");
}
}
} else {
error(loc, "Nest level invalid for DHCPv4 packets");
}
......
......@@ -60,16 +60,22 @@ the value stack. Then are then combined via logical or and
the result is pushed onto the value stack. The string is displayed
in text.
# For use with TokenPkt
% EVAL_DEBUG_PKT Pushing PKT meta data %1 with value %2
This debug message indicates that the given binary string representing
the value of the requested meta data is being pushed onto the value stack.
The string is displayed in hex at the exception of interface name.
# For use with TokenPkt4
% EVAL_DEBUG_PKT4 Pushing PKT4 field %1 with value %2
This debug message indicates that the given binary string representing
the value of the requested fied is being pushed onto the value stack.
the value of the requested field is being pushed onto the value stack.
The string is displayed in hex.
# For use with TokenPkt6
% EVAL_DEBUG_PKT6 Pushing PKT6 field %1 with value %2
This debug message indicates that the given binary string representing
the value of the requested fied is being pushed onto the value stack.
the value of the requested field is being pushed onto the value stack.
The string is displayed in hex.
# For use with TokenRelay6Field
......
This diff is collapsed.
......@@ -149,6 +149,11 @@ addr6 [0-9a-fA-F]*\:[0-9a-fA-F]*\:[0-9a-fA-F:.]*
"text" return isc::eval::EvalParser::make_TEXT(loc);
"hex" return isc::eval::EvalParser::make_HEX(loc);
"exists" return isc::eval::EvalParser::make_EXISTS(loc);
"pkt" return isc::eval::EvalParser::make_PKT(loc);
"iface" return isc::eval::EvalParser::make_IFACE(loc);
"src" return isc::eval::EvalParser::make_SRC(loc);
"dst" return isc::eval::EvalParser::make_DST(loc);
"len" return isc::eval::EvalParser::make_LEN(loc);
"pkt4" return isc::eval::EvalParser::make_PKT4(loc);
"mac" return isc::eval::EvalParser::make_CHADDR(loc);
"hlen" return isc::eval::EvalParser::make_HLEN(loc);
......@@ -157,6 +162,9 @@ addr6 [0-9a-fA-F]*\:[0-9a-fA-F]*\:[0-9a-fA-F:.]*
"giaddr" return isc::eval::EvalParser::make_GIADDR(loc);
"yiaddr" return isc::eval::EvalParser::make_YIADDR(loc);
"siaddr" return isc::eval::EvalParser::make_SIADDR(loc);
"pkt6" return isc::eval::EvalParser::make_PKT6(loc);
"msgtype" return isc::eval::EvalParser::make_MSGTYPE(loc);
"transid" return isc::eval::EvalParser::make_TRANSID(loc);
"substring" return isc::eval::EvalParser::make_SUBSTRING(loc);
"all" return isc::eval::EvalParser::make_ALL(loc);
"concat" return isc::eval::EvalParser::make_CONCAT(loc);
......@@ -170,10 +178,6 @@ addr6 [0-9a-fA-F]*\:[0-9a-fA-F]*\:[0-9a-fA-F:.]*
"]" return isc::eval::EvalParser::make_RBRACKET(loc);
"," return isc::eval::EvalParser::make_COMA(loc);
"pkt6" return isc::eval::EvalParser::make_PKT6(loc);
"msgtype" return isc::eval::EvalParser::make_MSGTYPE(loc);
"transid" return isc::eval::EvalParser::make_TRANSID(loc);
. driver.error (loc, "Invalid character: " + std::string(yytext));
<<EOF>> return isc::eval::EvalParser::make_END(loc);
%%
......
// Generated 201604271143
// Generated 201608081450
// A Bison parser, made by GNU Bison 3.0.4.
// Locations for Bison parsers in C++
......
This diff is collapsed.
......@@ -304,21 +304,24 @@ namespace isc { namespace eval {
// pkt6_field
char dummy3[sizeof(TokenPkt6::FieldType)];
// pkt_metadata
char dummy4[sizeof(TokenPkt::MetadataType)];
// relay6_field
char dummy4[sizeof(TokenRelay6Field::FieldType)];
char dummy5[sizeof(TokenRelay6Field::FieldType)];
// "constant string"
// "integer"
// "constant hexstring"
// "option name"
// "ip address"
char dummy5[sizeof(std::string)];
char dummy6[sizeof(std::string)];
// option_code
char dummy6[sizeof(uint16_t)];
char dummy7[sizeof(uint16_t)];
// nest_level
char dummy7[sizeof(uint8_t)];
char dummy8[sizeof(uint8_t)];
};
/// Symbol semantic values.
......@@ -359,26 +362,31 @@ namespace isc { namespace eval {
TOKEN_TEXT = 272,
TOKEN_HEX = 273,
TOKEN_EXISTS = 274,
TOKEN_PKT4 = 275,
TOKEN_CHADDR = 276,
TOKEN_HLEN = 277,
TOKEN_HTYPE = 278,
TOKEN_CIADDR = 279,
TOKEN_GIADDR = 280,
TOKEN_YIADDR = 281,
TOKEN_SIADDR = 282,
TOKEN_SUBSTRING = 283,
TOKEN_ALL = 284,
TOKEN_COMA = 285,
TOKEN_CONCAT = 286,
TOKEN_PKT6 = 287,
TOKEN_MSGTYPE = 288,
TOKEN_TRANSID = 289,
TOKEN_STRING = 290,
TOKEN_INTEGER = 291,
TOKEN_HEXSTRING = 292,
TOKEN_OPTION_NAME = 293,
TOKEN_IP_ADDRESS = 294
TOKEN_PKT = 275,
TOKEN_IFACE = 276,
TOKEN_SRC = 277,
TOKEN_DST = 278,
TOKEN_LEN = 279,
TOKEN_PKT4 = 280,
TOKEN_CHADDR = 281,
TOKEN_HLEN = 282,
TOKEN_HTYPE = 283,
TOKEN_CIADDR = 284,
TOKEN_GIADDR = 285,
TOKEN_YIADDR = 286,
TOKEN_SIADDR = 287,
TOKEN_PKT6 = 288,
TOKEN_MSGTYPE = 289,
TOKEN_TRANSID = 290,
TOKEN_SUBSTRING = 291,
TOKEN_ALL = 292,
TOKEN_COMA = 293,
TOKEN_CONCAT = 294,
TOKEN_STRING = 295,
TOKEN_INTEGER = 296,
TOKEN_HEXSTRING = 297,
TOKEN_OPTION_NAME = 298,
TOKEN_IP_ADDRESS = 299
};
};
......@@ -422,6 +430,8 @@ namespace isc { namespace eval {
basic_symbol (typename Base::kind_type t, const TokenPkt6::FieldType v, const location_type& l);
basic_symbol (typename Base::kind_type t, const TokenPkt::MetadataType v, const location_type& l);
basic_symbol (typename Base::kind_type t, const TokenRelay6Field::FieldType v, const location_type& l);
basic_symbol (typename Base::kind_type t, const std::string v, const location_type& l);
......@@ -569,6 +579,26 @@ namespace isc { namespace eval {
symbol_type
make_EXISTS (const location_type& l);
static inline
symbol_type
make_PKT (const location_type& l);
static inline
symbol_type
make_IFACE (const location_type& l);
static inline
symbol_type
make_SRC (const location_type& l);
static inline
symbol_type
make_DST (const location_type& l);
static inline
symbol_type
make_LEN (const location_type& l);
static inline
symbol_type
make_PKT4 (const location_type& l);
......@@ -603,31 +633,31 @@ namespace isc { namespace eval {
static inline
symbol_type
make_SUBSTRING (const location_type& l);
make_PKT6 (const location_type& l);
static inline
symbol_type
make_ALL (const location_type& l);
make_MSGTYPE (const location_type& l);
static inline
symbol_type
make_COMA (const location_type& l);
make_TRANSID (const location_type& l);
static inline
symbol_type
make_CONCAT (const location_type& l);
make_SUBSTRING (const location_type& l);
static inline
symbol_type
make_PKT6 (const location_type& l);
make_ALL (const location_type& l);
static inline
symbol_type
make_MSGTYPE (const location_type& l);
make_COMA (const location_type& l);
static inline
symbol_type
make_TRANSID (const location_type& l);
make_CONCAT (const location_type& l);
static inline
symbol_type
......@@ -854,12 +884,12 @@ namespace isc { namespace eval {
enum
{
yyeof_ = 0,
yylast_ = 113, ///< Last index in yytable_.
yynnts_ = 12, ///< Number of nonterminal symbols.
yyfinal_ = 25, ///< Termination state number.
yylast_ = 121, ///< Last index in yytable_.
yynnts_ = 13, ///< Number of nonterminal symbols.
yyfinal_ = 27, ///< Termination state number.
yyterror_ = 1,
yyerrcode_ = 256,
yyntokens_ = 40 ///< Number of tokens.
yyntokens_ = 45 ///< Number of tokens.
};
......@@ -905,9 +935,9 @@ namespace isc { namespace eval {
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
35, 36, 37, 38, 39, 40, 41, 42, 43, 44
};
const unsigned int user_token_number_max_ = 294;
const unsigned int user_token_number_max_ = 299;
const token_number_type undef_token_ = 2;
if (static_cast<int>(t) <= yyeof_)
......@@ -940,35 +970,39 @@ namespace isc { namespace eval {
{
switch (other.type_get ())
{
case 45: // option_repr_type
case 50: // option_repr_type
value.copy< TokenOption::RepresentationType > (other.value);
break;
case 46: // pkt4_field
case 53: // pkt4_field
value.copy< TokenPkt4::FieldType > (other.value);
break;
case 51: // pkt6_field
case 54: // pkt6_field
value.copy< TokenPkt6::FieldType > (other.value);
break;
case 49: // relay6_field
case 52: // pkt_metadata
value.copy< TokenPkt::MetadataType > (other.value);
break;
case 55: // relay6_field
value.copy< TokenRelay6Field::FieldType > (other.value);
break;
case 35: // "constant string"
case 36: // "integer"
case 37: // "constant hexstring"
case 38: // "option name"
case 39: // "ip address"
case 40: // "constant string"
case 41: // "integer"
case 42: // "constant hexstring"
case 43: // "option name"
case 44: // "ip address"
value.copy< std::string > (other.value);
break;
case 44: // option_code
case 49: // option_code
value.copy< uint16_t > (other.value);
break;
case 50: // nest_level
case 51: // nest_level
value.copy< uint8_t > (other.value);
break;
......@@ -989,35 +1023,39 @@ namespace isc { namespace eval {
(void) v;
switch (this->type_get ())
{
case 45: // option_repr_type
case 50: // option_repr_type
value.copy< TokenOption::RepresentationType > (v);
break;
case 46: // pkt4_field
case 53: // pkt4_field
value.copy< TokenPkt4::FieldType > (v);
break;
case 51: // pkt6_field
case 54: // pkt6_field
value.copy< TokenPkt6::FieldType > (v);
break;
case 49: // relay6_field
case 52: // pkt_metadata
value.copy< TokenPkt::MetadataType > (v);
break;
case 55: // relay6_field
value.copy< TokenRelay6Field::FieldType > (v);
break;
case 35: // "constant string"
case 36: // "integer"
case 37: // "constant hexstring"
case 38: // "option name"
case 39: // "ip address"
case 40: // "constant string"
case 41: // "integer"
case 42: // "constant hexstring"
case 43: // "option name"
case 44: // "ip address"
value.copy< std::string > (v);
break;
case 44: // option_code
case 49: // option_code
value.copy< uint16_t > (v);
break;
case 50: // nest_level
case 51: // nest_level
value.copy< uint8_t > (v);
break;
......@@ -1057,6 +1095,13 @@ namespace isc { namespace eval {
, location (l)
{}
template <typename Base>
EvalParser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t, const TokenPkt::MetadataType v, const location_type& l)
: Base (t)
, value (v)
, location (l)
{}
template <typename Base>
EvalParser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t, const TokenRelay6Field::FieldType v, const location_type& l)
: Base (t)
......@@ -1111,35 +1156,39 @@ namespace isc { namespace eval {
// Type destructor.
switch (yytype)
{
case 45: // option_repr_type
case 50: // option_repr_type
value.template destroy< TokenOption::RepresentationType > ();
break;
case 46: // pkt4_field
case 53: // pkt4_field
value.template destroy< TokenPkt4::FieldType > ();
break;
case 51: // pkt6_field
case 54: // pkt6_field
value.template destroy< TokenPkt6::FieldType > ();
break;
case 49: // relay6_field
case 52: // pkt_metadata
value.template destroy< TokenPkt::MetadataType > ();
break;
case 55: // relay6_field
value.template destroy< TokenRelay6Field::FieldType > ();
break;
case 35: // "constant string"
case 36: // "integer"
case 37: // "constant hexstring"
case 38: // "option name"
case 39: // "ip address"
case 40: // "constant string"
case 41: // "integer"
case 42: // "constant hexstring"
case 43: // "option name"
case 44: // "ip address"
value.template destroy< std::string > ();
break;
case 44: // option_code
case 49: // option_code
value.template destroy< uint16_t > ();
break;
case 50: // nest_level
case 51: // nest_level
value.template destroy< uint8_t > ();
break;
......@@ -1166,35 +1215,39 @@ namespace isc { namespace eval {
super_type::move(s);
switch (this->type_get ())
{
case 45: // option_repr_type
case 50: // option_repr_type
value.move< TokenOption::RepresentationType > (s.value);
break;
case 46: // pkt4_field
case 53: // pkt4_field
value.move< TokenPkt4::FieldType > (s.value);
break;
case 51: // pkt6_field
case 54: // pkt6_field
value.move< TokenPkt6::FieldType > (s.value);
break;
case 49: // relay6_field
case 52: // pkt_metadata
value.move< TokenPkt::MetadataType > (s.value);
break;
case 55: // relay6_field
value.move< TokenRelay6Field::FieldType > (s.value);
break;
case 35: // "constant string"
case 36: // "integer"
case 37: // "constant hexstring"
case 38: // "option name"
case 39: // "ip address"
case 40: // "constant string"
case 41: // "integer"
case 42: // "constant hexstring"
case 43: // "option name"
case 44: // "ip address"
value.move< std::string > (s.value);
break;
case 44: // option_code
case 49: // option_code
value.move< uint16_t > (s.value);
break;
case 50: // nest_level
case 51: // nest_level
value.move< uint8_t > (s.value);
break;
......@@ -1256,7 +1309,8 @@ namespace isc { namespace eval {
0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
285, 286, 287, 288, 289, 290, 291, 292, 293, 294
285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
295, 296, 297, 298, 299
};
return static_cast<token_type> (yytoken_number_[type]);
}
......@@ -1369,6 +1423,36 @@ namespace isc { namespace eval {
return symbol_type (token::TOKEN_EXISTS, l);
}
EvalParser::symbol_type
EvalParser::make_PKT (const location_type& l)
{
return symbol_type (token::TOKEN_PKT, l);
}
EvalParser::symbol_type
EvalParser::make_IFACE (const location_type& l)
{
return symbol_type (token::TOKEN_IFACE, l);
}
EvalParser::symbol_type