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 // Proto must be either the ICMPv4 or ICMPv6 protocol number.
13 // Marshal returns the binary encoding of ICMP message body.
14 // Proto must be either the ICMPv4 or ICMPv6 protocol number.
15 Marshal(proto int) ([]byte, error)
18 // A DefaultMessageBody represents the default message body.
19 type DefaultMessageBody struct {
23 // Len implements the Len method of MessageBody interface.
24 func (p *DefaultMessageBody) Len(proto int) int {
31 // Marshal implements the Marshal method of MessageBody interface.
32 func (p *DefaultMessageBody) Marshal(proto int) ([]byte, error) {
36 // parseDefaultMessageBody parses b as an ICMP message body.
37 func parseDefaultMessageBody(proto int, b []byte) (MessageBody, error) {
38 p := &DefaultMessageBody{Data: make([]byte, len(b))}