package ipbits

import "github.com/docker/docker/libnetwork/ipbits"

Package ipbits contains utilities for manipulating netip.Addr values as numbers or bitfields.

Index

Functions

func Add

func Add(ip netip.Addr, x uint64, shift uint) netip.Addr

Add returns ip + (x << shift).

func Field

func Field(ip netip.Addr, u, v uint) uint64

Field returns the value of the bitfield [u, v] in ip as an integer, where bit 0 is the most-significant bit of ip.

The result is undefined if u > v, if v-u > 64, or if u or v is larger than ip.BitLen().

func SubnetsBetween

func SubnetsBetween(a1 netip.Addr, a2 netip.Addr, sz int) uint64

SubnetsBetween computes the number of subnets of size 'sz' available between 'a1' and 'a2'. The result is capped at math.MaxUint64. It returns 0 when one of 'a1' or 'a2' is invalid, if both aren't of the same family, or when 'a2' is less than 'a1'.

Source Files

ipbits.go uint128.go

Version
v27.0.0-rc.2+incompatible
Published
Jun 17, 2024
Platform
linux/amd64
Imports
3 packages
Last checked
11 minutes ago

Tools for package owners.