Commit f9ce57c1 authored by Mikio Hara's avatar Mikio Hara

icmp: clarify the format used by raw ICMP socket

On BSD variaints, for some historical reason, the data format used by raw
ICMP socket may differ from the IPv4 wire format and the format used by
raw IP socket. This change clarifies that input of ParseIPv4Header must
conform to the raw ICMP socket format.

Change-Id: I7288eccaaae0662d0437794098c8f7fc4a55d81e
Reviewed-on: https://go-review.googlesource.com/128216Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent b6095f65
......@@ -17,8 +17,16 @@ import (
// See http://www.freebsd.org/doc/en/books/porters-handbook/freebsd-versions.html.
var freebsdVersion uint32
// ParseIPv4Header parses b as an IPv4 header of ICMP error message
// invoking packet, which is contained in ICMP error message.
// ParseIPv4Header returns the IPv4 header of the IPv4 packet that
// triggered an ICMP error message.
// This is found in the Data field of the ICMP error message body.
//
// The provided b must be in the format used by a raw ICMP socket on
// the local system.
// This may differ from the wire format, and the format used by a raw
// IP socket, depending on the system.
//
// To parse an IPv6 header, use ipv6.ParseHeader.
func ParseIPv4Header(b []byte) (*ipv4.Header, error) {
if len(b) < ipv4.HeaderLen {
return nil, errHeaderTooShort
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment