Ensure frame padding

This commit is contained in:
Josh Deprez 2024-08-10 16:15:11 +10:00
parent 0f8297e670
commit 100d70dccf
Signed by: josh
SSH key fingerprint: SHA256:zZji7w1Ilh2RuUpbQcqkLPrqmRwpiCSycbF2EfKm6Kw
3 changed files with 15 additions and 0 deletions

View file

@ -337,6 +337,9 @@ func (a *AARPMachine) heyThatsMe(targ aarp.AddrPair) error {
if err != nil {
return err
}
if len(respFrameRaw) < 64 {
respFrameRaw = append(respFrameRaw, make([]byte, 64-len(respFrameRaw))...)
}
return a.pcapHandle.WritePacketData(respFrameRaw)
}
@ -350,6 +353,9 @@ func (a *AARPMachine) probe() error {
if err != nil {
return err
}
if len(probeFrameRaw) < 64 {
probeFrameRaw = append(probeFrameRaw, make([]byte, 64-len(probeFrameRaw))...)
}
return a.pcapHandle.WritePacketData(probeFrameRaw)
}
@ -363,6 +369,9 @@ func (a *AARPMachine) request(ddpAddr ddp.Addr) error {
if err != nil {
return err
}
if len(reqFrameRaw) < 64 {
reqFrameRaw = append(reqFrameRaw, make([]byte, 64-len(reqFrameRaw))...)
}
return a.pcapHandle.WritePacketData(reqFrameRaw)
}

View file

@ -46,5 +46,8 @@ func (p *EtherTalkPeer) Forward(ctx context.Context, pkt *ddp.ExtPacket) error {
if err != nil {
return err
}
if len(outFrameRaw) < 64 {
outFrameRaw = append(outFrameRaw, make([]byte, 64-len(outFrameRaw))...)
}
return p.Port.PcapHandle.WritePacketData(outFrameRaw)
}

View file

@ -200,5 +200,8 @@ func (port *EtherTalkPort) send(dstEth ethernet.Addr, pkt *ddp.ExtPacket) error
if err != nil {
return err
}
if len(outFrameRaw) < 64 {
outFrameRaw = append(outFrameRaw, make([]byte, 64-len(outFrameRaw))...)
}
return port.PcapHandle.WritePacketData(outFrameRaw)
}