1 1.4 lukem /* $NetBSD: radlib_private.h,v 1.4 2009/01/19 07:21:59 lukem Exp $ */ 2 1.1 manu 3 1.1 manu /*- 4 1.1 manu * Copyright 1998 Juniper Networks, Inc. 5 1.1 manu * All rights reserved. 6 1.1 manu * 7 1.1 manu * Redistribution and use in source and binary forms, with or without 8 1.1 manu * modification, are permitted provided that the following conditions 9 1.1 manu * are met: 10 1.1 manu * 1. Redistributions of source code must retain the above copyright 11 1.1 manu * notice, this list of conditions and the following disclaimer. 12 1.1 manu * 2. Redistributions in binary form must reproduce the above copyright 13 1.1 manu * notice, this list of conditions and the following disclaimer in the 14 1.1 manu * documentation and/or other materials provided with the distribution. 15 1.1 manu * 16 1.1 manu * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 1.1 manu * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 1.1 manu * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 1.1 manu * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 1.1 manu * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 1.1 manu * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 1.1 manu * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 1.1 manu * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 1.1 manu * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 1.1 manu * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 1.1 manu * SUCH DAMAGE. 27 1.1 manu * 28 1.1 manu * $FreeBSD: /repoman/r/ncvs/src/lib/libradius/radlib_private.h,v 1.6 2004/04/27 15:00:29 ru Exp $ 29 1.1 manu */ 30 1.1 manu 31 1.1 manu #ifndef RADLIB_PRIVATE_H 32 1.1 manu #define RADLIB_PRIVATE_H 33 1.1 manu 34 1.1 manu #include <sys/types.h> 35 1.1 manu #include <netinet/in.h> 36 1.1 manu 37 1.1 manu #include "radlib.h" 38 1.1 manu #include "radlib_vs.h" 39 1.1 manu 40 1.1 manu /* Handle types */ 41 1.1 manu #define RADIUS_AUTH 0 /* RADIUS authentication, default */ 42 1.1 manu #define RADIUS_ACCT 1 /* RADIUS accounting */ 43 1.1 manu 44 1.1 manu /* Defaults */ 45 1.1 manu #define MAXTRIES 3 46 1.1 manu #define PATH_RADIUS_CONF "/etc/radius.conf" 47 1.1 manu #define RADIUS_PORT 1812 48 1.1 manu #define RADACCT_PORT 1813 49 1.1 manu #define TIMEOUT 3 /* In seconds */ 50 1.1 manu 51 1.1 manu /* Limits */ 52 1.1 manu #define ERRSIZE 128 /* Maximum error message length */ 53 1.1 manu #define MAXCONFLINE 1024 /* Maximum config file line length */ 54 1.1 manu #define MAXSERVERS 10 /* Maximum number of servers to try */ 55 1.1 manu #define MSGSIZE 4096 /* Maximum RADIUS message */ 56 1.1 manu #define PASSSIZE 128 /* Maximum significant password chars */ 57 1.1 manu 58 1.1 manu /* Positions of fields in RADIUS messages */ 59 1.1 manu #define POS_CODE 0 /* Message code */ 60 1.1 manu #define POS_IDENT 1 /* Identifier */ 61 1.1 manu #define POS_LENGTH 2 /* Message length */ 62 1.1 manu #define POS_AUTH 4 /* Authenticator */ 63 1.1 manu #define LEN_AUTH 16 /* Length of authenticator */ 64 1.1 manu #define POS_ATTRS 20 /* Start of attributes */ 65 1.1 manu 66 1.1 manu struct rad_server { 67 1.1 manu struct sockaddr_in addr; /* Address of server */ 68 1.1 manu char *secret; /* Shared secret */ 69 1.1 manu int timeout; /* Timeout in seconds */ 70 1.1 manu int max_tries; /* Number of tries before giving up */ 71 1.1 manu int num_tries; /* Number of tries so far */ 72 1.1 manu }; 73 1.1 manu 74 1.1 manu struct rad_handle { 75 1.1 manu int fd; /* Socket file descriptor */ 76 1.1 manu struct rad_server servers[MAXSERVERS]; /* Servers to contact */ 77 1.3 christos size_t num_servers; /* Number of valid server entries */ 78 1.1 manu int ident; /* Current identifier value */ 79 1.1 manu char errmsg[ERRSIZE]; /* Most recent error message */ 80 1.1 manu unsigned char request[MSGSIZE]; /* Request to send */ 81 1.1 manu char request_created; /* rad_create_request() called? */ 82 1.2 christos size_t req_len; /* Length of request */ 83 1.1 manu char pass[PASSSIZE]; /* Cleartext password */ 84 1.1 manu size_t pass_len; /* Length of cleartext password */ 85 1.3 christos size_t pass_pos; /* Position of scrambled password */ 86 1.1 manu char chap_pass; /* Have we got a CHAP_PASSWORD ? */ 87 1.3 christos size_t authentic_pos; /* Position of message authenticator */ 88 1.1 manu char eap_msg; /* Are we an EAP Proxy? */ 89 1.1 manu unsigned char response[MSGSIZE]; /* Response received */ 90 1.1 manu size_t resp_len; /* Length of response */ 91 1.3 christos size_t resp_pos; /* Current position scanning attrs */ 92 1.3 christos size_t total_tries; /* How many requests we'll send */ 93 1.3 christos size_t try; /* How many requests we've sent */ 94 1.4 lukem size_t srv; /* Server number we did last */ 95 1.1 manu int type; /* Handle type */ 96 1.1 manu }; 97 1.1 manu 98 1.1 manu struct vendor_attribute { 99 1.1 manu u_int32_t vendor_value; 100 1.1 manu u_char attrib_type; 101 1.1 manu u_char attrib_len; 102 1.1 manu u_char attrib_data[1]; 103 1.1 manu }; 104 1.1 manu 105 1.1 manu #endif 106