Commit 7e22da6a authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN: ISDN_GLOBAL_STOPPED cleanup

ISDN_GLOBAL_STOPPED is a way to globally stop the system
from dialing out / accepting incoming calls. Instead of
spreading checks all over the place, just catch dial
commands / incoming call indications in one place.

Also, kill isdn_net_phone typedef and clean up affected code.
parent 2a002db2
...@@ -449,8 +449,6 @@ isdn_status_callback(isdn_ctrl * c) ...@@ -449,8 +449,6 @@ isdn_status_callback(isdn_ctrl * c)
case ISDN_STAT_BSENT: case ISDN_STAT_BSENT:
if (i < 0) if (i < 0)
return -1; return -1;
if (dev->global_flags & ISDN_GLOBAL_STOPPED)
return 0;
if (isdn_net_stat_callback(i, c)) if (isdn_net_stat_callback(i, c))
return 0; return 0;
if (isdn_v110_stat_callback(&slot[i].iv110, c)) if (isdn_v110_stat_callback(&slot[i].iv110, c))
...@@ -480,15 +478,11 @@ isdn_status_callback(isdn_ctrl * c) ...@@ -480,15 +478,11 @@ isdn_status_callback(isdn_ctrl * c)
if (i < 0) if (i < 0)
return -1; return -1;
dbg_statcallb("ICALL: %d (%d,%ld) %s\n", i, di, c->arg, c->parm.num); dbg_statcallb("ICALL: %d (%d,%ld) %s\n", i, di, c->arg, c->parm.num);
if (dev->global_flags & ISDN_GLOBAL_STOPPED) { if (dev->global_flags & ISDN_GLOBAL_STOPPED)
cmd.driver = di;
cmd.arg = c->arg;
cmd.command = ISDN_CMD_HANGUP;
isdn_command(&cmd);
return 0; return 0;
}
/* Try to find a network-interface which will accept incoming call */ /* Try to find a network-interface which will accept incoming call */
r = ((c->command == ISDN_STAT_ICALLW) ? 0 : isdn_net_find_icall(di, c->arg, i, &c->parm.setup)); r = isdn_net_find_icall(di, c->arg, i, &c->parm.setup);
switch (r) { switch (r) {
case 0: case 0:
/* No network-device replies. /* No network-device replies.
...@@ -548,8 +542,6 @@ isdn_status_callback(isdn_ctrl * c) ...@@ -548,8 +542,6 @@ isdn_status_callback(isdn_ctrl * c)
if (i < 0) if (i < 0)
return -1; return -1;
dbg_statcallb("CINF: %d %s\n", i, c->parm.num); dbg_statcallb("CINF: %d %s\n", i, c->parm.num);
if (dev->global_flags & ISDN_GLOBAL_STOPPED)
return 0;
if (strcmp(c->parm.num, "0")) if (strcmp(c->parm.num, "0"))
isdn_net_stat_callback(i, c); isdn_net_stat_callback(i, c);
isdn_tty_stat_callback(i, c); isdn_tty_stat_callback(i, c);
...@@ -572,8 +564,6 @@ isdn_status_callback(isdn_ctrl * c) ...@@ -572,8 +564,6 @@ isdn_status_callback(isdn_ctrl * c)
if (i < 0) if (i < 0)
return -1; return -1;
dbg_statcallb("DCONN: %d\n", i); dbg_statcallb("DCONN: %d\n", i);
if (dev->global_flags & ISDN_GLOBAL_STOPPED)
return 0;
/* Find any net-device, waiting for D-channel setup */ /* Find any net-device, waiting for D-channel setup */
if (isdn_net_stat_callback(i, c)) if (isdn_net_stat_callback(i, c))
break; break;
...@@ -591,8 +581,6 @@ isdn_status_callback(isdn_ctrl * c) ...@@ -591,8 +581,6 @@ isdn_status_callback(isdn_ctrl * c)
if (i < 0) if (i < 0)
return -1; return -1;
dbg_statcallb("DHUP: %d\n", i); dbg_statcallb("DHUP: %d\n", i);
if (dev->global_flags & ISDN_GLOBAL_STOPPED)
return 0;
dev->drv[di]->online &= ~(1 << (c->arg)); dev->drv[di]->online &= ~(1 << (c->arg));
isdn_info_update(); isdn_info_update();
/* Signal hangup to network-devices */ /* Signal hangup to network-devices */
...@@ -609,8 +597,6 @@ isdn_status_callback(isdn_ctrl * c) ...@@ -609,8 +597,6 @@ isdn_status_callback(isdn_ctrl * c)
return -1; return -1;
dbg_statcallb("BCONN: %ld\n", c->arg); dbg_statcallb("BCONN: %ld\n", c->arg);
/* Signal B-channel-connect to network-devices */ /* Signal B-channel-connect to network-devices */
if (dev->global_flags & ISDN_GLOBAL_STOPPED)
return 0;
dev->drv[di]->online |= (1 << (c->arg)); dev->drv[di]->online |= (1 << (c->arg));
isdn_info_update(); isdn_info_update();
if (isdn_net_stat_callback(i, c)) if (isdn_net_stat_callback(i, c))
...@@ -623,8 +609,6 @@ isdn_status_callback(isdn_ctrl * c) ...@@ -623,8 +609,6 @@ isdn_status_callback(isdn_ctrl * c)
if (i < 0) if (i < 0)
return -1; return -1;
dbg_statcallb("BHUP: %d\n", i); dbg_statcallb("BHUP: %d\n", i);
if (dev->global_flags & ISDN_GLOBAL_STOPPED)
return 0;
dev->drv[di]->online &= ~(1 << (c->arg)); dev->drv[di]->online &= ~(1 << (c->arg));
isdn_info_update(); isdn_info_update();
#ifdef CONFIG_ISDN_X25 #ifdef CONFIG_ISDN_X25
...@@ -640,8 +624,6 @@ isdn_status_callback(isdn_ctrl * c) ...@@ -640,8 +624,6 @@ isdn_status_callback(isdn_ctrl * c)
if (i < 0) if (i < 0)
return -1; return -1;
dbg_statcallb("NODCH: %ld\n", c->arg); dbg_statcallb("NODCH: %ld\n", c->arg);
if (dev->global_flags & ISDN_GLOBAL_STOPPED)
return 0;
if (isdn_net_stat_callback(i, c)) if (isdn_net_stat_callback(i, c))
break; break;
if (isdn_tty_stat_callback(i, c)) if (isdn_tty_stat_callback(i, c))
...@@ -1401,8 +1383,6 @@ isdn_ctrl_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg) ...@@ -1401,8 +1383,6 @@ isdn_ctrl_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
} else { } else {
dev->global_flags &= ~ISDN_GLOBAL_STOPPED; dev->global_flags &= ~ISDN_GLOBAL_STOPPED;
} }
printk(KERN_INFO "isdn: Global Mode %s\n",
(dev->global_flags & ISDN_GLOBAL_STOPPED) ? "stopped" : "running");
return 0; return 0;
case IIOCSETBRJ: case IIOCSETBRJ:
drvidx = -1; drvidx = -1;
...@@ -2119,14 +2099,20 @@ isdn_slot_map_eaz2msn(int sl, char *msn) ...@@ -2119,14 +2099,20 @@ isdn_slot_map_eaz2msn(int sl, char *msn)
int int
isdn_slot_command(int sl, int cmd, isdn_ctrl *ctrl) isdn_slot_command(int sl, int cmd, isdn_ctrl *ctrl)
{ {
ctrl->command = cmd; ctrl->command = cmd;
ctrl->driver = isdn_slot_driver(sl); ctrl->driver = isdn_slot_driver(sl);
switch (cmd) { switch (cmd) {
case ISDN_CMD_SETL2: case ISDN_CMD_SETL2:
case ISDN_CMD_SETL3: case ISDN_CMD_SETL3:
case ISDN_CMD_PROT_IO: case ISDN_CMD_PROT_IO:
ctrl->arg &= ~0xff; ctrl->arg |= isdn_slot_channel(sl); ctrl->arg &= ~0xff; ctrl->arg |= isdn_slot_channel(sl);
break; break;
case ISDN_CMD_DIAL:
if (dev->global_flags & ISDN_GLOBAL_STOPPED)
return -EBUSY;
/* fall through */
default: default:
ctrl->arg = isdn_slot_channel(sl); ctrl->arg = isdn_slot_channel(sl);
break; break;
......
...@@ -206,7 +206,7 @@ static __inline__ void isdn_net_zero_frame_cnt(isdn_net_local *lp) ...@@ -206,7 +206,7 @@ static __inline__ void isdn_net_zero_frame_cnt(isdn_net_local *lp)
int isdn_net_force_dial_lp(isdn_net_local *); int isdn_net_force_dial_lp(isdn_net_local *);
static int isdn_net_start_xmit(struct sk_buff *, struct net_device *); static int isdn_net_start_xmit(struct sk_buff *, struct net_device *);
static int do_dialout(isdn_net_local *lp); static void do_dialout(isdn_net_local *lp);
static void isdn_net_ciscohdlck_connected(isdn_net_local *lp); static void isdn_net_ciscohdlck_connected(isdn_net_local *lp);
static void isdn_net_ciscohdlck_disconnected(isdn_net_local *lp); static void isdn_net_ciscohdlck_disconnected(isdn_net_local *lp);
...@@ -222,22 +222,14 @@ char *isdn_net_revision = "$Revision: 1.140.6.11 $"; ...@@ -222,22 +222,14 @@ char *isdn_net_revision = "$Revision: 1.140.6.11 $";
static void static void
isdn_net_unreachable(struct net_device *dev, struct sk_buff *skb, char *reason) isdn_net_unreachable(struct net_device *dev, struct sk_buff *skb, char *reason)
{ {
if(skb) { u_short proto = ntohs(skb->protocol);
u_short proto = ntohs(skb->protocol); printk(KERN_DEBUG "isdn_net: %s: %s, signalling dst_link_failure %s\n",
dev->name,
printk(KERN_DEBUG "isdn_net: %s: %s, signalling dst_link_failure %s\n", (reason != NULL) ? reason : "unknown",
dev->name, (proto != ETH_P_IP) ? "Protocol != ETH_P_IP" : "");
(reason != NULL) ? reason : "unknown",
(proto != ETH_P_IP) ? "Protocol != ETH_P_IP" : ""); dst_link_failure(skb);
dst_link_failure(skb);
}
else { /* dial not triggered by rawIP packet */
printk(KERN_DEBUG "isdn_net: %s: %s\n",
dev->name,
(reason != NULL) ? reason : "reason unknown");
}
} }
static void static void
...@@ -491,7 +483,7 @@ isdn_net_dial_timer(unsigned long data) ...@@ -491,7 +483,7 @@ isdn_net_dial_timer(unsigned long data)
/* Initiate dialout. Set phone-number-pointer to first number /* Initiate dialout. Set phone-number-pointer to first number
* of interface. * of interface.
*/ */
static int static void
init_dialout(isdn_net_local *lp) init_dialout(isdn_net_local *lp)
{ {
unsigned long flags; unsigned long flags;
...@@ -505,7 +497,7 @@ init_dialout(isdn_net_local *lp) ...@@ -505,7 +497,7 @@ init_dialout(isdn_net_local *lp)
printk(KERN_WARNING "%s: phone number deleted?\n", printk(KERN_WARNING "%s: phone number deleted?\n",
lp->name); lp->name);
isdn_net_hangup(lp); isdn_net_hangup(lp);
return 0; return;
} }
if (lp->dialtimeout > 0 && if (lp->dialtimeout > 0 &&
(lp->dialstarted == 0 || (lp->dialstarted == 0 ||
...@@ -514,83 +506,59 @@ init_dialout(isdn_net_local *lp) ...@@ -514,83 +506,59 @@ init_dialout(isdn_net_local *lp)
lp->dialwait_timer = 0; lp->dialwait_timer = 0;
} }
lp->dialretry = 0; lp->dialretry = 0;
return do_dialout(lp); do_dialout(lp);
} }
/* Setup interface, dial current phone-number, switch to next number. /* Setup interface, dial current phone-number, switch to next number.
* If list of phone-numbers is exhausted, increment * If list of phone-numbers is exhausted, increment
* retry-counter. * retry-counter.
*/ */
static int static void
do_dialout(isdn_net_local *lp) do_dialout(isdn_net_local *lp)
{ {
unsigned long flags; unsigned long flags;
struct dial_info dial = {
if(dev->global_flags & ISDN_GLOBAL_STOPPED || (ISDN_NET_DIALMODE(*lp) == ISDN_NET_DM_OFF)) { .l2_proto = lp->l2_proto,
char *s; .l3_proto = lp->l3_proto,
if (dev->global_flags & ISDN_GLOBAL_STOPPED) .si1 = 7,
s = "dial suppressed: isdn system stopped"; .si2 = 0,
else .msn = lp->msn,
s = "dial suppressed: dialmode `off'"; .phone = lp->dial->num,
isdn_net_unreachable(&lp->netdev->dev, 0, s); };
isdn_net_hangup(lp);
return 0; if (ISDN_NET_DIALMODE(*lp) == ISDN_NET_DM_OFF)
} return;
save_flags(flags); save_flags(flags);
cli(); cli();
if (!lp->dial) { if(lp->dialtimeout > 0 &&
restore_flags(flags); time_after(jiffies, lp->dialstarted + lp->dialtimeout)) {
printk(KERN_WARNING "%s: phone number deleted?\n", restore_flags(flags);
lp->name); lp->dialwait_timer = jiffies + lp->dialwait;
isdn_net_hangup(lp); lp->dialstarted = 0;
return 0; isdn_net_hangup(lp);
return;
} }
if (!strncmp(lp->dial->num, "LEASED", strlen("LEASED"))) { /*
restore_flags(flags); * Switch to next number or back to start if at end of list.
lp->dialstate = ST_OUT_WAIT_DCONN; */
printk(KERN_INFO "%s: Open leased line ...\n", lp->name); if (!(lp->dial = lp->dial->next)) {
return 1; lp->dial = lp->phone[1];
} else { lp->dialretry++;
struct dial_info dial = {
.l2_proto = lp->l2_proto, if (lp->dialretry > lp->dialmax) {
.l3_proto = lp->l3_proto, restore_flags(flags);
.si1 = 7, if (lp->dialtimeout == 0) {
.si2 = 0,
.msn = lp->msn,
.phone = lp->dial->num,
};
if(lp->dialtimeout > 0) {
if (time_after(jiffies, lp->dialstarted + lp->dialtimeout)) {
restore_flags(flags);
lp->dialwait_timer = jiffies + lp->dialwait; lp->dialwait_timer = jiffies + lp->dialwait;
lp->dialstarted = 0; lp->dialstarted = 0;
isdn_net_unreachable(&lp->netdev->dev, 0, "dial: timed out");
isdn_net_hangup(lp);
return 0;
}
}
/*
* Switch to next number or back to start if at end of list.
*/
if (!(lp->dial = (isdn_net_phone *) lp->dial->next)) {
lp->dial = lp->phone[1];
lp->dialretry++;
if (lp->dialretry > lp->dialmax) {
restore_flags(flags);
if (lp->dialtimeout == 0) {
lp->dialwait_timer = jiffies + lp->dialwait;
lp->dialstarted = 0;
isdn_net_unreachable(&lp->netdev->dev, 0, "dial: tried all numbers dialmax times");
}
isdn_net_hangup(lp);
return 0;
} }
isdn_net_hangup(lp);
return;
} }
restore_flags(flags);
isdn_slot_dial(lp->isdn_slot, &dial);
} }
restore_flags(flags);
isdn_slot_dial(lp->isdn_slot, &dial);
lp->huptimer = 0; lp->huptimer = 0;
lp->outgoing = 1; lp->outgoing = 1;
if (lp->chargeint) if (lp->chargeint)
...@@ -607,7 +575,6 @@ do_dialout(isdn_net_local *lp) ...@@ -607,7 +575,6 @@ do_dialout(isdn_net_local *lp)
} }
lp->dialstate = ST_OUT_WAIT_DCONN; lp->dialstate = ST_OUT_WAIT_DCONN;
add_timer(&lp->dial_timer); add_timer(&lp->dial_timer);
return 1;
} }
/* For EV_NET_DIAL, returns 1 if timer callback is needed /* For EV_NET_DIAL, returns 1 if timer callback is needed
...@@ -2114,7 +2081,7 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup) ...@@ -2114,7 +2081,7 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup)
int swapped; int swapped;
int sidx = 0; int sidx = 0;
struct list_head *l; struct list_head *l;
isdn_net_phone *n; struct isdn_net_phone *n;
ulong flags; ulong flags;
char nr[32]; char nr[32];
char *my_eaz; char *my_eaz;
...@@ -2148,7 +2115,7 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup) ...@@ -2148,7 +2115,7 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup)
return 0; return 0;
} }
n = (isdn_net_phone *) 0; n = NULL;
ematch = wret = swapped = 0; ematch = wret = swapped = 0;
dbg_net_icall("n_fi: di=%d ch=%d idx=%d usg=%d\n", di, ch, idx, dbg_net_icall("n_fi: di=%d ch=%d idx=%d usg=%d\n", di, ch, idx,
isdn_slot_usage(idx)); isdn_slot_usage(idx));
...@@ -2259,7 +2226,7 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup) ...@@ -2259,7 +2226,7 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup)
while (n) { while (n) {
if (!isdn_msncmp(nr, n->num)) if (!isdn_msncmp(nr, n->num))
break; break;
n = (isdn_net_phone *) n->next; n = n->next;
} }
} }
if (n || (!(lp->flags & ISDN_NET_SECURE))) { if (n || (!(lp->flags & ISDN_NET_SECURE))) {
...@@ -2939,17 +2906,20 @@ int ...@@ -2939,17 +2906,20 @@ int
isdn_net_addphone(isdn_net_ioctl_phone * phone) isdn_net_addphone(isdn_net_ioctl_phone * phone)
{ {
isdn_net_dev *p = isdn_net_findif(phone->name); isdn_net_dev *p = isdn_net_findif(phone->name);
isdn_net_phone *n; struct isdn_net_phone *n;
if (p) { if (!p)
if (!(n = (isdn_net_phone *) kmalloc(sizeof(isdn_net_phone), GFP_KERNEL))) return -ENODEV;
return -ENOMEM;
strcpy(n->num, phone->phone); n = kmalloc(sizeof(*n), GFP_KERNEL);
n->next = p->local.phone[phone->outgoing & 1]; if (!n)
p->local.phone[phone->outgoing & 1] = n; return -ENOMEM;
return 0;
} strcpy(n->num, phone->phone);
return -ENODEV; n->next = p->local.phone[phone->outgoing & 1];
p->local.phone[phone->outgoing & 1] = n;
return 0;
} }
/* /*
...@@ -2963,7 +2933,7 @@ isdn_net_getphones(isdn_net_ioctl_phone * phone, char *phones) ...@@ -2963,7 +2933,7 @@ isdn_net_getphones(isdn_net_ioctl_phone * phone, char *phones)
int inout = phone->outgoing & 1; int inout = phone->outgoing & 1;
int more = 0; int more = 0;
int count = 0; int count = 0;
isdn_net_phone *n; struct isdn_net_phone *n;
if (!p) if (!p)
return -ENODEV; return -ENODEV;
...@@ -3019,34 +2989,33 @@ isdn_net_delphone(isdn_net_ioctl_phone * phone) ...@@ -3019,34 +2989,33 @@ isdn_net_delphone(isdn_net_ioctl_phone * phone)
{ {
isdn_net_dev *p = isdn_net_findif(phone->name); isdn_net_dev *p = isdn_net_findif(phone->name);
int inout = phone->outgoing & 1; int inout = phone->outgoing & 1;
isdn_net_phone *n; struct isdn_net_phone *n, *m;
isdn_net_phone *m;
unsigned long flags; unsigned long flags;
if (p) { if (!p)
save_flags(flags); return -ENODEV;
cli();
n = p->local.phone[inout]; save_flags(flags);
m = NULL; cli();
while (n) { n = p->local.phone[inout];
if (!strcmp(n->num, phone->phone)) { m = NULL;
if (p->local.dial == n) while (n) {
p->local.dial = n->next; if (!strcmp(n->num, phone->phone)) {
if (m) if (p->local.dial == n)
m->next = n->next; p->local.dial = n->next;
else if (m)
p->local.phone[inout] = n->next; m->next = n->next;
kfree(n); else
restore_flags(flags); p->local.phone[inout] = n->next;
return 0; kfree(n);
} restore_flags(flags);
m = n; return 0;
n = (isdn_net_phone *) n->next;
} }
restore_flags(flags); m = n;
return -EINVAL; n = n->next;
} }
return -ENODEV; restore_flags(flags);
return -EINVAL;
} }
/* /*
...@@ -3055,8 +3024,7 @@ isdn_net_delphone(isdn_net_ioctl_phone * phone) ...@@ -3055,8 +3024,7 @@ isdn_net_delphone(isdn_net_ioctl_phone * phone)
static int static int
isdn_net_rmallphone(isdn_net_dev * p) isdn_net_rmallphone(isdn_net_dev * p)
{ {
isdn_net_phone *n; struct isdn_net_phone *n, *m;
isdn_net_phone *m;
unsigned long flags; unsigned long flags;
int i; int i;
......
...@@ -265,10 +265,10 @@ typedef struct { ...@@ -265,10 +265,10 @@ typedef struct {
#define ISDN_NET_MAGIC 0x49344C02 /* for paranoia-checking */ #define ISDN_NET_MAGIC 0x49344C02 /* for paranoia-checking */
/* Phone-list-element */ /* Phone-list-element */
typedef struct { struct isdn_net_phone {
void *next; struct isdn_net_phone *next;
char num[ISDN_MSNLEN]; char num[ISDN_MSNLEN];
} isdn_net_phone; };
/* /*
Principles when extending structures for generic encapsulation protocol Principles when extending structures for generic encapsulation protocol
...@@ -334,10 +334,10 @@ typedef struct isdn_net_local_s { ...@@ -334,10 +334,10 @@ typedef struct isdn_net_local_s {
ulong sqfull_stamp; /* Start-Time of overload */ ulong sqfull_stamp; /* Start-Time of overload */
ulong slavedelay; /* Dynamic bundling delaytime */ ulong slavedelay; /* Dynamic bundling delaytime */
int triggercps; /* BogoCPS needed for trigger slave */ int triggercps; /* BogoCPS needed for trigger slave */
isdn_net_phone *phone[2]; /* List of remote-phonenumbers */ struct isdn_net_phone *phone[2]; /* List of remote-phonenumbers */
/* phone[0] = Incoming Numbers */ /* phone[0] = Incoming Numbers */
/* phone[1] = Outgoing Numbers */ /* phone[1] = Outgoing Numbers */
isdn_net_phone *dial; /* Pointer to dialed number */ struct isdn_net_phone *dial; /* Pointer to dialed number */
struct net_device *master; /* Ptr to Master device for slaves */ struct net_device *master; /* Ptr to Master device for slaves */
struct net_device *slave; /* Ptr to Slave device for masters */ struct net_device *slave; /* Ptr to Slave device for masters */
struct isdn_net_local_s *next; /* Ptr to next link in bundle */ struct isdn_net_local_s *next; /* Ptr to next link in bundle */
......
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