mirror

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: May 16, 2022 License: Apache-2.0 Imports: 3 Imported by: 3

Documentation

Overview

Package mirror replicates the IPFIX packets with spoofing feature to 3rd party collector

Index

Constants

View Source
const (
	// IPv4HLen is IP version 4 header length
	IPv4HLen = 20

	// IPv6HLen is IP version 6 header length
	IPv6HLen = 40

	// UDPHLen is UDP header length
	UDPHLen = 8

	// UDPProto is UDP protocol IANA number
	UDPProto = 17
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

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

Conn represents socket connection properties

func NewRawConn

func NewRawConn(raddr net.IP) (Conn, error)

NewRawConn constructs new raw socket

func (*Conn) Close

func (c *Conn) Close(b []byte) error

Close releases file descriptor

func (*Conn) Send

func (c *Conn) Send(b []byte) error

Send tries to put the bytes to wire

type IP

type IP interface {
	Marshal() []byte
	SetLen([]byte, int)
	SetAddrs([]byte, net.IP, net.IP)
}

IP is network layer corresponding to IPv4/IPv6

type IPv4

type IPv4 struct {
	Version  uint8
	IHL      uint8
	TOS      uint8
	Length   uint16
	TTL      uint8
	Protocol uint8
}

IPv4 represents the minimum IPV4 fields which they need to setup.

func NewIPv4HeaderTpl

func NewIPv4HeaderTpl(proto int) IPv4

NewIPv4HeaderTpl constructs IPv4 header template

func (IPv4) Marshal

func (ip IPv4) Marshal() []byte

Marshal encodes the IPv4 packet

func (IPv4) SetAddrs

func (ip IPv4) SetAddrs(b []byte, src, dst net.IP)

SetAddrs sets the source and destination address

func (IPv4) SetLen

func (ip IPv4) SetLen(b []byte, n int)

SetLen sets the IPv4 header length

type IPv6

type IPv6 struct {
	Version       uint8
	TrafficClass  uint8
	FlowLabel     uint32
	PayloadLength uint16
	NextHeader    uint8
	HopLimit      uint8
}

IPv6 represents IP version 6 header

func NewIPv6HeaderTpl

func NewIPv6HeaderTpl(proto int) IPv6

NewIPv6HeaderTpl returns a new IPv6 as template

func (IPv6) Marshal

func (ip IPv6) Marshal() []byte

Marshal returns encoded IPv6

func (IPv6) SetAddrs

func (ip IPv6) SetAddrs(b []byte, src, dst net.IP)

SetAddrs sets IPv6 src and dst addresses

func (IPv6) SetLen

func (ip IPv6) SetLen(b []byte, n int)

SetLen sets IPv6 length

type UDP

type UDP struct {
	SrcPort  int
	DstPort  int
	Length   int
	Checksum int
}

UDP represents UDP header

func (*UDP) Marshal

func (u *UDP) Marshal() []byte

Marshal returns decoded UDP

func (*UDP) SetChecksum

func (u *UDP) SetChecksum()

SetChecksum calculates and sets IPv6 checksum

func (*UDP) SetLen

func (u *UDP) SetLen(b []byte, n int)

SetLen sets the payload length

Jump to

Keyboard shortcuts

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