//! This module exposes items from the core "C" code to Rust.
use std;
-use std::os::raw::{c_int, c_void};
+use std::os::raw::c_void;
use suricata_sys::sys::{AppProto, AppProtoEnum, SCLogLevel};
use crate::filecontainer::*;
/// cbindgen:ignore
extern "C" {
pub fn MpmAddPatternCI(
- ctx: *const c_void, pat: *const libc::c_char, pat_len: c_int, _offset: c_int,
- _depth: c_int, id: c_int, rule_id: c_int, _flags: c_int,
+ ctx: *const c_void, pat: *const libc::c_char, pat_len: u16, _offset: u16,
+ _depth: u16, id: u32, rule_id: u32, _flags: u8,
) -> c_void;
}
use std;
use std::ptr;
use std::ffi::{CStr, CString};
-use std::os::raw::{c_char, c_int, c_void};
+use std::os::raw::{c_char, c_void};
use crate::conf::{conf_get, get_memval};
use crate::core::*;
MpmAddPatternCI(
ctx,
name_ptr,
- len as c_int,
+ len as u16,
0,
0,
- index as c_int,
- index as c_int,
+ index as u32,
+ index as u32,
0,
);
}
void SCACTileInitCtx(MpmCtx *);
void SCACTileDestroyCtx(MpmCtx *);
-int SCACTileAddPatternCI(MpmCtx *, uint8_t *, uint16_t, uint16_t, uint16_t,
- uint32_t, SigIntId, uint8_t);
+int SCACTileAddPatternCI(
+ MpmCtx *, const uint8_t *, uint16_t, uint16_t, uint16_t, uint32_t, SigIntId, uint8_t);
int SCACTileAddPatternCS(MpmCtx *, uint8_t *, uint16_t, uint16_t, uint16_t,
uint32_t, SigIntId, uint8_t);
int SCACTilePreparePatterns(MpmConfig *mpm_conf, MpmCtx *mpm_ctx);
* \retval 0 On success.
* \retval -1 On failure.
*/
-int SCACTileAddPatternCI(MpmCtx *mpm_ctx, uint8_t *pat, uint16_t patlen,
- uint16_t offset, uint16_t depth, uint32_t pid,
- SigIntId sid, uint8_t flags)
+int SCACTileAddPatternCI(MpmCtx *mpm_ctx, const uint8_t *pat, uint16_t patlen, uint16_t offset,
+ uint16_t depth, uint32_t pid, SigIntId sid, uint8_t flags)
{
flags |= MPM_PATTERN_FLAG_NOCASE;
return MpmAddPattern(mpm_ctx, pat, patlen, offset, depth,
void SCACInitCtx(MpmCtx *);
void SCACDestroyCtx(MpmCtx *);
-int SCACAddPatternCI(MpmCtx *, uint8_t *, uint16_t, uint16_t, uint16_t,
- uint32_t, SigIntId, uint8_t);
+int SCACAddPatternCI(
+ MpmCtx *, const uint8_t *, uint16_t, uint16_t, uint16_t, uint32_t, SigIntId, uint8_t);
int SCACAddPatternCS(MpmCtx *, uint8_t *, uint16_t, uint16_t, uint16_t,
uint32_t, SigIntId, uint8_t);
int SCACPreparePatterns(MpmConfig *, MpmCtx *mpm_ctx);
* \retval 0 On success.
* \retval -1 On failure.
*/
-int SCACAddPatternCI(MpmCtx *mpm_ctx, uint8_t *pat, uint16_t patlen,
- uint16_t offset, uint16_t depth, uint32_t pid,
- SigIntId sid, uint8_t flags)
+int SCACAddPatternCI(MpmCtx *mpm_ctx, const uint8_t *pat, uint16_t patlen, uint16_t offset,
+ uint16_t depth, uint32_t pid, SigIntId sid, uint8_t flags)
{
flags |= MPM_PATTERN_FLAG_NOCASE;
return MpmAddPattern(mpm_ctx, pat, patlen, offset, depth, pid, sid, flags);
void SCHSInitThreadCtx(MpmCtx *, MpmThreadCtx *);
void SCHSDestroyCtx(MpmCtx *);
void SCHSDestroyThreadCtx(MpmCtx *, MpmThreadCtx *);
-int SCHSAddPatternCI(MpmCtx *, uint8_t *, uint16_t, uint16_t, uint16_t,
- uint32_t, SigIntId, uint8_t);
+int SCHSAddPatternCI(
+ MpmCtx *, const uint8_t *, uint16_t, uint16_t, uint16_t, uint32_t, SigIntId, uint8_t);
int SCHSAddPatternCS(MpmCtx *, uint8_t *, uint16_t, uint16_t, uint16_t,
uint32_t, SigIntId, uint8_t);
int SCHSPreparePatterns(MpmConfig *mpm_conf, MpmCtx *mpm_ctx);
*
* \retval hash A 32 bit unsigned hash.
*/
-static inline uint32_t SCHSInitHashRaw(uint8_t *pat, uint16_t patlen)
+static inline uint32_t SCHSInitHashRaw(const uint8_t *pat, uint16_t patlen)
{
uint32_t hash = patlen * pat[0];
if (patlen > 1)
*
* \retval hash A 32 bit unsigned hash.
*/
-static inline SCHSPattern *SCHSInitHashLookup(SCHSCtx *ctx, uint8_t *pat,
- uint16_t patlen, uint16_t offset,
- uint16_t depth, char flags,
- uint32_t pid)
+static inline SCHSPattern *SCHSInitHashLookup(SCHSCtx *ctx, const uint8_t *pat, uint16_t patlen,
+ uint16_t offset, uint16_t depth, char flags, uint32_t pid)
{
uint32_t hash = SCHSInitHashRaw(pat, patlen);
* \retval 0 On success.
* \retval -1 On failure.
*/
-static int SCHSAddPattern(MpmCtx *mpm_ctx, uint8_t *pat, uint16_t patlen,
- uint16_t offset, uint16_t depth, uint32_t pid,
- SigIntId sid, uint8_t flags)
+static int SCHSAddPattern(MpmCtx *mpm_ctx, const uint8_t *pat, uint16_t patlen, uint16_t offset,
+ uint16_t depth, uint32_t pid, SigIntId sid, uint8_t flags)
{
SCHSCtx *ctx = (SCHSCtx *)mpm_ctx->ctx;
* \retval 0 On success.
* \retval -1 On failure.
*/
-int SCHSAddPatternCI(MpmCtx *mpm_ctx, uint8_t *pat, uint16_t patlen,
- uint16_t offset, uint16_t depth, uint32_t pid,
- SigIntId sid, uint8_t flags)
+int SCHSAddPatternCI(MpmCtx *mpm_ctx, const uint8_t *pat, uint16_t patlen, uint16_t offset,
+ uint16_t depth, uint32_t pid, SigIntId sid, uint8_t flags)
{
flags |= MPM_PATTERN_FLAG_NOCASE;
return SCHSAddPattern(mpm_ctx, pat, patlen, offset, depth, pid, sid, flags);
pid, sid, flags);
}
-int MpmAddPatternCI(struct MpmCtx_ *mpm_ctx, uint8_t *pat, uint16_t patlen,
- uint16_t offset, uint16_t depth,
- uint32_t pid, SigIntId sid, uint8_t flags)
+int MpmAddPatternCI(MpmCtx *mpm_ctx, const uint8_t *pat, uint16_t patlen, uint16_t offset,
+ uint16_t depth, uint32_t pid, SigIntId sid, uint8_t flags)
{
return mpm_table[mpm_ctx->mpm_type].AddPatternNocase(mpm_ctx, pat, patlen,
offset, depth,
*
* \retval hash A 32 bit unsigned hash.
*/
-static inline uint32_t MpmInitHashRaw(uint8_t *pat, uint16_t patlen)
+static inline uint32_t MpmInitHashRaw(const uint8_t *pat, uint16_t patlen)
{
uint32_t hash = patlen * pat[0];
if (patlen > 1)
*
* \retval hash A 32 bit unsigned hash.
*/
-static inline MpmPattern *MpmInitHashLookup(MpmCtx *ctx,
- uint8_t *pat, uint16_t patlen,
- uint16_t offset, uint16_t depth,
- uint8_t flags, uint32_t pid)
+static inline MpmPattern *MpmInitHashLookup(MpmCtx *ctx, const uint8_t *pat, uint16_t patlen,
+ uint16_t offset, uint16_t depth, uint8_t flags, uint32_t pid)
{
uint32_t hash = MpmInitHashRaw(pat, patlen);
* \retval 0 On success.
* \retval -1 On failure.
*/
-int MpmAddPattern(MpmCtx *mpm_ctx, uint8_t *pat, uint16_t patlen,
- uint16_t offset, uint16_t depth, uint32_t pid,
- SigIntId sid, uint8_t flags)
+int MpmAddPattern(MpmCtx *mpm_ctx, const uint8_t *pat, uint16_t patlen, uint16_t offset,
+ uint16_t depth, uint32_t pid, SigIntId sid, uint8_t flags)
{
SCLogDebug("Adding pattern for ctx %p, patlen %"PRIu16" and pid %" PRIu32,
mpm_ctx, patlen, pid);
* \param flags pattern flags
*/
int (*AddPattern)(struct MpmCtx_ *, uint8_t *, uint16_t, uint16_t, uint16_t, uint32_t, SigIntId, uint8_t);
- int (*AddPatternNocase)(struct MpmCtx_ *, uint8_t *, uint16_t, uint16_t, uint16_t, uint32_t, SigIntId, uint8_t);
+ int (*AddPatternNocase)(struct MpmCtx_ *, const uint8_t *, uint16_t, uint16_t, uint16_t,
+ uint32_t, SigIntId, uint8_t);
int (*Prepare)(MpmConfig *, struct MpmCtx_ *);
int (*CacheRuleset)(MpmConfig *);
/** \retval cnt number of patterns that matches: once per pattern max. */
int MpmAddPatternCS(struct MpmCtx_ *mpm_ctx, uint8_t *pat, uint16_t patlen,
uint16_t offset, uint16_t depth,
uint32_t pid, SigIntId sid, uint8_t flags);
-int MpmAddPatternCI(struct MpmCtx_ *mpm_ctx, uint8_t *pat, uint16_t patlen,
- uint16_t offset, uint16_t depth,
- uint32_t pid, SigIntId sid, uint8_t flags);
+int MpmAddPatternCI(MpmCtx *mpm_ctx, const uint8_t *pat, uint16_t patlen, uint16_t offset,
+ uint16_t depth, uint32_t pid, SigIntId sid, uint8_t flags);
void MpmFreePattern(MpmCtx *mpm_ctx, MpmPattern *p);
-int MpmAddPattern(MpmCtx *mpm_ctx, uint8_t *pat, uint16_t patlen,
- uint16_t offset, uint16_t depth, uint32_t pid,
- SigIntId sid, uint8_t flags);
+int MpmAddPattern(MpmCtx *mpm_ctx, const uint8_t *pat, uint16_t patlen, uint16_t offset,
+ uint16_t depth, uint32_t pid, SigIntId sid, uint8_t flags);
#endif /* SURICATA_UTIL_MPM_H */