[WIP] AARP responses
This commit is contained in:
parent
fc5b07b975
commit
345bee4979
2 changed files with 23 additions and 3 deletions
|
@ -4,11 +4,8 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/google/gopacket/pcap"
|
||||
"github.com/sfiera/multitalk/pkg/ethernet"
|
||||
)
|
||||
|
||||
var MulticastDst = ethernet.Addr{0x09, 0x00, 0x07, 0xff, 0xff, 0xff}
|
||||
|
||||
// StartPcap opens an AppleTalk and AARP listening session on a network device.
|
||||
func StartPcap(device string) (*pcap.Handle, error) {
|
||||
handle, err := pcap.OpenLive(device, 4096, true, pcap.BlockForever)
|
||||
|
|
23
main.go
23
main.go
|
@ -202,6 +202,29 @@ func main() {
|
|||
amt.Learn(aapkt.Src.Proto, aapkt.Src.Hardware)
|
||||
log.Printf("AARP: Gleaned that %v -> %v", aapkt.Src.Proto, aapkt.Src.Hardware)
|
||||
|
||||
if aapkt.Dst.Proto != localDDPAddr {
|
||||
continue
|
||||
}
|
||||
// Respond!
|
||||
respFrame, err := ethertalk.AARP(localMAC, aarp.Response(aapkt.Src, aarp.AddrPair{
|
||||
Proto: localDDPAddr,
|
||||
Hardware: localMAC,
|
||||
}))
|
||||
if err != nil {
|
||||
log.Printf("Couldn't construct AARP Response: %v", err)
|
||||
continue
|
||||
}
|
||||
respFrame.Dst = ethFrame.Src
|
||||
respFrameRaw, err := ethertalk.Marshal(*respFrame)
|
||||
if err != nil {
|
||||
log.Printf("Couldn't marshal AARP Response: %v", err)
|
||||
continue
|
||||
}
|
||||
if err := handle.WritePacketData(respFrameRaw); err != nil {
|
||||
log.Printf("Couldn't write packet data: %v", err)
|
||||
continue
|
||||
}
|
||||
|
||||
case aarp.ResponseOp:
|
||||
log.Printf("AARP: %v is at %v", aapkt.Dst.Proto, aapkt.Dst.Hardware)
|
||||
amt.Learn(aapkt.Dst.Proto, aapkt.Dst.Hardware)
|
||||
|
|
Loading…
Reference in a new issue