mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'fix/examples_sta2eth_udpcheck' into 'master'
fix(examples): STA-ETH add the padding if the packet length is odd while updating udp checksum Closes IDFGH-12490 See merge request espressif/esp-idf!30266
This commit is contained in:
commit
ff07cae675
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user