2 * Copyright 2007 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 * Compatibility file for Linux wireless for kernels 2.6.24.
11 #include <net/compat.h>
15 * We simply won't use it though, just declare it for our wrappers and
16 * for usage with tons of code that makes mention to it.
19 EXPORT_SYMBOL(init_net);
21 /* 2.6.22 and 2.6.23 have eth_header_cache_update defined as extern in include/linux/etherdevice.h
22 * and actually defined in net/ethernet/eth.c but 2.6.24 exports it. Lets export it here */
25 * eth_header_cache_update - update cache entry
26 * @hh: destination cache entry
27 * @dev: network device
28 * @haddr: new hardware address
30 * Called by Address Resolution module to notify changes in address.
32 void eth_header_cache_update(struct hh_cache *hh,
33 struct net_device *dev,
36 memcpy(((u8 *) hh->hh_data) + HH_DATA_OFF(sizeof(struct ethhdr)),
39 EXPORT_SYMBOL(eth_header_cache_update);
41 /* 2.6.22 and 2.6.23 have eth_header_cache defined as extern in include/linux/etherdevice.h
42 * and actually defined in net/ethernet/eth.c but 2.6.24 exports it. Lets export it here */
45 * eth_header_cache - fill cache entry from neighbour
46 * @neigh: source neighbour
47 * @hh: destination cache entry
48 * Create an Ethernet header template from the neighbour.
50 int eth_header_cache(struct neighbour *neigh, struct hh_cache *hh)
52 __be16 type = hh->hh_type;
54 const struct net_device *dev = neigh->dev;
56 eth = (struct ethhdr *)
57 (((u8 *) hh->hh_data) + (HH_DATA_OFF(sizeof(*eth))));
59 if (type == htons(ETH_P_802_3))
63 memcpy(eth->h_source, dev->dev_addr, ETH_ALEN);
64 memcpy(eth->h_dest, neigh->ha, ETH_ALEN);
65 hh->hh_len = ETH_HLEN;
68 EXPORT_SYMBOL(eth_header_cache);
70 /* 2.6.22 and 2.6.23 have eth_header() defined as extern in include/linux/etherdevice.h
71 * and actually defined in net/ethernet/eth.c but 2.6.24 exports it. Lets export it here */
74 * eth_header - create the Ethernet header
75 * @skb: buffer to alter
77 * @type: Ethernet type field
78 * @daddr: destination address (NULL leave destination address)
79 * @saddr: source address (NULL use device source address)
80 * @len: packet length (<= skb->len)
83 * Set the protocol type. For a packet of type ETH_P_802_3 we put the length
84 * in here instead. It is up to the 802.2 layer to carry protocol information.
86 int eth_header(struct sk_buff *skb, struct net_device *dev, unsigned short type,
87 void *daddr, void *saddr, unsigned len)
89 struct ethhdr *eth = (struct ethhdr *)skb_push(skb, ETH_HLEN);
91 if (type != ETH_P_802_3)
92 eth->h_proto = htons(type);
94 eth->h_proto = htons(len);
97 * Set the source hardware address.
101 saddr = dev->dev_addr;
102 memcpy(eth->h_source, saddr, dev->addr_len);
105 memcpy(eth->h_dest, daddr, dev->addr_len);
110 * Anyway, the loopback-device should never use this function...
113 if (dev->flags & (IFF_LOOPBACK | IFF_NOARP)) {
114 memset(eth->h_dest, 0, dev->addr_len);
121 EXPORT_SYMBOL(eth_header);
123 /* 2.6.22 and 2.6.23 have eth_rebuild_header defined as extern in include/linux/etherdevice.h
124 * and actually defined in net/ethernet/eth.c but 2.6.24 exports it. Lets export it here */
127 * eth_rebuild_header- rebuild the Ethernet MAC header.
128 * @skb: socket buffer to update
130 * This is called after an ARP or IPV6 ndisc it's resolution on this
131 * sk_buff. We now let protocol (ARP) fill in the other fields.
133 * This routine CANNOT use cached dst->neigh!
134 * Really, it is used only when dst->neigh is wrong.
136 int eth_rebuild_header(struct sk_buff *skb)
138 struct ethhdr *eth = (struct ethhdr *)skb->data;
139 struct net_device *dev = skb->dev;
141 switch (eth->h_proto) {
143 case __constant_htons(ETH_P_IP):
144 return arp_find(eth->h_dest, skb);
148 "%s: unable to resolve type %X addresses.\n",
149 dev->name, (int)eth->h_proto);
151 memcpy(eth->h_source, dev->dev_addr, ETH_ALEN);
157 EXPORT_SYMBOL(eth_rebuild_header);