| Kea 3.0.2-git

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