• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 1999 Internet Business Solutions Ltd., Switzerland
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
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.
13  *
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
24  * SUCH DAMAGE.
25  *
26  * $FreeBSD: src/usr.sbin/ppp/radius.h,v 1.22.14.1 2010/12/21 17:10:29 kensmith Exp $
27  */
28 
29 #define	MPPE_POLICY_ALLOWED	1
30 #define	MPPE_POLICY_REQUIRED	2
31 
32 #define	MPPE_TYPE_40BIT		2
33 #define	MPPE_TYPE_128BIT	4
34 
35 #define	RPI_DEFAULT		1
36 #define	RPI_PID			2
37 #define	RPI_IFNUM		3
38 #define	RPI_TUNNUM		4
39 
40 struct radius {
41   struct fdescriptor desc;	/* We're a sort of (selectable) fdescriptor */
42   struct {
43     int fd;			/* We're selecting on this */
44     struct rad_handle *rad;	/* Using this to talk to our lib */
45     struct pppTimer timer;	/* for this long */
46     struct authinfo *auth;	/* Tell this about success/failure */
47   } cx;
48   unsigned valid : 1;           /* Is this structure valid ? */
49   unsigned vj : 1;              /* FRAMED Compression */
50   struct in_addr ip;            /* FRAMED IP */
51   struct in_addr mask;          /* FRAMED Netmask */
52   unsigned long mtu;            /* FRAMED MTU */
53   unsigned long sessiontime;    /* Session-Timeout */
54   char *filterid;		/* FRAMED Filter Id */
55   struct sticky_route *routes;  /* FRAMED Routes */
56   char *msrepstr;		/* MS-CHAP2-Response */
57   char *repstr;			/* Reply-Message */
58   char *errstr;			/* Error-Message */
59 #ifndef NOINET6
60   uint8_t *ipv6prefix;		/* FRAMED IPv6 Prefix */
61   struct sticky_route *ipv6routes;  /* FRAMED IPv6 Routes */
62 #endif
63   struct {
64     int policy;			/* MPPE_POLICY_* */
65     int types;			/* MPPE_TYPE_*BIT bitmask */
66     char *recvkey;
67     size_t recvkeylen;
68     char *sendkey;
69     size_t sendkeylen;
70   } mppe;
71   struct {
72     char file[PATH_MAX];	/* Radius config file */
73   } cfg;
74   struct {
75     struct pppTimer timer;	/* for this long */
76     int interval;
77   } alive;
78   short unsigned int port_id_type;
79 };
80 
81 struct radacct {
82   struct radius *rad_parent;	/* "Parent" struct radius stored in bundle */
83   char user_name[AUTHLEN];	/* Session User-Name */
84   char session_id[256];		/* Unique session ID */
85   char multi_session_id[51];	/* Unique MP session ID */
86   int  authentic;		/* How the session has been authenticated */
87   u_short proto;		/* Protocol number */
88   union {
89     struct {
90       struct in_addr addr;
91       struct in_addr mask;
92     } ip;
93 #ifndef NOINET6
94     struct {
95       u_char ifid[8];
96     } ipv6;
97 #endif
98   } peer;
99 };
100 
101 #define descriptor2radius(d) \
102   ((d)->type == RADIUS_DESCRIPTOR ? (struct radius *)(d) : NULL)
103 
104 struct bundle;
105 
106 extern void radius_Flush(struct radius *);
107 extern void radius_Init(struct radius *);
108 extern void radius_Destroy(struct radius *);
109 
110 extern void radius_Show(struct radius *, struct prompt *);
111 extern void radius_StartTimer(struct bundle *);
112 extern void radius_StopTimer(struct radius *);
113 extern int radius_Authenticate(struct radius *, struct authinfo *,
114                                const char *, const char *, int,
115                                const char *, int);
116 extern void radius_Account_Set_Ip(struct radacct *, struct in_addr *,
117 				  struct in_addr *);
118 #ifndef NOINET6
119 extern void radius_Account_Set_Ipv6(struct radacct *, u_char *);
120 #endif
121 extern void radius_Account(struct radius *, struct radacct *,
122                            struct datalink *, int, struct pppThroughput *);
123 
124 /* An (int) parameter to radius_Account, from radlib.h */
125 #if !defined(RAD_START)
126 #define RAD_START	1
127 #define RAD_STOP	2
128 #endif
129 
130 #define RAD_ALIVE	3
131 
132 /* Get address from NAS pool */
133 #define RADIUS_INADDR_POOL	htonl(0xfffffffe)	/* 255.255.255.254 */
134