diff options
author | Aloys Augustin <aloaugus@cisco.com> | 2021-10-18 14:16:59 +0200 |
---|---|---|
committer | Ondrej Fabry <ofabry@cisco.com> | 2021-11-29 07:16:05 +0000 |
commit | 0a0c03d459547aa9004cbbc1ed9a358d831adf03 (patch) | |
tree | e461f1100fa7e5faf6db331708f9cbbad4c0e829 /binapi/ethernet_types | |
parent | 4cc53fc9a836df099dde983d506eb892dc2fdef1 (diff) |
Add "FromIP" helper for addresses
Change-Id: Ib34b84b8267c95ce3bacef4806cc52a6c7c24f05
Signed-off-by: Aloys Augustin <aloaugus@cisco.com>
Diffstat (limited to 'binapi/ethernet_types')
-rw-r--r-- | binapi/ethernet_types/ethernet_types.ba.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/binapi/ethernet_types/ethernet_types.ba.go b/binapi/ethernet_types/ethernet_types.ba.go index dd18d9e..cce8de4 100644 --- a/binapi/ethernet_types/ethernet_types.ba.go +++ b/binapi/ethernet_types/ethernet_types.ba.go @@ -35,15 +35,19 @@ func ParseMacAddress(s string) (MacAddress, error) { copy(macaddr[:], mac[:]) return macaddr, nil } + func (x MacAddress) ToMAC() net.HardwareAddr { return net.HardwareAddr(x[:]) } + func (x MacAddress) String() string { return x.ToMAC().String() } + func (x *MacAddress) MarshalText() ([]byte, error) { return []byte(x.String()), nil } + func (x *MacAddress) UnmarshalText(text []byte) error { mac, err := ParseMacAddress(string(text)) if err != nil { |