goasn

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2019 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ASPathSegmentTypeSet = iota
	ASPathSegmentTypeSequence
)

Similar to https://github.com/kaorimatz/go-mrt/blob/master/bgp.go#L29-L32

Variables

This section is empty.

Functions

This section is empty.

Types

type ASNDatabase

type ASNDatabase struct {
	Entries []PrefixOrigin
}

func (ASNDatabase) MarshalText

func (db ASNDatabase) MarshalText(singleAS bool) ([]byte, error)

TODO: Deduplicate code

func (*ASNDatabase) UnmarshalText added in v0.0.2

func (db *ASNDatabase) UnmarshalText(data []byte) error

type ASNTree

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

func NewASNTree

func NewASNTree(prefixes []PrefixOrigin) (*ASNTree, error)

func NewASNTreeFromFile added in v0.0.2

func NewASNTreeFromFile(path string) (*ASNTree, error)

TODO: Detect file type (txt, json, ...)

func NewASNTreeFromText added in v0.0.4

func NewASNTreeFromText(b []byte) (*ASNTree, error)

func (ASNTree) LookupIP added in v0.0.2

func (t ASNTree) LookupIP(ip net.IP) ([]uint32, error)

func (ASNTree) LookupIPMultiple added in v0.0.2

func (t ASNTree) LookupIPMultiple(ips []net.IP) ([][]uint32, error)

func (ASNTree) LookupStr added in v0.0.2

func (t ASNTree) LookupStr(str string) ([]uint32, error)

func (ASNTree) LookupStrMultiple added in v0.0.2

func (t ASNTree) LookupStrMultiple(strs []string) ([][]uint32, error)

type ASPathSegment

type ASPathSegment struct {
	Type uint8
	ASNs []uint32
}

type IXPDatabase

type IXPDatabase struct {
	Entries []PrefixIXP
}

func (IXPDatabase) MarshalText added in v0.0.2

func (db IXPDatabase) MarshalText() ([]byte, error)

TODO: Deduplicate code

func (*IXPDatabase) UnmarshalText added in v0.0.2

func (db *IXPDatabase) UnmarshalText(data []byte) error

type IXPTree

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

func NewIXPTree added in v0.0.3

func NewIXPTree(db peeringdb.DB) (*IXPTree, error)

func (IXPTree) LookupIP added in v0.0.3

func (t IXPTree) LookupIP(ip net.IP) (string, error)

func (IXPTree) LookupIPMultiple added in v0.0.3

func (t IXPTree) LookupIPMultiple(ips []net.IP) ([]string, error)

func (IXPTree) LookupStr added in v0.0.3

func (t IXPTree) LookupStr(str string) (string, error)

func (IXPTree) LookupStrMultiple added in v0.0.3

func (t IXPTree) LookupStrMultiple(strs []string) ([]string, error)

type PrefixIXP

type PrefixIXP struct {
	Prefix net.IPNet `json:"prefix"`
	IXP    string    `json:"ixp"`
}

PrefixIXP represents the IXP associated to a prefix.

func (PrefixIXP) MarshalText added in v0.0.2

func (p PrefixIXP) MarshalText() ([]byte, error)

func (*PrefixIXP) UnmarshalText added in v0.0.2

func (p *PrefixIXP) UnmarshalText(data []byte) error

type PrefixOrigin

type PrefixOrigin struct {
	Prefix net.IPNet `json:"prefix"`
	Origin []uint32  `json:"origin"`
}

PrefixOrigin represents the origin AS(es) associated to a prefix. There can be multiple ASes if the prefix is multi-homed.

func NewPrefixOrigin

func NewPrefixOrigin(e RIBEntry) PrefixOrigin

func (PrefixOrigin) MarshalText added in v0.0.2

func (p PrefixOrigin) MarshalText(singleAS bool) ([]byte, error)

func (*PrefixOrigin) UnmarshalText added in v0.0.2

func (p *PrefixOrigin) UnmarshalText(data []byte) error

type RIBEntry

type RIBEntry struct {
	OriginCode string
	Network    net.IPNet
	LocPrf     uint32
	Path       []ASPathSegment
}

func RIBFromMRT

func RIBFromMRT(path string) ([]RIBEntry, error)

Jump to

Keyboard shortcuts

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