WIP
This commit is contained in:
parent
0c86aa6194
commit
5e48bdf880
1 changed files with 23 additions and 9 deletions
32
zip.go
32
zip.go
|
@ -112,7 +112,6 @@ func handleZIP(pcapHandle *pcap.Handle, srcHWAddr, myHWAddr ethernet.Addr, myAdd
|
||||||
Extended: false,
|
Extended: false,
|
||||||
Networks: zones.Query(zipkt.Networks),
|
Networks: zones.Query(zipkt.Networks),
|
||||||
}
|
}
|
||||||
// TODO: direct to queryer
|
|
||||||
|
|
||||||
case *zip.GetNetInfoPacket:
|
case *zip.GetNetInfoPacket:
|
||||||
// Only running a network with one zone for now.
|
// Only running a network with one zone for now.
|
||||||
|
@ -139,7 +138,6 @@ func handleZIP(pcapHandle *pcap.Handle, srcHWAddr, myHWAddr ethernet.Addr, myAdd
|
||||||
return fmt.Errorf("couldn't marshal %T: %w", resp, err)
|
return fmt.Errorf("couldn't marshal %T: %w", resp, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: fix
|
|
||||||
// "In cases where a node's provisional address is
|
// "In cases where a node's provisional address is
|
||||||
// invalid, routers will not be able to respond to
|
// invalid, routers will not be able to respond to
|
||||||
// the node in a directed manner. An address is
|
// the node in a directed manner. An address is
|
||||||
|
@ -148,16 +146,32 @@ func handleZIP(pcapHandle *pcap.Handle, srcHWAddr, myHWAddr ethernet.Addr, myAdd
|
||||||
// assigned to the node's network. In these cases,
|
// assigned to the node's network. In these cases,
|
||||||
// if the request was sent via a broadcast, the
|
// if the request was sent via a broadcast, the
|
||||||
// routers should respond with a broadcast."
|
// routers should respond with a broadcast."
|
||||||
ddpkt.DstNet, ddpkt.DstNode, ddpkt.DstSocket = 0x0000, 0xFF, ddpkt.SrcSocket
|
outDDP := ddp.ExtPacket{
|
||||||
ddpkt.SrcNet = myAddr.Proto.Network
|
ExtHeader: ddp.ExtHeader{
|
||||||
ddpkt.SrcNode = myAddr.Proto.Node
|
DstNet: ddpkt.SrcNet,
|
||||||
ddpkt.SrcSocket = 6
|
DstNode: ddpkt.SrcNode,
|
||||||
ddpkt.Data = respRaw
|
DstSocket: ddpkt.SrcSocket,
|
||||||
outFrame, err := ethertalk.AppleTalk(myHWAddr, *ddpkt)
|
SrcNet: myAddr.Proto.Network,
|
||||||
|
SrcNode: myAddr.Proto.Node,
|
||||||
|
SrcSocket: 6,
|
||||||
|
},
|
||||||
|
Data: respRaw,
|
||||||
|
}
|
||||||
|
if ddpkt.DstNet == 0x0000 {
|
||||||
|
outDDP.DstNet = 0x0000
|
||||||
|
}
|
||||||
|
if ddpkt.DstNode == 0xFF {
|
||||||
|
outDDP.DstNode = 0xFF
|
||||||
|
}
|
||||||
|
|
||||||
|
outFrame, err := ethertalk.AppleTalk(myHWAddr, outDDP)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("couldn't create EtherTalk frame: %w", err)
|
return fmt.Errorf("couldn't create EtherTalk frame: %w", err)
|
||||||
}
|
}
|
||||||
outFrame.Dst = srcHWAddr
|
// If it's a broadcast packet, broadcast it. Otherwise don't?
|
||||||
|
if outDDP.DstNet != 0x0000 || outDDP.DstNode != 0xFF {
|
||||||
|
outFrame.Dst = srcHWAddr
|
||||||
|
}
|
||||||
outFrameRaw, err := ethertalk.Marshal(*outFrame)
|
outFrameRaw, err := ethertalk.Marshal(*outFrame)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("couldn't marshal EtherTalk frame: %w", err)
|
return fmt.Errorf("couldn't marshal EtherTalk frame: %w", err)
|
||||||
|
|
Loading…
Reference in a new issue