Commit 9bf6b555 authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN: per net device auto hangup function

Preparing for a hangup timer per ISDN netdevice instead of always 
walking the list of all devices, separate out what we need to do
per device.
parent 273cbb5a
......@@ -348,7 +348,7 @@ isdn_net_unbind_channel(isdn_net_local * lp)
}
/*
* Perform auto-hangup and cps-calculation for net-interfaces.
* Perform auto-hangup for net-interfaces.
*
* auto-hangup:
* Increment idle-counter (this counter is reset on any incoming or
......@@ -357,6 +357,54 @@ isdn_net_unbind_channel(isdn_net_local * lp)
* charge-info.
*/
static int isdn_net_hup_timer(unsigned long data)
{
isdn_net_local *lp = (isdn_net_local *) data;
if (!(lp->flags & ISDN_NET_CONNECTED) || lp->dialstate != ST_ACTIVE) {
isdn_BUG();
return 1;
}
dbg_net_dial("%s: huptimer %d, onhtime %d, chargetime %ld, chargeint %d\n",
l->name, l->huptimer, l->onhtime, l->chargetime, l->chargeint);
if (!(lp->onhtime))
return 0;
if (lp->huptimer++ <= lp->onhtime)
return 1;
if (lp->hupflags & ISDN_MANCHARGE && lp->hupflags & ISDN_CHARGEHUP) {
while (time_after(jiffies, lp->chargetime + lp->chargeint))
lp->chargetime += lp->chargeint;
if (time_after(jiffies, lp->chargetime + lp->chargeint - 2 * HZ)) {
if (lp->outgoing || lp->hupflags & ISDN_INHUP) {
isdn_net_hangup(&lp->netdev->dev);
return 0;
}
}
} else if (lp->outgoing) {
if (lp->hupflags & ISDN_CHARGEHUP) {
if (lp->charge_state != ST_CHARGE_HAVE_CINT) {
dbg_net_dial("%s: did not get CINT\n", lp->name);
isdn_net_hangup(&lp->netdev->dev);
return 0;
} else if (time_after(jiffies, lp->chargetime + lp->chargeint)) {
dbg_net_dial("%s: chtime = %lu, chint = %d\n",
lp->name, lp->chargetime, lp->chargeint);
isdn_net_hangup(&lp->netdev->dev);
return 0;
}
}
} else if (lp->hupflags & ISDN_INHUP) {
isdn_net_hangup(&lp->netdev->dev);
return 0;
}
return 1;
}
void
isdn_net_autohup()
{
......@@ -376,44 +424,9 @@ isdn_net_autohup()
isdn_net_hangup(&p->dev);
continue;
}
dbg_net_dial("%s: huptimer %d, onhtime %d, chargetime %ld, chargeint %d\n",
l->name, l->huptimer, l->onhtime, l->chargetime, l->chargeint);
if (!(l->onhtime))
continue;
if (l->huptimer++ <= l->onhtime) {
if (isdn_net_hup_timer((unsigned long) l))
anymore = 1;
continue;
}
if (l->hupflags & ISDN_MANCHARGE && l->hupflags & ISDN_CHARGEHUP) {
while (time_after(jiffies, l->chargetime + l->chargeint))
l->chargetime += l->chargeint;
if (time_after(jiffies, l->chargetime + l->chargeint - 2 * HZ)) {
if (l->outgoing || l->hupflags & ISDN_INHUP) {
isdn_net_hangup(&p->dev);
continue;
}
}
} else if (l->outgoing) {
if (l->hupflags & ISDN_CHARGEHUP) {
if (l->charge_state != ST_CHARGE_HAVE_CINT) {
dbg_net_dial("%s: did not get CINT\n", l->name);
isdn_net_hangup(&p->dev);
continue;
} else if (time_after(jiffies, l->chargetime + l->chargeint)) {
dbg_net_dial("%s: chtime = %lu, chint = %d\n",
l->name, l->chargetime, l->chargeint);
isdn_net_hangup(&p->dev);
continue;
}
}
} else if (l->hupflags & ISDN_INHUP) {
isdn_net_hangup(&p->dev);
continue;
}
anymore = 1;
}
isdn_timer_ctrl(ISDN_TIMER_NETHANGUP, anymore);
}
......@@ -495,11 +508,6 @@ isdn_net_dial_timer(unsigned long data)
{
isdn_net_local *lp = (isdn_net_local *) data;
if (!lp) {
isdn_BUG();
return;
}
printk("%s: %s %#x\n", __FUNCTION__ , lp->name, lp->dial_event);
isdn_net_handle_event(lp, lp->dial_event, NULL);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment