diff options
author | Lisa Hsu <hsul@eecs.umich.edu> | 2004-03-12 11:04:58 -0500 |
---|---|---|
committer | Lisa Hsu <hsul@eecs.umich.edu> | 2004-03-12 11:04:58 -0500 |
commit | 48e6ed48e0672b7b5f5fa65d8fec450483a31676 (patch) | |
tree | e00dec409f9d3387db5bae0e48895a9baf0ff9d6 /dev/etherpkt.hh | |
parent | c82113d02296c40e1a2eac84ba55ae7ffbcf4419 (diff) | |
download | gem5-48e6ed48e0672b7b5f5fa65d8fec450483a31676.tar.xz |
first pass at ns_ethernet device. more will come later as i merge in nate's new ether infrastructure.
dev/etherpkt.hh:
add some stuff for support of the NS ethernet device.
--HG--
extra : convert_revision : 51f6508463b6394055e3428a42b7de490a9ae6c1
Diffstat (limited to 'dev/etherpkt.hh')
-rw-r--r-- | dev/etherpkt.hh | 69 |
1 files changed, 68 insertions, 1 deletions
diff --git a/dev/etherpkt.hh b/dev/etherpkt.hh index c91322526..312d98f64 100644 --- a/dev/etherpkt.hh +++ b/dev/etherpkt.hh @@ -36,11 +36,68 @@ #include <memory> #include "sim/host.hh" - #include "base/refcnt.hh" +#define EADDR_LEN 6 + class Checkpoint; +struct pseudo_header +{ + uint32_t src_ip_addr; + uint32_t dest_ip_addr; + uint16_t protocol; + uint16_t len; +}; + +/** Ethernet header struct for casting purposes */ +struct eth_header +{ + uint8_t dest[EADDR_LEN]; + uint8_t src[EADDR_LEN]; + uint16_t type; +}; + +struct ip_header +{ + uint8_t vers_len; + uint8_t service_type; + uint16_t dgram_len; + uint16_t ID; + uint16_t flags_frag_offset; + uint8_t TTL; + uint8_t protocol; + uint16_t hdr_chksum; + uint32_t src_ip_addr; + uint32_t dest_ip_addr; + uint8_t *options; + uint8_t *transport_header; +}; + +struct tcp_header +{ + uint16_t src_port_num; + uint16_t dest_port_num; + uint32_t seq_num; + uint32_t ack_num; + uint8_t hdr_len; + uint8_t flags; + uint16_t rcv_window; + uint16_t chksum; + uint16_t urgent; + uint8_t *options; + uint8_t *data; +}; + +struct udp_header +{ + uint16_t src_port_num; + uint16_t dest_port_num; + uint16_t len; + uint16_t chksum; + uint8_t *data; +}; + /* * Reference counted class containing ethernet packet data */ @@ -61,6 +118,16 @@ class EtherPacket : public RefCounted bool IsMulticast() { return data[0] == 0x01; } bool IsBroadcast() { return data[0] == 0xff; } + ip_header *getIpHdr() { return (ip_header *) (data + 14); } + + void *getTransportHdr() { + ip_header *ip = getIpHdr(); + return (void *) (ip + (ip->vers_len & 0xf)); + } + + + typedef RefCountingPtr<EtherPacket> PacketPtr; + void serialize(std::ostream &os); void unserialize(Checkpoint *cp, const std::string §ion); }; |