Kea 2.7.5
token.h
Go to the documentation of this file.
1// Copyright (C) 2015-2024 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef TOKEN_H
8#define TOKEN_H
9
11#include <dhcp/pkt.h>
12#include <regex>
13#include <stack>
14
15namespace isc {
16namespace dhcp {
17
18class Token;
19
21typedef boost::shared_ptr<Token> TokenPtr;
22
29typedef std::vector<TokenPtr> Expression;
30
31typedef boost::shared_ptr<Expression> ExpressionPtr;
32
34typedef std::stack<std::string> ValueStack;
35
38class EvalBadStack : public Exception {
39public:
40 EvalBadStack(const char* file, size_t line, const char* what) :
41 isc::Exception(file, line, what) { }
42};
43
46class EvalTypeError : public Exception {
47public:
48 EvalTypeError(const char* file, size_t line, const char* what) :
49 isc::Exception(file, line, what) { }
50};
51
53class EvalBadLabel : public Exception {
54public:
55 EvalBadLabel(const char* file, size_t line, const char* what) :
56 isc::Exception(file, line, what) { }
57};
58
70class Token {
71public:
72
86 virtual unsigned evaluate(Pkt& pkt, ValueStack& values) = 0;
87
89 virtual ~Token() {}
90
94 virtual unsigned getLabel() const {
95 return (0U);
96 }
97
105 static inline bool toBool(std::string value) {
106 if (value == "true") {
107 return (true);
108 } else if (value == "false") {
109 return (false);
110 } else {
111 isc_throw(EvalTypeError, "Incorrect boolean. Expected exactly "
112 "\"false\" or \"true\", got \"" << value << "\"");
113 }
114 }
115};
116
124
129class TokenString : public Token {
130public:
134 TokenString(const std::string& str) : value_(str) {}
135
141 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
142
143protected:
144 std::string value_;
145};
146
151class TokenHexString : public Token {
152public:
158 TokenHexString(const std::string& str);
159
167 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
168
169protected:
170 std::string value_;
171};
172
177class TokenLowerCase : public Token {
178public:
181
188 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
189};
190
195class TokenUpperCase : public Token {
196public:
199
206 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
207};
208
215class TokenInteger : public TokenString {
216public:
223 TokenInteger(const uint32_t value);
224
230 uint32_t getInteger() const {
231 return (int_value_);
232 }
233
234protected:
235 uint32_t int_value_;
236};
237
242class TokenIpAddress : public Token {
243public:
247 TokenIpAddress(const std::string& addr);
248
255 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
256
257protected:
259 std::string value_;
260};
261
267public:
270
277 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
278};
279
284class TokenInt8ToText : public Token {
285public:
288
296 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
297};
298
303class TokenInt16ToText : public Token {
304public:
307
315 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
316};
317
322class TokenInt32ToText : public Token {
323public:
326
334 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
335};
336
341class TokenUInt8ToText : public Token {
342public:
345
353 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
354};
355
360class TokenUInt16ToText : public Token {
361public:
364
372 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
373};
374
379class TokenUInt32ToText : public Token {
380public:
383
391 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
392};
393
403class TokenOption : public Token {
404public:
405
418
426 TokenOption(const uint16_t option_code, const RepresentationType& rep_type)
427 : option_code_(option_code), representation_type_(rep_type) {}
428
438 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
439
446 uint16_t getCode() const {
447 return (option_code_);
448 }
449
459
460protected:
470 virtual OptionPtr getOption(Pkt& pkt);
471
478 virtual std::string pushFailure(ValueStack& values);
479
480 uint16_t option_code_;
482};
483
496public:
497
502 TokenRelay4Option(const uint16_t option_code,
503 const RepresentationType& rep_type);
504
505protected:
509 virtual OptionPtr getOption(Pkt& pkt);
510};
511
528public:
535 TokenRelay6Option(const int8_t nest_level, const uint16_t option_code,
536 const RepresentationType& rep_type)
537 : TokenOption(option_code, rep_type), nest_level_(nest_level) {}
538
546 int8_t getNest() const {
547 return (nest_level_);
548 }
549
550protected:
554 virtual OptionPtr getOption(Pkt& pkt);
555
556 int8_t nest_level_;
557};
558
569class TokenPkt : public Token {
570public:
571
579
581 TokenPkt(const MetadataType type) : type_(type) {}
582
591 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
592
598 return (type_);
599 }
600
601private:
603 MetadataType type_;
604};
605
619class TokenPkt4 : public Token {
620public:
621
634
637 : type_(type) {}
638
649 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
650
656 return (type_);
657 }
658
659private:
661 FieldType type_;
662};
663
674class TokenPkt6 : public Token {
675public:
677 enum FieldType : int {
679 TRANSID
680 };
681
684 : type_(type) {}
685
696 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
697
703 return (type_);
704 }
705
706private:
708 FieldType type_;
709};
710
726class TokenRelay6Field : public Token {
727public:
728
730 enum FieldType : int {
732 LINKADDR
733 };
734
740 TokenRelay6Field(const int8_t nest_level, const FieldType type)
741 : nest_level_(nest_level), type_(type) {}
742
751 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
752
760 int8_t getNest() const {
761 return (nest_level_);
762 }
763
771 return (type_);
772 }
773
774protected:
776 int8_t nest_level_;
778};
779
784class TokenEqual : public Token {
785public:
788
802 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
803};
804
810class TokenSubstring : public Token {
811public:
814
860 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
861};
862
863class TokenSplit : public Token {
864public:
867
905 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
906};
907
913class TokenConcat : public Token {
914public:
917
930 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
931};
932
942class TokenIfElse : public Token {
943public:
946
962 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
963};
964
973class TokenToHexString : public Token {
974public:
977
1002 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
1003};
1004
1009class TokenNot : public Token {
1010public:
1013
1028 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
1029};
1030
1036class TokenAnd : public Token {
1037public:
1040
1056 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
1057};
1058
1064class TokenOr : public Token {
1065public:
1068
1084 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
1085};
1086
1090class TokenMember : public Token {
1091public:
1095 TokenMember(const std::string& client_class)
1096 : client_class_(client_class) {
1097 }
1098
1105 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
1106
1114 return (client_class_);
1115 }
1116
1117protected:
1120};
1121
1136class TokenVendor : public TokenOption {
1137public:
1138
1146
1152 TokenVendor(Option::Universe u, uint32_t vendor_id, FieldType field);
1153
1165 TokenVendor(Option::Universe u, uint32_t vendor_id, RepresentationType repr,
1166 uint16_t option_code = 0);
1167
1173 uint32_t getVendorId() const;
1174
1180 FieldType getField() const;
1181
1205 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
1206
1207protected:
1216 virtual OptionPtr getOption(Pkt& pkt);
1217
1223
1228 uint32_t vendor_id_;
1229
1232};
1233
1252public:
1253
1259 TokenVendorClass(Option::Universe u, uint32_t vendor_id, RepresentationType repr);
1260
1267 TokenVendorClass(Option::Universe u, uint32_t vendor_id, FieldType field,
1268 uint16_t index = 0);
1269
1274 uint16_t getDataIndex() const;
1275
1276protected:
1277
1302 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
1303
1305 uint16_t index_;
1306};
1307
1324class TokenSubOption : public virtual TokenOption {
1325public:
1326
1329
1337 TokenSubOption(const uint16_t option_code,
1338 const uint16_t sub_option_code,
1339 const RepresentationType& rep_type)
1340 : TokenOption(option_code, rep_type), sub_option_code_(sub_option_code) {}
1341
1354 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
1355
1362 uint16_t getSubCode() const {
1363 return (sub_option_code_);
1364 }
1365
1366protected:
1371 virtual OptionPtr getSubOption(const OptionPtr& parent);
1372
1374};
1375
1379class TokenMatch : public Token {
1380public:
1385 TokenMatch(const std::string& reg_exp);
1386
1397 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
1398
1405 const std::string& getRegExp() const {
1406 return (reg_exp_str_);
1407 }
1408
1409private:
1411 std::string reg_exp_str_;
1412
1414 std::regex reg_exp_;
1415};
1416
1421class TokenLabel : public Token {
1422public:
1427 TokenLabel(const unsigned label);
1428
1432 virtual unsigned getLabel() const {
1433 return (label_);
1434 }
1435
1441 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
1442
1443protected:
1444 unsigned label_;
1445};
1446
1451class TokenBranch : public Token {
1452public:
1457 TokenBranch(const unsigned target);
1458
1462 unsigned getTarget() const {
1463 return (target_);
1464 }
1465
1471 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
1472
1473protected:
1474 unsigned target_;
1475};
1476
1482public:
1487 TokenPopOrBranchTrue(const unsigned target);
1488
1498 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
1499};
1500
1506public:
1511 TokenPopOrBranchFalse(const unsigned target);
1512
1522 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
1523};
1524
1532public:
1537 TokenPopAndBranchFalse(const unsigned target);
1538
1548 virtual unsigned evaluate(Pkt& pkt, ValueStack& values);
1549};
1550
1551} // end of isc::dhcp namespace
1552} // end of isc namespace
1553#endif
This is a base class for exceptions thrown from the DNS library module.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
EvalBadLabel is thrown when a label can't be found.
Definition token.h:53
EvalBadLabel(const char *file, size_t line, const char *what)
Definition token.h:55
EvalBadStack is thrown when more or less parameters are on the stack than expected.
Definition token.h:38
EvalBadStack(const char *file, size_t line, const char *what)
Definition token.h:40
EvalTypeError is thrown when a value on the stack has a content with an unexpected type.
Definition token.h:46
EvalTypeError(const char *file, size_t line, const char *what)
Definition token.h:48
Universe
defines option universe DHCPv4 or DHCPv6
Definition option.h:90
Base class for classes representing DHCP messages.
Definition pkt.h:161
Token that represents logical and operator.
Definition token.h:1036
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
Logical and.
Definition token.cc:1089
TokenAnd()
Constructor (does nothing)
Definition token.h:1039
Token that represents unconditional branch.
Definition token.h:1451
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
Only return the target.
Definition token.cc:1527
TokenBranch(const unsigned target)
Constructor.
Definition token.cc:1520
unsigned getTarget() const
Returns branchtarget.
Definition token.h:1462
Token that represents concat operator (concatenates two other tokens)
Definition token.h:913
TokenConcat()
Constructor (does nothing)
Definition token.h:916
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
Concatenate two values.
Definition token.cc:964
Token that represents equality operator (compares two other tokens)
Definition token.h:784
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
Compare two values.
Definition token.cc:749
TokenEqual()
Constructor (does nothing)
Definition token.h:787
Token representing a constant string in hexadecimal format.
Definition token.h:151
std::string value_
Constant value.
Definition token.h:170
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (puts value of the constant string on the stack after decoding or an empty string if...
Definition token.cc:81
TokenHexString(const std::string &str)
Value is set during token construction.
Definition token.cc:52
Token that represents an alternative.
Definition token.h:942
TokenIfElse()
Constructor (does nothing)
Definition token.h:945
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
Alternative.
Definition token.cc:989
Token representing a 16 bit integer as a string.
Definition token.h:303
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (puts value of the string on the stack after decoding)
Definition token.cc:233
TokenInt16ToText()
Constructor (does nothing)
Definition token.h:306
Token representing a 32 bit integer as a string.
Definition token.h:322
TokenInt32ToText()
Constructor (does nothing)
Definition token.h:325
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (puts value of the string on the stack after decoding)
Definition token.cc:266
Token representing an 8 bit integer as a string.
Definition token.h:284
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (puts value of the string on the stack after decoding)
Definition token.cc:201
TokenInt8ToText()
Constructor (does nothing)
Definition token.h:287
Token representing an unsigned 32 bit integer.
Definition token.h:215
TokenInteger(const uint32_t value)
Integer value set during construction.
Definition token.cc:1403
uint32_t getInteger() const
Returns integer value.
Definition token.h:230
uint32_t int_value_
value as integer (stored for testing only)
Definition token.h:235
Token representing an IP address as a string.
Definition token.h:266
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (puts value of the string on the stack after decoding)
Definition token.cc:164
TokenIpAddressToText()
Constructor (does nothing)
Definition token.h:269
Token representing an IP address as a constant string.
Definition token.h:242
std::string value_
< Constant value (empty string if the IP address cannot be converted)
Definition token.h:259
TokenIpAddress(const std::string &addr)
Value is set during token construction.
Definition token.cc:135
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (puts value of the constant string on the stack after decoding)
Definition token.cc:151
Token label i.e.
Definition token.h:1421
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
Does nothing.
Definition token.cc:1516
virtual unsigned getLabel() const
Returns label.
Definition token.h:1432
TokenLabel(const unsigned label)
Constructor.
Definition token.cc:1509
Token representing a constant lower case string.
Definition token.h:177
TokenLowerCase()
Constructor (does nothing)
Definition token.h:180
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (puts value of the evaluated string expression converted to lower case on the stack)
Definition token.cc:94
Token that represents regular expression (regex) matching.
Definition token.h:1379
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
Match regular expression.
Definition token.cc:1482
const std::string & getRegExp() const
Returns regular expression.
Definition token.h:1405
TokenMatch(const std::string &reg_exp)
Constructor.
Definition token.cc:1472
Token that represents client class membership.
Definition token.h:1090
const ClientClass & getClientClass() const
Returns client class name.
Definition token.h:1113
ClientClass client_class_
The client class name.
Definition token.h:1119
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (check if client_class_ was added to packet client classes)
Definition token.cc:1149
TokenMember(const std::string &client_class)
Constructor.
Definition token.h:1095
Token that represents logical negation operator.
Definition token.h:1009
TokenNot()
Constructor (does nothing)
Definition token.h:1012
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
Logical negation.
Definition token.cc:1064
Token that represents a value of an option.
Definition token.h:403
uint16_t getCode() const
Returns option-code.
Definition token.h:446
RepresentationType getRepresentation() const
Returns representation-type.
Definition token.h:456
virtual OptionPtr getOption(Pkt &pkt)
Attempts to retrieve an option.
Definition token.cc:397
RepresentationType representation_type_
Representation type.
Definition token.h:481
uint16_t option_code_
Code of the option to be extracted.
Definition token.h:480
RepresentationType
Token representation type.
Definition token.h:413
TokenOption(const uint16_t option_code, const RepresentationType &rep_type)
Constructor that takes an option code as a parameter.
Definition token.h:426
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
Evaluates the values of the option.
Definition token.cc:402
virtual std::string pushFailure(ValueStack &values)
Auxiliary method that puts string representing a failure.
Definition token.cc:444
Token that represents logical or operator.
Definition token.h:1064
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
Logical or.
Definition token.cc:1119
TokenOr()
Constructor (does nothing)
Definition token.h:1067
Token that represents fields of a DHCPv4 packet.
Definition token.h:619
FieldType getType()
Returns field type.
Definition token.h:655
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
Gets a value from the specified packet.
Definition token.cc:560
FieldType
enum value that determines the field.
Definition token.h:623
@ CIADDR
ciaddr (IPv4 address)
Definition token.h:626
@ HLEN
hlen (hardware address length)
Definition token.h:629
@ HTYPE
htype (hardware address type)
Definition token.h:630
@ GIADDR
giaddr (IPv4 address)
Definition token.h:625
@ CHADDR
chaddr field (up to 16 bytes link-layer address)
Definition token.h:624
@ YIADDR
yiaddr (IPv4 address)
Definition token.h:627
@ SIADDR
siaddr (IPv4 address)
Definition token.h:628
@ TRANSID
transaction-id (xid)
Definition token.h:632
@ MSGTYPE
message type (not really a field, content of option 53)
Definition token.h:631
TokenPkt4(const FieldType type)
Constructor (does nothing)
Definition token.h:636
Token that represents fields of DHCPv6 packet.
Definition token.h:674
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
Gets a value of the specified packet.
Definition token.cc:641
TokenPkt6(const FieldType type)
Constructor (does nothing)
Definition token.h:683
FieldType
enum value that determines the field.
Definition token.h:677
@ TRANSID
transaction id (integer but manipulated as a string)
Definition token.h:679
@ MSGTYPE
msg type
Definition token.h:678
FieldType getType()
Returns field type.
Definition token.h:702
Token that represents meta data of a DHCP packet.
Definition token.h:569
MetadataType
enum value that determines the field.
Definition token.h:573
@ LEN
length (4 octets)
Definition token.h:577
@ DST
destination (IP address)
Definition token.h:576
@ IFACE
interface name (string)
Definition token.h:574
@ SRC
source (IP address)
Definition token.h:575
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
Gets a value from the specified packet.
Definition token.cc:507
MetadataType getType()
Returns metadata type.
Definition token.h:597
TokenPkt(const MetadataType type)
Constructor (does nothing)
Definition token.h:581
Token that represents pop and branch if false.
Definition token.h:1531
TokenPopAndBranchFalse(const unsigned target)
Constructor.
Definition token.cc:1579
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
Pops the top of stack which must be "false" or "true".
Definition token.cc:1584
Token that represents pop or branch if false.
Definition token.h:1505
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
Looks at the top of stack which must be "false" or "true".
Definition token.cc:1561
TokenPopOrBranchFalse(const unsigned target)
Constructor.
Definition token.cc:1556
Token that represents pop or branch if true.
Definition token.h:1481
TokenPopOrBranchTrue(const unsigned target)
Constructor.
Definition token.cc:1533
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
Looks at the top of stack which must be "false" or "true".
Definition token.cc:1538
Represents a sub-option inserted by the DHCPv4 relay.
Definition token.h:495
virtual OptionPtr getOption(Pkt &pkt)
Attempts to obtain specified sub-option of option 82 from the packet.
Definition token.cc:459
TokenRelay4Option(const uint16_t option_code, const RepresentationType &rep_type)
Constructor for extracting sub-option from RAI (option 82)
Definition token.cc:453
Token that represents a value of a field within a DHCPv6 relay encapsulation.
Definition token.h:726
FieldType type_
field to get
Definition token.h:777
FieldType
enum value that determines the field.
Definition token.h:730
@ LINKADDR
Link address field (IPv6 address)
Definition token.h:732
@ PEERADDR
Peer address field (IPv6 address)
Definition token.h:731
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
Extracts the specified field from the requested relay.
Definition token.cc:683
int8_t nest_level_
Specifies field of the DHCPv6 relay option to get.
Definition token.h:776
FieldType getType()
Returns field type.
Definition token.h:770
TokenRelay6Field(const int8_t nest_level, const FieldType type)
Constructor that takes a nesting level and field type as parameters.
Definition token.h:740
int8_t getNest() const
Returns nest-level.
Definition token.h:760
Token that represents a value of an option within a DHCPv6 relay encapsulation.
Definition token.h:527
int8_t nest_level_
nesting level of the relay block to use
Definition token.h:556
int8_t getNest() const
Returns nest-level.
Definition token.h:546
virtual OptionPtr getOption(Pkt &pkt)
Attempts to obtain specified option from the specified relay block.
Definition token.cc:471
TokenRelay6Option(const int8_t nest_level, const uint16_t option_code, const RepresentationType &rep_type)
Constructor that takes a nesting level and an option code as parameters.
Definition token.h:535
TokenSplit()
Constructor (does nothing)
Definition token.h:866
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
Extract a field from a delimited string.
Definition token.cc:876
The order where Token subtypes are declared should be:
Definition token.h:129
std::string value_
Constant value.
Definition token.h:144
TokenString(const std::string &str)
Value is set during token construction.
Definition token.h:134
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (puts value of the constant string on the stack)
Definition token.cc:40
Token that represents sub-options in DHCPv4 and DHCPv6.
Definition token.h:1324
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
This is a method for evaluating a packet.
Definition token.cc:1416
uint16_t sub_option_code_
Code of the sub-option to be extracted.
Definition token.h:1373
uint16_t getSubCode() const
Returns sub-option-code.
Definition token.h:1362
TokenSubOption(const uint16_t option_code, const uint16_t sub_option_code, const RepresentationType &rep_type)
Constructor that takes an option and sub-option codes as parameter.
Definition token.h:1337
virtual OptionPtr getSubOption(const OptionPtr &parent)
Attempts to retrieve a sub-option.
Definition token.cc:1408
Token that represents the substring operator (returns a portion of the supplied string)
Definition token.h:810
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
Extract a substring from a string.
Definition token.cc:776
TokenSubstring()
Constructor (does nothing)
Definition token.h:813
Token that converts to hexadecimal string.
Definition token.h:973
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
Convert a binary value to its hexadecimal string representation.
Definition token.cc:1028
TokenToHexString()
Constructor (does nothing)
Definition token.h:976
Token representing a 16 bit unsigned integer as a string.
Definition token.h:360
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (puts value of the string on the stack after decoding)
Definition token.cc:331
TokenUInt16ToText()
Constructor (does nothing)
Definition token.h:363
Token representing a 32 bit unsigned integer as a string.
Definition token.h:379
TokenUInt32ToText()
Constructor (does nothing)
Definition token.h:382
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (puts value of the string on the stack after decoding)
Definition token.cc:364
Token representing an 8 bit unsigned integer as a string.
Definition token.h:341
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (puts value of the string on the stack after decoding)
Definition token.cc:299
TokenUInt8ToText()
Constructor (does nothing)
Definition token.h:344
Token representing a constant upper case string.
Definition token.h:195
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (puts value of the evaluated string expression converted to upper case on the stack)
Definition token.cc:115
TokenUpperCase()
Constructor (does nothing)
Definition token.h:198
Token that represents vendor class options in DHCPv4 and DHCPv6.
Definition token.h:1251
TokenVendorClass(Option::Universe u, uint32_t vendor_id, RepresentationType repr)
This constructor is used to access fields.
Definition token.cc:1286
uint16_t getDataIndex() const
Returns data index.
Definition token.cc:1298
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
This is a method for evaluating a packet.
Definition token.cc:1303
uint16_t index_
Data chunk index.
Definition token.h:1305
Token that represents vendor options in DHCPv4 and DHCPv6.
Definition token.h:1136
Option::Universe universe_
Universe (V4 or V6)
Definition token.h:1222
uint32_t vendor_id_
Enterprise-id value.
Definition token.h:1228
FieldType field_
Specifies which field should be accessed.
Definition token.h:1231
uint32_t getVendorId() const
Returns enterprise-id.
Definition token.cc:1180
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)
This is a method for evaluating a packet.
Definition token.cc:1190
TokenVendor(Option::Universe u, uint32_t vendor_id, FieldType field)
Constructor used for accessing a field.
Definition token.cc:1171
virtual OptionPtr getOption(Pkt &pkt)
Attempts to get a suboption.
Definition token.cc:1264
FieldType
Specifies a field of the vendor option.
Definition token.h:1140
@ DATA
data chunk, used in derived vendor-class only
Definition token.h:1144
@ EXISTS
vendor[123].exists
Definition token.h:1143
@ ENTERPRISE_ID
enterprise-id field (vendor-info, vendor-class)
Definition token.h:1142
@ SUBOPTION
If this token fetches a suboption, not a field.
Definition token.h:1141
FieldType getField() const
Returns field.
Definition token.cc:1185
Base class for all tokens.
Definition token.h:70
virtual unsigned getLabel() const
Return the label of this token.
Definition token.h:94
virtual ~Token()
Virtual destructor.
Definition token.h:89
static bool toBool(std::string value)
Coverts a (string) value to a boolean.
Definition token.h:105
virtual unsigned evaluate(Pkt &pkt, ValueStack &values)=0
This is a generic method for evaluating a packet.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
std::string ClientClass
Defines a single class name.
Definition classify.h:42
boost::shared_ptr< Token > TokenPtr
Pointer to a single Token.
Definition token.h:21
boost::shared_ptr< Expression > ExpressionPtr
Definition token.h:31
std::vector< TokenPtr > Expression
This is a structure that holds an expression converted to RPN.
Definition token.h:29
boost::shared_ptr< Option > OptionPtr
Definition option.h:37
std::stack< std::string > ValueStack
Evaluated values are stored as a stack of strings.
Definition token.h:34
Defines the logger used by the top-level component of kea-lfc.