checker

package
v0.0.0-...-55fcc16 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2019 License: Apache-2.0 Imports: 7 Imported by: 8

Documentation

Overview

Package checker provides helper functions to check networking packets for validity.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IPv4

func IPv4(t *testing.T, b []byte, checkers ...NetworkChecker)

IPv4 checks the validity and properties of the given IPv4 packet. It is expected to be used in conjunction with other network checkers for specific properties. For example, to check the source and destination address, one would call:

checker.IPv4(t, b, checker.SrcAddr(x), checker.DstAddr(y))

func IPv6

func IPv6(t *testing.T, b []byte, checkers ...NetworkChecker)

IPv6 checks the validity and properties of the given IPv6 packet. The usage is similar to IPv4.

Types

type NetworkChecker

type NetworkChecker func(*testing.T, []header.Network)

NetworkChecker is a function to check a property of a network packet.

func DstAddr

func DstAddr(addr tcpip.Address) NetworkChecker

DstAddr creates a checker that checks the destination address.

func FragmentFlags

func FragmentFlags(flags uint8) NetworkChecker

FragmentFlags creates a checker that checks the fragment flags field.

func FragmentOffset

func FragmentOffset(offset uint16) NetworkChecker

FragmentOffset creates a checker that checks the FragmentOffset field.

func ICMPv4

func ICMPv4(checkers ...TransportChecker) NetworkChecker

ICMPv4 creates a checker that checks that the transport protocol is ICMPv4 and potentially additional ICMPv4 header fields.

func ICMPv6

func ICMPv6(checkers ...TransportChecker) NetworkChecker

ICMPv6 creates a checker that checks that the transport protocol is ICMPv6 and potentially additional ICMPv6 header fields.

ICMPv6 will validate the checksum field before calling checkers.

func IPv6Fragment

func IPv6Fragment(checkers ...NetworkChecker) NetworkChecker

IPv6Fragment creates a checker that validates an IPv6 fragment.

func NDP

func NDP(msgType header.ICMPv6Type, minSize int, checkers ...TransportChecker) NetworkChecker

NDP creates a checker that checks that the packet contains a valid NDP message for type of ty, with potentially additional checks specified by checkers.

checkers may assume that a valid ICMPv6 is passed to it containing a valid NDP message as far as the size of the message (minSize) is concerned. The values within the message are up to checkers to validate.

func NDPNS

func NDPNS(checkers ...TransportChecker) NetworkChecker

NDPNS creates a checker that checks that the packet contains a valid NDP Neighbor Solicitation message (as per the raw wire format), with potentially additional checks specified by checkers.

checkers may assume that a valid ICMPv6 is passed to it containing a valid NDPNS message as far as the size of the messages concerned. The values within the message are up to checkers to validate.

func PayloadLen

func PayloadLen(plen int) NetworkChecker

PayloadLen creates a checker that checks the payload length.

func Raw

func Raw(want []byte) NetworkChecker

Raw creates a checker that checks the bytes of payload. The checker always checks the payload of the last network header. For instance, in case of IPv6 fragments, the payload that will be checked is the one containing the actual data that the packet is carrying, without the bytes added by the IPv6 fragmentation.

func SrcAddr

func SrcAddr(addr tcpip.Address) NetworkChecker

SrcAddr creates a checker that checks the source address.

func TCP

func TCP(checkers ...TransportChecker) NetworkChecker

TCP creates a checker that checks that the transport protocol is TCP and potentially additional transport header fields.

func TOS

func TOS(tos uint8, label uint32) NetworkChecker

TOS creates a checker that checks the TOS field.

func TTL

func TTL(ttl uint8) NetworkChecker

TTL creates a checker that checks the TTL (ipv4) or HopLimit (ipv6).

func UDP

func UDP(checkers ...TransportChecker) NetworkChecker

UDP creates a checker that checks that the transport protocol is UDP and potentially additional transport header fields.

type TransportChecker

type TransportChecker func(*testing.T, header.Transport)

TransportChecker is a function to check a property of a transport packet.

func AckNum

func AckNum(seq uint32) TransportChecker

AckNum creates a checker that checks the ack number.

func DstPort

func DstPort(port uint16) TransportChecker

DstPort creates a checker that checks the destination port.

func ICMPv4Code

func ICMPv4Code(want byte) TransportChecker

ICMPv4Code creates a checker that checks the ICMPv4 Code field.

func ICMPv4Type

func ICMPv4Type(want header.ICMPv4Type) TransportChecker

ICMPv4Type creates a checker that checks the ICMPv4 Type field.

func ICMPv6Code

func ICMPv6Code(want byte) TransportChecker

ICMPv6Code creates a checker that checks the ICMPv6 Code field.

func ICMPv6Type

func ICMPv6Type(want header.ICMPv6Type) TransportChecker

ICMPv6Type creates a checker that checks the ICMPv6 Type field.

func NDPNSTargetAddress

func NDPNSTargetAddress(want tcpip.Address) TransportChecker

NDPNSTargetAddress creates a checker that checks the Target Address field of a header.NDPNeighborSolicit.

The returned TransportChecker assumes that a valid ICMPv6 is passed to it containing a valid NDPNS message as far as the size is concerned.

func Payload

func Payload(want []byte) TransportChecker

Payload creates a checker that checks the payload.

func SeqNum

func SeqNum(seq uint32) TransportChecker

SeqNum creates a checker that checks the sequence number.

func SrcPort

func SrcPort(port uint16) TransportChecker

SrcPort creates a checker that checks the source port.

func TCPFlags

func TCPFlags(flags uint8) TransportChecker

TCPFlags creates a checker that checks the tcp flags.

func TCPFlagsMatch

func TCPFlagsMatch(flags, mask uint8) TransportChecker

TCPFlagsMatch creates a checker that checks that the tcp flags, masked by the given mask, match the supplied flags.

func TCPNoSACKBlockChecker

func TCPNoSACKBlockChecker() TransportChecker

TCPNoSACKBlockChecker creates a checker that verifies that the segment does not contain any SACK blocks in the TCP options.

func TCPSACKBlockChecker

func TCPSACKBlockChecker(sackBlocks []header.SACKBlock) TransportChecker

TCPSACKBlockChecker creates a checker that verifies that the segment does contain the specified SACK blocks in the TCP options.

func TCPSynOptions

func TCPSynOptions(wantOpts header.TCPSynOptions) TransportChecker

TCPSynOptions creates a checker that checks the presence of TCP options in SYN segments.

If wndscale is negative, the window scale option must not be present.

func TCPTimestampChecker

func TCPTimestampChecker(wantTS bool, wantTSVal uint32, wantTSEcr uint32) TransportChecker

TCPTimestampChecker creates a checker that validates that a TCP segment has a TCP Timestamp option if wantTS is true, it also compares the wantTSVal and wantTSEcr values with those in the TCP segment (if present).

If wantTSVal or wantTSEcr is zero then the corresponding comparison is skipped.

func Window

func Window(window uint16) TransportChecker

Window creates a checker that checks the tcp window.

Jump to

Keyboard shortcuts

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