From ef471318d66dd2832df4dc929d312f7cd5f7009a Mon Sep 17 00:00:00 2001 From: Ondrej Fabry Date: Wed, 26 Jun 2019 16:28:20 +0200 Subject: [PATCH] Improvements for binapi-generator and support VPP 19.04 in statsclient - RPC service client implementation for dumps requests now streams responses - RPC service generation is now enabled by default - examples now allow setting binapi socket address - input dir flag for binapi-generator will recursively look into dirs to support core/plugins in /usr/share/vpp/api - minor improvements in debug logs - add support for VPP 19.04 for statsclient Change-Id: I0939ee3aa6e9f850d073fc5c87aff4ccc56b0d70 Signed-off-by: Ondrej Fabry --- adapter/socketclient/socketclient.go | 2 +- adapter/statsclient/stat_segment.go | 246 ++++++ adapter/statsclient/statsclient.go | 231 +---- adapter/statsclient/version.go | 33 + cmd/binapi-generator/generate.go | 290 +++---- cmd/binapi-generator/generate_test.go | 6 +- cmd/binapi-generator/main.go | 97 ++- cmd/binapi-generator/objects.go | 26 +- cmd/binapi-generator/parse.go | 16 +- core/connection.go | 10 +- core/log.go | 1 + examples/binapi/VPP_VERSION | 2 +- examples/binapi/acl/acl.ba.go | 373 ++++---- examples/binapi/af_packet/af_packet.ba.go | 119 +-- examples/binapi/gen.go | 5 +- examples/binapi/interfaces/interfaces.ba.go | 292 ++++--- examples/binapi/ip/ip.ba.go | 942 ++++++++++++--------- examples/binapi/memclnt/memclnt.ba.go | 134 +-- examples/binapi/memif/memif.ba.go | 166 ++-- examples/binapi/vpe/vpe.ba.go | 116 +-- .../rpc_service.go} | 42 +- examples/simple-client/simple_client.go | 23 +- examples/stats-api/README.md | 7 +- examples/stats-api/stats_api.go | 3 +- 24 files changed, 1786 insertions(+), 1396 deletions(-) create mode 100644 adapter/statsclient/stat_segment.go create mode 100644 adapter/statsclient/version.go rename examples/{service-client/service_client.go => rpc-service/rpc_service.go} (63%) diff --git a/adapter/socketclient/socketclient.go b/adapter/socketclient/socketclient.go index e56f89c..daca005 100644 --- a/adapter/socketclient/socketclient.go +++ b/adapter/socketclient/socketclient.go @@ -44,7 +44,7 @@ var ( // DefaultConnectTimeout is default timeout for connecting DefaultConnectTimeout = time.Second * 3 // DefaultDisconnectTimeout is default timeout for discconnecting - DefaultDisconnectTimeout = time.Second + DefaultDisconnectTimeout = time.Millisecond * 100 // MaxWaitReady defines maximum duration before waiting for socket file // times out MaxWaitReady = time.Second * 15 diff --git a/adapter/statsclient/stat_segment.go b/adapter/statsclient/stat_segment.go new file mode 100644 index 0000000..83afa10 --- /dev/null +++ b/adapter/statsclient/stat_segment.go @@ -0,0 +1,246 @@ +// Copyright (c) 2019 Cisco and/or its affiliates. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package statsclient + +import ( + "fmt" + "net" + "sync/atomic" + "syscall" + "time" + "unsafe" + + "github.com/ftrvxmtrx/fd" + + "git.fd.io/govpp.git/adapter" +) + +var ( + maxWaitInProgress = time.Second * 1 +) + +type statSegDirectoryEntry struct { + directoryType statDirectoryType + // unionData can represent: offset, index or value + unionData uint64 + offsetVector uint64 + name [128]byte +} + +type statDirectoryType int32 + +func (t statDirectoryType) String() string { + return adapter.StatType(t).String() +} + +type statSegment struct { + sharedHeader []byte + memorySize int64 + + oldHeader bool +} + +func (c *statSegment) connect(sockName string) error { + addr := &net.UnixAddr{ + Net: "unixpacket", + Name: sockName, + } + + Log.Debugf("connecting to: %v", addr) + + conn, err := net.DialUnix(addr.Net, nil, addr) + if err != nil { + Log.Warnf("connecting to socket %s failed: %s", addr, err) + return err + } + defer func() { + if err := conn.Close(); err != nil { + Log.Warnf("closing socket failed: %v", err) + } + }() + + Log.Debugf("connected to socket") + + files, err := fd.Get(conn, 1, nil) + if err != nil { + return fmt.Errorf("getting file descriptor over socket failed: %v", err) + } + if len(files) == 0 { + return fmt.Errorf("no files received over socket") + } + defer func() { + for _, f := range files { + if err := f.Close(); err != nil { + Log.Warnf("closing file %s failed: %v", f.Name(), err) + } + } + }() + + Log.Debugf("received %d files over socket", len(files)) + + f := files[0] + + info, err := f.Stat() + if err != nil { + return err + } + + size := info.Size() + + Log.Debugf("fd: name=%v size=%v", info.Name(), size) + + data, err := syscall.Mmap(int(f.Fd()), 0, int(size), syscall.PROT_READ, syscall.MAP_SHARED) + if err != nil { + Log.Warnf("mapping shared memory failed: %v", err) + return fmt.Errorf("mapping shared memory failed: %v", err) + } + + Log.Debugf("successfuly mapped shared memory") + + c.sharedHeader = data + c.memorySize = size + + header := c.readHeader() + Log.Debugf("stat segment header: %+v", header) + + // older VPP (19.04) did not have version in stat segment header + // we try to provide fallback support by skipping it in header + if header.version > MaxVersion && header.inProgress > 1 && header.epoch == 0 { + h := c.readHeaderOld() + Log.Warnf("falling back to old stat segment header version: %+v", h) + c.oldHeader = true + } + + return nil +} + +func (c *statSegment) disconnect() error { + if err := syscall.Munmap(c.sharedHeader); err != nil { + Log.Warnf("unmapping shared memory failed: %v", err) + return fmt.Errorf("unmapping shared memory failed: %v", err) + } + + Log.Debugf("successfuly unmapped shared memory") + + return nil +} + +type sharedHeaderBase struct { + epoch int64 + inProgress int64 + directoryOffset int64 + errorOffset int64 + statsOffset int64 +} + +type statSegSharedHeader struct { + version uint64 + sharedHeaderBase +} + +func (c *statSegment) readHeaderOld() (header statSegSharedHeader) { + h := (*sharedHeaderBase)(unsafe.Pointer(&c.sharedHeader[0])) + header.version = 0 + header.epoch = atomic.LoadInt64(&h.epoch) + header.inProgress = atomic.LoadInt64(&h.inProgress) + header.directoryOffset = atomic.LoadInt64(&h.directoryOffset) + header.errorOffset = atomic.LoadInt64(&h.errorOffset) + header.statsOffset = atomic.LoadInt64(&h.statsOffset) + return +} + +func (c *statSegment) readHeader() (header statSegSharedHeader) { + h := (*statSegSharedHeader)(unsafe.Pointer(&c.sharedHeader[0])) + header.version = atomic.LoadUint64(&h.version) + header.epoch = atomic.LoadInt64(&h.epoch) + header.inProgress = atomic.LoadInt64(&h.inProgress) + header.directoryOffset = atomic.LoadInt64(&h.directoryOffset) + header.errorOffset = atomic.LoadInt64(&h.errorOffset) + header.statsOffset = atomic.LoadInt64(&h.statsOffset) + return +} + +func (c *statSegment) readVersion() uint64 { + if c.oldHeader { + return 0 + } + header := (*statSegSharedHeader)(unsafe.Pointer(&c.sharedHeader[0])) + version := atomic.LoadUint64(&header.version) + return version +} + +func (c *statSegment) readEpoch() (int64, bool) { + if c.oldHeader { + h := c.readHeaderOld() + return h.epoch, h.inProgress != 0 + } + header := (*statSegSharedHeader)(unsafe.Pointer(&c.sharedHeader[0])) + epoch := atomic.LoadInt64(&header.epoch) + inprog := atomic.LoadInt64(&header.inProgress) + return epoch, inprog != 0 +} + +func (c *statSegment) readOffsets() (dir, err, stat int64) { + if c.oldHeader { + h := c.readHeaderOld() + return h.directoryOffset, h.errorOffset, h.statsOffset + } + header := (*statSegSharedHeader)(unsafe.Pointer(&c.sharedHeader[0])) + dirOffset := atomic.LoadInt64(&header.directoryOffset) + errOffset := atomic.LoadInt64(&header.errorOffset) + statOffset := atomic.LoadInt64(&header.statsOffset) + return dirOffset, errOffset, statOffset +} + +type statSegAccess struct { + epoch int64 +} + +func (c *statSegment) accessStart() *statSegAccess { + epoch, inprog := c.readEpoch() + t := time.Now() + for inprog { + if time.Since(t) > maxWaitInProgress { + return nil + } + epoch, inprog = c.readEpoch() + } + return &statSegAccess{ + epoch: epoch, + } +} + +func (c *statSegment) accessEnd(acc *statSegAccess) bool { + epoch, inprog := c.readEpoch() + if acc.epoch != epoch || inprog { + return false + } + return true +} + +type vecHeader struct { + length uint64 + vectorData [0]uint8 +} + +func vectorLen(v unsafe.Pointer) uint64 { + vec := *(*vecHeader)(unsafe.Pointer(uintptr(v) - unsafe.Sizeof(uintptr(0)))) + return vec.length +} + +//go:nosplit +func add(p unsafe.Pointer, x uintptr) unsafe.Pointer { + return unsafe.Pointer(uintptr(p) + x) +} diff --git a/adapter/statsclient/statsclient.go b/adapter/statsclient/statsclient.go index 07fcc49..4022740 100644 --- a/adapter/statsclient/statsclient.go +++ b/adapter/statsclient/statsclient.go @@ -12,20 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. +// Package statsclient is pure Go implementation of VPP stats API client. package statsclient import ( "bytes" "fmt" - "net" "os" "regexp" - "sync/atomic" - "syscall" - "time" "unsafe" - "github.com/ftrvxmtrx/fd" logger "github.com/sirupsen/logrus" "git.fd.io/govpp.git/adapter" @@ -52,130 +48,59 @@ func init() { type StatsClient struct { sockAddr string - currentEpoch int64 - sharedHeader []byte - directoryVector uintptr - memorySize int + currentEpoch int64 + statSegment } // NewStatsClient returns new VPP stats API client. -func NewStatsClient(socketName string) *StatsClient { - return &StatsClient{ - sockAddr: socketName, - } -} - -func (c *StatsClient) Connect() error { - var sockName string - if c.sockAddr == "" { - sockName = adapter.DefaultStatsSocket - } else { - sockName = c.sockAddr +func NewStatsClient(sockAddr string) *StatsClient { + if sockAddr == "" { + sockAddr = adapter.DefaultStatsSocket } - - if _, err := os.Stat(sockName); err != nil { - if os.IsNotExist(err) { - return fmt.Errorf("stats socket file %q does not exists, ensure that VPP is running with `statseg { ... }` section in config", sockName) - } - return fmt.Errorf("stats socket file error: %v", err) - } - - if err := c.statSegmentConnect(sockName); err != nil { - return err + return &StatsClient{ + sockAddr: sockAddr, } - - return nil } -const statshmFilename = "statshm" +const sockNotFoundWarn = `VPP stats socket not found at: %s! + Check if VPP is running with stats segment enabled. + To enable it include following section in VPP config: + statseg { + default + } +` -func (c *StatsClient) statSegmentConnect(sockName string) error { - addr := &net.UnixAddr{ - Net: "unixpacket", - Name: sockName, +func (c *StatsClient) Connect() error { + // check if socket exists + if _, err := os.Stat(c.sockAddr); os.IsNotExist(err) { + Log.Warnf(sockNotFoundWarn, c.sockAddr) + return fmt.Errorf("stats socket file %s does not exist", c.sockAddr) + } else if err != nil { + return fmt.Errorf("stats socket error: %v", err) } - Log.Debugf("connecting to: %v", addr) - - conn, err := net.DialUnix(addr.Net, nil, addr) - if err != nil { - Log.Warnf("connecting to socket %s failed: %s", addr, err) + if err := c.statSegment.connect(c.sockAddr); err != nil { return err } - defer func() { - if err := conn.Close(); err != nil { - Log.Warnf("closing socket failed: %v", err) - } - }() - - Log.Debugf("connected to socket: %v", addr) - - files, err := fd.Get(conn, 1, []string{statshmFilename}) - if err != nil { - return fmt.Errorf("getting file descriptor over socket failed: %v", err) - } else if len(files) == 0 { - return fmt.Errorf("no files received over socket") - } - defer func() { - for _, f := range files { - if err := f.Close(); err != nil { - Log.Warnf("closing file %s failed: %v", f.Name(), err) - } - } - }() - - Log.Debugf("received %d files over socket", len(files)) - f := files[0] + ver := c.readVersion() + Log.Debugf("stat segment version: %v", ver) - info, err := f.Stat() - if err != nil { + if err := checkVersion(ver); err != nil { return err } - size := int(info.Size()) - - Log.Debugf("fd: name=%v size=%v", info.Name(), size) - - data, err := syscall.Mmap(int(f.Fd()), 0, size, syscall.PROT_READ, syscall.MAP_SHARED) - if err != nil { - Log.Warnf("mapping shared memory failed: %v", err) - return fmt.Errorf("mapping shared memory failed: %v", err) - } - - Log.Debugf("successfuly mapped shared memory") - - c.sharedHeader = data - c.memorySize = size - return nil } func (c *StatsClient) Disconnect() error { - err := syscall.Munmap(c.sharedHeader) - if err != nil { - Log.Warnf("unmapping shared memory failed: %v", err) - return fmt.Errorf("unmapping shared memory failed: %v", err) + if err := c.statSegment.disconnect(); err != nil { + return err } - Log.Debugf("successfuly unmapped shared memory") - return nil } -func nameMatches(name string, patterns []string) bool { - if len(patterns) == 0 { - return true - } - for _, pattern := range patterns { - matched, err := regexp.MatchString(pattern, name) - if err == nil && matched { - return true - } - } - return false -} - func (c *StatsClient) ListStats(patterns ...string) (statNames []string, err error) { sa := c.accessStart() if sa == nil { @@ -344,11 +269,17 @@ func (c *StatsClient) copyData(dirEntry *statSegDirectoryEntry) (statEntry adapt nameVector := unsafe.Pointer(&c.sharedHeader[dirEntry.unionData]) // offset vecLen := vectorLen(nameVector) offsetVector := add(unsafe.Pointer(&c.sharedHeader[0]), uintptr(dirEntry.offsetVector)) + fmt.Printf("vecLen: %v\n", vecLen) data := make([]adapter.Name, vecLen) for i := uint64(0); i < vecLen; i++ { cb := *(*uint64)(add(offsetVector, uintptr(i)*unsafe.Sizeof(uint64(0)))) - nameVec := unsafe.Pointer(&c.sharedHeader[uintptr(cb)]) + if cb == 0 { + Log.Debugf("\tname vector cb out of range") + continue + } + nameVec := unsafe.Pointer(&c.sharedHeader[cb]) + fmt.Printf("offsetVector: %v, cb: %v\n", offsetVector, cb) vecLen2 := vectorLen(nameVec) var nameStr []byte @@ -372,89 +303,15 @@ func (c *StatsClient) copyData(dirEntry *statSegDirectoryEntry) (statEntry adapt return statEntry } -type statDirectoryType int32 - -func (t statDirectoryType) String() string { - return adapter.StatType(t).String() -} - -type statSegDirectoryEntry struct { - directoryType statDirectoryType - // unionData can represent: offset, index or value - unionData uint64 - offsetVector uint64 - name [128]byte -} - -type statSegSharedHeader struct { - version uint64 - epoch int64 - inProgress int64 - directoryOffset int64 - errorOffset int64 - statsOffset int64 -} - -func (c *StatsClient) readVersion() uint64 { - header := *(*statSegSharedHeader)(unsafe.Pointer(&c.sharedHeader[0])) - version := atomic.LoadUint64(&header.version) - return version -} - -func (c *StatsClient) readEpoch() (int64, bool) { - header := *(*statSegSharedHeader)(unsafe.Pointer(&c.sharedHeader[0])) - epoch := atomic.LoadInt64(&header.epoch) - inprog := atomic.LoadInt64(&header.inProgress) - return epoch, inprog != 0 -} - -func (c *StatsClient) readOffsets() (dir, err, stat int64) { - header := *(*statSegSharedHeader)(unsafe.Pointer(&c.sharedHeader[0])) - dirOffset := atomic.LoadInt64(&header.directoryOffset) - errOffset := atomic.LoadInt64(&header.errorOffset) - statOffset := atomic.LoadInt64(&header.statsOffset) - return dirOffset, errOffset, statOffset -} - -type statSegAccess struct { - epoch int64 -} - -var maxWaitInProgress = 1 * time.Second - -func (c *StatsClient) accessStart() *statSegAccess { - epoch, inprog := c.readEpoch() - t := time.Now() - for inprog { - if time.Since(t) > maxWaitInProgress { - return nil - } - epoch, inprog = c.readEpoch() - } - return &statSegAccess{ - epoch: epoch, +func nameMatches(name string, patterns []string) bool { + if len(patterns) == 0 { + return true } -} - -func (c *StatsClient) accessEnd(acc *statSegAccess) bool { - epoch, inprog := c.readEpoch() - if acc.epoch != epoch || inprog { - return false + for _, pattern := range patterns { + matched, err := regexp.MatchString(pattern, name) + if err == nil && matched { + return true + } } - return true -} - -type vecHeader struct { - length uint64 - vectorData [0]uint8 -} - -func vectorLen(v unsafe.Pointer) uint64 { - vec := *(*vecHeader)(unsafe.Pointer(uintptr(v) - unsafe.Sizeof(uintptr(0)))) - return vec.length -} - -//go:nosplit -func add(p unsafe.Pointer, x uintptr) unsafe.Pointer { - return unsafe.Pointer(uintptr(p) + x) + return false } diff --git a/adapter/statsclient/version.go b/adapter/statsclient/version.go new file mode 100644 index 0000000..a289faa --- /dev/null +++ b/adapter/statsclient/version.go @@ -0,0 +1,33 @@ +// Copyright (c) 2019 Cisco and/or its affiliates. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package statsclient + +import ( + "fmt" +) + +const ( + MinVersion = 0 + MaxVersion = 1 +) + +func checkVersion(ver uint64) error { + if ver < MinVersion { + return fmt.Errorf("stat segment version is too old: %v (minimal version: %v)", ver, MinVersion) + } else if ver > MaxVersion { + return fmt.Errorf("stat segment version is not supported: %v (minimal version: %v)", ver, MaxVersion) + } + return nil +} diff --git a/cmd/binapi-generator/generate.go b/cmd/binapi-generator/generate.go index 1ff3e4c..e386f8d 100644 --- a/cmd/binapi-generator/generate.go +++ b/cmd/binapi-generator/generate.go @@ -41,6 +41,10 @@ const ( constVersionCrc = "VersionCrc" // version CRC constant unionDataField = "XXX_UnionData" // name for the union data field + + serviceApiName = "RPCService" // name for the RPC service interface + serviceImplName = "serviceClient" // name for the RPC service implementation + serviceClientName = "ServiceClient" // name for the RPC service client ) // context is a structure storing data for code generation @@ -61,8 +65,8 @@ type context struct { packageData *Package // parsed package data } -// getContext returns context details of the code generation task -func getContext(inputFile, outputDir string) (*context, error) { +// newContext returns context details of the code generation task +func newContext(inputFile, outputDir string) (*context, error) { if !strings.HasSuffix(inputFile, inputFileExt) { return nil, fmt.Errorf("invalid input file name: %q", inputFile) } @@ -93,13 +97,14 @@ func getContext(inputFile, outputDir string) (*context, error) { return ctx, nil } -// generatePackage generates code for the parsed package data and writes it into w func generatePackage(ctx *context, w io.Writer) error { logf("generating package %q", ctx.packageName) - // generate file header + fmt.Fprintln(w, "// Code generated by GoVPP's binapi-generator. DO NOT EDIT.") + fmt.Fprintf(w, "// source: %s\n", ctx.inputFile) + fmt.Fprintln(w) + generateHeader(ctx, w) - generateImports(ctx, w) // generate module desc fmt.Fprintln(w, "const (") @@ -119,8 +124,6 @@ func generatePackage(ctx *context, w io.Writer) error { // generate enums if len(ctx.packageData.Enums) > 0 { - fmt.Fprintf(w, "/* Enums */\n\n") - for _, enum := range ctx.packageData.Enums { generateEnum(ctx, w, &enum) } @@ -128,8 +131,6 @@ func generatePackage(ctx *context, w io.Writer) error { // generate aliases if len(ctx.packageData.Aliases) > 0 { - fmt.Fprintf(w, "/* Aliases */\n\n") - for _, alias := range ctx.packageData.Aliases { generateAlias(ctx, w, &alias) } @@ -137,8 +138,6 @@ func generatePackage(ctx *context, w io.Writer) error { // generate types if len(ctx.packageData.Types) > 0 { - fmt.Fprintf(w, "/* Types */\n\n") - for _, typ := range ctx.packageData.Types { generateType(ctx, w, &typ) } @@ -146,8 +145,6 @@ func generatePackage(ctx *context, w io.Writer) error { // generate unions if len(ctx.packageData.Unions) > 0 { - fmt.Fprintf(w, "/* Unions */\n\n") - for _, union := range ctx.packageData.Unions { generateUnion(ctx, w, &union) } @@ -155,8 +152,6 @@ func generatePackage(ctx *context, w io.Writer) error { // generate messages if len(ctx.packageData.Messages) > 0 { - fmt.Fprintf(w, "/* Messages */\n\n") - for _, msg := range ctx.packageData.Messages { generateMessage(ctx, w, &msg) } @@ -189,20 +184,17 @@ func generatePackage(ctx *context, w io.Writer) error { } } + generateFooter(ctx, w) + return nil } -// generateHeader writes generated package header into w func generateHeader(ctx *context, w io.Writer) { - fmt.Fprintln(w, "// Code generated by GoVPP binapi-generator. DO NOT EDIT.") - fmt.Fprintf(w, "// source: %s\n", ctx.inputFile) - fmt.Fprintln(w) - fmt.Fprintln(w, "/*") - fmt.Fprintf(w, "Package %s is a generated from VPP binary API module '%s'.\n", ctx.packageName, ctx.moduleName) + fmt.Fprintf(w, "Package %s is a generated VPP binary API for '%s' module.\n", ctx.packageName, ctx.moduleName) fmt.Fprintln(w) - fmt.Fprintf(w, " The %s module consists of:\n", ctx.moduleName) - var printObjNum = func(obj string, num int) { + fmt.Fprintln(w, "It consists of:") + printObjNum := func(obj string, num int) { if num > 0 { if num > 1 { if strings.HasSuffix(obj, "s") { @@ -215,7 +207,6 @@ func generateHeader(ctx *context, w io.Writer) { fmt.Fprintf(w, "\t%3d %s\n", num, obj) } } - printObjNum("enum", len(ctx.packageData.Enums)) printObjNum("alias", len(ctx.packageData.Aliases)) printObjNum("type", len(ctx.packageData.Types)) @@ -223,42 +214,42 @@ func generateHeader(ctx *context, w io.Writer) { printObjNum("message", len(ctx.packageData.Messages)) printObjNum("service", len(ctx.packageData.Services)) fmt.Fprintln(w, "*/") - fmt.Fprintf(w, "package %s\n", ctx.packageName) fmt.Fprintln(w) + + fmt.Fprintln(w, "import (") + fmt.Fprintf(w, "\tapi \"%s\"\n", govppApiImportPath) + fmt.Fprintf(w, "\tbytes \"%s\"\n", "bytes") + fmt.Fprintf(w, "\tcontext \"%s\"\n", "context") + fmt.Fprintf(w, "\tio \"%s\"\n", "io") + fmt.Fprintf(w, "\tstrconv \"%s\"\n", "strconv") + fmt.Fprintf(w, "\tstruc \"%s\"\n", "github.com/lunixbochs/struc") + fmt.Fprintln(w, ")") + fmt.Fprintln(w) } -// generateImports writes generated package imports into w -func generateImports(ctx *context, w io.Writer) { - fmt.Fprintf(w, "import api \"%s\"\n", govppApiImportPath) - fmt.Fprintf(w, "import bytes \"%s\"\n", "bytes") - fmt.Fprintf(w, "import context \"%s\"\n", "context") - fmt.Fprintf(w, "import strconv \"%s\"\n", "strconv") - fmt.Fprintf(w, "import struc \"%s\"\n", "github.com/lunixbochs/struc") +func generateFooter(ctx *context, w io.Writer) { + fmt.Fprintln(w, "// This is a compile-time assertion to ensure that this generated file") + fmt.Fprintln(w, "// is compatible with the GoVPP api package it is being compiled against.") + fmt.Fprintln(w, "// A compilation error at this line likely means your copy of the") + fmt.Fprintln(w, "// GoVPP api package needs to be updated.") + fmt.Fprintf(w, "const _ = api.GoVppAPIPackageIsVersion%d // please upgrade the GoVPP api package\n", generatedCodeVersion) fmt.Fprintln(w) fmt.Fprintf(w, "// Reference imports to suppress errors if they are not otherwise used.\n") fmt.Fprintf(w, "var _ = api.RegisterMessage\n") fmt.Fprintf(w, "var _ = bytes.NewBuffer\n") fmt.Fprintf(w, "var _ = context.Background\n") + fmt.Fprintf(w, "var _ = io.Copy\n") fmt.Fprintf(w, "var _ = strconv.Itoa\n") fmt.Fprintf(w, "var _ = struc.Pack\n") - fmt.Fprintln(w) - - fmt.Fprintln(w, "// This is a compile-time assertion to ensure that this generated file") - fmt.Fprintln(w, "// is compatible with the GoVPP api package it is being compiled against.") - fmt.Fprintln(w, "// A compilation error at this line likely means your copy of the") - fmt.Fprintln(w, "// GoVPP api package needs to be updated.") - fmt.Fprintf(w, "const _ = api.GoVppAPIPackageIsVersion%d // please upgrade the GoVPP api package\n", generatedCodeVersion) - fmt.Fprintln(w) } -// generateComment writes generated comment for the object into w func generateComment(ctx *context, w io.Writer, goName string, vppName string, objKind string) { if objKind == "service" { - fmt.Fprintf(w, "// %s represents VPP binary API services in %s module.\n", goName, ctx.moduleName) + fmt.Fprintf(w, "// %s represents RPC service API for %s module.\n", goName, ctx.moduleName) } else { - fmt.Fprintf(w, "// %s represents VPP binary API %s '%s':\n", goName, objKind, vppName) + fmt.Fprintf(w, "// %s represents VPP binary API %s '%s'.\n", goName, objKind, vppName) } if !ctx.includeComments { @@ -315,97 +306,6 @@ func generateComment(ctx *context, w io.Writer, goName string, vppName string, o fmt.Fprintln(w, "//") } -// generateServices writes generated code for the Services interface into w -func generateServices(ctx *context, w io.Writer, services []Service) { - const apiName = "Service" - const implName = "service" - - // generate services comment - generateComment(ctx, w, apiName, "services", "service") - - // generate interface - fmt.Fprintf(w, "type %s interface {\n", apiName) - for _, svc := range services { - generateServiceMethod(ctx, w, &svc) - fmt.Fprintln(w) - } - fmt.Fprintln(w, "}") - fmt.Fprintln(w) - - // generate client implementation - fmt.Fprintf(w, "type %s struct {\n", implName) - fmt.Fprintf(w, "\tch api.Channel\n") - fmt.Fprintln(w, "}") - fmt.Fprintln(w) - - fmt.Fprintf(w, "func New%[1]s(ch api.Channel) %[1]s {\n", apiName) - fmt.Fprintf(w, "\treturn &%s{ch}\n", implName) - fmt.Fprintln(w, "}") - fmt.Fprintln(w) - - for _, svc := range services { - fmt.Fprintf(w, "func (c *%s) ", implName) - generateServiceMethod(ctx, w, &svc) - fmt.Fprintln(w, " {") - if svc.Stream { - // TODO: stream responses - //fmt.Fprintf(w, "\tstream := make(chan *%s)\n", camelCaseName(svc.ReplyType)) - replyTyp := camelCaseName(svc.ReplyType) - fmt.Fprintf(w, "\tvar dump []*%s\n", replyTyp) - fmt.Fprintf(w, "\treq := c.ch.SendMultiRequest(in)\n") - fmt.Fprintf(w, "\tfor {\n") - fmt.Fprintf(w, "\tm := new(%s)\n", replyTyp) - fmt.Fprintf(w, "\tstop, err := req.ReceiveReply(m)\n") - fmt.Fprintf(w, "\tif stop { break }\n") - fmt.Fprintf(w, "\tif err != nil { return nil, err }\n") - fmt.Fprintf(w, "\tdump = append(dump, m)\n") - fmt.Fprintln(w, "}") - fmt.Fprintf(w, "\treturn dump, nil\n") - } else if replyTyp := camelCaseName(svc.ReplyType); replyTyp != "" { - fmt.Fprintf(w, "\tout := new(%s)\n", replyTyp) - fmt.Fprintf(w, "\terr:= c.ch.SendRequest(in).ReceiveReply(out)\n") - fmt.Fprintf(w, "\tif err != nil { return nil, err }\n") - fmt.Fprintf(w, "\treturn out, nil\n") - } else { - fmt.Fprintf(w, "\tc.ch.SendRequest(in)\n") - fmt.Fprintf(w, "\treturn nil\n") - } - fmt.Fprintln(w, "}") - fmt.Fprintln(w) - } - - fmt.Fprintln(w) -} - -// generateServiceMethod writes generated code for the service into w -func generateServiceMethod(ctx *context, w io.Writer, svc *Service) { - reqTyp := camelCaseName(svc.RequestType) - - // method name is same as parameter type name by default - method := reqTyp - if svc.Stream { - // use Dump as prefix instead of suffix for stream services - if m := strings.TrimSuffix(method, "Dump"); method != m { - method = "Dump" + m - } - } - - params := fmt.Sprintf("in *%s", reqTyp) - returns := "error" - if replyType := camelCaseName(svc.ReplyType); replyType != "" { - replyTyp := fmt.Sprintf("*%s", replyType) - if svc.Stream { - // TODO: stream responses - //replyTyp = fmt.Sprintf("<-chan %s", replyTyp) - replyTyp = fmt.Sprintf("[]%s", replyTyp) - } - returns = fmt.Sprintf("(%s, error)", replyTyp) - } - - fmt.Fprintf(w, "\t%s(ctx context.Context, %s) %s", method, params, returns) -} - -// generateEnum writes generated code for the enum into w func generateEnum(ctx *context, w io.Writer, enum *Enum) { name := camelCaseName(enum.Name) typ := binapiTypes[enum.Type] @@ -450,7 +350,6 @@ func generateEnum(ctx *context, w io.Writer, enum *Enum) { fmt.Fprintln(w) } -// generateAlias writes generated code for the alias into w func generateAlias(ctx *context, w io.Writer, alias *Alias) { name := camelCaseName(alias.Name) @@ -472,7 +371,6 @@ func generateAlias(ctx *context, w io.Writer, alias *Alias) { fmt.Fprintln(w) } -// generateUnion writes generated code for the union into w func generateUnion(ctx *context, w io.Writer, union *Union) { name := camelCaseName(union.Name) @@ -561,7 +459,6 @@ func (u *%[1]s) Get%[2]s() (a %[3]s) { `, structName, getterField, getterStruct, unionDataField) } -// generateType writes generated code for the type into w func generateType(ctx *context, w io.Writer, typ *Type) { name := camelCaseName(typ.Name) @@ -598,7 +495,6 @@ func generateType(ctx *context, w io.Writer, typ *Type) { fmt.Fprintln(w) } -// generateMessage writes generated code for the message into w func generateMessage(ctx *context, w io.Writer, msg *Message) { name := camelCaseName(msg.Name) @@ -666,7 +562,6 @@ func generateMessage(ctx *context, w io.Writer, msg *Message) { fmt.Fprintln(w) } -// generateField writes generated code for the field into w func generateField(ctx *context, w io.Writer, fields []Field, i int) { field := fields[i] @@ -737,7 +632,6 @@ func generateField(ctx *context, w io.Writer, fields []Field, i int) { fmt.Fprintln(w) } -// generateMessageNameGetter generates getter for original VPP message name into the provider writer func generateMessageNameGetter(w io.Writer, structName, msgName string) { fmt.Fprintf(w, `func (*%s) GetMessageName() string { return %q @@ -745,7 +639,6 @@ func generateMessageNameGetter(w io.Writer, structName, msgName string) { `, structName, msgName) } -// generateTypeNameGetter generates getter for original VPP type name into the provider writer func generateTypeNameGetter(w io.Writer, structName, msgName string) { fmt.Fprintf(w, `func (*%s) GetTypeName() string { return %q @@ -753,7 +646,6 @@ func generateTypeNameGetter(w io.Writer, structName, msgName string) { `, structName, msgName) } -// generateCrcGetter generates getter for CRC checksum of the message definition into the provider writer func generateCrcGetter(w io.Writer, structName, crc string) { crc = strings.TrimPrefix(crc, "0x") fmt.Fprintf(w, `func (*%s) GetCrcString() string { @@ -762,7 +654,6 @@ func generateCrcGetter(w io.Writer, structName, crc string) { `, structName, crc) } -// generateMessageTypeGetter generates message factory for the generated message into the provider writer func generateMessageTypeGetter(w io.Writer, structName string, msgType MessageType) { fmt.Fprintln(w, "func (*"+structName+") GetMessageType() api.MessageType {") if msgType == requestMessage { @@ -776,3 +667,116 @@ func generateMessageTypeGetter(w io.Writer, structName string, msgType MessageTy } fmt.Fprintln(w, "}") } + +func generateServices(ctx *context, w io.Writer, services []Service) { + + // generate services comment + generateComment(ctx, w, serviceApiName, "services", "service") + + // generate service api + fmt.Fprintf(w, "type %s interface {\n", serviceApiName) + for _, svc := range services { + generateServiceMethod(ctx, w, &svc) + fmt.Fprintln(w) + } + fmt.Fprintln(w, "}") + fmt.Fprintln(w) + + // generate client implementation + fmt.Fprintf(w, "type %s struct {\n", serviceImplName) + fmt.Fprintf(w, "\tch api.Channel\n") + fmt.Fprintln(w, "}") + fmt.Fprintln(w) + + // generate client constructor + fmt.Fprintf(w, "func New%s(ch api.Channel) %s {\n", serviceClientName, serviceApiName) + fmt.Fprintf(w, "\treturn &%s{ch}\n", serviceImplName) + fmt.Fprintln(w, "}") + fmt.Fprintln(w) + + for _, svc := range services { + method := camelCaseName(svc.RequestType) + if m := strings.TrimSuffix(method, "Dump"); method != m { + method = "Dump" + m + } + + fmt.Fprintf(w, "func (c *%s) ", serviceImplName) + generateServiceMethod(ctx, w, &svc) + fmt.Fprintln(w, " {") + if svc.Stream { + streamImpl := fmt.Sprintf("%s_%sClient", serviceImplName, method) + fmt.Fprintf(w, "\tstream := c.ch.SendMultiRequest(in)\n") + fmt.Fprintf(w, "\tx := &%s{stream}\n", streamImpl) + fmt.Fprintf(w, "\treturn x, nil\n") + } else if replyTyp := camelCaseName(svc.ReplyType); replyTyp != "" { + fmt.Fprintf(w, "\tout := new(%s)\n", replyTyp) + fmt.Fprintf(w, "\terr:= c.ch.SendRequest(in).ReceiveReply(out)\n") + fmt.Fprintf(w, "\tif err != nil { return nil, err }\n") + fmt.Fprintf(w, "\treturn out, nil\n") + } else { + fmt.Fprintf(w, "\tc.ch.SendRequest(in)\n") + fmt.Fprintf(w, "\treturn nil\n") + } + fmt.Fprintln(w, "}") + fmt.Fprintln(w) + + if svc.Stream { + replyTyp := camelCaseName(svc.ReplyType) + method := camelCaseName(svc.RequestType) + if m := strings.TrimSuffix(method, "Dump"); method != m { + method = "Dump" + m + } + streamApi := fmt.Sprintf("%s_%sClient", serviceApiName, method) + + fmt.Fprintf(w, "type %s interface {\n", streamApi) + fmt.Fprintf(w, "\tRecv() (*%s, error)\n", replyTyp) + fmt.Fprintln(w, "}") + fmt.Fprintln(w) + + streamImpl := fmt.Sprintf("%s_%sClient", serviceImplName, method) + fmt.Fprintf(w, "type %s struct {\n", streamImpl) + fmt.Fprintf(w, "\tapi.MultiRequestCtx\n") + fmt.Fprintln(w, "}") + fmt.Fprintln(w) + + fmt.Fprintf(w, "func (c *%s) Recv() (*%s, error) {\n", streamImpl, replyTyp) + fmt.Fprintf(w, "\tm := new(%s)\n", replyTyp) + fmt.Fprintf(w, "\tstop, err := c.MultiRequestCtx.ReceiveReply(m)\n") + fmt.Fprintf(w, "\tif err != nil { return nil, err }\n") + fmt.Fprintf(w, "\tif stop { return nil, io.EOF }\n") + fmt.Fprintf(w, "\treturn m, nil\n") + fmt.Fprintln(w, "}") + fmt.Fprintln(w) + } + } + + fmt.Fprintln(w) +} + +func generateServiceMethod(ctx *context, w io.Writer, svc *Service) { + reqTyp := camelCaseName(svc.RequestType) + + // method name is same as parameter type name by default + method := reqTyp + if svc.Stream { + // use Dump as prefix instead of suffix for stream services + if m := strings.TrimSuffix(method, "Dump"); method != m { + method = "Dump" + m + } + } + + params := fmt.Sprintf("in *%s", reqTyp) + returns := "error" + + if replyType := camelCaseName(svc.ReplyType); replyType != "" { + var replyTyp string + if svc.Stream { + replyTyp = fmt.Sprintf("%s_%sClient", serviceApiName, method) + } else { + replyTyp = fmt.Sprintf("*%s", replyType) + } + returns = fmt.Sprintf("(%s, error)", replyTyp) + } + + fmt.Fprintf(w, "\t%s(ctx context.Context, %s) %s", method, params, returns) +} diff --git a/cmd/binapi-generator/generate_test.go b/cmd/binapi-generator/generate_test.go index bac5b51..e68b54a 100644 --- a/cmd/binapi-generator/generate_test.go +++ b/cmd/binapi-generator/generate_test.go @@ -85,7 +85,7 @@ func TestGenerateFromFileGeneratePackageError(t *testing.T) { func TestGetContext(t *testing.T) { RegisterTestingT(t) outDir := "test_output_directory" - result, err := getContext("testdata/af_packet.api.json", outDir) + result, err := newContext("testdata/af_packet.api.json", outDir) Expect(err).ShouldNot(HaveOccurred()) Expect(result).ToNot(BeNil()) Expect(result.outputFile).To(BeEquivalentTo(outDir + "/af_packet/af_packet.ba.go")) @@ -94,7 +94,7 @@ func TestGetContext(t *testing.T) { func TestGetContextNoJsonFile(t *testing.T) { RegisterTestingT(t) outDir := "test_output_directory" - result, err := getContext("testdata/input.txt", outDir) + result, err := newContext("testdata/input.txt", outDir) Expect(err).Should(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("invalid input file name")) Expect(result).To(BeNil()) @@ -103,7 +103,7 @@ func TestGetContextNoJsonFile(t *testing.T) { func TestGetContextInterfaceJson(t *testing.T) { RegisterTestingT(t) outDir := "test_output_directory" - result, err := getContext("testdata/ip.api.json", outDir) + result, err := newContext("testdata/ip.api.json", outDir) Expect(err).ShouldNot(HaveOccurred()) Expect(result).ToNot(BeNil()) Expect(result.outputFile) diff --git a/cmd/binapi-generator/main.go b/cmd/binapi-generator/main.go index d221317..89a2b2d 100644 --- a/cmd/binapi-generator/main.go +++ b/cmd/binapi-generator/main.go @@ -30,15 +30,18 @@ import ( ) var ( - inputFile = flag.String("input-file", "", "Input file with VPP API in JSON format.") - inputDir = flag.String("input-dir", ".", "Input directory with VPP API files in JSON format.") - outputDir = flag.String("output-dir", ".", "Output directory where package folders will be generated.") + theInputFile = flag.String("input-file", "", "Input file with VPP API in JSON format.") + theInputDir = flag.String("input-dir", "/usr/share/vpp/api", "Input directory with VPP API files in JSON format.") + theOutputDir = flag.String("output-dir", ".", "Output directory where package folders will be generated.") + includeAPIVer = flag.Bool("include-apiver", true, "Include APIVersion constant for each module.") + includeServices = flag.Bool("include-services", true, "Include RPC service api and client implementation.") includeComments = flag.Bool("include-comments", false, "Include JSON API source in comments for each object.") includeBinapiNames = flag.Bool("include-binapi-names", false, "Include binary API names in struct tag.") - includeServices = flag.Bool("include-services", false, "Include service interface with client implementation.") - continueOnError = flag.Bool("continue-onerror", false, "Continue with next file on error.") - debug = flag.Bool("debug", debugMode, "Enable debug mode.") + + continueOnError = flag.Bool("continue-onerror", false, "Continue with next file on error.") + + debug = flag.Bool("debug", debugMode, "Enable debug mode.") ) var debugMode = os.Getenv("DEBUG_BINAPI_GENERATOR") != "" @@ -49,69 +52,84 @@ func main() { logrus.SetLevel(logrus.DebugLevel) } - if *inputFile == "" && *inputDir == "" { - fmt.Fprintln(os.Stderr, "ERROR: input-file or input-dir must be specified") + if err := run(*theInputFile, *theInputDir, *theOutputDir, *continueOnError); err != nil { + logrus.Errorln("binapi-generator:", err) os.Exit(1) } +} + +func run(inputFile, inputDir string, outputDir string, continueErr bool) error { + if inputFile == "" && inputDir == "" { + return fmt.Errorf("input-file or input-dir must be specified") + } - if *inputFile != "" { + if inputFile != "" { // process one input file - if err := generateFromFile(*inputFile, *outputDir); err != nil { - fmt.Fprintf(os.Stderr, "ERROR: code generation from %s failed: %v\n", *inputFile, err) - os.Exit(1) + if err := generateFromFile(inputFile, outputDir); err != nil { + return fmt.Errorf("code generation from %s failed: %v\n", inputFile, err) } } else { // process all files in specified directory - dir, err := filepath.Abs(*inputDir) + dir, err := filepath.Abs(inputDir) if err != nil { - fmt.Fprintf(os.Stderr, "ERROR: invalid input directory: %v\n", err) - os.Exit(1) + return fmt.Errorf("invalid input directory: %v\n", err) } - files, err := getInputFiles(*inputDir) + files, err := getInputFiles(inputDir, 1) if err != nil { - fmt.Fprintf(os.Stderr, "ERROR: problem getting files from input directory: %v\n", err) - os.Exit(1) + return fmt.Errorf("problem getting files from input directory: %v\n", err) } else if len(files) == 0 { - fmt.Fprintf(os.Stderr, "ERROR: no input files found in input directory: %v\n", dir) - os.Exit(1) + return fmt.Errorf("no input files found in input directory: %v\n", dir) } for _, file := range files { - if err := generateFromFile(file, *outputDir); err != nil { - fmt.Fprintf(os.Stderr, "ERROR: code generation from %s failed: %v\n", file, err) - if *continueOnError { + if err := generateFromFile(file, outputDir); err != nil { + if continueErr { + logrus.Warnf("code generation from %s failed: %v (error ignored)\n", file, err) continue + } else { + return fmt.Errorf("code generation from %s failed: %v\n", file, err) } - os.Exit(1) } } } + + return nil } // getInputFiles returns all input files located in specified directory -func getInputFiles(inputDir string) (res []string, err error) { - files, err := ioutil.ReadDir(inputDir) +func getInputFiles(inputDir string, deep int) (files []string, err error) { + entries, err := ioutil.ReadDir(inputDir) if err != nil { return nil, fmt.Errorf("reading directory %s failed: %v", inputDir, err) } - for _, f := range files { - if strings.HasSuffix(f.Name(), inputFileExt) { - res = append(res, filepath.Join(inputDir, f.Name())) + for _, e := range entries { + if e.IsDir() && deep > 0 { + nestedDir := filepath.Join(inputDir, e.Name()) + if nested, err := getInputFiles(nestedDir, deep-1); err != nil { + return nil, err + } else { + files = append(files, nested...) + } + } else if strings.HasSuffix(e.Name(), inputFileExt) { + files = append(files, filepath.Join(inputDir, e.Name())) } } - return res, nil + return files, nil } // generateFromFile generates Go package from one input JSON file func generateFromFile(inputFile, outputDir string) error { - logf("generating from file: %s", inputFile) - logf("------------------------------------------------------------") - defer logf("------------------------------------------------------------") - - ctx, err := getContext(inputFile, outputDir) + // create generator context + ctx, err := newContext(inputFile, outputDir) if err != nil { return err } + logf("------------------------------------------------------------") + logf("module: %s", ctx.moduleName) + logf(" - input: %s", ctx.inputFile) + logf(" - output: %s", ctx.outputFile) + logf("------------------------------------------------------------") + // prepare options ctx.includeAPIVersion = *includeAPIVer ctx.includeComments = *includeComments @@ -123,7 +141,6 @@ func generateFromFile(inputFile, outputDir string) error { if err != nil { return fmt.Errorf("reading input file %s failed: %v", ctx.inputFile, err) } - // parse JSON data into objects jsonRoot := new(jsongo.JSONNode) if err := json.Unmarshal(ctx.inputData, jsonRoot); err != nil { @@ -156,14 +173,6 @@ func generateFromFile(inputFile, outputDir string) error { return fmt.Errorf("gofmt failed: %v\n%s", err, string(output)) } - // count number of lines in generated output file - cmd = exec.Command("wc", "-l", ctx.outputFile) - if output, err := cmd.CombinedOutput(); err != nil { - logf("wc command failed: %v\n%s", err, string(output)) - } else { - logf("number of generated lines: %s", output) - } - return nil } diff --git a/cmd/binapi-generator/objects.go b/cmd/binapi-generator/objects.go index e3270de..2d5321d 100644 --- a/cmd/binapi-generator/objects.go +++ b/cmd/binapi-generator/objects.go @@ -4,6 +4,7 @@ import "fmt" // Package represents collection of objects parsed from VPP binary API JSON data type Package struct { + Name string Version string CRC string Services []Service @@ -91,32 +92,33 @@ const ( // printPackage prints all loaded objects for package func printPackage(pkg *Package) { + logf("package: %s %s (%s)", pkg.Name, pkg.Version, pkg.CRC) if len(pkg.Enums) > 0 { - logf("loaded %d enums:", len(pkg.Enums)) - for k, enum := range pkg.Enums { - logf(" - enum #%d\t%+v", k, enum) + logf(" %d enums:", len(pkg.Enums)) + for _, enum := range pkg.Enums { + logf(" - %s: %+v", enum.Name, enum) } } if len(pkg.Unions) > 0 { - logf("loaded %d unions:", len(pkg.Unions)) - for k, union := range pkg.Unions { - logf(" - union #%d\t%+v", k, union) + logf(" %d unions:", len(pkg.Unions)) + for _, union := range pkg.Unions { + logf(" - %s: %+v", union.Name, union) } } if len(pkg.Types) > 0 { - logf("loaded %d types:", len(pkg.Types)) + logf(" %d types:", len(pkg.Types)) for _, typ := range pkg.Types { - logf(" - type: %q (%d fields)", typ.Name, len(typ.Fields)) + logf(" - %s (%d fields): %+v", typ.Name, len(typ.Fields), typ) } } if len(pkg.Messages) > 0 { - logf("loaded %d messages:", len(pkg.Messages)) + logf(" %d messages:", len(pkg.Messages)) for _, msg := range pkg.Messages { - logf(" - message: %q (%d fields)", msg.Name, len(msg.Fields)) + logf(" - %s (%d fields) %s", msg.Name, len(msg.Fields), msg.CRC) } } if len(pkg.Services) > 0 { - logf("loaded %d services:", len(pkg.Services)) + logf(" %d services:", len(pkg.Services)) for _, svc := range pkg.Services { var info string if svc.Stream { @@ -124,7 +126,7 @@ func printPackage(pkg *Package) { } else if len(svc.Events) > 0 { info = fmt.Sprintf("(EVENTS: %v)", svc.Events) } - logf(" - service: %s - %q -> %q %s", svc.Name, svc.RequestType, svc.ReplyType, info) + logf(" - %s: %q -> %q %s", svc.Name, svc.RequestType, svc.ReplyType, info) } } } diff --git a/cmd/binapi-generator/parse.go b/cmd/binapi-generator/parse.go index 602b17f..0e4f3ad 100644 --- a/cmd/binapi-generator/parse.go +++ b/cmd/binapi-generator/parse.go @@ -74,6 +74,7 @@ const ( // parsePackage parses provided JSON data into objects prepared for code generation func parsePackage(ctx *context, jsonRoot *jsongo.JSONNode) (*Package, error) { pkg := Package{ + Name: ctx.packageName, RefMap: make(map[string]string), } @@ -89,16 +90,11 @@ func parsePackage(ctx *context, jsonRoot *jsongo.JSONNode) (*Package, error) { } } - logf("parsing package %s (version: %s, CRC: %s) contains: %d services, %d messages, %d types, %d enums, %d unions, %d aliases", - ctx.packageName, - pkg.Version, pkg.CRC, - jsonRoot.Map(objServices).Len(), - jsonRoot.Map(objMessages).Len(), - jsonRoot.Map(objTypes).Len(), - jsonRoot.Map(objEnums).Len(), - jsonRoot.Map(objUnions).Len(), - jsonRoot.Map(objAliases).Len(), - ) + logf("parsing package %s (version: %s, CRC: %s)", pkg.Name, pkg.Version, pkg.CRC) + logf(" consists of:") + for _, key := range jsonRoot.GetKeys() { + logf(" - %d %s", jsonRoot.At(key).Len(), key) + } // parse enums enums := jsonRoot.Map(objEnums) diff --git a/core/connection.go b/core/connection.go index 67c7e1d..02f980a 100644 --- a/core/connection.go +++ b/core/connection.go @@ -174,8 +174,7 @@ func (c *Connection) connectVPP() error { if err := c.vppClient.Connect(); err != nil { return err } - - log.Debugf("Connected to VPP.") + log.Debugf("Connected to VPP") if err := c.retrieveMessageIDs(); err != nil { c.vppClient.Disconnect() @@ -202,7 +201,12 @@ func (c *Connection) Disconnect() { // disconnectVPP disconnects from VPP in case it is connected. func (c *Connection) disconnectVPP() { if atomic.CompareAndSwapUint32(&c.vppConnected, 1, 0) { - c.vppClient.Disconnect() + log.Debug("Disconnecting from VPP..") + + if err := c.vppClient.Disconnect(); err != nil { + log.Debugf("Disconnect from VPP failed: %v", err) + } + log.Debug("Disconnected from VPP") } } diff --git a/core/log.go b/core/log.go index aaef4cc..035c159 100644 --- a/core/log.go +++ b/core/log.go @@ -18,6 +18,7 @@ func init() { log.Out = os.Stdout if debug { log.Level = logger.DebugLevel + log.Debugf("debug mode enabled") } } diff --git a/examples/binapi/VPP_VERSION b/examples/binapi/VPP_VERSION index c12c3c9..a9bd32f 100644 --- a/examples/binapi/VPP_VERSION +++ b/examples/binapi/VPP_VERSION @@ -1 +1 @@ -19.04.1-rc0~15-g85ff80645~b56 \ No newline at end of file +19.04.1-rc0~5-g6f05f724f \ No newline at end of file diff --git a/examples/binapi/acl/acl.ba.go b/examples/binapi/acl/acl.ba.go index 6708e74..1f9528e 100644 --- a/examples/binapi/acl/acl.ba.go +++ b/examples/binapi/acl/acl.ba.go @@ -1,34 +1,24 @@ -// Code generated by GoVPP binapi-generator. DO NOT EDIT. +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. // source: /usr/share/vpp/api/plugins/acl.api.json /* -Package acl is a generated from VPP binary API module 'acl'. +Package acl is a generated VPP binary API for 'acl' module. - The acl module consists of: +It consists of: 2 types 36 messages 18 services */ package acl -import api "git.fd.io/govpp.git/api" -import bytes "bytes" -import context "context" -import strconv "strconv" -import struc "github.com/lunixbochs/struc" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = strconv.Itoa -var _ = struc.Pack - -// 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.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package +import ( + bytes "bytes" + context "context" + api "git.fd.io/govpp.git/api" + struc "github.com/lunixbochs/struc" + io "io" + strconv "strconv" +) const ( // ModuleName is the name of this module. @@ -39,9 +29,7 @@ const ( VersionCrc = 0x8ed22cb9 ) -/* Types */ - -// ACLRule represents VPP binary API type 'acl_rule': +// ACLRule represents VPP binary API type 'acl_rule'. type ACLRule struct { IsPermit uint8 IsIPv6 uint8 @@ -65,7 +53,7 @@ func (*ACLRule) GetCrcString() string { return "6f99bf4d" } -// MacipACLRule represents VPP binary API type 'macip_acl_rule': +// MacipACLRule represents VPP binary API type 'macip_acl_rule'. type MacipACLRule struct { IsPermit uint8 IsIPv6 uint8 @@ -82,9 +70,7 @@ func (*MacipACLRule) GetCrcString() string { return "70589f1e" } -/* Messages */ - -// ACLAddReplace represents VPP binary API message 'acl_add_replace': +// ACLAddReplace represents VPP binary API message 'acl_add_replace'. type ACLAddReplace struct { ACLIndex uint32 Tag []byte `struc:"[64]byte"` @@ -102,7 +88,7 @@ func (*ACLAddReplace) GetMessageType() api.MessageType { return api.RequestMessage } -// ACLAddReplaceReply represents VPP binary API message 'acl_add_replace_reply': +// ACLAddReplaceReply represents VPP binary API message 'acl_add_replace_reply'. type ACLAddReplaceReply struct { ACLIndex uint32 Retval int32 @@ -118,7 +104,7 @@ func (*ACLAddReplaceReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// ACLDel represents VPP binary API message 'acl_del': +// ACLDel represents VPP binary API message 'acl_del'. type ACLDel struct { ACLIndex uint32 } @@ -133,7 +119,7 @@ func (*ACLDel) GetMessageType() api.MessageType { return api.RequestMessage } -// ACLDelReply represents VPP binary API message 'acl_del_reply': +// ACLDelReply represents VPP binary API message 'acl_del_reply'. type ACLDelReply struct { Retval int32 } @@ -148,7 +134,7 @@ func (*ACLDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// ACLDetails represents VPP binary API message 'acl_details': +// ACLDetails represents VPP binary API message 'acl_details'. type ACLDetails struct { ACLIndex uint32 Tag []byte `struc:"[64]byte"` @@ -166,7 +152,7 @@ func (*ACLDetails) GetMessageType() api.MessageType { return api.ReplyMessage } -// ACLDump represents VPP binary API message 'acl_dump': +// ACLDump represents VPP binary API message 'acl_dump'. type ACLDump struct { ACLIndex uint32 } @@ -181,7 +167,7 @@ func (*ACLDump) GetMessageType() api.MessageType { return api.RequestMessage } -// ACLInterfaceAddDel represents VPP binary API message 'acl_interface_add_del': +// ACLInterfaceAddDel represents VPP binary API message 'acl_interface_add_del'. type ACLInterfaceAddDel struct { IsAdd uint8 IsInput uint8 @@ -199,7 +185,7 @@ func (*ACLInterfaceAddDel) GetMessageType() api.MessageType { return api.RequestMessage } -// ACLInterfaceAddDelReply represents VPP binary API message 'acl_interface_add_del_reply': +// ACLInterfaceAddDelReply represents VPP binary API message 'acl_interface_add_del_reply'. type ACLInterfaceAddDelReply struct { Retval int32 } @@ -214,7 +200,7 @@ func (*ACLInterfaceAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// ACLInterfaceEtypeWhitelistDetails represents VPP binary API message 'acl_interface_etype_whitelist_details': +// ACLInterfaceEtypeWhitelistDetails represents VPP binary API message 'acl_interface_etype_whitelist_details'. type ACLInterfaceEtypeWhitelistDetails struct { SwIfIndex uint32 Count uint8 `struc:"sizeof=Whitelist"` @@ -232,7 +218,7 @@ func (*ACLInterfaceEtypeWhitelistDetails) GetMessageType() api.MessageType { return api.ReplyMessage } -// ACLInterfaceEtypeWhitelistDump represents VPP binary API message 'acl_interface_etype_whitelist_dump': +// ACLInterfaceEtypeWhitelistDump represents VPP binary API message 'acl_interface_etype_whitelist_dump'. type ACLInterfaceEtypeWhitelistDump struct { SwIfIndex uint32 } @@ -247,7 +233,7 @@ func (*ACLInterfaceEtypeWhitelistDump) GetMessageType() api.MessageType { return api.RequestMessage } -// ACLInterfaceListDetails represents VPP binary API message 'acl_interface_list_details': +// ACLInterfaceListDetails represents VPP binary API message 'acl_interface_list_details'. type ACLInterfaceListDetails struct { SwIfIndex uint32 Count uint8 `struc:"sizeof=Acls"` @@ -265,7 +251,7 @@ func (*ACLInterfaceListDetails) GetMessageType() api.MessageType { return api.ReplyMessage } -// ACLInterfaceListDump represents VPP binary API message 'acl_interface_list_dump': +// ACLInterfaceListDump represents VPP binary API message 'acl_interface_list_dump'. type ACLInterfaceListDump struct { SwIfIndex uint32 } @@ -280,7 +266,7 @@ func (*ACLInterfaceListDump) GetMessageType() api.MessageType { return api.RequestMessage } -// ACLInterfaceSetACLList represents VPP binary API message 'acl_interface_set_acl_list': +// ACLInterfaceSetACLList represents VPP binary API message 'acl_interface_set_acl_list'. type ACLInterfaceSetACLList struct { SwIfIndex uint32 Count uint8 `struc:"sizeof=Acls"` @@ -298,7 +284,7 @@ func (*ACLInterfaceSetACLList) GetMessageType() api.MessageType { return api.RequestMessage } -// ACLInterfaceSetACLListReply represents VPP binary API message 'acl_interface_set_acl_list_reply': +// ACLInterfaceSetACLListReply represents VPP binary API message 'acl_interface_set_acl_list_reply'. type ACLInterfaceSetACLListReply struct { Retval int32 } @@ -313,7 +299,7 @@ func (*ACLInterfaceSetACLListReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// ACLInterfaceSetEtypeWhitelist represents VPP binary API message 'acl_interface_set_etype_whitelist': +// ACLInterfaceSetEtypeWhitelist represents VPP binary API message 'acl_interface_set_etype_whitelist'. type ACLInterfaceSetEtypeWhitelist struct { SwIfIndex uint32 Count uint8 `struc:"sizeof=Whitelist"` @@ -331,7 +317,7 @@ func (*ACLInterfaceSetEtypeWhitelist) GetMessageType() api.MessageType { return api.RequestMessage } -// ACLInterfaceSetEtypeWhitelistReply represents VPP binary API message 'acl_interface_set_etype_whitelist_reply': +// ACLInterfaceSetEtypeWhitelistReply represents VPP binary API message 'acl_interface_set_etype_whitelist_reply'. type ACLInterfaceSetEtypeWhitelistReply struct { Retval int32 } @@ -346,7 +332,7 @@ func (*ACLInterfaceSetEtypeWhitelistReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// ACLPluginControlPing represents VPP binary API message 'acl_plugin_control_ping': +// ACLPluginControlPing represents VPP binary API message 'acl_plugin_control_ping'. type ACLPluginControlPing struct{} func (*ACLPluginControlPing) GetMessageName() string { @@ -359,7 +345,7 @@ func (*ACLPluginControlPing) GetMessageType() api.MessageType { return api.RequestMessage } -// ACLPluginControlPingReply represents VPP binary API message 'acl_plugin_control_ping_reply': +// ACLPluginControlPingReply represents VPP binary API message 'acl_plugin_control_ping_reply'. type ACLPluginControlPingReply struct { Retval int32 ClientIndex uint32 @@ -376,7 +362,7 @@ func (*ACLPluginControlPingReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// ACLPluginGetConnTableMaxEntries represents VPP binary API message 'acl_plugin_get_conn_table_max_entries': +// ACLPluginGetConnTableMaxEntries represents VPP binary API message 'acl_plugin_get_conn_table_max_entries'. type ACLPluginGetConnTableMaxEntries struct{} func (*ACLPluginGetConnTableMaxEntries) GetMessageName() string { @@ -389,7 +375,7 @@ func (*ACLPluginGetConnTableMaxEntries) GetMessageType() api.MessageType { return api.RequestMessage } -// ACLPluginGetConnTableMaxEntriesReply represents VPP binary API message 'acl_plugin_get_conn_table_max_entries_reply': +// ACLPluginGetConnTableMaxEntriesReply represents VPP binary API message 'acl_plugin_get_conn_table_max_entries_reply'. type ACLPluginGetConnTableMaxEntriesReply struct { ConnTableMaxEntries uint64 } @@ -404,7 +390,7 @@ func (*ACLPluginGetConnTableMaxEntriesReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// ACLPluginGetVersion represents VPP binary API message 'acl_plugin_get_version': +// ACLPluginGetVersion represents VPP binary API message 'acl_plugin_get_version'. type ACLPluginGetVersion struct{} func (*ACLPluginGetVersion) GetMessageName() string { @@ -417,7 +403,7 @@ func (*ACLPluginGetVersion) GetMessageType() api.MessageType { return api.RequestMessage } -// ACLPluginGetVersionReply represents VPP binary API message 'acl_plugin_get_version_reply': +// ACLPluginGetVersionReply represents VPP binary API message 'acl_plugin_get_version_reply'. type ACLPluginGetVersionReply struct { Major uint32 Minor uint32 @@ -433,7 +419,7 @@ func (*ACLPluginGetVersionReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// MacipACLAdd represents VPP binary API message 'macip_acl_add': +// MacipACLAdd represents VPP binary API message 'macip_acl_add'. type MacipACLAdd struct { Tag []byte `struc:"[64]byte"` Count uint32 `struc:"sizeof=R"` @@ -450,7 +436,7 @@ func (*MacipACLAdd) GetMessageType() api.MessageType { return api.RequestMessage } -// MacipACLAddReplace represents VPP binary API message 'macip_acl_add_replace': +// MacipACLAddReplace represents VPP binary API message 'macip_acl_add_replace'. type MacipACLAddReplace struct { ACLIndex uint32 Tag []byte `struc:"[64]byte"` @@ -468,7 +454,7 @@ func (*MacipACLAddReplace) GetMessageType() api.MessageType { return api.RequestMessage } -// MacipACLAddReplaceReply represents VPP binary API message 'macip_acl_add_replace_reply': +// MacipACLAddReplaceReply represents VPP binary API message 'macip_acl_add_replace_reply'. type MacipACLAddReplaceReply struct { ACLIndex uint32 Retval int32 @@ -484,7 +470,7 @@ func (*MacipACLAddReplaceReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// MacipACLAddReply represents VPP binary API message 'macip_acl_add_reply': +// MacipACLAddReply represents VPP binary API message 'macip_acl_add_reply'. type MacipACLAddReply struct { ACLIndex uint32 Retval int32 @@ -500,7 +486,7 @@ func (*MacipACLAddReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// MacipACLDel represents VPP binary API message 'macip_acl_del': +// MacipACLDel represents VPP binary API message 'macip_acl_del'. type MacipACLDel struct { ACLIndex uint32 } @@ -515,7 +501,7 @@ func (*MacipACLDel) GetMessageType() api.MessageType { return api.RequestMessage } -// MacipACLDelReply represents VPP binary API message 'macip_acl_del_reply': +// MacipACLDelReply represents VPP binary API message 'macip_acl_del_reply'. type MacipACLDelReply struct { Retval int32 } @@ -530,7 +516,7 @@ func (*MacipACLDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// MacipACLDetails represents VPP binary API message 'macip_acl_details': +// MacipACLDetails represents VPP binary API message 'macip_acl_details'. type MacipACLDetails struct { ACLIndex uint32 Tag []byte `struc:"[64]byte"` @@ -548,7 +534,7 @@ func (*MacipACLDetails) GetMessageType() api.MessageType { return api.ReplyMessage } -// MacipACLDump represents VPP binary API message 'macip_acl_dump': +// MacipACLDump represents VPP binary API message 'macip_acl_dump'. type MacipACLDump struct { ACLIndex uint32 } @@ -563,7 +549,7 @@ func (*MacipACLDump) GetMessageType() api.MessageType { return api.RequestMessage } -// MacipACLInterfaceAddDel represents VPP binary API message 'macip_acl_interface_add_del': +// MacipACLInterfaceAddDel represents VPP binary API message 'macip_acl_interface_add_del'. type MacipACLInterfaceAddDel struct { IsAdd uint8 SwIfIndex uint32 @@ -580,7 +566,7 @@ func (*MacipACLInterfaceAddDel) GetMessageType() api.MessageType { return api.RequestMessage } -// MacipACLInterfaceAddDelReply represents VPP binary API message 'macip_acl_interface_add_del_reply': +// MacipACLInterfaceAddDelReply represents VPP binary API message 'macip_acl_interface_add_del_reply'. type MacipACLInterfaceAddDelReply struct { Retval int32 } @@ -595,7 +581,7 @@ func (*MacipACLInterfaceAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// MacipACLInterfaceGet represents VPP binary API message 'macip_acl_interface_get': +// MacipACLInterfaceGet represents VPP binary API message 'macip_acl_interface_get'. type MacipACLInterfaceGet struct{} func (*MacipACLInterfaceGet) GetMessageName() string { @@ -608,7 +594,7 @@ func (*MacipACLInterfaceGet) GetMessageType() api.MessageType { return api.RequestMessage } -// MacipACLInterfaceGetReply represents VPP binary API message 'macip_acl_interface_get_reply': +// MacipACLInterfaceGetReply represents VPP binary API message 'macip_acl_interface_get_reply'. type MacipACLInterfaceGetReply struct { Count uint32 `struc:"sizeof=Acls"` Acls []uint32 @@ -624,7 +610,7 @@ func (*MacipACLInterfaceGetReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// MacipACLInterfaceListDetails represents VPP binary API message 'macip_acl_interface_list_details': +// MacipACLInterfaceListDetails represents VPP binary API message 'macip_acl_interface_list_details'. type MacipACLInterfaceListDetails struct { SwIfIndex uint32 Count uint8 `struc:"sizeof=Acls"` @@ -641,7 +627,7 @@ func (*MacipACLInterfaceListDetails) GetMessageType() api.MessageType { return api.ReplyMessage } -// MacipACLInterfaceListDump represents VPP binary API message 'macip_acl_interface_list_dump': +// MacipACLInterfaceListDump represents VPP binary API message 'macip_acl_interface_list_dump'. type MacipACLInterfaceListDump struct { SwIfIndex uint32 } @@ -737,13 +723,13 @@ func AllMessages() []api.Message { } } -// Service represents VPP binary API services in acl module. -type Service interface { - DumpACL(ctx context.Context, in *ACLDump) ([]*ACLDetails, error) - DumpACLInterfaceEtypeWhitelist(ctx context.Context, in *ACLInterfaceEtypeWhitelistDump) ([]*ACLInterfaceEtypeWhitelistDetails, error) - DumpACLInterfaceList(ctx context.Context, in *ACLInterfaceListDump) ([]*ACLInterfaceListDetails, error) - DumpMacipACL(ctx context.Context, in *MacipACLDump) ([]*MacipACLDetails, error) - DumpMacipACLInterfaceList(ctx context.Context, in *MacipACLInterfaceListDump) ([]*MacipACLInterfaceListDetails, error) +// RPCService represents RPC service API for acl module. +type RPCService interface { + DumpACL(ctx context.Context, in *ACLDump) (RPCService_DumpACLClient, error) + DumpACLInterfaceEtypeWhitelist(ctx context.Context, in *ACLInterfaceEtypeWhitelistDump) (RPCService_DumpACLInterfaceEtypeWhitelistClient, error) + DumpACLInterfaceList(ctx context.Context, in *ACLInterfaceListDump) (RPCService_DumpACLInterfaceListClient, error) + DumpMacipACL(ctx context.Context, in *MacipACLDump) (RPCService_DumpMacipACLClient, error) + DumpMacipACLInterfaceList(ctx context.Context, in *MacipACLInterfaceListDump) (RPCService_DumpMacipACLInterfaceListClient, error) ACLAddReplace(ctx context.Context, in *ACLAddReplace) (*ACLAddReplaceReply, error) ACLDel(ctx context.Context, in *ACLDel) (*ACLDelReply, error) ACLInterfaceAddDel(ctx context.Context, in *ACLInterfaceAddDel) (*ACLInterfaceAddDelReply, error) @@ -759,100 +745,145 @@ type Service interface { MacipACLInterfaceGet(ctx context.Context, in *MacipACLInterfaceGet) (*MacipACLInterfaceGetReply, error) } -type service struct { +type serviceClient struct { ch api.Channel } -func NewService(ch api.Channel) Service { - return &service{ch} +func NewServiceClient(ch api.Channel) RPCService { + return &serviceClient{ch} +} + +func (c *serviceClient) DumpACL(ctx context.Context, in *ACLDump) (RPCService_DumpACLClient, error) { + stream := c.ch.SendMultiRequest(in) + x := &serviceClient_DumpACLClient{stream} + return x, nil +} + +type RPCService_DumpACLClient interface { + Recv() (*ACLDetails, error) +} + +type serviceClient_DumpACLClient struct { + api.MultiRequestCtx +} + +func (c *serviceClient_DumpACLClient) Recv() (*ACLDetails, error) { + m := new(ACLDetails) + stop, err := c.MultiRequestCtx.ReceiveReply(m) + if err != nil { + return nil, err + } + if stop { + return nil, io.EOF + } + return m, nil +} + +func (c *serviceClient) DumpACLInterfaceEtypeWhitelist(ctx context.Context, in *ACLInterfaceEtypeWhitelistDump) (RPCService_DumpACLInterfaceEtypeWhitelistClient, error) { + stream := c.ch.SendMultiRequest(in) + x := &serviceClient_DumpACLInterfaceEtypeWhitelistClient{stream} + return x, nil +} + +type RPCService_DumpACLInterfaceEtypeWhitelistClient interface { + Recv() (*ACLInterfaceEtypeWhitelistDetails, error) +} + +type serviceClient_DumpACLInterfaceEtypeWhitelistClient struct { + api.MultiRequestCtx +} + +func (c *serviceClient_DumpACLInterfaceEtypeWhitelistClient) Recv() (*ACLInterfaceEtypeWhitelistDetails, error) { + m := new(ACLInterfaceEtypeWhitelistDetails) + stop, err := c.MultiRequestCtx.ReceiveReply(m) + if err != nil { + return nil, err + } + if stop { + return nil, io.EOF + } + return m, nil +} + +func (c *serviceClient) DumpACLInterfaceList(ctx context.Context, in *ACLInterfaceListDump) (RPCService_DumpACLInterfaceListClient, error) { + stream := c.ch.SendMultiRequest(in) + x := &serviceClient_DumpACLInterfaceListClient{stream} + return x, nil +} + +type RPCService_DumpACLInterfaceListClient interface { + Recv() (*ACLInterfaceListDetails, error) } -func (c *service) DumpACL(ctx context.Context, in *ACLDump) ([]*ACLDetails, error) { - var dump []*ACLDetails - req := c.ch.SendMultiRequest(in) - for { - m := new(ACLDetails) - stop, err := req.ReceiveReply(m) - if stop { - break - } - if err != nil { - return nil, err - } - dump = append(dump, m) +type serviceClient_DumpACLInterfaceListClient struct { + api.MultiRequestCtx +} + +func (c *serviceClient_DumpACLInterfaceListClient) Recv() (*ACLInterfaceListDetails, error) { + m := new(ACLInterfaceListDetails) + stop, err := c.MultiRequestCtx.ReceiveReply(m) + if err != nil { + return nil, err } - return dump, nil -} - -func (c *service) DumpACLInterfaceEtypeWhitelist(ctx context.Context, in *ACLInterfaceEtypeWhitelistDump) ([]*ACLInterfaceEtypeWhitelistDetails, error) { - var dump []*ACLInterfaceEtypeWhitelistDetails - req := c.ch.SendMultiRequest(in) - for { - m := new(ACLInterfaceEtypeWhitelistDetails) - stop, err := req.ReceiveReply(m) - if stop { - break - } - if err != nil { - return nil, err - } - dump = append(dump, m) + if stop { + return nil, io.EOF } - return dump, nil -} - -func (c *service) DumpACLInterfaceList(ctx context.Context, in *ACLInterfaceListDump) ([]*ACLInterfaceListDetails, error) { - var dump []*ACLInterfaceListDetails - req := c.ch.SendMultiRequest(in) - for { - m := new(ACLInterfaceListDetails) - stop, err := req.ReceiveReply(m) - if stop { - break - } - if err != nil { - return nil, err - } - dump = append(dump, m) + return m, nil +} + +func (c *serviceClient) DumpMacipACL(ctx context.Context, in *MacipACLDump) (RPCService_DumpMacipACLClient, error) { + stream := c.ch.SendMultiRequest(in) + x := &serviceClient_DumpMacipACLClient{stream} + return x, nil +} + +type RPCService_DumpMacipACLClient interface { + Recv() (*MacipACLDetails, error) +} + +type serviceClient_DumpMacipACLClient struct { + api.MultiRequestCtx +} + +func (c *serviceClient_DumpMacipACLClient) Recv() (*MacipACLDetails, error) { + m := new(MacipACLDetails) + stop, err := c.MultiRequestCtx.ReceiveReply(m) + if err != nil { + return nil, err } - return dump, nil -} - -func (c *service) DumpMacipACL(ctx context.Context, in *MacipACLDump) ([]*MacipACLDetails, error) { - var dump []*MacipACLDetails - req := c.ch.SendMultiRequest(in) - for { - m := new(MacipACLDetails) - stop, err := req.ReceiveReply(m) - if stop { - break - } - if err != nil { - return nil, err - } - dump = append(dump, m) + if stop { + return nil, io.EOF } - return dump, nil -} - -func (c *service) DumpMacipACLInterfaceList(ctx context.Context, in *MacipACLInterfaceListDump) ([]*MacipACLInterfaceListDetails, error) { - var dump []*MacipACLInterfaceListDetails - req := c.ch.SendMultiRequest(in) - for { - m := new(MacipACLInterfaceListDetails) - stop, err := req.ReceiveReply(m) - if stop { - break - } - if err != nil { - return nil, err - } - dump = append(dump, m) + return m, nil +} + +func (c *serviceClient) DumpMacipACLInterfaceList(ctx context.Context, in *MacipACLInterfaceListDump) (RPCService_DumpMacipACLInterfaceListClient, error) { + stream := c.ch.SendMultiRequest(in) + x := &serviceClient_DumpMacipACLInterfaceListClient{stream} + return x, nil +} + +type RPCService_DumpMacipACLInterfaceListClient interface { + Recv() (*MacipACLInterfaceListDetails, error) +} + +type serviceClient_DumpMacipACLInterfaceListClient struct { + api.MultiRequestCtx +} + +func (c *serviceClient_DumpMacipACLInterfaceListClient) Recv() (*MacipACLInterfaceListDetails, error) { + m := new(MacipACLInterfaceListDetails) + stop, err := c.MultiRequestCtx.ReceiveReply(m) + if err != nil { + return nil, err + } + if stop { + return nil, io.EOF } - return dump, nil + return m, nil } -func (c *service) ACLAddReplace(ctx context.Context, in *ACLAddReplace) (*ACLAddReplaceReply, error) { +func (c *serviceClient) ACLAddReplace(ctx context.Context, in *ACLAddReplace) (*ACLAddReplaceReply, error) { out := new(ACLAddReplaceReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -861,7 +892,7 @@ func (c *service) ACLAddReplace(ctx context.Context, in *ACLAddReplace) (*ACLAdd return out, nil } -func (c *service) ACLDel(ctx context.Context, in *ACLDel) (*ACLDelReply, error) { +func (c *serviceClient) ACLDel(ctx context.Context, in *ACLDel) (*ACLDelReply, error) { out := new(ACLDelReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -870,7 +901,7 @@ func (c *service) ACLDel(ctx context.Context, in *ACLDel) (*ACLDelReply, error) return out, nil } -func (c *service) ACLInterfaceAddDel(ctx context.Context, in *ACLInterfaceAddDel) (*ACLInterfaceAddDelReply, error) { +func (c *serviceClient) ACLInterfaceAddDel(ctx context.Context, in *ACLInterfaceAddDel) (*ACLInterfaceAddDelReply, error) { out := new(ACLInterfaceAddDelReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -879,7 +910,7 @@ func (c *service) ACLInterfaceAddDel(ctx context.Context, in *ACLInterfaceAddDel return out, nil } -func (c *service) ACLInterfaceSetACLList(ctx context.Context, in *ACLInterfaceSetACLList) (*ACLInterfaceSetACLListReply, error) { +func (c *serviceClient) ACLInterfaceSetACLList(ctx context.Context, in *ACLInterfaceSetACLList) (*ACLInterfaceSetACLListReply, error) { out := new(ACLInterfaceSetACLListReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -888,7 +919,7 @@ func (c *service) ACLInterfaceSetACLList(ctx context.Context, in *ACLInterfaceSe return out, nil } -func (c *service) ACLInterfaceSetEtypeWhitelist(ctx context.Context, in *ACLInterfaceSetEtypeWhitelist) (*ACLInterfaceSetEtypeWhitelistReply, error) { +func (c *serviceClient) ACLInterfaceSetEtypeWhitelist(ctx context.Context, in *ACLInterfaceSetEtypeWhitelist) (*ACLInterfaceSetEtypeWhitelistReply, error) { out := new(ACLInterfaceSetEtypeWhitelistReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -897,7 +928,7 @@ func (c *service) ACLInterfaceSetEtypeWhitelist(ctx context.Context, in *ACLInte return out, nil } -func (c *service) ACLPluginControlPing(ctx context.Context, in *ACLPluginControlPing) (*ACLPluginControlPingReply, error) { +func (c *serviceClient) ACLPluginControlPing(ctx context.Context, in *ACLPluginControlPing) (*ACLPluginControlPingReply, error) { out := new(ACLPluginControlPingReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -906,7 +937,7 @@ func (c *service) ACLPluginControlPing(ctx context.Context, in *ACLPluginControl return out, nil } -func (c *service) ACLPluginGetConnTableMaxEntries(ctx context.Context, in *ACLPluginGetConnTableMaxEntries) (*ACLPluginGetConnTableMaxEntriesReply, error) { +func (c *serviceClient) ACLPluginGetConnTableMaxEntries(ctx context.Context, in *ACLPluginGetConnTableMaxEntries) (*ACLPluginGetConnTableMaxEntriesReply, error) { out := new(ACLPluginGetConnTableMaxEntriesReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -915,7 +946,7 @@ func (c *service) ACLPluginGetConnTableMaxEntries(ctx context.Context, in *ACLPl return out, nil } -func (c *service) ACLPluginGetVersion(ctx context.Context, in *ACLPluginGetVersion) (*ACLPluginGetVersionReply, error) { +func (c *serviceClient) ACLPluginGetVersion(ctx context.Context, in *ACLPluginGetVersion) (*ACLPluginGetVersionReply, error) { out := new(ACLPluginGetVersionReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -924,7 +955,7 @@ func (c *service) ACLPluginGetVersion(ctx context.Context, in *ACLPluginGetVersi return out, nil } -func (c *service) MacipACLAdd(ctx context.Context, in *MacipACLAdd) (*MacipACLAddReply, error) { +func (c *serviceClient) MacipACLAdd(ctx context.Context, in *MacipACLAdd) (*MacipACLAddReply, error) { out := new(MacipACLAddReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -933,7 +964,7 @@ func (c *service) MacipACLAdd(ctx context.Context, in *MacipACLAdd) (*MacipACLAd return out, nil } -func (c *service) MacipACLAddReplace(ctx context.Context, in *MacipACLAddReplace) (*MacipACLAddReplaceReply, error) { +func (c *serviceClient) MacipACLAddReplace(ctx context.Context, in *MacipACLAddReplace) (*MacipACLAddReplaceReply, error) { out := new(MacipACLAddReplaceReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -942,7 +973,7 @@ func (c *service) MacipACLAddReplace(ctx context.Context, in *MacipACLAddReplace return out, nil } -func (c *service) MacipACLDel(ctx context.Context, in *MacipACLDel) (*MacipACLDelReply, error) { +func (c *serviceClient) MacipACLDel(ctx context.Context, in *MacipACLDel) (*MacipACLDelReply, error) { out := new(MacipACLDelReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -951,7 +982,7 @@ func (c *service) MacipACLDel(ctx context.Context, in *MacipACLDel) (*MacipACLDe return out, nil } -func (c *service) MacipACLInterfaceAddDel(ctx context.Context, in *MacipACLInterfaceAddDel) (*MacipACLInterfaceAddDelReply, error) { +func (c *serviceClient) MacipACLInterfaceAddDel(ctx context.Context, in *MacipACLInterfaceAddDel) (*MacipACLInterfaceAddDelReply, error) { out := new(MacipACLInterfaceAddDelReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -960,7 +991,7 @@ func (c *service) MacipACLInterfaceAddDel(ctx context.Context, in *MacipACLInter return out, nil } -func (c *service) MacipACLInterfaceGet(ctx context.Context, in *MacipACLInterfaceGet) (*MacipACLInterfaceGetReply, error) { +func (c *serviceClient) MacipACLInterfaceGet(ctx context.Context, in *MacipACLInterfaceGet) (*MacipACLInterfaceGetReply, error) { out := new(MacipACLInterfaceGetReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -968,3 +999,17 @@ func (c *service) MacipACLInterfaceGet(ctx context.Context, in *MacipACLInterfac } return out, nil } + +// 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.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package + +// Reference imports to suppress errors if they are not otherwise used. +var _ = api.RegisterMessage +var _ = bytes.NewBuffer +var _ = context.Background +var _ = io.Copy +var _ = strconv.Itoa +var _ = struc.Pack diff --git a/examples/binapi/af_packet/af_packet.ba.go b/examples/binapi/af_packet/af_packet.ba.go index f4e47d0..9533f98 100644 --- a/examples/binapi/af_packet/af_packet.ba.go +++ b/examples/binapi/af_packet/af_packet.ba.go @@ -1,33 +1,23 @@ -// Code generated by GoVPP binapi-generator. DO NOT EDIT. +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. // source: /usr/share/vpp/api/core/af_packet.api.json /* -Package af_packet is a generated from VPP binary API module 'af_packet'. +Package af_packet is a generated VPP binary API for 'af_packet' module. - The af_packet module consists of: +It consists of: 8 messages 4 services */ package af_packet -import api "git.fd.io/govpp.git/api" -import bytes "bytes" -import context "context" -import strconv "strconv" -import struc "github.com/lunixbochs/struc" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = strconv.Itoa -var _ = struc.Pack - -// 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.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package +import ( + bytes "bytes" + context "context" + api "git.fd.io/govpp.git/api" + struc "github.com/lunixbochs/struc" + io "io" + strconv "strconv" +) const ( // ModuleName is the name of this module. @@ -38,9 +28,7 @@ const ( VersionCrc = 0x206563c ) -/* Messages */ - -// AfPacketCreate represents VPP binary API message 'af_packet_create': +// AfPacketCreate represents VPP binary API message 'af_packet_create'. type AfPacketCreate struct { HostIfName []byte `struc:"[64]byte"` HwAddr []byte `struc:"[6]byte"` @@ -57,7 +45,7 @@ func (*AfPacketCreate) GetMessageType() api.MessageType { return api.RequestMessage } -// AfPacketCreateReply represents VPP binary API message 'af_packet_create_reply': +// AfPacketCreateReply represents VPP binary API message 'af_packet_create_reply'. type AfPacketCreateReply struct { Retval int32 SwIfIndex uint32 @@ -73,7 +61,7 @@ func (*AfPacketCreateReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// AfPacketDelete represents VPP binary API message 'af_packet_delete': +// AfPacketDelete represents VPP binary API message 'af_packet_delete'. type AfPacketDelete struct { HostIfName []byte `struc:"[64]byte"` } @@ -88,7 +76,7 @@ func (*AfPacketDelete) GetMessageType() api.MessageType { return api.RequestMessage } -// AfPacketDeleteReply represents VPP binary API message 'af_packet_delete_reply': +// AfPacketDeleteReply represents VPP binary API message 'af_packet_delete_reply'. type AfPacketDeleteReply struct { Retval int32 } @@ -103,7 +91,7 @@ func (*AfPacketDeleteReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// AfPacketDetails represents VPP binary API message 'af_packet_details': +// AfPacketDetails represents VPP binary API message 'af_packet_details'. type AfPacketDetails struct { SwIfIndex uint32 HostIfName []byte `struc:"[64]byte"` @@ -119,7 +107,7 @@ func (*AfPacketDetails) GetMessageType() api.MessageType { return api.ReplyMessage } -// AfPacketDump represents VPP binary API message 'af_packet_dump': +// AfPacketDump represents VPP binary API message 'af_packet_dump'. type AfPacketDump struct{} func (*AfPacketDump) GetMessageName() string { @@ -132,7 +120,7 @@ func (*AfPacketDump) GetMessageType() api.MessageType { return api.RequestMessage } -// AfPacketSetL4CksumOffload represents VPP binary API message 'af_packet_set_l4_cksum_offload': +// AfPacketSetL4CksumOffload represents VPP binary API message 'af_packet_set_l4_cksum_offload'. type AfPacketSetL4CksumOffload struct { SwIfIndex uint8 Set uint8 @@ -148,7 +136,7 @@ func (*AfPacketSetL4CksumOffload) GetMessageType() api.MessageType { return api.RequestMessage } -// AfPacketSetL4CksumOffloadReply represents VPP binary API message 'af_packet_set_l4_cksum_offload_reply': +// AfPacketSetL4CksumOffloadReply represents VPP binary API message 'af_packet_set_l4_cksum_offload_reply'. type AfPacketSetL4CksumOffloadReply struct { Retval int32 } @@ -188,40 +176,49 @@ func AllMessages() []api.Message { } } -// Service represents VPP binary API services in af_packet module. -type Service interface { - DumpAfPacket(ctx context.Context, in *AfPacketDump) ([]*AfPacketDetails, error) +// RPCService represents RPC service API for af_packet module. +type RPCService interface { + DumpAfPacket(ctx context.Context, in *AfPacketDump) (RPCService_DumpAfPacketClient, error) AfPacketCreate(ctx context.Context, in *AfPacketCreate) (*AfPacketCreateReply, error) AfPacketDelete(ctx context.Context, in *AfPacketDelete) (*AfPacketDeleteReply, error) AfPacketSetL4CksumOffload(ctx context.Context, in *AfPacketSetL4CksumOffload) (*AfPacketSetL4CksumOffloadReply, error) } -type service struct { +type serviceClient struct { ch api.Channel } -func NewService(ch api.Channel) Service { - return &service{ch} +func NewServiceClient(ch api.Channel) RPCService { + return &serviceClient{ch} +} + +func (c *serviceClient) DumpAfPacket(ctx context.Context, in *AfPacketDump) (RPCService_DumpAfPacketClient, error) { + stream := c.ch.SendMultiRequest(in) + x := &serviceClient_DumpAfPacketClient{stream} + return x, nil +} + +type RPCService_DumpAfPacketClient interface { + Recv() (*AfPacketDetails, error) } -func (c *service) DumpAfPacket(ctx context.Context, in *AfPacketDump) ([]*AfPacketDetails, error) { - var dump []*AfPacketDetails - req := c.ch.SendMultiRequest(in) - for { - m := new(AfPacketDetails) - stop, err := req.ReceiveReply(m) - if stop { - break - } - if err != nil { - return nil, err - } - dump = append(dump, m) +type serviceClient_DumpAfPacketClient struct { + api.MultiRequestCtx +} + +func (c *serviceClient_DumpAfPacketClient) Recv() (*AfPacketDetails, error) { + m := new(AfPacketDetails) + stop, err := c.MultiRequestCtx.ReceiveReply(m) + if err != nil { + return nil, err + } + if stop { + return nil, io.EOF } - return dump, nil + return m, nil } -func (c *service) AfPacketCreate(ctx context.Context, in *AfPacketCreate) (*AfPacketCreateReply, error) { +func (c *serviceClient) AfPacketCreate(ctx context.Context, in *AfPacketCreate) (*AfPacketCreateReply, error) { out := new(AfPacketCreateReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -230,7 +227,7 @@ func (c *service) AfPacketCreate(ctx context.Context, in *AfPacketCreate) (*AfPa return out, nil } -func (c *service) AfPacketDelete(ctx context.Context, in *AfPacketDelete) (*AfPacketDeleteReply, error) { +func (c *serviceClient) AfPacketDelete(ctx context.Context, in *AfPacketDelete) (*AfPacketDeleteReply, error) { out := new(AfPacketDeleteReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -239,7 +236,7 @@ func (c *service) AfPacketDelete(ctx context.Context, in *AfPacketDelete) (*AfPa return out, nil } -func (c *service) AfPacketSetL4CksumOffload(ctx context.Context, in *AfPacketSetL4CksumOffload) (*AfPacketSetL4CksumOffloadReply, error) { +func (c *serviceClient) AfPacketSetL4CksumOffload(ctx context.Context, in *AfPacketSetL4CksumOffload) (*AfPacketSetL4CksumOffloadReply, error) { out := new(AfPacketSetL4CksumOffloadReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -247,3 +244,17 @@ func (c *service) AfPacketSetL4CksumOffload(ctx context.Context, in *AfPacketSet } return out, nil } + +// 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.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package + +// Reference imports to suppress errors if they are not otherwise used. +var _ = api.RegisterMessage +var _ = bytes.NewBuffer +var _ = context.Background +var _ = io.Copy +var _ = strconv.Itoa +var _ = struc.Pack diff --git a/examples/binapi/gen.go b/examples/binapi/gen.go index 40fb25d..edaa703 100644 --- a/examples/binapi/gen.go +++ b/examples/binapi/gen.go @@ -3,14 +3,13 @@ package binapi // Generate Go code from the VPP APIs located in the /usr/share/vpp/api directory. //go:generate -command binapigen binapi-generator --output-dir=. --include-services -// Core +// core //go:generate binapigen --input-file=/usr/share/vpp/api/core/af_packet.api.json //go:generate binapigen --input-file=/usr/share/vpp/api/core/interface.api.json //go:generate binapigen --input-file=/usr/share/vpp/api/core/ip.api.json //go:generate binapigen --input-file=/usr/share/vpp/api/core/memclnt.api.json //go:generate binapigen --input-file=/usr/share/vpp/api/core/vpe.api.json - -// Plugins +// plugins //go:generate binapigen --input-file=/usr/share/vpp/api/plugins/acl.api.json //go:generate binapigen --input-file=/usr/share/vpp/api/plugins/memif.api.json diff --git a/examples/binapi/interfaces/interfaces.ba.go b/examples/binapi/interfaces/interfaces.ba.go index e4ad5f5..958f78e 100644 --- a/examples/binapi/interfaces/interfaces.ba.go +++ b/examples/binapi/interfaces/interfaces.ba.go @@ -1,34 +1,24 @@ -// Code generated by GoVPP binapi-generator. DO NOT EDIT. +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. // source: /usr/share/vpp/api/core/interface.api.json /* -Package interfaces is a generated from VPP binary API module 'interface'. +Package interfaces is a generated VPP binary API for 'interface' module. - The interface module consists of: +It consists of: 1 alias 51 messages 25 services */ package interfaces -import api "git.fd.io/govpp.git/api" -import bytes "bytes" -import context "context" -import strconv "strconv" -import struc "github.com/lunixbochs/struc" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = strconv.Itoa -var _ = struc.Pack - -// 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.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package +import ( + bytes "bytes" + context "context" + api "git.fd.io/govpp.git/api" + struc "github.com/lunixbochs/struc" + io "io" + strconv "strconv" +) const ( // ModuleName is the name of this module. @@ -39,14 +29,10 @@ const ( VersionCrc = 0x672de521 ) -/* Aliases */ - -// InterfaceIndex represents VPP binary API alias 'interface_index': +// InterfaceIndex represents VPP binary API alias 'interface_index'. type InterfaceIndex uint32 -/* Messages */ - -// CollectDetailedInterfaceStats represents VPP binary API message 'collect_detailed_interface_stats': +// CollectDetailedInterfaceStats represents VPP binary API message 'collect_detailed_interface_stats'. type CollectDetailedInterfaceStats struct { SwIfIndex uint32 EnableDisable uint8 @@ -62,7 +48,7 @@ func (*CollectDetailedInterfaceStats) GetMessageType() api.MessageType { return api.RequestMessage } -// CollectDetailedInterfaceStatsReply represents VPP binary API message 'collect_detailed_interface_stats_reply': +// CollectDetailedInterfaceStatsReply represents VPP binary API message 'collect_detailed_interface_stats_reply'. type CollectDetailedInterfaceStatsReply struct { Retval int32 } @@ -77,7 +63,7 @@ func (*CollectDetailedInterfaceStatsReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// CreateLoopback represents VPP binary API message 'create_loopback': +// CreateLoopback represents VPP binary API message 'create_loopback'. type CreateLoopback struct { MacAddress []byte `struc:"[6]byte"` } @@ -92,7 +78,7 @@ func (*CreateLoopback) GetMessageType() api.MessageType { return api.RequestMessage } -// CreateLoopbackInstance represents VPP binary API message 'create_loopback_instance': +// CreateLoopbackInstance represents VPP binary API message 'create_loopback_instance'. type CreateLoopbackInstance struct { MacAddress []byte `struc:"[6]byte"` IsSpecified uint8 @@ -109,7 +95,7 @@ func (*CreateLoopbackInstance) GetMessageType() api.MessageType { return api.RequestMessage } -// CreateLoopbackInstanceReply represents VPP binary API message 'create_loopback_instance_reply': +// CreateLoopbackInstanceReply represents VPP binary API message 'create_loopback_instance_reply'. type CreateLoopbackInstanceReply struct { Retval int32 SwIfIndex uint32 @@ -125,7 +111,7 @@ func (*CreateLoopbackInstanceReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// CreateLoopbackReply represents VPP binary API message 'create_loopback_reply': +// CreateLoopbackReply represents VPP binary API message 'create_loopback_reply'. type CreateLoopbackReply struct { Retval int32 SwIfIndex uint32 @@ -141,7 +127,7 @@ func (*CreateLoopbackReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// CreateSubif represents VPP binary API message 'create_subif': +// CreateSubif represents VPP binary API message 'create_subif'. type CreateSubif struct { SwIfIndex uint32 SubID uint32 @@ -167,7 +153,7 @@ func (*CreateSubif) GetMessageType() api.MessageType { return api.RequestMessage } -// CreateSubifReply represents VPP binary API message 'create_subif_reply': +// CreateSubifReply represents VPP binary API message 'create_subif_reply'. type CreateSubifReply struct { Retval int32 SwIfIndex uint32 @@ -183,7 +169,7 @@ func (*CreateSubifReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// CreateVlanSubif represents VPP binary API message 'create_vlan_subif': +// CreateVlanSubif represents VPP binary API message 'create_vlan_subif'. type CreateVlanSubif struct { SwIfIndex uint32 VlanID uint32 @@ -199,7 +185,7 @@ func (*CreateVlanSubif) GetMessageType() api.MessageType { return api.RequestMessage } -// CreateVlanSubifReply represents VPP binary API message 'create_vlan_subif_reply': +// CreateVlanSubifReply represents VPP binary API message 'create_vlan_subif_reply'. type CreateVlanSubifReply struct { Retval int32 SwIfIndex uint32 @@ -215,7 +201,7 @@ func (*CreateVlanSubifReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// DeleteLoopback represents VPP binary API message 'delete_loopback': +// DeleteLoopback represents VPP binary API message 'delete_loopback'. type DeleteLoopback struct { SwIfIndex uint32 } @@ -230,7 +216,7 @@ func (*DeleteLoopback) GetMessageType() api.MessageType { return api.RequestMessage } -// DeleteLoopbackReply represents VPP binary API message 'delete_loopback_reply': +// DeleteLoopbackReply represents VPP binary API message 'delete_loopback_reply'. type DeleteLoopbackReply struct { Retval int32 } @@ -245,7 +231,7 @@ func (*DeleteLoopbackReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// DeleteSubif represents VPP binary API message 'delete_subif': +// DeleteSubif represents VPP binary API message 'delete_subif'. type DeleteSubif struct { SwIfIndex uint32 } @@ -260,7 +246,7 @@ func (*DeleteSubif) GetMessageType() api.MessageType { return api.RequestMessage } -// DeleteSubifReply represents VPP binary API message 'delete_subif_reply': +// DeleteSubifReply represents VPP binary API message 'delete_subif_reply'. type DeleteSubifReply struct { Retval int32 } @@ -275,7 +261,7 @@ func (*DeleteSubifReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// HwInterfaceSetMtu represents VPP binary API message 'hw_interface_set_mtu': +// HwInterfaceSetMtu represents VPP binary API message 'hw_interface_set_mtu'. type HwInterfaceSetMtu struct { SwIfIndex uint32 Mtu uint16 @@ -291,7 +277,7 @@ func (*HwInterfaceSetMtu) GetMessageType() api.MessageType { return api.RequestMessage } -// HwInterfaceSetMtuReply represents VPP binary API message 'hw_interface_set_mtu_reply': +// HwInterfaceSetMtuReply represents VPP binary API message 'hw_interface_set_mtu_reply'. type HwInterfaceSetMtuReply struct { Retval int32 } @@ -306,7 +292,7 @@ func (*HwInterfaceSetMtuReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// InterfaceNameRenumber represents VPP binary API message 'interface_name_renumber': +// InterfaceNameRenumber represents VPP binary API message 'interface_name_renumber'. type InterfaceNameRenumber struct { SwIfIndex uint32 NewShowDevInstance uint32 @@ -322,7 +308,7 @@ func (*InterfaceNameRenumber) GetMessageType() api.MessageType { return api.RequestMessage } -// InterfaceNameRenumberReply represents VPP binary API message 'interface_name_renumber_reply': +// InterfaceNameRenumberReply represents VPP binary API message 'interface_name_renumber_reply'. type InterfaceNameRenumberReply struct { Retval int32 } @@ -337,7 +323,7 @@ func (*InterfaceNameRenumberReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// SwInterfaceAddDelAddress represents VPP binary API message 'sw_interface_add_del_address': +// SwInterfaceAddDelAddress represents VPP binary API message 'sw_interface_add_del_address'. type SwInterfaceAddDelAddress struct { SwIfIndex uint32 IsAdd uint8 @@ -357,7 +343,7 @@ func (*SwInterfaceAddDelAddress) GetMessageType() api.MessageType { return api.RequestMessage } -// SwInterfaceAddDelAddressReply represents VPP binary API message 'sw_interface_add_del_address_reply': +// SwInterfaceAddDelAddressReply represents VPP binary API message 'sw_interface_add_del_address_reply'. type SwInterfaceAddDelAddressReply struct { Retval int32 } @@ -372,7 +358,7 @@ func (*SwInterfaceAddDelAddressReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// SwInterfaceClearStats represents VPP binary API message 'sw_interface_clear_stats': +// SwInterfaceClearStats represents VPP binary API message 'sw_interface_clear_stats'. type SwInterfaceClearStats struct { SwIfIndex uint32 } @@ -387,7 +373,7 @@ func (*SwInterfaceClearStats) GetMessageType() api.MessageType { return api.RequestMessage } -// SwInterfaceClearStatsReply represents VPP binary API message 'sw_interface_clear_stats_reply': +// SwInterfaceClearStatsReply represents VPP binary API message 'sw_interface_clear_stats_reply'. type SwInterfaceClearStatsReply struct { Retval int32 } @@ -402,7 +388,7 @@ func (*SwInterfaceClearStatsReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// SwInterfaceDetails represents VPP binary API message 'sw_interface_details': +// SwInterfaceDetails represents VPP binary API message 'sw_interface_details'. type SwInterfaceDetails struct { SwIfIndex uint32 SupSwIfIndex uint32 @@ -447,7 +433,7 @@ func (*SwInterfaceDetails) GetMessageType() api.MessageType { return api.ReplyMessage } -// SwInterfaceDump represents VPP binary API message 'sw_interface_dump': +// SwInterfaceDump represents VPP binary API message 'sw_interface_dump'. type SwInterfaceDump struct { NameFilterValid uint8 NameFilter []byte `struc:"[49]byte"` @@ -463,7 +449,7 @@ func (*SwInterfaceDump) GetMessageType() api.MessageType { return api.RequestMessage } -// SwInterfaceEvent represents VPP binary API message 'sw_interface_event': +// SwInterfaceEvent represents VPP binary API message 'sw_interface_event'. type SwInterfaceEvent struct { PID uint32 SwIfIndex uint32 @@ -482,7 +468,7 @@ func (*SwInterfaceEvent) GetMessageType() api.MessageType { return api.EventMessage } -// SwInterfaceGetMacAddress represents VPP binary API message 'sw_interface_get_mac_address': +// SwInterfaceGetMacAddress represents VPP binary API message 'sw_interface_get_mac_address'. type SwInterfaceGetMacAddress struct { SwIfIndex uint32 } @@ -497,7 +483,7 @@ func (*SwInterfaceGetMacAddress) GetMessageType() api.MessageType { return api.RequestMessage } -// SwInterfaceGetMacAddressReply represents VPP binary API message 'sw_interface_get_mac_address_reply': +// SwInterfaceGetMacAddressReply represents VPP binary API message 'sw_interface_get_mac_address_reply'. type SwInterfaceGetMacAddressReply struct { Retval int32 MacAddress []byte `struc:"[6]byte"` @@ -513,7 +499,7 @@ func (*SwInterfaceGetMacAddressReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// SwInterfaceGetTable represents VPP binary API message 'sw_interface_get_table': +// SwInterfaceGetTable represents VPP binary API message 'sw_interface_get_table'. type SwInterfaceGetTable struct { SwIfIndex uint32 IsIPv6 uint8 @@ -529,7 +515,7 @@ func (*SwInterfaceGetTable) GetMessageType() api.MessageType { return api.RequestMessage } -// SwInterfaceGetTableReply represents VPP binary API message 'sw_interface_get_table_reply': +// SwInterfaceGetTableReply represents VPP binary API message 'sw_interface_get_table_reply'. type SwInterfaceGetTableReply struct { Retval int32 VrfID uint32 @@ -545,7 +531,7 @@ func (*SwInterfaceGetTableReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// SwInterfaceRxPlacementDetails represents VPP binary API message 'sw_interface_rx_placement_details': +// SwInterfaceRxPlacementDetails represents VPP binary API message 'sw_interface_rx_placement_details'. type SwInterfaceRxPlacementDetails struct { SwIfIndex uint32 QueueID uint32 @@ -563,7 +549,7 @@ func (*SwInterfaceRxPlacementDetails) GetMessageType() api.MessageType { return api.RequestMessage } -// SwInterfaceRxPlacementDump represents VPP binary API message 'sw_interface_rx_placement_dump': +// SwInterfaceRxPlacementDump represents VPP binary API message 'sw_interface_rx_placement_dump'. type SwInterfaceRxPlacementDump struct { SwIfIndex uint32 } @@ -578,7 +564,7 @@ func (*SwInterfaceRxPlacementDump) GetMessageType() api.MessageType { return api.RequestMessage } -// SwInterfaceSetFlags represents VPP binary API message 'sw_interface_set_flags': +// SwInterfaceSetFlags represents VPP binary API message 'sw_interface_set_flags'. type SwInterfaceSetFlags struct { SwIfIndex uint32 AdminUpDown uint8 @@ -594,7 +580,7 @@ func (*SwInterfaceSetFlags) GetMessageType() api.MessageType { return api.RequestMessage } -// SwInterfaceSetFlagsReply represents VPP binary API message 'sw_interface_set_flags_reply': +// SwInterfaceSetFlagsReply represents VPP binary API message 'sw_interface_set_flags_reply'. type SwInterfaceSetFlagsReply struct { Retval int32 } @@ -609,7 +595,7 @@ func (*SwInterfaceSetFlagsReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// SwInterfaceSetIPDirectedBroadcast represents VPP binary API message 'sw_interface_set_ip_directed_broadcast': +// SwInterfaceSetIPDirectedBroadcast represents VPP binary API message 'sw_interface_set_ip_directed_broadcast'. type SwInterfaceSetIPDirectedBroadcast struct { SwIfIndex uint32 Enable uint8 @@ -625,7 +611,7 @@ func (*SwInterfaceSetIPDirectedBroadcast) GetMessageType() api.MessageType { return api.RequestMessage } -// SwInterfaceSetIPDirectedBroadcastReply represents VPP binary API message 'sw_interface_set_ip_directed_broadcast_reply': +// SwInterfaceSetIPDirectedBroadcastReply represents VPP binary API message 'sw_interface_set_ip_directed_broadcast_reply'. type SwInterfaceSetIPDirectedBroadcastReply struct { Retval int32 } @@ -640,7 +626,7 @@ func (*SwInterfaceSetIPDirectedBroadcastReply) GetMessageType() api.MessageType return api.ReplyMessage } -// SwInterfaceSetMacAddress represents VPP binary API message 'sw_interface_set_mac_address': +// SwInterfaceSetMacAddress represents VPP binary API message 'sw_interface_set_mac_address'. type SwInterfaceSetMacAddress struct { SwIfIndex uint32 MacAddress []byte `struc:"[6]byte"` @@ -656,7 +642,7 @@ func (*SwInterfaceSetMacAddress) GetMessageType() api.MessageType { return api.RequestMessage } -// SwInterfaceSetMacAddressReply represents VPP binary API message 'sw_interface_set_mac_address_reply': +// SwInterfaceSetMacAddressReply represents VPP binary API message 'sw_interface_set_mac_address_reply'. type SwInterfaceSetMacAddressReply struct { Retval int32 } @@ -671,7 +657,7 @@ func (*SwInterfaceSetMacAddressReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// SwInterfaceSetMtu represents VPP binary API message 'sw_interface_set_mtu': +// SwInterfaceSetMtu represents VPP binary API message 'sw_interface_set_mtu'. type SwInterfaceSetMtu struct { SwIfIndex uint32 Mtu []uint32 `struc:"[4]uint32"` @@ -687,7 +673,7 @@ func (*SwInterfaceSetMtu) GetMessageType() api.MessageType { return api.RequestMessage } -// SwInterfaceSetMtuReply represents VPP binary API message 'sw_interface_set_mtu_reply': +// SwInterfaceSetMtuReply represents VPP binary API message 'sw_interface_set_mtu_reply'. type SwInterfaceSetMtuReply struct { Retval int32 } @@ -702,7 +688,7 @@ func (*SwInterfaceSetMtuReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// SwInterfaceSetRxMode represents VPP binary API message 'sw_interface_set_rx_mode': +// SwInterfaceSetRxMode represents VPP binary API message 'sw_interface_set_rx_mode'. type SwInterfaceSetRxMode struct { SwIfIndex uint32 QueueIDValid uint8 @@ -720,7 +706,7 @@ func (*SwInterfaceSetRxMode) GetMessageType() api.MessageType { return api.RequestMessage } -// SwInterfaceSetRxModeReply represents VPP binary API message 'sw_interface_set_rx_mode_reply': +// SwInterfaceSetRxModeReply represents VPP binary API message 'sw_interface_set_rx_mode_reply'. type SwInterfaceSetRxModeReply struct { Retval int32 } @@ -735,7 +721,7 @@ func (*SwInterfaceSetRxModeReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// SwInterfaceSetRxPlacement represents VPP binary API message 'sw_interface_set_rx_placement': +// SwInterfaceSetRxPlacement represents VPP binary API message 'sw_interface_set_rx_placement'. type SwInterfaceSetRxPlacement struct { SwIfIndex uint32 QueueID uint32 @@ -753,7 +739,7 @@ func (*SwInterfaceSetRxPlacement) GetMessageType() api.MessageType { return api.RequestMessage } -// SwInterfaceSetRxPlacementReply represents VPP binary API message 'sw_interface_set_rx_placement_reply': +// SwInterfaceSetRxPlacementReply represents VPP binary API message 'sw_interface_set_rx_placement_reply'. type SwInterfaceSetRxPlacementReply struct { Retval int32 } @@ -768,7 +754,7 @@ func (*SwInterfaceSetRxPlacementReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// SwInterfaceSetTable represents VPP binary API message 'sw_interface_set_table': +// SwInterfaceSetTable represents VPP binary API message 'sw_interface_set_table'. type SwInterfaceSetTable struct { SwIfIndex uint32 IsIPv6 uint8 @@ -785,7 +771,7 @@ func (*SwInterfaceSetTable) GetMessageType() api.MessageType { return api.RequestMessage } -// SwInterfaceSetTableReply represents VPP binary API message 'sw_interface_set_table_reply': +// SwInterfaceSetTableReply represents VPP binary API message 'sw_interface_set_table_reply'. type SwInterfaceSetTableReply struct { Retval int32 } @@ -800,7 +786,7 @@ func (*SwInterfaceSetTableReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// SwInterfaceSetUnnumbered represents VPP binary API message 'sw_interface_set_unnumbered': +// SwInterfaceSetUnnumbered represents VPP binary API message 'sw_interface_set_unnumbered'. type SwInterfaceSetUnnumbered struct { SwIfIndex uint32 UnnumberedSwIfIndex uint32 @@ -817,7 +803,7 @@ func (*SwInterfaceSetUnnumbered) GetMessageType() api.MessageType { return api.RequestMessage } -// SwInterfaceSetUnnumberedReply represents VPP binary API message 'sw_interface_set_unnumbered_reply': +// SwInterfaceSetUnnumberedReply represents VPP binary API message 'sw_interface_set_unnumbered_reply'. type SwInterfaceSetUnnumberedReply struct { Retval int32 } @@ -832,7 +818,7 @@ func (*SwInterfaceSetUnnumberedReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// SwInterfaceTagAddDel represents VPP binary API message 'sw_interface_tag_add_del': +// SwInterfaceTagAddDel represents VPP binary API message 'sw_interface_tag_add_del'. type SwInterfaceTagAddDel struct { IsAdd uint8 SwIfIndex uint32 @@ -849,7 +835,7 @@ func (*SwInterfaceTagAddDel) GetMessageType() api.MessageType { return api.RequestMessage } -// SwInterfaceTagAddDelReply represents VPP binary API message 'sw_interface_tag_add_del_reply': +// SwInterfaceTagAddDelReply represents VPP binary API message 'sw_interface_tag_add_del_reply'. type SwInterfaceTagAddDelReply struct { Retval int32 } @@ -864,7 +850,7 @@ func (*SwInterfaceTagAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// WantInterfaceEvents represents VPP binary API message 'want_interface_events': +// WantInterfaceEvents represents VPP binary API message 'want_interface_events'. type WantInterfaceEvents struct { EnableDisable uint32 PID uint32 @@ -880,7 +866,7 @@ func (*WantInterfaceEvents) GetMessageType() api.MessageType { return api.RequestMessage } -// WantInterfaceEventsReply represents VPP binary API message 'want_interface_events_reply': +// WantInterfaceEventsReply represents VPP binary API message 'want_interface_events_reply'. type WantInterfaceEventsReply struct { Retval int32 } @@ -1006,10 +992,10 @@ func AllMessages() []api.Message { } } -// Service represents VPP binary API services in interface module. -type Service interface { - DumpSwInterface(ctx context.Context, in *SwInterfaceDump) ([]*SwInterfaceDetails, error) - DumpSwInterfaceRxPlacement(ctx context.Context, in *SwInterfaceRxPlacementDump) ([]*SwInterfaceRxPlacementDetails, error) +// RPCService represents RPC service API for interface module. +type RPCService interface { + DumpSwInterface(ctx context.Context, in *SwInterfaceDump) (RPCService_DumpSwInterfaceClient, error) + DumpSwInterfaceRxPlacement(ctx context.Context, in *SwInterfaceRxPlacementDump) (RPCService_DumpSwInterfaceRxPlacementClient, error) CollectDetailedInterfaceStats(ctx context.Context, in *CollectDetailedInterfaceStats) (*CollectDetailedInterfaceStatsReply, error) CreateLoopback(ctx context.Context, in *CreateLoopback) (*CreateLoopbackReply, error) CreateLoopbackInstance(ctx context.Context, in *CreateLoopbackInstance) (*CreateLoopbackInstanceReply, error) @@ -1035,49 +1021,67 @@ type Service interface { WantInterfaceEvents(ctx context.Context, in *WantInterfaceEvents) (*WantInterfaceEventsReply, error) } -type service struct { +type serviceClient struct { ch api.Channel } -func NewService(ch api.Channel) Service { - return &service{ch} +func NewServiceClient(ch api.Channel) RPCService { + return &serviceClient{ch} +} + +func (c *serviceClient) DumpSwInterface(ctx context.Context, in *SwInterfaceDump) (RPCService_DumpSwInterfaceClient, error) { + stream := c.ch.SendMultiRequest(in) + x := &serviceClient_DumpSwInterfaceClient{stream} + return x, nil +} + +type RPCService_DumpSwInterfaceClient interface { + Recv() (*SwInterfaceDetails, error) +} + +type serviceClient_DumpSwInterfaceClient struct { + api.MultiRequestCtx } -func (c *service) DumpSwInterface(ctx context.Context, in *SwInterfaceDump) ([]*SwInterfaceDetails, error) { - var dump []*SwInterfaceDetails - req := c.ch.SendMultiRequest(in) - for { - m := new(SwInterfaceDetails) - stop, err := req.ReceiveReply(m) - if stop { - break - } - if err != nil { - return nil, err - } - dump = append(dump, m) +func (c *serviceClient_DumpSwInterfaceClient) Recv() (*SwInterfaceDetails, error) { + m := new(SwInterfaceDetails) + stop, err := c.MultiRequestCtx.ReceiveReply(m) + if err != nil { + return nil, err } - return dump, nil -} - -func (c *service) DumpSwInterfaceRxPlacement(ctx context.Context, in *SwInterfaceRxPlacementDump) ([]*SwInterfaceRxPlacementDetails, error) { - var dump []*SwInterfaceRxPlacementDetails - req := c.ch.SendMultiRequest(in) - for { - m := new(SwInterfaceRxPlacementDetails) - stop, err := req.ReceiveReply(m) - if stop { - break - } - if err != nil { - return nil, err - } - dump = append(dump, m) + if stop { + return nil, io.EOF } - return dump, nil + return m, nil } -func (c *service) CollectDetailedInterfaceStats(ctx context.Context, in *CollectDetailedInterfaceStats) (*CollectDetailedInterfaceStatsReply, error) { +func (c *serviceClient) DumpSwInterfaceRxPlacement(ctx context.Context, in *SwInterfaceRxPlacementDump) (RPCService_DumpSwInterfaceRxPlacementClient, error) { + stream := c.ch.SendMultiRequest(in) + x := &serviceClient_DumpSwInterfaceRxPlacementClient{stream} + return x, nil +} + +type RPCService_DumpSwInterfaceRxPlacementClient interface { + Recv() (*SwInterfaceRxPlacementDetails, error) +} + +type serviceClient_DumpSwInterfaceRxPlacementClient struct { + api.MultiRequestCtx +} + +func (c *serviceClient_DumpSwInterfaceRxPlacementClient) Recv() (*SwInterfaceRxPlacementDetails, error) { + m := new(SwInterfaceRxPlacementDetails) + stop, err := c.MultiRequestCtx.ReceiveReply(m) + if err != nil { + return nil, err + } + if stop { + return nil, io.EOF + } + return m, nil +} + +func (c *serviceClient) CollectDetailedInterfaceStats(ctx context.Context, in *CollectDetailedInterfaceStats) (*CollectDetailedInterfaceStatsReply, error) { out := new(CollectDetailedInterfaceStatsReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -1086,7 +1090,7 @@ func (c *service) CollectDetailedInterfaceStats(ctx context.Context, in *Collect return out, nil } -func (c *service) CreateLoopback(ctx context.Context, in *CreateLoopback) (*CreateLoopbackReply, error) { +func (c *serviceClient) CreateLoopback(ctx context.Context, in *CreateLoopback) (*CreateLoopbackReply, error) { out := new(CreateLoopbackReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -1095,7 +1099,7 @@ func (c *service) CreateLoopback(ctx context.Context, in *CreateLoopback) (*Crea return out, nil } -func (c *service) CreateLoopbackInstance(ctx context.Context, in *CreateLoopbackInstance) (*CreateLoopbackInstanceReply, error) { +func (c *serviceClient) CreateLoopbackInstance(ctx context.Context, in *CreateLoopbackInstance) (*CreateLoopbackInstanceReply, error) { out := new(CreateLoopbackInstanceReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -1104,7 +1108,7 @@ func (c *service) CreateLoopbackInstance(ctx context.Context, in *CreateLoopback return out, nil } -func (c *service) CreateSubif(ctx context.Context, in *CreateSubif) (*CreateSubifReply, error) { +func (c *serviceClient) CreateSubif(ctx context.Context, in *CreateSubif) (*CreateSubifReply, error) { out := new(CreateSubifReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -1113,7 +1117,7 @@ func (c *service) CreateSubif(ctx context.Context, in *CreateSubif) (*CreateSubi return out, nil } -func (c *service) CreateVlanSubif(ctx context.Context, in *CreateVlanSubif) (*CreateVlanSubifReply, error) { +func (c *serviceClient) CreateVlanSubif(ctx context.Context, in *CreateVlanSubif) (*CreateVlanSubifReply, error) { out := new(CreateVlanSubifReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -1122,7 +1126,7 @@ func (c *service) CreateVlanSubif(ctx context.Context, in *CreateVlanSubif) (*Cr return out, nil } -func (c *service) DeleteLoopback(ctx context.Context, in *DeleteLoopback) (*DeleteLoopbackReply, error) { +func (c *serviceClient) DeleteLoopback(ctx context.Context, in *DeleteLoopback) (*DeleteLoopbackReply, error) { out := new(DeleteLoopbackReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -1131,7 +1135,7 @@ func (c *service) DeleteLoopback(ctx context.Context, in *DeleteLoopback) (*Dele return out, nil } -func (c *service) DeleteSubif(ctx context.Context, in *DeleteSubif) (*DeleteSubifReply, error) { +func (c *serviceClient) DeleteSubif(ctx context.Context, in *DeleteSubif) (*DeleteSubifReply, error) { out := new(DeleteSubifReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -1140,7 +1144,7 @@ func (c *service) DeleteSubif(ctx context.Context, in *DeleteSubif) (*DeleteSubi return out, nil } -func (c *service) HwInterfaceSetMtu(ctx context.Context, in *HwInterfaceSetMtu) (*HwInterfaceSetMtuReply, error) { +func (c *serviceClient) HwInterfaceSetMtu(ctx context.Context, in *HwInterfaceSetMtu) (*HwInterfaceSetMtuReply, error) { out := new(HwInterfaceSetMtuReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -1149,7 +1153,7 @@ func (c *service) HwInterfaceSetMtu(ctx context.Context, in *HwInterfaceSetMtu) return out, nil } -func (c *service) InterfaceNameRenumber(ctx context.Context, in *InterfaceNameRenumber) (*InterfaceNameRenumberReply, error) { +func (c *serviceClient) InterfaceNameRenumber(ctx context.Context, in *InterfaceNameRenumber) (*InterfaceNameRenumberReply, error) { out := new(InterfaceNameRenumberReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -1158,7 +1162,7 @@ func (c *service) InterfaceNameRenumber(ctx context.Context, in *InterfaceNameRe return out, nil } -func (c *service) SwInterfaceAddDelAddress(ctx context.Context, in *SwInterfaceAddDelAddress) (*SwInterfaceAddDelAddressReply, error) { +func (c *serviceClient) SwInterfaceAddDelAddress(ctx context.Context, in *SwInterfaceAddDelAddress) (*SwInterfaceAddDelAddressReply, error) { out := new(SwInterfaceAddDelAddressReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -1167,7 +1171,7 @@ func (c *service) SwInterfaceAddDelAddress(ctx context.Context, in *SwInterfaceA return out, nil } -func (c *service) SwInterfaceClearStats(ctx context.Context, in *SwInterfaceClearStats) (*SwInterfaceClearStatsReply, error) { +func (c *serviceClient) SwInterfaceClearStats(ctx context.Context, in *SwInterfaceClearStats) (*SwInterfaceClearStatsReply, error) { out := new(SwInterfaceClearStatsReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -1176,7 +1180,7 @@ func (c *service) SwInterfaceClearStats(ctx context.Context, in *SwInterfaceClea return out, nil } -func (c *service) SwInterfaceGetMacAddress(ctx context.Context, in *SwInterfaceGetMacAddress) (*SwInterfaceGetMacAddressReply, error) { +func (c *serviceClient) SwInterfaceGetMacAddress(ctx context.Context, in *SwInterfaceGetMacAddress) (*SwInterfaceGetMacAddressReply, error) { out := new(SwInterfaceGetMacAddressReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -1185,7 +1189,7 @@ func (c *service) SwInterfaceGetMacAddress(ctx context.Context, in *SwInterfaceG return out, nil } -func (c *service) SwInterfaceGetTable(ctx context.Context, in *SwInterfaceGetTable) (*SwInterfaceGetTableReply, error) { +func (c *serviceClient) SwInterfaceGetTable(ctx context.Context, in *SwInterfaceGetTable) (*SwInterfaceGetTableReply, error) { out := new(SwInterfaceGetTableReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -1194,7 +1198,7 @@ func (c *service) SwInterfaceGetTable(ctx context.Context, in *SwInterfaceGetTab return out, nil } -func (c *service) SwInterfaceSetFlags(ctx context.Context, in *SwInterfaceSetFlags) (*SwInterfaceSetFlagsReply, error) { +func (c *serviceClient) SwInterfaceSetFlags(ctx context.Context, in *SwInterfaceSetFlags) (*SwInterfaceSetFlagsReply, error) { out := new(SwInterfaceSetFlagsReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -1203,7 +1207,7 @@ func (c *service) SwInterfaceSetFlags(ctx context.Context, in *SwInterfaceSetFla return out, nil } -func (c *service) SwInterfaceSetIPDirectedBroadcast(ctx context.Context, in *SwInterfaceSetIPDirectedBroadcast) (*SwInterfaceSetIPDirectedBroadcastReply, error) { +func (c *serviceClient) SwInterfaceSetIPDirectedBroadcast(ctx context.Context, in *SwInterfaceSetIPDirectedBroadcast) (*SwInterfaceSetIPDirectedBroadcastReply, error) { out := new(SwInterfaceSetIPDirectedBroadcastReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -1212,7 +1216,7 @@ func (c *service) SwInterfaceSetIPDirectedBroadcast(ctx context.Context, in *SwI return out, nil } -func (c *service) SwInterfaceSetMacAddress(ctx context.Context, in *SwInterfaceSetMacAddress) (*SwInterfaceSetMacAddressReply, error) { +func (c *serviceClient) SwInterfaceSetMacAddress(ctx context.Context, in *SwInterfaceSetMacAddress) (*SwInterfaceSetMacAddressReply, error) { out := new(SwInterfaceSetMacAddressReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -1221,7 +1225,7 @@ func (c *service) SwInterfaceSetMacAddress(ctx context.Context, in *SwInterfaceS return out, nil } -func (c *service) SwInterfaceSetMtu(ctx context.Context, in *SwInterfaceSetMtu) (*SwInterfaceSetMtuReply, error) { +func (c *serviceClient) SwInterfaceSetMtu(ctx context.Context, in *SwInterfaceSetMtu) (*SwInterfaceSetMtuReply, error) { out := new(SwInterfaceSetMtuReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -1230,7 +1234,7 @@ func (c *service) SwInterfaceSetMtu(ctx context.Context, in *SwInterfaceSetMtu) return out, nil } -func (c *service) SwInterfaceSetRxMode(ctx context.Context, in *SwInterfaceSetRxMode) (*SwInterfaceSetRxModeReply, error) { +func (c *serviceClient) SwInterfaceSetRxMode(ctx context.Context, in *SwInterfaceSetRxMode) (*SwInterfaceSetRxModeReply, error) { out := new(SwInterfaceSetRxModeReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -1239,7 +1243,7 @@ func (c *service) SwInterfaceSetRxMode(ctx context.Context, in *SwInterfaceSetRx return out, nil } -func (c *service) SwInterfaceSetRxPlacement(ctx context.Context, in *SwInterfaceSetRxPlacement) (*SwInterfaceSetRxPlacementReply, error) { +func (c *serviceClient) SwInterfaceSetRxPlacement(ctx context.Context, in *SwInterfaceSetRxPlacement) (*SwInterfaceSetRxPlacementReply, error) { out := new(SwInterfaceSetRxPlacementReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -1248,7 +1252,7 @@ func (c *service) SwInterfaceSetRxPlacement(ctx context.Context, in *SwInterface return out, nil } -func (c *service) SwInterfaceSetTable(ctx context.Context, in *SwInterfaceSetTable) (*SwInterfaceSetTableReply, error) { +func (c *serviceClient) SwInterfaceSetTable(ctx context.Context, in *SwInterfaceSetTable) (*SwInterfaceSetTableReply, error) { out := new(SwInterfaceSetTableReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -1257,7 +1261,7 @@ func (c *service) SwInterfaceSetTable(ctx context.Context, in *SwInterfaceSetTab return out, nil } -func (c *service) SwInterfaceSetUnnumbered(ctx context.Context, in *SwInterfaceSetUnnumbered) (*SwInterfaceSetUnnumberedReply, error) { +func (c *serviceClient) SwInterfaceSetUnnumbered(ctx context.Context, in *SwInterfaceSetUnnumbered) (*SwInterfaceSetUnnumberedReply, error) { out := new(SwInterfaceSetUnnumberedReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -1266,7 +1270,7 @@ func (c *service) SwInterfaceSetUnnumbered(ctx context.Context, in *SwInterfaceS return out, nil } -func (c *service) SwInterfaceTagAddDel(ctx context.Context, in *SwInterfaceTagAddDel) (*SwInterfaceTagAddDelReply, error) { +func (c *serviceClient) SwInterfaceTagAddDel(ctx context.Context, in *SwInterfaceTagAddDel) (*SwInterfaceTagAddDelReply, error) { out := new(SwInterfaceTagAddDelReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -1275,7 +1279,7 @@ func (c *service) SwInterfaceTagAddDel(ctx context.Context, in *SwInterfaceTagAd return out, nil } -func (c *service) WantInterfaceEvents(ctx context.Context, in *WantInterfaceEvents) (*WantInterfaceEventsReply, error) { +func (c *serviceClient) WantInterfaceEvents(ctx context.Context, in *WantInterfaceEvents) (*WantInterfaceEventsReply, error) { out := new(WantInterfaceEventsReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -1283,3 +1287,17 @@ func (c *service) WantInterfaceEvents(ctx context.Context, in *WantInterfaceEven } return out, nil } + +// 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.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package + +// Reference imports to suppress errors if they are not otherwise used. +var _ = api.RegisterMessage +var _ = bytes.NewBuffer +var _ = context.Background +var _ = io.Copy +var _ = strconv.Itoa +var _ = struc.Pack diff --git a/examples/binapi/ip/ip.ba.go b/examples/binapi/ip/ip.ba.go index 58a9aaa..a23ae94 100644 --- a/examples/binapi/ip/ip.ba.go +++ b/examples/binapi/ip/ip.ba.go @@ -1,10 +1,10 @@ -// Code generated by GoVPP binapi-generator. DO NOT EDIT. +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. // source: /usr/share/vpp/api/core/ip.api.json /* -Package ip is a generated from VPP binary API module 'ip'. +Package ip is a generated VPP binary API for 'ip' module. - The ip module consists of: +It consists of: 2 enums 3 aliases 12 types @@ -14,24 +14,14 @@ Package ip is a generated from VPP binary API module 'ip'. */ package ip -import api "git.fd.io/govpp.git/api" -import bytes "bytes" -import context "context" -import strconv "strconv" -import struc "github.com/lunixbochs/struc" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = strconv.Itoa -var _ = struc.Pack - -// 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.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package +import ( + bytes "bytes" + context "context" + api "git.fd.io/govpp.git/api" + struc "github.com/lunixbochs/struc" + io "io" + strconv "strconv" +) const ( // ModuleName is the name of this module. @@ -42,9 +32,7 @@ const ( VersionCrc = 0x51ac4ce0 ) -/* Enums */ - -// AddressFamily represents VPP binary API enum 'address_family': +// AddressFamily represents VPP binary API enum 'address_family'. type AddressFamily uint32 const ( @@ -70,7 +58,7 @@ func (x AddressFamily) String() string { return strconv.Itoa(int(x)) } -// IPNeighborFlags represents VPP binary API enum 'ip_neighbor_flags': +// IPNeighborFlags represents VPP binary API enum 'ip_neighbor_flags'. type IPNeighborFlags uint32 const ( @@ -99,20 +87,16 @@ func (x IPNeighborFlags) String() string { return strconv.Itoa(int(x)) } -/* Aliases */ - -// IP4Address represents VPP binary API alias 'ip4_address': +// IP4Address represents VPP binary API alias 'ip4_address'. type IP4Address [4]uint8 -// IP6Address represents VPP binary API alias 'ip6_address': +// IP6Address represents VPP binary API alias 'ip6_address'. type IP6Address [16]uint8 -// MacAddress represents VPP binary API alias 'mac_address': +// MacAddress represents VPP binary API alias 'mac_address'. type MacAddress [6]uint8 -/* Types */ - -// Address represents VPP binary API type 'address': +// Address represents VPP binary API type 'address'. type Address struct { Af AddressFamily Un AddressUnion @@ -125,7 +109,7 @@ func (*Address) GetCrcString() string { return "09f11671" } -// FibMplsLabel represents VPP binary API type 'fib_mpls_label': +// FibMplsLabel represents VPP binary API type 'fib_mpls_label'. type FibMplsLabel struct { IsUniform uint8 Label uint32 @@ -140,7 +124,7 @@ func (*FibMplsLabel) GetCrcString() string { return "c93bf35c" } -// FibPath represents VPP binary API type 'fib_path': +// FibPath represents VPP binary API type 'fib_path'. type FibPath struct { SwIfIndex uint32 TableID uint32 @@ -172,7 +156,7 @@ func (*FibPath) GetCrcString() string { return "ba7a81f0" } -// IP4Prefix represents VPP binary API type 'ip4_prefix': +// IP4Prefix represents VPP binary API type 'ip4_prefix'. type IP4Prefix struct { Prefix IP4Address Len uint8 @@ -185,7 +169,7 @@ func (*IP4Prefix) GetCrcString() string { return "ea8dc11d" } -// IP6Prefix represents VPP binary API type 'ip6_prefix': +// IP6Prefix represents VPP binary API type 'ip6_prefix'. type IP6Prefix struct { Prefix IP6Address Len uint8 @@ -198,7 +182,7 @@ func (*IP6Prefix) GetCrcString() string { return "779fd64f" } -// IP6RaPrefixInfo represents VPP binary API type 'ip6_ra_prefix_info': +// IP6RaPrefixInfo represents VPP binary API type 'ip6_ra_prefix_info'. type IP6RaPrefixInfo struct { Prefix Prefix Flags uint8 @@ -213,7 +197,7 @@ func (*IP6RaPrefixInfo) GetCrcString() string { return "fa025b72" } -// IPNeighbor represents VPP binary API type 'ip_neighbor': +// IPNeighbor represents VPP binary API type 'ip_neighbor'. type IPNeighbor struct { SwIfIndex uint32 Flags IPNeighborFlags @@ -228,7 +212,7 @@ func (*IPNeighbor) GetCrcString() string { return "4bf82d5d" } -// MfibPath represents VPP binary API type 'mfib_path': +// MfibPath represents VPP binary API type 'mfib_path'. type MfibPath struct { Path FibPath ItfFlags uint32 @@ -241,7 +225,7 @@ func (*MfibPath) GetCrcString() string { return "4ba77d32" } -// Mprefix represents VPP binary API type 'mprefix': +// Mprefix represents VPP binary API type 'mprefix'. type Mprefix struct { Af AddressFamily GrpAddressLength uint16 @@ -256,7 +240,7 @@ func (*Mprefix) GetCrcString() string { return "1c4cba05" } -// Prefix represents VPP binary API type 'prefix': +// Prefix represents VPP binary API type 'prefix'. type Prefix struct { Address Address AddressLength uint8 @@ -269,7 +253,7 @@ func (*Prefix) GetCrcString() string { return "0403aebc" } -// ProxyArp represents VPP binary API type 'proxy_arp': +// ProxyArp represents VPP binary API type 'proxy_arp'. type ProxyArp struct { TableID uint32 Low IP4Address @@ -283,7 +267,7 @@ func (*ProxyArp) GetCrcString() string { return "e9067693" } -// PuntRedirect represents VPP binary API type 'punt_redirect': +// PuntRedirect represents VPP binary API type 'punt_redirect'. type PuntRedirect struct { RxSwIfIndex uint32 TxSwIfIndex uint32 @@ -297,9 +281,7 @@ func (*PuntRedirect) GetCrcString() string { return "3e7a801f" } -/* Unions */ - -// AddressUnion represents VPP binary API union 'address_union': +// AddressUnion represents VPP binary API union 'address_union'. type AddressUnion struct { XXX_UnionData [16]byte } @@ -345,9 +327,7 @@ func (u *AddressUnion) GetIP6() (a IP6Address) { return } -/* Messages */ - -// IoamDisable represents VPP binary API message 'ioam_disable': +// IoamDisable represents VPP binary API message 'ioam_disable'. type IoamDisable struct { ID uint16 } @@ -362,7 +342,7 @@ func (*IoamDisable) GetMessageType() api.MessageType { return api.RequestMessage } -// IoamDisableReply represents VPP binary API message 'ioam_disable_reply': +// IoamDisableReply represents VPP binary API message 'ioam_disable_reply'. type IoamDisableReply struct { Retval int32 } @@ -377,7 +357,7 @@ func (*IoamDisableReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// IoamEnable represents VPP binary API message 'ioam_enable': +// IoamEnable represents VPP binary API message 'ioam_enable'. type IoamEnable struct { ID uint16 Seqno uint8 @@ -397,7 +377,7 @@ func (*IoamEnable) GetMessageType() api.MessageType { return api.RequestMessage } -// IoamEnableReply represents VPP binary API message 'ioam_enable_reply': +// IoamEnableReply represents VPP binary API message 'ioam_enable_reply'. type IoamEnableReply struct { Retval int32 } @@ -412,7 +392,7 @@ func (*IoamEnableReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// IP4ArpEvent represents VPP binary API message 'ip4_arp_event': +// IP4ArpEvent represents VPP binary API message 'ip4_arp_event'. type IP4ArpEvent struct { IP IP4Address PID uint32 @@ -431,7 +411,7 @@ func (*IP4ArpEvent) GetMessageType() api.MessageType { return api.EventMessage } -// IP6FibDetails represents VPP binary API message 'ip6_fib_details': +// IP6FibDetails represents VPP binary API message 'ip6_fib_details'. type IP6FibDetails struct { TableID uint32 TableName []byte `struc:"[64]byte"` @@ -452,7 +432,7 @@ func (*IP6FibDetails) GetMessageType() api.MessageType { return api.ReplyMessage } -// IP6FibDump represents VPP binary API message 'ip6_fib_dump': +// IP6FibDump represents VPP binary API message 'ip6_fib_dump'. type IP6FibDump struct{} func (*IP6FibDump) GetMessageName() string { @@ -465,7 +445,7 @@ func (*IP6FibDump) GetMessageType() api.MessageType { return api.RequestMessage } -// IP6MfibDetails represents VPP binary API message 'ip6_mfib_details': +// IP6MfibDetails represents VPP binary API message 'ip6_mfib_details'. type IP6MfibDetails struct { TableID uint32 AddressLength uint8 @@ -485,7 +465,7 @@ func (*IP6MfibDetails) GetMessageType() api.MessageType { return api.ReplyMessage } -// IP6MfibDump represents VPP binary API message 'ip6_mfib_dump': +// IP6MfibDump represents VPP binary API message 'ip6_mfib_dump'. type IP6MfibDump struct{} func (*IP6MfibDump) GetMessageName() string { @@ -498,7 +478,7 @@ func (*IP6MfibDump) GetMessageType() api.MessageType { return api.RequestMessage } -// IP6NdEvent represents VPP binary API message 'ip6_nd_event': +// IP6NdEvent represents VPP binary API message 'ip6_nd_event'. type IP6NdEvent struct { PID uint32 SwIfIndex uint32 @@ -517,7 +497,7 @@ func (*IP6NdEvent) GetMessageType() api.MessageType { return api.EventMessage } -// IP6RaEvent represents VPP binary API message 'ip6_ra_event': +// IP6RaEvent represents VPP binary API message 'ip6_ra_event'. type IP6RaEvent struct { PID uint32 SwIfIndex uint32 @@ -541,7 +521,7 @@ func (*IP6RaEvent) GetMessageType() api.MessageType { return api.EventMessage } -// IP6ndProxyAddDel represents VPP binary API message 'ip6nd_proxy_add_del': +// IP6ndProxyAddDel represents VPP binary API message 'ip6nd_proxy_add_del'. type IP6ndProxyAddDel struct { SwIfIndex uint32 IsDel uint8 @@ -558,7 +538,7 @@ func (*IP6ndProxyAddDel) GetMessageType() api.MessageType { return api.RequestMessage } -// IP6ndProxyAddDelReply represents VPP binary API message 'ip6nd_proxy_add_del_reply': +// IP6ndProxyAddDelReply represents VPP binary API message 'ip6nd_proxy_add_del_reply'. type IP6ndProxyAddDelReply struct { Retval int32 } @@ -573,7 +553,7 @@ func (*IP6ndProxyAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// IP6ndProxyDetails represents VPP binary API message 'ip6nd_proxy_details': +// IP6ndProxyDetails represents VPP binary API message 'ip6nd_proxy_details'. type IP6ndProxyDetails struct { SwIfIndex uint32 IP IP6Address @@ -589,7 +569,7 @@ func (*IP6ndProxyDetails) GetMessageType() api.MessageType { return api.ReplyMessage } -// IP6ndProxyDump represents VPP binary API message 'ip6nd_proxy_dump': +// IP6ndProxyDump represents VPP binary API message 'ip6nd_proxy_dump'. type IP6ndProxyDump struct{} func (*IP6ndProxyDump) GetMessageName() string { @@ -602,7 +582,7 @@ func (*IP6ndProxyDump) GetMessageType() api.MessageType { return api.RequestMessage } -// IP6ndSendRouterSolicitation represents VPP binary API message 'ip6nd_send_router_solicitation': +// IP6ndSendRouterSolicitation represents VPP binary API message 'ip6nd_send_router_solicitation'. type IP6ndSendRouterSolicitation struct { Irt uint32 Mrt uint32 @@ -622,7 +602,7 @@ func (*IP6ndSendRouterSolicitation) GetMessageType() api.MessageType { return api.RequestMessage } -// IP6ndSendRouterSolicitationReply represents VPP binary API message 'ip6nd_send_router_solicitation_reply': +// IP6ndSendRouterSolicitationReply represents VPP binary API message 'ip6nd_send_router_solicitation_reply'. type IP6ndSendRouterSolicitationReply struct { Retval int32 } @@ -637,7 +617,7 @@ func (*IP6ndSendRouterSolicitationReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// IPAddDelRoute represents VPP binary API message 'ip_add_del_route': +// IPAddDelRoute represents VPP binary API message 'ip_add_del_route'. type IPAddDelRoute struct { NextHopSwIfIndex uint32 TableID uint32 @@ -678,7 +658,7 @@ func (*IPAddDelRoute) GetMessageType() api.MessageType { return api.RequestMessage } -// IPAddDelRouteReply represents VPP binary API message 'ip_add_del_route_reply': +// IPAddDelRouteReply represents VPP binary API message 'ip_add_del_route_reply'. type IPAddDelRouteReply struct { Retval int32 StatsIndex uint32 @@ -694,7 +674,7 @@ func (*IPAddDelRouteReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// IPAddressDetails represents VPP binary API message 'ip_address_details': +// IPAddressDetails represents VPP binary API message 'ip_address_details'. type IPAddressDetails struct { IP []byte `struc:"[16]byte"` PrefixLength uint8 @@ -712,7 +692,7 @@ func (*IPAddressDetails) GetMessageType() api.MessageType { return api.ReplyMessage } -// IPAddressDump represents VPP binary API message 'ip_address_dump': +// IPAddressDump represents VPP binary API message 'ip_address_dump'. type IPAddressDump struct { SwIfIndex uint32 IsIPv6 uint8 @@ -728,7 +708,7 @@ func (*IPAddressDump) GetMessageType() api.MessageType { return api.RequestMessage } -// IPContainerProxyAddDel represents VPP binary API message 'ip_container_proxy_add_del': +// IPContainerProxyAddDel represents VPP binary API message 'ip_container_proxy_add_del'. type IPContainerProxyAddDel struct { Pfx Prefix SwIfIndex uint32 @@ -745,7 +725,7 @@ func (*IPContainerProxyAddDel) GetMessageType() api.MessageType { return api.RequestMessage } -// IPContainerProxyAddDelReply represents VPP binary API message 'ip_container_proxy_add_del_reply': +// IPContainerProxyAddDelReply represents VPP binary API message 'ip_container_proxy_add_del_reply'. type IPContainerProxyAddDelReply struct { Retval int32 } @@ -760,7 +740,7 @@ func (*IPContainerProxyAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// IPContainerProxyDetails represents VPP binary API message 'ip_container_proxy_details': +// IPContainerProxyDetails represents VPP binary API message 'ip_container_proxy_details'. type IPContainerProxyDetails struct { SwIfIndex uint32 Prefix Prefix @@ -776,7 +756,7 @@ func (*IPContainerProxyDetails) GetMessageType() api.MessageType { return api.ReplyMessage } -// IPContainerProxyDump represents VPP binary API message 'ip_container_proxy_dump': +// IPContainerProxyDump represents VPP binary API message 'ip_container_proxy_dump'. type IPContainerProxyDump struct{} func (*IPContainerProxyDump) GetMessageName() string { @@ -789,7 +769,7 @@ func (*IPContainerProxyDump) GetMessageType() api.MessageType { return api.RequestMessage } -// IPDetails represents VPP binary API message 'ip_details': +// IPDetails represents VPP binary API message 'ip_details'. type IPDetails struct { SwIfIndex uint32 IsIPv6 uint8 @@ -805,7 +785,7 @@ func (*IPDetails) GetMessageType() api.MessageType { return api.ReplyMessage } -// IPDump represents VPP binary API message 'ip_dump': +// IPDump represents VPP binary API message 'ip_dump'. type IPDump struct { IsIPv6 uint8 } @@ -820,7 +800,7 @@ func (*IPDump) GetMessageType() api.MessageType { return api.RequestMessage } -// IPFibDetails represents VPP binary API message 'ip_fib_details': +// IPFibDetails represents VPP binary API message 'ip_fib_details'. type IPFibDetails struct { TableID uint32 TableName []byte `struc:"[64]byte"` @@ -841,7 +821,7 @@ func (*IPFibDetails) GetMessageType() api.MessageType { return api.ReplyMessage } -// IPFibDump represents VPP binary API message 'ip_fib_dump': +// IPFibDump represents VPP binary API message 'ip_fib_dump'. type IPFibDump struct{} func (*IPFibDump) GetMessageName() string { @@ -854,7 +834,7 @@ func (*IPFibDump) GetMessageType() api.MessageType { return api.RequestMessage } -// IPMfibDetails represents VPP binary API message 'ip_mfib_details': +// IPMfibDetails represents VPP binary API message 'ip_mfib_details'. type IPMfibDetails struct { TableID uint32 EntryFlags uint32 @@ -877,7 +857,7 @@ func (*IPMfibDetails) GetMessageType() api.MessageType { return api.ReplyMessage } -// IPMfibDump represents VPP binary API message 'ip_mfib_dump': +// IPMfibDump represents VPP binary API message 'ip_mfib_dump'. type IPMfibDump struct{} func (*IPMfibDump) GetMessageName() string { @@ -890,7 +870,7 @@ func (*IPMfibDump) GetMessageType() api.MessageType { return api.RequestMessage } -// IPMrouteAddDel represents VPP binary API message 'ip_mroute_add_del': +// IPMrouteAddDel represents VPP binary API message 'ip_mroute_add_del'. type IPMrouteAddDel struct { NextHopSwIfIndex uint32 TableID uint32 @@ -918,7 +898,7 @@ func (*IPMrouteAddDel) GetMessageType() api.MessageType { return api.RequestMessage } -// IPMrouteAddDelReply represents VPP binary API message 'ip_mroute_add_del_reply': +// IPMrouteAddDelReply represents VPP binary API message 'ip_mroute_add_del_reply'. type IPMrouteAddDelReply struct { Retval int32 StatsIndex uint32 @@ -934,7 +914,7 @@ func (*IPMrouteAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// IPNeighborAddDel represents VPP binary API message 'ip_neighbor_add_del': +// IPNeighborAddDel represents VPP binary API message 'ip_neighbor_add_del'. type IPNeighborAddDel struct { IsAdd uint8 Neighbor IPNeighbor @@ -950,7 +930,7 @@ func (*IPNeighborAddDel) GetMessageType() api.MessageType { return api.RequestMessage } -// IPNeighborAddDelReply represents VPP binary API message 'ip_neighbor_add_del_reply': +// IPNeighborAddDelReply represents VPP binary API message 'ip_neighbor_add_del_reply'. type IPNeighborAddDelReply struct { Retval int32 StatsIndex uint32 @@ -966,7 +946,7 @@ func (*IPNeighborAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// IPNeighborDetails represents VPP binary API message 'ip_neighbor_details': +// IPNeighborDetails represents VPP binary API message 'ip_neighbor_details'. type IPNeighborDetails struct { Neighbor IPNeighbor } @@ -981,7 +961,7 @@ func (*IPNeighborDetails) GetMessageType() api.MessageType { return api.ReplyMessage } -// IPNeighborDump represents VPP binary API message 'ip_neighbor_dump': +// IPNeighborDump represents VPP binary API message 'ip_neighbor_dump'. type IPNeighborDump struct { SwIfIndex uint32 IsIPv6 uint8 @@ -997,7 +977,7 @@ func (*IPNeighborDump) GetMessageType() api.MessageType { return api.RequestMessage } -// IPProbeNeighbor represents VPP binary API message 'ip_probe_neighbor': +// IPProbeNeighbor represents VPP binary API message 'ip_probe_neighbor'. type IPProbeNeighbor struct { SwIfIndex uint32 Dst Address @@ -1013,7 +993,7 @@ func (*IPProbeNeighbor) GetMessageType() api.MessageType { return api.RequestMessage } -// IPProbeNeighborReply represents VPP binary API message 'ip_probe_neighbor_reply': +// IPProbeNeighborReply represents VPP binary API message 'ip_probe_neighbor_reply'. type IPProbeNeighborReply struct { Retval int32 } @@ -1028,7 +1008,7 @@ func (*IPProbeNeighborReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// IPPuntPolice represents VPP binary API message 'ip_punt_police': +// IPPuntPolice represents VPP binary API message 'ip_punt_police'. type IPPuntPolice struct { PolicerIndex uint32 IsAdd uint8 @@ -1045,7 +1025,7 @@ func (*IPPuntPolice) GetMessageType() api.MessageType { return api.RequestMessage } -// IPPuntPoliceReply represents VPP binary API message 'ip_punt_police_reply': +// IPPuntPoliceReply represents VPP binary API message 'ip_punt_police_reply'. type IPPuntPoliceReply struct { Retval int32 } @@ -1060,7 +1040,7 @@ func (*IPPuntPoliceReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// IPPuntRedirect represents VPP binary API message 'ip_punt_redirect': +// IPPuntRedirect represents VPP binary API message 'ip_punt_redirect'. type IPPuntRedirect struct { Punt PuntRedirect IsAdd uint8 @@ -1076,7 +1056,7 @@ func (*IPPuntRedirect) GetMessageType() api.MessageType { return api.RequestMessage } -// IPPuntRedirectDetails represents VPP binary API message 'ip_punt_redirect_details': +// IPPuntRedirectDetails represents VPP binary API message 'ip_punt_redirect_details'. type IPPuntRedirectDetails struct { Punt PuntRedirect } @@ -1091,7 +1071,7 @@ func (*IPPuntRedirectDetails) GetMessageType() api.MessageType { return api.ReplyMessage } -// IPPuntRedirectDump represents VPP binary API message 'ip_punt_redirect_dump': +// IPPuntRedirectDump represents VPP binary API message 'ip_punt_redirect_dump'. type IPPuntRedirectDump struct { SwIfIndex uint32 IsIPv6 uint8 @@ -1107,7 +1087,7 @@ func (*IPPuntRedirectDump) GetMessageType() api.MessageType { return api.RequestMessage } -// IPPuntRedirectReply represents VPP binary API message 'ip_punt_redirect_reply': +// IPPuntRedirectReply represents VPP binary API message 'ip_punt_redirect_reply'. type IPPuntRedirectReply struct { Retval int32 } @@ -1122,7 +1102,7 @@ func (*IPPuntRedirectReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// IPReassemblyEnableDisable represents VPP binary API message 'ip_reassembly_enable_disable': +// IPReassemblyEnableDisable represents VPP binary API message 'ip_reassembly_enable_disable'. type IPReassemblyEnableDisable struct { SwIfIndex uint32 EnableIP4 uint8 @@ -1139,7 +1119,7 @@ func (*IPReassemblyEnableDisable) GetMessageType() api.MessageType { return api.RequestMessage } -// IPReassemblyEnableDisableReply represents VPP binary API message 'ip_reassembly_enable_disable_reply': +// IPReassemblyEnableDisableReply represents VPP binary API message 'ip_reassembly_enable_disable_reply'. type IPReassemblyEnableDisableReply struct { Retval int32 } @@ -1154,7 +1134,7 @@ func (*IPReassemblyEnableDisableReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// IPReassemblyGet represents VPP binary API message 'ip_reassembly_get': +// IPReassemblyGet represents VPP binary API message 'ip_reassembly_get'. type IPReassemblyGet struct { IsIP6 uint8 } @@ -1169,7 +1149,7 @@ func (*IPReassemblyGet) GetMessageType() api.MessageType { return api.RequestMessage } -// IPReassemblyGetReply represents VPP binary API message 'ip_reassembly_get_reply': +// IPReassemblyGetReply represents VPP binary API message 'ip_reassembly_get_reply'. type IPReassemblyGetReply struct { Retval int32 TimeoutMs uint32 @@ -1188,7 +1168,7 @@ func (*IPReassemblyGetReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// IPReassemblySet represents VPP binary API message 'ip_reassembly_set': +// IPReassemblySet represents VPP binary API message 'ip_reassembly_set'. type IPReassemblySet struct { TimeoutMs uint32 MaxReassemblies uint32 @@ -1206,7 +1186,7 @@ func (*IPReassemblySet) GetMessageType() api.MessageType { return api.RequestMessage } -// IPReassemblySetReply represents VPP binary API message 'ip_reassembly_set_reply': +// IPReassemblySetReply represents VPP binary API message 'ip_reassembly_set_reply'. type IPReassemblySetReply struct { Retval int32 } @@ -1221,7 +1201,7 @@ func (*IPReassemblySetReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// IPScanNeighborEnableDisable represents VPP binary API message 'ip_scan_neighbor_enable_disable': +// IPScanNeighborEnableDisable represents VPP binary API message 'ip_scan_neighbor_enable_disable'. type IPScanNeighborEnableDisable struct { Mode uint8 ScanInterval uint8 @@ -1241,7 +1221,7 @@ func (*IPScanNeighborEnableDisable) GetMessageType() api.MessageType { return api.RequestMessage } -// IPScanNeighborEnableDisableReply represents VPP binary API message 'ip_scan_neighbor_enable_disable_reply': +// IPScanNeighborEnableDisableReply represents VPP binary API message 'ip_scan_neighbor_enable_disable_reply'. type IPScanNeighborEnableDisableReply struct { Retval int32 } @@ -1256,7 +1236,7 @@ func (*IPScanNeighborEnableDisableReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// IPSourceAndPortRangeCheckAddDel represents VPP binary API message 'ip_source_and_port_range_check_add_del': +// IPSourceAndPortRangeCheckAddDel represents VPP binary API message 'ip_source_and_port_range_check_add_del'. type IPSourceAndPortRangeCheckAddDel struct { IsAdd uint8 Prefix Prefix @@ -1276,7 +1256,7 @@ func (*IPSourceAndPortRangeCheckAddDel) GetMessageType() api.MessageType { return api.RequestMessage } -// IPSourceAndPortRangeCheckAddDelReply represents VPP binary API message 'ip_source_and_port_range_check_add_del_reply': +// IPSourceAndPortRangeCheckAddDelReply represents VPP binary API message 'ip_source_and_port_range_check_add_del_reply'. type IPSourceAndPortRangeCheckAddDelReply struct { Retval int32 } @@ -1291,7 +1271,7 @@ func (*IPSourceAndPortRangeCheckAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// IPSourceAndPortRangeCheckInterfaceAddDel represents VPP binary API message 'ip_source_and_port_range_check_interface_add_del': +// IPSourceAndPortRangeCheckInterfaceAddDel represents VPP binary API message 'ip_source_and_port_range_check_interface_add_del'. type IPSourceAndPortRangeCheckInterfaceAddDel struct { IsAdd uint8 SwIfIndex uint32 @@ -1311,7 +1291,7 @@ func (*IPSourceAndPortRangeCheckInterfaceAddDel) GetMessageType() api.MessageTyp return api.RequestMessage } -// IPSourceAndPortRangeCheckInterfaceAddDelReply represents VPP binary API message 'ip_source_and_port_range_check_interface_add_del_reply': +// IPSourceAndPortRangeCheckInterfaceAddDelReply represents VPP binary API message 'ip_source_and_port_range_check_interface_add_del_reply'. type IPSourceAndPortRangeCheckInterfaceAddDelReply struct { Retval int32 } @@ -1326,7 +1306,7 @@ func (*IPSourceAndPortRangeCheckInterfaceAddDelReply) GetMessageType() api.Messa return api.ReplyMessage } -// IPSourceCheckInterfaceAddDel represents VPP binary API message 'ip_source_check_interface_add_del': +// IPSourceCheckInterfaceAddDel represents VPP binary API message 'ip_source_check_interface_add_del'. type IPSourceCheckInterfaceAddDel struct { IsAdd uint8 Loose uint8 @@ -1343,7 +1323,7 @@ func (*IPSourceCheckInterfaceAddDel) GetMessageType() api.MessageType { return api.RequestMessage } -// IPSourceCheckInterfaceAddDelReply represents VPP binary API message 'ip_source_check_interface_add_del_reply': +// IPSourceCheckInterfaceAddDelReply represents VPP binary API message 'ip_source_check_interface_add_del_reply'. type IPSourceCheckInterfaceAddDelReply struct { Retval int32 } @@ -1358,7 +1338,7 @@ func (*IPSourceCheckInterfaceAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// IPTableAddDel represents VPP binary API message 'ip_table_add_del': +// IPTableAddDel represents VPP binary API message 'ip_table_add_del'. type IPTableAddDel struct { TableID uint32 IsIPv6 uint8 @@ -1376,7 +1356,7 @@ func (*IPTableAddDel) GetMessageType() api.MessageType { return api.RequestMessage } -// IPTableAddDelReply represents VPP binary API message 'ip_table_add_del_reply': +// IPTableAddDelReply represents VPP binary API message 'ip_table_add_del_reply'. type IPTableAddDelReply struct { Retval int32 } @@ -1391,7 +1371,7 @@ func (*IPTableAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// IPUnnumberedDetails represents VPP binary API message 'ip_unnumbered_details': +// IPUnnumberedDetails represents VPP binary API message 'ip_unnumbered_details'. type IPUnnumberedDetails struct { SwIfIndex uint32 IPSwIfIndex uint32 @@ -1407,7 +1387,7 @@ func (*IPUnnumberedDetails) GetMessageType() api.MessageType { return api.ReplyMessage } -// IPUnnumberedDump represents VPP binary API message 'ip_unnumbered_dump': +// IPUnnumberedDump represents VPP binary API message 'ip_unnumbered_dump'. type IPUnnumberedDump struct { SwIfIndex uint32 } @@ -1422,7 +1402,7 @@ func (*IPUnnumberedDump) GetMessageType() api.MessageType { return api.RequestMessage } -// MfibSignalDetails represents VPP binary API message 'mfib_signal_details': +// MfibSignalDetails represents VPP binary API message 'mfib_signal_details'. type MfibSignalDetails struct { SwIfIndex uint32 TableID uint32 @@ -1443,7 +1423,7 @@ func (*MfibSignalDetails) GetMessageType() api.MessageType { return api.ReplyMessage } -// MfibSignalDump represents VPP binary API message 'mfib_signal_dump': +// MfibSignalDump represents VPP binary API message 'mfib_signal_dump'. type MfibSignalDump struct{} func (*MfibSignalDump) GetMessageName() string { @@ -1456,7 +1436,7 @@ func (*MfibSignalDump) GetMessageType() api.MessageType { return api.RequestMessage } -// ProxyArpAddDel represents VPP binary API message 'proxy_arp_add_del': +// ProxyArpAddDel represents VPP binary API message 'proxy_arp_add_del'. type ProxyArpAddDel struct { IsAdd uint8 Proxy ProxyArp @@ -1472,7 +1452,7 @@ func (*ProxyArpAddDel) GetMessageType() api.MessageType { return api.RequestMessage } -// ProxyArpAddDelReply represents VPP binary API message 'proxy_arp_add_del_reply': +// ProxyArpAddDelReply represents VPP binary API message 'proxy_arp_add_del_reply'. type ProxyArpAddDelReply struct { Retval int32 } @@ -1487,7 +1467,7 @@ func (*ProxyArpAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// ProxyArpDetails represents VPP binary API message 'proxy_arp_details': +// ProxyArpDetails represents VPP binary API message 'proxy_arp_details'. type ProxyArpDetails struct { Proxy ProxyArp } @@ -1502,7 +1482,7 @@ func (*ProxyArpDetails) GetMessageType() api.MessageType { return api.ReplyMessage } -// ProxyArpDump represents VPP binary API message 'proxy_arp_dump': +// ProxyArpDump represents VPP binary API message 'proxy_arp_dump'. type ProxyArpDump struct{} func (*ProxyArpDump) GetMessageName() string { @@ -1515,7 +1495,7 @@ func (*ProxyArpDump) GetMessageType() api.MessageType { return api.RequestMessage } -// ProxyArpIntfcDetails represents VPP binary API message 'proxy_arp_intfc_details': +// ProxyArpIntfcDetails represents VPP binary API message 'proxy_arp_intfc_details'. type ProxyArpIntfcDetails struct { SwIfIndex uint32 } @@ -1530,7 +1510,7 @@ func (*ProxyArpIntfcDetails) GetMessageType() api.MessageType { return api.ReplyMessage } -// ProxyArpIntfcDump represents VPP binary API message 'proxy_arp_intfc_dump': +// ProxyArpIntfcDump represents VPP binary API message 'proxy_arp_intfc_dump'. type ProxyArpIntfcDump struct{} func (*ProxyArpIntfcDump) GetMessageName() string { @@ -1543,7 +1523,7 @@ func (*ProxyArpIntfcDump) GetMessageType() api.MessageType { return api.RequestMessage } -// ProxyArpIntfcEnableDisable represents VPP binary API message 'proxy_arp_intfc_enable_disable': +// ProxyArpIntfcEnableDisable represents VPP binary API message 'proxy_arp_intfc_enable_disable'. type ProxyArpIntfcEnableDisable struct { SwIfIndex uint32 EnableDisable uint8 @@ -1559,7 +1539,7 @@ func (*ProxyArpIntfcEnableDisable) GetMessageType() api.MessageType { return api.RequestMessage } -// ProxyArpIntfcEnableDisableReply represents VPP binary API message 'proxy_arp_intfc_enable_disable_reply': +// ProxyArpIntfcEnableDisableReply represents VPP binary API message 'proxy_arp_intfc_enable_disable_reply'. type ProxyArpIntfcEnableDisableReply struct { Retval int32 } @@ -1574,7 +1554,7 @@ func (*ProxyArpIntfcEnableDisableReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// ResetFib represents VPP binary API message 'reset_fib': +// ResetFib represents VPP binary API message 'reset_fib'. type ResetFib struct { VrfID uint32 IsIPv6 uint8 @@ -1590,7 +1570,7 @@ func (*ResetFib) GetMessageType() api.MessageType { return api.RequestMessage } -// ResetFibReply represents VPP binary API message 'reset_fib_reply': +// ResetFibReply represents VPP binary API message 'reset_fib_reply'. type ResetFibReply struct { Retval int32 } @@ -1605,7 +1585,7 @@ func (*ResetFibReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// SetArpNeighborLimit represents VPP binary API message 'set_arp_neighbor_limit': +// SetArpNeighborLimit represents VPP binary API message 'set_arp_neighbor_limit'. type SetArpNeighborLimit struct { IsIPv6 uint8 ArpNeighborLimit uint32 @@ -1621,7 +1601,7 @@ func (*SetArpNeighborLimit) GetMessageType() api.MessageType { return api.RequestMessage } -// SetArpNeighborLimitReply represents VPP binary API message 'set_arp_neighbor_limit_reply': +// SetArpNeighborLimitReply represents VPP binary API message 'set_arp_neighbor_limit_reply'. type SetArpNeighborLimitReply struct { Retval int32 } @@ -1636,7 +1616,7 @@ func (*SetArpNeighborLimitReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// SetIPFlowHash represents VPP binary API message 'set_ip_flow_hash': +// SetIPFlowHash represents VPP binary API message 'set_ip_flow_hash'. type SetIPFlowHash struct { VrfID uint32 IsIPv6 uint8 @@ -1659,7 +1639,7 @@ func (*SetIPFlowHash) GetMessageType() api.MessageType { return api.RequestMessage } -// SetIPFlowHashReply represents VPP binary API message 'set_ip_flow_hash_reply': +// SetIPFlowHashReply represents VPP binary API message 'set_ip_flow_hash_reply'. type SetIPFlowHashReply struct { Retval int32 } @@ -1674,7 +1654,7 @@ func (*SetIPFlowHashReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// SwInterfaceIP6EnableDisable represents VPP binary API message 'sw_interface_ip6_enable_disable': +// SwInterfaceIP6EnableDisable represents VPP binary API message 'sw_interface_ip6_enable_disable'. type SwInterfaceIP6EnableDisable struct { SwIfIndex uint32 Enable uint8 @@ -1690,7 +1670,7 @@ func (*SwInterfaceIP6EnableDisable) GetMessageType() api.MessageType { return api.RequestMessage } -// SwInterfaceIP6EnableDisableReply represents VPP binary API message 'sw_interface_ip6_enable_disable_reply': +// SwInterfaceIP6EnableDisableReply represents VPP binary API message 'sw_interface_ip6_enable_disable_reply'. type SwInterfaceIP6EnableDisableReply struct { Retval int32 } @@ -1705,7 +1685,7 @@ func (*SwInterfaceIP6EnableDisableReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// SwInterfaceIP6ndRaConfig represents VPP binary API message 'sw_interface_ip6nd_ra_config': +// SwInterfaceIP6ndRaConfig represents VPP binary API message 'sw_interface_ip6nd_ra_config'. type SwInterfaceIP6ndRaConfig struct { SwIfIndex uint32 Suppress uint8 @@ -1733,7 +1713,7 @@ func (*SwInterfaceIP6ndRaConfig) GetMessageType() api.MessageType { return api.RequestMessage } -// SwInterfaceIP6ndRaConfigReply represents VPP binary API message 'sw_interface_ip6nd_ra_config_reply': +// SwInterfaceIP6ndRaConfigReply represents VPP binary API message 'sw_interface_ip6nd_ra_config_reply'. type SwInterfaceIP6ndRaConfigReply struct { Retval int32 } @@ -1748,7 +1728,7 @@ func (*SwInterfaceIP6ndRaConfigReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// SwInterfaceIP6ndRaPrefix represents VPP binary API message 'sw_interface_ip6nd_ra_prefix': +// SwInterfaceIP6ndRaPrefix represents VPP binary API message 'sw_interface_ip6nd_ra_prefix'. type SwInterfaceIP6ndRaPrefix struct { SwIfIndex uint32 Prefix Prefix @@ -1772,7 +1752,7 @@ func (*SwInterfaceIP6ndRaPrefix) GetMessageType() api.MessageType { return api.RequestMessage } -// SwInterfaceIP6ndRaPrefixReply represents VPP binary API message 'sw_interface_ip6nd_ra_prefix_reply': +// SwInterfaceIP6ndRaPrefixReply represents VPP binary API message 'sw_interface_ip6nd_ra_prefix_reply'. type SwInterfaceIP6ndRaPrefixReply struct { Retval int32 } @@ -1787,7 +1767,7 @@ func (*SwInterfaceIP6ndRaPrefixReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// WantIP4ArpEvents represents VPP binary API message 'want_ip4_arp_events': +// WantIP4ArpEvents represents VPP binary API message 'want_ip4_arp_events'. type WantIP4ArpEvents struct { EnableDisable uint8 PID uint32 @@ -1804,7 +1784,7 @@ func (*WantIP4ArpEvents) GetMessageType() api.MessageType { return api.RequestMessage } -// WantIP4ArpEventsReply represents VPP binary API message 'want_ip4_arp_events_reply': +// WantIP4ArpEventsReply represents VPP binary API message 'want_ip4_arp_events_reply'. type WantIP4ArpEventsReply struct { Retval int32 } @@ -1819,7 +1799,7 @@ func (*WantIP4ArpEventsReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// WantIP6NdEvents represents VPP binary API message 'want_ip6_nd_events': +// WantIP6NdEvents represents VPP binary API message 'want_ip6_nd_events'. type WantIP6NdEvents struct { EnableDisable uint8 PID uint32 @@ -1836,7 +1816,7 @@ func (*WantIP6NdEvents) GetMessageType() api.MessageType { return api.RequestMessage } -// WantIP6NdEventsReply represents VPP binary API message 'want_ip6_nd_events_reply': +// WantIP6NdEventsReply represents VPP binary API message 'want_ip6_nd_events_reply'. type WantIP6NdEventsReply struct { Retval int32 } @@ -1851,7 +1831,7 @@ func (*WantIP6NdEventsReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// WantIP6RaEvents represents VPP binary API message 'want_ip6_ra_events': +// WantIP6RaEvents represents VPP binary API message 'want_ip6_ra_events'. type WantIP6RaEvents struct { EnableDisable uint8 PID uint32 @@ -1867,7 +1847,7 @@ func (*WantIP6RaEvents) GetMessageType() api.MessageType { return api.RequestMessage } -// WantIP6RaEventsReply represents VPP binary API message 'want_ip6_ra_events_reply': +// WantIP6RaEventsReply represents VPP binary API message 'want_ip6_ra_events_reply'. type WantIP6RaEventsReply struct { Retval int32 } @@ -2073,22 +2053,22 @@ func AllMessages() []api.Message { } } -// Service represents VPP binary API services in ip module. -type Service interface { - DumpIP6Fib(ctx context.Context, in *IP6FibDump) ([]*IP6FibDetails, error) - DumpIP6Mfib(ctx context.Context, in *IP6MfibDump) ([]*IP6MfibDetails, error) - DumpIP6ndProxy(ctx context.Context, in *IP6ndProxyDump) ([]*IP6ndProxyDetails, error) - DumpIPAddress(ctx context.Context, in *IPAddressDump) ([]*IPAddressDetails, error) - DumpIPContainerProxy(ctx context.Context, in *IPContainerProxyDump) ([]*IPContainerProxyDetails, error) - DumpIP(ctx context.Context, in *IPDump) ([]*IPDetails, error) - DumpIPFib(ctx context.Context, in *IPFibDump) ([]*IPFibDetails, error) - DumpIPMfib(ctx context.Context, in *IPMfibDump) ([]*IPMfibDetails, error) - DumpIPNeighbor(ctx context.Context, in *IPNeighborDump) ([]*IPNeighborDetails, error) - DumpIPPuntRedirect(ctx context.Context, in *IPPuntRedirectDump) ([]*IPPuntRedirectDetails, error) - DumpIPUnnumbered(ctx context.Context, in *IPUnnumberedDump) ([]*IPUnnumberedDetails, error) - DumpMfibSignal(ctx context.Context, in *MfibSignalDump) ([]*MfibSignalDetails, error) - DumpProxyArp(ctx context.Context, in *ProxyArpDump) ([]*ProxyArpDetails, error) - DumpProxyArpIntfc(ctx context.Context, in *ProxyArpIntfcDump) ([]*ProxyArpIntfcDetails, error) +// RPCService represents RPC service API for ip module. +type RPCService interface { + DumpIP6Fib(ctx context.Context, in *IP6FibDump) (RPCService_DumpIP6FibClient, error) + DumpIP6Mfib(ctx context.Context, in *IP6MfibDump) (RPCService_DumpIP6MfibClient, error) + DumpIP6ndProxy(ctx context.Context, in *IP6ndProxyDump) (RPCService_DumpIP6ndProxyClient, error) + DumpIPAddress(ctx context.Context, in *IPAddressDump) (RPCService_DumpIPAddressClient, error) + DumpIPContainerProxy(ctx context.Context, in *IPContainerProxyDump) (RPCService_DumpIPContainerProxyClient, error) + DumpIP(ctx context.Context, in *IPDump) (RPCService_DumpIPClient, error) + DumpIPFib(ctx context.Context, in *IPFibDump) (RPCService_DumpIPFibClient, error) + DumpIPMfib(ctx context.Context, in *IPMfibDump) (RPCService_DumpIPMfibClient, error) + DumpIPNeighbor(ctx context.Context, in *IPNeighborDump) (RPCService_DumpIPNeighborClient, error) + DumpIPPuntRedirect(ctx context.Context, in *IPPuntRedirectDump) (RPCService_DumpIPPuntRedirectClient, error) + DumpIPUnnumbered(ctx context.Context, in *IPUnnumberedDump) (RPCService_DumpIPUnnumberedClient, error) + DumpMfibSignal(ctx context.Context, in *MfibSignalDump) (RPCService_DumpMfibSignalClient, error) + DumpProxyArp(ctx context.Context, in *ProxyArpDump) (RPCService_DumpProxyArpClient, error) + DumpProxyArpIntfc(ctx context.Context, in *ProxyArpIntfcDump) (RPCService_DumpProxyArpIntfcClient, error) IoamDisable(ctx context.Context, in *IoamDisable) (*IoamDisableReply, error) IoamEnable(ctx context.Context, in *IoamEnable) (*IoamEnableReply, error) IP6ndProxyAddDel(ctx context.Context, in *IP6ndProxyAddDel) (*IP6ndProxyAddDelReply, error) @@ -2121,253 +2101,379 @@ type Service interface { WantIP6RaEvents(ctx context.Context, in *WantIP6RaEvents) (*WantIP6RaEventsReply, error) } -type service struct { +type serviceClient struct { ch api.Channel } -func NewService(ch api.Channel) Service { - return &service{ch} +func NewServiceClient(ch api.Channel) RPCService { + return &serviceClient{ch} +} + +func (c *serviceClient) DumpIP6Fib(ctx context.Context, in *IP6FibDump) (RPCService_DumpIP6FibClient, error) { + stream := c.ch.SendMultiRequest(in) + x := &serviceClient_DumpIP6FibClient{stream} + return x, nil +} + +type RPCService_DumpIP6FibClient interface { + Recv() (*IP6FibDetails, error) +} + +type serviceClient_DumpIP6FibClient struct { + api.MultiRequestCtx +} + +func (c *serviceClient_DumpIP6FibClient) Recv() (*IP6FibDetails, error) { + m := new(IP6FibDetails) + stop, err := c.MultiRequestCtx.ReceiveReply(m) + if err != nil { + return nil, err + } + if stop { + return nil, io.EOF + } + return m, nil +} + +func (c *serviceClient) DumpIP6Mfib(ctx context.Context, in *IP6MfibDump) (RPCService_DumpIP6MfibClient, error) { + stream := c.ch.SendMultiRequest(in) + x := &serviceClient_DumpIP6MfibClient{stream} + return x, nil +} + +type RPCService_DumpIP6MfibClient interface { + Recv() (*IP6MfibDetails, error) +} + +type serviceClient_DumpIP6MfibClient struct { + api.MultiRequestCtx +} + +func (c *serviceClient_DumpIP6MfibClient) Recv() (*IP6MfibDetails, error) { + m := new(IP6MfibDetails) + stop, err := c.MultiRequestCtx.ReceiveReply(m) + if err != nil { + return nil, err + } + if stop { + return nil, io.EOF + } + return m, nil +} + +func (c *serviceClient) DumpIP6ndProxy(ctx context.Context, in *IP6ndProxyDump) (RPCService_DumpIP6ndProxyClient, error) { + stream := c.ch.SendMultiRequest(in) + x := &serviceClient_DumpIP6ndProxyClient{stream} + return x, nil +} + +type RPCService_DumpIP6ndProxyClient interface { + Recv() (*IP6ndProxyDetails, error) +} + +type serviceClient_DumpIP6ndProxyClient struct { + api.MultiRequestCtx +} + +func (c *serviceClient_DumpIP6ndProxyClient) Recv() (*IP6ndProxyDetails, error) { + m := new(IP6ndProxyDetails) + stop, err := c.MultiRequestCtx.ReceiveReply(m) + if err != nil { + return nil, err + } + if stop { + return nil, io.EOF + } + return m, nil +} + +func (c *serviceClient) DumpIPAddress(ctx context.Context, in *IPAddressDump) (RPCService_DumpIPAddressClient, error) { + stream := c.ch.SendMultiRequest(in) + x := &serviceClient_DumpIPAddressClient{stream} + return x, nil +} + +type RPCService_DumpIPAddressClient interface { + Recv() (*IPAddressDetails, error) +} + +type serviceClient_DumpIPAddressClient struct { + api.MultiRequestCtx +} + +func (c *serviceClient_DumpIPAddressClient) Recv() (*IPAddressDetails, error) { + m := new(IPAddressDetails) + stop, err := c.MultiRequestCtx.ReceiveReply(m) + if err != nil { + return nil, err + } + if stop { + return nil, io.EOF + } + return m, nil +} + +func (c *serviceClient) DumpIPContainerProxy(ctx context.Context, in *IPContainerProxyDump) (RPCService_DumpIPContainerProxyClient, error) { + stream := c.ch.SendMultiRequest(in) + x := &serviceClient_DumpIPContainerProxyClient{stream} + return x, nil +} + +type RPCService_DumpIPContainerProxyClient interface { + Recv() (*IPContainerProxyDetails, error) +} + +type serviceClient_DumpIPContainerProxyClient struct { + api.MultiRequestCtx +} + +func (c *serviceClient_DumpIPContainerProxyClient) Recv() (*IPContainerProxyDetails, error) { + m := new(IPContainerProxyDetails) + stop, err := c.MultiRequestCtx.ReceiveReply(m) + if err != nil { + return nil, err + } + if stop { + return nil, io.EOF + } + return m, nil +} + +func (c *serviceClient) DumpIP(ctx context.Context, in *IPDump) (RPCService_DumpIPClient, error) { + stream := c.ch.SendMultiRequest(in) + x := &serviceClient_DumpIPClient{stream} + return x, nil +} + +type RPCService_DumpIPClient interface { + Recv() (*IPDetails, error) +} + +type serviceClient_DumpIPClient struct { + api.MultiRequestCtx +} + +func (c *serviceClient_DumpIPClient) Recv() (*IPDetails, error) { + m := new(IPDetails) + stop, err := c.MultiRequestCtx.ReceiveReply(m) + if err != nil { + return nil, err + } + if stop { + return nil, io.EOF + } + return m, nil +} + +func (c *serviceClient) DumpIPFib(ctx context.Context, in *IPFibDump) (RPCService_DumpIPFibClient, error) { + stream := c.ch.SendMultiRequest(in) + x := &serviceClient_DumpIPFibClient{stream} + return x, nil +} + +type RPCService_DumpIPFibClient interface { + Recv() (*IPFibDetails, error) } -func (c *service) DumpIP6Fib(ctx context.Context, in *IP6FibDump) ([]*IP6FibDetails, error) { - var dump []*IP6FibDetails - req := c.ch.SendMultiRequest(in) - for { - m := new(IP6FibDetails) - stop, err := req.ReceiveReply(m) - if stop { - break - } - if err != nil { - return nil, err - } - dump = append(dump, m) +type serviceClient_DumpIPFibClient struct { + api.MultiRequestCtx +} + +func (c *serviceClient_DumpIPFibClient) Recv() (*IPFibDetails, error) { + m := new(IPFibDetails) + stop, err := c.MultiRequestCtx.ReceiveReply(m) + if err != nil { + return nil, err } - return dump, nil -} - -func (c *service) DumpIP6Mfib(ctx context.Context, in *IP6MfibDump) ([]*IP6MfibDetails, error) { - var dump []*IP6MfibDetails - req := c.ch.SendMultiRequest(in) - for { - m := new(IP6MfibDetails) - stop, err := req.ReceiveReply(m) - if stop { - break - } - if err != nil { - return nil, err - } - dump = append(dump, m) + if stop { + return nil, io.EOF } - return dump, nil -} - -func (c *service) DumpIP6ndProxy(ctx context.Context, in *IP6ndProxyDump) ([]*IP6ndProxyDetails, error) { - var dump []*IP6ndProxyDetails - req := c.ch.SendMultiRequest(in) - for { - m := new(IP6ndProxyDetails) - stop, err := req.ReceiveReply(m) - if stop { - break - } - if err != nil { - return nil, err - } - dump = append(dump, m) + return m, nil +} + +func (c *serviceClient) DumpIPMfib(ctx context.Context, in *IPMfibDump) (RPCService_DumpIPMfibClient, error) { + stream := c.ch.SendMultiRequest(in) + x := &serviceClient_DumpIPMfibClient{stream} + return x, nil +} + +type RPCService_DumpIPMfibClient interface { + Recv() (*IPMfibDetails, error) +} + +type serviceClient_DumpIPMfibClient struct { + api.MultiRequestCtx +} + +func (c *serviceClient_DumpIPMfibClient) Recv() (*IPMfibDetails, error) { + m := new(IPMfibDetails) + stop, err := c.MultiRequestCtx.ReceiveReply(m) + if err != nil { + return nil, err + } + if stop { + return nil, io.EOF + } + return m, nil +} + +func (c *serviceClient) DumpIPNeighbor(ctx context.Context, in *IPNeighborDump) (RPCService_DumpIPNeighborClient, error) { + stream := c.ch.SendMultiRequest(in) + x := &serviceClient_DumpIPNeighborClient{stream} + return x, nil +} + +type RPCService_DumpIPNeighborClient interface { + Recv() (*IPNeighborDetails, error) +} + +type serviceClient_DumpIPNeighborClient struct { + api.MultiRequestCtx +} + +func (c *serviceClient_DumpIPNeighborClient) Recv() (*IPNeighborDetails, error) { + m := new(IPNeighborDetails) + stop, err := c.MultiRequestCtx.ReceiveReply(m) + if err != nil { + return nil, err } - return dump, nil -} - -func (c *service) DumpIPAddress(ctx context.Context, in *IPAddressDump) ([]*IPAddressDetails, error) { - var dump []*IPAddressDetails - req := c.ch.SendMultiRequest(in) - for { - m := new(IPAddressDetails) - stop, err := req.ReceiveReply(m) - if stop { - break - } - if err != nil { - return nil, err - } - dump = append(dump, m) + if stop { + return nil, io.EOF } - return dump, nil -} - -func (c *service) DumpIPContainerProxy(ctx context.Context, in *IPContainerProxyDump) ([]*IPContainerProxyDetails, error) { - var dump []*IPContainerProxyDetails - req := c.ch.SendMultiRequest(in) - for { - m := new(IPContainerProxyDetails) - stop, err := req.ReceiveReply(m) - if stop { - break - } - if err != nil { - return nil, err - } - dump = append(dump, m) + return m, nil +} + +func (c *serviceClient) DumpIPPuntRedirect(ctx context.Context, in *IPPuntRedirectDump) (RPCService_DumpIPPuntRedirectClient, error) { + stream := c.ch.SendMultiRequest(in) + x := &serviceClient_DumpIPPuntRedirectClient{stream} + return x, nil +} + +type RPCService_DumpIPPuntRedirectClient interface { + Recv() (*IPPuntRedirectDetails, error) +} + +type serviceClient_DumpIPPuntRedirectClient struct { + api.MultiRequestCtx +} + +func (c *serviceClient_DumpIPPuntRedirectClient) Recv() (*IPPuntRedirectDetails, error) { + m := new(IPPuntRedirectDetails) + stop, err := c.MultiRequestCtx.ReceiveReply(m) + if err != nil { + return nil, err } - return dump, nil -} - -func (c *service) DumpIP(ctx context.Context, in *IPDump) ([]*IPDetails, error) { - var dump []*IPDetails - req := c.ch.SendMultiRequest(in) - for { - m := new(IPDetails) - stop, err := req.ReceiveReply(m) - if stop { - break - } - if err != nil { - return nil, err - } - dump = append(dump, m) + if stop { + return nil, io.EOF } - return dump, nil -} - -func (c *service) DumpIPFib(ctx context.Context, in *IPFibDump) ([]*IPFibDetails, error) { - var dump []*IPFibDetails - req := c.ch.SendMultiRequest(in) - for { - m := new(IPFibDetails) - stop, err := req.ReceiveReply(m) - if stop { - break - } - if err != nil { - return nil, err - } - dump = append(dump, m) + return m, nil +} + +func (c *serviceClient) DumpIPUnnumbered(ctx context.Context, in *IPUnnumberedDump) (RPCService_DumpIPUnnumberedClient, error) { + stream := c.ch.SendMultiRequest(in) + x := &serviceClient_DumpIPUnnumberedClient{stream} + return x, nil +} + +type RPCService_DumpIPUnnumberedClient interface { + Recv() (*IPUnnumberedDetails, error) +} + +type serviceClient_DumpIPUnnumberedClient struct { + api.MultiRequestCtx +} + +func (c *serviceClient_DumpIPUnnumberedClient) Recv() (*IPUnnumberedDetails, error) { + m := new(IPUnnumberedDetails) + stop, err := c.MultiRequestCtx.ReceiveReply(m) + if err != nil { + return nil, err } - return dump, nil -} - -func (c *service) DumpIPMfib(ctx context.Context, in *IPMfibDump) ([]*IPMfibDetails, error) { - var dump []*IPMfibDetails - req := c.ch.SendMultiRequest(in) - for { - m := new(IPMfibDetails) - stop, err := req.ReceiveReply(m) - if stop { - break - } - if err != nil { - return nil, err - } - dump = append(dump, m) + if stop { + return nil, io.EOF } - return dump, nil -} - -func (c *service) DumpIPNeighbor(ctx context.Context, in *IPNeighborDump) ([]*IPNeighborDetails, error) { - var dump []*IPNeighborDetails - req := c.ch.SendMultiRequest(in) - for { - m := new(IPNeighborDetails) - stop, err := req.ReceiveReply(m) - if stop { - break - } - if err != nil { - return nil, err - } - dump = append(dump, m) + return m, nil +} + +func (c *serviceClient) DumpMfibSignal(ctx context.Context, in *MfibSignalDump) (RPCService_DumpMfibSignalClient, error) { + stream := c.ch.SendMultiRequest(in) + x := &serviceClient_DumpMfibSignalClient{stream} + return x, nil +} + +type RPCService_DumpMfibSignalClient interface { + Recv() (*MfibSignalDetails, error) +} + +type serviceClient_DumpMfibSignalClient struct { + api.MultiRequestCtx +} + +func (c *serviceClient_DumpMfibSignalClient) Recv() (*MfibSignalDetails, error) { + m := new(MfibSignalDetails) + stop, err := c.MultiRequestCtx.ReceiveReply(m) + if err != nil { + return nil, err } - return dump, nil -} - -func (c *service) DumpIPPuntRedirect(ctx context.Context, in *IPPuntRedirectDump) ([]*IPPuntRedirectDetails, error) { - var dump []*IPPuntRedirectDetails - req := c.ch.SendMultiRequest(in) - for { - m := new(IPPuntRedirectDetails) - stop, err := req.ReceiveReply(m) - if stop { - break - } - if err != nil { - return nil, err - } - dump = append(dump, m) + if stop { + return nil, io.EOF } - return dump, nil -} - -func (c *service) DumpIPUnnumbered(ctx context.Context, in *IPUnnumberedDump) ([]*IPUnnumberedDetails, error) { - var dump []*IPUnnumberedDetails - req := c.ch.SendMultiRequest(in) - for { - m := new(IPUnnumberedDetails) - stop, err := req.ReceiveReply(m) - if stop { - break - } - if err != nil { - return nil, err - } - dump = append(dump, m) + return m, nil +} + +func (c *serviceClient) DumpProxyArp(ctx context.Context, in *ProxyArpDump) (RPCService_DumpProxyArpClient, error) { + stream := c.ch.SendMultiRequest(in) + x := &serviceClient_DumpProxyArpClient{stream} + return x, nil +} + +type RPCService_DumpProxyArpClient interface { + Recv() (*ProxyArpDetails, error) +} + +type serviceClient_DumpProxyArpClient struct { + api.MultiRequestCtx +} + +func (c *serviceClient_DumpProxyArpClient) Recv() (*ProxyArpDetails, error) { + m := new(ProxyArpDetails) + stop, err := c.MultiRequestCtx.ReceiveReply(m) + if err != nil { + return nil, err } - return dump, nil -} - -func (c *service) DumpMfibSignal(ctx context.Context, in *MfibSignalDump) ([]*MfibSignalDetails, error) { - var dump []*MfibSignalDetails - req := c.ch.SendMultiRequest(in) - for { - m := new(MfibSignalDetails) - stop, err := req.ReceiveReply(m) - if stop { - break - } - if err != nil { - return nil, err - } - dump = append(dump, m) + if stop { + return nil, io.EOF } - return dump, nil -} - -func (c *service) DumpProxyArp(ctx context.Context, in *ProxyArpDump) ([]*ProxyArpDetails, error) { - var dump []*ProxyArpDetails - req := c.ch.SendMultiRequest(in) - for { - m := new(ProxyArpDetails) - stop, err := req.ReceiveReply(m) - if stop { - break - } - if err != nil { - return nil, err - } - dump = append(dump, m) + return m, nil +} + +func (c *serviceClient) DumpProxyArpIntfc(ctx context.Context, in *ProxyArpIntfcDump) (RPCService_DumpProxyArpIntfcClient, error) { + stream := c.ch.SendMultiRequest(in) + x := &serviceClient_DumpProxyArpIntfcClient{stream} + return x, nil +} + +type RPCService_DumpProxyArpIntfcClient interface { + Recv() (*ProxyArpIntfcDetails, error) +} + +type serviceClient_DumpProxyArpIntfcClient struct { + api.MultiRequestCtx +} + +func (c *serviceClient_DumpProxyArpIntfcClient) Recv() (*ProxyArpIntfcDetails, error) { + m := new(ProxyArpIntfcDetails) + stop, err := c.MultiRequestCtx.ReceiveReply(m) + if err != nil { + return nil, err } - return dump, nil -} - -func (c *service) DumpProxyArpIntfc(ctx context.Context, in *ProxyArpIntfcDump) ([]*ProxyArpIntfcDetails, error) { - var dump []*ProxyArpIntfcDetails - req := c.ch.SendMultiRequest(in) - for { - m := new(ProxyArpIntfcDetails) - stop, err := req.ReceiveReply(m) - if stop { - break - } - if err != nil { - return nil, err - } - dump = append(dump, m) + if stop { + return nil, io.EOF } - return dump, nil + return m, nil } -func (c *service) IoamDisable(ctx context.Context, in *IoamDisable) (*IoamDisableReply, error) { +func (c *serviceClient) IoamDisable(ctx context.Context, in *IoamDisable) (*IoamDisableReply, error) { out := new(IoamDisableReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -2376,7 +2482,7 @@ func (c *service) IoamDisable(ctx context.Context, in *IoamDisable) (*IoamDisabl return out, nil } -func (c *service) IoamEnable(ctx context.Context, in *IoamEnable) (*IoamEnableReply, error) { +func (c *serviceClient) IoamEnable(ctx context.Context, in *IoamEnable) (*IoamEnableReply, error) { out := new(IoamEnableReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -2385,7 +2491,7 @@ func (c *service) IoamEnable(ctx context.Context, in *IoamEnable) (*IoamEnableRe return out, nil } -func (c *service) IP6ndProxyAddDel(ctx context.Context, in *IP6ndProxyAddDel) (*IP6ndProxyAddDelReply, error) { +func (c *serviceClient) IP6ndProxyAddDel(ctx context.Context, in *IP6ndProxyAddDel) (*IP6ndProxyAddDelReply, error) { out := new(IP6ndProxyAddDelReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -2394,7 +2500,7 @@ func (c *service) IP6ndProxyAddDel(ctx context.Context, in *IP6ndProxyAddDel) (* return out, nil } -func (c *service) IP6ndSendRouterSolicitation(ctx context.Context, in *IP6ndSendRouterSolicitation) (*IP6ndSendRouterSolicitationReply, error) { +func (c *serviceClient) IP6ndSendRouterSolicitation(ctx context.Context, in *IP6ndSendRouterSolicitation) (*IP6ndSendRouterSolicitationReply, error) { out := new(IP6ndSendRouterSolicitationReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -2403,7 +2509,7 @@ func (c *service) IP6ndSendRouterSolicitation(ctx context.Context, in *IP6ndSend return out, nil } -func (c *service) IPAddDelRoute(ctx context.Context, in *IPAddDelRoute) (*IPAddDelRouteReply, error) { +func (c *serviceClient) IPAddDelRoute(ctx context.Context, in *IPAddDelRoute) (*IPAddDelRouteReply, error) { out := new(IPAddDelRouteReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -2412,7 +2518,7 @@ func (c *service) IPAddDelRoute(ctx context.Context, in *IPAddDelRoute) (*IPAddD return out, nil } -func (c *service) IPContainerProxyAddDel(ctx context.Context, in *IPContainerProxyAddDel) (*IPContainerProxyAddDelReply, error) { +func (c *serviceClient) IPContainerProxyAddDel(ctx context.Context, in *IPContainerProxyAddDel) (*IPContainerProxyAddDelReply, error) { out := new(IPContainerProxyAddDelReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -2421,7 +2527,7 @@ func (c *service) IPContainerProxyAddDel(ctx context.Context, in *IPContainerPro return out, nil } -func (c *service) IPMrouteAddDel(ctx context.Context, in *IPMrouteAddDel) (*IPMrouteAddDelReply, error) { +func (c *serviceClient) IPMrouteAddDel(ctx context.Context, in *IPMrouteAddDel) (*IPMrouteAddDelReply, error) { out := new(IPMrouteAddDelReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -2430,7 +2536,7 @@ func (c *service) IPMrouteAddDel(ctx context.Context, in *IPMrouteAddDel) (*IPMr return out, nil } -func (c *service) IPNeighborAddDel(ctx context.Context, in *IPNeighborAddDel) (*IPNeighborAddDelReply, error) { +func (c *serviceClient) IPNeighborAddDel(ctx context.Context, in *IPNeighborAddDel) (*IPNeighborAddDelReply, error) { out := new(IPNeighborAddDelReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -2439,7 +2545,7 @@ func (c *service) IPNeighborAddDel(ctx context.Context, in *IPNeighborAddDel) (* return out, nil } -func (c *service) IPProbeNeighbor(ctx context.Context, in *IPProbeNeighbor) (*IPProbeNeighborReply, error) { +func (c *serviceClient) IPProbeNeighbor(ctx context.Context, in *IPProbeNeighbor) (*IPProbeNeighborReply, error) { out := new(IPProbeNeighborReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -2448,7 +2554,7 @@ func (c *service) IPProbeNeighbor(ctx context.Context, in *IPProbeNeighbor) (*IP return out, nil } -func (c *service) IPPuntPolice(ctx context.Context, in *IPPuntPolice) (*IPPuntPoliceReply, error) { +func (c *serviceClient) IPPuntPolice(ctx context.Context, in *IPPuntPolice) (*IPPuntPoliceReply, error) { out := new(IPPuntPoliceReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -2457,7 +2563,7 @@ func (c *service) IPPuntPolice(ctx context.Context, in *IPPuntPolice) (*IPPuntPo return out, nil } -func (c *service) IPPuntRedirect(ctx context.Context, in *IPPuntRedirect) (*IPPuntRedirectReply, error) { +func (c *serviceClient) IPPuntRedirect(ctx context.Context, in *IPPuntRedirect) (*IPPuntRedirectReply, error) { out := new(IPPuntRedirectReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -2466,7 +2572,7 @@ func (c *service) IPPuntRedirect(ctx context.Context, in *IPPuntRedirect) (*IPPu return out, nil } -func (c *service) IPReassemblyEnableDisable(ctx context.Context, in *IPReassemblyEnableDisable) (*IPReassemblyEnableDisableReply, error) { +func (c *serviceClient) IPReassemblyEnableDisable(ctx context.Context, in *IPReassemblyEnableDisable) (*IPReassemblyEnableDisableReply, error) { out := new(IPReassemblyEnableDisableReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -2475,7 +2581,7 @@ func (c *service) IPReassemblyEnableDisable(ctx context.Context, in *IPReassembl return out, nil } -func (c *service) IPReassemblyGet(ctx context.Context, in *IPReassemblyGet) (*IPReassemblyGetReply, error) { +func (c *serviceClient) IPReassemblyGet(ctx context.Context, in *IPReassemblyGet) (*IPReassemblyGetReply, error) { out := new(IPReassemblyGetReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -2484,7 +2590,7 @@ func (c *service) IPReassemblyGet(ctx context.Context, in *IPReassemblyGet) (*IP return out, nil } -func (c *service) IPReassemblySet(ctx context.Context, in *IPReassemblySet) (*IPReassemblySetReply, error) { +func (c *serviceClient) IPReassemblySet(ctx context.Context, in *IPReassemblySet) (*IPReassemblySetReply, error) { out := new(IPReassemblySetReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -2493,7 +2599,7 @@ func (c *service) IPReassemblySet(ctx context.Context, in *IPReassemblySet) (*IP return out, nil } -func (c *service) IPScanNeighborEnableDisable(ctx context.Context, in *IPScanNeighborEnableDisable) (*IPScanNeighborEnableDisableReply, error) { +func (c *serviceClient) IPScanNeighborEnableDisable(ctx context.Context, in *IPScanNeighborEnableDisable) (*IPScanNeighborEnableDisableReply, error) { out := new(IPScanNeighborEnableDisableReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -2502,7 +2608,7 @@ func (c *service) IPScanNeighborEnableDisable(ctx context.Context, in *IPScanNei return out, nil } -func (c *service) IPSourceAndPortRangeCheckAddDel(ctx context.Context, in *IPSourceAndPortRangeCheckAddDel) (*IPSourceAndPortRangeCheckAddDelReply, error) { +func (c *serviceClient) IPSourceAndPortRangeCheckAddDel(ctx context.Context, in *IPSourceAndPortRangeCheckAddDel) (*IPSourceAndPortRangeCheckAddDelReply, error) { out := new(IPSourceAndPortRangeCheckAddDelReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -2511,7 +2617,7 @@ func (c *service) IPSourceAndPortRangeCheckAddDel(ctx context.Context, in *IPSou return out, nil } -func (c *service) IPSourceAndPortRangeCheckInterfaceAddDel(ctx context.Context, in *IPSourceAndPortRangeCheckInterfaceAddDel) (*IPSourceAndPortRangeCheckInterfaceAddDelReply, error) { +func (c *serviceClient) IPSourceAndPortRangeCheckInterfaceAddDel(ctx context.Context, in *IPSourceAndPortRangeCheckInterfaceAddDel) (*IPSourceAndPortRangeCheckInterfaceAddDelReply, error) { out := new(IPSourceAndPortRangeCheckInterfaceAddDelReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -2520,7 +2626,7 @@ func (c *service) IPSourceAndPortRangeCheckInterfaceAddDel(ctx context.Context, return out, nil } -func (c *service) IPSourceCheckInterfaceAddDel(ctx context.Context, in *IPSourceCheckInterfaceAddDel) (*IPSourceCheckInterfaceAddDelReply, error) { +func (c *serviceClient) IPSourceCheckInterfaceAddDel(ctx context.Context, in *IPSourceCheckInterfaceAddDel) (*IPSourceCheckInterfaceAddDelReply, error) { out := new(IPSourceCheckInterfaceAddDelReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -2529,7 +2635,7 @@ func (c *service) IPSourceCheckInterfaceAddDel(ctx context.Context, in *IPSource return out, nil } -func (c *service) IPTableAddDel(ctx context.Context, in *IPTableAddDel) (*IPTableAddDelReply, error) { +func (c *serviceClient) IPTableAddDel(ctx context.Context, in *IPTableAddDel) (*IPTableAddDelReply, error) { out := new(IPTableAddDelReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -2538,7 +2644,7 @@ func (c *service) IPTableAddDel(ctx context.Context, in *IPTableAddDel) (*IPTabl return out, nil } -func (c *service) ProxyArpAddDel(ctx context.Context, in *ProxyArpAddDel) (*ProxyArpAddDelReply, error) { +func (c *serviceClient) ProxyArpAddDel(ctx context.Context, in *ProxyArpAddDel) (*ProxyArpAddDelReply, error) { out := new(ProxyArpAddDelReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -2547,7 +2653,7 @@ func (c *service) ProxyArpAddDel(ctx context.Context, in *ProxyArpAddDel) (*Prox return out, nil } -func (c *service) ProxyArpIntfcEnableDisable(ctx context.Context, in *ProxyArpIntfcEnableDisable) (*ProxyArpIntfcEnableDisableReply, error) { +func (c *serviceClient) ProxyArpIntfcEnableDisable(ctx context.Context, in *ProxyArpIntfcEnableDisable) (*ProxyArpIntfcEnableDisableReply, error) { out := new(ProxyArpIntfcEnableDisableReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -2556,7 +2662,7 @@ func (c *service) ProxyArpIntfcEnableDisable(ctx context.Context, in *ProxyArpIn return out, nil } -func (c *service) ResetFib(ctx context.Context, in *ResetFib) (*ResetFibReply, error) { +func (c *serviceClient) ResetFib(ctx context.Context, in *ResetFib) (*ResetFibReply, error) { out := new(ResetFibReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -2565,7 +2671,7 @@ func (c *service) ResetFib(ctx context.Context, in *ResetFib) (*ResetFibReply, e return out, nil } -func (c *service) SetArpNeighborLimit(ctx context.Context, in *SetArpNeighborLimit) (*SetArpNeighborLimitReply, error) { +func (c *serviceClient) SetArpNeighborLimit(ctx context.Context, in *SetArpNeighborLimit) (*SetArpNeighborLimitReply, error) { out := new(SetArpNeighborLimitReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -2574,7 +2680,7 @@ func (c *service) SetArpNeighborLimit(ctx context.Context, in *SetArpNeighborLim return out, nil } -func (c *service) SetIPFlowHash(ctx context.Context, in *SetIPFlowHash) (*SetIPFlowHashReply, error) { +func (c *serviceClient) SetIPFlowHash(ctx context.Context, in *SetIPFlowHash) (*SetIPFlowHashReply, error) { out := new(SetIPFlowHashReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -2583,7 +2689,7 @@ func (c *service) SetIPFlowHash(ctx context.Context, in *SetIPFlowHash) (*SetIPF return out, nil } -func (c *service) SwInterfaceIP6EnableDisable(ctx context.Context, in *SwInterfaceIP6EnableDisable) (*SwInterfaceIP6EnableDisableReply, error) { +func (c *serviceClient) SwInterfaceIP6EnableDisable(ctx context.Context, in *SwInterfaceIP6EnableDisable) (*SwInterfaceIP6EnableDisableReply, error) { out := new(SwInterfaceIP6EnableDisableReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -2592,7 +2698,7 @@ func (c *service) SwInterfaceIP6EnableDisable(ctx context.Context, in *SwInterfa return out, nil } -func (c *service) SwInterfaceIP6ndRaConfig(ctx context.Context, in *SwInterfaceIP6ndRaConfig) (*SwInterfaceIP6ndRaConfigReply, error) { +func (c *serviceClient) SwInterfaceIP6ndRaConfig(ctx context.Context, in *SwInterfaceIP6ndRaConfig) (*SwInterfaceIP6ndRaConfigReply, error) { out := new(SwInterfaceIP6ndRaConfigReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -2601,7 +2707,7 @@ func (c *service) SwInterfaceIP6ndRaConfig(ctx context.Context, in *SwInterfaceI return out, nil } -func (c *service) SwInterfaceIP6ndRaPrefix(ctx context.Context, in *SwInterfaceIP6ndRaPrefix) (*SwInterfaceIP6ndRaPrefixReply, error) { +func (c *serviceClient) SwInterfaceIP6ndRaPrefix(ctx context.Context, in *SwInterfaceIP6ndRaPrefix) (*SwInterfaceIP6ndRaPrefixReply, error) { out := new(SwInterfaceIP6ndRaPrefixReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -2610,7 +2716,7 @@ func (c *service) SwInterfaceIP6ndRaPrefix(ctx context.Context, in *SwInterfaceI return out, nil } -func (c *service) WantIP4ArpEvents(ctx context.Context, in *WantIP4ArpEvents) (*WantIP4ArpEventsReply, error) { +func (c *serviceClient) WantIP4ArpEvents(ctx context.Context, in *WantIP4ArpEvents) (*WantIP4ArpEventsReply, error) { out := new(WantIP4ArpEventsReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -2619,7 +2725,7 @@ func (c *service) WantIP4ArpEvents(ctx context.Context, in *WantIP4ArpEvents) (* return out, nil } -func (c *service) WantIP6NdEvents(ctx context.Context, in *WantIP6NdEvents) (*WantIP6NdEventsReply, error) { +func (c *serviceClient) WantIP6NdEvents(ctx context.Context, in *WantIP6NdEvents) (*WantIP6NdEventsReply, error) { out := new(WantIP6NdEventsReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -2628,7 +2734,7 @@ func (c *service) WantIP6NdEvents(ctx context.Context, in *WantIP6NdEvents) (*Wa return out, nil } -func (c *service) WantIP6RaEvents(ctx context.Context, in *WantIP6RaEvents) (*WantIP6RaEventsReply, error) { +func (c *serviceClient) WantIP6RaEvents(ctx context.Context, in *WantIP6RaEvents) (*WantIP6RaEventsReply, error) { out := new(WantIP6RaEventsReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -2636,3 +2742,17 @@ func (c *service) WantIP6RaEvents(ctx context.Context, in *WantIP6RaEvents) (*Wa } return out, nil } + +// 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.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package + +// Reference imports to suppress errors if they are not otherwise used. +var _ = api.RegisterMessage +var _ = bytes.NewBuffer +var _ = context.Background +var _ = io.Copy +var _ = strconv.Itoa +var _ = struc.Pack diff --git a/examples/binapi/memclnt/memclnt.ba.go b/examples/binapi/memclnt/memclnt.ba.go index 0fa28dd..d1ffe03 100644 --- a/examples/binapi/memclnt/memclnt.ba.go +++ b/examples/binapi/memclnt/memclnt.ba.go @@ -1,34 +1,24 @@ -// Code generated by GoVPP binapi-generator. DO NOT EDIT. +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. // source: /usr/share/vpp/api/core/memclnt.api.json /* -Package memclnt is a generated from VPP binary API module 'memclnt'. +Package memclnt is a generated VPP binary API for 'memclnt' module. - The memclnt module consists of: +It consists of: 2 types 22 messages 13 services */ package memclnt -import api "git.fd.io/govpp.git/api" -import bytes "bytes" -import context "context" -import strconv "strconv" -import struc "github.com/lunixbochs/struc" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = strconv.Itoa -var _ = struc.Pack - -// 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.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package +import ( + bytes "bytes" + context "context" + api "git.fd.io/govpp.git/api" + struc "github.com/lunixbochs/struc" + io "io" + strconv "strconv" +) const ( // ModuleName is the name of this module. @@ -39,9 +29,7 @@ const ( VersionCrc = 0xb619530 ) -/* Types */ - -// MessageTableEntry represents VPP binary API type 'message_table_entry': +// MessageTableEntry represents VPP binary API type 'message_table_entry'. type MessageTableEntry struct { Index uint16 Name []byte `struc:"[64]byte"` @@ -54,7 +42,7 @@ func (*MessageTableEntry) GetCrcString() string { return "913bf1c6" } -// ModuleVersion represents VPP binary API type 'module_version': +// ModuleVersion represents VPP binary API type 'module_version'. type ModuleVersion struct { Major uint32 Minor uint32 @@ -69,9 +57,7 @@ func (*ModuleVersion) GetCrcString() string { return "4b6da11a" } -/* Messages */ - -// APIVersions represents VPP binary API message 'api_versions': +// APIVersions represents VPP binary API message 'api_versions'. type APIVersions struct{} func (*APIVersions) GetMessageName() string { @@ -84,7 +70,7 @@ func (*APIVersions) GetMessageType() api.MessageType { return api.RequestMessage } -// APIVersionsReply represents VPP binary API message 'api_versions_reply': +// APIVersionsReply represents VPP binary API message 'api_versions_reply'. type APIVersionsReply struct { Retval int32 Count uint32 `struc:"sizeof=APIVersions"` @@ -101,7 +87,7 @@ func (*APIVersionsReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// GetFirstMsgID represents VPP binary API message 'get_first_msg_id': +// GetFirstMsgID represents VPP binary API message 'get_first_msg_id'. type GetFirstMsgID struct { Name []byte `struc:"[64]byte"` } @@ -116,7 +102,7 @@ func (*GetFirstMsgID) GetMessageType() api.MessageType { return api.RequestMessage } -// GetFirstMsgIDReply represents VPP binary API message 'get_first_msg_id_reply': +// GetFirstMsgIDReply represents VPP binary API message 'get_first_msg_id_reply'. type GetFirstMsgIDReply struct { Retval int32 FirstMsgID uint16 @@ -132,7 +118,7 @@ func (*GetFirstMsgIDReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// MemclntCreate represents VPP binary API message 'memclnt_create': +// MemclntCreate represents VPP binary API message 'memclnt_create'. type MemclntCreate struct { CtxQuota int32 InputQueue uint64 @@ -150,7 +136,7 @@ func (*MemclntCreate) GetMessageType() api.MessageType { return api.ReplyMessage } -// MemclntCreateReply represents VPP binary API message 'memclnt_create_reply': +// MemclntCreateReply represents VPP binary API message 'memclnt_create_reply'. type MemclntCreateReply struct { Response int32 Handle uint64 @@ -168,7 +154,7 @@ func (*MemclntCreateReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// MemclntDelete represents VPP binary API message 'memclnt_delete': +// MemclntDelete represents VPP binary API message 'memclnt_delete'. type MemclntDelete struct { Index uint32 Handle uint64 @@ -185,7 +171,7 @@ func (*MemclntDelete) GetMessageType() api.MessageType { return api.OtherMessage } -// MemclntDeleteReply represents VPP binary API message 'memclnt_delete_reply': +// MemclntDeleteReply represents VPP binary API message 'memclnt_delete_reply'. type MemclntDeleteReply struct { Response int32 Handle uint64 @@ -201,7 +187,7 @@ func (*MemclntDeleteReply) GetMessageType() api.MessageType { return api.OtherMessage } -// MemclntKeepalive represents VPP binary API message 'memclnt_keepalive': +// MemclntKeepalive represents VPP binary API message 'memclnt_keepalive'. type MemclntKeepalive struct{} func (*MemclntKeepalive) GetMessageName() string { @@ -214,7 +200,7 @@ func (*MemclntKeepalive) GetMessageType() api.MessageType { return api.RequestMessage } -// MemclntKeepaliveReply represents VPP binary API message 'memclnt_keepalive_reply': +// MemclntKeepaliveReply represents VPP binary API message 'memclnt_keepalive_reply'. type MemclntKeepaliveReply struct { Retval int32 } @@ -229,7 +215,7 @@ func (*MemclntKeepaliveReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// MemclntReadTimeout represents VPP binary API message 'memclnt_read_timeout': +// MemclntReadTimeout represents VPP binary API message 'memclnt_read_timeout'. type MemclntReadTimeout struct { Dummy uint8 } @@ -244,7 +230,7 @@ func (*MemclntReadTimeout) GetMessageType() api.MessageType { return api.OtherMessage } -// MemclntRxThreadSuspend represents VPP binary API message 'memclnt_rx_thread_suspend': +// MemclntRxThreadSuspend represents VPP binary API message 'memclnt_rx_thread_suspend'. type MemclntRxThreadSuspend struct { Dummy uint8 } @@ -259,7 +245,7 @@ func (*MemclntRxThreadSuspend) GetMessageType() api.MessageType { return api.OtherMessage } -// RPCCall represents VPP binary API message 'rpc_call': +// RPCCall represents VPP binary API message 'rpc_call'. type RPCCall struct { Function uint64 Multicast uint8 @@ -279,7 +265,7 @@ func (*RPCCall) GetMessageType() api.MessageType { return api.RequestMessage } -// RPCCallReply represents VPP binary API message 'rpc_call_reply': +// RPCCallReply represents VPP binary API message 'rpc_call_reply'. type RPCCallReply struct { Retval int32 } @@ -294,7 +280,7 @@ func (*RPCCallReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// RxThreadExit represents VPP binary API message 'rx_thread_exit': +// RxThreadExit represents VPP binary API message 'rx_thread_exit'. type RxThreadExit struct { Dummy uint8 } @@ -309,7 +295,7 @@ func (*RxThreadExit) GetMessageType() api.MessageType { return api.OtherMessage } -// SockInitShm represents VPP binary API message 'sock_init_shm': +// SockInitShm represents VPP binary API message 'sock_init_shm'. type SockInitShm struct { RequestedSize uint32 Nitems uint8 `struc:"sizeof=Configs"` @@ -326,7 +312,7 @@ func (*SockInitShm) GetMessageType() api.MessageType { return api.RequestMessage } -// SockInitShmReply represents VPP binary API message 'sock_init_shm_reply': +// SockInitShmReply represents VPP binary API message 'sock_init_shm_reply'. type SockInitShmReply struct { Retval int32 } @@ -341,7 +327,7 @@ func (*SockInitShmReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// SockclntCreate represents VPP binary API message 'sockclnt_create': +// SockclntCreate represents VPP binary API message 'sockclnt_create'. type SockclntCreate struct { Name []byte `struc:"[64]byte"` } @@ -356,7 +342,7 @@ func (*SockclntCreate) GetMessageType() api.MessageType { return api.ReplyMessage } -// SockclntCreateReply represents VPP binary API message 'sockclnt_create_reply': +// SockclntCreateReply represents VPP binary API message 'sockclnt_create_reply'. type SockclntCreateReply struct { Response int32 Index uint32 @@ -374,7 +360,7 @@ func (*SockclntCreateReply) GetMessageType() api.MessageType { return api.RequestMessage } -// SockclntDelete represents VPP binary API message 'sockclnt_delete': +// SockclntDelete represents VPP binary API message 'sockclnt_delete'. type SockclntDelete struct { Index uint32 } @@ -389,7 +375,7 @@ func (*SockclntDelete) GetMessageType() api.MessageType { return api.RequestMessage } -// SockclntDeleteReply represents VPP binary API message 'sockclnt_delete_reply': +// SockclntDeleteReply represents VPP binary API message 'sockclnt_delete_reply'. type SockclntDeleteReply struct { Response int32 } @@ -404,7 +390,7 @@ func (*SockclntDeleteReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// TracePluginMsgIds represents VPP binary API message 'trace_plugin_msg_ids': +// TracePluginMsgIds represents VPP binary API message 'trace_plugin_msg_ids'. type TracePluginMsgIds struct { PluginName []byte `struc:"[128]byte"` FirstMsgID uint16 @@ -474,8 +460,8 @@ func AllMessages() []api.Message { } } -// Service represents VPP binary API services in memclnt module. -type Service interface { +// RPCService represents RPC service API for memclnt module. +type RPCService interface { APIVersions(ctx context.Context, in *APIVersions) (*APIVersionsReply, error) GetFirstMsgID(ctx context.Context, in *GetFirstMsgID) (*GetFirstMsgIDReply, error) MemclntCreate(ctx context.Context, in *MemclntCreate) (*MemclntCreateReply, error) @@ -491,15 +477,15 @@ type Service interface { TracePluginMsgIds(ctx context.Context, in *TracePluginMsgIds) error } -type service struct { +type serviceClient struct { ch api.Channel } -func NewService(ch api.Channel) Service { - return &service{ch} +func NewServiceClient(ch api.Channel) RPCService { + return &serviceClient{ch} } -func (c *service) APIVersions(ctx context.Context, in *APIVersions) (*APIVersionsReply, error) { +func (c *serviceClient) APIVersions(ctx context.Context, in *APIVersions) (*APIVersionsReply, error) { out := new(APIVersionsReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -508,7 +494,7 @@ func (c *service) APIVersions(ctx context.Context, in *APIVersions) (*APIVersion return out, nil } -func (c *service) GetFirstMsgID(ctx context.Context, in *GetFirstMsgID) (*GetFirstMsgIDReply, error) { +func (c *serviceClient) GetFirstMsgID(ctx context.Context, in *GetFirstMsgID) (*GetFirstMsgIDReply, error) { out := new(GetFirstMsgIDReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -517,7 +503,7 @@ func (c *service) GetFirstMsgID(ctx context.Context, in *GetFirstMsgID) (*GetFir return out, nil } -func (c *service) MemclntCreate(ctx context.Context, in *MemclntCreate) (*MemclntCreateReply, error) { +func (c *serviceClient) MemclntCreate(ctx context.Context, in *MemclntCreate) (*MemclntCreateReply, error) { out := new(MemclntCreateReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -526,7 +512,7 @@ func (c *service) MemclntCreate(ctx context.Context, in *MemclntCreate) (*Memcln return out, nil } -func (c *service) MemclntDelete(ctx context.Context, in *MemclntDelete) (*MemclntDeleteReply, error) { +func (c *serviceClient) MemclntDelete(ctx context.Context, in *MemclntDelete) (*MemclntDeleteReply, error) { out := new(MemclntDeleteReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -535,7 +521,7 @@ func (c *service) MemclntDelete(ctx context.Context, in *MemclntDelete) (*Memcln return out, nil } -func (c *service) MemclntKeepalive(ctx context.Context, in *MemclntKeepalive) (*MemclntKeepaliveReply, error) { +func (c *serviceClient) MemclntKeepalive(ctx context.Context, in *MemclntKeepalive) (*MemclntKeepaliveReply, error) { out := new(MemclntKeepaliveReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -544,17 +530,17 @@ func (c *service) MemclntKeepalive(ctx context.Context, in *MemclntKeepalive) (* return out, nil } -func (c *service) MemclntReadTimeout(ctx context.Context, in *MemclntReadTimeout) error { +func (c *serviceClient) MemclntReadTimeout(ctx context.Context, in *MemclntReadTimeout) error { c.ch.SendRequest(in) return nil } -func (c *service) MemclntRxThreadSuspend(ctx context.Context, in *MemclntRxThreadSuspend) error { +func (c *serviceClient) MemclntRxThreadSuspend(ctx context.Context, in *MemclntRxThreadSuspend) error { c.ch.SendRequest(in) return nil } -func (c *service) RPCCall(ctx context.Context, in *RPCCall) (*RPCCallReply, error) { +func (c *serviceClient) RPCCall(ctx context.Context, in *RPCCall) (*RPCCallReply, error) { out := new(RPCCallReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -563,12 +549,12 @@ func (c *service) RPCCall(ctx context.Context, in *RPCCall) (*RPCCallReply, erro return out, nil } -func (c *service) RxThreadExit(ctx context.Context, in *RxThreadExit) error { +func (c *serviceClient) RxThreadExit(ctx context.Context, in *RxThreadExit) error { c.ch.SendRequest(in) return nil } -func (c *service) SockInitShm(ctx context.Context, in *SockInitShm) (*SockInitShmReply, error) { +func (c *serviceClient) SockInitShm(ctx context.Context, in *SockInitShm) (*SockInitShmReply, error) { out := new(SockInitShmReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -577,7 +563,7 @@ func (c *service) SockInitShm(ctx context.Context, in *SockInitShm) (*SockInitSh return out, nil } -func (c *service) SockclntCreate(ctx context.Context, in *SockclntCreate) (*SockclntCreateReply, error) { +func (c *serviceClient) SockclntCreate(ctx context.Context, in *SockclntCreate) (*SockclntCreateReply, error) { out := new(SockclntCreateReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -586,7 +572,7 @@ func (c *service) SockclntCreate(ctx context.Context, in *SockclntCreate) (*Sock return out, nil } -func (c *service) SockclntDelete(ctx context.Context, in *SockclntDelete) (*SockclntDeleteReply, error) { +func (c *serviceClient) SockclntDelete(ctx context.Context, in *SockclntDelete) (*SockclntDeleteReply, error) { out := new(SockclntDeleteReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -595,7 +581,21 @@ func (c *service) SockclntDelete(ctx context.Context, in *SockclntDelete) (*Sock return out, nil } -func (c *service) TracePluginMsgIds(ctx context.Context, in *TracePluginMsgIds) error { +func (c *serviceClient) TracePluginMsgIds(ctx context.Context, in *TracePluginMsgIds) error { c.ch.SendRequest(in) return nil } + +// 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.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package + +// Reference imports to suppress errors if they are not otherwise used. +var _ = api.RegisterMessage +var _ = bytes.NewBuffer +var _ = context.Background +var _ = io.Copy +var _ = strconv.Itoa +var _ = struc.Pack diff --git a/examples/binapi/memif/memif.ba.go b/examples/binapi/memif/memif.ba.go index 4123ad8..8d23986 100644 --- a/examples/binapi/memif/memif.ba.go +++ b/examples/binapi/memif/memif.ba.go @@ -1,33 +1,23 @@ -// Code generated by GoVPP binapi-generator. DO NOT EDIT. +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. // source: /usr/share/vpp/api/plugins/memif.api.json /* -Package memif is a generated from VPP binary API module 'memif'. +Package memif is a generated VPP binary API for 'memif' module. - The memif module consists of: +It consists of: 10 messages 5 services */ package memif -import api "git.fd.io/govpp.git/api" -import bytes "bytes" -import context "context" -import strconv "strconv" -import struc "github.com/lunixbochs/struc" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = strconv.Itoa -var _ = struc.Pack - -// 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.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package +import ( + bytes "bytes" + context "context" + api "git.fd.io/govpp.git/api" + struc "github.com/lunixbochs/struc" + io "io" + strconv "strconv" +) const ( // ModuleName is the name of this module. @@ -38,9 +28,7 @@ const ( VersionCrc = 0x31b42e17 ) -/* Messages */ - -// MemifCreate represents VPP binary API message 'memif_create': +// MemifCreate represents VPP binary API message 'memif_create'. type MemifCreate struct { Role uint8 Mode uint8 @@ -64,7 +52,7 @@ func (*MemifCreate) GetMessageType() api.MessageType { return api.RequestMessage } -// MemifCreateReply represents VPP binary API message 'memif_create_reply': +// MemifCreateReply represents VPP binary API message 'memif_create_reply'. type MemifCreateReply struct { Retval int32 SwIfIndex uint32 @@ -80,7 +68,7 @@ func (*MemifCreateReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// MemifDelete represents VPP binary API message 'memif_delete': +// MemifDelete represents VPP binary API message 'memif_delete'. type MemifDelete struct { SwIfIndex uint32 } @@ -95,7 +83,7 @@ func (*MemifDelete) GetMessageType() api.MessageType { return api.RequestMessage } -// MemifDeleteReply represents VPP binary API message 'memif_delete_reply': +// MemifDeleteReply represents VPP binary API message 'memif_delete_reply'. type MemifDeleteReply struct { Retval int32 } @@ -110,7 +98,7 @@ func (*MemifDeleteReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// MemifDetails represents VPP binary API message 'memif_details': +// MemifDetails represents VPP binary API message 'memif_details'. type MemifDetails struct { SwIfIndex uint32 IfName []byte `struc:"[64]byte"` @@ -135,7 +123,7 @@ func (*MemifDetails) GetMessageType() api.MessageType { return api.ReplyMessage } -// MemifDump represents VPP binary API message 'memif_dump': +// MemifDump represents VPP binary API message 'memif_dump'. type MemifDump struct{} func (*MemifDump) GetMessageName() string { @@ -148,7 +136,7 @@ func (*MemifDump) GetMessageType() api.MessageType { return api.RequestMessage } -// MemifSocketFilenameAddDel represents VPP binary API message 'memif_socket_filename_add_del': +// MemifSocketFilenameAddDel represents VPP binary API message 'memif_socket_filename_add_del'. type MemifSocketFilenameAddDel struct { IsAdd uint8 SocketID uint32 @@ -165,7 +153,7 @@ func (*MemifSocketFilenameAddDel) GetMessageType() api.MessageType { return api.RequestMessage } -// MemifSocketFilenameAddDelReply represents VPP binary API message 'memif_socket_filename_add_del_reply': +// MemifSocketFilenameAddDelReply represents VPP binary API message 'memif_socket_filename_add_del_reply'. type MemifSocketFilenameAddDelReply struct { Retval int32 } @@ -180,7 +168,7 @@ func (*MemifSocketFilenameAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// MemifSocketFilenameDetails represents VPP binary API message 'memif_socket_filename_details': +// MemifSocketFilenameDetails represents VPP binary API message 'memif_socket_filename_details'. type MemifSocketFilenameDetails struct { SocketID uint32 SocketFilename []byte `struc:"[128]byte"` @@ -196,7 +184,7 @@ func (*MemifSocketFilenameDetails) GetMessageType() api.MessageType { return api.ReplyMessage } -// MemifSocketFilenameDump represents VPP binary API message 'memif_socket_filename_dump': +// MemifSocketFilenameDump represents VPP binary API message 'memif_socket_filename_dump'. type MemifSocketFilenameDump struct{} func (*MemifSocketFilenameDump) GetMessageName() string { @@ -238,58 +226,76 @@ func AllMessages() []api.Message { } } -// Service represents VPP binary API services in memif module. -type Service interface { - DumpMemif(ctx context.Context, in *MemifDump) ([]*MemifDetails, error) - DumpMemifSocketFilename(ctx context.Context, in *MemifSocketFilenameDump) ([]*MemifSocketFilenameDetails, error) +// RPCService represents RPC service API for memif module. +type RPCService interface { + DumpMemif(ctx context.Context, in *MemifDump) (RPCService_DumpMemifClient, error) + DumpMemifSocketFilename(ctx context.Context, in *MemifSocketFilenameDump) (RPCService_DumpMemifSocketFilenameClient, error) MemifCreate(ctx context.Context, in *MemifCreate) (*MemifCreateReply, error) MemifDelete(ctx context.Context, in *MemifDelete) (*MemifDeleteReply, error) MemifSocketFilenameAddDel(ctx context.Context, in *MemifSocketFilenameAddDel) (*MemifSocketFilenameAddDelReply, error) } -type service struct { +type serviceClient struct { ch api.Channel } -func NewService(ch api.Channel) Service { - return &service{ch} +func NewServiceClient(ch api.Channel) RPCService { + return &serviceClient{ch} +} + +func (c *serviceClient) DumpMemif(ctx context.Context, in *MemifDump) (RPCService_DumpMemifClient, error) { + stream := c.ch.SendMultiRequest(in) + x := &serviceClient_DumpMemifClient{stream} + return x, nil +} + +type RPCService_DumpMemifClient interface { + Recv() (*MemifDetails, error) +} + +type serviceClient_DumpMemifClient struct { + api.MultiRequestCtx +} + +func (c *serviceClient_DumpMemifClient) Recv() (*MemifDetails, error) { + m := new(MemifDetails) + stop, err := c.MultiRequestCtx.ReceiveReply(m) + if err != nil { + return nil, err + } + if stop { + return nil, io.EOF + } + return m, nil +} + +func (c *serviceClient) DumpMemifSocketFilename(ctx context.Context, in *MemifSocketFilenameDump) (RPCService_DumpMemifSocketFilenameClient, error) { + stream := c.ch.SendMultiRequest(in) + x := &serviceClient_DumpMemifSocketFilenameClient{stream} + return x, nil +} + +type RPCService_DumpMemifSocketFilenameClient interface { + Recv() (*MemifSocketFilenameDetails, error) +} + +type serviceClient_DumpMemifSocketFilenameClient struct { + api.MultiRequestCtx } -func (c *service) DumpMemif(ctx context.Context, in *MemifDump) ([]*MemifDetails, error) { - var dump []*MemifDetails - req := c.ch.SendMultiRequest(in) - for { - m := new(MemifDetails) - stop, err := req.ReceiveReply(m) - if stop { - break - } - if err != nil { - return nil, err - } - dump = append(dump, m) +func (c *serviceClient_DumpMemifSocketFilenameClient) Recv() (*MemifSocketFilenameDetails, error) { + m := new(MemifSocketFilenameDetails) + stop, err := c.MultiRequestCtx.ReceiveReply(m) + if err != nil { + return nil, err } - return dump, nil -} - -func (c *service) DumpMemifSocketFilename(ctx context.Context, in *MemifSocketFilenameDump) ([]*MemifSocketFilenameDetails, error) { - var dump []*MemifSocketFilenameDetails - req := c.ch.SendMultiRequest(in) - for { - m := new(MemifSocketFilenameDetails) - stop, err := req.ReceiveReply(m) - if stop { - break - } - if err != nil { - return nil, err - } - dump = append(dump, m) + if stop { + return nil, io.EOF } - return dump, nil + return m, nil } -func (c *service) MemifCreate(ctx context.Context, in *MemifCreate) (*MemifCreateReply, error) { +func (c *serviceClient) MemifCreate(ctx context.Context, in *MemifCreate) (*MemifCreateReply, error) { out := new(MemifCreateReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -298,7 +304,7 @@ func (c *service) MemifCreate(ctx context.Context, in *MemifCreate) (*MemifCreat return out, nil } -func (c *service) MemifDelete(ctx context.Context, in *MemifDelete) (*MemifDeleteReply, error) { +func (c *serviceClient) MemifDelete(ctx context.Context, in *MemifDelete) (*MemifDeleteReply, error) { out := new(MemifDeleteReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -307,7 +313,7 @@ func (c *service) MemifDelete(ctx context.Context, in *MemifDelete) (*MemifDelet return out, nil } -func (c *service) MemifSocketFilenameAddDel(ctx context.Context, in *MemifSocketFilenameAddDel) (*MemifSocketFilenameAddDelReply, error) { +func (c *serviceClient) MemifSocketFilenameAddDel(ctx context.Context, in *MemifSocketFilenameAddDel) (*MemifSocketFilenameAddDelReply, error) { out := new(MemifSocketFilenameAddDelReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -315,3 +321,17 @@ func (c *service) MemifSocketFilenameAddDel(ctx context.Context, in *MemifSocket } return out, nil } + +// 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.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package + +// Reference imports to suppress errors if they are not otherwise used. +var _ = api.RegisterMessage +var _ = bytes.NewBuffer +var _ = context.Background +var _ = io.Copy +var _ = strconv.Itoa +var _ = struc.Pack diff --git a/examples/binapi/vpe/vpe.ba.go b/examples/binapi/vpe/vpe.ba.go index c475a70..cff53cd 100644 --- a/examples/binapi/vpe/vpe.ba.go +++ b/examples/binapi/vpe/vpe.ba.go @@ -1,34 +1,24 @@ -// Code generated by GoVPP binapi-generator. DO NOT EDIT. +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. // source: /usr/share/vpp/api/core/vpe.api.json /* -Package vpe is a generated from VPP binary API module 'vpe'. +Package vpe is a generated VPP binary API for 'vpe' module. - The vpe module consists of: +It consists of: 1 type 18 messages 9 services */ package vpe -import api "git.fd.io/govpp.git/api" -import bytes "bytes" -import context "context" -import strconv "strconv" -import struc "github.com/lunixbochs/struc" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = strconv.Itoa -var _ = struc.Pack - -// 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.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package +import ( + bytes "bytes" + context "context" + api "git.fd.io/govpp.git/api" + struc "github.com/lunixbochs/struc" + io "io" + strconv "strconv" +) const ( // ModuleName is the name of this module. @@ -39,9 +29,7 @@ const ( VersionCrc = 0x2cc8d629 ) -/* Types */ - -// ThreadData represents VPP binary API type 'thread_data': +// ThreadData represents VPP binary API type 'thread_data'. type ThreadData struct { ID uint32 Name []byte `struc:"[64]byte"` @@ -59,9 +47,7 @@ func (*ThreadData) GetCrcString() string { return "0f57094e" } -/* Messages */ - -// AddNodeNext represents VPP binary API message 'add_node_next': +// AddNodeNext represents VPP binary API message 'add_node_next'. type AddNodeNext struct { NodeName []byte `struc:"[64]byte"` NextName []byte `struc:"[64]byte"` @@ -77,7 +63,7 @@ func (*AddNodeNext) GetMessageType() api.MessageType { return api.RequestMessage } -// AddNodeNextReply represents VPP binary API message 'add_node_next_reply': +// AddNodeNextReply represents VPP binary API message 'add_node_next_reply'. type AddNodeNextReply struct { Retval int32 NextIndex uint32 @@ -93,7 +79,7 @@ func (*AddNodeNextReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// Cli represents VPP binary API message 'cli': +// Cli represents VPP binary API message 'cli'. type Cli struct { CmdInShmem uint64 } @@ -108,7 +94,7 @@ func (*Cli) GetMessageType() api.MessageType { return api.RequestMessage } -// CliInband represents VPP binary API message 'cli_inband': +// CliInband represents VPP binary API message 'cli_inband'. type CliInband struct { XXX_CmdLen uint32 `struc:"sizeof=Cmd"` Cmd string @@ -124,7 +110,7 @@ func (*CliInband) GetMessageType() api.MessageType { return api.RequestMessage } -// CliInbandReply represents VPP binary API message 'cli_inband_reply': +// CliInbandReply represents VPP binary API message 'cli_inband_reply'. type CliInbandReply struct { Retval int32 XXX_ReplyLen uint32 `struc:"sizeof=Reply"` @@ -141,7 +127,7 @@ func (*CliInbandReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// CliReply represents VPP binary API message 'cli_reply': +// CliReply represents VPP binary API message 'cli_reply'. type CliReply struct { Retval int32 ReplyInShmem uint64 @@ -157,7 +143,7 @@ func (*CliReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// ControlPing represents VPP binary API message 'control_ping': +// ControlPing represents VPP binary API message 'control_ping'. type ControlPing struct{} func (*ControlPing) GetMessageName() string { @@ -170,7 +156,7 @@ func (*ControlPing) GetMessageType() api.MessageType { return api.RequestMessage } -// ControlPingReply represents VPP binary API message 'control_ping_reply': +// ControlPingReply represents VPP binary API message 'control_ping_reply'. type ControlPingReply struct { Retval int32 ClientIndex uint32 @@ -187,7 +173,7 @@ func (*ControlPingReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// GetNextIndex represents VPP binary API message 'get_next_index': +// GetNextIndex represents VPP binary API message 'get_next_index'. type GetNextIndex struct { NodeName []byte `struc:"[64]byte"` NextName []byte `struc:"[64]byte"` @@ -203,7 +189,7 @@ func (*GetNextIndex) GetMessageType() api.MessageType { return api.RequestMessage } -// GetNextIndexReply represents VPP binary API message 'get_next_index_reply': +// GetNextIndexReply represents VPP binary API message 'get_next_index_reply'. type GetNextIndexReply struct { Retval int32 NextIndex uint32 @@ -219,7 +205,7 @@ func (*GetNextIndexReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// GetNodeGraph represents VPP binary API message 'get_node_graph': +// GetNodeGraph represents VPP binary API message 'get_node_graph'. type GetNodeGraph struct{} func (*GetNodeGraph) GetMessageName() string { @@ -232,7 +218,7 @@ func (*GetNodeGraph) GetMessageType() api.MessageType { return api.RequestMessage } -// GetNodeGraphReply represents VPP binary API message 'get_node_graph_reply': +// GetNodeGraphReply represents VPP binary API message 'get_node_graph_reply'. type GetNodeGraphReply struct { Retval int32 ReplyInShmem uint64 @@ -248,7 +234,7 @@ func (*GetNodeGraphReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// GetNodeIndex represents VPP binary API message 'get_node_index': +// GetNodeIndex represents VPP binary API message 'get_node_index'. type GetNodeIndex struct { NodeName []byte `struc:"[64]byte"` } @@ -263,7 +249,7 @@ func (*GetNodeIndex) GetMessageType() api.MessageType { return api.RequestMessage } -// GetNodeIndexReply represents VPP binary API message 'get_node_index_reply': +// GetNodeIndexReply represents VPP binary API message 'get_node_index_reply'. type GetNodeIndexReply struct { Retval int32 NodeIndex uint32 @@ -279,7 +265,7 @@ func (*GetNodeIndexReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// ShowThreads represents VPP binary API message 'show_threads': +// ShowThreads represents VPP binary API message 'show_threads'. type ShowThreads struct{} func (*ShowThreads) GetMessageName() string { @@ -292,7 +278,7 @@ func (*ShowThreads) GetMessageType() api.MessageType { return api.RequestMessage } -// ShowThreadsReply represents VPP binary API message 'show_threads_reply': +// ShowThreadsReply represents VPP binary API message 'show_threads_reply'. type ShowThreadsReply struct { Retval int32 Count uint32 `struc:"sizeof=ThreadData"` @@ -309,7 +295,7 @@ func (*ShowThreadsReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// ShowVersion represents VPP binary API message 'show_version': +// ShowVersion represents VPP binary API message 'show_version'. type ShowVersion struct{} func (*ShowVersion) GetMessageName() string { @@ -322,7 +308,7 @@ func (*ShowVersion) GetMessageType() api.MessageType { return api.RequestMessage } -// ShowVersionReply represents VPP binary API message 'show_version_reply': +// ShowVersionReply represents VPP binary API message 'show_version_reply'. type ShowVersionReply struct { Retval int32 XXX_ProgramLen uint32 `struc:"sizeof=Program"` @@ -390,8 +376,8 @@ func AllMessages() []api.Message { } } -// Service represents VPP binary API services in vpe module. -type Service interface { +// RPCService represents RPC service API for vpe module. +type RPCService interface { AddNodeNext(ctx context.Context, in *AddNodeNext) (*AddNodeNextReply, error) Cli(ctx context.Context, in *Cli) (*CliReply, error) CliInband(ctx context.Context, in *CliInband) (*CliInbandReply, error) @@ -403,15 +389,15 @@ type Service interface { ShowVersion(ctx context.Context, in *ShowVersion) (*ShowVersionReply, error) } -type service struct { +type serviceClient struct { ch api.Channel } -func NewService(ch api.Channel) Service { - return &service{ch} +func NewServiceClient(ch api.Channel) RPCService { + return &serviceClient{ch} } -func (c *service) AddNodeNext(ctx context.Context, in *AddNodeNext) (*AddNodeNextReply, error) { +func (c *serviceClient) AddNodeNext(ctx context.Context, in *AddNodeNext) (*AddNodeNextReply, error) { out := new(AddNodeNextReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -420,7 +406,7 @@ func (c *service) AddNodeNext(ctx context.Context, in *AddNodeNext) (*AddNodeNex return out, nil } -func (c *service) Cli(ctx context.Context, in *Cli) (*CliReply, error) { +func (c *serviceClient) Cli(ctx context.Context, in *Cli) (*CliReply, error) { out := new(CliReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -429,7 +415,7 @@ func (c *service) Cli(ctx context.Context, in *Cli) (*CliReply, error) { return out, nil } -func (c *service) CliInband(ctx context.Context, in *CliInband) (*CliInbandReply, error) { +func (c *serviceClient) CliInband(ctx context.Context, in *CliInband) (*CliInbandReply, error) { out := new(CliInbandReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -438,7 +424,7 @@ func (c *service) CliInband(ctx context.Context, in *CliInband) (*CliInbandReply return out, nil } -func (c *service) ControlPing(ctx context.Context, in *ControlPing) (*ControlPingReply, error) { +func (c *serviceClient) ControlPing(ctx context.Context, in *ControlPing) (*ControlPingReply, error) { out := new(ControlPingReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -447,7 +433,7 @@ func (c *service) ControlPing(ctx context.Context, in *ControlPing) (*ControlPin return out, nil } -func (c *service) GetNextIndex(ctx context.Context, in *GetNextIndex) (*GetNextIndexReply, error) { +func (c *serviceClient) GetNextIndex(ctx context.Context, in *GetNextIndex) (*GetNextIndexReply, error) { out := new(GetNextIndexReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -456,7 +442,7 @@ func (c *service) GetNextIndex(ctx context.Context, in *GetNextIndex) (*GetNextI return out, nil } -func (c *service) GetNodeGraph(ctx context.Context, in *GetNodeGraph) (*GetNodeGraphReply, error) { +func (c *serviceClient) GetNodeGraph(ctx context.Context, in *GetNodeGraph) (*GetNodeGraphReply, error) { out := new(GetNodeGraphReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -465,7 +451,7 @@ func (c *service) GetNodeGraph(ctx context.Context, in *GetNodeGraph) (*GetNodeG return out, nil } -func (c *service) GetNodeIndex(ctx context.Context, in *GetNodeIndex) (*GetNodeIndexReply, error) { +func (c *serviceClient) GetNodeIndex(ctx context.Context, in *GetNodeIndex) (*GetNodeIndexReply, error) { out := new(GetNodeIndexReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -474,7 +460,7 @@ func (c *service) GetNodeIndex(ctx context.Context, in *GetNodeIndex) (*GetNodeI return out, nil } -func (c *service) ShowThreads(ctx context.Context, in *ShowThreads) (*ShowThreadsReply, error) { +func (c *serviceClient) ShowThreads(ctx context.Context, in *ShowThreads) (*ShowThreadsReply, error) { out := new(ShowThreadsReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -483,7 +469,7 @@ func (c *service) ShowThreads(ctx context.Context, in *ShowThreads) (*ShowThread return out, nil } -func (c *service) ShowVersion(ctx context.Context, in *ShowVersion) (*ShowVersionReply, error) { +func (c *serviceClient) ShowVersion(ctx context.Context, in *ShowVersion) (*ShowVersionReply, error) { out := new(ShowVersionReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { @@ -491,3 +477,17 @@ func (c *service) ShowVersion(ctx context.Context, in *ShowVersion) (*ShowVersio } return out, nil } + +// 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.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package + +// Reference imports to suppress errors if they are not otherwise used. +var _ = api.RegisterMessage +var _ = bytes.NewBuffer +var _ = context.Background +var _ = io.Copy +var _ = strconv.Itoa +var _ = struc.Pack diff --git a/examples/service-client/service_client.go b/examples/rpc-service/rpc_service.go similarity index 63% rename from examples/service-client/service_client.go rename to examples/rpc-service/rpc_service.go index 9aa07db..ca0c295 100644 --- a/examples/service-client/service_client.go +++ b/examples/rpc-service/rpc_service.go @@ -19,29 +19,38 @@ package main import ( "bytes" "context" + "flag" "fmt" + "io" "log" "git.fd.io/govpp.git" + "git.fd.io/govpp.git/adapter/socketclient" "git.fd.io/govpp.git/api" "git.fd.io/govpp.git/examples/binapi/interfaces" "git.fd.io/govpp.git/examples/binapi/vpe" ) +var ( + sockAddr = flag.String("sock", socketclient.DefaultSocketName, "Path to VPP binary API socket file") +) + func main() { - fmt.Println("Starting VPP service client...") + flag.Parse() + + fmt.Println("Starting RPC service example") // connect to VPP - conn, err := govpp.Connect("") + conn, err := govpp.Connect(*sockAddr) if err != nil { - log.Fatalln("failed to connect:", err) + log.Fatalln("ERROR: connecting to VPP failed:", err) } defer conn.Disconnect() - // create an API channel + // create a channel ch, err := conn.NewAPIChannel() if err != nil { - log.Fatalln("failed to create channel:", err) + log.Fatalln("ERROR: creating channel failed:", err) } defer ch.Close() @@ -51,11 +60,11 @@ func main() { // showVersion shows an example of simple request with services. func showVersion(ch api.Channel) { - c := vpe.NewService(ch) + c := vpe.NewServiceClient(ch) version, err := c.ShowVersion(context.Background(), &vpe.ShowVersion{}) if err != nil { - log.Fatalln("ShowVersion failed:", err) + log.Fatalln("ERROR: ShowVersion failed:", err) } fmt.Printf("Version: %v\n", version.Version) @@ -63,15 +72,22 @@ func showVersion(ch api.Channel) { // interfaceDump shows an example of multi request with services. func interfaceDump(ch api.Channel) { - c := interfaces.NewService(ch) + c := interfaces.NewServiceClient(ch) - ifaces, err := c.DumpSwInterface(context.Background(), &interfaces.SwInterfaceDump{}) + stream, err := c.DumpSwInterface(context.Background(), &interfaces.SwInterfaceDump{}) if err != nil { - log.Fatalln("DumpSwInterface failed:", err) + log.Fatalln("ERROR: DumpSwInterface failed:", err) } - fmt.Printf("Listing %d interfaces:\n", len(ifaces)) - for _, d := range ifaces { - fmt.Printf("- interface: %s\n", bytes.Trim(d.InterfaceName, "\x00")) + fmt.Println("Dumping interfaces") + for { + iface, err := stream.Recv() + if err == io.EOF { + break + } + if err != nil { + log.Fatalln("ERROR: DumpSwInterface failed:", err) + } + fmt.Printf("- interface: %s\n", bytes.Trim(iface.InterfaceName, "\x00")) } } diff --git a/examples/simple-client/simple_client.go b/examples/simple-client/simple_client.go index f3ee412..609a25d 100644 --- a/examples/simple-client/simple_client.go +++ b/examples/simple-client/simple_client.go @@ -17,6 +17,7 @@ package main import ( + "flag" "fmt" "log" "net" @@ -24,6 +25,7 @@ import ( "strings" "git.fd.io/govpp.git" + "git.fd.io/govpp.git/adapter/socketclient" "git.fd.io/govpp.git/api" "git.fd.io/govpp.git/core" "git.fd.io/govpp.git/examples/binapi/acl" @@ -31,11 +33,17 @@ import ( "git.fd.io/govpp.git/examples/binapi/ip" ) +var ( + sockAddr = flag.String("sock", socketclient.DefaultSocketName, "Path to VPP binary API socket file") +) + func main() { - fmt.Println("Starting simple VPP client...") + flag.Parse() + + fmt.Println("Starting simple client example") // connect to VPP - conn, conev, err := govpp.AsyncConnect("", core.DefaultMaxReconnectAttempts, core.DefaultReconnectInterval) + conn, conev, err := govpp.AsyncConnect(*sockAddr, core.DefaultMaxReconnectAttempts, core.DefaultReconnectInterval) if err != nil { log.Fatalln("ERROR:", err) } @@ -44,14 +52,14 @@ func main() { select { case e := <-conev: if e.State != core.Connected { - log.Fatalf("failed to connect: %v", e.Error) + log.Fatalln("ERROR: connecting to VPP failed:", err) } } // create an API channel that will be used in the examples ch, err := conn.NewAPIChannel() if err != nil { - log.Fatalln("ERROR:", err) + log.Fatalln("ERROR: creating channel failed:", err) } defer ch.Close() @@ -115,10 +123,6 @@ func aclConfig(ch api.Channel) { fmt.Println("ERROR:", err) return } - if reply.Retval != 0 { - fmt.Println("Retval:", reply.Retval) - return - } fmt.Printf("ACL add replace reply: %+v\n", reply) @@ -154,6 +158,7 @@ func interfaceDump(ch api.Channel) { } if err != nil { fmt.Println("ERROR:", err) + return } ifaceName := strings.TrimFunc(string(msg.InterfaceName), func(r rune) bool { return r == 0x00 @@ -178,6 +183,7 @@ func ipAddressDump(ch api.Channel) { } if err != nil { fmt.Println("ERROR:", err) + return } fmt.Printf("ip address details: %d %+v\n", msg.SwIfIndex, msg) } @@ -214,6 +220,7 @@ func ipUnnumberedDump(ch api.Channel) { } if err != nil { fmt.Println("ERROR:", err) + return } fmt.Printf("IP unnumbered details: %+v\n", msg) } diff --git a/examples/stats-api/README.md b/examples/stats-api/README.md index 77afad8..5511bf4 100644 --- a/examples/stats-api/README.md +++ b/examples/stats-api/README.md @@ -6,8 +6,10 @@ This example demonstrates how to retrieve statistics from VPP using [the new Sta The following requirements are required to run this example: -- install **VPP 18.10+** -- enable stats in VPP: +- install **VPP 18.10+** (VPP 19.04+ for goclient) +- enable stats in VPP + +To enable stats add following section to you VPP config: ```sh statseg { @@ -16,7 +18,6 @@ The following requirements are required to run this example: } ``` > The [default socket](https://wiki.fd.io/view/VPP/Command-line_Arguments#.22statseg.22_parameters) is located at `/run/vpp/stats.sock`. -- run the VPP (ideally with some traffic) ## Running example diff --git a/examples/stats-api/stats_api.go b/examples/stats-api/stats_api.go index e20ce7a..a42e3d2 100644 --- a/examples/stats-api/stats_api.go +++ b/examples/stats-api/stats_api.go @@ -36,8 +36,9 @@ import ( var ( statsSocket = flag.String("socket", adapter.DefaultStatsSocket, "Path to VPP stats socket") - goclient = flag.Bool("goclient", true, "Use pure Go client for stats API") dumpAll = flag.Bool("all", false, "Dump all stats including ones with zero values") + + goclient = flag.Bool("goclient", false, "Use pure Go client for stats API") ) func init() { -- 2.16.6