If IPv4 is in question and I want to extract IP and ICMP header out of std::istream, first I get the initial 20 bytes, then check if the header lenght provided in the IPv4 header is larger than 20 bytes in order to extract any options. The next bytes are the ICMP packet. Using the header lenght value carried inside the IPv4 header I can see the expect size of the IP header.
However how to get the exact size of IPv6 header? There is a payload value inside IPv6 header that includes the size of header extensions plus higher level data such as ICMP. I need to know the size of IPv6 header including the header extensions but without higher level data, in order to know at what position the ICMPv6 header starts in the std::istream.
Thank you!