#
#   Libnet FreeBSD source etheraddr patch
#   (c) 2000 Matt Bing <matt@csis.gvsu.edu>
#   (c) 1999 Nicholas Brawn <nick@feralmonkey.org>
#   (c) 1998 - 2001  Mike D. Schiffman <mike@infonexus.com>
#
# Specify Source Hardware Address Patch (FreeBSD 4.0)
#
# This patch enables you to specify a source ethernet address other than your
# own when creating custom ethernet packets.
#
# To use, copy the patch into /sys/net. Create a backup of if_ethersubr.c,
# then: patch < diff.if_ethersubr.c
#
# Recompile your kernel and reboot. You will now have a new sysctl MIB,
# net.link.ether.inet.specify_src_hwaddr. To use, you must set it to > 0:

Index: if_ethersubr.c
===================================================================
RCS file: /home/ncvs/src/sys/net/if_ethersubr.c,v
retrieving revision 1.70.2.1
diff -c -r1.70.2.1 if_ethersubr.c
*** if_ethersubr.c	2000/05/01 01:04:41	1.70.2.1
--- if_ethersubr.c	2000/05/18 21:17:45
***************
*** 95,100 ****
--- 95,105 ----
  extern u_char	aarp_org_code[3];
  #endif /* NETATALK */
  
+ static int specify_src_hwaddr; /* arbitrary ether src address */
+ SYSCTL_DECL(_net_link_ether_inet);
+ SYSCTL_INT(_net_link_ether_inet, OID_AUTO, specify_src_hwaddr, CTLFLAG_RW,
+        &specify_src_hwaddr, 0, "");
+ 
  #ifdef BRIDGE
  #include <net/bridge.h>
  #endif
***************
*** 318,323 ****
--- 323,330 ----
  		loop_copy = -1; /* if this is for us, don't do it */
  		eh = (struct ether_header *)dst->sa_data;
   		(void)memcpy(edst, eh->ether_dhost, sizeof (edst));
+ 		if(specify_src_hwaddr)
+ 			(void)memcpy(esrc, eh->ether_shost, sizeof (esrc));
  		type = eh->ether_type;
  		break;
  
***************
*** 338,344 ****
  	(void)memcpy(&eh->ether_type, &type,
  		sizeof(eh->ether_type));
   	(void)memcpy(eh->ether_dhost, edst, sizeof (edst));
! 	if (hdrcmplt)
  		(void)memcpy(eh->ether_shost, esrc,
  			sizeof(eh->ether_shost));
  	else
--- 345,351 ----
  	(void)memcpy(&eh->ether_type, &type,
  		sizeof(eh->ether_type));
   	(void)memcpy(eh->ether_dhost, edst, sizeof (edst));
! 	if (hdrcmplt || specify_src_hwaddr)
  		(void)memcpy(eh->ether_shost, esrc,
  			sizeof(eh->ether_shost));
  	else
