radlib_private.h revision 128684
141118Sjdp/*- 241118Sjdp * Copyright 1998 Juniper Networks, Inc. 341118Sjdp * All rights reserved. 441118Sjdp * 541118Sjdp * Redistribution and use in source and binary forms, with or without 641118Sjdp * modification, are permitted provided that the following conditions 741118Sjdp * are met: 841118Sjdp * 1. Redistributions of source code must retain the above copyright 941118Sjdp * notice, this list of conditions and the following disclaimer. 1041118Sjdp * 2. Redistributions in binary form must reproduce the above copyright 1141118Sjdp * notice, this list of conditions and the following disclaimer in the 1241118Sjdp * documentation and/or other materials provided with the distribution. 1341118Sjdp * 1441118Sjdp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1541118Sjdp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1641118Sjdp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1741118Sjdp * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1841118Sjdp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1941118Sjdp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2041118Sjdp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2141118Sjdp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2241118Sjdp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2341118Sjdp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2441118Sjdp * SUCH DAMAGE. 2541118Sjdp * 2641118Sjdp * $FreeBSD: head/lib/libradius/radlib_private.h 128684 2004-04-27 15:00:29Z ru $ 2741118Sjdp */ 2841118Sjdp 2941118Sjdp#ifndef RADLIB_PRIVATE_H 3041118Sjdp#define RADLIB_PRIVATE_H 3141118Sjdp 3241118Sjdp#include <sys/types.h> 3341118Sjdp#include <netinet/in.h> 3441118Sjdp 3541118Sjdp#include "radlib.h" 3696154Sbrian#include "radlib_vs.h" 3741118Sjdp 3852709Sjdp/* Handle types */ 3952709Sjdp#define RADIUS_AUTH 0 /* RADIUS authentication, default */ 4052709Sjdp#define RADIUS_ACCT 1 /* RADIUS accounting */ 4152709Sjdp 4241118Sjdp/* Defaults */ 4341118Sjdp#define MAXTRIES 3 4441118Sjdp#define PATH_RADIUS_CONF "/etc/radius.conf" 4541118Sjdp#define RADIUS_PORT 1812 4652709Sjdp#define RADACCT_PORT 1813 4741118Sjdp#define TIMEOUT 3 /* In seconds */ 4841118Sjdp 4941118Sjdp/* Limits */ 5041118Sjdp#define ERRSIZE 128 /* Maximum error message length */ 5141118Sjdp#define MAXCONFLINE 1024 /* Maximum config file line length */ 5241118Sjdp#define MAXSERVERS 10 /* Maximum number of servers to try */ 5341118Sjdp#define MSGSIZE 4096 /* Maximum RADIUS message */ 5441118Sjdp#define PASSSIZE 128 /* Maximum significant password chars */ 5541118Sjdp 5641118Sjdp/* Positions of fields in RADIUS messages */ 5741118Sjdp#define POS_CODE 0 /* Message code */ 5841118Sjdp#define POS_IDENT 1 /* Identifier */ 5941118Sjdp#define POS_LENGTH 2 /* Message length */ 6041118Sjdp#define POS_AUTH 4 /* Authenticator */ 6141118Sjdp#define LEN_AUTH 16 /* Length of authenticator */ 6241118Sjdp#define POS_ATTRS 20 /* Start of attributes */ 6341118Sjdp 6441118Sjdpstruct rad_server { 6541118Sjdp struct sockaddr_in addr; /* Address of server */ 6641118Sjdp char *secret; /* Shared secret */ 6741118Sjdp int timeout; /* Timeout in seconds */ 6841118Sjdp int max_tries; /* Number of tries before giving up */ 6941118Sjdp int num_tries; /* Number of tries so far */ 7041118Sjdp}; 7141118Sjdp 7241118Sjdpstruct rad_handle { 7341118Sjdp int fd; /* Socket file descriptor */ 7441118Sjdp struct rad_server servers[MAXSERVERS]; /* Servers to contact */ 7541118Sjdp int num_servers; /* Number of valid server entries */ 7641118Sjdp int ident; /* Current identifier value */ 7741118Sjdp char errmsg[ERRSIZE]; /* Most recent error message */ 7841118Sjdp unsigned char request[MSGSIZE]; /* Request to send */ 79128684Sru char request_created; /* rad_create_request() called? */ 8041118Sjdp int req_len; /* Length of request */ 8141118Sjdp char pass[PASSSIZE]; /* Cleartext password */ 8241118Sjdp int pass_len; /* Length of cleartext password */ 8341118Sjdp int pass_pos; /* Position of scrambled password */ 8443662Sbrian char chap_pass; /* Have we got a CHAP_PASSWORD ? */ 85128684Sru int authentic_pos; /* Position of message authenticator */ 86128684Sru char eap_msg; /* Are we an EAP Proxy? */ 8741118Sjdp unsigned char response[MSGSIZE]; /* Response received */ 8841118Sjdp int resp_len; /* Length of response */ 8941118Sjdp int resp_pos; /* Current position scanning attrs */ 9043662Sbrian int total_tries; /* How many requests we'll send */ 9143662Sbrian int try; /* How many requests we've sent */ 9243662Sbrian int srv; /* Server number we did last */ 9352709Sjdp int type; /* Handle type */ 9441118Sjdp}; 9541118Sjdp 9696154Sbrianstruct vendor_attribute { 9796154Sbrian u_int32_t vendor_value; 9896154Sbrian u_char attrib_type; 9996154Sbrian u_char attrib_len; 10096154Sbrian u_char attrib_data[1]; 10196154Sbrian}; 10296154Sbrian 10341118Sjdp#endif 104