Documentation ¶
Index ¶
- type AARPMachine
- func (a *AARPMachine) Address() (aarp.AddrPair, bool)
- func (a *AARPMachine) Assigned() <-chan struct{}
- func (t AARPMachine) Dump() map[ddp.Addr]AMTEntry
- func (a *AARPMachine) Handle(ctx context.Context, pkt *ethertalk.Packet)
- func (t AARPMachine) Learn(ddpAddr ddp.Addr, hwAddr ethernet.Addr)
- func (a *AARPMachine) Resolve(ctx context.Context, ddpAddr ddp.Addr) (ethernet.Addr, error)
- func (a *AARPMachine) Run(ctx context.Context) error
- type AMTEntry
- type AURPPeer
- type Config
- type EtherTalkPeer
- type EtherTalkPort
- func (port *EtherTalkPort) Broadcast(pkt *ddp.ExtPacket) error
- func (port *EtherTalkPort) HandleNBP(ctx context.Context, ddpkt *ddp.ExtPacket) error
- func (port *EtherTalkPort) HandleRTMP(ctx context.Context, pkt *ddp.ExtPacket) error
- func (port *EtherTalkPort) HandleZIP(ctx context.Context, ddpkt *ddp.ExtPacket) error
- func (port *EtherTalkPort) RunRTMP(ctx context.Context) (err error)
- func (port *EtherTalkPort) Send(ctx context.Context, pkt *ddp.ExtPacket) error
- func (port *EtherTalkPort) Serve(ctx context.Context)
- func (port *EtherTalkPort) ZoneMulticast(zone string, pkt *ddp.ExtPacket) error
- type ReceiverState
- type Route
- type RouteTable
- func (rt *RouteTable) AddZonesToNetwork(n ddp.Network, zs ...string)
- func (rt *RouteTable) AllZoneNames() (zones []string)
- func (rt *RouteTable) DeleteAURPPeer(peer *AURPPeer)
- func (rt *RouteTable) DeleteAURPPeerNetwork(peer *AURPPeer, network ddp.Network)
- func (rt *RouteTable) Dump() []Route
- func (rt *RouteTable) InsertAURPRoute(peer *AURPPeer, extended bool, netStart, netEnd ddp.Network, metric uint8) error
- func (rt *RouteTable) InsertEtherTalkDirect(port *EtherTalkPort)
- func (rt *RouteTable) LookupRoute(network ddp.Network) *Route
- func (rt *RouteTable) RoutesForZone(zone string) []*Route
- func (rt *RouteTable) UpdateAURPRouteDistance(peer *AURPPeer, network ddp.Network, distance uint8)
- func (rt *RouteTable) UpsertEtherTalkRoute(peer *EtherTalkPeer, extended bool, netStart, netEnd ddp.Network, metric uint8) (*Route, error)
- func (rt *RouteTable) ValidNonAURPRoutes() []*Route
- func (rt *RouteTable) ValidRoutes() []*Route
- func (rt *RouteTable) ZonesForNetworks(ns []ddp.Network) map[ddp.Network][]string
- type Router
- func (rtr *Router) Forward(ctx context.Context, ddpkt *ddp.ExtPacket) error
- func (rtr *Router) HandleAEP(ctx context.Context, ddpkt *ddp.ExtPacket) error
- func (rtr *Router) HandleNBPFromAURP(ctx context.Context, ddpkt *ddp.ExtPacket) error
- func (rtr *Router) Output(ctx context.Context, ddpkt *ddp.ExtPacket) error
- type SenderState
- type StringSet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AARPMachine ¶
type AARPMachine struct {
// contains filtered or unexported fields
}
AARPMachine maintains both an Address Mapping Table and handles AARP packets (sending and receiving requests, responses, and probes). This process assumes a particular network range rather than using the startup range, since this program is a seed router.
func NewAARPMachine ¶
NewAARPMachine creates a new AARPMachine.
func (*AARPMachine) Address ¶
func (a *AARPMachine) Address() (aarp.AddrPair, bool)
Address returns the address of this node, and reports if the address is valid (i.e. not tentative).
func (*AARPMachine) Assigned ¶
func (a *AARPMachine) Assigned() <-chan struct{}
Assigned returns a channel that is closed when the local address is valid.
func (*AARPMachine) Handle ¶
func (a *AARPMachine) Handle(ctx context.Context, pkt *ethertalk.Packet)
Handle handles a packet.
type AMTEntry ¶
type AMTEntry struct { // The hardware address that the entry maps to. HWAddr ethernet.Addr // The last time this entry was updated. LastUpdated time.Time // Whether the address is being resolved. Resolving bool // contains filtered or unexported fields }
AMTEntry is an entry in an address mapping table.
func (AMTEntry) LastUpdatedAgo ¶
LastUpdatedAgo is a friendly string reporting how long ago the entry was updated/resolved.
type AURPPeer ¶
type AURPPeer struct { // AURP-Tr state for producing packets. Transport *aurp.Transport // Connection to reply to packets on. UDPConn *net.UDPConn // The string that appeared in the config file / peer list file (with a // ":387" appended as necessary). // May be empty if this peer was not configured (it connected to us). ConfiguredAddr string // The resolved address of the peer. RemoteAddr *net.UDPAddr // Incoming packet channel. ReceiveCh chan aurp.Packet // Route table (the peer will add/remove/update routes and zones) RouteTable *RouteTable // contains filtered or unexported fields }
AURPPeer handles the peering with a peer AURP router.
func (*AURPPeer) ReceiverState ¶
func (p *AURPPeer) ReceiverState() ReceiverState
func (*AURPPeer) SenderState ¶
func (p *AURPPeer) SenderState() SenderState
type Config ¶
type Config struct { // Optional: default is 387. ListenPort uint16 `yaml:"listen_port"` // Sets the Domain Identifier used by this router. // Note: this does not "bind" the IP side of the router to a particular // interface; it will listen on all interfaces with IP addresses. // Optional: defaults to the first global unicast address on any local // network interface. LocalIP string `yaml:"local_ip"` // Required for routing a local EtherTalk network. EtherTalk struct { EthAddr string `yaml:"ethernet_addr"` Device string `yaml:"device"` ZoneName string `yaml:"zone_name"` NetStart ddp.Network `yaml:"net_start"` NetEnd ddp.Network `yaml:"net_end"` } `yaml:"ethertalk"` // Allow routers other than those listed under peers? OpenPeering bool `yaml:"open_peering"` // List of peer routers. Peers []string `yaml:"peers"` // Or a URL to fetch a list of peers from. PeerListURL string `yaml:"peerlist_url"` }
func LoadConfig ¶
type EtherTalkPeer ¶
type EtherTalkPeer struct { Port *EtherTalkPort PeerAddr ddp.Addr }
EtherTalkPeer holds data needed to forward packets to another router on the EtherTalk network.
type EtherTalkPort ¶
type EtherTalkPort struct { Device string EthernetAddr ethernet.Addr NetStart ddp.Network NetEnd ddp.Network MyAddr ddp.Addr DefaultZoneName string AvailableZones StringSet PcapHandle *pcap.Handle AARPMachine *AARPMachine Router *Router }
EtherTalkPort is all the data and helpers needed for EtherTalk on one port.
func (*EtherTalkPort) HandleRTMP ¶
RTMPMachine implements RTMP on an AppleTalk network attached to the router.
func (*EtherTalkPort) RunRTMP ¶
func (port *EtherTalkPort) RunRTMP(ctx context.Context) (err error)
RunRTMP makes periodic RTMP Data broadcasts on this port.
func (*EtherTalkPort) Serve ¶
func (port *EtherTalkPort) Serve(ctx context.Context)
func (*EtherTalkPort) ZoneMulticast ¶
func (port *EtherTalkPort) ZoneMulticast(zone string, pkt *ddp.ExtPacket) error
type ReceiverState ¶
type ReceiverState int
const ( ReceiverUnconnected ReceiverState = iota ReceiverConnected ReceiverWaitForOpenRsp ReceiverWaitForRIRsp ReceiverWaitForTickleAck )
func (ReceiverState) String ¶
func (rs ReceiverState) String() string
type Route ¶
type Route struct { Extended bool NetStart ddp.Network NetEnd ddp.Network Distance uint8 LastSeen time.Time // ZoneNames may be empty between learning the existence of a route and // receiving zone information. ZoneNames StringSet // Exactly one of the following should be set AURPPeer *AURPPeer // Next hop is this peer router (over AURP) EtherTalkPeer *EtherTalkPeer // Next hop is this peer router (over EtherTalk) EtherTalkDirect *EtherTalkPort // Directly connected to this network (via EtherTalk) }
func (Route) LastSeenAgo ¶
type RouteTable ¶
type RouteTable struct {
// contains filtered or unexported fields
}
func NewRouteTable ¶
func NewRouteTable() *RouteTable
func (*RouteTable) AddZonesToNetwork ¶
func (rt *RouteTable) AddZonesToNetwork(n ddp.Network, zs ...string)
func (*RouteTable) AllZoneNames ¶
func (rt *RouteTable) AllZoneNames() (zones []string)
func (*RouteTable) DeleteAURPPeer ¶
func (rt *RouteTable) DeleteAURPPeer(peer *AURPPeer)
func (*RouteTable) DeleteAURPPeerNetwork ¶
func (rt *RouteTable) DeleteAURPPeerNetwork(peer *AURPPeer, network ddp.Network)
func (*RouteTable) Dump ¶
func (rt *RouteTable) Dump() []Route
func (*RouteTable) InsertAURPRoute ¶
func (*RouteTable) InsertEtherTalkDirect ¶
func (rt *RouteTable) InsertEtherTalkDirect(port *EtherTalkPort)
func (*RouteTable) LookupRoute ¶
func (rt *RouteTable) LookupRoute(network ddp.Network) *Route
func (*RouteTable) RoutesForZone ¶
func (rt *RouteTable) RoutesForZone(zone string) []*Route
func (*RouteTable) UpdateAURPRouteDistance ¶
func (rt *RouteTable) UpdateAURPRouteDistance(peer *AURPPeer, network ddp.Network, distance uint8)
func (*RouteTable) UpsertEtherTalkRoute ¶
func (rt *RouteTable) UpsertEtherTalkRoute(peer *EtherTalkPeer, extended bool, netStart, netEnd ddp.Network, metric uint8) (*Route, error)
func (*RouteTable) ValidNonAURPRoutes ¶
func (rt *RouteTable) ValidNonAURPRoutes() []*Route
ValidNonAURPRoutes returns all valid routes that were not learned via AURP.
func (*RouteTable) ValidRoutes ¶
func (rt *RouteTable) ValidRoutes() []*Route
ValidRoutes returns all valid routes.
func (*RouteTable) ZonesForNetworks ¶
type Router ¶
type Router struct { Config *Config RouteTable *RouteTable Ports []*EtherTalkPort }
func (*Router) Forward ¶
Forward increments the hop count, then outputs the packet in the direction of the destination.
func (*Router) HandleNBPFromAURP ¶
type SenderState ¶
type SenderState int
const ( SenderUnconnected SenderState = iota SenderConnected SenderWaitForRIRspAck SenderWaitForRIUpdAck SenderWaitForRDAck )
func (SenderState) String ¶
func (ss SenderState) String() string
type StringSet ¶
type StringSet map[string]struct{}
StringSet is a set of strings. Yep, yet another string set implementation. Took me 2 minutes to write *shrug*