1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
7 // A MessageBody represents an ICMP message body.
8 type MessageBody interface {
9 // Len returns the length of ICMP message body.
10 // The provided proto must be either the ICMPv4 or ICMPv6
14 // Marshal returns the binary encoding of ICMP message body.
15 // The provided proto must be either the ICMPv4 or ICMPv6
17 Marshal(proto int) ([]byte, error)
20 // A RawBody represents a raw message body.
22 // A raw message body is excluded from message processing and can be
23 // used to construct applications such as protocol conformance
29 // Len implements the Len method of MessageBody interface.
30 func (p *RawBody) Len(proto int) int {
37 // Marshal implements the Marshal method of MessageBody interface.
38 func (p *RawBody) Marshal(proto int) ([]byte, error) {
42 // parseRawBody parses b as an ICMP message body.
43 func parseRawBody(proto int, b []byte) (MessageBody, error) {
44 p := &RawBody{Data: make([]byte, len(b))}
49 // A DefaultMessageBody represents the default message body.
51 // Deprecated: Use RawBody instead.
52 type DefaultMessageBody = RawBody