From: Guus Sliepen Date: Wed, 11 Jun 2003 19:28:38 +0000 (+0000) Subject: Remove mymac stuff from device.c. X-Git-Tag: import-tinc-1.1~785^2~184 X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=12de5a8eedd985f4732e88de6185f77a8244612c;p=meshlink Remove mymac stuff from device.c. --- diff --git a/src/cygwin/device.c b/src/cygwin/device.c index 3bfc2ab1..9b06d4d1 100644 --- a/src/cygwin/device.c +++ b/src/cygwin/device.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: device.c,v 1.1.2.4 2002/09/10 21:29:42 guus Exp $ + $Id: device.c,v 1.1.2.5 2003/06/11 19:28:36 guus Exp $ */ #include "config.h" @@ -47,8 +47,6 @@ char *device_info; int device_total_in = 0; int device_total_out = 0; -extern subnet_t mymac; - int setup_device(void) { struct ifreq ifr; @@ -66,15 +64,6 @@ int setup_device(void) return -1; } - /* Set default MAC address for ethertap devices */ - mymac.type = SUBNET_MAC; - mymac.net.mac.address.x[0] = 0xfe; - mymac.net.mac.address.x[1] = 0xfd; - mymac.net.mac.address.x[2] = 0x00; - mymac.net.mac.address.x[3] = 0x00; - mymac.net.mac.address.x[4] = 0x00; - mymac.net.mac.address.x[5] = 0x00; - device_info = _("Stub device for Cygwin environment"); syslog(LOG_INFO, _("%s is a %s"), device, device_info); diff --git a/src/darwin/device.c b/src/darwin/device.c index 4b597ad2..c08153fe 100644 --- a/src/darwin/device.c +++ b/src/darwin/device.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: device.c,v 1.1.2.5 2002/09/10 21:29:42 guus Exp $ + $Id: device.c,v 1.1.2.6 2003/06/11 19:28:36 guus Exp $ */ #include "config.h" @@ -51,8 +51,6 @@ char *device_info; int device_total_in = 0; int device_total_out = 0; -extern subnet_t mymac; - /* open the local ethertap device */ @@ -71,15 +69,6 @@ int setup_device(void) return -1; } - /* Set default MAC address for ethertap devices */ - mymac.type = SUBNET_MAC; - mymac.net.mac.address.x[0] = 0xfe; - mymac.net.mac.address.x[1] = 0xfd; - mymac.net.mac.address.x[2] = 0x00; - mymac.net.mac.address.x[3] = 0x00; - mymac.net.mac.address.x[4] = 0x00; - mymac.net.mac.address.x[5] = 0x00; - device_info = _("MacOS/X tun device"); syslog(LOG_INFO, _("%s is a %s"), device, device_info); @@ -110,8 +99,6 @@ int read_packet(vpn_packet_t *packet) return -1; } - memcpy(packet->data, mymac.net.mac.address.x, 6); - memcpy(packet->data + 6, mymac.net.mac.address.x, 6); packet->data[12] = 0x08; packet->data[13] = 0x00; diff --git a/src/freebsd/device.c b/src/freebsd/device.c index 5e0fff25..86ed951b 100644 --- a/src/freebsd/device.c +++ b/src/freebsd/device.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: device.c,v 1.1.2.8 2002/09/10 21:29:42 guus Exp $ + $Id: device.c,v 1.1.2.9 2003/06/11 19:28:37 guus Exp $ */ #include "config.h" @@ -51,8 +51,6 @@ char *device_info; int device_total_in = 0; int device_total_out = 0; -extern subnet_t mymac; - /* open the local ethertap device */ @@ -71,15 +69,6 @@ int setup_device(void) return -1; } - /* Set default MAC address for ethertap devices */ - mymac.type = SUBNET_MAC; - mymac.net.mac.address.x[0] = 0xfe; - mymac.net.mac.address.x[1] = 0xfd; - mymac.net.mac.address.x[2] = 0x00; - mymac.net.mac.address.x[3] = 0x00; - mymac.net.mac.address.x[4] = 0x00; - mymac.net.mac.address.x[5] = 0x00; - device_info = _("FreeBSD tap device"); syslog(LOG_INFO, _("%s is a %s"), device, device_info); diff --git a/src/linux/device.c b/src/linux/device.c index c5c8bcd4..ea663846 100644 --- a/src/linux/device.c +++ b/src/linux/device.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: device.c,v 1.1.2.14 2003/06/11 19:09:52 guus Exp $ + $Id: device.c,v 1.1.2.15 2003/06/11 19:28:37 guus Exp $ */ #include "config.h" @@ -68,8 +68,6 @@ char *device_info; int device_total_in = 0; int device_total_out = 0; -extern subnet_t mymac; - /* open the local ethertap device */ @@ -95,15 +93,6 @@ int setup_device(void) return -1; } - /* Set default MAC address for ethertap devices */ - mymac.type = SUBNET_MAC; - mymac.net.mac.address.x[0] = 0xfe; - mymac.net.mac.address.x[1] = 0xfd; - mymac.net.mac.address.x[2] = 0x00; - mymac.net.mac.address.x[3] = 0x00; - mymac.net.mac.address.x[4] = 0x00; - mymac.net.mac.address.x[5] = 0x00; - #ifdef HAVE_TUNTAP /* Ok now check if this is an old ethertap or a new tun/tap thingie */ @@ -131,6 +120,8 @@ int setup_device(void) } else #endif { + if(routing_mode == RMODE_ROUTER) + overwrite_mac = 1; device_info = _("Linux ethertap device"); device_type = DEVICE_TYPE_ETHERTAP; interface = rindex(device, '/') ? rindex(device, '/') + 1 : device; diff --git a/src/netbsd/device.c b/src/netbsd/device.c index 98b607a3..b9400358 100644 --- a/src/netbsd/device.c +++ b/src/netbsd/device.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: device.c,v 1.1.2.7 2002/09/10 21:29:42 guus Exp $ + $Id: device.c,v 1.1.2.8 2003/06/11 19:28:37 guus Exp $ */ #include "config.h" @@ -56,8 +56,6 @@ char *device_info; int device_total_in = 0; int device_total_out = 0; -extern subnet_t mymac; - /* open the local ethertap device */ @@ -75,15 +73,6 @@ int setup_device(void) return -1; } - /* Set default MAC address for ethertap devices */ - mymac.type = SUBNET_MAC; - mymac.net.mac.address.x[0] = 0xfe; - mymac.net.mac.address.x[1] = 0xfd; - mymac.net.mac.address.x[2] = 0x00; - mymac.net.mac.address.x[3] = 0x00; - mymac.net.mac.address.x[4] = 0x00; - mymac.net.mac.address.x[5] = 0x00; - device_info = _("NetBSD tun device"); syslog(LOG_INFO, _("%s is a %s"), device, device_info); @@ -110,8 +99,6 @@ int read_packet(vpn_packet_t *packet) return -1; } - memcpy(packet->data, mymac.net.mac.address.x, 6); - memcpy(packet->data + 6, mymac.net.mac.address.x, 6); packet->data[12] = 0x08; packet->data[13] = 0x00; diff --git a/src/openbsd/device.c b/src/openbsd/device.c index 3e032b6c..b1a30d22 100644 --- a/src/openbsd/device.c +++ b/src/openbsd/device.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: device.c,v 1.1.2.12 2002/09/10 21:29:42 guus Exp $ + $Id: device.c,v 1.1.2.13 2003/06/11 19:28:37 guus Exp $ */ #include "config.h" @@ -56,8 +56,6 @@ char *device_info; int device_total_in = 0; int device_total_out = 0; -extern subnet_t mymac; - /* open the local ethertap device */ @@ -75,15 +73,6 @@ int setup_device(void) return -1; } - /* Set default MAC address for ethertap devices */ - mymac.type = SUBNET_MAC; - mymac.net.mac.address.x[0] = 0xfe; - mymac.net.mac.address.x[1] = 0xfd; - mymac.net.mac.address.x[2] = 0x00; - mymac.net.mac.address.x[3] = 0x00; - mymac.net.mac.address.x[4] = 0x00; - mymac.net.mac.address.x[5] = 0x00; - device_info = _("OpenBSD tun device"); syslog(LOG_INFO, _("%s is a %s"), device, device_info); @@ -112,9 +101,6 @@ int read_packet(vpn_packet_t *packet) return -1; } - memcpy(packet->data, mymac.net.mac.address.x, 6); - memcpy(packet->data + 6, mymac.net.mac.address.x, 6); - switch (ntohl(type)) { case AF_INET: packet->data[12] = 0x8; diff --git a/src/raw_socket/device.c b/src/raw_socket/device.c index b75f824d..1b9d8949 100644 --- a/src/raw_socket/device.c +++ b/src/raw_socket/device.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: device.c,v 1.1.2.4 2002/09/10 21:29:42 guus Exp $ + $Id: device.c,v 1.1.2.5 2003/06/11 19:28:38 guus Exp $ */ #include "config.h" @@ -53,8 +53,6 @@ char *device_info; int device_total_in = 0; int device_total_out = 0; -extern subnet_t mymac; - /* open the local ethertap device */ @@ -99,15 +97,6 @@ int setup_device(void) return -1; } - /* Set default MAC address for ethertap devices */ - mymac.type = SUBNET_MAC; - mymac.net.mac.address.x[0] = 0xfe; - mymac.net.mac.address.x[1] = 0xfd; - mymac.net.mac.address.x[2] = 0x00; - mymac.net.mac.address.x[3] = 0x00; - mymac.net.mac.address.x[4] = 0x00; - mymac.net.mac.address.x[5] = 0x00; - syslog(LOG_INFO, _("%s is a %s"), device, device_info); return 0; diff --git a/src/route.c b/src/route.c index 06dffc97..571b1ba2 100644 --- a/src/route.c +++ b/src/route.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: route.c,v 1.1.2.49 2003/03/29 22:11:22 guus Exp $ + $Id: route.c,v 1.1.2.50 2003/06/11 19:28:35 guus Exp $ */ #include "config.h" @@ -67,7 +67,8 @@ int routing_mode = RMODE_ROUTER; int priorityinheritance = 0; int macexpire = 600; -subnet_t mymac; +int overwrite_mac = 0; +mac_t mymac = {0xFE, 0xFD, 0, 0, 0, 0}; /* RFC 1071 */ @@ -397,7 +398,8 @@ void route_neighborsol(vpn_packet_t *packet) /* First, snatch the source address from the neighbor solicitation packet */ - memcpy(mymac.net.mac.address.x, packet->data + 6, 6); + if(overwrite_mac) + memcpy(mymac.x, packet->data + 6, 6); /* Check if this is a valid neighbor solicitation request */ @@ -499,7 +501,8 @@ void route_arp(vpn_packet_t *packet) /* First, snatch the source address from the ARP packet */ - memcpy(mymac.net.mac.address.x, packet->data + 6, 6); + if(overwrite_mac) + memcpy(mymac.x, packet->data + 6, 6); /* This routine generates replies to ARP requests. You don't need to set NOARP flag on the interface anymore (which is broken on FreeBSD). @@ -628,7 +631,8 @@ void route_incoming(node_t *source, vpn_packet_t *packet) if(n) { if(n == myself) { - memcpy(packet->data, mymac.net.mac.address.x, 6); + if(overwrite_mac) + memcpy(packet->data, mymac.x, 6); write_packet(packet); } else send_packet(n, packet); diff --git a/src/route.h b/src/route.h index 1752d470..0e23486f 100644 --- a/src/route.h +++ b/src/route.h @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: route.h,v 1.1.2.9 2002/09/09 21:25:07 guus Exp $ + $Id: route.h,v 1.1.2.10 2003/06/11 19:28:35 guus Exp $ */ #ifndef __TINC_ROUTE_H__ @@ -30,6 +30,7 @@ enum { }; extern int routing_mode; +extern int overwrite_mac; extern int priorityinheritance; extern int macexpire; diff --git a/src/solaris/device.c b/src/solaris/device.c index a9ea6eb9..3054a98f 100644 --- a/src/solaris/device.c +++ b/src/solaris/device.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: device.c,v 1.1.2.11 2002/09/10 21:29:42 guus Exp $ + $Id: device.c,v 1.1.2.12 2003/06/11 19:28:38 guus Exp $ */ @@ -57,8 +57,6 @@ char *device_info = NULL; int device_total_in = 0; int device_total_out = 0; -subnet_t mymac; - int setup_device(void) { int ip_fd = -1, if_fd = -1; @@ -120,16 +118,6 @@ int setup_device(void) device_info = _("Solaris tun device"); - /* Set default MAC address for ethertap devices */ - - mymac.type = SUBNET_MAC; - mymac.net.mac.address.x[0] = 0xfe; - mymac.net.mac.address.x[1] = 0xfd; - mymac.net.mac.address.x[2] = 0x00; - mymac.net.mac.address.x[3] = 0x00; - mymac.net.mac.address.x[4] = 0x00; - mymac.net.mac.address.x[5] = 0x00; - syslog(LOG_INFO, _("%s is a %s"), device, device_info); return 0; @@ -154,8 +142,6 @@ int read_packet(vpn_packet_t *packet) return -1; } - memcpy(packet->data, mymac.net.mac.address.x, 6); - memcpy(packet->data + 6, mymac.net.mac.address.x, 6); packet->data[12] = 0x08; packet->data[13] = 0x00;