Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: c-robinson/iplib
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.0.3
Choose a base ref
...
head repository: c-robinson/iplib
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.0.4
Choose a head ref
  • 3 commits
  • 3 files changed
  • 1 contributor

Commits on Jan 7, 2024

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    3415cb7 View commit details

Commits on Jan 18, 2024

  1. typo

    c-robinson committed Jan 18, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    e42b6ae View commit details
  2. 0 is a valid mask length

    c-robinson committed Jan 18, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    59bd9a5 View commit details
Showing with 13 additions and 13 deletions.
  1. +1 −1 hostmask.go
  2. +2 −2 net.go
  3. +10 −10 net6.go
2 changes: 1 addition & 1 deletion hostmask.go
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ import (
// which the final 64bits of the address are used to construct a unique host
// identifier and the allocator only has control of the first 64bits. So the
// next IP from 2001:db8:1234:5678:: would be 2001:db8:1234:5679 instead of
// 2001:db8:1234:5678::1. Here is a Net6 object eing initialized without a
// 2001:db8:1234:5678::1. Here is a Net6 object being initialized without a
// hostmask:
//
// n := NewNet6(2001:db8::, 56, 0)
4 changes: 2 additions & 2 deletions net.go
Original file line number Diff line number Diff line change
@@ -81,15 +81,15 @@ func AllNetsBetween(a, b net.IP) ([]Net, error) {
// will be false. If no fit can be found (probably because a >= b) an
// ErrNoValidRange will be returned
func NewNetBetween(a, b net.IP) (Net, bool, error) {
if CompareIPs(a, b) == 1 { // != -1 {
if CompareIPs(a, b) == 1 {
return nil, false, ErrNoValidRange
}

if EffectiveVersion(a) != EffectiveVersion(b) {
return nil, false, ErrNoValidRange
}

return fitNetworkBetween(a, b, 1)
return fitNetworkBetween(a, b, 0)
}

// ByNet implements sort.Interface for iplib.Net based on the
20 changes: 10 additions & 10 deletions net6.go
Original file line number Diff line number Diff line change
@@ -130,7 +130,7 @@ func (n Net6) Enumerate(size, offset int) []net.IP {
return nil
}

count := getEnumerationCount(size, offset, n.Count())
count := getEnumerationCount(uint(size), uint(offset), n.Count())

// Handle edge-case mask sizes
ones, _ := n.Mask().Size()
@@ -155,21 +155,21 @@ func (n Net6) Enumerate(size, offset int) []net.IP {
// our worker-pool based on request size; and [b] don't have to worry
// about exhausting some upper bound of goroutines -- enumerate requests
// are limited to MaxUint32, so we won't generate more than 65536
limit := 65535
pos := 0
var limit uint = 65535
var pos uint = 0
wg := sync.WaitGroup{}
for pos < count {
incr := limit
if limit > count-pos {
incr = count - pos
}
wg.Add(1)
go func(fip net.IP, pos, count int) {
go func(fip net.IP, pos, count uint) {
defer wg.Done()
firstip := CopyIP(fip)
lpos := pos
addrs[lpos], _ = IncrementIP6WithinHostmask(firstip, n.Hostmask, uint128.New(uint64(lpos), 0))
for i := 1; i < count; i++ {
for i := uint(1); i < count; i++ {
lpos++
addrs[lpos], _ = NextIP6WithinHostmask(addrs[lpos-1], n.Hostmask)
}
@@ -360,13 +360,13 @@ func (n Net6) wildcard() net.IPMask {

// getEnumerationCount returns the size of the array needed to satisfy an
// Enumerate request. Mostly split out to ease testing of larger values
func getEnumerationCount(reqSize, offset int, count uint128.Uint128) int {
sizes := []int{math.MaxUint32}
func getEnumerationCount(reqSize, offset uint, count uint128.Uint128) uint {
sizes := []uint{math.MaxUint32}

if count.Cmp64(math.MaxUint32) <= 0 {
realCount := 0
if int(count.Lo) > offset {
realCount = int(count.Lo) - offset
var realCount uint = 0
if uint(count.Lo) > offset {
realCount = uint(count.Lo) - offset
}
sizes = append(sizes, realCount)
}