summaryrefslogtreecommitdiff
path: root/src/base/inet.hh
diff options
context:
space:
mode:
authorGabe Black <gblack@eecs.umich.edu>2010-11-23 15:54:43 -0500
committerGabe Black <gblack@eecs.umich.edu>2010-11-23 15:54:43 -0500
commitb3de4855c3dba9df80cca4540c4ee6625c26f9e1 (patch)
tree28f1876bd2d31904d1f3d4bdbde4ac6def7207a1 /src/base/inet.hh
parent40d434d5516affffe9ded9365e0d2da060aa7c78 (diff)
downloadgem5-b3de4855c3dba9df80cca4540c4ee6625c26f9e1.tar.xz
Params: Add parameter types for IP addresses in various forms.
New parameter forms are: IP address in the format "a.b.c.d" where a-d are from decimal 0 to 255. IP address with netmask which is an IP followed by "/n" where n is a netmask length in bits from decimal 0 to 32 or by "/e.f.g.h" where e-h are from decimal 0 to 255 and which is all 1 bits followed by all 0 bits when represented in binary. These can also be specified as an integral IP and netmask passed in separately. IP address with port which is an IP followed by ":p" where p is a port index from decimal 0 to 65535. These can also be specified as an integral IP and port value passed in separately.
Diffstat (limited to 'src/base/inet.hh')
-rw-r--r--src/base/inet.hh59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/base/inet.hh b/src/base/inet.hh
index ef9a7d81c..12387087b 100644
--- a/src/base/inet.hh
+++ b/src/base/inet.hh
@@ -147,6 +147,65 @@ class EthPtr
/*
* IP Stuff
*/
+struct IpAddress
+{
+ protected:
+ uint32_t _ip;
+
+ public:
+ IpAddress() : _ip(0)
+ {}
+ IpAddress(const uint32_t __ip) : _ip(__ip)
+ {}
+
+ uint32_t ip() const { return _ip; }
+
+ std::string string() const;
+};
+
+std::ostream &operator<<(std::ostream &stream, const IpAddress &ia);
+bool operator==(const IpAddress &left, const IpAddress &right);
+
+struct IpNetmask : public IpAddress
+{
+ protected:
+ uint8_t _netmask;
+
+ public:
+ IpNetmask() : IpAddress(), _netmask(0)
+ {}
+ IpNetmask(const uint32_t __ip, const uint8_t __netmask) :
+ IpAddress(__ip), _netmask(__netmask)
+ {}
+
+ uint8_t netmask() const { return _netmask; }
+
+ std::string string() const;
+};
+
+std::ostream &operator<<(std::ostream &stream, const IpNetmask &in);
+bool operator==(const IpNetmask &left, const IpNetmask &right);
+
+struct IpWithPort : public IpAddress
+{
+ protected:
+ uint16_t _port;
+
+ public:
+ IpWithPort() : IpAddress(), _port(0)
+ {}
+ IpWithPort(const uint32_t __ip, const uint16_t __port) :
+ IpAddress(__ip), _port(__port)
+ {}
+
+ uint8_t port() const { return _port; }
+
+ std::string string() const;
+};
+
+std::ostream &operator<<(std::ostream &stream, const IpWithPort &iwp);
+bool operator==(const IpWithPort &left, const IpWithPort &right);
+
struct IpOpt;
struct IpHdr : public ip_hdr
{