package corenet
import "github.com/purpleidea/mgmt/lang/core/net"
Index ¶
- Constants
- func CidrToFirst(ctx context.Context, input []types.Value) (types.Value, error)
- func CidrToIP(ctx context.Context, input []types.Value) (types.Value, error)
- func CidrToLast(ctx context.Context, input []types.Value) (types.Value, error)
- func CidrToMask(ctx context.Context, input []types.Value) (types.Value, error)
- func CidrToPrefix(ctx context.Context, input []types.Value) (types.Value, error)
- func IsMac(ctx context.Context, input []types.Value) (types.Value, error)
- func MacFmt(ctx context.Context, input []types.Value) (types.Value, error)
- func Macs(ctx context.Context, input []types.Value) (types.Value, error)
- func OldMacFmt(ctx context.Context, input []types.Value) (types.Value, error)
- func URLParser(ctx context.Context, input []types.Value) (types.Value, error)
Constants ¶
const ( // ModuleName is the prefix given to all the functions in this module. ModuleName = "net" )
Functions ¶
func CidrToFirst ¶
CidrToFirst returns the first usable IP from a CIDR address.
func CidrToIP ¶
CidrToIP returns the IP from a CIDR address.
func CidrToLast ¶
CidrToLast returns the last IP from a CIDR address. It's often used as the "broadcast" ip.
func CidrToMask ¶
CidrToMask returns the subnet mask from a CIDR address.
func CidrToPrefix ¶
CidrToPrefix returns the prefix from a CIDR address. For example, if you give us 192.0.2.0/24 then we will return "24" as a string.
func IsMac ¶
IsMac takes a string and returns true if it's a mac in the standard format.
func MacFmt ¶
MacFmt takes a MAC address with hyphens and converts it to a format with colons.
func Macs ¶
Macs returns the list of mac addresses that are seen on the machine.
XXX: These should produce new values if the list of interfaces change.
func OldMacFmt ¶
OldMacFmt takes a MAC address with colons and converts it to a format with hyphens. This is the old deprecated style that nobody likes.
func URLParser ¶
URLParser takes a URL as a string, and extracts the different components of the URL: scheme, host, path, and query. The function will error out if the given URL doesn't contain a valid URL, as this is a requirement of the underlying net/url library. Note that additional fields may be added to the output in the future.
Source Files ¶
cidr_to_ip.go macfmt.go macs.go net.go url_parser.go
- Version
- v0.0.0-20250322185616-c50a578426f1 (latest)
- Published
- Mar 22, 2025
- Platform
- linux/amd64
- Imports
- 11 packages
- Last checked
- 4 days ago –
Tools for package owners.