From ee8c8cbcd89f70d50a770007c6bcaf428ac2f233 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Fri, 20 Feb 2004 15:19:19 -0500 Subject: make etherdump work again dev/etherdump.cc: now that init is automatically called by the framework, don't init twice. --HG-- extra : convert_revision : 16dcdef67aa193ed71ff546e7b255d60f39bf13d --- dev/etherdump.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'dev/etherdump.cc') diff --git a/dev/etherdump.cc b/dev/etherdump.cc index 6d86adc32..23b3d778e 100644 --- a/dev/etherdump.cc +++ b/dev/etherdump.cc @@ -43,11 +43,8 @@ using std::string; EtherDump::EtherDump(const string &name, const string &file) : SimObject(name) { - if (!file.empty()) { + if (!file.empty()) stream.open(file.c_str()); - if (stream.is_open()) - init(); - } } #define DLT_EN10MB 1 // Ethernet (10Mb) @@ -74,6 +71,9 @@ struct pcap_pkthdr { void EtherDump::init() { + if (!stream.is_open()) + return; + curtime = time(NULL); s_freq = ticksPerSecond; us_freq = ticksPerSecond / ULL(1000000); -- cgit v1.2.3 From 2272164d6652c554fb3bab7bddfd0d53151e4115 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Sun, 29 Feb 2004 17:05:23 -0500 Subject: Fix dumping to work on the opteron. struct timeval can vary in size, so we're explicit about the fields. --HG-- extra : convert_revision : e5264849dafb878676b2bfd3a6e6f95f6f94ea48 --- dev/etherdump.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'dev/etherdump.cc') diff --git a/dev/etherdump.cc b/dev/etherdump.cc index 23b3d778e..b6d6bbe30 100644 --- a/dev/etherdump.cc +++ b/dev/etherdump.cc @@ -34,6 +34,7 @@ #include +#include "base/misc.hh" #include "dev/etherdump.hh" #include "sim/builder.hh" #include "sim/universe.hh" @@ -63,7 +64,8 @@ struct pcap_file_header { }; struct pcap_pkthdr { - struct timeval ts; // time stamp + uint32_t seconds; + uint32_t microseconds; uint32_t caplen; // length of portion present uint32_t len; // length this packet (off wire) }; @@ -96,8 +98,8 @@ EtherDump::init() * to sim_cycles. */ pcap_pkthdr pkthdr; - pkthdr.ts.tv_sec = curtime; - pkthdr.ts.tv_usec = 0; + pkthdr.seconds = curtime; + pkthdr.microseconds = 0; pkthdr.caplen = 0; pkthdr.len = 0; stream.write(reinterpret_cast(&pkthdr), sizeof(pkthdr)); @@ -109,8 +111,8 @@ void EtherDump::dumpPacket(PacketPtr &packet) { pcap_pkthdr pkthdr; - pkthdr.ts.tv_sec = curtime + (curTick / s_freq); - pkthdr.ts.tv_usec = (curTick / us_freq) % ULL(1000000); + pkthdr.seconds = curtime + (curTick / s_freq); + pkthdr.microseconds = (curTick / us_freq) % ULL(1000000); pkthdr.caplen = packet->length; pkthdr.len = packet->length; stream.write(reinterpret_cast(&pkthdr), sizeof(pkthdr)); -- cgit v1.2.3