|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
patch ppp for support radius acctterminatecause
From: Динар Талыпов (dinar
yantel.ru)
Date: Fri Sep 01 2006 - 07:54:51 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hello,
Recently, I wrote patch for ppp(8) that adds acct-terminate-cause
attribute to radius accounting packets.
Currently supported acct-terminate-causes are:
RAD_TERM_IDLE_TIMEOUT, RAD_TERM_USER_REQUEST, RAD_TERM_SESSION_TIMEOUT
may be it can be useful?
=== begin patch ===
--- bundle.h.orig Wed Sep 21 19:04:28 2005
+++ bundle.h Thu Aug 17 16:52:11 2006

-138,6 +138,13 
struct pppTimer timer;
time_t done;
} session;
+ enum {
+ CAUSE_NONE,
+ CAUSE_USER,
+ CAUSE_CARRIER,
+ CAUSE_IDLE,
+ CAUSE_TIMEOUT
+ } terminate_cause;
#endif
struct {
--- bundle.c.orig Wed Sep 21 19:04:28 2005
+++ bundle.c Thu Aug 17 16:48:50 2006

-1159,6 +1159,9 
struct bundle *bundle = (struct bundle *)v;
log_Printf(LogPHASE, "Idle timer expired\n");
+#ifndef NORADIUS
+ bundle->terminate_cause = CAUSE_IDLE;
+#endif
bundle_StopIdleTimer(bundle);
bundle_Close(bundle, NULL, CLOSE_STAYDOWN);
}

-1228,6 +1231,7 
struct bundle *bundle = (struct bundle *)v;
log_Printf(LogPHASE, "Session-Timeout timer expired\n");
+ bundle->terminate_cause = CAUSE_TIMEOUT;
bundle_StopSessionTimer(bundle);
bundle_Close(bundle, NULL, CLOSE_STAYDOWN);
}
--- lcp.c.orig Thu Aug 17 15:13:16 2006
+++ lcp.c Thu Aug 17 16:14:13 2006

-545,7 +545,9 
if (p && p->dl->state == DATALINK_CBCP)
cbcp_ReceiveTerminateReq(p);
-
+#ifndef NORADIUS
+ fp->bundle->terminate_cause = CAUSE_USER;
+#endif
fsm_Output(fp, CODE_TERMACK, id, NULL, 0, MB_LCPOUT);
}
--- radius.c.orig Wed Sep 21 20:58:34 2005
+++ radius.c Thu Aug 17 16:30:39 2006

-1073,6 +1073,7 
{
struct timeval tv;
int got;
+ unsigned int terminate_cause=0;
char hostname[MAXHOSTNAMELEN];
char *mac_addr;
struct hostent *hp;

-1230,6 +1231,33 
return;
}
+ if (acct_type == RAD_STOP ){
+ switch (dl->bundle->terminate_cause) {
+ case CAUSE_NONE:
+ terminate_cause = 0;
+ break;
+ case CAUSE_IDLE:
+ terminate_cause = RAD_TERM_IDLE_TIMEOUT;
+ break;
+ case CAUSE_USER:
+ terminate_cause = RAD_TERM_USER_REQUEST;
+ break;
+ case CAUSE_TIMEOUT:
+ terminate_cause = RAD_TERM_SESSION_TIMEOUT;
+ break;
+ case CAUSE_CARRIER:
+ terminate_cause = RAD_TERM_LOST_CARRIER;
+ break;
+ }
+
+ if (terminate_cause)
+ if (rad_put_int(r->cx.rad, RAD_ACCT_TERMINATE_CAUSE, terminate_cause) != 0 ) {
+ log_Printf(LogERROR, "rad_put: %s\n", rad_strerror(r->cx.rad));
+ rad_close(r->cx.rad);
+ return;
+ }
+ log_Printf(LogRADIUS, "terminate_cause: %d\n", terminate_cause);
+ }
if (log_IsKept(LogPHASE) || log_IsKept(LogRADIUS)) {
char *what;
int level;
=== end patch ===
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]