binapigen: fix union size
[govpp.git] / binapi / lisp_types / lisp_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/lisp_types.api.json
6
7 // Package lisp_types contains generated bindings for API file lisp_types.api.
8 //
9 // Contents:
10 //   2 enums
11 //   5 structs
12 //   1 union
13 //
14 package lisp_types
15
16 import (
17         "strconv"
18
19         api "git.fd.io/govpp.git/api"
20         ethernet_types "git.fd.io/govpp.git/binapi/ethernet_types"
21         interface_types "git.fd.io/govpp.git/binapi/interface_types"
22         ip_types "git.fd.io/govpp.git/binapi/ip_types"
23         codec "git.fd.io/govpp.git/codec"
24 )
25
26 // This is a compile-time assertion to ensure that this generated file
27 // is compatible with the GoVPP api package it is being compiled against.
28 // A compilation error at this line likely means your copy of the
29 // GoVPP api package needs to be updated.
30 const _ = api.GoVppAPIPackageIsVersion2
31
32 // EidType defines enum 'eid_type'.
33 type EidType uint8
34
35 const (
36         EID_TYPE_API_PREFIX EidType = 0
37         EID_TYPE_API_MAC    EidType = 1
38         EID_TYPE_API_NSH    EidType = 2
39 )
40
41 var (
42         EidType_name = map[uint8]string{
43                 0: "EID_TYPE_API_PREFIX",
44                 1: "EID_TYPE_API_MAC",
45                 2: "EID_TYPE_API_NSH",
46         }
47         EidType_value = map[string]uint8{
48                 "EID_TYPE_API_PREFIX": 0,
49                 "EID_TYPE_API_MAC":    1,
50                 "EID_TYPE_API_NSH":    2,
51         }
52 )
53
54 func (x EidType) String() string {
55         s, ok := EidType_name[uint8(x)]
56         if ok {
57                 return s
58         }
59         return "EidType(" + strconv.Itoa(int(x)) + ")"
60 }
61
62 // HmacKeyID defines enum 'hmac_key_id'.
63 type HmacKeyID uint8
64
65 const (
66         KEY_ID_API_HMAC_NO_KEY      HmacKeyID = 0
67         KEY_ID_API_HMAC_SHA_1_96    HmacKeyID = 1
68         KEY_ID_API_HMAC_SHA_256_128 HmacKeyID = 2
69 )
70
71 var (
72         HmacKeyID_name = map[uint8]string{
73                 0: "KEY_ID_API_HMAC_NO_KEY",
74                 1: "KEY_ID_API_HMAC_SHA_1_96",
75                 2: "KEY_ID_API_HMAC_SHA_256_128",
76         }
77         HmacKeyID_value = map[string]uint8{
78                 "KEY_ID_API_HMAC_NO_KEY":      0,
79                 "KEY_ID_API_HMAC_SHA_1_96":    1,
80                 "KEY_ID_API_HMAC_SHA_256_128": 2,
81         }
82 )
83
84 func (x HmacKeyID) String() string {
85         s, ok := HmacKeyID_name[uint8(x)]
86         if ok {
87                 return s
88         }
89         return "HmacKeyID(" + strconv.Itoa(int(x)) + ")"
90 }
91
92 // Eid defines type 'eid'.
93 type Eid struct {
94         Type    EidType         `binapi:"eid_type,name=type" json:"type,omitempty"`
95         Address EidAddressUnion `binapi:"eid_address,name=address" json:"address,omitempty"`
96 }
97
98 // HmacKey defines type 'hmac_key'.
99 type HmacKey struct {
100         ID  HmacKeyID `binapi:"hmac_key_id,name=id" json:"id,omitempty"`
101         Key []byte    `binapi:"u8[64],name=key" json:"key,omitempty"`
102 }
103
104 // LocalLocator defines type 'local_locator'.
105 type LocalLocator struct {
106         SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
107         Priority  uint8                          `binapi:"u8,name=priority" json:"priority,omitempty"`
108         Weight    uint8                          `binapi:"u8,name=weight" json:"weight,omitempty"`
109 }
110
111 // Nsh defines type 'nsh'.
112 type Nsh struct {
113         Spi uint32 `binapi:"u32,name=spi" json:"spi,omitempty"`
114         Si  uint8  `binapi:"u8,name=si" json:"si,omitempty"`
115 }
116
117 // RemoteLocator defines type 'remote_locator'.
118 type RemoteLocator struct {
119         Priority  uint8            `binapi:"u8,name=priority" json:"priority,omitempty"`
120         Weight    uint8            `binapi:"u8,name=weight" json:"weight,omitempty"`
121         IPAddress ip_types.Address `binapi:"address,name=ip_address" json:"ip_address,omitempty"`
122 }
123
124 // EidAddressUnion defines union 'eid_address'.
125 type EidAddressUnion struct {
126         // EidAddressUnion can be one of:
127         // - Prefix *ip_types.Prefix
128         // - Mac *ethernet_types.MacAddress
129         // - Nsh *Nsh
130         XXX_UnionData [18]byte
131 }
132
133 func EidAddressUnionPrefix(a ip_types.Prefix) (u EidAddressUnion) {
134         u.SetPrefix(a)
135         return
136 }
137 func (u *EidAddressUnion) SetPrefix(a ip_types.Prefix) {
138         buf := codec.NewBuffer(u.XXX_UnionData[:])
139         buf.EncodeUint8(uint8(a.Address.Af))
140         buf.EncodeBytes(a.Address.Un.XXX_UnionData[:], 16)
141         buf.EncodeUint8(a.Len)
142 }
143 func (u *EidAddressUnion) GetPrefix() (a ip_types.Prefix) {
144         buf := codec.NewBuffer(u.XXX_UnionData[:])
145         a.Address.Af = ip_types.AddressFamily(buf.DecodeUint8())
146         copy(a.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16))
147         a.Len = buf.DecodeUint8()
148         return
149 }
150
151 func EidAddressUnionMac(a ethernet_types.MacAddress) (u EidAddressUnion) {
152         u.SetMac(a)
153         return
154 }
155 func (u *EidAddressUnion) SetMac(a ethernet_types.MacAddress) {
156         buf := codec.NewBuffer(u.XXX_UnionData[:])
157         buf.EncodeBytes(a[:], 6)
158 }
159 func (u *EidAddressUnion) GetMac() (a ethernet_types.MacAddress) {
160         buf := codec.NewBuffer(u.XXX_UnionData[:])
161         copy(a[:], buf.DecodeBytes(6))
162         return
163 }
164
165 func EidAddressUnionNsh(a Nsh) (u EidAddressUnion) {
166         u.SetNsh(a)
167         return
168 }
169 func (u *EidAddressUnion) SetNsh(a Nsh) {
170         buf := codec.NewBuffer(u.XXX_UnionData[:])
171         buf.EncodeUint32(a.Spi)
172         buf.EncodeUint8(a.Si)
173 }
174 func (u *EidAddressUnion) GetNsh() (a Nsh) {
175         buf := codec.NewBuffer(u.XXX_UnionData[:])
176         a.Spi = buf.DecodeUint32()
177         a.Si = buf.DecodeUint8()
178         return
179 }