Skip to content

Commit

Permalink
fix: 部分虚拟网卡模式下,arp包需要no-padding
Browse files Browse the repository at this point in the history
  • Loading branch information
XinRoom committed Dec 5, 2022
1 parent 1152e76 commit 9de1f2f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion core/port/syn/syn.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func (ss *synScanner) getHwAddrV4(arpDst net.IP) (mac net.HardwareAddr, err erro
DstProtAddress: []byte(arpDst),
}

if err = ss.send(&eth, &arp); err != nil {
if err = ss.sendArp(&eth, &arp); err != nil {
return nil, err
}

Expand Down Expand Up @@ -303,6 +303,19 @@ func (ss *synScanner) send(l ...gopacket.SerializableLayer) error {
return ss.handle.WritePacketData(buf.Bytes())
}

// send sends the given layers as a single packet on the network., need fix padding
func (ss *synScanner) sendArp(l ...gopacket.SerializableLayer) error {
buf := ss.bufPool.Get().(gopacket.SerializeBuffer)
defer func() {
buf.Clear()
ss.bufPool.Put(buf)
}()
if err := gopacket.SerializeLayers(buf, ss.opts, l...); err != nil {
return err
}
return ss.handle.WritePacketData(buf.Bytes()[:42]) // need fix padding
}

// recv packet on the network.
func (ss *synScanner) recv() {
eth := layers.Ethernet{
Expand Down

0 comments on commit 9de1f2f

Please sign in to comment.