rust: bindgen functions neede for features

Ticket: 7762
pull/14332/head
Philippe Antoine 9 months ago committed by Victor Julien
parent b21c93d789
commit 12892ba010

@ -46,17 +46,13 @@ mod mock {
#[cfg(not(test))]
mod real {
use std::ffi::CString;
use std::os::raw::c_char;
use suricata_sys::sys::{SCRequiresFeature, SCSigTableHasKeyword};
extern "C" {
fn RequiresFeature(feature: *const c_char) -> bool;
fn SigTableHasKeyword(keyword: *const c_char) -> bool;
}
/// Check for a feature returning true if found.
pub fn requires(feature: &str) -> bool {
if let Ok(feature) = CString::new(feature) {
unsafe { RequiresFeature(feature.as_ptr()) }
unsafe { SCRequiresFeature(feature.as_ptr()) }
} else {
false
}
@ -64,7 +60,7 @@ mod real {
pub fn has_keyword(keyword: &str) -> bool {
if let Ok(keyword) = CString::new(keyword) {
unsafe { SigTableHasKeyword(keyword.as_ptr()) }
unsafe { SCSigTableHasKeyword(keyword.as_ptr()) }
} else {
false
}

@ -177,6 +177,9 @@ extern "C" {
KeywordsRegister: ::std::option::Option<unsafe extern "C" fn()>,
) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn SCSigTableHasKeyword(keyword: *const ::std::os::raw::c_char) -> bool;
}
extern "C" {
pub fn SCDetectHelperKeywordSetCleanCString(id: u16);
}
@ -1031,3 +1034,6 @@ extern "C" {
extern "C" {
pub fn SCSRepCatGetByShortname(shortname: *const ::std::os::raw::c_char) -> u8;
}
extern "C" {
pub fn SCRequiresFeature(arg1: *const ::std::os::raw::c_char) -> bool;
}

@ -64,5 +64,6 @@
#include "flow-bindgen.h"
#include "reputation.h"
#include "feature.h"
#endif

@ -1715,7 +1715,7 @@ void EngineAnalysisRules(const DetectEngineCtx *de_ctx,
} /* for ( ; list_id < DETECT_SM_LIST_MAX; list_id++) */
if (file_store && !RequiresFeature("output::file-store")) {
if (file_store && !SCRequiresFeature("output::file-store")) {
rule_warning += 1;
warn_file_store_not_present = 1;
}

@ -387,7 +387,7 @@ static void SigMultilinePrint(size_t i, const char *prefix)
}
/** \brief Check if a keyword exists. */
bool SigTableHasKeyword(const char *keyword)
bool SCSigTableHasKeyword(const char *keyword)
{
for (int i = 0; i < DETECT_TBLSIZE; i++) {
const char *name = sigmatch_table[i].name;

@ -339,7 +339,7 @@ void SigTableInit(void);
void SigTableSetup(void);
int SCSigTablePreRegister(void (*KeywordsRegister)(void));
void SigTableRegisterTests(void);
bool SigTableHasKeyword(const char *keyword);
bool SCSigTableHasKeyword(const char *keyword);
void SCDetectHelperKeywordSetCleanCString(uint16_t id);
#endif /* SURICATA_DETECT_ENGINE_REGISTER_H */

@ -354,7 +354,7 @@ static int DetectFilestoreSetup (DetectEngineCtx *de_ctx, Signature *s, const ch
SCLogDebug("reload-detected; re-checking feature presence; DE version now %"PRIu32,
de_ctx->version);
}
if (!RequiresFeature(FEATURE_OUTPUT_FILESTORE)) {
if (!SCRequiresFeature(FEATURE_OUTPUT_FILESTORE)) {
SCLogWarning("One or more rule(s) depends on the "
"file-store output log which is not enabled. "
"Enable the output \"file-store\".");

@ -123,7 +123,7 @@ void ProvidesFeature(const char *feature_name)
SCMutexUnlock(&feature_table_mutex);
}
bool RequiresFeature(const char *feature_name)
bool SCRequiresFeature(const char *feature_name)
{
FeatureEntryType f = { feature_name };

@ -30,7 +30,7 @@
#define FEATURE_JA4 "ja4"
void ProvidesFeature(const char *);
bool RequiresFeature(const char *);
bool SCRequiresFeature(const char *);
void FeatureDump(void);

@ -110,7 +110,7 @@ static inline struct landlock_ruleset *LandlockCreateRuleset(void)
return NULL;
}
if (abi < 2) {
if (RequiresFeature(FEATURE_OUTPUT_FILESTORE)) {
if (SCRequiresFeature(FEATURE_OUTPUT_FILESTORE)) {
SCLogError("Landlock disabled: need Linux 5.19+ for file store support");
SCFree(ruleset);
return NULL;

Loading…
Cancel
Save