From a3b08f670c488e2d14515dc0eedb9240d4855f7b Mon Sep 17 00:00:00 2001 From: Abhijit Gadgil Date: Sun, 5 May 2024 15:07:03 +0530 Subject: [PATCH] Minor fixes in example and README updated Signed-off-by: Abhijit Gadgil --- README.md | 17 +++++++++++++++-- examples/packet_sculpting.rs | 6 +++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index b69f314..b0b7648 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ `scalpel` is a crate for Packet Dissection and Sculpting in Rust. -Scalpel can be used for dissecting packets on the wire and or generating packets from some specifications that can be sent on wire (This functionality is not being implemented at present). Goal of 'scalpel' is to be able to be able to make packet dissection API friendly so that it's easier to use it in any application. See Examples in the `examples/` directory to get an idea of what kind of 'applications' it can be used in. +Scalpel can be used for dissecting packets on the wire and or generating packets from some specifications that can be sent on wire (This functionality is very early in development and a proof of concept implementation is available). Goal of 'scalpel' is to be able to be able to make packet dissection API friendly so that it's easier to use it in any application. See Examples in the `examples/` directory to get an idea of what kind of 'applications' it can be used in. This is still early, actively being developed, the APIs are not stable and are likely to change substantially. @@ -16,4 +16,17 @@ Right now the supported API allows one to dissect packets on wire and display as 1. `packet_json` - An example that demonstrates how any `buffer` can be read as a `scalpel::Packet` structure. 1. `pcap` - An example that demonstrates how to display packets in Json format those captured on the wire. (this should be run as `sudo`). -By default, python bindings are disabled. If you want python bindings, use `--features="python-bindings"` command line argument while building or running the code. Refer to [`using-python-bindings.md`](https://github.com/gabhijit/scalpel/blob/master/using-python-bindings.md) to get started with using Python bindings. Currently, only we provide a basic dissection and displaying a packet as json functionality from the Python bindings. This support is a WIP. +# Features + +## Python Bindings + +An experimental Python API is available to demonstrate how scalpel can be used for packet dissection from Python. By default, python bindings are disabled. Python bindings can be enabled using `--features="python-bindings"` command line argument while building or running the code. Refer to ['Using Python Bindings'](https://github.com/gabhijit/scalpel/blob/master/using-python-bindings.md) to get started with using Python bindings. Currently, only we provide a basic dissection and displaying a packet as json functionality from the Python bindings. This support is a WIP. + + +## Wasm support + +An experimental 'wasm' support is available. This support can be enabled using `--features=wasm`. Please note `python-bindings` and `wasm` are mutually exclusive features. [This repository](https://github.com/ystero-dev/scalpel-examples) contains an example using 'actix' based web server for running packet dissection inside the browser. + +## Packet Generation (or Sculpting) + +This is a WIP and a very early support. An initial implementation of creating a simple Ethernet and IP based packet and then serializing to wire is currently implemented. The goal of this feature is it should be possible to have an API friendly Packet Generator using `scalpel` crate. diff --git a/examples/packet_sculpting.rs b/examples/packet_sculpting.rs index 02bcf33..688f06a 100644 --- a/examples/packet_sculpting.rs +++ b/examples/packet_sculpting.rs @@ -20,9 +20,9 @@ fn main() -> Result<(), Box> { let res_string = result[0] .iter() - .fold(String::new(), |acc, num| format!("{}{:02x}", acc, num)) - .trim_end() - .to_string(); + .map(|num| format!("{:02x}", num)) + .collect::>() + .join(""); println!("Packet Data: {:#?}", res_string);