impl

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2019 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package impl implements handlers for agentctl commands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCommonIfPutFlags

func AddCommonIfPutFlags(cmd *cobra.Command)

AddCommonIfPutFlags adds flags common for all interface types.

func AddInterfaceNameFlag

func AddInterfaceNameFlag(cmd *cobra.Command)

AddInterfaceNameFlag adds a name flag to interface flags.

func IfJSONPut

func IfJSONPut(endpoints []string, label string)

// PutMemif creates a memif type interface.

func PutMemif(endpoints []string, label string, flags *interfaces.MemifLink) {
	found, key, ifc, db := utils.GetInterfaceKeyAndValue(endpoints, label, ifCommonFields.Name)
	processCommonIfFlags(found, interfaces.Interface_MEMIF, ifc)

	// Process MEMIF-specific flags.
	if utils.IsFlagPresent(utils.MemifMaster) {
		if ifc.Memif == nil {
			ifc.Memif = &interfaces.Interfaces_Interface_Memif{}
		}
		ifc.Memif.Master = flags.Master
	}
	if utils.IsFlagPresent(utils.MemifMode) {
		if ifc.Memif == nil {
			ifc.Memif = &interfaces.Interfaces_Interface_Memif{}
		}
		ifc.Memif.Mode = flags.Mode
	}
	if utils.IsFlagPresent(utils.MemifID) {
		if ifc.Memif == nil {
			ifc.Memif = &interfaces.Interfaces_Interface_Memif{}
		}
		ifc.Memif.Id = flags.Id
	}
	if flags.SocketFilename != "" {
		if ifc.Memif == nil {
			ifc.Memif = &interfaces.Interfaces_Interface_Memif{}
		}
		ifc.Memif.SocketFilename = flags.SocketFilename
	}
	if flags.Secret != "" {
		if ifc.Memif == nil {
			ifc.Memif = &interfaces.Interfaces_Interface_Memif{}
		}
		ifc.Memif.Secret = flags.Secret
	}
	if utils.IsFlagPresent(utils.MemifRingSize) {
		if ifc.Memif == nil {
			ifc.Memif = &interfaces.Interfaces_Interface_Memif{}
		}
		ifc.Memif.RingSize = flags.RingSize
	}
	if utils.IsFlagPresent(utils.MemifBufferSize) {
		if ifc.Memif == nil {
			ifc.Memif = &interfaces.Interfaces_Interface_Memif{}
		}
		ifc.Memif.BufferSize = flags.BufferSize
	}
	if utils.IsFlagPresent(utils.MemifRxQueues) {
		if ifc.Memif == nil {
			ifc.Memif = &interfaces.Interfaces_Interface_Memif{}
		}
		ifc.Memif.RxQueues = flags.RxQueues
	}
	if utils.IsFlagPresent(utils.MemifTxQueues) {
		if ifc.Memif == nil {
			ifc.Memif = &interfaces.Interfaces_Interface_Memif{}
		}
		ifc.Memif.TxQueues = flags.TxQueues
	}
	utils.WriteInterfaceToDb(db, key, ifc)
}

// PutTap creates a tap type interface.

func PutTap(endpoints []string, label string) {
	found, key, ifc, db := utils.GetInterfaceKeyAndValue(endpoints, label, ifCommonFields.Name)
	processCommonIfFlags(found, interfaces.InterfaceType_TAP_INTERFACE, ifc)
	utils.WriteInterfaceToDb(db, key, ifc)
}

// PutVxLan creates a vxlan type interface.

func PutVxLan(endpoints []string, label string, flags *interfaces.Interfaces_Interface_Vxlan) {
	found, key, ifc, db := utils.GetInterfaceKeyAndValue(endpoints, label, ifCommonFields.Name)
	processCommonIfFlags(found, interfaces.InterfaceType_VXLAN_TUNNEL, ifc)

	// Process VXLAN-specific flags.
	if flags.SrcAddress != "" {
		if ifc.Vxlan == nil {
			ifc.Vxlan = &interfaces.Interfaces_Interface_Vxlan{}
		}
		if utils.ValidateIpv4Addr(flags.SrcAddress) || utils.ValidateIpv6Addr(flags.SrcAddress) {
			ifc.Vxlan.SrcAddress = flags.SrcAddress
		} else {
			utils.ExitWithError(utils.ExitBadArgs, errors.New("Invalid "+utils.VxLanSrcAddr+" "+flags.SrcAddress))
		}
	}
	if flags.DstAddress != "" {
		if ifc.Vxlan == nil {
			ifc.Vxlan = &interfaces.Interfaces_Interface_Vxlan{}
		}
		if utils.ValidateIpv4Addr(flags.DstAddress) || utils.ValidateIpv6Addr(flags.DstAddress) {
			ifc.Vxlan.DstAddress = flags.DstAddress
		} else {
			utils.ExitWithError(utils.ExitBadArgs, errors.New("Invalid "+utils.VxLanDstAddr+" "+flags.DstAddress))
		}
	}
	if utils.IsFlagPresent(utils.VxLanVni) && flags.Vni > 0 {
		if ifc.Vxlan == nil {
			ifc.Vxlan = &interfaces.Interfaces_Interface_Vxlan{}
		}
		ifc.Vxlan.Vni = flags.Vni
	}
	utils.WriteInterfaceToDb(db, key, ifc)
}

IfJSONPut creates an interface according to json configuration.

func InterfaceDel

func InterfaceDel(endpoints []string, label string)

InterfaceDel removes the interface with defined name.

func PutAfPkt

func PutAfPkt(endpoints []string, label string, flags *interfaces.AfpacketLink)

PutAfPkt creates an Af-packet type interface.

func PutEthernet

func PutEthernet(endpoints []string, label string)

PutEthernet creates an ethernet type interface.

func PutLoopback

func PutLoopback(endpoints []string, label string)

PutLoopback creates a loopback type interface.

Types

type IfaceCommonFields

type IfaceCommonFields struct {
	Name      string
	Desc      string
	IfType    string
	Enabled   bool
	PhysAddr  string
	Mtu       uint32
	Ipv4Addrs []string
	Ipv6Addrs []string
}

IfaceCommonFields are fields common for interfaces of any type.

Jump to

Keyboard shortcuts

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