FixLengths Option doesn't work for EAP Layer
- Dominant language
- Go
- Stars
- 6.8k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
This code sent EAPoL packet, but it doesn't work
Length field value of EAP field is 12 : it should be 16.
Length field value of 802.1X field is 0 : it should be 16.
```
func eapol_ResponseIdentity(handle *pcap.Handle, iface *net.Interface, id uint8, identity []byte) error {
//.len := 5 + uint16(len(identity))
eap1 := layers.EAP{
Code: layers.EAPCodeResponse,
Id: id,
Type: layers.EAPTypeIdentity,
TypeData: identity,
//.Length: len,
}
eapol := layers.EAPOL{
Version: 1,
Type: layers.EAPOLTypeEAP,
Length: eap1.Length,
}
eth := layers.Ethernet{
SrcMAC: iface.HardwareAddr,
DstMAC: net.HardwareAddr{0x01, 0x80, 0xc2, 0x00, 0x00, 0x03},
EthernetType: layers.EthernetTypeEAPOL,
}
buf := gopacket.NewSerializeBuffer()
opts := gopacket.SerializeOptions{
FixLengths: true,
//.FixLengths: false,
ComputeChecksums: true,
}
gopacket.SerializeLayers(buf, opts, ð, &eapol, &eap1)
log.Printf("send EOPoL : Response Identity %v, %s...", id, string(identity))
if err := handle.WritePacketData(buf.Bytes()); err != nil {
log.Printf("Send err ", err)
return err
}
//log.Printf("send packet [OK]")
return nil
}
```
I think problem come from calculation of Length field value of EAP field.
If you uncomment lines with "//.", code works... but it isn't normal to do it...
Contributor guide
Assessment
This issue has not been assessed yet.