MCPcopy Index your code
hub / github.com/CrabeDeFrance/rtshark

github.com/CrabeDeFrance/rtshark @4.3.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release 4.3.0 ↗ · + Follow
168 symbols 850 edges 8 files 63 documented · 38% updated 3mo ago★ 38
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

rtshark

Crate Crate Crate Documentation dependency status

A Rust interface to TShark, the famous network protocol analyzer. TShark is a part of Wireshark distribution. This crate provides an API to start TShark and analyze it's output. It lets you capture packet data from a live network or read packets from a previously saved capture file, printing a decoded form of those packets. TShark's native capture file format is pcapng format, which is also the format used by Wireshark and various other tools.

TShark application must be installed for this crate to work properly.

This crates supports both offline processing (using pcap file) and live analysis (using an interface or a fifo).

Example

// Creates a builder with needed tshark parameters
let builder = rtshark::RTSharkBuilder::builder()
    .input_path("/tmp/my.pcap");

// Start a new tshark process
let mut rtshark = builder.spawn()
    .unwrap_or_else(|e| panic!("Error starting tshark: {e}"));

// read packets until the end of the PCAP file
while let Some(packet) = rtshark.read().unwrap_or_else(|e| {
    eprintln!("Error parsing tshark output: {e}");
    None
}) {
    for layer in packet {
        println!("Layer: {}", layer.name());
        for metadata in layer {
            println!("\t{}", metadata.display());
        }
    }
}

Development rules

New parameters

There is actually no specific work to add more TShark parameters. If you miss an important parameter, you can create an issue. But if you want something to be added quickly, please do a patch proposal with the missing parameter or feature (it is easy!). Of course, any new proposal should include documentation to explain how to use it and an unit test to validate it.

Version

This library follows the Semantic Versioning rules https://semver.org/, including :

  • Only make breaking changes when you increment the major version. Don't break the build.
  • Don't add any new public API (no new pub anything) in patch-level versions. Always increment the minor version if you add any new pub structs, traits, fields, types, functions, methods or anything else.

Credits

Many thanks to Emmanuel Touzery for creating Hotwire. Core parts of this crate are coming from this tool.

License

Licensed under either of

  • Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
  • MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Core symbols most depended-on inside this repo

input_path
called by 72
src/builder.rs
spawn
called by 70
src/builder.rs
read
called by 34
src/rtshark.rs
read
called by 33
src/rtshark_async.rs
kill
called by 30
src/rtshark.rs
kill
called by 28
src/rtshark_async.rs
layer_name
called by 27
src/packet.rs
live_capture
called by 18
src/builder.rs

Shape

Function 79
Method 78
Class 10
Enum 1

Languages

Rust100%

Modules by API surface

src/rtshark.rs37 symbols
src/rtshark_async.rs35 symbols
src/builder.rs31 symbols
src/xml.rs30 symbols
src/packet.rs13 symbols
src/metadata.rs12 symbols
src/layer.rs10 symbols

For agents

$ claude mcp add rtshark \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page