1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Copyright (C) 2020-2025 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

#include <config.h>

#include <util/str.h>
#include <dhcp/dhcp4.h>
#include <radius_utils.h>
#include <cctype>
#include <iomanip>
#include <sstream>

using namespace std;
using namespace isc;
using namespace isc::dhcp;
using namespace isc::util;
using namespace isc::util::str;

namespace isc {
namespace radius {

string
canonize(const string& hexdump) {<--- The function 'canonize' is never used.
    string result(hexdump);
    for (char& c : result) {
        switch (c) {
        case 'A':
        case 'B':
        case 'C':
        case 'D':
        case 'E':
        case 'F':
            // Lower case
            c += 'a' - 'A';
            break;
        case ':':
            // Canonical format use - as the separator.
            c = '-';
            break;
        default:
            break;
        }
    }
    return (result);
}

vector<uint8_t>
pop0(const ClientIdPtr& client_id) {<--- The function 'pop0' is never used.
    vector<uint8_t> content = client_id->getClientId();
    if ((content.size() > 1) && (content[0] == 0)) {
        content.erase(content.begin());
    }
    return (content);
}

vector<uint8_t>
pop0(const DuidPtr& duid) {
    vector<uint8_t> content = duid->getDuid();
    if ((content[0] == 0) && (content[1] == 0)) {
        content.erase(content.begin(), content.begin() + 2);
    }
    return (content);
}

string
toPrintable(const vector<uint8_t>& content) {<--- The function 'toPrintable' is never used.
    if (content.empty()) {
        return ("");
    }
    if (str::isPrintable(content)) {
        string repr;
        repr.resize(content.size());
        memmove(&repr[0], &content[0], repr.size());
        return (repr);
    } else {
        return (dumpAsHex(content));
    }
}

vector<uint8_t>
extractDuid(const ClientIdPtr& client_id, bool& extracted) {<--- The function 'extractDuid' is never used.
    vector<uint8_t> content = client_id->getClientId();
    extracted = false;
    if ((content.size() > 5) && (content[0] == CLIENT_ID_OPTION_TYPE_DUID)) {
        extracted = true;
        content.erase(content.begin(), content.begin() + 5);
    }
    // Not an error condition but likely to be unused anyway...
    return (content);
}

} // end of namespace isc::radius
} // end of namespace isc