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