radius.h revision 96730
143313Sbrian/*
243313Sbrian * Copyright 1999 Internet Business Solutions Ltd., Switzerland
343313Sbrian * All rights reserved.
443313Sbrian *
543313Sbrian * Redistribution and use in source and binary forms, with or without
643313Sbrian * modification, are permitted provided that the following conditions
743313Sbrian * are met:
843313Sbrian * 1. Redistributions of source code must retain the above copyright
943313Sbrian *    notice, this list of conditions and the following disclaimer.
1043313Sbrian * 2. Redistributions in binary form must reproduce the above copyright
1143313Sbrian *    notice, this list of conditions and the following disclaimer in the
1243313Sbrian *    documentation and/or other materials provided with the distribution.
1343313Sbrian *
1443313Sbrian * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1543313Sbrian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1643313Sbrian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1743313Sbrian * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1843313Sbrian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1943313Sbrian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2043313Sbrian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2143313Sbrian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2243313Sbrian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2343313Sbrian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2443313Sbrian * SUCH DAMAGE.
2543313Sbrian *
2650479Speter * $FreeBSD: head/usr.sbin/ppp/radius.h 96730 2002-05-16 13:34:20Z brian $
2743313Sbrian */
2843313Sbrian
2943313Sbrianstruct radius {
3058028Sbrian  struct fdescriptor desc;	/* We're a sort of (selectable) fdescriptor */
3143693Sbrian  struct {
3243693Sbrian    int fd;			/* We're selecting on this */
3343693Sbrian    struct rad_handle *rad;	/* Using this to talk to our lib */
3443693Sbrian    struct pppTimer timer;	/* for this long */
3543693Sbrian    struct authinfo *auth;	/* Tell this about success/failure */
3643693Sbrian  } cx;
3743313Sbrian  unsigned valid : 1;           /* Is this structure valid ? */
3843313Sbrian  unsigned vj : 1;              /* FRAMED Compression */
3943313Sbrian  struct in_addr ip;            /* FRAMED IP */
4043313Sbrian  struct in_addr mask;          /* FRAMED Netmask */
4143313Sbrian  unsigned long mtu;            /* FRAMED MTU */
4296153Sbrian  unsigned long sessiontime;    /* Session-Timeout */
4396153Sbrian  char *filterid;		/* FRAMED Filter Id */
4443313Sbrian  struct sticky_route *routes;  /* FRAMED Routes */
4596730Sbrian  char *msrepstr;		/* MS-CHAP2-Response */
4696324Sbrian  char *repstr;			/* Reply-Message */
4796324Sbrian  char *errstr;			/* Error-Message */
4843313Sbrian  struct {
4974001Sbrian    char file[PATH_MAX];	/* Radius config file */
5043313Sbrian  } cfg;
5143313Sbrian};
5243313Sbrian
5365178Sbrianstruct radacct {
5465178Sbrian  struct radius *rad_parent;	/* "Parent" struct radius stored in bundle */
5565178Sbrian  char user_name[AUTHLEN];	/* Session User-Name */
5665178Sbrian  char session_id[256];		/* Unique session ID */
5765178Sbrian  char multi_session_id[51];	/* Unique MP session ID */
5865178Sbrian  int  authentic;		/* How the session has been authenticated */
5965178Sbrian  struct in_addr ip;
6065178Sbrian  struct in_addr mask;
6165178Sbrian};
6265178Sbrian
6343693Sbrian#define descriptor2radius(d) \
6443693Sbrian  ((d)->type == RADIUS_DESCRIPTOR ? (struct radius *)(d) : NULL)
6543693Sbrian
6643313Sbrianstruct bundle;
6743313Sbrian
6843313Sbrianextern void radius_Init(struct radius *);
6943313Sbrianextern void radius_Destroy(struct radius *);
7043313Sbrian
7143313Sbrianextern void radius_Show(struct radius *, struct prompt *);
7296730Sbrianextern int radius_Authenticate(struct radius *, struct authinfo *,
7396730Sbrian                               const char *, const char *, int,
7496730Sbrian                               const char *, int, const char *, int);
7565178Sbrianextern void radius_Account(struct radius *, struct radacct *,
7665178Sbrian                           struct datalink *, int, struct in_addr *,
7765178Sbrian                           struct in_addr *, struct pppThroughput *);
7865178Sbrian
7965178Sbrian/* An (int) parameter to radius_Account, from radlib.h */
8065178Sbrian#if !defined(RAD_START)
8165178Sbrian#define RAD_START	1
8265178Sbrian#define RAD_STOP	2
8365178Sbrian#endif
8493767Shosokawa
8593767Shosokawa/* Get address from NAS pool */
8693767Shosokawa#define RADIUS_INADDR_POOL	htonl(0xfffffffe)	/* 255.255.255.254 */
87