Fix L2BD arp termination Test Case
[vpp.git] / test / vpp_mac.py
1 """
2   MAC Types
3
4 """
5
6 from util import mactobinary
7
8
9 class VppMacAddress():
10     def __init__(self, addr):
11         self._address = addr
12
13     def encode(self):
14         return {
15             'bytes': self.bytes
16         }
17
18     @property
19     def bytes(self):
20         return mactobinary(self.address)
21
22     @property
23     def address(self):
24         return self._address
25
26     def __str__(self):
27         return self.address
28
29     def __eq__(self, other):
30         if isinstance(other, self.__class__):
31             return self.address == other.address
32         elif hasattr(other, "bytes"):
33             # vl_api_mac_addres_t
34             return self.bytes == other.bytes
35         else:
36             raise TypeError("Comparing VppMacAddress:%s"
37                             "with unknown type: %s" %
38                             (self, other))
39         return False