summaryrefslogtreecommitdiffstats
path: root/src/net/ipv4.c
diff options
context:
space:
mode:
authorMichael Brown2006-07-20 01:38:05 +0200
committerMichael Brown2006-07-20 01:38:05 +0200
commit2c0eb6eb1dc2b3828adad19ff46aeffae95b0102 (patch)
tree37de4267c2cf9d1df9fd233de0dab9b7fa57df4d /src/net/ipv4.c
parentudp_open() takes ports in network-endian order. (diff)
downloadipxe-2c0eb6eb1dc2b3828adad19ff46aeffae95b0102.tar.gz
ipxe-2c0eb6eb1dc2b3828adad19ff46aeffae95b0102.tar.xz
ipxe-2c0eb6eb1dc2b3828adad19ff46aeffae95b0102.zip
Correct TCP/IP checksum generation.
Diffstat (limited to 'src/net/ipv4.c')
-rw-r--r--src/net/ipv4.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/net/ipv4.c b/src/net/ipv4.c
index 19e56440..6594af46 100644
--- a/src/net/ipv4.c
+++ b/src/net/ipv4.c
@@ -238,9 +238,8 @@ void ipv4_tx_csum ( struct pk_buff *pkb, struct tcpip_protocol *tcpip ) {
struct iphdr *iphdr = pkb->data;
struct ipv4_pseudo_header pshdr;
- void *csum_offset = iphdr + sizeof ( *iphdr ) + tcpip->csum_offset;
- uint16_t partial_csum = *( ( uint16_t* ) csum_offset );
- uint16_t csum;
+ uint16_t *csum = ( ( ( void * ) iphdr ) + sizeof ( *iphdr )
+ + tcpip->csum_offset );
/* Calculate pseudo header */
pshdr.src = iphdr->src;
@@ -250,8 +249,7 @@ void ipv4_tx_csum ( struct pk_buff *pkb, struct tcpip_protocol *tcpip ) {
pshdr.len = htons ( pkb_len ( pkb ) - sizeof ( *iphdr ) );
/* Update the checksum value */
- csum = partial_csum + calc_chksum ( &pshdr, sizeof ( pshdr ) );
- memcpy ( csum_offset, &csum, 2 );
+ *csum = tcpip_continue_chksum ( *csum, &pshdr, sizeof ( pshdr ) );
}
/**
@@ -407,7 +405,7 @@ int ipv4_tx ( struct pk_buff *pkb, struct tcpip_protocol *tcpip,
/* Calculate header checksum, in network byte order */
iphdr->chksum = 0;
- iphdr->chksum = htons ( calc_chksum ( iphdr, sizeof ( *iphdr ) ) );
+ iphdr->chksum = tcpip_chksum ( iphdr, sizeof ( *iphdr ) );
/* Print IP4 header for debugging */
ipv4_dump ( iphdr );