Documentation ¶
Overview ¶
Package aurp implements types for encoding and decoding AppleTalk Update-Based Routing Protocol (AURP, RFC 1504) messages.
Index ¶
- func Inc(p *uint16)
- func ParsePacket(p []byte) (DomainHeader, Packet, error)
- type AppleTalkPacket
- type Authority
- type CmdCode
- type DomainHeader
- type DomainIdentifier
- type ErrorCode
- type EventCode
- type EventTuple
- type EventTuples
- type GDZLReqPacket
- type GDZLRspPacket
- type GZNReqPacket
- type GZNRspPacket
- type Header
- type IPDomainIdentifier
- type NetworkTuple
- type NetworkTuples
- type NullDomainIdentifier
- type OpenReqPacket
- type OpenRspPacket
- type OptionTuple
- type OptionType
- type Options
- type Packet
- type PacketType
- type RDPacket
- type RIAckPacket
- type RIReqPacket
- type RIRspPacket
- type RIUpdPacket
- type RoutingFlag
- type Subcode
- type TickleAckPacket
- type TicklePacket
- type TrHeader
- type Transport
- func (tr *Transport) NewAppleTalkPacket(data []byte) *AppleTalkPacket
- func (tr *Transport) NewGDZLReqPacket(startIdx uint16) *GDZLReqPacket
- func (tr *Transport) NewGDZLRspPacket(startIdx int16, zoneNames []string) *GDZLRspPacket
- func (tr *Transport) NewGZNReqPacket(zoneName string) *GZNReqPacket
- func (tr *Transport) NewGZNRspPacket(zoneName string, notSupported bool, nets NetworkTuples) *GZNRspPacket
- func (tr *Transport) NewOpenReqPacket(opts Options) *OpenReqPacket
- func (tr *Transport) NewOpenRspPacket(envFlags RoutingFlag, rateOrErr int16, opts Options) *OpenRspPacket
- func (tr *Transport) NewRDPacket(errCode ErrorCode) *RDPacket
- func (tr *Transport) NewRIAckPacket(connID, seq uint16, szi RoutingFlag) *RIAckPacket
- func (tr *Transport) NewRIReqPacket() *RIReqPacket
- func (tr *Transport) NewRIRspPacket(last RoutingFlag, nets NetworkTuples) *RIRspPacket
- func (tr *Transport) NewRIUpdPacket(events EventTuples) *RIUpdPacket
- func (tr *Transport) NewTickleAckPacket() *TickleAckPacket
- func (tr *Transport) NewTicklePacket() *TicklePacket
- func (tr *Transport) NewZIRspPacket(zoneLists map[ddp.Network][]string) *ZIRspPacket
- type ZIReqPacket
- type ZIRspPacket
- type ZoneTuple
- type ZoneTuples
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParsePacket ¶
func ParsePacket(p []byte) (DomainHeader, Packet, error)
ParsePacket parses the body of a UDP packet for a domain header, and then based on the packet type, an AURP-Tr header, an AURP routing header, and then a particular packet type.
(This function contains the big switch statement.)
Types ¶
type AppleTalkPacket ¶
type AppleTalkPacket struct { DomainHeader // where PacketTypeAppleTalk Data []byte }
AppleTalkPacket is for encapsulated AppleTalk traffic.
type Authority ¶
type Authority byte
Authority represents the different possible authorities ("types") for domain identifiers.
type CmdCode ¶
type CmdCode uint16
CmdCode is the command code used in AURP packets.
const ( CmdCodeRIReq CmdCode = 0x0001 CmdCodeRIRsp CmdCode = 0x0002 CmdCodeRIAck CmdCode = 0x0003 CmdCodeRIUpd CmdCode = 0x0004 CmdCodeRD CmdCode = 0x0005 CmdCodeZoneReq CmdCode = 0x0006 // has subcodes CmdCodeZoneRsp CmdCode = 0x0007 // has subcodes CmdCodeOpenReq CmdCode = 0x0008 CmdCodeOpenRsp CmdCode = 0x0009 CmdCodeTickle CmdCode = 0x000e CmdCodeTickleAck CmdCode = 0x000f )
Various command codes.
type DomainHeader ¶
type DomainHeader struct { DestinationDI DomainIdentifier SourceDI DomainIdentifier Version uint16 // Should always be 0x0001 Reserved uint16 // Should always be 0x0000 PacketType PacketType // 2 = AppleTalk data packet, 3 = AURP packet }
DomainHeader represents the header used to encapsulate both AppleTalk data packets and AURP packets within UDP.
func ParseDomainHeader ¶
func ParseDomainHeader(b []byte) (DomainHeader, []byte, error)
ParseDomainHeader parses a domain header, returning the DH and the remainder of the input slice. It does not validate the version or packet type fields.
type DomainIdentifier ¶
DomainIdentifier is the byte representation of a domain identifier.
type ErrorCode ¶
type ErrorCode int16
type EventCode ¶
type EventCode uint8
const ( // Null event EventCodeNull EventCode = 0 // Network added event EventCodeNA EventCode = 1 // Network deleted event EventCodeND EventCode = 2 // Network route change event EventCodeNRC EventCode = 3 // Network distance change event EventCodeNDC EventCode = 4 // Network zone change event // Note: "The ZC event tuple is not yet defined." EventCodeZC EventCode = 5 )
type EventTuple ¶
type EventTuples ¶
type EventTuples []EventTuple
type GDZLReqPacket ¶
type GDZLRspPacket ¶
type GZNReqPacket ¶
type GZNRspPacket ¶
type GZNRspPacket struct { Header Subcode ZoneName string NotSupported bool Networks NetworkTuples }
type Header ¶
type Header struct { TrHeader CommandCode CmdCode Flags RoutingFlag }
Header represents an AURP packet header. It includes the AURP-Tr header, which includes the domain header.
type IPDomainIdentifier ¶
IPDomainIdentifier represents an IP address in a domain identifier.
func (IPDomainIdentifier) String ¶
func (i IPDomainIdentifier) String() string
type NetworkTuple ¶
type NetworkTuples ¶
type NetworkTuples []NetworkTuple
func (NetworkTuples) String ¶
func (n NetworkTuples) String() string
type NullDomainIdentifier ¶
type NullDomainIdentifier struct{}
NullDomainIdentifier represents a null domain identifier.
func (NullDomainIdentifier) String ¶
func (NullDomainIdentifier) String() string
type OpenReqPacket ¶
OpenReq is used to open a one-way connection between AIRs.
type OpenRspPacket ¶
OpenRsp is used to respond to Open-Req.
type OptionTuple ¶
type OptionTuple struct { // Length uint8 = 1(for Type) + len(Data) Type OptionType Data []byte }
OptionTuple is used to pass option information in Open-Req and Open-Rsp packets.
type OptionType ¶
type OptionType uint8
OptionType is used to distinguish different options.
const (
OptionTypeAuthentication OptionType = 0x01
)
Various option types
type Options ¶
type Options []OptionTuple
type Packet ¶
Packet represents a full AURP packet, not including UDP or lower layers, but including the domain header and higher layers.
type PacketType ¶
type PacketType uint16
PacketType is used to distinguish domain-header encapsulated packets.
const ( PacketTypeAppleTalk PacketType = 0x0002 PacketTypeRouting PacketType = 0x0003 )
Various packet types.
type RIAckPacket ¶
type RIAckPacket struct {
Header
}
type RIReqPacket ¶
type RIReqPacket struct {
Header
}
type RIRspPacket ¶
type RIRspPacket struct { Header Networks NetworkTuples }
type RIUpdPacket ¶
type RIUpdPacket struct { Header Events EventTuples }
type RoutingFlag ¶
type RoutingFlag uint16
RoutingFlag is used in the flags field
const ( // Open-Req and RI-Req (SUI flags) RoutingFlagSUINA RoutingFlag = 0x4000 RoutingFlagSUINDOrNRC RoutingFlag = 0x2000 RoutingFlagSUINDC RoutingFlag = 0x1000 RoutingFlagSUIZC RoutingFlag = 0x0800 // The combination of the above four flags (the SUI flags). RoutingFlagAllSUI RoutingFlag = 0x7800 // RI-Rsp and GDZL-Rsp RoutingFlagLast RoutingFlag = 0x8000 // Open-Rsp (environment flags) RoutingFlagRemappingActive RoutingFlag = 0x4000 RoutingFlagHopCountReduction RoutingFlag = 0x2000 RoutingFlagReservedEnv RoutingFlag = 0x1800 // RI-Ack RoutingFlagSendZoneInfo RoutingFlag = 0x4000 )
type TickleAckPacket ¶
type TickleAckPacket struct {
Header
}
type TicklePacket ¶
type TicklePacket struct {
Header
}
type TrHeader ¶
type TrHeader struct { DomainHeader ConnectionID uint16 Sequence uint16 }
TrHeader represent an AURP-Tr packet header. It includes the domain header.
type Transport ¶
type Transport struct {
// LocalDI and RemoteDI are used for producing packets.
// When sending a packet, we use LocalDI as SourceDI and RemoteDI as
// DestinationDI.
// (When receiving a packet, we expect to see LocalDI as DestinationDI
// - but it might not be - and we expect to see RemoteDI as SourceDI.)
LocalDI, RemoteDI DomainIdentifier
// LocalConnID is used for packets sent in the role of data receiver.
// RemoteConnID is used for packets sent in the role of data sender.
LocalConnID, RemoteConnID uint16
// LocalSeq is used for packets sent (as data sender)
// RemoteSeq is used to check packets received (remote is the data sender).
LocalSeq, RemoteSeq uint16
}
Transport tracks local and remote domain identifiers, connection IDs, and sequence numbers for use in a pair of one-way connections.
func (*Transport) NewAppleTalkPacket ¶
func (tr *Transport) NewAppleTalkPacket(data []byte) *AppleTalkPacket
NewAppleTalkPacket returns a new AppleTalkPacket.
func (*Transport) NewGDZLReqPacket ¶
func (tr *Transport) NewGDZLReqPacket(startIdx uint16) *GDZLReqPacket
NewGDZLReqPacket returns a new GDZL-Req packet structure.
func (*Transport) NewGDZLRspPacket ¶
func (tr *Transport) NewGDZLRspPacket(startIdx int16, zoneNames []string) *GDZLRspPacket
NewGZNRspPacket returns a new GDZL-Rsp packet structure. If GDZL function is not supported, startIdx should be set to -1.
func (*Transport) NewGZNReqPacket ¶
func (tr *Transport) NewGZNReqPacket(zoneName string) *GZNReqPacket
NewGZNReqPacket returns a new GZN-Req packet structure requesting nets for a given zone name.
func (*Transport) NewGZNRspPacket ¶
func (tr *Transport) NewGZNRspPacket(zoneName string, notSupported bool, nets NetworkTuples) *GZNRspPacket
NewGZNRspPacket returns a new GZN-Rsp packet structure.
func (*Transport) NewOpenReqPacket ¶
func (tr *Transport) NewOpenReqPacket(opts Options) *OpenReqPacket
NewOpenReqPacket returns a new Open-Req packet structure. By default it sets all SUI flags and uses version 1.
func (*Transport) NewOpenRspPacket ¶
func (tr *Transport) NewOpenRspPacket(envFlags RoutingFlag, rateOrErr int16, opts Options) *OpenRspPacket
NewOpenRspPacket returns a new Open-Rsp packet structure.
func (*Transport) NewRDPacket ¶
NewRDPacket returns a new RD packet structure.
func (*Transport) NewRIAckPacket ¶
func (tr *Transport) NewRIAckPacket(connID, seq uint16, szi RoutingFlag) *RIAckPacket
NewRIAckPacket returns a new RI-Ack packet structure.
func (*Transport) NewRIReqPacket ¶
func (tr *Transport) NewRIReqPacket() *RIReqPacket
NewRIReqPacket returns a new RI-Req packet structure. By default it sets all SUI flags.
func (*Transport) NewRIRspPacket ¶
func (tr *Transport) NewRIRspPacket(last RoutingFlag, nets NetworkTuples) *RIRspPacket
NewRIRspPacket returs a new RI-Rsp packet structure.
func (*Transport) NewRIUpdPacket ¶
func (tr *Transport) NewRIUpdPacket(events EventTuples) *RIUpdPacket
NewRIUpdPacket returns a new RI-Upd packet structure.
func (*Transport) NewTickleAckPacket ¶
func (tr *Transport) NewTickleAckPacket() *TickleAckPacket
NewTickleAckPacket returns a new Tickle-Ack packet.
func (*Transport) NewTicklePacket ¶
func (tr *Transport) NewTicklePacket() *TicklePacket
NewTicklePacket returns a new Tickle packet structure.
func (*Transport) NewZIRspPacket ¶
func (tr *Transport) NewZIRspPacket(zoneLists map[ddp.Network][]string) *ZIRspPacket
NewZIRspPacket returns a new ZI-Rsp packet structure containing the given zone information. It automatically chooses between subcodes 1 or 2 depending on whether there is one network ID or more than one network ID.
type ZIReqPacket ¶
type ZIRspPacket ¶
type ZIRspPacket struct { Header Subcode Zones ZoneTuples }
ZIRspPacket represents a ZI-Rsp: a response packet to a ZI-Req.
"When the data sender receives a ZI-Req and the zone list for the network or networks for which that ZI-Req requested zone information fits in one ZI-Rsp packet, it sends a nonextended ZI-Rsp." "When the data sender receives a ZI-Req and the zone list for a network about which that ZI-Req requested zone information does not fit in a single ZI-Rsp packet, it sends a sequence of extended ZI-Rsp packets." "All tuples in a single extended ZI-Rsp packet must contain the same network number" "Duplicate zone names never exist in extended ZI-Rsp packets"
type ZoneTuples ¶
type ZoneTuples []ZoneTuple
func (ZoneTuples) String ¶
func (zs ZoneTuples) String() string