ipv4

package
v0.0.0-...-a6dae5b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2017 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package ipv4 contains the implementation of the ipv4 network protocol. To use it in the networking stack, this package must be added to the project, and activated on the stack by passing ipv4.ProtocolName (or "ipv4") as one of the network protocols when calling stack.New(). Then endpoints can be created by passing ipv4.ProtocolNumber as the network protocol number when calling Stack.NewEndpoint().

Index

Constants

View Source
const (
	// ProtocolName is the string representation of the ipv4 protocol name.
	ProtocolName = "ipv4"

	// ProtocolNumber is the ipv4 protocol number.
	ProtocolNumber = header.IPv4ProtocolNumber
)
View Source
const PingProtocolName = "icmpv4ping"

PingProtocolName is a pseudo transport protocol used to handle ping replies. Use it when constructing a stack that intends to use ipv4.Ping.

Variables

This section is empty.

Functions

func NewProtocol

func NewProtocol() stack.NetworkProtocol

NewProtocol creates a new protocol ipv4 protocol descriptor. This is exported only for tests that short-circuit the stack. Regular use of the protocol is done via the stack, which gets a protocol descriptor from the init() function below.

Types

type PingReply

type PingReply struct {
	Error     error // reports any errors sending a ping request
	Duration  time.Duration
	SeqNumber uint16
}

PingReply summarizes an ICMP echo reply.

type Pinger

type Pinger struct {
	Stack     *stack.Stack
	NICID     tcpip.NICID
	Addr      tcpip.Address
	LocalAddr tcpip.Address // optional
	Wait      time.Duration // if zero, defaults to 1 second
	Count     uint16        // if zero, defaults to MaxUint16
}

A Pinger can send echo requests to an address.

func (*Pinger) Ping

func (p *Pinger) Ping(ctx context.Context, ch chan<- PingReply) error

Ping sends echo requests to an ICMPv4 endpoint. Responses are streamed to the channel ch.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL