From: Alexandr D. Kanevskiy Date: Fri, 26 Mar 2004 13:27:17 +0000 (+0000) Subject: Describe avpair in pppd-radius.8 X-Git-Tag: ppp-2.4.7~247 X-Git-Url: https://git.ozlabs.org/?a=commitdiff_plain;h=9de3e97a61ecec98a465be8b518d2d7c1cbc7460;hp=2a7288026268a2a4bcbb622e496ebe77b4f66e6e;p=ppp.git Describe avpair in pppd-radius.8 Add support for: NAS-Port-Type (Async/Virtual) Acct-Terminate-Cause Selectable NAS-Port-Id equal to interface number or try map via libradiusclient --- diff --git a/pppd/plugins/radius/pppd-radius.8 b/pppd/plugins/radius/pppd-radius.8 index 516c96d..a8c103c 100644 --- a/pppd/plugins/radius/pppd-radius.8 +++ b/pppd/plugins/radius/pppd-radius.8 @@ -1,5 +1,5 @@ .\" manual page [] for RADIUS plugin for pppd 2.4 -.\" $Id: pppd-radius.8,v 1.4 2002/04/02 13:55:00 dfs Exp $ +.\" $Id: pppd-radius.8,v 1.5 2004/03/26 13:27:17 kad Exp $ .\" SH section heading .\" SS subsection heading .\" LP paragraph @@ -40,6 +40,15 @@ is taken as the radiusclient configuration file. If this option is not used, then the plugin uses .I /etc/radiusclient/radiusclient.conf as the configuration file. +.TP +.BI "avpair " attribute=value +Adds an Attribute-Value pair to be passed on to the RADIUS server on each request. +.TP +.BI map-to-ifname +Sets Radius NAS-Port attribute to number equal to interface name (Default) +.TP +.BI map-to-ttyname +Sets Radius NAS-Port attribute value via libradiusclient library .SH USAGE To use the plugin, simply supply the diff --git a/pppd/plugins/radius/radius.c b/pppd/plugins/radius/radius.c index 4bed565..67d18fd 100644 --- a/pppd/plugins/radius/radius.c +++ b/pppd/plugins/radius/radius.c @@ -24,7 +24,7 @@ * ***********************************************************************/ static char const RCSID[] = -"$Id: radius.c,v 1.22 2004/01/11 08:01:30 paulus Exp $"; +"$Id: radius.c,v 1.23 2004/03/26 13:27:17 kad Exp $"; #include "pppd.h" #include "chap-new.h" @@ -52,10 +52,15 @@ static struct avpopt { char *vpstr; struct avpopt *next; } *avpopt = NULL; +static bool portnummap = 0; static option_t Options[] = { { "radius-config-file", o_string, &config_file }, { "avpair", o_special, add_avp }, + { "map-to-ttyname", o_bool, &portnummap, + "Set Radius NAS-Port attribute value via libradiusclient library", OPT_PRIO | 1 }, + { "map-to-ifname", o_bool, &portnummap, + "Set Radius NAS-Port attribute to number as in interface name (Default)", OPT_PRIOSUB | 0 }, { NULL } }; @@ -264,7 +269,7 @@ radius_pap_auth(char *user, /* Hack... the "port" is the ppp interface number. Should really be the tty */ - rstate.client_port = get_client_port(ifname); + rstate.client_port = get_client_port(portnummap ? devnam : ifname); av_type = PW_FRAMED; rc_avpair_add(&send, PW_SERVICE_TYPE, &av_type, 0, VENDOR_NONE); @@ -363,7 +368,7 @@ radius_chap_verify(char *user, char *ourname, int id, /* Put user with potentially realm added in rstate.user */ if (!rstate.done_chap_once) { make_username_realm(user); - rstate.client_port = get_client_port (ifname); + rstate.client_port = get_client_port (portnummap ? devnam : ifname); if (radius_pre_auth_hook) { radius_pre_auth_hook(rstate.user, &rstate.authserver, @@ -881,7 +886,7 @@ radius_acct_start(void) rc_avpair_add(&send, PW_ACCT_AUTHENTIC, &av_type, 0, VENDOR_NONE); - av_type = PW_ASYNC; + av_type = using_pty ? PW_VIRTUAL : PW_ASYNC; rc_avpair_add(&send, PW_NAS_PORT_TYPE, &av_type, 0, VENDOR_NONE); hisaddr = ho->hisaddr; @@ -981,9 +986,56 @@ radius_acct_stop(void) remote_number, 0, VENDOR_NONE); } - av_type = PW_ASYNC; + av_type = using_pty ? PW_VIRTUAL : PW_ASYNC; rc_avpair_add(&send, PW_NAS_PORT_TYPE, &av_type, 0, VENDOR_NONE); + av_type = PW_NAS_ERROR; + switch( status ) { + case EXIT_OK: + case EXIT_USER_REQUEST: + av_type = PW_USER_REQUEST; + break; + + case EXIT_HANGUP: + case EXIT_PEER_DEAD: + case EXIT_CONNECT_FAILED: + av_type = PW_LOST_CARRIER; + break; + + case EXIT_INIT_FAILED: + case EXIT_OPEN_FAILED: + case EXIT_LOCK_FAILED: + case EXIT_PTYCMD_FAILED: + av_type = PW_PORT_ERROR; + break; + + case EXIT_PEER_AUTH_FAILED: + case EXIT_AUTH_TOPEER_FAILED: + case EXIT_NEGOTIATION_FAILED: + case EXIT_CNID_AUTH_FAILED: + av_type = PW_SERVICE_UNAVAILABLE; + break; + + case EXIT_IDLE_TIMEOUT: + av_type = PW_ACCT_IDLE_TIMEOUT; + break; + + case EXIT_CONNECT_TIME: + av_type = PW_ACCT_SESSION_TIMEOUT; + break; + +#ifdef MAXOCTETS + case EXIT_TRAFFIC_LIMIT: + av_type = PW_NAS_REQUEST; + break; +#endif + + default: + av_type = PW_NAS_ERROR; + break; + } + rc_avpair_add(&send, PW_ACCT_TERMINATE_CAUSE, &av_type, 0, VENDOR_NONE); + hisaddr = ho->hisaddr; av_type = htonl(hisaddr); rc_avpair_add(&send, PW_FRAMED_IP_ADDRESS , &av_type , 0, VENDOR_NONE); @@ -1077,7 +1129,7 @@ radius_acct_interim(void *ignored) remote_number, 0, VENDOR_NONE); } - av_type = PW_ASYNC; + av_type = using_pty ? PW_VIRTUAL : PW_ASYNC; rc_avpair_add(&send, PW_NAS_PORT_TYPE, &av_type, 0, VENDOR_NONE); hisaddr = ho->hisaddr;