Skip to content
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

[draft] bindgen poc - v1 #12018

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft

[draft] bindgen poc - v1 #12018

wants to merge 7 commits into from

Commits on Oct 23, 2024

  1. Configuration menu
    Copy the full SHA
    0216af5 View commit details
    Browse the repository at this point in the history

Commits on Oct 24, 2024

  1. app-layer: extract out a simple function type to simple header

    Extract a simple function function to a simple header with no circular
    dependencies.
    
    Next we'll use bindgen to generate Rust bindings for this function.
    
    Ticket: OISF#7341
    jasonish committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    de28619 View commit details
    Browse the repository at this point in the history
  2. rust: integrate bindgen to generate rust bindings to C

    Add a build.rs to generate Rust bindings to specific C functions at
    build time using the bindgen crate. As can be seen in build.rs, we
    currently only pull in the test header, "app-layer-ext.h" and only
    output items starting with "SC".
    
    Bindgen generates the bindings in a file named "bindings.rs" in the
    target/ direction, which "sys.rs" will statically "include" at
    compiling name, making these bindings available under package
    "crate::sys".
    
    "build.rs" had to be placed in the non-standard location of
    "src/build.rs" (its usually alongside Cargo.toml) to satisfy the
    out-of-tree build requirements of distcheck.
    
    Note that bindgen is also available as a command line tool which could
    be used instead of integrating this at compile time, however the tool
    requires a newer version of Rust than our MSRV, and may present
    additional issues with respect to autoconf and distcheck.
    jasonish committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    ad27d3b View commit details
    Browse the repository at this point in the history
  3. rust: used bindgen generated bindings for StateGetProgressFn

    This function is now named SCAppLayerStateGetProgressFn, note how its
    definition differs from ours:
    
    pub type SCAppLayerStateGetProgressFn = ::std::option::Option<
        unsafe extern "C" fn(
            alstate: *mut ::std::os::raw::c_void,
            direction: u8,
        ) -> ::std::os::raw::c_int,
    >;
    
    Our previous definition:
    
    pub type StateGetProgressFn = unsafe extern "C" fn (*mut c_void, u8) -> c_int;
    
    The main differing being wrapped in an option which makes sense as its
    a function pointer that could be NULL/None, but does require wrapping
    it in an Option now.
    jasonish committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    e010f9b View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    e7f9983 View commit details
    Browse the repository at this point in the history
  5. app-layer: export to SCAppLayerStateGetEventInfoByFn with bindgen

    Rust will now fail, as the discrepancy between i8 and i32 is picked up.
    jasonish committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    8294905 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    6bf01cd View commit details
    Browse the repository at this point in the history