generator

package
v0.9.3-0...-e3c37e7 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2019 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NULL = iota
	ETHERHDR
	IPv4HDR
	IPv6HDR
	TCPHDR
	UDPHDR
	ICMPHDR
	ARPHDR
	DATA
	PDISTDATA
	RANDDATA
	RAWDATA
	NONE
)

Variables

This section is empty.

Functions

func FillEtherHdr

func FillEtherHdr(pkt *packet.Packet, l2 *EtherConfig)

func FillICMPHdr

func FillICMPHdr(pkt *packet.Packet, l4 *ICMPConfig, rnd *rand.Rand)

func FillIPv4Hdr

func FillIPv4Hdr(pkt *packet.Packet, l3 *IPv4Config)

func FillIPv6Hdr

func FillIPv6Hdr(pkt *packet.Packet, l3 *IPv6Config)

func FillTCPHdr

func FillTCPHdr(pkt *packet.Packet, l4 *TCPConfig, rnd *rand.Rand)

func FillUDPHdr

func FillUDPHdr(pkt *packet.Packet, l4 *UDPConfig)

func Generate

func Generate(pkt *packet.Packet, context flow.UserContext)

Generate is a main generatior func

func GetContext

func GetContext(mixConfig GeneratorConfig) (*genParameters, error)

GetContext gets generator context according to config

func GetGenerator

func GetGenerator() *generator

GetGenerator returns generator struct pointer generator is single and created only once

func SwapBytesUint64

func SwapBytesUint64(x uint64) uint64

SwapBytesUint32 swaps uint32 in Little Endian and Big Endian

Types

type ARPConfig

type ARPConfig struct {
	Operation  uint16
	Gratuitous bool
	SHA        AddrRange
	SPA        AddrRange
	THA        AddrRange
	TPA        AddrRange
}

ARPConfig configures arp header.

type AddrIPv6Range

type AddrIPv6Range struct {
	Min     []byte
	Max     []byte
	Current []byte
	Inc     []byte
}

AddrRange describes range of addresses.

type AddrRange

type AddrRange struct {
	Min     uint64
	Max     uint64
	Current uint64
	Inc     uint64
}

type DataType

type DataType int

type EtherConfig

type EtherConfig struct {
	DAddr AddrRange
	SAddr AddrRange
	VLAN  *VlanTagConfig
	DType DataType
	IPv4  IPv4Config
	IPv6  IPv6Config
	ARP   ARPConfig
	Bytes RawBytes
}

EtherConfig configures ether header.

type GeneratorConfig

type GeneratorConfig []MixConfig

func ParseConfig

func ParseConfig(in map[string]interface{}) (config GeneratorConfig, err error)

ParseConfig parses json config and returns GeneratorConfig.

func ParseConfigFile

func ParseConfigFile(f *os.File) (config GeneratorConfig, err error)

ParseConfigFile parses json config file and returns GeneratorConfig.

func ParseGeneratorConfig

func ParseGeneratorConfig(in map[string]interface{}) (config GeneratorConfig, err error)

func ReadConfig

func ReadConfig(fileName string) (GeneratorConfig, error)

ReadConfig function reads and parses config file.

func (*GeneratorConfig) UnmarshalJSON

func (mca *GeneratorConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON implements Unmarshaller interface for GeneratorConfig.

type ICMPConfig

type ICMPConfig struct {
	Type       uint8
	Code       uint8
	Identifier uint16
	Seq        Sequence
	DType      DataType
	Bytes      RawBytes
}

ICMPConfig configures tcp header.

type IPv4Config

type IPv4Config struct {
	SAddr AddrRange // source address
	DAddr AddrRange // destination address
	DType DataType
	TCP   TCPConfig
	UDP   UDPConfig
	ICMP  ICMPConfig
	Bytes RawBytes
}

IPv4Config configures ip header.

func (*IPv4Config) UnmarshalJSON

func (ipv4 *IPv4Config) UnmarshalJSON(data []byte) error

type IPv6Config

type IPv6Config struct {
	SAddr AddrIPv6Range // source address
	DAddr AddrIPv6Range // destination address
	DType DataType
	TCP   TCPConfig
	UDP   UDPConfig
	ICMP  ICMPConfig
	Bytes RawBytes
}

IPv6Config configures ip header.

func (*IPv6Config) UnmarshalJSON

func (ipv6 *IPv6Config) UnmarshalJSON(data []byte) error

type MixConfig

type MixConfig struct {
	Config   PacketConfig
	Quantity uint32
}

MixConfig contains PacketConfigs with quantity.

func (*MixConfig) String

func (mc *MixConfig) String() string

type PDistEntry

type PDistEntry struct {
	Probability float64
	DType       DataType
	Data        string
	Rand        RandBytes
}

PDistEntry gives data with associated probability of being chosen.

type PacketConfig

type PacketConfig struct {
	DType DataType
	Ether EtherConfig
}

PacketConfig configures packet

type RandBytes

type RandBytes struct {
	Size      uint32
	Deviation uint32
}

RandBytes gives a payload of random bytes, of a given size. Optionally it is possible to specify a deviation.

type RawBytes

type RawBytes struct {
	Data  string
	Rand  RandBytes
	Dist  []PDistEntry
	DType DataType
}

Raw represents raw data

type Sequence

type Sequence struct {
	Type    SequenceType
	Current uint32
}

Sequence contains type and next sequence value.

type SequenceType

type SequenceType uint

SequenceType used in enum below.

const (
	RANDOM SequenceType = iota
	INCREASING
)

Types of Sequence.

type TCPConfig

type TCPConfig struct {
	SPort AddrRange
	DPort AddrRange
	Seq   Sequence
	Flags types.TCPFlags
	DType DataType
	Bytes RawBytes
}

TCPConfig configures tcp header.

type UDPConfig

type UDPConfig struct {
	SPort AddrRange
	DPort AddrRange
	DType DataType
	Bytes RawBytes
}

UDPConfig configures tcp header.

type VlanTagConfig

type VlanTagConfig struct {
	TCI uint16
}

VlanTagConfig configures vlan tag

Jump to

Keyboard shortcuts

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