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