iphhy

package module
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2020 License: MIT Imports: 8 Imported by: 0

README

iphhy

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IPToInt

func IPToInt(ip net.IP) uint32

IPToInt converts an IPv4 address to a uint32

func IntToIP

func IntToIP(nn uint32) net.IP

IntToIP converts a uint32 to an IPv4 address

func InvertIPMask added in v1.0.2

func InvertIPMask(in net.IPMask) net.IPMask

InvertIPMask inverts a net.IPMask

func MustOffsetString

func MustOffsetString(subnet string, offset int) string

MustOffsetString same as OffsetString but panics if called with wrong parameter

func OffsetString

func OffsetString(subnet string, offset int) (string, error)

OffsetString returns the IPv4 string for a given subnet string and a given offset

Types

type I4

type I4 struct {
	// contains filtered or unexported fields
}

I4 is a simple and easy to use type to handle an IP address or an IP network it is designed to be mutable

func MustNewI4

func MustNewI4(s string) I4

MustNewI4 creates a new I4 value and panics on error

func NewI4

func NewI4(s string) (I4, error)

NewI4 create a new I4 from a string

func NewI4FromIP

func NewI4FromIP(ni net.IP) I4

NewI4FromIP creates a new I4 from net.IP (32 bit mask)

func NewI4NoOffset

func NewI4NoOffset(s string) (I4, error)

NewI4NoOffset create a new I4 from a string

func (I4) Base

func (i I4) Base() I4

Base returns a new I4 where the ip is the network number

func (I4) CIDRString

func (i4 I4) CIDRString() string

CIDRString returns the IP in CIDR notation

func (I4) DoubleDottedQuad

func (i4 I4) DoubleDottedQuad() string

DoubleDottedQuad returns the IP in double dotted quad 192.168.0.1 255.255.255.255

func (I4) DoubleDottedQuadInvertedMask added in v1.0.2

func (i4 I4) DoubleDottedQuadInvertedMask() string

DoubleDottedQuadInvertedMask returns the IP in double dotted quad 192.168.0.1 255.255.255.255

func (*I4) FromString

func (i4 *I4) FromString(s string) error

FromString sets the state from the string but supports + Notation for Offsets

func (*I4) FromStringNoOffset

func (i4 *I4) FromStringNoOffset(s string) error

FromStringNoOffset sets the state from the string

func (I4) GetAll

func (i I4) GetAll(lowerOffset, upperOffset int) ([]I4, error)

GetAll returns a slice of all I4 numbers, including first and last

func (I4) Host

func (i I4) Host() I4

Host returns a new I4 with a /32 mask

func (I4) IP

func (i4 I4) IP() net.IP

IP returns the IP

func (I4) IPString

func (i4 I4) IPString() string

IPString returns the IP

func (I4) Last

func (i I4) Last() I4

Last returns a new I4 where the ip is the last number in the network

func (*I4) MakeHost

func (i *I4) MakeHost()

MakeHost sets the mask to 32

func (I4) MarshalJSON added in v1.0.1

func (i4 I4) MarshalJSON() ([]byte, error)

MarshalJSON used to marshal json

func (I4) Mask

func (i4 I4) Mask() IPMask

Mask returns the Mask

func (I4) MaskBits

func (i4 I4) MaskBits() int

MaskBits returns the Mask

func (I4) MaskString

func (i4 I4) MaskString() string

MaskString returns the mask in dq

func (I4) MustOffset

func (i I4) MustOffset(offset int) I4

MustOffset sames as offset but panics on error

func (I4) NumHosts

func (i I4) NumHosts() int

NumHosts gives the number of hosts

func (I4) NumIPs

func (i I4) NumIPs() int

NumIPs gives the number of IPs in the subnet

func (I4) Number

func (i I4) Number() uint32

Number returns the number

func (I4) Offset

func (i I4) Offset(offset int) (I4, error)

Offset adds the offset to the network address offset 0 returns the network address offset 1 returns the first host address offset -1 returns the last address (i.e. the broadcast address) offset -2 returns the last host address

func (I4) Overlaps

func (i I4) Overlaps(i2 I4) bool

Overlaps determines if the two subnets share nodes

func (*I4) Rebase

func (i *I4) Rebase()

Rebase changes the underlying object to the base

func (I4) SetMaskBits added in v1.2.0

func (i I4) SetMaskBits(maskBits int) I4

SetMaskBits sets the mask bits

func (I4) String

func (i4 I4) String() string

String returns the IP in CIDR notation

func (I4) SubnetOffset

func (i I4) SubnetOffset(o int) I4

SubnetOffset gives the +-i subnet with the same mask, i.e. the IP address that is shifted o times the number of hosts upwards or downwards

func (*I4) UnmarshalJSON

func (i4 *I4) UnmarshalJSON(b []byte) error

UnmarshalJSON is used to unmarshal json

func (*I4) UnmarshalText

func (i4 *I4) UnmarshalText(b []byte) error

UnmarshalText satisfies encoding.TextUnmarshaler

type I4Numerical

type I4Numerical []I4

I4Numerical makes IP addresses sortable

func (I4Numerical) Len

func (i4n I4Numerical) Len() int

func (I4Numerical) Less

func (i4n I4Numerical) Less(i, j int) bool

func (I4Numerical) Swap

func (i4n I4Numerical) Swap(i, j int)

type IPMask added in v1.1.0

type IPMask []byte

IPMask is like the net.IPMask type

func CIDRMask added in v1.1.0

func CIDRMask(ones, bits int) IPMask

CIDRMask points to net.CIDRMask

func IPv4Mask added in v1.1.0

func IPv4Mask(a, b, c, d byte) IPMask

IPv4Mask points to net.IPv4Mask

func (IPMask) Invert added in v1.1.0

func (m IPMask) Invert() IPMask

Invert inverts the Mask and returns itself

func (IPMask) Size added in v1.1.0

func (m IPMask) Size() (ones, bits int)

Size points to net.IPMask.Size

func (IPMask) String added in v1.1.0

func (m IPMask) String() string

String points to net.IPMask.String

Jump to

Keyboard shortcuts

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