netalloc

package
v2.4.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ModuleName is the module name used for models of the netalloc plugin.
	ModuleName = "netalloc"

	// AllocRefPrefix is a prefix added in front of references to allocated objects.
	AllocRefPrefix = "alloc:"

	// AllocRefGWSuffix is a suffix added at the back of the reference when address
	// of the default gateway is requested (instead of interface IP address).
	AllocRefGWSuffix = "/GW"
)

Variables

View Source
var IPAddressForm_name = map[int32]string{
	0: "UNDEFINED_FORM",
	1: "ADDR_ONLY",
	2: "ADDR_WITH_MASK",
	3: "ADDR_NET",
	4: "SINGLE_ADDR_NET",
}
View Source
var IPAddressForm_value = map[string]int32{
	"UNDEFINED_FORM":  0,
	"ADDR_ONLY":       1,
	"ADDR_WITH_MASK":  2,
	"ADDR_NET":        3,
	"SINGLE_ADDR_NET": 4,
}
View Source
var IPAddressSource_name = map[int32]string{
	0: "UNDEFINED_SOURCE",
	1: "STATIC",
	2: "FROM_DHCP",
	3: "ALLOC_REF",
}
View Source
var IPAddressSource_value = map[string]int32{
	"UNDEFINED_SOURCE": 0,
	"STATIC":           1,
	"FROM_DHCP":        2,
	"ALLOC_REF":        3,
}
View Source
var (
	ModelIPAllocation = models.Register(&IPAllocation{}, models.Spec{
		Module:  ModuleName,
		Version: "v1",
		Type:    "ip",
	}, models.WithNameTemplate(
		"network/{{.NetworkName}}/interface/{{.InterfaceName}}",
	))
)

Functions

func NeighGwKey

func NeighGwKey(network, iface string) string

NeighGwKey returns a derived key used to represent IP allocation where GW is a neighbour of the interface (addresses are from the same IP network).

Types

type ConfigData

type ConfigData struct {
	IpAddresses          []*IPAllocation `protobuf:"bytes,10,rep,name=ip_addresses,json=ipAddresses,proto3" json:"ip_addresses,omitempty"`
	XXX_NoUnkeyedLiteral struct{}        `json:"-"`
	XXX_unrecognized     []byte          `json:"-"`
	XXX_sizecache        int32           `json:"-"`
}

ConfigData wraps all configuration items exported by netalloc. TBD: MACs, VXLAN VNIs, memif IDs, etc.

func (*ConfigData) Descriptor

func (*ConfigData) Descriptor() ([]byte, []int)

func (*ConfigData) GetIpAddresses

func (m *ConfigData) GetIpAddresses() []*IPAllocation

func (*ConfigData) ProtoMessage

func (*ConfigData) ProtoMessage()

func (*ConfigData) Reset

func (m *ConfigData) Reset()

func (*ConfigData) String

func (m *ConfigData) String() string

func (*ConfigData) XXX_DiscardUnknown

func (m *ConfigData) XXX_DiscardUnknown()

func (*ConfigData) XXX_Marshal

func (m *ConfigData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ConfigData) XXX_Merge

func (m *ConfigData) XXX_Merge(src proto.Message)

func (*ConfigData) XXX_MessageName

func (*ConfigData) XXX_MessageName() string

func (*ConfigData) XXX_Size

func (m *ConfigData) XXX_Size() int

func (*ConfigData) XXX_Unmarshal

func (m *ConfigData) XXX_Unmarshal(b []byte) error

type IPAddressForm

type IPAddressForm int32

IPAddressForm can be used in descriptors whose models reference allocated IP addresses, to ask for a specific form in which the address should applied.

const (
	IPAddressForm_UNDEFINED_FORM IPAddressForm = 0
	// ADDR_ONLY = apply address without mask, e.g. 192.168.2.5
	IPAddressForm_ADDR_ONLY IPAddressForm = 1
	// ADDR_WITH_MASK = apply address including the mask of the network,
	// e.g. 192.168.2.5/24
	IPAddressForm_ADDR_WITH_MASK IPAddressForm = 2
	// ADDR_NET = apply network implied by the address,
	// e.g. for 192.168.2.10/24 apply 192.168.2.0/24
	IPAddressForm_ADDR_NET IPAddressForm = 3
	// SINGLE_ADDR_NET = apply address with an all-ones mask (i.e. /32 for IPv4,
	// /128 for IPv6)
	IPAddressForm_SINGLE_ADDR_NET IPAddressForm = 4
)

func (IPAddressForm) EnumDescriptor

func (IPAddressForm) EnumDescriptor() ([]byte, []int)

func (IPAddressForm) String

func (x IPAddressForm) String() string

type IPAddressSource

type IPAddressSource int32

IPAddressSource can be used to remember the source of an IP address. (e.g. to distinguish allocated IP addresses from statically defined ones)

const (
	IPAddressSource_UNDEFINED_SOURCE IPAddressSource = 0
	// STATIC is IP address statically assigned in the NB configuration.
	IPAddressSource_STATIC IPAddressSource = 1
	// FROM_DHCP is set when IP address is obtained from DHCP.
	IPAddressSource_FROM_DHCP IPAddressSource = 2
	// ALLOC_REF is a reference inside NB configuration to an allocated
	// IP address.
	IPAddressSource_ALLOC_REF IPAddressSource = 3
)

func (IPAddressSource) EnumDescriptor

func (IPAddressSource) EnumDescriptor() ([]byte, []int)

func (IPAddressSource) String

func (x IPAddressSource) String() string

type IPAllocMetadata

type IPAllocMetadata struct {
	IfaceAddr *net.IPNet
	GwAddr    *net.IPNet
}

IPAllocMetadata stores allocated IP address already parsed from string.

type IPAllocation

type IPAllocation struct {
	// NetworkName is some label assigned to the network where the IP address
	// was assigned to the given interface.
	// In theory, interface can have multiple IP adresses or there can be multiple
	// address allocators and the network name allows to separate them.
	// The network name is not allowed to contain forward slashes.
	NetworkName string `protobuf:"bytes,1,opt,name=network_name,json=networkName,proto3" json:"network_name,omitempty"`
	// InterfaceName is the logical VPP or Linux interface name for which the
	// address is allocated.
	InterfaceName string `protobuf:"bytes,2,opt,name=interface_name,json=interfaceName,proto3" json:"interface_name,omitempty"`
	// Address is an IP addres allocated to the interface inside the given
	// network.
	// If the address is specified without a mask, the all-ones mask (/32 for
	// IPv4, /128 for IPv6) will be assumed.
	Address string `protobuf:"bytes,4,opt,name=address,proto3" json:"address,omitempty"`
	// Gw is the address of the default gateway assigned to the interface in
	// the given network.
	// If the address is specified without a mask, then either:
	//  a) the mask of the <address> is used provided that GW IP falls into the
	//     same network IP range, or
	//  b) the all-ones mask is used otherwise
	Gw                   string   `protobuf:"bytes,5,opt,name=gw,proto3" json:"gw,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

IPAllocation represents a single allocated IP address.

To reference allocated address, instead of entering specific IP address for interface/route/ARP/..., use one of the following string templates prefixed with netalloc keyword "alloc" followed by colon:

a) reference IP address allocated for an interface:
      "alloc:<network_name>/<interface_name>"
b) when interface is given (e.g. when asked for IP from interface model),
   interface_name can be omitted:
      "alloc:<network_name>"
c) reference default gateway IP address assigned to an interface:
      "alloc:<network_name>/<interface_name>/GW"
d) when asking for GW IP for interface which is given, interface_name
   can be omitted:
      "alloc:<network_name>/GW"

func (*IPAllocation) Descriptor

func (*IPAllocation) Descriptor() ([]byte, []int)

func (*IPAllocation) GetAddress

func (m *IPAllocation) GetAddress() string

func (*IPAllocation) GetGw

func (m *IPAllocation) GetGw() string

func (*IPAllocation) GetInterfaceName

func (m *IPAllocation) GetInterfaceName() string

func (*IPAllocation) GetNetworkName

func (m *IPAllocation) GetNetworkName() string

func (*IPAllocation) ProtoMessage

func (*IPAllocation) ProtoMessage()

func (*IPAllocation) Reset

func (m *IPAllocation) Reset()

func (*IPAllocation) String

func (m *IPAllocation) String() string

func (*IPAllocation) XXX_DiscardUnknown

func (m *IPAllocation) XXX_DiscardUnknown()

func (*IPAllocation) XXX_Marshal

func (m *IPAllocation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*IPAllocation) XXX_Merge

func (m *IPAllocation) XXX_Merge(src proto.Message)

func (*IPAllocation) XXX_MessageName

func (*IPAllocation) XXX_MessageName() string

func (*IPAllocation) XXX_Size

func (m *IPAllocation) XXX_Size() int

func (*IPAllocation) XXX_Unmarshal

func (m *IPAllocation) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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