openc2lib.types.targets.mac_addr
1import macaddress 2 3from openc2lib.core.target import target 4 5@target('mac_addr') 6class MACAddr: 7 """ OpenC2 MACAddr 8 9 Implements the `mac_addr`` target (Section 3.4.1.14). 10 Media Access Control / Extended Unique Identifier address - EUI- 48 or EUI-64. 11 The text representation of a MAC Address in colon hexadecimal format. 12 """ 13 14 def __init__(self, eui): 15 """ Raises an error if `eui` is not EUI48 or EUI64 """ 16 self.set(eui) 17 18 def set(self, eui): 19 """ Instantiates an EUI48/EUI64 address. 20 21 Raises an error if `eui` is not EUI48 or EUI64. 22 Takes as input a string, a binary, or an integer. 23 """ 24 self.__eui = macaddress.parse(eui, macaddress.EUI48, macaddress.EUI64) 25 26 def get(self): 27 """ Returns colon hexadeciaml format """ 28 return str(self.__eui).replace('-',':') 29 30 def __str__(self): 31 return str(self.__eui).replace('-',':')
@target('mac_addr')
class
MACAddr:
6@target('mac_addr') 7class MACAddr: 8 """ OpenC2 MACAddr 9 10 Implements the `mac_addr`` target (Section 3.4.1.14). 11 Media Access Control / Extended Unique Identifier address - EUI- 48 or EUI-64. 12 The text representation of a MAC Address in colon hexadecimal format. 13 """ 14 15 def __init__(self, eui): 16 """ Raises an error if `eui` is not EUI48 or EUI64 """ 17 self.set(eui) 18 19 def set(self, eui): 20 """ Instantiates an EUI48/EUI64 address. 21 22 Raises an error if `eui` is not EUI48 or EUI64. 23 Takes as input a string, a binary, or an integer. 24 """ 25 self.__eui = macaddress.parse(eui, macaddress.EUI48, macaddress.EUI64) 26 27 def get(self): 28 """ Returns colon hexadeciaml format """ 29 return str(self.__eui).replace('-',':') 30 31 def __str__(self): 32 return str(self.__eui).replace('-',':')
OpenC2 MACAddr
Implements the `mac_addr`` target (Section 3.4.1.14). Media Access Control / Extended Unique Identifier address - EUI- 48 or EUI-64. The text representation of a MAC Address in colon hexadecimal format.
MACAddr(eui)
15 def __init__(self, eui): 16 """ Raises an error if `eui` is not EUI48 or EUI64 """ 17 self.set(eui)
Raises an error if eui is not EUI48 or EUI64
def
set(self, eui):
19 def set(self, eui): 20 """ Instantiates an EUI48/EUI64 address. 21 22 Raises an error if `eui` is not EUI48 or EUI64. 23 Takes as input a string, a binary, or an integer. 24 """ 25 self.__eui = macaddress.parse(eui, macaddress.EUI48, macaddress.EUI64)
Instantiates an EUI48/EUI64 address.
Raises an error if eui is not EUI48 or EUI64.
Takes as input a string, a binary, or an integer.