Documentation
¶
Overview ¶
Package aurp implements types for encoding and decoding AppleTalk Update-Based Routing Protocol (AURP, RFC 1504) messages.
Index ¶
- func ParsePacket(p []byte) (DomainHeader, Packet, error)
- func Pred(n uint16) uint16
- func Succ(n uint16) uint16
- 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 RoutingPacket
- type Subcode
- type TickleAckPacket
- type TicklePacket
- type TrHeader
- type Transport
- func (tr *Transport) IncLocalConnID()
- func (tr *Transport) IncLocalSeq()
- func (tr *Transport) IncRemoteSeq()
- func (tr *Transport) LocalConnID() uint16
- func (tr *Transport) LocalDI() DomainIdentifier
- func (tr *Transport) LocalSeq() uint16
- 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
- func (tr *Transport) RemoteConnID() uint16
- func (tr *Transport) RemoteDI() DomainIdentifier
- func (tr *Transport) RemoteSeq() uint16
- func (tr *Transport) ResetLocalSeq()
- func (tr *Transport) ResetRemoteSeq()
- func (tr *Transport) SetRemoteConnID(id uint16)
- func (tr *Transport) SetRemoteDI(di DomainIdentifier)
- 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.
func (*DomainHeader) GetDomainHeader ¶ added in v0.0.19
func (dh *DomainHeader) GetDomainHeader() *DomainHeader
GetDomainHeader returns itself. This is here to make it easy to get the domain header out of an arbitrary aurp.Packet that embeds it.
func (*DomainHeader) String ¶ added in v0.0.19
func (dh *DomainHeader) String() string
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 EventTuple struct {
EventCode EventCode
Extended bool
RangeStart ddp.Network
Distance uint8
RangeEnd ddp.Network
}
func (EventTuple) String ¶ added in v0.0.19
func (et EventTuple) String() string
type EventTuples ¶
type EventTuples []EventTuple
type GDZLReqPacket ¶
func (*GDZLReqPacket) String ¶ added in v0.0.19
func (p *GDZLReqPacket) String() string
type GDZLRspPacket ¶
func (*GDZLRspPacket) String ¶ added in v0.0.19
func (p *GDZLRspPacket) String() string
type GZNReqPacket ¶
func (*GZNReqPacket) String ¶ added in v0.0.19
func (p *GZNReqPacket) String() string
type GZNRspPacket ¶
type GZNRspPacket struct {
Header
Subcode
ZoneName string
NotSupported bool
Networks NetworkTuples
}
func (*GZNRspPacket) String ¶ added in v0.0.19
func (p *GZNRspPacket) String() string
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.
func (*Header) AURPHeader ¶ added in v0.0.19
AURPHeader returns itself.
type IPDomainIdentifier ¶
IPDomainIdentifier represents an IP address in a domain identifier.
func (IPDomainIdentifier) String ¶
func (i IPDomainIdentifier) String() string
type NetworkTuple ¶
type NetworkTuple struct {
Extended bool
RangeStart ddp.Network
Distance uint8
RangeEnd ddp.Network
}
func (NetworkTuple) String ¶ added in v0.0.19
func (nt NetworkTuple) String() string
type NetworkTuples ¶
type NetworkTuples []NetworkTuple
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.
func (*OpenReqPacket) String ¶ added in v0.0.19
func (p *OpenReqPacket) String() string
type OpenRspPacket ¶
OpenRsp is used to respond to Open-Req.
func (*OpenRspPacket) String ¶ added in v0.0.19
func (p *OpenRspPacket) String() string
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.
func (OptionTuple) String ¶ added in v0.0.19
func (ot OptionTuple) String() string
type OptionType ¶
type OptionType uint8
OptionType is used to distinguish different options.
const (
OptionTypeAuthentication OptionType = 0x01
)
Various option types
func (OptionType) String ¶ added in v0.0.19
func (ot OptionType) String() string
type Options ¶
type Options []OptionTuple
type Packet ¶
type Packet interface {
io.WriterTo
GetDomainHeader() *DomainHeader
}
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.
func (PacketType) String ¶ added in v0.0.19
func (pt PacketType) String() string
type RIAckPacket ¶
type RIAckPacket struct {
Header
}
type RIReqPacket ¶
type RIReqPacket struct {
Header
}
type RIRspPacket ¶
type RIRspPacket struct {
Header
Networks NetworkTuples
}
func (*RIRspPacket) String ¶ added in v0.0.19
func (p *RIRspPacket) String() string
type RIUpdPacket ¶
type RIUpdPacket struct {
Header
Events EventTuples
}
func (*RIUpdPacket) String ¶ added in v0.0.19
func (p *RIUpdPacket) String() string
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 RoutingPacket ¶ added in v0.0.19
RoutingPacket represents AURP routing information packets, which include extra layers that encapsulated AppleTalk packets do not have.
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.
func (*TrHeader) GetTrHeader ¶ added in v0.0.19
GetTrHeader returns itself. This is here to make it easy to get the transport header out of an arbitrary aurp.Packet that embeds it.
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport tracks local and remote domain identifiers, connection IDs, and sequence numbers for use in a pair of one-way connections.
func NewTransport ¶ added in v0.0.19
func NewTransport(localDI, remoteDI DomainIdentifier, localConnID, remoteConnID uint16) *Transport
NewTransport creates a new AURP-Tr transport.
func (*Transport) IncLocalConnID ¶ added in v0.0.20
func (tr *Transport) IncLocalConnID()
IncLocalConnID increments the local connection ID. It avoids 0, which is reserved.
func (*Transport) IncLocalSeq ¶ added in v0.0.20
func (tr *Transport) IncLocalSeq()
IncLocalSeq increments the sequence number. It avoids 0, which is reserved.
func (*Transport) IncRemoteSeq ¶ added in v0.0.20
func (tr *Transport) IncRemoteSeq()
IncRemoteSeq increments the expected sequence number. It avoids 0, which is reserved.
func (*Transport) LocalConnID ¶
LocalConnID returns the connection ID to supply from this side.
func (*Transport) LocalDI ¶
func (tr *Transport) LocalDI() DomainIdentifier
RemoteDI returns the domain identifier for the local side of the connection.
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.
func (*Transport) RemoteConnID ¶
RemoteConnID returns the connection ID supplied by the remote side.
func (*Transport) RemoteDI ¶
func (tr *Transport) RemoteDI() DomainIdentifier
RemoteDI returns the domain identifier for the remote side of the connection.
func (*Transport) RemoteSeq ¶
RemoteSeq returns the expected sequence number for data sent by the remote.
func (*Transport) ResetLocalSeq ¶ added in v0.0.20
func (tr *Transport) ResetLocalSeq()
ResetLocalSeq resets the sequence number back to 1.
func (*Transport) ResetRemoteSeq ¶ added in v0.0.20
func (tr *Transport) ResetRemoteSeq()
ResetRemoteSeq resets the expected sequence number back to 1.
func (*Transport) SetRemoteConnID ¶ added in v0.0.20
SetRemoteConnID updates the connection ID.
func (*Transport) SetRemoteDI ¶ added in v0.0.19
func (tr *Transport) SetRemoteDI(di DomainIdentifier)
SetRemoteDI updates the domain identifier for the remote side.
type ZIReqPacket ¶
func (*ZIReqPacket) String ¶ added in v0.0.19
func (p *ZIReqPacket) String() string
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"
func (*ZIRspPacket) String ¶ added in v0.0.19
func (p *ZIRspPacket) String() string
type ZoneTuples ¶
type ZoneTuples []ZoneTuple