mirror of
https://github.com/maride/pancap.git
synced 2024-11-22 08:54:24 +00:00
Fix 'DHCPv4 length 0 too short' error
This commit is contained in:
parent
4bb9dad91e
commit
a1281360cd
@ -18,8 +18,15 @@ func HandleDHCPv4Packet(packet gopacket.Packet) error {
|
|||||||
var dhcppacket layers.DHCPv4
|
var dhcppacket layers.DHCPv4
|
||||||
var ethernetpacket layers.Ethernet
|
var ethernetpacket layers.Ethernet
|
||||||
|
|
||||||
|
// For some reason I can't find an explanation for,
|
||||||
|
// packet.Layer(layers.LayerTypeDHCPv4).LayerContents(), which effectively is
|
||||||
|
// packet.Layers()[3].layerContents(), is empty, but
|
||||||
|
// packet.Layers()[2].layerPayload() contains the correct DHCP packet.
|
||||||
|
// ... although both calls should return the same bytes.
|
||||||
|
// TODO: Open an Issue on github.com/google/gopacket
|
||||||
|
|
||||||
// Decode raw packet into DHCPv4
|
// Decode raw packet into DHCPv4
|
||||||
decodeDHCPErr := dhcppacket.DecodeFromBytes(packet.Layer(layers.LayerTypeDHCPv4).LayerContents(), gopacket.NilDecodeFeedback)
|
decodeDHCPErr := dhcppacket.DecodeFromBytes(packet.Layers()[2].LayerPayload(), gopacket.NilDecodeFeedback)
|
||||||
if decodeDHCPErr != nil {
|
if decodeDHCPErr != nil {
|
||||||
// Encountered an error during decoding, most likely a broken packet
|
// Encountered an error during decoding, most likely a broken packet
|
||||||
return decodeDHCPErr
|
return decodeDHCPErr
|
||||||
|
Loading…
Reference in New Issue
Block a user