Expand description
Protocol parsing framework.
This module provides:
Protocoltrait for implementing parsersProtocolRegistryfor managing registered parsers- Built-in parsers for common protocols
§Supported Protocols
| Layer | Protocols |
|---|---|
| Link | Ethernet, VLAN (802.1Q) |
| Network | IPv4, IPv6, ARP, ICMP, ICMPv6 |
| Transport | TCP, UDP |
| Application | DNS, DHCP, NTP, TLS, SSH, QUIC |
Note: HTTP is parsed via TCP stream reassembly (see stream::parsers::http).
§Example
use pcapsql_core::protocol::{default_registry, parse_packet};
let registry = default_registry();
// Ethernet frame with IP/TCP
let packet_data: &[u8] = &[
// Ethernet header (14 bytes)
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // dst mac
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // src mac
0x08, 0x00, // ethertype (IPv4)
// Minimal IPv4 header would follow...
];
let results = parse_packet(®istry, 1, packet_data); // 1 = Ethernet
for (name, result) in results {
let field_names: Vec<_> = result.fields.iter().map(|(k, _)| *k).collect();
println!("Parsed {}: {:?}", name, field_names);
}Modules§
- ethertype
- Well-known EtherType values (IEEE 802).
- netlink_
family - Netlink protocol families.
- next_
header - IPv6 Next Header values for extension headers and encapsulation.
- rcode
- DNS response codes (RFC 1035, RFC 2136, RFC 2845, RFC 6895).
- record_
type - DNS record types.
Structs§
- ArpProtocol
- ARP protocol parser.
- BgpProtocol
- BGP protocol parser.
- Dhcp
Protocol - DHCP protocol parser.
- DnsProtocol
- DNS protocol parser.
- Ethernet
Protocol - Ethernet II protocol parser.
- GreProtocol
- GRE protocol parser.
- GtpProtocol
- GTP protocol parser.
- Icmp
Protocol - ICMP protocol parser.
- Icmpv6
Protocol - ICMPv6 protocol parser.
- Ipsec
Protocol - IPsec protocol parser (handles both ESP and AH).
- Ipv4
Protocol - IPv4 protocol parser.
- Ipv6
Protocol - IPv6 protocol parser.
- Linux
SllProtocol - Linux SLL protocol parser.
- Mpls
Protocol - MPLS protocol parser.
- Netlink
Protocol - Netlink protocol parser.
- NtpProtocol
- NTP protocol parser.
- Ospf
Protocol - OSPF protocol parser.
- Parse
Context - Context passed through the parsing chain.
- Parse
Result - Result of parsing a protocol layer.
- Projection
Config - Configuration for field projection during parsing.
- Protocol
Registry - Registry for protocol parsers with priority-based selection.
- Quic
Protocol - QUIC protocol parser.
- Rtnetlink
Protocol - RTNetlink protocol parser.
- SshProtocol
- SSH protocol parser.
- TcpProtocol
- TCP protocol parser.
- TlsProtocol
- TLS protocol parser using tls-parser crate.
- Tunnel
Layer - Information about a single tunnel encapsulation layer.
- UdpProtocol
- UDP protocol parser.
- Vlan
Protocol - 802.1Q VLAN tag parser.
- Vxlan
Protocol - VXLAN protocol parser.
Enums§
- Builtin
Protocol - Enum of all built-in protocol parsers.
- Field
Value - Possible field value types (maps to Arrow types).
- Payload
Mode - How a protocol’s remaining bytes should be handled.
- Tunnel
Type - Type of encapsulating tunnel protocol.
Traits§
- Protocol
- Core trait all protocol parsers must implement.
Functions§
- chain_
fields_ for_ protocol - Fields required for protocol chaining.
- compute_
required_ protocols - Compute the set of protocols required to satisfy a query.
- default_
registry - Create a registry with all built-in protocol parsers.
- merge_
with_ chain_ fields - Merge projection with chain fields if needed.
- parse_
packet - Parse a packet through all protocol layers.
- parse_
packet_ projected - Parse a packet with field projection.
- parse_
packet_ pruned - Parse a packet with protocol pruning.
- parse_
packet_ pruned_ projected - Parse a packet with both protocol pruning and field projection.
- should_
continue_ parsing - Check if parsing should continue given the current parse results and required set.
- should_
run_ parser - Check if a specific parser should be run.
Type Aliases§
- Field
Entry - Field entry for parse results: (field_name, value). Field names are always static strings (protocol-defined). The lifetime parameter ties the value to the packet/buffer data.
- Hint
Entry - Hint entry for child protocol detection: (hint_name, value).
- Owned
Field Value - Type alias for FieldValue that owns all its data. Useful for caching where lifetime of packet data is not available.