-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
rust/app-layer: derive functions for app-layer events - v10 #6318
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The derive macro will implement this trait for app-layer event enums.
Currently has one derive, AppLayerEvent to be used like: #[derive(AppLayerEvent)] pub enum DNSEvent { MalformedData, NotRequest, NotResponse, ZFlagSet, } Code will be generated to: - Convert enum to a c type string - Convert string to enum variant - Convert id to enum variant
Provide generic functions for get_event_info and get_event_info_by_id. These functions can be used by any app-layer event enum that implements AppLayerEvent. Unfortunately the parser registration cannot use these functions directly as generic functions cannot be #[no_mangle]. So they do need small extern "C" wrappers around them.
Add generation of wrapper functions for get_event_info and get_event_info_by_id to the derive macro. Eliminates the need for the wrapper method to be created by the parser author.
Implementations are not required if they're just going to return -1. We allow None to be registered for that.
Codecov Report
@@ Coverage Diff @@
## master #6318 +/- ##
=======================================
Coverage 76.95% 76.95%
=======================================
Files 611 611
Lines 185955 185955
=======================================
Hits 143102 143102
Misses 42853 42853
Flags with carried forward coverage won't be shown. Click here to find out more. |
This was referenced Aug 31, 2021
Closed
Closed
Merged
Merged in #6324, thanks! |
AkakiAlice
added a commit
to AkakiAlice/suricata
that referenced
this pull request
Oct 3, 2024
5 tasks
AkakiAlice
added a commit
to AkakiAlice/suricata
that referenced
this pull request
Oct 3, 2024
5 tasks
AkakiAlice
added a commit
to AkakiAlice/suricata
that referenced
this pull request
Oct 5, 2024
5 tasks
victorjulien
pushed a commit
to victorjulien/suricata
that referenced
this pull request
Oct 8, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previous PR: #5579
Redmine issue:
https://redmine.openinfosecfoundation.org/issues/4154
Changes from last PR:
This PR shows how we can use a Rust procedural macro to derive AppLayer event
functions from an emum.
Given an enum like:
supporting code will be added allowing the protocol to register
get_event_info
andget_event_info_by_id
callbacks like:All the parser needs to do is enumerate the different events, the macro will
take care of generating the support code.