vppcalls

package
v2.0.0-alpha+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2018 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package vppcalls contains wrappers over VPP binary APIs for all supported interface types and for dumping all interfaces configured in VPP.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	SwIfIndex        uint32
	Hostname         string
	ID               string
	WantDhcpEvent    bool
	SetBroadcastFlag bool
	Pid              uint32
}

Client is helper struct grouping DHCP client data

type Dhcp

type Dhcp struct {
	Client *Client `json:"dhcp_client"`
	Lease  *Lease  `json:"dhcp_lease"`
}

Dhcp is helper struct for DHCP metadata, split to client and lease (similar to VPP binary API)

type IfVppAPI

type IfVppAPI interface {
	IfVppWrite
	IfVppRead
}

IfVppAPI provides methods for creating and managing interface plugin

type IfVppHandler

type IfVppHandler struct {
	// contains filtered or unexported fields
}

IfVppHandler is accessor for interface-related vppcalls methods

func NewIfVppHandler

func NewIfVppHandler(callsChan api.Channel, log logging.Logger) *IfVppHandler

NewIfVppHandler creates new instance of interface vppcalls handler

func (*IfVppHandler) AddAfPacketInterface

func (h *IfVppHandler) AddAfPacketInterface(ifName string, hwAddr string, afPacketIntf *intf.Interface_AfpacketLink) (swIndex uint32, err error)

AddAfPacketInterface implements AfPacket handler.

func (*IfVppHandler) AddContainerIP

func (h *IfVppHandler) AddContainerIP(ifIdx uint32, addr string) error

AddContainerIP implements interface handler.

func (*IfVppHandler) AddInterfaceIP

func (h *IfVppHandler) AddInterfaceIP(ifIdx uint32, addr *net.IPNet) error

AddInterfaceIP implements interface handler.

func (*IfVppHandler) AddLoopbackInterface

func (h *IfVppHandler) AddLoopbackInterface(ifName string) (swIndex uint32, err error)

AddLoopbackInterface implements interface handler.

func (*IfVppHandler) AddMemifInterface

func (h *IfVppHandler) AddMemifInterface(ifName string, memIface *intf.Interface_MemifLink, socketID uint32) (swIdx uint32, err error)

AddMemifInterface implements interface handler.

func (*IfVppHandler) AddTapInterface

func (h *IfVppHandler) AddTapInterface(ifName string, tapIf *interfaces.Interface_TapLink) (swIfIdx uint32, err error)

AddTapInterface implements interface handler.

func (*IfVppHandler) AddVxLanTunnel

func (h *IfVppHandler) AddVxLanTunnel(ifName string, vrf, multicastIf uint32, vxLan *intf.Interface_VxlanLink) (swIndex uint32, err error)

AddVxLanTunnel implements VxLan handler.

func (*IfVppHandler) CreateVrf

func (h *IfVppHandler) CreateVrf(vrfID uint32) error

CreateVrf implements interface handler.

func (*IfVppHandler) CreateVrfIPv6

func (h *IfVppHandler) CreateVrfIPv6(vrfID uint32) error

CreateVrfIPv6 implements interface handler.

func (*IfVppHandler) DelContainerIP

func (h *IfVppHandler) DelContainerIP(ifIdx uint32, addr string) error

DelContainerIP implements interface handler.

func (*IfVppHandler) DelInterfaceIP

func (h *IfVppHandler) DelInterfaceIP(ifIdx uint32, addr *net.IPNet) error

DelInterfaceIP implements interface handler.

func (*IfVppHandler) DeleteAfPacketInterface

func (h *IfVppHandler) DeleteAfPacketInterface(ifName string, idx uint32, afPacketIntf *intf.Interface_AfpacketLink) error

DeleteAfPacketInterface implements AfPacket handler.

func (*IfVppHandler) DeleteLoopbackInterface

func (h *IfVppHandler) DeleteLoopbackInterface(ifName string, idx uint32) error

DeleteLoopbackInterface implements interface handler.

func (*IfVppHandler) DeleteMemifInterface

func (h *IfVppHandler) DeleteMemifInterface(ifName string, idx uint32) error

DeleteMemifInterface implements interface handler.

func (*IfVppHandler) DeleteTapInterface

func (h *IfVppHandler) DeleteTapInterface(ifName string, idx uint32, version uint32) error

DeleteTapInterface implements interface handler.

func (*IfVppHandler) DeleteVxLanTunnel

func (h *IfVppHandler) DeleteVxLanTunnel(ifName string, idx, vrf uint32, vxLan *intf.Interface_VxlanLink) error

DeleteVxLanTunnel implements VxLan handler.

func (*IfVppHandler) DumpDhcpClients

func (h *IfVppHandler) DumpDhcpClients() (map[uint32]*Dhcp, error)

DumpDhcpClients returns a slice of DhcpMeta with all interfaces and other DHCP-related information available

func (*IfVppHandler) DumpInterfaces

func (h *IfVppHandler) DumpInterfaces() (map[uint32]*InterfaceDetails, error)

DumpInterfaces implements interface handler.

func (*IfVppHandler) DumpInterfacesByType

func (h *IfVppHandler) DumpInterfacesByType(reqType ifnb.Interface_Type) (map[uint32]*InterfaceDetails, error)

DumpInterfacesByType implements interface handler.

func (*IfVppHandler) DumpMemifSocketDetails

func (h *IfVppHandler) DumpMemifSocketDetails() (map[string]uint32, error)

DumpMemifSocketDetails implements interface handler.

func (*IfVppHandler) GetInterfaceVrf

func (h *IfVppHandler) GetInterfaceVrf(ifIdx uint32) (vrfID uint32, err error)

GetInterfaceVrf implements interface handler.

func (*IfVppHandler) GetInterfaceVrfIPv6

func (h *IfVppHandler) GetInterfaceVrfIPv6(ifIdx uint32) (vrfID uint32, err error)

GetInterfaceVrfIPv6 implements interface handler.

func (*IfVppHandler) InterfaceAdminDown

func (h *IfVppHandler) InterfaceAdminDown(ifIdx uint32) error

InterfaceAdminDown implements interface handler.

func (*IfVppHandler) InterfaceAdminUp

func (h *IfVppHandler) InterfaceAdminUp(ifIdx uint32) error

InterfaceAdminUp implements interface handler.

func (*IfVppHandler) RegisterMemifSocketFilename

func (h *IfVppHandler) RegisterMemifSocketFilename(filename []byte, id uint32) error

RegisterMemifSocketFilename implements interface handler.

func (*IfVppHandler) RemoveInterfaceTag

func (h *IfVppHandler) RemoveInterfaceTag(tag string, ifIdx uint32) error

RemoveInterfaceTag implements interface handler.

func (*IfVppHandler) SetInterfaceAsDHCPClient

func (h *IfVppHandler) SetInterfaceAsDHCPClient(ifIdx uint32, hostName string) error

SetInterfaceAsDHCPClient implements interface handler.

func (*IfVppHandler) SetInterfaceMac

func (h *IfVppHandler) SetInterfaceMac(ifIdx uint32, macAddress string) error

SetInterfaceMac implements interface handler.

func (*IfVppHandler) SetInterfaceMtu

func (h *IfVppHandler) SetInterfaceMtu(ifIdx uint32, mtu uint32) error

SetInterfaceMtu implements interface handler.

func (*IfVppHandler) SetInterfaceTag

func (h *IfVppHandler) SetInterfaceTag(tag string, ifIdx uint32) error

SetInterfaceTag implements interface handler.

func (*IfVppHandler) SetInterfaceVrf

func (h *IfVppHandler) SetInterfaceVrf(ifIdx, vrfID uint32) error

SetInterfaceVrf implements interface handler.

func (*IfVppHandler) SetInterfaceVrfIPv6

func (h *IfVppHandler) SetInterfaceVrfIPv6(ifIdx, vrfID uint32) error

SetInterfaceVrfIPv6 implements interface handler.

func (*IfVppHandler) SetRxMode

func (h *IfVppHandler) SetRxMode(ifIdx uint32, rxModeSettings *intf.Interface_RxModeSettings) error

SetRxMode implements interface handler.

func (*IfVppHandler) SetRxPlacement

func (h *IfVppHandler) SetRxPlacement(ifIdx uint32, rxPlacement *intf.Interface_RxPlacementSettings) error

SetRxPlacement implements interface handler.

func (*IfVppHandler) SetUnnumberedIP

func (h *IfVppHandler) SetUnnumberedIP(uIfIdx uint32, ifIdxWithIP uint32) error

SetUnnumberedIP implements interface handler.

func (*IfVppHandler) UnsetInterfaceAsDHCPClient

func (h *IfVppHandler) UnsetInterfaceAsDHCPClient(ifIdx uint32, hostName string) error

UnsetInterfaceAsDHCPClient implements interface handler.

func (*IfVppHandler) UnsetUnnumberedIP

func (h *IfVppHandler) UnsetUnnumberedIP(uIfIdx uint32) error

UnsetUnnumberedIP implements interface handler.

type IfVppRead

type IfVppRead interface {
	// DumpInterfaces dumps VPP interface data into the northbound API data structure
	// map indexed by software interface index.
	//
	// LIMITATIONS:
	// - there is no af_packet dump binary API. We relay on naming conventions of the internal VPP interface names
	// - ip.IPAddressDetails has wrong internal structure, as a workaround we need to handle them as notifications
	DumpInterfaces() (map[uint32]*InterfaceDetails, error)
	// DumpInterfacesByType returns all VPP interfaces of the specified type
	DumpInterfacesByType(reqType interfaces.Interface_Type) (map[uint32]*InterfaceDetails, error)
	// GetInterfaceVrf reads VRF table to interface
	GetInterfaceVrf(ifIdx uint32) (vrfID uint32, err error)
	// GetInterfaceVrfIPv6 reads IPv6 VRF table to interface
	GetInterfaceVrfIPv6(ifIdx uint32) (vrfID uint32, err error)
	// DumpMemifSocketDetails dumps memif socket details from the VPP
	DumpMemifSocketDetails() (map[string]uint32, error)
	// DumpDhcpClients dumps DHCP-related information for all interfaces.
	DumpDhcpClients() (map[uint32]*Dhcp, error)
}

IfVppRead provides read methods for interface plugin

type IfVppWrite

type IfVppWrite interface {
	// AddAfPacketInterface calls AfPacketCreate VPP binary API.
	AddAfPacketInterface(ifName string, hwAddr string, afPacketIntf *interfaces.Interface_AfpacketLink) (swIndex uint32, err error)
	// DeleteAfPacketInterface calls AfPacketDelete VPP binary API.
	DeleteAfPacketInterface(ifName string, idx uint32, afPacketIntf *interfaces.Interface_AfpacketLink) error
	// AddLoopbackInterface calls CreateLoopback bin API.
	AddLoopbackInterface(ifName string) (swIndex uint32, err error)
	// DeleteLoopbackInterface calls DeleteLoopback bin API.
	DeleteLoopbackInterface(ifName string, idx uint32) error
	// AddMemifInterface calls MemifCreate bin API.
	AddMemifInterface(ifName string, memIface *interfaces.Interface_MemifLink, socketID uint32) (swIdx uint32, err error)
	// DeleteMemifInterface calls MemifDelete bin API.
	DeleteMemifInterface(ifName string, idx uint32) error
	// AddTapInterface calls TapConnect bin API.
	AddTapInterface(ifName string, tapIf *interfaces.Interface_TapLink) (swIfIdx uint32, err error)
	// DeleteTapInterface calls TapDelete bin API.
	DeleteTapInterface(ifName string, idx uint32, version uint32) error
	// AddVxLanTunnel calls AddDelVxLanTunnelReq with flag add=1.
	AddVxLanTunnel(ifName string, vrf, multicastIf uint32, vxLan *interfaces.Interface_VxlanLink) (swIndex uint32, err error)
	// DeleteVxLanTunnel calls AddDelVxLanTunnelReq with flag add=0.
	DeleteVxLanTunnel(ifName string, idx, vrf uint32, vxLan *interfaces.Interface_VxlanLink) error
	// InterfaceAdminDown calls binary API SwInterfaceSetFlagsReply with AdminUpDown=0.
	InterfaceAdminDown(ifIdx uint32) error
	// InterfaceAdminUp calls binary API SwInterfaceSetFlagsReply with AdminUpDown=1.
	InterfaceAdminUp(ifIdx uint32) error
	// SetInterfaceTag registers new interface index/tag pair
	SetInterfaceTag(tag string, ifIdx uint32) error
	// RemoveInterfaceTag un-registers new interface index/tag pair
	RemoveInterfaceTag(tag string, ifIdx uint32) error
	// SetInterfaceAsDHCPClient sets provided interface as a DHCP client
	SetInterfaceAsDHCPClient(ifIdx uint32, hostName string) error
	// UnsetInterfaceAsDHCPClient un-sets interface as DHCP client
	UnsetInterfaceAsDHCPClient(ifIdx uint32, hostName string) error
	// AddContainerIP calls IPContainerProxyAddDel VPP API with IsAdd=1
	AddContainerIP(ifIdx uint32, addr string) error
	// DelContainerIP calls IPContainerProxyAddDel VPP API with IsAdd=0
	DelContainerIP(ifIdx uint32, addr string) error
	// AddInterfaceIP calls SwInterfaceAddDelAddress bin API with IsAdd=1.
	AddInterfaceIP(ifIdx uint32, addr *net.IPNet) error
	// DelInterfaceIP calls SwInterfaceAddDelAddress bin API with IsAdd=00.
	DelInterfaceIP(ifIdx uint32, addr *net.IPNet) error
	// SetUnnumberedIP sets interface as un-numbered, linking IP address of the another interface (ifIdxWithIP)
	SetUnnumberedIP(uIfIdx uint32, ifIdxWithIP uint32) error
	// UnsetUnnumberedIP unset provided interface as un-numbered. IP address of the linked interface is removed
	UnsetUnnumberedIP(uIfIdx uint32) error
	// SetInterfaceMac calls SwInterfaceSetMacAddress bin API.
	SetInterfaceMac(ifIdx uint32, macAddress string) error
	// RegisterMemifSocketFilename registers new socket file name with provided ID.
	RegisterMemifSocketFilename(filename []byte, id uint32) error
	// SetInterfaceMtu calls HwInterfaceSetMtu bin API with desired MTU value.
	SetInterfaceMtu(ifIdx uint32, mtu uint32) error
	// SetRxMode calls SwInterfaceSetRxMode bin
	SetRxMode(ifIdx uint32, rxModeSettings *interfaces.Interface_RxModeSettings) error
	// SetRxPlacement configures rx-placement for interface
	SetRxPlacement(ifIdx uint32, rxPlacement *interfaces.Interface_RxPlacementSettings) error
	// CreateVrf checks if VRF exists and creates it if not
	CreateVrf(vrfID uint32) error
	// CreateVrfIPv6 checks if IPv6 VRF exists and creates it if not
	CreateVrfIPv6(vrfID uint32) error
	// SetInterfaceVrf retrieves VRF table from interface
	SetInterfaceVrf(ifaceIndex, vrfID uint32) error
	// SetInterfaceVrfIPv6 retrieves IPV6 VRF table from interface
	SetInterfaceVrfIPv6(ifaceIndex, vrfID uint32) error
}

IfVppWrite provides write methods for interface plugin

type InterfaceDetails

type InterfaceDetails struct {
	Interface *ifnb.Interface `json:"interface"`
	Meta      *InterfaceMeta  `json:"interface_meta"`
}

InterfaceDetails is the wrapper structure for the interface northbound API structure.

type InterfaceMeta

type InterfaceMeta struct {
	SwIfIndex    uint32 `json:"sw_if_index"`
	Tag          string `json:"tag"`
	InternalName string `json:"internal_name"`
	Dhcp         *Dhcp  `json:"dhcp"`
}

InterfaceMeta is combination of proto-modelled Interface data and VPP provided metadata

type Lease

type Lease struct {
	SwIfIndex     uint32
	State         uint8
	Hostname      string
	IsIPv6        bool
	HostAddress   string
	RouterAddress string
	HostMac       string
}

Lease is helper struct grouping DHCP lease data

Jump to

Keyboard shortcuts

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