Commit 38bfd3a1 authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN: isdn_netif_rx() helper

The different types of ISDN network interfaces all need to do the same
thing when passing received packets on to the network stack, so let's
have a helper function for that.
parent 3d3cacd5
......@@ -52,10 +52,11 @@ static void
isdn_iptyp_receive(isdn_net_local *lp, isdn_net_dev *idev,
struct sk_buff *skb)
{
idev->huptimer = 0;
get_u16(skb->data, &skb->protocol);
u16 protocol;
get_u16(skb->data, &protocol);
skb_pull(skb, 2);
netif_rx(skb);
isdn_netif_rx(idev, skb, protocol);
}
static struct isdn_netif_ops iptyp_ops = {
......@@ -84,10 +85,8 @@ static void
isdn_uihdlc_receive(isdn_net_local *lp, isdn_net_dev *idev,
struct sk_buff *skb)
{
idev->huptimer = 0;
skb_pull(skb, 2);
skb->protocol = htons(ETH_P_IP);
netif_rx(skb);
isdn_netif_rx(idev, skb, htons(ETH_P_IP));
}
static struct isdn_netif_ops uihdlc_ops = {
......@@ -127,9 +126,7 @@ static void
isdn_ether_receive(isdn_net_local *lp, isdn_net_dev *idev,
struct sk_buff *skb)
{
idev->huptimer = 0;
skb->protocol = eth_type_trans(skb, skb->dev);
netif_rx(skb);
isdn_netif_rx(idev, skb, eth_type_trans(skb, &lp->dev));
}
static int
......
......@@ -37,6 +37,7 @@ void isdn_net_writebuf_skb(isdn_net_dev *, struct sk_buff *skb);
void isdn_net_write_super(isdn_net_dev *, struct sk_buff *skb);
int isdn_net_autodial(struct sk_buff *skb, struct net_device *ndev);
isdn_net_dev *isdn_net_get_xmit_dev(isdn_net_local *mlp);
void isdn_netif_rx(isdn_net_dev *idev, struct sk_buff *skb, u16 protocol);
static inline int
put_u8(unsigned char *p, u8 x)
......
......@@ -2297,6 +2297,20 @@ isdn_net_rcv_skb(int idx, struct sk_buff *skb)
return 1;
}
/*
* After handling connection-type specific stuff, the receiver function
* can use this function to pass the skb on to the network layer.
*/
void
isdn_netif_rx(isdn_net_dev *idev, struct sk_buff *skb, u16 protocol)
{
idev->huptimer = 0;
skb->protocol = protocol;
skb->dev = &idev->mlp->dev;
netif_rx(skb);
}
/* ====================================================================== */
/* init / exit */
/* ====================================================================== */
......
......@@ -960,27 +960,27 @@ static void
isdn_ppp_push_higher(isdn_net_local *lp, isdn_net_dev *idev,
struct sk_buff *skb, u16 proto)
{
struct net_device *dev = &lp->dev;
struct ipppd *is = idev->ipppd;
if (is->debug & 0x10) {
printk(KERN_DEBUG "push, skb %d %04x\n", (int) skb->len, proto);
isdn_ppp_frame_log("rpush", skb->data, skb->len, 32,is->unit, -1);
}
/* all packets need to passed through the compressor */
skb = ippp_ccp_decompress(lp->ccp, skb, &proto);
if (!skb) // decompression error
goto out;
if (!skb) /* decompression error */
goto error;
switch (proto) {
case PPP_IPX: /* untested */
if (is->debug & 0x20)
printk(KERN_DEBUG "isdn_ppp: IPX\n");
skb->protocol = htons(ETH_P_IPX);
isdn_netif_rx(idev, skb, htons(ETH_P_IPX));
break;
case PPP_IP:
if (is->debug & 0x20)
printk(KERN_DEBUG "isdn_ppp: IP\n");
skb->protocol = htons(ETH_P_IP);
isdn_netif_rx(idev, skb, htons(ETH_P_IP));
break;
case PPP_COMP:
case PPP_COMPFRAG:
......@@ -988,11 +988,7 @@ isdn_ppp_push_higher(isdn_net_local *lp, isdn_net_dev *idev,
goto drop;
case PPP_VJC_UNCOMP:
case PPP_VJC_COMP:
skb = ippp_vj_decompress(lp->slcomp, skb, proto);
if (!skb) {
lp->stats.rx_dropped++;
goto out;
}
ippp_vj_decompress(idev, skb, proto);
break;
case PPP_CCPFRAG:
ippp_ccp_receive_ccp(idev->ccp, skb);
......@@ -1011,20 +1007,16 @@ isdn_ppp_push_higher(isdn_net_local *lp, isdn_net_dev *idev,
ipppd_queue_read(is, proto, skb->data, skb->len);
goto free;
}
/* Reset hangup-timer */
idev->huptimer = 0;
skb->dev = dev;
netif_rx(skb);
/* net_dev->local->stats.rx_packets++; done in isdn_net.c */
out:
return;
drop:
lp->stats.rx_dropped++;
free:
kfree_skb(skb);
return;
error:
lp->stats.rx_dropped++;
}
/*
......
......@@ -36,10 +36,10 @@ ippp_vj_set_maxcid(isdn_net_dev *idev, int val)
return 0;
}
struct sk_buff *
ippp_vj_decompress(struct slcompress *slcomp, struct sk_buff *skb_old,
u16 proto)
void
ippp_vj_decompress(isdn_net_dev *idev, struct sk_buff *skb_old, u16 proto)
{
struct slcompress *slcomp = idev->mlp->slcomp;
struct sk_buff *skb;
int len;
......@@ -67,14 +67,14 @@ ippp_vj_decompress(struct slcompress *slcomp, struct sk_buff *skb_old,
isdn_BUG();
goto drop;
}
skb->protocol = htons(ETH_P_IP);
return skb;
isdn_netif_rx(idev, skb, htons(ETH_P_IP));
return;
drop_both:
kfree_skb(skb);
drop:
kfree_skb(skb_old);
return NULL;
idev->mlp->stats.rx_dropped++;
}
struct sk_buff *
......
......@@ -18,9 +18,8 @@ ippp_vj_free(struct slcompress *slcomp);
int
ippp_vj_set_maxcid(isdn_net_dev *idev, int val);
struct sk_buff *
ippp_vj_decompress(struct slcompress *slcomp, struct sk_buff *skb_old,
u16 proto);
void
ippp_vj_decompress(isdn_net_dev *idev, struct sk_buff *skb_old, u16 proto);
struct sk_buff *
ippp_vj_compress(isdn_net_dev *idev, struct sk_buff *skb_old, u16 *proto);
......
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