Refactored binapi generator with message encoding
[govpp.git] / examples / binapi / fib_types / fib_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/fib_types.api.json
6
7 /*
8 Package fib_types contains generated code for VPP binary API defined by fib_types.api (version 2.0.0).
9
10 It consists of:
11           5 aliases
12           7 enums
13           9 types
14           1 union
15 */
16 package fib_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 = "fib_types"
40         // APIVersion is the API version of this module.
41         APIVersion = "2.0.0"
42         // VersionCrc is the CRC of this module.
43         VersionCrc = 0x57387845
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 // FibPathFlags represents VPP binary API enum 'fib_path_flags'.
74 type FibPathFlags uint32
75
76 const (
77         FIB_API_PATH_FLAG_NONE                 FibPathFlags = 0
78         FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED FibPathFlags = 1
79         FIB_API_PATH_FLAG_RESOLVE_VIA_HOST     FibPathFlags = 2
80         FIB_API_PATH_FLAG_POP_PW_CW            FibPathFlags = 4
81 )
82
83 var (
84         FibPathFlags_name = map[uint32]string{
85                 0: "FIB_API_PATH_FLAG_NONE",
86                 1: "FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED",
87                 2: "FIB_API_PATH_FLAG_RESOLVE_VIA_HOST",
88                 4: "FIB_API_PATH_FLAG_POP_PW_CW",
89         }
90         FibPathFlags_value = map[string]uint32{
91                 "FIB_API_PATH_FLAG_NONE":                 0,
92                 "FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED": 1,
93                 "FIB_API_PATH_FLAG_RESOLVE_VIA_HOST":     2,
94                 "FIB_API_PATH_FLAG_POP_PW_CW":            4,
95         }
96 )
97
98 func (x FibPathFlags) String() string {
99         s, ok := FibPathFlags_name[uint32(x)]
100         if ok {
101                 return s
102         }
103         return "FibPathFlags(" + strconv.Itoa(int(x)) + ")"
104 }
105
106 // FibPathNhProto represents VPP binary API enum 'fib_path_nh_proto'.
107 type FibPathNhProto uint32
108
109 const (
110         FIB_API_PATH_NH_PROTO_IP4      FibPathNhProto = 0
111         FIB_API_PATH_NH_PROTO_IP6      FibPathNhProto = 1
112         FIB_API_PATH_NH_PROTO_MPLS     FibPathNhProto = 2
113         FIB_API_PATH_NH_PROTO_ETHERNET FibPathNhProto = 3
114         FIB_API_PATH_NH_PROTO_BIER     FibPathNhProto = 4
115 )
116
117 var (
118         FibPathNhProto_name = map[uint32]string{
119                 0: "FIB_API_PATH_NH_PROTO_IP4",
120                 1: "FIB_API_PATH_NH_PROTO_IP6",
121                 2: "FIB_API_PATH_NH_PROTO_MPLS",
122                 3: "FIB_API_PATH_NH_PROTO_ETHERNET",
123                 4: "FIB_API_PATH_NH_PROTO_BIER",
124         }
125         FibPathNhProto_value = map[string]uint32{
126                 "FIB_API_PATH_NH_PROTO_IP4":      0,
127                 "FIB_API_PATH_NH_PROTO_IP6":      1,
128                 "FIB_API_PATH_NH_PROTO_MPLS":     2,
129                 "FIB_API_PATH_NH_PROTO_ETHERNET": 3,
130                 "FIB_API_PATH_NH_PROTO_BIER":     4,
131         }
132 )
133
134 func (x FibPathNhProto) String() string {
135         s, ok := FibPathNhProto_name[uint32(x)]
136         if ok {
137                 return s
138         }
139         return "FibPathNhProto(" + strconv.Itoa(int(x)) + ")"
140 }
141
142 // FibPathType represents VPP binary API enum 'fib_path_type'.
143 type FibPathType uint32
144
145 const (
146         FIB_API_PATH_TYPE_NORMAL        FibPathType = 0
147         FIB_API_PATH_TYPE_LOCAL         FibPathType = 1
148         FIB_API_PATH_TYPE_DROP          FibPathType = 2
149         FIB_API_PATH_TYPE_UDP_ENCAP     FibPathType = 3
150         FIB_API_PATH_TYPE_BIER_IMP      FibPathType = 4
151         FIB_API_PATH_TYPE_ICMP_UNREACH  FibPathType = 5
152         FIB_API_PATH_TYPE_ICMP_PROHIBIT FibPathType = 6
153         FIB_API_PATH_TYPE_SOURCE_LOOKUP FibPathType = 7
154         FIB_API_PATH_TYPE_DVR           FibPathType = 8
155         FIB_API_PATH_TYPE_INTERFACE_RX  FibPathType = 9
156         FIB_API_PATH_TYPE_CLASSIFY      FibPathType = 10
157 )
158
159 var (
160         FibPathType_name = map[uint32]string{
161                 0:  "FIB_API_PATH_TYPE_NORMAL",
162                 1:  "FIB_API_PATH_TYPE_LOCAL",
163                 2:  "FIB_API_PATH_TYPE_DROP",
164                 3:  "FIB_API_PATH_TYPE_UDP_ENCAP",
165                 4:  "FIB_API_PATH_TYPE_BIER_IMP",
166                 5:  "FIB_API_PATH_TYPE_ICMP_UNREACH",
167                 6:  "FIB_API_PATH_TYPE_ICMP_PROHIBIT",
168                 7:  "FIB_API_PATH_TYPE_SOURCE_LOOKUP",
169                 8:  "FIB_API_PATH_TYPE_DVR",
170                 9:  "FIB_API_PATH_TYPE_INTERFACE_RX",
171                 10: "FIB_API_PATH_TYPE_CLASSIFY",
172         }
173         FibPathType_value = map[string]uint32{
174                 "FIB_API_PATH_TYPE_NORMAL":        0,
175                 "FIB_API_PATH_TYPE_LOCAL":         1,
176                 "FIB_API_PATH_TYPE_DROP":          2,
177                 "FIB_API_PATH_TYPE_UDP_ENCAP":     3,
178                 "FIB_API_PATH_TYPE_BIER_IMP":      4,
179                 "FIB_API_PATH_TYPE_ICMP_UNREACH":  5,
180                 "FIB_API_PATH_TYPE_ICMP_PROHIBIT": 6,
181                 "FIB_API_PATH_TYPE_SOURCE_LOOKUP": 7,
182                 "FIB_API_PATH_TYPE_DVR":           8,
183                 "FIB_API_PATH_TYPE_INTERFACE_RX":  9,
184                 "FIB_API_PATH_TYPE_CLASSIFY":      10,
185         }
186 )
187
188 func (x FibPathType) String() string {
189         s, ok := FibPathType_name[uint32(x)]
190         if ok {
191                 return s
192         }
193         return "FibPathType(" + strconv.Itoa(int(x)) + ")"
194 }
195
196 // IPDscp represents VPP binary API enum 'ip_dscp'.
197 type IPDscp uint8
198
199 const (
200         IP_API_DSCP_CS0  IPDscp = 0
201         IP_API_DSCP_CS1  IPDscp = 8
202         IP_API_DSCP_AF11 IPDscp = 10
203         IP_API_DSCP_AF12 IPDscp = 12
204         IP_API_DSCP_AF13 IPDscp = 14
205         IP_API_DSCP_CS2  IPDscp = 16
206         IP_API_DSCP_AF21 IPDscp = 18
207         IP_API_DSCP_AF22 IPDscp = 20
208         IP_API_DSCP_AF23 IPDscp = 22
209         IP_API_DSCP_CS3  IPDscp = 24
210         IP_API_DSCP_AF31 IPDscp = 26
211         IP_API_DSCP_AF32 IPDscp = 28
212         IP_API_DSCP_AF33 IPDscp = 30
213         IP_API_DSCP_CS4  IPDscp = 32
214         IP_API_DSCP_AF41 IPDscp = 34
215         IP_API_DSCP_AF42 IPDscp = 36
216         IP_API_DSCP_AF43 IPDscp = 38
217         IP_API_DSCP_CS5  IPDscp = 40
218         IP_API_DSCP_EF   IPDscp = 46
219         IP_API_DSCP_CS6  IPDscp = 48
220         IP_API_DSCP_CS7  IPDscp = 50
221 )
222
223 var (
224         IPDscp_name = map[uint8]string{
225                 0:  "IP_API_DSCP_CS0",
226                 8:  "IP_API_DSCP_CS1",
227                 10: "IP_API_DSCP_AF11",
228                 12: "IP_API_DSCP_AF12",
229                 14: "IP_API_DSCP_AF13",
230                 16: "IP_API_DSCP_CS2",
231                 18: "IP_API_DSCP_AF21",
232                 20: "IP_API_DSCP_AF22",
233                 22: "IP_API_DSCP_AF23",
234                 24: "IP_API_DSCP_CS3",
235                 26: "IP_API_DSCP_AF31",
236                 28: "IP_API_DSCP_AF32",
237                 30: "IP_API_DSCP_AF33",
238                 32: "IP_API_DSCP_CS4",
239                 34: "IP_API_DSCP_AF41",
240                 36: "IP_API_DSCP_AF42",
241                 38: "IP_API_DSCP_AF43",
242                 40: "IP_API_DSCP_CS5",
243                 46: "IP_API_DSCP_EF",
244                 48: "IP_API_DSCP_CS6",
245                 50: "IP_API_DSCP_CS7",
246         }
247         IPDscp_value = map[string]uint8{
248                 "IP_API_DSCP_CS0":  0,
249                 "IP_API_DSCP_CS1":  8,
250                 "IP_API_DSCP_AF11": 10,
251                 "IP_API_DSCP_AF12": 12,
252                 "IP_API_DSCP_AF13": 14,
253                 "IP_API_DSCP_CS2":  16,
254                 "IP_API_DSCP_AF21": 18,
255                 "IP_API_DSCP_AF22": 20,
256                 "IP_API_DSCP_AF23": 22,
257                 "IP_API_DSCP_CS3":  24,
258                 "IP_API_DSCP_AF31": 26,
259                 "IP_API_DSCP_AF32": 28,
260                 "IP_API_DSCP_AF33": 30,
261                 "IP_API_DSCP_CS4":  32,
262                 "IP_API_DSCP_AF41": 34,
263                 "IP_API_DSCP_AF42": 36,
264                 "IP_API_DSCP_AF43": 38,
265                 "IP_API_DSCP_CS5":  40,
266                 "IP_API_DSCP_EF":   46,
267                 "IP_API_DSCP_CS6":  48,
268                 "IP_API_DSCP_CS7":  50,
269         }
270 )
271
272 func (x IPDscp) String() string {
273         s, ok := IPDscp_name[uint8(x)]
274         if ok {
275                 return s
276         }
277         return "IPDscp(" + strconv.Itoa(int(x)) + ")"
278 }
279
280 // IPEcn represents VPP binary API enum 'ip_ecn'.
281 type IPEcn uint8
282
283 const (
284         IP_API_ECN_NONE IPEcn = 0
285         IP_API_ECN_ECT0 IPEcn = 1
286         IP_API_ECN_ECT1 IPEcn = 2
287         IP_API_ECN_CE   IPEcn = 3
288 )
289
290 var (
291         IPEcn_name = map[uint8]string{
292                 0: "IP_API_ECN_NONE",
293                 1: "IP_API_ECN_ECT0",
294                 2: "IP_API_ECN_ECT1",
295                 3: "IP_API_ECN_CE",
296         }
297         IPEcn_value = map[string]uint8{
298                 "IP_API_ECN_NONE": 0,
299                 "IP_API_ECN_ECT0": 1,
300                 "IP_API_ECN_ECT1": 2,
301                 "IP_API_ECN_CE":   3,
302         }
303 )
304
305 func (x IPEcn) String() string {
306         s, ok := IPEcn_name[uint8(x)]
307         if ok {
308                 return s
309         }
310         return "IPEcn(" + strconv.Itoa(int(x)) + ")"
311 }
312
313 // IPProto represents VPP binary API enum 'ip_proto'.
314 type IPProto uint32
315
316 const (
317         IP_API_PROTO_HOPOPT   IPProto = 0
318         IP_API_PROTO_ICMP     IPProto = 1
319         IP_API_PROTO_IGMP     IPProto = 2
320         IP_API_PROTO_TCP      IPProto = 6
321         IP_API_PROTO_UDP      IPProto = 17
322         IP_API_PROTO_GRE      IPProto = 47
323         IP_API_PROTO_AH       IPProto = 50
324         IP_API_PROTO_ESP      IPProto = 51
325         IP_API_PROTO_EIGRP    IPProto = 88
326         IP_API_PROTO_OSPF     IPProto = 89
327         IP_API_PROTO_SCTP     IPProto = 132
328         IP_API_PROTO_RESERVED IPProto = 255
329 )
330
331 var (
332         IPProto_name = map[uint32]string{
333                 0:   "IP_API_PROTO_HOPOPT",
334                 1:   "IP_API_PROTO_ICMP",
335                 2:   "IP_API_PROTO_IGMP",
336                 6:   "IP_API_PROTO_TCP",
337                 17:  "IP_API_PROTO_UDP",
338                 47:  "IP_API_PROTO_GRE",
339                 50:  "IP_API_PROTO_AH",
340                 51:  "IP_API_PROTO_ESP",
341                 88:  "IP_API_PROTO_EIGRP",
342                 89:  "IP_API_PROTO_OSPF",
343                 132: "IP_API_PROTO_SCTP",
344                 255: "IP_API_PROTO_RESERVED",
345         }
346         IPProto_value = map[string]uint32{
347                 "IP_API_PROTO_HOPOPT":   0,
348                 "IP_API_PROTO_ICMP":     1,
349                 "IP_API_PROTO_IGMP":     2,
350                 "IP_API_PROTO_TCP":      6,
351                 "IP_API_PROTO_UDP":      17,
352                 "IP_API_PROTO_GRE":      47,
353                 "IP_API_PROTO_AH":       50,
354                 "IP_API_PROTO_ESP":      51,
355                 "IP_API_PROTO_EIGRP":    88,
356                 "IP_API_PROTO_OSPF":     89,
357                 "IP_API_PROTO_SCTP":     132,
358                 "IP_API_PROTO_RESERVED": 255,
359         }
360 )
361
362 func (x IPProto) String() string {
363         s, ok := IPProto_name[uint32(x)]
364         if ok {
365                 return s
366         }
367         return "IPProto(" + strconv.Itoa(int(x)) + ")"
368 }
369
370 // AddressWithPrefix represents VPP binary API alias 'address_with_prefix'.
371 type AddressWithPrefix Prefix
372
373 // IP4Address represents VPP binary API alias 'ip4_address'.
374 type IP4Address [4]uint8
375
376 // IP4AddressWithPrefix represents VPP binary API alias 'ip4_address_with_prefix'.
377 type IP4AddressWithPrefix IP4Prefix
378
379 // IP6Address represents VPP binary API alias 'ip6_address'.
380 type IP6Address [16]uint8
381
382 // IP6AddressWithPrefix represents VPP binary API alias 'ip6_address_with_prefix'.
383 type IP6AddressWithPrefix IP6Prefix
384
385 // Address represents VPP binary API type 'address'.
386 type Address struct {
387         Af AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"`
388         Un AddressUnion  `binapi:"address_union,name=un" json:"un,omitempty"`
389 }
390
391 func (*Address) GetTypeName() string { return "address" }
392
393 // FibMplsLabel represents VPP binary API type 'fib_mpls_label'.
394 type FibMplsLabel struct {
395         IsUniform uint8  `binapi:"u8,name=is_uniform" json:"is_uniform,omitempty"`
396         Label     uint32 `binapi:"u32,name=label" json:"label,omitempty"`
397         TTL       uint8  `binapi:"u8,name=ttl" json:"ttl,omitempty"`
398         Exp       uint8  `binapi:"u8,name=exp" json:"exp,omitempty"`
399 }
400
401 func (*FibMplsLabel) GetTypeName() string { return "fib_mpls_label" }
402
403 // FibPath represents VPP binary API type 'fib_path'.
404 type FibPath struct {
405         SwIfIndex  uint32           `binapi:"u32,name=sw_if_index" json:"sw_if_index,omitempty"`
406         TableID    uint32           `binapi:"u32,name=table_id" json:"table_id,omitempty"`
407         RpfID      uint32           `binapi:"u32,name=rpf_id" json:"rpf_id,omitempty"`
408         Weight     uint8            `binapi:"u8,name=weight" json:"weight,omitempty"`
409         Preference uint8            `binapi:"u8,name=preference" json:"preference,omitempty"`
410         Type       FibPathType      `binapi:"fib_path_type,name=type" json:"type,omitempty"`
411         Flags      FibPathFlags     `binapi:"fib_path_flags,name=flags" json:"flags,omitempty"`
412         Proto      FibPathNhProto   `binapi:"fib_path_nh_proto,name=proto" json:"proto,omitempty"`
413         Nh         FibPathNh        `binapi:"fib_path_nh,name=nh" json:"nh,omitempty"`
414         NLabels    uint8            `binapi:"u8,name=n_labels" json:"n_labels,omitempty"`
415         LabelStack [16]FibMplsLabel `binapi:"fib_mpls_label[16],name=label_stack" json:"label_stack,omitempty" struc:"[16]FibMplsLabel"`
416 }
417
418 func (*FibPath) GetTypeName() string { return "fib_path" }
419
420 // FibPathNh represents VPP binary API type 'fib_path_nh'.
421 type FibPathNh struct {
422         Address            AddressUnion `binapi:"address_union,name=address" json:"address,omitempty"`
423         ViaLabel           uint32       `binapi:"u32,name=via_label" json:"via_label,omitempty"`
424         ObjID              uint32       `binapi:"u32,name=obj_id" json:"obj_id,omitempty"`
425         ClassifyTableIndex uint32       `binapi:"u32,name=classify_table_index" json:"classify_table_index,omitempty"`
426 }
427
428 func (*FibPathNh) GetTypeName() string { return "fib_path_nh" }
429
430 // IP4Prefix represents VPP binary API type 'ip4_prefix'.
431 type IP4Prefix struct {
432         Address IP4Address `binapi:"ip4_address,name=address" json:"address,omitempty"`
433         Len     uint8      `binapi:"u8,name=len" json:"len,omitempty"`
434 }
435
436 func (*IP4Prefix) GetTypeName() string { return "ip4_prefix" }
437
438 // IP6Prefix represents VPP binary API type 'ip6_prefix'.
439 type IP6Prefix struct {
440         Address IP6Address `binapi:"ip6_address,name=address" json:"address,omitempty"`
441         Len     uint8      `binapi:"u8,name=len" json:"len,omitempty"`
442 }
443
444 func (*IP6Prefix) GetTypeName() string { return "ip6_prefix" }
445
446 // Mprefix represents VPP binary API type 'mprefix'.
447 type Mprefix struct {
448         Af               AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"`
449         GrpAddressLength uint16        `binapi:"u16,name=grp_address_length" json:"grp_address_length,omitempty"`
450         GrpAddress       AddressUnion  `binapi:"address_union,name=grp_address" json:"grp_address,omitempty"`
451         SrcAddress       AddressUnion  `binapi:"address_union,name=src_address" json:"src_address,omitempty"`
452 }
453
454 func (*Mprefix) GetTypeName() string { return "mprefix" }
455
456 // Prefix represents VPP binary API type 'prefix'.
457 type Prefix struct {
458         Address Address `binapi:"address,name=address" json:"address,omitempty"`
459         Len     uint8   `binapi:"u8,name=len" json:"len,omitempty"`
460 }
461
462 func (*Prefix) GetTypeName() string { return "prefix" }
463
464 // PrefixMatcher represents VPP binary API type 'prefix_matcher'.
465 type PrefixMatcher struct {
466         Le uint8 `binapi:"u8,name=le" json:"le,omitempty"`
467         Ge uint8 `binapi:"u8,name=ge" json:"ge,omitempty"`
468 }
469
470 func (*PrefixMatcher) GetTypeName() string { return "prefix_matcher" }
471
472 // AddressUnion represents VPP binary API union 'address_union'.
473 type AddressUnion struct {
474         XXX_UnionData [16]byte
475 }
476
477 func (*AddressUnion) GetTypeName() string { return "address_union" }
478
479 func AddressUnionIP4(a IP4Address) (u AddressUnion) {
480         u.SetIP4(a)
481         return
482 }
483 func (u *AddressUnion) SetIP4(a IP4Address) {
484         var b = new(bytes.Buffer)
485         if err := struc.Pack(b, &a); err != nil {
486                 return
487         }
488         copy(u.XXX_UnionData[:], b.Bytes())
489 }
490 func (u *AddressUnion) GetIP4() (a IP4Address) {
491         var b = bytes.NewReader(u.XXX_UnionData[:])
492         struc.Unpack(b, &a)
493         return
494 }
495
496 func AddressUnionIP6(a IP6Address) (u AddressUnion) {
497         u.SetIP6(a)
498         return
499 }
500 func (u *AddressUnion) SetIP6(a IP6Address) {
501         var b = new(bytes.Buffer)
502         if err := struc.Pack(b, &a); err != nil {
503                 return
504         }
505         copy(u.XXX_UnionData[:], b.Bytes())
506 }
507 func (u *AddressUnion) GetIP6() (a IP6Address) {
508         var b = bytes.NewReader(u.XXX_UnionData[:])
509         struc.Unpack(b, &a)
510         return
511 }
512
513 // Reference imports to suppress errors if they are not otherwise used.
514 var _ = api.RegisterMessage
515 var _ = codec.DecodeString
516 var _ = bytes.NewBuffer
517 var _ = context.Background
518 var _ = io.Copy
519 var _ = strconv.Itoa
520 var _ = struc.Pack
521 var _ = binary.BigEndian
522 var _ = math.Float32bits