From d1f24d37bd447b64e402298bb8eb2479681facf9 Mon Sep 17 00:00:00 2001 From: Ondrej Fabry Date: Fri, 17 Jul 2020 10:36:28 +0200 Subject: 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 --- binapi/ipip/ipip.ba.go | 527 ++++++++++++++++++++++++++++++++++++++++++++ binapi/ipip/ipip_rest.ba.go | 106 +++++++++ binapi/ipip/ipip_rpc.ba.go | 103 +++++++++ 3 files changed, 736 insertions(+) create mode 100644 binapi/ipip/ipip.ba.go create mode 100644 binapi/ipip/ipip_rest.ba.go create mode 100644 binapi/ipip/ipip_rpc.ba.go (limited to 'binapi/ipip') diff --git a/binapi/ipip/ipip.ba.go b/binapi/ipip/ipip.ba.go new file mode 100644 index 0000000..aab72c2 --- /dev/null +++ b/binapi/ipip/ipip.ba.go @@ -0,0 +1,527 @@ +// 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/ipip.api.json + +// Package ipip contains generated bindings for API file ipip.api. +// +// Contents: +// 1 struct +// 10 messages +// +package ipip + +import ( + api "git.fd.io/govpp.git/api" + interface_types "git.fd.io/govpp.git/binapi/interface_types" + ip_types "git.fd.io/govpp.git/binapi/ip_types" + tunnel_types "git.fd.io/govpp.git/binapi/tunnel_types" + codec "git.fd.io/govpp.git/codec" +) + +// 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 = "ipip" + APIVersion = "2.0.1" + VersionCrc = 0xa095e728 +) + +// IpipTunnel defines type 'ipip_tunnel'. +type IpipTunnel struct { + Instance uint32 `binapi:"u32,name=instance" json:"instance,omitempty"` + Src ip_types.Address `binapi:"address,name=src" json:"src,omitempty"` + Dst ip_types.Address `binapi:"address,name=dst" json:"dst,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + TableID uint32 `binapi:"u32,name=table_id" json:"table_id,omitempty"` + Flags tunnel_types.TunnelEncapDecapFlags `binapi:"tunnel_encap_decap_flags,name=flags" json:"flags,omitempty"` + Mode tunnel_types.TunnelMode `binapi:"tunnel_mode,name=mode" json:"mode,omitempty"` + Dscp ip_types.IPDscp `binapi:"ip_dscp,name=dscp" json:"dscp,omitempty"` +} + +// Ipip6rdAddTunnel defines message 'ipip_6rd_add_tunnel'. +type Ipip6rdAddTunnel struct { + IP6TableID uint32 `binapi:"u32,name=ip6_table_id" json:"ip6_table_id,omitempty"` + IP4TableID uint32 `binapi:"u32,name=ip4_table_id" json:"ip4_table_id,omitempty"` + IP6Prefix ip_types.IP6Prefix `binapi:"ip6_prefix,name=ip6_prefix" json:"ip6_prefix,omitempty"` + IP4Prefix ip_types.IP4Prefix `binapi:"ip4_prefix,name=ip4_prefix" json:"ip4_prefix,omitempty"` + IP4Src ip_types.IP4Address `binapi:"ip4_address,name=ip4_src" json:"ip4_src,omitempty"` + SecurityCheck bool `binapi:"bool,name=security_check" json:"security_check,omitempty"` + TcTos uint8 `binapi:"u8,name=tc_tos" json:"tc_tos,omitempty"` +} + +func (m *Ipip6rdAddTunnel) Reset() { *m = Ipip6rdAddTunnel{} } +func (*Ipip6rdAddTunnel) GetMessageName() string { return "ipip_6rd_add_tunnel" } +func (*Ipip6rdAddTunnel) GetCrcString() string { return "56e93cc0" } +func (*Ipip6rdAddTunnel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *Ipip6rdAddTunnel) Size() int { + if m == nil { + return 0 + } + var size int + size += 4 // m.IP6TableID + size += 4 // m.IP4TableID + size += 1 * 16 // m.IP6Prefix.Address + size += 1 // m.IP6Prefix.Len + size += 1 * 4 // m.IP4Prefix.Address + size += 1 // m.IP4Prefix.Len + size += 1 * 4 // m.IP4Src + size += 1 // m.SecurityCheck + size += 1 // m.TcTos + return size +} +func (m *Ipip6rdAddTunnel) 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.IP6TableID)) + buf.EncodeUint32(uint32(m.IP4TableID)) + buf.EncodeBytes(m.IP6Prefix.Address[:], 16) + buf.EncodeUint8(uint8(m.IP6Prefix.Len)) + buf.EncodeBytes(m.IP4Prefix.Address[:], 4) + buf.EncodeUint8(uint8(m.IP4Prefix.Len)) + buf.EncodeBytes(m.IP4Src[:], 4) + buf.EncodeBool(m.SecurityCheck) + buf.EncodeUint8(uint8(m.TcTos)) + return buf.Bytes(), nil +} +func (m *Ipip6rdAddTunnel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IP6TableID = buf.DecodeUint32() + m.IP4TableID = buf.DecodeUint32() + copy(m.IP6Prefix.Address[:], buf.DecodeBytes(16)) + m.IP6Prefix.Len = buf.DecodeUint8() + copy(m.IP4Prefix.Address[:], buf.DecodeBytes(4)) + m.IP4Prefix.Len = buf.DecodeUint8() + copy(m.IP4Src[:], buf.DecodeBytes(4)) + m.SecurityCheck = buf.DecodeBool() + m.TcTos = buf.DecodeUint8() + return nil +} + +// Ipip6rdAddTunnelReply defines message 'ipip_6rd_add_tunnel_reply'. +type Ipip6rdAddTunnelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *Ipip6rdAddTunnelReply) Reset() { *m = Ipip6rdAddTunnelReply{} } +func (*Ipip6rdAddTunnelReply) GetMessageName() string { return "ipip_6rd_add_tunnel_reply" } +func (*Ipip6rdAddTunnelReply) GetCrcString() string { return "5383d31f" } +func (*Ipip6rdAddTunnelReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *Ipip6rdAddTunnelReply) Size() int { + if m == nil { + return 0 + } + var size int + size += 4 // m.Retval + size += 4 // m.SwIfIndex + return size +} +func (m *Ipip6rdAddTunnelReply) 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.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *Ipip6rdAddTunnelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = int32(buf.DecodeUint32()) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Ipip6rdDelTunnel defines message 'ipip_6rd_del_tunnel'. +type Ipip6rdDelTunnel struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *Ipip6rdDelTunnel) Reset() { *m = Ipip6rdDelTunnel{} } +func (*Ipip6rdDelTunnel) GetMessageName() string { return "ipip_6rd_del_tunnel" } +func (*Ipip6rdDelTunnel) GetCrcString() string { return "f9e6675e" } +func (*Ipip6rdDelTunnel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *Ipip6rdDelTunnel) Size() int { + if m == nil { + return 0 + } + var size int + size += 4 // m.SwIfIndex + return size +} +func (m *Ipip6rdDelTunnel) 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)) + return buf.Bytes(), nil +} +func (m *Ipip6rdDelTunnel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Ipip6rdDelTunnelReply defines message 'ipip_6rd_del_tunnel_reply'. +type Ipip6rdDelTunnelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *Ipip6rdDelTunnelReply) Reset() { *m = Ipip6rdDelTunnelReply{} } +func (*Ipip6rdDelTunnelReply) GetMessageName() string { return "ipip_6rd_del_tunnel_reply" } +func (*Ipip6rdDelTunnelReply) GetCrcString() string { return "e8d4e804" } +func (*Ipip6rdDelTunnelReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *Ipip6rdDelTunnelReply) Size() int { + if m == nil { + return 0 + } + var size int + size += 4 // m.Retval + return size +} +func (m *Ipip6rdDelTunnelReply) 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 *Ipip6rdDelTunnelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = int32(buf.DecodeUint32()) + return nil +} + +// IpipAddTunnel defines message 'ipip_add_tunnel'. +type IpipAddTunnel struct { + Tunnel IpipTunnel `binapi:"ipip_tunnel,name=tunnel" json:"tunnel,omitempty"` +} + +func (m *IpipAddTunnel) Reset() { *m = IpipAddTunnel{} } +func (*IpipAddTunnel) GetMessageName() string { return "ipip_add_tunnel" } +func (*IpipAddTunnel) GetCrcString() string { return "a9decfcd" } +func (*IpipAddTunnel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IpipAddTunnel) Size() int { + if m == nil { + return 0 + } + var size int + size += 4 // m.Tunnel.Instance + size += 1 // m.Tunnel.Src.Af + size += 1 * 16 // m.Tunnel.Src.Un + size += 1 // m.Tunnel.Dst.Af + size += 1 * 16 // m.Tunnel.Dst.Un + size += 4 // m.Tunnel.SwIfIndex + size += 4 // m.Tunnel.TableID + size += 1 // m.Tunnel.Flags + size += 1 // m.Tunnel.Mode + size += 1 // m.Tunnel.Dscp + return size +} +func (m *IpipAddTunnel) 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.Tunnel.Instance)) + buf.EncodeUint8(uint8(m.Tunnel.Src.Af)) + buf.EncodeBytes(m.Tunnel.Src.Un.XXX_UnionData[:], 0) + buf.EncodeUint8(uint8(m.Tunnel.Dst.Af)) + buf.EncodeBytes(m.Tunnel.Dst.Un.XXX_UnionData[:], 0) + buf.EncodeUint32(uint32(m.Tunnel.SwIfIndex)) + buf.EncodeUint32(uint32(m.Tunnel.TableID)) + buf.EncodeUint8(uint8(m.Tunnel.Flags)) + buf.EncodeUint8(uint8(m.Tunnel.Mode)) + buf.EncodeUint8(uint8(m.Tunnel.Dscp)) + return buf.Bytes(), nil +} +func (m *IpipAddTunnel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Tunnel.Instance = buf.DecodeUint32() + m.Tunnel.Src.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Tunnel.Src.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Tunnel.Dst.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Tunnel.Dst.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Tunnel.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Tunnel.TableID = buf.DecodeUint32() + m.Tunnel.Flags = tunnel_types.TunnelEncapDecapFlags(buf.DecodeUint8()) + m.Tunnel.Mode = tunnel_types.TunnelMode(buf.DecodeUint8()) + m.Tunnel.Dscp = ip_types.IPDscp(buf.DecodeUint8()) + return nil +} + +// IpipAddTunnelReply defines message 'ipip_add_tunnel_reply'. +type IpipAddTunnelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *IpipAddTunnelReply) Reset() { *m = IpipAddTunnelReply{} } +func (*IpipAddTunnelReply) GetMessageName() string { return "ipip_add_tunnel_reply" } +func (*IpipAddTunnelReply) GetCrcString() string { return "5383d31f" } +func (*IpipAddTunnelReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IpipAddTunnelReply) Size() int { + if m == nil { + return 0 + } + var size int + size += 4 // m.Retval + size += 4 // m.SwIfIndex + return size +} +func (m *IpipAddTunnelReply) 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.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *IpipAddTunnelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = int32(buf.DecodeUint32()) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// IpipDelTunnel defines message 'ipip_del_tunnel'. +type IpipDelTunnel struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *IpipDelTunnel) Reset() { *m = IpipDelTunnel{} } +func (*IpipDelTunnel) GetMessageName() string { return "ipip_del_tunnel" } +func (*IpipDelTunnel) GetCrcString() string { return "f9e6675e" } +func (*IpipDelTunnel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IpipDelTunnel) Size() int { + if m == nil { + return 0 + } + var size int + size += 4 // m.SwIfIndex + return size +} +func (m *IpipDelTunnel) 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)) + return buf.Bytes(), nil +} +func (m *IpipDelTunnel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// IpipDelTunnelReply defines message 'ipip_del_tunnel_reply'. +type IpipDelTunnelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *IpipDelTunnelReply) Reset() { *m = IpipDelTunnelReply{} } +func (*IpipDelTunnelReply) GetMessageName() string { return "ipip_del_tunnel_reply" } +func (*IpipDelTunnelReply) GetCrcString() string { return "e8d4e804" } +func (*IpipDelTunnelReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IpipDelTunnelReply) Size() int { + if m == nil { + return 0 + } + var size int + size += 4 // m.Retval + return size +} +func (m *IpipDelTunnelReply) 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 *IpipDelTunnelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = int32(buf.DecodeUint32()) + return nil +} + +// IpipTunnelDetails defines message 'ipip_tunnel_details'. +type IpipTunnelDetails struct { + Tunnel IpipTunnel `binapi:"ipip_tunnel,name=tunnel" json:"tunnel,omitempty"` +} + +func (m *IpipTunnelDetails) Reset() { *m = IpipTunnelDetails{} } +func (*IpipTunnelDetails) GetMessageName() string { return "ipip_tunnel_details" } +func (*IpipTunnelDetails) GetCrcString() string { return "53236d75" } +func (*IpipTunnelDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IpipTunnelDetails) Size() int { + if m == nil { + return 0 + } + var size int + size += 4 // m.Tunnel.Instance + size += 1 // m.Tunnel.Src.Af + size += 1 * 16 // m.Tunnel.Src.Un + size += 1 // m.Tunnel.Dst.Af + size += 1 * 16 // m.Tunnel.Dst.Un + size += 4 // m.Tunnel.SwIfIndex + size += 4 // m.Tunnel.TableID + size += 1 // m.Tunnel.Flags + size += 1 // m.Tunnel.Mode + size += 1 // m.Tunnel.Dscp + return size +} +func (m *IpipTunnelDetails) 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.Tunnel.Instance)) + buf.EncodeUint8(uint8(m.Tunnel.Src.Af)) + buf.EncodeBytes(m.Tunnel.Src.Un.XXX_UnionData[:], 0) + buf.EncodeUint8(uint8(m.Tunnel.Dst.Af)) + buf.EncodeBytes(m.Tunnel.Dst.Un.XXX_UnionData[:], 0) + buf.EncodeUint32(uint32(m.Tunnel.SwIfIndex)) + buf.EncodeUint32(uint32(m.Tunnel.TableID)) + buf.EncodeUint8(uint8(m.Tunnel.Flags)) + buf.EncodeUint8(uint8(m.Tunnel.Mode)) + buf.EncodeUint8(uint8(m.Tunnel.Dscp)) + return buf.Bytes(), nil +} +func (m *IpipTunnelDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Tunnel.Instance = buf.DecodeUint32() + m.Tunnel.Src.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Tunnel.Src.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Tunnel.Dst.Af = ip_types.AddressFamily(buf.DecodeUint8()) + copy(m.Tunnel.Dst.Un.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Tunnel.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.Tunnel.TableID = buf.DecodeUint32() + m.Tunnel.Flags = tunnel_types.TunnelEncapDecapFlags(buf.DecodeUint8()) + m.Tunnel.Mode = tunnel_types.TunnelMode(buf.DecodeUint8()) + m.Tunnel.Dscp = ip_types.IPDscp(buf.DecodeUint8()) + return nil +} + +// IpipTunnelDump defines message 'ipip_tunnel_dump'. +type IpipTunnelDump struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *IpipTunnelDump) Reset() { *m = IpipTunnelDump{} } +func (*IpipTunnelDump) GetMessageName() string { return "ipip_tunnel_dump" } +func (*IpipTunnelDump) GetCrcString() string { return "f9e6675e" } +func (*IpipTunnelDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IpipTunnelDump) Size() int { + if m == nil { + return 0 + } + var size int + size += 4 // m.SwIfIndex + return size +} +func (m *IpipTunnelDump) 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)) + return buf.Bytes(), nil +} +func (m *IpipTunnelDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +func init() { file_ipip_binapi_init() } +func file_ipip_binapi_init() { + api.RegisterMessage((*Ipip6rdAddTunnel)(nil), "ipip_6rd_add_tunnel_56e93cc0") + api.RegisterMessage((*Ipip6rdAddTunnelReply)(nil), "ipip_6rd_add_tunnel_reply_5383d31f") + api.RegisterMessage((*Ipip6rdDelTunnel)(nil), "ipip_6rd_del_tunnel_f9e6675e") + api.RegisterMessage((*Ipip6rdDelTunnelReply)(nil), "ipip_6rd_del_tunnel_reply_e8d4e804") + api.RegisterMessage((*IpipAddTunnel)(nil), "ipip_add_tunnel_a9decfcd") + api.RegisterMessage((*IpipAddTunnelReply)(nil), "ipip_add_tunnel_reply_5383d31f") + api.RegisterMessage((*IpipDelTunnel)(nil), "ipip_del_tunnel_f9e6675e") + api.RegisterMessage((*IpipDelTunnelReply)(nil), "ipip_del_tunnel_reply_e8d4e804") + api.RegisterMessage((*IpipTunnelDetails)(nil), "ipip_tunnel_details_53236d75") + api.RegisterMessage((*IpipTunnelDump)(nil), "ipip_tunnel_dump_f9e6675e") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*Ipip6rdAddTunnel)(nil), + (*Ipip6rdAddTunnelReply)(nil), + (*Ipip6rdDelTunnel)(nil), + (*Ipip6rdDelTunnelReply)(nil), + (*IpipAddTunnel)(nil), + (*IpipAddTunnelReply)(nil), + (*IpipDelTunnel)(nil), + (*IpipDelTunnelReply)(nil), + (*IpipTunnelDetails)(nil), + (*IpipTunnelDump)(nil), + } +} diff --git a/binapi/ipip/ipip_rest.ba.go b/binapi/ipip/ipip_rest.ba.go new file mode 100644 index 0000000..63fe220 --- /dev/null +++ b/binapi/ipip/ipip_rest.ba.go @@ -0,0 +1,106 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package ipip + +import ( + "encoding/json" + "io/ioutil" + "net/http" +) + +func RESTHandler(rpc RPCService) http.Handler { + mux := http.NewServeMux() + mux.HandleFunc("/ipip_6rd_add_tunnel", func(w http.ResponseWriter, req *http.Request) { + var request = new(Ipip6rdAddTunnel) + 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.Ipip6rdAddTunnel(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("/ipip_6rd_del_tunnel", func(w http.ResponseWriter, req *http.Request) { + var request = new(Ipip6rdDelTunnel) + 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.Ipip6rdDelTunnel(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("/ipip_add_tunnel", func(w http.ResponseWriter, req *http.Request) { + var request = new(IpipAddTunnel) + 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.IpipAddTunnel(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("/ipip_del_tunnel", func(w http.ResponseWriter, req *http.Request) { + var request = new(IpipDelTunnel) + 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.IpipDelTunnel(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/ipip/ipip_rpc.ba.go b/binapi/ipip/ipip_rpc.ba.go new file mode 100644 index 0000000..bab3b22 --- /dev/null +++ b/binapi/ipip/ipip_rpc.ba.go @@ -0,0 +1,103 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package ipip + +import ( + "context" + "fmt" + api "git.fd.io/govpp.git/api" + vpe "git.fd.io/govpp.git/binapi/vpe" + "io" +) + +// RPCService defines RPC service ipip. +type RPCService interface { + Ipip6rdAddTunnel(ctx context.Context, in *Ipip6rdAddTunnel) (*Ipip6rdAddTunnelReply, error) + Ipip6rdDelTunnel(ctx context.Context, in *Ipip6rdDelTunnel) (*Ipip6rdDelTunnelReply, error) + IpipAddTunnel(ctx context.Context, in *IpipAddTunnel) (*IpipAddTunnelReply, error) + IpipDelTunnel(ctx context.Context, in *IpipDelTunnel) (*IpipDelTunnelReply, error) + IpipTunnelDump(ctx context.Context, in *IpipTunnelDump) (RPCService_IpipTunnelDumpClient, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) Ipip6rdAddTunnel(ctx context.Context, in *Ipip6rdAddTunnel) (*Ipip6rdAddTunnelReply, error) { + out := new(Ipip6rdAddTunnelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) Ipip6rdDelTunnel(ctx context.Context, in *Ipip6rdDelTunnel) (*Ipip6rdDelTunnelReply, error) { + out := new(Ipip6rdDelTunnelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) IpipAddTunnel(ctx context.Context, in *IpipAddTunnel) (*IpipAddTunnelReply, error) { + out := new(IpipAddTunnelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) IpipDelTunnel(ctx context.Context, in *IpipDelTunnel) (*IpipDelTunnelReply, error) { + out := new(IpipDelTunnelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) IpipTunnelDump(ctx context.Context, in *IpipTunnelDump) (RPCService_IpipTunnelDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_IpipTunnelDumpClient{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_IpipTunnelDumpClient interface { + Recv() (*IpipTunnelDetails, error) + api.Stream +} + +type serviceClient_IpipTunnelDumpClient struct { + api.Stream +} + +func (c *serviceClient_IpipTunnelDumpClient) Recv() (*IpipTunnelDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *IpipTunnelDetails: + return m, nil + case *vpe.ControlPingReply: + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} -- cgit 1.2.3-korg