-
Notifications
You must be signed in to change notification settings - Fork 7
modify dissect_packet function #69
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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: JnanaN <[email protected]>
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
wasmfeature. - Supporting new API that can directly use binary data
- Test cases for different encap types.
| 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.
| 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.
|
|
||
| #[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
wasmas a feature during crate compilation #66 under Addingwasmas a feature during crate compilation #66 (comment)