Commit 737bfa64 authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN: Move net_device setup to a type-specific method

isdn_net handles all kind of interfaces, e.g. raw IP, ethernet over ISDN,
PPP - this is a cleanup making the setup of a net_device specific to the
type of interface.
parent 5fd62b58
......@@ -371,8 +371,9 @@ isdn_ciscohdlck_receive(isdn_net_local *lp, struct sk_buff *skb)
kfree_skb(skb);
}
int isdn_ciscohdlck_setup_dev(isdn_net_dev *p)
int isdn_ciscohdlck_setup(isdn_net_dev *p)
{
isdn_other_setup(p);
p->dev.do_ioctl = isdn_ciscohdlck_dev_ioctl;
return 0;
......
......@@ -13,7 +13,7 @@
void isdn_ciscohdlck_connected(isdn_net_local *lp);
void isdn_ciscohdlck_disconnected(isdn_net_local *lp);
int isdn_ciscohdlck_setup_dev(isdn_net_dev *p);
int isdn_ciscohdlck_setup(isdn_net_dev *p);
void isdn_ciscohdlck_receive(isdn_net_local *lp, struct sk_buff *skb);
#endif
......@@ -611,11 +611,9 @@ isdn_status_callback(isdn_ctrl * c)
dbg_statcallb("BHUP: %d\n", i);
dev->drv[di]->online &= ~(1 << (c->arg));
isdn_info_update();
#ifdef CONFIG_ISDN_X25
/* Signal hangup to network-devices */
if (isdn_net_stat_callback(i, c))
break;
#endif
isdn_v110_stat_callback(&slot[i].iv110, c);
if (isdn_tty_stat_callback(i, c))
break;
......
......@@ -107,7 +107,7 @@ struct concap_proto * isdn_concap_new( int encap )
return NULL;
}
void isdn_x25_encap_changed(isdn_net_dev *p, isdn_net_ioctl_cfg *cfg)
void isdn_x25_cleanup(isdn_net_dev *p)
{
isdn_net_local *lp = &p->local;
struct concap_proto * cprot = p -> cprot;
......@@ -122,8 +122,14 @@ void isdn_x25_encap_changed(isdn_net_dev *p, isdn_net_ioctl_cfg *cfg)
p -> cprot = NULL;
lp -> dops = NULL;
restore_flags(flags);
}
int isdn_x25_setup(isdn_net_dev *p, int encap)
{
isdn_net_local *lp = &p->local;
/* ... , prepare for configuration of new one ... */
switch ( cfg -> p_encap ){
switch ( encap ){
case ISDN_NET_ENCAP_X25IFACE:
lp -> dops = &isdn_concap_reliable_dl_dops;
}
......@@ -131,15 +137,16 @@ void isdn_x25_encap_changed(isdn_net_dev *p, isdn_net_ioctl_cfg *cfg)
p -> cprot = isdn_concap_new( cfg -> p_encap );
/* p -> cprot == NULL now if p_encap is not supported
by means of the concap_proto mechanism */
/* the protocol is not configured yet; this will
happen later when isdn_net_reset() is called */
}
if (!p->cprot)
return -EINVAL;
int isdn_x25_setup_dev(isdn_net_dev *p)
{
isdn_other_setup(p);
p->dev.type = ARPHRD_X25; /* change ARP type */
p->dev.addr_len = 0;
/* the protocol is not configured yet; this will
happen later when isdn_x25_open() is called */
return 0;
}
......@@ -251,9 +258,6 @@ void isdn_x25_receive(isdn_net_local *lp, struct sk_buff *skb)
cprot -> pops -> data_ind(cprot,skb);
return;
}
printk(KERN_WARNING "%s: unknown encapsulation, dropping\n",
lp->name);
kfree_skb(skb);
}
void isdn_x25_realrm(isdn_net_dev *p)
......
......@@ -14,8 +14,8 @@ struct concap_proto *isdn_concap_new(int);
#ifdef CONFIG_ISDN_X25
void isdn_x25_encap_changed(isdn_net_dev *p, isdn_net_ioctl_cfg *cfg);
int isdn_x25_setup_dev(isdn_net_dev *p);
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_connected(isdn_net_local *lp);
......@@ -28,14 +28,14 @@ void isdn_x25_realrm(isdn_net_dev *p);
#else
static inline void
isdn_x25_encap_changed(isdn_net_dev *p, isdn_net_ioctl_cfg *cfg)
isdn_x25_cleanup(isdn_net_dev *p)
{
}
static inline int
isdn_x25_setup_dev(isdn_net_dev *p)
isdn_x25_setup(isdn_net_dev *p, int encap)
{
printk(KERN_WARNING "ISDN: SyncPPP support not configured\n");
printk(KERN_WARNING "ISDN: X25 support not configured\n");
return -EINVAL;
}
......@@ -69,12 +69,15 @@ isdn_x25_hangup(isdn_net_local *lp)
{
}
static inline int
isdn_x25_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
return 0;
}
static inline void
isdn_x25_receive(isdn_net_local *lp, struct sk_buff *skb)
{
printk(KERN_WARNING "%s: unknown encapsulation, dropping\n",
lp->name);
kfree_skb(skb);
}
static inline void
......
......@@ -205,6 +205,9 @@ static void do_dialout(isdn_net_local *lp);
static int isdn_net_handle_event(isdn_net_local *lp, int pr, void *arg);
static int isdn_rawip_setup(isdn_net_dev *p);
static int isdn_ether_setup(isdn_net_dev *p);
char *isdn_net_revision = "$Revision: 1.140.6.11 $";
/*
......@@ -1061,10 +1064,8 @@ isdn_net_start_xmit(struct sk_buff *skb, struct net_device *ndev)
unsigned long flags;
isdn_net_local *lp = (isdn_net_local *) ndev->priv;
#ifdef CONFIG_ISDN_X25
if (lp->netdev->cprot)
if (lp->p_encap == ISDN_NET_ENCAP_X25IFACE)
return isdn_x25_start_xmit(skb, ndev);
#endif
/* auto-dialing xmit function */
{
......@@ -1320,10 +1321,13 @@ isdn_net_receive(struct net_device *ndev, struct sk_buff *skb)
}
isdn_ppp_receive(lp->netdev, olp, skb);
return;
default:
case ISDN_NET_ENCAP_X25IFACE:
isdn_x25_receive(lp, skb);
return;
default:
isdn_BUG();
kfree_skb(skb);
return;
}
netif_rx(skb);
......@@ -1928,14 +1932,12 @@ isdn_net_force_dial_lp(isdn_net_local * lp)
}
/* Connect interface with channel */
isdn_net_bind_channel(lp, chi);
#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 -EAGAIN;
}
#endif
/* Initiate dialing */
restore_flags(flags);
init_dialout(lp);
......@@ -2102,55 +2104,48 @@ isdn_net_set_encap(isdn_net_dev *p, isdn_net_ioctl_cfg *cfg)
isdn_net_local *lp = &p->local;
int retval;
if (cfg->p_encap < 0 ||
cfg->p_encap > ISDN_NET_ENCAP_MAX_ENCAP) {
retval = -EINVAL;
goto out;
}
if (lp->p_encap == cfg->p_encap){
/* no change */
/* nothing to do */
retval = 0;
goto out;
}
if (isdn_net_device_started(p)) {
retval = -EBUSY;
goto out;
}
isdn_x25_encap_changed(p, cfg);
switch (lp->p_encap) {
case ISDN_NET_ENCAP_X25IFACE:
isdn_x25_cleanup(p);
break;
}
switch ( cfg->p_encap ) {
switch (cfg->p_encap) {
case ISDN_NET_ENCAP_SYNCPPP:
retval = isdn_ppp_setup_dev(p);
retval = isdn_ppp_setup(p);
break;
case ISDN_NET_ENCAP_X25IFACE:
retval = isdn_x25_setup_dev(p);
retval = isdn_x25_setup(p, cfg->p_encap);
break;
case ISDN_NET_ENCAP_CISCOHDLCK:
retval = isdn_ciscohdlck_setup_dev(p);
retval = isdn_ciscohdlck_setup(p);
break;
case ISDN_NET_ENCAP_RAWIP:
retval = isdn_rawip_setup(p);
break;
case ISDN_NET_ENCAP_ETHER:
retval = isdn_ether_setup(p);
break;
default:
if (cfg->p_encap < 0 ||
cfg->p_encap > ISDN_NET_ENCAP_MAX_ENCAP) {
retval = -EINVAL;
break;
}
retval = 0;
}
if (cfg->p_encap == ISDN_NET_ENCAP_RAWIP) {
p->dev.hard_header = NULL;
p->dev.hard_header_cache = NULL;
p->dev.header_cache_update = NULL;
p->dev.flags = IFF_NOARP|IFF_POINTOPOINT;
} else {
p->dev.hard_header = isdn_net_header;
if (cfg->p_encap == ISDN_NET_ENCAP_ETHER) {
p->dev.hard_header_cache = lp->org_hhc;
p->dev.header_cache_update = lp->org_hcu;
p->dev.flags = IFF_BROADCAST | IFF_MULTICAST;
} else {
p->dev.hard_header_cache = NULL;
p->dev.header_cache_update = NULL;
p->dev.flags = IFF_NOARP|IFF_POINTOPOINT;
}
retval = isdn_other_setup(p);
break;
}
lp->p_encap = cfg->p_encap;
if (retval == 0)
lp->p_encap = cfg->p_encap;
out:
return retval;
......@@ -2651,3 +2646,39 @@ isdn_net_rmall(void)
restore_flags(flags);
return 0;
}
static int
isdn_rawip_setup(isdn_net_dev *p)
{
p->dev.hard_header = NULL;
p->dev.hard_header_cache = NULL;
p->dev.header_cache_update = NULL;
p->dev.flags = IFF_NOARP|IFF_POINTOPOINT;
return 0;
}
static int
isdn_ether_setup(isdn_net_dev *p)
{
isdn_net_local *lp = &p->local;
p->dev.hard_header = isdn_net_header;
p->dev.hard_header_cache = lp->org_hhc;
p->dev.header_cache_update = lp->org_hcu;
p->dev.flags = IFF_BROADCAST | IFF_MULTICAST;
return 0;
}
int
isdn_other_setup(isdn_net_dev *p)
{
p->dev.hard_header = isdn_net_header;
p->dev.hard_header_cache = NULL;
p->dev.header_cache_update = NULL;
p->dev.flags = IFF_NOARP|IFF_POINTOPOINT;
return 0;
}
......@@ -53,6 +53,7 @@ extern int isdn_net_rcv_skb(int, struct sk_buff *);
extern int isdn_net_dial_req(isdn_net_local *);
extern void isdn_net_writebuf_skb(isdn_net_local *lp, struct sk_buff *skb);
extern void isdn_net_write_super(isdn_net_local *lp, struct sk_buff *skb);
extern int isdn_other_setup(isdn_net_dev *p);
#define ISDN_NET_MAX_QUEUE_LENGTH 2
......
......@@ -2895,8 +2895,9 @@ static int isdn_ppp_set_compressor(struct ippp_struct *is, struct isdn_ppp_comp_
return -EINVAL;
}
int isdn_ppp_setup_dev(isdn_net_dev *p)
int isdn_ppp_setup(isdn_net_dev *p)
{
isdn_other_setup(p);
p->dev.type = ARPHRD_PPP; /* change ARP type */
p->dev.addr_len = 0;
p->dev.do_ioctl = isdn_ppp_dev_ioctl;
......
......@@ -21,7 +21,7 @@ extern int isdn_ppp_hangup_slave(char *);
#ifdef CONFIG_ISDN_PPP
int isdn_ppp_setup_dev(isdn_net_dev *p);
int isdn_ppp_setup(isdn_net_dev *p);
void isdn_ppp_wakeup_daemon(isdn_net_local *);
int isdn_ppp_bind(isdn_net_local *);
void isdn_ppp_free(isdn_net_local *);
......@@ -31,7 +31,7 @@ int isdn_ppp_xmit(struct sk_buff *, struct net_device *);
#else
static inline int
isdn_ppp_setup_dev(isdn_net_dev *p)
isdn_ppp_setup(isdn_net_dev *p)
{
printk(KERN_WARNING "ISDN: SyncPPP support not configured\n");
return -EINVAL;
......
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