Compare commits
No commits in common. "0d92cd7ba6e8598654936500582bcfdfc48a3e8e" and "7f9a15bff1fb44a2da838ffc998a9e9587aabda0" have entirely different histories.
0d92cd7ba6
...
7f9a15bff1
3 changed files with 4 additions and 57 deletions
|
@ -35,15 +35,6 @@ const (
|
|||
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.
|
||||
type Packet struct {
|
||||
Function Function // top 4 bits of first byte
|
||||
|
|
19
main.go
19
main.go
|
@ -169,14 +169,6 @@ func main() {
|
|||
rtmpCh := make(chan *ddp.ExtPacket, 1024)
|
||||
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 ----------
|
||||
go func() {
|
||||
for {
|
||||
|
@ -214,8 +206,8 @@ func main() {
|
|||
|
||||
case ethertalk.AppleTalkProto:
|
||||
// log.Print("Got an AppleTalk frame")
|
||||
ddpkt := new(ddp.ExtPacket)
|
||||
if err := ddp.ExtUnmarshal(ethFrame.Payload, ddpkt); err != nil {
|
||||
var ddpkt ddp.ExtPacket
|
||||
if err := ddp.ExtUnmarshal(ethFrame.Payload, &ddpkt); err != nil {
|
||||
log.Printf("Couldn't unmarshal DDP packet: %v", err)
|
||||
continue
|
||||
}
|
||||
|
@ -253,13 +245,10 @@ func main() {
|
|||
|
||||
switch ddpkt.DstSocket {
|
||||
case 1: // The RTMP socket
|
||||
rtmpCh <- ddpkt
|
||||
|
||||
case 2: // The NIS (NBP socket)
|
||||
nbpCh <- ddpkt
|
||||
rtmpCh <- &ddpkt
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
|
|
33
nbp.go
33
nbp.go
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue