我尝试发送请求身份 EAPoL 数据包:
func eapol_requestIdentity(handle *pcap.Handle, iface *net.Interface, id uint8) error {
len := uint16(5) // eap1 field length
eap1 := layers.EAP{
Code: layers.EAPCodeResponse,
Id: id,
Type: layers.EAPTypeIdentity,
TypeData: []byte{byte(layers.EAPTypeIdentity)}, // bugfix
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, // doesn't work
FixLengths: false,
ComputeChecksums: true,
}
gopacket.SerializeLayers(buf, opts, ð, &eapol, &eap1)
log.Printf("send EOPoL : Request Identity %u...", id)
if err := handle.WritePacketData(buf.Bytes()); err != nil {
log.Printf("Send err ", err)
return err
}
log.Printf("send packet [OK]")
return nil
}
我不明白:如果我删除 lineTypeData: [] byte{byte(layers.EAPTypeIdentity)}
或 line Type: layers.EAPTypeIdentity
,我的应用程序发送了错误的数据包。正常吗?...为什么我必须为数据包中的同一字节设置两次数据?
另外,我尝试将 FixLengths 设置为 true,但是长度字段在发送的数据包中是错误的......