Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / net / 802 / hippi.c
index 7ae2797..6d7fed3 100644 (file)
@@ -7,7 +7,7 @@
  *
  * Version:    @(#)hippi.c     1.0.0   05/29/97
  *
- * Authors:    Ross Biro, <bir7@leland.Stanford.Edu>
+ * Authors:    Ross Biro
  *             Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
  *             Mark Evans, <evansmp@uhura.aston.ac.uk>
  *             Florian  La Roche, <rzsfl@rz.uni-sb.de>
 #include <asm/checksum.h>
 #include <asm/system.h>
 
-/*
- * hippi_net_init()
- *
- * Do nothing, this is just to pursuade the stupid linker to behave.
- */
-
-void hippi_net_init(void)
-{
-       return;
-}
-
 /*
  * Create the HIPPI MAC header for an arbitrary protocol layer 
  *
@@ -57,11 +46,12 @@ void hippi_net_init(void)
  * daddr=NULL  means leave destination address (eg unresolved arp)
  */
 
-int hippi_header(struct sk_buff *skb, struct net_device *dev,
-                unsigned short type, void *daddr, void *saddr,
-                unsigned len)
+static int hippi_header(struct sk_buff *skb, struct net_device *dev,
+                       unsigned short type, void *daddr, void *saddr,
+                       unsigned len)
 {
        struct hippi_hdr *hip = (struct hippi_hdr *)skb_push(skb, HIPPI_HLEN);
+       struct hippi_cb *hcb = (struct hippi_cb *) skb->cb;
 
        if (!len){
                len = skb->len - HIPPI_HLEN;
@@ -95,9 +85,10 @@ int hippi_header(struct sk_buff *skb, struct net_device *dev,
        if (daddr)
        {
                memcpy(hip->le.dest_switch_addr, daddr + 3, 3);
-               memcpy(&skb->private.ifield, daddr + 2, 4);
+               memcpy(&hcb->ifield, daddr + 2, 4);
                return HIPPI_HLEN;
        }
+       hcb->ifield = 0;
        return -((int)HIPPI_HLEN);
 }
 
@@ -107,7 +98,7 @@ int hippi_header(struct sk_buff *skb, struct net_device *dev,
  * completed on this sk_buff. We now let ARP fill in the other fields.
  */
 
-int hippi_rebuild_header(struct sk_buff *skb)
+static int hippi_rebuild_header(struct sk_buff *skb)
 {
        struct hippi_hdr *hip = (struct hippi_hdr *)skb->data;
 
@@ -133,7 +124,7 @@ int hippi_rebuild_header(struct sk_buff *skb)
  *     Determine the packet's protocol ID.
  */
  
-unsigned short hippi_type_trans(struct sk_buff *skb, struct net_device *dev)
+__be16 hippi_type_trans(struct sk_buff *skb, struct net_device *dev)
 {
        struct hippi_hdr *hip;
        
@@ -154,3 +145,92 @@ unsigned short hippi_type_trans(struct sk_buff *skb, struct net_device *dev)
 }
 
 EXPORT_SYMBOL(hippi_type_trans);
+
+static int hippi_change_mtu(struct net_device *dev, int new_mtu)
+{
+       /*
+        * HIPPI's got these nice large MTUs.
+        */
+       if ((new_mtu < 68) || (new_mtu > 65280))
+               return -EINVAL;
+       dev->mtu = new_mtu;
+       return(0);
+}
+
+/*
+ * For HIPPI we will actually use the lower 4 bytes of the hardware
+ * address as the I-FIELD rather than the actual hardware address.
+ */
+static int hippi_mac_addr(struct net_device *dev, void *p)
+{
+       struct sockaddr *addr = p;
+       if (netif_running(dev))
+               return -EBUSY;
+       memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
+       return 0;
+}
+
+static int hippi_neigh_setup_dev(struct net_device *dev, struct neigh_parms *p)
+{
+       /* Never send broadcast/multicast ARP messages */
+       p->mcast_probes = 0;
+       /* In IPv6 unicast probes are valid even on NBMA,
+       * because they are encapsulated in normal IPv6 protocol.
+       * Should be a generic flag. 
+       */
+       if (p->tbl->family != AF_INET6)
+               p->ucast_probes = 0;
+       return 0;
+}
+
+static void hippi_setup(struct net_device *dev)
+{
+       dev->set_multicast_list         = NULL;
+       dev->change_mtu                 = hippi_change_mtu;
+       dev->hard_header                = hippi_header;
+       dev->rebuild_header             = hippi_rebuild_header;
+       dev->set_mac_address            = hippi_mac_addr;
+       dev->hard_header_parse          = NULL;
+       dev->hard_header_cache          = NULL;
+       dev->header_cache_update        = NULL;
+       dev->neigh_setup                = hippi_neigh_setup_dev; 
+
+       /*
+        * We don't support HIPPI `ARP' for the time being, and probably
+        * never will unless someone else implements it. However we
+        * still need a fake ARPHRD to make ifconfig and friends play ball.
+        */
+       dev->type               = ARPHRD_HIPPI;
+       dev->hard_header_len    = HIPPI_HLEN;
+       dev->mtu                = 65280;
+       dev->addr_len           = HIPPI_ALEN;
+       dev->tx_queue_len       = 25 /* 5 */;
+       memset(dev->broadcast, 0xFF, HIPPI_ALEN);
+
+
+       /*
+        * HIPPI doesn't support broadcast+multicast and we only use
+        * static ARP tables. ARP is disabled by hippi_neigh_setup_dev. 
+        */
+       dev->flags = 0; 
+}
+
+/**
+ * alloc_hippi_dev - Register HIPPI device
+ * @sizeof_priv: Size of additional driver-private structure to be allocated
+ *     for this HIPPI device
+ *
+ * Fill in the fields of the device structure with HIPPI-generic values.
+ *
+ * Constructs a new net device, complete with a private data area of
+ * size @sizeof_priv.  A 32-byte (not bit) alignment is enforced for
+ * this private data area.
+ */
+
+struct net_device *alloc_hippi_dev(int sizeof_priv)
+{
+       return alloc_netdev(sizeof_priv, "hip%d", hippi_setup);
+}
+
+EXPORT_SYMBOL(alloc_hippi_dev);