GoVPP release v0.5.0
[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.5.0
4 //  VPP:              22.02-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         "net"
16
17         api "git.fd.io/govpp.git/api"
18 )
19
20 // This is a compile-time assertion to ensure that this generated file
21 // is compatible with the GoVPP api package it is being compiled against.
22 // A compilation error at this line likely means your copy of the
23 // GoVPP api package needs to be updated.
24 const _ = api.GoVppAPIPackageIsVersion2
25
26 const (
27         APIFile    = "ethernet_types"
28         APIVersion = "1.0.0"
29         VersionCrc = 0xf24103d6
30 )
31
32 // MacAddress defines alias 'mac_address'.
33 type MacAddress [6]uint8
34
35 func ParseMacAddress(s string) (MacAddress, error) {
36         var macaddr MacAddress
37         mac, err := net.ParseMAC(s)
38         if err != nil {
39                 return macaddr, err
40         }
41         copy(macaddr[:], mac[:])
42         return macaddr, nil
43 }
44
45 func (x MacAddress) ToMAC() net.HardwareAddr {
46         return net.HardwareAddr(x[:])
47 }
48
49 func (x MacAddress) String() string {
50         return x.ToMAC().String()
51 }
52
53 func (x *MacAddress) MarshalText() ([]byte, error) {
54         return []byte(x.String()), nil
55 }
56
57 func (x *MacAddress) UnmarshalText(text []byte) error {
58         mac, err := ParseMacAddress(string(text))
59         if err != nil {
60                 return err
61         }
62         *x = mac
63         return nil
64 }