radius.h revision 116990
190075Sobrien/*
290075Sobrien * Copyright 1999 Internet Business Solutions Ltd., Switzerland
3132718Skan * All rights reserved.
490075Sobrien *
590075Sobrien * Redistribution and use in source and binary forms, with or without
6132718Skan * modification, are permitted provided that the following conditions
790075Sobrien * are met:
8132718Skan * 1. Redistributions of source code must retain the above copyright
9132718Skan *    notice, this list of conditions and the following disclaimer.
10132718Skan * 2. Redistributions in binary form must reproduce the above copyright
11132718Skan *    notice, this list of conditions and the following disclaimer in the
1290075Sobrien *    documentation and/or other materials provided with the distribution.
13132718Skan *
14132718Skan * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15132718Skan * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16132718Skan * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1790075Sobrien * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18132718Skan * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19132718Skan * 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
24132718Skan * SUCH DAMAGE.
2590075Sobrien *
2690075Sobrien * $FreeBSD: head/usr.sbin/ppp/radius.h 116990 2003-06-28 15:37:04Z ume $
27132718Skan */
2890075Sobrien
2990075Sobrien#define	MPPE_POLICY_ALLOWED	1
30132718Skan#define	MPPE_POLICY_REQUIRED	2
3190075Sobrien
32#define	MPPE_TYPE_40BIT		2
33#define	MPPE_TYPE_128BIT	4
34
35struct radius {
36  struct fdescriptor desc;	/* We're a sort of (selectable) fdescriptor */
37  struct {
38    int fd;			/* We're selecting on this */
39    struct rad_handle *rad;	/* Using this to talk to our lib */
40    struct pppTimer timer;	/* for this long */
41    struct authinfo *auth;	/* Tell this about success/failure */
42  } cx;
43  unsigned valid : 1;           /* Is this structure valid ? */
44  unsigned vj : 1;              /* FRAMED Compression */
45  struct in_addr ip;            /* FRAMED IP */
46  struct in_addr mask;          /* FRAMED Netmask */
47  unsigned long mtu;            /* FRAMED MTU */
48  unsigned long sessiontime;    /* Session-Timeout */
49  char *filterid;		/* FRAMED Filter Id */
50  struct sticky_route *routes;  /* FRAMED Routes */
51  char *msrepstr;		/* MS-CHAP2-Response */
52  char *repstr;			/* Reply-Message */
53  char *errstr;			/* Error-Message */
54#ifndef NOINET6
55  uint8_t *ipv6prefix;		/* FRAMED IPv6 Prefix */
56  struct sticky_route *ipv6routes;  /* FRAMED IPv6 Routes */
57#endif
58  struct {
59    int policy;			/* MPPE_POLICY_* */
60    int types;			/* MPPE_TYPE_*BIT bitmask */
61    char *recvkey;
62    size_t recvkeylen;
63    char *sendkey;
64    size_t sendkeylen;
65  } mppe;
66  struct {
67    char file[PATH_MAX];	/* Radius config file */
68  } cfg;
69};
70
71struct radacct {
72  struct radius *rad_parent;	/* "Parent" struct radius stored in bundle */
73  char user_name[AUTHLEN];	/* Session User-Name */
74  char session_id[256];		/* Unique session ID */
75  char multi_session_id[51];	/* Unique MP session ID */
76  int  authentic;		/* How the session has been authenticated */
77  u_short proto;		/* Protocol number */
78  union {
79    struct {
80      struct in_addr addr;
81      struct in_addr mask;
82    } ip;
83#ifndef NOINET6
84    struct {
85      u_char ifid[8];
86    } ipv6;
87#endif
88  } peer;
89};
90
91#define descriptor2radius(d) \
92  ((d)->type == RADIUS_DESCRIPTOR ? (struct radius *)(d) : NULL)
93
94struct bundle;
95
96extern void radius_Init(struct radius *);
97extern void radius_Destroy(struct radius *);
98
99extern void radius_Show(struct radius *, struct prompt *);
100extern int radius_Authenticate(struct radius *, struct authinfo *,
101                               const char *, const char *, int,
102                               const char *, int);
103extern void radius_Account_Set_Ip(struct radacct *, struct in_addr *,
104				  struct in_addr *);
105#ifndef NOINET6
106extern void radius_Account_Set_Ipv6(struct radacct *, u_char *);
107#endif
108extern void radius_Account(struct radius *, struct radacct *,
109                           struct datalink *, int, struct pppThroughput *);
110
111/* An (int) parameter to radius_Account, from radlib.h */
112#if !defined(RAD_START)
113#define RAD_START	1
114#define RAD_STOP	2
115#endif
116
117/* Get address from NAS pool */
118#define RADIUS_INADDR_POOL	htonl(0xfffffffe)	/* 255.255.255.254 */
119