binapigen: fix union size
[govpp.git] / binapi / udp / udp.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/udp.api.json
6
7 // Package udp contains generated bindings for API file udp.api.
8 //
9 // Contents:
10 //   1 struct
11 //   6 messages
12 //
13 package udp
14
15 import (
16         api "git.fd.io/govpp.git/api"
17         ip_types "git.fd.io/govpp.git/binapi/ip_types"
18         codec "git.fd.io/govpp.git/codec"
19 )
20
21 // This is a compile-time assertion to ensure that this generated file
22 // is compatible with the GoVPP api package it is being compiled against.
23 // A compilation error at this line likely means your copy of the
24 // GoVPP api package needs to be updated.
25 const _ = api.GoVppAPIPackageIsVersion2
26
27 const (
28         APIFile    = "udp"
29         APIVersion = "1.1.0"
30         VersionCrc = 0xb827bf4f
31 )
32
33 // UDPEncap defines type 'udp_encap'.
34 type UDPEncap struct {
35         TableID uint32           `binapi:"u32,name=table_id" json:"table_id,omitempty"`
36         SrcPort uint16           `binapi:"u16,name=src_port" json:"src_port,omitempty"`
37         DstPort uint16           `binapi:"u16,name=dst_port" json:"dst_port,omitempty"`
38         SrcIP   ip_types.Address `binapi:"address,name=src_ip" json:"src_ip,omitempty"`
39         DstIP   ip_types.Address `binapi:"address,name=dst_ip" json:"dst_ip,omitempty"`
40         ID      uint32           `binapi:"u32,name=id" json:"id,omitempty"`
41 }
42
43 // UDPEncapAdd defines message 'udp_encap_add'.
44 type UDPEncapAdd struct {
45         UDPEncap UDPEncap `binapi:"udp_encap,name=udp_encap" json:"udp_encap,omitempty"`
46 }
47
48 func (m *UDPEncapAdd) Reset()               { *m = UDPEncapAdd{} }
49 func (*UDPEncapAdd) GetMessageName() string { return "udp_encap_add" }
50 func (*UDPEncapAdd) GetCrcString() string   { return "61d5fc48" }
51 func (*UDPEncapAdd) GetMessageType() api.MessageType {
52         return api.RequestMessage
53 }
54
55 func (m *UDPEncapAdd) Size() (size int) {
56         if m == nil {
57                 return 0
58         }
59         size += 4      // m.UDPEncap.TableID
60         size += 2      // m.UDPEncap.SrcPort
61         size += 2      // m.UDPEncap.DstPort
62         size += 1      // m.UDPEncap.SrcIP.Af
63         size += 1 * 16 // m.UDPEncap.SrcIP.Un
64         size += 1      // m.UDPEncap.DstIP.Af
65         size += 1 * 16 // m.UDPEncap.DstIP.Un
66         size += 4      // m.UDPEncap.ID
67         return size
68 }
69 func (m *UDPEncapAdd) Marshal(b []byte) ([]byte, error) {
70         if b == nil {
71                 b = make([]byte, m.Size())
72         }
73         buf := codec.NewBuffer(b)
74         buf.EncodeUint32(m.UDPEncap.TableID)
75         buf.EncodeUint16(m.UDPEncap.SrcPort)
76         buf.EncodeUint16(m.UDPEncap.DstPort)
77         buf.EncodeUint8(uint8(m.UDPEncap.SrcIP.Af))
78         buf.EncodeBytes(m.UDPEncap.SrcIP.Un.XXX_UnionData[:], 16)
79         buf.EncodeUint8(uint8(m.UDPEncap.DstIP.Af))
80         buf.EncodeBytes(m.UDPEncap.DstIP.Un.XXX_UnionData[:], 16)
81         buf.EncodeUint32(m.UDPEncap.ID)
82         return buf.Bytes(), nil
83 }
84 func (m *UDPEncapAdd) Unmarshal(b []byte) error {
85         buf := codec.NewBuffer(b)
86         m.UDPEncap.TableID = buf.DecodeUint32()
87         m.UDPEncap.SrcPort = buf.DecodeUint16()
88         m.UDPEncap.DstPort = buf.DecodeUint16()
89         m.UDPEncap.SrcIP.Af = ip_types.AddressFamily(buf.DecodeUint8())
90         copy(m.UDPEncap.SrcIP.Un.XXX_UnionData[:], buf.DecodeBytes(16))
91         m.UDPEncap.DstIP.Af = ip_types.AddressFamily(buf.DecodeUint8())
92         copy(m.UDPEncap.DstIP.Un.XXX_UnionData[:], buf.DecodeBytes(16))
93         m.UDPEncap.ID = buf.DecodeUint32()
94         return nil
95 }
96
97 // UDPEncapAddReply defines message 'udp_encap_add_reply'.
98 type UDPEncapAddReply struct {
99         Retval int32  `binapi:"i32,name=retval" json:"retval,omitempty"`
100         ID     uint32 `binapi:"u32,name=id" json:"id,omitempty"`
101 }
102
103 func (m *UDPEncapAddReply) Reset()               { *m = UDPEncapAddReply{} }
104 func (*UDPEncapAddReply) GetMessageName() string { return "udp_encap_add_reply" }
105 func (*UDPEncapAddReply) GetCrcString() string   { return "e2fc8294" }
106 func (*UDPEncapAddReply) GetMessageType() api.MessageType {
107         return api.ReplyMessage
108 }
109
110 func (m *UDPEncapAddReply) Size() (size int) {
111         if m == nil {
112                 return 0
113         }
114         size += 4 // m.Retval
115         size += 4 // m.ID
116         return size
117 }
118 func (m *UDPEncapAddReply) Marshal(b []byte) ([]byte, error) {
119         if b == nil {
120                 b = make([]byte, m.Size())
121         }
122         buf := codec.NewBuffer(b)
123         buf.EncodeInt32(m.Retval)
124         buf.EncodeUint32(m.ID)
125         return buf.Bytes(), nil
126 }
127 func (m *UDPEncapAddReply) Unmarshal(b []byte) error {
128         buf := codec.NewBuffer(b)
129         m.Retval = buf.DecodeInt32()
130         m.ID = buf.DecodeUint32()
131         return nil
132 }
133
134 // UDPEncapDel defines message 'udp_encap_del'.
135 type UDPEncapDel struct {
136         ID uint32 `binapi:"u32,name=id" json:"id,omitempty"`
137 }
138
139 func (m *UDPEncapDel) Reset()               { *m = UDPEncapDel{} }
140 func (*UDPEncapDel) GetMessageName() string { return "udp_encap_del" }
141 func (*UDPEncapDel) GetCrcString() string   { return "3a91bde5" }
142 func (*UDPEncapDel) GetMessageType() api.MessageType {
143         return api.RequestMessage
144 }
145
146 func (m *UDPEncapDel) Size() (size int) {
147         if m == nil {
148                 return 0
149         }
150         size += 4 // m.ID
151         return size
152 }
153 func (m *UDPEncapDel) Marshal(b []byte) ([]byte, error) {
154         if b == nil {
155                 b = make([]byte, m.Size())
156         }
157         buf := codec.NewBuffer(b)
158         buf.EncodeUint32(m.ID)
159         return buf.Bytes(), nil
160 }
161 func (m *UDPEncapDel) Unmarshal(b []byte) error {
162         buf := codec.NewBuffer(b)
163         m.ID = buf.DecodeUint32()
164         return nil
165 }
166
167 // UDPEncapDelReply defines message 'udp_encap_del_reply'.
168 type UDPEncapDelReply struct {
169         Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
170 }
171
172 func (m *UDPEncapDelReply) Reset()               { *m = UDPEncapDelReply{} }
173 func (*UDPEncapDelReply) GetMessageName() string { return "udp_encap_del_reply" }
174 func (*UDPEncapDelReply) GetCrcString() string   { return "e8d4e804" }
175 func (*UDPEncapDelReply) GetMessageType() api.MessageType {
176         return api.ReplyMessage
177 }
178
179 func (m *UDPEncapDelReply) Size() (size int) {
180         if m == nil {
181                 return 0
182         }
183         size += 4 // m.Retval
184         return size
185 }
186 func (m *UDPEncapDelReply) Marshal(b []byte) ([]byte, error) {
187         if b == nil {
188                 b = make([]byte, m.Size())
189         }
190         buf := codec.NewBuffer(b)
191         buf.EncodeInt32(m.Retval)
192         return buf.Bytes(), nil
193 }
194 func (m *UDPEncapDelReply) Unmarshal(b []byte) error {
195         buf := codec.NewBuffer(b)
196         m.Retval = buf.DecodeInt32()
197         return nil
198 }
199
200 // UDPEncapDetails defines message 'udp_encap_details'.
201 type UDPEncapDetails struct {
202         UDPEncap UDPEncap `binapi:"udp_encap,name=udp_encap" json:"udp_encap,omitempty"`
203 }
204
205 func (m *UDPEncapDetails) Reset()               { *m = UDPEncapDetails{} }
206 func (*UDPEncapDetails) GetMessageName() string { return "udp_encap_details" }
207 func (*UDPEncapDetails) GetCrcString() string   { return "87c82821" }
208 func (*UDPEncapDetails) GetMessageType() api.MessageType {
209         return api.ReplyMessage
210 }
211
212 func (m *UDPEncapDetails) Size() (size int) {
213         if m == nil {
214                 return 0
215         }
216         size += 4      // m.UDPEncap.TableID
217         size += 2      // m.UDPEncap.SrcPort
218         size += 2      // m.UDPEncap.DstPort
219         size += 1      // m.UDPEncap.SrcIP.Af
220         size += 1 * 16 // m.UDPEncap.SrcIP.Un
221         size += 1      // m.UDPEncap.DstIP.Af
222         size += 1 * 16 // m.UDPEncap.DstIP.Un
223         size += 4      // m.UDPEncap.ID
224         return size
225 }
226 func (m *UDPEncapDetails) Marshal(b []byte) ([]byte, error) {
227         if b == nil {
228                 b = make([]byte, m.Size())
229         }
230         buf := codec.NewBuffer(b)
231         buf.EncodeUint32(m.UDPEncap.TableID)
232         buf.EncodeUint16(m.UDPEncap.SrcPort)
233         buf.EncodeUint16(m.UDPEncap.DstPort)
234         buf.EncodeUint8(uint8(m.UDPEncap.SrcIP.Af))
235         buf.EncodeBytes(m.UDPEncap.SrcIP.Un.XXX_UnionData[:], 16)
236         buf.EncodeUint8(uint8(m.UDPEncap.DstIP.Af))
237         buf.EncodeBytes(m.UDPEncap.DstIP.Un.XXX_UnionData[:], 16)
238         buf.EncodeUint32(m.UDPEncap.ID)
239         return buf.Bytes(), nil
240 }
241 func (m *UDPEncapDetails) Unmarshal(b []byte) error {
242         buf := codec.NewBuffer(b)
243         m.UDPEncap.TableID = buf.DecodeUint32()
244         m.UDPEncap.SrcPort = buf.DecodeUint16()
245         m.UDPEncap.DstPort = buf.DecodeUint16()
246         m.UDPEncap.SrcIP.Af = ip_types.AddressFamily(buf.DecodeUint8())
247         copy(m.UDPEncap.SrcIP.Un.XXX_UnionData[:], buf.DecodeBytes(16))
248         m.UDPEncap.DstIP.Af = ip_types.AddressFamily(buf.DecodeUint8())
249         copy(m.UDPEncap.DstIP.Un.XXX_UnionData[:], buf.DecodeBytes(16))
250         m.UDPEncap.ID = buf.DecodeUint32()
251         return nil
252 }
253
254 // UDPEncapDump defines message 'udp_encap_dump'.
255 type UDPEncapDump struct{}
256
257 func (m *UDPEncapDump) Reset()               { *m = UDPEncapDump{} }
258 func (*UDPEncapDump) GetMessageName() string { return "udp_encap_dump" }
259 func (*UDPEncapDump) GetCrcString() string   { return "51077d14" }
260 func (*UDPEncapDump) GetMessageType() api.MessageType {
261         return api.RequestMessage
262 }
263
264 func (m *UDPEncapDump) Size() (size int) {
265         if m == nil {
266                 return 0
267         }
268         return size
269 }
270 func (m *UDPEncapDump) Marshal(b []byte) ([]byte, error) {
271         if b == nil {
272                 b = make([]byte, m.Size())
273         }
274         buf := codec.NewBuffer(b)
275         return buf.Bytes(), nil
276 }
277 func (m *UDPEncapDump) Unmarshal(b []byte) error {
278         return nil
279 }
280
281 func init() { file_udp_binapi_init() }
282 func file_udp_binapi_init() {
283         api.RegisterMessage((*UDPEncapAdd)(nil), "udp_encap_add_61d5fc48")
284         api.RegisterMessage((*UDPEncapAddReply)(nil), "udp_encap_add_reply_e2fc8294")
285         api.RegisterMessage((*UDPEncapDel)(nil), "udp_encap_del_3a91bde5")
286         api.RegisterMessage((*UDPEncapDelReply)(nil), "udp_encap_del_reply_e8d4e804")
287         api.RegisterMessage((*UDPEncapDetails)(nil), "udp_encap_details_87c82821")
288         api.RegisterMessage((*UDPEncapDump)(nil), "udp_encap_dump_51077d14")
289 }
290
291 // Messages returns list of all messages in this module.
292 func AllMessages() []api.Message {
293         return []api.Message{
294                 (*UDPEncapAdd)(nil),
295                 (*UDPEncapAddReply)(nil),
296                 (*UDPEncapDel)(nil),
297                 (*UDPEncapDelReply)(nil),
298                 (*UDPEncapDetails)(nil),
299                 (*UDPEncapDump)(nil),
300         }
301 }