[AX25] Introduce ax25_type_trans
authorArnaldo Carvalho de Melo <acme@ghostprotocols.net>
Mon, 25 Apr 2005 01:53:06 +0000 (18:53 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 25 Apr 2005 01:53:06 +0000 (18:53 -0700)
Replacing the open coded equivalents and making ax25 look more like
a linux network protocol, i.e. more similar to inet.

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/hamradio/6pack.c
drivers/net/hamradio/baycom_epp.c
drivers/net/hamradio/bpqether.c
drivers/net/hamradio/dmascc.c
drivers/net/hamradio/hdlcdrv.c
drivers/net/hamradio/mkiss.c
drivers/net/hamradio/scc.c
drivers/net/hamradio/yam.c
include/net/ax25.h
net/ax25/ax25_ds_subr.c
net/ax25/ax25_out.c

index 067b353e1cbdaabfe64e9f92cdd5b0f35cbcfb49..89454915b857dcf72b6b64be822108adc14eb377 100644 (file)
@@ -394,13 +394,11 @@ static void sp_bump(struct sixpack *sp, char cmd)
        if ((skb = dev_alloc_skb(count)) == NULL)
                goto out_mem;
 
-       skb->dev = sp->dev;
        ptr = skb_put(skb, count);
        *ptr++ = cmd;   /* KISS command */
 
        memcpy(ptr, sp->cooked_buf + 1, count);
-       skb->mac.raw = skb->data;
-       skb->protocol = htons(ETH_P_AX25);
+       skb->protocol = ax25_type_trans(skb, sp->dev);
        netif_rx(skb);
        sp->dev->last_rx = jiffies;
        sp->stats.rx_packets++;
index e8cb87d906fcfa12b86a14cdc6b1d860c28cffbf..1c563f905a5964fb094d40ab6626e4b590a6bcb2 100644 (file)
@@ -601,12 +601,10 @@ static void do_rxpacket(struct net_device *dev)
                bc->stats.rx_dropped++;
                return;
        }
-       skb->dev = dev;
        cp = skb_put(skb, pktlen);
        *cp++ = 0; /* KISS kludge */
        memcpy(cp, bc->hdlcrx.buf, pktlen - 1);
-       skb->protocol = htons(ETH_P_AX25);
-       skb->mac.raw = skb->data;
+       skb->protocol = ax25_type_trans(skb, dev);
        netif_rx(skb);
        dev->last_rx = jiffies;
        bc->stats.rx_packets++;
index ef1a359e227347ac0ba168aee38777ec45aef626..ba9f0580e1f9be97d9398bcfdccc6d7aa1754789 100644 (file)
@@ -211,11 +211,7 @@ static int bpq_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_ty
        ptr = skb_push(skb, 1);
        *ptr = 0;
 
-       skb->dev = dev;
-       skb->protocol = htons(ETH_P_AX25);
-       skb->mac.raw = skb->data;
-       skb->pkt_type = PACKET_HOST;
-
+       skb->protocol = ax25_type_trans(skb, dev);
        netif_rx(skb);
        dev->last_rx = jiffies;
 unlock:
@@ -272,8 +268,6 @@ static int bpq_xmit(struct sk_buff *skb, struct net_device *dev)
                skb = newskb;
        }
 
-       skb->protocol = htons(ETH_P_AX25);
-
        ptr = skb_push(skb, 2);
 
        *ptr++ = (size + 5) % 256;
@@ -287,7 +281,7 @@ static int bpq_xmit(struct sk_buff *skb, struct net_device *dev)
                return -ENODEV;
        }
 
-       skb->dev = dev;
+       skb->protocol = ax25_type_trans(skb, dev);
        skb->nh.raw = skb->data;
        dev->hard_header(skb, dev, ETH_P_BPQ, bpq->dest_addr, NULL, 0);
        bpq->stats.tx_packets++;
index f3269b70a8c59e10b44961038f796640c85c8998..f515245a3fd0997f049aaa626ba8af0300b2ad9d 100644 (file)
@@ -1306,9 +1306,7 @@ static void rx_bh(void *arg)
                        data = skb_put(skb, cb + 1);
                        data[0] = 0;
                        memcpy(&data[1], priv->rx_buf[i], cb);
-                       skb->dev = priv->dev;
-                       skb->protocol = ntohs(ETH_P_AX25);
-                       skb->mac.raw = skb->data;
+                       skb->protocol = ax25_type_trans(skb, priv->dev);
                        netif_rx(skb);
                        priv->dev->last_rx = jiffies;
                        priv->stats.rx_packets++;
index b89959a596d7f615e2db9f4b23a27980e11c551f..b4c836e4fe860d4a4e7fe0d82a52736dd7432f2c 100644 (file)
@@ -174,12 +174,10 @@ static void hdlc_rx_flag(struct net_device *dev, struct hdlcdrv_state *s)
                s->stats.rx_dropped++;
                return;
        }
-       skb->dev = dev;
        cp = skb_put(skb, pkt_len);
        *cp++ = 0; /* KISS kludge */
        memcpy(cp, s->hdlcrx.buffer, pkt_len - 1);
-       skb->protocol = htons(ETH_P_AX25);
-       skb->mac.raw = skb->data;
+       skb->protocol = ax25_type_trans(skb, dev);
        netif_rx(skb);
        dev->last_rx = jiffies;
        s->stats.rx_packets++;
index d9ea080aea0f3513a3173b9348149f3b8662896d..62790511098f6506241b94fa9f8043c0c02047aa 100644 (file)
@@ -332,12 +332,10 @@ static void ax_bump(struct ax_disp *ax)
                return;
        }
 
-       skb->dev      = ax->dev;
        spin_lock_bh(&ax->buflock);
        memcpy(skb_put(skb,count), ax->rbuff, count);
        spin_unlock_bh(&ax->buflock);
-       skb->mac.raw  = skb->data;
-       skb->protocol = htons(ETH_P_AX25);
+       skb->protocol = ax25_type_trans(skb, ax->dev);
        netif_rx(skb);
        ax->dev->last_rx = jiffies;
        ax->rx_packets++;
index ce9e7af020da583d04bc80243614c18a4becd7a3..ece1b1a1318632da085d4e0a855bf4c2cb7a5e7f 100644 (file)
@@ -1630,10 +1630,7 @@ static void scc_net_rx(struct scc_channel *scc, struct sk_buff *skb)
        scc->dev_stat.rx_packets++;
        scc->dev_stat.rx_bytes += skb->len;
 
-       skb->dev      = scc->dev;
-       skb->protocol = htons(ETH_P_AX25);
-       skb->mac.raw  = skb->data;
-       skb->pkt_type = PACKET_HOST;
+       skb->protocol = ax25_type_trans(skb, scc->dev);
        
        netif_rx(skb);
        scc->dev->last_rx = jiffies;
index fd7b00fe38e5e0c95920c3ca872c323ec83d93bb..41213ef602dc764bad14bb772684289d1b831f07 100644 (file)
@@ -522,12 +522,10 @@ static inline void yam_rx_flag(struct net_device *dev, struct yam_port *yp)
                                ++yp->stats.rx_dropped;
                        } else {
                                unsigned char *cp;
-                               skb->dev = dev;
                                cp = skb_put(skb, pkt_len);
                                *cp++ = 0;              /* KISS kludge */
                                memcpy(cp, yp->rx_buf, pkt_len - 1);
-                               skb->protocol = htons(ETH_P_AX25);
-                               skb->mac.raw = skb->data;
+                               skb->protocol = ax25_type_trans(skb, dev);
                                netif_rx(skb);
                                dev->last_rx = jiffies;
                                ++yp->stats.rx_packets;
index 875edbba396d2601fce49e8e1c88f90195b56698..9e6368a5454760fa9bc1c56fc691b110474094b3 100644 (file)
@@ -220,6 +220,14 @@ static __inline__ void ax25_cb_put(ax25_cb *ax25)
        }
 }
 
+static inline unsigned short ax25_type_trans(struct sk_buff *skb, struct net_device *dev)
+{
+       skb->dev      = dev;
+       skb->pkt_type = PACKET_HOST;
+       skb->mac.raw  = skb->data;
+       return htons(ETH_P_AX25);
+}
+
 /* af_ax25.c */
 extern struct hlist_head ax25_list;
 extern spinlock_t ax25_list_lock;
index 10ffd2beba3f861a4ca8800f1e61faa9f3a983d4..1d4ab641f82be6094255f9046983a3b33fa9e570 100644 (file)
@@ -143,8 +143,7 @@ static void ax25_kiss_cmd(ax25_dev *ax25_dev, unsigned char cmd, unsigned char p
        *p++ = cmd;
        *p++ = param;
 
-       skb->dev      = ax25_dev->dev;
-       skb->protocol = htons(ETH_P_AX25);
+       skb->protocol = ax25_type_trans(skb, ax25_dev->dev);
 
        dev_queue_xmit(skb);
 }
index 94557b1a1fa2acedd47b30c3e51b9733eb02b53a..5fc048dcd39ab29089b4140785f75315d4348f6f 100644 (file)
@@ -351,8 +351,7 @@ void ax25_queue_xmit(struct sk_buff *skb, struct net_device *dev)
 {
        unsigned char *ptr;
 
-       skb->protocol = htons(ETH_P_AX25);
-       skb->dev      = ax25_fwd_dev(dev);
+       skb->protocol = ax25_type_trans(skb, ax25_fwd_dev(dev));
 
        ptr  = skb_push(skb, 1);
        *ptr = 0x00;                    /* KISS */