summaryrefslogtreecommitdiffstats
path: root/src/net/ipv4.c
diff options
context:
space:
mode:
authorNikhil Chandru Rao2006-06-28 11:59:27 +0200
committerNikhil Chandru Rao2006-06-28 11:59:27 +0200
commit6e2c97b0c0a5eeec99bbfce1eec075ded11bb591 (patch)
treeb6819704317dcf45fb401de71baf6717bcb8b32a /src/net/ipv4.c
parentIP6 specifications (diff)
downloadipxe-6e2c97b0c0a5eeec99bbfce1eec075ded11bb591.tar.gz
ipxe-6e2c97b0c0a5eeec99bbfce1eec075ded11bb591.tar.xz
ipxe-6e2c97b0c0a5eeec99bbfce1eec075ded11bb591.zip
Added ipv4_pseudo_header structure
Diffstat (limited to 'src/net/ipv4.c')
-rw-r--r--src/net/ipv4.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/net/ipv4.c b/src/net/ipv4.c
index 91b2d7ff..b770301a 100644
--- a/src/net/ipv4.c
+++ b/src/net/ipv4.c
@@ -124,21 +124,18 @@ static void ipv4_dump ( struct iphdr *iphdr __unused ) {
void ipv4_tx_csum ( struct pk_buff *pkb, uint8_t trans_proto ) {
struct iphdr *iphdr = pkb->data;
- void *pshdr = malloc ( IP_PSHLEN );
- void *csum_offset = iphdr + IP_HLEN + ( trans_proto == IP_UDP ? 6 : 16 );
- int offset = 0;
+ struct ipv4_pseudo_header pshdr;
+ void *csum_offset = iphdr + sizeof ( *iphdr ) + ( trans_proto == IP_UDP ? 6 : 16 );
/* Calculate pseudo header */
- memcpy ( pshdr, &iphdr->src, sizeof ( in_addr ) );
- offset += sizeof ( in_addr );
- memcpy ( pshdr + offset, &iphdr->dest, sizeof ( in_addr ) );
- offset += sizeof ( in_addr );
- *( ( uint8_t* ) ( pshdr + offset++ ) ) = 0x00;
- *( ( uint8_t* ) ( pshdr + offset++ ) ) = iphdr->protocol;
- *( ( uint16_t* ) ( pshdr + offset ) ) = pkb_len ( pkb ) - IP_HLEN;
+ pshdr.src = iphdr->src;
+ pshdr.dest = iphdr->dest;
+ pshdr.zero_padding = 0x00;
+ pshdr.protocol = iphdr->protocol;
+ pshdr.len = htons ( pkb_len ( pkb ) - sizeof ( *iphdr ) );
/* Update the checksum value */
- *( ( uint16_t* ) csum_offset ) = *( ( uint16_t* ) csum_offset ) + calc_chksum ( pshdr, IP_PSHLEN );
+ *( ( uint16_t* ) csum_offset ) = *( ( uint16_t* ) csum_offset ) + calc_chksum ( &pshdr, IP_PSHLEN );
}
/**