summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp/bundle.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>2002-05-07 10:06:54 +0000
committerbrian <brian@FreeBSD.org>2002-05-07 10:06:54 +0000
commit920f339ee0360ae3f2069fa04c25c1ae979fbe65 (patch)
tree86531cf7a7e689db81efecb1236fcce8aeed44b1 /usr.sbin/ppp/bundle.c
parent3d392cbffdb42022550522a3427ebe7ad7444a39 (diff)
downloadFreeBSD-src-920f339ee0360ae3f2069fa04c25c1ae979fbe65.zip
FreeBSD-src-920f339ee0360ae3f2069fa04c25c1ae979fbe65.tar.gz
Understand the Session-Timeout RADIUS attribute
Store the Filter-Id attribute (we don't do anything with it yet) Submitted mostly by: andrew pavlov <and@kremenchug.net>
Diffstat (limited to 'usr.sbin/ppp/bundle.c')
-rw-r--r--usr.sbin/ppp/bundle.c73
1 files changed, 71 insertions, 2 deletions
diff --git a/usr.sbin/ppp/bundle.c b/usr.sbin/ppp/bundle.c
index 137888b..bbec25d 100644
--- a/usr.sbin/ppp/bundle.c
+++ b/usr.sbin/ppp/bundle.c
@@ -227,6 +227,13 @@ bundle_LinkAdded(struct bundle *bundle, struct datalink *dl)
if (dl->state == DATALINK_OPEN)
bundle->phys_type.open |= dl->physical->type;
+#ifndef NORADIUS
+ if ((bundle->phys_type.open & (PHYS_DEDICATED|PHYS_DDIAL))
+ != bundle->phys_type.open && bundle->session.timer.state == TIMER_STOPPED)
+ if (bundle->radius.sessiontime)
+ bundle_StartSessionTimer(bundle, 0);
+#endif
+
if ((bundle->phys_type.open & (PHYS_DEDICATED|PHYS_DDIAL))
!= bundle->phys_type.open && bundle->idle.timer.state == TIMER_STOPPED)
/* We may need to start our idle timer */
@@ -246,8 +253,13 @@ bundle_LinksRemoved(struct bundle *bundle)
mp_CheckAutoloadTimer(&bundle->ncp.mp);
if ((bundle->phys_type.open & (PHYS_DEDICATED|PHYS_DDIAL))
- == bundle->phys_type.open)
+ == bundle->phys_type.open) {
+#ifndef NORADIUS
+ if (bundle->radius.sessiontime)
+ bundle_StopSessionTimer(bundle);
+#endif
bundle_StopIdleTimer(bundle);
+ }
}
static void
@@ -274,6 +286,10 @@ bundle_LayerUp(void *v, struct fsm *fp)
if (ncp_LayersOpen(&fp->bundle->ncp) == 1) {
bundle_CalculateBandwidth(fp->bundle);
time(&bundle->upat);
+#ifndef NORADIUS
+ if (bundle->radius.sessiontime)
+ bundle_StartSessionTimer(bundle, 0);
+#endif
bundle_StartIdleTimer(bundle, 0);
mp_CheckAutoloadTimer(&fp->bundle->ncp.mp);
}
@@ -300,6 +316,10 @@ bundle_LayerDown(void *v, struct fsm *fp)
if (isncp(fp->proto)) {
if (ncp_LayersOpen(&fp->bundle->ncp) == 0) {
+#ifndef NORADIUS
+ if (bundle->radius.sessiontime)
+ bundle_StopSessionTimer(bundle);
+#endif
bundle_StopIdleTimer(bundle);
bundle->upat = 0;
mp_StopAutoloadTimer(&bundle->ncp.mp);
@@ -399,6 +419,10 @@ bundle_Close(struct bundle *bundle, const char *name, int how)
}
if (!others_active) {
+#ifndef NORADIUS
+ if (bundle->radius.sessiontime)
+ bundle_StopSessionTimer(bundle);
+#endif
bundle_StopIdleTimer(bundle);
if (ncp_LayersUnfinished(&bundle->ncp))
ncp_Close(&bundle->ncp);
@@ -942,6 +966,10 @@ bundle_LinkClosed(struct bundle *bundle, struct datalink *dl)
ncp2initial(&bundle->ncp);
mp_Down(&bundle->ncp.mp);
bundle_NewPhase(bundle, PHASE_DEAD);
+#ifndef NORADIUS
+ if (bundle->radius.sessiontime)
+ bundle_StopSessionTimer(bundle);
+#endif
bundle_StopIdleTimer(bundle);
}
}
@@ -1184,6 +1212,47 @@ bundle_RemainingIdleTime(struct bundle *bundle)
return -1;
}
+#ifndef NORADIUS
+
+static void
+bundle_SessionTimeout(void *v)
+{
+ struct bundle *bundle = (struct bundle *)v;
+
+ log_Printf(LogPHASE, "Session-Timeout timer expired\n");
+ bundle_StopSessionTimer(bundle);
+ bundle_Close(bundle, NULL, CLOSE_STAYDOWN);
+}
+
+void
+bundle_StartSessionTimer(struct bundle *bundle, unsigned secs)
+{
+ timer_Stop(&bundle->session.timer);
+ if ((bundle->phys_type.open & (PHYS_DEDICATED|PHYS_DDIAL)) !=
+ bundle->phys_type.open && bundle->radius.sessiontime) {
+ time_t now = time(NULL);
+
+ if (secs == 0)
+ secs = bundle->radius.sessiontime;
+
+ bundle->session.timer.func = bundle_SessionTimeout;
+ bundle->session.timer.name = "session";
+ bundle->session.timer.load = secs * SECTICKS;
+ bundle->session.timer.arg = bundle;
+ timer_Start(&bundle->session.timer);
+ bundle->session.done = now + secs;
+ }
+}
+
+void
+bundle_StopSessionTimer(struct bundle *bundle)
+{
+ timer_Stop(&bundle->session.timer);
+ bundle->session.done = 0;
+}
+
+#endif
+
int
bundle_IsDead(struct bundle *bundle)
{
@@ -1825,7 +1894,7 @@ bundle_CalculateBandwidth(struct bundle *bundle)
}
}
- if(bundle->bandwidth == 0)
+ if (bundle->bandwidth == 0)
bundle->bandwidth = 115200; /* Shrug */
if (bundle->ncp.mp.active) {
OpenPOWER on IntegriCloud