Compare commits

..

No commits in common. "0d92cd7ba6e8598654936500582bcfdfc48a3e8e" and "7f9a15bff1fb44a2da838ffc998a9e9587aabda0" have entirely different histories.

3 changed files with 4 additions and 57 deletions

View file

@ -35,15 +35,6 @@ const (
FunctionFwdReq Function = 4 FunctionFwdReq Function = 4
) )
func (f Function) String() string {
return map[Function]string{
FunctionBrRq: "BrRq",
FunctionLkUp: "LkUp",
FunctionLkUpReply: "LkUp-Reply",
FunctionFwdReq: "FwdReq",
}[f]
}
// Packet represents an NBP packet. // Packet represents an NBP packet.
type Packet struct { type Packet struct {
Function Function // top 4 bits of first byte Function Function // top 4 bits of first byte

19
main.go
View file

@ -169,14 +169,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 {
@ -214,8 +206,8 @@ func main() {
case ethertalk.AppleTalkProto: case ethertalk.AppleTalkProto:
// log.Print("Got an AppleTalk frame") // log.Print("Got an AppleTalk frame")
ddpkt := new(ddp.ExtPacket) var ddpkt ddp.ExtPacket
if err := ddp.ExtUnmarshal(ethFrame.Payload, ddpkt); err != nil { if err := ddp.ExtUnmarshal(ethFrame.Payload, &ddpkt); err != nil {
log.Printf("Couldn't unmarshal DDP packet: %v", err) log.Printf("Couldn't unmarshal DDP packet: %v", err)
continue continue
} }
@ -253,13 +245,10 @@ func main() {
switch ddpkt.DstSocket { switch ddpkt.DstSocket {
case 1: // The RTMP socket case 1: // The RTMP socket
rtmpCh <- ddpkt rtmpCh <- &ddpkt
case 2: // The NIS (NBP socket)
nbpCh <- ddpkt
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 {
log.Printf("AEP: Couldn't handle: %v", err) log.Printf("AEP: Couldn't handle: %v", err)
} }

33
nbp.go
View file

@ -1,33 +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:
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)
}
}
}