diff options
author | Ondrej Fabry <ofabry@cisco.com> | 2020-07-17 10:36:28 +0200 |
---|---|---|
committer | Ondrej Fabry <ofabry@cisco.com> | 2020-07-17 11:43:41 +0200 |
commit | d1f24d37bd447b64e402298bb8eb2479681facf9 (patch) | |
tree | a3fc21ba730a91d8a402c7a5bf9c614e3677c4fc /binapi/ip_neighbor | |
parent | 1548c7e12531e3d055567d761c580a1c7ff0ac40 (diff) |
Improve binapi generator
- simplified Size/Marshal/Unmarshal methods
- replace struc in unions with custom marshal/unmarshal
- fix imports in generated files
- fix mock adapter
- generate rpc service using low-level stream API (dumps generate control ping or stream msg..)
- move examples/binapi to binapi and generate all API for latest release
- add binapigen.Plugin for developing custom generator plugins
- optionally generate HTTP handlers (REST API) for RPC services
- add govpp program for browsing VPP API
Change-Id: I092e9ed2b0c17972b3476463c3d4b14dd76ed42b
Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
Diffstat (limited to 'binapi/ip_neighbor')
-rw-r--r-- | binapi/ip_neighbor/ip_neighbor.ba.go | 747 | ||||
-rw-r--r-- | binapi/ip_neighbor/ip_neighbor_rest.ba.go | 134 | ||||
-rw-r--r-- | binapi/ip_neighbor/ip_neighbor_rpc.ba.go | 123 |
3 files changed, 1004 insertions, 0 deletions
diff --git a/binapi/ip_neighbor/ip_neighbor.ba.go b/binapi/ip_neighbor/ip_neighbor.ba.go new file mode 100644 index 0000000..60df4cc --- /dev/null +++ b/binapi/ip_neighbor/ip_neighbor.ba.go @@ -0,0 +1,747 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.4.0-dev +// VPP: 20.05-release +// source: /usr/share/vpp/api/core/ip_neighbor.api.json + +// Package ip_neighbor contains generated bindings for API file ip_neighbor.api. +// +// Contents: +// 1 enum +// 1 struct +// 15 messages +// +package ip_neighbor + +import ( + api "git.fd.io/govpp.git/api" + ethernet_types "git.fd.io/govpp.git/binapi/ethernet_types" + interface_types "git.fd.io/govpp.git/binapi/interface_types" + ip_types "git.fd.io/govpp.git/binapi/ip_types" + codec "git.fd.io/govpp.git/codec" + "strconv" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the GoVPP api package it is being compiled against. +// A compilation error at this line likely means your copy of the +// GoVPP api package needs to be updated. +const _ = api.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "ip_neighbor" + APIVersion = "1.0.0" + VersionCrc = 0xe6512b94 +) + +// IPNeighborFlags defines enum 'ip_neighbor_flags'. +type IPNeighborFlags uint8 + +const ( + IP_API_NEIGHBOR_FLAG_NONE IPNeighborFlags = 0 + IP_API_NEIGHBOR_FLAG_STATIC IPNeighborFlags = 1 + IP_API_NEIGHBOR_FLAG_NO_FIB_ENTRY IPNeighborFlags = 2 +) + +var ( + IPNeighborFlags_name = map[uint8]string{ + 0: "IP_API_NEIGHBOR_FLAG_NONE", + 1: "IP_API_NEIGHBOR_FLAG_STATIC", + 2: "IP_API_NEIGHBOR_FLAG_NO_FIB_ENTRY", + } + IPNeighborFlags_value = map[string]uint8{ + "IP_API_NEIGHBOR_FLAG_NONE": 0, + "IP_API_NEIGHBOR_FLAG_STATIC": 1, + "IP_API_NEIGHBOR_FLAG_NO_FIB_ENTRY": 2, + } +) + +func (x IPNeighborFlags) String() string { + s, ok := IPNeighborFlags_name[uint8(x)] + if ok { + return s + } + str := func(n uint8) string { + s, ok := IPNeighborFlags_name[uint8(n)] + if ok { + return s + } + return "IPNeighborFlags(" + strconv.Itoa(int(n)) + ")" + } + for i := uint8(0); i <= 8; i++ { + val := uint8(x) + if val&(1<<i) != 0 { + if s != "" { + s += "|" + } + s += str(1 << i) + } + } + if s == "" { + return str(uint8(x)) + } + return s +} + +// IPNeighbor defines type 'ip_neighbor'. +type IPNeighbor struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Flags IPNeighborFlags `binapi:"ip_neighbor_flags,name=flags" json:"flags,omitempty"` + MacAddress ethernet_types.MacAddress `binapi:"mac_address,name=mac_address" json:"mac_address,omitempty"` + IPAddress ip_types.Address `binapi:"address,name=ip_address" json:"ip_address,omitempty"` +} + +// IPNeighborAddDel defines message 'ip_neighbor_add_del'. +type IPNeighborAddDel struct { + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` + Neighbor IPNeighbor `binapi:"ip_neighbor,name=neighbor" json:"neighbor,omitempty"` +} + +func (m *IPNeighborAddDel) Reset() { *m = IPNeighborAddDel{} } +func (*IPNeighborAddDel) GetMessageName() string { return "ip_neighbor_add_del" } +func (*IPNeighborAddDel) GetCrcString() string { return "105518b6" } +func (*IPNeighborAddDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IPNeighborAddDel) Size() int { + if m == nil { + return 0 + } + var size int + size += 1 // m.IsAdd + size += 4 // m.Neighbor.SwIfIndex + size += 1 // m.Neighbor.Flags + size += 1 * 6 // m.Neighbor.MacAddress + size += 1 // m.Neighbor.IPAddress.Af + size += 1 * 16 // m.Neighbor.IPAddress.Un + return size +} +func (m *IPNeighborAddDel) Marshal(b []byte) ([]byte, error) { + var buf *codec.Buffer + if b == nil { + buf = codec.NewBuffer(make([]byte, m.Size())) + } else { + buf = codec.NewBuffer(b) + } + buf.EncodeBool(m.IsAdd) + buf.EncodeUint32(uint32(m.Neighbor.SwIfIndex)) + buf.EncodeUint8(uint8(m.Neighbor.Flags)) + buf.EncodeBytes(m.Neighbor.MacAddress[:], 6) + buf.EncodeUint8(uint8(m.Neighbor.IPAddress.Af)) + buf.EncodeBytes(m.Neighbor.IPAddress.Un.XXX_UnionData[:], 0) + return buf.Bytes(), nil +} +func (m *IPNeighborAddDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.Neighbor.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Neighbor.Flags = IPNeighborFlags(buf.DecodeUint8()) + copy(m.Neighbor.MacAddress[:], buf.DecodeBytes(6)) + m.Neighbor.IPAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Neighbor.IPAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + return nil +} + +// IPNeighborAddDelReply defines message 'ip_neighbor_add_del_reply'. +type IPNeighborAddDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + StatsIndex uint32 `binapi:"u32,name=stats_index" json:"stats_index,omitempty"` +} + +func (m *IPNeighborAddDelReply) Reset() { *m = IPNeighborAddDelReply{} } +func (*IPNeighborAddDelReply) GetMessageName() string { return "ip_neighbor_add_del_reply" } +func (*IPNeighborAddDelReply) GetCrcString() string { return "1992deab" } +func (*IPNeighborAddDelReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IPNeighborAddDelReply) Size() int { + if m == nil { + return 0 + } + var size int + size += 4 // m.Retval + size += 4 // m.StatsIndex + return size +} +func (m *IPNeighborAddDelReply) Marshal(b []byte) ([]byte, error) { + var buf *codec.Buffer + if b == nil { + buf = codec.NewBuffer(make([]byte, m.Size())) + } else { + buf = codec.NewBuffer(b) + } + buf.EncodeUint32(uint32(m.Retval)) + buf.EncodeUint32(uint32(m.StatsIndex)) + return buf.Bytes(), nil +} +func (m *IPNeighborAddDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = int32(buf.DecodeUint32()) + m.StatsIndex = buf.DecodeUint32() + return nil +} + +// IPNeighborConfig defines message 'ip_neighbor_config'. +type IPNeighborConfig struct { + Af ip_types.AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"` + MaxNumber uint32 `binapi:"u32,name=max_number" json:"max_number,omitempty"` + MaxAge uint32 `binapi:"u32,name=max_age" json:"max_age,omitempty"` + Recycle bool `binapi:"bool,name=recycle" json:"recycle,omitempty"` +} + +func (m *IPNeighborConfig) Reset() { *m = IPNeighborConfig{} } +func (*IPNeighborConfig) GetMessageName() string { return "ip_neighbor_config" } +func (*IPNeighborConfig) GetCrcString() string { return "f4a5cf44" } +func (*IPNeighborConfig) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IPNeighborConfig) Size() int { + if m == nil { + return 0 + } + var size int + size += 1 // m.Af + size += 4 // m.MaxNumber + size += 4 // m.MaxAge + size += 1 // m.Recycle + return size +} +func (m *IPNeighborConfig) Marshal(b []byte) ([]byte, error) { + var buf *codec.Buffer + if b == nil { + buf = codec.NewBuffer(make([]byte, m.Size())) + } else { + buf = codec.NewBuffer(b) + } + buf.EncodeUint8(uint8(m.Af)) + buf.EncodeUint32(uint32(m.MaxNumber)) + buf.EncodeUint32(uint32(m.MaxAge)) + buf.EncodeBool(m.Recycle) + return buf.Bytes(), nil +} +func (m *IPNeighborConfig) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Af = ip_types.AddressFamily(buf.DecodeUint8()) + m.MaxNumber = buf.DecodeUint32() + m.MaxAge = buf.DecodeUint32() + m.Recycle = buf.DecodeBool() + return nil +} + +// IPNeighborConfigReply defines message 'ip_neighbor_config_reply'. +type IPNeighborConfigReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *IPNeighborConfigReply) Reset() { *m = IPNeighborConfigReply{} } +func (*IPNeighborConfigReply) GetMessageName() string { return "ip_neighbor_config_reply" } +func (*IPNeighborConfigReply) GetCrcString() string { return "e8d4e804" } +func (*IPNeighborConfigReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IPNeighborConfigReply) Size() int { + if m == nil { + return 0 + } + var size int + size += 4 // m.Retval + return size +} +func (m *IPNeighborConfigReply) Marshal(b []byte) ([]byte, error) { + var buf *codec.Buffer + if b == nil { + buf = codec.NewBuffer(make([]byte, m.Size())) + } else { + buf = codec.NewBuffer(b) + } + buf.EncodeUint32(uint32(m.Retval)) + return buf.Bytes(), nil +} +func (m *IPNeighborConfigReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = int32(buf.DecodeUint32()) + return nil +} + +// IPNeighborDetails defines message 'ip_neighbor_details'. +type IPNeighborDetails struct { + Age float64 `binapi:"f64,name=age" json:"age,omitempty"` + Neighbor IPNeighbor `binapi:"ip_neighbor,name=neighbor" json:"neighbor,omitempty"` +} + +func (m *IPNeighborDetails) Reset() { *m = IPNeighborDetails{} } +func (*IPNeighborDetails) GetMessageName() string { return "ip_neighbor_details" } +func (*IPNeighborDetails) GetCrcString() string { return "870e80b9" } +func (*IPNeighborDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IPNeighborDetails) Size() int { + if m == nil { + return 0 + } + var size int + size += 8 // m.Age + size += 4 // m.Neighbor.SwIfIndex + size += 1 // m.Neighbor.Flags + size += 1 * 6 // m.Neighbor.MacAddress + size += 1 // m.Neighbor.IPAddress.Af + size += 1 * 16 // m.Neighbor.IPAddress.Un + return size +} +func (m *IPNeighborDetails) Marshal(b []byte) ([]byte, error) { + var buf *codec.Buffer + if b == nil { + buf = codec.NewBuffer(make([]byte, m.Size())) + } else { + buf = codec.NewBuffer(b) + } + buf.EncodeFloat64(float64(m.Age)) + buf.EncodeUint32(uint32(m.Neighbor.SwIfIndex)) + buf.EncodeUint8(uint8(m.Neighbor.Flags)) + buf.EncodeBytes(m.Neighbor.MacAddress[:], 6) + buf.EncodeUint8(uint8(m.Neighbor.IPAddress.Af)) + buf.EncodeBytes(m.Neighbor.IPAddress.Un.XXX_UnionData[:], 0) + return buf.Bytes(), nil +} +func (m *IPNeighborDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Age = float64(buf.DecodeFloat64()) + m.Neighbor.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Neighbor.Flags = IPNeighborFlags(buf.DecodeUint8()) + copy(m.Neighbor.MacAddress[:], buf.DecodeBytes(6)) + m.Neighbor.IPAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Neighbor.IPAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + return nil +} + +// IPNeighborDump defines message 'ip_neighbor_dump'. +type IPNeighborDump struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index,default=%!s(float64=4.294967295e+09)" json:"sw_if_index,omitempty"` + Af ip_types.AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"` +} + +func (m *IPNeighborDump) Reset() { *m = IPNeighborDump{} } +func (*IPNeighborDump) GetMessageName() string { return "ip_neighbor_dump" } +func (*IPNeighborDump) GetCrcString() string { return "cd831298" } +func (*IPNeighborDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IPNeighborDump) Size() int { + if m == nil { + return 0 + } + var size int + size += 4 // m.SwIfIndex + size += 1 // m.Af + return size +} +func (m *IPNeighborDump) Marshal(b []byte) ([]byte, error) { + var buf *codec.Buffer + if b == nil { + buf = codec.NewBuffer(make([]byte, m.Size())) + } else { + buf = codec.NewBuffer(b) + } + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint8(uint8(m.Af)) + return buf.Bytes(), nil +} +func (m *IPNeighborDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Af = ip_types.AddressFamily(buf.DecodeUint8()) + return nil +} + +// IPNeighborEvent defines message 'ip_neighbor_event'. +type IPNeighborEvent struct { + PID uint32 `binapi:"u32,name=pid" json:"pid,omitempty"` + Neighbor IPNeighbor `binapi:"ip_neighbor,name=neighbor" json:"neighbor,omitempty"` +} + +func (m *IPNeighborEvent) Reset() { *m = IPNeighborEvent{} } +func (*IPNeighborEvent) GetMessageName() string { return "ip_neighbor_event" } +func (*IPNeighborEvent) GetCrcString() string { return "83933131" } +func (*IPNeighborEvent) GetMessageType() api.MessageType { + return api.EventMessage +} + +func (m *IPNeighborEvent) Size() int { + if m == nil { + return 0 + } + var size int + size += 4 // m.PID + size += 4 // m.Neighbor.SwIfIndex + size += 1 // m.Neighbor.Flags + size += 1 * 6 // m.Neighbor.MacAddress + size += 1 // m.Neighbor.IPAddress.Af + size += 1 * 16 // m.Neighbor.IPAddress.Un + return size +} +func (m *IPNeighborEvent) Marshal(b []byte) ([]byte, error) { + var buf *codec.Buffer + if b == nil { + buf = codec.NewBuffer(make([]byte, m.Size())) + } else { + buf = codec.NewBuffer(b) + } + buf.EncodeUint32(uint32(m.PID)) + buf.EncodeUint32(uint32(m.Neighbor.SwIfIndex)) + buf.EncodeUint8(uint8(m.Neighbor.Flags)) + buf.EncodeBytes(m.Neighbor.MacAddress[:], 6) + buf.EncodeUint8(uint8(m.Neighbor.IPAddress.Af)) + buf.EncodeBytes(m.Neighbor.IPAddress.Un.XXX_UnionData[:], 0) + return buf.Bytes(), nil +} +func (m *IPNeighborEvent) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.PID = buf.DecodeUint32() + m.Neighbor.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Neighbor.Flags = IPNeighborFlags(buf.DecodeUint8()) + copy(m.Neighbor.MacAddress[:], buf.DecodeBytes(6)) + m.Neighbor.IPAddress.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Neighbor.IPAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + return nil +} + +// IPNeighborFlush defines message 'ip_neighbor_flush'. +type IPNeighborFlush struct { + Af ip_types.AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index,default=%!s(float64=4.294967295e+09)" json:"sw_if_index,omitempty"` +} + +func (m *IPNeighborFlush) Reset() { *m = IPNeighborFlush{} } +func (*IPNeighborFlush) GetMessageName() string { return "ip_neighbor_flush" } +func (*IPNeighborFlush) GetCrcString() string { return "16aa35d2" } +func (*IPNeighborFlush) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IPNeighborFlush) Size() int { + if m == nil { + return 0 + } + var size int + size += 1 // m.Af + size += 4 // m.SwIfIndex + return size +} +func (m *IPNeighborFlush) Marshal(b []byte) ([]byte, error) { + var buf *codec.Buffer + if b == nil { + buf = codec.NewBuffer(make([]byte, m.Size())) + } else { + buf = codec.NewBuffer(b) + } + buf.EncodeUint8(uint8(m.Af)) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *IPNeighborFlush) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Af = ip_types.AddressFamily(buf.DecodeUint8()) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// IPNeighborFlushReply defines message 'ip_neighbor_flush_reply'. +type IPNeighborFlushReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *IPNeighborFlushReply) Reset() { *m = IPNeighborFlushReply{} } +func (*IPNeighborFlushReply) GetMessageName() string { return "ip_neighbor_flush_reply" } +func (*IPNeighborFlushReply) GetCrcString() string { return "e8d4e804" } +func (*IPNeighborFlushReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IPNeighborFlushReply) Size() int { + if m == nil { + return 0 + } + var size int + size += 4 // m.Retval + return size +} +func (m *IPNeighborFlushReply) Marshal(b []byte) ([]byte, error) { + var buf *codec.Buffer + if b == nil { + buf = codec.NewBuffer(make([]byte, m.Size())) + } else { + buf = codec.NewBuffer(b) + } + buf.EncodeUint32(uint32(m.Retval)) + return buf.Bytes(), nil +} +func (m *IPNeighborFlushReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = int32(buf.DecodeUint32()) + return nil +} + +// IPNeighborReplaceBegin defines message 'ip_neighbor_replace_begin'. +type IPNeighborReplaceBegin struct{} + +func (m *IPNeighborReplaceBegin) Reset() { *m = IPNeighborReplaceBegin{} } +func (*IPNeighborReplaceBegin) GetMessageName() string { return "ip_neighbor_replace_begin" } +func (*IPNeighborReplaceBegin) GetCrcString() string { return "51077d14" } +func (*IPNeighborReplaceBegin) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IPNeighborReplaceBegin) Size() int { + if m == nil { + return 0 + } + var size int + return size +} +func (m *IPNeighborReplaceBegin) Marshal(b []byte) ([]byte, error) { + var buf *codec.Buffer + if b == nil { + buf = codec.NewBuffer(make([]byte, m.Size())) + } else { + buf = codec.NewBuffer(b) + } + return buf.Bytes(), nil +} +func (m *IPNeighborReplaceBegin) Unmarshal(b []byte) error { + return nil +} + +// IPNeighborReplaceBeginReply defines message 'ip_neighbor_replace_begin_reply'. +type IPNeighborReplaceBeginReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *IPNeighborReplaceBeginReply) Reset() { *m = IPNeighborReplaceBeginReply{} } +func (*IPNeighborReplaceBeginReply) GetMessageName() string { return "ip_neighbor_replace_begin_reply" } +func (*IPNeighborReplaceBeginReply) GetCrcString() string { return "e8d4e804" } +func (*IPNeighborReplaceBeginReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IPNeighborReplaceBeginReply) Size() int { + if m == nil { + return 0 + } + var size int + size += 4 // m.Retval + return size +} +func (m *IPNeighborReplaceBeginReply) Marshal(b []byte) ([]byte, error) { + var buf *codec.Buffer + if b == nil { + buf = codec.NewBuffer(make([]byte, m.Size())) + } else { + buf = codec.NewBuffer(b) + } + buf.EncodeUint32(uint32(m.Retval)) + return buf.Bytes(), nil +} +func (m *IPNeighborReplaceBeginReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = int32(buf.DecodeUint32()) + return nil +} + +// IPNeighborReplaceEnd defines message 'ip_neighbor_replace_end'. +type IPNeighborReplaceEnd struct{} + +func (m *IPNeighborReplaceEnd) Reset() { *m = IPNeighborReplaceEnd{} } +func (*IPNeighborReplaceEnd) GetMessageName() string { return "ip_neighbor_replace_end" } +func (*IPNeighborReplaceEnd) GetCrcString() string { return "51077d14" } +func (*IPNeighborReplaceEnd) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IPNeighborReplaceEnd) Size() int { + if m == nil { + return 0 + } + var size int + return size +} +func (m *IPNeighborReplaceEnd) Marshal(b []byte) ([]byte, error) { + var buf *codec.Buffer + if b == nil { + buf = codec.NewBuffer(make([]byte, m.Size())) + } else { + buf = codec.NewBuffer(b) + } + return buf.Bytes(), nil +} +func (m *IPNeighborReplaceEnd) Unmarshal(b []byte) error { + return nil +} + +// IPNeighborReplaceEndReply defines message 'ip_neighbor_replace_end_reply'. +type IPNeighborReplaceEndReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *IPNeighborReplaceEndReply) Reset() { *m = IPNeighborReplaceEndReply{} } +func (*IPNeighborReplaceEndReply) GetMessageName() string { return "ip_neighbor_replace_end_reply" } +func (*IPNeighborReplaceEndReply) GetCrcString() string { return "e8d4e804" } +func (*IPNeighborReplaceEndReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IPNeighborReplaceEndReply) Size() int { + if m == nil { + return 0 + } + var size int + size += 4 // m.Retval + return size +} +func (m *IPNeighborReplaceEndReply) Marshal(b []byte) ([]byte, error) { + var buf *codec.Buffer + if b == nil { + buf = codec.NewBuffer(make([]byte, m.Size())) + } else { + buf = codec.NewBuffer(b) + } + buf.EncodeUint32(uint32(m.Retval)) + return buf.Bytes(), nil +} +func (m *IPNeighborReplaceEndReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = int32(buf.DecodeUint32()) + return nil +} + +// WantIPNeighborEvents defines message 'want_ip_neighbor_events'. +type WantIPNeighborEvents struct { + Enable bool `binapi:"bool,name=enable" json:"enable,omitempty"` + PID uint32 `binapi:"u32,name=pid" json:"pid,omitempty"` + IP ip_types.Address `binapi:"address,name=ip" json:"ip,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index,default=%!s(float64=4.294967295e+09)" json:"sw_if_index,omitempty"` +} + +func (m *WantIPNeighborEvents) Reset() { *m = WantIPNeighborEvents{} } +func (*WantIPNeighborEvents) GetMessageName() string { return "want_ip_neighbor_events" } +func (*WantIPNeighborEvents) GetCrcString() string { return "1a312870" } +func (*WantIPNeighborEvents) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *WantIPNeighborEvents) Size() int { + if m == nil { + return 0 + } + var size int + size += 1 // m.Enable + size += 4 // m.PID + size += 1 // m.IP.Af + size += 1 * 16 // m.IP.Un + size += 4 // m.SwIfIndex + return size +} +func (m *WantIPNeighborEvents) Marshal(b []byte) ([]byte, error) { + var buf *codec.Buffer + if b == nil { + buf = codec.NewBuffer(make([]byte, m.Size())) + } else { + buf = codec.NewBuffer(b) + } + buf.EncodeBool(m.Enable) + buf.EncodeUint32(uint32(m.PID)) + buf.EncodeUint8(uint8(m.IP.Af)) + buf.EncodeBytes(m.IP.Un.XXX_UnionData[:], 0) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *WantIPNeighborEvents) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Enable = buf.DecodeBool() + m.PID = buf.DecodeUint32() + m.IP.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.IP.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// WantIPNeighborEventsReply defines message 'want_ip_neighbor_events_reply'. +type WantIPNeighborEventsReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *WantIPNeighborEventsReply) Reset() { *m = WantIPNeighborEventsReply{} } +func (*WantIPNeighborEventsReply) GetMessageName() string { return "want_ip_neighbor_events_reply" } +func (*WantIPNeighborEventsReply) GetCrcString() string { return "e8d4e804" } +func (*WantIPNeighborEventsReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *WantIPNeighborEventsReply) Size() int { + if m == nil { + return 0 + } + var size int + size += 4 // m.Retval + return size +} +func (m *WantIPNeighborEventsReply) Marshal(b []byte) ([]byte, error) { + var buf *codec.Buffer + if b == nil { + buf = codec.NewBuffer(make([]byte, m.Size())) + } else { + buf = codec.NewBuffer(b) + } + buf.EncodeUint32(uint32(m.Retval)) + return buf.Bytes(), nil +} +func (m *WantIPNeighborEventsReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = int32(buf.DecodeUint32()) + return nil +} + +func init() { file_ip_neighbor_binapi_init() } +func file_ip_neighbor_binapi_init() { + api.RegisterMessage((*IPNeighborAddDel)(nil), "ip_neighbor_add_del_105518b6") + api.RegisterMessage((*IPNeighborAddDelReply)(nil), "ip_neighbor_add_del_reply_1992deab") + api.RegisterMessage((*IPNeighborConfig)(nil), "ip_neighbor_config_f4a5cf44") + api.RegisterMessage((*IPNeighborConfigReply)(nil), "ip_neighbor_config_reply_e8d4e804") + api.RegisterMessage((*IPNeighborDetails)(nil), "ip_neighbor_details_870e80b9") + api.RegisterMessage((*IPNeighborDump)(nil), "ip_neighbor_dump_cd831298") + api.RegisterMessage((*IPNeighborEvent)(nil), "ip_neighbor_event_83933131") + api.RegisterMessage((*IPNeighborFlush)(nil), "ip_neighbor_flush_16aa35d2") + api.RegisterMessage((*IPNeighborFlushReply)(nil), "ip_neighbor_flush_reply_e8d4e804") + api.RegisterMessage((*IPNeighborReplaceBegin)(nil), "ip_neighbor_replace_begin_51077d14") + api.RegisterMessage((*IPNeighborReplaceBeginReply)(nil), "ip_neighbor_replace_begin_reply_e8d4e804") + api.RegisterMessage((*IPNeighborReplaceEnd)(nil), "ip_neighbor_replace_end_51077d14") + api.RegisterMessage((*IPNeighborReplaceEndReply)(nil), "ip_neighbor_replace_end_reply_e8d4e804") + api.RegisterMessage((*WantIPNeighborEvents)(nil), "want_ip_neighbor_events_1a312870") + api.RegisterMessage((*WantIPNeighborEventsReply)(nil), "want_ip_neighbor_events_reply_e8d4e804") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*IPNeighborAddDel)(nil), + (*IPNeighborAddDelReply)(nil), + (*IPNeighborConfig)(nil), + (*IPNeighborConfigReply)(nil), + (*IPNeighborDetails)(nil), + (*IPNeighborDump)(nil), + (*IPNeighborEvent)(nil), + (*IPNeighborFlush)(nil), + (*IPNeighborFlushReply)(nil), + (*IPNeighborReplaceBegin)(nil), + (*IPNeighborReplaceBeginReply)(nil), + (*IPNeighborReplaceEnd)(nil), + (*IPNeighborReplaceEndReply)(nil), + (*WantIPNeighborEvents)(nil), + (*WantIPNeighborEventsReply)(nil), + } +} diff --git a/binapi/ip_neighbor/ip_neighbor_rest.ba.go b/binapi/ip_neighbor/ip_neighbor_rest.ba.go new file mode 100644 index 0000000..7db4694 --- /dev/null +++ b/binapi/ip_neighbor/ip_neighbor_rest.ba.go @@ -0,0 +1,134 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package ip_neighbor + +import ( + "encoding/json" + "io/ioutil" + "net/http" +) + +func RESTHandler(rpc RPCService) http.Handler { + mux := http.NewServeMux() + mux.HandleFunc("/ip_neighbor_add_del", func(w http.ResponseWriter, req *http.Request) { + var request = new(IPNeighborAddDel) + b, err := ioutil.ReadAll(req.Body) + if err != nil { + http.Error(w, "read body failed", http.StatusBadRequest) + return + } + if err := json.Unmarshal(b, request); err != nil { + http.Error(w, "unmarshal data failed", http.StatusBadRequest) + return + } + reply, err := rpc.IPNeighborAddDel(req.Context(), request) + if err != nil { + http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError) + return + } + rep, err := json.MarshalIndent(reply, "", " ") + if err != nil { + http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError) + return + } + w.Write(rep) + }) + mux.HandleFunc("/ip_neighbor_config", func(w http.ResponseWriter, req *http.Request) { + var request = new(IPNeighborConfig) + b, err := ioutil.ReadAll(req.Body) + if err != nil { + http.Error(w, "read body failed", http.StatusBadRequest) + return + } + if err := json.Unmarshal(b, request); err != nil { + http.Error(w, "unmarshal data failed", http.StatusBadRequest) + return + } + reply, err := rpc.IPNeighborConfig(req.Context(), request) + if err != nil { + http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError) + return + } + rep, err := json.MarshalIndent(reply, "", " ") + if err != nil { + http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError) + return + } + w.Write(rep) + }) + mux.HandleFunc("/ip_neighbor_flush", func(w http.ResponseWriter, req *http.Request) { + var request = new(IPNeighborFlush) + b, err := ioutil.ReadAll(req.Body) + if err != nil { + http.Error(w, "read body failed", http.StatusBadRequest) + return + } + if err := json.Unmarshal(b, request); err != nil { + http.Error(w, "unmarshal data failed", http.StatusBadRequest) + return + } + reply, err := rpc.IPNeighborFlush(req.Context(), request) + if err != nil { + http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError) + return + } + rep, err := json.MarshalIndent(reply, "", " ") + if err != nil { + http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError) + return + } + w.Write(rep) + }) + mux.HandleFunc("/ip_neighbor_replace_begin", func(w http.ResponseWriter, req *http.Request) { + var request = new(IPNeighborReplaceBegin) + reply, err := rpc.IPNeighborReplaceBegin(req.Context(), request) + if err != nil { + http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError) + return + } + rep, err := json.MarshalIndent(reply, "", " ") + if err != nil { + http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError) + return + } + w.Write(rep) + }) + mux.HandleFunc("/ip_neighbor_replace_end", func(w http.ResponseWriter, req *http.Request) { + var request = new(IPNeighborReplaceEnd) + reply, err := rpc.IPNeighborReplaceEnd(req.Context(), request) + if err != nil { + http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError) + return + } + rep, err := json.MarshalIndent(reply, "", " ") + if err != nil { + http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError) + return + } + w.Write(rep) + }) + mux.HandleFunc("/want_ip_neighbor_events", func(w http.ResponseWriter, req *http.Request) { + var request = new(WantIPNeighborEvents) + b, err := ioutil.ReadAll(req.Body) + if err != nil { + http.Error(w, "read body failed", http.StatusBadRequest) + return + } + if err := json.Unmarshal(b, request); err != nil { + http.Error(w, "unmarshal data failed", http.StatusBadRequest) + return + } + reply, err := rpc.WantIPNeighborEvents(req.Context(), request) + if err != nil { + http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError) + return + } + rep, err := json.MarshalIndent(reply, "", " ") + if err != nil { + http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError) + return + } + w.Write(rep) + }) + return http.HandlerFunc(mux.ServeHTTP) +} diff --git a/binapi/ip_neighbor/ip_neighbor_rpc.ba.go b/binapi/ip_neighbor/ip_neighbor_rpc.ba.go new file mode 100644 index 0000000..86589dd --- /dev/null +++ b/binapi/ip_neighbor/ip_neighbor_rpc.ba.go @@ -0,0 +1,123 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package ip_neighbor + +import ( + "context" + "fmt" + api "git.fd.io/govpp.git/api" + vpe "git.fd.io/govpp.git/binapi/vpe" + "io" +) + +// RPCService defines RPC service ip_neighbor. +type RPCService interface { + IPNeighborAddDel(ctx context.Context, in *IPNeighborAddDel) (*IPNeighborAddDelReply, error) + IPNeighborConfig(ctx context.Context, in *IPNeighborConfig) (*IPNeighborConfigReply, error) + IPNeighborDump(ctx context.Context, in *IPNeighborDump) (RPCService_IPNeighborDumpClient, error) + IPNeighborFlush(ctx context.Context, in *IPNeighborFlush) (*IPNeighborFlushReply, error) + IPNeighborReplaceBegin(ctx context.Context, in *IPNeighborReplaceBegin) (*IPNeighborReplaceBeginReply, error) + IPNeighborReplaceEnd(ctx context.Context, in *IPNeighborReplaceEnd) (*IPNeighborReplaceEndReply, error) + WantIPNeighborEvents(ctx context.Context, in *WantIPNeighborEvents) (*WantIPNeighborEventsReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) IPNeighborAddDel(ctx context.Context, in *IPNeighborAddDel) (*IPNeighborAddDelReply, error) { + out := new(IPNeighborAddDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) IPNeighborConfig(ctx context.Context, in *IPNeighborConfig) (*IPNeighborConfigReply, error) { + out := new(IPNeighborConfigReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) IPNeighborDump(ctx context.Context, in *IPNeighborDump) (RPCService_IPNeighborDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_IPNeighborDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&vpe.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_IPNeighborDumpClient interface { + Recv() (*IPNeighborDetails, error) + api.Stream +} + +type serviceClient_IPNeighborDumpClient struct { + api.Stream +} + +func (c *serviceClient_IPNeighborDumpClient) Recv() (*IPNeighborDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *IPNeighborDetails: + return m, nil + case *vpe.ControlPingReply: + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) IPNeighborFlush(ctx context.Context, in *IPNeighborFlush) (*IPNeighborFlushReply, error) { + out := new(IPNeighborFlushReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) IPNeighborReplaceBegin(ctx context.Context, in *IPNeighborReplaceBegin) (*IPNeighborReplaceBeginReply, error) { + out := new(IPNeighborReplaceBeginReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) IPNeighborReplaceEnd(ctx context.Context, in *IPNeighborReplaceEnd) (*IPNeighborReplaceEndReply, error) { + out := new(IPNeighborReplaceEndReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) WantIPNeighborEvents(ctx context.Context, in *WantIPNeighborEvents) (*WantIPNeighborEventsReply, error) { + out := new(WantIPNeighborEventsReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, nil +} |