api

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2022 License: Apache-2.0 Imports: 6 Imported by: 2,927

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.

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

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

Variables

This section is empty.

Functions

func GetRegisteredMessageTypes added in v0.3.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 API waits for a reply
	// from VPP before returning an error.
	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.

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.

type CompatibilityError added in v0.3.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.3.0

func (c *CompatibilityError) Error() string

type Connection added in v0.4.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
}

Connection represents the client connection to VPP API.

NOTE: This API is EXPERIMENTAL.

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.2.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.5.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.4.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.

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.4.0

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

Record contains essential information about 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.

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.4.0

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

NOTE: This API is EXPERIMENTAL.

type StreamOption added in v0.4.0

type StreamOption func(Stream)

StreamOption allows customizing a Stream. Available options are: - WithRequestSize - WithReplySize - WithReplyTimeout

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.

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.4.0

type Trace interface {
	// Enable allows to enable or disable API trace for a connection.
	Enable(enable bool)

	// GetRecords retrieves all messages collected (from all channels if they are used)
	// since the point the trace was enabled or cleared.
	GetRecords() []*Record

	// GetRecordsForChannel retrieves messages collected by the given channel since
	// the point the trace was enabled or cleared.
	GetRecordsForChannel(chId uint16) []*Record

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

Trace gives access to the API trace tool, capturing outcoming and incoming messages to and from GoVPP.

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.

func (VPPApiError) Error

func (e VPPApiError) Error() string

Jump to

Keyboard shortcuts

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