Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/crypto/krb5/src/lib/krad/code.c
39536 views
1
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
/* lib/krad/code.c - RADIUS code name table for libkrad */
3
/*
4
* Copyright 2013 Red Hat, Inc. All rights reserved.
5
*
6
* Redistribution and use in source and binary forms, with or without
7
* modification, are permitted provided that the following conditions are met:
8
*
9
* 1. Redistributions of source code must retain the above copyright
10
* notice, this list of conditions and the following disclaimer.
11
*
12
* 2. Redistributions in binary form must reproduce the above copyright
13
* notice, this list of conditions and the following disclaimer in
14
* the documentation and/or other materials provided with the
15
* distribution.
16
*
17
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
18
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
21
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
*/
29
30
#include "internal.h"
31
32
#include <string.h>
33
34
static const char *codes[UCHAR_MAX] = {
35
"Access-Request",
36
"Access-Accept",
37
"Access-Reject",
38
"Accounting-Request",
39
"Accounting-Response",
40
"Accounting-Status",
41
"Password-Request",
42
"Password-Ack",
43
"Password-Reject",
44
"Accounting-Message",
45
"Access-Challenge",
46
"Status-Server",
47
"Status-Client",
48
NULL,
49
NULL,
50
NULL,
51
NULL,
52
NULL,
53
NULL,
54
NULL,
55
"Resource-Free-Request",
56
"Resource-Free-Response",
57
"Resource-Query-Request",
58
"Resource-Query-Response",
59
"Alternate-Resource-Reclaim-Request",
60
"NAS-Reboot-Request",
61
"NAS-Reboot-Response",
62
NULL,
63
"Next-Passcode",
64
"New-Pin",
65
"Terminate-Session",
66
"Password-Expired",
67
"Event-Request",
68
"Event-Response",
69
NULL,
70
NULL,
71
NULL,
72
NULL,
73
NULL,
74
"Disconnect-Request",
75
"Disconnect-Ack",
76
"Disconnect-Nak",
77
"Change-Filters-Request",
78
"Change-Filters-Ack",
79
"Change-Filters-Nak",
80
NULL,
81
NULL,
82
NULL,
83
NULL,
84
"IP-Address-Allocate",
85
"IP-Address-Release",
86
};
87
88
krad_code
89
krad_code_name2num(const char *name)
90
{
91
unsigned char i;
92
93
for (i = 0; i < UCHAR_MAX; i++) {
94
if (codes[i] == NULL)
95
continue;
96
97
if (strcmp(codes[i], name) == 0)
98
return ++i;
99
}
100
101
return 0;
102
}
103
104
const char *
105
krad_code_num2name(krad_code code)
106
{
107
if (code == 0)
108
return NULL;
109
110
return codes[code - 1];
111
}
112
113