df1ba1f9b209f39a1eeb019e4f8e015af356b091
[dragonfly.git] / contrib / hostapd-0.5.8 / radius_client.h
1 /*
2  * hostapd / RADIUS client
3  * Copyright (c) 2002-2005, Jouni Malinen <j@w1.fi>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation.
8  *
9  * Alternatively, this software may be distributed under the terms of BSD
10  * license.
11  *
12  * See README and COPYING for more details.
13  */
14
15 #ifndef RADIUS_CLIENT_H
16 #define RADIUS_CLIENT_H
17
18 #include "config_types.h"
19
20 struct radius_msg;
21
22 struct hostapd_radius_server {
23         /* MIB prefix for shared variables:
24          * @ = radiusAuth or radiusAcc depending on the type of the server */
25         struct hostapd_ip_addr addr; /* @ServerAddress */
26         int port; /* @ClientServerPortNumber */
27         u8 *shared_secret;
28         size_t shared_secret_len;
29
30         /* Dynamic (not from configuration file) MIB data */
31         int index; /* @ServerIndex */
32         int round_trip_time; /* @ClientRoundTripTime; in hundredths of a
33                               * second */
34         u32 requests; /* @Client{Access,}Requests */
35         u32 retransmissions; /* @Client{Access,}Retransmissions */
36         u32 access_accepts; /* radiusAuthClientAccessAccepts */
37         u32 access_rejects; /* radiusAuthClientAccessRejects */
38         u32 access_challenges; /* radiusAuthClientAccessChallenges */
39         u32 responses; /* radiusAccClientResponses */
40         u32 malformed_responses; /* @ClientMalformed{Access,}Responses */
41         u32 bad_authenticators; /* @ClientBadAuthenticators */
42         u32 timeouts; /* @ClientTimeouts */
43         u32 unknown_types; /* @ClientUnknownTypes */
44         u32 packets_dropped; /* @ClientPacketsDropped */
45         /* @ClientPendingRequests: length of hapd->radius->msgs for matching
46          * msg_type */
47 };
48
49 struct hostapd_radius_servers {
50         /* RADIUS Authentication and Accounting servers in priority order */
51         struct hostapd_radius_server *auth_servers, *auth_server;
52         int num_auth_servers;
53         struct hostapd_radius_server *acct_servers, *acct_server;
54         int num_acct_servers;
55
56         int retry_primary_interval;
57         int acct_interim_interval;
58
59         int msg_dumps;
60 };
61
62
63 typedef enum {
64         RADIUS_AUTH,
65         RADIUS_ACCT,
66         RADIUS_ACCT_INTERIM /* used only with radius_client_send(); just like
67                              * RADIUS_ACCT, but removes any pending interim
68                              * RADIUS Accounting packages for the same STA
69                              * before sending the new interim update */
70 } RadiusType;
71
72 typedef enum {
73         RADIUS_RX_PROCESSED,
74         RADIUS_RX_QUEUED,
75         RADIUS_RX_UNKNOWN,
76         RADIUS_RX_INVALID_AUTHENTICATOR
77 } RadiusRxResult;
78
79 struct radius_client_data;
80
81 int radius_client_register(struct radius_client_data *radius,
82                            RadiusType msg_type,
83                            RadiusRxResult (*handler)
84                            (struct radius_msg *msg, struct radius_msg *req,
85                             u8 *shared_secret, size_t shared_secret_len,
86                             void *data),
87                            void *data);
88 int radius_client_send(struct radius_client_data *radius,
89                        struct radius_msg *msg,
90                        RadiusType msg_type, const u8 *addr);
91 u8 radius_client_get_id(struct radius_client_data *radius);
92
93 void radius_client_flush(struct radius_client_data *radius, int only_auth);
94 struct radius_client_data *
95 radius_client_init(void *ctx, struct hostapd_radius_servers *conf);
96 void radius_client_deinit(struct radius_client_data *radius);
97 void radius_client_flush_auth(struct radius_client_data *radius, u8 *addr);
98 int radius_client_get_mib(struct radius_client_data *radius, char *buf,
99                           size_t buflen);
100 struct radius_client_data *
101 radius_client_reconfig(struct radius_client_data *old, void *ctx,
102                        struct hostapd_radius_servers *oldconf,
103                        struct hostapd_radius_servers *newconf);
104
105 #endif /* RADIUS_CLIENT_H */