Improve binapi generator
[govpp.git] / binapi / gre / gre.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/gre.api.json
6
7 // Package gre contains generated bindings for API file gre.api.
8 //
9 // Contents:
10 //   1 enum
11 //   1 struct
12 //   4 messages
13 //
14 package gre
15
16 import (
17         api "git.fd.io/govpp.git/api"
18         interface_types "git.fd.io/govpp.git/binapi/interface_types"
19         ip_types "git.fd.io/govpp.git/binapi/ip_types"
20         tunnel_types "git.fd.io/govpp.git/binapi/tunnel_types"
21         codec "git.fd.io/govpp.git/codec"
22         "strconv"
23 )
24
25 // This is a compile-time assertion to ensure that this generated file
26 // is compatible with the GoVPP api package it is being compiled against.
27 // A compilation error at this line likely means your copy of the
28 // GoVPP api package needs to be updated.
29 const _ = api.GoVppAPIPackageIsVersion2
30
31 const (
32         APIFile    = "gre"
33         APIVersion = "2.1.0"
34         VersionCrc = 0xb9021569
35 )
36
37 // GreTunnelType defines enum 'gre_tunnel_type'.
38 type GreTunnelType uint8
39
40 const (
41         GRE_API_TUNNEL_TYPE_L3     GreTunnelType = 0
42         GRE_API_TUNNEL_TYPE_TEB    GreTunnelType = 1
43         GRE_API_TUNNEL_TYPE_ERSPAN GreTunnelType = 2
44 )
45
46 var (
47         GreTunnelType_name = map[uint8]string{
48                 0: "GRE_API_TUNNEL_TYPE_L3",
49                 1: "GRE_API_TUNNEL_TYPE_TEB",
50                 2: "GRE_API_TUNNEL_TYPE_ERSPAN",
51         }
52         GreTunnelType_value = map[string]uint8{
53                 "GRE_API_TUNNEL_TYPE_L3":     0,
54                 "GRE_API_TUNNEL_TYPE_TEB":    1,
55                 "GRE_API_TUNNEL_TYPE_ERSPAN": 2,
56         }
57 )
58
59 func (x GreTunnelType) String() string {
60         s, ok := GreTunnelType_name[uint8(x)]
61         if ok {
62                 return s
63         }
64         return "GreTunnelType(" + strconv.Itoa(int(x)) + ")"
65 }
66
67 // GreTunnel defines type 'gre_tunnel'.
68 type GreTunnel struct {
69         Type         GreTunnelType                      `binapi:"gre_tunnel_type,name=type" json:"type,omitempty"`
70         Mode         tunnel_types.TunnelMode            `binapi:"tunnel_mode,name=mode" json:"mode,omitempty"`
71         Flags        tunnel_types.TunnelEncapDecapFlags `binapi:"tunnel_encap_decap_flags,name=flags" json:"flags,omitempty"`
72         SessionID    uint16                             `binapi:"u16,name=session_id" json:"session_id,omitempty"`
73         Instance     uint32                             `binapi:"u32,name=instance" json:"instance,omitempty"`
74         OuterTableID uint32                             `binapi:"u32,name=outer_table_id" json:"outer_table_id,omitempty"`
75         SwIfIndex    interface_types.InterfaceIndex     `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
76         Src          ip_types.Address                   `binapi:"address,name=src" json:"src,omitempty"`
77         Dst          ip_types.Address                   `binapi:"address,name=dst" json:"dst,omitempty"`
78 }
79
80 // GreTunnelAddDel defines message 'gre_tunnel_add_del'.
81 type GreTunnelAddDel struct {
82         IsAdd  bool      `binapi:"bool,name=is_add" json:"is_add,omitempty"`
83         Tunnel GreTunnel `binapi:"gre_tunnel,name=tunnel" json:"tunnel,omitempty"`
84 }
85
86 func (m *GreTunnelAddDel) Reset()               { *m = GreTunnelAddDel{} }
87 func (*GreTunnelAddDel) GetMessageName() string { return "gre_tunnel_add_del" }
88 func (*GreTunnelAddDel) GetCrcString() string   { return "6efc9c22" }
89 func (*GreTunnelAddDel) GetMessageType() api.MessageType {
90         return api.RequestMessage
91 }
92
93 func (m *GreTunnelAddDel) Size() int {
94         if m == nil {
95                 return 0
96         }
97         var size int
98         size += 1      // m.IsAdd
99         size += 1      // m.Tunnel.Type
100         size += 1      // m.Tunnel.Mode
101         size += 1      // m.Tunnel.Flags
102         size += 2      // m.Tunnel.SessionID
103         size += 4      // m.Tunnel.Instance
104         size += 4      // m.Tunnel.OuterTableID
105         size += 4      // m.Tunnel.SwIfIndex
106         size += 1      // m.Tunnel.Src.Af
107         size += 1 * 16 // m.Tunnel.Src.Un
108         size += 1      // m.Tunnel.Dst.Af
109         size += 1 * 16 // m.Tunnel.Dst.Un
110         return size
111 }
112 func (m *GreTunnelAddDel) Marshal(b []byte) ([]byte, error) {
113         var buf *codec.Buffer
114         if b == nil {
115                 buf = codec.NewBuffer(make([]byte, m.Size()))
116         } else {
117                 buf = codec.NewBuffer(b)
118         }
119         buf.EncodeBool(m.IsAdd)
120         buf.EncodeUint8(uint8(m.Tunnel.Type))
121         buf.EncodeUint8(uint8(m.Tunnel.Mode))
122         buf.EncodeUint8(uint8(m.Tunnel.Flags))
123         buf.EncodeUint16(uint16(m.Tunnel.SessionID))
124         buf.EncodeUint32(uint32(m.Tunnel.Instance))
125         buf.EncodeUint32(uint32(m.Tunnel.OuterTableID))
126         buf.EncodeUint32(uint32(m.Tunnel.SwIfIndex))
127         buf.EncodeUint8(uint8(m.Tunnel.Src.Af))
128         buf.EncodeBytes(m.Tunnel.Src.Un.XXX_UnionData[:], 0)
129         buf.EncodeUint8(uint8(m.Tunnel.Dst.Af))
130         buf.EncodeBytes(m.Tunnel.Dst.Un.XXX_UnionData[:], 0)
131         return buf.Bytes(), nil
132 }
133 func (m *GreTunnelAddDel) Unmarshal(b []byte) error {
134         buf := codec.NewBuffer(b)
135         m.IsAdd = buf.DecodeBool()
136         m.Tunnel.Type = GreTunnelType(buf.DecodeUint8())
137         m.Tunnel.Mode = tunnel_types.TunnelMode(buf.DecodeUint8())
138         m.Tunnel.Flags = tunnel_types.TunnelEncapDecapFlags(buf.DecodeUint8())
139         m.Tunnel.SessionID = buf.DecodeUint16()
140         m.Tunnel.Instance = buf.DecodeUint32()
141         m.Tunnel.OuterTableID = buf.DecodeUint32()
142         m.Tunnel.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32())
143         m.Tunnel.Src.Af = ip_types.AddressFamily(buf.DecodeUint8())
144         copy(m.Tunnel.Src.Un.XXX_UnionData[:], buf.DecodeBytes(16))
145         m.Tunnel.Dst.Af = ip_types.AddressFamily(buf.DecodeUint8())
146         copy(m.Tunnel.Dst.Un.XXX_UnionData[:], buf.DecodeBytes(16))
147         return nil
148 }
149
150 // GreTunnelAddDelReply defines message 'gre_tunnel_add_del_reply'.
151 type GreTunnelAddDelReply struct {
152         Retval    int32                          `binapi:"i32,name=retval" json:"retval,omitempty"`
153         SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
154 }
155
156 func (m *GreTunnelAddDelReply) Reset()               { *m = GreTunnelAddDelReply{} }
157 func (*GreTunnelAddDelReply) GetMessageName() string { return "gre_tunnel_add_del_reply" }
158 func (*GreTunnelAddDelReply) GetCrcString() string   { return "5383d31f" }
159 func (*GreTunnelAddDelReply) GetMessageType() api.MessageType {
160         return api.ReplyMessage
161 }
162
163 func (m *GreTunnelAddDelReply) Size() int {
164         if m == nil {
165                 return 0
166         }
167         var size int
168         size += 4 // m.Retval
169         size += 4 // m.SwIfIndex
170         return size
171 }
172 func (m *GreTunnelAddDelReply) Marshal(b []byte) ([]byte, error) {
173         var buf *codec.Buffer
174         if b == nil {
175                 buf = codec.NewBuffer(make([]byte, m.Size()))
176         } else {
177                 buf = codec.NewBuffer(b)
178         }
179         buf.EncodeUint32(uint32(m.Retval))
180         buf.EncodeUint32(uint32(m.SwIfIndex))
181         return buf.Bytes(), nil
182 }
183 func (m *GreTunnelAddDelReply) Unmarshal(b []byte) error {
184         buf := codec.NewBuffer(b)
185         m.Retval = int32(buf.DecodeUint32())
186         m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32())
187         return nil
188 }
189
190 // GreTunnelDetails defines message 'gre_tunnel_details'.
191 type GreTunnelDetails struct {
192         Tunnel GreTunnel `binapi:"gre_tunnel,name=tunnel" json:"tunnel,omitempty"`
193 }
194
195 func (m *GreTunnelDetails) Reset()               { *m = GreTunnelDetails{} }
196 func (*GreTunnelDetails) GetMessageName() string { return "gre_tunnel_details" }
197 func (*GreTunnelDetails) GetCrcString() string   { return "003bfbf1" }
198 func (*GreTunnelDetails) GetMessageType() api.MessageType {
199         return api.ReplyMessage
200 }
201
202 func (m *GreTunnelDetails) Size() int {
203         if m == nil {
204                 return 0
205         }
206         var size int
207         size += 1      // m.Tunnel.Type
208         size += 1      // m.Tunnel.Mode
209         size += 1      // m.Tunnel.Flags
210         size += 2      // m.Tunnel.SessionID
211         size += 4      // m.Tunnel.Instance
212         size += 4      // m.Tunnel.OuterTableID
213         size += 4      // m.Tunnel.SwIfIndex
214         size += 1      // m.Tunnel.Src.Af
215         size += 1 * 16 // m.Tunnel.Src.Un
216         size += 1      // m.Tunnel.Dst.Af
217         size += 1 * 16 // m.Tunnel.Dst.Un
218         return size
219 }
220 func (m *GreTunnelDetails) Marshal(b []byte) ([]byte, error) {
221         var buf *codec.Buffer
222         if b == nil {
223                 buf = codec.NewBuffer(make([]byte, m.Size()))
224         } else {
225                 buf = codec.NewBuffer(b)
226         }
227         buf.EncodeUint8(uint8(m.Tunnel.Type))
228         buf.EncodeUint8(uint8(m.Tunnel.Mode))
229         buf.EncodeUint8(uint8(m.Tunnel.Flags))
230         buf.EncodeUint16(uint16(m.Tunnel.SessionID))
231         buf.EncodeUint32(uint32(m.Tunnel.Instance))
232         buf.EncodeUint32(uint32(m.Tunnel.OuterTableID))
233         buf.EncodeUint32(uint32(m.Tunnel.SwIfIndex))
234         buf.EncodeUint8(uint8(m.Tunnel.Src.Af))
235         buf.EncodeBytes(m.Tunnel.Src.Un.XXX_UnionData[:], 0)
236         buf.EncodeUint8(uint8(m.Tunnel.Dst.Af))
237         buf.EncodeBytes(m.Tunnel.Dst.Un.XXX_UnionData[:], 0)
238         return buf.Bytes(), nil
239 }
240 func (m *GreTunnelDetails) Unmarshal(b []byte) error {
241         buf := codec.NewBuffer(b)
242         m.Tunnel.Type = GreTunnelType(buf.DecodeUint8())
243         m.Tunnel.Mode = tunnel_types.TunnelMode(buf.DecodeUint8())
244         m.Tunnel.Flags = tunnel_types.TunnelEncapDecapFlags(buf.DecodeUint8())
245         m.Tunnel.SessionID = buf.DecodeUint16()
246         m.Tunnel.Instance = buf.DecodeUint32()
247         m.Tunnel.OuterTableID = buf.DecodeUint32()
248         m.Tunnel.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32())
249         m.Tunnel.Src.Af = ip_types.AddressFamily(buf.DecodeUint8())
250         copy(m.Tunnel.Src.Un.XXX_UnionData[:], buf.DecodeBytes(16))
251         m.Tunnel.Dst.Af = ip_types.AddressFamily(buf.DecodeUint8())
252         copy(m.Tunnel.Dst.Un.XXX_UnionData[:], buf.DecodeBytes(16))
253         return nil
254 }
255
256 // GreTunnelDump defines message 'gre_tunnel_dump'.
257 type GreTunnelDump struct {
258         SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
259 }
260
261 func (m *GreTunnelDump) Reset()               { *m = GreTunnelDump{} }
262 func (*GreTunnelDump) GetMessageName() string { return "gre_tunnel_dump" }
263 func (*GreTunnelDump) GetCrcString() string   { return "f9e6675e" }
264 func (*GreTunnelDump) GetMessageType() api.MessageType {
265         return api.RequestMessage
266 }
267
268 func (m *GreTunnelDump) Size() int {
269         if m == nil {
270                 return 0
271         }
272         var size int
273         size += 4 // m.SwIfIndex
274         return size
275 }
276 func (m *GreTunnelDump) Marshal(b []byte) ([]byte, error) {
277         var buf *codec.Buffer
278         if b == nil {
279                 buf = codec.NewBuffer(make([]byte, m.Size()))
280         } else {
281                 buf = codec.NewBuffer(b)
282         }
283         buf.EncodeUint32(uint32(m.SwIfIndex))
284         return buf.Bytes(), nil
285 }
286 func (m *GreTunnelDump) Unmarshal(b []byte) error {
287         buf := codec.NewBuffer(b)
288         m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32())
289         return nil
290 }
291
292 func init() { file_gre_binapi_init() }
293 func file_gre_binapi_init() {
294         api.RegisterMessage((*GreTunnelAddDel)(nil), "gre_tunnel_add_del_6efc9c22")
295         api.RegisterMessage((*GreTunnelAddDelReply)(nil), "gre_tunnel_add_del_reply_5383d31f")
296         api.RegisterMessage((*GreTunnelDetails)(nil), "gre_tunnel_details_003bfbf1")
297         api.RegisterMessage((*GreTunnelDump)(nil), "gre_tunnel_dump_f9e6675e")
298 }
299
300 // Messages returns list of all messages in this module.
301 func AllMessages() []api.Message {
302         return []api.Message{
303                 (*GreTunnelAddDel)(nil),
304                 (*GreTunnelAddDelReply)(nil),
305                 (*GreTunnelDetails)(nil),
306                 (*GreTunnelDump)(nil),
307         }
308 }