Table unification #2

Merged
josh merged 6 commits from table-unification into main 2024-05-05 18:15:46 +10:00
2 changed files with 9 additions and 8 deletions
Showing only changes of commit 376c09d189 - Show all commits

View file

@ -102,8 +102,7 @@ func (port *EtherTalkPort) HandleRTMP(ctx context.Context, pkt *ddp.ExtPacket) e
} }
case rtmp.FunctionLoopProbe: case rtmp.FunctionLoopProbe:
log.Print("RTMP: TODO: handle Loop Probes") return fmt.Errorf("TODO: handle Loop Probes")
return nil
} }
case ddp.ProtoRTMPResp: case ddp.ProtoRTMPResp:
@ -122,7 +121,7 @@ func (port *EtherTalkPort) HandleRTMP(ctx context.Context, pkt *ddp.ExtPacket) e
for _, nt := range dataPkt.NetworkTuples { for _, nt := range dataPkt.NetworkTuples {
route, err := port.Router.RouteTable.UpsertEtherTalkRoute(peer, nt.Extended, nt.RangeStart, nt.RangeEnd, nt.Distance+1) route, err := port.Router.RouteTable.UpsertEtherTalkRoute(peer, nt.Extended, nt.RangeStart, nt.RangeEnd, nt.Distance+1)
if err != nil { if err != nil {
log.Printf("RTMP: Couldn't upsert EtherTalk route: %v", err) return fmt.Errorf("upsert EtherTalk route: %v", err)
} }
if len(route.ZoneNames) == 0 { if len(route.ZoneNames) == 0 {
noZones = append(noZones, route.NetStart) noZones = append(noZones, route.NetStart)
@ -149,11 +148,13 @@ func (port *EtherTalkPort) HandleRTMP(ctx context.Context, pkt *ddp.ExtPacket) e
}, },
Data: qryPkt, Data: qryPkt,
} }
port.Send(ctx, outDDP) if err := port.Send(ctx, outDDP); err != nil {
return fmt.Errorf("sending ZIP Query: %w", err)
}
} }
default: default:
log.Printf("RTMP: invalid DDP type %d on socket 1", pkt.Proto) return fmt.Errorf("invalid DDP type %d on socket 1", pkt.Proto)
} }
return nil return nil

View file

@ -52,7 +52,7 @@ func (port *EtherTalkPort) handleZIPZIP(ctx context.Context, ddpkt *ddp.ExtPacke
return port.handleZIPQuery(ctx, ddpkt, zipkt) return port.handleZIPQuery(ctx, ddpkt, zipkt)
case *zip.ReplyPacket: case *zip.ReplyPacket:
return port.handleZIPReply(ctx, zipkt) return port.handleZIPReply(zipkt)
case *zip.GetNetInfoPacket: case *zip.GetNetInfoPacket:
return port.handleZIPGetNetInfo(ctx, ddpkt, zipkt) return port.handleZIPGetNetInfo(ctx, ddpkt, zipkt)
@ -158,8 +158,8 @@ func (port *EtherTalkPort) handleZIPQuery(ctx context.Context, ddpkt *ddp.ExtPac
return nil return nil
} }
func (port *EtherTalkPort) handleZIPReply(ctx context.Context, zipkt *zip.ReplyPacket) error { func (port *EtherTalkPort) handleZIPReply(zipkt *zip.ReplyPacket) error {
log.Printf("ZIP: Got Reply for networks %v", zipkt.Networks) log.Printf("ZIP: Got Reply containing %v", zipkt.Networks)
// Integrate new zone information into route table. // Integrate new zone information into route table.
for n, zs := range zipkt.Networks { for n, zs := range zipkt.Networks {