Eui48.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 #ifndef _SQUID_EUI_EUI48_H
10 #define _SQUID_EUI_EUI48_H
11 
12 #if USE_SQUID_EUI
13 
14 /* EUI-48 is 6 bytes. */
15 #define SZ_EUI48_BUF 6
16 
17 namespace Ip
18 {
19 class Address;
20 };
21 
22 #include <cstring>
23 
24 namespace Eui
25 {
26 
27 class Eui48
28 {
29 
30 public:
31  Eui48() { clear(); }
32  Eui48(const Eui48 &t) { memcpy(this, &t, sizeof(Eui48)); }
33  bool operator== (const Eui48 &t) const { return memcmp(eui, t.eui, SZ_EUI48_BUF) == 0; }
34  bool operator< (const Eui48 &t) const { return memcmp(eui, t.eui, SZ_EUI48_BUF) < 0; }
35  ~Eui48() {}
36 
37  const unsigned char *get(void);
38 
39  bool set(const char *src, const int len) {
40  if (len > SZ_EUI48_BUF) return false;
41  if (len < SZ_EUI48_BUF) clear();
42  memcpy(eui, src, len);
43  return true;
44  }
45 
46  void clear() { memset(eui, 0, SZ_EUI48_BUF); }
47 
56  bool decode(const char *asc);
57 
67  bool encode(char *buf, const int len) const;
68 
69  // lookup an EUI-48 / MAC address via ARP
70  bool lookup(const Ip::Address &c);
71 
72 private:
73  unsigned char eui[SZ_EUI48_BUF];
74 };
75 
76 } // namespace Eui
77 
78 #endif /* USE_SQUID_EUI */
79 #endif /* _SQUID_EUI_EUI48_H */
80 
bool decode(const char *asc)
Definition: Eui48.cc:97
#define SZ_EUI48_BUF
Definition: Eui48.h:15
Eui48()
Definition: Eui48.h:31
bool operator==(const Eui48 &t) const
Definition: Eui48.h:33
unsigned char eui[SZ_EUI48_BUF]
Definition: Eui48.h:73
bool lookup(const Ip::Address &c)
Definition: Eui48.cc:135
bool set(const char *src, const int len)
Definition: Eui48.h:39
~Eui48()
Definition: Eui48.h:35
int unsigned int const char *desc STUB void int len
Definition: stub_fd.cc:20
void const char * buf
Definition: stub_helper.cc:16
bool operator<(const Eui48 &t) const
Definition: Eui48.h:34
Eui48(const Eui48 &t)
Definition: Eui48.h:32
bool encode(char *buf, const int len) const
Definition: Eui48.cc:119
void clear()
Definition: Eui48.h:46
Definition: Address.cc:190

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors