Commit c25b65fe authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN: Use a function pointer for type-specific disconnected() callback

Again, instead of a switch statement, just use a callback.
parent 8dd4eb5c
......@@ -217,7 +217,7 @@ isdn_ciscohdlck_connected(isdn_net_local *lp)
isdn_net_device_wake_queue(lp);
}
void
static void
isdn_ciscohdlck_disconnected(isdn_net_local *lp)
{
if (lp->p_encap == ISDN_NET_ENCAP_CISCOHDLCK) {
......@@ -400,6 +400,7 @@ isdn_ciscohdlck_setup(isdn_net_dev *p)
p->dev.do_ioctl = isdn_ciscohdlck_dev_ioctl;
p->local.receive = isdn_ciscohdlck_receive;
p->local.connected = isdn_ciscohdlck_connected;
p->local.disconnected = isdn_ciscohdlck_disconnected;
return 0;
}
......
......@@ -12,6 +12,5 @@
#define ISDN_CISCOHDLCK_H
int isdn_ciscohdlck_setup(isdn_net_dev *p);
void isdn_ciscohdlck_disconnected(isdn_net_local *lp);
#endif
......@@ -160,27 +160,11 @@ static void isdn_x25_connected(isdn_net_local *lp)
isdn_net_device_wake_queue(lp);
}
void isdn_x25_dhup(isdn_net_local *lp)
static void isdn_x25_disconnected(isdn_net_local *lp)
{
struct concap_proto *cprot = lp -> netdev -> cprot;
struct concap_proto_ops *pops = cprot ? cprot -> pops : 0;
/* If we are not connected then dialing had
failed. If there are generic encap protocol
receiver routines signal the closure of
the link */
if (!(lp->flags & ISDN_NET_CONNECTED)
&& pops && pops->disconn_ind)
pops -> disconn_ind(cprot);
}
void isdn_x25_bhup(isdn_net_local *lp)
{
struct concap_proto *cprot = lp -> netdev -> cprot;
struct concap_proto_ops *pops = cprot ? cprot -> pops : 0;
/* B-Channel-hangup */
/* try if there are generic encap protocol
receiver routines and signal the closure of
the link */
......@@ -188,18 +172,6 @@ void isdn_x25_bhup(isdn_net_local *lp)
pops -> disconn_ind(cprot);
}
void isdn_x25_hangup(isdn_net_local *lp)
{
struct concap_proto *cprot = lp -> netdev -> cprot;
struct concap_proto_ops *pops = cprot ? cprot -> pops : 0;
/* try if there are generic encap protocol
receiver routines and signal the closure of
the link */
if( pops && pops -> disconn_ind )
pops -> disconn_ind(cprot);
}
int isdn_x25_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
/* At this point hard_start_xmit() passes control to the encapsulation
......@@ -267,6 +239,7 @@ int isdn_x25_setup(isdn_net_dev *p, int encap)
p->dev.header_cache_update = NULL;
p->local.receive = isdn_x25_receive;
p->local.connected = isdn_x25_connected;
p->local.disconnected = isdn_x25_disconnected;
/* the protocol is not configured yet; this will
happen later when isdn_x25_open() is called */
......
......@@ -18,8 +18,6 @@ int isdn_x25_setup(isdn_net_dev *p, int encap);
void isdn_x25_cleanup(isdn_net_dev *p);
void isdn_x25_open(struct net_device *dev);
void isdn_x25_close(struct net_device *dev);
void isdn_x25_bhup(isdn_net_local *lp);
void isdn_x25_hangup(isdn_net_local *lp);
int isdn_x25_start_xmit(struct sk_buff *skb, struct net_device *dev);
void isdn_x25_realrm(isdn_net_dev *p);
......@@ -47,21 +45,6 @@ isdn_x25_close(struct net_device *dev)
{
}
static inline void
isdn_x25_dhup(isdn_net_local *lp)
{
}
static inline void
isdn_x25_bhup(isdn_net_local *lp)
{
}
static inline void
isdn_x25_hangup(isdn_net_local *lp)
{
}
static inline int
isdn_x25_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
......
......@@ -548,26 +548,19 @@ isdn_net_handle_event(isdn_net_local *lp, int pr, void *arg)
}
break;
case ISDN_STAT_DHUP:
/* Either D-Channel-hangup or error during dialout */
isdn_x25_dhup(lp);
if (lp->flags & ISDN_NET_CONNECTED) {
if (lp->p_encap == ISDN_NET_ENCAP_CISCOHDLCK)
isdn_ciscohdlck_disconnected(lp);
if (lp->p_encap == ISDN_NET_ENCAP_SYNCPPP)
isdn_ppp_free(lp);
isdn_net_lp_disconnected(lp);
isdn_slot_all_eaz(lp->isdn_slot);
printk(KERN_INFO "%s: remote hangup\n", lp->name);
printk(KERN_INFO "%s: Chargesum is %d\n", lp->name,
lp->charge);
isdn_net_unbind_channel(lp);
return 1;
}
break;
case ISDN_STAT_BHUP:
isdn_x25_bhup(lp);
break;
if (!(lp->flags & ISDN_NET_CONNECTED))
break;
if (lp->disconnected)
lp->disconnected(lp);
isdn_net_lp_disconnected(lp);
isdn_slot_all_eaz(lp->isdn_slot);
printk(KERN_INFO "%s: remote hangup\n", lp->name);
printk(KERN_INFO "%s: Chargesum is %d\n", lp->name,
lp->charge);
isdn_net_unbind_channel(lp);
return 1;
case ISDN_STAT_CINF:
/* Charge-info from TelCo. Calculate interval between
* charge-infos and set timestamp for last info for
......@@ -713,10 +706,10 @@ isdn_net_hangup(isdn_net_local *lp)
}
}
printk(KERN_INFO "isdn_net: local hangup %s\n", lp->name);
if (lp->p_encap == ISDN_NET_ENCAP_SYNCPPP)
isdn_ppp_free(lp);
if (lp->disconnected)
lp->disconnected(lp);
isdn_net_lp_disconnected(lp);
isdn_x25_hangup(lp);
isdn_slot_command(lp->isdn_slot, ISDN_CMD_HANGUP, &cmd);
printk(KERN_INFO "%s: Chargesum is %d\n", lp->name, lp->charge);
......@@ -1622,8 +1615,9 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup)
/* if this interface is dialing, it does it probably on a different
device, so free this device */
if (lp->dialstate == ST_OUT_WAIT_DCONN) {
if (lp->p_encap == ISDN_NET_ENCAP_SYNCPPP)
isdn_ppp_free(lp);
if (lp->disconnected)
lp->disconnected(lp);
isdn_net_lp_disconnected(lp);
isdn_slot_free(lp->isdn_slot,
ISDN_USAGE_NET);
......@@ -1651,14 +1645,12 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup)
add_timer(&lp->dial_timer);
lp->dialstate = ST_IN_WAIT_DCONN;
#ifdef CONFIG_ISDN_PPP
if (lp->p_encap == ISDN_NET_ENCAP_SYNCPPP)
if (isdn_ppp_bind(lp) < 0) {
isdn_net_unbind_channel(lp);
restore_flags(flags);
return 0;
}
#endif
restore_flags(flags);
return 1;
}
......@@ -2465,6 +2457,7 @@ isdn_iptyp_setup(isdn_net_dev *p)
p->dev.flags = IFF_NOARP|IFF_POINTOPOINT;
p->local.receive = isdn_iptyp_receive;
p->local.connected = isdn_net_device_wake_queue;
p->local.disconnected = NULL;
return 0;
}
......@@ -2503,6 +2496,7 @@ isdn_uihdlc_setup(isdn_net_dev *p)
p->dev.flags = IFF_NOARP|IFF_POINTOPOINT;
p->local.receive = isdn_uihdlc_receive;
p->local.connected = isdn_net_device_wake_queue;
p->local.disconnected = NULL;
return 0;
}
......@@ -2531,6 +2525,7 @@ isdn_rawip_setup(isdn_net_dev *p)
p->dev.flags = IFF_NOARP|IFF_POINTOPOINT;
p->local.receive = isdn_rawip_receive;
p->local.connected = isdn_net_device_wake_queue;
p->local.disconnected = NULL;
return 0;
}
......@@ -2613,6 +2608,7 @@ isdn_ether_setup(isdn_net_dev *p)
p->dev.flags = IFF_BROADCAST | IFF_MULTICAST;
p->local.receive = isdn_ether_receive;
p->local.connected = isdn_net_device_wake_queue;
p->local.disconnected = NULL;
return 0;
}
......@@ -99,7 +99,7 @@ isdn_ppp_frame_log(char *info, char *data, int len, int maxlen,int unit,int slot
* note: it can happen, that we hangup/free the master before the slaves
* in this case we bind another lp to the master device
*/
void
static void
isdn_ppp_free(isdn_net_local * lp)
{
unsigned long flags;
......@@ -2927,6 +2927,7 @@ isdn_ppp_setup(isdn_net_dev *p)
p->dev.do_ioctl = isdn_ppp_dev_ioctl;
p->local.receive = isdn_ppp_receive;
p->local.connected = isdn_ppp_wakeup_daemon;
p->local.disconnected = isdn_ppp_free;
return 0;
}
......@@ -23,7 +23,6 @@ extern int isdn_ppp_hangup_slave(char *);
int isdn_ppp_setup(isdn_net_dev *p);
int isdn_ppp_bind(isdn_net_local *);
void isdn_ppp_free(isdn_net_local *);
int isdn_ppp_xmit(struct sk_buff *, struct net_device *);
#else
......@@ -41,11 +40,6 @@ isdn_ppp_bind(isdn_net_local *)
return 0;
}
static inline void
isdn_ppp_free(isdn_net_local *lp)
{
}
static inline int
isdn_ppp_xmit(struct sk_buff *, struct net_device *);
{
......
......@@ -375,6 +375,7 @@ typedef struct isdn_net_local_s {
struct isdn_net_local_s *olp,
struct sk_buff *skb);
void (*connected)(struct isdn_net_local_s *lp);
void (*disconnected)(struct isdn_net_local_s *lp);
} isdn_net_local;
/* the interface itself */
......
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