netutil

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2018 License: Apache-2.0 Imports: 4 Imported by: 10

README

netutil

Common Go libraries for networking application.

  • preifx -- Prefix handling utilities.
  • ptree -- Patricia tree utilities.

Documentation

Index

Constants

View Source
const (
	AFI_IP = iota
	AFI_IP6
	AFI_MAX
)

Variables

View Source
var MaskBits = []byte{0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff}
View Source
var MaskReverseBits = []byte{0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01, 0x00}

Functions

func CopyIP

func CopyIP(ip net.IP) net.IP

func IPNetFromPrefix

func IPNetFromPrefix(p *Prefix) net.IPNet

func ParseIPv4

func ParseIPv4(s string) net.IP

func SameIp

func SameIp(a net.IP, b net.IP) bool

Types

type Prefix

type Prefix struct {
	net.IP
	Length int
}

func NewPrefixAFI

func NewPrefixAFI(afi int) *Prefix

func ParsePrefix

func ParsePrefix(s string) (*Prefix, error)

func PrefixFromIPNet

func PrefixFromIPNet(net net.IPNet) *Prefix

func PrefixFromIPPrefixlen

func PrefixFromIPPrefixlen(ip net.IP, len int) *Prefix

func PrefixFromNode

func PrefixFromNode(n *PtreeNode) *Prefix

func (*Prefix) AFI

func (p *Prefix) AFI() int

func (*Prefix) ApplyMask

func (p *Prefix) ApplyMask() *Prefix

func (*Prefix) ApplyReverseMask

func (p *Prefix) ApplyReverseMask() *Prefix

func (*Prefix) ByteLength

func (p *Prefix) ByteLength() int

func (*Prefix) Copy

func (p *Prefix) Copy() *Prefix

func (*Prefix) Equal

func (p *Prefix) Equal(x *Prefix) bool

func (*Prefix) IsDefault

func (p *Prefix) IsDefault() bool

func (*Prefix) MarshalJSON

func (p *Prefix) MarshalJSON() ([]byte, error)

func (*Prefix) Match

func (p *Prefix) Match(q *Prefix) bool

func (*Prefix) String

func (p *Prefix) String() string

type Ptree

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

func NewPtree

func NewPtree(maxKeyBits int) *Ptree

func (*Ptree) Acquire

func (this *Ptree) Acquire(key []byte, keyLength int) *PtreeNode

func (*Ptree) AcquireByIPv4

func (this *Ptree) AcquireByIPv4(key []byte) *PtreeNode

func (*Ptree) AcquireByIPv6

func (this *Ptree) AcquireByIPv6(key []byte) *PtreeNode

func (*Ptree) AcquireByMaxBits

func (this *Ptree) AcquireByMaxBits(key []byte) *PtreeNode

func (*Ptree) AcquireByUint32

func (this *Ptree) AcquireByUint32(keyInt uint32) *PtreeNode

func (*Ptree) AcquireWithItem

func (this *Ptree) AcquireWithItem(key []byte, keyLength int, v interface{}) *PtreeNode

func (*Ptree) Lookup

func (this *Ptree) Lookup(key []byte, keyLength int) *PtreeNode

func (*Ptree) LookupByIPv4

func (this *Ptree) LookupByIPv4(key []byte) *PtreeNode

func (*Ptree) LookupByIPv6

func (this *Ptree) LookupByIPv6(key []byte) *PtreeNode

func (*Ptree) LookupByMaxBits

func (this *Ptree) LookupByMaxBits(key []byte) *PtreeNode

func (*Ptree) LookupByUint32

func (this *Ptree) LookupByUint32(keyInt uint32) *PtreeNode

func (*Ptree) LookupTop

func (this *Ptree) LookupTop() *PtreeNode

func (*Ptree) Match

func (this *Ptree) Match(key []byte, keyLength int) *PtreeNode

func (*Ptree) MatchIPv4

func (this *Ptree) MatchIPv4(key []byte) *PtreeNode

func (*Ptree) MatchIPv6

func (this *Ptree) MatchIPv6(key []byte) *PtreeNode

func (*Ptree) Next

func (this *Ptree) Next(node *PtreeNode) *PtreeNode

func (*Ptree) Release

func (this *Ptree) Release(node *PtreeNode)

func (*Ptree) ReleaseByUint32

func (this *Ptree) ReleaseByUint32(keyInt uint32)

func (*Ptree) ReleaseWithItem

func (this *Ptree) ReleaseWithItem(key []byte, keyLength int, v interface{})

func (*Ptree) ReverseOrderSet

func (this *Ptree) ReverseOrderSet()

func (*Ptree) Top

func (this *Ptree) Top() *PtreeNode

type PtreeNode

type PtreeNode struct {
	Item interface{}
	// contains filtered or unexported fields
}

func NewPtreeNode

func NewPtreeNode(key []byte, keyLength int) *PtreeNode

func (*PtreeNode) Key

func (n *PtreeNode) Key() []byte

func (*PtreeNode) KeyLength

func (n *PtreeNode) KeyLength() int

func (*PtreeNode) Refcnt

func (node *PtreeNode) Refcnt() uint32

Jump to

Keyboard shortcuts

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