Act only on stuff directed at us or broadcast

This commit is contained in:
Juhani Krekelä 2019-07-06 20:41:31 +03:00
parent 211473b48e
commit b75943d2e6
1 changed files with 11 additions and 1 deletions

View File

@ -71,13 +71,23 @@ void read_command(void) {
void process_frame(void) {
unsigned char frame[1518]; // Largest a 802.3 frame can be without FCS
unsigned char broadcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
errno = 0;
if (recv(packet_socket, frame, sizeof(frame), 0) == -1) {
errx(1, "recv");
}
fprintf(stderr, "."); // debg
if (memcmp(frame, own_mac, sizeof(own_mac)) == 0) {
// Targetted at us
fprintf(stderr, "."); // debg
} else if (memcmp(frame, broadcast_addr, sizeof(broadcast_addr)) == 0) {
// Broadcast
fprintf(stderr, "^"); // debg
} else {
// No concern
return;
}
}
void eventloop(void) {