Changed ethernet address when using tap interface.

This commit is contained in:
Dan Sumorok 2013-05-27 13:55:38 -04:00
parent f994087291
commit 5aa782acc0
2 changed files with 18 additions and 7 deletions

View File

@ -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;

View File

@ -1188,12 +1188,23 @@ static bool open_ether_slave(const std::string &if_name)
dev_name.erase(pos);
}
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));
fclose(fp);