binapigen: fix union size
[govpp.git] / binapi / pppoe / pppoe.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/plugins/pppoe.api.json
6
7 // Package pppoe contains generated bindings for API file pppoe.api.
8 //
9 // Contents:
10 //   4 messages
11 //
12 package pppoe
13
14 import (
15         api "git.fd.io/govpp.git/api"
16         ethernet_types "git.fd.io/govpp.git/binapi/ethernet_types"
17         interface_types "git.fd.io/govpp.git/binapi/interface_types"
18         ip_types "git.fd.io/govpp.git/binapi/ip_types"
19         codec "git.fd.io/govpp.git/codec"
20 )
21
22 // This is a compile-time assertion to ensure that this generated file
23 // is compatible with the GoVPP api package it is being compiled against.
24 // A compilation error at this line likely means your copy of the
25 // GoVPP api package needs to be updated.
26 const _ = api.GoVppAPIPackageIsVersion2
27
28 const (
29         APIFile    = "pppoe"
30         APIVersion = "2.0.0"
31         VersionCrc = 0x24ebf557
32 )
33
34 // PppoeAddDelSession defines message 'pppoe_add_del_session'.
35 type PppoeAddDelSession struct {
36         IsAdd      bool                      `binapi:"bool,name=is_add" json:"is_add,omitempty"`
37         SessionID  uint16                    `binapi:"u16,name=session_id" json:"session_id,omitempty"`
38         ClientIP   ip_types.Address          `binapi:"address,name=client_ip" json:"client_ip,omitempty"`
39         DecapVrfID uint32                    `binapi:"u32,name=decap_vrf_id" json:"decap_vrf_id,omitempty"`
40         ClientMac  ethernet_types.MacAddress `binapi:"mac_address,name=client_mac" json:"client_mac,omitempty"`
41 }
42
43 func (m *PppoeAddDelSession) Reset()               { *m = PppoeAddDelSession{} }
44 func (*PppoeAddDelSession) GetMessageName() string { return "pppoe_add_del_session" }
45 func (*PppoeAddDelSession) GetCrcString() string   { return "46ace853" }
46 func (*PppoeAddDelSession) GetMessageType() api.MessageType {
47         return api.RequestMessage
48 }
49
50 func (m *PppoeAddDelSession) Size() (size int) {
51         if m == nil {
52                 return 0
53         }
54         size += 1      // m.IsAdd
55         size += 2      // m.SessionID
56         size += 1      // m.ClientIP.Af
57         size += 1 * 16 // m.ClientIP.Un
58         size += 4      // m.DecapVrfID
59         size += 1 * 6  // m.ClientMac
60         return size
61 }
62 func (m *PppoeAddDelSession) Marshal(b []byte) ([]byte, error) {
63         if b == nil {
64                 b = make([]byte, m.Size())
65         }
66         buf := codec.NewBuffer(b)
67         buf.EncodeBool(m.IsAdd)
68         buf.EncodeUint16(m.SessionID)
69         buf.EncodeUint8(uint8(m.ClientIP.Af))
70         buf.EncodeBytes(m.ClientIP.Un.XXX_UnionData[:], 16)
71         buf.EncodeUint32(m.DecapVrfID)
72         buf.EncodeBytes(m.ClientMac[:], 6)
73         return buf.Bytes(), nil
74 }
75 func (m *PppoeAddDelSession) Unmarshal(b []byte) error {
76         buf := codec.NewBuffer(b)
77         m.IsAdd = buf.DecodeBool()
78         m.SessionID = buf.DecodeUint16()
79         m.ClientIP.Af = ip_types.AddressFamily(buf.DecodeUint8())
80         copy(m.ClientIP.Un.XXX_UnionData[:], buf.DecodeBytes(16))
81         m.DecapVrfID = buf.DecodeUint32()
82         copy(m.ClientMac[:], buf.DecodeBytes(6))
83         return nil
84 }
85
86 // PppoeAddDelSessionReply defines message 'pppoe_add_del_session_reply'.
87 type PppoeAddDelSessionReply struct {
88         Retval    int32                          `binapi:"i32,name=retval" json:"retval,omitempty"`
89         SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
90 }
91
92 func (m *PppoeAddDelSessionReply) Reset()               { *m = PppoeAddDelSessionReply{} }
93 func (*PppoeAddDelSessionReply) GetMessageName() string { return "pppoe_add_del_session_reply" }
94 func (*PppoeAddDelSessionReply) GetCrcString() string   { return "5383d31f" }
95 func (*PppoeAddDelSessionReply) GetMessageType() api.MessageType {
96         return api.ReplyMessage
97 }
98
99 func (m *PppoeAddDelSessionReply) Size() (size int) {
100         if m == nil {
101                 return 0
102         }
103         size += 4 // m.Retval
104         size += 4 // m.SwIfIndex
105         return size
106 }
107 func (m *PppoeAddDelSessionReply) Marshal(b []byte) ([]byte, error) {
108         if b == nil {
109                 b = make([]byte, m.Size())
110         }
111         buf := codec.NewBuffer(b)
112         buf.EncodeInt32(m.Retval)
113         buf.EncodeUint32(uint32(m.SwIfIndex))
114         return buf.Bytes(), nil
115 }
116 func (m *PppoeAddDelSessionReply) Unmarshal(b []byte) error {
117         buf := codec.NewBuffer(b)
118         m.Retval = buf.DecodeInt32()
119         m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32())
120         return nil
121 }
122
123 // PppoeSessionDetails defines message 'pppoe_session_details'.
124 type PppoeSessionDetails struct {
125         SwIfIndex    interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
126         SessionID    uint16                         `binapi:"u16,name=session_id" json:"session_id,omitempty"`
127         ClientIP     ip_types.Address               `binapi:"address,name=client_ip" json:"client_ip,omitempty"`
128         EncapIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=encap_if_index" json:"encap_if_index,omitempty"`
129         DecapVrfID   uint32                         `binapi:"u32,name=decap_vrf_id" json:"decap_vrf_id,omitempty"`
130         LocalMac     ethernet_types.MacAddress      `binapi:"mac_address,name=local_mac" json:"local_mac,omitempty"`
131         ClientMac    ethernet_types.MacAddress      `binapi:"mac_address,name=client_mac" json:"client_mac,omitempty"`
132 }
133
134 func (m *PppoeSessionDetails) Reset()               { *m = PppoeSessionDetails{} }
135 func (*PppoeSessionDetails) GetMessageName() string { return "pppoe_session_details" }
136 func (*PppoeSessionDetails) GetCrcString() string   { return "332bc742" }
137 func (*PppoeSessionDetails) GetMessageType() api.MessageType {
138         return api.ReplyMessage
139 }
140
141 func (m *PppoeSessionDetails) Size() (size int) {
142         if m == nil {
143                 return 0
144         }
145         size += 4      // m.SwIfIndex
146         size += 2      // m.SessionID
147         size += 1      // m.ClientIP.Af
148         size += 1 * 16 // m.ClientIP.Un
149         size += 4      // m.EncapIfIndex
150         size += 4      // m.DecapVrfID
151         size += 1 * 6  // m.LocalMac
152         size += 1 * 6  // m.ClientMac
153         return size
154 }
155 func (m *PppoeSessionDetails) Marshal(b []byte) ([]byte, error) {
156         if b == nil {
157                 b = make([]byte, m.Size())
158         }
159         buf := codec.NewBuffer(b)
160         buf.EncodeUint32(uint32(m.SwIfIndex))
161         buf.EncodeUint16(m.SessionID)
162         buf.EncodeUint8(uint8(m.ClientIP.Af))
163         buf.EncodeBytes(m.ClientIP.Un.XXX_UnionData[:], 16)
164         buf.EncodeUint32(uint32(m.EncapIfIndex))
165         buf.EncodeUint32(m.DecapVrfID)
166         buf.EncodeBytes(m.LocalMac[:], 6)
167         buf.EncodeBytes(m.ClientMac[:], 6)
168         return buf.Bytes(), nil
169 }
170 func (m *PppoeSessionDetails) Unmarshal(b []byte) error {
171         buf := codec.NewBuffer(b)
172         m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32())
173         m.SessionID = buf.DecodeUint16()
174         m.ClientIP.Af = ip_types.AddressFamily(buf.DecodeUint8())
175         copy(m.ClientIP.Un.XXX_UnionData[:], buf.DecodeBytes(16))
176         m.EncapIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32())
177         m.DecapVrfID = buf.DecodeUint32()
178         copy(m.LocalMac[:], buf.DecodeBytes(6))
179         copy(m.ClientMac[:], buf.DecodeBytes(6))
180         return nil
181 }
182
183 // PppoeSessionDump defines message 'pppoe_session_dump'.
184 type PppoeSessionDump struct {
185         SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
186 }
187
188 func (m *PppoeSessionDump) Reset()               { *m = PppoeSessionDump{} }
189 func (*PppoeSessionDump) GetMessageName() string { return "pppoe_session_dump" }
190 func (*PppoeSessionDump) GetCrcString() string   { return "f9e6675e" }
191 func (*PppoeSessionDump) GetMessageType() api.MessageType {
192         return api.RequestMessage
193 }
194
195 func (m *PppoeSessionDump) Size() (size int) {
196         if m == nil {
197                 return 0
198         }
199         size += 4 // m.SwIfIndex
200         return size
201 }
202 func (m *PppoeSessionDump) Marshal(b []byte) ([]byte, error) {
203         if b == nil {
204                 b = make([]byte, m.Size())
205         }
206         buf := codec.NewBuffer(b)
207         buf.EncodeUint32(uint32(m.SwIfIndex))
208         return buf.Bytes(), nil
209 }
210 func (m *PppoeSessionDump) Unmarshal(b []byte) error {
211         buf := codec.NewBuffer(b)
212         m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32())
213         return nil
214 }
215
216 func init() { file_pppoe_binapi_init() }
217 func file_pppoe_binapi_init() {
218         api.RegisterMessage((*PppoeAddDelSession)(nil), "pppoe_add_del_session_46ace853")
219         api.RegisterMessage((*PppoeAddDelSessionReply)(nil), "pppoe_add_del_session_reply_5383d31f")
220         api.RegisterMessage((*PppoeSessionDetails)(nil), "pppoe_session_details_332bc742")
221         api.RegisterMessage((*PppoeSessionDump)(nil), "pppoe_session_dump_f9e6675e")
222 }
223
224 // Messages returns list of all messages in this module.
225 func AllMessages() []api.Message {
226         return []api.Message{
227                 (*PppoeAddDelSession)(nil),
228                 (*PppoeAddDelSessionReply)(nil),
229                 (*PppoeSessionDetails)(nil),
230                 (*PppoeSessionDump)(nil),
231         }
232 }