Porównaj commity

...

2 Commity

Autor SHA1 Wiadomość Data
Yash Katkar 75bfa7e2e4
Merge f73194fbbb into 5a40bb8746 2024-04-06 18:50:05 +01:00
Yash Katkar f73194fbbb feat: add the padding if the packet length is odd while updating udp checksum 2024-03-29 21:05:16 +00:00
1 zmienionych plików z 4 dodań i 0 usunięć

Wyświetl plik

@ -118,6 +118,10 @@ static void update_udp_checksum(uint16_t *udp_header, uint16_t* ip_header)
for (int i = 0; i < payload_len/2; i++) {
sum += htons(*ptr++);
}
// add the padding if the packet length is odd
if (payload_len & 1) {
sum += (*((uint8_t *)ptr) << 8);
}
// add some IP header data
ptr = ip_header + 6;
for (int i = 0; i < 4; i++) { // IP addresses