From fd389891137ab249158a9d036293943d7462f51b Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Tue, 31 Jul 2018 09:34:29 +0200 Subject: [PATCH] proto/detect: remove probing parser offset argument Remove offset argument as it was unused. --- rust/src/dhcp/dhcp.rs | 3 +-- rust/src/ikev2/ikev2.rs | 2 +- rust/src/krb/krb5.rs | 6 +++--- rust/src/ntp/ntp.rs | 2 +- rust/src/parser.rs | 2 +- src/app-layer-detect-proto.c | 11 +++++------ src/app-layer-detect-proto.h | 3 +-- src/app-layer-dnp3.c | 13 ++++++------- src/app-layer-dns-tcp-rust.c | 3 +-- src/app-layer-dns-tcp.c | 13 +++++-------- src/app-layer-dns-udp-rust.c | 3 +-- src/app-layer-dns-udp.c | 3 +-- src/app-layer-enip.c | 3 +-- src/app-layer-modbus.c | 3 +-- src/app-layer-nfs-tcp.c | 6 ++---- src/app-layer-nfs-udp.c | 6 ++---- src/app-layer-smb-tcp-rust.c | 2 +- src/app-layer-smb.c | 3 +-- src/app-layer-ssl.c | 3 +-- src/app-layer-template.c | 3 +-- src/app-layer-tftp.c | 3 +-- 21 files changed, 38 insertions(+), 58 deletions(-) diff --git a/rust/src/dhcp/dhcp.rs b/rust/src/dhcp/dhcp.rs index 8bfb3bd367..835af50f7f 100644 --- a/rust/src/dhcp/dhcp.rs +++ b/rust/src/dhcp/dhcp.rs @@ -201,8 +201,7 @@ impl DHCPState { #[no_mangle] pub extern "C" fn rs_dhcp_probing_parser(_flow: *const Flow, input: *const libc::uint8_t, - input_len: u32, - _offset: *const u32) -> AppProto { + input_len: u32) -> AppProto { if input_len < DHCP_MIN_FRAME_LEN { return ALPROTO_UNKNOWN; } diff --git a/rust/src/ikev2/ikev2.rs b/rust/src/ikev2/ikev2.rs index 908ab57e76..e41eeb51de 100644 --- a/rust/src/ikev2/ikev2.rs +++ b/rust/src/ikev2/ikev2.rs @@ -610,7 +610,7 @@ pub extern "C" fn rs_ikev2_state_get_event_info(event_name: *const libc::c_char, static mut ALPROTO_IKEV2 : AppProto = ALPROTO_UNKNOWN; #[no_mangle] -pub extern "C" fn rs_ikev2_probing_parser(_flow: *const Flow, input:*const libc::uint8_t, input_len: u32, _offset: *const u32) -> AppProto { +pub extern "C" fn rs_ikev2_probing_parser(_flow: *const Flow, input:*const libc::uint8_t, input_len: u32) -> AppProto { let slice = build_slice!(input,input_len as usize); let alproto = unsafe{ ALPROTO_IKEV2 }; match parse_ikev2_header(slice) { diff --git a/rust/src/krb/krb5.rs b/rust/src/krb/krb5.rs index 846a5505c0..4116478137 100644 --- a/rust/src/krb/krb5.rs +++ b/rust/src/krb/krb5.rs @@ -404,7 +404,7 @@ pub extern "C" fn rs_krb5_state_get_event_info(event_name: *const libc::c_char, static mut ALPROTO_KRB5 : AppProto = ALPROTO_UNKNOWN; #[no_mangle] -pub extern "C" fn rs_krb5_probing_parser(_flow: *const Flow, input:*const libc::uint8_t, input_len: u32, _offset: *const u32) -> AppProto { +pub extern "C" fn rs_krb5_probing_parser(_flow: *const Flow, input:*const libc::uint8_t, input_len: u32) -> AppProto { let slice = build_slice!(input,input_len as usize); let alproto = unsafe{ ALPROTO_KRB5 }; if slice.len() <= 10 { return unsafe{ALPROTO_FAILED}; } @@ -438,13 +438,13 @@ pub extern "C" fn rs_krb5_probing_parser(_flow: *const Flow, input:*const libc:: } #[no_mangle] -pub extern "C" fn rs_krb5_probing_parser_tcp(_flow: *const Flow, input:*const libc::uint8_t, input_len: u32, _offset: *const u32) -> AppProto { +pub extern "C" fn rs_krb5_probing_parser_tcp(_flow: *const Flow, input:*const libc::uint8_t, input_len: u32) -> AppProto { let slice = build_slice!(input,input_len as usize); if slice.len() <= 14 { return unsafe{ALPROTO_FAILED}; } match be_u32(slice) { IResult::Done(rem, record_mark) => { if record_mark != rem.len() as u32 { return unsafe{ALPROTO_FAILED}; } - return rs_krb5_probing_parser(_flow, rem.as_ptr(), rem.len() as u32, _offset); + return rs_krb5_probing_parser(_flow, rem.as_ptr(), rem.len() as u32); }, IResult::Incomplete(_) => { return ALPROTO_UNKNOWN; diff --git a/rust/src/ntp/ntp.rs b/rust/src/ntp/ntp.rs index ee6b4a02fb..c3d1b2247c 100644 --- a/rust/src/ntp/ntp.rs +++ b/rust/src/ntp/ntp.rs @@ -343,7 +343,7 @@ pub extern "C" fn rs_ntp_state_get_event_info(event_name: *const libc::c_char, static mut ALPROTO_NTP : AppProto = ALPROTO_UNKNOWN; #[no_mangle] -pub extern "C" fn ntp_probing_parser(_flow: *const Flow, input:*const u8, input_len: u32, _offset: *const u32) -> AppProto { +pub extern "C" fn ntp_probing_parser(_flow: *const Flow, input:*const u8, input_len: u32) -> AppProto { let slice: &[u8] = unsafe { std::slice::from_raw_parts(input as *mut u8, input_len as usize) }; let alproto = unsafe{ ALPROTO_NTP }; match parse_ntp(slice) { diff --git a/rust/src/parser.rs b/rust/src/parser.rs index dce39f827c..d7ae41946c 100644 --- a/rust/src/parser.rs +++ b/rust/src/parser.rs @@ -125,7 +125,7 @@ pub type ParseFn = extern "C" fn (flow: *const Flow, input_len: u32, data: *const c_void, flags: u8) -> i8; -pub type ProbeFn = extern "C" fn (flow: *const Flow,input:*const u8, input_len: u32, offset: *const u32) -> AppProto; +pub type ProbeFn = extern "C" fn (flow: *const Flow,input:*const u8, input_len: u32) -> AppProto; pub type StateAllocFn = extern "C" fn () -> *mut c_void; pub type StateFreeFn = extern "C" fn (*mut c_void); pub type StateTxFreeFn = extern "C" fn (*mut c_void, u64); diff --git a/src/app-layer-detect-proto.c b/src/app-layer-detect-proto.c index 04144981d0..3a976c63fc 100644 --- a/src/app-layer-detect-proto.c +++ b/src/app-layer-detect-proto.c @@ -420,9 +420,9 @@ static AppProto AppLayerProtoDetectPPGetProto(Flow *f, } if (direction & STREAM_TOSERVER && pe->ProbingParserTs != NULL) { - alproto = pe->ProbingParserTs(f, buf, buflen, NULL); + alproto = pe->ProbingParserTs(f, buf, buflen); } else if (pe->ProbingParserTc != NULL) { - alproto = pe->ProbingParserTc(f, buf, buflen, NULL); + alproto = pe->ProbingParserTc(f, buf, buflen); } if (alproto != ALPROTO_UNKNOWN && alproto != ALPROTO_FAILED) goto end; @@ -441,9 +441,9 @@ static AppProto AppLayerProtoDetectPPGetProto(Flow *f, } if (direction & STREAM_TOSERVER && pe->ProbingParserTs != NULL) { - alproto = pe->ProbingParserTs(f, buf, buflen, NULL); + alproto = pe->ProbingParserTs(f, buf, buflen); } else if (pe->ProbingParserTc != NULL) { - alproto = pe->ProbingParserTc(f, buf, buflen, NULL); + alproto = pe->ProbingParserTc(f, buf, buflen); } if (alproto != ALPROTO_UNKNOWN && alproto != ALPROTO_FAILED) goto end; @@ -3105,8 +3105,7 @@ static int AppLayerProtoDetectPPTestData(AppLayerProtoDetectProbingParser *pp, static uint16_t ProbingParserDummyForTesting(Flow *f, uint8_t *input, - uint32_t input_len, - uint32_t *offset) + uint32_t input_len) { return 0; } diff --git a/src/app-layer-detect-proto.h b/src/app-layer-detect-proto.h index 89e430f8ce..0f0e3a97d5 100644 --- a/src/app-layer-detect-proto.h +++ b/src/app-layer-detect-proto.h @@ -28,8 +28,7 @@ typedef struct AppLayerProtoDetectThreadCtx_ AppLayerProtoDetectThreadCtx; typedef AppProto (*ProbingParserFPtr)(Flow *f, - uint8_t *input, uint32_t input_len, - uint32_t *offset); + uint8_t *input, uint32_t input_len); /***** Protocol Retrieval *****/ diff --git a/src/app-layer-dnp3.c b/src/app-layer-dnp3.c index fe12d77964..61945a4046 100644 --- a/src/app-layer-dnp3.c +++ b/src/app-layer-dnp3.c @@ -264,8 +264,7 @@ static int DNP3ContainsBanner(const uint8_t *input, uint32_t len) /** * \brief DNP3 probing parser. */ -static uint16_t DNP3ProbingParser(Flow *f, uint8_t *input, uint32_t len, - uint32_t *offset) +static uint16_t DNP3ProbingParser(Flow *f, uint8_t *input, uint32_t len) { DNP3LinkHeader *hdr = (DNP3LinkHeader *)input; @@ -2044,25 +2043,25 @@ static int DNP3ProbingParserTest(void) }; /* Valid frame. */ - FAIL_IF(DNP3ProbingParser(NULL, pkt, sizeof(pkt), NULL) != ALPROTO_DNP3); + FAIL_IF(DNP3ProbingParser(NULL, pkt, sizeof(pkt)) != ALPROTO_DNP3); /* Send too little bytes. */ - FAIL_IF(DNP3ProbingParser(NULL, pkt, sizeof(DNP3LinkHeader) - 1, NULL) != ALPROTO_UNKNOWN); + FAIL_IF(DNP3ProbingParser(NULL, pkt, sizeof(DNP3LinkHeader) - 1) != ALPROTO_UNKNOWN); /* Bad start bytes. */ pkt[0] = 0x06; - FAIL_IF(DNP3ProbingParser(NULL, pkt, sizeof(pkt), NULL) != ALPROTO_FAILED); + FAIL_IF(DNP3ProbingParser(NULL, pkt, sizeof(pkt)) != ALPROTO_FAILED); /* Restore start byte. */ pkt[0] = 0x05; /* Set the length to a value less than the minimum length of 5. */ pkt[2] = 0x03; - FAIL_IF(DNP3ProbingParser(NULL, pkt, sizeof(pkt), NULL) != ALPROTO_FAILED); + FAIL_IF(DNP3ProbingParser(NULL, pkt, sizeof(pkt)) != ALPROTO_FAILED); /* Send a banner. */ char mybanner[] = "Welcome to DNP3 SCADA."; - FAIL_IF(DNP3ProbingParser(NULL, (uint8_t *)mybanner, sizeof(mybanner), NULL) != ALPROTO_DNP3); + FAIL_IF(DNP3ProbingParser(NULL, (uint8_t *)mybanner, sizeof(mybanner)) != ALPROTO_DNP3); PASS; } diff --git a/src/app-layer-dns-tcp-rust.c b/src/app-layer-dns-tcp-rust.c index 7739cde506..1ecb34a04b 100644 --- a/src/app-layer-dns-tcp-rust.c +++ b/src/app-layer-dns-tcp-rust.c @@ -52,8 +52,7 @@ static int RustDNSTCPParseResponse(Flow *f, void *state, local_data); } -static uint16_t RustDNSTCPProbe(Flow *f, uint8_t *input, uint32_t len, - uint32_t *offset) +static uint16_t RustDNSTCPProbe(Flow *f, uint8_t *input, uint32_t len) { SCLogDebug("RustDNSTCPProbe"); if (len == 0 || len < sizeof(DNSHeader)) { diff --git a/src/app-layer-dns-tcp.c b/src/app-layer-dns-tcp.c index 4945123e68..8a27985d39 100644 --- a/src/app-layer-dns-tcp.c +++ b/src/app-layer-dns-tcp.c @@ -62,8 +62,7 @@ struct DNSTcpHeader_ { } __attribute__((__packed__)); typedef struct DNSTcpHeader_ DNSTcpHeader; -static uint16_t DNSTcpProbingParser(Flow *f, uint8_t *input, uint32_t ilen, - uint32_t *offset); +static uint16_t DNSTcpProbingParser(Flow *f, uint8_t *input, uint32_t ilen); /** \internal * \param input_len at least enough for the DNSTcpHeader @@ -317,7 +316,7 @@ static int DNSTCPRequestParse(Flow *f, void *dstate, /* Clear gap state. */ if (dns_state->gap_ts) { - if (DNSTcpProbingParser(f, input, input_len, NULL) == ALPROTO_DNS) { + if (DNSTcpProbingParser(f, input, input_len) == ALPROTO_DNS) { SCLogDebug("New data probed as DNS, clearing gap state."); BufferReset(dns_state); dns_state->gap_ts = 0; @@ -557,7 +556,7 @@ static int DNSTCPResponseParse(Flow *f, void *dstate, /* Clear gap state. */ if (dns_state->gap_tc) { - if (DNSTcpProbingParser(f, input, input_len, NULL) == ALPROTO_DNS) { + if (DNSTcpProbingParser(f, input, input_len) == ALPROTO_DNS) { SCLogDebug("New data probed as DNS, clearing gap state."); BufferReset(dns_state); dns_state->gap_tc = 0; @@ -639,8 +638,7 @@ bad_data: SCReturnInt(-1); } -static uint16_t DNSTcpProbingParser(Flow *f, uint8_t *input, uint32_t ilen, - uint32_t *offset) +static uint16_t DNSTcpProbingParser(Flow *f, uint8_t *input, uint32_t ilen) { if (ilen == 0 || ilen < sizeof(DNSTcpHeader)) { SCLogDebug("ilen too small, hoped for at least %"PRIuMAX, (uintmax_t)sizeof(DNSTcpHeader)); @@ -680,8 +678,7 @@ static uint16_t DNSTcpProbingParser(Flow *f, uint8_t *input, uint32_t ilen, * This is a minimal parser that just checks that the input contains enough * data for a TCP DNS response. */ -static uint16_t DNSTcpProbeResponse(Flow *f, uint8_t *input, uint32_t len, - uint32_t *offset) +static uint16_t DNSTcpProbeResponse(Flow *f, uint8_t *input, uint32_t len) { if (len == 0 || len < sizeof(DNSTcpHeader)) { return ALPROTO_UNKNOWN; diff --git a/src/app-layer-dns-udp-rust.c b/src/app-layer-dns-udp-rust.c index 8c3388e1cd..0411b9febb 100644 --- a/src/app-layer-dns-udp-rust.c +++ b/src/app-layer-dns-udp-rust.c @@ -50,8 +50,7 @@ static int RustDNSUDPParseResponse(Flow *f, void *state, local_data); } -static uint16_t DNSUDPProbe(Flow *f, uint8_t *input, uint32_t len, - uint32_t *offset) +static uint16_t DNSUDPProbe(Flow *f, uint8_t *input, uint32_t len) { if (len == 0 || len < sizeof(DNSHeader)) { return ALPROTO_UNKNOWN; diff --git a/src/app-layer-dns-udp.c b/src/app-layer-dns-udp.c index 44a2fceb85..24d68875eb 100644 --- a/src/app-layer-dns-udp.c +++ b/src/app-layer-dns-udp.c @@ -330,8 +330,7 @@ insufficient_data: SCReturnInt(-1); } -static uint16_t DNSUdpProbingParser(Flow *f, uint8_t *input, uint32_t ilen, - uint32_t *offset) +static uint16_t DNSUdpProbingParser(Flow *f, uint8_t *input, uint32_t ilen) { if (ilen == 0 || ilen < sizeof(DNSHeader)) { SCLogDebug("ilen too small, hoped for at least %"PRIuMAX, (uintmax_t)sizeof(DNSHeader)); diff --git a/src/app-layer-enip.c b/src/app-layer-enip.c index c35dbf764c..743a84b262 100644 --- a/src/app-layer-enip.c +++ b/src/app-layer-enip.c @@ -359,8 +359,7 @@ static int ENIPParse(Flow *f, void *state, AppLayerParserState *pstate, -static uint16_t ENIPProbingParser(Flow *f, uint8_t *input, uint32_t input_len, - uint32_t *offset) +static uint16_t ENIPProbingParser(Flow *f, uint8_t *input, uint32_t input_len) { // SCLogDebug("ENIPProbingParser %d", input_len); if (input_len < sizeof(ENIPEncapHdr)) diff --git a/src/app-layer-modbus.c b/src/app-layer-modbus.c index e96a9c60c1..c945b4c579 100644 --- a/src/app-layer-modbus.c +++ b/src/app-layer-modbus.c @@ -1428,8 +1428,7 @@ static void ModbusStateFree(void *state) static uint16_t ModbusProbingParser(Flow *f, uint8_t *input, - uint32_t input_len, - uint32_t *offset) + uint32_t input_len) { ModbusHeader *header = (ModbusHeader *) input; diff --git a/src/app-layer-nfs-tcp.c b/src/app-layer-nfs-tcp.c index 5e22fdd534..abd816b3ea 100644 --- a/src/app-layer-nfs-tcp.c +++ b/src/app-layer-nfs-tcp.c @@ -112,8 +112,7 @@ static AppLayerDecoderEvents *NFSTCPGetEvents(void *state, uint64_t id) * \retval ALPROTO_NFS if it looks like echo, otherwise * ALPROTO_UNKNOWN. */ -static AppProto NFSTCPProbingParserTS(Flow *f, uint8_t *input, uint32_t input_len, - uint32_t *offset) +static AppProto NFSTCPProbingParserTS(Flow *f, uint8_t *input, uint32_t input_len) { if (input_len < NFSTCP_MIN_FRAME_LEN) { return ALPROTO_UNKNOWN; @@ -130,8 +129,7 @@ static AppProto NFSTCPProbingParserTS(Flow *f, uint8_t *input, uint32_t input_le return ALPROTO_UNKNOWN; } -static AppProto NFSTCPProbingParserTC(Flow *f, uint8_t *input, uint32_t input_len, - uint32_t *offset) +static AppProto NFSTCPProbingParserTC(Flow *f, uint8_t *input, uint32_t input_len) { if (input_len < NFSTCP_MIN_FRAME_LEN) { return ALPROTO_UNKNOWN; diff --git a/src/app-layer-nfs-udp.c b/src/app-layer-nfs-udp.c index 42378b05a8..50cce89790 100644 --- a/src/app-layer-nfs-udp.c +++ b/src/app-layer-nfs-udp.c @@ -109,8 +109,7 @@ static AppLayerDecoderEvents *NFSGetEvents(void *state, uint64_t id) * \retval ALPROTO_NFS if it looks like echo, otherwise * ALPROTO_UNKNOWN. */ -static AppProto NFSProbingParserTS(Flow *f, uint8_t *input, uint32_t input_len, - uint32_t *offset) +static AppProto NFSProbingParserTS(Flow *f, uint8_t *input, uint32_t input_len) { SCLogDebug("probing"); if (input_len < NFS_MIN_FRAME_LEN) { @@ -131,8 +130,7 @@ static AppProto NFSProbingParserTS(Flow *f, uint8_t *input, uint32_t input_len, return ALPROTO_UNKNOWN; } -static AppProto NFSProbingParserTC(Flow *f, uint8_t *input, uint32_t input_len, - uint32_t *offset) +static AppProto NFSProbingParserTC(Flow *f, uint8_t *input, uint32_t input_len) { SCLogDebug("probing"); if (input_len < NFS_MIN_FRAME_LEN) { diff --git a/src/app-layer-smb-tcp-rust.c b/src/app-layer-smb-tcp-rust.c index 634e90dc2a..a12307c1bf 100644 --- a/src/app-layer-smb-tcp-rust.c +++ b/src/app-layer-smb-tcp-rust.c @@ -78,7 +78,7 @@ static int RustSMBTCPParseResponse(Flow *f, void *state, } static uint16_t RustSMBTCPProbe(Flow *f, - uint8_t *input, uint32_t len, uint32_t *offset) + uint8_t *input, uint32_t len) { SCLogDebug("RustSMBTCPProbe"); diff --git a/src/app-layer-smb.c b/src/app-layer-smb.c index d036481eb2..1cb07b4e83 100644 --- a/src/app-layer-smb.c +++ b/src/app-layer-smb.c @@ -1510,8 +1510,7 @@ static int SMBGetAlstateProgress(void *tx, uint8_t direction) #define SMB_PROBING_PARSER_MIN_DEPTH 8 -static uint16_t SMBProbingParser(Flow *f, uint8_t *input, uint32_t ilen, - uint32_t *offset) +static uint16_t SMBProbingParser(Flow *f, uint8_t *input, uint32_t ilen) { int32_t len; int32_t input_len = ilen; diff --git a/src/app-layer-ssl.c b/src/app-layer-ssl.c index 5e4333e19f..6eadc42a43 100644 --- a/src/app-layer-ssl.c +++ b/src/app-layer-ssl.c @@ -2332,8 +2332,7 @@ static void SSLStateTransactionFree(void *state, uint64_t tx_id) /* do nothing */ } -static uint16_t SSLProbingParser(Flow *f, uint8_t *input, uint32_t ilen, - uint32_t *offset) +static uint16_t SSLProbingParser(Flow *f, uint8_t *input, uint32_t ilen) { /* probably a rst/fin sending an eof */ if (ilen == 0) diff --git a/src/app-layer-template.c b/src/app-layer-template.c index 26885163c7..d66fab7189 100644 --- a/src/app-layer-template.c +++ b/src/app-layer-template.c @@ -195,8 +195,7 @@ static AppLayerDecoderEvents *TemplateGetEvents(void *state, uint64_t tx_id) * \retval ALPROTO_TEMPLATE if it looks like echo, otherwise * ALPROTO_UNKNOWN. */ -static AppProto TemplateProbingParser(Flow *f, uint8_t *input, uint32_t input_len, - uint32_t *offset) +static AppProto TemplateProbingParser(Flow *f, uint8_t *input, uint32_t input_len) { /* Very simple test - if there is input, this is echo. */ if (input_len >= TEMPLATE_MIN_FRAME_LEN) { diff --git a/src/app-layer-tftp.c b/src/app-layer-tftp.c index b2a3a17172..733baadbed 100644 --- a/src/app-layer-tftp.c +++ b/src/app-layer-tftp.c @@ -112,8 +112,7 @@ static AppLayerDecoderEvents *TFTPGetEvents(void *state, uint64_t tx_id) * \retval ALPROTO_TFTP if it looks like echo, otherwise * ALPROTO_UNKNOWN. */ -static AppProto TFTPProbingParser(Flow *f, uint8_t *input, uint32_t input_len, - uint32_t *offset) +static AppProto TFTPProbingParser(Flow *f, uint8_t *input, uint32_t input_len) { /* Very simple test - if there is input, this is tftp. * Also check if it's starting by a zero */