Documentation ¶
Index ¶
- Constants
- func FillEtherHdr(pkt *packet.Packet, l2 *EtherConfig)
- func FillICMPHdr(pkt *packet.Packet, l4 *ICMPConfig, rnd *rand.Rand)
- func FillIPv4Hdr(pkt *packet.Packet, l3 *IPv4Config)
- func FillIPv6Hdr(pkt *packet.Packet, l3 *IPv6Config)
- func FillTCPHdr(pkt *packet.Packet, l4 *TCPConfig, rnd *rand.Rand)
- func FillUDPHdr(pkt *packet.Packet, l4 *UDPConfig)
- func Generate(pkt *packet.Packet, context flow.UserContext)
- func GetContext(mixConfig GeneratorConfig) (*genParameters, error)
- func GetGenerator() *generator
- func SwapBytesUint64(x uint64) uint64
- type ARPConfig
- type AddrIPv6Range
- type AddrRange
- type DataType
- type EtherConfig
- type GeneratorConfig
- type ICMPConfig
- type IPv4Config
- type IPv6Config
- type MixConfig
- type PDistEntry
- type PacketConfig
- type PcapConfig
- type RandBytes
- type RawBytes
- type Sequence
- type SequenceType
- type TCPConfig
- type UDPConfig
- type VlanTagConfig
Constants ¶
const ( NULL = iota ETHERHDR IPv4HDR IPv6HDR TCPHDR UDPHDR ICMPHDR ARPHDR DATA PDISTDATA RANDDATA RAWDATA NONE PCAP )
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 FillUDPHdr ¶
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 ¶
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 ¶
AddrRange describes range of addresses.
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.
type PDistEntry ¶
PDistEntry gives data with associated probability of being chosen.
type PacketConfig ¶
type PacketConfig struct { DType DataType Ether EtherConfig Pcap PcapConfig }
PacketConfig configures packet
type PcapConfig ¶
type PcapConfig struct { Path string FileReader *os.File InMemory bool ReachedEOF bool Packets [][]byte NextPacket int }
PcapCOnfig configures pcap file
type RandBytes ¶
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.