Commit e3b9e70d authored by Mikio Hara's avatar Mikio Hara

icmp: add support for multi-part messages

ICMP extension structures allow a few existing ICMP error messages to
convey extra information for troubleshooting; especially the root cause
of why the original datagram could not be delivered.

This CL adds generic support for ICMP extension stuructures to
DstUnreach, TimeExceeded and ParamProb structs. Specific extensions such
as MPLS label-stack, interface and next-hop identification will be
inplemneted in separate followup CLs.

Change-Id: I90798c135bdf76b806e2dde2bdd57c2c11d7e7e9
parent 0000f67a
...@@ -7,7 +7,8 @@ package icmp ...@@ -7,7 +7,8 @@ package icmp
// A DstUnreach represents an ICMP destination unreachable message // A DstUnreach represents an ICMP destination unreachable message
// body. // body.
type DstUnreach struct { type DstUnreach struct {
Data []byte // data Data []byte // data, known as original datagram field
Extensions []Extension // extensions
} }
// Len implements the Len method of MessageBody interface. // Len implements the Len method of MessageBody interface.
......
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package icmp
// An Extension represents an ICMP extension.
type Extension interface {
// Len returns the length of ICMP extension.
Len() int
// Marshal returns the binary enconding of ICMP extension.
Marshal() ([]byte, error)
}
const extensionVersion = 2
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
// ICMPv4 and ICMPv6. // ICMPv4 and ICMPv6.
// //
// ICMPv4 and ICMPv6 are defined in RFC 792 and RFC 4443. // ICMPv4 and ICMPv6 are defined in RFC 792 and RFC 4443.
// Multi-part message support for ICMP is defined in RFC 4884.
package icmp // import "golang.org/x/net/icmp" package icmp // import "golang.org/x/net/icmp"
import ( import (
......
...@@ -9,7 +9,8 @@ import "golang.org/x/net/internal/iana" ...@@ -9,7 +9,8 @@ import "golang.org/x/net/internal/iana"
// A ParamProb represents an ICMP parameter problem message body. // A ParamProb represents an ICMP parameter problem message body.
type ParamProb struct { type ParamProb struct {
Pointer uintptr // offset within the data where the error was detected Pointer uintptr // offset within the data where the error was detected
Data []byte // data Data []byte // data, known as original datagram field
Extensions []Extension // extensions
} }
// Len implements the Len method of MessageBody interface. // Len implements the Len method of MessageBody interface.
......
...@@ -6,7 +6,8 @@ package icmp ...@@ -6,7 +6,8 @@ package icmp
// A TimeExceeded represents an ICMP time exceeded message body. // A TimeExceeded represents an ICMP time exceeded message body.
type TimeExceeded struct { type TimeExceeded struct {
Data []byte // data Data []byte // data, known as original datagram field
Extensions []Extension // extensions
} }
// Len implements the Len method of MessageBody interface. // Len implements the Len method of MessageBody interface.
......
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