aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore12
-rw-r--r--Makefile63
-rw-r--r--adapter/adapter.go2
-rw-r--r--adapter/mock/mock_adapter.go11
-rw-r--r--adapter/vppapiclient/vppapiclient_adapter.go9
-rw-r--r--api/api.go37
-rw-r--r--cmd/binapi-generator/generate.go28
-rw-r--r--codec/msg_codec.go31
-rw-r--r--codec/msg_codec_test.go63
-rw-r--r--core/channel.go218
-rw-r--r--core/channel_test.go173
-rw-r--r--core/connection.go235
-rw-r--r--core/connection_test.go210
-rw-r--r--core/notification_handler.go170
-rw-r--r--core/request_handler.go108
-rw-r--r--examples/bin_api/acl/acl.ba.go153
-rw-r--r--examples/bin_api/af_packet/af_packet.ba.go45
-rw-r--r--examples/bin_api/interfaces/interfaces.ba.go198
-rw-r--r--examples/bin_api/ip/ip.ba.go377
-rw-r--r--examples/bin_api/memif/memif.ba.go53
-rw-r--r--examples/bin_api/stats/stats.ba.go181
-rw-r--r--examples/bin_api/tap/tap.ba.go45
-rw-r--r--examples/bin_api/vpe/vpe.ba.go77
-rw-r--r--examples/cmd/perf-bench/perf-bench.go16
-rw-r--r--examples/cmd/simple-client/simple_client.go70
-rw-r--r--examples/cmd/stats-client/stats_client.go31
26 files changed, 715 insertions, 1901 deletions
diff --git a/.gitignore b/.gitignore
index ec02bba..c10a9ca 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,15 @@
.idea
+
+# cmds
cmd/binapi-generator/binapi-generator
+
+# examples
+examples/cmd/perf-bench/perf-bench
examples/cmd/simple-client/simple-client
examples/cmd/stats-client/stats-client
-examples/cmd/perf-bench/perf-bench
+
+# extras
+extras/libmemif/examples/gopacket/gopacket
+extras/libmemif/examples/icmp-responder/icmp-responder
+extras/libmemif/examples/jumbo-frames/jumbo-frames
+extras/libmemif/examples/raw-data/raw-data
diff --git a/Makefile b/Makefile
index ee06818..ec01313 100644
--- a/Makefile
+++ b/Makefile
@@ -1,35 +1,52 @@
-build:
- @cd cmd/binapi-generator && go build -v
- @cd examples/cmd/simple-client && go build -v
- @cd examples/cmd/stats-client && go build -v
- @cd examples/cmd/perf-bench && go build -v
+VERSION ?= $(shell git describe --always --tags --dirty)
-test:
- @cd cmd/binapi-generator && go test -cover .
- @cd core && go test -cover .
+all: test build examples
install:
- @cd cmd/binapi-generator && go install -v
+ @echo "=> installing ${VERSION}"
+ go install ./cmd/binapi-generator
+
+build:
+ @echo "=> building ${VERSION}"
+ cd cmd/binapi-generator && go build -v
+
+examples:
+ @echo "=> building examples"
+ cd examples/cmd/simple-client && go build -v
+ cd examples/cmd/stats-client && go build -v
+ cd examples/cmd/perf-bench && go build -v
+
+test:
+ @echo "=> testing"
+ go test -cover ./cmd/...
+ go test -cover ./core ./api ./codec
extras:
- @cd extras/libmemif/examples/raw-data && go build -v
- @cd extras/libmemif/examples/icmp-responder && go build -v
- @cd extras/libmemif/examples/gopacket && go build -v
- @cd extras/libmemif/examples/jumbo-frames && go build -v
+ @echo "=> building extras"
+ cd extras/libmemif/examples/gopacket && go build -v
+ cd extras/libmemif/examples/icmp-responder && go build -v
+ cd extras/libmemif/examples/jumbo-frames && go build -v
+ cd extras/libmemif/examples/raw-data && go build -v
clean:
- @rm -f cmd/binapi-generator/binapi-generator
- @rm -f examples/cmd/simple-client/simple-client
- @rm -f examples/cmd/stats-client/stats-client
- @rm -f examples/cmd/perf-bench/perf-bench
- @rm -f extras/libmemif/examples/raw-data/raw-data
- @rm -f extras/libmemif/examples/icmp-responder/icmp-responder
+ @echo "=> cleaning"
+ rm -f cmd/binapi-generator/binapi-generator
+ rm -f examples/cmd/perf-bench/perf-bench
+ rm -f examples/cmd/simple-client/simple-client
+ rm -f examples/cmd/stats-client/stats-client
+ rm -f extras/libmemif/examples/gopacket/gopacket
+ rm -f extras/libmemif/examples/icmp-responder/icmp-responder
+ rm -f extras/libmemif/examples/jumbo-frames/jumbo-frames
+ rm -f extras/libmemif/examples/raw-data/raw-data
-generate:
- @cd core && go generate ./...
- @cd examples && go generate ./...
+generate: install
+ @echo "=> generating code"
+ cd examples && go generate ./...
lint:
+ @echo "=> running linter"
@golint ./... | grep -v vendor | grep -v bin_api || true
-.PHONY: build test install extras clean generate
+.PHONY: all \
+ install build examples test \
+ extras clean generate lint
diff --git a/adapter/adapter.go b/adapter/adapter.go
index 7d3d1e4..aa34329 100644
--- a/adapter/adapter.go
+++ b/adapter/adapter.go
@@ -22,7 +22,7 @@ import (
var ErrNotImplemented = errors.New("not implemented for this OS")
// MsgCallback defines func signature for message callback.
-type MsgCallback func(msgID uint16, context uint32, data []byte)
+type MsgCallback func(msgID uint16, data []byte)
// VppAdapter provides connection to VPP. It is responsible for sending and receiving of binary-encoded messages to/from VPP.
type VppAdapter interface {
diff --git a/adapter/mock/mock_adapter.go b/adapter/mock/mock_adapter.go
index 5ca190f..cdf2081 100644
--- a/adapter/mock/mock_adapter.go
+++ b/adapter/mock/mock_adapter.go
@@ -92,9 +92,9 @@ const (
// NewVppAdapter returns a new mock adapter.
func NewVppAdapter() *VppAdapter {
a := &VppAdapter{
+ msgIDSeq: 1000,
msgIDsToName: make(map[uint16]string),
msgNameToIds: make(map[string]uint16),
- msgIDSeq: 1000,
binAPITypes: make(map[string]reflect.Type),
}
a.registerBinAPITypes()
@@ -186,8 +186,7 @@ func (a *VppAdapter) ReplyBytes(request MessageDTO, reply api.Message) ([]byte,
if err != nil {
return nil, err
}
- err = struc.Pack(buf, reply)
- if err != nil {
+ if err = struc.Pack(buf, reply); err != nil {
return nil, err
}
@@ -245,7 +244,7 @@ func (a *VppAdapter) SendMsg(clientID uint32, data []byte) error {
Data: data,
})
if finished {
- a.callback(msgID, clientID, reply)
+ a.callback(msgID, reply)
return nil
}
}
@@ -276,7 +275,7 @@ func (a *VppAdapter) SendMsg(clientID uint32, data []byte) error {
struc.Pack(buf, &codec.VppOtherHeader{VlMsgID: msgID})
}
struc.Pack(buf, msg.Msg)
- a.callback(msgID, context, buf.Bytes())
+ a.callback(msgID, buf.Bytes())
}
a.replies = a.replies[1:]
@@ -295,7 +294,7 @@ func (a *VppAdapter) SendMsg(clientID uint32, data []byte) error {
msgID := uint16(defaultReplyMsgID)
struc.Pack(buf, &codec.VppReplyHeader{VlMsgID: msgID, Context: clientID})
struc.Pack(buf, &defaultReply{})
- a.callback(msgID, clientID, buf.Bytes())
+ a.callback(msgID, buf.Bytes())
}
return nil
}
diff --git a/adapter/vppapiclient/vppapiclient_adapter.go b/adapter/vppapiclient/vppapiclient_adapter.go
index 7aafa55..e62bccd 100644
--- a/adapter/vppapiclient/vppapiclient_adapter.go
+++ b/adapter/vppapiclient/vppapiclient_adapter.go
@@ -28,7 +28,7 @@ package vppapiclient
#include <arpa/inet.h>
#include <vpp-api/client/vppapiclient.h>
-extern void go_msg_callback(uint16_t msg_id, uint32_t context, void* data, size_t size);
+extern void go_msg_callback(uint16_t msg_id, void* data, size_t size);
typedef struct __attribute__((__packed__)) _req_header {
uint16_t msg_id;
@@ -38,14 +38,13 @@ typedef struct __attribute__((__packed__)) _req_header {
typedef struct __attribute__((__packed__)) _reply_header {
uint16_t msg_id;
- uint32_t context; // currently not all reply messages contain context field
} reply_header_t;
static void
govpp_msg_callback (unsigned char *data, int size)
{
reply_header_t *header = ((reply_header_t *)data);
- go_msg_callback(ntohs(header->msg_id), ntohl(header->context), data, size);
+ go_msg_callback(ntohs(header->msg_id), data, size);
}
static int
@@ -204,10 +203,10 @@ func fileExists(name string) bool {
}
//export go_msg_callback
-func go_msg_callback(msgID C.uint16_t, context C.uint32_t, data unsafe.Pointer, size C.size_t) {
+func go_msg_callback(msgID C.uint16_t, data unsafe.Pointer, size C.size_t) {
// convert unsafe.Pointer to byte slice
slice := &reflect.SliceHeader{Data: uintptr(data), Len: int(size), Cap: int(size)}
byteArr := *(*[]byte)(unsafe.Pointer(slice))
- vppClient.callback(uint16(msgID), uint32(context), byteArr)
+ vppClient.callback(uint16(msgID), byteArr)
}
diff --git a/api/api.go b/api/api.go
index 39fe60f..9b7f0ff 100644
--- a/api/api.go
+++ b/api/api.go
@@ -58,21 +58,6 @@ type DataType interface {
GetCrcString() string
}
-// MessageDecoder provides functionality for decoding binary data to generated API messages.
-type MessageDecoder interface {
- // DecodeMsg decodes binary-encoded data of a message into provided Message structure.
- DecodeMsg(data []byte, msg Message) error
-}
-
-// MessageIdentifier provides identification of generated API messages.
-type MessageIdentifier interface {
- // GetMessageID returns message identifier of given API message.
- GetMessageID(msg Message) (uint16, error)
-
- // LookupByID looks up message name and crc by ID
- LookupByID(msgID uint16) (Message, error)
-}
-
// ChannelProvider provides the communication channel with govpp core.
type ChannelProvider interface {
// NewAPIChannel returns a new channel for communication with VPP via govpp core.
@@ -86,9 +71,6 @@ type ChannelProvider interface {
// Channel provides methods for direct communication with VPP channel.
type Channel interface {
- // GetID returns channel's ID
- GetID() uint16
-
// SendRequest asynchronously sends a request to VPP. Returns a request context, that can be used to call ReceiveReply.
// In case of any errors by sending, the error will be delivered to ReplyChan (and returned by ReceiveReply).
SendRequest(msg Message) RequestCtx
@@ -101,10 +83,7 @@ type Channel interface {
// SubscribeNotification subscribes for receiving of the specified notification messages via provided Go channel.
// Note that the caller is responsible for creating the Go channel with preferred buffer size. If the channel's
// buffer is full, the notifications will not be delivered into it.
- SubscribeNotification(notifChan chan Message, msgFactory func() Message) (*NotifSubscription, error)
-
- // UnsubscribeNotification unsubscribes from receiving the notifications tied to the provided notification subscription.
- UnsubscribeNotification(subscription *NotifSubscription) error
+ SubscribeNotification(notifChan chan Message, event Message) (SubscriptionCtx, error)
// SetReplyTimeout sets the timeout for replies from VPP. It represents the maximum time the API waits for a reply
// from VPP before returning an error.
@@ -114,14 +93,14 @@ type Channel interface {
Close()
}
-// RequestCtx is helper interface which allows to receive reply on request context data
+// RequestCtx is helper interface which allows to receive reply on request.
type RequestCtx interface {
// ReceiveReply receives a reply from VPP (blocks until a reply is delivered from VPP, or until an error occurs).
// The reply will be decoded into the msg argument. Error will be returned if the response cannot be received or decoded.
ReceiveReply(msg Message) error
}
-// MultiRequestCtx is helper interface which allows to receive reply on multi-request context data
+// MultiRequestCtx is helper interface which allows to receive reply on multi-request.
type MultiRequestCtx interface {
// ReceiveReply receives a reply from VPP (blocks until a reply is delivered from VPP, or until an error occurs).
// The reply will be decoded into the msg argument. If the last reply has been already consumed, lastReplyReceived is
@@ -130,13 +109,13 @@ type MultiRequestCtx interface {
ReceiveReply(msg Message) (lastReplyReceived bool, err error)
}
-// NotifSubscription represents a subscription for delivery of specific notification messages.
-type NotifSubscription struct {
- NotifChan chan Message // channel where notification messages will be delivered to
- MsgFactory func() Message // function that returns a new instance of the specific message that is expected as a notification
- // TODO: use Message directly here, not a factory, eliminating need to allocation
+// SubscriptionCtx is helper interface which allows to control subscription for notification events.
+type SubscriptionCtx interface {
+ // Unsubscribe unsubscribes from receiving the notifications tied to the subscription context.
+ Unsubscribe() error
}
+// map of registered messages
var registeredMessages = make(map[string]Message)
// RegisterMessage is called from generated code to register message.
diff --git a/cmd/binapi-generator/generate.go b/cmd/binapi-generator/generate.go
index 33ab614..7cfe338 100644
--- a/cmd/binapi-generator/generate.go
+++ b/cmd/binapi-generator/generate.go
@@ -140,9 +140,9 @@ func generatePackage(ctx *context, w *bufio.Writer) error {
if len(ctx.packageData.Services) > 0 {
fmt.Fprintf(w, "/* Services */\n\n")
- fmt.Fprintf(w, "type %s interface {\n", "Services")
ctx.inputBuff = bytes.NewBuffer(ctx.inputData)
ctx.inputLine = 0
+ fmt.Fprintf(w, "type %s interface {\n", "Services")
for _, svc := range ctx.packageData.Services {
generateService(ctx, w, &svc)
}
@@ -171,23 +171,19 @@ func generatePackage(ctx *context, w *bufio.Writer) error {
// 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.Fprintf(w, "// source: %s\n", ctx.inputFile)
fmt.Fprintln(w)
fmt.Fprintln(w, "/*")
- fmt.Fprintf(w, "Package %s is a generated VPP binary API of the '%s' VPP module.\n", ctx.packageName, ctx.moduleName)
- fmt.Fprintln(w)
- fmt.Fprintln(w, "It is generated from this file:")
- fmt.Fprintf(w, "\t%s\n", filepath.Base(ctx.inputFile))
+ fmt.Fprintf(w, " Package %s is a generated from VPP binary API module '%s'.\n", ctx.packageName, ctx.moduleName)
fmt.Fprintln(w)
- fmt.Fprintln(w, "It contains these VPP binary API objects:")
-
+ fmt.Fprintln(w, " It contains following objects:")
var printObjNum = func(obj string, num int) {
if num > 0 {
if num > 1 {
obj += "s"
}
- fmt.Fprintf(w, "\t%d %s\n", num, obj)
+ fmt.Fprintf(w, "\t%3d %s\n", num, obj)
}
}
printObjNum("message", len(ctx.packageData.Messages))
@@ -195,7 +191,7 @@ func generateHeader(ctx *context, w io.Writer) {
printObjNum("enum", len(ctx.packageData.Enums))
printObjNum("union", len(ctx.packageData.Unions))
printObjNum("service", len(ctx.packageData.Services))
-
+ fmt.Fprintln(w)
fmt.Fprintln(w, "*/")
fmt.Fprintf(w, "package %s\n", ctx.packageName)
fmt.Fprintln(w)
@@ -209,6 +205,7 @@ func generateImports(ctx *context, w io.Writer) {
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 _ = struc.Pack\n")
fmt.Fprintf(w, "var _ = bytes.NewBuffer\n")
fmt.Fprintln(w)
@@ -241,7 +238,6 @@ func generateComment(ctx *context, w io.Writer, goName string, vppName string, o
// If no other non-whitespace character then we are at the message header.
if trimmed := strings.TrimSpace(line); trimmed == objTitle {
objFound = true
- fmt.Fprintf(w, "// Generated from '%s', line %d:\n", filepath.Base(ctx.inputFile), ctx.inputLine)
fmt.Fprintln(w, "//")
}
} else {
@@ -462,9 +458,6 @@ func generateMessage(ctx *context, w io.Writer, msg *Message) {
// generate message type getter method
generateMessageTypeGetter(w, name, msgType)
-
- // generate message factory
- generateMessageFactory(w, name)
}
// generateField writes generated code for the field into w
@@ -555,10 +548,3 @@ func generateMessageTypeGetter(w io.Writer, structName string, msgType MessageTy
}
fmt.Fprintln(w, "}")
}
-
-// generateMessageFactory generates message factory for the generated message into the provider writer
-func generateMessageFactory(w io.Writer, structName string) {
- fmt.Fprintln(w, "func New"+structName+"() api.Message {")
- fmt.Fprintln(w, "\treturn &"+structName+"{}")
- fmt.Fprintln(w, "}")
-}
diff --git a/codec/msg_codec.go b/codec/msg_codec.go
index 572e672..67628a4 100644
--- a/codec/msg_codec.go
+++ b/codec/msg_codec.go
@@ -53,13 +53,25 @@ type VppOtherHeader struct {
}
// EncodeMsg encodes provided `Message` structure into its binary-encoded data representation.
-func (*MsgCodec) EncodeMsg(msg api.Message, msgID uint16) ([]byte, error) {
+func (*MsgCodec) EncodeMsg(msg api.Message, msgID uint16) (data []byte, err error) {
if msg == nil {
return nil, errors.New("nil message passed in")
}
- // encode message header
+ // try to recover panic which might possibly occur in struc.Pack call
+ defer func() {
+ if r := recover(); r != nil {
+ var ok bool
+ if err, ok = r.(error); !ok {
+ err = fmt.Errorf("%v", r)
+ }
+ err = fmt.Errorf("panic occurred: %v", err)
+ }
+ }()
+
var header interface{}
+
+ // encode message header
switch msg.GetMessageType() {
case api.RequestMessage:
header = &VppRequestHeader{VlMsgID: msgID}
@@ -75,13 +87,13 @@ func (*MsgCodec) EncodeMsg(msg api.Message, msgID uint16) ([]byte, error) {
// encode message header
if err := struc.Pack(buf, header); err != nil {
- return nil, fmt.Errorf("unable to encode message header: %v, error %v", header, err)
+ return nil, fmt.Errorf("failed to encode message header: %+v, error: %v", header, err)
}
// encode message content
if reflect.TypeOf(msg).Elem().NumField() > 0 {
if err := struc.Pack(buf, msg); err != nil {
- return nil, fmt.Errorf("unable to encode message data: %v, error %v", header, err)
+ return nil, fmt.Errorf("failed to encode message data: %+v, error: %v", data, err)
}
}
@@ -94,8 +106,9 @@ func (*MsgCodec) DecodeMsg(data []byte, msg api.Message) error {
return errors.New("nil message passed in")
}
- // check which header is expected
var header interface{}
+
+ // check which header is expected
switch msg.GetMessageType() {
case api.RequestMessage:
header = new(VppRequestHeader)
@@ -111,12 +124,12 @@ func (*MsgCodec) DecodeMsg(data []byte, msg api.Message) error {
// decode message header
if err := struc.Unpack(buf, header); err != nil {
- return fmt.Errorf("unable to decode message header: %+v, error %v", data, err)
+ return fmt.Errorf("failed to decode message header: %+v, error: %v", header, err)
}
// decode message content
if err := struc.Unpack(buf, msg); err != nil {
- return fmt.Errorf("unable to decode message data: %+v, error %v", data, err)
+ return fmt.Errorf("failed to decode message data: %+v, error: %v", data, err)
}
return nil
@@ -127,17 +140,19 @@ func (*MsgCodec) DecodeMsgContext(data []byte, msg api.Message) (uint32, error)
return 0, errors.New("nil message passed in")
}
+ var header interface{}
var getContext func() uint32
// check which header is expected
- var header interface{}
switch msg.GetMessageType() {
case api.RequestMessage:
header = new(VppRequestHeader)
getContext = func() uint32 { return header.(*VppRequestHeader).Context }
+
case api.ReplyMessage:
header = new(VppReplyHeader)
getContext = func() uint32 { return header.(*VppReplyHeader).Context }
+
default:
return 0, nil
}
diff --git a/codec/msg_codec_test.go b/codec/msg_codec_test.go
new file mode 100644
index 0000000..cd1240e
--- /dev/null
+++ b/codec/msg_codec_test.go
@@ -0,0 +1,63 @@
+package codec
+
+import (
+ "bytes"
+ "testing"
+
+ "git.fd.io/govpp.git/api"
+)
+
+type MyMsg struct {
+ Index uint16
+ Label []byte `struc:"[16]byte"`
+ Port uint16
+}
+
+func (*MyMsg) GetMessageName() string {
+ return "my_msg"
+}
+func (*MyMsg) GetCrcString() string {
+ return "xxxxx"
+}
+func (*MyMsg) GetMessageType() api.MessageType {
+ return api.OtherMessage
+}
+
+func TestEncode(t *testing.T) {
+ tests := []struct {
+ name string
+ msg api.Message
+ msgID uint16
+ expData []byte
+ }{
+ {name: "basic",
+ msg: &MyMsg{Index: 1, Label: []byte("Abcdef"), Port: 1000},
+ msgID: 100,
+ expData: []byte{0x00, 0x64, 0x00, 0x01, 0x41, 0x62, 0x63, 0x64, 0x65, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xE8},
+ },
+ }
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ c := &MsgCodec{}
+
+ data, err := c.EncodeMsg(test.msg, test.msgID)
+ if err != nil {
+ t.Fatalf("expected nil error, got: %v", err)
+ }
+ if !bytes.Equal(data, test.expData) {
+ t.Fatalf("expected data: % 0X, got: % 0X", test.expData, data)
+ }
+ })
+ }
+}
+
+func TestEncodePanic(t *testing.T) {
+ c := &MsgCodec{}
+
+ msg := &MyMsg{Index: 1, Label: []byte("thisIsLongerThan16Bytes"), Port: 1000}
+
+ _, err := c.EncodeMsg(msg, 100)
+ if err == nil {
+ t.Fatalf("expected non-nil error, got: %v", err)
+ }
+}
diff --git a/core/channel.go b/core/channel.go
index 718f89c..a7d95fe 100644
--- a/core/channel.go
+++ b/core/channel.go
@@ -29,40 +29,20 @@ var (
ErrInvalidRequestCtx = errors.New("invalid request context")
)
-// requestCtx is a context for request with single reply
-type requestCtx struct {
- ch *channel
- seqNum uint16
-}
-
-// multiRequestCtx is a context for request with multiple responses
-type multiRequestCtx struct {
- ch *channel
- seqNum uint16
-}
-
-func (req *requestCtx) ReceiveReply(msg api.Message) error {
- if req == nil || req.ch == nil {
- return ErrInvalidRequestCtx
- }
-
- lastReplyReceived, err := req.ch.receiveReplyInternal(msg, req.seqNum)
- if err != nil {
- return err
- }
- if lastReplyReceived {
- return errors.New("multipart reply recieved while a single reply expected")
- }
-
- return nil
+// MessageCodec provides functionality for decoding binary data to generated API messages.
+type MessageCodec interface {
+ //EncodeMsg encodes message into binary data.
+ EncodeMsg(msg api.Message, msgID uint16) ([]byte, error)
+ // DecodeMsg decodes binary-encoded data of a message into provided Message structure.
+ DecodeMsg(data []byte, msg api.Message) error
}
-func (req *multiRequestCtx) ReceiveReply(msg api.Message) (lastReplyReceived bool, err error) {
- if req == nil || req.ch == nil {
- return false, ErrInvalidRequestCtx
- }
-
- return req.ch.receiveReplyInternal(msg, req.seqNum)
+// MessageIdentifier provides identification of generated API messages.
+type MessageIdentifier interface {
+ // GetMessageID returns message identifier of given API message.
+ GetMessageID(msg api.Message) (uint16, error)
+ // LookupByID looks up message name and crc by ID
+ LookupByID(msgID uint16) (api.Message, error)
}
// vppRequest is a request that will be sent to VPP.
@@ -81,27 +61,40 @@ type vppReply struct {
err error // in case of error, data is nil and this member contains error
}
-// NotifSubscribeRequest is a request to subscribe for delivery of specific notification messages.
-type subscriptionRequest struct {
- sub *api.NotifSubscription // subscription details
- subscribe bool // true if this is a request to subscribe
+// requestCtx is a context for request with single reply
+type requestCtx struct {
+ ch *Channel
+ seqNum uint16
+}
+
+// multiRequestCtx is a context for request with multiple responses
+type multiRequestCtx struct {
+ ch *Channel
+ seqNum uint16
+}
+
+// subscriptionCtx is a context of subscription for delivery of specific notification messages.
+type subscriptionCtx struct {
+ ch *Channel
+ notifChan chan api.Message // channel where notification messages will be delivered to
+ msgID uint16 // message ID for the subscribed event message
+ event api.Message // event message that this subscription is for
+ msgFactory func() api.Message // function that returns a new instance of the specific message that is expected as a notification
}
// channel is the main communication interface with govpp core. It contains four Go channels, one for sending the requests
// to VPP, one for receiving the replies from it and the same set for notifications. The user can access the Go channels
// via methods provided by Channel interface in this package. Do not use the same channel from multiple goroutines
// concurrently, otherwise the responses could mix! Use multiple channels instead.
-type channel struct {
- id uint16 // channel ID
+type Channel struct {
+ id uint16
+ conn *Connection
reqChan chan *vppRequest // channel for sending the requests to VPP
replyChan chan *vppReply // channel where VPP replies are delivered to
- notifSubsChan chan *subscriptionRequest // channel for sending notification subscribe requests
- notifSubsReplyChan chan error // channel where replies to notification subscribe requests are delivered to
-
- msgDecoder api.MessageDecoder // used to decode binary data to generated API messages
- msgIdentifier api.MessageIdentifier // used to retrieve message ID of a message
+ msgCodec MessageCodec // used to decode binary data to generated API messages
+ msgIdentifier MessageIdentifier // used to retrieve message ID of a message
lastSeqNum uint16 // sequence number of the last sent request
@@ -109,73 +102,142 @@ type channel struct {
replyTimeout time.Duration // maximum time that the API waits for a reply from VPP before returning an error, can be set with SetReplyTimeout
}
-func (ch *channel) GetID() uint16 {
+func newChannel(id uint16, conn *Connection, codec MessageCodec, identifier MessageIdentifier, reqSize, replySize int) *Channel {
+ return &Channel{
+ id: id,
+ conn: conn,
+ msgCodec: codec,
+ msgIdentifier: identifier,
+ reqChan: make(chan *vppRequest, reqSize),
+ replyChan: make(chan *vppReply, replySize),
+ replyTimeout: DefaultReplyTimeout,
+ }
+}
+
+func (ch *Channel) GetID() uint16 {
return ch.id
}
-func (ch *channel) nextSeqNum() uint16 {
+func (ch *Channel) nextSeqNum() uint16 {
ch.lastSeqNum++
return ch.lastSeqNum
}
-func (ch *channel) SendRequest(msg api.Message) api.RequestCtx {
- req := &vppRequest{
+func (ch *Channel) SendRequest(msg api.Message) api.RequestCtx {
+ seqNum := ch.nextSeqNum()
+ ch.reqChan <- &vppRequest{
msg: msg,
- seqNum: ch.nextSeqNum(),
+ seqNum: seqNum,
}
- ch.reqChan <- req
- return &requestCtx{ch: ch, seqNum: req.seqNum}
+ return &requestCtx{ch: ch, seqNum: seqNum}
}
-func (ch *channel) SendMultiRequest(msg api.Message) api.MultiRequestCtx {
- req := &vppRequest{
+func (ch *Channel) SendMultiRequest(msg api.Message) api.MultiRequestCtx {
+ seqNum := ch.nextSeqNum()
+ ch.reqChan <- &vppRequest{
msg: msg,
- seqNum: ch.nextSeqNum(),
+ seqNum: seqNum,
multi: true,
}
- ch.reqChan <- req
- return &multiRequestCtx{ch: ch, seqNum: req.seqNum}
+ return &multiRequestCtx{ch: ch, seqNum: seqNum}
}
-func (ch *channel) SubscribeNotification(notifChan chan api.Message, msgFactory func() api.Message) (*api.NotifSubscription, error) {
- sub := &api.NotifSubscription{
- NotifChan: notifChan,
- MsgFactory: msgFactory,
+func getMsgFactory(msg api.Message) func() api.Message {
+ return func() api.Message {
+ return reflect.New(reflect.TypeOf(msg).Elem()).Interface().(api.Message)
}
- // TODO: get rid of notifSubsChan and notfSubsReplyChan,
- // it's no longer need because we know all message IDs and can store subscription right here
- ch.notifSubsChan <- &subscriptionRequest{
- sub: sub,
- subscribe: true,
- }
- return sub, <-ch.notifSubsReplyChan
}
-func (ch *channel) UnsubscribeNotification(subscription *api.NotifSubscription) error {
- ch.notifSubsChan <- &subscriptionRequest{
- sub: subscription,
- subscribe: false,
+func (ch *Channel) SubscribeNotification(notifChan chan api.Message, event api.Message) (api.SubscriptionCtx, error) {
+ msgID, err := ch.msgIdentifier.GetMessageID(event)
+ if err != nil {
+ log.WithFields(logrus.Fields{
+ "msg_name": event.GetMessageName(),
+ "msg_crc": event.GetCrcString(),
+ }).Errorf("unable to retrieve message ID: %v", err)
+ return nil, fmt.Errorf("unable to retrieve event message ID: %v", err)
+ }
+
+ sub := &subscriptionCtx{
+ ch: ch,
+ notifChan: notifChan,
+ msgID: msgID,
+ event: event,
+ msgFactory: getMsgFactory(event),
}
- return <-ch.notifSubsReplyChan
+
+ // add the subscription into map
+ ch.conn.subscriptionsLock.Lock()
+ defer ch.conn.subscriptionsLock.Unlock()
+
+ ch.conn.subscriptions[msgID] = append(ch.conn.subscriptions[msgID], sub)
+
+ return sub, nil
}
-func (ch *channel) SetReplyTimeout(timeout time.Duration) {
+func (ch *Channel) SetReplyTimeout(timeout time.Duration) {
ch.replyTimeout = timeout
}
-func (ch *channel) Close() {
+func (ch *Channel) Close() {
if ch.reqChan != nil {
close(ch.reqChan)
+ ch.reqChan = nil
+ }
+}
+
+func (req *requestCtx) ReceiveReply(msg api.Message) error {
+ if req == nil || req.ch == nil {
+ return ErrInvalidRequestCtx
+ }
+
+ lastReplyReceived, err := req.ch.receiveReplyInternal(msg, req.seqNum)
+ if err != nil {
+ return err
+ } else if lastReplyReceived {
+ return errors.New("multipart reply recieved while a single reply expected")
+ }
+
+ return nil
+}
+
+func (req *multiRequestCtx) ReceiveReply(msg api.Message) (lastReplyReceived bool, err error) {
+ if req == nil || req.ch == nil {
+ return false, ErrInvalidRequestCtx
}
+
+ return req.ch.receiveReplyInternal(msg, req.seqNum)
+}
+
+func (sub *subscriptionCtx) Unsubscribe() error {
+ log.WithFields(logrus.Fields{
+ "msg_name": sub.event.GetMessageName(),
+ "msg_id": sub.msgID,
+ }).Debug("Removing notification subscription.")
+
+ // remove the subscription from the map
+ sub.ch.conn.subscriptionsLock.Lock()
+ defer sub.ch.conn.subscriptionsLock.Unlock()
+
+ for i, item := range sub.ch.conn.subscriptions[sub.msgID] {
+ if item == sub {
+ // remove i-th item in the slice
+ sub.ch.conn.subscriptions[sub.msgID] = append(sub.ch.conn.subscriptions[sub.msgID][:i], sub.ch.conn.subscriptions[sub.msgID][i+1:]...)
+ return nil
+ }
+ }
+
+ return fmt.Errorf("subscription for %q not found", sub.event.GetMessageName())
}
// receiveReplyInternal receives a reply from the reply channel into the provided msg structure.
-func (ch *channel) receiveReplyInternal(msg api.Message, expSeqNum uint16) (lastReplyReceived bool, err error) {
- var ignore bool
+func (ch *Channel) receiveReplyInternal(msg api.Message, expSeqNum uint16) (lastReplyReceived bool, err error) {
if msg == nil {
return false, errors.New("nil message passed in")
}
+ var ignore bool
+
if vppReply := ch.delayedReply; vppReply != nil {
// try the delayed reply
ch.delayedReply = nil
@@ -204,12 +266,12 @@ func (ch *channel) receiveReplyInternal(msg api.Message, expSeqNum uint16) (last
return
}
-func (ch *channel) processReply(reply *vppReply, expSeqNum uint16, msg api.Message) (ignore bool, lastReplyReceived bool, err error) {
+func (ch *Channel) processReply(reply *vppReply, expSeqNum uint16, msg api.Message) (ignore bool, lastReplyReceived bool, err error) {
// check the sequence number
cmpSeqNums := compareSeqNumbers(reply.seqNum, expSeqNum)
if cmpSeqNums == -1 {
// reply received too late, ignore the message
- logrus.WithField("sequence-number", reply.seqNum).Warn(
+ logrus.WithField("seqNum", reply.seqNum).Warn(
"Received reply to an already closed binary API request")
ignore = true
return
@@ -253,7 +315,7 @@ func (ch *channel) processReply(reply *vppReply, expSeqNum uint16, msg api.Messa
}
// decode the message
- if err = ch.msgDecoder.DecodeMsg(reply.data, msg); err != nil {
+ if err = ch.msgCodec.DecodeMsg(reply.data, msg); err != nil {
return
}
diff --git a/core/channel_test.go b/core/channel_test.go
index 4a9ab2b..b06e3e9 100644
--- a/core/channel_test.go
+++ b/core/channel_test.go
@@ -22,6 +22,7 @@ import (
"git.fd.io/govpp.git/examples/bin_api/interfaces"
"git.fd.io/govpp.git/examples/bin_api/memif"
"git.fd.io/govpp.git/examples/bin_api/tap"
+ "git.fd.io/govpp.git/examples/bin_api/vpe"
"git.fd.io/govpp.git/api"
. "github.com/onsi/gomega"
@@ -59,10 +60,11 @@ func TestRequestReplyTapConnect(t *testing.T) {
ctx := setupTest(t)
defer ctx.teardownTest()
+ // mock reply
ctx.mockVpp.MockReply(&tap.TapConnectReply{
- Retval: 0,
SwIfIndex: 1,
})
+
request := &tap.TapConnect{
TapName: []byte("test-tap-name"),
UseRandomMac: 1,
@@ -71,17 +73,21 @@ func TestRequestReplyTapConnect(t *testing.T) {
err := ctx.ch.SendRequest(request).ReceiveReply(reply)
Expect(err).ShouldNot(HaveOccurred())
- Expect(reply.Retval).To(BeEquivalentTo(0), "Incorrect retval value for TapConnectReply")
- Expect(reply.SwIfIndex).To(BeEquivalentTo(1), "Incorrect SwIfIndex value for TapConnectReply")
+ Expect(reply.Retval).To(BeEquivalentTo(0),
+ "Incorrect Retval value for TapConnectReply")
+ Expect(reply.SwIfIndex).To(BeEquivalentTo(1),
+ "Incorrect SwIfIndex value for TapConnectReply")
}
func TestRequestReplyTapModify(t *testing.T) {
ctx := setupTest(t)
defer ctx.teardownTest()
+ // mock reply
ctx.mockVpp.MockReply(&tap.TapModifyReply{
SwIfIndex: 2,
})
+
request := &tap.TapModify{
TapName: []byte("test-tap-modify"),
UseRandomMac: 1,
@@ -91,15 +97,19 @@ func TestRequestReplyTapModify(t *testing.T) {
err := ctx.ch.SendRequest(request).ReceiveReply(reply)
Expect(err).ShouldNot(HaveOccurred())
- Expect(reply.Retval).To(BeEquivalentTo(0), "Incorrect retval value for TapModifyReply")
- Expect(reply.SwIfIndex).To(BeEquivalentTo(2), "Incorrect SwIfIndex value for TapModifyReply")
+ Expect(reply.Retval).To(BeEquivalentTo(0),
+ "Incorrect Retval value for TapModifyReply")
+ Expect(reply.SwIfIndex).To(BeEquivalentTo(2),
+ "Incorrect SwIfIndex value for TapModifyReply")
}
func TestRequestReplyTapDelete(t *testing.T) {
ctx := setupTest(t)
defer ctx.teardownTest()
+ // mock reply
ctx.mockVpp.MockReply(&tap.TapDeleteReply{})
+
request := &tap.TapDelete{
SwIfIndex: 3,
}
@@ -107,34 +117,41 @@ func TestRequestReplyTapDelete(t *testing.T) {
err := ctx.ch.SendRequest(request).ReceiveReply(reply)
Expect(err).ShouldNot(HaveOccurred())
- Expect(reply.Retval).To(BeEquivalentTo(0), "Incorrect retval value for TapDeleteReply")
+ Expect(reply.Retval).To(BeEquivalentTo(0),
+ "Incorrect Retval value for TapDeleteReply")
}
func TestRequestReplySwInterfaceTapDump(t *testing.T) {
ctx := setupTest(t)
defer ctx.teardownTest()
+ // mock reply
byteName := []byte("dev-name-test")
ctx.mockVpp.MockReply(&tap.SwInterfaceTapDetails{
SwIfIndex: 25,
DevName: byteName,
})
+
request := &tap.SwInterfaceTapDump{}
reply := &tap.SwInterfaceTapDetails{}
err := ctx.ch.SendRequest(request).ReceiveReply(reply)
Expect(err).ShouldNot(HaveOccurred())
- Expect(reply.SwIfIndex).To(BeEquivalentTo(25), "Incorrect SwIfIndex value for SwInterfaceTapDetails")
- Expect(reply.DevName).ToNot(BeNil(), "Incorrect DevName value for SwInterfaceTapDetails")
+ Expect(reply.SwIfIndex).To(BeEquivalentTo(25),
+ "Incorrect SwIfIndex value for SwInterfaceTapDetails")
+ Expect(reply.DevName).ToNot(BeEquivalentTo(byteName),
+ "Incorrect DevName value for SwInterfaceTapDetails")
}
func TestRequestReplyMemifCreate(t *testing.T) {
ctx := setupTest(t)
defer ctx.teardownTest()
+ // mock reply
ctx.mockVpp.MockReply(&memif.MemifCreateReply{
SwIfIndex: 4,
})
+
request := &memif.MemifCreate{
Role: 10,
ID: 12,
@@ -145,15 +162,19 @@ func TestRequestReplyMemifCreate(t *testing.T) {
err := ctx.ch.SendRequest(request).ReceiveReply(reply)
Expect(err).ShouldNot(HaveOccurred())
- Expect(reply.Retval).To(BeEquivalentTo(0), "Incorrect Retval value for MemifCreate")
- Expect(reply.SwIfIndex).To(BeEquivalentTo(4), "Incorrect SwIfIndex value for MemifCreate")
+ Expect(reply.Retval).To(BeEquivalentTo(0),
+ "Incorrect Retval value for MemifCreate")
+ Expect(reply.SwIfIndex).To(BeEquivalentTo(4),
+ "Incorrect SwIfIndex value for MemifCreate")
}
func TestRequestReplyMemifDelete(t *testing.T) {
ctx := setupTest(t)
defer ctx.teardownTest()
+ // mock reply
ctx.mockVpp.MockReply(&memif.MemifDeleteReply{})
+
request := &memif.MemifDelete{
SwIfIndex: 15,
}
@@ -161,26 +182,30 @@ func TestRequestReplyMemifDelete(t *testing.T) {
err := ctx.ch.SendRequest(request).ReceiveReply(reply)
Expect(err).ShouldNot(HaveOccurred())
- Expect(reply.Retval).To(BeEquivalentTo(0), "Incorrect Retval value for MemifDelete")
}
func TestRequestReplyMemifDetails(t *testing.T) {
ctx := setupTest(t)
defer ctx.teardownTest()
+ // mock reply
ctx.mockVpp.MockReply(&memif.MemifDetails{
SwIfIndex: 25,
IfName: []byte("memif-name"),
Role: 0,
})
+
request := &memif.MemifDump{}
reply := &memif.MemifDetails{}
err := ctx.ch.SendRequest(request).ReceiveReply(reply)
Expect(err).ShouldNot(HaveOccurred())
- Expect(reply.SwIfIndex).To(BeEquivalentTo(25), "Incorrect SwIfIndex value for MemifDetails")
- Expect(reply.IfName).ToNot(BeEmpty(), "MemifDetails IfName is empty byte array")
- Expect(reply.Role).To(BeEquivalentTo(0), "Incorrect Role value for MemifDetails")
+ Expect(reply.SwIfIndex).To(BeEquivalentTo(25),
+ "Incorrect SwIfIndex value for MemifDetails")
+ Expect(reply.IfName).ToNot(BeEmpty(),
+ "MemifDetails IfName is empty byte array")
+ Expect(reply.Role).To(BeEquivalentTo(0),
+ "Incorrect Role value for MemifDetails")
}
func TestMultiRequestReplySwInterfaceTapDump(t *testing.T) {
@@ -204,7 +229,7 @@ func TestMultiRequestReplySwInterfaceTapDump(t *testing.T) {
msg := &tap.SwInterfaceTapDetails{}
stop, err := reqCtx.ReceiveReply(msg)
if stop {
- break // break out of the loop
+ break
}
Expect(err).ShouldNot(HaveOccurred())
cnt++
@@ -232,7 +257,7 @@ func TestMultiRequestReplySwInterfaceMemifDump(t *testing.T) {
msg := &memif.MemifDetails{}
stop, err := reqCtx.ReceiveReply(msg)
if stop {
- break // break out of the loop
+ break
}
Expect(err).ShouldNot(HaveOccurred())
cnt++
@@ -240,51 +265,16 @@ func TestMultiRequestReplySwInterfaceMemifDump(t *testing.T) {
Expect(cnt).To(BeEquivalentTo(10))
}
-func TestNotifications(t *testing.T) {
- ctx := setupTest(t)
- defer ctx.teardownTest()
-
- // subscribe for notification
- notifChan := make(chan api.Message, 1)
- subs, err := ctx.ch.SubscribeNotification(notifChan, interfaces.NewSwInterfaceSetFlags)
- Expect(err).ShouldNot(HaveOccurred())
-
- // mock the notification and force its delivery
- ctx.mockVpp.MockReply(&interfaces.SwInterfaceSetFlags{
- SwIfIndex: 3,
- AdminUpDown: 1,
- })
- ctx.mockVpp.SendMsg(0, []byte(""))
-
- // receive the notification
- var notif *interfaces.SwInterfaceSetFlags
- Eventually(func() *interfaces.SwInterfaceSetFlags {
- select {
- case n := <-notifChan:
- notif = n.(*interfaces.SwInterfaceSetFlags)
- return notif
- default:
- return nil
- }
- }).ShouldNot(BeNil())
-
- // verify the received notifications
- Expect(notif.SwIfIndex).To(BeEquivalentTo(3), "Incorrect SwIfIndex value for SwInterfaceSetFlags")
- Expect(notif.AdminUpDown).To(BeEquivalentTo(1), "Incorrect AdminUpDown value for SwInterfaceSetFlags")
-
- ctx.ch.UnsubscribeNotification(subs)
-}
-
func TestNotificationEvent(t *testing.T) {
ctx := setupTest(t)
defer ctx.teardownTest()
// subscribe for notification
notifChan := make(chan api.Message, 1)
- subs, err := ctx.ch.SubscribeNotification(notifChan, interfaces.NewSwInterfaceEvent)
+ sub, err := ctx.ch.SubscribeNotification(notifChan, &interfaces.SwInterfaceEvent{})
Expect(err).ShouldNot(HaveOccurred())
- // mock the notification and force its delivery
+ // mock event and force its delivery
ctx.mockVpp.MockReply(&interfaces.SwInterfaceEvent{
SwIfIndex: 2,
LinkUpDown: 1,
@@ -307,16 +297,9 @@ func TestNotificationEvent(t *testing.T) {
Expect(notif.SwIfIndex).To(BeEquivalentTo(2), "Incorrect SwIfIndex value for SwInterfaceSetFlags")
Expect(notif.LinkUpDown).To(BeEquivalentTo(1), "Incorrect LinkUpDown value for SwInterfaceSetFlags")
- ctx.ch.UnsubscribeNotification(subs)
-}
-
-/*func TestCheckMessageCompatibility(t *testing.T) {
- ctx := setupTest(t)
- defer ctx.teardownTest()
-
- err := ctx.ch.CheckMessageCompatibility(&interfaces.SwInterfaceSetFlags{})
+ err = sub.Unsubscribe()
Expect(err).ShouldNot(HaveOccurred())
-}*/
+}
func TestSetReplyTimeout(t *testing.T) {
ctx := setupTest(t)
@@ -324,8 +307,10 @@ func TestSetReplyTimeout(t *testing.T) {
ctx.ch.SetReplyTimeout(time.Millisecond)
- // first one request should work
+ // mock reply
ctx.mockVpp.MockReply(&ControlPingReply{})
+
+ // first one request should work
err := ctx.ch.SendRequest(&ControlPing{}).ReceiveReply(&ControlPingReply{})
Expect(err).ShouldNot(HaveOccurred())
@@ -339,16 +324,23 @@ func TestSetReplyTimeoutMultiRequest(t *testing.T) {
ctx := setupTest(t)
defer ctx.teardownTest()
- ctx.ch.SetReplyTimeout(time.Millisecond)
+ ctx.ch.SetReplyTimeout(time.Millisecond * 100)
- var msgs []api.Message
- for i := 1; i <= 3; i++ {
- msgs = append(msgs, &interfaces.SwInterfaceDetails{
- SwIfIndex: uint32(i),
+ // mock reply
+ ctx.mockVpp.MockReply(
+ &interfaces.SwInterfaceDetails{
+ SwIfIndex: 1,
InterfaceName: []byte("if-name-test"),
- })
- }
- ctx.mockVpp.MockReply(msgs...)
+ },
+ &interfaces.SwInterfaceDetails{
+ SwIfIndex: 2,
+ InterfaceName: []byte("if-name-test"),
+ },
+ &interfaces.SwInterfaceDetails{
+ SwIfIndex: 3,
+ InterfaceName: []byte("if-name-test"),
+ },
+ )
ctx.mockVpp.MockReply(&ControlPingReply{})
cnt := 0
@@ -357,12 +349,12 @@ func TestSetReplyTimeoutMultiRequest(t *testing.T) {
for {
msg := &interfaces.SwInterfaceDetails{}
stop, err := reqCtx.ReceiveReply(msg)
- if stop {
- break // break out of the loop
- }
if err != nil {
return err
}
+ if stop {
+ break
+ }
cnt++
}
return nil
@@ -443,7 +435,7 @@ func TestMultiRequestDouble(t *testing.T) {
msg := &interfaces.SwInterfaceDetails{}
stop, err := reqCtx.ReceiveReply(msg)
if stop {
- break // break out of the loop
+ break
}
if err != nil {
return err
@@ -468,8 +460,10 @@ func TestReceiveReplyAfterTimeout(t *testing.T) {
ctx.ch.SetReplyTimeout(time.Millisecond)
- // first one request should work
+ // mock reply
ctx.mockVpp.MockReplyWithContext(mock.MsgWithContext{Msg: &ControlPingReply{}, SeqNum: 1})
+ // first one request should work
+
err := ctx.ch.SendRequest(&ControlPing{}).ReceiveReply(&ControlPingReply{})
Expect(err).ShouldNot(HaveOccurred())
@@ -479,9 +473,16 @@ func TestReceiveReplyAfterTimeout(t *testing.T) {
ctx.mockVpp.MockReplyWithContext(
// simulating late reply
- mock.MsgWithContext{Msg: &ControlPingReply{}, SeqNum: 2},
+ mock.MsgWithContext{
+ Msg: &ControlPingReply{},
+ SeqNum: 2,
+ },
// normal reply for next request
- mock.MsgWithContext{Msg: &tap.TapConnectReply{}, SeqNum: 3})
+ mock.MsgWithContext{
+ Msg: &tap.TapConnectReply{},
+ SeqNum: 3,
+ },
+ )
req := &tap.TapConnect{
TapName: []byte("test-tap-name"),
@@ -508,8 +509,10 @@ func TestReceiveReplyAfterTimeoutMultiRequest(t *testing.T) {
ctx.ch.SetReplyTimeout(time.Millisecond * 100)
- // first one request should work
+ // mock reply
ctx.mockVpp.MockReplyWithContext(mock.MsgWithContext{Msg: &ControlPingReply{}, SeqNum: 1})
+
+ // first one request should work
err := ctx.ch.SendRequest(&ControlPing{}).ReceiveReply(&ControlPingReply{})
Expect(err).ShouldNot(HaveOccurred())
@@ -520,7 +523,7 @@ func TestReceiveReplyAfterTimeoutMultiRequest(t *testing.T) {
msg := &interfaces.SwInterfaceDetails{}
stop, err := reqCtx.ReceiveReply(msg)
if stop {
- break // break out of the loop
+ break
}
if err != nil {
return err
@@ -564,18 +567,20 @@ func TestReceiveReplyAfterTimeoutMultiRequest(t *testing.T) {
Expect(err).ShouldNot(HaveOccurred())
}
-/*func TestInvalidMessageID(t *testing.T) {
+func TestInvalidMessageID(t *testing.T) {
ctx := setupTest(t)
defer ctx.teardownTest()
- // first one request should work
+ // mock reply
+ ctx.mockVpp.MockReply(&vpe.ShowVersionReply{})
ctx.mockVpp.MockReply(&vpe.ShowVersionReply{})
+
+ // first one request should work
err := ctx.ch.SendRequest(&vpe.ShowVersion{}).ReceiveReply(&vpe.ShowVersionReply{})
Expect(err).ShouldNot(HaveOccurred())
// second should fail with error invalid message ID
- ctx.mockVpp.MockReply(&vpe.ShowVersionReply{})
err = ctx.ch.SendRequest(&ControlPing{}).ReceiveReply(&ControlPingReply{})
Expect(err).Should(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("invalid message ID"))
-}*/
+}
diff --git a/core/connection.go b/core/connection.go
index c77358f..7d014ce 100644
--- a/core/connection.go
+++ b/core/connection.go
@@ -29,42 +29,19 @@ import (
"git.fd.io/govpp.git/codec"
)
-const (
- requestChannelBufSize = 100 // default size of the request channel buffer
- replyChannelBufSize = 100 // default size of the reply channel buffer
- notificationChannelBufSize = 100 // default size of the notification channel buffer
-
- defaultReplyTimeout = time.Second * 1 // default timeout for replies from VPP, can be changed with SetReplyTimeout
+var (
+ RequestChanBufSize = 100 // default size of the request channel buffer
+ ReplyChanBufSize = 100 // default size of the reply channel buffer
+ NotificationChanBufSize = 100 // default size of the notification channel buffer
)
var (
- healthCheckInterval = time.Second * 1 // default health check interval
- healthCheckReplyTimeout = time.Millisecond * 100 // timeout for reply to a health check
- healthCheckThreshold = 1 // number of failed health checks until the error is reported
+ HealthCheckProbeInterval = time.Second * 1 // default health check probe interval
+ HealthCheckReplyTimeout = time.Millisecond * 100 // timeout for reply to a health check probe
+ HealthCheckThreshold = 1 // number of failed health checks until the error is reported
+ DefaultReplyTimeout = time.Second * 1 // default timeout for replies from VPP
)
-// SetHealthCheckProbeInterval sets health check probe interval.
-// Beware: Function is not thread-safe. It is recommended to setup this parameter
-// before connecting to vpp.
-func SetHealthCheckProbeInterval(interval time.Duration) {
- healthCheckInterval = interval
-}
-
-// SetHealthCheckReplyTimeout sets timeout for reply to a health check probe.
-// If reply arrives after the timeout, check is considered as failed.
-// Beware: Function is not thread-safe. It is recommended to setup this parameter
-// before connecting to vpp.
-func SetHealthCheckReplyTimeout(timeout time.Duration) {
- healthCheckReplyTimeout = timeout
-}
-
-// SetHealthCheckThreshold sets the number of failed healthProbe checks until the error is reported.
-// Beware: Function is not thread-safe. It is recommended to setup this parameter
-// before connecting to vpp.
-func SetHealthCheckThreshold(threshold int) {
- healthCheckThreshold = threshold
-}
-
// ConnectionState represents the current state of the connection to VPP.
type ConnectionState int
@@ -104,10 +81,10 @@ type Connection struct {
maxChannelID uint32 // maximum used channel ID (the real limit is 2^15, 32-bit is used for atomic operations)
channelsLock sync.RWMutex // lock for the channels map
- channels map[uint16]*channel // map of all API channels indexed by the channel ID
+ channels map[uint16]*Channel // map of all API channels indexed by the channel ID
- notifSubscriptionsLock sync.RWMutex // lock for the subscriptions map
- notifSubscriptions map[uint16][]*api.NotifSubscription // map od all notification subscriptions indexed by message ID
+ subscriptionsLock sync.RWMutex // lock for the subscriptions map
+ subscriptions map[uint16][]*subscriptionCtx // map od all notification subscriptions indexed by message ID
pingReqID uint16 // ID if the ControlPing message
pingReplyID uint16 // ID of the ControlPingReply message
@@ -116,18 +93,30 @@ type Connection struct {
lastReply time.Time // time of the last received reply from VPP
}
+func newConnection(vpp adapter.VppAdapter) *Connection {
+ c := &Connection{
+ vpp: vpp,
+ codec: &codec.MsgCodec{},
+ msgIDs: make(map[string]uint16),
+ msgMap: make(map[uint16]api.Message),
+ channels: make(map[uint16]*Channel),
+ subscriptions: make(map[uint16][]*subscriptionCtx),
+ }
+ vpp.SetMsgCallback(c.msgCallback)
+ return c
+}
+
// Connect connects to VPP using specified VPP adapter and returns the connection handle.
// This call blocks until VPP is connected, or an error occurs. Only one connection attempt will be performed.
func Connect(vppAdapter adapter.VppAdapter) (*Connection, error) {
// create new connection handle
- c, err := newConnection(vppAdapter)
+ c, err := createConnection(vppAdapter)
if err != nil {
return nil, err
}
// blocking attempt to connect to VPP
- err = c.connectVPP()
- if err != nil {
+ if err := c.connectVPP(); err != nil {
return nil, err
}
@@ -140,13 +129,13 @@ func Connect(vppAdapter adapter.VppAdapter) (*Connection, error) {
// Connected/Disconnected events. In case of disconnect, the library will asynchronously try to reconnect.
func AsyncConnect(vppAdapter adapter.VppAdapter) (*Connection, chan ConnectionEvent, error) {
// create new connection handle
- c, err := newConnection(vppAdapter)
+ c, err := createConnection(vppAdapter)
if err != nil {
return nil, nil, err
}
// asynchronously attempt to connect to VPP
- connChan := make(chan ConnectionEvent, notificationChannelBufSize)
+ connChan := make(chan ConnectionEvent, NotificationChanBufSize)
go c.connectLoop(connChan)
return c, connChan, nil
@@ -168,7 +157,7 @@ func (c *Connection) Disconnect() {
}
// newConnection returns new connection handle.
-func newConnection(vppAdapter adapter.VppAdapter) (*Connection, error) {
+func createConnection(vppAdapter adapter.VppAdapter) (*Connection, error) {
connLock.Lock()
defer connLock.Unlock()
@@ -176,15 +165,7 @@ func newConnection(vppAdapter adapter.VppAdapter) (*Connection, error) {
return nil, errors.New("only one connection per process is supported")
}
- conn = &Connection{
- vpp: vppAdapter,
- codec: &codec.MsgCodec{},
- channels: make(map[uint16]*channel),
- msgIDs: make(map[string]uint16),
- msgMap: make(map[uint16]api.Message),
- notifSubscriptions: make(map[uint16][]*api.NotifSubscription),
- }
- conn.vpp.SetMsgCallback(conn.msgCallback)
+ conn = newConnection(vppAdapter)
return conn, nil
}
@@ -211,8 +192,72 @@ func (c *Connection) connectVPP() error {
return nil
}
-func getMsgNameWithCrc(x api.Message) string {
- return x.GetMessageName() + "_" + x.GetCrcString()
+func (c *Connection) NewAPIChannel() (api.Channel, error) {
+ return c.newAPIChannel(RequestChanBufSize, ReplyChanBufSize)
+}
+
+func (c *Connection) NewAPIChannelBuffered(reqChanBufSize, replyChanBufSize int) (api.Channel, error) {
+ return c.newAPIChannel(reqChanBufSize, replyChanBufSize)
+}
+
+// NewAPIChannelBuffered returns a new API channel for communication with VPP via govpp core.
+// It allows to specify custom buffer sizes for the request and reply Go channels.
+func (c *Connection) newAPIChannel(reqChanBufSize, replyChanBufSize int) (*Channel, error) {
+ if c == nil {
+ return nil, errors.New("nil connection passed in")
+ }
+
+ // create new channel
+ chID := uint16(atomic.AddUint32(&c.maxChannelID, 1) & 0x7fff)
+ channel := newChannel(chID, c, c.codec, c, reqChanBufSize, replyChanBufSize)
+
+ // store API channel within the client
+ c.channelsLock.Lock()
+ c.channels[chID] = channel
+ c.channelsLock.Unlock()
+
+ // start watching on the request channel
+ go c.watchRequests(channel)
+
+ return channel, nil
+}
+
+// releaseAPIChannel releases API channel that needs to be closed.
+func (c *Connection) releaseAPIChannel(ch *Channel) {
+ log.WithFields(logger.Fields{
+ "channel": ch.id,
+ }).Debug("API channel released")
+
+ // delete the channel from channels map
+ c.channelsLock.Lock()
+ delete(c.channels, ch.id)
+ c.channelsLock.Unlock()
+}
+
+// GetMessageID returns message identifier of given API message.
+func (c *Connection) GetMessageID(msg api.Message) (uint16, error) {
+ if c == nil {
+ return 0, errors.New("nil connection passed in")
+ }
+
+ if msgID, ok := c.msgIDs[getMsgNameWithCrc(msg)]; ok {
+ return msgID, nil
+ }
+
+ return 0, fmt.Errorf("unknown message: %s (%s)", msg.GetMessageName(), msg.GetCrcString())
+}
+
+// LookupByID looks up message name and crc by ID.
+func (c *Connection) LookupByID(msgID uint16) (api.Message, error) {
+ if c == nil {
+ return nil, errors.New("nil connection passed in")
+ }
+
+ if msg, ok := c.msgMap[msgID]; ok {
+ return msg, nil
+ }
+
+ return nil, fmt.Errorf("unknown message ID: %d", msgID)
}
// retrieveMessageIDs retrieves IDs for all registered messages and stores them in map
@@ -268,32 +313,6 @@ func (c *Connection) retrieveMessageIDs() (err error) {
return nil
}
-// GetMessageID returns message identifier of given API message.
-func (c *Connection) GetMessageID(msg api.Message) (uint16, error) {
- if c == nil {
- return 0, errors.New("nil connection passed in")
- }
-
- if msgID, ok := c.msgIDs[getMsgNameWithCrc(msg)]; ok {
- return msgID, nil
- }
-
- return 0, fmt.Errorf("unknown message: %s (%s)", msg.GetMessageName(), msg.GetCrcString())
-}
-
-// LookupByID looks up message name and crc by ID.
-func (c *Connection) LookupByID(msgID uint16) (api.Message, error) {
- if c == nil {
- return nil, errors.New("nil connection passed in")
- }
-
- if msg, ok := c.msgMap[msgID]; ok {
- return msg, nil
- }
-
- return nil, fmt.Errorf("unknown message ID: %d", msgID)
-}
-
// disconnectVPP disconnects from VPP in case it is connected.
func (c *Connection) disconnectVPP() {
if atomic.CompareAndSwapUint32(&c.connected, 1, 0) {
@@ -341,7 +360,7 @@ func (c *Connection) healthCheckLoop(connChan chan ConnectionEvent) {
// send health check probes until an error or timeout occurs
for {
// sleep until next health check probe period
- time.Sleep(healthCheckInterval)
+ time.Sleep(HealthCheckProbeInterval)
if atomic.LoadUint32(&c.connected) == 0 {
// Disconnect has been called in the meantime, return the healthcheck - reconnect loop
@@ -365,7 +384,7 @@ func (c *Connection) healthCheckLoop(connChan chan ConnectionEvent) {
case vppReply := <-ch.replyChan:
err = vppReply.err
- case <-time.After(healthCheckReplyTimeout):
+ case <-time.After(HealthCheckReplyTimeout):
err = ErrProbeTimeout
// check if time since last reply from any other
@@ -374,7 +393,7 @@ func (c *Connection) healthCheckLoop(connChan chan ConnectionEvent) {
sinceLastReply = time.Since(c.lastReply)
c.lastReplyLock.Unlock()
- if sinceLastReply < healthCheckReplyTimeout {
+ if sinceLastReply < HealthCheckReplyTimeout {
log.Warnf("VPP health check probe timing out, but some request on other channel was received %v ago, continue waiting!", sinceLastReply)
continue
}
@@ -384,10 +403,10 @@ func (c *Connection) healthCheckLoop(connChan chan ConnectionEvent) {
if err == ErrProbeTimeout {
failedChecks++
- log.Warnf("VPP health check probe timed out after %v (%d. timeout)", healthCheckReplyTimeout, failedChecks)
- if failedChecks > healthCheckThreshold {
+ log.Warnf("VPP health check probe timed out after %v (%d. timeout)", HealthCheckReplyTimeout, failedChecks)
+ if failedChecks > HealthCheckThreshold {
// in case of exceeded failed check treshold, assume VPP disconnected
- log.Errorf("VPP health check exceeded treshold for timeouts (>%d), assuming disconnect", healthCheckThreshold)
+ log.Errorf("VPP health check exceeded treshold for timeouts (>%d), assuming disconnect", HealthCheckThreshold)
connChan <- ConnectionEvent{Timestamp: time.Now(), State: Disconnected}
break
}
@@ -411,52 +430,6 @@ func (c *Connection) healthCheckLoop(connChan chan ConnectionEvent) {
c.connectLoop(connChan)
}
-func (c *Connection) NewAPIChannel() (api.Channel, error) {
- return c.newAPIChannel(requestChannelBufSize, replyChannelBufSize)
-}
-
-func (c *Connection) NewAPIChannelBuffered(reqChanBufSize, replyChanBufSize int) (api.Channel, error) {
- return c.newAPIChannel(reqChanBufSize, replyChanBufSize)
-}
-
-// NewAPIChannelBuffered returns a new API channel for communication with VPP via govpp core.
-// It allows to specify custom buffer sizes for the request and reply Go channels.
-func (c *Connection) newAPIChannel(reqChanBufSize, replyChanBufSize int) (*channel, error) {
- if c == nil {
- return nil, errors.New("nil connection passed in")
- }
-
- chID := uint16(atomic.AddUint32(&c.maxChannelID, 1) & 0x7fff)
- ch := &channel{
- id: chID,
- replyTimeout: defaultReplyTimeout,
- msgDecoder: c.codec,
- msgIdentifier: c,
- reqChan: make(chan *vppRequest, reqChanBufSize),
- replyChan: make(chan *vppReply, replyChanBufSize),
- notifSubsChan: make(chan *subscriptionRequest, reqChanBufSize),
- notifSubsReplyChan: make(chan error, replyChanBufSize),
- }
-
- // store API channel within the client
- c.channelsLock.Lock()
- c.channels[chID] = ch
- c.channelsLock.Unlock()
-
- // start watching on the request channel
- go c.watchRequests(ch)
-
- return ch, nil
-}
-
-// releaseAPIChannel releases API channel that needs to be closed.
-func (c *Connection) releaseAPIChannel(ch *channel) {
- log.WithFields(logger.Fields{
- "channel": ch.id,
- }).Debug("API channel released")
-
- // delete the channel from channels map
- c.channelsLock.Lock()
- delete(c.channels, ch.id)
- c.channelsLock.Unlock()
+func getMsgNameWithCrc(x api.Message) string {
+ return x.GetMessageName() + "_" + x.GetCrcString()
}
diff --git a/core/connection_test.go b/core/connection_test.go
index 5c8c309..2ecdd34 100644
--- a/core/connection_test.go
+++ b/core/connection_test.go
@@ -14,18 +14,16 @@
package core_test
-/*
import (
"testing"
"git.fd.io/govpp.git/adapter/mock"
"git.fd.io/govpp.git/api"
+ "git.fd.io/govpp.git/codec"
"git.fd.io/govpp.git/core"
- "git.fd.io/govpp.git/core/bin_api/vpe"
"git.fd.io/govpp.git/examples/bin_api/interfaces"
"git.fd.io/govpp.git/examples/bin_api/stats"
-
- "git.fd.io/govpp.git/codec"
+ "git.fd.io/govpp.git/examples/bin_api/vpe"
. "github.com/onsi/gomega"
)
@@ -38,8 +36,9 @@ type testCtx struct {
func setupTest(t *testing.T, bufferedChan bool) *testCtx {
RegisterTestingT(t)
- ctx := &testCtx{}
- ctx.mockVpp = &mock.VppAdapter{}
+ ctx := &testCtx{
+ mockVpp: mock.NewVppAdapter(),
+ }
var err error
ctx.conn, err = core.Connect(ctx.mockVpp)
@@ -60,100 +59,6 @@ func (ctx *testCtx) teardownTest() {
ctx.conn.Disconnect()
}
-func TestSimpleRequest(t *testing.T) {
- ctx := setupTest(t, false)
- defer ctx.teardownTest()
-
- ctx.mockVpp.MockReply(&vpe.ControlPingReply{Retval: -5})
-
- req := &vpe.ControlPing{}
- reply := &vpe.ControlPingReply{}
-
- // send the request and receive a reply
- ctx.ch.GetRequestChannel() <- &api.VppRequest{Message: req}
- vppReply := <-ctx.ch.GetReplyChannel()
-
- Expect(vppReply).ShouldNot(BeNil())
- Expect(vppReply.Error).ShouldNot(HaveOccurred())
-
- // decode the message
- err := ctx.ch.GetMessageDecoder().DecodeMsg(vppReply.Data, reply)
- Expect(err).ShouldNot(HaveOccurred())
-
- Expect(reply.Retval).To(BeEquivalentTo(-5))
-}
-
-func TestMultiRequest(t *testing.T) {
- ctx := setupTest(t, false)
- defer ctx.teardownTest()
-
- msgs := []api.Message{}
- for m := 0; m < 10; m++ {
- msgs = append(msgs, &interfaces.SwInterfaceDetails{})
- }
- ctx.mockVpp.MockReply(msgs...)
- ctx.mockVpp.MockReply(&vpe.ControlPingReply{})
-
- // send multipart request
- ctx.ch.GetRequestChannel() <- &api.VppRequest{Message: &interfaces.SwInterfaceDump{}, Multipart: true}
-
- cnt := 0
- for {
- // receive a reply
- vppReply := <-ctx.ch.GetReplyChannel()
- if vppReply.LastReplyReceived {
- break // break out of the loop
- }
- Expect(vppReply.Error).ShouldNot(HaveOccurred())
-
- // decode the message
- reply := &interfaces.SwInterfaceDetails{}
- err := ctx.ch.GetMessageDecoder().DecodeMsg(vppReply.Data, reply)
- Expect(err).ShouldNot(HaveOccurred())
- cnt++
- }
-
- Expect(cnt).To(BeEquivalentTo(10))
-}
-
-func TestNotifications(t *testing.T) {
- ctx := setupTest(t, false)
- defer ctx.teardownTest()
-
- // subscribe for notification
- notifChan := make(chan api.Message, 1)
- subscription := &api.NotifSubscription{
- NotifChan: notifChan,
- MsgFactory: interfaces.NewSwInterfaceSetFlags,
- }
- ctx.ch.GetNotificationChannel() <- &api.NotifSubscribeRequest{
- Subscription: subscription,
- Subscribe: true,
- }
- err := <-ctx.ch.GetNotificationReplyChannel()
- Expect(err).ShouldNot(HaveOccurred())
-
- // mock the notification and force its delivery
- ctx.mockVpp.MockReply(&interfaces.SwInterfaceSetFlags{
- SwIfIndex: 3,
- AdminUpDown: 1,
- })
- ctx.mockVpp.SendMsg(0, []byte{0})
-
- // receive the notification
- notif := (<-notifChan).(*interfaces.SwInterfaceSetFlags)
-
- Expect(notif.SwIfIndex).To(BeEquivalentTo(3))
-
- // unsubscribe notification
- ctx.ch.GetNotificationChannel() <- &api.NotifSubscribeRequest{
- Subscription: subscription,
- Subscribe: false,
- }
- err = <-ctx.ch.GetNotificationReplyChannel()
- Expect(err).ShouldNot(HaveOccurred())
-}
-
func TestNilConnection(t *testing.T) {
RegisterTestingT(t)
var conn *core.Connection
@@ -184,47 +89,16 @@ func TestAsyncConnection(t *testing.T) {
defer ctx.teardownTest()
ctx.conn.Disconnect()
- conn, ch, err := core.AsyncConnect(ctx.mockVpp)
+ conn, statusChan, err := core.AsyncConnect(ctx.mockVpp)
ctx.conn = conn
Expect(err).ShouldNot(HaveOccurred())
Expect(conn).ShouldNot(BeNil())
- ev := <-ch
+ ev := <-statusChan
Expect(ev.State).Should(BeEquivalentTo(core.Connected))
}
-func TestFullBuffer(t *testing.T) {
- ctx := setupTest(t, false)
- defer ctx.teardownTest()
-
- // close the default API channel
- ctx.ch.Close()
-
- // create a new channel with limited buffer sizes
- var err error
- ctx.ch, err = ctx.conn.NewAPIChannelBuffered(10, 1)
- Expect(err).ShouldNot(HaveOccurred())
-
- // send multiple requests, only one reply should be read
- for i := 0; i < 20; i++ {
- ctx.mockVpp.MockReply(&vpe.ControlPingReply{})
- ctx.ch.GetRequestChannel() <- &api.VppRequest{Message: &vpe.ControlPing{}}
- }
-
- vppReply := <-ctx.ch.GetReplyChannel()
- Expect(vppReply).ShouldNot(BeNil())
-
- var received bool
- select {
- case <-ctx.ch.GetReplyChannel():
- received = true // this should not happen
- default:
- received = false // no reply to be received
- }
- Expect(received).Should(BeFalse(), "A reply has been recieved, should had been ignored.")
-}
-
func TestCodec(t *testing.T) {
RegisterTestingT(t)
@@ -289,7 +163,7 @@ func TestSimpleRequestsWithSequenceNumbers(t *testing.T) {
var reqCtx []api.RequestCtx
for i := 0; i < 10; i++ {
- ctx.mockVpp.MockReply(&vpe.ControlPingReply{Retval: int32(i)})
+ ctx.mockVpp.MockReply(&vpe.ControlPingReply{})
req := &vpe.ControlPing{}
reqCtx = append(reqCtx, ctx.ch.SendRequest(req))
}
@@ -298,7 +172,6 @@ func TestSimpleRequestsWithSequenceNumbers(t *testing.T) {
reply := &vpe.ControlPingReply{}
err := reqCtx[i].ReceiveReply(reply)
Expect(err).ShouldNot(HaveOccurred())
- Expect(reply.Retval).To(BeEquivalentTo(i))
}
}
@@ -306,7 +179,7 @@ func TestMultiRequestsWithSequenceNumbers(t *testing.T) {
ctx := setupTest(t, false)
defer ctx.teardownTest()
- msgs := []api.Message{}
+ var msgs []api.Message
for i := 0; i < 10; i++ {
msgs = append(msgs, &interfaces.SwInterfaceDetails{SwIfIndex: uint32(i)})
}
@@ -325,7 +198,7 @@ func TestMultiRequestsWithSequenceNumbers(t *testing.T) {
lastReplyReceived, err := reqCtx.ReceiveReply(reply)
if lastReplyReceived {
- break // break out of the loop
+ break
}
Expect(err).ShouldNot(HaveOccurred())
@@ -343,7 +216,7 @@ func TestSimpleRequestWithTimeout(t *testing.T) {
// reply for a previous timeouted requests to be ignored
ctx.mockVpp.MockReplyWithContext(mock.MsgWithContext{
- Msg: &vpe.ControlPingReply{Retval: 1},
+ Msg: &vpe.ControlPingReply{},
SeqNum: 0,
})
@@ -359,12 +232,12 @@ func TestSimpleRequestWithTimeout(t *testing.T) {
ctx.mockVpp.MockReplyWithContext(
// reply for the previous request
mock.MsgWithContext{
- Msg: &vpe.ControlPingReply{Retval: 1},
+ Msg: &vpe.ControlPingReply{},
SeqNum: 1,
},
// reply for the next request
mock.MsgWithContext{
- Msg: &vpe.ControlPingReply{Retval: 2},
+ Msg: &vpe.ControlPingReply{},
SeqNum: 2,
})
@@ -376,7 +249,6 @@ func TestSimpleRequestWithTimeout(t *testing.T) {
reply = &vpe.ControlPingReply{}
err = reqCtx2.ReceiveReply(reply)
Expect(err).To(BeNil())
- Expect(reply.Retval).To(BeEquivalentTo(2))
}
func TestSimpleRequestsWithMissingReply(t *testing.T) {
@@ -393,7 +265,7 @@ func TestSimpleRequestsWithMissingReply(t *testing.T) {
// third request with reply
ctx.mockVpp.MockReplyWithContext(mock.MsgWithContext{
- Msg: &vpe.ControlPingReply{Retval: 3},
+ Msg: &vpe.ControlPingReply{},
SeqNum: 3,
})
req3 := &vpe.ControlPing{}
@@ -414,7 +286,6 @@ func TestSimpleRequestsWithMissingReply(t *testing.T) {
reply = &vpe.ControlPingReply{}
err = reqCtx3.ReceiveReply(reply)
Expect(err).To(BeNil())
- Expect(reply.Retval).To(BeEquivalentTo(3))
}
func TestMultiRequestsWithErrors(t *testing.T) {
@@ -422,38 +293,25 @@ func TestMultiRequestsWithErrors(t *testing.T) {
defer ctx.teardownTest()
// replies for a previous timeouted requests to be ignored
- msgs := []mock.MsgWithContext{}
- msgs = append(msgs,
- mock.MsgWithContext{
- Msg: &vpe.ControlPingReply{Retval: 1},
- SeqNum: 0xffff - 1,
- },
- mock.MsgWithContext{
- Msg: &vpe.ControlPingReply{Retval: 1},
- SeqNum: 0xffff,
- },
- mock.MsgWithContext{
- Msg: &vpe.ControlPingReply{Retval: 1},
- SeqNum: 0,
- })
-
+ msgs := []mock.MsgWithContext{
+ {Msg: &vpe.ControlPingReply{}, SeqNum: 0xffff - 1},
+ {Msg: &vpe.ControlPingReply{}, SeqNum: 0xffff},
+ {Msg: &vpe.ControlPingReply{}, SeqNum: 0},
+ }
for i := 0; i < 10; i++ {
- msgs = append(msgs,
- mock.MsgWithContext{
- Msg: &interfaces.SwInterfaceDetails{SwIfIndex: uint32(i)},
- SeqNum: 1,
- Multipart: true,
- })
+ msgs = append(msgs, mock.MsgWithContext{
+ Msg: &interfaces.SwInterfaceDetails{SwIfIndex: uint32(i)},
+ SeqNum: 1,
+ Multipart: true,
+ })
}
// missing finalizing control ping
// reply for a next request
- msgs = append(msgs,
- mock.MsgWithContext{
- Msg: &vpe.ControlPingReply{Retval: 2},
- SeqNum: 2,
- Multipart: false,
- })
+ msgs = append(msgs, mock.MsgWithContext{
+ Msg: &vpe.ControlPingReply{},
+ SeqNum: 2,
+ })
// queue replies
ctx.mockVpp.MockReplyWithContext(msgs...)
@@ -487,7 +345,6 @@ func TestMultiRequestsWithErrors(t *testing.T) {
reply2 := &vpe.ControlPingReply{}
err = reqCtx2.ReceiveReply(reply2)
Expect(err).To(BeNil())
- Expect(reply2.Retval).To(BeEquivalentTo(2))
}
func TestRequestsOrdering(t *testing.T) {
@@ -498,12 +355,12 @@ func TestRequestsOrdering(t *testing.T) {
// some replies will get thrown away
// first request
- ctx.mockVpp.MockReply(&vpe.ControlPingReply{Retval: 1})
+ ctx.mockVpp.MockReply(&vpe.ControlPingReply{})
req1 := &vpe.ControlPing{}
reqCtx1 := ctx.ch.SendRequest(req1)
// second request
- ctx.mockVpp.MockReply(&vpe.ControlPingReply{Retval: 2})
+ ctx.mockVpp.MockReply(&vpe.ControlPingReply{})
req2 := &vpe.ControlPing{}
reqCtx2 := ctx.ch.SendRequest(req2)
@@ -512,7 +369,6 @@ func TestRequestsOrdering(t *testing.T) {
reply2 := &vpe.ControlPingReply{}
err := reqCtx2.ReceiveReply(reply2)
Expect(err).To(BeNil())
- Expect(reply2.Retval).To(BeEquivalentTo(2))
// first request has already been considered closed
reply1 := &vpe.ControlPingReply{}
@@ -522,7 +378,7 @@ func TestRequestsOrdering(t *testing.T) {
}
func TestCycleOverSetOfSequenceNumbers(t *testing.T) {
- ctx := setupTest(t, true)
+ ctx := setupTest(t, false)
defer ctx.teardownTest()
numIters := 0xffff + 100
@@ -530,7 +386,7 @@ func TestCycleOverSetOfSequenceNumbers(t *testing.T) {
for i := 0; i < numIters+30; i++ {
if i < numIters {
- ctx.mockVpp.MockReply(&vpe.ControlPingReply{Retval: int32(i)})
+ ctx.mockVpp.MockReply(&vpe.ControlPingReply{})
req := &vpe.ControlPing{}
reqCtx[i] = ctx.ch.SendRequest(req)
}
@@ -538,8 +394,6 @@ func TestCycleOverSetOfSequenceNumbers(t *testing.T) {
reply := &vpe.ControlPingReply{}
err := reqCtx[i-30].ReceiveReply(reply)
Expect(err).ShouldNot(HaveOccurred())
- Expect(reply.Retval).To(BeEquivalentTo(i - 30))
}
}
}
-*/
diff --git a/core/notification_handler.go b/core/notification_handler.go
deleted file mode 100644
index 7b889e3..0000000
--- a/core/notification_handler.go
+++ /dev/null
@@ -1,170 +0,0 @@
-// Copyright (c) 2017 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 core
-
-import (
- "fmt"
-
- "git.fd.io/govpp.git/api"
- logger "github.com/sirupsen/logrus"
-)
-
-// processSubscriptionRequest processes a notification subscribe request.
-func (c *Connection) processSubscriptionRequest(ch *channel, req *subscriptionRequest) error {
- var err error
-
- // subscribe / unsubscribe
- if req.subscribe {
- err = c.addNotifSubscription(req.sub)
- } else {
- err = c.removeNotifSubscription(req.sub)
- }
-
- // send the reply into the go channel
- select {
- case ch.notifSubsReplyChan <- err:
- // reply sent successfully
- default:
- // unable to write into the channel without blocking
- log.WithFields(logger.Fields{
- "channel": ch.id,
- }).Warn("Unable to deliver the subscribe reply, reciever end not ready.")
- }
-
- return err
-}
-
-// addNotifSubscription adds the notification subscription into the subscriptions map of the connection.
-func (c *Connection) addNotifSubscription(subs *api.NotifSubscription) error {
- // get message ID of the notification message
- msgID, msgName, err := c.getSubscriptionMessageID(subs)
- if err != nil {
- return err
- }
-
- log.WithFields(logger.Fields{
- "msg_name": msgName,
- "msg_id": msgID,
- }).Debug("Adding new notification subscription.")
-
- // add the subscription into map
- c.notifSubscriptionsLock.Lock()
- defer c.notifSubscriptionsLock.Unlock()
-
- c.notifSubscriptions[msgID] = append(c.notifSubscriptions[msgID], subs)
-
- return nil
-}
-
-// removeNotifSubscription removes the notification subscription from the subscriptions map of the connection.
-func (c *Connection) removeNotifSubscription(subs *api.NotifSubscription) error {
- // get message ID of the notification message
- msgID, msgName, err := c.getSubscriptionMessageID(subs)
- if err != nil {
- return err
- }
-
- log.WithFields(logger.Fields{
- "msg_name": msgName,
- "msg_id": msgID,
- }).Debug("Removing notification subscription.")
-
- // remove the subscription from the map
- c.notifSubscriptionsLock.Lock()
- defer c.notifSubscriptionsLock.Unlock()
-
- for i, item := range c.notifSubscriptions[msgID] {
- if item == subs {
- // remove i-th item in the slice
- c.notifSubscriptions[msgID] = append(c.notifSubscriptions[msgID][:i], c.notifSubscriptions[msgID][i+1:]...)
- break
- }
- }
-
- return nil
-}
-
-// isNotificationMessage returns true if someone has subscribed to provided message ID.
-func (c *Connection) isNotificationMessage(msgID uint16) bool {
- c.notifSubscriptionsLock.RLock()
- defer c.notifSubscriptionsLock.RUnlock()
-
- _, exists := c.notifSubscriptions[msgID]
- return exists
-}
-
-// sendNotifications send a notification message to all subscribers subscribed for that message.
-func (c *Connection) sendNotifications(msgID uint16, data []byte) {
- c.notifSubscriptionsLock.RLock()
- defer c.notifSubscriptionsLock.RUnlock()
-
- matched := false
-
- // send to notification to each subscriber
- for _, subs := range c.notifSubscriptions[msgID] {
- msg := subs.MsgFactory()
- log.WithFields(logger.Fields{
- "msg_name": msg.GetMessageName(),
- "msg_id": msgID,
- "msg_size": len(data),
- }).Debug("Sending a notification to the subscription channel.")
-
- if err := c.codec.DecodeMsg(data, msg); err != nil {
- log.WithFields(logger.Fields{
- "msg_name": msg.GetMessageName(),
- "msg_id": msgID,
- "msg_size": len(data),
- }).Errorf("Unable to decode the notification message: %v", err)
- continue
- }
-
- // send the message into the go channel of the subscription
- select {
- case subs.NotifChan <- msg:
- // message sent successfully
- default:
- // unable to write into the channel without blocking
- log.WithFields(logger.Fields{
- "msg_name": msg.GetMessageName(),
- "msg_id": msgID,
- "msg_size": len(data),
- }).Warn("Unable to deliver the notification, reciever end not ready.")
- }
-
- matched = true
- }
-
- if !matched {
- log.WithFields(logger.Fields{
- "msg_id": msgID,
- "msg_size": len(data),
- }).Info("No subscription found for the notification message.")
- }
-}
-
-// getSubscriptionMessageID returns ID of the message the subscription is tied to.
-func (c *Connection) getSubscriptionMessageID(subs *api.NotifSubscription) (uint16, string, error) {
- msg := subs.MsgFactory()
- msgID, err := c.GetMessageID(msg)
- if err != nil {
- log.WithFields(logger.Fields{
- "msg_name": msg.GetMessageName(),
- "msg_crc": msg.GetCrcString(),
- }).Errorf("unable to retrieve message ID: %v", err)
- return 0, "", fmt.Errorf("unable to retrieve message ID: %v", err)
- }
-
- return msgID, msg.GetMessageName(), nil
-}
diff --git a/core/request_handler.go b/core/request_handler.go
index fd6d100..e52e262 100644
--- a/core/request_handler.go
+++ b/core/request_handler.go
@@ -29,7 +29,7 @@ var (
)
// watchRequests watches for requests on the request API channel and forwards them as messages to VPP.
-func (c *Connection) watchRequests(ch *channel) {
+func (c *Connection) watchRequests(ch *Channel) {
for {
select {
case req, ok := <-ch.reqChan:
@@ -39,54 +39,49 @@ func (c *Connection) watchRequests(ch *channel) {
c.releaseAPIChannel(ch)
return
}
- c.processRequest(ch, req)
-
- case req := <-ch.notifSubsChan:
- // new request on the notification subscribe channel
- c.processSubscriptionRequest(ch, req)
+ if err := c.processRequest(ch, req); err != nil {
+ sendReplyError(ch, req, err)
+ }
}
}
}
// processRequest processes a single request received on the request channel.
-func (c *Connection) processRequest(ch *channel, req *vppRequest) error {
+func (c *Connection) processRequest(ch *Channel, req *vppRequest) error {
// check whether we are connected to VPP
if atomic.LoadUint32(&c.connected) == 0 {
err := ErrNotConnected
log.Errorf("processing request failed: %v", err)
- sendReplyError(ch, req, err)
return err
}
// retrieve message ID
msgID, err := c.GetMessageID(req.msg)
if err != nil {
- err = fmt.Errorf("unable to retrieve message ID: %v", err)
log.WithFields(logger.Fields{
"msg_name": req.msg.GetMessageName(),
"msg_crc": req.msg.GetCrcString(),
"seq_num": req.seqNum,
- }).Error(err)
- sendReplyError(ch, req, err)
- return err
+ "error": err,
+ }).Errorf("failed to retrieve message ID")
+ return fmt.Errorf("unable to retrieve message ID: %v", err)
}
// encode the message into binary
data, err := c.codec.EncodeMsg(req.msg, msgID)
if err != nil {
- err = fmt.Errorf("unable to encode the messge: %v", err)
log.WithFields(logger.Fields{
"channel": ch.id,
"msg_id": msgID,
"msg_name": req.msg.GetMessageName(),
"seq_num": req.seqNum,
- }).Error(err)
- sendReplyError(ch, req, err)
- return err
+ "error": err,
+ }).Errorf("failed to encode message: %#v", req.msg)
+ return fmt.Errorf("unable to encode the message: %v", err)
}
- // get context
context := packRequestContext(ch.id, req.multi, req.seqNum)
+
if log.Level == logger.DebugLevel { // for performance reasons - logrus does some processing even if debugs are disabled
log.WithFields(logger.Fields{
"channel": ch.id,
@@ -108,7 +103,6 @@ func (c *Connection) processRequest(ch *channel, req *vppRequest) error {
"msg_id": msgID,
"seq_num": req.seqNum,
}).Error(err)
- sendReplyError(ch, req, err)
return err
}
@@ -137,7 +131,7 @@ func (c *Connection) processRequest(ch *channel, req *vppRequest) error {
}
// msgCallback is called whenever any binary API message comes from VPP.
-func (c *Connection) msgCallback(msgID uint16, context uint32, data []byte) {
+func (c *Connection) msgCallback(msgID uint16, data []byte) {
connLock.RLock()
defer connLock.RUnlock()
@@ -157,13 +151,8 @@ func (c *Connection) msgCallback(msgID uint16, context uint32, data []byte) {
// - replies that don't have context as first field (comes as zero)
// - events that don't have context at all (comes as non zero)
//
- msgContext, err := c.codec.DecodeMsgContext(data, msg)
- if err == nil {
- if context != msgContext {
- log.Debugf("different context was decoded from message (%d -> %d)", context, msgContext)
- context = msgContext
- }
- } else {
+ context, err := c.codec.DecodeMsgContext(data, msg)
+ if err != nil {
log.Errorf("decoding context failed: %v", err)
}
@@ -202,11 +191,12 @@ func (c *Connection) msgCallback(msgID uint16, context uint32, data []byte) {
// treat this as a last part of the reply
lastReplyReceived := isMulti && msgID == c.pingReplyID
- // send the data to the channel
+ // send the data to the channel, it needs to be copied,
+ // because it will be freed after this function returns
sendReply(ch, &vppReply{
msgID: msgID,
seqNum: seqNum,
- data: data,
+ data: append([]byte(nil), data...),
lastReceived: lastReplyReceived,
})
@@ -218,7 +208,7 @@ func (c *Connection) msgCallback(msgID uint16, context uint32, data []byte) {
// sendReply sends the reply into the go channel, if it cannot be completed without blocking, otherwise
// it logs the error and do not send the message.
-func sendReply(ch *channel, reply *vppReply) {
+func sendReply(ch *Channel, reply *vppReply) {
select {
case ch.replyChan <- reply:
// reply sent successfully
@@ -232,10 +222,68 @@ func sendReply(ch *channel, reply *vppReply) {
}
}
-func sendReplyError(ch *channel, req *vppRequest, err error) {
+func sendReplyError(ch *Channel, req *vppRequest, err error) {
sendReply(ch, &vppReply{seqNum: req.seqNum, err: err})
}
+// isNotificationMessage returns true if someone has subscribed to provided message ID.
+func (c *Connection) isNotificationMessage(msgID uint16) bool {
+ c.subscriptionsLock.RLock()
+ defer c.subscriptionsLock.RUnlock()
+
+ _, exists := c.subscriptions[msgID]
+ return exists
+}
+
+// sendNotifications send a notification message to all subscribers subscribed for that message.
+func (c *Connection) sendNotifications(msgID uint16, data []byte) {
+ c.subscriptionsLock.RLock()
+ defer c.subscriptionsLock.RUnlock()
+
+ matched := false
+
+ // send to notification to each subscriber
+ for _, sub := range c.subscriptions[msgID] {
+ log.WithFields(logger.Fields{
+ "msg_name": sub.event.GetMessageName(),
+ "msg_id": msgID,
+ "msg_size": len(data),
+ }).Debug("Sending a notification to the subscription channel.")
+
+ event := sub.msgFactory()
+ if err := c.codec.DecodeMsg(data, event); err != nil {
+ log.WithFields(logger.Fields{
+ "msg_name": sub.event.GetMessageName(),
+ "msg_id": msgID,
+ "msg_size": len(data),
+ }).Errorf("Unable to decode the notification message: %v", err)
+ continue
+ }
+
+ // send the message into the go channel of the subscription
+ select {
+ case sub.notifChan <- event:
+ // message sent successfully
+ default:
+ // unable to write into the channel without blocking
+ log.WithFields(logger.Fields{
+ "msg_name": sub.event.GetMessageName(),
+ "msg_id": msgID,
+ "msg_size": len(data),
+ }).Warn("Unable to deliver the notification, reciever end not ready.")
+ }
+
+ matched = true
+ }
+
+ if !matched {
+ log.WithFields(logger.Fields{
+ "msg_id": msgID,
+ "msg_size": len(data),
+ }).Info("No subscription found for the notification message.")
+ }
+}
+
// +------------------+-------------------+-----------------------+
// | 15b = channel ID | 1b = is multipart | 16b = sequence number |
// +------------------+-------------------+-----------------------+
diff --git a/examples/bin_api/acl/acl.ba.go b/examples/bin_api/acl/acl.ba.go
index ff80173..47b79cf 100644
--- a/examples/bin_api/acl/acl.ba.go
+++ b/examples/bin_api/acl/acl.ba.go
@@ -1,16 +1,14 @@
// Code generated by GoVPP binapi-generator. DO NOT EDIT.
-// source: acl.api.json
+// source: acl.api.json
/*
-Package acl is a generated VPP binary API of the 'acl' VPP module.
+ Package acl is a generated from VPP binary API module 'acl'.
-It is generated from this file:
- acl.api.json
+ It contains following objects:
+ 34 messages
+ 2 types
+ 17 services
-It contains these VPP binary API objects:
- 34 messages
- 2 types
- 17 services
*/
package acl
@@ -19,13 +17,13 @@ import "github.com/lunixbochs/struc"
import "bytes"
// Reference imports to suppress errors if they are not otherwise used.
+var _ = api.RegisterMessage
var _ = struc.Pack
var _ = bytes.NewBuffer
/* Types */
// ACLRule represents the VPP binary API type 'acl_rule'.
-// Generated from 'acl.api.json', line 922:
//
// "acl_rule",
// [
@@ -110,7 +108,6 @@ func (*ACLRule) GetCrcString() string {
}
// MacipACLRule represents the VPP binary API type 'macip_acl_rule'.
-// Generated from 'acl.api.json', line 982:
//
// "macip_acl_rule",
// [
@@ -163,7 +160,6 @@ func (*MacipACLRule) GetCrcString() string {
/* Messages */
// ACLPluginGetVersion represents the VPP binary API message 'acl_plugin_get_version'.
-// Generated from 'acl.api.json', line 4:
//
// "acl_plugin_get_version",
// [
@@ -193,12 +189,8 @@ func (*ACLPluginGetVersion) GetCrcString() string {
func (*ACLPluginGetVersion) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewACLPluginGetVersion() api.Message {
- return &ACLPluginGetVersion{}
-}
// ACLPluginGetVersionReply represents the VPP binary API message 'acl_plugin_get_version_reply'.
-// Generated from 'acl.api.json', line 22:
//
// "acl_plugin_get_version_reply",
// [
@@ -235,12 +227,8 @@ func (*ACLPluginGetVersionReply) GetCrcString() string {
func (*ACLPluginGetVersionReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewACLPluginGetVersionReply() api.Message {
- return &ACLPluginGetVersionReply{}
-}
// ACLPluginControlPing represents the VPP binary API message 'acl_plugin_control_ping'.
-// Generated from 'acl.api.json', line 44:
//
// "acl_plugin_control_ping",
// [
@@ -270,12 +258,8 @@ func (*ACLPluginControlPing) GetCrcString() string {
func (*ACLPluginControlPing) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewACLPluginControlPing() api.Message {
- return &ACLPluginControlPing{}
-}
// ACLPluginControlPingReply represents the VPP binary API message 'acl_plugin_control_ping_reply'.
-// Generated from 'acl.api.json', line 62:
//
// "acl_plugin_control_ping_reply",
// [
@@ -317,12 +301,8 @@ func (*ACLPluginControlPingReply) GetCrcString() string {
func (*ACLPluginControlPingReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewACLPluginControlPingReply() api.Message {
- return &ACLPluginControlPingReply{}
-}
// ACLAddReplace represents the VPP binary API message 'acl_add_replace'.
-// Generated from 'acl.api.json', line 88:
//
// "acl_add_replace",
// [
@@ -376,12 +356,8 @@ func (*ACLAddReplace) GetCrcString() string {
func (*ACLAddReplace) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewACLAddReplace() api.Message {
- return &ACLAddReplace{}
-}
// ACLAddReplaceReply represents the VPP binary API message 'acl_add_replace_reply'.
-// Generated from 'acl.api.json', line 125:
//
// "acl_add_replace_reply",
// [
@@ -418,12 +394,8 @@ func (*ACLAddReplaceReply) GetCrcString() string {
func (*ACLAddReplaceReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewACLAddReplaceReply() api.Message {
- return &ACLAddReplaceReply{}
-}
// ACLDel represents the VPP binary API message 'acl_del'.
-// Generated from 'acl.api.json', line 147:
//
// "acl_del",
// [
@@ -459,12 +431,8 @@ func (*ACLDel) GetCrcString() string {
func (*ACLDel) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewACLDel() api.Message {
- return &ACLDel{}
-}
// ACLDelReply represents the VPP binary API message 'acl_del_reply'.
-// Generated from 'acl.api.json', line 169:
//
// "acl_del_reply",
// [
@@ -496,12 +464,8 @@ func (*ACLDelReply) GetCrcString() string {
func (*ACLDelReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewACLDelReply() api.Message {
- return &ACLDelReply{}
-}
// ACLInterfaceAddDel represents the VPP binary API message 'acl_interface_add_del'.
-// Generated from 'acl.api.json', line 187:
//
// "acl_interface_add_del",
// [
@@ -552,12 +516,8 @@ func (*ACLInterfaceAddDel) GetCrcString() string {
func (*ACLInterfaceAddDel) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewACLInterfaceAddDel() api.Message {
- return &ACLInterfaceAddDel{}
-}
// ACLInterfaceAddDelReply represents the VPP binary API message 'acl_interface_add_del_reply'.
-// Generated from 'acl.api.json', line 221:
//
// "acl_interface_add_del_reply",
// [
@@ -589,12 +549,8 @@ func (*ACLInterfaceAddDelReply) GetCrcString() string {
func (*ACLInterfaceAddDelReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewACLInterfaceAddDelReply() api.Message {
- return &ACLInterfaceAddDelReply{}
-}
// ACLInterfaceSetACLList represents the VPP binary API message 'acl_interface_set_acl_list'.
-// Generated from 'acl.api.json', line 239:
//
// "acl_interface_set_acl_list",
// [
@@ -647,12 +603,8 @@ func (*ACLInterfaceSetACLList) GetCrcString() string {
func (*ACLInterfaceSetACLList) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewACLInterfaceSetACLList() api.Message {
- return &ACLInterfaceSetACLList{}
-}
// ACLInterfaceSetACLListReply represents the VPP binary API message 'acl_interface_set_acl_list_reply'.
-// Generated from 'acl.api.json', line 275:
//
// "acl_interface_set_acl_list_reply",
// [
@@ -684,12 +636,8 @@ func (*ACLInterfaceSetACLListReply) GetCrcString() string {
func (*ACLInterfaceSetACLListReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewACLInterfaceSetACLListReply() api.Message {
- return &ACLInterfaceSetACLListReply{}
-}
// ACLDump represents the VPP binary API message 'acl_dump'.
-// Generated from 'acl.api.json', line 293:
//
// "acl_dump",
// [
@@ -725,12 +673,8 @@ func (*ACLDump) GetCrcString() string {
func (*ACLDump) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewACLDump() api.Message {
- return &ACLDump{}
-}
// ACLDetails represents the VPP binary API message 'acl_details'.
-// Generated from 'acl.api.json', line 315:
//
// "acl_details",
// [
@@ -780,12 +724,8 @@ func (*ACLDetails) GetCrcString() string {
func (*ACLDetails) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewACLDetails() api.Message {
- return &ACLDetails{}
-}
// ACLInterfaceListDump represents the VPP binary API message 'acl_interface_list_dump'.
-// Generated from 'acl.api.json', line 348:
//
// "acl_interface_list_dump",
// [
@@ -821,12 +761,8 @@ func (*ACLInterfaceListDump) GetCrcString() string {
func (*ACLInterfaceListDump) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewACLInterfaceListDump() api.Message {
- return &ACLInterfaceListDump{}
-}
// ACLInterfaceListDetails represents the VPP binary API message 'acl_interface_list_details'.
-// Generated from 'acl.api.json', line 370:
//
// "acl_interface_list_details",
// [
@@ -875,12 +811,8 @@ func (*ACLInterfaceListDetails) GetCrcString() string {
func (*ACLInterfaceListDetails) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewACLInterfaceListDetails() api.Message {
- return &ACLInterfaceListDetails{}
-}
// MacipACLAdd represents the VPP binary API message 'macip_acl_add'.
-// Generated from 'acl.api.json', line 402:
//
// "macip_acl_add",
// [
@@ -929,12 +861,8 @@ func (*MacipACLAdd) GetCrcString() string {
func (*MacipACLAdd) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewMacipACLAdd() api.Message {
- return &MacipACLAdd{}
-}
// MacipACLAddReply represents the VPP binary API message 'macip_acl_add_reply'.
-// Generated from 'acl.api.json', line 435:
//
// "macip_acl_add_reply",
// [
@@ -971,12 +899,8 @@ func (*MacipACLAddReply) GetCrcString() string {
func (*MacipACLAddReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewMacipACLAddReply() api.Message {
- return &MacipACLAddReply{}
-}
// MacipACLAddReplace represents the VPP binary API message 'macip_acl_add_replace'.
-// Generated from 'acl.api.json', line 457:
//
// "macip_acl_add_replace",
// [
@@ -1030,12 +954,8 @@ func (*MacipACLAddReplace) GetCrcString() string {
func (*MacipACLAddReplace) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewMacipACLAddReplace() api.Message {
- return &MacipACLAddReplace{}
-}
// MacipACLAddReplaceReply represents the VPP binary API message 'macip_acl_add_replace_reply'.
-// Generated from 'acl.api.json', line 494:
//
// "macip_acl_add_replace_reply",
// [
@@ -1072,12 +992,8 @@ func (*MacipACLAddReplaceReply) GetCrcString() string {
func (*MacipACLAddReplaceReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewMacipACLAddReplaceReply() api.Message {
- return &MacipACLAddReplaceReply{}
-}
// MacipACLDel represents the VPP binary API message 'macip_acl_del'.
-// Generated from 'acl.api.json', line 516:
//
// "macip_acl_del",
// [
@@ -1113,12 +1029,8 @@ func (*MacipACLDel) GetCrcString() string {
func (*MacipACLDel) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewMacipACLDel() api.Message {
- return &MacipACLDel{}
-}
// MacipACLDelReply represents the VPP binary API message 'macip_acl_del_reply'.
-// Generated from 'acl.api.json', line 538:
//
// "macip_acl_del_reply",
// [
@@ -1150,12 +1062,8 @@ func (*MacipACLDelReply) GetCrcString() string {
func (*MacipACLDelReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewMacipACLDelReply() api.Message {
- return &MacipACLDelReply{}
-}
// MacipACLInterfaceAddDel represents the VPP binary API message 'macip_acl_interface_add_del'.
-// Generated from 'acl.api.json', line 556:
//
// "macip_acl_interface_add_del",
// [
@@ -1201,12 +1109,8 @@ func (*MacipACLInterfaceAddDel) GetCrcString() string {
func (*MacipACLInterfaceAddDel) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewMacipACLInterfaceAddDel() api.Message {
- return &MacipACLInterfaceAddDel{}
-}
// MacipACLInterfaceAddDelReply represents the VPP binary API message 'macip_acl_interface_add_del_reply'.
-// Generated from 'acl.api.json', line 586:
//
// "macip_acl_interface_add_del_reply",
// [
@@ -1238,12 +1142,8 @@ func (*MacipACLInterfaceAddDelReply) GetCrcString() string {
func (*MacipACLInterfaceAddDelReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewMacipACLInterfaceAddDelReply() api.Message {
- return &MacipACLInterfaceAddDelReply{}
-}
// MacipACLDump represents the VPP binary API message 'macip_acl_dump'.
-// Generated from 'acl.api.json', line 604:
//
// "macip_acl_dump",
// [
@@ -1279,12 +1179,8 @@ func (*MacipACLDump) GetCrcString() string {
func (*MacipACLDump) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewMacipACLDump() api.Message {
- return &MacipACLDump{}
-}
// MacipACLDetails represents the VPP binary API message 'macip_acl_details'.
-// Generated from 'acl.api.json', line 626:
//
// "macip_acl_details",
// [
@@ -1334,12 +1230,8 @@ func (*MacipACLDetails) GetCrcString() string {
func (*MacipACLDetails) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewMacipACLDetails() api.Message {
- return &MacipACLDetails{}
-}
// MacipACLInterfaceGet represents the VPP binary API message 'macip_acl_interface_get'.
-// Generated from 'acl.api.json', line 659:
//
// "macip_acl_interface_get",
// [
@@ -1369,12 +1261,8 @@ func (*MacipACLInterfaceGet) GetCrcString() string {
func (*MacipACLInterfaceGet) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewMacipACLInterfaceGet() api.Message {
- return &MacipACLInterfaceGet{}
-}
// MacipACLInterfaceGetReply represents the VPP binary API message 'macip_acl_interface_get_reply'.
-// Generated from 'acl.api.json', line 677:
//
// "macip_acl_interface_get_reply",
// [
@@ -1413,12 +1301,8 @@ func (*MacipACLInterfaceGetReply) GetCrcString() string {
func (*MacipACLInterfaceGetReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewMacipACLInterfaceGetReply() api.Message {
- return &MacipACLInterfaceGetReply{}
-}
// MacipACLInterfaceListDump represents the VPP binary API message 'macip_acl_interface_list_dump'.
-// Generated from 'acl.api.json', line 701:
//
// "macip_acl_interface_list_dump",
// [
@@ -1454,12 +1338,8 @@ func (*MacipACLInterfaceListDump) GetCrcString() string {
func (*MacipACLInterfaceListDump) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewMacipACLInterfaceListDump() api.Message {
- return &MacipACLInterfaceListDump{}
-}
// MacipACLInterfaceListDetails represents the VPP binary API message 'macip_acl_interface_list_details'.
-// Generated from 'acl.api.json', line 723:
//
// "macip_acl_interface_list_details",
// [
@@ -1503,12 +1383,8 @@ func (*MacipACLInterfaceListDetails) GetCrcString() string {
func (*MacipACLInterfaceListDetails) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewMacipACLInterfaceListDetails() api.Message {
- return &MacipACLInterfaceListDetails{}
-}
// ACLInterfaceSetEtypeWhitelist represents the VPP binary API message 'acl_interface_set_etype_whitelist'.
-// Generated from 'acl.api.json', line 751:
//
// "acl_interface_set_etype_whitelist",
// [
@@ -1561,12 +1437,8 @@ func (*ACLInterfaceSetEtypeWhitelist) GetCrcString() string {
func (*ACLInterfaceSetEtypeWhitelist) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewACLInterfaceSetEtypeWhitelist() api.Message {
- return &ACLInterfaceSetEtypeWhitelist{}
-}
// ACLInterfaceSetEtypeWhitelistReply represents the VPP binary API message 'acl_interface_set_etype_whitelist_reply'.
-// Generated from 'acl.api.json', line 787:
//
// "acl_interface_set_etype_whitelist_reply",
// [
@@ -1598,12 +1470,8 @@ func (*ACLInterfaceSetEtypeWhitelistReply) GetCrcString() string {
func (*ACLInterfaceSetEtypeWhitelistReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewACLInterfaceSetEtypeWhitelistReply() api.Message {
- return &ACLInterfaceSetEtypeWhitelistReply{}
-}
// ACLInterfaceEtypeWhitelistDump represents the VPP binary API message 'acl_interface_etype_whitelist_dump'.
-// Generated from 'acl.api.json', line 805:
//
// "acl_interface_etype_whitelist_dump",
// [
@@ -1639,12 +1507,8 @@ func (*ACLInterfaceEtypeWhitelistDump) GetCrcString() string {
func (*ACLInterfaceEtypeWhitelistDump) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewACLInterfaceEtypeWhitelistDump() api.Message {
- return &ACLInterfaceEtypeWhitelistDump{}
-}
// ACLInterfaceEtypeWhitelistDetails represents the VPP binary API message 'acl_interface_etype_whitelist_details'.
-// Generated from 'acl.api.json', line 827:
//
// "acl_interface_etype_whitelist_details",
// [
@@ -1693,9 +1557,6 @@ func (*ACLInterfaceEtypeWhitelistDetails) GetCrcString() string {
func (*ACLInterfaceEtypeWhitelistDetails) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewACLInterfaceEtypeWhitelistDetails() api.Message {
- return &ACLInterfaceEtypeWhitelistDetails{}
-}
/* Services */
diff --git a/examples/bin_api/af_packet/af_packet.ba.go b/examples/bin_api/af_packet/af_packet.ba.go
index a6bdc93..81c2b9d 100644
--- a/examples/bin_api/af_packet/af_packet.ba.go
+++ b/examples/bin_api/af_packet/af_packet.ba.go
@@ -1,15 +1,13 @@
// Code generated by GoVPP binapi-generator. DO NOT EDIT.
-// source: af_packet.api.json
+// source: af_packet.api.json
/*
-Package af_packet is a generated VPP binary API of the 'af_packet' VPP module.
+ Package af_packet is a generated from VPP binary API module 'af_packet'.
-It is generated from this file:
- af_packet.api.json
+ It contains following objects:
+ 8 messages
+ 4 services
-It contains these VPP binary API objects:
- 8 messages
- 4 services
*/
package af_packet
@@ -18,13 +16,13 @@ import "github.com/lunixbochs/struc"
import "bytes"
// Reference imports to suppress errors if they are not otherwise used.
+var _ = api.RegisterMessage
var _ = struc.Pack
var _ = bytes.NewBuffer
/* Messages */
// AfPacketCreate represents the VPP binary API message 'af_packet_create'.
-// Generated from 'af_packet.api.json', line 4:
//
// "af_packet_create",
// [
@@ -72,12 +70,8 @@ func (*AfPacketCreate) GetCrcString() string {
func (*AfPacketCreate) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewAfPacketCreate() api.Message {
- return &AfPacketCreate{}
-}
// AfPacketCreateReply represents the VPP binary API message 'af_packet_create_reply'.
-// Generated from 'af_packet.api.json', line 36:
//
// "af_packet_create_reply",
// [
@@ -114,12 +108,8 @@ func (*AfPacketCreateReply) GetCrcString() string {
func (*AfPacketCreateReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewAfPacketCreateReply() api.Message {
- return &AfPacketCreateReply{}
-}
// AfPacketDelete represents the VPP binary API message 'af_packet_delete'.
-// Generated from 'af_packet.api.json', line 58:
//
// "af_packet_delete",
// [
@@ -156,12 +146,8 @@ func (*AfPacketDelete) GetCrcString() string {
func (*AfPacketDelete) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewAfPacketDelete() api.Message {
- return &AfPacketDelete{}
-}
// AfPacketDeleteReply represents the VPP binary API message 'af_packet_delete_reply'.
-// Generated from 'af_packet.api.json', line 81:
//
// "af_packet_delete_reply",
// [
@@ -193,12 +179,8 @@ func (*AfPacketDeleteReply) GetCrcString() string {
func (*AfPacketDeleteReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewAfPacketDeleteReply() api.Message {
- return &AfPacketDeleteReply{}
-}
// AfPacketSetL4CksumOffload represents the VPP binary API message 'af_packet_set_l4_cksum_offload'.
-// Generated from 'af_packet.api.json', line 99:
//
// "af_packet_set_l4_cksum_offload",
// [
@@ -239,12 +221,8 @@ func (*AfPacketSetL4CksumOffload) GetCrcString() string {
func (*AfPacketSetL4CksumOffload) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewAfPacketSetL4CksumOffload() api.Message {
- return &AfPacketSetL4CksumOffload{}
-}
// AfPacketSetL4CksumOffloadReply represents the VPP binary API message 'af_packet_set_l4_cksum_offload_reply'.
-// Generated from 'af_packet.api.json', line 125:
//
// "af_packet_set_l4_cksum_offload_reply",
// [
@@ -276,12 +254,8 @@ func (*AfPacketSetL4CksumOffloadReply) GetCrcString() string {
func (*AfPacketSetL4CksumOffloadReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewAfPacketSetL4CksumOffloadReply() api.Message {
- return &AfPacketSetL4CksumOffloadReply{}
-}
// AfPacketDump represents the VPP binary API message 'af_packet_dump'.
-// Generated from 'af_packet.api.json', line 143:
//
// "af_packet_dump",
// [
@@ -311,12 +285,8 @@ func (*AfPacketDump) GetCrcString() string {
func (*AfPacketDump) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewAfPacketDump() api.Message {
- return &AfPacketDump{}
-}
// AfPacketDetails represents the VPP binary API message 'af_packet_details'.
-// Generated from 'af_packet.api.json', line 161:
//
// "af_packet_details",
// [
@@ -354,9 +324,6 @@ func (*AfPacketDetails) GetCrcString() string {
func (*AfPacketDetails) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewAfPacketDetails() api.Message {
- return &AfPacketDetails{}
-}
/* Services */
diff --git a/examples/bin_api/interfaces/interfaces.ba.go b/examples/bin_api/interfaces/interfaces.ba.go
index 5ef58ed..6ab79d3 100644
--- a/examples/bin_api/interfaces/interfaces.ba.go
+++ b/examples/bin_api/interfaces/interfaces.ba.go
@@ -1,16 +1,14 @@
// Code generated by GoVPP binapi-generator. DO NOT EDIT.
-// source: interface.api.json
+// source: interface.api.json
/*
-Package interfaces is a generated VPP binary API of the 'interface' VPP module.
+ Package interfaces is a generated from VPP binary API module 'interface'.
-It is generated from this file:
- interface.api.json
+ It contains following objects:
+ 45 messages
+ 3 types
+ 22 services
-It contains these VPP binary API objects:
- 45 messages
- 3 types
- 22 services
*/
package interfaces
@@ -19,13 +17,13 @@ import "github.com/lunixbochs/struc"
import "bytes"
// Reference imports to suppress errors if they are not otherwise used.
+var _ = api.RegisterMessage
var _ = struc.Pack
var _ = bytes.NewBuffer
/* Types */
// VlibCounter represents the VPP binary API type 'vlib_counter'.
-// Generated from 'interface.api.json', line 1301:
//
// "vlib_counter",
// [
@@ -53,7 +51,6 @@ func (*VlibCounter) GetCrcString() string {
}
// VnetCombinedCounter represents the VPP binary API type 'vnet_combined_counter'.
-// Generated from 'interface.api.json', line 1315:
//
// "vnet_combined_counter",
// [
@@ -156,7 +153,6 @@ func (*VnetCombinedCounter) GetCrcString() string {
}
// VnetSimpleCounter represents the VPP binary API type 'vnet_simple_counter'.
-// Generated from 'interface.api.json', line 1389:
//
// "vnet_simple_counter",
// [
@@ -226,7 +222,6 @@ func (*VnetSimpleCounter) GetCrcString() string {
/* Messages */
// SwInterfaceSetFlags represents the VPP binary API message 'sw_interface_set_flags'.
-// Generated from 'interface.api.json', line 4:
//
// "sw_interface_set_flags",
// [
@@ -267,12 +262,8 @@ func (*SwInterfaceSetFlags) GetCrcString() string {
func (*SwInterfaceSetFlags) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewSwInterfaceSetFlags() api.Message {
- return &SwInterfaceSetFlags{}
-}
// SwInterfaceSetFlagsReply represents the VPP binary API message 'sw_interface_set_flags_reply'.
-// Generated from 'interface.api.json', line 30:
//
// "sw_interface_set_flags_reply",
// [
@@ -304,12 +295,8 @@ func (*SwInterfaceSetFlagsReply) GetCrcString() string {
func (*SwInterfaceSetFlagsReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewSwInterfaceSetFlagsReply() api.Message {
- return &SwInterfaceSetFlagsReply{}
-}
// HwInterfaceSetMtu represents the VPP binary API message 'hw_interface_set_mtu'.
-// Generated from 'interface.api.json', line 48:
//
// "hw_interface_set_mtu",
// [
@@ -350,12 +337,8 @@ func (*HwInterfaceSetMtu) GetCrcString() string {
func (*HwInterfaceSetMtu) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewHwInterfaceSetMtu() api.Message {
- return &HwInterfaceSetMtu{}
-}
// HwInterfaceSetMtuReply represents the VPP binary API message 'hw_interface_set_mtu_reply'.
-// Generated from 'interface.api.json', line 74:
//
// "hw_interface_set_mtu_reply",
// [
@@ -387,12 +370,8 @@ func (*HwInterfaceSetMtuReply) GetCrcString() string {
func (*HwInterfaceSetMtuReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewHwInterfaceSetMtuReply() api.Message {
- return &HwInterfaceSetMtuReply{}
-}
// SwInterfaceSetMtu represents the VPP binary API message 'sw_interface_set_mtu'.
-// Generated from 'interface.api.json', line 92:
//
// "sw_interface_set_mtu",
// [
@@ -434,12 +413,8 @@ func (*SwInterfaceSetMtu) GetCrcString() string {
func (*SwInterfaceSetMtu) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewSwInterfaceSetMtu() api.Message {
- return &SwInterfaceSetMtu{}
-}
// SwInterfaceSetMtuReply represents the VPP binary API message 'sw_interface_set_mtu_reply'.
-// Generated from 'interface.api.json', line 119:
//
// "sw_interface_set_mtu_reply",
// [
@@ -471,12 +446,8 @@ func (*SwInterfaceSetMtuReply) GetCrcString() string {
func (*SwInterfaceSetMtuReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewSwInterfaceSetMtuReply() api.Message {
- return &SwInterfaceSetMtuReply{}
-}
// SwInterfaceEvent represents the VPP binary API message 'sw_interface_event'.
-// Generated from 'interface.api.json', line 137:
//
// "sw_interface_event",
// [
@@ -528,12 +499,8 @@ func (*SwInterfaceEvent) GetCrcString() string {
func (*SwInterfaceEvent) GetMessageType() api.MessageType {
return api.EventMessage
}
-func NewSwInterfaceEvent() api.Message {
- return &SwInterfaceEvent{}
-}
// WantInterfaceEvents represents the VPP binary API message 'want_interface_events'.
-// Generated from 'interface.api.json', line 171:
//
// "want_interface_events",
// [
@@ -574,12 +541,8 @@ func (*WantInterfaceEvents) GetCrcString() string {
func (*WantInterfaceEvents) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewWantInterfaceEvents() api.Message {
- return &WantInterfaceEvents{}
-}
// WantInterfaceEventsReply represents the VPP binary API message 'want_interface_events_reply'.
-// Generated from 'interface.api.json', line 197:
//
// "want_interface_events_reply",
// [
@@ -611,12 +574,8 @@ func (*WantInterfaceEventsReply) GetCrcString() string {
func (*WantInterfaceEventsReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewWantInterfaceEventsReply() api.Message {
- return &WantInterfaceEventsReply{}
-}
// SwInterfaceDetails represents the VPP binary API message 'sw_interface_details'.
-// Generated from 'interface.api.json', line 215:
//
// "sw_interface_details",
// [
@@ -804,12 +763,8 @@ func (*SwInterfaceDetails) GetCrcString() string {
func (*SwInterfaceDetails) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewSwInterfaceDetails() api.Message {
- return &SwInterfaceDetails{}
-}
// SwInterfaceDump represents the VPP binary API message 'sw_interface_dump'.
-// Generated from 'interface.api.json', line 359:
//
// "sw_interface_dump",
// [
@@ -851,12 +806,8 @@ func (*SwInterfaceDump) GetCrcString() string {
func (*SwInterfaceDump) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewSwInterfaceDump() api.Message {
- return &SwInterfaceDump{}
-}
// SwInterfaceAddDelAddress represents the VPP binary API message 'sw_interface_add_del_address'.
-// Generated from 'interface.api.json', line 386:
//
// "sw_interface_add_del_address",
// [
@@ -918,12 +869,8 @@ func (*SwInterfaceAddDelAddress) GetCrcString() string {
func (*SwInterfaceAddDelAddress) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewSwInterfaceAddDelAddress() api.Message {
- return &SwInterfaceAddDelAddress{}
-}
// SwInterfaceAddDelAddressReply represents the VPP binary API message 'sw_interface_add_del_address_reply'.
-// Generated from 'interface.api.json', line 429:
//
// "sw_interface_add_del_address_reply",
// [
@@ -955,12 +902,8 @@ func (*SwInterfaceAddDelAddressReply) GetCrcString() string {
func (*SwInterfaceAddDelAddressReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewSwInterfaceAddDelAddressReply() api.Message {
- return &SwInterfaceAddDelAddressReply{}
-}
// SwInterfaceSetTable represents the VPP binary API message 'sw_interface_set_table'.
-// Generated from 'interface.api.json', line 447:
//
// "sw_interface_set_table",
// [
@@ -1006,12 +949,8 @@ func (*SwInterfaceSetTable) GetCrcString() string {
func (*SwInterfaceSetTable) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewSwInterfaceSetTable() api.Message {
- return &SwInterfaceSetTable{}
-}
// SwInterfaceSetTableReply represents the VPP binary API message 'sw_interface_set_table_reply'.
-// Generated from 'interface.api.json', line 477:
//
// "sw_interface_set_table_reply",
// [
@@ -1043,12 +982,8 @@ func (*SwInterfaceSetTableReply) GetCrcString() string {
func (*SwInterfaceSetTableReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewSwInterfaceSetTableReply() api.Message {
- return &SwInterfaceSetTableReply{}
-}
// SwInterfaceGetTable represents the VPP binary API message 'sw_interface_get_table'.
-// Generated from 'interface.api.json', line 495:
//
// "sw_interface_get_table",
// [
@@ -1089,12 +1024,8 @@ func (*SwInterfaceGetTable) GetCrcString() string {
func (*SwInterfaceGetTable) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewSwInterfaceGetTable() api.Message {
- return &SwInterfaceGetTable{}
-}
// SwInterfaceGetTableReply represents the VPP binary API message 'sw_interface_get_table_reply'.
-// Generated from 'interface.api.json', line 521:
//
// "sw_interface_get_table_reply",
// [
@@ -1131,12 +1062,8 @@ func (*SwInterfaceGetTableReply) GetCrcString() string {
func (*SwInterfaceGetTableReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewSwInterfaceGetTableReply() api.Message {
- return &SwInterfaceGetTableReply{}
-}
// SwInterfaceSetUnnumbered represents the VPP binary API message 'sw_interface_set_unnumbered'.
-// Generated from 'interface.api.json', line 543:
//
// "sw_interface_set_unnumbered",
// [
@@ -1182,12 +1109,8 @@ func (*SwInterfaceSetUnnumbered) GetCrcString() string {
func (*SwInterfaceSetUnnumbered) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewSwInterfaceSetUnnumbered() api.Message {
- return &SwInterfaceSetUnnumbered{}
-}
// SwInterfaceSetUnnumberedReply represents the VPP binary API message 'sw_interface_set_unnumbered_reply'.
-// Generated from 'interface.api.json', line 573:
//
// "sw_interface_set_unnumbered_reply",
// [
@@ -1219,12 +1142,8 @@ func (*SwInterfaceSetUnnumberedReply) GetCrcString() string {
func (*SwInterfaceSetUnnumberedReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewSwInterfaceSetUnnumberedReply() api.Message {
- return &SwInterfaceSetUnnumberedReply{}
-}
// SwInterfaceClearStats represents the VPP binary API message 'sw_interface_clear_stats'.
-// Generated from 'interface.api.json', line 591:
//
// "sw_interface_clear_stats",
// [
@@ -1260,12 +1179,8 @@ func (*SwInterfaceClearStats) GetCrcString() string {
func (*SwInterfaceClearStats) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewSwInterfaceClearStats() api.Message {
- return &SwInterfaceClearStats{}
-}
// SwInterfaceClearStatsReply represents the VPP binary API message 'sw_interface_clear_stats_reply'.
-// Generated from 'interface.api.json', line 613:
//
// "sw_interface_clear_stats_reply",
// [
@@ -1297,12 +1212,8 @@ func (*SwInterfaceClearStatsReply) GetCrcString() string {
func (*SwInterfaceClearStatsReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewSwInterfaceClearStatsReply() api.Message {
- return &SwInterfaceClearStatsReply{}
-}
// SwInterfaceTagAddDel represents the VPP binary API message 'sw_interface_tag_add_del'.
-// Generated from 'interface.api.json', line 631:
//
// "sw_interface_tag_add_del",
// [
@@ -1349,12 +1260,8 @@ func (*SwInterfaceTagAddDel) GetCrcString() string {
func (*SwInterfaceTagAddDel) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewSwInterfaceTagAddDel() api.Message {
- return &SwInterfaceTagAddDel{}
-}
// SwInterfaceTagAddDelReply represents the VPP binary API message 'sw_interface_tag_add_del_reply'.
-// Generated from 'interface.api.json', line 662:
//
// "sw_interface_tag_add_del_reply",
// [
@@ -1386,12 +1293,8 @@ func (*SwInterfaceTagAddDelReply) GetCrcString() string {
func (*SwInterfaceTagAddDelReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewSwInterfaceTagAddDelReply() api.Message {
- return &SwInterfaceTagAddDelReply{}
-}
// SwInterfaceSetMacAddress represents the VPP binary API message 'sw_interface_set_mac_address'.
-// Generated from 'interface.api.json', line 680:
//
// "sw_interface_set_mac_address",
// [
@@ -1433,12 +1336,8 @@ func (*SwInterfaceSetMacAddress) GetCrcString() string {
func (*SwInterfaceSetMacAddress) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewSwInterfaceSetMacAddress() api.Message {
- return &SwInterfaceSetMacAddress{}
-}
// SwInterfaceSetMacAddressReply represents the VPP binary API message 'sw_interface_set_mac_address_reply'.
-// Generated from 'interface.api.json', line 707:
//
// "sw_interface_set_mac_address_reply",
// [
@@ -1470,12 +1369,8 @@ func (*SwInterfaceSetMacAddressReply) GetCrcString() string {
func (*SwInterfaceSetMacAddressReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewSwInterfaceSetMacAddressReply() api.Message {
- return &SwInterfaceSetMacAddressReply{}
-}
// SwInterfaceGetMacAddress represents the VPP binary API message 'sw_interface_get_mac_address'.
-// Generated from 'interface.api.json', line 725:
//
// "sw_interface_get_mac_address",
// [
@@ -1511,12 +1406,8 @@ func (*SwInterfaceGetMacAddress) GetCrcString() string {
func (*SwInterfaceGetMacAddress) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewSwInterfaceGetMacAddress() api.Message {
- return &SwInterfaceGetMacAddress{}
-}
// SwInterfaceGetMacAddressReply represents the VPP binary API message 'sw_interface_get_mac_address_reply'.
-// Generated from 'interface.api.json', line 747:
//
// "sw_interface_get_mac_address_reply",
// [
@@ -1554,12 +1445,8 @@ func (*SwInterfaceGetMacAddressReply) GetCrcString() string {
func (*SwInterfaceGetMacAddressReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewSwInterfaceGetMacAddressReply() api.Message {
- return &SwInterfaceGetMacAddressReply{}
-}
// SwInterfaceSetRxMode represents the VPP binary API message 'sw_interface_set_rx_mode'.
-// Generated from 'interface.api.json', line 770:
//
// "sw_interface_set_rx_mode",
// [
@@ -1610,12 +1497,8 @@ func (*SwInterfaceSetRxMode) GetCrcString() string {
func (*SwInterfaceSetRxMode) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewSwInterfaceSetRxMode() api.Message {
- return &SwInterfaceSetRxMode{}
-}
// SwInterfaceSetRxModeReply represents the VPP binary API message 'sw_interface_set_rx_mode_reply'.
-// Generated from 'interface.api.json', line 804:
//
// "sw_interface_set_rx_mode_reply",
// [
@@ -1647,12 +1530,8 @@ func (*SwInterfaceSetRxModeReply) GetCrcString() string {
func (*SwInterfaceSetRxModeReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewSwInterfaceSetRxModeReply() api.Message {
- return &SwInterfaceSetRxModeReply{}
-}
// InterfaceNameRenumber represents the VPP binary API message 'interface_name_renumber'.
-// Generated from 'interface.api.json', line 822:
//
// "interface_name_renumber",
// [
@@ -1693,12 +1572,8 @@ func (*InterfaceNameRenumber) GetCrcString() string {
func (*InterfaceNameRenumber) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewInterfaceNameRenumber() api.Message {
- return &InterfaceNameRenumber{}
-}
// InterfaceNameRenumberReply represents the VPP binary API message 'interface_name_renumber_reply'.
-// Generated from 'interface.api.json', line 848:
//
// "interface_name_renumber_reply",
// [
@@ -1730,12 +1605,8 @@ func (*InterfaceNameRenumberReply) GetCrcString() string {
func (*InterfaceNameRenumberReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewInterfaceNameRenumberReply() api.Message {
- return &InterfaceNameRenumberReply{}
-}
// CreateSubif represents the VPP binary API message 'create_subif'.
-// Generated from 'interface.api.json', line 866:
//
// "create_subif",
// [
@@ -1826,12 +1697,8 @@ func (*CreateSubif) GetCrcString() string {
func (*CreateSubif) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewCreateSubif() api.Message {
- return &CreateSubif{}
-}
// CreateSubifReply represents the VPP binary API message 'create_subif_reply'.
-// Generated from 'interface.api.json', line 932:
//
// "create_subif_reply",
// [
@@ -1868,12 +1735,8 @@ func (*CreateSubifReply) GetCrcString() string {
func (*CreateSubifReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewCreateSubifReply() api.Message {
- return &CreateSubifReply{}
-}
// CreateVlanSubif represents the VPP binary API message 'create_vlan_subif'.
-// Generated from 'interface.api.json', line 954:
//
// "create_vlan_subif",
// [
@@ -1914,12 +1777,8 @@ func (*CreateVlanSubif) GetCrcString() string {
func (*CreateVlanSubif) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewCreateVlanSubif() api.Message {
- return &CreateVlanSubif{}
-}
// CreateVlanSubifReply represents the VPP binary API message 'create_vlan_subif_reply'.
-// Generated from 'interface.api.json', line 980:
//
// "create_vlan_subif_reply",
// [
@@ -1956,12 +1815,8 @@ func (*CreateVlanSubifReply) GetCrcString() string {
func (*CreateVlanSubifReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewCreateVlanSubifReply() api.Message {
- return &CreateVlanSubifReply{}
-}
// DeleteSubif represents the VPP binary API message 'delete_subif'.
-// Generated from 'interface.api.json', line 1002:
//
// "delete_subif",
// [
@@ -1997,12 +1852,8 @@ func (*DeleteSubif) GetCrcString() string {
func (*DeleteSubif) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewDeleteSubif() api.Message {
- return &DeleteSubif{}
-}
// DeleteSubifReply represents the VPP binary API message 'delete_subif_reply'.
-// Generated from 'interface.api.json', line 1024:
//
// "delete_subif_reply",
// [
@@ -2034,12 +1885,8 @@ func (*DeleteSubifReply) GetCrcString() string {
func (*DeleteSubifReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewDeleteSubifReply() api.Message {
- return &DeleteSubifReply{}
-}
// CreateLoopback represents the VPP binary API message 'create_loopback'.
-// Generated from 'interface.api.json', line 1042:
//
// "create_loopback",
// [
@@ -2076,12 +1923,8 @@ func (*CreateLoopback) GetCrcString() string {
func (*CreateLoopback) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewCreateLoopback() api.Message {
- return &CreateLoopback{}
-}
// CreateLoopbackReply represents the VPP binary API message 'create_loopback_reply'.
-// Generated from 'interface.api.json', line 1065:
//
// "create_loopback_reply",
// [
@@ -2118,12 +1961,8 @@ func (*CreateLoopbackReply) GetCrcString() string {
func (*CreateLoopbackReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewCreateLoopbackReply() api.Message {
- return &CreateLoopbackReply{}
-}
// CreateLoopbackInstance represents the VPP binary API message 'create_loopback_instance'.
-// Generated from 'interface.api.json', line 1087:
//
// "create_loopback_instance",
// [
@@ -2170,12 +2009,8 @@ func (*CreateLoopbackInstance) GetCrcString() string {
func (*CreateLoopbackInstance) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewCreateLoopbackInstance() api.Message {
- return &CreateLoopbackInstance{}
-}
// CreateLoopbackInstanceReply represents the VPP binary API message 'create_loopback_instance_reply'.
-// Generated from 'interface.api.json', line 1118:
//
// "create_loopback_instance_reply",
// [
@@ -2212,12 +2047,8 @@ func (*CreateLoopbackInstanceReply) GetCrcString() string {
func (*CreateLoopbackInstanceReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewCreateLoopbackInstanceReply() api.Message {
- return &CreateLoopbackInstanceReply{}
-}
// DeleteLoopback represents the VPP binary API message 'delete_loopback'.
-// Generated from 'interface.api.json', line 1140:
//
// "delete_loopback",
// [
@@ -2253,12 +2084,8 @@ func (*DeleteLoopback) GetCrcString() string {
func (*DeleteLoopback) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewDeleteLoopback() api.Message {
- return &DeleteLoopback{}
-}
// DeleteLoopbackReply represents the VPP binary API message 'delete_loopback_reply'.
-// Generated from 'interface.api.json', line 1162:
//
// "delete_loopback_reply",
// [
@@ -2290,12 +2117,8 @@ func (*DeleteLoopbackReply) GetCrcString() string {
func (*DeleteLoopbackReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewDeleteLoopbackReply() api.Message {
- return &DeleteLoopbackReply{}
-}
// CollectDetailedInterfaceStats represents the VPP binary API message 'collect_detailed_interface_stats'.
-// Generated from 'interface.api.json', line 1180:
//
// "collect_detailed_interface_stats",
// [
@@ -2336,12 +2159,8 @@ func (*CollectDetailedInterfaceStats) GetCrcString() string {
func (*CollectDetailedInterfaceStats) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewCollectDetailedInterfaceStats() api.Message {
- return &CollectDetailedInterfaceStats{}
-}
// CollectDetailedInterfaceStatsReply represents the VPP binary API message 'collect_detailed_interface_stats_reply'.
-// Generated from 'interface.api.json', line 1206:
//
// "collect_detailed_interface_stats_reply",
// [
@@ -2373,9 +2192,6 @@ func (*CollectDetailedInterfaceStatsReply) GetCrcString() string {
func (*CollectDetailedInterfaceStatsReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewCollectDetailedInterfaceStatsReply() api.Message {
- return &CollectDetailedInterfaceStatsReply{}
-}
/* Services */
diff --git a/examples/bin_api/ip/ip.ba.go b/examples/bin_api/ip/ip.ba.go
index c980b6a..abbddb9 100644
--- a/examples/bin_api/ip/ip.ba.go
+++ b/examples/bin_api/ip/ip.ba.go
@@ -1,18 +1,16 @@
// Code generated by GoVPP binapi-generator. DO NOT EDIT.
-// source: ip.api.json
+// source: ip.api.json
/*
-Package ip is a generated VPP binary API of the 'ip' VPP module.
+ Package ip is a generated from VPP binary API module 'ip'.
-It is generated from this file:
- ip.api.json
+ It contains following objects:
+ 87 messages
+ 8 types
+ 1 enum
+ 1 union
+ 42 services
-It contains these VPP binary API objects:
- 87 messages
- 8 types
- 1 enum
- 1 union
- 42 services
*/
package ip
@@ -21,13 +19,13 @@ import "github.com/lunixbochs/struc"
import "bytes"
// Reference imports to suppress errors if they are not otherwise used.
+var _ = api.RegisterMessage
var _ = struc.Pack
var _ = bytes.NewBuffer
/* Enums */
// AddressFamily represents the VPP binary API enum 'address_family'.
-// Generated from 'ip.api.json', line 2727:
//
// "address_family",
// [
@@ -52,7 +50,6 @@ const (
/* Types */
// IP4Address represents the VPP binary API type 'ip4_address'.
-// Generated from 'ip.api.json', line 2743:
//
// "ip4_address",
// [
@@ -76,7 +73,6 @@ func (*IP4Address) GetCrcString() string {
}
// IP6Address represents the VPP binary API type 'ip6_address'.
-// Generated from 'ip.api.json', line 2754:
//
// "ip6_address",
// [
@@ -100,7 +96,6 @@ func (*IP6Address) GetCrcString() string {
}
// Address represents the VPP binary API type 'address'.
-// Generated from 'ip.api.json', line 2765:
//
// "address",
// [
@@ -128,7 +123,6 @@ func (*Address) GetCrcString() string {
}
// Prefix represents the VPP binary API type 'prefix'.
-// Generated from 'ip.api.json', line 2779:
//
// "prefix",
// [
@@ -156,7 +150,6 @@ func (*Prefix) GetCrcString() string {
}
// FibMplsLabel represents the VPP binary API type 'fib_mpls_label'.
-// Generated from 'ip.api.json', line 2793:
//
// "fib_mpls_label",
// [
@@ -194,7 +187,6 @@ func (*FibMplsLabel) GetCrcString() string {
}
// FibPath represents the VPP binary API type 'fib_path'.
-// Generated from 'ip.api.json', line 2815:
//
// "fib_path",
// [
@@ -314,7 +306,6 @@ func (*FibPath) GetCrcString() string {
}
// IP6RaPrefixInfo represents the VPP binary API type 'ip6_ra_prefix_info'.
-// Generated from 'ip.api.json', line 2903:
//
// "ip6_ra_prefix_info",
// [
@@ -358,7 +349,6 @@ func (*IP6RaPrefixInfo) GetCrcString() string {
}
// ProxyArp represents the VPP binary API type 'proxy_arp'.
-// Generated from 'ip.api.json', line 2930:
//
// "proxy_arp",
// [
@@ -395,7 +385,6 @@ func (*ProxyArp) GetCrcString() string {
/* Unions */
// AddressUnion represents the VPP binary API union 'address_union'.
-// Generated from 'ip.api.json', line 2562:
//
// "address_union",
// [
@@ -450,7 +439,6 @@ func (u *AddressUnion) GetIP6() (a IP6Address) {
/* Messages */
// IPTableAddDel represents the VPP binary API message 'ip_table_add_del'.
-// Generated from 'ip.api.json', line 4:
//
// "ip_table_add_del",
// [
@@ -502,12 +490,8 @@ func (*IPTableAddDel) GetCrcString() string {
func (*IPTableAddDel) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewIPTableAddDel() api.Message {
- return &IPTableAddDel{}
-}
// IPTableAddDelReply represents the VPP binary API message 'ip_table_add_del_reply'.
-// Generated from 'ip.api.json', line 39:
//
// "ip_table_add_del_reply",
// [
@@ -539,12 +523,8 @@ func (*IPTableAddDelReply) GetCrcString() string {
func (*IPTableAddDelReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewIPTableAddDelReply() api.Message {
- return &IPTableAddDelReply{}
-}
// IPFibDump represents the VPP binary API message 'ip_fib_dump'.
-// Generated from 'ip.api.json', line 57:
//
// "ip_fib_dump",
// [
@@ -574,12 +554,8 @@ func (*IPFibDump) GetCrcString() string {
func (*IPFibDump) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewIPFibDump() api.Message {
- return &IPFibDump{}
-}
// IPFibDetails represents the VPP binary API message 'ip_fib_details'.
-// Generated from 'ip.api.json', line 75:
//
// "ip_fib_details",
// [
@@ -640,12 +616,8 @@ func (*IPFibDetails) GetCrcString() string {
func (*IPFibDetails) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewIPFibDetails() api.Message {
- return &IPFibDetails{}
-}
// IP6FibDump represents the VPP binary API message 'ip6_fib_dump'.
-// Generated from 'ip.api.json', line 117:
//
// "ip6_fib_dump",
// [
@@ -675,12 +647,8 @@ func (*IP6FibDump) GetCrcString() string {
func (*IP6FibDump) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewIP6FibDump() api.Message {
- return &IP6FibDump{}
-}
// IP6FibDetails represents the VPP binary API message 'ip6_fib_details'.
-// Generated from 'ip.api.json', line 135:
//
// "ip6_fib_details",
// [
@@ -741,12 +709,8 @@ func (*IP6FibDetails) GetCrcString() string {
func (*IP6FibDetails) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewIP6FibDetails() api.Message {
- return &IP6FibDetails{}
-}
// IPNeighborDump represents the VPP binary API message 'ip_neighbor_dump'.
-// Generated from 'ip.api.json', line 177:
//
// "ip_neighbor_dump",
// [
@@ -787,12 +751,8 @@ func (*IPNeighborDump) GetCrcString() string {
func (*IPNeighborDump) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewIPNeighborDump() api.Message {
- return &IPNeighborDump{}
-}
// IPNeighborDetails represents the VPP binary API message 'ip_neighbor_details'.
-// Generated from 'ip.api.json', line 203:
//
// "ip_neighbor_details",
// [
@@ -846,12 +806,8 @@ func (*IPNeighborDetails) GetCrcString() string {
func (*IPNeighborDetails) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewIPNeighborDetails() api.Message {
- return &IPNeighborDetails{}
-}
// IPNeighborAddDel represents the VPP binary API message 'ip_neighbor_add_del'.
-// Generated from 'ip.api.json', line 239:
//
// "ip_neighbor_add_del",
// [
@@ -919,12 +875,8 @@ func (*IPNeighborAddDel) GetCrcString() string {
func (*IPNeighborAddDel) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewIPNeighborAddDel() api.Message {
- return &IPNeighborAddDel{}
-}
// IPNeighborAddDelReply represents the VPP binary API message 'ip_neighbor_add_del_reply'.
-// Generated from 'ip.api.json', line 287:
//
// "ip_neighbor_add_del_reply",
// [
@@ -956,12 +908,8 @@ func (*IPNeighborAddDelReply) GetCrcString() string {
func (*IPNeighborAddDelReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewIPNeighborAddDelReply() api.Message {
- return &IPNeighborAddDelReply{}
-}
// SetIPFlowHash represents the VPP binary API message 'set_ip_flow_hash'.
-// Generated from 'ip.api.json', line 305:
//
// "set_ip_flow_hash",
// [
@@ -1032,12 +980,8 @@ func (*SetIPFlowHash) GetCrcString() string {
func (*SetIPFlowHash) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewSetIPFlowHash() api.Message {
- return &SetIPFlowHash{}
-}
// SetIPFlowHashReply represents the VPP binary API message 'set_ip_flow_hash_reply'.
-// Generated from 'ip.api.json', line 355:
//
// "set_ip_flow_hash_reply",
// [
@@ -1069,12 +1013,8 @@ func (*SetIPFlowHashReply) GetCrcString() string {
func (*SetIPFlowHashReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewSetIPFlowHashReply() api.Message {
- return &SetIPFlowHashReply{}
-}
// SwInterfaceIP6ndRaConfig represents the VPP binary API message 'sw_interface_ip6nd_ra_config'.
-// Generated from 'ip.api.json', line 373:
//
// "sw_interface_ip6nd_ra_config",
// [
@@ -1175,12 +1115,8 @@ func (*SwInterfaceIP6ndRaConfig) GetCrcString() string {
func (*SwInterfaceIP6ndRaConfig) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewSwInterfaceIP6ndRaConfig() api.Message {
- return &SwInterfaceIP6ndRaConfig{}
-}
// SwInterfaceIP6ndRaConfigReply represents the VPP binary API message 'sw_interface_ip6nd_ra_config_reply'.
-// Generated from 'ip.api.json', line 447:
//
// "sw_interface_ip6nd_ra_config_reply",
// [
@@ -1212,12 +1148,8 @@ func (*SwInterfaceIP6ndRaConfigReply) GetCrcString() string {
func (*SwInterfaceIP6ndRaConfigReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewSwInterfaceIP6ndRaConfigReply() api.Message {
- return &SwInterfaceIP6ndRaConfigReply{}
-}
// SwInterfaceIP6ndRaPrefix represents the VPP binary API message 'sw_interface_ip6nd_ra_prefix'.
-// Generated from 'ip.api.json', line 465:
//
// "sw_interface_ip6nd_ra_prefix",
// [
@@ -1304,12 +1236,8 @@ func (*SwInterfaceIP6ndRaPrefix) GetCrcString() string {
func (*SwInterfaceIP6ndRaPrefix) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewSwInterfaceIP6ndRaPrefix() api.Message {
- return &SwInterfaceIP6ndRaPrefix{}
-}
// SwInterfaceIP6ndRaPrefixReply represents the VPP binary API message 'sw_interface_ip6nd_ra_prefix_reply'.
-// Generated from 'ip.api.json', line 528:
//
// "sw_interface_ip6nd_ra_prefix_reply",
// [
@@ -1341,12 +1269,8 @@ func (*SwInterfaceIP6ndRaPrefixReply) GetCrcString() string {
func (*SwInterfaceIP6ndRaPrefixReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewSwInterfaceIP6ndRaPrefixReply() api.Message {
- return &SwInterfaceIP6ndRaPrefixReply{}
-}
// IP6ndProxyAddDel represents the VPP binary API message 'ip6nd_proxy_add_del'.
-// Generated from 'ip.api.json', line 546:
//
// "ip6nd_proxy_add_del",
// [
@@ -1393,12 +1317,8 @@ func (*IP6ndProxyAddDel) GetCrcString() string {
func (*IP6ndProxyAddDel) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewIP6ndProxyAddDel() api.Message {
- return &IP6ndProxyAddDel{}
-}
// IP6ndProxyAddDelReply represents the VPP binary API message 'ip6nd_proxy_add_del_reply'.
-// Generated from 'ip.api.json', line 577:
//
// "ip6nd_proxy_add_del_reply",
// [
@@ -1430,12 +1350,8 @@ func (*IP6ndProxyAddDelReply) GetCrcString() string {
func (*IP6ndProxyAddDelReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewIP6ndProxyAddDelReply() api.Message {
- return &IP6ndProxyAddDelReply{}
-}
// IP6ndProxyDetails represents the VPP binary API message 'ip6nd_proxy_details'.
-// Generated from 'ip.api.json', line 595:
//
// "ip6nd_proxy_details",
// [
@@ -1477,12 +1393,8 @@ func (*IP6ndProxyDetails) GetCrcString() string {
func (*IP6ndProxyDetails) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewIP6ndProxyDetails() api.Message {
- return &IP6ndProxyDetails{}
-}
// IP6ndProxyDump represents the VPP binary API message 'ip6nd_proxy_dump'.
-// Generated from 'ip.api.json', line 622:
//
// "ip6nd_proxy_dump",
// [
@@ -1512,12 +1424,8 @@ func (*IP6ndProxyDump) GetCrcString() string {
func (*IP6ndProxyDump) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewIP6ndProxyDump() api.Message {
- return &IP6ndProxyDump{}
-}
// IP6ndSendRouterSolicitation represents the VPP binary API message 'ip6nd_send_router_solicitation'.
-// Generated from 'ip.api.json', line 640:
//
// "ip6nd_send_router_solicitation",
// [
@@ -1578,12 +1486,8 @@ func (*IP6ndSendRouterSolicitation) GetCrcString() string {
func (*IP6ndSendRouterSolicitation) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewIP6ndSendRouterSolicitation() api.Message {
- return &IP6ndSendRouterSolicitation{}
-}
// IP6ndSendRouterSolicitationReply represents the VPP binary API message 'ip6nd_send_router_solicitation_reply'.
-// Generated from 'ip.api.json', line 682:
//
// "ip6nd_send_router_solicitation_reply",
// [
@@ -1615,12 +1519,8 @@ func (*IP6ndSendRouterSolicitationReply) GetCrcString() string {
func (*IP6ndSendRouterSolicitationReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewIP6ndSendRouterSolicitationReply() api.Message {
- return &IP6ndSendRouterSolicitationReply{}
-}
// SwInterfaceIP6EnableDisable represents the VPP binary API message 'sw_interface_ip6_enable_disable'.
-// Generated from 'ip.api.json', line 700:
//
// "sw_interface_ip6_enable_disable",
// [
@@ -1661,12 +1561,8 @@ func (*SwInterfaceIP6EnableDisable) GetCrcString() string {
func (*SwInterfaceIP6EnableDisable) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewSwInterfaceIP6EnableDisable() api.Message {
- return &SwInterfaceIP6EnableDisable{}
-}
// SwInterfaceIP6EnableDisableReply represents the VPP binary API message 'sw_interface_ip6_enable_disable_reply'.
-// Generated from 'ip.api.json', line 726:
//
// "sw_interface_ip6_enable_disable_reply",
// [
@@ -1698,12 +1594,8 @@ func (*SwInterfaceIP6EnableDisableReply) GetCrcString() string {
func (*SwInterfaceIP6EnableDisableReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewSwInterfaceIP6EnableDisableReply() api.Message {
- return &SwInterfaceIP6EnableDisableReply{}
-}
// SwInterfaceIP6SetLinkLocalAddress represents the VPP binary API message 'sw_interface_ip6_set_link_local_address'.
-// Generated from 'ip.api.json', line 744:
//
// "sw_interface_ip6_set_link_local_address",
// [
@@ -1745,12 +1637,8 @@ func (*SwInterfaceIP6SetLinkLocalAddress) GetCrcString() string {
func (*SwInterfaceIP6SetLinkLocalAddress) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewSwInterfaceIP6SetLinkLocalAddress() api.Message {
- return &SwInterfaceIP6SetLinkLocalAddress{}
-}
// SwInterfaceIP6SetLinkLocalAddressReply represents the VPP binary API message 'sw_interface_ip6_set_link_local_address_reply'.
-// Generated from 'ip.api.json', line 771:
//
// "sw_interface_ip6_set_link_local_address_reply",
// [
@@ -1782,12 +1670,8 @@ func (*SwInterfaceIP6SetLinkLocalAddressReply) GetCrcString() string {
func (*SwInterfaceIP6SetLinkLocalAddressReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewSwInterfaceIP6SetLinkLocalAddressReply() api.Message {
- return &SwInterfaceIP6SetLinkLocalAddressReply{}
-}
// IPAddDelRoute represents the VPP binary API message 'ip_add_del_route'.
-// Generated from 'ip.api.json', line 789:
//
// "ip_add_del_route",
// [
@@ -1957,12 +1841,8 @@ func (*IPAddDelRoute) GetCrcString() string {
func (*IPAddDelRoute) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewIPAddDelRoute() api.Message {
- return &IPAddDelRoute{}
-}
// IPAddDelRouteReply represents the VPP binary API message 'ip_add_del_route_reply'.
-// Generated from 'ip.api.json', line 919:
//
// "ip_add_del_route_reply",
// [
@@ -1994,12 +1874,8 @@ func (*IPAddDelRouteReply) GetCrcString() string {
func (*IPAddDelRouteReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewIPAddDelRouteReply() api.Message {
- return &IPAddDelRouteReply{}
-}
// IPMrouteAddDel represents the VPP binary API message 'ip_mroute_add_del'.
-// Generated from 'ip.api.json', line 937:
//
// "ip_mroute_add_del",
// [
@@ -2103,12 +1979,8 @@ func (*IPMrouteAddDel) GetCrcString() string {
func (*IPMrouteAddDel) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewIPMrouteAddDel() api.Message {
- return &IPMrouteAddDel{}
-}
// IPMrouteAddDelReply represents the VPP binary API message 'ip_mroute_add_del_reply'.
-// Generated from 'ip.api.json', line 1014:
//
// "ip_mroute_add_del_reply",
// [
@@ -2140,12 +2012,8 @@ func (*IPMrouteAddDelReply) GetCrcString() string {
func (*IPMrouteAddDelReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewIPMrouteAddDelReply() api.Message {
- return &IPMrouteAddDelReply{}
-}
// IPMfibDump represents the VPP binary API message 'ip_mfib_dump'.
-// Generated from 'ip.api.json', line 1032:
//
// "ip_mfib_dump",
// [
@@ -2175,12 +2043,8 @@ func (*IPMfibDump) GetCrcString() string {
func (*IPMfibDump) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewIPMfibDump() api.Message {
- return &IPMfibDump{}
-}
// IPMfibDetails represents the VPP binary API message 'ip_mfib_details'.
-// Generated from 'ip.api.json', line 1050:
//
// "ip_mfib_details",
// [
@@ -2251,12 +2115,8 @@ func (*IPMfibDetails) GetCrcString() string {
func (*IPMfibDetails) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewIPMfibDetails() api.Message {
- return &IPMfibDetails{}
-}
// IP6MfibDump represents the VPP binary API message 'ip6_mfib_dump'.
-// Generated from 'ip.api.json', line 1100:
//
// "ip6_mfib_dump",
// [
@@ -2286,12 +2146,8 @@ func (*IP6MfibDump) GetCrcString() string {
func (*IP6MfibDump) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewIP6MfibDump() api.Message {
- return &IP6MfibDump{}
-}
// IP6MfibDetails represents the VPP binary API message 'ip6_mfib_details'.
-// Generated from 'ip.api.json', line 1118:
//
// "ip6_mfib_details",
// [
@@ -2352,12 +2208,8 @@ func (*IP6MfibDetails) GetCrcString() string {
func (*IP6MfibDetails) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewIP6MfibDetails() api.Message {
- return &IP6MfibDetails{}
-}
// IPAddressDetails represents the VPP binary API message 'ip_address_details'.
-// Generated from 'ip.api.json', line 1160:
//
// "ip_address_details",
// [
@@ -2409,12 +2261,8 @@ func (*IPAddressDetails) GetCrcString() string {
func (*IPAddressDetails) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewIPAddressDetails() api.Message {
- return &IPAddressDetails{}
-}
// IPAddressDump represents the VPP binary API message 'ip_address_dump'.
-// Generated from 'ip.api.json', line 1195:
//
// "ip_address_dump",
// [
@@ -2455,12 +2303,8 @@ func (*IPAddressDump) GetCrcString() string {
func (*IPAddressDump) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewIPAddressDump() api.Message {
- return &IPAddressDump{}
-}
// IPUnnumberedDetails represents the VPP binary API message 'ip_unnumbered_details'.
-// Generated from 'ip.api.json', line 1221:
//
// "ip_unnumbered_details",
// [
@@ -2501,12 +2345,8 @@ func (*IPUnnumberedDetails) GetCrcString() string {
func (*IPUnnumberedDetails) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewIPUnnumberedDetails() api.Message {
- return &IPUnnumberedDetails{}
-}
// IPUnnumberedDump represents the VPP binary API message 'ip_unnumbered_dump'.
-// Generated from 'ip.api.json', line 1247:
//
// "ip_unnumbered_dump",
// [
@@ -2542,12 +2382,8 @@ func (*IPUnnumberedDump) GetCrcString() string {
func (*IPUnnumberedDump) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewIPUnnumberedDump() api.Message {
- return &IPUnnumberedDump{}
-}
// IPDetails represents the VPP binary API message 'ip_details'.
-// Generated from 'ip.api.json', line 1269:
//
// "ip_details",
// [
@@ -2585,12 +2421,8 @@ func (*IPDetails) GetCrcString() string {
func (*IPDetails) GetMessageType() api.MessageType {
return api.OtherMessage
}
-func NewIPDetails() api.Message {
- return &IPDetails{}
-}
// IPDump represents the VPP binary API message 'ip_dump'.
-// Generated from 'ip.api.json', line 1291:
//
// "ip_dump",
// [
@@ -2626,12 +2458,8 @@ func (*IPDump) GetCrcString() string {
func (*IPDump) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewIPDump() api.Message {
- return &IPDump{}
-}
// MfibSignalDump represents the VPP binary API message 'mfib_signal_dump'.
-// Generated from 'ip.api.json', line 1313:
//
// "mfib_signal_dump",
// [
@@ -2661,12 +2489,8 @@ func (*MfibSignalDump) GetCrcString() string {
func (*MfibSignalDump) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewMfibSignalDump() api.Message {
- return &MfibSignalDump{}
-}
// MfibSignalDetails represents the VPP binary API message 'mfib_signal_details'.
-// Generated from 'ip.api.json', line 1331:
//
// "mfib_signal_details",
// [
@@ -2735,12 +2559,8 @@ func (*MfibSignalDetails) GetCrcString() string {
func (*MfibSignalDetails) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewMfibSignalDetails() api.Message {
- return &MfibSignalDetails{}
-}
// IPPuntPolice represents the VPP binary API message 'ip_punt_police'.
-// Generated from 'ip.api.json', line 1380:
//
// "ip_punt_police",
// [
@@ -2786,12 +2606,8 @@ func (*IPPuntPolice) GetCrcString() string {
func (*IPPuntPolice) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewIPPuntPolice() api.Message {
- return &IPPuntPolice{}
-}
// IPPuntPoliceReply represents the VPP binary API message 'ip_punt_police_reply'.
-// Generated from 'ip.api.json', line 1410:
//
// "ip_punt_police_reply",
// [
@@ -2823,12 +2639,8 @@ func (*IPPuntPoliceReply) GetCrcString() string {
func (*IPPuntPoliceReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewIPPuntPoliceReply() api.Message {
- return &IPPuntPoliceReply{}
-}
// IPPuntRedirect represents the VPP binary API message 'ip_punt_redirect'.
-// Generated from 'ip.api.json', line 1428:
//
// "ip_punt_redirect",
// [
@@ -2885,12 +2697,8 @@ func (*IPPuntRedirect) GetCrcString() string {
func (*IPPuntRedirect) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewIPPuntRedirect() api.Message {
- return &IPPuntRedirect{}
-}
// IPPuntRedirectReply represents the VPP binary API message 'ip_punt_redirect_reply'.
-// Generated from 'ip.api.json', line 1467:
//
// "ip_punt_redirect_reply",
// [
@@ -2922,12 +2730,8 @@ func (*IPPuntRedirectReply) GetCrcString() string {
func (*IPPuntRedirectReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewIPPuntRedirectReply() api.Message {
- return &IPPuntRedirectReply{}
-}
// IPContainerProxyAddDel represents the VPP binary API message 'ip_container_proxy_add_del'.
-// Generated from 'ip.api.json', line 1485:
//
// "ip_container_proxy_add_del",
// [
@@ -2984,12 +2788,8 @@ func (*IPContainerProxyAddDel) GetCrcString() string {
func (*IPContainerProxyAddDel) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewIPContainerProxyAddDel() api.Message {
- return &IPContainerProxyAddDel{}
-}
// IPContainerProxyAddDelReply represents the VPP binary API message 'ip_container_proxy_add_del_reply'.
-// Generated from 'ip.api.json', line 1524:
//
// "ip_container_proxy_add_del_reply",
// [
@@ -3021,12 +2821,8 @@ func (*IPContainerProxyAddDelReply) GetCrcString() string {
func (*IPContainerProxyAddDelReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewIPContainerProxyAddDelReply() api.Message {
- return &IPContainerProxyAddDelReply{}
-}
// IPSourceAndPortRangeCheckAddDel represents the VPP binary API message 'ip_source_and_port_range_check_add_del'.
-// Generated from 'ip.api.json', line 1542:
//
// "ip_source_and_port_range_check_add_del",
// [
@@ -3100,12 +2896,8 @@ func (*IPSourceAndPortRangeCheckAddDel) GetCrcString() string {
func (*IPSourceAndPortRangeCheckAddDel) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewIPSourceAndPortRangeCheckAddDel() api.Message {
- return &IPSourceAndPortRangeCheckAddDel{}
-}
// IPSourceAndPortRangeCheckAddDelReply represents the VPP binary API message 'ip_source_and_port_range_check_add_del_reply'.
-// Generated from 'ip.api.json', line 1595:
//
// "ip_source_and_port_range_check_add_del_reply",
// [
@@ -3137,12 +2929,8 @@ func (*IPSourceAndPortRangeCheckAddDelReply) GetCrcString() string {
func (*IPSourceAndPortRangeCheckAddDelReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewIPSourceAndPortRangeCheckAddDelReply() api.Message {
- return &IPSourceAndPortRangeCheckAddDelReply{}
-}
// IPSourceAndPortRangeCheckInterfaceAddDel represents the VPP binary API message 'ip_source_and_port_range_check_interface_add_del'.
-// Generated from 'ip.api.json', line 1613:
//
// "ip_source_and_port_range_check_interface_add_del",
// [
@@ -3203,12 +2991,8 @@ func (*IPSourceAndPortRangeCheckInterfaceAddDel) GetCrcString() string {
func (*IPSourceAndPortRangeCheckInterfaceAddDel) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewIPSourceAndPortRangeCheckInterfaceAddDel() api.Message {
- return &IPSourceAndPortRangeCheckInterfaceAddDel{}
-}
// IPSourceAndPortRangeCheckInterfaceAddDelReply represents the VPP binary API message 'ip_source_and_port_range_check_interface_add_del_reply'.
-// Generated from 'ip.api.json', line 1655:
//
// "ip_source_and_port_range_check_interface_add_del_reply",
// [
@@ -3240,12 +3024,8 @@ func (*IPSourceAndPortRangeCheckInterfaceAddDelReply) GetCrcString() string {
func (*IPSourceAndPortRangeCheckInterfaceAddDelReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewIPSourceAndPortRangeCheckInterfaceAddDelReply() api.Message {
- return &IPSourceAndPortRangeCheckInterfaceAddDelReply{}
-}
// IPScanNeighborEnableDisable represents the VPP binary API message 'ip_scan_neighbor_enable_disable'.
-// Generated from 'ip.api.json', line 1673:
//
// "ip_scan_neighbor_enable_disable",
// [
@@ -3306,12 +3086,8 @@ func (*IPScanNeighborEnableDisable) GetCrcString() string {
func (*IPScanNeighborEnableDisable) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewIPScanNeighborEnableDisable() api.Message {
- return &IPScanNeighborEnableDisable{}
-}
// IPScanNeighborEnableDisableReply represents the VPP binary API message 'ip_scan_neighbor_enable_disable_reply'.
-// Generated from 'ip.api.json', line 1715:
//
// "ip_scan_neighbor_enable_disable_reply",
// [
@@ -3343,12 +3119,8 @@ func (*IPScanNeighborEnableDisableReply) GetCrcString() string {
func (*IPScanNeighborEnableDisableReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewIPScanNeighborEnableDisableReply() api.Message {
- return &IPScanNeighborEnableDisableReply{}
-}
// IPProbeNeighbor represents the VPP binary API message 'ip_probe_neighbor'.
-// Generated from 'ip.api.json', line 1733:
//
// "ip_probe_neighbor",
// [
@@ -3395,12 +3167,8 @@ func (*IPProbeNeighbor) GetCrcString() string {
func (*IPProbeNeighbor) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewIPProbeNeighbor() api.Message {
- return &IPProbeNeighbor{}
-}
// IPProbeNeighborReply represents the VPP binary API message 'ip_probe_neighbor_reply'.
-// Generated from 'ip.api.json', line 1764:
//
// "ip_probe_neighbor_reply",
// [
@@ -3432,12 +3200,8 @@ func (*IPProbeNeighborReply) GetCrcString() string {
func (*IPProbeNeighborReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewIPProbeNeighborReply() api.Message {
- return &IPProbeNeighborReply{}
-}
// WantIP4ArpEvents represents the VPP binary API message 'want_ip4_arp_events'.
-// Generated from 'ip.api.json', line 1782:
//
// "want_ip4_arp_events",
// [
@@ -3483,12 +3247,8 @@ func (*WantIP4ArpEvents) GetCrcString() string {
func (*WantIP4ArpEvents) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewWantIP4ArpEvents() api.Message {
- return &WantIP4ArpEvents{}
-}
// WantIP4ArpEventsReply represents the VPP binary API message 'want_ip4_arp_events_reply'.
-// Generated from 'ip.api.json', line 1812:
//
// "want_ip4_arp_events_reply",
// [
@@ -3520,12 +3280,8 @@ func (*WantIP4ArpEventsReply) GetCrcString() string {
func (*WantIP4ArpEventsReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewWantIP4ArpEventsReply() api.Message {
- return &WantIP4ArpEventsReply{}
-}
// IP4ArpEvent represents the VPP binary API message 'ip4_arp_event'.
-// Generated from 'ip.api.json', line 1830:
//
// "ip4_arp_event",
// [
@@ -3578,12 +3334,8 @@ func (*IP4ArpEvent) GetCrcString() string {
func (*IP4ArpEvent) GetMessageType() api.MessageType {
return api.EventMessage
}
-func NewIP4ArpEvent() api.Message {
- return &IP4ArpEvent{}
-}
// WantIP6NdEvents represents the VPP binary API message 'want_ip6_nd_events'.
-// Generated from 'ip.api.json', line 1865:
//
// "want_ip6_nd_events",
// [
@@ -3630,12 +3382,8 @@ func (*WantIP6NdEvents) GetCrcString() string {
func (*WantIP6NdEvents) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewWantIP6NdEvents() api.Message {
- return &WantIP6NdEvents{}
-}
// WantIP6NdEventsReply represents the VPP binary API message 'want_ip6_nd_events_reply'.
-// Generated from 'ip.api.json', line 1896:
//
// "want_ip6_nd_events_reply",
// [
@@ -3667,12 +3415,8 @@ func (*WantIP6NdEventsReply) GetCrcString() string {
func (*WantIP6NdEventsReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewWantIP6NdEventsReply() api.Message {
- return &WantIP6NdEventsReply{}
-}
// IP6NdEvent represents the VPP binary API message 'ip6_nd_event'.
-// Generated from 'ip.api.json', line 1914:
//
// "ip6_nd_event",
// [
@@ -3726,12 +3470,8 @@ func (*IP6NdEvent) GetCrcString() string {
func (*IP6NdEvent) GetMessageType() api.MessageType {
return api.EventMessage
}
-func NewIP6NdEvent() api.Message {
- return &IP6NdEvent{}
-}
// WantIP6RaEvents represents the VPP binary API message 'want_ip6_ra_events'.
-// Generated from 'ip.api.json', line 1950:
//
// "want_ip6_ra_events",
// [
@@ -3772,12 +3512,8 @@ func (*WantIP6RaEvents) GetCrcString() string {
func (*WantIP6RaEvents) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewWantIP6RaEvents() api.Message {
- return &WantIP6RaEvents{}
-}
// WantIP6RaEventsReply represents the VPP binary API message 'want_ip6_ra_events_reply'.
-// Generated from 'ip.api.json', line 1976:
//
// "want_ip6_ra_events_reply",
// [
@@ -3809,12 +3545,8 @@ func (*WantIP6RaEventsReply) GetCrcString() string {
func (*WantIP6RaEventsReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewWantIP6RaEventsReply() api.Message {
- return &WantIP6RaEventsReply{}
-}
// IP6RaEvent represents the VPP binary API message 'ip6_ra_event'.
-// Generated from 'ip.api.json', line 1994:
//
// "ip6_ra_event",
// [
@@ -3894,12 +3626,8 @@ func (*IP6RaEvent) GetCrcString() string {
func (*IP6RaEvent) GetMessageType() api.MessageType {
return api.EventMessage
}
-func NewIP6RaEvent() api.Message {
- return &IP6RaEvent{}
-}
// ProxyArpAddDel represents the VPP binary API message 'proxy_arp_add_del'.
-// Generated from 'ip.api.json', line 2051:
//
// "proxy_arp_add_del",
// [
@@ -3940,12 +3668,8 @@ func (*ProxyArpAddDel) GetCrcString() string {
func (*ProxyArpAddDel) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewProxyArpAddDel() api.Message {
- return &ProxyArpAddDel{}
-}
// ProxyArpAddDelReply represents the VPP binary API message 'proxy_arp_add_del_reply'.
-// Generated from 'ip.api.json', line 2077:
//
// "proxy_arp_add_del_reply",
// [
@@ -3977,12 +3701,8 @@ func (*ProxyArpAddDelReply) GetCrcString() string {
func (*ProxyArpAddDelReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewProxyArpAddDelReply() api.Message {
- return &ProxyArpAddDelReply{}
-}
// ProxyArpDump represents the VPP binary API message 'proxy_arp_dump'.
-// Generated from 'ip.api.json', line 2095:
//
// "proxy_arp_dump",
// [
@@ -4012,12 +3732,8 @@ func (*ProxyArpDump) GetCrcString() string {
func (*ProxyArpDump) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewProxyArpDump() api.Message {
- return &ProxyArpDump{}
-}
// ProxyArpDetails represents the VPP binary API message 'proxy_arp_details'.
-// Generated from 'ip.api.json', line 2113:
//
// "proxy_arp_details",
// [
@@ -4049,12 +3765,8 @@ func (*ProxyArpDetails) GetCrcString() string {
func (*ProxyArpDetails) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewProxyArpDetails() api.Message {
- return &ProxyArpDetails{}
-}
// ProxyArpIntfcEnableDisable represents the VPP binary API message 'proxy_arp_intfc_enable_disable'.
-// Generated from 'ip.api.json', line 2131:
//
// "proxy_arp_intfc_enable_disable",
// [
@@ -4095,12 +3807,8 @@ func (*ProxyArpIntfcEnableDisable) GetCrcString() string {
func (*ProxyArpIntfcEnableDisable) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewProxyArpIntfcEnableDisable() api.Message {
- return &ProxyArpIntfcEnableDisable{}
-}
// ProxyArpIntfcEnableDisableReply represents the VPP binary API message 'proxy_arp_intfc_enable_disable_reply'.
-// Generated from 'ip.api.json', line 2157:
//
// "proxy_arp_intfc_enable_disable_reply",
// [
@@ -4132,12 +3840,8 @@ func (*ProxyArpIntfcEnableDisableReply) GetCrcString() string {
func (*ProxyArpIntfcEnableDisableReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewProxyArpIntfcEnableDisableReply() api.Message {
- return &ProxyArpIntfcEnableDisableReply{}
-}
// ProxyArpIntfcDump represents the VPP binary API message 'proxy_arp_intfc_dump'.
-// Generated from 'ip.api.json', line 2175:
//
// "proxy_arp_intfc_dump",
// [
@@ -4167,12 +3871,8 @@ func (*ProxyArpIntfcDump) GetCrcString() string {
func (*ProxyArpIntfcDump) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewProxyArpIntfcDump() api.Message {
- return &ProxyArpIntfcDump{}
-}
// ProxyArpIntfcDetails represents the VPP binary API message 'proxy_arp_intfc_details'.
-// Generated from 'ip.api.json', line 2193:
//
// "proxy_arp_intfc_details",
// [
@@ -4204,12 +3904,8 @@ func (*ProxyArpIntfcDetails) GetCrcString() string {
func (*ProxyArpIntfcDetails) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewProxyArpIntfcDetails() api.Message {
- return &ProxyArpIntfcDetails{}
-}
// ResetFib represents the VPP binary API message 'reset_fib'.
-// Generated from 'ip.api.json', line 2211:
//
// "reset_fib",
// [
@@ -4250,12 +3946,8 @@ func (*ResetFib) GetCrcString() string {
func (*ResetFib) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewResetFib() api.Message {
- return &ResetFib{}
-}
// ResetFibReply represents the VPP binary API message 'reset_fib_reply'.
-// Generated from 'ip.api.json', line 2237:
//
// "reset_fib_reply",
// [
@@ -4287,12 +3979,8 @@ func (*ResetFibReply) GetCrcString() string {
func (*ResetFibReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewResetFibReply() api.Message {
- return &ResetFibReply{}
-}
// SetArpNeighborLimit represents the VPP binary API message 'set_arp_neighbor_limit'.
-// Generated from 'ip.api.json', line 2255:
//
// "set_arp_neighbor_limit",
// [
@@ -4333,12 +4021,8 @@ func (*SetArpNeighborLimit) GetCrcString() string {
func (*SetArpNeighborLimit) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewSetArpNeighborLimit() api.Message {
- return &SetArpNeighborLimit{}
-}
// SetArpNeighborLimitReply represents the VPP binary API message 'set_arp_neighbor_limit_reply'.
-// Generated from 'ip.api.json', line 2281:
//
// "set_arp_neighbor_limit_reply",
// [
@@ -4370,12 +4054,8 @@ func (*SetArpNeighborLimitReply) GetCrcString() string {
func (*SetArpNeighborLimitReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewSetArpNeighborLimitReply() api.Message {
- return &SetArpNeighborLimitReply{}
-}
// IoamEnable represents the VPP binary API message 'ioam_enable'.
-// Generated from 'ip.api.json', line 2299:
//
// "ioam_enable",
// [
@@ -4436,12 +4116,8 @@ func (*IoamEnable) GetCrcString() string {
func (*IoamEnable) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewIoamEnable() api.Message {
- return &IoamEnable{}
-}
// IoamEnableReply represents the VPP binary API message 'ioam_enable_reply'.
-// Generated from 'ip.api.json', line 2341:
//
// "ioam_enable_reply",
// [
@@ -4473,12 +4149,8 @@ func (*IoamEnableReply) GetCrcString() string {
func (*IoamEnableReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewIoamEnableReply() api.Message {
- return &IoamEnableReply{}
-}
// IoamDisable represents the VPP binary API message 'ioam_disable'.
-// Generated from 'ip.api.json', line 2359:
//
// "ioam_disable",
// [
@@ -4514,12 +4186,8 @@ func (*IoamDisable) GetCrcString() string {
func (*IoamDisable) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewIoamDisable() api.Message {
- return &IoamDisable{}
-}
// IoamDisableReply represents the VPP binary API message 'ioam_disable_reply'.
-// Generated from 'ip.api.json', line 2381:
//
// "ioam_disable_reply",
// [
@@ -4551,12 +4219,8 @@ func (*IoamDisableReply) GetCrcString() string {
func (*IoamDisableReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewIoamDisableReply() api.Message {
- return &IoamDisableReply{}
-}
// IPReassemblySet represents the VPP binary API message 'ip_reassembly_set'.
-// Generated from 'ip.api.json', line 2399:
//
// "ip_reassembly_set",
// [
@@ -4607,12 +4271,8 @@ func (*IPReassemblySet) GetCrcString() string {
func (*IPReassemblySet) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewIPReassemblySet() api.Message {
- return &IPReassemblySet{}
-}
// IPReassemblySetReply represents the VPP binary API message 'ip_reassembly_set_reply'.
-// Generated from 'ip.api.json', line 2433:
//
// "ip_reassembly_set_reply",
// [
@@ -4644,12 +4304,8 @@ func (*IPReassemblySetReply) GetCrcString() string {
func (*IPReassemblySetReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewIPReassemblySetReply() api.Message {
- return &IPReassemblySetReply{}
-}
// IPReassemblyGet represents the VPP binary API message 'ip_reassembly_get'.
-// Generated from 'ip.api.json', line 2451:
//
// "ip_reassembly_get",
// [
@@ -4685,12 +4341,8 @@ func (*IPReassemblyGet) GetCrcString() string {
func (*IPReassemblyGet) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewIPReassemblyGet() api.Message {
- return &IPReassemblyGet{}
-}
// IPReassemblyGetReply represents the VPP binary API message 'ip_reassembly_get_reply'.
-// Generated from 'ip.api.json', line 2473:
//
// "ip_reassembly_get_reply",
// [
@@ -4746,12 +4398,8 @@ func (*IPReassemblyGetReply) GetCrcString() string {
func (*IPReassemblyGetReply) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewIPReassemblyGetReply() api.Message {
- return &IPReassemblyGetReply{}
-}
// IPReassemblyEnableDisable represents the VPP binary API message 'ip_reassembly_enable_disable'.
-// Generated from 'ip.api.json', line 2511:
//
// "ip_reassembly_enable_disable",
// [
@@ -4797,12 +4445,8 @@ func (*IPReassemblyEnableDisable) GetCrcString() string {
func (*IPReassemblyEnableDisable) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewIPReassemblyEnableDisable() api.Message {
- return &IPReassemblyEnableDisable{}
-}
// IPReassemblyEnableDisableReply represents the VPP binary API message 'ip_reassembly_enable_disable_reply'.
-// Generated from 'ip.api.json', line 2541:
//
// "ip_reassembly_enable_disable_reply",
// [
@@ -4834,9 +4478,6 @@ func (*IPReassemblyEnableDisableReply) GetCrcString() string {
func (*IPReassemblyEnableDisableReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewIPReassemblyEnableDisableReply() api.Message {
- return &IPReassemblyEnableDisableReply{}
-}
/* Services */
diff --git a/examples/bin_api/memif/memif.ba.go b/examples/bin_api/memif/memif.ba.go
index 3650355..ce8c9c0 100644
--- a/examples/bin_api/memif/memif.ba.go
+++ b/examples/bin_api/memif/memif.ba.go
@@ -1,15 +1,13 @@
// Code generated by GoVPP binapi-generator. DO NOT EDIT.
-// source: memif.api.json
+// source: memif.api.json
/*
-Package memif is a generated VPP binary API of the 'memif' VPP module.
+ Package memif is a generated from VPP binary API module 'memif'.
-It is generated from this file:
- memif.api.json
+ It contains following objects:
+ 10 messages
+ 5 services
-It contains these VPP binary API objects:
- 10 messages
- 5 services
*/
package memif
@@ -18,13 +16,13 @@ import "github.com/lunixbochs/struc"
import "bytes"
// Reference imports to suppress errors if they are not otherwise used.
+var _ = api.RegisterMessage
var _ = struc.Pack
var _ = bytes.NewBuffer
/* Messages */
// MemifSocketFilenameAddDel represents the VPP binary API message 'memif_socket_filename_add_del'.
-// Generated from 'memif.api.json', line 4:
//
// "memif_socket_filename_add_del",
// [
@@ -71,12 +69,8 @@ func (*MemifSocketFilenameAddDel) GetCrcString() string {
func (*MemifSocketFilenameAddDel) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewMemifSocketFilenameAddDel() api.Message {
- return &MemifSocketFilenameAddDel{}
-}
// MemifSocketFilenameAddDelReply represents the VPP binary API message 'memif_socket_filename_add_del_reply'.
-// Generated from 'memif.api.json', line 35:
//
// "memif_socket_filename_add_del_reply",
// [
@@ -108,12 +102,8 @@ func (*MemifSocketFilenameAddDelReply) GetCrcString() string {
func (*MemifSocketFilenameAddDelReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewMemifSocketFilenameAddDelReply() api.Message {
- return &MemifSocketFilenameAddDelReply{}
-}
// MemifCreate represents the VPP binary API message 'memif_create'.
-// Generated from 'memif.api.json', line 53:
//
// "memif_create",
// [
@@ -196,12 +186,8 @@ func (*MemifCreate) GetCrcString() string {
func (*MemifCreate) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewMemifCreate() api.Message {
- return &MemifCreate{}
-}
// MemifCreateReply represents the VPP binary API message 'memif_create_reply'.
-// Generated from 'memif.api.json', line 113:
//
// "memif_create_reply",
// [
@@ -238,12 +224,8 @@ func (*MemifCreateReply) GetCrcString() string {
func (*MemifCreateReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewMemifCreateReply() api.Message {
- return &MemifCreateReply{}
-}
// MemifDelete represents the VPP binary API message 'memif_delete'.
-// Generated from 'memif.api.json', line 135:
//
// "memif_delete",
// [
@@ -279,12 +261,8 @@ func (*MemifDelete) GetCrcString() string {
func (*MemifDelete) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewMemifDelete() api.Message {
- return &MemifDelete{}
-}
// MemifDeleteReply represents the VPP binary API message 'memif_delete_reply'.
-// Generated from 'memif.api.json', line 157:
//
// "memif_delete_reply",
// [
@@ -316,12 +294,8 @@ func (*MemifDeleteReply) GetCrcString() string {
func (*MemifDeleteReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewMemifDeleteReply() api.Message {
- return &MemifDeleteReply{}
-}
// MemifSocketFilenameDetails represents the VPP binary API message 'memif_socket_filename_details'.
-// Generated from 'memif.api.json', line 175:
//
// "memif_socket_filename_details",
// [
@@ -359,12 +333,8 @@ func (*MemifSocketFilenameDetails) GetCrcString() string {
func (*MemifSocketFilenameDetails) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewMemifSocketFilenameDetails() api.Message {
- return &MemifSocketFilenameDetails{}
-}
// MemifSocketFilenameDump represents the VPP binary API message 'memif_socket_filename_dump'.
-// Generated from 'memif.api.json', line 198:
//
// "memif_socket_filename_dump",
// [
@@ -394,12 +364,8 @@ func (*MemifSocketFilenameDump) GetCrcString() string {
func (*MemifSocketFilenameDump) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewMemifSocketFilenameDump() api.Message {
- return &MemifSocketFilenameDump{}
-}
// MemifDetails represents the VPP binary API message 'memif_details'.
-// Generated from 'memif.api.json', line 216:
//
// "memif_details",
// [
@@ -483,12 +449,8 @@ func (*MemifDetails) GetCrcString() string {
func (*MemifDetails) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewMemifDetails() api.Message {
- return &MemifDetails{}
-}
// MemifDump represents the VPP binary API message 'memif_dump'.
-// Generated from 'memif.api.json', line 276:
//
// "memif_dump",
// [
@@ -518,9 +480,6 @@ func (*MemifDump) GetCrcString() string {
func (*MemifDump) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewMemifDump() api.Message {
- return &MemifDump{}
-}
/* Services */
diff --git a/examples/bin_api/stats/stats.ba.go b/examples/bin_api/stats/stats.ba.go
index eb2dd8f..58c178f 100644
--- a/examples/bin_api/stats/stats.ba.go
+++ b/examples/bin_api/stats/stats.ba.go
@@ -1,16 +1,14 @@
// Code generated by GoVPP binapi-generator. DO NOT EDIT.
-// source: stats.api.json
+// source: stats.api.json
/*
-Package stats is a generated VPP binary API of the 'stats' VPP module.
+ Package stats is a generated from VPP binary API module 'stats'.
-It is generated from this file:
- stats.api.json
+ It contains following objects:
+ 39 messages
+ 10 types
+ 14 services
-It contains these VPP binary API objects:
- 39 messages
- 10 types
- 14 services
*/
package stats
@@ -19,13 +17,13 @@ import "github.com/lunixbochs/struc"
import "bytes"
// Reference imports to suppress errors if they are not otherwise used.
+var _ = api.RegisterMessage
var _ = struc.Pack
var _ = bytes.NewBuffer
/* Types */
// VlibCounter represents the VPP binary API type 'vlib_counter'.
-// Generated from 'stats.api.json', line 1004:
//
// "vlib_counter",
// [
@@ -53,7 +51,6 @@ func (*VlibCounter) GetCrcString() string {
}
// VnetCombinedCounter represents the VPP binary API type 'vnet_combined_counter'.
-// Generated from 'stats.api.json', line 1018:
//
// "vnet_combined_counter",
// [
@@ -156,7 +153,6 @@ func (*VnetCombinedCounter) GetCrcString() string {
}
// VnetSimpleCounter represents the VPP binary API type 'vnet_simple_counter'.
-// Generated from 'stats.api.json', line 1092:
//
// "vnet_simple_counter",
// [
@@ -224,7 +220,6 @@ func (*VnetSimpleCounter) GetCrcString() string {
}
// IP4FibCounter represents the VPP binary API type 'ip4_fib_counter'.
-// Generated from 'stats.api.json', line 1138:
//
// "ip4_fib_counter",
// [
@@ -262,7 +257,6 @@ func (*IP4FibCounter) GetCrcString() string {
}
// IP4MfibCounter represents the VPP binary API type 'ip4_mfib_counter'.
-// Generated from 'stats.api.json', line 1160:
//
// "ip4_mfib_counter",
// [
@@ -307,7 +301,6 @@ func (*IP4MfibCounter) GetCrcString() string {
}
// IP4NbrCounter represents the VPP binary API type 'ip4_nbr_counter'.
-// Generated from 'stats.api.json', line 1188:
//
// "ip4_nbr_counter",
// [
@@ -345,7 +338,6 @@ func (*IP4NbrCounter) GetCrcString() string {
}
// IP6FibCounter represents the VPP binary API type 'ip6_fib_counter'.
-// Generated from 'stats.api.json', line 1210:
//
// "ip6_fib_counter",
// [
@@ -384,7 +376,6 @@ func (*IP6FibCounter) GetCrcString() string {
}
// IP6MfibCounter represents the VPP binary API type 'ip6_mfib_counter'.
-// Generated from 'stats.api.json', line 1233:
//
// "ip6_mfib_counter",
// [
@@ -429,7 +420,6 @@ func (*IP6MfibCounter) GetCrcString() string {
}
// IP6NbrCounter represents the VPP binary API type 'ip6_nbr_counter'.
-// Generated from 'stats.api.json', line 1261:
//
// "ip6_nbr_counter",
// [
@@ -468,7 +458,6 @@ func (*IP6NbrCounter) GetCrcString() string {
}
// UDPEncapCounter represents the VPP binary API type 'udp_encap_counter'.
-// Generated from 'stats.api.json', line 1284:
//
// "udp_encap_counter",
// [
@@ -503,7 +492,6 @@ func (*UDPEncapCounter) GetCrcString() string {
/* Messages */
// WantStats represents the VPP binary API message 'want_stats'.
-// Generated from 'stats.api.json', line 4:
//
// "want_stats",
// [
@@ -544,12 +532,8 @@ func (*WantStats) GetCrcString() string {
func (*WantStats) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewWantStats() api.Message {
- return &WantStats{}
-}
// WantStatsReply represents the VPP binary API message 'want_stats_reply'.
-// Generated from 'stats.api.json', line 30:
//
// "want_stats_reply",
// [
@@ -581,12 +565,8 @@ func (*WantStatsReply) GetCrcString() string {
func (*WantStatsReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewWantStatsReply() api.Message {
- return &WantStatsReply{}
-}
// WantInterfaceSimpleStats represents the VPP binary API message 'want_interface_simple_stats'.
-// Generated from 'stats.api.json', line 48:
//
// "want_interface_simple_stats",
// [
@@ -627,12 +607,8 @@ func (*WantInterfaceSimpleStats) GetCrcString() string {
func (*WantInterfaceSimpleStats) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewWantInterfaceSimpleStats() api.Message {
- return &WantInterfaceSimpleStats{}
-}
// WantInterfaceSimpleStatsReply represents the VPP binary API message 'want_interface_simple_stats_reply'.
-// Generated from 'stats.api.json', line 74:
//
// "want_interface_simple_stats_reply",
// [
@@ -664,12 +640,8 @@ func (*WantInterfaceSimpleStatsReply) GetCrcString() string {
func (*WantInterfaceSimpleStatsReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewWantInterfaceSimpleStatsReply() api.Message {
- return &WantInterfaceSimpleStatsReply{}
-}
// WantPerInterfaceSimpleStats represents the VPP binary API message 'want_per_interface_simple_stats'.
-// Generated from 'stats.api.json', line 92:
//
// "want_per_interface_simple_stats",
// [
@@ -722,12 +694,8 @@ func (*WantPerInterfaceSimpleStats) GetCrcString() string {
func (*WantPerInterfaceSimpleStats) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewWantPerInterfaceSimpleStats() api.Message {
- return &WantPerInterfaceSimpleStats{}
-}
// WantPerInterfaceSimpleStatsReply represents the VPP binary API message 'want_per_interface_simple_stats_reply'.
-// Generated from 'stats.api.json', line 128:
//
// "want_per_interface_simple_stats_reply",
// [
@@ -759,12 +727,8 @@ func (*WantPerInterfaceSimpleStatsReply) GetCrcString() string {
func (*WantPerInterfaceSimpleStatsReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewWantPerInterfaceSimpleStatsReply() api.Message {
- return &WantPerInterfaceSimpleStatsReply{}
-}
// WantInterfaceCombinedStats represents the VPP binary API message 'want_interface_combined_stats'.
-// Generated from 'stats.api.json', line 146:
//
// "want_interface_combined_stats",
// [
@@ -805,12 +769,8 @@ func (*WantInterfaceCombinedStats) GetCrcString() string {
func (*WantInterfaceCombinedStats) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewWantInterfaceCombinedStats() api.Message {
- return &WantInterfaceCombinedStats{}
-}
// WantInterfaceCombinedStatsReply represents the VPP binary API message 'want_interface_combined_stats_reply'.
-// Generated from 'stats.api.json', line 172:
//
// "want_interface_combined_stats_reply",
// [
@@ -842,12 +802,8 @@ func (*WantInterfaceCombinedStatsReply) GetCrcString() string {
func (*WantInterfaceCombinedStatsReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewWantInterfaceCombinedStatsReply() api.Message {
- return &WantInterfaceCombinedStatsReply{}
-}
// WantPerInterfaceCombinedStats represents the VPP binary API message 'want_per_interface_combined_stats'.
-// Generated from 'stats.api.json', line 190:
//
// "want_per_interface_combined_stats",
// [
@@ -900,12 +856,8 @@ func (*WantPerInterfaceCombinedStats) GetCrcString() string {
func (*WantPerInterfaceCombinedStats) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewWantPerInterfaceCombinedStats() api.Message {
- return &WantPerInterfaceCombinedStats{}
-}
// WantPerInterfaceCombinedStatsReply represents the VPP binary API message 'want_per_interface_combined_stats_reply'.
-// Generated from 'stats.api.json', line 226:
//
// "want_per_interface_combined_stats_reply",
// [
@@ -937,12 +889,8 @@ func (*WantPerInterfaceCombinedStatsReply) GetCrcString() string {
func (*WantPerInterfaceCombinedStatsReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewWantPerInterfaceCombinedStatsReply() api.Message {
- return &WantPerInterfaceCombinedStatsReply{}
-}
// WantIP4FibStats represents the VPP binary API message 'want_ip4_fib_stats'.
-// Generated from 'stats.api.json', line 244:
//
// "want_ip4_fib_stats",
// [
@@ -983,12 +931,8 @@ func (*WantIP4FibStats) GetCrcString() string {
func (*WantIP4FibStats) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewWantIP4FibStats() api.Message {
- return &WantIP4FibStats{}
-}
// WantIP4FibStatsReply represents the VPP binary API message 'want_ip4_fib_stats_reply'.
-// Generated from 'stats.api.json', line 270:
//
// "want_ip4_fib_stats_reply",
// [
@@ -1020,12 +964,8 @@ func (*WantIP4FibStatsReply) GetCrcString() string {
func (*WantIP4FibStatsReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewWantIP4FibStatsReply() api.Message {
- return &WantIP4FibStatsReply{}
-}
// WantIP6FibStats represents the VPP binary API message 'want_ip6_fib_stats'.
-// Generated from 'stats.api.json', line 288:
//
// "want_ip6_fib_stats",
// [
@@ -1066,12 +1006,8 @@ func (*WantIP6FibStats) GetCrcString() string {
func (*WantIP6FibStats) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewWantIP6FibStats() api.Message {
- return &WantIP6FibStats{}
-}
// WantIP6FibStatsReply represents the VPP binary API message 'want_ip6_fib_stats_reply'.
-// Generated from 'stats.api.json', line 314:
//
// "want_ip6_fib_stats_reply",
// [
@@ -1103,12 +1039,8 @@ func (*WantIP6FibStatsReply) GetCrcString() string {
func (*WantIP6FibStatsReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewWantIP6FibStatsReply() api.Message {
- return &WantIP6FibStatsReply{}
-}
// WantIP4MfibStats represents the VPP binary API message 'want_ip4_mfib_stats'.
-// Generated from 'stats.api.json', line 332:
//
// "want_ip4_mfib_stats",
// [
@@ -1149,12 +1081,8 @@ func (*WantIP4MfibStats) GetCrcString() string {
func (*WantIP4MfibStats) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewWantIP4MfibStats() api.Message {
- return &WantIP4MfibStats{}
-}
// WantIP4MfibStatsReply represents the VPP binary API message 'want_ip4_mfib_stats_reply'.
-// Generated from 'stats.api.json', line 358:
//
// "want_ip4_mfib_stats_reply",
// [
@@ -1186,12 +1114,8 @@ func (*WantIP4MfibStatsReply) GetCrcString() string {
func (*WantIP4MfibStatsReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewWantIP4MfibStatsReply() api.Message {
- return &WantIP4MfibStatsReply{}
-}
// WantIP6MfibStats represents the VPP binary API message 'want_ip6_mfib_stats'.
-// Generated from 'stats.api.json', line 376:
//
// "want_ip6_mfib_stats",
// [
@@ -1232,12 +1156,8 @@ func (*WantIP6MfibStats) GetCrcString() string {
func (*WantIP6MfibStats) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewWantIP6MfibStats() api.Message {
- return &WantIP6MfibStats{}
-}
// WantIP6MfibStatsReply represents the VPP binary API message 'want_ip6_mfib_stats_reply'.
-// Generated from 'stats.api.json', line 402:
//
// "want_ip6_mfib_stats_reply",
// [
@@ -1269,12 +1189,8 @@ func (*WantIP6MfibStatsReply) GetCrcString() string {
func (*WantIP6MfibStatsReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewWantIP6MfibStatsReply() api.Message {
- return &WantIP6MfibStatsReply{}
-}
// WantIP4NbrStats represents the VPP binary API message 'want_ip4_nbr_stats'.
-// Generated from 'stats.api.json', line 420:
//
// "want_ip4_nbr_stats",
// [
@@ -1315,12 +1231,8 @@ func (*WantIP4NbrStats) GetCrcString() string {
func (*WantIP4NbrStats) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewWantIP4NbrStats() api.Message {
- return &WantIP4NbrStats{}
-}
// WantIP4NbrStatsReply represents the VPP binary API message 'want_ip4_nbr_stats_reply'.
-// Generated from 'stats.api.json', line 446:
//
// "want_ip4_nbr_stats_reply",
// [
@@ -1352,12 +1264,8 @@ func (*WantIP4NbrStatsReply) GetCrcString() string {
func (*WantIP4NbrStatsReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewWantIP4NbrStatsReply() api.Message {
- return &WantIP4NbrStatsReply{}
-}
// WantIP6NbrStats represents the VPP binary API message 'want_ip6_nbr_stats'.
-// Generated from 'stats.api.json', line 464:
//
// "want_ip6_nbr_stats",
// [
@@ -1398,12 +1306,8 @@ func (*WantIP6NbrStats) GetCrcString() string {
func (*WantIP6NbrStats) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewWantIP6NbrStats() api.Message {
- return &WantIP6NbrStats{}
-}
// WantIP6NbrStatsReply represents the VPP binary API message 'want_ip6_nbr_stats_reply'.
-// Generated from 'stats.api.json', line 490:
//
// "want_ip6_nbr_stats_reply",
// [
@@ -1435,12 +1339,8 @@ func (*WantIP6NbrStatsReply) GetCrcString() string {
func (*WantIP6NbrStatsReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewWantIP6NbrStatsReply() api.Message {
- return &WantIP6NbrStatsReply{}
-}
// VnetIP4FibCounters represents the VPP binary API message 'vnet_ip4_fib_counters'.
-// Generated from 'stats.api.json', line 508:
//
// "vnet_ip4_fib_counters",
// [
@@ -1480,12 +1380,8 @@ func (*VnetIP4FibCounters) GetCrcString() string {
func (*VnetIP4FibCounters) GetMessageType() api.MessageType {
return api.OtherMessage
}
-func NewVnetIP4FibCounters() api.Message {
- return &VnetIP4FibCounters{}
-}
// VnetIP4MfibCounters represents the VPP binary API message 'vnet_ip4_mfib_counters'.
-// Generated from 'stats.api.json', line 532:
//
// "vnet_ip4_mfib_counters",
// [
@@ -1525,12 +1421,8 @@ func (*VnetIP4MfibCounters) GetCrcString() string {
func (*VnetIP4MfibCounters) GetMessageType() api.MessageType {
return api.OtherMessage
}
-func NewVnetIP4MfibCounters() api.Message {
- return &VnetIP4MfibCounters{}
-}
// VnetIP4NbrCounters represents the VPP binary API message 'vnet_ip4_nbr_counters'.
-// Generated from 'stats.api.json', line 556:
//
// "vnet_ip4_nbr_counters",
// [
@@ -1575,12 +1467,8 @@ func (*VnetIP4NbrCounters) GetCrcString() string {
func (*VnetIP4NbrCounters) GetMessageType() api.MessageType {
return api.OtherMessage
}
-func NewVnetIP4NbrCounters() api.Message {
- return &VnetIP4NbrCounters{}
-}
// VnetIP6FibCounters represents the VPP binary API message 'vnet_ip6_fib_counters'.
-// Generated from 'stats.api.json', line 584:
//
// "vnet_ip6_fib_counters",
// [
@@ -1620,12 +1508,8 @@ func (*VnetIP6FibCounters) GetCrcString() string {
func (*VnetIP6FibCounters) GetMessageType() api.MessageType {
return api.OtherMessage
}
-func NewVnetIP6FibCounters() api.Message {
- return &VnetIP6FibCounters{}
-}
// VnetIP6MfibCounters represents the VPP binary API message 'vnet_ip6_mfib_counters'.
-// Generated from 'stats.api.json', line 608:
//
// "vnet_ip6_mfib_counters",
// [
@@ -1665,12 +1549,8 @@ func (*VnetIP6MfibCounters) GetCrcString() string {
func (*VnetIP6MfibCounters) GetMessageType() api.MessageType {
return api.OtherMessage
}
-func NewVnetIP6MfibCounters() api.Message {
- return &VnetIP6MfibCounters{}
-}
// VnetIP6NbrCounters represents the VPP binary API message 'vnet_ip6_nbr_counters'.
-// Generated from 'stats.api.json', line 632:
//
// "vnet_ip6_nbr_counters",
// [
@@ -1715,12 +1595,8 @@ func (*VnetIP6NbrCounters) GetCrcString() string {
func (*VnetIP6NbrCounters) GetMessageType() api.MessageType {
return api.OtherMessage
}
-func NewVnetIP6NbrCounters() api.Message {
- return &VnetIP6NbrCounters{}
-}
// VnetInterfaceSimpleCounters represents the VPP binary API message 'vnet_interface_simple_counters'.
-// Generated from 'stats.api.json', line 660:
//
// "vnet_interface_simple_counters",
// [
@@ -1765,12 +1641,8 @@ func (*VnetInterfaceSimpleCounters) GetCrcString() string {
func (*VnetInterfaceSimpleCounters) GetMessageType() api.MessageType {
return api.OtherMessage
}
-func NewVnetInterfaceSimpleCounters() api.Message {
- return &VnetInterfaceSimpleCounters{}
-}
// VnetInterfaceCombinedCounters represents the VPP binary API message 'vnet_interface_combined_counters'.
-// Generated from 'stats.api.json', line 688:
//
// "vnet_interface_combined_counters",
// [
@@ -1815,12 +1687,8 @@ func (*VnetInterfaceCombinedCounters) GetCrcString() string {
func (*VnetInterfaceCombinedCounters) GetMessageType() api.MessageType {
return api.OtherMessage
}
-func NewVnetInterfaceCombinedCounters() api.Message {
- return &VnetInterfaceCombinedCounters{}
-}
// VnetPerInterfaceSimpleCounters represents the VPP binary API message 'vnet_per_interface_simple_counters'.
-// Generated from 'stats.api.json', line 716:
//
// "vnet_per_interface_simple_counters",
// [
@@ -1860,12 +1728,8 @@ func (*VnetPerInterfaceSimpleCounters) GetCrcString() string {
func (*VnetPerInterfaceSimpleCounters) GetMessageType() api.MessageType {
return api.OtherMessage
}
-func NewVnetPerInterfaceSimpleCounters() api.Message {
- return &VnetPerInterfaceSimpleCounters{}
-}
// VnetPerInterfaceCombinedCounters represents the VPP binary API message 'vnet_per_interface_combined_counters'.
-// Generated from 'stats.api.json', line 740:
//
// "vnet_per_interface_combined_counters",
// [
@@ -1905,12 +1769,8 @@ func (*VnetPerInterfaceCombinedCounters) GetCrcString() string {
func (*VnetPerInterfaceCombinedCounters) GetMessageType() api.MessageType {
return api.OtherMessage
}
-func NewVnetPerInterfaceCombinedCounters() api.Message {
- return &VnetPerInterfaceCombinedCounters{}
-}
// VnetGetSummaryStats represents the VPP binary API message 'vnet_get_summary_stats'.
-// Generated from 'stats.api.json', line 764:
//
// "vnet_get_summary_stats",
// [
@@ -1940,12 +1800,8 @@ func (*VnetGetSummaryStats) GetCrcString() string {
func (*VnetGetSummaryStats) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewVnetGetSummaryStats() api.Message {
- return &VnetGetSummaryStats{}
-}
// VnetGetSummaryStatsReply represents the VPP binary API message 'vnet_get_summary_stats_reply'.
-// Generated from 'stats.api.json', line 782:
//
// "vnet_get_summary_stats_reply",
// [
@@ -1994,12 +1850,8 @@ func (*VnetGetSummaryStatsReply) GetCrcString() string {
func (*VnetGetSummaryStatsReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewVnetGetSummaryStatsReply() api.Message {
- return &VnetGetSummaryStatsReply{}
-}
// StatsGetPollerDelay represents the VPP binary API message 'stats_get_poller_delay'.
-// Generated from 'stats.api.json', line 814:
//
// "stats_get_poller_delay",
// [
@@ -2029,12 +1881,8 @@ func (*StatsGetPollerDelay) GetCrcString() string {
func (*StatsGetPollerDelay) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewStatsGetPollerDelay() api.Message {
- return &StatsGetPollerDelay{}
-}
// StatsGetPollerDelayReply represents the VPP binary API message 'stats_get_poller_delay_reply'.
-// Generated from 'stats.api.json', line 832:
//
// "stats_get_poller_delay_reply",
// [
@@ -2071,12 +1919,8 @@ func (*StatsGetPollerDelayReply) GetCrcString() string {
func (*StatsGetPollerDelayReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewStatsGetPollerDelayReply() api.Message {
- return &StatsGetPollerDelayReply{}
-}
// WantUDPEncapStats represents the VPP binary API message 'want_udp_encap_stats'.
-// Generated from 'stats.api.json', line 854:
//
// "want_udp_encap_stats",
// [
@@ -2117,12 +1961,8 @@ func (*WantUDPEncapStats) GetCrcString() string {
func (*WantUDPEncapStats) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewWantUDPEncapStats() api.Message {
- return &WantUDPEncapStats{}
-}
// WantUDPEncapStatsReply represents the VPP binary API message 'want_udp_encap_stats_reply'.
-// Generated from 'stats.api.json', line 880:
//
// "want_udp_encap_stats_reply",
// [
@@ -2154,12 +1994,8 @@ func (*WantUDPEncapStatsReply) GetCrcString() string {
func (*WantUDPEncapStatsReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewWantUDPEncapStatsReply() api.Message {
- return &WantUDPEncapStatsReply{}
-}
// VnetUDPEncapCounters represents the VPP binary API message 'vnet_udp_encap_counters'.
-// Generated from 'stats.api.json', line 898:
//
// "vnet_udp_encap_counters",
// [
@@ -2199,9 +2035,6 @@ func (*VnetUDPEncapCounters) GetCrcString() string {
func (*VnetUDPEncapCounters) GetMessageType() api.MessageType {
return api.OtherMessage
}
-func NewVnetUDPEncapCounters() api.Message {
- return &VnetUDPEncapCounters{}
-}
/* Services */
diff --git a/examples/bin_api/tap/tap.ba.go b/examples/bin_api/tap/tap.ba.go
index 36f5549..d4daa1d 100644
--- a/examples/bin_api/tap/tap.ba.go
+++ b/examples/bin_api/tap/tap.ba.go
@@ -1,15 +1,13 @@
// Code generated by GoVPP binapi-generator. DO NOT EDIT.
-// source: tap.api.json
+// source: tap.api.json
/*
-Package tap is a generated VPP binary API of the 'tap' VPP module.
+ Package tap is a generated from VPP binary API module 'tap'.
-It is generated from this file:
- tap.api.json
+ It contains following objects:
+ 8 messages
+ 4 services
-It contains these VPP binary API objects:
- 8 messages
- 4 services
*/
package tap
@@ -18,13 +16,13 @@ import "github.com/lunixbochs/struc"
import "bytes"
// Reference imports to suppress errors if they are not otherwise used.
+var _ = api.RegisterMessage
var _ = struc.Pack
var _ = bytes.NewBuffer
/* Messages */
// TapConnect represents the VPP binary API message 'tap_connect'.
-// Generated from 'tap.api.json', line 4:
//
// "tap_connect",
// [
@@ -120,12 +118,8 @@ func (*TapConnect) GetCrcString() string {
func (*TapConnect) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewTapConnect() api.Message {
- return &TapConnect{}
-}
// TapConnectReply represents the VPP binary API message 'tap_connect_reply'.
-// Generated from 'tap.api.json', line 75:
//
// "tap_connect_reply",
// [
@@ -162,12 +156,8 @@ func (*TapConnectReply) GetCrcString() string {
func (*TapConnectReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewTapConnectReply() api.Message {
- return &TapConnectReply{}
-}
// TapModify represents the VPP binary API message 'tap_modify'.
-// Generated from 'tap.api.json', line 97:
//
// "tap_modify",
// [
@@ -230,12 +220,8 @@ func (*TapModify) GetCrcString() string {
func (*TapModify) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewTapModify() api.Message {
- return &TapModify{}
-}
// TapModifyReply represents the VPP binary API message 'tap_modify_reply'.
-// Generated from 'tap.api.json', line 141:
//
// "tap_modify_reply",
// [
@@ -272,12 +258,8 @@ func (*TapModifyReply) GetCrcString() string {
func (*TapModifyReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewTapModifyReply() api.Message {
- return &TapModifyReply{}
-}
// TapDelete represents the VPP binary API message 'tap_delete'.
-// Generated from 'tap.api.json', line 163:
//
// "tap_delete",
// [
@@ -313,12 +295,8 @@ func (*TapDelete) GetCrcString() string {
func (*TapDelete) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewTapDelete() api.Message {
- return &TapDelete{}
-}
// TapDeleteReply represents the VPP binary API message 'tap_delete_reply'.
-// Generated from 'tap.api.json', line 185:
//
// "tap_delete_reply",
// [
@@ -350,12 +328,8 @@ func (*TapDeleteReply) GetCrcString() string {
func (*TapDeleteReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewTapDeleteReply() api.Message {
- return &TapDeleteReply{}
-}
// SwInterfaceTapDump represents the VPP binary API message 'sw_interface_tap_dump'.
-// Generated from 'tap.api.json', line 203:
//
// "sw_interface_tap_dump",
// [
@@ -385,12 +359,8 @@ func (*SwInterfaceTapDump) GetCrcString() string {
func (*SwInterfaceTapDump) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewSwInterfaceTapDump() api.Message {
- return &SwInterfaceTapDump{}
-}
// SwInterfaceTapDetails represents the VPP binary API message 'sw_interface_tap_details'.
-// Generated from 'tap.api.json', line 221:
//
// "sw_interface_tap_details",
// [
@@ -428,9 +398,6 @@ func (*SwInterfaceTapDetails) GetCrcString() string {
func (*SwInterfaceTapDetails) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewSwInterfaceTapDetails() api.Message {
- return &SwInterfaceTapDetails{}
-}
/* Services */
diff --git a/examples/bin_api/vpe/vpe.ba.go b/examples/bin_api/vpe/vpe.ba.go
index f91a164..fe0fa03 100644
--- a/examples/bin_api/vpe/vpe.ba.go
+++ b/examples/bin_api/vpe/vpe.ba.go
@@ -1,15 +1,13 @@
// Code generated by GoVPP binapi-generator. DO NOT EDIT.
-// source: vpe.api.json
+// source: vpe.api.json
/*
-Package vpe is a generated VPP binary API of the 'vpe' VPP module.
+ Package vpe is a generated from VPP binary API module 'vpe'.
-It is generated from this file:
- vpe.api.json
+ It contains following objects:
+ 16 messages
+ 8 services
-It contains these VPP binary API objects:
- 16 messages
- 8 services
*/
package vpe
@@ -18,13 +16,13 @@ import "github.com/lunixbochs/struc"
import "bytes"
// Reference imports to suppress errors if they are not otherwise used.
+var _ = api.RegisterMessage
var _ = struc.Pack
var _ = bytes.NewBuffer
/* Messages */
// ControlPing represents the VPP binary API message 'control_ping'.
-// Generated from 'vpe.api.json', line 4:
//
// "control_ping",
// [
@@ -54,12 +52,8 @@ func (*ControlPing) GetCrcString() string {
func (*ControlPing) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewControlPing() api.Message {
- return &ControlPing{}
-}
// ControlPingReply represents the VPP binary API message 'control_ping_reply'.
-// Generated from 'vpe.api.json', line 22:
//
// "control_ping_reply",
// [
@@ -101,12 +95,8 @@ func (*ControlPingReply) GetCrcString() string {
func (*ControlPingReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewControlPingReply() api.Message {
- return &ControlPingReply{}
-}
// Cli represents the VPP binary API message 'cli'.
-// Generated from 'vpe.api.json', line 48:
//
// "cli",
// [
@@ -142,12 +132,8 @@ func (*Cli) GetCrcString() string {
func (*Cli) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewCli() api.Message {
- return &Cli{}
-}
// CliInband represents the VPP binary API message 'cli_inband'.
-// Generated from 'vpe.api.json', line 70:
//
// "cli_inband",
// [
@@ -190,12 +176,8 @@ func (*CliInband) GetCrcString() string {
func (*CliInband) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewCliInband() api.Message {
- return &CliInband{}
-}
// CliReply represents the VPP binary API message 'cli_reply'.
-// Generated from 'vpe.api.json', line 98:
//
// "cli_reply",
// [
@@ -232,12 +214,8 @@ func (*CliReply) GetCrcString() string {
func (*CliReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewCliReply() api.Message {
- return &CliReply{}
-}
// CliInbandReply represents the VPP binary API message 'cli_inband_reply'.
-// Generated from 'vpe.api.json', line 120:
//
// "cli_inband_reply",
// [
@@ -281,12 +259,8 @@ func (*CliInbandReply) GetCrcString() string {
func (*CliInbandReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewCliInbandReply() api.Message {
- return &CliInbandReply{}
-}
// GetNodeIndex represents the VPP binary API message 'get_node_index'.
-// Generated from 'vpe.api.json', line 148:
//
// "get_node_index",
// [
@@ -323,12 +297,8 @@ func (*GetNodeIndex) GetCrcString() string {
func (*GetNodeIndex) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewGetNodeIndex() api.Message {
- return &GetNodeIndex{}
-}
// GetNodeIndexReply represents the VPP binary API message 'get_node_index_reply'.
-// Generated from 'vpe.api.json', line 171:
//
// "get_node_index_reply",
// [
@@ -365,12 +335,8 @@ func (*GetNodeIndexReply) GetCrcString() string {
func (*GetNodeIndexReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewGetNodeIndexReply() api.Message {
- return &GetNodeIndexReply{}
-}
// AddNodeNext represents the VPP binary API message 'add_node_next'.
-// Generated from 'vpe.api.json', line 193:
//
// "add_node_next",
// [
@@ -413,12 +379,8 @@ func (*AddNodeNext) GetCrcString() string {
func (*AddNodeNext) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewAddNodeNext() api.Message {
- return &AddNodeNext{}
-}
// AddNodeNextReply represents the VPP binary API message 'add_node_next_reply'.
-// Generated from 'vpe.api.json', line 221:
//
// "add_node_next_reply",
// [
@@ -455,12 +417,8 @@ func (*AddNodeNextReply) GetCrcString() string {
func (*AddNodeNextReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewAddNodeNextReply() api.Message {
- return &AddNodeNextReply{}
-}
// ShowVersion represents the VPP binary API message 'show_version'.
-// Generated from 'vpe.api.json', line 243:
//
// "show_version",
// [
@@ -490,12 +448,8 @@ func (*ShowVersion) GetCrcString() string {
func (*ShowVersion) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewShowVersion() api.Message {
- return &ShowVersion{}
-}
// ShowVersionReply represents the VPP binary API message 'show_version_reply'.
-// Generated from 'vpe.api.json', line 261:
//
// "show_version_reply",
// [
@@ -551,12 +505,8 @@ func (*ShowVersionReply) GetCrcString() string {
func (*ShowVersionReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewShowVersionReply() api.Message {
- return &ShowVersionReply{}
-}
// GetNodeGraph represents the VPP binary API message 'get_node_graph'.
-// Generated from 'vpe.api.json', line 299:
//
// "get_node_graph",
// [
@@ -586,12 +536,8 @@ func (*GetNodeGraph) GetCrcString() string {
func (*GetNodeGraph) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewGetNodeGraph() api.Message {
- return &GetNodeGraph{}
-}
// GetNodeGraphReply represents the VPP binary API message 'get_node_graph_reply'.
-// Generated from 'vpe.api.json', line 317:
//
// "get_node_graph_reply",
// [
@@ -628,12 +574,8 @@ func (*GetNodeGraphReply) GetCrcString() string {
func (*GetNodeGraphReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewGetNodeGraphReply() api.Message {
- return &GetNodeGraphReply{}
-}
// GetNextIndex represents the VPP binary API message 'get_next_index'.
-// Generated from 'vpe.api.json', line 339:
//
// "get_next_index",
// [
@@ -676,12 +618,8 @@ func (*GetNextIndex) GetCrcString() string {
func (*GetNextIndex) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func NewGetNextIndex() api.Message {
- return &GetNextIndex{}
-}
// GetNextIndexReply represents the VPP binary API message 'get_next_index_reply'.
-// Generated from 'vpe.api.json', line 367:
//
// "get_next_index_reply",
// [
@@ -718,9 +656,6 @@ func (*GetNextIndexReply) GetCrcString() string {
func (*GetNextIndexReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func NewGetNextIndexReply() api.Message {
- return &GetNextIndexReply{}
-}
/* Services */
diff --git a/examples/cmd/perf-bench/perf-bench.go b/examples/cmd/perf-bench/perf-bench.go
index 5b4b17d..664f046 100644
--- a/examples/cmd/perf-bench/perf-bench.go
+++ b/examples/cmd/perf-bench/perf-bench.go
@@ -20,7 +20,6 @@ import (
"flag"
"fmt"
"log"
- "os"
"time"
"github.com/pkg/profile"
@@ -65,16 +64,14 @@ func main() {
// connect to VPP
conn, err := govpp.Connect("")
if err != nil {
- log.Println("Error:", err)
- os.Exit(1)
+ log.Fatalln("Error:", err)
}
defer conn.Disconnect()
// create an API channel
ch, err := conn.NewAPIChannelBuffered(cnt, cnt)
if err != nil {
- log.Println("Error:", err)
- os.Exit(1)
+ log.Fatalln("Error:", err)
}
defer ch.Close()
@@ -101,10 +98,8 @@ func syncTest(ch api.Channel, cnt int) {
req := &vpe.ControlPing{}
reply := &vpe.ControlPingReply{}
- err := ch.SendRequest(req).ReceiveReply(reply)
- if err != nil {
- log.Println("Error in reply:", err)
- os.Exit(1)
+ if err := ch.SendRequest(req).ReceiveReply(reply); err != nil {
+ log.Fatalln("Error in reply:", err)
}
}
}
@@ -125,8 +120,7 @@ func asyncTest(ch api.Channel, cnt int) {
for ctx := range ctxChan {
reply := &vpe.ControlPingReply{}
if err := ctx.ReceiveReply(reply); err != nil {
- log.Println("Error in reply:", err)
- os.Exit(1)
+ log.Fatalln("Error in reply:", err)
}
}
}
diff --git a/examples/cmd/simple-client/simple_client.go b/examples/cmd/simple-client/simple_client.go
index b9e8052..08d4da6 100644
--- a/examples/cmd/simple-client/simple_client.go
+++ b/examples/cmd/simple-client/simple_client.go
@@ -18,6 +18,7 @@ package main
import (
"fmt"
+ "log"
"net"
"os"
"strings"
@@ -35,16 +36,14 @@ func main() {
// connect to VPP
conn, err := govpp.Connect("")
if err != nil {
- fmt.Println("Error:", err)
- os.Exit(1)
+ log.Fatalln("ERROR:", err)
}
defer conn.Disconnect()
// create an API channel that will be used in the examples
ch, err := conn.NewAPIChannel()
if err != nil {
- fmt.Println("Error:", err)
- os.Exit(1)
+ log.Fatalln("ERROR:", err)
}
defer ch.Close()
@@ -64,20 +63,22 @@ func main() {
// aclVersion is the simplest API example - one empty request message and one reply message.
func aclVersion(ch api.Channel) {
+ fmt.Println("ACL getting version")
+
req := &acl.ACLPluginGetVersion{}
reply := &acl.ACLPluginGetVersionReply{}
- err := ch.SendRequest(req).ReceiveReply(reply)
-
- if err != nil {
- fmt.Println("Error:", err)
+ if err := ch.SendRequest(req).ReceiveReply(reply); err != nil {
+ fmt.Println("ERROR:", err)
} else {
- fmt.Printf("%+v\n", reply)
+ fmt.Printf("ACL version reply: %+v\n", reply)
}
}
// aclConfig is another simple API example - in this case, the request contains structured data.
func aclConfig(ch api.Channel) {
+ fmt.Println("ACL adding replace")
+
req := &acl.ACLAddReplace{
ACLIndex: ^uint32(0),
Tag: []byte("access list 1"),
@@ -102,10 +103,8 @@ func aclConfig(ch api.Channel) {
}
reply := &acl.ACLAddReplaceReply{}
- err := ch.SendRequest(req).ReceiveReply(reply)
-
- if err != nil {
- fmt.Println("Error:", err)
+ if err := ch.SendRequest(req).ReceiveReply(reply); err != nil {
+ fmt.Println("ERROR:", err)
return
}
if reply.Retval != 0 {
@@ -113,19 +112,23 @@ func aclConfig(ch api.Channel) {
return
}
- fmt.Printf("%+v\n", reply)
+ fmt.Printf("ACL add replace reply: %+v\n", reply)
}
// aclDump shows an example where SendRequest and ReceiveReply are not chained together.
func aclDump(ch api.Channel) {
+ fmt.Println("Dumping ACL")
+
req := &acl.ACLDump{}
reply := &acl.ACLDetails{}
- if err := ch.SendRequest(req).ReceiveReply(reply); err != nil {
- fmt.Println("Error:", err)
+ reqCtx := ch.SendRequest(req)
+
+ if err := reqCtx.ReceiveReply(reply); err != nil {
+ fmt.Println("ERROR:", err)
} else {
- fmt.Printf("%+v\n", reply)
+ fmt.Printf("ACL details: %+v\n", reply)
}
}
@@ -133,14 +136,13 @@ func aclDump(ch api.Channel) {
func interfaceDump(ch api.Channel) {
fmt.Println("Dumping interfaces")
- req := &interfaces.SwInterfaceDump{}
- reqCtx := ch.SendMultiRequest(req)
+ reqCtx := ch.SendMultiRequest(&interfaces.SwInterfaceDump{})
for {
msg := &interfaces.SwInterfaceDetails{}
stop, err := reqCtx.ReceiveReply(msg)
if stop {
- break // break out of the loop
+ break
}
if err != nil {
fmt.Println("ERROR:", err)
@@ -148,7 +150,7 @@ func interfaceDump(ch api.Channel) {
ifaceName := strings.TrimFunc(string(msg.InterfaceName), func(r rune) bool {
return r == 0x00
})
- fmt.Printf("Interface: %q %+v\n", ifaceName, msg)
+ fmt.Printf("Interface %q: %+v\n", ifaceName, msg)
}
}
@@ -164,12 +166,12 @@ func ipAddressDump(ch api.Channel) {
msg := &ip.IPAddressDetails{}
stop, err := reqCtx.ReceiveReply(msg)
if stop {
- break // break out of the loop
+ break
}
if err != nil {
fmt.Println("ERROR:", err)
}
- fmt.Printf("ip address: %d %+v\n", msg.SwIfIndex, msg)
+ fmt.Printf("ip address details: %d %+v\n", msg.SwIfIndex, msg)
}
}
@@ -183,7 +185,7 @@ func setIpUnnumbered(ch api.Channel) {
reply := &interfaces.SwInterfaceSetUnnumberedReply{}
if err := ch.SendRequest(req).ReceiveReply(reply); err != nil {
- fmt.Println("Error:", err)
+ fmt.Println("ERROR:", err)
} else {
fmt.Printf("%+v\n", reply)
}
@@ -192,21 +194,20 @@ func setIpUnnumbered(ch api.Channel) {
func ipUnnumberedDump(ch api.Channel) {
fmt.Println("Dumping IP unnumbered")
- req := &ip.IPUnnumberedDump{
+ reqCtx := ch.SendMultiRequest(&ip.IPUnnumberedDump{
SwIfIndex: ^uint32(0),
- }
- reqCtx := ch.SendMultiRequest(req)
+ })
for {
msg := &ip.IPUnnumberedDetails{}
stop, err := reqCtx.ReceiveReply(msg)
if stop {
- break // break out of the loop
+ break
}
if err != nil {
fmt.Println("ERROR:", err)
}
- fmt.Printf("ip unnumbered: %+v\n", msg)
+ fmt.Printf("IP unnumbered details: %+v\n", msg)
}
}
@@ -214,9 +215,12 @@ func ipUnnumberedDump(ch api.Channel) {
// you are supposed to create your own Go channel with your preferred buffer size. If the channel's
// buffer is full, the notifications will not be delivered into it.
func interfaceNotifications(ch api.Channel) {
- // subscribe for specific notification message
+ fmt.Println("Subscribing to notificaiton events")
+
notifChan := make(chan api.Message, 100)
- subs, err := ch.SubscribeNotification(notifChan, interfaces.NewSwInterfaceEvent)
+
+ // subscribe for specific notification message
+ sub, err := ch.SubscribeNotification(notifChan, &interfaces.SwInterfaceEvent{})
if err != nil {
panic(err)
}
@@ -248,7 +252,7 @@ func interfaceNotifications(ch api.Channel) {
// receive one notification
notif := (<-notifChan).(*interfaces.SwInterfaceEvent)
- fmt.Printf("NOTIF: %+v\n", notif)
+ fmt.Printf("incoming event: %+v\n", notif)
// disable interface events in VPP
err = ch.SendRequest(&interfaces.WantInterfaceEvents{
@@ -260,7 +264,7 @@ func interfaceNotifications(ch api.Channel) {
}
// unsubscribe from delivery of the notifications
- err = ch.UnsubscribeNotification(subs)
+ err = sub.Unsubscribe()
if err != nil {
panic(err)
}
diff --git a/examples/cmd/stats-client/stats_client.go b/examples/cmd/stats-client/stats_client.go
index 4ea4659..f61f975 100644
--- a/examples/cmd/stats-client/stats_client.go
+++ b/examples/cmd/stats-client/stats_client.go
@@ -18,6 +18,7 @@ package main
import (
"fmt"
+ "log"
"os"
"os/signal"
@@ -28,45 +29,41 @@ import (
)
func main() {
- fmt.Println("Starting stats VPP client...")
+ fmt.Println("Starting stats VPP client..")
// async connect to VPP
conn, statCh, err := govpp.AsyncConnect("")
if err != nil {
- fmt.Println("Error:", err)
- os.Exit(1)
+ log.Fatalln("Error:", err)
}
defer conn.Disconnect()
// create an API channel that will be used in the examples
ch, err := conn.NewAPIChannel()
if err != nil {
- fmt.Println("Error:", err)
- os.Exit(1)
+ log.Fatalln("Error:", err)
}
- defer fmt.Println("calling close")
defer ch.Close()
// create channel for Interrupt signal
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, os.Interrupt)
- var simpleCountersSubs *api.NotifSubscription
- var combinedCountersSubs *api.NotifSubscription
var notifChan chan api.Message
+ var simpleSub api.SubscriptionCtx
+ var combinedSub api.SubscriptionCtx
// loop until Interrupt signal is received
loop:
for {
select {
-
case connEvent := <-statCh:
// VPP connection state change
switch connEvent.State {
case core.Connected:
fmt.Println("VPP connected.")
- if simpleCountersSubs == nil {
- simpleCountersSubs, combinedCountersSubs, notifChan = subscribeNotifications(ch)
+ if notifChan == nil {
+ simpleSub, combinedSub, notifChan = subscribeNotifications(ch)
}
requestStatistics(ch)
@@ -93,24 +90,24 @@ loop:
}
}
- ch.UnsubscribeNotification(simpleCountersSubs)
- ch.UnsubscribeNotification(combinedCountersSubs)
+ simpleSub.Unsubscribe()
+ combinedSub.Unsubscribe()
}
// subscribeNotifications subscribes for interface counters notifications.
-func subscribeNotifications(ch api.Channel) (*api.NotifSubscription, *api.NotifSubscription, chan api.Message) {
+func subscribeNotifications(ch api.Channel) (api.SubscriptionCtx, api.SubscriptionCtx, chan api.Message) {
notifChan := make(chan api.Message, 100)
- simpleCountersSubs, err := ch.SubscribeNotification(notifChan, stats.NewVnetInterfaceSimpleCounters)
+ simpleSub, err := ch.SubscribeNotification(notifChan, &stats.VnetInterfaceSimpleCounters{})
if err != nil {
panic(err)
}
- combinedCountersSubs, err := ch.SubscribeNotification(notifChan, stats.NewVnetInterfaceCombinedCounters)
+ combinedSub, err := ch.SubscribeNotification(notifChan, &stats.VnetInterfaceCombinedCounters{})
if err != nil {
panic(err)
}
- return simpleCountersSubs, combinedCountersSubs, notifChan
+ return simpleSub, combinedSub, notifChan
}
// requestStatistics requests interface counters notifications from VPP.