X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Fplugins%2Fradius%2Fradius.c;h=264b0ade4a0391eeb7e520f39f563a02350599bb;hb=dd41357657d1436fe20692aa43613ceae8e03fa0;hp=76b68e105343f61b3d6c9730f0e31a941e94976e;hpb=216967db316a190aa012a57660a2aad8124452a7;p=ppp.git diff --git a/pppd/plugins/radius/radius.c b/pppd/plugins/radius/radius.c index 76b68e1..264b0ad 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.21 2003/11/25 11:50:10 paulus Exp $"; +"$Id: radius.c,v 1.26 2004/10/28 00:22:54 paulus 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 } }; @@ -69,7 +74,7 @@ static int radius_chap_verify(char *user, char *ourname, int id, struct chap_digest_type *digest, unsigned char *challenge, unsigned char *response, - unsigned char *message, int message_space); + char *message, int message_space); static void radius_ip_up(void *opaque, int arg); static void radius_ip_down(void *opaque, int arg); @@ -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); @@ -324,7 +329,7 @@ static int radius_chap_verify(char *user, char *ourname, int id, struct chap_digest_type *digest, unsigned char *challenge, unsigned char *response, - unsigned char *message, int message_space) + char *message, int message_space) { VALUE_PAIR *send, *received; UINT4 av_type; @@ -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, @@ -425,7 +430,7 @@ radius_chap_verify(char *user, char *ourname, int id, case CHAP_MICROSOFT_V2: { /* MS-CHAP-Challenge and MS-CHAP2-Response */ - MS_Chap2Response *rmd = (MS_Chap2Response *) (response + 1); + MS_Chap2Response *rmd = (MS_Chap2Response *) response; u_char *p = cpassword; if (response_len != MS_CHAP2_RESPONSE_LEN) @@ -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 : ( sync_serial ? PW_SYNC : 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 : ( sync_serial ? PW_SYNC : 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 : ( sync_serial ? PW_SYNC : PW_ASYNC ) ); rc_avpair_add(&send, PW_NAS_PORT_TYPE, &av_type, 0, VENDOR_NONE); hisaddr = ho->hisaddr;