Optimization #3524

Remove unsafe Rust code for ALPROTO_X constants

Added by Philippe Antoine about 1 year ago. Updated 6 months ago.

Target version:


Now, these constants are defined in C enumeration `AppProtoEnum`

In Rust, we use a global variable ('`static mut`) whose value we get as a return of a C function call.
As a global variable, we must use `unsafe` every time we read it

We should either :
- export these from C to Rust with bindgen
- move this enum to Rust and export it to C with cbindgen (cbindgen is already used)


Updated by Nick Price 10 months ago

Got started on this - moved the enum to Rust and am exporting it with cbindgen

Looks like there are a few "cyclic header dependencies" that will have to be sorted out - other than that it's just a question of safely accessing/mutating the global variables


Updated by Philippe Antoine 10 months ago

Thanks for working on this and letting us know


Updated by Victor Julien 10 months ago

  • Status changed from New to Assigned
  • Assignee set to Nick Price
  • Target version set to TBD

Updated by Nick Price 10 months ago

Think I've got everything sorted except the header cross-dependencies - once that's done I'll run the test suites and make a PR - hopefully what I did makes sense :P


Updated by Philippe Antoine 6 months ago

Hello Nick, where are you with this ? Could you create a draft PR ?

Also available in: Atom PDF