Make it so we can cast an EthAddr to a 64-bit integer
authorNathan Binkert <binkertn@umich.edu>
Wed, 10 Nov 2004 23:49:55 +0000 (18:49 -0500)
committerNathan Binkert <binkertn@umich.edu>
Wed, 10 Nov 2004 23:49:55 +0000 (18:49 -0500)
--HG--
extra : convert_revision : 2f470d122997fbc375f04e9c2682b6528adef50c

base/inet.hh

index 7ea4de6bb17a04a40649878c18d5383480da02ae..10b782a6c8618e02d4502ed7d8c0d2aed1d17747 100644 (file)
@@ -81,6 +81,19 @@ struct EthAddr : protected eth_addr
     bool multicast() const { return data[0] == 0x01; }
     bool broadcast() const { return data[0] == 0xff; }
     std::string string() const;
+
+    operator uint64_t() const
+    {
+        uint64_t reg = 0;
+        reg |= ((uint64_t)data[0]) << 40;
+        reg |= ((uint64_t)data[1]) << 32;
+        reg |= ((uint64_t)data[2]) << 24;
+        reg |= ((uint64_t)data[3]) << 16;
+        reg |= ((uint64_t)data[4]) << 8;
+        reg |= ((uint64_t)data[5]) << 0;
+        return reg;
+    }
+
 };
 
 std::ostream &operator<<(std::ostream &stream, const EthAddr &ea);