|
@@ -51,6 +51,10 @@ func (h *Header) String() string {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Marshal returns the binary encoding of h.
|
|
// Marshal returns the binary encoding of h.
|
|
|
|
|
+//
|
|
|
|
|
+// The returned slice is in the format used by a raw IP socket on the
|
|
|
|
|
+// local system.
|
|
|
|
|
+// This may differ from the wire format, depending on the system.
|
|
|
func (h *Header) Marshal() ([]byte, error) {
|
|
func (h *Header) Marshal() ([]byte, error) {
|
|
|
if h == nil {
|
|
if h == nil {
|
|
|
return nil, errInvalidConn
|
|
return nil, errInvalidConn
|
|
@@ -98,6 +102,10 @@ func (h *Header) Marshal() ([]byte, error) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Parse parses b as an IPv4 header and stores the result in h.
|
|
// Parse parses b as an IPv4 header and stores the result in h.
|
|
|
|
|
+//
|
|
|
|
|
+// The provided b must be in the format used by a raw IP socket on the
|
|
|
|
|
+// local system.
|
|
|
|
|
+// This may differ from the wire format, depending on the system.
|
|
|
func (h *Header) Parse(b []byte) error {
|
|
func (h *Header) Parse(b []byte) error {
|
|
|
if h == nil || len(b) < HeaderLen {
|
|
if h == nil || len(b) < HeaderLen {
|
|
|
return errHeaderTooShort
|
|
return errHeaderTooShort
|
|
@@ -149,6 +157,10 @@ func (h *Header) Parse(b []byte) error {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// ParseHeader parses b as an IPv4 header.
|
|
// ParseHeader parses b as an IPv4 header.
|
|
|
|
|
+//
|
|
|
|
|
+// The provided b must be in the format used by a raw IP socket on the
|
|
|
|
|
+// local system.
|
|
|
|
|
+// This may differ from the wire format, depending on the system.
|
|
|
func ParseHeader(b []byte) (*Header, error) {
|
|
func ParseHeader(b []byte) (*Header, error) {
|
|
|
h := new(Header)
|
|
h := new(Header)
|
|
|
if err := h.Parse(b); err != nil {
|
|
if err := h.Parse(b); err != nil {
|