govpp

package module
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: 5 Imported by: 21

README

⚠️ The GoVPP project is changing hosting :

The last version archived on git.fd.io/govpp.git will be v0.5.0.

GoVPP

stable PkgGoDev

The GoVPP repository contains a Go client library for interacting with the VPP, generator of Go bindings for the VPP binary API and various other tooling for VPP.

Overview

Here is a brief overview for the repository structure.

  • govpp - the entry point for the GoVPP client
    • adapter - VPP binary & stats API interface
      • mock - Mock adapter used for testing
      • socketclient - Go implementation of VPP API client for unix socket
      • statsclient - Go implementation of VPP Stats client for shared memory
      • vppapiclient - CGo wrapper of vppapiclient library (DEPRECATED!)
    • api - GoVPP client API
    • binapigen - library for generating code from VPP API
    • cmd/
    • codec - handles encoding/decoding of generated messages into binary form
    • core - implementation of the GoVPP client
    • docs - documentation
    • examples - examples demonstrating GoVPP functionality
    • internal - packages used internally by GoVPP
    • proxy - contains client/server implementation for proxy
    • test - integration tests, benchmarks and performance tests

Quick Start

Below are some code examples showing GoVPP client interacting with VPP API.

Using raw messages directly

Here is a code for low-level way to access the VPP API using the generated messages directly for sending/receiving.

package main

import (
    "log"
    
	"git.fd.io/govpp.git"
	"git.fd.io/govpp.git/binapi/interfaces"
	"git.fd.io/govpp.git/binapi/vpe"
)

func main() {
	// Connect to VPP
	conn, _ := govpp.Connect("/run/vpp/api.sock")
	defer conn.Disconnect()

	// Open channel
	ch, _ := conn.NewAPIChannel()
	defer ch.Close()

	// Prepare messages
	req := &vpe.ShowVersion{}
	reply := &vpe.ShowVersionReply{}

	// Send the request
	err := ch.SendRequest(req).ReceiveReply(reply)
	if err != nil {
        log.Fatal("ERROR: ", err)
	}

    log.Print("Version: ", reply.Version)
}

For a complete example see simple-client.

Using RPC service client

Here is a sample code for an effortless way to access the VPP API using a generated RPC service client for calling.

package main

import (
    "context"
    "log"

	"git.fd.io/govpp.git"
	"git.fd.io/govpp.git/binapi/vpe"
)

func main() {
	// Connect to VPP API socket
	conn, _ := govpp.Connect("/run/vpp/api.sock")
	defer conn.Disconnect()

	// Init vpe service client
    client := vpe.NewServiceClient(conn)

	reply, err := client.ShowVersion(context.Background(), &vpe.ShowVersion{})
	if err != nil {
		log.Fatal("ERROR: ", err)
	}

	log.Print("Version: ", reply.Version)
}

For a complete example see rpc-service.

More code examples

More examples can be found in examples directory.

  • api-trace - trace sent/received messages
  • binapi-types - using common types from generated code
  • multi-vpp - connect to multiple VPP instances
  • perf-bench - very basic performance test for measuring throughput
  • rpc-service - effortless way to call VPP API via RPC client
  • simple-client - send and receive VPP API messages using GoVPP API directly
  • stats-client - client for retrieving VPP stats data
  • stream-client - using new stream API to call VPP API

Documentation

Further documentation can be found in docs directory.

  • Adapters - detailed info about transport adapters and their implementations
  • Binapi Generator - user guide for generating VPP binary API

Documentation

Overview

Package govpp provides the entry point to govpp functionality. It provides the API for connecting the govpp core to VPP either using the default VPP adapter, or using the adapter previously set by SetAdapter function (useful mostly just for unit/integration tests with mocked VPP adapter).

To create a connection to VPP, use govpp.Connect function:

conn, err := govpp.Connect()
if err != nil {
	// handle error!
}
defer conn.Disconnect()

Make sure you close the connection after using it. If the connection is not closed, it will leak resources. Please note that only one VPP connection is allowed for a single process.

In case you need to mock the connection to VPP (e.g. for testing), use the govpp.SetAdapter function before calling govpp.Connect.

Once connected to VPP, use the functions from the api package to communicate with it.

Index

Constants

This section is empty.

Variables

View Source
var NewVppAdapter = func(target string) adapter.VppAPI {
	return socketclient.NewVppClient(target)
}

NewVppAdapter returns new instance of VPP adapter for connecting to VPP API.

Functions

func AsyncConnect

func AsyncConnect(target string, attempts int, interval time.Duration) (*core.Connection, chan core.ConnectionEvent, error)

AsyncConnect asynchronously connects to the VPP API using a new adapter instance created with NewVppAPIAdapter.

This call does not block until connection is established, it returns immediately. The caller is supposed to watch the returned ConnectionState channel for connection events. In case of disconnect, the library will asynchronously try to reconnect.

func Connect

func Connect(target string) (*core.Connection, error)

Connect connects to the VPP API using a new adapter instance created with NewVppAPIAdapter.

This call blocks until VPP is connected, or an error occurs. Only one connection attempt will be performed.

func Version added in v0.4.0

func Version() string

Version returns version of GoVPP.

Types

This section is empty.

Directories

Path Synopsis
Package adapter provides an interface between govpp core and the VPP.
Package adapter provides an interface between govpp core and the VPP.
mock
Package mock is an alternative VPP adapter aimed for unit/integration testing where the actual communication with VPP is not demanded.
Package mock is an alternative VPP adapter aimed for unit/integration testing where the actual communication with VPP is not demanded.
mock/binapi
Package binapi is a helper package for generic handling of VPP binary API messages in the mock adapter and integration tests.
Package binapi is a helper package for generic handling of VPP binary API messages in the mock adapter and integration tests.
socketclient
Package socketclient is a pure Go implementation of adapter.VppAPI, which uses unix domain sockets as the transport for connecting to the VPP binary API.
Package socketclient is a pure Go implementation of adapter.VppAPI, which uses unix domain sockets as the transport for connecting to the VPP binary API.
statsclient
Package statsclient is pure Go implementation of VPP stats API client.
Package statsclient is pure Go implementation of VPP stats API client.
vppapiclient
Package vppapiclient is the default VPP adapter being used for the connection to VPP binary & stats API via shared memory.
Package vppapiclient is the default VPP adapter being used for the connection to VPP binary & stats API via shared memory.
Package api defines interfaces required by every file generated with binapi-generator
Package api defines interfaces required by every file generated with binapi-generator
abf
Package abf contains generated bindings for API file abf.api.
Package abf contains generated bindings for API file abf.api.
acl
Package acl contains generated bindings for API file acl.api.
Package acl contains generated bindings for API file acl.api.
acl_types
Package acl_types contains generated bindings for API file acl_types.api.
Package acl_types contains generated bindings for API file acl_types.api.
adl
Package adl contains generated bindings for API file adl.api.
Package adl contains generated bindings for API file adl.api.
af_packet
Package af_packet contains generated bindings for API file af_packet.api.
Package af_packet contains generated bindings for API file af_packet.api.
af_xdp
Package af_xdp contains generated bindings for API file af_xdp.api.
Package af_xdp contains generated bindings for API file af_xdp.api.
arp
Package arp contains generated bindings for API file arp.api.
Package arp contains generated bindings for API file arp.api.
arping
Package arping contains generated bindings for API file arping.api.
Package arping contains generated bindings for API file arping.api.
avf
Package avf contains generated bindings for API file avf.api.
Package avf contains generated bindings for API file avf.api.
bfd
Package bfd contains generated bindings for API file bfd.api.
Package bfd contains generated bindings for API file bfd.api.
bier
Package bier contains generated bindings for API file bier.api.
Package bier contains generated bindings for API file bier.api.
bond
Package bond contains generated bindings for API file bond.api.
Package bond contains generated bindings for API file bond.api.
builtinurl
Package builtinurl contains generated bindings for API file builtinurl.api.
Package builtinurl contains generated bindings for API file builtinurl.api.
cdp
Package cdp contains generated bindings for API file cdp.api.
Package cdp contains generated bindings for API file cdp.api.
classify
Package classify contains generated bindings for API file classify.api.
Package classify contains generated bindings for API file classify.api.
cnat
Package cnat contains generated bindings for API file cnat.api.
Package cnat contains generated bindings for API file cnat.api.
crypto
Package crypto contains generated bindings for API file crypto.api.
Package crypto contains generated bindings for API file crypto.api.
crypto_sw_scheduler
Package crypto_sw_scheduler contains generated bindings for API file crypto_sw_scheduler.api.
Package crypto_sw_scheduler contains generated bindings for API file crypto_sw_scheduler.api.
ct6
Package ct6 contains generated bindings for API file ct6.api.
Package ct6 contains generated bindings for API file ct6.api.
det44
Package det44 contains generated bindings for API file det44.api.
Package det44 contains generated bindings for API file det44.api.
dhcp
Package dhcp contains generated bindings for API file dhcp.api.
Package dhcp contains generated bindings for API file dhcp.api.
dhcp6_ia_na_client_cp
Package dhcp6_ia_na_client_cp contains generated bindings for API file dhcp6_ia_na_client_cp.api.
Package dhcp6_ia_na_client_cp contains generated bindings for API file dhcp6_ia_na_client_cp.api.
dhcp6_pd_client_cp
Package dhcp6_pd_client_cp contains generated bindings for API file dhcp6_pd_client_cp.api.
Package dhcp6_pd_client_cp contains generated bindings for API file dhcp6_pd_client_cp.api.
dns
Package dns contains generated bindings for API file dns.api.
Package dns contains generated bindings for API file dns.api.
dslite
Package dslite contains generated bindings for API file dslite.api.
Package dslite contains generated bindings for API file dslite.api.
ethernet_types
Package ethernet_types contains generated bindings for API file ethernet_types.api.
Package ethernet_types contains generated bindings for API file ethernet_types.api.
feature
Package feature contains generated bindings for API file feature.api.
Package feature contains generated bindings for API file feature.api.
fib
Package fib contains generated bindings for API file fib.api.
Package fib contains generated bindings for API file fib.api.
fib_types
Package fib_types contains generated bindings for API file fib_types.api.
Package fib_types contains generated bindings for API file fib_types.api.
flow
Package flow contains generated bindings for API file flow.api.
Package flow contains generated bindings for API file flow.api.
flow_types
Package flow_types contains generated bindings for API file flow_types.api.
Package flow_types contains generated bindings for API file flow_types.api.
flowprobe
Package flowprobe contains generated bindings for API file flowprobe.api.
Package flowprobe contains generated bindings for API file flowprobe.api.
geneve
Package geneve contains generated bindings for API file geneve.api.
Package geneve contains generated bindings for API file geneve.api.
graph
Package graph contains generated bindings for API file graph.api.
Package graph contains generated bindings for API file graph.api.
gre
Package gre contains generated bindings for API file gre.api.
Package gre contains generated bindings for API file gre.api.
gso
Package gso contains generated bindings for API file gso.api.
Package gso contains generated bindings for API file gso.api.
gtpu
Package gtpu contains generated bindings for API file gtpu.api.
Package gtpu contains generated bindings for API file gtpu.api.
http_static
Package http_static contains generated bindings for API file http_static.api.
Package http_static contains generated bindings for API file http_static.api.
igmp
Package igmp contains generated bindings for API file igmp.api.
Package igmp contains generated bindings for API file igmp.api.
ikev2
Package ikev2 contains generated bindings for API file ikev2.api.
Package ikev2 contains generated bindings for API file ikev2.api.
ikev2_types
Package ikev2_types contains generated bindings for API file ikev2_types.api.
Package ikev2_types contains generated bindings for API file ikev2_types.api.
interface
Package interfaces contains generated bindings for API file interface.api.
Package interfaces contains generated bindings for API file interface.api.
interface_types
Package interface_types contains generated bindings for API file interface_types.api.
Package interface_types contains generated bindings for API file interface_types.api.
ioam_cache
Package ioam_cache contains generated bindings for API file ioam_cache.api.
Package ioam_cache contains generated bindings for API file ioam_cache.api.
ioam_export
Package ioam_export contains generated bindings for API file ioam_export.api.
Package ioam_export contains generated bindings for API file ioam_export.api.
ioam_vxlan_gpe
Package ioam_vxlan_gpe contains generated bindings for API file ioam_vxlan_gpe.api.
Package ioam_vxlan_gpe contains generated bindings for API file ioam_vxlan_gpe.api.
ip
Package ip contains generated bindings for API file ip.api.
Package ip contains generated bindings for API file ip.api.
ip6_nd
Package ip6_nd contains generated bindings for API file ip6_nd.api.
Package ip6_nd contains generated bindings for API file ip6_nd.api.
ip_neighbor
Package ip_neighbor contains generated bindings for API file ip_neighbor.api.
Package ip_neighbor contains generated bindings for API file ip_neighbor.api.
ip_types
Package ip_types contains generated bindings for API file ip_types.api.
Package ip_types contains generated bindings for API file ip_types.api.
ipfix_export
Package ipfix_export contains generated bindings for API file ipfix_export.api.
Package ipfix_export contains generated bindings for API file ipfix_export.api.
ipip
Package ipip contains generated bindings for API file ipip.api.
Package ipip contains generated bindings for API file ipip.api.
ipsec
Package ipsec contains generated bindings for API file ipsec.api.
Package ipsec contains generated bindings for API file ipsec.api.
ipsec_types
Package ipsec_types contains generated bindings for API file ipsec_types.api.
Package ipsec_types contains generated bindings for API file ipsec_types.api.
l2
Package l2 contains generated bindings for API file l2.api.
Package l2 contains generated bindings for API file l2.api.
l2tp
Package l2tp contains generated bindings for API file l2tp.api.
Package l2tp contains generated bindings for API file l2tp.api.
l3xc
Package l3xc contains generated bindings for API file l3xc.api.
Package l3xc contains generated bindings for API file l3xc.api.
lacp
Package lacp contains generated bindings for API file lacp.api.
Package lacp contains generated bindings for API file lacp.api.
lb
Package lb contains generated bindings for API file lb.api.
Package lb contains generated bindings for API file lb.api.
lb_types
Package lb_types contains generated bindings for API file lb_types.api.
Package lb_types contains generated bindings for API file lb_types.api.
lcp
Package lcp contains generated bindings for API file lcp.api.
Package lcp contains generated bindings for API file lcp.api.
lisp
Package lisp contains generated bindings for API file lisp.api.
Package lisp contains generated bindings for API file lisp.api.
lisp_gpe
Package lisp_gpe contains generated bindings for API file lisp_gpe.api.
Package lisp_gpe contains generated bindings for API file lisp_gpe.api.
lisp_types
Package lisp_types contains generated bindings for API file lisp_types.api.
Package lisp_types contains generated bindings for API file lisp_types.api.
lldp
Package lldp contains generated bindings for API file lldp.api.
Package lldp contains generated bindings for API file lldp.api.
mactime
Package mactime contains generated bindings for API file mactime.api.
Package mactime contains generated bindings for API file mactime.api.
map
Package maps contains generated bindings for API file map.api.
Package maps contains generated bindings for API file map.api.
mdata
Package mdata contains generated bindings for API file mdata.api.
Package mdata contains generated bindings for API file mdata.api.
memclnt
Package memclnt contains generated bindings for API file memclnt.api.
Package memclnt contains generated bindings for API file memclnt.api.
memif
Package memif contains generated bindings for API file memif.api.
Package memif contains generated bindings for API file memif.api.
mfib_types
Package mfib_types contains generated bindings for API file mfib_types.api.
Package mfib_types contains generated bindings for API file mfib_types.api.
mpls
Package mpls contains generated bindings for API file mpls.api.
Package mpls contains generated bindings for API file mpls.api.
mss_clamp
Package mss_clamp contains generated bindings for API file mss_clamp.api.
Package mss_clamp contains generated bindings for API file mss_clamp.api.
nat44_ed
Package nat44_ed contains generated bindings for API file nat44_ed.api.
Package nat44_ed contains generated bindings for API file nat44_ed.api.
nat44_ei
Package nat44_ei contains generated bindings for API file nat44_ei.api.
Package nat44_ei contains generated bindings for API file nat44_ei.api.
nat64
Package nat64 contains generated bindings for API file nat64.api.
Package nat64 contains generated bindings for API file nat64.api.
nat66
Package nat66 contains generated bindings for API file nat66.api.
Package nat66 contains generated bindings for API file nat66.api.
nat_types
Package nat_types contains generated bindings for API file nat_types.api.
Package nat_types contains generated bindings for API file nat_types.api.
nsh
Package nsh contains generated bindings for API file nsh.api.
Package nsh contains generated bindings for API file nsh.api.
nsim
Package nsim contains generated bindings for API file nsim.api.
Package nsim contains generated bindings for API file nsim.api.
oddbuf
Package oddbuf contains generated bindings for API file oddbuf.api.
Package oddbuf contains generated bindings for API file oddbuf.api.
one
Package one contains generated bindings for API file one.api.
Package one contains generated bindings for API file one.api.
p2p_ethernet
Package p2p_ethernet contains generated bindings for API file p2p_ethernet.api.
Package p2p_ethernet contains generated bindings for API file p2p_ethernet.api.
pci_types
Package pci_types contains generated bindings for API file pci_types.api.
Package pci_types contains generated bindings for API file pci_types.api.
pg
Package pg contains generated bindings for API file pg.api.
Package pg contains generated bindings for API file pg.api.
pipe
Package pipe contains generated bindings for API file pipe.api.
Package pipe contains generated bindings for API file pipe.api.
pnat
Package pnat contains generated bindings for API file pnat.api.
Package pnat contains generated bindings for API file pnat.api.
policer
Package policer contains generated bindings for API file policer.api.
Package policer contains generated bindings for API file policer.api.
policer_types
Package policer_types contains generated bindings for API file policer_types.api.
Package policer_types contains generated bindings for API file policer_types.api.
pot
Package pot contains generated bindings for API file pot.api.
Package pot contains generated bindings for API file pot.api.
pp2
Package pp2 contains generated bindings for API file pp2.api.
Package pp2 contains generated bindings for API file pp2.api.
pppoe
Package pppoe contains generated bindings for API file pppoe.api.
Package pppoe contains generated bindings for API file pppoe.api.
punt
Package punt contains generated bindings for API file punt.api.
Package punt contains generated bindings for API file punt.api.
qos
Package qos contains generated bindings for API file qos.api.
Package qos contains generated bindings for API file qos.api.
rd_cp
Package rd_cp contains generated bindings for API file rd_cp.api.
Package rd_cp contains generated bindings for API file rd_cp.api.
rdma
Package rdma contains generated bindings for API file rdma.api.
Package rdma contains generated bindings for API file rdma.api.
session
Package session contains generated bindings for API file session.api.
Package session contains generated bindings for API file session.api.
span
Package span contains generated bindings for API file span.api.
Package span contains generated bindings for API file span.api.
sr
Package sr contains generated bindings for API file sr.api.
Package sr contains generated bindings for API file sr.api.
sr_mpls
Package sr_mpls contains generated bindings for API file sr_mpls.api.
Package sr_mpls contains generated bindings for API file sr_mpls.api.
sr_types
Package sr_types contains generated bindings for API file sr_types.api.
Package sr_types contains generated bindings for API file sr_types.api.
stn
Package stn contains generated bindings for API file stn.api.
Package stn contains generated bindings for API file stn.api.
svs
Package svs contains generated bindings for API file svs.api.
Package svs contains generated bindings for API file svs.api.
syslog
Package syslog contains generated bindings for API file syslog.api.
Package syslog contains generated bindings for API file syslog.api.
tapv2
Package tapv2 contains generated bindings for API file tapv2.api.
Package tapv2 contains generated bindings for API file tapv2.api.
tcp
Package tcp contains generated bindings for API file tcp.api.
Package tcp contains generated bindings for API file tcp.api.
teib
Package teib contains generated bindings for API file teib.api.
Package teib contains generated bindings for API file teib.api.
tls_openssl
Package tls_openssl contains generated bindings for API file tls_openssl.api.
Package tls_openssl contains generated bindings for API file tls_openssl.api.
trace
Package trace contains generated bindings for API file trace.api.
Package trace contains generated bindings for API file trace.api.
tracedump
Package tracedump contains generated bindings for API file tracedump.api.
Package tracedump contains generated bindings for API file tracedump.api.
tunnel_types
Package tunnel_types contains generated bindings for API file tunnel_types.api.
Package tunnel_types contains generated bindings for API file tunnel_types.api.
udp
Package udp contains generated bindings for API file udp.api.
Package udp contains generated bindings for API file udp.api.
udp_ping
Package udp_ping contains generated bindings for API file udp_ping.api.
Package udp_ping contains generated bindings for API file udp_ping.api.
urpf
Package urpf contains generated bindings for API file urpf.api.
Package urpf contains generated bindings for API file urpf.api.
vhost_user
Package vhost_user contains generated bindings for API file vhost_user.api.
Package vhost_user contains generated bindings for API file vhost_user.api.
virtio
Package virtio contains generated bindings for API file virtio.api.
Package virtio contains generated bindings for API file virtio.api.
virtio_types
Package virtio_types contains generated bindings for API file virtio_types.api.
Package virtio_types contains generated bindings for API file virtio_types.api.
vlib
Package vlib contains generated bindings for API file vlib.api.
Package vlib contains generated bindings for API file vlib.api.
vmxnet3
Package vmxnet3 contains generated bindings for API file vmxnet3.api.
Package vmxnet3 contains generated bindings for API file vmxnet3.api.
vpe
Package vpe contains generated bindings for API file vpe.api.
Package vpe contains generated bindings for API file vpe.api.
vpe_types
Package vpe_types contains generated bindings for API file vpe_types.api.
Package vpe_types contains generated bindings for API file vpe_types.api.
vrrp
Package vrrp contains generated bindings for API file vrrp.api.
Package vrrp contains generated bindings for API file vrrp.api.
vxlan
Package vxlan contains generated bindings for API file vxlan.api.
Package vxlan contains generated bindings for API file vxlan.api.
vxlan_gpe
Package vxlan_gpe contains generated bindings for API file vxlan_gpe.api.
Package vxlan_gpe contains generated bindings for API file vxlan_gpe.api.
vxlan_gpe_ioam_export
Package vxlan_gpe_ioam_export contains generated bindings for API file vxlan_gpe_ioam_export.api.
Package vxlan_gpe_ioam_export contains generated bindings for API file vxlan_gpe_ioam_export.api.
wireguard
Package wireguard contains generated bindings for API file wireguard.api.
Package wireguard contains generated bindings for API file wireguard.api.
vppapi
Package vppapi parses VPP API files without any additional processing.
Package vppapi parses VPP API files without any additional processing.
cmd
binapi-generator
Context of Go structs out of the VPP binary API definitions in JSON format.
Context of Go structs out of the VPP binary API definitions in JSON format.
Package codec provides methods allowing to encode and decode message structs to/from binary format accepted by VPP.
Package codec provides methods allowing to encode and decode message structs to/from binary format accepted by VPP.
Package core provides connectivity to VPP via the adapter: sends and receives the messages to/from VPP, marshalls/unmarshalls them and forwards them between the client Go channels and the VPP.
Package core provides connectivity to VPP via the adapter: sends and receives the messages to/from VPP, marshalls/unmarshalls them and forwards them between the client Go channels and the VPP.
examples
binapi-types
binapi-types is an example showing how to use and convert data with helper methods from *-types packages in VPP binary API.
binapi-types is an example showing how to use and convert data with helper methods from *-types packages in VPP binary API.
multi-vpp
multi-vpp is an example of managing multiple VPPs in single application.
multi-vpp is an example of managing multiple VPPs in single application.
perf-bench
Binary simple-client is an example VPP management application that exercises the govpp API on real-world use-cases.
Binary simple-client is an example VPP management application that exercises the govpp API on real-world use-cases.
rpc-service
service-client is an example VPP management application that exercises the govpp API using generated service client.
service-client is an example VPP management application that exercises the govpp API using generated service client.
simple-client
simple-client is an example VPP management application that exercises the govpp API on real-world use-cases.
simple-client is an example VPP management application that exercises the govpp API on real-world use-cases.
stream-client
stream-client is an example VPP management application that exercises the govpp API on real-world use-cases.
stream-client is an example VPP management application that exercises the govpp API on real-world use-cases.
extras module
Package version keeps track of versioning info for GoVPP.
Package version keeps track of versioning info for GoVPP.

Jump to

Keyboard shortcuts

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