radlib_private.h revision 43400
190075Sobrien/*-
2169689Skan * Copyright 1998 Juniper Networks, Inc.
3169689Skan * All rights reserved.
490075Sobrien *
590075Sobrien * Redistribution and use in source and binary forms, with or without
690075Sobrien * modification, are permitted provided that the following conditions
790075Sobrien * are met:
890075Sobrien * 1. Redistributions of source code must retain the above copyright
990075Sobrien *    notice, this list of conditions and the following disclaimer.
1090075Sobrien * 2. Redistributions in binary form must reproduce the above copyright
1190075Sobrien *    notice, this list of conditions and the following disclaimer in the
1290075Sobrien *    documentation and/or other materials provided with the distribution.
1390075Sobrien *
1490075Sobrien * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1590075Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1690075Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1790075Sobrien * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1890075Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1990075Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20169689Skan * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21169689Skan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2290075Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2390075Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2490075Sobrien * SUCH DAMAGE.
2590075Sobrien *
26132718Skan *	$FreeBSD: head/lib/libradius/radlib_private.h 43400 1999-01-29 22:44:47Z brian $
27169689Skan */
2890075Sobrien
29132718Skan#ifndef RADLIB_PRIVATE_H
3090075Sobrien#define RADLIB_PRIVATE_H
3190075Sobrien
32132718Skan#include <sys/types.h>
3390075Sobrien#include <netinet/in.h>
3490075Sobrien
3590075Sobrien#include "radlib.h"
3690075Sobrien
3790075Sobrien/* Defaults */
38117395Skan#define MAXTRIES		3
39117395Skan#define PATH_RADIUS_CONF	"/etc/radius.conf"
40117395Skan#define RADIUS_PORT		1812
41117395Skan#define TIMEOUT			3	/* In seconds */
42117395Skan
43117395Skan/* Limits */
44117395Skan#define ERRSIZE		128		/* Maximum error message length */
45117395Skan#define MAXCONFLINE	1024		/* Maximum config file line length */
46117395Skan#define MAXSERVERS	10		/* Maximum number of servers to try */
47169689Skan#define MSGSIZE		4096		/* Maximum RADIUS message */
48169689Skan#define PASSSIZE	128		/* Maximum significant password chars */
49117395Skan
50117395Skan/* Positions of fields in RADIUS messages */
5190075Sobrien#define POS_CODE	0		/* Message code */
5290075Sobrien#define POS_IDENT	1		/* Identifier */
5390075Sobrien#define POS_LENGTH	2		/* Message length */
54117395Skan#define POS_AUTH	4		/* Authenticator */
55117395Skan#define LEN_AUTH	16		/* Length of authenticator */
56132718Skan#define POS_ATTRS	20		/* Start of attributes */
57132718Skan
58117395Skanstruct rad_server {
59117395Skan	struct sockaddr_in addr;	/* Address of server */
6090075Sobrien	char		*secret;	/* Shared secret */
6190075Sobrien	int		 timeout;	/* Timeout in seconds */
6290075Sobrien	int		 max_tries;	/* Number of tries before giving up */
6390075Sobrien	int		 num_tries;	/* Number of tries so far */
64132718Skan};
65132718Skan
6690075Sobrienstruct rad_handle {
67117395Skan	int		 fd;		/* Socket file descriptor */
68117395Skan	struct rad_server servers[MAXSERVERS];	/* Servers to contact */
6990075Sobrien	int		 num_servers;	/* Number of valid server entries */
70117395Skan	int		 ident;		/* Current identifier value */
71117395Skan	char		 errmsg[ERRSIZE];	/* Most recent error message */
72169689Skan	unsigned char	 request[MSGSIZE];	/* Request to send */
73169689Skan	int		 req_len;	/* Length of request */
74169689Skan	char		 pass[PASSSIZE];	/* Cleartext password */
75169689Skan	int		 pass_len;	/* Length of cleartext password */
7690075Sobrien	int		 pass_pos;	/* Position of scrambled password */
77169689Skan	unsigned	 chap_pass : 1; /* Have we got a CHAP_PASSWORD ? */
78169689Skan	unsigned char	 response[MSGSIZE];	/* Response received */
79169689Skan	int		 resp_len;	/* Length of response */
80169689Skan	int		 resp_pos;	/* Current position scanning attrs */
81169689Skan};
82169689Skan
83169689Skan#endif
84169689Skan