ipam

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const BITMAP_BUSY = ^Bitmap(0)
View Source
const MAX_BITMAP_HOST_MASK = (1 << MAX_BITMAP_NET) - 1
View Source
const MAX_BITMAP_NET = 6
View Source
const MAX_BITMAP_SIZE = 1 << MAX_BITMAP_NET

Variables

View Source
var IntOne = Int64(1)
View Source
var IntTwoFiveFive = Int64(255)
View Source
var IntZero = Int64(0)

Functions

func CIDRAlign

func CIDRAlign(cidr *net.IPNet, bits int) *net.IPNet

func CIDRBits

func CIDRBits(cidr *net.IPNet) int

func CIDRClone

func CIDRClone(cidr *net.IPNet) *net.IPNet

func CIDREqual

func CIDREqual(a, b *net.IPNet) bool

func CIDRExtend

func CIDRExtend(cidr *net.IPNet) *net.IPNet

func CIDRFirstIP

func CIDRFirstIP(cidr *net.IPNet) net.IP

func CIDRHostMaskSize

func CIDRHostMaskSize(cidr *net.IPNet) int

func CIDRLastIP

func CIDRLastIP(cidr *net.IPNet) net.IP

func CIDRNet

func CIDRNet(cidr *net.IPNet) *net.IPNet

func CIDRNetMaskSize

func CIDRNetMaskSize(cidr *net.IPNet) int

func CIDRSplit

func CIDRSplit(cidr *net.IPNet) (lower, upper *net.IPNet)

func CIDRSubIP

func CIDRSubIP(cidr *net.IPNet, n int64) net.IP

func CIDRSubIPInt

func CIDRSubIPInt(cidr *net.IPNet, n Int) net.IP

func CIDRto16

func CIDRto16(cidr *net.IPNet) *net.IPNet

func CIDRto4

func CIDRto4(cidr *net.IPNet) *net.IPNet

func IPAdd

func IPAdd(ip net.IP, n int64) net.IP

func IPAddInt

func IPAddInt(ip net.IP, n Int) net.IP

func IPClone

func IPClone(ip net.IP) net.IP

func IPCmp

func IPCmp(a, b net.IP) int

func IPMaskClone

func IPMaskClone(mask net.IPMask) net.IPMask

func IPtoCIDR

func IPtoCIDR(ip net.IP) *net.IPNet

func MustParseCIDR

func MustParseCIDR(s string) *net.IPNet

func ParseCIDR

func ParseCIDR(s string) (*net.IPNet, error)

func ParseIP

func ParseIP(s string) net.IP

Types

type Bitmap

type Bitmap uint64

type Block

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

func ParseBlock added in v0.0.7

func ParseBlock(s string) *Block

func (*Block) IsUpper

func (this *Block) IsUpper() bool

func (*Block) Next

func (this *Block) Next() *Block

func (*Block) Prev

func (this *Block) Prev() *Block

func (*Block) Size

func (this *Block) Size() int

func (*Block) String

func (this *Block) String() string

type CIDRList

type CIDRList []*net.IPNet

func Excludes

func Excludes(cidr *net.IPNet, ranges ...*IPRange) (CIDRList, error)

func Includes

func Includes(ranges ...*IPRange) (CIDRList, error)

func (*CIDRList) Add

func (this *CIDRList) Add(cidrs ...*net.IPNet)

func (CIDRList) Contains

func (this CIDRList) Contains(ip net.IP) bool

func (CIDRList) Copy added in v0.0.7

func (this CIDRList) Copy() CIDRList

func (CIDRList) IsEmpty

func (this CIDRList) IsEmpty() bool

func (CIDRList) Len

func (p CIDRList) Len() int

func (CIDRList) Less

func (p CIDRList) Less(i, j int) bool

func (*CIDRList) String

func (this *CIDRList) String() string

func (CIDRList) Swap

func (p CIDRList) Swap(i, j int)

type IPAM

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

func NewIPAM

func NewIPAM(cidr *net.IPNet, ranges ...*IPRange) (*IPAM, error)

func NewIPAMForRanges

func NewIPAMForRanges(ranges IPRanges) (*IPAM, error)

func (*IPAM) Alloc

func (this *IPAM) Alloc(reqsize int) *net.IPNet

func (*IPAM) Bits

func (this *IPAM) Bits() int

func (*IPAM) Busy

func (this *IPAM) Busy(cidr *net.IPNet) bool

func (*IPAM) Free

func (this *IPAM) Free(cidr *net.IPNet) bool

func (*IPAM) IsRoundRobin

func (this *IPAM) IsRoundRobin() bool

func (*IPAM) Ranges added in v0.0.7

func (this *IPAM) Ranges() CIDRList

func (*IPAM) SetRoundRobin

func (this *IPAM) SetRoundRobin(b bool)

func (*IPAM) SetState

func (this *IPAM) SetState(blocks []string, next []net.IP) error

func (*IPAM) State

func (this *IPAM) State() ([]string, []net.IP)

func (*IPAM) String

func (this *IPAM) String() string

type IPRange

type IPRange struct {
	Start net.IP
	End   net.IP
}

func MustParseIPRange

func MustParseIPRange(str string) *IPRange

func ParseIPRange

func ParseIPRange(str string) (*IPRange, error)

func (*IPRange) Contains

func (this *IPRange) Contains(ip net.IP) bool

func (*IPRange) String

func (this *IPRange) String() string

type IPRanges

type IPRanges []*IPRange

IPRanges attaches the methods of Interface to []string, sorting in increasing order.

func MustParseIPRanges

func MustParseIPRanges(str ...string) IPRanges

func NormalizeIPRanges

func NormalizeIPRanges(ranges ...*IPRange) IPRanges

func ParseIPRanges

func ParseIPRanges(str ...string) (IPRanges, error)

func (IPRanges) Contains

func (this IPRanges) Contains(ip net.IP) bool

func (IPRanges) Len

func (p IPRanges) Len() int

func (IPRanges) Less

func (p IPRanges) Less(i, j int) bool

func (IPRanges) String

func (this IPRanges) String() string

func (IPRanges) Swap

func (p IPRanges) Swap(i, j int)

type Int

type Int big.Int

func CIDRHostSize

func CIDRHostSize(cidr *net.IPNet) Int

func IPDiff

func IPDiff(a, b net.IP) Int

func Int64

func Int64(i int64) Int

func ParseInt added in v0.0.7

func ParseInt(s string) (Int, error)

func (Int) Add

func (this Int) Add(a Int) Int

func (Int) And

func (this Int) And(a Int) Int

func (Int) Cmp

func (this Int) Cmp(a Int) int

func (Int) Div

func (this Int) Div(a Int) Int

func (Int) DivMod

func (this Int) DivMod(a Int) (Int, Int)

func (Int) Int64

func (this Int) Int64() int64

func (Int) IsInt64

func (this Int) IsInt64() bool

func (Int) IsUint64

func (this Int) IsUint64() bool

func (Int) LShift

func (this Int) LShift(n uint) Int

func (Int) Mod

func (this Int) Mod(a Int) Int

func (Int) Mul

func (this Int) Mul(a Int) Int

func (Int) Or

func (this Int) Or(a Int) Int

func (Int) RShift

func (this Int) RShift(n uint) Int

func (Int) Sgn

func (this Int) Sgn() int

func (Int) String

func (this Int) String() string

func (Int) Sub

func (this Int) Sub(a Int) Int

func (Int) Uint64

func (this Int) Uint64() uint64

type RequestSpec added in v0.0.7

type RequestSpec interface {
	IsCIDR() bool
	Bits() int
	Alloc(ipam *IPAM) (*net.IPNet, error)
	String() string
}

RequestSpec represents a dedicate allocation type for a cidr from an IPAM.

func ParseRequestSpec added in v0.0.7

func ParseRequestSpec(s string) (RequestSpec, error)

type RequestSpecList added in v0.0.7

type RequestSpecList []RequestSpec

func (RequestSpecList) String added in v0.0.7

func (r RequestSpecList) String() string

Jump to

Keyboard shortcuts

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