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