rust: bindgen SCFlowGetAppProtocol

pull/15240/head
Philippe Antoine 4 months ago committed by Victor Julien
parent fd31e50954
commit a36af353bc

@ -1755,6 +1755,9 @@ extern "C" {
extern "C" {
pub fn SCFlowGetDestinationPort(flow: *const Flow) -> u16;
}
extern "C" {
pub fn SCFlowGetAppProtocol(f: *const Flow) -> AppProto;
}
extern "C" {
pub fn SCSRepCatGetByShortname(shortname: *const ::std::os::raw::c_char) -> u8;
}

@ -29,6 +29,7 @@
#include "decode.h"
#include "packet.h"
#include "flow.h"
#include "flow-bindgen.h"
#include "stream-tcp.h"
#include "app-layer.h"
#include "app-layer-parser.h"
@ -1012,7 +1013,7 @@ static DetectRunScratchpad DetectRunSetup(const DetectEngineCtx *de_ctx,
{
/* update flow flags with knowledge on disruptions */
flow_flags = FlowGetDisruptionFlags(pflow, flow_flags);
alproto = FlowGetAppProtocol(pflow);
alproto = SCFlowGetAppProtocol(pflow);
if (p->proto == IPPROTO_TCP && pflow->protoctx &&
StreamReassembleRawHasDataReady(pflow->protoctx, p)) {
p->flags |= PKT_DETECT_HAS_STREAMDATA;

@ -25,5 +25,6 @@ void SCFlowGetLastTimeAsParts(const Flow *flow, uint64_t *secs, uint64_t *usecs)
uint64_t SCFlowGetFlags(const Flow *flow);
uint16_t SCFlowGetSourcePort(const Flow *flow);
uint16_t SCFlowGetDestinationPort(const Flow *flow);
AppProto SCFlowGetAppProtocol(const Flow *f);
#endif /* SURICATA_FLOW_BINDGEN_H */

@ -1231,6 +1231,11 @@ uint16_t SCFlowGetSourcePort(const Flow *flow)
return flow->sp;
}
AppProto SCFlowGetAppProtocol(const Flow *f)
{
return f->alproto;
}
/**
* \brief Get flow destination port.
*

@ -576,12 +576,6 @@ SCFlowStorageId GetFlowBypassInfoID(void);
void RegisterFlowBypassInfo(void);
/** ----- Inline functions ----- */
static inline AppProto FlowGetAppProtocol(const Flow *f)
{
return f->alproto;
}
static inline void *FlowGetAppState(const Flow *f)
{
return f->alstate;
@ -648,7 +642,6 @@ static inline bool FlowIsBypassed(const Flow *f)
int FlowClearMemory(Flow *,uint8_t );
AppProto FlowGetAppProtocol(const Flow *f);
void *FlowGetAppState(const Flow *f);
uint8_t FlowGetDisruptionFlags(const Flow *f, uint8_t flags);

@ -28,6 +28,7 @@
#include "packet.h"
#include "detect.h"
#include "flow.h"
#include "flow-bindgen.h"
#include "conf.h"
#include "stream.h"
@ -322,7 +323,7 @@ static void AlertAddPayload(AlertJsonOutputCtx *json_output_ctx, SCJsonBuilder *
static void AlertAddAppLayer(
const Packet *p, SCJsonBuilder *jb, const uint64_t tx_id, const uint16_t option_flags)
{
const AppProto proto = FlowGetAppProtocol(p->flow);
const AppProto proto = SCFlowGetAppProtocol(p->flow);
EveJsonSimpleAppLayerLogger *al = SCEveJsonSimpleGetLogger(proto);
SCJsonBuilderMark mark = { 0, 0, 0 };
if (al && al->LogTx) {
@ -668,7 +669,7 @@ static int AlertJson(ThreadVars *tv, JsonAlertLogThread *aft, const Packet *p)
char xff_buffer[XFF_MAXLEN];
xff_buffer[0] = 0;
if ((xff_cfg != NULL) && !(xff_cfg->flags & XFF_DISABLED) && p->flow != NULL) {
if (FlowGetAppProtocol(p->flow) == ALPROTO_HTTP1) {
if (SCFlowGetAppProtocol(p->flow) == ALPROTO_HTTP1) {
if (pa->flags & PACKET_ALERT_FLAG_TX) {
have_xff_ip = HttpXFFGetIPFromTx(p->flow, pa->tx_id, xff_cfg,
xff_buffer, XFF_MAXLEN);

@ -51,6 +51,7 @@
#include "output-json.h"
#include "output-json-email-common.h"
#include "flow-bindgen.h"
#define LOG_EMAIL_DEFAULT 0
#define LOG_EMAIL_EXTENDED (1<<0)
@ -141,7 +142,7 @@ static bool EveEmailLogJsonData(
MimeStateSMTP *mime_state;
/* check if we have SMTP state or not */
AppProto proto = FlowGetAppProtocol(f);
AppProto proto = SCFlowGetAppProtocol(f);
switch (proto) {
case ALPROTO_SMTP:
smtp_state = (SMTPState *)state;

@ -66,6 +66,7 @@
#include "app-layer-htp-xff.h"
#include "util-memcmp.h"
#include "stream-tcp-reassemble.h"
#include "flow-bindgen.h"
typedef struct OutputFileCtx_ {
uint32_t file_cnt;
@ -104,7 +105,7 @@ SCJsonBuilder *JsonBuildFileInfoRecord(const Packet *p, const File *ff, void *tx
int have_xff_ip = 0;
char xff_buffer[XFF_MAXLEN];
if ((xff_cfg != NULL) && !(xff_cfg->flags & XFF_DISABLED)) {
if (FlowGetAppProtocol(p->flow) == ALPROTO_HTTP1) {
if (SCFlowGetAppProtocol(p->flow) == ALPROTO_HTTP1) {
have_xff_ip = HttpXFFGetIPFromTx(p->flow, tx_id, xff_cfg, xff_buffer, XFF_MAXLEN);
}
if (have_xff_ip && xff_cfg->flags & XFF_OVERWRITE) {

Loading…
Cancel
Save