Skip to content

Commit

Permalink
checksum: pseudo_header_initial() host byte order
Browse files Browse the repository at this point in the history
Make the C function pseudo_header_initial() return the checksum in host
byte order. This is to match the other checksum functions and
particularly to make the value suitable as the argument to ipsum().
  • Loading branch information
lukego committed Jul 31, 2015
1 parent 750559d commit 84b497a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib/checksum.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void checksum_update_incremental_32(uint16_t* checksum_cell,
// calculates the initial checksum value resulting from
// the pseudo header.
// return values:
// 0x0000 - 0xFFFF : initial checksum (in network order).
// 0x0000 - 0xFFFF : initial checksum (in host byte order).
// 0xFFFF0001 : unknown packet (non IPv4/6 or non TCP/UDP)
// 0xFFFF0002 : bad header
uint32_t pseudo_header_initial(const int8_t *buf, size_t len)
Expand Down Expand Up @@ -146,7 +146,7 @@ uint32_t pseudo_header_initial(const int8_t *buf, size_t len)
}
sum = ((sum & 0xffff0000) >> 16) + (sum & 0xffff);
sum = ((sum & 0xffff0000) >> 16) + (sum & 0xffff);
return sum;
return ntohs(sum);
}
return 0xFFFF0001;
}

0 comments on commit 84b497a

Please sign in to comment.