1 // Code generated by GoVPP's binapi-generator. DO NOT EDIT.
3 // binapi-generator: v0.4.0-dev
5 // source: /usr/share/vpp/api/core/af_packet.api.json
8 Package af_packet contains generated code for VPP API file af_packet.api (2.0.0).
28 api "git.fd.io/govpp.git/api"
29 codec "git.fd.io/govpp.git/codec"
30 struc "github.com/lunixbochs/struc"
32 interface_types "git.fd.io/govpp.git/examples/binapi/interface_types"
35 // This is a compile-time assertion to ensure that this generated file
36 // is compatible with the GoVPP api package it is being compiled against.
37 // A compilation error at this line likely means your copy of the
38 // GoVPP api package needs to be updated.
39 const _ = api.GoVppAPIPackageIsVersion2 // please upgrade the GoVPP api package
42 // ModuleName is the name of this module.
43 ModuleName = "af_packet"
44 // APIVersion is the API version of this module.
46 // VersionCrc is the CRC of this module.
47 VersionCrc = 0xe0b6c022
50 // MacAddress represents VPP binary API alias 'mac_address'.
51 type MacAddress [6]uint8
53 func ParseMAC(mac string) (parsed MacAddress, err error) {
54 var hw net.HardwareAddr
55 if hw, err = net.ParseMAC(mac); err != nil {
58 copy(parsed[:], hw[:])
62 func (m *MacAddress) ToString() string {
63 return net.HardwareAddr(m[:]).String()
66 // AfPacketCreate represents VPP binary API message 'af_packet_create'.
67 type AfPacketCreate struct {
68 HwAddr MacAddress `binapi:"mac_address,name=hw_addr" json:"hw_addr,omitempty"`
69 UseRandomHwAddr bool `binapi:"bool,name=use_random_hw_addr" json:"use_random_hw_addr,omitempty"`
70 HostIfName string `binapi:"string[64],name=host_if_name" json:"host_if_name,omitempty" struc:"[64]byte"`
73 func (m *AfPacketCreate) Reset() { *m = AfPacketCreate{} }
74 func (*AfPacketCreate) GetMessageName() string { return "af_packet_create" }
75 func (*AfPacketCreate) GetCrcString() string { return "a190415f" }
76 func (*AfPacketCreate) GetMessageType() api.MessageType { return api.RequestMessage }
78 func (m *AfPacketCreate) Size() int {
85 // field[1] m.UseRandomHwAddr
87 // field[1] m.HostIfName
91 func (m *AfPacketCreate) Marshal(b []byte) ([]byte, error) {
98 buf = make([]byte, m.Size())
103 for i := 0; i < 6; i++ {
105 if i < len(m.HwAddr) {
106 x = uint8(m.HwAddr[i])
111 // field[1] m.UseRandomHwAddr
112 if m.UseRandomHwAddr {
116 // field[1] m.HostIfName
117 copy(buf[pos:pos+64], m.HostIfName)
121 func (m *AfPacketCreate) Unmarshal(tmp []byte) error {
122 o := binary.BigEndian
127 for i := 0; i < len(m.HwAddr); i++ {
128 m.HwAddr[i] = uint8(tmp[pos])
131 // field[1] m.UseRandomHwAddr
132 m.UseRandomHwAddr = tmp[pos] != 0
134 // field[1] m.HostIfName
136 nul := bytes.Index(tmp[pos:pos+64], []byte{0x00})
137 m.HostIfName = codec.DecodeString(tmp[pos : pos+nul])
143 // AfPacketCreateReply represents VPP binary API message 'af_packet_create_reply'.
144 type AfPacketCreateReply struct {
145 Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
146 SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
149 func (m *AfPacketCreateReply) Reset() { *m = AfPacketCreateReply{} }
150 func (*AfPacketCreateReply) GetMessageName() string { return "af_packet_create_reply" }
151 func (*AfPacketCreateReply) GetCrcString() string { return "5383d31f" }
152 func (*AfPacketCreateReply) GetMessageType() api.MessageType { return api.ReplyMessage }
154 func (m *AfPacketCreateReply) Size() int {
161 // field[1] m.SwIfIndex
165 func (m *AfPacketCreateReply) Marshal(b []byte) ([]byte, error) {
166 o := binary.BigEndian
172 buf = make([]byte, m.Size())
177 o.PutUint32(buf[pos:pos+4], uint32(m.Retval))
179 // field[1] m.SwIfIndex
180 o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex))
184 func (m *AfPacketCreateReply) Unmarshal(tmp []byte) error {
185 o := binary.BigEndian
190 m.Retval = int32(o.Uint32(tmp[pos : pos+4]))
192 // field[1] m.SwIfIndex
193 m.SwIfIndex = interface_types.InterfaceIndex(o.Uint32(tmp[pos : pos+4]))
198 // AfPacketDelete represents VPP binary API message 'af_packet_delete'.
199 type AfPacketDelete struct {
200 HostIfName string `binapi:"string[64],name=host_if_name" json:"host_if_name,omitempty" struc:"[64]byte"`
203 func (m *AfPacketDelete) Reset() { *m = AfPacketDelete{} }
204 func (*AfPacketDelete) GetMessageName() string { return "af_packet_delete" }
205 func (*AfPacketDelete) GetCrcString() string { return "863fa648" }
206 func (*AfPacketDelete) GetMessageType() api.MessageType { return api.RequestMessage }
208 func (m *AfPacketDelete) Size() int {
213 // field[1] m.HostIfName
217 func (m *AfPacketDelete) Marshal(b []byte) ([]byte, error) {
218 o := binary.BigEndian
224 buf = make([]byte, m.Size())
228 // field[1] m.HostIfName
229 copy(buf[pos:pos+64], m.HostIfName)
233 func (m *AfPacketDelete) Unmarshal(tmp []byte) error {
234 o := binary.BigEndian
238 // field[1] m.HostIfName
240 nul := bytes.Index(tmp[pos:pos+64], []byte{0x00})
241 m.HostIfName = codec.DecodeString(tmp[pos : pos+nul])
247 // AfPacketDeleteReply represents VPP binary API message 'af_packet_delete_reply'.
248 type AfPacketDeleteReply struct {
249 Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
252 func (m *AfPacketDeleteReply) Reset() { *m = AfPacketDeleteReply{} }
253 func (*AfPacketDeleteReply) GetMessageName() string { return "af_packet_delete_reply" }
254 func (*AfPacketDeleteReply) GetCrcString() string { return "e8d4e804" }
255 func (*AfPacketDeleteReply) GetMessageType() api.MessageType { return api.ReplyMessage }
257 func (m *AfPacketDeleteReply) Size() int {
266 func (m *AfPacketDeleteReply) Marshal(b []byte) ([]byte, error) {
267 o := binary.BigEndian
273 buf = make([]byte, m.Size())
278 o.PutUint32(buf[pos:pos+4], uint32(m.Retval))
282 func (m *AfPacketDeleteReply) Unmarshal(tmp []byte) error {
283 o := binary.BigEndian
288 m.Retval = int32(o.Uint32(tmp[pos : pos+4]))
293 // AfPacketDetails represents VPP binary API message 'af_packet_details'.
294 type AfPacketDetails struct {
295 SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
296 HostIfName string `binapi:"string[64],name=host_if_name" json:"host_if_name,omitempty" struc:"[64]byte"`
299 func (m *AfPacketDetails) Reset() { *m = AfPacketDetails{} }
300 func (*AfPacketDetails) GetMessageName() string { return "af_packet_details" }
301 func (*AfPacketDetails) GetCrcString() string { return "58c7c042" }
302 func (*AfPacketDetails) GetMessageType() api.MessageType { return api.ReplyMessage }
304 func (m *AfPacketDetails) Size() int {
309 // field[1] m.SwIfIndex
311 // field[1] m.HostIfName
315 func (m *AfPacketDetails) Marshal(b []byte) ([]byte, error) {
316 o := binary.BigEndian
322 buf = make([]byte, m.Size())
326 // field[1] m.SwIfIndex
327 o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex))
329 // field[1] m.HostIfName
330 copy(buf[pos:pos+64], m.HostIfName)
334 func (m *AfPacketDetails) Unmarshal(tmp []byte) error {
335 o := binary.BigEndian
339 // field[1] m.SwIfIndex
340 m.SwIfIndex = interface_types.InterfaceIndex(o.Uint32(tmp[pos : pos+4]))
342 // field[1] m.HostIfName
344 nul := bytes.Index(tmp[pos:pos+64], []byte{0x00})
345 m.HostIfName = codec.DecodeString(tmp[pos : pos+nul])
351 // AfPacketDump represents VPP binary API message 'af_packet_dump'.
352 type AfPacketDump struct{}
354 func (m *AfPacketDump) Reset() { *m = AfPacketDump{} }
355 func (*AfPacketDump) GetMessageName() string { return "af_packet_dump" }
356 func (*AfPacketDump) GetCrcString() string { return "51077d14" }
357 func (*AfPacketDump) GetMessageType() api.MessageType { return api.RequestMessage }
359 func (m *AfPacketDump) Size() int {
366 func (m *AfPacketDump) Marshal(b []byte) ([]byte, error) {
367 o := binary.BigEndian
373 buf = make([]byte, m.Size())
379 func (m *AfPacketDump) Unmarshal(tmp []byte) error {
380 o := binary.BigEndian
387 // AfPacketSetL4CksumOffload represents VPP binary API message 'af_packet_set_l4_cksum_offload'.
388 type AfPacketSetL4CksumOffload struct {
389 SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
390 Set bool `binapi:"bool,name=set" json:"set,omitempty"`
393 func (m *AfPacketSetL4CksumOffload) Reset() { *m = AfPacketSetL4CksumOffload{} }
394 func (*AfPacketSetL4CksumOffload) GetMessageName() string { return "af_packet_set_l4_cksum_offload" }
395 func (*AfPacketSetL4CksumOffload) GetCrcString() string { return "319cd5c8" }
396 func (*AfPacketSetL4CksumOffload) GetMessageType() api.MessageType { return api.RequestMessage }
398 func (m *AfPacketSetL4CksumOffload) Size() int {
403 // field[1] m.SwIfIndex
409 func (m *AfPacketSetL4CksumOffload) Marshal(b []byte) ([]byte, error) {
410 o := binary.BigEndian
416 buf = make([]byte, m.Size())
420 // field[1] m.SwIfIndex
421 o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex))
430 func (m *AfPacketSetL4CksumOffload) Unmarshal(tmp []byte) error {
431 o := binary.BigEndian
435 // field[1] m.SwIfIndex
436 m.SwIfIndex = interface_types.InterfaceIndex(o.Uint32(tmp[pos : pos+4]))
439 m.Set = tmp[pos] != 0
444 // AfPacketSetL4CksumOffloadReply represents VPP binary API message 'af_packet_set_l4_cksum_offload_reply'.
445 type AfPacketSetL4CksumOffloadReply struct {
446 Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
449 func (m *AfPacketSetL4CksumOffloadReply) Reset() { *m = AfPacketSetL4CksumOffloadReply{} }
450 func (*AfPacketSetL4CksumOffloadReply) GetMessageName() string {
451 return "af_packet_set_l4_cksum_offload_reply"
453 func (*AfPacketSetL4CksumOffloadReply) GetCrcString() string { return "e8d4e804" }
454 func (*AfPacketSetL4CksumOffloadReply) GetMessageType() api.MessageType { return api.ReplyMessage }
456 func (m *AfPacketSetL4CksumOffloadReply) Size() int {
465 func (m *AfPacketSetL4CksumOffloadReply) Marshal(b []byte) ([]byte, error) {
466 o := binary.BigEndian
472 buf = make([]byte, m.Size())
477 o.PutUint32(buf[pos:pos+4], uint32(m.Retval))
481 func (m *AfPacketSetL4CksumOffloadReply) Unmarshal(tmp []byte) error {
482 o := binary.BigEndian
487 m.Retval = int32(o.Uint32(tmp[pos : pos+4]))
492 func init() { file_af_packet_binapi_init() }
493 func file_af_packet_binapi_init() {
494 api.RegisterMessage((*AfPacketCreate)(nil), "af_packet.AfPacketCreate")
495 api.RegisterMessage((*AfPacketCreateReply)(nil), "af_packet.AfPacketCreateReply")
496 api.RegisterMessage((*AfPacketDelete)(nil), "af_packet.AfPacketDelete")
497 api.RegisterMessage((*AfPacketDeleteReply)(nil), "af_packet.AfPacketDeleteReply")
498 api.RegisterMessage((*AfPacketDetails)(nil), "af_packet.AfPacketDetails")
499 api.RegisterMessage((*AfPacketDump)(nil), "af_packet.AfPacketDump")
500 api.RegisterMessage((*AfPacketSetL4CksumOffload)(nil), "af_packet.AfPacketSetL4CksumOffload")
501 api.RegisterMessage((*AfPacketSetL4CksumOffloadReply)(nil), "af_packet.AfPacketSetL4CksumOffloadReply")
504 // Messages returns list of all messages in this module.
505 func AllMessages() []api.Message {
506 return []api.Message{
507 (*AfPacketCreate)(nil),
508 (*AfPacketCreateReply)(nil),
509 (*AfPacketDelete)(nil),
510 (*AfPacketDeleteReply)(nil),
511 (*AfPacketDetails)(nil),
512 (*AfPacketDump)(nil),
513 (*AfPacketSetL4CksumOffload)(nil),
514 (*AfPacketSetL4CksumOffloadReply)(nil),
518 // Reference imports to suppress errors if they are not otherwise used.
519 var _ = api.RegisterMessage
520 var _ = codec.DecodeString
521 var _ = bytes.NewBuffer
522 var _ = context.Background
525 var _ = strings.Contains
527 var _ = binary.BigEndian
528 var _ = math.Float32bits