package addrset
import "github.com/dotcloud/docker/libnetwork/internal/addrset"
Package addrset implements a set of IP addresses.
Index ¶
- Variables
- type AddrSet
- func New(pool netip.Prefix) *AddrSet
- func (as *AddrSet) Add(addr netip.Addr) error
- func (as *AddrSet) AddAny(serial bool) (netip.Addr, error)
- func (as *AddrSet) AddAnyInRange(ipr netip.Prefix, serial bool) (netip.Addr, error)
- func (as *AddrSet) Remove(addr netip.Addr) error
- func (as *AddrSet) String() string
Variables ¶
var ( // ErrNotAvailable is returned when no more addresses are available to set ErrNotAvailable = errors.New("address not available") // ErrAllocated is returned when the specific address requested is already allocated ErrAllocated = errors.New("address already allocated") )
Types ¶
type AddrSet ¶
type AddrSet struct {
// contains filtered or unexported fields
}
AddrSet is a set of IP addresses.
func New ¶
New returns an AddrSet for the range of addresses in pool.
func (*AddrSet) Add ¶
Add adds address addr to the set. If addr is already in the set, it returns a wrapped ErrAllocated. If addr is not in the set's address range, it returns an error.
func (*AddrSet) AddAny ¶
AddAny adds an arbitrary address to the set, and returns that address. Or, if no addresses are available, it returns a wrapped ErrNotAvailable.
If the address set's pool contains fewer than 1<<maxBitsPerBitmap addresses, AddAny will add any address from the entire set. If the pool is bigger than that, AddAny will only consider the first 1<<maxBitsPerBitmap addresses. If those are all allocated, it returns ErrNotAvailable.
When serial=true, the set is scanned starting from the address following the address most recently set by AddrSet.AddAny (or AddrSet.AddAnyInRange if the range is in the same 1<<maxBitsPerBitmap .
func (*AddrSet) AddAnyInRange ¶
AddAnyInRange adds an arbitrary address from ipr to the set, and returns that address. Or, if no addresses are available, it returns a wrapped ErrNotAvailable. If ipr is not fully contained within the set's range, it returns an error.
When serial=true, the set is scanned starting from the address following the address most recently set by AddrSet.AddAny or AddrSet.AddAnyInRange.
func (*AddrSet) Remove ¶
Remove removes addr from the set or, if addr is not in the set's address range it returns an error. If addr is not in the set, it returns nil (removing an address that's not in the set is not an error).
func (*AddrSet) String ¶
String returns a description of the address set.
Source Files ¶
- Version
- v28.1.1+incompatible (latest)
- Published
- Apr 18, 2025
- Platform
- linux/amd64
- Imports
- 8 packages
- Last checked
- 56 minutes ago –
Tools for package owners.