binapigen: fix union size
[govpp.git] / binapi / tcp / tcp.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/tcp.api.json
6
7 // Package tcp contains generated bindings for API file tcp.api.
8 //
9 // Contents:
10 //   2 messages
11 //
12 package tcp
13
14 import (
15         api "git.fd.io/govpp.git/api"
16         ip_types "git.fd.io/govpp.git/binapi/ip_types"
17         codec "git.fd.io/govpp.git/codec"
18 )
19
20 // This is a compile-time assertion to ensure that this generated file
21 // is compatible with the GoVPP api package it is being compiled against.
22 // A compilation error at this line likely means your copy of the
23 // GoVPP api package needs to be updated.
24 const _ = api.GoVppAPIPackageIsVersion2
25
26 const (
27         APIFile    = "tcp"
28         APIVersion = "2.0.0"
29         VersionCrc = 0xf586c9ba
30 )
31
32 // TCPConfigureSrcAddresses defines message 'tcp_configure_src_addresses'.
33 type TCPConfigureSrcAddresses struct {
34         VrfID        uint32           `binapi:"u32,name=vrf_id" json:"vrf_id,omitempty"`
35         FirstAddress ip_types.Address `binapi:"address,name=first_address" json:"first_address,omitempty"`
36         LastAddress  ip_types.Address `binapi:"address,name=last_address" json:"last_address,omitempty"`
37 }
38
39 func (m *TCPConfigureSrcAddresses) Reset()               { *m = TCPConfigureSrcAddresses{} }
40 func (*TCPConfigureSrcAddresses) GetMessageName() string { return "tcp_configure_src_addresses" }
41 func (*TCPConfigureSrcAddresses) GetCrcString() string   { return "4b02b946" }
42 func (*TCPConfigureSrcAddresses) GetMessageType() api.MessageType {
43         return api.RequestMessage
44 }
45
46 func (m *TCPConfigureSrcAddresses) Size() (size int) {
47         if m == nil {
48                 return 0
49         }
50         size += 4      // m.VrfID
51         size += 1      // m.FirstAddress.Af
52         size += 1 * 16 // m.FirstAddress.Un
53         size += 1      // m.LastAddress.Af
54         size += 1 * 16 // m.LastAddress.Un
55         return size
56 }
57 func (m *TCPConfigureSrcAddresses) Marshal(b []byte) ([]byte, error) {
58         if b == nil {
59                 b = make([]byte, m.Size())
60         }
61         buf := codec.NewBuffer(b)
62         buf.EncodeUint32(m.VrfID)
63         buf.EncodeUint8(uint8(m.FirstAddress.Af))
64         buf.EncodeBytes(m.FirstAddress.Un.XXX_UnionData[:], 16)
65         buf.EncodeUint8(uint8(m.LastAddress.Af))
66         buf.EncodeBytes(m.LastAddress.Un.XXX_UnionData[:], 16)
67         return buf.Bytes(), nil
68 }
69 func (m *TCPConfigureSrcAddresses) Unmarshal(b []byte) error {
70         buf := codec.NewBuffer(b)
71         m.VrfID = buf.DecodeUint32()
72         m.FirstAddress.Af = ip_types.AddressFamily(buf.DecodeUint8())
73         copy(m.FirstAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16))
74         m.LastAddress.Af = ip_types.AddressFamily(buf.DecodeUint8())
75         copy(m.LastAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16))
76         return nil
77 }
78
79 // TCPConfigureSrcAddressesReply defines message 'tcp_configure_src_addresses_reply'.
80 type TCPConfigureSrcAddressesReply struct {
81         Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
82 }
83
84 func (m *TCPConfigureSrcAddressesReply) Reset() { *m = TCPConfigureSrcAddressesReply{} }
85 func (*TCPConfigureSrcAddressesReply) GetMessageName() string {
86         return "tcp_configure_src_addresses_reply"
87 }
88 func (*TCPConfigureSrcAddressesReply) GetCrcString() string { return "e8d4e804" }
89 func (*TCPConfigureSrcAddressesReply) GetMessageType() api.MessageType {
90         return api.ReplyMessage
91 }
92
93 func (m *TCPConfigureSrcAddressesReply) Size() (size int) {
94         if m == nil {
95                 return 0
96         }
97         size += 4 // m.Retval
98         return size
99 }
100 func (m *TCPConfigureSrcAddressesReply) Marshal(b []byte) ([]byte, error) {
101         if b == nil {
102                 b = make([]byte, m.Size())
103         }
104         buf := codec.NewBuffer(b)
105         buf.EncodeInt32(m.Retval)
106         return buf.Bytes(), nil
107 }
108 func (m *TCPConfigureSrcAddressesReply) Unmarshal(b []byte) error {
109         buf := codec.NewBuffer(b)
110         m.Retval = buf.DecodeInt32()
111         return nil
112 }
113
114 func init() { file_tcp_binapi_init() }
115 func file_tcp_binapi_init() {
116         api.RegisterMessage((*TCPConfigureSrcAddresses)(nil), "tcp_configure_src_addresses_4b02b946")
117         api.RegisterMessage((*TCPConfigureSrcAddressesReply)(nil), "tcp_configure_src_addresses_reply_e8d4e804")
118 }
119
120 // Messages returns list of all messages in this module.
121 func AllMessages() []api.Message {
122         return []api.Message{
123                 (*TCPConfigureSrcAddresses)(nil),
124                 (*TCPConfigureSrcAddressesReply)(nil),
125         }
126 }