api

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 6 Imported by: 721

Documentation

Overview

Package api defines interfaces required by every file generated with binapi-generator

Index

Constants

View Source
const (
	GoVppAPIPackageIsVersion1 = true
	GoVppAPIPackageIsVersion2 = true
)

GoVppAPIPackageIsVersionX is referenced from generated binapi files to assert that that code is compatible with this version of the GoVPP api package.

Variables

This section is empty.

Functions

func GetRegisteredMessageTypes added in v0.6.0

func GetRegisteredMessageTypes() map[string]map[reflect.Type]string

GetRegisteredMessageTypes returns list of all registered message types.

func GetRegisteredMessages

func GetRegisteredMessages() map[string]map[string]Message

GetRegisteredMessages returns list of all registered messages.

func RegisterMessage

func RegisterMessage(x Message, name string)

RegisterMessage is called from generated code to register message.

func RetvalToVPPApiError

func RetvalToVPPApiError(retval int32) error

RetvalToVPPApiError returns error for retval value. Retval 0 returns nil error.

Types

type BufferPool

type BufferPool struct {
	PoolName string

	Cached    float64
	Used      float64
	Available float64
}

BufferPool represents buffer pool.

type BufferStats

type BufferStats struct {
	Buffer map[string]BufferPool
}

BufferStats represents statistics per buffer pool.

type Channel

type Channel interface {
	// 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

	// SendMultiRequest asynchronously sends a multipart request (request to which multiple responses are expected) to VPP.
	// Returns a multipart 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).
	SendMultiRequest(msg Message) MultiRequestCtx

	// 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, event Message) (SubscriptionCtx, error)

	// SetReplyTimeout sets the timeout for replies from VPP. It represents the maximum time the client waits for a reply
	// from VPP before returning a timeout error. Setting the reply timeout to 0 disables it. The initial reply timeout is
	//set to the value of core.DefaultReplyTimeout.
	SetReplyTimeout(timeout time.Duration)

	// CheckCompatibility checks the compatiblity for the given messages.
	// It will return an error if any of the given messages are not compatible.
	CheckCompatiblity(msgs ...Message) error

	// Close closes the API channel and releases all API channel-related resources
	// in the ChannelProvider.
	Close()
}

Channel provides methods for direct communication with VPP channel.

DEPRECATED: Use Stream instead.

type ChannelProvider

type ChannelProvider interface {
	// NewAPIChannel returns a new channel for communication with VPP via govpp core.
	// It uses default buffer sizes for the request and reply Go channels.
	NewAPIChannel() (Channel, error)

	// NewAPIChannelBuffered returns a new channel for communication with VPP via govpp core.
	// It allows to specify custom buffer sizes for the request and reply Go channels.
	NewAPIChannelBuffered(reqChanBufSize, replyChanBufSize int) (Channel, error)
}

ChannelProvider provides the communication channel with govpp core.

DEPRECATED: Use Connection instead.

type CompatibilityError added in v0.6.0

type CompatibilityError struct {
	CompatibleMessages   []string
	IncompatibleMessages []string
}

CompatibilityError is the error type usually returned by CheckCompatibility method of Channel. It contains list of all the compatible/incompatible messages.

func (*CompatibilityError) Error added in v0.6.0

func (c *CompatibilityError) Error() string

type Connection added in v0.6.0

type Connection interface {
	// NewStream creates a new stream for sending and receiving messages.
	// Context can be used to close the stream using cancel or timeout.
	NewStream(ctx context.Context, options ...StreamOption) (Stream, error)

	// Invoke can be used for a simple request-reply RPC.
	// It creates stream and calls SendMsg with req and RecvMsg which returns
	// reply.
	Invoke(ctx context.Context, req Message, reply Message) error

	// WatchEvent creates a new watcher for watching events of type specified by
	// event parameter. Context can be used to close the watcher.
	WatchEvent(ctx context.Context, event Message) (Watcher, error)
}

Connection represents the client connection to VPP API.

type DataType

type DataType interface {
	// GetTypeName returns the original VPP name of the data type, as defined in the VPP API.
	GetTypeName() string
}

DataType is an interface that is implemented by all VPP Binary API data types by the binapi_generator.

type ErrorCounter

type ErrorCounter struct {
	CounterName string

	Values []uint64
}

ErrorCounter represents error counter.

type ErrorStats

type ErrorStats struct {
	Errors []ErrorCounter
}

ErrorStats represents statistics per error counter.

type InterfaceCounterCombined added in v0.6.0

type InterfaceCounterCombined struct {
	Packets uint64
	Bytes   uint64
}

InterfaceCounterCombined defines combined counters for interfaces.

type InterfaceCounters

type InterfaceCounters struct {
	InterfaceIndex uint32
	InterfaceName  string // requires VPP 19.04+

	Rx InterfaceCounterCombined
	Tx InterfaceCounterCombined

	RxErrors uint64
	TxErrors uint64

	RxUnicast   InterfaceCounterCombined
	RxMulticast InterfaceCounterCombined
	RxBroadcast InterfaceCounterCombined
	TxUnicast   InterfaceCounterCombined
	TxMulticast InterfaceCounterCombined
	TxBroadcast InterfaceCounterCombined

	Drops   uint64
	Punts   uint64
	IP4     uint64
	IP6     uint64
	RxNoBuf uint64
	RxMiss  uint64
	Mpls    uint64
}

InterfaceCounters represents interface counters.

type InterfaceStats

type InterfaceStats struct {
	Interfaces []InterfaceCounters
}

InterfaceStats represents per interface statistics.

type MemoryCounters added in v0.6.0

type MemoryCounters struct {
	Total      uint64
	Used       uint64
	Free       uint64
	UsedMMap   uint64
	TotalAlloc uint64
	FreeChunks uint64
	Releasable uint64
}

MemoryCounters represents values of various memory usage

type MemoryStats added in v0.6.0

type MemoryStats struct {
	// Deprecated: /mem/statseg total memory directory
	Total float64
	// Deprecated: /mem/statseg used memory directory
	Used float64

	// stat/main memory usage per-heap
	Stat map[int]MemoryCounters
	Main map[int]MemoryCounters
}

MemoryStats represents memory stats segment counters.

type Message

type Message interface {
	// GetMessageName returns the original VPP name of the message, as defined in the VPP API.
	GetMessageName() string

	// GetCrcString returns the string with CRC checksum of the message definition (the string represents a hexadecimal number).
	GetCrcString() string

	// GetMessageType returns the type of the VPP message.
	GetMessageType() MessageType
}

Message is an interface that is implemented by all VPP Binary API messages generated by the binapigenerator.

type MessageType

type MessageType int

MessageType represents the type of a VPP message derived from message header fields.

const (
	// RequestMessage represents a VPP request message
	RequestMessage MessageType = iota
	// ReplyMessage represents a VPP reply message
	ReplyMessage
	// EventMessage represents a VPP event message
	EventMessage
	// OtherMessage represents other VPP message
	OtherMessage
)

type MultiRequestCtx

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
	// set to true. Do not use the message itself if lastReplyReceived is
	// true - it won't be filled with actual data.Error will be returned if the
	// response cannot be received or decoded.
	ReceiveReply(msg Message) (lastReplyReceived bool, err error)
}

MultiRequestCtx is helper interface which allows to receive reply on multi-request.

DEPRECATED: Use Stream instead.

type NodeCounters

type NodeCounters struct {
	NodeIndex uint32
	NodeName  string // requires VPP 19.04+

	Clocks   uint64
	Vectors  uint64
	Calls    uint64
	Suspends uint64
}

NodeCounters represents node counters.

type NodeStats

type NodeStats struct {
	Nodes []NodeCounters
}

NodeStats represents per node statistics.

type Record added in v0.6.0

type Record struct {
	Message    Message
	Timestamp  time.Time
	IsReceived bool
	ChannelID  uint16
	Succeeded  bool
}

Record contains essential information about the traced message, its timestamp and whether the message was received or sent

type RequestCtx

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
}

RequestCtx is helper interface which allows to receive reply on request.

DEPRECATED: Use Stream instead.

type StatsProvider

type StatsProvider interface {
	GetSystemStats(*SystemStats) error
	GetNodeStats(*NodeStats) error
	GetInterfaceStats(*InterfaceStats) error
	GetErrorStats(*ErrorStats) error
	GetBufferStats(*BufferStats) error
	GetMemoryStats(*MemoryStats) error
}

StatsProvider provides methods for retrieving statistics.

type Stream added in v0.6.0

type Stream interface {
	// Context returns the context for this stream.
	Context() context.Context

	// SendMsg sends a message to the client.
	// It blocks until message is sent to the transport.
	SendMsg(Message) error

	// RecvMsg blocks until a message is received or error occurs.
	RecvMsg() (Message, error)

	// Close closes the stream. Calling SendMsg and RecvMsg will return error
	// after closing stream.
	Close() error
}

Stream provides low-level access for sending and receiving messages. Users should handle correct type and ordering of messages.

It is not safe to call these methods on the same stream in different goroutines.

type StreamOption added in v0.6.0

type StreamOption func(Stream)

StreamOption allows customizing a Stream.

type SubscriptionCtx

type SubscriptionCtx interface {
	// Unsubscribe unsubscribes from receiving the notifications tied to the
	// subscription context.
	Unsubscribe() error
}

SubscriptionCtx is helper interface which allows to control subscription for notification events.

DEPRECATED: Use Connection instead.

type SystemStats

type SystemStats struct {
	VectorRate          uint64
	NumWorkerThreads    uint64
	VectorRatePerWorker []uint64
	InputRate           uint64
	LastUpdate          uint64
	LastStatsClear      uint64
	Heartbeat           uint64
}

SystemStats represents global system statistics.

type Trace added in v0.6.0

type Trace interface {
	// GetRecords returns all API messages from all channels captured since the trace
	// was initialized or cleared up to the point of the call.
	GetRecords() []*Record

	// GetRecordsForChannel returns all API messages recorded by the given channel.
	GetRecordsForChannel(chId uint16) []*Record

	// Clear erases messages captured so far.
	Clear()

	// Close the tracer and release associated resources
	Close()
}

Trace is the GoVPP utility tool capturing processed API messages. The trace is not operational by default. Enable trace for a given connection by calling `NewTrace(connection, size)`

type VPPApiError

type VPPApiError int32

VPPApiError represents VPP's vnet API error that is usually returned as Retval field in replies from VPP binary API.

const (
	UNSPECIFIED                        VPPApiError = -1
	INVALID_SW_IF_INDEX                VPPApiError = -2
	NO_SUCH_FIB                        VPPApiError = -3
	NO_SUCH_INNER_FIB                  VPPApiError = -4
	NO_SUCH_LABEL                      VPPApiError = -5
	NO_SUCH_ENTRY                      VPPApiError = -6
	INVALID_VALUE                      VPPApiError = -7
	INVALID_VALUE_2                    VPPApiError = -8
	UNIMPLEMENTED                      VPPApiError = -9
	INVALID_SW_IF_INDEX_2              VPPApiError = -10
	SYSCALL_ERROR_1                    VPPApiError = -11
	SYSCALL_ERROR_2                    VPPApiError = -12
	SYSCALL_ERROR_3                    VPPApiError = -13
	SYSCALL_ERROR_4                    VPPApiError = -14
	SYSCALL_ERROR_5                    VPPApiError = -15
	SYSCALL_ERROR_6                    VPPApiError = -16
	SYSCALL_ERROR_7                    VPPApiError = -17
	SYSCALL_ERROR_8                    VPPApiError = -18
	SYSCALL_ERROR_9                    VPPApiError = -19
	SYSCALL_ERROR_10                   VPPApiError = -20
	FEATURE_DISABLED                   VPPApiError = -30
	INVALID_REGISTRATION               VPPApiError = -31
	NEXT_HOP_NOT_IN_FIB                VPPApiError = -50
	UNKNOWN_DESTINATION                VPPApiError = -51
	PREFIX_MATCHES_NEXT_HOP            VPPApiError = -52
	NEXT_HOP_NOT_FOUND_MP              VPPApiError = -53
	NO_MATCHING_INTERFACE              VPPApiError = -54
	INVALID_VLAN                       VPPApiError = -55
	VLAN_ALREADY_EXISTS                VPPApiError = -56
	INVALID_SRC_ADDRESS                VPPApiError = -57
	INVALID_DST_ADDRESS                VPPApiError = -58
	ADDRESS_LENGTH_MISMATCH            VPPApiError = -59
	ADDRESS_NOT_FOUND_FOR_INTERFACE    VPPApiError = -60
	ADDRESS_NOT_DELETABLE              VPPApiError = -61
	IP6_NOT_ENABLED                    VPPApiError = -62
	NO_SUCH_NODE                       VPPApiError = -63
	NO_SUCH_NODE2                      VPPApiError = -64
	NO_SUCH_TABLE                      VPPApiError = -65
	NO_SUCH_TABLE2                     VPPApiError = -66
	NO_SUCH_TABLE3                     VPPApiError = -67
	SUBIF_ALREADY_EXISTS               VPPApiError = -68
	SUBIF_CREATE_FAILED                VPPApiError = -69
	INVALID_MEMORY_SIZE                VPPApiError = -70
	INVALID_INTERFACE                  VPPApiError = -71
	INVALID_VLAN_TAG_COUNT             VPPApiError = -72
	INVALID_ARGUMENT                   VPPApiError = -73
	UNEXPECTED_INTF_STATE              VPPApiError = -74
	TUNNEL_EXIST                       VPPApiError = -75
	INVALID_DECAP_NEXT                 VPPApiError = -76
	RESPONSE_NOT_READY                 VPPApiError = -77
	NOT_CONNECTED                      VPPApiError = -78
	IF_ALREADY_EXISTS                  VPPApiError = -79
	BOND_SLAVE_NOT_ALLOWED             VPPApiError = -80
	VALUE_EXIST                        VPPApiError = -81
	SAME_SRC_DST                       VPPApiError = -82
	IP6_MULTICAST_ADDRESS_NOT_PRESENT  VPPApiError = -83
	SR_POLICY_NAME_NOT_PRESENT         VPPApiError = -84
	NOT_RUNNING_AS_ROOT                VPPApiError = -85
	ALREADY_CONNECTED                  VPPApiError = -86
	UNSUPPORTED_JNI_VERSION            VPPApiError = -87
	FAILED_TO_ATTACH_TO_JAVA_THREAD    VPPApiError = -88
	INVALID_WORKER                     VPPApiError = -89
	LISP_DISABLED                      VPPApiError = -90
	CLASSIFY_TABLE_NOT_FOUND           VPPApiError = -91
	INVALID_EID_TYPE                   VPPApiError = -92
	CANNOT_CREATE_PCAP_FILE            VPPApiError = -93
	INCORRECT_ADJACENCY_TYPE           VPPApiError = -94
	EXCEEDED_NUMBER_OF_RANGES_CAPACITY VPPApiError = -95
	EXCEEDED_NUMBER_OF_PORTS_CAPACITY  VPPApiError = -96
	INVALID_ADDRESS_FAMILY             VPPApiError = -97
	INVALID_SUB_SW_IF_INDEX            VPPApiError = -98
	TABLE_TOO_BIG                      VPPApiError = -99
	CANNOT_ENABLE_DISABLE_FEATURE      VPPApiError = -100
	BFD_EEXIST                         VPPApiError = -101
	BFD_ENOENT                         VPPApiError = -102
	BFD_EINUSE                         VPPApiError = -103
	BFD_NOTSUPP                        VPPApiError = -104
	ADDRESS_IN_USE                     VPPApiError = -105
	ADDRESS_NOT_IN_USE                 VPPApiError = -106
	QUEUE_FULL                         VPPApiError = -107
	APP_UNSUPPORTED_CFG                VPPApiError = -108
	URI_FIFO_CREATE_FAILED             VPPApiError = -109
	LISP_RLOC_LOCAL                    VPPApiError = -110
	BFD_EAGAIN                         VPPApiError = -111
	INVALID_GPE_MODE                   VPPApiError = -112
	LISP_GPE_ENTRIES_PRESENT           VPPApiError = -113
	ADDRESS_FOUND_FOR_INTERFACE        VPPApiError = -114
	SESSION_CONNECT                    VPPApiError = -115
	ENTRY_ALREADY_EXISTS               VPPApiError = -116
	SVM_SEGMENT_CREATE_FAIL            VPPApiError = -117
	APPLICATION_NOT_ATTACHED           VPPApiError = -118
	BD_ALREADY_EXISTS                  VPPApiError = -119
	BD_IN_USE                          VPPApiError = -120
	BD_NOT_MODIFIABLE                  VPPApiError = -121
	BD_ID_EXCEED_MAX                   VPPApiError = -122
	SUBIF_DOESNT_EXIST                 VPPApiError = -123
	L2_MACS_EVENT_CLINET_PRESENT       VPPApiError = -124
	INVALID_QUEUE                      VPPApiError = -125
	UNSUPPORTED                        VPPApiError = -126
	DUPLICATE_IF_ADDRESS               VPPApiError = -127
	APP_INVALID_NS                     VPPApiError = -128
	APP_WRONG_NS_SECRET                VPPApiError = -129
	APP_CONNECT_SCOPE                  VPPApiError = -130
	APP_ALREADY_ATTACHED               VPPApiError = -131
	SESSION_REDIRECT                   VPPApiError = -132
	ILLEGAL_NAME                       VPPApiError = -133
	NO_NAME_SERVERS                    VPPApiError = -134
	NAME_SERVER_NOT_FOUND              VPPApiError = -135
	NAME_RESOLUTION_NOT_ENABLED        VPPApiError = -136
	NAME_SERVER_FORMAT_ERROR           VPPApiError = -137
	NAME_SERVER_NO_SUCH_NAME           VPPApiError = -138
	NAME_SERVER_NO_ADDRESSES           VPPApiError = -139
	NAME_SERVER_NEXT_SERVER            VPPApiError = -140
	APP_CONNECT_FILTERED               VPPApiError = -141
	ACL_IN_USE_INBOUND                 VPPApiError = -142
	ACL_IN_USE_OUTBOUND                VPPApiError = -143
	INIT_FAILED                        VPPApiError = -144
	NETLINK_ERROR                      VPPApiError = -145
	BIER_BSL_UNSUP                     VPPApiError = -146
	INSTANCE_IN_USE                    VPPApiError = -147
	INVALID_SESSION_ID                 VPPApiError = -148
	ACL_IN_USE_BY_LOOKUP_CONTEXT       VPPApiError = -149
	INVALID_VALUE_3                    VPPApiError = -150
	NON_ETHERNET                       VPPApiError = -151
	BD_ALREADY_HAS_BVI                 VPPApiError = -152
	INVALID_PROTOCOL                   VPPApiError = -153
	INVALID_ALGORITHM                  VPPApiError = -154
	RSRC_IN_USE                        VPPApiError = -155
	KEY_LENGTH                         VPPApiError = -156
	FIB_PATH_UNSUPPORTED_NH_PROTO      VPPApiError = -157
	API_ENDIAN_FAILED                  VPPApiError = -159
	NO_CHANGE                          VPPApiError = -160
	MISSING_CERT_KEY                   VPPApiError = -161
	LIMIT_EXCEEDED                     VPPApiError = -162
	IKE_NO_PORT                        VPPApiError = -163
	UDP_PORT_TAKEN                     VPPApiError = -164
	EAGAIN                             VPPApiError = -165
	INVALID_VALUE_4                    VPPApiError = -166
	BUSY                               VPPApiError = -167
	BUG                                VPPApiError = -168
	FEATURE_ALREADY_DISABLED           VPPApiError = -169
	FEATURE_ALREADY_ENABLED            VPPApiError = -170
	INVALID_PREFIX_LENGTH              VPPApiError = -171
)

definitions from: vpp/src/vnet/error.h

func (VPPApiError) Error

func (e VPPApiError) Error() string

type Watcher added in v0.7.0

type Watcher interface {
	// Events returns a channel where events are sent. The channel is closed when
	// watcher context is canceled or when Close is called.
	Events() <-chan Message

	// Close closes the watcher along with the events channel.
	Close()
}

Watcher provides access to watched event messages. It can be created by calling Connection.WatchEvent.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL