Home | History | Annotate | Download | only in radius
      1 /*
      2  * hostapd / RADIUS client
      3  * Copyright (c) 2002-2005, Jouni Malinen <j (at) 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 "ip_addr.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 	struct hostapd_ip_addr client_addr;
     62 	int force_client_addr;
     63 };
     64 
     65 
     66 typedef enum {
     67 	RADIUS_AUTH,
     68 	RADIUS_ACCT,
     69 	RADIUS_ACCT_INTERIM /* used only with radius_client_send(); just like
     70 			     * RADIUS_ACCT, but removes any pending interim
     71 			     * RADIUS Accounting packages for the same STA
     72 			     * before sending the new interim update */
     73 } RadiusType;
     74 
     75 typedef enum {
     76 	RADIUS_RX_PROCESSED,
     77 	RADIUS_RX_QUEUED,
     78 	RADIUS_RX_UNKNOWN,
     79 	RADIUS_RX_INVALID_AUTHENTICATOR
     80 } RadiusRxResult;
     81 
     82 struct radius_client_data;
     83 
     84 int radius_client_register(struct radius_client_data *radius,
     85 			   RadiusType msg_type,
     86 			   RadiusRxResult (*handler)
     87 			   (struct radius_msg *msg, struct radius_msg *req,
     88 			    const u8 *shared_secret, size_t shared_secret_len,
     89 			    void *data),
     90 			   void *data);
     91 int radius_client_send(struct radius_client_data *radius,
     92 		       struct radius_msg *msg,
     93 		       RadiusType msg_type, const u8 *addr);
     94 u8 radius_client_get_id(struct radius_client_data *radius);
     95 
     96 void radius_client_flush(struct radius_client_data *radius, int only_auth);
     97 struct radius_client_data *
     98 radius_client_init(void *ctx, struct hostapd_radius_servers *conf);
     99 void radius_client_deinit(struct radius_client_data *radius);
    100 void radius_client_flush_auth(struct radius_client_data *radius, u8 *addr);
    101 int radius_client_get_mib(struct radius_client_data *radius, char *buf,
    102 			  size_t buflen);
    103 struct radius_client_data *
    104 radius_client_reconfig(struct radius_client_data *old, void *ctx,
    105 		       struct hostapd_radius_servers *oldconf,
    106 		       struct hostapd_radius_servers *newconf);
    107 
    108 #endif /* RADIUS_CLIENT_H */
    109