98bbead21d2b749435978a303b0cd746b6568b31
[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
6 // Package ethernet_types contains generated bindings for API file ethernet_types.api.
7 //
8 // Contents:
9 //   1 alias
10 //
11 package ethernet_types
12
13 import (
14         "net"
15
16         api "git.fd.io/govpp.git/api"
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 }