wimax: oops: wimax_dev_add() is the only one that can initialize the state
[safe/jmp/linux-2.6] / net / ax25 / ax25_ip.c
index 136c3ae..f047a57 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/in.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/sched.h>
 #include <linux/timer.h>
 #include <linux/string.h>
 #include <linux/sockios.h>
@@ -47,7 +46,9 @@
 
 #ifdef CONFIG_INET
 
-int ax25_hard_header(struct sk_buff *skb, struct net_device *dev, unsigned short type, void *daddr, void *saddr, unsigned len)
+int ax25_hard_header(struct sk_buff *skb, struct net_device *dev,
+                    unsigned short type, const void *daddr,
+                    const void *saddr, unsigned len)
 {
        unsigned char *buff;
 
@@ -55,46 +56,46 @@ int ax25_hard_header(struct sk_buff *skb, struct net_device *dev, unsigned short
        if (type == ETH_P_AX25)
                return 0;
 
-       /* header is an AX.25 UI frame from us to them */
-       buff = skb_push(skb, AX25_HEADER_LEN);
-       *buff++ = 0x00; /* KISS DATA */
+       /* header is an AX.25 UI frame from us to them */
+       buff = skb_push(skb, AX25_HEADER_LEN);
+       *buff++ = 0x00; /* KISS DATA */
 
        if (daddr != NULL)
                memcpy(buff, daddr, dev->addr_len);     /* Address specified */
 
-       buff[6] &= ~AX25_CBIT;
-       buff[6] &= ~AX25_EBIT;
-       buff[6] |= AX25_SSSID_SPARE;
-       buff    += AX25_ADDR_LEN;
-
-       if (saddr != NULL)
-               memcpy(buff, saddr, dev->addr_len);
-       else
-               memcpy(buff, dev->dev_addr, dev->addr_len);
-
-       buff[6] &= ~AX25_CBIT;
-       buff[6] |= AX25_EBIT;
-       buff[6] |= AX25_SSSID_SPARE;
-       buff    += AX25_ADDR_LEN;
-
-       *buff++  = AX25_UI;     /* UI */
-
-       /* Append a suitable AX.25 PID */
-       switch (type) {
-       case ETH_P_IP:
-               *buff++ = AX25_P_IP;
-               break;
-       case ETH_P_ARP:
-               *buff++ = AX25_P_ARP;
-               break;
-       default:
-               printk(KERN_ERR "AX.25: ax25_hard_header - wrong protocol type 0x%2.2x\n", type);
-               *buff++ = 0;
-               break;
-       }
+       buff[6] &= ~AX25_CBIT;
+       buff[6] &= ~AX25_EBIT;
+       buff[6] |= AX25_SSSID_SPARE;
+       buff    += AX25_ADDR_LEN;
+
+       if (saddr != NULL)
+               memcpy(buff, saddr, dev->addr_len);
+       else
+               memcpy(buff, dev->dev_addr, dev->addr_len);
+
+       buff[6] &= ~AX25_CBIT;
+       buff[6] |= AX25_EBIT;
+       buff[6] |= AX25_SSSID_SPARE;
+       buff    += AX25_ADDR_LEN;
+
+       *buff++  = AX25_UI;     /* UI */
+
+       /* Append a suitable AX.25 PID */
+       switch (type) {
+       case ETH_P_IP:
+               *buff++ = AX25_P_IP;
+               break;
+       case ETH_P_ARP:
+               *buff++ = AX25_P_ARP;
+               break;
+       default:
+               printk(KERN_ERR "AX.25: ax25_hard_header - wrong protocol type 0x%2.2x\n", type);
+               *buff++ = 0;
+               break;
+       }
 
        if (daddr != NULL)
-               return AX25_HEADER_LEN;
+               return AX25_HEADER_LEN;
 
        return -AX25_HEADER_LEN;        /* Unfinished header */
 }
@@ -114,21 +115,21 @@ int ax25_rebuild_header(struct sk_buff *skb)
        dst = (ax25_address *)(bp + 1);
        src = (ax25_address *)(bp + 8);
 
-       if (arp_find(bp + 1, skb))
-               return 1;
+       if (arp_find(bp + 1, skb))
+               return 1;
 
        route = ax25_get_route(dst, NULL);
        if (route) {
                digipeat = route->digipeat;
                dev = route->dev;
                ip_mode = route->ip_mode;
-       };
+       }
 
        if (dev == NULL)
                dev = skb->dev;
 
-        if ((ax25_dev = ax25_dev_ax25dev(dev)) == NULL) {
-                goto put;
+       if ((ax25_dev = ax25_dev_ax25dev(dev)) == NULL) {
+               goto put;
        }
 
        if (bp[16] == AX25_P_IP) {
@@ -172,11 +173,11 @@ int ax25_rebuild_header(struct sk_buff *skb)
                        src_c = *(ax25_address *)(bp + 8);
 
                        skb_pull(ourskb, AX25_HEADER_LEN - 1);  /* Keep PID */
-                       ourskb->nh.raw = ourskb->data;
+                       skb_reset_network_header(ourskb);
 
                        ax25=ax25_send_frame(
-                           ourskb, 
-                           ax25_dev->values[AX25_VALUES_PACLEN], 
+                           ourskb,
+                           ax25_dev->values[AX25_VALUES_PACLEN],
                            &src_c,
                            &dst_c, digipeat, dev);
                        if (ax25) {
@@ -186,13 +187,13 @@ int ax25_rebuild_header(struct sk_buff *skb)
                }
        }
 
-       bp[7]  &= ~AX25_CBIT;
-       bp[7]  &= ~AX25_EBIT;
-       bp[7]  |= AX25_SSSID_SPARE;
+       bp[7]  &= ~AX25_CBIT;
+       bp[7]  &= ~AX25_EBIT;
+       bp[7]  |= AX25_SSSID_SPARE;
 
-       bp[14] &= ~AX25_CBIT;
-       bp[14] |= AX25_EBIT;
-       bp[14] |= AX25_SSSID_SPARE;
+       bp[14] &= ~AX25_CBIT;
+       bp[14] |= AX25_EBIT;
+       bp[14] |= AX25_SSSID_SPARE;
 
        skb_pull(skb, AX25_KISS_HEADER_LEN);
 
@@ -211,12 +212,14 @@ put:
        if (route)
                ax25_put_route(route);
 
-       return 1;
+       return 1;
 }
 
 #else  /* INET */
 
-int ax25_hard_header(struct sk_buff *skb, struct net_device *dev, unsigned short type, void *daddr, void *saddr, unsigned len)
+int ax25_hard_header(struct sk_buff *skb, struct net_device *dev,
+                    unsigned short type, const void *daddr,
+                    const void *saddr, unsigned len)
 {
        return -AX25_HEADER_LEN;
 }
@@ -228,5 +231,12 @@ int ax25_rebuild_header(struct sk_buff *skb)
 
 #endif
 
+const struct header_ops ax25_header_ops = {
+       .create = ax25_hard_header,
+       .rebuild = ax25_rebuild_header,
+};
+
 EXPORT_SYMBOL(ax25_hard_header);
 EXPORT_SYMBOL(ax25_rebuild_header);
+EXPORT_SYMBOL(ax25_header_ops);
+