Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Schrader
Kea
Commits
55e3be08
Commit
55e3be08
authored
Mar 16, 2016
by
Francis Dupont
Browse files
[4232a] Addressed comments
parent
03481324
Changes
5
Hide whitespace changes
Inline
Side-by-side
doc/guide/classify.xml
View file @
55e3be08
...
...
@@ -179,7 +179,8 @@ sub-option with code "code" from the DHCPv4 Relay Agent Information option
</para>
<para>
IP addresses are converted into strings of length 4 or 16.
IP addresses are converted into strings of length 4 or 16. IPv4, IPv6,
IPv4 embedded IPv6 (e.g., IPv4 mapped IPv6) addresses are supported.
</para>
<para>
...
...
src/lib/eval/lexer.cc
View file @
55e3be08
...
...
@@ -642,9 +642,9 @@ int yy_flex_debug = 1;
static
yyconst
flex_int16_t
yy_rule_linenum
[
27
]
=
{
0
,
8
1
,
8
5
,
9
1
,
10
1
,
10
7
,
12
1
,
12
8
,
14
1
,
14
2
,
14
3
,
144
,
145
,
146
,
147
,
148
,
149
,
150
,
151
,
152
,
153
,
154
,
155
,
156
,
157
,
158
,
1
60
8
2
,
8
6
,
9
2
,
10
2
,
10
8
,
12
2
,
12
9
,
14
3
,
14
4
,
14
5
,
146
,
147
,
148
,
149
,
150
,
151
,
152
,
153
,
154
,
155
,
156
,
157
,
158
,
1
59
,
160
,
162
}
;
static
yy_state_type
*
yy_state_buf
=
0
,
*
yy_state_ptr
=
0
;
...
...
@@ -716,13 +716,14 @@ static isc::eval::location loc;
useful for client classes, which typically are one-liners, but it may be
useful in more complex cases. */
/* These are not token expressions yet, just convenience expressions that
can be used during actual token definitions. */
#line 68 "lexer.ll"
can be used during actual token definitions. Note some can match
incorrect inputs (e.g., IP addresses) which must be checked. */
#line 69 "lexer.ll"
// This code run each time a pattern is matched. It updates the location
// by moving it ahead by yyleng bytes. yyleng specifies the length of the
// currently matched token.
#define YY_USER_ACTION loc.columns(yyleng);
#line 72
6
"lexer.cc"
#line 72
7
"lexer.cc"
#define INITIAL 0
...
...
@@ -962,7 +963,7 @@ YY_DECL
register
int
yy_act
;
/* %% [7.0] user's declarations go here */
#line 7
4
"lexer.ll"
#line 7
5
"lexer.ll"
...
...
@@ -970,7 +971,7 @@ YY_DECL
loc
.
step
();
#line 97
4
"lexer.cc"
#line 97
5
"lexer.cc"
if
(
!
(
yy_init
)
)
{
...
...
@@ -1126,7 +1127,7 @@ do_action: /* This label is used only to access EOF actions. */
/* %% [13.0] actions go here */
case
1
:
YY_RULE_SETUP
#line 8
1
"lexer.ll"
#line 8
2
"lexer.ll"
{
// Ok, we found a with space. Let's ignore it and update loc variable.
loc
.
step
();
...
...
@@ -1135,7 +1136,7 @@ YY_RULE_SETUP
case
2
:
/* rule 2 can match eol */
YY_RULE_SETUP
#line 8
5
"lexer.ll"
#line 8
6
"lexer.ll"
{
// Newline found. Let's update the location and continue.
loc
.
lines
(
yyleng
);
...
...
@@ -1144,7 +1145,7 @@ YY_RULE_SETUP
YY_BREAK
case
3
:
YY_RULE_SETUP
#line 9
1
"lexer.ll"
#line 9
2
"lexer.ll"
{
// A string has been matched. It contains the actual string and single quotes.
// We need to get those quotes out of the way and just use its content, e.g.
...
...
@@ -1157,7 +1158,7 @@ YY_RULE_SETUP
YY_BREAK
case
4
:
YY_RULE_SETUP
#line 10
1
"lexer.ll"
#line 10
2
"lexer.ll"
{
// A hex string has been matched. It contains the '0x' or '0X' header
// followed by at least one hexadecimal digit.
...
...
@@ -1166,7 +1167,7 @@ YY_RULE_SETUP
YY_BREAK
case
5
:
YY_RULE_SETUP
#line 10
7
"lexer.ll"
#line 10
8
"lexer.ll"
{
// An integer was found.
std
::
string
tmp
(
yytext
);
...
...
@@ -1184,7 +1185,7 @@ YY_RULE_SETUP
case
6
:
/* rule 6 can match eol */
YY_RULE_SETUP
#line 12
1
"lexer.ll"
#line 12
2
"lexer.ll"
{
// This string specifies option name starting with a letter
// and further containing letters, digits, hyphens and
...
...
@@ -1194,11 +1195,12 @@ YY_RULE_SETUP
YY_BREAK
case
7
:
YY_RULE_SETUP
#line 12
8
"lexer.ll"
#line 12
9
"lexer.ll"
{
// IPv4 or IPv6 address
std
::
string
tmp
(
yytext
);
// Some incorrect addresses can match so we have to check.
try
{
isc
::
asiolink
::
IOAddress
ip
(
tmp
);
}
catch
(...)
{
...
...
@@ -1210,109 +1212,109 @@ YY_RULE_SETUP
YY_BREAK
case
8
:
YY_RULE_SETUP
#line 14
1
"lexer.ll"
#line 14
3
"lexer.ll"
return
isc
::
eval
::
EvalParser
::
make_EQUAL
(
loc
);
YY_BREAK
case
9
:
YY_RULE_SETUP
#line 14
2
"lexer.ll"
#line 14
4
"lexer.ll"
return
isc
::
eval
::
EvalParser
::
make_OPTION
(
loc
);
YY_BREAK
case
10
:
YY_RULE_SETUP
#line 14
3
"lexer.ll"
#line 14
5
"lexer.ll"
return
isc
::
eval
::
EvalParser
::
make_TEXT
(
loc
);
YY_BREAK
case
11
:
YY_RULE_SETUP
#line 14
4
"lexer.ll"
#line 14
6
"lexer.ll"
return
isc
::
eval
::
EvalParser
::
make_HEX
(
loc
);
YY_BREAK
case
12
:
YY_RULE_SETUP
#line 14
5
"lexer.ll"
#line 14
7
"lexer.ll"
return
isc
::
eval
::
EvalParser
::
make_EXISTS
(
loc
);
YY_BREAK
case
13
:
YY_RULE_SETUP
#line 14
6
"lexer.ll"
#line 14
8
"lexer.ll"
return
isc
::
eval
::
EvalParser
::
make_RELAY4
(
loc
);
YY_BREAK
case
14
:
YY_RULE_SETUP
#line 14
7
"lexer.ll"
#line 14
9
"lexer.ll"
return
isc
::
eval
::
EvalParser
::
make_SUBSTRING
(
loc
);
YY_BREAK
case
15
:
YY_RULE_SETUP
#line 1
48
"lexer.ll"
#line 1
50
"lexer.ll"
return
isc
::
eval
::
EvalParser
::
make_ALL
(
loc
);
YY_BREAK
case
16
:
YY_RULE_SETUP
#line 1
49
"lexer.ll"
#line 1
51
"lexer.ll"
return
isc
::
eval
::
EvalParser
::
make_CONCAT
(
loc
);
YY_BREAK
case
17
:
YY_RULE_SETUP
#line 15
0
"lexer.ll"
#line 15
2
"lexer.ll"
return
isc
::
eval
::
EvalParser
::
make_NOT
(
loc
);
YY_BREAK
case
18
:
YY_RULE_SETUP
#line 15
1
"lexer.ll"
#line 15
3
"lexer.ll"
return
isc
::
eval
::
EvalParser
::
make_AND
(
loc
);
YY_BREAK
case
19
:
YY_RULE_SETUP
#line 15
2
"lexer.ll"
#line 15
4
"lexer.ll"
return
isc
::
eval
::
EvalParser
::
make_OR
(
loc
);
YY_BREAK
case
20
:
YY_RULE_SETUP
#line 15
3
"lexer.ll"
#line 15
5
"lexer.ll"
return
isc
::
eval
::
EvalParser
::
make_DOT
(
loc
);
YY_BREAK
case
21
:
YY_RULE_SETUP
#line 15
4
"lexer.ll"
#line 15
6
"lexer.ll"
return
isc
::
eval
::
EvalParser
::
make_LPAREN
(
loc
);
YY_BREAK
case
22
:
YY_RULE_SETUP
#line 15
5
"lexer.ll"
#line 15
7
"lexer.ll"
return
isc
::
eval
::
EvalParser
::
make_RPAREN
(
loc
);
YY_BREAK
case
23
:
YY_RULE_SETUP
#line 15
6
"lexer.ll"
#line 15
8
"lexer.ll"
return
isc
::
eval
::
EvalParser
::
make_LBRACKET
(
loc
);
YY_BREAK
case
24
:
YY_RULE_SETUP
#line 15
7
"lexer.ll"
#line 15
9
"lexer.ll"
return
isc
::
eval
::
EvalParser
::
make_RBRACKET
(
loc
);
YY_BREAK
case
25
:
YY_RULE_SETUP
#line 1
58
"lexer.ll"
#line 1
60
"lexer.ll"
return
isc
::
eval
::
EvalParser
::
make_COMA
(
loc
);
YY_BREAK
case
26
:
YY_RULE_SETUP
#line 16
0
"lexer.ll"
#line 16
2
"lexer.ll"
driver
.
error
(
loc
,
"Invalid character: "
+
std
::
string
(
yytext
));
YY_BREAK
case
YY_STATE_EOF
(
INITIAL
):
#line 16
1
"lexer.ll"
#line 16
3
"lexer.ll"
return
isc
::
eval
::
EvalParser
::
make_END
(
loc
);
YY_BREAK
case
27
:
YY_RULE_SETUP
#line 16
2
"lexer.ll"
#line 16
4
"lexer.ll"
ECHO
;
YY_BREAK
#line 131
6
"lexer.cc"
#line 131
8
"lexer.cc"
case
YY_END_OF_BUFFER
:
{
...
...
@@ -2382,7 +2384,7 @@ void yyfree (void * ptr )
/* %ok-for-header */
#line 16
2
"lexer.ll"
#line 16
4
"lexer.ll"
...
...
src/lib/eval/lexer.ll
View file @
55e3be08
...
...
@@ -57,7 +57,8 @@ static isc::eval::location loc;
%option
yylineno
/
*
These
are
not
token
expressions
yet
,
just
convenience
expressions
that
can
be
used
during
actual
token
definitions
.
*
/
can
be
used
during
actual
token
definitions
.
Note
some
can
match
incorrect
inputs
(
e
.
g
.,
IP
addresses
)
which
must
be
checked
.
*
/
int
\-?
[
0-9
]
+
hex
[
0-9
a-fA-F
]
+
blank
[
\t
]
...
...
@@ -129,6 +130,7 @@ addr6 [0-9a-fA-F]*\:[0-9a-fA-F]*\:[0-9a-fA-F:.]*
//
IPv4
or
IPv6
address
std:
:string
tmp
(
yytext
)
;
//
Some
incorrect
addresses
can
match
so
we
have
to
check
.
try
{
isc:
:
asiolink:
:IOAddress
ip
(
tmp
)
;
}
catch
(...)
{
...
...
src/lib/eval/tests/context_unittest.cc
View file @
55e3be08
...
...
@@ -254,7 +254,7 @@ TEST_F(EvalContextTest, ipaddress6) {
checkTokenIpAddress
(
tmp
,
"2001:db8::1"
);
}
// Test the parsing of an IPv4
mapped
IPv6 address
// Test the parsing of an IPv4
compatible
IPv6 address
TEST_F
(
EvalContextTest
,
ipaddress46
)
{
EvalContext
eval
(
Option
::
V6
);
...
...
@@ -282,6 +282,20 @@ TEST_F(EvalContextTest, ipaddress6unspec) {
checkTokenIpAddress
(
tmp
,
"::"
);
}
// Test the parsing of an IPv6 prefix
TEST_F
(
EvalContextTest
,
ipaddress6prefix
)
{
EvalContext
eval
(
Option
::
V6
);
EXPECT_NO_THROW
(
parsed_
=
eval
.
parseString
(
"2001:db8:: == 'foo'"
));
EXPECT_TRUE
(
parsed_
);
ASSERT_EQ
(
3
,
eval
.
expression
.
size
());
TokenPtr
tmp
=
eval
.
expression
.
at
(
0
);
checkTokenIpAddress
(
tmp
,
"2001:db8::"
);
}
// Test the parsing of an equal expression
TEST_F
(
EvalContextTest
,
equal
)
{
...
...
src/lib/eval/tests/token_unittest.cc
View file @
55e3be08
...
...
@@ -286,7 +286,7 @@ TEST_F(TokenTest, hexstring6) {
// This test checks that a TokenIpAddress, representing an IP address as
// a constant string, can be used in Pkt4/Pkt6 evaluation.
// (The actual packet is not used)
TEST_F
(
TokenTest
,
ipaddress
6
)
{
TEST_F
(
TokenTest
,
ipaddress
)
{
TokenPtr
bad4
;
TokenPtr
bad6
;
TokenPtr
ip4
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment