Kea 2.7.6
server_tag.cc
Go to the documentation of this file.
1// Copyright (C) 2019-2024 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#include <config.h>
8
9#include <cc/server_tag.h>
11#include <util/str.h>
12#include <boost/algorithm/string.hpp>
13
14namespace isc {
15namespace data {
16
17std::string ServerTag::ALL = "all";
18
20 : tag_(ALL) {
21}
22
23ServerTag::ServerTag(const std::string& tag)
24 : tag_(util::str::trim(tag)) {
25 if (tag_.empty()) {
26 isc_throw(BadValue, "server-tag must not be empty");
27
28 } else if (tag_.length() > 256) {
29 isc_throw(BadValue, "server-tag must not be longer than 256 characters");
30 }
31
32 boost::algorithm::to_lower(tag_);
33
34 // ANY has a defined meaning for server selector and must not be used as
35 // a server tag.
36 if (tag_ == "any") {
37 isc_throw(BadValue, "'any' is reserved and must not be used as a server-tag");
38 }
39}
40
41bool
43 return (tag_ == ALL);
44}
45
46std::ostream&
47operator<<(std::ostream& os, const ServerTag& server_tag) {
48 os << server_tag.get();
49 return (os);
50}
51
52} // end of namespace isc::data
53} // end of namespace isc
if(!(yy_init))
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
Represents a server tag.
Definition server_tag.h:25
static std::string ALL
Server tag for all servers as text.
Definition server_tag.h:29
bool amAll() const
Checks if the server tag is set to "all servers".
Definition server_tag.cc:42
std::string get() const
Returns server tag as string.
Definition server_tag.h:51
ServerTag()
Default constructor.
Definition server_tag.cc:19
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
std::ostream & operator<<(std::ostream &out, const Element::Position &pos)
Insert Element::Position as a string into stream.
Definition data.cc:48
Defines the logger used by the top-level component of kea-lfc.