xref: /freebsd/usr.sbin/ppp/radius.h (revision 744bfb213144c63cbaf38d91a1c4f7aebb9b9fbc)
1 /*
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright 1999 Internet Business Solutions Ltd., Switzerland
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  *
28  * $FreeBSD$
29  */
30 
31 #define	MPPE_POLICY_ALLOWED	1
32 #define	MPPE_POLICY_REQUIRED	2
33 
34 #define	MPPE_TYPE_40BIT		2
35 #define	MPPE_TYPE_128BIT	4
36 
37 #define	RPI_DEFAULT		1
38 #define	RPI_PID			2
39 #define	RPI_IFNUM		3
40 #define	RPI_TUNNUM		4
41 
42 struct radius {
43   struct fdescriptor desc;	/* We're a sort of (selectable) fdescriptor */
44   struct {
45     int fd;			/* We're selecting on this */
46     struct rad_handle *rad;	/* Using this to talk to our lib */
47     struct pppTimer timer;	/* for this long */
48     struct authinfo *auth;	/* Tell this about success/failure */
49   } cx;
50   unsigned valid : 1;           /* Is this structure valid ? */
51   unsigned vj : 1;              /* FRAMED Compression */
52   struct in_addr ip;            /* FRAMED IP */
53   struct in_addr mask;          /* FRAMED Netmask */
54   unsigned long mtu;            /* FRAMED MTU */
55   unsigned long sessiontime;    /* Session-Timeout */
56   char *filterid;		/* FRAMED Filter Id */
57   struct sticky_route *routes;  /* FRAMED Routes */
58   char *msrepstr;		/* MS-CHAP2-Response */
59   char *repstr;			/* Reply-Message */
60   char *errstr;			/* Error-Message */
61 #ifndef NOINET6
62   uint8_t *ipv6prefix;		/* FRAMED IPv6 Prefix */
63   struct sticky_route *ipv6routes;  /* FRAMED IPv6 Routes */
64 #endif
65   struct {
66     int policy;			/* MPPE_POLICY_* */
67     int types;			/* MPPE_TYPE_*BIT bitmask */
68     char *recvkey;
69     size_t recvkeylen;
70     char *sendkey;
71     size_t sendkeylen;
72   } mppe;
73   struct {
74     char file[PATH_MAX];	/* Radius config file */
75   } cfg;
76   struct {
77     struct pppTimer timer;	/* for this long */
78     int interval;
79   } alive;
80   short unsigned int port_id_type;
81 };
82 
83 struct radacct {
84   struct radius *rad_parent;	/* "Parent" struct radius stored in bundle */
85   char user_name[AUTHLEN];	/* Session User-Name */
86   char session_id[256];		/* Unique session ID */
87   char multi_session_id[51];	/* Unique MP session ID */
88   int  authentic;		/* How the session has been authenticated */
89   u_short proto;		/* Protocol number */
90   union {
91     struct {
92       struct in_addr addr;
93       struct in_addr mask;
94     } ip;
95 #ifndef NOINET6
96     struct {
97       u_char ifid[8];
98     } ipv6;
99 #endif
100   } peer;
101 };
102 
103 #define descriptor2radius(d) \
104   ((d)->type == RADIUS_DESCRIPTOR ? (struct radius *)(d) : NULL)
105 
106 struct bundle;
107 
108 extern void radius_Flush(struct radius *);
109 extern void radius_Init(struct radius *);
110 extern void radius_Destroy(struct radius *);
111 
112 extern void radius_Show(struct radius *, struct prompt *);
113 extern void radius_StartTimer(struct bundle *);
114 extern void radius_StopTimer(struct radius *);
115 extern int radius_Authenticate(struct radius *, struct authinfo *,
116                                const char *, const char *, int,
117                                const char *, int);
118 extern void radius_Account_Set_Ip(struct radacct *, struct in_addr *,
119 				  struct in_addr *);
120 #ifndef NOINET6
121 extern void radius_Account_Set_Ipv6(struct radacct *, u_char *);
122 #endif
123 extern void radius_Account(struct radius *, struct radacct *,
124                            struct datalink *, int, struct pppThroughput *);
125 
126 /* An (int) parameter to radius_Account, from radlib.h */
127 #if !defined(RAD_START)
128 #define RAD_START	1
129 #define RAD_STOP	2
130 #endif
131 
132 #define RAD_ALIVE	3
133 
134 /* Get address from NAS pool */
135 #define RADIUS_INADDR_POOL	htonl(0xfffffffe)	/* 255.255.255.254 */
136