b54b1efd5d745579ea6545f34c1db106fa923554
[govpp.git] / binapi / ethernet_types / ethernet_types.ba.go
1 // Code generated by GoVPP's binapi-generator. DO NOT EDIT.
2 // versions:
3 //  binapi-generator: v0.4.0-dev
4 //  VPP:              20.05-release
5 // source: /usr/share/vpp/api/core/ethernet_types.api.json
6
7 // Package ethernet_types contains generated bindings for API file ethernet_types.api.
8 //
9 // Contents:
10 //   1 alias
11 //
12 package ethernet_types
13
14 import (
15         api "git.fd.io/govpp.git/api"
16         "net"
17 )
18
19 // This is a compile-time assertion to ensure that this generated file
20 // is compatible with the GoVPP api package it is being compiled against.
21 // A compilation error at this line likely means your copy of the
22 // GoVPP api package needs to be updated.
23 const _ = api.GoVppAPIPackageIsVersion2
24
25 // MacAddress defines alias 'mac_address'.
26 type MacAddress [6]uint8
27
28 func ParseMacAddress(s string) (MacAddress, error) {
29         var macaddr MacAddress
30         mac, err := net.ParseMAC(s)
31         if err != nil {
32                 return macaddr, err
33         }
34         copy(macaddr[:], mac[:])
35         return macaddr, nil
36 }
37 func (x MacAddress) ToMAC() net.HardwareAddr {
38         return net.HardwareAddr(x[:])
39 }
40 func (x MacAddress) String() string {
41         return x.ToMAC().String()
42 }
43 func (x *MacAddress) MarshalText() ([]byte, error) {
44         return []byte(x.String()), nil
45 }
46 func (x *MacAddress) UnmarshalText(text []byte) error {
47         mac, err := ParseMacAddress(string(text))
48         if err != nil {
49                 return err
50         }
51         *x = mac
52         return nil
53 }