-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
modify dissect_packet function #69
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: JnanaN <jnanabhushan943@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This mostly looks okay, here are a few suggestions using -
- Conditional compilation for
wasm
feature. - Supporting new API that can directly use binary data
- Test cases for different encap types.
@@ -19,6 +19,10 @@ serde = { version = "1.0", features = ["derive"] } | |||
serde_json = { version = "1.0" } | |||
erased-serde = "0.4" | |||
log = { version = "0.4", optional = true } | |||
console_error_panic_hook = "0.1.6" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and next three two dependencies should be added only when feature wasm
is used.
#[wasm_bindgen_test] | ||
fn simple_dissect_test() { | ||
let bytestream = "003096e6fc3900309605283888470001ddff45c0002800030000ff06a4e80a0102010a2200012af90017983210058dd58ea55010102099cd00000000"; | ||
scalpel::dissect_packet(bytestream.to_string()); | ||
let encap_type = scalpel::ENCAP_TYPE_ETH; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and other ENCAP_TYPE_*
constants should be exported to the JS world. Not sure whether this is possible. I
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's indeed not possible to export constants we can ignore this one. I tried around a bit, but couldn't find an easy way to do it.
scalpel::dissect_packet(bytestream.to_string()); | ||
let encap_type = scalpel::ENCAP_TYPE_ETH; | ||
|
||
match scalpel::dissect_packet(encap_type, bytestream.to_string()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also add another API something like dissect_packet_bin
when the data is available as actual binary data. While using this, we realized there's an unnecessary round trip to hex string and back. So see if that can be avoided by defining new API.
@@ -5,11 +5,23 @@ | |||
extern crate wasm_bindgen_test; | |||
use wasm_bindgen_test::*; | |||
|
|||
use web_sys::console::error_1; | |||
use web_sys::console::log_1; | |||
wasm_bindgen_test_configure!(run_in_browser); | |||
|
|||
#[wasm_bindgen_test] | |||
fn simple_dissect_test() { | |||
let bytestream = "003096e6fc3900309605283888470001ddff45c0002800030000ff06a4e80a0102010a2200012af90017983210058dd58ea55010102099cd00000000"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If possible try to add a test case or two for other encap types as well.
This PR adds following features
as mentioned in Adding
wasm
as a feature during crate compilation #66 under Addingwasm
as a feature during crate compilation #66 (comment)