ethertalk

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: BSD-3-Clause Imports: 7 Imported by: 2

Documentation

Overview

Encodes and decodes EtherTalk (DDP/AARP-over-Ethernet) packets.

Index

Constants

View Source
const (
	EthHeaderSize  = 13
	LinkHeaderSize = 3
	SNAPProtoSize  = 5
)

Variables

View Source
var (
	SNAP           = LinkHeader{0xAA, 0xAA, 0x03}
	AppleTalkProto = SNAPProto{[3]byte{0x08, 0x00, 0x07}, 0x809B}
	AARPProto      = SNAPProto{[3]byte{0x00, 0x00, 0x00}, 0x80F3}

	AppleTalkBroadcast = ethernet.Addr{0x09, 0x00, 0x07, 0xff, 0xff, 0xff}
)

Functions

func Equal

func Equal(a, b *Packet) bool

Returns true if two packets are equal. Ignores padding.

func Marshal

func Marshal(pak Packet) ([]byte, error)

Marshals a packet to bytes.

func Unmarshal

func Unmarshal(data []byte, pak *Packet) error

Unmarshals a packet from bytes.

Types

type EthHeader

type EthHeader struct {
	Dst, Src ethernet.Addr
	Size     uint16
}

type LinkHeader

type LinkHeader struct {
	DSAP, SSAP byte
	Control    byte
}

type Packet

type Packet struct {
	EthHeader
	LinkHeader        // always equals SNAP in EtherTalk
	SNAPProto         // always AppleTalkProto or AARPProto in EtherTalk
	Payload    []byte // marshaled ddp.Packet or aarp.Packet
	Pad        []byte
}

Combines all data in an EtherTalk packet.

EtherTalk packets contain:

  • an Ethernet header,
  • an LLC (Logical Link Control) header, which must equal the SNAP (Subnetwork Access Protocol) LinkHeader value,
  • the SNAP data, indicating either an AppleTalk (DDP) or AARP payload,
  • the DDP or AARP payload itself, and
  • optionally, extra padding as specified by the Ethernet header.

func AARP

func AARP(src ethernet.Addr, payload aarp.Packet) (*Packet, error)

func AppleTalk

func AppleTalk(src ethernet.Addr, payload ddp.ExtPacket) (*Packet, error)

type SNAPProto

type SNAPProto struct {
	OUI   [3]byte
	Proto uint16
}

Jump to

Keyboard shortcuts

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