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 ...@@ -52,10 +52,11 @@ static void
isdn_iptyp_receive(isdn_net_local *lp, isdn_net_dev *idev, isdn_iptyp_receive(isdn_net_local *lp, isdn_net_dev *idev,
struct sk_buff *skb) struct sk_buff *skb)
{ {
idev->huptimer = 0; u16 protocol;
get_u16(skb->data, &skb->protocol);
get_u16(skb->data, &protocol);
skb_pull(skb, 2); skb_pull(skb, 2);
netif_rx(skb); isdn_netif_rx(idev, skb, protocol);
} }
static struct isdn_netif_ops iptyp_ops = { static struct isdn_netif_ops iptyp_ops = {
...@@ -84,10 +85,8 @@ static void ...@@ -84,10 +85,8 @@ static void
isdn_uihdlc_receive(isdn_net_local *lp, isdn_net_dev *idev, isdn_uihdlc_receive(isdn_net_local *lp, isdn_net_dev *idev,
struct sk_buff *skb) struct sk_buff *skb)
{ {
idev->huptimer = 0;
skb_pull(skb, 2); skb_pull(skb, 2);
skb->protocol = htons(ETH_P_IP); isdn_netif_rx(idev, skb, htons(ETH_P_IP));
netif_rx(skb);
} }
static struct isdn_netif_ops uihdlc_ops = { static struct isdn_netif_ops uihdlc_ops = {
...@@ -127,9 +126,7 @@ static void ...@@ -127,9 +126,7 @@ static void
isdn_ether_receive(isdn_net_local *lp, isdn_net_dev *idev, isdn_ether_receive(isdn_net_local *lp, isdn_net_dev *idev,
struct sk_buff *skb) struct sk_buff *skb)
{ {
idev->huptimer = 0; isdn_netif_rx(idev, skb, eth_type_trans(skb, &lp->dev));
skb->protocol = eth_type_trans(skb, skb->dev);
netif_rx(skb);
} }
static int static int
......
...@@ -37,6 +37,7 @@ void isdn_net_writebuf_skb(isdn_net_dev *, struct sk_buff *skb); ...@@ -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); void isdn_net_write_super(isdn_net_dev *, struct sk_buff *skb);
int isdn_net_autodial(struct sk_buff *skb, struct net_device *ndev); int isdn_net_autodial(struct sk_buff *skb, struct net_device *ndev);
isdn_net_dev *isdn_net_get_xmit_dev(isdn_net_local *mlp); 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 static inline int
put_u8(unsigned char *p, u8 x) put_u8(unsigned char *p, u8 x)
......
...@@ -2297,6 +2297,20 @@ isdn_net_rcv_skb(int idx, struct sk_buff *skb) ...@@ -2297,6 +2297,20 @@ isdn_net_rcv_skb(int idx, struct sk_buff *skb)
return 1; 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 */ /* init / exit */
/* ====================================================================== */ /* ====================================================================== */
......
...@@ -960,27 +960,27 @@ static void ...@@ -960,27 +960,27 @@ static void
isdn_ppp_push_higher(isdn_net_local *lp, isdn_net_dev *idev, isdn_ppp_push_higher(isdn_net_local *lp, isdn_net_dev *idev,
struct sk_buff *skb, u16 proto) struct sk_buff *skb, u16 proto)
{ {
struct net_device *dev = &lp->dev;
struct ipppd *is = idev->ipppd; struct ipppd *is = idev->ipppd;
if (is->debug & 0x10) { if (is->debug & 0x10) {
printk(KERN_DEBUG "push, skb %d %04x\n", (int) skb->len, proto); 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); 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); skb = ippp_ccp_decompress(lp->ccp, skb, &proto);
if (!skb) // decompression error if (!skb) /* decompression error */
goto out; goto error;
switch (proto) { switch (proto) {
case PPP_IPX: /* untested */ case PPP_IPX: /* untested */
if (is->debug & 0x20) if (is->debug & 0x20)
printk(KERN_DEBUG "isdn_ppp: IPX\n"); printk(KERN_DEBUG "isdn_ppp: IPX\n");
skb->protocol = htons(ETH_P_IPX); isdn_netif_rx(idev, skb, htons(ETH_P_IPX));
break; break;
case PPP_IP: case PPP_IP:
if (is->debug & 0x20) if (is->debug & 0x20)
printk(KERN_DEBUG "isdn_ppp: IP\n"); printk(KERN_DEBUG "isdn_ppp: IP\n");
skb->protocol = htons(ETH_P_IP); isdn_netif_rx(idev, skb, htons(ETH_P_IP));
break; break;
case PPP_COMP: case PPP_COMP:
case PPP_COMPFRAG: case PPP_COMPFRAG:
...@@ -988,11 +988,7 @@ isdn_ppp_push_higher(isdn_net_local *lp, isdn_net_dev *idev, ...@@ -988,11 +988,7 @@ isdn_ppp_push_higher(isdn_net_local *lp, isdn_net_dev *idev,
goto drop; goto drop;
case PPP_VJC_UNCOMP: case PPP_VJC_UNCOMP:
case PPP_VJC_COMP: case PPP_VJC_COMP:
skb = ippp_vj_decompress(lp->slcomp, skb, proto); ippp_vj_decompress(idev, skb, proto);
if (!skb) {
lp->stats.rx_dropped++;
goto out;
}
break; break;
case PPP_CCPFRAG: case PPP_CCPFRAG:
ippp_ccp_receive_ccp(idev->ccp, skb); ippp_ccp_receive_ccp(idev->ccp, skb);
...@@ -1011,20 +1007,16 @@ isdn_ppp_push_higher(isdn_net_local *lp, isdn_net_dev *idev, ...@@ -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); ipppd_queue_read(is, proto, skb->data, skb->len);
goto free; 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; return;
drop: drop:
lp->stats.rx_dropped++; lp->stats.rx_dropped++;
free: free:
kfree_skb(skb); kfree_skb(skb);
return;
error:
lp->stats.rx_dropped++;
} }
/* /*
......
...@@ -36,10 +36,10 @@ ippp_vj_set_maxcid(isdn_net_dev *idev, int val) ...@@ -36,10 +36,10 @@ ippp_vj_set_maxcid(isdn_net_dev *idev, int val)
return 0; return 0;
} }
struct sk_buff * void
ippp_vj_decompress(struct slcompress *slcomp, struct sk_buff *skb_old, ippp_vj_decompress(isdn_net_dev *idev, struct sk_buff *skb_old, u16 proto)
u16 proto)
{ {
struct slcompress *slcomp = idev->mlp->slcomp;
struct sk_buff *skb; struct sk_buff *skb;
int len; int len;
...@@ -67,14 +67,14 @@ ippp_vj_decompress(struct slcompress *slcomp, struct sk_buff *skb_old, ...@@ -67,14 +67,14 @@ ippp_vj_decompress(struct slcompress *slcomp, struct sk_buff *skb_old,
isdn_BUG(); isdn_BUG();
goto drop; goto drop;
} }
skb->protocol = htons(ETH_P_IP); isdn_netif_rx(idev, skb, htons(ETH_P_IP));
return skb; return;
drop_both: drop_both:
kfree_skb(skb); kfree_skb(skb);
drop: drop:
kfree_skb(skb_old); kfree_skb(skb_old);
return NULL; idev->mlp->stats.rx_dropped++;
} }
struct sk_buff * struct sk_buff *
......
...@@ -18,9 +18,8 @@ ippp_vj_free(struct slcompress *slcomp); ...@@ -18,9 +18,8 @@ ippp_vj_free(struct slcompress *slcomp);
int int
ippp_vj_set_maxcid(isdn_net_dev *idev, int val); ippp_vj_set_maxcid(isdn_net_dev *idev, int val);
struct sk_buff * void
ippp_vj_decompress(struct slcompress *slcomp, struct sk_buff *skb_old, ippp_vj_decompress(isdn_net_dev *idev, struct sk_buff *skb_old, u16 proto);
u16 proto);
struct sk_buff * struct sk_buff *
ippp_vj_compress(isdn_net_dev *idev, struct sk_buff *skb_old, u16 *proto); 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