nltest

package
v0.0.0-...-6ea0516 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2017 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package nltest provides utilities for netlink testing.

Index

Constants

View Source
const PID = 1

PID is the netlink header PID value assigned by nltest.

Variables

This section is empty.

Functions

func Dial

func Dial(fn Func) *netlink.Conn

Dial sets up a netlink.Conn for testing using the specified Func. All requests sent from the connection will be passed to the Func. The connection should be closed as usual when it is no longer needed.

func Error

func Error(number int, req netlink.Message) ([]netlink.Message, error)

Error returns a netlink error to the caller with the specified error number, in the body of the specified request message.

func Multipart

func Multipart(msgs []netlink.Message) ([]netlink.Message, error)

Multipart sends a slice of netlink.Messages to the caller as a netlink multi-part message. If less than two messages are present, the messages are not altered.

Types

type Func

type Func func(req netlink.Message) ([]netlink.Message, error)

A Func is a function that can be used to test netlink.Conn interactions. The function can choose to return zero or more netlink messages, or an error if needed.

For a netlink request/response interaction, a request req is populated by netlink.Conn.Send and passed to the function.

For multicast interactions, an empty request req is passed to the function when netlink.Conn.Receive is called.

If a Func returns an error, the error will be returned as-is to the caller. If no messages and io.EOF are returned, no messages and no error will be returned to the caller, simulating a multi-part message with no data.

Jump to

Keyboard shortcuts

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