Eui48.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2023 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_SRC_EUI_EUI48_H
10 #define SQUID_SRC_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  bool operator== (const Eui48 &t) const { return memcmp(eui, t.eui, SZ_EUI48_BUF) == 0; }
33  bool operator< (const Eui48 &t) const { return memcmp(eui, t.eui, SZ_EUI48_BUF) < 0; }
34 
35  const unsigned char *get(void);
36 
37  bool set(const char *src, const int len) {
38  if (len > SZ_EUI48_BUF) return false;
39  if (len < SZ_EUI48_BUF) clear();
40  memcpy(eui, src, len);
41  return true;
42  }
43 
44  void clear() { memset(eui, 0, SZ_EUI48_BUF); }
45 
54  bool decode(const char *asc);
55 
65  bool encode(char *buf, const int len) const;
66 
67  // lookup an EUI-48 / MAC address via ARP
68  bool lookup(const Ip::Address &c);
69 
70 private:
71  unsigned char eui[SZ_EUI48_BUF];
72 };
73 
74 } // namespace Eui
75 
76 #endif /* USE_SQUID_EUI */
77 #endif /* SQUID_SRC_EUI_EUI48_H */
78 
void clear()
Definition: Eui48.h:44
#define SZ_EUI48_BUF
Definition: Eui48.h:15
bool encode(char *buf, const int len) const
Definition: Eui48.cc:144
bool decode(const char *asc)
Definition: Eui48.cc:122
Eui48()
Definition: Eui48.h:31
bool set(const char *src, const int len)
Definition: Eui48.h:37
bool lookup(const Ip::Address &c)
Definition: Eui48.cc:160
unsigned char eui[SZ_EUI48_BUF]
Definition: Eui48.h:71
bool operator<(const Eui48 &t) const
Definition: Eui48.h:33
Definition: Xaction.cc:137
const unsigned char * get(void)
Definition: Config.h:12
bool operator==(const Eui48 &t) const
Definition: Eui48.h:32

 

Introduction

Documentation

Support

Miscellaneous