xref: /freebsd/lib/libradius/radlib.h (revision af23369a6deaaeb612ab266eb88b8bb8d560c322)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright 1998 Juniper Networks, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  *
28  *	$FreeBSD$
29  */
30 
31 #ifndef _RADLIB_H_
32 #define _RADLIB_H_
33 
34 #include <sys/types.h>
35 #include <netinet/in.h>
36 
37 /* Limits */
38 #define RAD_MAX_ATTR_LEN		253
39 
40 /* Message types */
41 #define RAD_ACCESS_REQUEST		1
42 #define RAD_ACCESS_ACCEPT		2
43 #define RAD_ACCESS_REJECT		3
44 #define RAD_ACCOUNTING_REQUEST		4
45 #define RAD_ACCOUNTING_RESPONSE		5
46 #define RAD_ACCESS_CHALLENGE		11
47 #define RAD_DISCONNECT_REQUEST		40
48 #define RAD_DISCONNECT_ACK		41
49 #define RAD_DISCONNECT_NAK		42
50 #define RAD_COA_REQUEST			43
51 #define RAD_COA_ACK			44
52 #define RAD_COA_NAK			45
53 
54 /* Attribute types and values */
55 #define RAD_USER_NAME			1	/* String */
56 #define RAD_USER_PASSWORD		2	/* String */
57 #define RAD_CHAP_PASSWORD		3	/* String */
58 #define RAD_NAS_IP_ADDRESS		4	/* IP address */
59 #define RAD_NAS_PORT			5	/* Integer */
60 #define RAD_SERVICE_TYPE		6	/* Integer */
61 	#define RAD_LOGIN			1
62 	#define RAD_FRAMED			2
63 	#define RAD_CALLBACK_LOGIN		3
64 	#define RAD_CALLBACK_FRAMED		4
65 	#define RAD_OUTBOUND			5
66 	#define RAD_ADMINISTRATIVE		6
67 	#define RAD_NAS_PROMPT			7
68 	#define RAD_AUTHENTICATE_ONLY		8
69 	#define RAD_CALLBACK_NAS_PROMPT		9
70 #define RAD_FRAMED_PROTOCOL		7	/* Integer */
71 	#define RAD_PPP				1
72 	#define RAD_SLIP			2
73 	#define RAD_ARAP			3	/* Appletalk */
74 	#define RAD_GANDALF			4
75 	#define RAD_XYLOGICS			5
76 #define RAD_FRAMED_IP_ADDRESS		8	/* IP address */
77 #define RAD_FRAMED_IP_NETMASK		9	/* IP address */
78 #define RAD_FRAMED_ROUTING		10	/* Integer */
79 #define RAD_FILTER_ID			11	/* String */
80 #define RAD_FRAMED_MTU			12	/* Integer */
81 #define RAD_FRAMED_COMPRESSION		13	/* Integer */
82 	#define RAD_COMP_NONE			0
83 	#define RAD_COMP_VJ			1
84 	#define RAD_COMP_IPXHDR			2
85 #define RAD_LOGIN_IP_HOST		14	/* IP address */
86 #define RAD_LOGIN_SERVICE		15	/* Integer */
87 #define RAD_LOGIN_TCP_PORT		16	/* Integer */
88      /* unassiged			17 */
89 #define RAD_REPLY_MESSAGE		18	/* String */
90 #define RAD_CALLBACK_NUMBER		19	/* String */
91 #define RAD_CALLBACK_ID			20	/* String */
92      /* unassiged			21 */
93 #define RAD_FRAMED_ROUTE		22	/* String */
94 #define RAD_FRAMED_IPX_NETWORK		23	/* IP address */
95 #define RAD_STATE			24	/* String */
96 #define RAD_CLASS			25	/* Integer */
97 #define RAD_VENDOR_SPECIFIC		26	/* Integer */
98 #define RAD_SESSION_TIMEOUT		27	/* Integer */
99 #define RAD_IDLE_TIMEOUT		28	/* Integer */
100 #define RAD_TERMINATION_ACTION		29	/* Integer */
101 #define RAD_CALLED_STATION_ID		30	/* String */
102 #define RAD_CALLING_STATION_ID		31	/* String */
103 #define RAD_NAS_IDENTIFIER		32	/* String */
104 #define RAD_PROXY_STATE			33	/* Integer */
105 #define RAD_LOGIN_LAT_SERVICE		34	/* Integer */
106 #define RAD_LOGIN_LAT_NODE		35	/* Integer */
107 #define RAD_LOGIN_LAT_GROUP		36	/* Integer */
108 #define RAD_FRAMED_APPLETALK_LINK	37	/* Integer */
109 #define RAD_FRAMED_APPLETALK_NETWORK	38	/* Integer */
110 #define RAD_FRAMED_APPLETALK_ZONE	39	/* Integer */
111      /* reserved for accounting		40-59 */
112 #define RAD_ACCT_INPUT_GIGAWORDS	52
113 #define RAD_ACCT_OUTPUT_GIGAWORDS	53
114 
115 #define RAD_CHAP_CHALLENGE		60	/* String */
116 #define RAD_NAS_PORT_TYPE		61	/* Integer */
117 	#define RAD_ASYNC			0
118 	#define RAD_SYNC			1
119 	#define RAD_ISDN_SYNC			2
120 	#define RAD_ISDN_ASYNC_V120		3
121 	#define RAD_ISDN_ASYNC_V110		4
122 	#define RAD_VIRTUAL			5
123 	#define RAD_PIAFS			6
124 	#define RAD_HDLC_CLEAR_CHANNEL		7
125 	#define RAD_X_25			8
126 	#define RAD_X_75			9
127 	#define RAD_G_3_FAX			10
128 	#define RAD_SDSL			11
129 	#define RAD_ADSL_CAP			12
130 	#define RAD_ADSL_DMT			13
131 	#define RAD_IDSL			14
132 	#define RAD_ETHERNET			15
133 	#define RAD_XDSL			16
134 	#define RAD_CABLE			17
135 	#define RAD_WIRELESS_OTHER		18
136 	#define RAD_WIRELESS_IEEE_802_11	19
137 #define RAD_PORT_LIMIT			62	/* Integer */
138 #define RAD_LOGIN_LAT_PORT		63	/* Integer */
139 #define RAD_CONNECT_INFO		77	/* String */
140 #define RAD_EAP_MESSAGE			79	/* Octets */
141 #define RAD_MESSAGE_AUTHENTIC		80	/* Octets */
142 #define RAD_ACCT_INTERIM_INTERVAL	85	/* Integer */
143 #define RAD_NAS_IPV6_ADDRESS		95	/* IPv6 address */
144 #define RAD_FRAMED_INTERFACE_ID		96	/* 8 octets */
145 #define RAD_FRAMED_IPV6_PREFIX		97	/* Octets */
146 #define RAD_LOGIN_IPV6_HOST		98	/* IPv6 address */
147 #define RAD_FRAMED_IPV6_ROUTE		99	/* String */
148 #define RAD_FRAMED_IPV6_POOL		100	/* String */
149 
150 /* Accounting attribute types and values */
151 #define RAD_ACCT_STATUS_TYPE		40	/* Integer */
152 	#define RAD_START			1
153 	#define RAD_STOP			2
154 	#define RAD_UPDATE			3
155 	#define RAD_ACCOUNTING_ON		7
156 	#define RAD_ACCOUNTING_OFF		8
157 #define RAD_ACCT_DELAY_TIME		41	/* Integer */
158 #define RAD_ACCT_INPUT_OCTETS		42	/* Integer */
159 #define RAD_ACCT_OUTPUT_OCTETS		43	/* Integer */
160 #define RAD_ACCT_SESSION_ID		44	/* String */
161 #define RAD_ACCT_AUTHENTIC		45	/* Integer */
162 	#define RAD_AUTH_RADIUS			1
163 	#define RAD_AUTH_LOCAL			2
164 	#define RAD_AUTH_REMOTE			3
165 #define RAD_ACCT_SESSION_TIME		46	/* Integer */
166 #define RAD_ACCT_INPUT_PACKETS		47	/* Integer */
167 #define RAD_ACCT_OUTPUT_PACKETS		48	/* Integer */
168 #define RAD_ACCT_TERMINATE_CAUSE	49	/* Integer */
169         #define RAD_TERM_USER_REQUEST		1
170         #define RAD_TERM_LOST_CARRIER		2
171         #define RAD_TERM_LOST_SERVICE		3
172         #define RAD_TERM_IDLE_TIMEOUT		4
173         #define RAD_TERM_SESSION_TIMEOUT	5
174         #define RAD_TERM_ADMIN_RESET		6
175         #define RAD_TERM_ADMIN_REBOOT		7
176         #define RAD_TERM_PORT_ERROR		8
177         #define RAD_TERM_NAS_ERROR		9
178         #define RAD_TERM_NAS_REQUEST		10
179         #define RAD_TERM_NAS_REBOOT		11
180         #define RAD_TERM_PORT_UNNEEDED		12
181         #define RAD_TERM_PORT_PREEMPTED		13
182         #define RAD_TERM_PORT_SUSPENDED		14
183         #define RAD_TERM_SERVICE_UNAVAILABLE    15
184         #define RAD_TERM_CALLBACK		16
185         #define RAD_TERM_USER_ERROR		17
186         #define RAD_TERM_HOST_REQUEST		18
187 #define	RAD_ACCT_MULTI_SESSION_ID	50	/* String */
188 #define	RAD_ACCT_LINK_COUNT		51	/* Integer */
189 
190 #define	RAD_ERROR_CAUSE			101	/* Integer */
191 
192 struct rad_handle;
193 struct timeval;
194 
195 __BEGIN_DECLS
196 struct rad_handle	*rad_acct_open(void);
197 int			 rad_add_server(struct rad_handle *,
198 			    const char *, int, const char *, int, int);
199 int			 rad_add_server_ex(struct rad_handle *,
200 			    const char *, int, const char *, int, int,
201 			    int, struct in_addr *);
202 struct rad_handle	*rad_auth_open(void);
203 void			 rad_bind_to(struct rad_handle *, in_addr_t);
204 void			 rad_close(struct rad_handle *);
205 int			 rad_config(struct rad_handle *, const char *);
206 int			 rad_continue_send_request(struct rad_handle *, int,
207 			    int *, struct timeval *);
208 int			 rad_create_request(struct rad_handle *, int);
209 int			 rad_create_response(struct rad_handle *, int);
210 struct in_addr		 rad_cvt_addr(const void *);
211 struct in6_addr		 rad_cvt_addr6(const void *);
212 u_int32_t		 rad_cvt_int(const void *);
213 char			*rad_cvt_string(const void *, size_t);
214 int			 rad_get_attr(struct rad_handle *, const void **,
215 			    size_t *);
216 int			 rad_init_send_request(struct rad_handle *, int *,
217 			    struct timeval *);
218 struct rad_handle	*rad_open(void);  /* Deprecated, == rad_auth_open */
219 int			 rad_put_addr(struct rad_handle *, int, struct in_addr);
220 int			 rad_put_addr6(struct rad_handle *, int, struct in6_addr);
221 int			 rad_put_attr(struct rad_handle *, int,
222 			    const void *, size_t);
223 int			 rad_put_int(struct rad_handle *, int, u_int32_t);
224 int			 rad_put_string(struct rad_handle *, int,
225 			    const char *);
226 int			 rad_put_message_authentic(struct rad_handle *);
227 ssize_t			 rad_request_authenticator(struct rad_handle *, char *,
228 			    size_t);
229 int			 rad_receive_request(struct rad_handle *);
230 int			 rad_send_request(struct rad_handle *);
231 int			 rad_send_response(struct rad_handle *);
232 struct rad_handle	*rad_server_open(int fd);
233 const char		*rad_server_secret(struct rad_handle *);
234 const char		*rad_strerror(struct rad_handle *);
235 u_char			*rad_demangle(struct rad_handle *, const void *,
236 			    size_t);
237 
238 __END_DECLS
239 
240 #endif /* _RADLIB_H_ */
241