From 5aa782acc063597252b17d70b91e7005a9cee16c Mon Sep 17 00:00:00 2001 From: Dan Sumorok Date: Mon, 27 May 2013 13:55:38 -0400 Subject: [PATCH] Changed ethernet address when using tap interface. --- BasiliskII/src/MacOSX/etherslavetool.c | 4 ++-- BasiliskII/src/Unix/ether_unix.cpp | 21 ++++++++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/BasiliskII/src/MacOSX/etherslavetool.c b/BasiliskII/src/MacOSX/etherslavetool.c index e60c6ce9..baa5b46f 100644 --- a/BasiliskII/src/MacOSX/etherslavetool.c +++ b/BasiliskII/src/MacOSX/etherslavetool.c @@ -126,7 +126,7 @@ static int main_loop(int sd, int use_bpf) return -1; } } else { - blen = 2048; + blen = 4096; } incoming = malloc(blen); @@ -239,7 +239,7 @@ static int main_loop(int sd, int use_bpf) if (!use_bpf && FD_ISSET(sd, &readSet)) { in_len = (unsigned short *)incoming; - pkt_len = read(sd, incoming+2, blen-2); + pkt_len = read(sd, in_len + 1, blen-2); if (pkt_len < 14) { fret = -8; break; diff --git a/BasiliskII/src/Unix/ether_unix.cpp b/BasiliskII/src/Unix/ether_unix.cpp index 947ea080..8e005308 100644 --- a/BasiliskII/src/Unix/ether_unix.cpp +++ b/BasiliskII/src/Unix/ether_unix.cpp @@ -1188,11 +1188,22 @@ static bool open_ether_slave(const std::string &if_name) dev_name.erase(pos); } - if (get_mac_address(dev_name.c_str(), ether_addr) != 0) { - snprintf(str, sizeof(str), "Unable to find interface %s.", - dev_name.c_str()); - WarningAlert(str); - return false; + if(strncmp(if_name.c_str(), "tap", 3) != 0) { + if (get_mac_address(dev_name.c_str(), ether_addr) != 0) { + snprintf(str, sizeof(str), "Unable to find interface %s.", + dev_name.c_str()); + WarningAlert(str); + return false; + } + } else { + /* There is something special about this address. */ + pid_t p = getpid(); + ether_addr[0] = 0xfe; + ether_addr[1] = 0xfd; + ether_addr[2] = p >> 24; + ether_addr[3] = p >> 16; + ether_addr[4] = p >> 8; + ether_addr[5] = p; } fd = dup(fileno(fp));