github.com/edwarnicke/govpp@v0.0.0-20230130211138-14ef5d20b1d0/binapi/ethernet_types/ethernet_types.ba.go (about) 1 // Code generated by GoVPP's binapi-generator. DO NOT EDIT. 2 // versions: 3 // binapi-generator: v0.4.0-dev 4 // VPP: 23.02-rc0~189-g57127b32a 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 // MacAddress defines alias 'mac_address'. 27 type MacAddress [6]uint8 28 29 func ParseMacAddress(s string) (MacAddress, error) { 30 var macaddr MacAddress 31 mac, err := net.ParseMAC(s) 32 if err != nil { 33 return macaddr, err 34 } 35 copy(macaddr[:], mac[:]) 36 return macaddr, nil 37 } 38 func (x MacAddress) ToMAC() net.HardwareAddr { 39 return net.HardwareAddr(x[:]) 40 } 41 func (x MacAddress) String() string { 42 return x.ToMAC().String() 43 } 44 func (x *MacAddress) MarshalText() ([]byte, error) { 45 return []byte(x.String()), nil 46 } 47 func (x *MacAddress) UnmarshalText(text []byte) error { 48 mac, err := ParseMacAddress(string(text)) 49 if err != nil { 50 return err 51 } 52 *x = mac 53 return nil 54 }