checker

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

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 IPv6Fragment

func IPv6Fragment(checkers ...NetworkChecker) NetworkChecker

IPv6Fragment creates a checker that validates an IPv6 fragment.

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 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