data: *const c_void,
flags: u8) -> AppLayerResult;
pub type ProbeFn = extern "C" fn (flow: *const Flow,direction: u8,input:*const u8, input_len: u32, rdir: *mut u8) -> AppProto;
-pub type StateAllocFn = extern "C" fn () -> *mut c_void;
+pub type StateAllocFn = extern "C" fn (*mut c_void, AppProto) -> *mut c_void;
pub type StateFreeFn = extern "C" fn (*mut c_void);
pub type StateTxFreeFn = extern "C" fn (*mut c_void, u64);
pub type StateGetTxFn = extern "C" fn (*mut c_void, u64) -> *mut c_void;
}
#[no_mangle]
-pub extern "C" fn rs_template_state_new() -> *mut std::os::raw::c_void {
+pub extern "C" fn rs_template_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void {
let state = TemplateState::new();
let boxed = Box::new(state);
return unsafe { transmute(boxed) };
let r = state.parse_request(&buf[0..9]);
assert_eq!(r, AppLayerResult{ status: 1, consumed: 7, needed: 3});
}
-}
\ No newline at end of file
+}
}
#[no_mangle]
-pub unsafe extern "C" fn rs_dcerpc_state_new() -> *mut std::os::raw::c_void {
+pub unsafe extern "C" fn rs_dcerpc_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: core::AppProto) -> *mut std::os::raw::c_void {
let state = DCERPCState::new();
let boxed = Box::new(state);
transmute(boxed)
}
#[no_mangle]
-pub unsafe extern "C" fn rs_dcerpc_udp_state_new() -> *mut std::os::raw::c_void {
+pub unsafe extern "C" fn rs_dcerpc_udp_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: core::AppProto) -> *mut std::os::raw::c_void {
let state = DCERPCUDPState::new();
let boxed = Box::new(state);
transmute(boxed)
}
#[no_mangle]
-pub extern "C" fn rs_dhcp_state_new() -> *mut std::os::raw::c_void {
+pub extern "C" fn rs_dhcp_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void {
let state = DHCPState::new();
let boxed = Box::new(state);
return unsafe {
/// Returns *mut DNSState
#[no_mangle]
-pub extern "C" fn rs_dns_state_new() -> *mut std::os::raw::c_void {
+pub extern "C" fn rs_dns_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void {
let state = DNSState::new();
let boxed = Box::new(state);
return unsafe{transmute(boxed)};
}
#[no_mangle]
-pub extern "C" fn rs_http2_state_new() -> *mut std::os::raw::c_void {
+pub extern "C" fn rs_http2_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void {
let state = HTTP2State::new();
let boxed = Box::new(state);
return unsafe { transmute(boxed) };
/// Returns *mut IKEV2State
#[no_mangle]
-pub extern "C" fn rs_ikev2_state_new() -> *mut std::os::raw::c_void {
+pub extern "C" fn rs_ikev2_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void {
let state = IKEV2State::new();
let boxed = Box::new(state);
return unsafe{std::mem::transmute(boxed)};
/// Returns *mut KRB5State
#[no_mangle]
-pub extern "C" fn rs_krb5_state_new() -> *mut std::os::raw::c_void {
+pub extern "C" fn rs_krb5_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void {
let state = KRB5State::new();
let boxed = Box::new(state);
return unsafe{std::mem::transmute(boxed)};
}
#[no_mangle]
-pub extern "C" fn rs_mqtt_state_new() -> *mut std::os::raw::c_void {
+pub extern "C" fn rs_mqtt_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void {
let state = MQTTState::new();
let boxed = Box::new(state);
return unsafe { transmute(boxed) };
/// Returns *mut NFSState
#[no_mangle]
-pub extern "C" fn rs_nfs_state_new() -> *mut std::os::raw::c_void {
+pub extern "C" fn rs_nfs_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void {
let state = NFSState::new();
let boxed = Box::new(state);
SCLogDebug!("allocating state");
/// Returns *mut NTPState
#[no_mangle]
-pub extern "C" fn rs_ntp_state_new() -> *mut std::os::raw::c_void {
+pub extern "C" fn rs_ntp_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void {
let state = NTPState::new();
let boxed = Box::new(state);
return unsafe{std::mem::transmute(boxed)};
}
#[no_mangle]
-pub extern "C" fn rs_rdp_state_new() -> *mut std::os::raw::c_void {
+pub extern "C" fn rs_rdp_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void {
let state = RdpState::new();
let boxed = Box::new(state);
return unsafe { std::mem::transmute(boxed) };
);
#[no_mangle]
-pub extern "C" fn rs_rfb_state_new() -> *mut std::os::raw::c_void {
+pub extern "C" fn rs_rfb_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void {
let state = RFBState::new();
let boxed = Box::new(state);
return unsafe { transmute(boxed) };
}
#[no_mangle]
-pub extern "C" fn rs_sip_state_new() -> *mut std::os::raw::c_void {
+pub extern "C" fn rs_sip_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void {
let state = SIPState::new();
let boxed = Box::new(state);
return unsafe { std::mem::transmute(boxed) };
/// Returns *mut SMBState
#[no_mangle]
-pub extern "C" fn rs_smb_state_new() -> *mut std::os::raw::c_void {
+pub extern "C" fn rs_smb_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void {
let state = SMBState::new();
let boxed = Box::new(state);
SCLogDebug!("allocating state");
/// Returns *mut SNMPState
#[no_mangle]
-pub extern "C" fn rs_snmp_state_new() -> *mut std::os::raw::c_void {
+pub extern "C" fn rs_snmp_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void {
let state = SNMPState::new();
let boxed = Box::new(state);
return unsafe{std::mem::transmute(boxed)};
}
#[no_mangle]
-pub extern "C" fn rs_ssh_state_new() -> *mut std::os::raw::c_void {
+pub extern "C" fn rs_ssh_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void {
let state = SSHState::new();
let boxed = Box::new(state);
return unsafe { transmute(boxed) };
local_data, flags);
}
-static void *RustDCERPCUDPStateNew(void)
+static void *RustDCERPCUDPStateNew(void *state_orig, AppProto proto_orig)
{
- return rs_dcerpc_udp_state_new();
+ return rs_dcerpc_udp_state_new(state_orig, proto_orig);
}
static void RustDCERPCUDPStateFree(void *s)
}
}
-static void *RustDCERPCStateNew(void)
+static void *RustDCERPCStateNew(void *state_orig, AppProto proto_orig)
{
- return rs_dcerpc_state_new();
+ return rs_dcerpc_state_new(state_orig, proto_orig);
}
static void DCERPCStateFree(void *s)
*
* The DNP3 state object represents a single DNP3 TCP session.
*/
-static void *DNP3StateAlloc(void)
+static void *DNP3StateAlloc(void *orig_state, AppProto proto_orig)
{
SCEnter();
DNP3State *dnp3;
0xe1, 0xc8, 0x01, 0x01, 0x00, 0x06, 0x77, 0x6e
};
- DNP3State *dnp3state = DNP3StateAlloc();
+ DNP3State *dnp3state = DNP3StateAlloc(NULL, ALPROTO_UNKNOWN);
int pdus = DNP3HandleRequestLinkLayer(dnp3state, pkt, sizeof(pkt));
FAIL_IF(pdus < 1);
DNP3Transaction *dnp3tx = DNP3GetTx(dnp3state, 0);
0xc4, 0x8b
};
- DNP3State *dnp3state = DNP3StateAlloc();
+ DNP3State *dnp3state = DNP3StateAlloc(NULL, ALPROTO_UNKNOWN);
FAIL_IF_NULL(dnp3state);
int bytes = DNP3HandleRequestLinkLayer(dnp3state, pkt, sizeof(pkt));
FAIL_IF(bytes != sizeof(pkt));
DNP3FixCrc(pkt + 10, sizeof(pkt) - 10);
- DNP3State *dnp3state = DNP3StateAlloc();
+ DNP3State *dnp3state = DNP3StateAlloc(NULL, ALPROTO_UNKNOWN);
FAIL_IF_NULL(dnp3state);
int bytes = DNP3HandleRequestLinkLayer(dnp3state, pkt, sizeof(pkt));
FAIL_IF(bytes != sizeof(pkt));
*
* return state
*/
-static void *ENIPStateAlloc(void)
+static void *ENIPStateAlloc(void *orig_state, AppProto proto_orig)
{
SCLogDebug("ENIPStateAlloc");
void *s = SCMalloc(sizeof(ENIPState));
static uint64_t ftp_state_memcnt = 0;
#endif
-static void *FTPStateAlloc(void)
+static void *FTPStateAlloc(void *orig_state, AppProto proto_orig)
{
void *s = FTPCalloc(1, sizeof(FtpState));
if (unlikely(s == NULL))
static uint64_t ftpdata_state_memcnt = 0;
#endif
-static void *FTPDataStateAlloc(void)
+static void *FTPDataStateAlloc(void *orig_state, AppProto proto_orig)
{
void *s = FTPCalloc(1, sizeof(FtpDataState));
if (unlikely(s == NULL))
/** \brief Function to allocates the HTTP state memory and also creates the HTTP
* connection parser to be used by the HTP library
*/
-static void *HTPStateAlloc(void)
+static void *HTPStateAlloc(void *orig_state, AppProto proto_orig)
{
SCEnter();
/** \internal
* \brief Function to allocate the Modbus state memory
*/
-static void *ModbusStateAlloc(void)
+static void *ModbusStateAlloc(void *orig_state, AppProto proto_orig)
{
ModbusState *modbus;
{ NULL, 0 }
};
-static void *NFSTCPStateAlloc(void)
+static void *NFSTCPStateAlloc(void *orig_state, AppProto proto_orig)
{
- return rs_nfs_state_new();
+ return rs_nfs_state_new(orig_state, proto_orig);
}
static void NFSTCPStateFree(void *state)
{ NULL, 0 }
};
-static void *NFSStateAlloc(void)
+static void *NFSStateAlloc(void *orig_state, AppProto proto_orig)
{
- return rs_nfs_state_new();
+ return rs_nfs_state_new(orig_state, proto_orig);
}
static void NFSStateFree(void *state)
bool logger;
uint32_t logger_bits; /**< registered loggers for this proto */
- void *(*StateAlloc)(void);
+ void *(*StateAlloc)(void *, AppProto);
void (*StateFree)(void *);
void (*StateTransactionFree)(void *, uint64_t);
void *(*LocalStorageAlloc)(void);
}
void AppLayerParserRegisterStateFuncs(uint8_t ipproto, AppProto alproto,
- void *(*StateAlloc)(void),
- void (*StateFree)(void *))
+ void *(*StateAlloc)(void *, AppProto), void (*StateFree)(void *))
{
SCEnter();
alstate = f->alstate;
if (alstate == NULL) {
- f->alstate = alstate = p->StateAlloc();
+ f->alstate = alstate = p->StateAlloc(alstate, f->alproto_orig);
if (alstate == NULL)
goto error;
SCLogDebug("alloced new app layer state %p (name %s)",
/** \brief Function to allocates the Test protocol state memory
*/
-static void *TestProtocolStateAlloc(void)
+static void *TestProtocolStateAlloc(void *orig_state, AppProto proto_orig)
{
SCEnter();
void *s = SCMalloc(sizeof(TestState));
void AppLayerParserRegisterOptionFlags(uint8_t ipproto, AppProto alproto,
uint32_t flags);
void AppLayerParserRegisterStateFuncs(uint8_t ipproto, AppProto alproto,
- void *(*StateAlloc)(void),
- void (*StateFree)(void *));
+ void *(*StateAlloc)(void *, AppProto), void (*StateFree)(void *));
void AppLayerParserRegisterLocalStorageFunc(uint8_t ipproto, AppProto proto,
void *(*LocalStorageAlloc)(void),
void (*LocalStorageFree)(void *));
uint16_t min_depth;
uint16_t max_depth;
- void *(*StateAlloc)(void);
+ void *(*StateAlloc)(void *, AppProto);
void (*StateFree)(void *);
AppLayerParserFPtr ParseTS;
* \internal
* \brief Function to allocate SMTP state memory.
*/
-void *SMTPStateAlloc(void)
+void *SMTPStateAlloc(void *orig_state, AppProto proto_orig)
{
SMTPState *smtp_state = SCMalloc(sizeof(SMTPState));
if (unlikely(smtp_state == NULL))
memset(&ssn, 0, sizeof(ssn));
FLOW_INITIALIZE(&f);
f.protoctx = &ssn;
- f.alstate = SMTPStateAlloc();
+ f.alstate = SMTPStateAlloc(NULL, ALPROTO_UNKNOWN);
MimeDecParseState *state = MimeDecInitParser(&f, NULL);
((MimeDecEntity *)state->stack->top->data)->ctnt_flags = CTNT_IS_ATTACHMENT;
state->body_begin = 1;
Flow f;
FLOW_INITIALIZE(&f);
f.protoctx = &ssn;
- f.alstate = SMTPStateAlloc();
+ f.alstate = SMTPStateAlloc(NULL, ALPROTO_UNKNOWN);
MimeDecParseState *state = MimeDecInitParser(&f, NULL);
((MimeDecEntity *)state->stack->top->data)->ctnt_flags = CTNT_IS_ATTACHMENT;
int ret;
Flow f;
FLOW_INITIALIZE(&f);
f.protoctx = &ssn;
- f.alstate = SMTPStateAlloc();
+ f.alstate = SMTPStateAlloc(NULL, ALPROTO_UNKNOWN);
MimeDecParseState *state = MimeDecInitParser(&f, NULL);
((MimeDecEntity *)state->stack->top->data)->ctnt_flags = CTNT_IS_ATTACHMENT;
int ret = MIME_DEC_OK;
int ret;
FLOW_INITIALIZE(&f);
f.protoctx = &ssn;
- f.alstate = SMTPStateAlloc();
+ f.alstate = SMTPStateAlloc(NULL, ALPROTO_UNKNOWN);
FAIL_IF(f.alstate == NULL);
MimeDecParseState *state = MimeDecInitParser(&f, NULL);
((MimeDecEntity *)state->stack->top->data)->ctnt_flags = CTNT_IS_ATTACHMENT;
extern SMTPConfig smtp_config;
int SMTPProcessDataChunk(const uint8_t *chunk, uint32_t len, MimeDecParseState *state);
-void *SMTPStateAlloc(void);
+void *SMTPStateAlloc(void *orig_state, AppProto proto_orig);
void RegisterSMTPParsers(void);
void SMTPParserCleanup(void);
void SMTPParserRegisterTests(void);
* \internal
* \brief Function to allocate the SSL state memory.
*/
-static void *SSLStateAlloc(void)
+static void *SSLStateAlloc(void *orig_state, AppProto proto_orig)
{
SSLState *ssl_state = SCMalloc(sizeof(SSLState));
if (unlikely(ssl_state == NULL))
SCFree(tx);
}
-static void *TemplateStateAlloc(void)
+static void *TemplateStateAlloc(void *orig_state, AppProto proto_orig)
{
SCLogNotice("Allocating template state.");
TemplateState *state = SCCalloc(1, sizeof(TemplateState));
* be the size of a header. */
#define TFTP_MIN_FRAME_LEN 4
-static void *TFTPStateAlloc(void)
+static void *TFTPStateAlloc(void *orig_state, AppProto proto_orig)
{
return rs_tftp_state_alloc();
}
f.protoctx = (void *)&ssn;
f.proto = IPPROTO_TCP;
f.flags |= FLOW_IPV4;
- f.alstate = SMTPStateAlloc();
+ f.alstate = SMTPStateAlloc(NULL, ALPROTO_UNKNOWN);
MimeDecParseState *state = MimeDecInitParser(&f, NULL);
((MimeDecEntity *)state->stack->top->data)->ctnt_flags = CTNT_IS_ATTACHMENT;
f.protoctx = (void *)&ssn;
f.proto = IPPROTO_TCP;
f.flags |= FLOW_IPV4;
- f.alstate = SMTPStateAlloc();
+ f.alstate = SMTPStateAlloc(NULL, ALPROTO_UNKNOWN);
MimeDecParseState *state = MimeDecInitParser(&f, NULL);
((MimeDecEntity *)state->stack->top->data)->ctnt_flags = CTNT_IS_ATTACHMENT;