allocator

package
v0.0.0-...-7c66ffc Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeviceAddressAllocator

type DeviceAddressAllocator interface {
	// AllocateIP allocates an IP address in a single range of IP addresses. The
	// call is idempotent; if the same IMSI tries to allocate an address a
	// 2nd time it will return the same IP address.
	AllocateIP(imsi int64, nasID int) (net.IP, bool, error)

	// Allocated returns the number of currently allocated addresses in the pool
	Allocated(nasID int) int

	// Available returns the number of available addresses in the pool
	Available(nasID int) int

	// ReleaseIP releases the IP address and moves it into the free pool.
	ReleaseIP(imsi int64, nasID int) error
}

DeviceAddressAllocator is a type that can allocate IP addresses for devices.

func NewWriteThroughAllocator

func NewWriteThroughAllocator(apnConfig *storage.APNConfigCache, store storage.APNStore) (DeviceAddressAllocator, error)

NewWriteThroughAllocator creates a write-through allocator that writes the allocations to a backend store while using the memory allocator for the allocations.

type NASMap

type NASMap interface {
	Allocator(nasIdentifier string) ServingRange
}

NASMap maps the NAS Identifier

type RangeAllocator

type RangeAllocator interface {
	// AllocateIP allocates a single IP address. An error is returned if the
	// IP addresse can't be allocated
	AllocateIP() (net.IP, error)
	// ReleaseIP releases a previously allocated IP address.
	ReleaseIP(net.IP) error

	// Available returns the number of available IP addresses
	Available() int

	// Allocated returns the number of allocated IP addresses.
	Allocated() int
}

RangeAllocator is a type capable of allocating IP addresses in a range.

func NewMemoryIPAllocator

func NewMemoryIPAllocator(cidr string, currentAllocations []model.Allocation) (RangeAllocator, error)

NewMemoryIPAllocator returns a memory-based memory allocators. Note that the IP addresses in the allocations are are IPv4 addresses so make sure to call To4() if you use the net.ParseIP function. (yes this has caused me headaches)

type ServingRange

type ServingRange struct {
	ApnID     int
	NasID     int
	Allocator DeviceAddressAllocator
}

ServingRange represents IP ranges that the RADIUS server will serve.

Jump to

Keyboard shortcuts

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