You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is working well now, but brittle. A user may have type Port = u16. In which case we would wrongly read Port as a struct instead of a u16.
I am proposing a re-write of the main dissection trait such that it can be implemented directly on basic types u8, Vec<u8>, etc. We can then directly leverage the trait in the generated code, i.e. we no longer need to care about what the type of each field is. We just assume the trait is implemented and use the methods.
traitDissect<'tvb,MaybeBytes: ?Sized>{/// We would like to query the value of some fields, e.g. `u8`. If the type supports this/// querying, we set its `Emit` type. Otherwise, `Emit` can be set to `()`.typeEmit;/// Adds the field to the protocol tree. Must return the new packet offset.fnadd_to_tree(args:&DissectorArgs,fields:&mutFieldsStore) -> usize;/// Registers the field. It is the responsibility of the implementor to save the hf index/// and possibly the ett index into the two maps.fnregister(args:RegisterArgs,hf_indices:&mutHashMap<String,c_int>,etts:&mutHashMap<String,c_int>,);/// Returns the value associated with the field, if any.fnemit(args:&DissectorArgs<'_,'tvb>) -> Self::Emit;}traitPrimitive<'tvb,T: ?Sized>:Dissect<'tvb,T>{/// Adds the field to the protocol tree using a custom string. Must return the new packet/// offset.fnadd_to_tree_format_value(args:&DissectorArgs<'_,'tvb>,s:&impl std::fmt::Display,nr_bytes:usize,) -> usize;/// Saves the field into the fields store.fnsave(args:&DissectorArgs<'_,'tvb>,store:&mutFieldsStore<'tvb>);}
We can avoid breaking changes by offering the new API alongside the old one. Once the new one is stable enough, we can remove the old Protocol and ProtocolField API. In any case, there should be minimal changes from the usage perspective as this changes addresses the underlying framework design.
The text was updated successfully, but these errors were encountered:
It dawned upon me that we should aim to make the dissection-related trait more useful.
Currently, we form an internal model of field types in a "stringy" way: https://github.com/ghpr-asia/wsdf/blob/0fc4333dc6f783101567b46a484e12f2863bbdf3/wsdf-derive/src/types.rs#L140C1-L148C61
This is working well now, but brittle. A user may have
type Port = u16
. In which case we would wrongly readPort
as a struct instead of au16
.I am proposing a re-write of the main dissection trait such that it can be implemented directly on basic types
u8
,Vec<u8>
, etc. We can then directly leverage the trait in the generated code, i.e. we no longer need to care about what the type of each field is. We just assume the trait is implemented and use the methods.Progress will be in https://github.com/immanuelhume/wsdf/tree/proper-impls. As a initial cut, I have designed the trait like so:
We can avoid breaking changes by offering the new API alongside the old one. Once the new one is stable enough, we can remove the old
Protocol
andProtocolField
API. In any case, there should be minimal changes from the usage perspective as this changes addresses the underlying framework design.The text was updated successfully, but these errors were encountered: