mirror of
https://github.com/OISF/suricata.git
synced 2026-10-12 02:07:10 +00:00
rust: bindgen SCSRepCatGetByShortname
Ticket: 7667
This commit is contained in:
committed by
Victor Julien
parent
368ef839de
commit
92c7be1cb6
@@ -100,7 +100,6 @@ exclude = [
|
||||
"HttpRangeContainerBlock",
|
||||
"IPPROTO_TCP",
|
||||
"IPPROTO_UDP",
|
||||
"SRepCatGetByShortname",
|
||||
"SIGMATCH_NOOPT",
|
||||
"SIGMATCH_INFO_STICKY_BUFFER",
|
||||
"SIGMATCH_INFO_MULTI_BUFFER",
|
||||
|
||||
@@ -21,11 +21,12 @@ use nom7::bytes::complete::tag;
|
||||
use nom7::character::complete::multispace0;
|
||||
use nom7::sequence::preceded;
|
||||
|
||||
use suricata_sys::sys::SCSRepCatGetByShortname;
|
||||
|
||||
use nom7::Err;
|
||||
use nom7::IResult;
|
||||
|
||||
use std::ffi::{CStr, CString};
|
||||
use std::os::raw::c_char;
|
||||
use std::str::FromStr;
|
||||
|
||||
#[repr(u8)]
|
||||
@@ -78,10 +79,6 @@ pub fn is_alphanumeric_or_slash(chr: char) -> bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
pub fn SRepCatGetByShortname(name: *const c_char) -> u8;
|
||||
}
|
||||
|
||||
pub fn detect_parse_iprep(i: &str) -> IResult<&str, DetectIPRepData, RuleParseError<&str>> {
|
||||
// Inner utility function for easy error creation.
|
||||
fn make_error(reason: String) -> nom7::Err<RuleParseError<&'static str>> {
|
||||
@@ -105,7 +102,7 @@ pub fn detect_parse_iprep(i: &str) -> IResult<&str, DetectIPRepData, RuleParseEr
|
||||
} else {
|
||||
return Err(make_error("invalid name".to_string()));
|
||||
};
|
||||
let cat = unsafe { SRepCatGetByShortname(namez.as_ptr()) };
|
||||
let cat = unsafe { SCSRepCatGetByShortname(namez.as_ptr()) };
|
||||
if cat == 0 {
|
||||
return Err(make_error("unknown category".to_string()));
|
||||
}
|
||||
|
||||
@@ -984,3 +984,6 @@ extern "C" {
|
||||
extern "C" {
|
||||
pub fn SCFlowGetDestinationPort(flow: *const Flow) -> u16;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn SCSRepCatGetByShortname(shortname: *const ::std::os::raw::c_char) -> u8;
|
||||
}
|
||||
|
||||
@@ -62,4 +62,6 @@
|
||||
|
||||
#include "flow-bindgen.h"
|
||||
|
||||
#include "reputation.h"
|
||||
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -326,7 +326,7 @@ static int SRepSplitLine(SRepCIDRTree *cidr_ctx, char *line, Address *ip, uint8_
|
||||
#define SREP_SHORTNAME_LEN 32
|
||||
static char srep_cat_table[SREP_MAX_CATS][SREP_SHORTNAME_LEN];
|
||||
|
||||
uint8_t SRepCatGetByShortname(char *shortname)
|
||||
uint8_t SCSRepCatGetByShortname(const char *shortname)
|
||||
{
|
||||
uint8_t cat;
|
||||
for (cat = 0; cat < SREP_MAX_CATS; cat++) {
|
||||
|
||||
+6
-1
@@ -26,6 +26,10 @@
|
||||
#ifndef SURICATA_REPUTATION_H
|
||||
#define SURICATA_REPUTATION_H
|
||||
|
||||
uint8_t SCSRepCatGetByShortname(const char *shortname);
|
||||
|
||||
#ifndef SURICATA_BINDGEN_H
|
||||
|
||||
#include "host.h"
|
||||
#include "util-radix4-tree.h"
|
||||
#include "util-radix6-tree.h"
|
||||
@@ -44,7 +48,6 @@ typedef struct SReputation_ {
|
||||
} SReputation;
|
||||
|
||||
void SRepFreeHostData(Host *h);
|
||||
uint8_t SRepCatGetByShortname(char *shortname);
|
||||
int SRepInit(struct DetectEngineCtx_ *de_ctx);
|
||||
void SRepDestroy(struct DetectEngineCtx_ *de_ctx);
|
||||
void SRepReloadComplete(void);
|
||||
@@ -58,4 +61,6 @@ int SRepLoadFileFromFD(SRepCIDRTree *cidr_ctx, FILE *fp);
|
||||
|
||||
void SCReputationRegisterTests(void);
|
||||
|
||||
#endif // SURICATA_BINDGEN_H
|
||||
|
||||
#endif /* SURICATA_REPUTATION_H */
|
||||
|
||||
Reference in New Issue
Block a user