Commit 13667ed1 authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN: Use a function pointer for type-specific receive

parent 98a6bc6e
......@@ -324,7 +324,7 @@ isdn_net_ciscohdlck_slarp_in(isdn_net_local *lp, struct sk_buff *skb)
}
}
void
static void
isdn_ciscohdlck_receive(isdn_net_dev *idev, isdn_net_local *olp,
struct sk_buff *skb)
{
......@@ -393,6 +393,7 @@ isdn_ciscohdlck_setup(isdn_net_dev *p)
p->dev.header_cache_update = NULL;
p->dev.flags = IFF_NOARP|IFF_POINTOPOINT;
p->dev.do_ioctl = isdn_ciscohdlck_dev_ioctl;
p->local.receive = isdn_ciscohdlck_receive;
return 0;
}
......
......@@ -14,7 +14,5 @@
int isdn_ciscohdlck_setup(isdn_net_dev *p);
void isdn_ciscohdlck_connected(isdn_net_local *lp);
void isdn_ciscohdlck_disconnected(isdn_net_local *lp);
void isdn_ciscohdlck_receive(isdn_net_dev *p, isdn_net_local *olp,
struct sk_buff *skb);
#endif
......@@ -124,32 +124,6 @@ void isdn_x25_cleanup(isdn_net_dev *p)
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 ( encap ){
case ISDN_NET_ENCAP_X25IFACE:
lp -> dops = &isdn_concap_reliable_dl_dops;
}
/* ... and allocate new one ... */
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 */
if (!p->cprot)
return -EINVAL;
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;
}
void isdn_x25_open(struct net_device *dev)
{
struct concap_device_ops * dops =
......@@ -247,7 +221,8 @@ int isdn_x25_start_xmit(struct sk_buff *skb, struct net_device *dev)
return ret;
}
void isdn_x25_receive(isdn_net_dev *p, isdn_net_local *olp, struct sk_buff *skb)
static void
isdn_x25_receive(isdn_net_dev *p, isdn_net_local *olp, struct sk_buff *skb)
{
isdn_net_local *lp = &p->local;
struct concap_proto *cprot = lp -> netdev -> cprot;
......@@ -267,4 +242,33 @@ void isdn_x25_realrm(isdn_net_dev *p)
p -> cprot -> pops -> proto_del ( p -> cprot );
}
int isdn_x25_setup(isdn_net_dev *p, int encap)
{
isdn_net_local *lp = &p->local;
/* ... , prepare for configuration of new one ... */
switch ( encap ){
case ISDN_NET_ENCAP_X25IFACE:
lp -> dops = &isdn_concap_reliable_dl_dops;
}
/* ... and allocate new one ... */
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 */
if (!p->cprot)
return -EINVAL;
p->dev.type = ARPHRD_X25; /* change ARP type */
p->dev.addr_len = 0;
p->dev.hard_header = NULL;
p->dev.hard_header_cache = NULL;
p->dev.header_cache_update = NULL;
p->local.receive = isdn_x25_receive;
/* the protocol is not configured yet; this will
happen later when isdn_x25_open() is called */
return 0;
}
#endif /* CONFIG_ISDN_X25 */
......@@ -22,7 +22,6 @@ void isdn_x25_connected(isdn_net_local *lp);
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_receive(isdn_net_dev *p, isdn_net_local *olp, struct sk_buff *skb);
void isdn_x25_realrm(isdn_net_dev *p);
#else
......@@ -75,11 +74,6 @@ isdn_x25_start_xmit(struct sk_buff *skb, struct net_device *dev)
return 0;
}
static inline void
isdn_x25_receive(isdn_net_dev *p, isdn_net_local *olp, struct sk_buff *skb)
{
}
static inline void
isdn_x25_realrm(isdn_net_dev *p)
{
......
......@@ -210,11 +210,6 @@ static int isdn_ether_setup(isdn_net_dev *p);
static int isdn_uihdlc_setup(isdn_net_dev *p);
static int isdn_iptyp_setup(isdn_net_dev *p);
static void isdn_rawip_receive(isdn_net_dev *p, isdn_net_local *olp, struct sk_buff *skb);
static void isdn_ether_receive(isdn_net_dev *p, isdn_net_local *olp, struct sk_buff *skb);
static void isdn_uihdlc_receive(isdn_net_dev *p, isdn_net_local *olp, struct sk_buff *skb);
static void isdn_iptyp_receive(isdn_net_dev *p, isdn_net_local *olp, struct sk_buff *skb);
char *isdn_net_revision = "$Revision: 1.140.6.11 $";
/*
......@@ -1228,34 +1223,8 @@ isdn_net_receive(struct net_device *ndev, struct sk_buff *skb)
skb->pkt_type = PACKET_HOST;
skb->mac.raw = skb->data;
isdn_dumppkt("R:", skb->data, skb->len, 40);
switch (lp->p_encap) {
case ISDN_NET_ENCAP_ETHER:
isdn_ether_receive(lp->netdev, olp, skb);
break;
case ISDN_NET_ENCAP_UIHDLC:
isdn_uihdlc_receive(lp->netdev, olp, skb);
break;
case ISDN_NET_ENCAP_RAWIP:
isdn_rawip_receive(lp->netdev, olp, skb);
break;
case ISDN_NET_ENCAP_CISCOHDLCK:
case ISDN_NET_ENCAP_CISCOHDLC:
isdn_ciscohdlck_receive(lp->netdev, olp, skb);
break;
case ISDN_NET_ENCAP_IPTYP:
isdn_iptyp_receive(lp->netdev, olp, skb);
break;
case ISDN_NET_ENCAP_SYNCPPP:
isdn_ppp_receive(lp->netdev, olp, skb);
break;
case ISDN_NET_ENCAP_X25IFACE:
isdn_x25_receive(lp->netdev, olp, skb);
break;
default:
isdn_BUG();
kfree_skb(skb);
break;
}
lp->receive(lp->netdev, olp, skb);
}
/*
......@@ -2514,6 +2483,7 @@ isdn_iptyp_setup(isdn_net_dev *p)
p->dev.hard_header_cache = NULL;
p->dev.header_cache_update = NULL;
p->dev.flags = IFF_NOARP|IFF_POINTOPOINT;
p->local.receive = isdn_iptyp_receive;
return 0;
}
......@@ -2550,6 +2520,7 @@ isdn_uihdlc_setup(isdn_net_dev *p)
p->dev.hard_header_cache = NULL;
p->dev.header_cache_update = NULL;
p->dev.flags = IFF_NOARP|IFF_POINTOPOINT;
p->local.receive = isdn_uihdlc_receive;
return 0;
}
......@@ -2576,6 +2547,7 @@ isdn_rawip_setup(isdn_net_dev *p)
p->dev.hard_header_cache = NULL;
p->dev.header_cache_update = NULL;
p->dev.flags = IFF_NOARP|IFF_POINTOPOINT;
p->local.receive = isdn_rawip_receive;
return 0;
}
......@@ -2656,6 +2628,7 @@ isdn_ether_setup(isdn_net_dev *p)
p->dev.hard_header_cache = eth_header_cache;
p->dev.header_cache_update = eth_header_cache_update;
p->dev.flags = IFF_BROADCAST | IFF_MULTICAST;
p->local.receive = isdn_ether_receive;
return 0;
}
......@@ -962,7 +962,8 @@ static int isdn_ppp_strip_proto(struct sk_buff *skb)
/*
* handler for incoming packets on a syncPPP interface
*/
void isdn_ppp_receive(isdn_net_dev * net_dev, isdn_net_local * lp, struct sk_buff *skb)
static void isdn_ppp_receive(isdn_net_dev *net_dev, isdn_net_local *lp,
struct sk_buff *skb)
{
struct ippp_struct *is;
int slot;
......@@ -2914,7 +2915,8 @@ isdn_ppp_header(struct sk_buff *skb, struct net_device *dev,
int isdn_ppp_setup(isdn_net_dev *p)
int
isdn_ppp_setup(isdn_net_dev *p)
{
p->dev.hard_header = isdn_ppp_header;
p->dev.hard_header_cache = NULL;
......@@ -2923,6 +2925,7 @@ int isdn_ppp_setup(isdn_net_dev *p)
p->dev.type = ARPHRD_PPP; /* change ARP type */
p->dev.addr_len = 0;
p->dev.do_ioctl = isdn_ppp_dev_ioctl;
p->local.receive = isdn_ppp_receive;
return 0;
}
......@@ -25,7 +25,6 @@ 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 *);
void isdn_ppp_receive(isdn_net_dev *, isdn_net_local *, struct sk_buff *);
int isdn_ppp_xmit(struct sk_buff *, struct net_device *);
#else
......@@ -53,11 +52,6 @@ isdn_ppp_free(isdn_net_local *lp)
{
}
static inline void
isdn_ppp_receive(isdn_net_dev *, isdn_net_local *, struct sk_buff *)
{
}
static inline int
isdn_ppp_xmit(struct sk_buff *, struct net_device *);
{
......
......@@ -371,6 +371,9 @@ typedef struct isdn_net_local_s {
char cisco_debserint; /* debugging flag of cisco hdlc with slarp */
struct timer_list cisco_timer;
struct tq_struct tqueue;
void (*receive)(struct isdn_net_dev_s *p,
struct isdn_net_local_s *olp,
struct sk_buff *skb);
} 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