- don't modify the destination MAC address if it's the broadcast address (tap and tuntap)
- definition of the broadcast MAC address moved to eth.h - removed eth_tap.cc description from eth_tuntap.cc - disabled eth_tap.cc packet logging
This commit is contained in:
parent
b6657b1322
commit
8d72800b09
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: eth.h,v 1.12 2003-04-26 14:48:45 cbothamy Exp $
|
||||
// $Id: eth.h,v 1.13 2004-09-18 12:35:13 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -31,6 +31,8 @@
|
||||
|
||||
typedef void (*eth_rx_handler_t)(void *arg, const void *buf, unsigned len);
|
||||
|
||||
static const Bit8u broadcast_macaddr[6] = {0xff,0xff,0xff,0xff,0xff,0xff};
|
||||
|
||||
int execute_script(char *name, char* arg1);
|
||||
|
||||
//
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: eth_arpback.cc,v 1.14 2004-09-05 10:30:18 vruppert Exp $
|
||||
// $Id: eth_arpback.cc,v 1.15 2004-09-18 12:35:13 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -49,7 +49,6 @@
|
||||
//static const Bit8u external_mac[]={0xB0, 0xC4, 0x20, 0x20, 0x00, 0x00, 0x00};
|
||||
//static const Bit8u internal_mac[]={0xB0, 0xC4, 0x20, 0x00, 0x00, 0x00, 0x00};
|
||||
//static const Bit8u external_ip[]={ 192, 168, 0, 2, 0x00 };
|
||||
//static const Bit8u broadcast_mac[]={0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00};
|
||||
//static const Bit8u ethtype_arp[]={0x08, 0x06, 0x00};
|
||||
|
||||
#define MAX_FRAME_SIZE 2048
|
||||
@ -138,7 +137,7 @@ bx_arpback_pktmover_c::sendpkt(void *buf, unsigned io_len)
|
||||
packetmaker.sendpacket(barney);
|
||||
}
|
||||
/*
|
||||
if(( (!memcmp(buf, external_mac, 6)) || (!memcmp(buf, broadcast_mac, 6)) )
|
||||
if(( (!memcmp(buf, external_mac, 6)) || (!memcmp(buf, broadcast_macaddr, 6)) )
|
||||
&& (!memcmp(((Bit8u *)buf)+12, ethtype_arp, 2)) ) {
|
||||
Bit32u tempcrc;
|
||||
memcpy(arpbuf,buf,io_len); //move to temporary buffer
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: eth_linux.cc,v 1.17 2004-09-05 10:30:18 vruppert Exp $
|
||||
// $Id: eth_linux.cc,v 1.18 2004-09-18 12:35:13 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -262,7 +262,6 @@ bx_linux_pktmover_c::rx_timer(void)
|
||||
Bit8u rxbuf[BX_PACKET_BUFSIZ];
|
||||
struct sockaddr_ll sll;
|
||||
socklen_t fromlen;
|
||||
//static unsigned char bcast_addr[6] = {0xff,0xff,0xff,0xff,0xff,0xff};
|
||||
|
||||
if (this->fd == -1)
|
||||
return;
|
||||
@ -281,7 +280,7 @@ bx_linux_pktmover_c::rx_timer(void)
|
||||
if (memcmp(sll.sll_addr, this->linux_macaddr, 6) == 0)
|
||||
return;
|
||||
// let through broadcast, multicast, and our mac address
|
||||
// if ((memcmp(rxbuf, bcast_addr, 6) == 0) || (memcmp(rxbuf, this->linux_macaddr, 6) == 0) || rxbuf[0] & 0x01) {
|
||||
// if ((memcmp(rxbuf, broadcast_macaddr, 6) == 0) || (memcmp(rxbuf, this->linux_macaddr, 6) == 0) || rxbuf[0] & 0x01) {
|
||||
BX_DEBUG(("eth_linux: got packet: %d bytes, dst=%x:%x:%x:%x:%x:%x, src=%x:%x:%x:%x:%x:%x\n", nbytes, rxbuf[0], rxbuf[1], rxbuf[2], rxbuf[3], rxbuf[4], rxbuf[5], rxbuf[6], rxbuf[7], rxbuf[8], rxbuf[9], rxbuf[10], rxbuf[11]));
|
||||
(*rxh)(rxarg, rxbuf, nbytes);
|
||||
// }
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: eth_packetmaker.cc,v 1.11 2004-09-05 10:30:18 vruppert Exp $
|
||||
// $Id: eth_packetmaker.cc,v 1.12 2004-09-18 12:35:13 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Define BX_PLUGGABLE in files that can be compiled into plugins. For
|
||||
@ -112,7 +112,7 @@ bx_bool
|
||||
eth_ETHmaker::ishandler(const eth_packet& outpacket) {
|
||||
if((outpacket.len>=60) &&
|
||||
( (!memcmp(outpacket.buf, external_mac, 6))
|
||||
|| (!memcmp(outpacket.buf, broadcast_mac, 6)) ) &&
|
||||
|| (!memcmp(outpacket.buf, broadcast_macaddr, 6)) ) &&
|
||||
( (!memcmp(outpacket.buf+12, ethtype_arp, 2)) ||
|
||||
(!memcmp(outpacket.buf+12, ethtype_ip, 2)) ) &&
|
||||
(outpacket.len<PACKET_BUF_SIZE)
|
||||
@ -152,7 +152,7 @@ eth_ARPmaker::ishandler(const eth_packet& outpacket) {
|
||||
(!memcmp(outpacket.buf+12, ethtype_arp, 2)) &&
|
||||
(outpacket.len<PACKET_BUF_SIZE) &&
|
||||
( (!memcmp(outpacket.buf, external_mac, 6))
|
||||
|| (!memcmp(outpacket.buf, broadcast_mac, 6)) ) &&
|
||||
|| (!memcmp(outpacket.buf, broadcast_macaddr, 6)) ) &&
|
||||
(!memcmp(outpacket.buf+38, external_ip, 4))
|
||||
) {
|
||||
return 1;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: eth_packetmaker.h,v 1.6 2002-10-25 11:44:39 bdenney Exp $
|
||||
// $Id: eth_packetmaker.h,v 1.7 2004-09-18 12:35:13 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
@ -14,7 +14,6 @@
|
||||
static const Bit8u internal_mac[]={0xB0, 0xC4, 0x20, 0x20, 0x00, 0x00, 0x00};
|
||||
static const Bit8u external_mac[]={0xB0, 0xC4, 0x20, 0x20, 0x00, 0x00, 0x00};
|
||||
static const Bit8u external_ip[]={ 192, 168, 0, 2, 0x00 };
|
||||
static const Bit8u broadcast_mac[]={0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00};
|
||||
static const Bit8u ethtype_arp[]={0x08, 0x06, 0x00};
|
||||
static const Bit8u ethtype_ip[]={0x08, 0x00, 0x00};
|
||||
static const Bit8u prot_udp=17;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: eth_tap.cc,v 1.20 2004-09-11 15:39:52 vruppert Exp $
|
||||
// $Id: eth_tap.cc,v 1.21 2004-09-18 12:35:13 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -114,7 +114,7 @@
|
||||
#include <errno.h>
|
||||
|
||||
#define TAP_VIRTUAL_HW_ADDR 0xDEADBEEF
|
||||
#define BX_ETH_TAP_LOGGING 1
|
||||
#define BX_ETH_TAP_LOGGING 0
|
||||
#define BX_PACKET_BUFSIZ 2048 // Enough for an ether frame
|
||||
|
||||
//
|
||||
@ -131,7 +131,9 @@ private:
|
||||
int rx_timer_index;
|
||||
static void rx_timer_handler(void *);
|
||||
void rx_timer ();
|
||||
#if BX_ETH_TAP_LOGGING
|
||||
FILE *txlog, *txlog_txt, *rxlog, *rxlog_txt;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@ -327,11 +329,13 @@ void bx_tap_pktmover_c::rx_timer ()
|
||||
nbytes-=2;
|
||||
#endif
|
||||
|
||||
#if defined(__linux__)
|
||||
// hack: TAP device likes to create an ethernet header which has
|
||||
// the same source and destination address FE:FD:00:00:00:00.
|
||||
// Change the dest address to FE:FD:00:00:00:01.
|
||||
#if defined(__linux__)
|
||||
rxbuf[5] = 1;
|
||||
if (memcmp(&rxbuf[0], broadcast_macaddr, 6)) {
|
||||
rxbuf[5] = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (nbytes>0)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: eth_tuntap.cc,v 1.15 2004-09-05 10:30:18 vruppert Exp $
|
||||
// $Id: eth_tuntap.cc,v 1.16 2004-09-18 12:35:13 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -25,61 +25,6 @@
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
// eth_tuntap.cc - TUN/TAP interface by Renzo Davoli <renzo@cs.unibo.it>
|
||||
//
|
||||
// WARNING: These instructions were written for ethertap, not TUN/TAP.
|
||||
//
|
||||
// Here's how to get this working. On the host machine:
|
||||
// $ su root
|
||||
// # /sbin/insmod ethertap
|
||||
// Using /lib/modules/2.2.14-5.0/net/ethertap.o
|
||||
// # mknod /dev/tap0 c 36 16 # if not already there
|
||||
// # /sbin/ifconfig tap0 10.0.0.1
|
||||
// # /sbin/route add -host 10.0.0.2 gw 10.0.0.1
|
||||
//
|
||||
// Now you have a tap0 device which you can on the ifconfig output. The
|
||||
// tap0 interface has the IP address of 10.0.0.1. The bochs machine will have
|
||||
// the IP address 10.0.0.2.
|
||||
//
|
||||
// Compile a bochs version from March 8, 2002 or later with --enable-ne2000.
|
||||
// Add this ne2k line to your .bochsrc to activate the tap device.
|
||||
// ne2k: ioaddr=0x280, irq=9, mac=fe:fd:00:00:00:01, ethmod=tap, ethdev=tap0
|
||||
// Don't change the mac or ethmod!
|
||||
//
|
||||
// Boot up DLX Linux in Bochs. Log in as root and then type the following
|
||||
// commands to set up networking:
|
||||
// # ifconfig eth0 10.0.0.2
|
||||
// # route add -net 10.0.0.0
|
||||
// # route add default gw 10.0.0.1
|
||||
// Now you should be able to ping from guest OS to your host machine, if
|
||||
// you give its IP number. I'm still having trouble with pings from the
|
||||
// host machine to the guest, so something is still not right. Symptoms: I
|
||||
// ping from the host to the guest's IP address 10.0.0.2. With tcpdump I can
|
||||
// see the ping going to Bochs, and then the ping reply coming from Bochs.
|
||||
// But the ping program itself does not see the responses....well every
|
||||
// once in a while it does, like 1 in 60 pings.
|
||||
//
|
||||
// host$ ping 10.0.0.2
|
||||
// PING 10.0.0.2 (10.0.0.2) from 10.0.0.1 : 56(84) bytes of data.
|
||||
//
|
||||
// Netstat output:
|
||||
// 20:29:59.018776 fe:fd:0:0:0:0 fe:fd:0:0:0:1 0800 98: 10.0.0.1 > 10.0.0.2: icmp: echo request
|
||||
// 4500 0054 2800 0000 4001 3ea7 0a00 0001
|
||||
// 0a00 0002 0800 09d3 a53e 0400 9765 893c
|
||||
// 3949 0000 0809 0a0b 0c0d 0e0f 1011 1213
|
||||
// 1415 1617 1819
|
||||
// 20:29:59.023017 fe:fd:0:0:0:1 fe:fd:0:0:0:0 0800 98: 10.0.0.2 > 10.0.0.1: icmp: echo reply
|
||||
// 4500 0054 004a 0000 4001 665d 0a00 0002
|
||||
// 0a00 0001 0000 11d3 a53e 0400 9765 893c
|
||||
// 3949 0000 0809 0a0b 0c0d 0e0f 1011 1213
|
||||
// 1415 1617 1819
|
||||
//
|
||||
// I suspect it may be related to the fact that ping 10.0.0.1 from the
|
||||
// host also doesn't work. Why wouldn't the host respond to its own IP
|
||||
// address on the tap0 device?
|
||||
//
|
||||
// Theoretically, if you set up packet forwarding (with masquerading) on the
|
||||
// host, you should be able to get Bochs talking to anyone on the internet.
|
||||
//
|
||||
|
||||
// Define BX_PLUGGABLE in files that can be compiled into plugins. For
|
||||
// platforms that require a special tag on exported symbols, BX_PLUGGABLE
|
||||
@ -141,7 +86,9 @@ private:
|
||||
int rx_timer_index;
|
||||
static void rx_timer_handler(void *);
|
||||
void rx_timer ();
|
||||
#if BX_ETH_TUNTAP_LOGGING
|
||||
FILE *txlog, *txlog_txt, *rxlog, *rxlog_txt;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@ -361,7 +308,9 @@ void bx_tuntap_pktmover_c::rx_timer ()
|
||||
// hack: TUN/TAP device likes to create an ethernet header which has
|
||||
// the same source and destination address FE:FD:00:00:00:00.
|
||||
// Change the dest address to FE:FD:00:00:00:01.
|
||||
rxbuf[5] = 1;
|
||||
if (memcmp(&rxbuf[0], broadcast_macaddr, 6)) {
|
||||
rxbuf[5] = 1;
|
||||
}
|
||||
|
||||
#ifdef __APPLE__ //FIXME:hack
|
||||
if (nbytes>14)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: eth_vnet.cc,v 1.6 2004-09-11 11:26:41 vruppert Exp $
|
||||
// $Id: eth_vnet.cc,v 1.7 2004-09-18 12:35:13 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// virtual Ethernet locator
|
||||
@ -30,7 +30,6 @@
|
||||
// handler to send/receive packets
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static const Bit8u broadcast_macaddr[6] = {0xff,0xff,0xff,0xff,0xff,0xff};
|
||||
static const Bit8u default_host_ipv4addr[4] = {192,168,10,1};
|
||||
static const Bit8u subnetmask_ipv4addr[4] = {0xff,0xff,0xff,0x00};
|
||||
static const Bit8u default_guest_ipv4addr[4] = {192,168,10,2};
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: eth_win32.cc,v 1.20 2004-09-05 10:30:18 vruppert Exp $
|
||||
// $Id: eth_win32.cc,v 1.21 2004-09-18 12:35:13 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -332,7 +332,6 @@ void bx_win32_pktmover_c::rx_timer_handler (void *this_ptr)
|
||||
unsigned int iOffset = 0;
|
||||
struct bpf_hdr *hdr;
|
||||
int pktlen;
|
||||
static unsigned char bcast_addr[6] = {0xff,0xff,0xff,0xff,0xff,0xff};
|
||||
PacketInitPacket(pkRecv, (char *)buffer, 256000);
|
||||
//fprintf(stderr, "[ETH-WIN32] poll packet\n");
|
||||
if (WaitForSingleObject(lpAdapter->ReadEvent,0) == WAIT_OBJECT_0 || IsNT) {
|
||||
@ -345,7 +344,7 @@ void bx_win32_pktmover_c::rx_timer_handler (void *this_ptr)
|
||||
pPacket = (unsigned char *)(pBuf + iOffset + hdr->bh_hdrlen);
|
||||
if (memcmp(pPacket + 6, cMacAddr, 6) != 0) // src field != ours
|
||||
{
|
||||
if(memcmp(pPacket, cMacAddr, 6) == 0 || memcmp(pPacket, bcast_addr, 6) == 0)
|
||||
if(memcmp(pPacket, cMacAddr, 6) == 0 || memcmp(pPacket, broadcast_macaddr, 6) == 0)
|
||||
{
|
||||
//fprintf(stderr, "[ETH-WIN32] RX packet: size=%i, dst=%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x, src=%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n", hdr->bh_caplen, pPacket[0], pPacket[1], pPacket[2], pPacket[3], pPacket[4], pPacket[5], pPacket[6], pPacket[7], pPacket[8], pPacket[9], pPacket[10], pPacket[11]);
|
||||
pktlen = hdr->bh_caplen;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: ne2k.cc,v 1.68 2004-09-10 11:54:46 vruppert Exp $
|
||||
// $Id: ne2k.cc,v 1.69 2004-09-18 12:35:13 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2002 MandrakeSoft S.A.
|
||||
@ -1184,7 +1184,6 @@ bx_ne2k_c::rx_frame(const void *buf, unsigned io_len)
|
||||
unsigned char pkthdr[4];
|
||||
unsigned char *pktbuf = (unsigned char *) buf;
|
||||
unsigned char *startptr;
|
||||
static unsigned char bcast_addr[6] = {0xff,0xff,0xff,0xff,0xff,0xff};
|
||||
|
||||
BX_DEBUG(("rx_frame with length %d", io_len));
|
||||
|
||||
@ -1227,7 +1226,7 @@ bx_ne2k_c::rx_frame(const void *buf, unsigned io_len)
|
||||
|
||||
// Do address filtering if not in promiscuous mode
|
||||
if (! BX_NE2K_THIS s.RCR.promisc) {
|
||||
if (!memcmp(buf, bcast_addr, 6)) {
|
||||
if (!memcmp(buf, broadcast_macaddr, 6)) {
|
||||
if (!BX_NE2K_THIS s.RCR.broadcast) {
|
||||
return;
|
||||
}
|
||||
@ -1305,7 +1304,7 @@ bx_ne2k_c::init(void)
|
||||
{
|
||||
char devname[16];
|
||||
|
||||
BX_DEBUG(("Init $Id: ne2k.cc,v 1.68 2004-09-10 11:54:46 vruppert Exp $"));
|
||||
BX_DEBUG(("Init $Id: ne2k.cc,v 1.69 2004-09-18 12:35:13 vruppert Exp $"));
|
||||
|
||||
// Read in values from config file
|
||||
memcpy(BX_NE2K_THIS s.physaddr, bx_options.ne2k.Omacaddr->getptr (), 6);
|
||||
|
Loading…
x
Reference in New Issue
Block a user