Documentation
¶
Overview ¶
Package packet Package decoder implements decoders to transform network packets into protocol buffers for various protocols
Index ¶
- Constants
- Variables
- func ApplyActionToGoPacketDecoders(action func(*GoPacketDecoder))
- func ApplyActionToGoPacketDecodersAsync(action func(*GoPacketDecoder))
- func ApplyActionToPacketDecoders(action func(DecoderAPI))
- func ApplyActionToPacketDecodersAsync(action func(DecoderAPI))
- func CalcCommunityID(p gopacket.Packet) string
- func GetBaseLayerType() gopacket.LayerType
- func InitGoPacketDecoders(c *config.Config) (decoders map[gopacket.LayerType][]*GoPacketDecoder, err error)
- func MarkdownOverview()
- func ResetConnections()
- func ResetDeviceProfiles()
- func ResetHosts()
- func SetBaseLayerType(lt gopacket.LayerType)
- func SetConfig(cfg *config.Config)
- func SetDecoderLogger(lg *zap.Logger)
- func ShowDecoders(verbose bool)
- func WalkDeviceProfiles(visit func(*types.DeviceProfile) error) error
- type Decoder
- func (pd *Decoder) DeInitFunc() error
- func (pd *Decoder) Decode(p gopacket.Packet, ctx *types.PacketContext) error
- func (pd *Decoder) Destroy() (name string, size int64)
- func (pd *Decoder) FlushCurrentState() int64
- func (pd *Decoder) GetChan() <-chan []byte
- func (pd *Decoder) GetDescription() string
- func (pd *Decoder) GetName() string
- func (pd *Decoder) GetType() types.Type
- func (pd *Decoder) GetWriter() netio.AuditRecordWriter
- func (pd *Decoder) NumRecords() int64
- func (pd *Decoder) PostInitFunc() error
- func (pd *Decoder) SetWriter(w netio.AuditRecordWriter)
- type DecoderAPI
- type GoPacketDecoder
- func (dec *GoPacketDecoder) DeInitFunc() error
- func (dec *GoPacketDecoder) Decode(ctx *types.PacketContext, p gopacket.Packet, l gopacket.Layer) error
- func (dec *GoPacketDecoder) Destroy() (name string, size int64)
- func (dec *GoPacketDecoder) FlushCurrentState() int64
- func (cd *GoPacketDecoder) GetChan() <-chan []byte
- func (dec *GoPacketDecoder) GetDescription() string
- func (dec *GoPacketDecoder) GetName() string
- func (dec *GoPacketDecoder) GetType() types.Type
- func (dec *GoPacketDecoder) GetWriter() netio.AuditRecordWriter
- func (dec *GoPacketDecoder) NumRecords() int64
- func (dec *GoPacketDecoder) PostInitFunc() error
- func (dec *GoPacketDecoder) SetWriter(writer netio.AuditRecordWriter)
Constants ¶
const ( EthernetCTPFunctionReply = 1 EthernetCTPFunctionForwardData = 2 )
CTP function codes as defined in the Xerox Ethernet II specification
const ( RMCPClassASF = 0x06 RMCPClassIPMI = 0x07 )
RMCP class constants
Variables ¶
var ( // DeviceProfiles hold all connections. DeviceProfiles = &atomicDeviceProfileMap{ Items: make(map[string]*deviceProfile), } )
var ( // ErrInvalidDecoder occurs when a decoder name is unknown during initialization. ErrInvalidDecoder = errors.New("invalid decoder") )
var ( // LocalDNS controls whether the DNS names shall be resolved locally // without contacting a nameserver. LocalDNS = true )
Functions ¶
func ApplyActionToGoPacketDecoders ¶
func ApplyActionToGoPacketDecoders(action func(*GoPacketDecoder))
ApplyActionToGoPacketDecoders can be used to run custom code for all gopacket decoders.
func ApplyActionToGoPacketDecodersAsync ¶
func ApplyActionToGoPacketDecodersAsync(action func(*GoPacketDecoder))
ApplyActionToGoPacketDecodersAsync can be used to run custom code for all gopacket decoders asynchronously.
func ApplyActionToPacketDecoders ¶
func ApplyActionToPacketDecoders(action func(DecoderAPI))
ApplyActionToPacketDecoders can be used to run custom code for all packet decoders.
func ApplyActionToPacketDecodersAsync ¶
func ApplyActionToPacketDecodersAsync(action func(DecoderAPI))
ApplyActionToPacketDecodersAsync can be used to run custom code for all packet decoders asynchronously.
func CalcCommunityID ¶
CalcCommunityID generates a Community ID v1 for a packet. This provides a standardized flow identifier that is compatible with Zeek, Suricata, and other network monitoring tools. Returns an empty string if the packet lacks the necessary layers.
func GetBaseLayerType ¶
GetBaseLayerType returns the current base layer type
func InitGoPacketDecoders ¶
func InitGoPacketDecoders(c *config.Config) (decoders map[gopacket.LayerType][]*GoPacketDecoder, err error)
InitGoPacketDecoders initializes all gopacket decoders.
func MarkdownOverview ¶
func MarkdownOverview()
MarkdownOverview dumps a Markdown summary of all available decoders and their fields.
func ResetConnections ¶
func ResetConnections()
ResetConnections clears all connections from memory This should be called when resetting state between processing different files
func ResetDeviceProfiles ¶
func ResetDeviceProfiles()
ResetDeviceProfiles clears all device profiles from memory This should be called when resetting state between processing different files
func ResetHosts ¶
func ResetHosts()
ResetHosts clears all IP profiles from memory This should be called when resetting state between processing different files
func SetBaseLayerType ¶
SetBaseLayerType sets the base layer type for packet decoding This should be called by the collector when it determines the link type
func SetDecoderLogger ¶
SetDecoderLogger sets the general decoder logger for the decoder package.
func WalkDeviceProfiles ¶ added in v0.16.8
func WalkDeviceProfiles(visit func(*types.DeviceProfile) error) error
WalkDeviceProfiles supplies detached records without collecting every profile into a second in-memory snapshot. The callback must not re-enter profile APIs.
Types ¶
type Decoder ¶
type Decoder struct {
// used to keep track of the number of generated audit records
NumRecordsWritten int64
// Name of the decoder
Name string
// Description of the decoder
Description string
// Icon name for the decoder (for Maltego)
Icon string
// Handler to process packets
Handler packetDecoderHandler
// init functions
PostInit func(*Decoder) error
DeInit func(*Decoder) error
// FlushState is called during live capture to write current state without clearing it.
// This allows accumulating decoders (DeviceProfile, IPProfile, Connection) to periodically
// make their data visible while continuing to track state.
FlushState func(*Decoder) int64
// Writer for audit records
Writer netio.AuditRecordWriter
// Type of the audit records produced by this decoder
Type types.Type
}
Decoder implements custom logic to decode data from a gopacket.Packet this structure has an optimized field order to avoid excessive padding.
func (*Decoder) DeInitFunc ¶
DeInitFunc is called prior to teardown.
func (*Decoder) Decode ¶
Decode is called for each layer this calls the handler function of the decoder and writes the serialized protobuf into the data pipe.
func (*Decoder) FlushCurrentState ¶
FlushCurrentState writes the current state of accumulating records to disk without clearing the in-memory state. This is used during live capture to periodically make data visible while continuing to track state. Returns the number of records flushed.
func (*Decoder) GetChan ¶
GetChan returns a channel to receive serialized protobuf data from the decoder.
func (*Decoder) GetDescription ¶
GetDescription returns the description of the decoder.
func (*Decoder) GetWriter ¶
func (pd *Decoder) GetWriter() netio.AuditRecordWriter
GetWriter returns the current writer.
func (*Decoder) NumRecords ¶
NumRecords returns the number of written records.
func (*Decoder) PostInitFunc ¶
PostInitFunc is called after the decoder has been initialized.
func (*Decoder) SetWriter ¶
func (pd *Decoder) SetWriter(w netio.AuditRecordWriter)
SetWriter sets the netcap writer to use for the decoder.
type DecoderAPI ¶
type DecoderAPI interface {
core.DecoderAPI
// Decode parses a gopacket and returns an error
Decode(p gopacket.Packet, ctx *types.PacketContext) error
}
DecoderAPI PacketDecoderAPI describes an interface that all custom decoders need to implement this allows to supply a custom structure and maintain state for advanced protocol analysis.
func GetPacketDecoders ¶
func GetPacketDecoders() []DecoderAPI
GetPacketDecoders returns all available packet decoders
func InitPacketDecoders ¶
func InitPacketDecoders(c *config.Config) (decoders []DecoderAPI, err error)
InitPacketDecoders initializes all packet decoders.
type GoPacketDecoder ¶
type GoPacketDecoder struct {
Description string
Layer gopacket.LayerType
Handler goPacketDecoderHandler
Type types.Type
// contains filtered or unexported fields
}
GoPacketDecoder represents an decoder for the gopacket.Layer type this structure has an optimized field order to avoid excessive padding.
func GetGoPacketDecoders ¶
func GetGoPacketDecoders() []*GoPacketDecoder
GetGoPacketDecoders returns all available gopacket layer decoders
func (*GoPacketDecoder) DeInitFunc ¶
func (dec *GoPacketDecoder) DeInitFunc() error
func (*GoPacketDecoder) Decode ¶
func (dec *GoPacketDecoder) Decode(ctx *types.PacketContext, p gopacket.Packet, l gopacket.Layer) error
Decode is called for each layer this calls the handler function of the decoder and writes the serialized protobuf into the data pipe.
func (*GoPacketDecoder) Destroy ¶
func (dec *GoPacketDecoder) Destroy() (name string, size int64)
Destroy closes and flushes all writers.
func (*GoPacketDecoder) FlushCurrentState ¶
func (dec *GoPacketDecoder) FlushCurrentState() int64
FlushCurrentState flushes the writer buffer for gopacket decoders. GoPacket decoders write records immediately, so there's no accumulated state to flush. This just ensures any buffered data is written to disk.
func (*GoPacketDecoder) GetChan ¶
func (cd *GoPacketDecoder) GetChan() <-chan []byte
GetChan returns a channel to receive serialized protobuf data from the decoder.
func (*GoPacketDecoder) GetDescription ¶
func (dec *GoPacketDecoder) GetDescription() string
func (*GoPacketDecoder) GetName ¶
func (dec *GoPacketDecoder) GetName() string
func (*GoPacketDecoder) GetType ¶
func (dec *GoPacketDecoder) GetType() types.Type
func (*GoPacketDecoder) GetWriter ¶
func (dec *GoPacketDecoder) GetWriter() netio.AuditRecordWriter
func (*GoPacketDecoder) NumRecords ¶
func (dec *GoPacketDecoder) NumRecords() int64
func (*GoPacketDecoder) PostInitFunc ¶
func (dec *GoPacketDecoder) PostInitFunc() error
func (*GoPacketDecoder) SetWriter ¶
func (dec *GoPacketDecoder) SetWriter(writer netio.AuditRecordWriter)
Source Files
¶
- arp.go
- bfd.go
- cisco_dicovery_info.go
- cisco_discovery.go
- cldap.go
- community_id.go
- connection.go
- connection_ja4plus_disabled.go
- connection_storage.go
- deferred_storage.go
- device_profile.go
- device_storage.go
- dhcp4.go
- dhcp6.go
- diameter.go
- dns.go
- dot11.go
- dot1q.go
- eap.go
- eapol.go
- eapolkey.go
- eth.go
- ethctp.go
- ethctpr.go
- fddi.go
- geneve.go
- gopacket_decoder.go
- gre.go
- gtp.go
- host.go
- host_storage.go
- icmp4.go
- icmp6.go
- icmp6e.go
- icmp6na.go
- icmp6ns.go
- icmp6ra.go
- icmp6rs.go
- ieee802154.go
- igmp.go
- init.go
- ip4.go
- ip6.go
- ip6hop.go
- ipsecah.go
- ipsecesp.go
- ipv6fragment.go
- isis.go
- lcm.go
- link_frame.go
- llc.go
- lld.go
- lldi.go
- llmnr.go
- log.go
- mldv2_query.go
- mldv2_report.go
- mpls.go
- nbns.go
- netflow.go
- nortel_discovery.go
- ntp.go
- ocsp.go
- ospfv2.go
- ospfv3.go
- packet_decoder.go
- pim.go
- pktap.go
- ppp.go
- pppoe.go
- radius.go
- rarp.go
- rmcp.go
- sctp.go
- sip.go
- snap.go
- stp.go
- stun.go
- tcp.go
- tcp_mptcp.go
- typed_handler.go
- udp.go
- usb.go
- usb_request_block_setup.go
- utils.go
- vrrpv2.go
- vxlan.go