packetinjector

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2019 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Namespace Packet_Injector
	Namespace = "Packet_Injector"
)

Variables

This section is empty.

Functions

func InjectPackets

func InjectPackets(pp *PacketInjectionParams, g *graph.Graph, chnl *channels) (string, error)

InjectPackets inject some packets based on the graph

Types

type Client

type Client struct {
	common.MasterElection
	// contains filtered or unexported fields
}

Client describes a packet injector client

func NewClient

func NewClient(pool ws.StructSpeakerPool, etcdClient *etcd.Client, piHandler *apiServer.PacketInjectorAPI, g *graph.Graph) *Client

NewClient returns a new packet injector client

func (*Client) InjectPackets

func (pc *Client) InjectPackets(host string, pp *PacketInjectionParams) (string, error)

InjectPackets issues a packet injection request and returns the expected tracking id

func (*Client) OnStartAsMaster

func (pc *Client) OnStartAsMaster()

OnStartAsMaster event

func (*Client) OnStartAsSlave

func (pc *Client) OnStartAsSlave()

OnStartAsSlave event

func (*Client) OnSwitchToMaster

func (pc *Client) OnSwitchToMaster()

OnSwitchToMaster event

func (*Client) OnSwitchToSlave

func (pc *Client) OnSwitchToSlave()

OnSwitchToSlave event

func (*Client) Start

func (pc *Client) Start()

Start the packet injector client

func (*Client) Stop

func (pc *Client) Stop()

Stop the packet injector client

func (*Client) StopInjection

func (pc *Client) StopInjection(host string, uuid string) error

StopInjection cancels a running packet injection

type ForgedPacketGenerator

type ForgedPacketGenerator struct {
	*PacketInjectionParams
	// contains filtered or unexported fields
}

ForgedPacketGenerator is used to forge packets. It creates a gopacket.Packet with the proper layers that can be directly inserted into a socket.

func NewForgedPacketGenerator

func NewForgedPacketGenerator(pp *PacketInjectionParams, srcNode *graph.Node) (*ForgedPacketGenerator, error)

NewForgedPacketGenerator returns a new generator of forged packets

func (*ForgedPacketGenerator) PacketSource

func (f *ForgedPacketGenerator) PacketSource() chan *Packet

PacketSource returns a channel when forged packets are pushed

type Packet

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

Packet is defined as a gopacket and it byte representation

type PacketForger

type PacketForger interface {
	PacketSource() chan *Packet
}

PacketForger describes an objects that feeds a channel with packets

type PacketInjectionParams

type PacketInjectionParams struct {
	UUID             string
	SrcNodeID        graph.Identifier `valid:"nonzero"`
	SrcIP            string
	SrcMAC           string
	SrcPort          int64 `valid:"min=0"`
	DstIP            string
	DstMAC           string
	DstPort          int64  `valid:"min=0"`
	Type             string `valid:"regexp=^(icmp4|icmp6|tcp4|tcp6|udp4|udp6)$"`
	Count            int64  `valid:"min=1"`
	ID               int64  `valid:"min=0"`
	Interval         int64  `valid:"min=0"`
	Increment        bool
	IncrementPayload int64
	Payload          string
	Pcap             []byte
}

PacketInjectionParams describes the packet parameters to be injected

type PacketInjector

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

PacketInjector injects packets coming from a packet forget intoto a raw socket

func NewPacketInjector

func NewPacketInjector(g *graph.Graph, srcNode *graph.Node) (*PacketInjector, error)

NewPacketInjector returns a new packet injector into one interface

func (*PacketInjector) Close

func (p *PacketInjector) Close()

Close the packet injector and its socket

func (*PacketInjector) Write

func (p *PacketInjector) Write(data []byte)

Write injects data into the raw socket

type PcapPacketGenerator

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

PcapPacketGenerator reads packets from a pcap file and inject it into a channel

func NewPcapPacketGenerator

func NewPcapPacketGenerator(pcap []byte) (*PcapPacketGenerator, error)

NewPcapPacketGenerator returns a new pcap packet generator

func (*PcapPacketGenerator) PacketSource

func (p *PcapPacketGenerator) PacketSource() chan *Packet

PacketSource returns a channel when pcap packets are pushed

type Reply

type Reply struct {
	TrackingID string
	Error      string
}

Reply describes the reply to a packet injection request

type Server

type Server struct {
	Graph    *graph.Graph
	Channels *channels
}

Server creates a packet injector server API

func NewServer

func NewServer(graph *graph.Graph, pool ws.StructSpeakerPool) *Server

NewServer creates a new packet injector server API based on websocket server

func (*Server) OnStructMessage

func (pis *Server) OnStructMessage(c ws.Speaker, msg *ws.StructMessage)

OnStructMessage event, websocket PIRequest message

Source Files

  • client.go
  • forge.go
  • inject_packet.go
  • pcap.go
  • server.go

Jump to

Keyboard shortcuts

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