| Crates.io | pcapsql-core |
| lib.rs | pcapsql-core |
| version | 0.3.1 |
| created_at | 2026-01-02 02:21:46.465292+00 |
| updated_at | 2026-01-02 02:21:46.465292+00 |
| description | Engine-agnostic PCAP protocol parsing library |
| homepage | https://github.com/mtottenh/pcapsql |
| repository | https://github.com/mtottenh/pcapsql |
| max_upload_size | |
| id | 2017825 |
| size | 1,285,159 |
Engine-agnostic PCAP protocol parsing library.
This crate provides the core parsing functionality for pcapsql, without any SQL engine dependencies. It can be used standalone for protocol analysis or as the foundation for SQL integrations (DataFusion, DuckDB).
use pcapsql_core::prelude::*;
use pcapsql_core::io::FilePacketSource;
// Create a protocol registry with all built-in parsers
let registry = default_registry();
// Open a PCAP file
let source = FilePacketSource::open("capture.pcap").unwrap();
let mut reader = source.reader(None).unwrap();
// Read and parse packets
reader.process_packets(1000, |packet| {
let results = pcapsql_core::parse_packet(
®istry,
packet.link_type as u16,
&packet.data,
);
for (protocol_name, result) in results {
println!("{}: {} fields", protocol_name, result.fields.len());
}
Ok(())
}).unwrap();
| Layer | Protocols |
|---|---|
| Link | Ethernet, VLAN (802.1Q), Linux SLL |
| Network | IPv4, IPv6, ARP, ICMP, ICMPv6 |
| Transport | TCP, UDP |
| Application | DNS, DHCP, NTP, HTTP, TLS, SSH, QUIC |
| Tunneling | VXLAN, GRE, MPLS, GTP, IPsec |
| Routing | BGP, OSPF |
| Feature | Default | Description |
|---|---|---|
mmap |
Yes | Memory-mapped file I/O |
compress-gzip |
Yes | Gzip decompression |
compress-zstd |
Yes | Zstd decompression |
compress-lz4 |
No | LZ4 decompression |
compress-bzip2 |
No | Bzip2 decompression |
compress-xz |
No | XZ decompression |
compress-all |
No | All compression formats |
pcapsql-core
├── schema/ - FieldDescriptor, DataKind (engine-agnostic types)
├── protocol/ - Protocol trait, parsers, FieldValue
├── io/ - PacketSource, PacketReader, mmap support
├── pcap/ - PCAP/PCAPNG reading, compression
├── cache/ - LRU parse cache
├── stream/ - TCP reassembly, HTTP/TLS stream parsing
├── tls/ - TLS key derivation and decryption
└── format/ - Address formatting utilities
MIT