]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/eui/Eui48.h
Docs: Copyright updates for 2018 (#114)
[thirdparty/squid.git] / src / eui / Eui48.h
index 982db871101eb29aa7951cc24fdd0a7d8c604a0a..73099b735fb561a1cca118bb2bcf44fcaa7e2c47 100644 (file)
@@ -1,8 +1,14 @@
+/*
+ * Copyright (C) 1996-2018 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
 #ifndef _SQUID_EUI_EUI48_H
 #define _SQUID_EUI_EUI48_H
 
-#include "config.h"
-
 #if USE_SQUID_EUI
 
 /* EUI-48 is 6 bytes. */
@@ -13,14 +19,7 @@ namespace Ip
 class Address;
 };
 
-#if HAVE_CSTRING
 #include <cstring>
-#endif
-
-/* memcpy and friends */
-#if HAVE_STRING_H
-#include <string.h>
-#endif
 
 namespace Eui
 {
@@ -29,9 +28,11 @@ class Eui48
 {
 
 public:
-    Eui48() { clear(); };
-    Eui48(const Eui48 &t) { memcpy(this, &t, sizeof(Eui48)); };
-    ~Eui48() {};
+    Eui48() { clear(); }
+    Eui48(const Eui48 &t) { memcpy(this, &t, sizeof(Eui48)); }
+    bool operator== (const Eui48 &t) const { return memcmp(eui, t.eui, SZ_EUI48_BUF) == 0; }
+    bool operator< (const Eui48 &t) const { return memcmp(eui, t.eui, SZ_EUI48_BUF) < 0; }
+    ~Eui48() {}
 
     const unsigned char *get(void);
 
@@ -40,9 +41,9 @@ public:
         if (len < SZ_EUI48_BUF) clear();
         memcpy(eui, src, len);
         return true;
-    };
+    }
 
-    void clear() { memset(eui, 0, SZ_EUI48_BUF); };
+    void clear() { memset(eui, 0, SZ_EUI48_BUF); }
 
     /**
      * Decode an ascii representation of an EUI-48 ethernet address.
@@ -63,7 +64,7 @@ public:
      * \retval false        Conversion to ASCII failed.
      * \retval true         Conversion completed successfully.
      */
-    bool encode(char *buf, const int len);
+    bool encode(char *buf, const int len) const;
 
     // lookup an EUI-48 / MAC address via ARP
     bool lookup(const Ip::Address &c);
@@ -72,7 +73,8 @@ private:
     unsigned char eui[SZ_EUI48_BUF];
 };
 
-}; // namespace Eui
+} // namespace Eui
 
 #endif /* USE_SQUID_EUI */
 #endif /* _SQUID_EUI_EUI48_H */
+