This commit is contained in:
Josh Deprez 2024-04-13 15:27:41 +10:00
parent e91dfcc3d9
commit 5abfe17837
Signed by: josh
SSH key fingerprint: SHA256:zZji7w1Ilh2RuUpbQcqkLPrqmRwpiCSycbF2EfKm6Kw
3 changed files with 9 additions and 2 deletions

View file

@ -136,7 +136,7 @@ func (a *AARPMachine) Run(ctx context.Context, incomingCh <-chan *ethertalk.Pack
log.Printf("AARP: Who has %v? Tell %v", aapkt.Dst.Proto, aapkt.Src.Proto)
// Glean that aapkt.Src.Proto -> aapkt.Src.Hardware
a.addressMappingTable.Learn(aapkt.Src.Proto, aapkt.Src.Hardware)
log.Printf("AARP: Gleaned that %v -> %v", aapkt.Src.Proto, aapkt.Src.Hardware)
log.Printf("AARP: Gleaned that %d.%d -> %v", aapkt.Src.Proto.Network, aapkt.Src.Proto.Node, aapkt.Src.Hardware)
if !(aapkt.Dst.Proto == a.myAddr.Proto && a.assigned) {
continue

View file

@ -84,6 +84,8 @@ type DomainIdentifier interface {
// NullDomainIdentifier represents a null domain identifier.
type NullDomainIdentifier struct{}
func (NullDomainIdentifier) String() string { return "(null DI)" }
// WriteTo writes the encoded form of the domain identifier to w.
func (NullDomainIdentifier) WriteTo(w io.Writer) (int64, error) {
n, err := w.Write([]byte{0x01, 0x00})
@ -93,6 +95,8 @@ func (NullDomainIdentifier) WriteTo(w io.Writer) (int64, error) {
// IPDomainIdentifier represents an IP address in a domain identifier.
type IPDomainIdentifier net.IP
func (i IPDomainIdentifier) String() string { return net.IP(i).String() }
// WriteTo writes the encoded form of the domain identifier to w.
func (i IPDomainIdentifier) WriteTo(w io.Writer) (int64, error) {
v4 := net.IP(i).To4()

View file

@ -224,10 +224,11 @@ func main() {
ddpkt.SrcNet, ddpkt.SrcNode, ddpkt.SrcSocket,
ddpkt.DstNet, ddpkt.DstNode, ddpkt.DstSocket,
ddpkt.Proto, len(ddpkt.Data))
// Glean address info for AMT
srcAddr := ddp.Addr{Network: ddpkt.SrcNet, Node: ddpkt.SrcNode}
aarpMachine.Learn(srcAddr, ethFrame.Src)
log.Printf("DDP: Gleaned that %v -> %v", srcAddr, ethFrame.Src)
log.Printf("DDP: Gleaned that %d.%d -> %v", srcAddr.Network, srcAddr.Node, ethFrame.Src)
// Packet for us? First, who am I?
myAddr, ok := aarpMachine.Address()
@ -249,10 +250,12 @@ func main() {
// Is it for a network in the routing table?
rt := lookupRoute(ddpkt.DstNet)
if rt == nil {
log.Printf("DDP: no route for network %d", ddpkt.DstNet)
continue
}
// Encap ethPacket.Payload into an AURP packet
log.Printf("DDP: forwarding to AURP peer %v", rt.peer.tr.RemoteDI)
if _, err := rt.peer.send(rt.peer.tr.NewAppleTalkPacket(ethFrame.Payload)); err != nil {
log.Printf("DDP: Couldn't forward packet to AURP peer: %v", err)
}