sync
[bitrig.git] / usr.sbin / npppd / npppd / radius_req.h
blob2b354979112e301739029ff151ff3406d043752d
1 /* $OpenBSD: radius_req.h,v 1.6 2012/09/18 13:14:08 yasuoka Exp $ */
3 /*-
4 * Copyright (c) 2009 Internet Initiative Japan Inc.
5 * All rights reserved.
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.
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.
28 #ifndef RADIUS_REQ_H
29 #define RADIUS_REQ_H 1
31 /** maximum number of length for RADIUS shared secret */
32 #define MAX_RADIUS_SECRET 128
34 /** maximum number of RADIUS server */
35 #define MAX_RADIUS_SERVERS 16
37 /** RADIUS request failed */
38 #define RADIUS_REQUEST_ERROR 0x0001
40 /** RADIUS request timed out */
41 #define RADIUS_REQUEST_TIMEOUT 0x0002
43 /** response has valid authenticator */
44 #define RADIUS_REQUEST_CHECK_AUTHENTICATOR_OK 0x0010
46 /** authenticator is not checked */
47 #define RADIUS_REQUEST_CHECK_AUTHENTICATOR_NO_CHECK 0x0020
49 /** type for context to handle RADIUS request / response */
50 typedef void * RADIUS_REQUEST_CTX;
52 /** type for callback function to receive the RADIUS response */
53 typedef void (radius_response)(void *context, RADIUS_PACKET *pkt, int flags, RADIUS_REQUEST_CTX reqctx);
55 /** type for setting of RADIUS request */
56 typedef struct _radius_req_setting
58 /** RADIUS Servers */
59 struct {
60 /** Server's address */
61 union {
62 struct sockaddr_in6 sin6;
63 struct sockaddr_in sin4;
64 } peer;
65 /** Our address */
66 union {
67 struct sockaddr_in6 sin6;
68 struct sockaddr_in sin4;
69 } sock;
70 char secret[MAX_RADIUS_SECRET];
71 int enabled;
72 } server[MAX_RADIUS_SERVERS];
73 /** Index of current server */
74 int curr_server;
75 /** request timeout(in second) */
76 int timeout;
77 /** The maximum number of RADIUS request transmission */
78 int max_tries;
79 /** The maximum number of RADIUS request failover */
80 int max_failovers;
82 /** references by radius request */
83 int refcnt;
84 /** destroy is requested */
85 int destroyed;
87 } radius_req_setting;
89 #ifdef __cplusplus
90 extern "C" {
91 #endif
93 void radius_request (RADIUS_REQUEST_CTX, RADIUS_PACKET *);
94 int radius_prepare_nas_address (radius_req_setting *, RADIUS_PACKET *);
95 int radius_request_can_failover (RADIUS_REQUEST_CTX);
96 int radius_request_failover (RADIUS_REQUEST_CTX);
97 int radius_prepare (radius_req_setting *, void *, RADIUS_REQUEST_CTX *, radius_response);
98 void radius_cancel_request (RADIUS_REQUEST_CTX);
99 const char *radius_get_server_secret (RADIUS_REQUEST_CTX);
100 struct sockaddr *radius_get_server_address (RADIUS_REQUEST_CTX);
101 radius_req_setting *radius_req_setting_create (void);
102 int radius_req_setting_has_server(radius_req_setting *);
103 void radius_req_setting_destroy (radius_req_setting *);
105 #ifdef __cplusplus
107 #endif
109 #endif