aboutsummaryrefslogtreecommitdiffstats
path: root/binapi/dns
diff options
context:
space:
mode:
authorOndrej Fabry <ofabry@cisco.com>2020-07-17 10:36:28 +0200
committerOndrej Fabry <ofabry@cisco.com>2020-07-17 11:43:41 +0200
commitd1f24d37bd447b64e402298bb8eb2479681facf9 (patch)
treea3fc21ba730a91d8a402c7a5bf9c614e3677c4fc /binapi/dns
parent1548c7e12531e3d055567d761c580a1c7ff0ac40 (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/dns')
-rw-r--r--binapi/dns/dns.ba.go375
-rw-r--r--binapi/dns/dns_rest.ba.go106
-rw-r--r--binapi/dns/dns_rpc.ba.go60
3 files changed, 541 insertions, 0 deletions
diff --git a/binapi/dns/dns.ba.go b/binapi/dns/dns.ba.go
new file mode 100644
index 0000000..25c8ddf
--- /dev/null
+++ b/binapi/dns/dns.ba.go
@@ -0,0 +1,375 @@
+// 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/dns.api.json
+
+// Package dns contains generated bindings for API file dns.api.
+//
+// Contents:
+// 8 messages
+//
+package dns
+
+import (
+ api "git.fd.io/govpp.git/api"
+ 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 = "dns"
+ APIVersion = "1.0.0"
+ VersionCrc = 0x269575cd
+)
+
+// DNSEnableDisable defines message 'dns_enable_disable'.
+type DNSEnableDisable struct {
+ Enable uint8 `binapi:"u8,name=enable" json:"enable,omitempty"`
+}
+
+func (m *DNSEnableDisable) Reset() { *m = DNSEnableDisable{} }
+func (*DNSEnableDisable) GetMessageName() string { return "dns_enable_disable" }
+func (*DNSEnableDisable) GetCrcString() string { return "8050327d" }
+func (*DNSEnableDisable) GetMessageType() api.MessageType {
+ return api.RequestMessage
+}
+
+func (m *DNSEnableDisable) Size() int {
+ if m == nil {
+ return 0
+ }
+ var size int
+ size += 1 // m.Enable
+ return size
+}
+func (m *DNSEnableDisable) 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.Enable))
+ return buf.Bytes(), nil
+}
+func (m *DNSEnableDisable) Unmarshal(b []byte) error {
+ buf := codec.NewBuffer(b)
+ m.Enable = buf.DecodeUint8()
+ return nil
+}
+
+// DNSEnableDisableReply defines message 'dns_enable_disable_reply'.
+type DNSEnableDisableReply struct {
+ Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
+}
+
+func (m *DNSEnableDisableReply) Reset() { *m = DNSEnableDisableReply{} }
+func (*DNSEnableDisableReply) GetMessageName() string { return "dns_enable_disable_reply" }
+func (*DNSEnableDisableReply) GetCrcString() string { return "e8d4e804" }
+func (*DNSEnableDisableReply) GetMessageType() api.MessageType {
+ return api.ReplyMessage
+}
+
+func (m *DNSEnableDisableReply) Size() int {
+ if m == nil {
+ return 0
+ }
+ var size int
+ size += 4 // m.Retval
+ return size
+}
+func (m *DNSEnableDisableReply) 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 *DNSEnableDisableReply) Unmarshal(b []byte) error {
+ buf := codec.NewBuffer(b)
+ m.Retval = int32(buf.DecodeUint32())
+ return nil
+}
+
+// DNSNameServerAddDel defines message 'dns_name_server_add_del'.
+type DNSNameServerAddDel struct {
+ IsIP6 uint8 `binapi:"u8,name=is_ip6" json:"is_ip6,omitempty"`
+ IsAdd uint8 `binapi:"u8,name=is_add" json:"is_add,omitempty"`
+ ServerAddress []byte `binapi:"u8[16],name=server_address" json:"server_address,omitempty"`
+}
+
+func (m *DNSNameServerAddDel) Reset() { *m = DNSNameServerAddDel{} }
+func (*DNSNameServerAddDel) GetMessageName() string { return "dns_name_server_add_del" }
+func (*DNSNameServerAddDel) GetCrcString() string { return "3bb05d8c" }
+func (*DNSNameServerAddDel) GetMessageType() api.MessageType {
+ return api.RequestMessage
+}
+
+func (m *DNSNameServerAddDel) Size() int {
+ if m == nil {
+ return 0
+ }
+ var size int
+ size += 1 // m.IsIP6
+ size += 1 // m.IsAdd
+ size += 1 * 16 // m.ServerAddress
+ return size
+}
+func (m *DNSNameServerAddDel) 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.IsIP6))
+ buf.EncodeUint8(uint8(m.IsAdd))
+ buf.EncodeBytes(m.ServerAddress[:], 16)
+ return buf.Bytes(), nil
+}
+func (m *DNSNameServerAddDel) Unmarshal(b []byte) error {
+ buf := codec.NewBuffer(b)
+ m.IsIP6 = buf.DecodeUint8()
+ m.IsAdd = buf.DecodeUint8()
+ copy(m.ServerAddress[:], buf.DecodeBytes(16))
+ return nil
+}
+
+// DNSNameServerAddDelReply defines message 'dns_name_server_add_del_reply'.
+type DNSNameServerAddDelReply struct {
+ Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
+}
+
+func (m *DNSNameServerAddDelReply) Reset() { *m = DNSNameServerAddDelReply{} }
+func (*DNSNameServerAddDelReply) GetMessageName() string { return "dns_name_server_add_del_reply" }
+func (*DNSNameServerAddDelReply) GetCrcString() string { return "e8d4e804" }
+func (*DNSNameServerAddDelReply) GetMessageType() api.MessageType {
+ return api.ReplyMessage
+}
+
+func (m *DNSNameServerAddDelReply) Size() int {
+ if m == nil {
+ return 0
+ }
+ var size int
+ size += 4 // m.Retval
+ return size
+}
+func (m *DNSNameServerAddDelReply) 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 *DNSNameServerAddDelReply) Unmarshal(b []byte) error {
+ buf := codec.NewBuffer(b)
+ m.Retval = int32(buf.DecodeUint32())
+ return nil
+}
+
+// DNSResolveIP defines message 'dns_resolve_ip'.
+type DNSResolveIP struct {
+ IsIP6 uint8 `binapi:"u8,name=is_ip6" json:"is_ip6,omitempty"`
+ Address []byte `binapi:"u8[16],name=address" json:"address,omitempty"`
+}
+
+func (m *DNSResolveIP) Reset() { *m = DNSResolveIP{} }
+func (*DNSResolveIP) GetMessageName() string { return "dns_resolve_ip" }
+func (*DNSResolveIP) GetCrcString() string { return "ae96a1a3" }
+func (*DNSResolveIP) GetMessageType() api.MessageType {
+ return api.RequestMessage
+}
+
+func (m *DNSResolveIP) Size() int {
+ if m == nil {
+ return 0
+ }
+ var size int
+ size += 1 // m.IsIP6
+ size += 1 * 16 // m.Address
+ return size
+}
+func (m *DNSResolveIP) 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.IsIP6))
+ buf.EncodeBytes(m.Address[:], 16)
+ return buf.Bytes(), nil
+}
+func (m *DNSResolveIP) Unmarshal(b []byte) error {
+ buf := codec.NewBuffer(b)
+ m.IsIP6 = buf.DecodeUint8()
+ copy(m.Address[:], buf.DecodeBytes(16))
+ return nil
+}
+
+// DNSResolveIPReply defines message 'dns_resolve_ip_reply'.
+type DNSResolveIPReply struct {
+ Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
+ Name []byte `binapi:"u8[256],name=name" json:"name,omitempty"`
+}
+
+func (m *DNSResolveIPReply) Reset() { *m = DNSResolveIPReply{} }
+func (*DNSResolveIPReply) GetMessageName() string { return "dns_resolve_ip_reply" }
+func (*DNSResolveIPReply) GetCrcString() string { return "49ed78d6" }
+func (*DNSResolveIPReply) GetMessageType() api.MessageType {
+ return api.ReplyMessage
+}
+
+func (m *DNSResolveIPReply) Size() int {
+ if m == nil {
+ return 0
+ }
+ var size int
+ size += 4 // m.Retval
+ size += 1 * 256 // m.Name
+ return size
+}
+func (m *DNSResolveIPReply) 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.Name[:], 256)
+ return buf.Bytes(), nil
+}
+func (m *DNSResolveIPReply) Unmarshal(b []byte) error {
+ buf := codec.NewBuffer(b)
+ m.Retval = int32(buf.DecodeUint32())
+ copy(m.Name[:], buf.DecodeBytes(256))
+ return nil
+}
+
+// DNSResolveName defines message 'dns_resolve_name'.
+type DNSResolveName struct {
+ Name []byte `binapi:"u8[256],name=name" json:"name,omitempty"`
+}
+
+func (m *DNSResolveName) Reset() { *m = DNSResolveName{} }
+func (*DNSResolveName) GetMessageName() string { return "dns_resolve_name" }
+func (*DNSResolveName) GetCrcString() string { return "c6566676" }
+func (*DNSResolveName) GetMessageType() api.MessageType {
+ return api.RequestMessage
+}
+
+func (m *DNSResolveName) Size() int {
+ if m == nil {
+ return 0
+ }
+ var size int
+ size += 1 * 256 // m.Name
+ return size
+}
+func (m *DNSResolveName) 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.Name[:], 256)
+ return buf.Bytes(), nil
+}
+func (m *DNSResolveName) Unmarshal(b []byte) error {
+ buf := codec.NewBuffer(b)
+ copy(m.Name[:], buf.DecodeBytes(256))
+ return nil
+}
+
+// DNSResolveNameReply defines message 'dns_resolve_name_reply'.
+type DNSResolveNameReply struct {
+ Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
+ IP4Set uint8 `binapi:"u8,name=ip4_set" json:"ip4_set,omitempty"`
+ IP6Set uint8 `binapi:"u8,name=ip6_set" json:"ip6_set,omitempty"`
+ IP4Address []byte `binapi:"u8[4],name=ip4_address" json:"ip4_address,omitempty"`
+ IP6Address []byte `binapi:"u8[16],name=ip6_address" json:"ip6_address,omitempty"`
+}
+
+func (m *DNSResolveNameReply) Reset() { *m = DNSResolveNameReply{} }
+func (*DNSResolveNameReply) GetMessageName() string { return "dns_resolve_name_reply" }
+func (*DNSResolveNameReply) GetCrcString() string { return "c2d758c3" }
+func (*DNSResolveNameReply) GetMessageType() api.MessageType {
+ return api.ReplyMessage
+}
+
+func (m *DNSResolveNameReply) Size() int {
+ if m == nil {
+ return 0
+ }
+ var size int
+ size += 4 // m.Retval
+ size += 1 // m.IP4Set
+ size += 1 // m.IP6Set
+ size += 1 * 4 // m.IP4Address
+ size += 1 * 16 // m.IP6Address
+ return size
+}
+func (m *DNSResolveNameReply) 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.EncodeUint8(uint8(m.IP4Set))
+ buf.EncodeUint8(uint8(m.IP6Set))
+ buf.EncodeBytes(m.IP4Address[:], 4)
+ buf.EncodeBytes(m.IP6Address[:], 16)
+ return buf.Bytes(), nil
+}
+func (m *DNSResolveNameReply) Unmarshal(b []byte) error {
+ buf := codec.NewBuffer(b)
+ m.Retval = int32(buf.DecodeUint32())
+ m.IP4Set = buf.DecodeUint8()
+ m.IP6Set = buf.DecodeUint8()
+ copy(m.IP4Address[:], buf.DecodeBytes(4))
+ copy(m.IP6Address[:], buf.DecodeBytes(16))
+ return nil
+}
+
+func init() { file_dns_binapi_init() }
+func file_dns_binapi_init() {
+ api.RegisterMessage((*DNSEnableDisable)(nil), "dns_enable_disable_8050327d")
+ api.RegisterMessage((*DNSEnableDisableReply)(nil), "dns_enable_disable_reply_e8d4e804")
+ api.RegisterMessage((*DNSNameServerAddDel)(nil), "dns_name_server_add_del_3bb05d8c")
+ api.RegisterMessage((*DNSNameServerAddDelReply)(nil), "dns_name_server_add_del_reply_e8d4e804")
+ api.RegisterMessage((*DNSResolveIP)(nil), "dns_resolve_ip_ae96a1a3")
+ api.RegisterMessage((*DNSResolveIPReply)(nil), "dns_resolve_ip_reply_49ed78d6")
+ api.RegisterMessage((*DNSResolveName)(nil), "dns_resolve_name_c6566676")
+ api.RegisterMessage((*DNSResolveNameReply)(nil), "dns_resolve_name_reply_c2d758c3")
+}
+
+// Messages returns list of all messages in this module.
+func AllMessages() []api.Message {
+ return []api.Message{
+ (*DNSEnableDisable)(nil),
+ (*DNSEnableDisableReply)(nil),
+ (*DNSNameServerAddDel)(nil),
+ (*DNSNameServerAddDelReply)(nil),
+ (*DNSResolveIP)(nil),
+ (*DNSResolveIPReply)(nil),
+ (*DNSResolveName)(nil),
+ (*DNSResolveNameReply)(nil),
+ }
+}
diff --git a/binapi/dns/dns_rest.ba.go b/binapi/dns/dns_rest.ba.go
new file mode 100644
index 0000000..e67d971
--- /dev/null
+++ b/binapi/dns/dns_rest.ba.go
@@ -0,0 +1,106 @@
+// Code generated by GoVPP's binapi-generator. DO NOT EDIT.
+
+package dns
+
+import (
+ "encoding/json"
+ "io/ioutil"
+ "net/http"
+)
+
+func RESTHandler(rpc RPCService) http.Handler {
+ mux := http.NewServeMux()
+ mux.HandleFunc("/dns_enable_disable", func(w http.ResponseWriter, req *http.Request) {
+ var request = new(DNSEnableDisable)
+ 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.DNSEnableDisable(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("/dns_name_server_add_del", func(w http.ResponseWriter, req *http.Request) {
+ var request = new(DNSNameServerAddDel)
+ 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.DNSNameServerAddDel(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("/dns_resolve_ip", func(w http.ResponseWriter, req *http.Request) {
+ var request = new(DNSResolveIP)
+ 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.DNSResolveIP(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("/dns_resolve_name", func(w http.ResponseWriter, req *http.Request) {
+ var request = new(DNSResolveName)
+ 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.DNSResolveName(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/dns/dns_rpc.ba.go b/binapi/dns/dns_rpc.ba.go
new file mode 100644
index 0000000..57760ab
--- /dev/null
+++ b/binapi/dns/dns_rpc.ba.go
@@ -0,0 +1,60 @@
+// Code generated by GoVPP's binapi-generator. DO NOT EDIT.
+
+package dns
+
+import (
+ "context"
+ api "git.fd.io/govpp.git/api"
+)
+
+// RPCService defines RPC service dns.
+type RPCService interface {
+ DNSEnableDisable(ctx context.Context, in *DNSEnableDisable) (*DNSEnableDisableReply, error)
+ DNSNameServerAddDel(ctx context.Context, in *DNSNameServerAddDel) (*DNSNameServerAddDelReply, error)
+ DNSResolveIP(ctx context.Context, in *DNSResolveIP) (*DNSResolveIPReply, error)
+ DNSResolveName(ctx context.Context, in *DNSResolveName) (*DNSResolveNameReply, error)
+}
+
+type serviceClient struct {
+ conn api.Connection
+}
+
+func NewServiceClient(conn api.Connection) RPCService {
+ return &serviceClient{conn}
+}
+
+func (c *serviceClient) DNSEnableDisable(ctx context.Context, in *DNSEnableDisable) (*DNSEnableDisableReply, error) {
+ out := new(DNSEnableDisableReply)
+ err := c.conn.Invoke(ctx, in, out)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *serviceClient) DNSNameServerAddDel(ctx context.Context, in *DNSNameServerAddDel) (*DNSNameServerAddDelReply, error) {
+ out := new(DNSNameServerAddDelReply)
+ err := c.conn.Invoke(ctx, in, out)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *serviceClient) DNSResolveIP(ctx context.Context, in *DNSResolveIP) (*DNSResolveIPReply, error) {
+ out := new(DNSResolveIPReply)
+ err := c.conn.Invoke(ctx, in, out)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *serviceClient) DNSResolveName(ctx context.Context, in *DNSResolveName) (*DNSResolveNameReply, error) {
+ out := new(DNSResolveNameReply)
+ err := c.conn.Invoke(ctx, in, out)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}