etherdump.hh revision 2665
110515SN/A/*
210515SN/A * Copyright (c) 2002-2005 The Regents of The University of Michigan
310515SN/A * All rights reserved.
410515SN/A *
510515SN/A * Redistribution and use in source and binary forms, with or without
610515SN/A * modification, are permitted provided that the following conditions are
710515SN/A * met: redistributions of source code must retain the above copyright
810515SN/A * notice, this list of conditions and the following disclaimer;
910515SN/A * redistributions in binary form must reproduce the above copyright
1010515SN/A * notice, this list of conditions and the following disclaimer in the
1110515SN/A * documentation and/or other materials provided with the distribution;
1210515SN/A * neither the name of the copyright holders nor the names of its
1310515SN/A * contributors may be used to endorse or promote products derived from
1410515SN/A * this software without specific prior written permission.
1511239Sandreas.sandberg@arm.com *
1610515SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1710515SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1810515SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1911239Sandreas.sandberg@arm.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2010515SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2110515SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2210515SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2310515SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2410515SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2510515SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2610515SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2710515SN/A *
2810515SN/A * Authors: Nathan Binkert
2910515SN/A */
3010515SN/A
3111239Sandreas.sandberg@arm.com/* @file
3210515SN/A * Simple object for creating a simple pcap style packet trace
3310515SN/A */
3410515SN/A
3510515SN/A#ifndef __ETHERDUMP_H__
3610515SN/A#define __ETHERDUMP_H__
3710515SN/A
3810636SN/A#include <fstream>
3910736SN/A#include "dev/etherpkt.hh"
4010515SN/A#include "sim/sim_object.hh"
4111167Sjthestness@gmail.com
4210515SN/A/*
4310515SN/A * Simple object for creating a simple pcap style packet trace
4410515SN/A */
4510515SN/Aclass EtherDump : public SimObject
4611245Sandreas.sandberg@arm.com{
4710515SN/A  private:
4810515SN/A    std::ofstream stream;
4910515SN/A    const int maxlen;
5010515SN/A    void dumpPacket(EthPacketPtr &packet);
5110515SN/A    void init();
5210515SN/A
5310515SN/A    Tick curtime;
5410515SN/A
5510515SN/A  public:
5610515SN/A    EtherDump(const std::string &name, const std::string &file, int max);
5710515SN/A
5810515SN/A    inline void dump(EthPacketPtr &pkt) { dumpPacket(pkt); }
5910515SN/A};
6010515SN/A
6110515SN/A#endif // __ETHERDUMP_H__
6210515SN/A