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$ 2743313Sbrian */ 2843313Sbrian 2998132Sbrian#define MPPE_POLICY_ALLOWED 1 3098132Sbrian#define MPPE_POLICY_REQUIRED 2 3198132Sbrian 3298132Sbrian#define MPPE_TYPE_40BIT 2 3398132Sbrian#define MPPE_TYPE_128BIT 4 3498132Sbrian 35169986Snovel#define RPI_DEFAULT 1 36169986Snovel#define RPI_PID 2 37169986Snovel#define RPI_IFNUM 3 38169986Snovel#define RPI_TUNNUM 4 39169986Snovel 4043313Sbrianstruct radius { 4158028Sbrian struct fdescriptor desc; /* We're a sort of (selectable) fdescriptor */ 4243693Sbrian struct { 4343693Sbrian int fd; /* We're selecting on this */ 4443693Sbrian struct rad_handle *rad; /* Using this to talk to our lib */ 4543693Sbrian struct pppTimer timer; /* for this long */ 4643693Sbrian struct authinfo *auth; /* Tell this about success/failure */ 4743693Sbrian } cx; 4843313Sbrian unsigned valid : 1; /* Is this structure valid ? */ 4943313Sbrian unsigned vj : 1; /* FRAMED Compression */ 5043313Sbrian struct in_addr ip; /* FRAMED IP */ 5143313Sbrian struct in_addr mask; /* FRAMED Netmask */ 5243313Sbrian unsigned long mtu; /* FRAMED MTU */ 5396153Sbrian unsigned long sessiontime; /* Session-Timeout */ 5496153Sbrian char *filterid; /* FRAMED Filter Id */ 5543313Sbrian struct sticky_route *routes; /* FRAMED Routes */ 5696730Sbrian char *msrepstr; /* MS-CHAP2-Response */ 5796324Sbrian char *repstr; /* Reply-Message */ 5896324Sbrian char *errstr; /* Error-Message */ 59116586Sume#ifndef NOINET6 60116622Sume uint8_t *ipv6prefix; /* FRAMED IPv6 Prefix */ 61116586Sume struct sticky_route *ipv6routes; /* FRAMED IPv6 Routes */ 62116586Sume#endif 6343313Sbrian struct { 6498132Sbrian int policy; /* MPPE_POLICY_* */ 6598132Sbrian int types; /* MPPE_TYPE_*BIT bitmask */ 6698132Sbrian char *recvkey; 6798132Sbrian size_t recvkeylen; 6898132Sbrian char *sendkey; 6998132Sbrian size_t sendkeylen; 7098132Sbrian } mppe; 7198132Sbrian struct { 7274001Sbrian char file[PATH_MAX]; /* Radius config file */ 7343313Sbrian } cfg; 74132273Sbrian struct { 75132273Sbrian struct pppTimer timer; /* for this long */ 76132273Sbrian int interval; 77132273Sbrian } alive; 78169986Snovel short unsigned int port_id_type; 7943313Sbrian}; 8043313Sbrian 8165178Sbrianstruct radacct { 8265178Sbrian struct radius *rad_parent; /* "Parent" struct radius stored in bundle */ 8365178Sbrian char user_name[AUTHLEN]; /* Session User-Name */ 8465178Sbrian char session_id[256]; /* Unique session ID */ 8565178Sbrian char multi_session_id[51]; /* Unique MP session ID */ 8665178Sbrian int authentic; /* How the session has been authenticated */ 87116588Sume u_short proto; /* Protocol number */ 88116588Sume union { 89116588Sume struct { 90116588Sume struct in_addr addr; 91116588Sume struct in_addr mask; 92116588Sume } ip; 93116588Sume#ifndef NOINET6 94116588Sume struct { 95116588Sume u_char ifid[8]; 96116588Sume } ipv6; 97116588Sume#endif 98116990Sume } peer; 9965178Sbrian}; 10065178Sbrian 10143693Sbrian#define descriptor2radius(d) \ 10243693Sbrian ((d)->type == RADIUS_DESCRIPTOR ? (struct radius *)(d) : NULL) 10343693Sbrian 10443313Sbrianstruct bundle; 10543313Sbrian 106140905Sbrianextern void radius_Flush(struct radius *); 10743313Sbrianextern void radius_Init(struct radius *); 10843313Sbrianextern void radius_Destroy(struct radius *); 10943313Sbrian 11043313Sbrianextern void radius_Show(struct radius *, struct prompt *); 111132273Sbrianextern void radius_StartTimer(struct bundle *); 112132273Sbrianextern void radius_StopTimer(struct radius *); 11396730Sbrianextern int radius_Authenticate(struct radius *, struct authinfo *, 11496730Sbrian const char *, const char *, int, 11598311Sbrian const char *, int); 116116588Sumeextern void radius_Account_Set_Ip(struct radacct *, struct in_addr *, 117116588Sume struct in_addr *); 118116588Sume#ifndef NOINET6 119116588Sumeextern void radius_Account_Set_Ipv6(struct radacct *, u_char *); 120116588Sume#endif 12198243Sbrianextern void radius_Account(struct radius *, struct radacct *, 122116588Sume struct datalink *, int, struct pppThroughput *); 12365178Sbrian 12465178Sbrian/* An (int) parameter to radius_Account, from radlib.h */ 12565178Sbrian#if !defined(RAD_START) 12665178Sbrian#define RAD_START 1 12765178Sbrian#define RAD_STOP 2 12865178Sbrian#endif 12993767Shosokawa 130132273Sbrian#define RAD_ALIVE 3 131132273Sbrian 13293767Shosokawa/* Get address from NAS pool */ 13393767Shosokawa#define RADIUS_INADDR_POOL htonl(0xfffffffe) /* 255.255.255.254 */ 134