Remove NBP machine for now
This commit is contained in:
parent
5abfe17837
commit
23f9633b1e
2 changed files with 18 additions and 46 deletions
27
main.go
27
main.go
|
@ -170,14 +170,6 @@ func main() {
|
||||||
rtmpCh := make(chan *ddp.ExtPacket, 1024)
|
rtmpCh := make(chan *ddp.ExtPacket, 1024)
|
||||||
go rtmpMachine.Run(ctx, rtmpCh)
|
go rtmpMachine.Run(ctx, rtmpCh)
|
||||||
|
|
||||||
// ---------------------------------- NBP ---------------------------------
|
|
||||||
nbpMachine := &NBPMachine{
|
|
||||||
aarp: aarpMachine,
|
|
||||||
pcapHandle: pcapHandle,
|
|
||||||
}
|
|
||||||
nbpCh := make(chan *ddp.ExtPacket, 1024)
|
|
||||||
go nbpMachine.Run(ctx, nbpCh)
|
|
||||||
|
|
||||||
// ---------------------- Raw AppleTalk/AARP inbound ----------------------
|
// ---------------------- Raw AppleTalk/AARP inbound ----------------------
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
|
@ -276,7 +268,24 @@ func main() {
|
||||||
rtmpCh <- ddpkt
|
rtmpCh <- ddpkt
|
||||||
|
|
||||||
case 2: // The NIS (NBP socket)
|
case 2: // The NIS (NBP socket)
|
||||||
nbpCh <- ddpkt
|
if ddpkt.Proto != ddp.ProtoNBP {
|
||||||
|
log.Printf("NBP: invalid DDP type %d on socket 2", ddpkt.Proto)
|
||||||
|
}
|
||||||
|
|
||||||
|
nbpkt, err := nbp.Unmarshal(ddpkt.Data)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("NBP: invalid packet: %v", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("NBP: Got %v id %d with tuples %v", nbpkt.Function, nbpkt.NBPID, nbpkt.Tuples)
|
||||||
|
|
||||||
|
// Is it a BrRq?
|
||||||
|
if nbpkt.Function == nbp.FunctionBrRq {
|
||||||
|
// TODO: Translate it into a FwdReq and route it to the
|
||||||
|
// routers with the appropriate zone(s).
|
||||||
|
log.Print("NBP: TODO: BrRq-FwdReq translation")
|
||||||
|
}
|
||||||
|
|
||||||
case 4: // The AEP socket
|
case 4: // The AEP socket
|
||||||
if err := handleAEP(pcapHandle, myHWAddr, ethFrame.Src, ddpkt); err != nil {
|
if err := handleAEP(pcapHandle, myHWAddr, ethFrame.Src, ddpkt); err != nil {
|
||||||
|
|
37
nbp.go
37
nbp.go
|
@ -1,37 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"log"
|
|
||||||
|
|
||||||
"gitea.drjosh.dev/josh/jrouter/atalk/nbp"
|
|
||||||
"github.com/google/gopacket/pcap"
|
|
||||||
"github.com/sfiera/multitalk/pkg/ddp"
|
|
||||||
)
|
|
||||||
|
|
||||||
type NBPMachine struct {
|
|
||||||
aarp *AARPMachine
|
|
||||||
pcapHandle *pcap.Handle
|
|
||||||
}
|
|
||||||
|
|
||||||
func (NBPMachine) Run(ctx context.Context, incoming <-chan *ddp.ExtPacket) error {
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case <-ctx.Done():
|
|
||||||
return ctx.Err()
|
|
||||||
|
|
||||||
case ddpkt := <-incoming:
|
|
||||||
if ddpkt.Proto != ddp.ProtoNBP {
|
|
||||||
log.Printf("NBP: invalid DDP type %d on socket 2", ddpkt.Proto)
|
|
||||||
}
|
|
||||||
|
|
||||||
pkt, err := nbp.Unmarshal(ddpkt.Data)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("NBP: invalid packet: %v", err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
// TODO:
|
|
||||||
log.Printf("NBP: Got %v", pkt.Function)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue