/*
* Copyright (c) 2002-2005 The Regents of The University of Michigan
+ * Copyright (c) 2010 Advanced Micro Devices, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Authors: Nathan Binkert
+ * Gabe Black
*/
+#include <cstddef>
+#include <cstdio>
#include <sstream>
#include <string>
#include "base/cprintf.hh"
-#include "sim/host.hh"
#include "base/inet.hh"
+#include "base/types.hh"
using namespace std;
namespace Net {
return stream;
}
+string
+IpAddress::string() const
+{
+ stringstream stream;
+ stream << *this;
+ return stream.str();
+}
+
+bool
+operator==(const IpAddress &left, const IpAddress &right)
+{
+ return left.ip() == right.ip();
+}
+
+ostream &
+operator<<(ostream &stream, const IpAddress &ia)
+{
+ uint32_t ip = ia.ip();
+ ccprintf(stream, "%x.%x.%x.%x",
+ (uint8_t)(ip >> 24), (uint8_t)(ip >> 16),
+ (uint8_t)(ip >> 8), (uint8_t)(ip >> 0));
+ return stream;
+}
+
+string
+IpNetmask::string() const
+{
+ stringstream stream;
+ stream << *this;
+ return stream.str();
+}
+
+bool
+operator==(const IpNetmask &left, const IpNetmask &right)
+{
+ return (left.ip() == right.ip()) &&
+ (left.netmask() == right.netmask());
+}
+
+ostream &
+operator<<(ostream &stream, const IpNetmask &in)
+{
+ ccprintf(stream, "%s/%d", (const IpAddress &)in, in.netmask());
+ return stream;
+}
+
+string
+IpWithPort::string() const
+{
+ stringstream stream;
+ stream << *this;
+ return stream.str();
+}
+
+bool
+operator==(const IpWithPort &left, const IpWithPort &right)
+{
+ return (left.ip() == right.ip()) && (left.port() == right.port());
+}
+
+ostream &
+operator<<(ostream &stream, const IpWithPort &iwp)
+{
+ ccprintf(stream, "%s:%d", (const IpAddress &)iwp, iwp.port());
+ return stream;
+}
+
uint16_t
cksum(const IpPtr &ptr)
{
return false;
}
-/* namespace Net */ }
+int
+hsplit(const EthPacketPtr &ptr)
+{
+ int split_point = 0;
+
+ IpPtr ip(ptr);
+ if (ip) {
+ split_point = ip.pstart();
+
+ TcpPtr tcp(ip);
+ if (tcp)
+ split_point = tcp.pstart();
+
+ UdpPtr udp(ip);
+ if (udp)
+ split_point = udp.pstart();
+ }
+ return split_point;
+}
+
+
+} // namespace Net