ipnetsgenerator

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

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

Go to latest
Published: Dec 14, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateIPNets

func GenerateIPNets(ipnets []IPNetRequest, seed int64) []net.IPNet

GenerateIPNets creates an array of random IPv4 net.IPNet objects. The ipnets parameter contains a list with th number of objects for each prefix length to generate.

Types

type IPNetRequest

type IPNetRequest struct {
	Count     int // Number of elements of this type to generate
	PrefixLen int // Length of the prefix (24, 32)...
}

func ParseIPNetsParam

func ParseIPNetsParam(count int, ipnets string) []IPNetRequest

ParseIPNetsParam parses a string containinig a list of prefixes' lengths and their weight (0.0-1.0) and returns a list of IPNetRequest to be used with GenerateIPNets. The ipnets string is formated as "prefix1Length:prefix1Weigth,prefix2Length:prefix2Weigth,..." If the sum of all weights isn't 1.0 the remaining are assigned to the /32 prefix.

Jump to

Keyboard shortcuts

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