Pad the frame to the required length.
If we don't do that, the NIC will generate padding that contains non-zero bytes. EtherMess excepts all-zero padding, so this will break.
This commit is contained in:
parent
2410a28947
commit
9513911377
|
@ -256,10 +256,21 @@ void drop_privileges(void) {
|
|||
}
|
||||
|
||||
void send_frame(const unsigned char *frame, size_t frame_length) {
|
||||
// 64B is the minimum frame side
|
||||
// We check for 60B, since kernel handles the FCS (4B)
|
||||
if (frame_length < 60) {
|
||||
unsigned char padded_frame[60];
|
||||
memset(padded_frame, 0, sizeof(padded_frame));
|
||||
memcpy(padded_frame, frame, frame_length);
|
||||
if (write(packet_socket, padded_frame, sizeof(padded_frame)) == -1) {
|
||||
err(1, "write");
|
||||
}
|
||||
} else {
|
||||
if (write(packet_socket, frame, frame_length) == -1) {
|
||||
err(1, "write");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void write_headers(unsigned char frame[14], const unsigned char destination_mac[6], unsigned char packet_type) {
|
||||
// Destination MAC
|
||||
|
|
Loading…
Reference in New Issue