Kea: token.h Source File

| Kea 2.2.0

token.h
Go to the documentation of this file.
1// Copyright (C) 2015-2022 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 <stack>
13
14namespace isc {
15namespace dhcp {
16
17class Token;
18
20 typedef boost::shared_ptr<Token> TokenPtr;
21
28 typedef std::vector<TokenPtr> Expression;
29
30 typedef boost::shared_ptr<Expression> ExpressionPtr;
31
33 typedef std::stack<std::string> ValueStack;
34
37 class EvalBadStack : public Exception {
38public:
39 EvalBadStack(const char* file, size_t line, const char* what) :
40 isc::Exception(file, line, what) { };
41};
42
45 class EvalTypeError : public Exception {
46public:
47 EvalTypeError(const char* file, size_t line, const char* what) :
48 isc::Exception(file, line, what) { };
49};
50
51
63 class Token {
64public:
65
78 virtual void evaluate(Pkt& pkt, ValueStack& values) = 0;
79
81 virtual ~Token() {}
82
90 static inline bool toBool(std::string value) {
91 if (value == "true") {
92 return (true);
93 } else if (value == "false") {
94 return (false);
95 } else {
96 isc_throw(EvalTypeError, "Incorrect boolean. Expected exactly "
97 "\"false\" or \"true\", got \"" << value << "\"");
98 }
99 }
100};
101
109
114 class TokenString : public Token {
115public:
119 TokenString(const std::string& str)
120 :value_(str){
121 }
122
127 void evaluate(Pkt& pkt, ValueStack& values);
128
129protected:
130 std::string value_;
131};
132
137 class TokenHexString : public Token {
138public:
144 TokenHexString(const std::string& str);
145
152 void evaluate(Pkt& pkt, ValueStack& values);
153
154protected:
155 std::string value_;
156};
157
164 class TokenInteger : public TokenString {
165public:
172 TokenInteger(const uint32_t value);
173
179 uint32_t getInteger() const {
180 return (int_value_);
181 }
182
183protected:
184 uint32_t int_value_;
185};
186
191 class TokenIpAddress : public Token {
192public:
196 TokenIpAddress(const std::string& addr);
197
203 void evaluate(Pkt& pkt, ValueStack& values);
204
205protected:
207 std::string value_;
208};
209
214 class TokenIpAddressToText : public Token {
215public:
217 TokenIpAddressToText() {}
218
224 void evaluate(Pkt& pkt, ValueStack& values);
225};
226
231 class TokenInt8ToText : public Token {
232public:
234 TokenInt8ToText() {}
235
242 void evaluate(Pkt& pkt, ValueStack& values);
243};
244
249 class TokenInt16ToText : public Token {
250public:
252 TokenInt16ToText() {}
253
260 void evaluate(Pkt& pkt, ValueStack& values);
261};
262
267 class TokenInt32ToText : public Token {
268public:
270 TokenInt32ToText() {}
271
278 void evaluate(Pkt& pkt, ValueStack& values);
279};
280
285 class TokenUInt8ToText : public Token {
286public:
288 TokenUInt8ToText() {}
289
296 void evaluate(Pkt& pkt, ValueStack& values);
297};
298
303 class TokenUInt16ToText : public Token {
304public:
306 TokenUInt16ToText() {}
307
314 void evaluate(Pkt& pkt, ValueStack& values);
315};
316
321 class TokenUInt32ToText : public Token {
322public:
324 TokenUInt32ToText() {}
325
332 void evaluate(Pkt& pkt, ValueStack& values);
333};
334
344 class TokenOption : public Token {
345public:
346
354 enum RepresentationType {
355 TEXTUAL,
356 HEXADECIMAL,
357 EXISTS
358 };
359
367 TokenOption(const uint16_t option_code, const RepresentationType& rep_type)
368 : option_code_(option_code), representation_type_(rep_type) {}
369
378 void evaluate(Pkt& pkt, ValueStack& values);
379
386 uint16_t getCode() const {
387 return (option_code_);
388 }
389
396 RepresentationType getRepresentation() const {
397 return (representation_type_);
398 }
399
400protected:
410 virtual OptionPtr getOption(Pkt& pkt);
411
418 virtual std::string pushFailure(ValueStack& values);
419
420 uint16_t option_code_;
421 RepresentationType representation_type_;
422};
423
435 class TokenRelay4Option : public TokenOption {
436public:
437
442 TokenRelay4Option(const uint16_t option_code,
443 const RepresentationType& rep_type);
444
445protected:
449 virtual OptionPtr getOption(Pkt& pkt);
450};
451
467 class TokenRelay6Option : public TokenOption {
468public:
475 TokenRelay6Option(const int8_t nest_level, const uint16_t option_code,
476 const RepresentationType& rep_type)
477 :TokenOption(option_code, rep_type), nest_level_(nest_level) {}
478
486 int8_t getNest() const {
487 return (nest_level_);
488 }
489
490protected:
494 virtual OptionPtr getOption(Pkt& pkt);
495
496 int8_t nest_level_;
497};
498
509 class TokenPkt : public Token {
510public:
511
513 enum MetadataType {
514 IFACE,
515 SRC,
516 DST,
517 LEN
518 };
519
521 TokenPkt(const MetadataType type)
522 : type_(type) {}
523
531 void evaluate(Pkt& pkt, ValueStack& values);
532
537 MetadataType getType() {
538 return (type_);
539 }
540
541private:
543 MetadataType type_;
544};
545
559 class TokenPkt4 : public Token {
560public:
561
563 enum FieldType {
564 CHADDR,
565 GIADDR,
566 CIADDR,
567 YIADDR,
568 SIADDR,
569 HLEN,
570 HTYPE,
571 MSGTYPE,
572 TRANSID,
573 };
574
576 TokenPkt4(const FieldType type)
577 : type_(type) {}
578
588 void evaluate(Pkt& pkt, ValueStack& values);
589
594 FieldType getType() {
595 return (type_);
596 }
597
598private:
600 FieldType type_;
601};
602
613 class TokenPkt6 : public Token {
614public:
616 enum FieldType {
617 MSGTYPE,
618 TRANSID
619 };
620
622 TokenPkt6(const FieldType type)
623 : type_(type) {}
624
634 void evaluate(Pkt& pkt, ValueStack& values);
635
640 FieldType getType() {
641 return(type_);
642 }
643
644private:
646 FieldType type_;
647};
648
664 class TokenRelay6Field : public Token {
665public:
666
668 enum FieldType {
669 PEERADDR,
670 LINKADDR
671 };
672
678 TokenRelay6Field(const int8_t nest_level, const FieldType type)
679 : nest_level_(nest_level), type_(type) {}
680
688 void evaluate(Pkt& pkt, ValueStack& values);
689
697 int8_t getNest() const {
698 return (nest_level_);
699 }
700
707 FieldType getType() {
708 return (type_);
709 }
710
711protected:
713 int8_t nest_level_;
714 FieldType type_;
715};
716
721 class TokenEqual : public Token {
722public:
724 TokenEqual() {}
725
738 void evaluate(Pkt& pkt, ValueStack& values);
739};
740
746 class TokenSubstring : public Token {
747public:
749 TokenSubstring() {}
750
795 void evaluate(Pkt& pkt, ValueStack& values);
796};
797
798 class TokenSplit : public Token {
799public:
801 TokenSplit() {}
802
839 void evaluate(Pkt& pkt, ValueStack& values);
840};
841
847 class TokenConcat : public Token {
848public:
850 TokenConcat() {}
851
863 void evaluate(Pkt& pkt, ValueStack& values);
864};
865
875 class TokenIfElse : public Token {
876public:
878 TokenIfElse() { }
879
894 void evaluate(Pkt& pkt, ValueStack& values);
895};
896
905 class TokenToHexString : public Token {
906public:
908 TokenToHexString() { }
909
933 void evaluate(Pkt& pkt, ValueStack& values);
934};
935
940 class TokenNot : public Token {
941public:
943 TokenNot() {}
944
958 void evaluate(Pkt& pkt, ValueStack& values);
959};
960
964 class TokenAnd : public Token {
965public:
967 TokenAnd() {}
968
983 void evaluate(Pkt& pkt, ValueStack& values);
984};
985
989 class TokenOr : public Token {
990public:
992 TokenOr() {}
993
1008 void evaluate(Pkt& pkt, ValueStack& values);
1009};
1010
1014 class TokenMember : public Token {
1015public:
1019 TokenMember(const std::string& client_class)
1020 :client_class_(client_class){
1021 }
1022
1028 void evaluate(Pkt& pkt, ValueStack& values);
1029
1036 const ClientClass& getClientClass() const {
1037 return (client_class_);
1038 }
1039
1040protected:
1042 ClientClass client_class_;
1043};
1044
1059 class TokenVendor : public TokenOption {
1060public:
1061
1063 enum FieldType {
1064 SUBOPTION,
1065 ENTERPRISE_ID,
1066 EXISTS,
1067 DATA
1068 };
1069
1075 TokenVendor(Option::Universe u, uint32_t vendor_id, FieldType field);
1076
1077
1089 TokenVendor(Option::Universe u, uint32_t vendor_id, RepresentationType repr,
1090 uint16_t option_code = 0);
1091
1097 uint32_t getVendorId() const;
1098
1104 FieldType getField() const;
1105
1128 virtual void evaluate(Pkt& pkt, ValueStack& values);
1129
1130protected:
1139 virtual OptionPtr getOption(Pkt& pkt);
1140
1145 Option::Universe universe_;
1146
1151 uint32_t vendor_id_;
1152
1154 FieldType field_;
1155};
1156
1174 class TokenVendorClass : public TokenVendor {
1175public:
1176
1182 TokenVendorClass(Option::Universe u, uint32_t vendor_id, RepresentationType repr);
1183
1190 TokenVendorClass(Option::Universe u, uint32_t vendor_id, FieldType field,
1191 uint16_t index = 0);
1192
1197 uint16_t getDataIndex() const;
1198
1199protected:
1200
1224 void evaluate(Pkt& pkt, ValueStack& values);
1225
1227 uint16_t index_;
1228};
1229
1246 class TokenSubOption : public virtual TokenOption {
1247public:
1248
1251
1259 TokenSubOption(const uint16_t option_code,
1260 const uint16_t sub_option_code,
1261 const RepresentationType& rep_type)
1262 : TokenOption(option_code, rep_type), sub_option_code_(sub_option_code) {}
1263
1275 virtual void evaluate(Pkt& pkt, ValueStack& values);
1276
1283 uint16_t getSubCode() const {
1284 return (sub_option_code_);
1285 }
1286
1287protected:
1292 virtual OptionPtr getSubOption(const OptionPtr& parent);
1293
1294 uint16_t sub_option_code_;
1295};
1296
1297} // end of isc::dhcp namespace
1298} // end of isc namespace
1299
1300#endif
isc::Exception
This is a base class for exceptions thrown from the DNS library module.
Definition: exceptions/exceptions.h:23
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::EvalBadStack
EvalBadStack is thrown when more or less parameters are on the stack than expected.
Definition: token.h:37
isc::dhcp::EvalBadStack::EvalBadStack
EvalBadStack(const char *file, size_t line, const char *what)
Definition: token.h:39
isc::dhcp::EvalTypeError
EvalTypeError is thrown when a value on the stack has a content with an unexpected type.
Definition: token.h:45
isc::dhcp::EvalTypeError::EvalTypeError
EvalTypeError(const char *file, size_t line, const char *what)
Definition: token.h:47
isc::dhcp::Option::Universe
Universe
defines option universe DHCPv4 or DHCPv6
Definition: option.h:83
isc::dhcp::Pkt
Base class for classes representing DHCP messages.
Definition: pkt.h:90
isc::dhcp::TokenAnd
Token that represents logical and operator.
Definition: token.h:964
isc::dhcp::TokenAnd::evaluate
void evaluate(Pkt &pkt, ValueStack &values)
Logical and.
Definition: token.cc:977
isc::dhcp::TokenAnd::TokenAnd
TokenAnd()
Constructor (does nothing)
Definition: token.h:967
isc::dhcp::TokenConcat
Token that represents concat operator (concatenates two other tokens)
Definition: token.h:847
isc::dhcp::TokenConcat::evaluate
void evaluate(Pkt &pkt, ValueStack &values)
Concatenate two values.
Definition: token.cc:865
isc::dhcp::TokenConcat::TokenConcat
TokenConcat()
Constructor (does nothing)
Definition: token.h:850
isc::dhcp::TokenEqual
Token that represents equality operator (compares two other tokens)
Definition: token.h:721
isc::dhcp::TokenEqual::evaluate
void evaluate(Pkt &pkt, ValueStack &values)
Compare two values.
Definition: token.cc:664
isc::dhcp::TokenEqual::TokenEqual
TokenEqual()
Constructor (does nothing)
Definition: token.h:724
isc::dhcp::TokenHexString
Token representing a constant string in hexadecimal format.
Definition: token.h:137
isc::dhcp::TokenHexString::evaluate
void 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:77
isc::dhcp::TokenHexString::value_
std::string value_
Constant value.
Definition: token.h:155
isc::dhcp::TokenHexString::TokenHexString
TokenHexString(const std::string &str)
Value is set during token construction.
Definition: token.cc:48
isc::dhcp::TokenIfElse
Token that represents an alternative.
Definition: token.h:875
isc::dhcp::TokenIfElse::TokenIfElse
TokenIfElse()
Constructor (does nothing)
Definition: token.h:878
isc::dhcp::TokenIfElse::evaluate
void evaluate(Pkt &pkt, ValueStack &values)
Alternative.
Definition: token.cc:887
isc::dhcp::TokenInt16ToText
Token representing a 16 bit integer as a string.
Definition: token.h:249
isc::dhcp::TokenInt16ToText::TokenInt16ToText
TokenInt16ToText()
Constructor (does nothing)
Definition: token.h:252
isc::dhcp::TokenInt16ToText::evaluate
void evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (puts value of the string on the stack after decoding)
Definition: token.cc:175
isc::dhcp::TokenInt32ToText
Token representing a 32 bit integer as a string.
Definition: token.h:267
isc::dhcp::TokenInt32ToText::TokenInt32ToText
TokenInt32ToText()
Constructor (does nothing)
Definition: token.h:270
isc::dhcp::TokenInt32ToText::evaluate
void evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (puts value of the string on the stack after decoding)
Definition: token.cc:206
isc::dhcp::TokenInt8ToText
Token representing an 8 bit integer as a string.
Definition: token.h:231
isc::dhcp::TokenInt8ToText::evaluate
void evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (puts value of the string on the stack after decoding)
Definition: token.cc:146
isc::dhcp::TokenInt8ToText::TokenInt8ToText
TokenInt8ToText()
Constructor (does nothing)
Definition: token.h:234
isc::dhcp::TokenInteger
Token representing an unsigned 32 bit integer.
Definition: token.h:164
isc::dhcp::TokenInteger::TokenInteger
TokenInteger(const uint32_t value)
Integer value set during construction.
Definition: token.cc:1263
isc::dhcp::TokenInteger::getInteger
uint32_t getInteger() const
Returns integer value.
Definition: token.h:179
isc::dhcp::TokenInteger::int_value_
uint32_t int_value_
value as integer (stored for testing only)
Definition: token.h:184
isc::dhcp::TokenIpAddressToText
Token representing an IP address as a string.
Definition: token.h:214
isc::dhcp::TokenIpAddressToText::TokenIpAddressToText
TokenIpAddressToText()
Constructor (does nothing)
Definition: token.h:217
isc::dhcp::TokenIpAddressToText::evaluate
void evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (puts value of the string on the stack after decoding)
Definition: token.cc:112
isc::dhcp::TokenIpAddress
Token representing an IP address as a constant string.
Definition: token.h:191
isc::dhcp::TokenIpAddress::evaluate
void evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (puts value of the constant string on the stack after decoding)
Definition: token.cc:102
isc::dhcp::TokenIpAddress::value_
std::string value_
< Constant value (empty string if the IP address cannot be converted)
Definition: token.h:207
isc::dhcp::TokenIpAddress::TokenIpAddress
TokenIpAddress(const std::string &addr)
Value is set during token construction.
Definition: token.cc:86
isc::dhcp::TokenMember
Token that represents client class membership.
Definition: token.h:1014
isc::dhcp::TokenMember::getClientClass
const ClientClass & getClientClass() const
Returns client class name.
Definition: token.h:1036
isc::dhcp::TokenMember::client_class_
ClientClass client_class_
The client class name.
Definition: token.h:1042
isc::dhcp::TokenMember::evaluate
void evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (check if client_class_ was added to packet client classes)
Definition: token.cc:1031
isc::dhcp::TokenMember::TokenMember
TokenMember(const std::string &client_class)
Constructor.
Definition: token.h:1019
isc::dhcp::TokenNot
Token that represents logical negation operator.
Definition: token.h:940
isc::dhcp::TokenNot::TokenNot
TokenNot()
Constructor (does nothing)
Definition: token.h:943
isc::dhcp::TokenNot::evaluate
void evaluate(Pkt &pkt, ValueStack &values)
Logical negation.
Definition: token.cc:955
isc::dhcp::TokenOption
Token that represents a value of an option.
Definition: token.h:344
isc::dhcp::TokenOption::getCode
uint16_t getCode() const
Returns option-code.
Definition: token.h:386
isc::dhcp::TokenOption::getRepresentation
RepresentationType getRepresentation() const
Returns representation-type.
Definition: token.h:396
isc::dhcp::TokenOption::getOption
virtual OptionPtr getOption(Pkt &pkt)
Attempts to retrieve an option.
Definition: token.cc:328
isc::dhcp::TokenOption::evaluate
void evaluate(Pkt &pkt, ValueStack &values)
Evaluates the values of the option.
Definition: token.cc:333
isc::dhcp::TokenOption::representation_type_
RepresentationType representation_type_
Representation type.
Definition: token.h:421
isc::dhcp::TokenOption::option_code_
uint16_t option_code_
Code of the option to be extracted.
Definition: token.h:420
isc::dhcp::TokenOption::RepresentationType
RepresentationType
Token representation type.
Definition: token.h:354
isc::dhcp::TokenOption::HEXADECIMAL
@ HEXADECIMAL
Definition: token.h:356
isc::dhcp::TokenOption::EXISTS
@ EXISTS
Definition: token.h:357
isc::dhcp::TokenOption::TEXTUAL
@ TEXTUAL
Definition: token.h:355
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:367
isc::dhcp::TokenOption::pushFailure
virtual std::string pushFailure(ValueStack &values)
Auxiliary method that puts string representing a failure.
Definition: token.cc:371
isc::dhcp::TokenOr
Token that represents logical or operator.
Definition: token.h:989
isc::dhcp::TokenOr::evaluate
void evaluate(Pkt &pkt, ValueStack &values)
Logical or.
Definition: token.cc:1004
isc::dhcp::TokenOr::TokenOr
TokenOr()
Constructor (does nothing)
Definition: token.h:992
isc::dhcp::TokenPkt4
Token that represents fields of a DHCPv4 packet.
Definition: token.h:559
isc::dhcp::TokenPkt4::getType
FieldType getType()
Returns field type.
Definition: token.h:594
isc::dhcp::TokenPkt4::FieldType
FieldType
enum value that determines the field.
Definition: token.h:563
isc::dhcp::TokenPkt4::CIADDR
@ CIADDR
ciaddr (IPv4 address)
Definition: token.h:566
isc::dhcp::TokenPkt4::HLEN
@ HLEN
hlen (hardware address length)
Definition: token.h:569
isc::dhcp::TokenPkt4::HTYPE
@ HTYPE
htype (hardware address type)
Definition: token.h:570
isc::dhcp::TokenPkt4::GIADDR
@ GIADDR
giaddr (IPv4 address)
Definition: token.h:565
isc::dhcp::TokenPkt4::CHADDR
@ CHADDR
chaddr field (up to 16 bytes link-layer address)
Definition: token.h:564
isc::dhcp::TokenPkt4::YIADDR
@ YIADDR
yiaddr (IPv4 address)
Definition: token.h:567
isc::dhcp::TokenPkt4::SIADDR
@ SIADDR
siaddr (IPv4 address)
Definition: token.h:568
isc::dhcp::TokenPkt4::TRANSID
@ TRANSID
transaction-id (xid)
Definition: token.h:572
isc::dhcp::TokenPkt4::MSGTYPE
@ MSGTYPE
message type (not really a field, content of option 53)
Definition: token.h:571
isc::dhcp::TokenPkt4::evaluate
void evaluate(Pkt &pkt, ValueStack &values)
Gets a value from the specified packet.
Definition: token.cc:483
isc::dhcp::TokenPkt4::TokenPkt4
TokenPkt4(const FieldType type)
Constructor (does nothing)
Definition: token.h:576
isc::dhcp::TokenPkt6
Token that represents fields of DHCPv6 packet.
Definition: token.h:613
isc::dhcp::TokenPkt6::TokenPkt6
TokenPkt6(const FieldType type)
Constructor (does nothing)
Definition: token.h:622
isc::dhcp::TokenPkt6::evaluate
void evaluate(Pkt &pkt, ValueStack &values)
Gets a value of the specified packet.
Definition: token.cc:562
isc::dhcp::TokenPkt6::getType
FieldType getType()
Returns field type.
Definition: token.h:640
isc::dhcp::TokenPkt6::FieldType
FieldType
enum value that determines the field.
Definition: token.h:616
isc::dhcp::TokenPkt6::TRANSID
@ TRANSID
transaction id (integer but manipulated as a string)
Definition: token.h:618
isc::dhcp::TokenPkt6::MSGTYPE
@ MSGTYPE
msg type
Definition: token.h:617
isc::dhcp::TokenPkt
Token that represents meta data of a DHCP packet.
Definition: token.h:509
isc::dhcp::TokenPkt::MetadataType
MetadataType
enum value that determines the field.
Definition: token.h:513
isc::dhcp::TokenPkt::LEN
@ LEN
length (4 octets)
Definition: token.h:517
isc::dhcp::TokenPkt::DST
@ DST
destination (IP address)
Definition: token.h:516
isc::dhcp::TokenPkt::IFACE
@ IFACE
interface name (string)
Definition: token.h:514
isc::dhcp::TokenPkt::SRC
@ SRC
source (IP address)
Definition: token.h:515
isc::dhcp::TokenPkt::getType
MetadataType getType()
Returns metadata type.
Definition: token.h:537
isc::dhcp::TokenPkt::evaluate
void evaluate(Pkt &pkt, ValueStack &values)
Gets a value from the specified packet.
Definition: token.cc:432
isc::dhcp::TokenPkt::TokenPkt
TokenPkt(const MetadataType type)
Constructor (does nothing)
Definition: token.h:521
isc::dhcp::TokenRelay4Option
Represents a sub-option inserted by the DHCPv4 relay.
Definition: token.h:435
isc::dhcp::TokenRelay4Option::getOption
virtual OptionPtr getOption(Pkt &pkt)
Attempts to obtain specified sub-option of option 82 from the packet.
Definition: token.cc:385
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:380
isc::dhcp::TokenRelay6Field
Token that represents a value of a field within a DHCPv6 relay encapsulation.
Definition: token.h:664
isc::dhcp::TokenRelay6Field::type_
FieldType type_
field to get
Definition: token.h:714
isc::dhcp::TokenRelay6Field::evaluate
void evaluate(Pkt &pkt, ValueStack &values)
Extracts the specified field from the requested relay.
Definition: token.cc:602
isc::dhcp::TokenRelay6Field::FieldType
FieldType
enum value that determines the field.
Definition: token.h:668
isc::dhcp::TokenRelay6Field::LINKADDR
@ LINKADDR
Link address field (IPv6 address)
Definition: token.h:670
isc::dhcp::TokenRelay6Field::PEERADDR
@ PEERADDR
Peer address field (IPv6 address)
Definition: token.h:669
isc::dhcp::TokenRelay6Field::nest_level_
int8_t nest_level_
Specifies field of the DHCPv6 relay option to get.
Definition: token.h:713
isc::dhcp::TokenRelay6Field::getType
FieldType getType()
Returns field type.
Definition: token.h:707
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:678
isc::dhcp::TokenRelay6Field::getNest
int8_t getNest() const
Returns nest-level.
Definition: token.h:697
isc::dhcp::TokenRelay6Option
Token that represents a value of an option within a DHCPv6 relay encapsulation.
Definition: token.h:467
isc::dhcp::TokenRelay6Option::nest_level_
int8_t nest_level_
nesting level of the relay block to use
Definition: token.h:496
isc::dhcp::TokenRelay6Option::getNest
int8_t getNest() const
Returns nest-level.
Definition: token.h:486
isc::dhcp::TokenRelay6Option::getOption
virtual OptionPtr getOption(Pkt &pkt)
Attempts to obtain specified option from the specified relay block.
Definition: token.cc:396
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:475
isc::dhcp::TokenSplit
Definition: token.h:798
isc::dhcp::TokenSplit::TokenSplit
TokenSplit()
Constructor (does nothing)
Definition: token.h:801
isc::dhcp::TokenSplit::evaluate
void evaluate(Pkt &pkt, ValueStack &values)
Extract a field from a delimited string.
Definition: token.cc:783
isc::dhcp::TokenString
The order where Token subtypes are declared should be:
Definition: token.h:114
isc::dhcp::TokenString::value_
std::string value_
Constant value.
Definition: token.h:130
isc::dhcp::TokenString::TokenString
TokenString(const std::string &str)
Value is set during token construction.
Definition: token.h:119
isc::dhcp::TokenString::evaluate
void evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (puts value of the constant string on the stack)
Definition: token.cc:39
isc::dhcp::TokenSubOption
Token that represents sub-options in DHCPv4 and DHCPv6.
Definition: token.h:1246
isc::dhcp::TokenSubOption::evaluate
virtual void evaluate(Pkt &pkt, ValueStack &values)
This is a method for evaluating a packet.
Definition: token.cc:1276
isc::dhcp::TokenSubOption::sub_option_code_
uint16_t sub_option_code_
Code of the sub-option to be extracted.
Definition: token.h:1294
isc::dhcp::TokenSubOption::getSubCode
uint16_t getSubCode() const
Returns sub-option-code.
Definition: token.h:1283
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:1259
isc::dhcp::TokenSubOption::getSubOption
virtual OptionPtr getSubOption(const OptionPtr &parent)
Attempts to retrieve a sub-option.
Definition: token.cc:1268
isc::dhcp::TokenSubstring
Token that represents the substring operator (returns a portion of the supplied string)
Definition: token.h:746
isc::dhcp::TokenSubstring::evaluate
void evaluate(Pkt &pkt, ValueStack &values)
Extract a substring from a string.
Definition: token.cc:688
isc::dhcp::TokenSubstring::TokenSubstring
TokenSubstring()
Constructor (does nothing)
Definition: token.h:749
isc::dhcp::TokenToHexString
Token that converts to hexadecimal string.
Definition: token.h:905
isc::dhcp::TokenToHexString::TokenToHexString
TokenToHexString()
Constructor (does nothing)
Definition: token.h:908
isc::dhcp::TokenToHexString::evaluate
void evaluate(Pkt &pkt, ValueStack &values)
Convert a binary value to its hexadecimal string representation.
Definition: token.cc:922
isc::dhcp::TokenUInt16ToText
Token representing a 16 bit unsigned integer as a string.
Definition: token.h:303
isc::dhcp::TokenUInt16ToText::evaluate
void evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (puts value of the string on the stack after decoding)
Definition: token.cc:266
isc::dhcp::TokenUInt16ToText::TokenUInt16ToText
TokenUInt16ToText()
Constructor (does nothing)
Definition: token.h:306
isc::dhcp::TokenUInt32ToText
Token representing a 32 bit unsigned integer as a string.
Definition: token.h:321
isc::dhcp::TokenUInt32ToText::TokenUInt32ToText
TokenUInt32ToText()
Constructor (does nothing)
Definition: token.h:324
isc::dhcp::TokenUInt32ToText::evaluate
void evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (puts value of the string on the stack after decoding)
Definition: token.cc:297
isc::dhcp::TokenUInt8ToText
Token representing an 8 bit unsigned integer as a string.
Definition: token.h:285
isc::dhcp::TokenUInt8ToText::TokenUInt8ToText
TokenUInt8ToText()
Constructor (does nothing)
Definition: token.h:288
isc::dhcp::TokenUInt8ToText::evaluate
void evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (puts value of the string on the stack after decoding)
Definition: token.cc:237
isc::dhcp::TokenVendorClass
Token that represents vendor class options in DHCPv4 and DHCPv6.
Definition: token.h:1174
isc::dhcp::TokenVendorClass::TokenVendorClass
TokenVendorClass(Option::Universe u, uint32_t vendor_id, RepresentationType repr)
This constructor is used to access fields.
Definition: token.cc:1156
isc::dhcp::TokenVendorClass::getDataIndex
uint16_t getDataIndex() const
Returns data index.
Definition: token.cc:1167
isc::dhcp::TokenVendorClass::index_
uint16_t index_
Data chunk index.
Definition: token.h:1227
isc::dhcp::TokenVendorClass::evaluate
void evaluate(Pkt &pkt, ValueStack &values)
This is a method for evaluating a packet.
Definition: token.cc:1171
isc::dhcp::TokenVendor
Token that represents vendor options in DHCPv4 and DHCPv6.
Definition: token.h:1059
isc::dhcp::TokenVendor::FieldType
FieldType
Specifies a field of the vendor option.
Definition: token.h:1063
isc::dhcp::TokenVendor::DATA
@ DATA
data chunk, used in derived vendor-class only
Definition: token.h:1067
isc::dhcp::TokenVendor::EXISTS
@ EXISTS
vendor[123].exists
Definition: token.h:1066
isc::dhcp::TokenVendor::ENTERPRISE_ID
@ ENTERPRISE_ID
enterprise-id field (vendor-info, vendor-class)
Definition: token.h:1065
isc::dhcp::TokenVendor::SUBOPTION
@ SUBOPTION
If this token fetches a suboption, not a field.
Definition: token.h:1064
isc::dhcp::TokenVendor::universe_
Option::Universe universe_
Universe (V4 or V6)
Definition: token.h:1145
isc::dhcp::TokenVendor::vendor_id_
uint32_t vendor_id_
Enterprise-id value.
Definition: token.h:1151
isc::dhcp::TokenVendor::field_
FieldType field_
Specifies which field should be accessed.
Definition: token.h:1154
isc::dhcp::TokenVendor::getVendorId
uint32_t getVendorId() const
Returns enterprise-id.
Definition: token.cc:1058
isc::dhcp::TokenVendor::TokenVendor
TokenVendor(Option::Universe u, uint32_t vendor_id, FieldType field)
Constructor used for accessing a field.
Definition: token.cc:1050
isc::dhcp::TokenVendor::getOption
virtual OptionPtr getOption(Pkt &pkt)
Attempts to get a suboption.
Definition: token.cc:1134
isc::dhcp::TokenVendor::evaluate
virtual void evaluate(Pkt &pkt, ValueStack &values)
This is a method for evaluating a packet.
Definition: token.cc:1066
isc::dhcp::TokenVendor::getField
FieldType getField() const
Returns field.
Definition: token.cc:1062
isc::dhcp::Token
Base class for all tokens.
Definition: token.h:63
isc::dhcp::Token::evaluate
virtual void evaluate(Pkt &pkt, ValueStack &values)=0
This is a generic method for evaluating a packet.
isc::dhcp::Token::~Token
virtual ~Token()
Virtual destructor.
Definition: token.h:81
isc::dhcp::Token::toBool
static bool toBool(std::string value)
Coverts a (string) value to a boolean.
Definition: token.h:90
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::ClientClass
std::string ClientClass
Defines a single class name.
Definition: classify.h:42
isc::dhcp::TokenPtr
boost::shared_ptr< Token > TokenPtr
Pointer to a single Token.
Definition: token.h:17
isc::dhcp::ExpressionPtr
boost::shared_ptr< Expression > ExpressionPtr
Definition: token.h:30
isc::dhcp::Expression
std::vector< TokenPtr > Expression
This is a structure that holds an expression converted to RPN.
Definition: token.h:28
isc::dhcp::OptionPtr
boost::shared_ptr< Option > OptionPtr
Definition: option.h:36
isc::dhcp::ValueStack
std::stack< std::string > ValueStack
Evaluated values are stored as a stack of strings.
Definition: token.h:33
isc
Defines the logger used by the top-level component of kea-lfc.
Definition: agent_parser.cc:143
pkt.h