summaryrefslogtreecommitdiff
path: root/base/inet.hh
diff options
context:
space:
mode:
authorNathan Binkert <binkertn@umich.edu>2004-10-01 19:48:33 -0400
committerNathan Binkert <binkertn@umich.edu>2004-10-01 19:48:33 -0400
commiteaf66f46588cdfd8a91b93821406e1d797c6d1fb (patch)
treeb2e418935f2730c5977600e414cecaf03a832faa /base/inet.hh
parent72276af49f1113649e97074b5b492ad7b5e25837 (diff)
downloadgem5-eaf66f46588cdfd8a91b93821406e1d797c6d1fb.tar.xz
fix some bugs in the headers and fix checksumming.
base/inet.cc: we can't use a uint16_t for the intermediate checksum values since there may be some bits that carry. the length that is added in the pseudo header is the length of the tcp portion only. base/inet.hh: silly me, the ip_hlen field is in terms of 4-byte words. when caclulating checksum, we're dealing with network byte order, so don't bother doing any byteswapping. --HG-- extra : convert_revision : 993e3413e9febea0ba2fb6ba8bf04c053cca15ed
Diffstat (limited to 'base/inet.hh')
-rw-r--r--base/inet.hh10
1 files changed, 5 insertions, 5 deletions
diff --git a/base/inet.hh b/base/inet.hh
index b20c90beb..8a49790a7 100644
--- a/base/inet.hh
+++ b/base/inet.hh
@@ -82,7 +82,7 @@ struct EthHdr : protected eth_hdr
struct IpHdr : protected ip_hdr
{
uint8_t version() const { return ip_v; }
- uint8_t hlen() const { return ip_hl; }
+ uint8_t hlen() const { return ip_hl * 4; }
uint8_t tos() const { return ip_tos; }
uint16_t len() const { return ntohs(ip_len); }
uint16_t id() const { return ntohs(ip_id); }
@@ -90,11 +90,11 @@ struct IpHdr : protected ip_hdr
uint16_t frag_off() const { return ntohs(ip_off) & 0x1fff; }
uint8_t ttl() const { return ip_ttl; }
uint8_t proto() const { return ip_p; }
- uint16_t sum() const { return ntohs(ip_sum); }
+ uint16_t sum() const { return ip_sum; }
uint32_t src() const { return ntohl(ip_src); }
uint32_t dst() const { return ntohl(ip_dst); }
- void sum(uint16_t sum) { ip_sum = htons(sum); }
+ void sum(uint16_t sum) { ip_sum = sum; }
uint16_t ip_cksum() const;
uint16_t tu_cksum() const;
@@ -126,10 +126,10 @@ struct TcpHdr : protected tcp_hdr
uint8_t off() const { return th_off; }
uint8_t flags() const { return th_flags & 0x3f; }
uint16_t win() const { return ntohs(th_win); }
- uint16_t sum() const { return ntohs(th_sum); }
+ uint16_t sum() const { return th_sum; }
uint16_t urp() const { return ntohs(th_urp); }
- void sum(uint16_t sum) { th_sum = htons(sum); }
+ void sum(uint16_t sum) { th_sum = sum; }
int size() const { return off(); }
const uint8_t *bytes() const { return (const uint8_t *)this; }