nat

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2019 License: BSD-3-Clause Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DHCPServerPort = 67
	DHCPClientPort = 68
	BroadcastIPv4  = types.IPv4Address(0xffffffff)
)
View Source
const (
	DHCPv6ClientPort = 546
	DHCPv6ServerPort = 547
)
View Source
const (
	GRPCServerPort = ":60602"
)

Variables

View Source
var (
	// Natconfig is a config file.
	Natconfig *Config
	// CalculateChecksum is a flag whether checksums should be
	// calculated for modified packets.
	NoCalculateChecksum bool
	// HWTXChecksum is a flag whether checksums calculation should be
	// offloaded to HW.
	NoHWTXChecksum bool
	NeedKNI        bool
	NeedDHCP       bool

	// Debug variables
	DumpEnabled [DirKNI + 1]bool
)
View Source
var (
	BroadcastIPv6 = types.IPv6Address{
		0xff, 0x02, 0x00, 0x00,
		0x00, 0x00, 0x00, 0x00,
		0x00, 0x00, 0x00, 0x00,
		0x00, 0x01, 0x00, 0x02,
	}
	SingleIPMask = types.IPv6Address{
		0xff, 0xff, 0xff, 0xff,
		0xff, 0xff, 0xff, 0xff,
		0xff, 0xff, 0xff, 0xff,
		0xff, 0xff, 0xff, 0xff,
	}
	SingleIPNetMask = net.CIDRMask(128, 128)
)
View Source
var (
	BroadcastMAC = types.MACAddress{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
)

Functions

func CheckHWOffloading

func CheckHWOffloading() bool

func CloseAllDumpFiles

func CloseAllDumpFiles()

CloseAllDumpFiles closes all debug dump files.

func InitFlows

func InitFlows()

InitFlows initializes flow graph for all interface pairs.

func OptionsLen

func OptionsLen(options layers.DHCPv6Options) int

Returns length of data portion of option (excluding IANA code 3 and option length)

func ParseAllKnownL4

func ParseAllKnownL4(pkt *packet.Packet, pktIPv4 *packet.IPv4Hdr, pktIPv6 *packet.IPv6Hdr) (uint8, *packet.TCPHdr, *packet.UDPHdr, *packet.ICMPHdr, uint16, uint16)

func PrivateToPublicTranslation

func PrivateToPublicTranslation(pkt *packet.Packet, ctx flow.UserContext) uint

PrivateToPublicTranslation does egress translation.

func PublicToPrivateTranslation

func PublicToPrivateTranslation(pkt *packet.Packet, ctx flow.UserContext) uint

PublicToPrivateTranslation does ingress translation.

func ReadConfig

func ReadConfig(fileName string, setKniIP, bringUpKniInterfaces bool) error

ReadConfig function reads and parses config file

func StartDHCPClient

func StartDHCPClient()

func StartGRPCServer

func StartGRPCServer() error

func StringIPv4Int

func StringIPv4Int(addr uint32) string

Types

type Config

type Config struct {
	HostName  string     `json:"host-name"`
	PortPairs []portPair `json:"port-pairs"`
	// contains filtered or unexported fields
}

Config for NAT.

type DHCPv6FQDN

type DHCPv6FQDN struct {
	Flags      DHCPv6FQDNFlags
	DomainName string
}

FQDN option encoded according to RFC 4704

func (*DHCPv6FQDN) DecodeFromBytes

func (fqdn *DHCPv6FQDN) DecodeFromBytes(data []byte) error

func (*DHCPv6FQDN) Encode

func (fqdn *DHCPv6FQDN) Encode() []byte

type DHCPv6FQDNFlags

type DHCPv6FQDNFlags byte
const (
	DHCPv6OptFQDNOptionCode                layers.DHCPv6Opt = 39
	DHCPv6FQDNOptionServerUpdateForwardDNS DHCPv6FQDNFlags  = 1
	DHCPv6FQDNOptionServerOverride         DHCPv6FQDNFlags  = 2
	DHCPv6FQDNOptionServerNoDNSUpdate      DHCPv6FQDNFlags  = 4
)

type DHCPv6IAAddress

type DHCPv6IAAddress struct {
	Address           net.IP
	PreferredLifetime uint32
	ValidLifetime     uint32
	Options           layers.DHCPv6Options
}

IA Address Option

func (*DHCPv6IAAddress) DecodeFromBytes

func (ia *DHCPv6IAAddress) DecodeFromBytes(data []byte) error

func (*DHCPv6IAAddress) Encode

func (ia *DHCPv6IAAddress) Encode() []byte

type DHCPv6IANA

type DHCPv6IANA struct {
	IAID    uint32
	T1, T2  uint32
	Options layers.DHCPv6Options
}

Identity Association for Non-temporary Addresses Option

func (*DHCPv6IANA) DecodeFromBytes

func (iana *DHCPv6IANA) DecodeFromBytes(data []byte) error

func (*DHCPv6IANA) Encode

func (iana *DHCPv6IANA) Encode() []byte

type DHCPv6ServerStatusCode

type DHCPv6ServerStatusCode struct {
	StatusCode    layers.DHCPv6StatusCode
	StatusMessage string
}

Server status code option

func (*DHCPv6ServerStatusCode) DecodeFromBytes

func (sc *DHCPv6ServerStatusCode) DecodeFromBytes(data []byte) error

func (*DHCPv6ServerStatusCode) Encode

func (sc *DHCPv6ServerStatusCode) Encode() []byte

type Tuple

type Tuple struct {
	// contains filtered or unexported fields
}

Tuple is a pair of address and port.

func (*Tuple) String

func (t *Tuple) String() string

type Tuple6

type Tuple6 struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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