Open gongjw123 opened 5 years ago
Mby something like DecodeLayers(gre.Payload[8:], &decodedLayers) and check LayerTypeIPv4, LayerTypeIPv6 again?
I am having a similar issue, it seems like go packet caches the IPv4 layer or something. In the GRE packets that I am seeing there are 2 IPv4 layers but both of them have the same IPs. If I collect the layers and print them out it shows that there are additional layers after GRE but printing out the details of the IPv4 layer just print the same thing twice. For example:
Layers - Ethernet,Dot1Q,IPv4,GRE,IPv4,UDP,Payload First IPv4Layer - layer: IPv4, proto: 47, srcip: 1.2.3.4, dstip: 1.2.3.5 Second IPv4Layer - layer: IPv4, proto: 47, srcip: 1.2.3.4, dstip: 1.2.3.5
I changed the IPs but the point is the first IPv4 layer and second IPv4 layer are the same. You can't seem to get the inner IP information.
gre := packet.Layer(layers.LayerTypeGRE).(layers.GRE) innerPacket = gopacket.NewPacket(gre.Payload, gre.NextLayerType(), gopacket.Default) innerPacket.Layer(layers.LayerTypeIPv4).(layers.IPv4)
use "ipLayer := packet.Layer(layers.LayerTypeIPv4)" i can get outer ip, but i want to know how to get inner IP in GRE or IPIP Thanks~