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/dslite | |
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/dslite')
-rw-r--r-- | binapi/dslite/dslite.ba.go | 513 | ||||
-rw-r--r-- | binapi/dslite/dslite_rest.ba.go | 111 | ||||
-rw-r--r-- | binapi/dslite/dslite_rpc.ba.go | 113 |
3 files changed, 737 insertions, 0 deletions
diff --git a/binapi/dslite/dslite.ba.go b/binapi/dslite/dslite.ba.go new file mode 100644 index 0000000..b7aff21 --- /dev/null +++ b/binapi/dslite/dslite.ba.go @@ -0,0 +1,513 @@ +// 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/plugins/dslite.api.json + +// Package dslite contains generated bindings for API file dslite.api. +// +// Contents: +// 12 messages +// +package dslite + +import ( + api "git.fd.io/govpp.git/api" + _ "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" +) + +// 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 = "dslite" + APIVersion = "1.0.0" + VersionCrc = 0xb62715c5 +) + +// DsliteAddDelPoolAddrRange defines message 'dslite_add_del_pool_addr_range'. +type DsliteAddDelPoolAddrRange struct { + StartAddr ip_types.IP4Address `binapi:"ip4_address,name=start_addr" json:"start_addr,omitempty"` + EndAddr ip_types.IP4Address `binapi:"ip4_address,name=end_addr" json:"end_addr,omitempty"` + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` +} + +func (m *DsliteAddDelPoolAddrRange) Reset() { *m = DsliteAddDelPoolAddrRange{} } +func (*DsliteAddDelPoolAddrRange) GetMessageName() string { return "dslite_add_del_pool_addr_range" } +func (*DsliteAddDelPoolAddrRange) GetCrcString() string { return "c448457a" } +func (*DsliteAddDelPoolAddrRange) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *DsliteAddDelPoolAddrRange) Size() int { + if m == nil { + return 0 + } + var size int + size += 1 * 4 // m.StartAddr + size += 1 * 4 // m.EndAddr + size += 1 // m.IsAdd + return size +} +func (m *DsliteAddDelPoolAddrRange) 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.EncodeBytes(m.StartAddr[:], 4) + buf.EncodeBytes(m.EndAddr[:], 4) + buf.EncodeBool(m.IsAdd) + return buf.Bytes(), nil +} +func (m *DsliteAddDelPoolAddrRange) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + copy(m.StartAddr[:], buf.DecodeBytes(4)) + copy(m.EndAddr[:], buf.DecodeBytes(4)) + m.IsAdd = buf.DecodeBool() + return nil +} + +// DsliteAddDelPoolAddrRangeReply defines message 'dslite_add_del_pool_addr_range_reply'. +type DsliteAddDelPoolAddrRangeReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *DsliteAddDelPoolAddrRangeReply) Reset() { *m = DsliteAddDelPoolAddrRangeReply{} } +func (*DsliteAddDelPoolAddrRangeReply) GetMessageName() string { + return "dslite_add_del_pool_addr_range_reply" +} +func (*DsliteAddDelPoolAddrRangeReply) GetCrcString() string { return "e8d4e804" } +func (*DsliteAddDelPoolAddrRangeReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *DsliteAddDelPoolAddrRangeReply) Size() int { + if m == nil { + return 0 + } + var size int + size += 4 // m.Retval + return size +} +func (m *DsliteAddDelPoolAddrRangeReply) 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 *DsliteAddDelPoolAddrRangeReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = int32(buf.DecodeUint32()) + return nil +} + +// DsliteAddressDetails defines message 'dslite_address_details'. +type DsliteAddressDetails struct { + IPAddress ip_types.IP4Address `binapi:"ip4_address,name=ip_address" json:"ip_address,omitempty"` +} + +func (m *DsliteAddressDetails) Reset() { *m = DsliteAddressDetails{} } +func (*DsliteAddressDetails) GetMessageName() string { return "dslite_address_details" } +func (*DsliteAddressDetails) GetCrcString() string { return "ec26d648" } +func (*DsliteAddressDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *DsliteAddressDetails) Size() int { + if m == nil { + return 0 + } + var size int + size += 1 * 4 // m.IPAddress + return size +} +func (m *DsliteAddressDetails) 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.EncodeBytes(m.IPAddress[:], 4) + return buf.Bytes(), nil +} +func (m *DsliteAddressDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + copy(m.IPAddress[:], buf.DecodeBytes(4)) + return nil +} + +// DsliteAddressDump defines message 'dslite_address_dump'. +type DsliteAddressDump struct{} + +func (m *DsliteAddressDump) Reset() { *m = DsliteAddressDump{} } +func (*DsliteAddressDump) GetMessageName() string { return "dslite_address_dump" } +func (*DsliteAddressDump) GetCrcString() string { return "51077d14" } +func (*DsliteAddressDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *DsliteAddressDump) Size() int { + if m == nil { + return 0 + } + var size int + return size +} +func (m *DsliteAddressDump) 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 *DsliteAddressDump) Unmarshal(b []byte) error { + return nil +} + +// DsliteGetAftrAddr defines message 'dslite_get_aftr_addr'. +type DsliteGetAftrAddr struct{} + +func (m *DsliteGetAftrAddr) Reset() { *m = DsliteGetAftrAddr{} } +func (*DsliteGetAftrAddr) GetMessageName() string { return "dslite_get_aftr_addr" } +func (*DsliteGetAftrAddr) GetCrcString() string { return "51077d14" } +func (*DsliteGetAftrAddr) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *DsliteGetAftrAddr) Size() int { + if m == nil { + return 0 + } + var size int + return size +} +func (m *DsliteGetAftrAddr) 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 *DsliteGetAftrAddr) Unmarshal(b []byte) error { + return nil +} + +// DsliteGetAftrAddrReply defines message 'dslite_get_aftr_addr_reply'. +type DsliteGetAftrAddrReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + IP4Addr ip_types.IP4Address `binapi:"ip4_address,name=ip4_addr" json:"ip4_addr,omitempty"` + IP6Addr ip_types.IP6Address `binapi:"ip6_address,name=ip6_addr" json:"ip6_addr,omitempty"` +} + +func (m *DsliteGetAftrAddrReply) Reset() { *m = DsliteGetAftrAddrReply{} } +func (*DsliteGetAftrAddrReply) GetMessageName() string { return "dslite_get_aftr_addr_reply" } +func (*DsliteGetAftrAddrReply) GetCrcString() string { return "38e30db1" } +func (*DsliteGetAftrAddrReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *DsliteGetAftrAddrReply) Size() int { + if m == nil { + return 0 + } + var size int + size += 4 // m.Retval + size += 1 * 4 // m.IP4Addr + size += 1 * 16 // m.IP6Addr + return size +} +func (m *DsliteGetAftrAddrReply) 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.EncodeBytes(m.IP4Addr[:], 4) + buf.EncodeBytes(m.IP6Addr[:], 16) + return buf.Bytes(), nil +} +func (m *DsliteGetAftrAddrReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = int32(buf.DecodeUint32()) + copy(m.IP4Addr[:], buf.DecodeBytes(4)) + copy(m.IP6Addr[:], buf.DecodeBytes(16)) + return nil +} + +// DsliteGetB4Addr defines message 'dslite_get_b4_addr'. +type DsliteGetB4Addr struct{} + +func (m *DsliteGetB4Addr) Reset() { *m = DsliteGetB4Addr{} } +func (*DsliteGetB4Addr) GetMessageName() string { return "dslite_get_b4_addr" } +func (*DsliteGetB4Addr) GetCrcString() string { return "51077d14" } +func (*DsliteGetB4Addr) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *DsliteGetB4Addr) Size() int { + if m == nil { + return 0 + } + var size int + return size +} +func (m *DsliteGetB4Addr) 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 *DsliteGetB4Addr) Unmarshal(b []byte) error { + return nil +} + +// DsliteGetB4AddrReply defines message 'dslite_get_b4_addr_reply'. +type DsliteGetB4AddrReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + IP4Addr ip_types.IP4Address `binapi:"ip4_address,name=ip4_addr" json:"ip4_addr,omitempty"` + IP6Addr ip_types.IP6Address `binapi:"ip6_address,name=ip6_addr" json:"ip6_addr,omitempty"` +} + +func (m *DsliteGetB4AddrReply) Reset() { *m = DsliteGetB4AddrReply{} } +func (*DsliteGetB4AddrReply) GetMessageName() string { return "dslite_get_b4_addr_reply" } +func (*DsliteGetB4AddrReply) GetCrcString() string { return "38e30db1" } +func (*DsliteGetB4AddrReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *DsliteGetB4AddrReply) Size() int { + if m == nil { + return 0 + } + var size int + size += 4 // m.Retval + size += 1 * 4 // m.IP4Addr + size += 1 * 16 // m.IP6Addr + return size +} +func (m *DsliteGetB4AddrReply) 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.EncodeBytes(m.IP4Addr[:], 4) + buf.EncodeBytes(m.IP6Addr[:], 16) + return buf.Bytes(), nil +} +func (m *DsliteGetB4AddrReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = int32(buf.DecodeUint32()) + copy(m.IP4Addr[:], buf.DecodeBytes(4)) + copy(m.IP6Addr[:], buf.DecodeBytes(16)) + return nil +} + +// DsliteSetAftrAddr defines message 'dslite_set_aftr_addr'. +type DsliteSetAftrAddr struct { + IP4Addr ip_types.IP4Address `binapi:"ip4_address,name=ip4_addr" json:"ip4_addr,omitempty"` + IP6Addr ip_types.IP6Address `binapi:"ip6_address,name=ip6_addr" json:"ip6_addr,omitempty"` +} + +func (m *DsliteSetAftrAddr) Reset() { *m = DsliteSetAftrAddr{} } +func (*DsliteSetAftrAddr) GetMessageName() string { return "dslite_set_aftr_addr" } +func (*DsliteSetAftrAddr) GetCrcString() string { return "1e955f8d" } +func (*DsliteSetAftrAddr) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *DsliteSetAftrAddr) Size() int { + if m == nil { + return 0 + } + var size int + size += 1 * 4 // m.IP4Addr + size += 1 * 16 // m.IP6Addr + return size +} +func (m *DsliteSetAftrAddr) 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.EncodeBytes(m.IP4Addr[:], 4) + buf.EncodeBytes(m.IP6Addr[:], 16) + return buf.Bytes(), nil +} +func (m *DsliteSetAftrAddr) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + copy(m.IP4Addr[:], buf.DecodeBytes(4)) + copy(m.IP6Addr[:], buf.DecodeBytes(16)) + return nil +} + +// DsliteSetAftrAddrReply defines message 'dslite_set_aftr_addr_reply'. +type DsliteSetAftrAddrReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *DsliteSetAftrAddrReply) Reset() { *m = DsliteSetAftrAddrReply{} } +func (*DsliteSetAftrAddrReply) GetMessageName() string { return "dslite_set_aftr_addr_reply" } +func (*DsliteSetAftrAddrReply) GetCrcString() string { return "e8d4e804" } +func (*DsliteSetAftrAddrReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *DsliteSetAftrAddrReply) Size() int { + if m == nil { + return 0 + } + var size int + size += 4 // m.Retval + return size +} +func (m *DsliteSetAftrAddrReply) 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 *DsliteSetAftrAddrReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = int32(buf.DecodeUint32()) + return nil +} + +// DsliteSetB4Addr defines message 'dslite_set_b4_addr'. +type DsliteSetB4Addr struct { + IP4Addr ip_types.IP4Address `binapi:"ip4_address,name=ip4_addr" json:"ip4_addr,omitempty"` + IP6Addr ip_types.IP6Address `binapi:"ip6_address,name=ip6_addr" json:"ip6_addr,omitempty"` +} + +func (m *DsliteSetB4Addr) Reset() { *m = DsliteSetB4Addr{} } +func (*DsliteSetB4Addr) GetMessageName() string { return "dslite_set_b4_addr" } +func (*DsliteSetB4Addr) GetCrcString() string { return "1e955f8d" } +func (*DsliteSetB4Addr) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *DsliteSetB4Addr) Size() int { + if m == nil { + return 0 + } + var size int + size += 1 * 4 // m.IP4Addr + size += 1 * 16 // m.IP6Addr + return size +} +func (m *DsliteSetB4Addr) 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.EncodeBytes(m.IP4Addr[:], 4) + buf.EncodeBytes(m.IP6Addr[:], 16) + return buf.Bytes(), nil +} +func (m *DsliteSetB4Addr) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + copy(m.IP4Addr[:], buf.DecodeBytes(4)) + copy(m.IP6Addr[:], buf.DecodeBytes(16)) + return nil +} + +// DsliteSetB4AddrReply defines message 'dslite_set_b4_addr_reply'. +type DsliteSetB4AddrReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *DsliteSetB4AddrReply) Reset() { *m = DsliteSetB4AddrReply{} } +func (*DsliteSetB4AddrReply) GetMessageName() string { return "dslite_set_b4_addr_reply" } +func (*DsliteSetB4AddrReply) GetCrcString() string { return "e8d4e804" } +func (*DsliteSetB4AddrReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *DsliteSetB4AddrReply) Size() int { + if m == nil { + return 0 + } + var size int + size += 4 // m.Retval + return size +} +func (m *DsliteSetB4AddrReply) 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 *DsliteSetB4AddrReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = int32(buf.DecodeUint32()) + return nil +} + +func init() { file_dslite_binapi_init() } +func file_dslite_binapi_init() { + api.RegisterMessage((*DsliteAddDelPoolAddrRange)(nil), "dslite_add_del_pool_addr_range_c448457a") + api.RegisterMessage((*DsliteAddDelPoolAddrRangeReply)(nil), "dslite_add_del_pool_addr_range_reply_e8d4e804") + api.RegisterMessage((*DsliteAddressDetails)(nil), "dslite_address_details_ec26d648") + api.RegisterMessage((*DsliteAddressDump)(nil), "dslite_address_dump_51077d14") + api.RegisterMessage((*DsliteGetAftrAddr)(nil), "dslite_get_aftr_addr_51077d14") + api.RegisterMessage((*DsliteGetAftrAddrReply)(nil), "dslite_get_aftr_addr_reply_38e30db1") + api.RegisterMessage((*DsliteGetB4Addr)(nil), "dslite_get_b4_addr_51077d14") + api.RegisterMessage((*DsliteGetB4AddrReply)(nil), "dslite_get_b4_addr_reply_38e30db1") + api.RegisterMessage((*DsliteSetAftrAddr)(nil), "dslite_set_aftr_addr_1e955f8d") + api.RegisterMessage((*DsliteSetAftrAddrReply)(nil), "dslite_set_aftr_addr_reply_e8d4e804") + api.RegisterMessage((*DsliteSetB4Addr)(nil), "dslite_set_b4_addr_1e955f8d") + api.RegisterMessage((*DsliteSetB4AddrReply)(nil), "dslite_set_b4_addr_reply_e8d4e804") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*DsliteAddDelPoolAddrRange)(nil), + (*DsliteAddDelPoolAddrRangeReply)(nil), + (*DsliteAddressDetails)(nil), + (*DsliteAddressDump)(nil), + (*DsliteGetAftrAddr)(nil), + (*DsliteGetAftrAddrReply)(nil), + (*DsliteGetB4Addr)(nil), + (*DsliteGetB4AddrReply)(nil), + (*DsliteSetAftrAddr)(nil), + (*DsliteSetAftrAddrReply)(nil), + (*DsliteSetB4Addr)(nil), + (*DsliteSetB4AddrReply)(nil), + } +} diff --git a/binapi/dslite/dslite_rest.ba.go b/binapi/dslite/dslite_rest.ba.go new file mode 100644 index 0000000..eba86b0 --- /dev/null +++ b/binapi/dslite/dslite_rest.ba.go @@ -0,0 +1,111 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package dslite + +import ( + "encoding/json" + "io/ioutil" + "net/http" +) + +func RESTHandler(rpc RPCService) http.Handler { + mux := http.NewServeMux() + mux.HandleFunc("/dslite_add_del_pool_addr_range", func(w http.ResponseWriter, req *http.Request) { + var request = new(DsliteAddDelPoolAddrRange) + 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.DsliteAddDelPoolAddrRange(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("/dslite_get_aftr_addr", func(w http.ResponseWriter, req *http.Request) { + var request = new(DsliteGetAftrAddr) + reply, err := rpc.DsliteGetAftrAddr(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("/dslite_get_b4_addr", func(w http.ResponseWriter, req *http.Request) { + var request = new(DsliteGetB4Addr) + reply, err := rpc.DsliteGetB4Addr(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("/dslite_set_aftr_addr", func(w http.ResponseWriter, req *http.Request) { + var request = new(DsliteSetAftrAddr) + 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.DsliteSetAftrAddr(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("/dslite_set_b4_addr", func(w http.ResponseWriter, req *http.Request) { + var request = new(DsliteSetB4Addr) + 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.DsliteSetB4Addr(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/dslite/dslite_rpc.ba.go b/binapi/dslite/dslite_rpc.ba.go new file mode 100644 index 0000000..7f6e90e --- /dev/null +++ b/binapi/dslite/dslite_rpc.ba.go @@ -0,0 +1,113 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package dslite + +import ( + "context" + "fmt" + api "git.fd.io/govpp.git/api" + vpe "git.fd.io/govpp.git/binapi/vpe" + "io" +) + +// RPCService defines RPC service dslite. +type RPCService interface { + DsliteAddDelPoolAddrRange(ctx context.Context, in *DsliteAddDelPoolAddrRange) (*DsliteAddDelPoolAddrRangeReply, error) + DsliteAddressDump(ctx context.Context, in *DsliteAddressDump) (RPCService_DsliteAddressDumpClient, error) + DsliteGetAftrAddr(ctx context.Context, in *DsliteGetAftrAddr) (*DsliteGetAftrAddrReply, error) + DsliteGetB4Addr(ctx context.Context, in *DsliteGetB4Addr) (*DsliteGetB4AddrReply, error) + DsliteSetAftrAddr(ctx context.Context, in *DsliteSetAftrAddr) (*DsliteSetAftrAddrReply, error) + DsliteSetB4Addr(ctx context.Context, in *DsliteSetB4Addr) (*DsliteSetB4AddrReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) DsliteAddDelPoolAddrRange(ctx context.Context, in *DsliteAddDelPoolAddrRange) (*DsliteAddDelPoolAddrRangeReply, error) { + out := new(DsliteAddDelPoolAddrRangeReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) DsliteAddressDump(ctx context.Context, in *DsliteAddressDump) (RPCService_DsliteAddressDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_DsliteAddressDumpClient{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_DsliteAddressDumpClient interface { + Recv() (*DsliteAddressDetails, error) + api.Stream +} + +type serviceClient_DsliteAddressDumpClient struct { + api.Stream +} + +func (c *serviceClient_DsliteAddressDumpClient) Recv() (*DsliteAddressDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *DsliteAddressDetails: + return m, nil + case *vpe.ControlPingReply: + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) DsliteGetAftrAddr(ctx context.Context, in *DsliteGetAftrAddr) (*DsliteGetAftrAddrReply, error) { + out := new(DsliteGetAftrAddrReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) DsliteGetB4Addr(ctx context.Context, in *DsliteGetB4Addr) (*DsliteGetB4AddrReply, error) { + out := new(DsliteGetB4AddrReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) DsliteSetAftrAddr(ctx context.Context, in *DsliteSetAftrAddr) (*DsliteSetAftrAddrReply, error) { + out := new(DsliteSetAftrAddrReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) DsliteSetB4Addr(ctx context.Context, in *DsliteSetB4Addr) (*DsliteSetB4AddrReply, error) { + out := new(DsliteSetB4AddrReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, nil +} |