mirror of
https://github.com/kanjitalk755/macemu.git
synced 2024-11-26 10:49:21 +00:00
Changed ethernet address when using tap interface.
This commit is contained in:
parent
f994087291
commit
5aa782acc0
@ -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;
|
||||
|
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user