patch-1.3.7 linux/net/ethernet/eth.c

Next file: linux/net/ipv4/af_inet.c
Previous file: linux/net/core/sock.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.6/linux/net/ethernet/eth.c linux/net/ethernet/eth.c
@@ -24,7 +24,8 @@
  *				  and changes for new arp and skbuff.
  *		Alan Cox	: Redid header building to reflect new format.
  *		Alan Cox	: ARP only when compiled with CONFIG_INET
- *		Greg Page	: 802.2 and SNAP stuff
+ *		Greg Page	: 802.2 and SNAP stuff.
+ *		Alan Cox	: MAC layer pointers/new format.
  *
  *		This program is free software; you can redistribute it and/or
  *		modify it under the terms of the GNU General Public License
@@ -48,6 +49,7 @@
 #include <linux/config.h>
 #include <net/arp.h>
 #include <net/sock.h>
+#include <asm/checksum.h>
 
 void eth_setup(char *str, int *ints)
 {
@@ -166,9 +168,13 @@
  
 unsigned short eth_type_trans(struct sk_buff *skb, struct device *dev)
 {
-	struct ethhdr *eth = (struct ethhdr *) skb->data;
+	struct ethhdr *eth;
 	unsigned char *rawp;
 	
+	skb->mac.raw=skb->data;
+	skb_pull(skb,14);	
+	eth= skb->mac.ethernet;
+	
 	if(*eth->h_dest&1)
 	{
 		if(memcmp(eth->h_dest,dev->broadcast, ETH_ALEN)==0)
@@ -186,11 +192,20 @@
 	if (ntohs(eth->h_proto) >= 1536)
 		return eth->h_proto;
 		
-	rawp = (unsigned char *)(eth + 1);
+	rawp = skb->data;
 	
+	/*
+	 *	This is a magic hack to spot IPX packets. Older Novell breaks
+	 *	the protocol design and runs IPX over 802.3 without an 802.2 LLC
+	 *	layer. We look for FFFF which isnt a used 802.2 SSAP/DSAP. This
+	 *	won't work for fault tolerant netware but does for the rest.
+	 */
 	if (*(unsigned short *)rawp == 0xFFFF)
 		return htons(ETH_P_802_3);
 		
+	/*
+	 *	Real 802.2 LLC
+	 */
 	return htons(ETH_P_802_2);
 }
 
@@ -214,3 +229,20 @@
 	}
 }
 
+/*
+ *	Copy from an ethernet device memory space to an sk_buff while checksumming if IP
+ */
+ 
+void eth_copy_and_sum(struct sk_buff *dest,unsigned char *src, int length, int base)
+{
+	struct ethhdr *eth=(struct ethhdr *)dest->data;
+	memcpy(dest->data,src,34);	/* ethernet is always >= 60 */
+	length-=34;
+	if(eth->h_proto!=htons(ETH_P_IP))
+	{
+		memcpy(dest->data+34,src+34,length);
+		return;
+	}
+	dest->csum=csum_partial_copy(src+34,dest->data+34,length,base);
+	dest->ip_summed=1;
+}

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this