etherpkt.cc revision 11701
1572SN/A/* 21762SN/A * Copyright (c) 2004-2005 The Regents of The University of Michigan 3572SN/A * All rights reserved. 4572SN/A * 5572SN/A * Redistribution and use in source and binary forms, with or without 6572SN/A * modification, are permitted provided that the following conditions are 7572SN/A * met: redistributions of source code must retain the above copyright 8572SN/A * notice, this list of conditions and the following disclaimer; 9572SN/A * redistributions in binary form must reproduce the above copyright 10572SN/A * notice, this list of conditions and the following disclaimer in the 11572SN/A * documentation and/or other materials provided with the distribution; 12572SN/A * neither the name of the copyright holders nor the names of its 13572SN/A * contributors may be used to endorse or promote products derived from 14572SN/A * this software without specific prior written permission. 15572SN/A * 16572SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17572SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18572SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19572SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20572SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21572SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22572SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23572SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24572SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25572SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26572SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665SN/A * 282665SN/A * Authors: Nathan Binkert 29572SN/A */ 30572SN/A 3111263Sandreas.sandberg@arm.com#include "dev/net/etherpkt.hh" 3211263Sandreas.sandberg@arm.com 33572SN/A#include <iostream> 34572SN/A 3511263Sandreas.sandberg@arm.com#include "base/inet.hh" 361153SN/A#include "base/misc.hh" 37572SN/A#include "sim/serialize.hh" 38572SN/A 39572SN/Ausing namespace std; 40572SN/A 41572SN/Avoid 4210905SN/AEthPacketData::serialize(const string &base, CheckpointOut &cp) const 43572SN/A{ 4411701Smichael.lebeane@amd.com paramOut(cp, base + ".simLength", simLength); 4510905SN/A paramOut(cp, base + ".length", length); 4610905SN/A arrayParamOut(cp, base + ".data", data, length); 47572SN/A} 48572SN/A 49572SN/Avoid 5010905SN/AEthPacketData::unserialize(const string &base, CheckpointIn &cp) 51572SN/A{ 5210905SN/A paramIn(cp, base + ".length", length); 5311701Smichael.lebeane@amd.com if (length) { 5411701Smichael.lebeane@amd.com assert(data == nullptr); 5511701Smichael.lebeane@amd.com data = new uint8_t[length]; 5610905SN/A arrayParamIn(cp, base + ".data", data, length); 5711701Smichael.lebeane@amd.com } 5811701Smichael.lebeane@amd.com if (!optParamIn(cp, base + ".simLength", simLength)) 5911701Smichael.lebeane@amd.com simLength = length; 60572SN/A} 6110923SN/A 62