Kea: client_attribute.h Source File

| Kea 3.2.0-git

client_attribute.h
Go to the documentation of this file.
1// Copyright (C) 2023-2026 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 RADIUS_CLIENT_ATTRIBUTE_H
8#define RADIUS_CLIENT_ATTRIBUTE_H
9
10#include <exceptions/exceptions.h>
11#include <cc/cfg_to_element.h>
12#include <cc/data.h>
13#include <cc/simple_parser.h>
14#include <asiolink/io_address.h>
15#include <client_dictionary.h>
16#include <boost/multi_index_container.hpp>
17#include <boost/multi_index/hashed_index.hpp>
18#include <boost/multi_index/member.hpp>
19#include <boost/multi_index/sequenced_index.hpp>
20#include <boost/noncopyable.hpp>
21#include <boost/shared_ptr.hpp>
22#include <string>
23#include <vector>
24
25namespace isc {
26namespace radius {
27
29static constexpr size_t MAX_STRING_LEN = 253;
30
32static constexpr size_t MAX_VSA_DATA_LEN = MAX_STRING_LEN - 4;
33
35using isc::data::TypeError;
36
38class Attribute;
39 typedef boost::shared_ptr<Attribute> AttributePtr;
40 typedef boost::shared_ptr<const Attribute> ConstAttributePtr;
41
43 class Attribute : public data::CfgToElement {
44protected:
45
51 explicit Attribute(const uint8_t type) : type_(type) {
52 }
53
54public:
56 virtual ~Attribute() = default;
57
61 uint8_t getType() const {
62 return (type_);
63 }
64
68 virtual AttrValueType getValueType() const = 0;
69
71
77 static AttributePtr fromBytes(const std::vector<uint8_t>& bytes);
78
80
89 static AttributePtr fromText(const AttrDefPtr& def,
90 const std::string& value);
91
100 static AttributePtr fromBytes(const AttrDefPtr& def,
101 const std::vector<uint8_t>& value);
102
106
113 static AttributePtr fromString(const uint8_t type,
114 const std::string& value);
115
122 static AttributePtr fromBinary(const uint8_t type,
123 const std::vector<uint8_t>& value);
124
131 static AttributePtr fromInt(const uint8_t type, const uint32_t value);
132
139 static AttributePtr fromIpAddr(const uint8_t type,
140 const asiolink::IOAddress& value);
141
148 static AttributePtr fromIpv6Addr(const uint8_t type,
149 const asiolink::IOAddress& value);
150
158 static AttributePtr fromIpv6Prefix(const uint8_t type,
159 const uint8_t len,
160 const asiolink::IOAddress& value);
161
170 static AttributePtr fromVsa(const uint8_t type,
171 const uint32_t vendor,
172 const std::string& value);
173
181 static AttributePtr fromVsa(const uint8_t type,
182 const uint32_t vendor,
183 const std::vector<uint8_t>& value);
184
186
190 virtual size_t getValueLen() const = 0;
191
198 virtual std::string toText(size_t indent = 0) const = 0;
199
203 virtual std::vector<uint8_t> toBytes() const = 0;
204
208
213 virtual std::string toString() const;
214
219 virtual std::vector<uint8_t> toBinary() const;
220
225 virtual uint32_t toInt() const;
226
231 virtual asiolink::IOAddress toIpAddr() const;
232
237 virtual asiolink::IOAddress toIpv6Addr() const;
238
243 virtual asiolink::IOAddress toIpv6Prefix() const;
244
249 virtual uint8_t toIpv6PrefixLen() const;
250
255 virtual uint32_t toVendorId() const;
256
261 virtual std::vector<uint8_t> toVsaData() const;
262
264 const uint8_t type_;
265
268
269private:
270
279 static AttributePtr fromText0(const AttrDefPtr& def,
280 const std::string& value);
281
290 static AttributePtr fromBytes0(const AttrDefPtr& def,
291 const std::vector<uint8_t>& value);
292};
293
296
298 class AttrString : public Attribute {
299protected:
300
305 AttrString(const uint8_t type, const std::string& value)
306 : Attribute(type), value_(value) {
307 if (value.empty()) {
308 isc_throw(BadValue, "value is empty");
309 }
310 if (value.size() > MAX_STRING_LEN) {
311 isc_throw(BadValue, "value is too large " << value.size()
312 << " > " << MAX_STRING_LEN);
313 }
314 }
315
320 AttrString(const uint8_t type, const std::vector<uint8_t>& value);
321
327 static AttributePtr fromText(const uint8_t type, const std::string& repr);
328
334 static AttributePtr fromBytes(const uint8_t type,
335 const std::vector<uint8_t>& bytes);
336
338 friend class Attribute;
339
340public:
344 virtual AttrValueType getValueType() const override {
345 return (PW_TYPE_STRING);
346 }
347
351 virtual size_t getValueLen() const override {
352 return (value_.size());
353 }
354
359 virtual std::string toText(size_t indent = 0) const override;
360
364 virtual std::vector<uint8_t> toBytes() const override;
365
369 virtual std::string toString() const override {
370 return (value_);
371 }
372
376 virtual std::vector<uint8_t> toBinary() const override;
377
381 virtual data::ElementPtr toElement() const override;
382
383private:
385 std::string value_;
386};
387
389 class AttrInt : public Attribute {
390protected:
391
396 AttrInt(const uint8_t type, const int32_t value)
397 : Attribute(type), value_(static_cast<uint32_t>(value)) {
398 }
399
404 AttrInt(const uint8_t type, const uint32_t value)
405 : Attribute(type), value_(value) {
406 }
407
413 static AttributePtr fromText(const uint8_t type, const std::string& repr);
414
420 static AttributePtr fromBytes(const uint8_t type,
421 const std::vector<uint8_t>& bytes);
422
424 friend class Attribute;
425
426public:
427
431 virtual AttrValueType getValueType() const override {
432 return (PW_TYPE_INTEGER);
433 }
434
438 virtual size_t getValueLen() const override {
439 return (4);
440 }
441
446 virtual std::string toText(size_t indent = 0) const override;
447
451 virtual std::vector<uint8_t> toBytes() const override;
452
456 virtual uint32_t toInt() const override {
457 return (value_);
458 }
459
463 virtual data::ElementPtr toElement() const override;
464
465private:
467 const uint32_t value_;
468};
469
471 class AttrIpAddr : public Attribute {
472protected:
473
478 AttrIpAddr(const uint8_t type, const asiolink::IOAddress& value)
479 : Attribute(type), value_(value) {
480 if (!value.isV4()) {
481 isc_throw(BadValue, "not v4 address " << value);
482 }
483 }
484
490 static AttributePtr fromText(const uint8_t type, const std::string& repr);
491
497 static AttributePtr fromBytes(const uint8_t type,
498 const std::vector<uint8_t>& bytes);
499
501 friend class Attribute;
502
503public:
507 virtual AttrValueType getValueType() const override {
508 return (PW_TYPE_IPADDR);
509 }
510
514 virtual size_t getValueLen() const override {
515 return (4);
516 }
517
522 virtual std::string toText(size_t indent = 0) const override;
523
527 virtual std::vector<uint8_t> toBytes() const override;
528
532 virtual asiolink::IOAddress toIpAddr() const override {
533 return (value_);
534 }
535
539 virtual data::ElementPtr toElement() const override;
540
541private:
543 asiolink::IOAddress value_;
544};
545
547 class AttrIpv6Addr : public Attribute {
548protected:
549
554 AttrIpv6Addr(const uint8_t type, const asiolink::IOAddress& value)
555 : Attribute(type), value_(value) {
556 if (!value.isV6()) {
557 isc_throw(BadValue, "not v6 address " << value);
558 }
559 }
560
566 static AttributePtr fromText(const uint8_t type, const std::string& repr);
567
573 static AttributePtr fromBytes(const uint8_t type,
574 const std::vector<uint8_t>& bytes);
575
577 friend class Attribute;
578
579public:
580
584 virtual AttrValueType getValueType() const override {
585 return (PW_TYPE_IPV6ADDR);
586 }
587
591 virtual size_t getValueLen() const override {
592 return (16);
593 }
594
599 virtual std::string toText(size_t indent = 0) const override;
600
604 virtual std::vector<uint8_t> toBytes() const override;
605
609 virtual asiolink::IOAddress toIpv6Addr() const override {
610 return (value_);
611 }
612
616 virtual data::ElementPtr toElement() const override;
617
618private:
620 asiolink::IOAddress value_;
621};
622
624 class AttrIpv6Prefix : public Attribute {
625protected:
626
632 AttrIpv6Prefix(const uint8_t type, const uint8_t len,
633 const asiolink::IOAddress& value)
634 : Attribute(type), len_(len), value_(value) {
635 if (!value.isV6()) {
636 isc_throw(BadValue, "not v6 address " << value);
637 }
638 if (len > 128) {
639 isc_throw(BadValue, "too long prefix "
640 << static_cast<unsigned>(len));
641 }
642 }
643
649 static AttributePtr fromText(const uint8_t type, const std::string& repr);
650
656 static AttributePtr fromBytes(const uint8_t type,
657 const std::vector<uint8_t>& bytes);
658
660 friend class Attribute;
661
662public:
663
667 virtual AttrValueType getValueType() const override {
668 return (PW_TYPE_IPV6PREFIX);
669 }
670
674 virtual size_t getValueLen() const override {
675 return (17);
676 }
677
682 virtual std::string toText(size_t indent = 0) const override;
683
687 virtual std::vector<uint8_t> toBytes() const override;
688
692 virtual asiolink::IOAddress toIpv6Prefix() const override {
693 return (value_);
694 }
695
699 virtual uint8_t toIpv6PrefixLen() const override {
700 return (len_);
701 }
702
706 virtual data::ElementPtr toElement() const override;
707
708private:
710 const uint8_t len_;
711
713 asiolink::IOAddress value_;
714};
715
717 class AttrVsa : public Attribute {
718protected:
719
725 AttrVsa(const uint8_t type, const uint32_t vendor,
726 const std::string& value)
727 : Attribute(type), vendor_(vendor), value_(value) {
728 if (value.empty()) {
729 isc_throw(BadValue, "value is empty");
730 }
731 if (value.size() > MAX_VSA_DATA_LEN) {
732 isc_throw(BadValue, "value is too large " << value.size()
733 << " > " << MAX_VSA_DATA_LEN);
734 }
735 }
736
742 AttrVsa(const uint8_t type, const uint32_t vendor,
743 const std::vector<uint8_t>& value);
744
751 static AttributePtr fromText(const uint8_t type, const std::string& repr);
752
758 static AttributePtr fromBytes(const uint8_t type,
759 const std::vector<uint8_t>& bytes);
760
762 friend class Attribute;
763
764public:
765
769 virtual AttrValueType getValueType() const override {
770 return (PW_TYPE_VSA);
771 }
772
776 virtual size_t getValueLen() const override {
777 return (4 + value_.size());
778 }
779
784 virtual std::string toText(size_t indent = 0) const override;
785
789 virtual std::vector<uint8_t> toBytes() const override;
790
794 virtual uint32_t toVendorId() const override {
795 return (vendor_);
796 }
797
801 virtual std::vector<uint8_t> toVsaData() const override;
802
806 virtual data::ElementPtr toElement() const override;
807
808private:
810 uint32_t vendor_;
811
813 std::string value_;
814};
815
819 class Attributes : public data::CfgToElement {
820public:
821
823 typedef boost::multi_index_container<
824 // This container stores pointers to attributes.
825 ConstAttributePtr,
826 // Start specification of indexes here.
827 boost::multi_index::indexed_by<
828 // Sequenced index to keep insert order.
829 boost::multi_index::sequenced<>,
830 // Hash index for direct retrieval.
831 boost::multi_index::hashed_non_unique<
832 boost::multi_index::member<
833 Attribute, const uint8_t, &Attribute::type_
834 >
835 >
836 >
837 > AttributeContainer;
838
840 Attributes() : container_() {
841 }
842
844 virtual ~Attributes() {
845 clear();
846 }
847
851 bool empty() const {
852 return (container_.empty());
853 }
854
858 size_t size() const {
859 return (container_.size());
860 }
861
866 void add(const ConstAttributePtr& attr, bool back = true);
867
874 bool del(const uint8_t type);
875
877 void clear() {
878 container_.clear();
879 }
880
884 void append(const Attributes& other);
885
890 size_t count(const uint8_t type) const;
891
896 ConstAttributePtr get(const uint8_t type) const;
897
904 std::string toText(size_t indent = 0) const;
905
909 data::ElementPtr toElement() const override;
910
915 static Attributes fromElement(const data::ConstElementPtr& attr_list);
916
920 AttributeContainer::iterator begin() {
921 return (container_.begin());
922 }
923
927 AttributeContainer::const_iterator begin() const {
928 return (container_.begin());
929 }
930
934 AttributeContainer::const_iterator cbegin() const {
935 return (container_.cbegin());
936 }
937
941 AttributeContainer::iterator end() {
942 return (container_.end());
943 }
944
948 AttributeContainer::const_iterator end() const {
949 return (container_.end());
950 }
951
953 AttributeContainer::const_iterator cend() const {
954 return (container_.cend());
955 }
956
957protected:
959 AttributeContainer container_;
960};
961
963 typedef boost::shared_ptr<Attributes> AttributesPtr;
964
965} // end of namespace isc::radius
966} // end of namespace isc
967
968#endif
cfg_to_element.h
isc::BadValue
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
Definition exceptions/exceptions.h:132
isc::asiolink::IOAddress
The IOAddress class represents an IP addresses (version agnostic).
Definition io_address.h:53
isc::asiolink::IOAddress::isV6
bool isV6() const
Convenience function to check for an IPv6 address.
Definition io_address.h:144
isc::asiolink::IOAddress::isV4
bool isV4() const
Convenience function to check for an IPv4 address.
Definition io_address.h:122
isc::radius::AttrInt::toInt
virtual uint32_t toInt() const override
To integer.
Definition client_attribute.h:456
isc::radius::AttrInt::fromText
static AttributePtr fromText(const uint8_t type, const std::string &repr)
From text.
Definition client_attribute.cc:343
isc::radius::AttrInt::toBytes
virtual std::vector< uint8_t > toBytes() const override
To bytes.
Definition client_attribute.cc:398
isc::radius::AttrInt::getValueLen
virtual size_t getValueLen() const override
Value length.
Definition client_attribute.h:438
isc::radius::AttrInt::toElement
virtual data::ElementPtr toElement() const override
Unparse attribute.
Definition client_attribute.cc:411
isc::radius::AttrInt::AttrInt
AttrInt(const uint8_t type, const uint32_t value)
Constructor (unsigned).
Definition client_attribute.h:404
isc::radius::AttrInt::Attribute
friend class Attribute
Make Attribute a friend class.
Definition client_attribute.h:424
isc::radius::AttrInt::toText
virtual std::string toText(size_t indent=0) const override
Returns text representation of the attribute.
Definition client_attribute.cc:382
isc::radius::AttrInt::AttrInt
AttrInt(const uint8_t type, const int32_t value)
Constructor (signed).
Definition client_attribute.h:396
isc::radius::AttrInt::fromBytes
static AttributePtr fromBytes(const uint8_t type, const std::vector< uint8_t > &bytes)
From bytes.
Definition client_attribute.cc:364
isc::radius::AttrInt::getValueType
virtual AttrValueType getValueType() const override
Get value type.
Definition client_attribute.h:431
isc::radius::AttrIpAddr::AttrIpAddr
AttrIpAddr(const uint8_t type, const asiolink::IOAddress &value)
Constructor.
Definition client_attribute.h:478
isc::radius::AttrIpAddr::toElement
virtual data::ElementPtr toElement() const override
Unparse attribute.
Definition client_attribute.cc:476
isc::radius::AttrIpAddr::toBytes
virtual std::vector< uint8_t > toBytes() const override
To bytes.
Definition client_attribute.cc:465
isc::radius::AttrIpAddr::fromText
static AttributePtr fromText(const uint8_t type, const std::string &repr)
From text.
Definition client_attribute.cc:425
isc::radius::AttrIpAddr::toIpAddr
virtual asiolink::IOAddress toIpAddr() const override
To IPv4 address.
Definition client_attribute.h:532
isc::radius::AttrIpAddr::fromBytes
static AttributePtr fromBytes(const uint8_t type, const std::vector< uint8_t > &bytes)
From bytes.
Definition client_attribute.cc:439
isc::radius::AttrIpAddr::getValueLen
virtual size_t getValueLen() const override
Value length.
Definition client_attribute.h:514
isc::radius::AttrIpAddr::Attribute
friend class Attribute
Make Attribute a friend class.
Definition client_attribute.h:501
isc::radius::AttrIpAddr::getValueType
virtual AttrValueType getValueType() const override
Get value type.
Definition client_attribute.h:507
isc::radius::AttrIpAddr::toText
virtual std::string toText(size_t indent=0) const override
Returns text representation of the attribute.
Definition client_attribute.cc:454
isc::radius::AttrIpv6Addr::toText
virtual std::string toText(size_t indent=0) const override
Returns text representation of the attribute.
Definition client_attribute.cc:519
isc::radius::AttrIpv6Addr::toIpv6Addr
virtual asiolink::IOAddress toIpv6Addr() const override
To IPv6 address.
Definition client_attribute.h:609
isc::radius::AttrIpv6Addr::fromBytes
static AttributePtr fromBytes(const uint8_t type, const std::vector< uint8_t > &bytes)
From bytes.
Definition client_attribute.cc:504
isc::radius::AttrIpv6Addr::toBytes
virtual std::vector< uint8_t > toBytes() const override
To bytes.
Definition client_attribute.cc:530
isc::radius::AttrIpv6Addr::getValueType
virtual AttrValueType getValueType() const override
Get value type.
Definition client_attribute.h:584
isc::radius::AttrIpv6Addr::getValueLen
virtual size_t getValueLen() const override
Value length.
Definition client_attribute.h:591
isc::radius::AttrIpv6Addr::fromText
static AttributePtr fromText(const uint8_t type, const std::string &repr)
From text.
Definition client_attribute.cc:490
isc::radius::AttrIpv6Addr::AttrIpv6Addr
AttrIpv6Addr(const uint8_t type, const asiolink::IOAddress &value)
Constructor.
Definition client_attribute.h:554
isc::radius::AttrIpv6Addr::Attribute
friend class Attribute
Make Attribute a friend class.
Definition client_attribute.h:577
isc::radius::AttrIpv6Addr::toElement
virtual data::ElementPtr toElement() const override
Unparse attribute.
Definition client_attribute.cc:541
isc::radius::AttrIpv6Prefix::toIpv6Prefix
virtual asiolink::IOAddress toIpv6Prefix() const override
To IPv6 prefix.
Definition client_attribute.h:692
isc::radius::AttrIpv6Prefix::AttrIpv6Prefix
AttrIpv6Prefix(const uint8_t type, const uint8_t len, const asiolink::IOAddress &value)
Constructor.
Definition client_attribute.h:632
isc::radius::AttrIpv6Prefix::toBytes
virtual std::vector< uint8_t > toBytes() const override
To bytes.
Definition client_attribute.cc:621
isc::radius::AttrIpv6Prefix::toElement
virtual data::ElementPtr toElement() const override
Unparse attribute.
Definition client_attribute.cc:635
isc::radius::AttrIpv6Prefix::getValueLen
virtual size_t getValueLen() const override
Value length.
Definition client_attribute.h:674
isc::radius::AttrIpv6Prefix::toIpv6PrefixLen
virtual uint8_t toIpv6PrefixLen() const override
To IPv6 prefix length.
Definition client_attribute.h:699
isc::radius::AttrIpv6Prefix::Attribute
friend class Attribute
Make Attribute a friend class.
Definition client_attribute.h:660
isc::radius::AttrIpv6Prefix::getValueType
virtual AttrValueType getValueType() const override
Get value type.
Definition client_attribute.h:667
isc::radius::AttrIpv6Prefix::fromText
static AttributePtr fromText(const uint8_t type, const std::string &repr)
From text.
Definition client_attribute.cc:555
isc::radius::AttrIpv6Prefix::fromBytes
static AttributePtr fromBytes(const uint8_t type, const std::vector< uint8_t > &bytes)
From bytes.
Definition client_attribute.cc:582
isc::radius::AttrIpv6Prefix::toText
virtual std::string toText(size_t indent=0) const override
Returns text representation of the attribute.
Definition client_attribute.cc:610
isc::radius::AttrString::fromBytes
static AttributePtr fromBytes(const uint8_t type, const std::vector< uint8_t > &bytes)
From bytes.
Definition client_attribute.cc:267
isc::radius::AttrString::fromText
static AttributePtr fromText(const uint8_t type, const std::string &repr)
From text.
Definition client_attribute.cc:255
isc::radius::AttrString::toBytes
virtual std::vector< uint8_t > toBytes() const override
To bytes.
Definition client_attribute.cc:299
isc::radius::AttrString::toElement
virtual data::ElementPtr toElement() const override
Unparse attribute.
Definition client_attribute.cc:321
isc::radius::AttrString::toText
virtual std::string toText(size_t indent=0) const override
Returns text representation of the attribute.
Definition client_attribute.cc:279
isc::radius::AttrString::AttrString
AttrString(const uint8_t type, const std::string &value)
Constructor.
Definition client_attribute.h:305
isc::radius::AttrString::toBinary
virtual std::vector< uint8_t > toBinary() const override
To binary.
Definition client_attribute.cc:311
isc::radius::AttrString::getValueLen
virtual size_t getValueLen() const override
Value length.
Definition client_attribute.h:351
isc::radius::AttrString::Attribute
friend class Attribute
Make Attribute a friend class.
Definition client_attribute.h:338
isc::radius::AttrString::toString
virtual std::string toString() const override
To string.
Definition client_attribute.h:369
isc::radius::AttrString::getValueType
virtual AttrValueType getValueType() const override
Get value type.
Definition client_attribute.h:344
isc::radius::AttrVsa::toElement
virtual data::ElementPtr toElement() const override
Unparse attribute.
Definition client_attribute.cc:734
isc::radius::AttrVsa::toText
virtual std::string toText(size_t indent=0) const override
Returns text representation of the attribute.
Definition client_attribute.cc:691
isc::radius::AttrVsa::toVendorId
virtual uint32_t toVendorId() const override
To vendor id.
Definition client_attribute.h:794
isc::radius::AttrVsa::fromBytes
static AttributePtr fromBytes(const uint8_t type, const std::vector< uint8_t > &bytes)
From bytes.
Definition client_attribute.cc:668
isc::radius::AttrVsa::getValueType
virtual AttrValueType getValueType() const override
Get value type.
Definition client_attribute.h:769
isc::radius::AttrVsa::Attribute
friend class Attribute
Make Attribute a friend class.
Definition client_attribute.h:762
isc::radius::AttrVsa::fromText
static AttributePtr fromText(const uint8_t type, const std::string &repr)
From text.
Definition client_attribute.cc:663
isc::radius::AttrVsa::toVsaData
virtual std::vector< uint8_t > toVsaData() const override
To vsa data.
Definition client_attribute.cc:724
isc::radius::AttrVsa::AttrVsa
AttrVsa(const uint8_t type, const uint32_t vendor, const std::string &value)
Constructor.
Definition client_attribute.h:725
isc::radius::AttrVsa::getValueLen
virtual size_t getValueLen() const override
Value length.
Definition client_attribute.h:776
isc::radius::AttrVsa::toBytes
virtual std::vector< uint8_t > toBytes() const override
To bytes.
Definition client_attribute.cc:708
isc::radius::Attribute
RADIUS attribute base class.
Definition client_attribute.h:43
isc::radius::Attribute::fromBytes
static AttributePtr fromBytes(const std::vector< uint8_t > &bytes)
Generic factories.
Definition client_attribute.cc:75
isc::radius::Attribute::toString
virtual std::string toString() const
Specific get methods.
Definition client_attribute.cc:188
isc::radius::Attribute::getValueLen
virtual size_t getValueLen() const =0
Generic get methods.
isc::radius::Attribute::fromInt
static AttributePtr fromInt(const uint8_t type, const uint32_t value)
From integer with type.
Definition client_attribute.cc:155
isc::radius::Attribute::fromIpAddr
static AttributePtr fromIpAddr(const uint8_t type, const asiolink::IOAddress &value)
From IPv4 address with type.
Definition client_attribute.cc:160
isc::radius::Attribute::toInt
virtual uint32_t toInt() const
To integer.
Definition client_attribute.cc:200
isc::radius::Attribute::Attribute
Attribute(const uint8_t type)
Constructor.
Definition client_attribute.h:51
isc::radius::Attribute::toVendorId
virtual uint32_t toVendorId() const
To vendor id.
Definition client_attribute.cc:230
isc::radius::Attribute::fromString
static AttributePtr fromString(const uint8_t type, const std::string &value)
From type specific factories.
Definition client_attribute.cc:139
isc::radius::Attribute::toBytes
virtual std::vector< uint8_t > toBytes() const =0
To bytes (wire format).
isc::radius::Attribute::getType
uint8_t getType() const
Get type.
Definition client_attribute.h:61
isc::radius::Attribute::~Attribute
virtual ~Attribute()=default
Virtual destructor.
isc::radius::Attribute::toIpAddr
virtual asiolink::IOAddress toIpAddr() const
To IPv4 address.
Definition client_attribute.cc:206
isc::radius::Attribute::toIpv6Addr
virtual asiolink::IOAddress toIpv6Addr() const
To IPv6 address.
Definition client_attribute.cc:212
isc::radius::Attribute::fromBinary
static AttributePtr fromBinary(const uint8_t type, const std::vector< uint8_t > &value)
From binary with type.
Definition client_attribute.cc:147
isc::radius::Attribute::fromText
static AttributePtr fromText(const AttrDefPtr &def, const std::string &value)
From definition generic factories.
Definition client_attribute.cc:28
isc::radius::Attribute::toIpv6PrefixLen
virtual uint8_t toIpv6PrefixLen() const
To IPv6 prefix length.
Definition client_attribute.cc:224
isc::radius::Attribute::fromIpv6Prefix
static AttributePtr fromIpv6Prefix(const uint8_t type, const uint8_t len, const asiolink::IOAddress &value)
From IPv6 prefix with type.
Definition client_attribute.cc:170
isc::radius::Attribute::toText
virtual std::string toText(size_t indent=0) const =0
Returns text representation of the attribute.
isc::radius::Attribute::fromIpv6Addr
static AttributePtr fromIpv6Addr(const uint8_t type, const asiolink::IOAddress &value)
From IPv6 address with type.
Definition client_attribute.cc:165
isc::radius::Attribute::toIpv6Prefix
virtual asiolink::IOAddress toIpv6Prefix() const
To IPv6 prefix.
Definition client_attribute.cc:218
isc::radius::Attribute::getValueType
virtual AttrValueType getValueType() const =0
Get value type.
isc::radius::Attribute::type_
const uint8_t type_
Type.
Definition client_attribute.h:264
isc::radius::Attribute::toBinary
virtual std::vector< uint8_t > toBinary() const
To binary.
Definition client_attribute.cc:194
isc::radius::Attribute::fromVsa
static AttributePtr fromVsa(const uint8_t type, const uint32_t vendor, const std::string &value)
From Vendor ID and string data with type.
Definition client_attribute.cc:176
isc::radius::Attribute::toVsaData
virtual std::vector< uint8_t > toVsaData() const
To vsa data.
Definition client_attribute.cc:236
isc::radius::Attributes
Collection of attributes.
Definition client_attribute.h:819
isc::radius::Attributes::AttributeContainer
boost::multi_index_container< ConstAttributePtr, boost::multi_index::indexed_by< boost::multi_index::sequenced<>, boost::multi_index::hashed_non_unique< boost::multi_index::member< Attribute, const uint8_t, &Attribute::type_ > > > > AttributeContainer
Type of the container.
Definition client_attribute.h:837
isc::radius::Attributes::container_
AttributeContainer container_
The container.
Definition client_attribute.h:959
isc::radius::Attributes::size
size_t size() const
Returns the number of elements.
Definition client_attribute.h:858
isc::radius::Attributes::begin
AttributeContainer::const_iterator begin() const
Get the iterator to the beginning.
Definition client_attribute.h:927
isc::radius::Attributes::toText
std::string toText(size_t indent=0) const
Returns text representation of the collection.
Definition client_attribute.cc:802
isc::radius::Attributes::Attributes
Attributes()
constructor.
Definition client_attribute.h:840
isc::radius::Attributes::empty
bool empty() const
Indicates the object is empty.
Definition client_attribute.h:851
isc::radius::Attributes::append
void append(const Attributes &other)
Append another collection.
Definition client_attribute.cc:778
isc::radius::Attributes::count
size_t count(const uint8_t type) const
Counts instance of the attribute in the collection.
Definition client_attribute.cc:785
isc::radius::Attributes::~Attributes
virtual ~Attributes()
Destructor.
Definition client_attribute.h:844
isc::radius::Attributes::cend
AttributeContainer::const_iterator cend() const
Get the const iterator to the past-the-end.
Definition client_attribute.h:953
isc::radius::Attributes::get
ConstAttributePtr get(const uint8_t type) const
Get instance of the attribute in the collection.
Definition client_attribute.cc:791
isc::radius::Attributes::toElement
data::ElementPtr toElement() const override
Unparse collection.
Definition client_attribute.cc:817
isc::radius::Attributes::add
void add(const ConstAttributePtr &attr, bool back=true)
Adds instance of the attribute to the collection.
Definition client_attribute.cc:755
isc::radius::Attributes::cbegin
AttributeContainer::const_iterator cbegin() const
Get the const iterator to the beginning.
Definition client_attribute.h:934
isc::radius::Attributes::clear
void clear()
Clear the collection.
Definition client_attribute.h:877
isc::radius::Attributes::begin
AttributeContainer::iterator begin()
Get the iterator to the beginning.
Definition client_attribute.h:920
isc::radius::Attributes::del
bool del(const uint8_t type)
Deletes an attribute from the collection.
Definition client_attribute.cc:767
isc::radius::Attributes::fromElement
static Attributes fromElement(const data::ConstElementPtr &attr_list)
Parse collection.
Definition client_attribute.cc:826
isc::radius::Attributes::end
AttributeContainer::iterator end()
Get the iterator to the past-the-end.
Definition client_attribute.h:941
isc::radius::Attributes::end
AttributeContainer::const_iterator end() const
Get the iterator to the past-the-end.
Definition client_attribute.h:948
client_dictionary.h
if
if(!(yy_init))
Definition d2_lexer.cc:1515
data.h
exceptions.h
isc_throw
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Definition exceptions/exceptions.h:210
io_address.h
simple_parser.h
isc::data::ConstElementPtr
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:30
isc::data::ElementPtr
boost::shared_ptr< Element > ElementPtr
Definition data.h:29
isc::radius
Definition cfg_attribute.cc:21
isc::radius::AttributesPtr
boost::shared_ptr< Attributes > AttributesPtr
Shared pointers to attribute collection.
Definition client_attribute.h:963
isc::radius::ConstAttributePtr
boost::shared_ptr< const Attribute > ConstAttributePtr
Definition client_attribute.h:40
isc::radius::AttrValueType
AttrValueType
Attribute value types.
Definition client_dictionary.h:29
isc::radius::PW_TYPE_INTEGER
@ PW_TYPE_INTEGER
Definition client_dictionary.h:31
isc::radius::PW_TYPE_IPV6PREFIX
@ PW_TYPE_IPV6PREFIX
Definition client_dictionary.h:34
isc::radius::PW_TYPE_IPV6ADDR
@ PW_TYPE_IPV6ADDR
Definition client_dictionary.h:33
isc::radius::PW_TYPE_VSA
@ PW_TYPE_VSA
Definition client_dictionary.h:35
isc::radius::PW_TYPE_IPADDR
@ PW_TYPE_IPADDR
Definition client_dictionary.h:32
isc::radius::PW_TYPE_STRING
@ PW_TYPE_STRING
Definition client_dictionary.h:30
isc::radius::AttrDefPtr
boost::shared_ptr< AttrDef > AttrDefPtr
Shared pointers to Attribute definition.
Definition client_dictionary.h:81
isc::radius::AttributePtr
boost::shared_ptr< Attribute > AttributePtr
Definition client_attribute.h:39
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18
isc::data::CfgToElement
Abstract class for configuration Cfg_* classes.
Definition cfg_to_element.h:29