Refactored binapi generator with message encoding
[govpp.git] / examples / binapi / ip_types / ip_types.ba.go
1 // Code generated by GoVPP's binapi-generator. DO NOT EDIT.
2 // versions:
3 //  binapi-generator: v0.4.0-alpha-1-g435c3f4-dirty
4 //  VPP:              20.01-45~g7a071e370~b63
5 // source: /usr/share/vpp/api/core/ip_types.api.json
6
7 /*
8 Package ip_types contains generated code for VPP binary API defined by ip_types.api (version 3.0.0).
9
10 It consists of:
11           5 aliases
12           4 enums
13           6 types
14           1 union
15 */
16 package ip_types
17
18 import (
19         "bytes"
20         "context"
21         "encoding/binary"
22         "io"
23         "math"
24         "strconv"
25
26         api "git.fd.io/govpp.git/api"
27         codec "git.fd.io/govpp.git/codec"
28         struc "github.com/lunixbochs/struc"
29 )
30
31 // This is a compile-time assertion to ensure that this generated file
32 // is compatible with the GoVPP api package it is being compiled against.
33 // A compilation error at this line likely means your copy of the
34 // GoVPP api package needs to be updated.
35 const _ = api.GoVppAPIPackageIsVersion2 // please upgrade the GoVPP api package
36
37 const (
38         // ModuleName is the name of this module.
39         ModuleName = "ip_types"
40         // APIVersion is the API version of this module.
41         APIVersion = "3.0.0"
42         // VersionCrc is the CRC of this module.
43         VersionCrc = 0x80424562
44 )
45
46 // AddressFamily represents VPP binary API enum 'address_family'.
47 type AddressFamily uint32
48
49 const (
50         ADDRESS_IP4 AddressFamily = 0
51         ADDRESS_IP6 AddressFamily = 1
52 )
53
54 var (
55         AddressFamily_name = map[uint32]string{
56                 0: "ADDRESS_IP4",
57                 1: "ADDRESS_IP6",
58         }
59         AddressFamily_value = map[string]uint32{
60                 "ADDRESS_IP4": 0,
61                 "ADDRESS_IP6": 1,
62         }
63 )
64
65 func (x AddressFamily) String() string {
66         s, ok := AddressFamily_name[uint32(x)]
67         if ok {
68                 return s
69         }
70         return "AddressFamily(" + strconv.Itoa(int(x)) + ")"
71 }
72
73 // IPDscp represents VPP binary API enum 'ip_dscp'.
74 type IPDscp uint8
75
76 const (
77         IP_API_DSCP_CS0  IPDscp = 0
78         IP_API_DSCP_CS1  IPDscp = 8
79         IP_API_DSCP_AF11 IPDscp = 10
80         IP_API_DSCP_AF12 IPDscp = 12
81         IP_API_DSCP_AF13 IPDscp = 14
82         IP_API_DSCP_CS2  IPDscp = 16
83         IP_API_DSCP_AF21 IPDscp = 18
84         IP_API_DSCP_AF22 IPDscp = 20
85         IP_API_DSCP_AF23 IPDscp = 22
86         IP_API_DSCP_CS3  IPDscp = 24
87         IP_API_DSCP_AF31 IPDscp = 26
88         IP_API_DSCP_AF32 IPDscp = 28
89         IP_API_DSCP_AF33 IPDscp = 30
90         IP_API_DSCP_CS4  IPDscp = 32
91         IP_API_DSCP_AF41 IPDscp = 34
92         IP_API_DSCP_AF42 IPDscp = 36
93         IP_API_DSCP_AF43 IPDscp = 38
94         IP_API_DSCP_CS5  IPDscp = 40
95         IP_API_DSCP_EF   IPDscp = 46
96         IP_API_DSCP_CS6  IPDscp = 48
97         IP_API_DSCP_CS7  IPDscp = 50
98 )
99
100 var (
101         IPDscp_name = map[uint8]string{
102                 0:  "IP_API_DSCP_CS0",
103                 8:  "IP_API_DSCP_CS1",
104                 10: "IP_API_DSCP_AF11",
105                 12: "IP_API_DSCP_AF12",
106                 14: "IP_API_DSCP_AF13",
107                 16: "IP_API_DSCP_CS2",
108                 18: "IP_API_DSCP_AF21",
109                 20: "IP_API_DSCP_AF22",
110                 22: "IP_API_DSCP_AF23",
111                 24: "IP_API_DSCP_CS3",
112                 26: "IP_API_DSCP_AF31",
113                 28: "IP_API_DSCP_AF32",
114                 30: "IP_API_DSCP_AF33",
115                 32: "IP_API_DSCP_CS4",
116                 34: "IP_API_DSCP_AF41",
117                 36: "IP_API_DSCP_AF42",
118                 38: "IP_API_DSCP_AF43",
119                 40: "IP_API_DSCP_CS5",
120                 46: "IP_API_DSCP_EF",
121                 48: "IP_API_DSCP_CS6",
122                 50: "IP_API_DSCP_CS7",
123         }
124         IPDscp_value = map[string]uint8{
125                 "IP_API_DSCP_CS0":  0,
126                 "IP_API_DSCP_CS1":  8,
127                 "IP_API_DSCP_AF11": 10,
128                 "IP_API_DSCP_AF12": 12,
129                 "IP_API_DSCP_AF13": 14,
130                 "IP_API_DSCP_CS2":  16,
131                 "IP_API_DSCP_AF21": 18,
132                 "IP_API_DSCP_AF22": 20,
133                 "IP_API_DSCP_AF23": 22,
134                 "IP_API_DSCP_CS3":  24,
135                 "IP_API_DSCP_AF31": 26,
136                 "IP_API_DSCP_AF32": 28,
137                 "IP_API_DSCP_AF33": 30,
138                 "IP_API_DSCP_CS4":  32,
139                 "IP_API_DSCP_AF41": 34,
140                 "IP_API_DSCP_AF42": 36,
141                 "IP_API_DSCP_AF43": 38,
142                 "IP_API_DSCP_CS5":  40,
143                 "IP_API_DSCP_EF":   46,
144                 "IP_API_DSCP_CS6":  48,
145                 "IP_API_DSCP_CS7":  50,
146         }
147 )
148
149 func (x IPDscp) String() string {
150         s, ok := IPDscp_name[uint8(x)]
151         if ok {
152                 return s
153         }
154         return "IPDscp(" + strconv.Itoa(int(x)) + ")"
155 }
156
157 // IPEcn represents VPP binary API enum 'ip_ecn'.
158 type IPEcn uint8
159
160 const (
161         IP_API_ECN_NONE IPEcn = 0
162         IP_API_ECN_ECT0 IPEcn = 1
163         IP_API_ECN_ECT1 IPEcn = 2
164         IP_API_ECN_CE   IPEcn = 3
165 )
166
167 var (
168         IPEcn_name = map[uint8]string{
169                 0: "IP_API_ECN_NONE",
170                 1: "IP_API_ECN_ECT0",
171                 2: "IP_API_ECN_ECT1",
172                 3: "IP_API_ECN_CE",
173         }
174         IPEcn_value = map[string]uint8{
175                 "IP_API_ECN_NONE": 0,
176                 "IP_API_ECN_ECT0": 1,
177                 "IP_API_ECN_ECT1": 2,
178                 "IP_API_ECN_CE":   3,
179         }
180 )
181
182 func (x IPEcn) String() string {
183         s, ok := IPEcn_name[uint8(x)]
184         if ok {
185                 return s
186         }
187         return "IPEcn(" + strconv.Itoa(int(x)) + ")"
188 }
189
190 // IPProto represents VPP binary API enum 'ip_proto'.
191 type IPProto uint32
192
193 const (
194         IP_API_PROTO_HOPOPT   IPProto = 0
195         IP_API_PROTO_ICMP     IPProto = 1
196         IP_API_PROTO_IGMP     IPProto = 2
197         IP_API_PROTO_TCP      IPProto = 6
198         IP_API_PROTO_UDP      IPProto = 17
199         IP_API_PROTO_GRE      IPProto = 47
200         IP_API_PROTO_AH       IPProto = 50
201         IP_API_PROTO_ESP      IPProto = 51
202         IP_API_PROTO_EIGRP    IPProto = 88
203         IP_API_PROTO_OSPF     IPProto = 89
204         IP_API_PROTO_SCTP     IPProto = 132
205         IP_API_PROTO_RESERVED IPProto = 255
206 )
207
208 var (
209         IPProto_name = map[uint32]string{
210                 0:   "IP_API_PROTO_HOPOPT",
211                 1:   "IP_API_PROTO_ICMP",
212                 2:   "IP_API_PROTO_IGMP",
213                 6:   "IP_API_PROTO_TCP",
214                 17:  "IP_API_PROTO_UDP",
215                 47:  "IP_API_PROTO_GRE",
216                 50:  "IP_API_PROTO_AH",
217                 51:  "IP_API_PROTO_ESP",
218                 88:  "IP_API_PROTO_EIGRP",
219                 89:  "IP_API_PROTO_OSPF",
220                 132: "IP_API_PROTO_SCTP",
221                 255: "IP_API_PROTO_RESERVED",
222         }
223         IPProto_value = map[string]uint32{
224                 "IP_API_PROTO_HOPOPT":   0,
225                 "IP_API_PROTO_ICMP":     1,
226                 "IP_API_PROTO_IGMP":     2,
227                 "IP_API_PROTO_TCP":      6,
228                 "IP_API_PROTO_UDP":      17,
229                 "IP_API_PROTO_GRE":      47,
230                 "IP_API_PROTO_AH":       50,
231                 "IP_API_PROTO_ESP":      51,
232                 "IP_API_PROTO_EIGRP":    88,
233                 "IP_API_PROTO_OSPF":     89,
234                 "IP_API_PROTO_SCTP":     132,
235                 "IP_API_PROTO_RESERVED": 255,
236         }
237 )
238
239 func (x IPProto) String() string {
240         s, ok := IPProto_name[uint32(x)]
241         if ok {
242                 return s
243         }
244         return "IPProto(" + strconv.Itoa(int(x)) + ")"
245 }
246
247 // AddressWithPrefix represents VPP binary API alias 'address_with_prefix'.
248 type AddressWithPrefix Prefix
249
250 // IP4Address represents VPP binary API alias 'ip4_address'.
251 type IP4Address [4]uint8
252
253 // IP4AddressWithPrefix represents VPP binary API alias 'ip4_address_with_prefix'.
254 type IP4AddressWithPrefix IP4Prefix
255
256 // IP6Address represents VPP binary API alias 'ip6_address'.
257 type IP6Address [16]uint8
258
259 // IP6AddressWithPrefix represents VPP binary API alias 'ip6_address_with_prefix'.
260 type IP6AddressWithPrefix IP6Prefix
261
262 // Address represents VPP binary API type 'address'.
263 type Address struct {
264         Af AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"`
265         Un AddressUnion  `binapi:"address_union,name=un" json:"un,omitempty"`
266 }
267
268 func (*Address) GetTypeName() string { return "address" }
269
270 // IP4Prefix represents VPP binary API type 'ip4_prefix'.
271 type IP4Prefix struct {
272         Address IP4Address `binapi:"ip4_address,name=address" json:"address,omitempty"`
273         Len     uint8      `binapi:"u8,name=len" json:"len,omitempty"`
274 }
275
276 func (*IP4Prefix) GetTypeName() string { return "ip4_prefix" }
277
278 // IP6Prefix represents VPP binary API type 'ip6_prefix'.
279 type IP6Prefix struct {
280         Address IP6Address `binapi:"ip6_address,name=address" json:"address,omitempty"`
281         Len     uint8      `binapi:"u8,name=len" json:"len,omitempty"`
282 }
283
284 func (*IP6Prefix) GetTypeName() string { return "ip6_prefix" }
285
286 // Mprefix represents VPP binary API type 'mprefix'.
287 type Mprefix struct {
288         Af               AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"`
289         GrpAddressLength uint16        `binapi:"u16,name=grp_address_length" json:"grp_address_length,omitempty"`
290         GrpAddress       AddressUnion  `binapi:"address_union,name=grp_address" json:"grp_address,omitempty"`
291         SrcAddress       AddressUnion  `binapi:"address_union,name=src_address" json:"src_address,omitempty"`
292 }
293
294 func (*Mprefix) GetTypeName() string { return "mprefix" }
295
296 // Prefix represents VPP binary API type 'prefix'.
297 type Prefix struct {
298         Address Address `binapi:"address,name=address" json:"address,omitempty"`
299         Len     uint8   `binapi:"u8,name=len" json:"len,omitempty"`
300 }
301
302 func (*Prefix) GetTypeName() string { return "prefix" }
303
304 // PrefixMatcher represents VPP binary API type 'prefix_matcher'.
305 type PrefixMatcher struct {
306         Le uint8 `binapi:"u8,name=le" json:"le,omitempty"`
307         Ge uint8 `binapi:"u8,name=ge" json:"ge,omitempty"`
308 }
309
310 func (*PrefixMatcher) GetTypeName() string { return "prefix_matcher" }
311
312 // AddressUnion represents VPP binary API union 'address_union'.
313 type AddressUnion struct {
314         XXX_UnionData [16]byte
315 }
316
317 func (*AddressUnion) GetTypeName() string { return "address_union" }
318
319 func AddressUnionIP4(a IP4Address) (u AddressUnion) {
320         u.SetIP4(a)
321         return
322 }
323 func (u *AddressUnion) SetIP4(a IP4Address) {
324         var b = new(bytes.Buffer)
325         if err := struc.Pack(b, &a); err != nil {
326                 return
327         }
328         copy(u.XXX_UnionData[:], b.Bytes())
329 }
330 func (u *AddressUnion) GetIP4() (a IP4Address) {
331         var b = bytes.NewReader(u.XXX_UnionData[:])
332         struc.Unpack(b, &a)
333         return
334 }
335
336 func AddressUnionIP6(a IP6Address) (u AddressUnion) {
337         u.SetIP6(a)
338         return
339 }
340 func (u *AddressUnion) SetIP6(a IP6Address) {
341         var b = new(bytes.Buffer)
342         if err := struc.Pack(b, &a); err != nil {
343                 return
344         }
345         copy(u.XXX_UnionData[:], b.Bytes())
346 }
347 func (u *AddressUnion) GetIP6() (a IP6Address) {
348         var b = bytes.NewReader(u.XXX_UnionData[:])
349         struc.Unpack(b, &a)
350         return
351 }
352
353 // Reference imports to suppress errors if they are not otherwise used.
354 var _ = api.RegisterMessage
355 var _ = codec.DecodeString
356 var _ = bytes.NewBuffer
357 var _ = context.Background
358 var _ = io.Copy
359 var _ = strconv.Itoa
360 var _ = struc.Pack
361 var _ = binary.BigEndian
362 var _ = math.Float32bits