Open cang233 opened 4 years ago
According to source code,use -> as "point to",then p.ether->0, p.ipv4->14,
func (packet *Packet) unparsed() unsafe.Pointer {
ether := unsafe.Pointer(packet.Ether)
return unsafe.Pointer(uintptr(ether) + types.EtherLen)
}
p.tcp->34,header length is 20 here according to the screenshot,and code excatly compute correctly.
func (packet *Packet) ParseL4ForIPv4() {
packet.L4 = unsafe.Pointer(uintptr(packet.L3) + uintptr((packet.GetIPv4NoCheck().VersionIhl&0x0f)<<2))
}
But the tcp head length flag in the packet is 28,nff-go is also not wrong. Seems that it does excce the allowed length.
code:
I read the source code and find that GetRawPacketBytes() only get mbuf length in one CMbuf struct,but ParseData parse all packets' payload if scattered?
Now update the pkt I capture,covert function is used to print the raw bytes as below.
and I save the packet .pcap as follows: