nftget

package
v2.6.1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package nftget help with conveniently retrieving information from nftable expressions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IPv46

func IPv46(cmp *expr.Cmp) (net.IP, bool)

IPv46 returns the IPv4 or IPv6 address enclosed in a Cmp expression, otherwise false.

func IsPayloadDestIP added in v2.6.0

func IsPayloadDestIP(payl *expr.Payload) bool

IsPayloadDestIP returns true if the passed Payload expression loads an IP address of the correct size (either 4 or 16 bytes) from the correct IPv4 or IPv6 network layer header.

See also RFC 791, section 3.1 for the following IPv4 header structure; the word offsets are in decimal and not shown in the original RFC ASCII illustration.

     0                   1                   2                   3
     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+00 |Version|  IHL  |Type of Service|          Total Length         |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+04 |         Identification        |Flags|      Fragment Offset    |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+08 |  Time to Live |    Protocol   |         Header Checksum       |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+12 |                       Source Address                          |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+16 |                    Destination Address                        |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+20 |                    Options                    |    Padding    |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

See also RFC 8200, section 3 for the following IPv6 header structure; the word offsets are in decimal and not shown in the original RFC ASCII illustration. Similarly, the bit number heading has been added for improved clarification.

     0                   1                   2                   3
     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+00 |Version| Traffic Class |           Flow Label                  |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+04 |         Payload Length        |  Next Header  |   Hop Limit   |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+08 |                                                               |
    +                                                               +
+12 |                                                               |
    +                         Source Address                        +
+16 |                                                               |
    +                                                               +
+20 |                                                               |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+24 |                                                               |
    +                                                               +
+28 |                                                               |
    +                      Destination Address                      +
+32 |                                                               |
    +                                                               +
+36 |                                                               |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

func MetaL4ProtoTcpUdp added in v2.6.1

func MetaL4ProtoTcpUdp(exprs nufftables.Expressions) (nufftables.Expressions, string)

MetaL4ProtoTcpUdp returns the transport layer protocol name checked for from a Meta/Cmp twin-expression, together with the remaining expressions; otherwise, it returns nil.

func OptionalDestIPv46 added in v2.6.0

func OptionalDestIPv46(exprs nufftables.Expressions, family nftables.TableFamily) (nufftables.Expressions, net.IP)

OptionalDestIPv46 returns the IPv4 or IPv6 address in a twin Payload network header load and Cmp expression; otherwise, it returns the unspecified IP address of the particular IP family.

func OptionalIPv46

func OptionalIPv46(exprs nufftables.Expressions, family nftables.TableFamily) (nufftables.Expressions, net.IP)

OptionalIPv46 returns the IPv4 or IPv6 address enclosed in a Cmp expression, otherwise the unspecified IP address of the particular IP family.

func PayloadL4ProtoTcpUdp added in v2.6.1

func PayloadL4ProtoTcpUdp(exprs nufftables.Expressions) (nufftables.Expressions, string)

PayloadL4ProtoTcpUdp returns the transport layer protocol name checked for from a Payload/Cmp twin-expression, together with the remaining expressions; otherwise, it returns nil.

func PayloadPort added in v2.6.0

func PayloadPort(exprs nufftables.Expressions) (nufftables.Expressions, uint16)

PayloadPort returns the (transport) destination port number from a payload-cmp twin expression, together with the remaining expressions; otherwise, it returns nil expressions and a zero port.

func Port

func Port(cmp *expr.Cmp) (uint16, bool)

Port returns the (transport) port number from a Cmp expression; otherwise, returns false.

func TcpUdp

func TcpUdp(cmp *expr.Cmp) (string, bool)

TcpUdp returns the transport protocol name enclosed in a Cmp expression testing the L4 protocol for TCP and UDP, otherwise false.

Types

This section is empty.

Jump to

Keyboard shortcuts

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