pub extern "C" fn rs_dns_parse_request(_flow: *mut core::Flow,
state: &mut DNSState,
_pstate: *mut std::os::raw::c_void,
- input: *mut u8,
+ input: *const u8,
input_len: u32,
_data: *mut std::os::raw::c_void)
-> i8 {
pub extern "C" fn rs_dns_parse_response(_flow: *mut core::Flow,
state: &mut DNSState,
_pstate: *mut std::os::raw::c_void,
- input: *mut u8,
+ input: *const u8,
input_len: u32,
_data: *mut std::os::raw::c_void)
-> i8 {
pub extern "C" fn rs_dns_parse_request_tcp(_flow: *mut core::Flow,
state: &mut DNSState,
_pstate: *mut std::os::raw::c_void,
- input: *mut u8,
+ input: *const u8,
input_len: u32,
_data: *mut std::os::raw::c_void)
-> i8 {
pub extern "C" fn rs_dns_parse_response_tcp(_flow: *mut core::Flow,
state: &mut DNSState,
_pstate: *mut std::os::raw::c_void,
- input: *mut u8,
+ input: *const u8,
input_len: u32,
_data: *mut std::os::raw::c_void)
-> i8 {
pub extern "C" fn rs_nfs_parse_request(_flow: *mut Flow,
state: &mut NFSState,
_pstate: *mut std::os::raw::c_void,
- input: *mut u8,
+ input: *const u8,
input_len: u32,
_data: *mut std::os::raw::c_void)
-> i8
pub extern "C" fn rs_nfs_parse_response(_flow: *mut Flow,
state: &mut NFSState,
_pstate: *mut std::os::raw::c_void,
- input: *mut u8,
+ input: *const u8,
input_len: u32,
_data: *mut std::os::raw::c_void)
-> i8
pub extern "C" fn rs_nfs_parse_request_udp(_flow: *mut Flow,
state: &mut NFSState,
_pstate: *mut std::os::raw::c_void,
- input: *mut u8,
+ input: *const u8,
input_len: u32,
_data: *mut std::os::raw::c_void)
-> i8
pub extern "C" fn rs_nfs_parse_response_udp(_flow: *mut Flow,
state: &mut NFSState,
_pstate: *mut std::os::raw::c_void,
- input: *mut u8,
+ input: *const u8,
input_len: u32,
_data: *mut std::os::raw::c_void)
-> i8
pub extern "C" fn rs_smb_parse_request_tcp(_flow: *mut Flow,
state: &mut SMBState,
_pstate: *mut std::os::raw::c_void,
- input: *mut u8,
+ input: *const u8,
input_len: u32,
_data: *mut std::os::raw::c_void,
flags: u8)
pub extern "C" fn rs_smb_parse_response_tcp(_flow: *mut Flow,
state: &mut SMBState,
_pstate: *mut std::os::raw::c_void,
- input: *mut u8,
+ input: *const u8,
input_len: u32,
_data: *mut std::os::raw::c_void,
flags: u8)
#define USER_DATA_NOT_READABLE 6 /* not used */
#define NO_PSAP_AVAILABLE 7 /* not used */
-int32_t DCERPCParser(DCERPC *, uint8_t *, uint32_t);
+int32_t DCERPCParser(DCERPC *, const uint8_t *, uint32_t);
void hexdump(const void *buf, size_t len);
void printUUID(const char *type, DCERPCUuidEntry *uuid);
/** \internal
* \retval stub_len or 0 in case of error */
static uint32_t FragmentDataParser(Flow *f, void *dcerpcudp_state,
- AppLayerParserState *pstate, uint8_t *input, uint32_t input_len)
+ AppLayerParserState *pstate, const uint8_t *input, uint32_t input_len)
{
SCEnter();
DCERPCUDPState *sstate = (DCERPCUDPState *) dcerpcudp_state;
* fragmented packets.
*/
static int DCERPCUDPParseHeader(Flow *f, void *dcerpcudp_state,
- AppLayerParserState *pstate, uint8_t *input, uint32_t input_len)
+ AppLayerParserState *pstate, const uint8_t *input, uint32_t input_len)
{
SCEnter();
- uint8_t *p = input;
+ const uint8_t *p = input;
DCERPCUDPState *sstate = (DCERPCUDPState *) dcerpcudp_state;
if (input_len) {
switch (sstate->bytesprocessed) {
}
static int DCERPCUDPParse(Flow *f, void *dcerpc_state,
- AppLayerParserState *pstate, uint8_t *input, uint32_t input_len,
+ AppLayerParserState *pstate, const uint8_t *input, uint32_t input_len,
void *local_data, const uint8_t flags)
{
uint32_t retval = 0;
* \brief DCERPCParseSecondaryAddr reads secondaryaddrlen bytes from the BIND_ACK
* DCERPC call.
*/
-static uint32_t DCERPCParseSecondaryAddr(DCERPC *dcerpc, uint8_t *input, uint32_t input_len)
+static uint32_t DCERPCParseSecondaryAddr(DCERPC *dcerpc, const uint8_t *input, uint32_t input_len)
{
SCEnter();
- uint8_t *p = input;
+ const uint8_t *p = input;
while (dcerpc->dcerpcbindbindack.secondaryaddrlenleft-- && input_len--) {
SCLogDebug("0x%02x ", *p);
p++;
SCReturnUInt((uint32_t)(p - input));
}
-static uint32_t PaddingParser(DCERPC *dcerpc, uint8_t *input, uint32_t input_len)
+static uint32_t PaddingParser(DCERPC *dcerpc, const uint8_t *input, uint32_t input_len)
{
SCEnter();
- uint8_t *p = input;
+ const uint8_t *p = input;
while (dcerpc->padleft-- && input_len--) {
SCLogDebug("0x%02x ", *p);
p++;
SCReturnUInt((uint32_t)(p - input));
}
-static uint32_t DCERPCGetCTXItems(DCERPC *dcerpc, uint8_t *input, uint32_t input_len)
+static uint32_t DCERPCGetCTXItems(DCERPC *dcerpc, const uint8_t *input, uint32_t input_len)
{
SCEnter();
- uint8_t *p = input;
+ const uint8_t *p = input;
if (input_len) {
switch (dcerpc->dcerpcbindbindack.ctxbytesprocessed) {
case 0:
* each UUID is added to a TAILQ.
*/
-static uint32_t DCERPCParseBINDCTXItem(DCERPC *dcerpc, uint8_t *input, uint32_t input_len)
+static uint32_t DCERPCParseBINDCTXItem(DCERPC *dcerpc, const uint8_t *input, uint32_t input_len)
{
SCEnter();
- uint8_t *p = input;
+ const uint8_t *p = input;
if (input_len) {
switch (dcerpc->dcerpcbindbindack.ctxbytesprocessed) {
* the BIND_ACK call. The result (Accepted or Rejected) is added to the
* correct UUID from the BIND call.
*/
-static uint32_t DCERPCParseBINDACKCTXItem(DCERPC *dcerpc, uint8_t *input, uint32_t input_len)
+static uint32_t DCERPCParseBINDACKCTXItem(DCERPC *dcerpc, const uint8_t *input, uint32_t input_len)
{
SCEnter();
- uint8_t *p = input;
+ const uint8_t *p = input;
DCERPCUuidEntry *uuid_entry;
if (input_len) {
SCReturnUInt((uint32_t)(p - input));
}
-static uint32_t DCERPCParseBIND(DCERPC *dcerpc, uint8_t *input, uint32_t input_len)
+static uint32_t DCERPCParseBIND(DCERPC *dcerpc, const uint8_t *input, uint32_t input_len)
{
SCEnter();
- uint8_t *p = input;
+ const uint8_t *p = input;
if (input_len) {
switch (dcerpc->bytesprocessed) {
case 16:
SCReturnUInt((uint32_t)(p - input));
}
-static uint32_t DCERPCParseBINDACK(DCERPC *dcerpc, uint8_t *input, uint32_t input_len)
+static uint32_t DCERPCParseBINDACK(DCERPC *dcerpc, const uint8_t *input, uint32_t input_len)
{
SCEnter();
- uint8_t *p = input;
+ const uint8_t *p = input;
switch (dcerpc->bytesprocessed) {
case 16:
SCReturnUInt((uint32_t)(p - input));
}
-static uint32_t DCERPCParseREQUEST(DCERPC *dcerpc, uint8_t *input, uint32_t input_len)
+static uint32_t DCERPCParseREQUEST(DCERPC *dcerpc, const uint8_t *input, uint32_t input_len)
{
SCEnter();
- uint8_t *p = input;
+ const uint8_t *p = input;
switch (dcerpc->bytesprocessed) {
case 16:
* \retval -1 if DCERPC Header does not validate
* \retval Number of bytes processed
*/
-static int DCERPCParseHeader(DCERPC *dcerpc, uint8_t *input, uint32_t input_len)
+static int DCERPCParseHeader(DCERPC *dcerpc, const uint8_t *input, uint32_t input_len)
{
SCEnter();
- uint8_t *p = input;
+ const uint8_t *p = input;
if (input_len) {
SCLogDebug("dcerpc->bytesprocessed %u", dcerpc->bytesprocessed);
return;
}
-static inline int DCERPCThrowOutExtraData(DCERPC *dcerpc, uint8_t *input,
+static inline int DCERPCThrowOutExtraData(DCERPC *dcerpc, const uint8_t *input,
uint16_t input_len)
{
int parsed = 0;
* a condition where it has receives a segment with 2 pdus, while the
* first pdu in the segment is corrupt.
*/
-int32_t DCERPCParser(DCERPC *dcerpc, uint8_t *input, uint32_t input_len)
+int32_t DCERPCParser(DCERPC *dcerpc, const uint8_t *input, uint32_t input_len)
{
SCEnter();
static int DCERPCParse(Flow *f, void *dcerpc_state,
AppLayerParserState *pstate,
- uint8_t *input, uint32_t input_len,
+ const uint8_t *input, uint32_t input_len,
void *local_data, int dir)
{
SCEnter();
static int DCERPCParseRequest(Flow *f, void *dcerpc_state,
AppLayerParserState *pstate,
- uint8_t *input, uint32_t input_len,
+ const uint8_t *input, uint32_t input_len,
void *local_data, const uint8_t flags)
{
return DCERPCParse(f, dcerpc_state, pstate, input, input_len,
static int DCERPCParseResponse(Flow *f, void *dcerpc_state,
AppLayerParserState *pstate,
- uint8_t *input, uint32_t input_len,
+ const uint8_t *input, uint32_t input_len,
void *local_data, const uint8_t flags)
{
return DCERPCParse(f, dcerpc_state, pstate, input, input_len,
const AppLayerProtoDetectPMSignature *s,
AppLayerProtoDetectThreadCtx *tctx,
Flow *f, uint8_t direction,
- uint8_t *buf, uint16_t buflen, uint16_t searchlen,
+ const uint8_t *buf, uint16_t buflen, uint16_t searchlen,
bool *rflow)
{
SCEnter();
SCReturnUInt(ALPROTO_UNKNOWN);
}
- uint8_t *sbuf = buf + s->cd->offset;
+ const uint8_t *sbuf = buf + s->cd->offset;
uint16_t ssearchlen = s->cd->depth - s->cd->offset;
SCLogDebug("s->co->offset (%"PRIu16") s->cd->depth (%"PRIu16")",
s->cd->offset, s->cd->depth);
AppLayerProtoDetectThreadCtx *tctx,
AppLayerProtoDetectPMCtx *pm_ctx,
MpmThreadCtx *mpm_tctx,
- Flow *f, uint8_t *buf, uint16_t buflen,
+ Flow *f, const uint8_t *buf, uint16_t buflen,
uint8_t direction, AppProto *pm_results, bool *rflow)
{
int pm_matches = 0;
* \param pm_results[out] AppProto array of size ALPROTO_MAX */
static AppProto AppLayerProtoDetectPMGetProto(
AppLayerProtoDetectThreadCtx *tctx,
- Flow *f, uint8_t *buf, uint16_t buflen,
+ Flow *f, const uint8_t *buf, uint16_t buflen,
uint8_t direction, AppProto *pm_results, bool *rflow)
{
SCEnter();
static inline AppProto PPGetProto(
const AppLayerProtoDetectProbingParserElement *pe,
Flow *f, uint8_t direction,
- uint8_t *buf, uint32_t buflen,
+ const uint8_t *buf, uint32_t buflen,
uint32_t *alproto_masks, uint8_t *rdir
)
{
*
*/
static AppProto AppLayerProtoDetectPPGetProto(Flow *f,
- uint8_t *buf, uint32_t buflen,
+ const uint8_t *buf, uint32_t buflen,
uint8_t ipproto, const uint8_t idir,
bool *reverse_flow)
{
AppProto AppLayerProtoDetectGetProto(AppLayerProtoDetectThreadCtx *tctx,
Flow *f,
- uint8_t *buf, uint32_t buflen,
+ const uint8_t *buf, uint32_t buflen,
uint8_t ipproto, uint8_t direction,
bool *reverse_flow)
{
}
static uint16_t ProbingParserDummyForTesting(Flow *f, uint8_t direction,
- uint8_t *input,
+ const uint8_t *input,
uint32_t input_len, uint8_t *rdir)
{
return 0;
typedef struct AppLayerProtoDetectThreadCtx_ AppLayerProtoDetectThreadCtx;
typedef AppProto (*ProbingParserFPtr)(Flow *f, uint8_t dir,
- uint8_t *input, uint32_t input_len,
+ const uint8_t *input, uint32_t input_len,
uint8_t *rdir);
/***** Protocol Retrieval *****/
*/
AppProto AppLayerProtoDetectGetProto(AppLayerProtoDetectThreadCtx *tctx,
Flow *f,
- uint8_t *buf, uint32_t buflen,
+ const uint8_t *buf, uint32_t buflen,
uint8_t ipproto, uint8_t direction,
bool *reverse_flow);
* \brief DNP3 probing parser.
*/
static uint16_t DNP3ProbingParser(Flow *f, uint8_t direction,
- uint8_t *input, uint32_t len,
+ const uint8_t *input, uint32_t len,
uint8_t *rdir)
{
DNP3LinkHeader *hdr = (DNP3LinkHeader *)input;
* multiple frames, but not the complete final frame).
*/
static int DNP3ParseRequest(Flow *f, void *state, AppLayerParserState *pstate,
- uint8_t *input, uint32_t input_len, void *local_data,
+ const uint8_t *input, uint32_t input_len, void *local_data,
const uint8_t flags)
{
SCEnter();
* See DNP3ParseResponsePDUs for DNP3 frame handling.
*/
static int DNP3ParseResponse(Flow *f, void *state, AppLayerParserState *pstate,
- uint8_t *input, uint32_t input_len, void *local_data,
+ const uint8_t *input, uint32_t input_len, void *local_data,
const uint8_t flags)
{
SCEnter();
#endif
static int RustDNSTCPParseRequest(Flow *f, void *state,
- AppLayerParserState *pstate, uint8_t *input, uint32_t input_len,
+ AppLayerParserState *pstate, const uint8_t *input, uint32_t input_len,
void *local_data, const uint8_t flags)
{
SCLogDebug("RustDNSTCPParseRequest");
}
static int RustDNSTCPParseResponse(Flow *f, void *state,
- AppLayerParserState *pstate, uint8_t *input, uint32_t input_len,
+ AppLayerParserState *pstate, const uint8_t *input, uint32_t input_len,
void *local_data, const uint8_t flags)
{
SCLogDebug("RustDNSTCPParseResponse");
}
static uint16_t RustDNSTCPProbe(Flow *f, uint8_t direction,
- uint8_t *input, uint32_t len, uint8_t *rdir)
+ const uint8_t *input, uint32_t len, uint8_t *rdir)
{
SCLogDebug("RustDNSTCPProbe");
if (len == 0 || len < sizeof(DNSHeader)) {
#endif
static int RustDNSUDPParseRequest(Flow *f, void *state,
- AppLayerParserState *pstate, uint8_t *input, uint32_t input_len,
+ AppLayerParserState *pstate, const uint8_t *input, uint32_t input_len,
void *local_data, const uint8_t flags)
{
return rs_dns_parse_request(f, state, pstate, input, input_len,
}
static int RustDNSUDPParseResponse(Flow *f, void *state,
- AppLayerParserState *pstate, uint8_t *input, uint32_t input_len,
+ AppLayerParserState *pstate, const uint8_t *input, uint32_t input_len,
void *local_data, const uint8_t flags)
{
return rs_dns_parse_response(f, state, pstate, input, input_len,
}
static uint16_t DNSUDPProbe(Flow *f, uint8_t direction,
- uint8_t *input, uint32_t len, uint8_t *rdir)
+ const uint8_t *input, uint32_t len, uint8_t *rdir)
{
if (len == 0 || len < sizeof(DNSHeader)) {
return ALPROTO_UNKNOWN;
* @param input
* @param offset
*/
-static int ENIPExtractUint8(uint8_t *res, uint8_t *input, uint16_t *offset, uint32_t input_len)
+static int ENIPExtractUint8(uint8_t *res, const uint8_t *input, uint16_t *offset, uint32_t input_len)
{
if (input_len < sizeof(uint8_t) || *offset > (input_len - sizeof(uint8_t)))
* @param input
* @param offset
*/
-static int ENIPExtractUint16(uint16_t *res, uint8_t *input, uint16_t *offset, uint32_t input_len)
+static int ENIPExtractUint16(uint16_t *res, const uint8_t *input, uint16_t *offset, uint32_t input_len)
{
if (input_len < sizeof(uint16_t) || *offset > (input_len - sizeof(uint16_t)))
* @param input
* @param offset
*/
-static int ENIPExtractUint32(uint32_t *res, uint8_t *input, uint16_t *offset, uint32_t input_len)
+static int ENIPExtractUint32(uint32_t *res, const uint8_t *input, uint16_t *offset, uint32_t input_len)
{
if (input_len < sizeof(uint32_t) || *offset > (input_len - sizeof(uint32_t)))
* @param input
* @param offset
*/
-static int ENIPExtractUint64(uint64_t *res, uint8_t *input, uint16_t *offset, uint32_t input_len)
+static int ENIPExtractUint64(uint64_t *res, const uint8_t *input, uint16_t *offset, uint32_t input_len)
{
if (input_len < sizeof(uint64_t) || *offset > (input_len - sizeof(uint64_t)))
* @return 1 Packet ok
* @return 0 Packet has errors
*/
-int DecodeENIPPDU(uint8_t *input, uint32_t input_len,
+int DecodeENIPPDU(const uint8_t *input, uint32_t input_len,
ENIPTransaction *enip_data)
{
int ret = 1;
* @return 1 Packet ok
* @return 0 Packet has errors
*/
-int DecodeCommonPacketFormatPDU(uint8_t *input, uint32_t input_len,
+int DecodeCommonPacketFormatPDU(const uint8_t *input, uint32_t input_len,
ENIPTransaction *enip_data, uint16_t offset)
{
* @return 0 Packet has errors
*/
-int DecodeCIPPDU(uint8_t *input, uint32_t input_len,
+int DecodeCIPPDU(const uint8_t *input, uint32_t input_len,
ENIPTransaction *enip_data, uint16_t offset)
{
int ret = 1;
* @return 1 Packet ok
* @return 0 Packet has errors
*/
-int DecodeCIPRequestPDU(uint8_t *input, uint32_t input_len,
+int DecodeCIPRequestPDU(const uint8_t *input, uint32_t input_len,
ENIPTransaction *enip_data, uint16_t offset)
{
int ret = 1;
* @return 1 Packet matches
* @return 0 Packet not match
*/
-int DecodeCIPRequestPathPDU(uint8_t *input, uint32_t input_len,
+int DecodeCIPRequestPathPDU(const uint8_t *input, uint32_t input_len,
CIPServiceEntry *node, uint16_t offset)
{
//SCLogDebug("DecodeCIPRequestPath: service 0x%x size %d length %d",
* @return 1 Packet ok
* @return 0 Packet has errors
*/
-int DecodeCIPResponsePDU(uint8_t *input, uint32_t input_len,
+int DecodeCIPResponsePDU(const uint8_t *input, uint32_t input_len,
ENIPTransaction *enip_data, uint16_t offset)
{
int ret = 1;
* @return 1 Packet ok
* @return 0 Packet has errors
*/
-int DecodeCIPRequestMSPPDU(uint8_t *input, uint32_t input_len,
+int DecodeCIPRequestMSPPDU(const uint8_t *input, uint32_t input_len,
ENIPTransaction *enip_data, uint16_t offset)
{
int ret = 1;
* @return 1 Packet ok
* @return 0 Packet has errors
*/
-int DecodeCIPResponseMSPPDU(uint8_t *input, uint32_t input_len,
+int DecodeCIPResponseMSPPDU(const uint8_t *input, uint32_t input_len,
ENIPTransaction *enip_data, uint16_t offset)
{
int ret = 1;
uint8_t *buffer;
} ENIPState;
-int DecodeENIPPDU(uint8_t *input, uint32_t input_len,
+int DecodeENIPPDU(const uint8_t *input, uint32_t input_len,
ENIPTransaction *enip_data);
-int DecodeCommonPacketFormatPDU(uint8_t *input, uint32_t input_len,
+int DecodeCommonPacketFormatPDU(const uint8_t *input, uint32_t input_len,
ENIPTransaction *enip_data, uint16_t offset);
-int DecodeCIPPDU(uint8_t *input, uint32_t input_len,
+int DecodeCIPPDU(const uint8_t *input, uint32_t input_len,
ENIPTransaction *enip_data, uint16_t offset);
-int DecodeCIPRequestPDU(uint8_t *input, uint32_t input_len,
+int DecodeCIPRequestPDU(const uint8_t *input, uint32_t input_len,
ENIPTransaction *enip_data, uint16_t offset);
-int DecodeCIPResponsePDU(uint8_t *input, uint32_t input_len,
+int DecodeCIPResponsePDU(const uint8_t *input, uint32_t input_len,
ENIPTransaction *enip_data, uint16_t offset);
-int DecodeCIPRequestPathPDU(uint8_t *input, uint32_t input_len,
+int DecodeCIPRequestPathPDU(const uint8_t *input, uint32_t input_len,
CIPServiceEntry *node, uint16_t offset);
-int DecodeCIPRequestMSPPDU(uint8_t *input, uint32_t input_len,
+int DecodeCIPRequestMSPPDU(const uint8_t *input, uint32_t input_len,
ENIPTransaction *enip_data, uint16_t offset);
-int DecodeCIPResponseMSPPDU(uint8_t *input, uint32_t input_len,
+int DecodeCIPResponseMSPPDU(const uint8_t *input, uint32_t input_len,
ENIPTransaction *enip_data, uint16_t offset);
#endif /* __APP_LAYER_ENIP_COMMON_H__ */
* \retval 1 when the command is parsed, 0 otherwise
*/
static int ENIPParse(Flow *f, void *state, AppLayerParserState *pstate,
- uint8_t *input, uint32_t input_len, void *local_data,
+ const uint8_t *input, uint32_t input_len, void *local_data,
const uint8_t flags)
{
SCEnter();
static uint16_t ENIPProbingParser(Flow *f, uint8_t direction,
- uint8_t *input, uint32_t input_len, uint8_t *rdir)
+ const uint8_t *input, uint32_t input_len, uint8_t *rdir)
{
// SCLogDebug("ENIPProbingParser %d", input_len);
if (input_len < sizeof(ENIPEncapHdr))
* \retval 1 when the command is parsed, 0 otherwise
*/
static int FTPParseRequestCommand(FTPThreadCtx *td,
- uint8_t *input, uint32_t input_len,
+ const uint8_t *input, uint32_t input_len,
const FtpCommand **cmd_descriptor)
{
SCEnter();
FTPFree(cmd, sizeof(struct FtpTransferCmd));
}
-static uint32_t CopyCommandLine(uint8_t **dest, uint8_t *src, uint32_t length)
+static uint32_t CopyCommandLine(uint8_t **dest, const uint8_t *src, uint32_t length)
{
if (likely(length)) {
uint8_t *where = FTPCalloc(length + 1, sizeof(char));
*
* \retval 0 if a port number could not be extracted; otherwise, the dynamic port number
*/
-static uint16_t FTPGetV6PortNumber(uint8_t *input, uint32_t input_len)
+static uint16_t FTPGetV6PortNumber(const uint8_t *input, uint32_t input_len)
{
uint16_t res;
*
* \retval 0 if a port number could not be extracted; otherwise, the dynamic port number
*/
-static uint16_t FTPGetV4PortNumber(uint8_t *input, uint32_t input_len)
+static uint16_t FTPGetV4PortNumber(const uint8_t *input, uint32_t input_len)
{
uint16_t part1, part2;
uint8_t *ptr = memrchr(input, ',', input_len);
*/
static int FTPParseRequest(Flow *f, void *ftp_state,
AppLayerParserState *pstate,
- uint8_t *input, uint32_t input_len,
+ const uint8_t *input, uint32_t input_len,
void *local_data, const uint8_t flags)
{
FTPThreadCtx *thread_data = local_data;
return 1;
}
-static int FTPParsePassiveResponse(Flow *f, FtpState *state, uint8_t *input, uint32_t input_len)
+static int FTPParsePassiveResponse(Flow *f, FtpState *state, const uint8_t *input, uint32_t input_len)
{
uint16_t dyn_port = rs_ftp_pasv_response(input, input_len);
if (dyn_port == 0) {
return 0;
}
-static int FTPParsePassiveResponseV6(Flow *f, FtpState *state, uint8_t *input, uint32_t input_len)
+static int FTPParsePassiveResponseV6(Flow *f, FtpState *state, const uint8_t *input, uint32_t input_len)
{
uint16_t dyn_port = rs_ftp_epsv_response(input, input_len);
if (dyn_port == 0) {
* The requested action is being initiated; expect another
* reply before proceeding with a new command
*/
-static inline bool FTPIsPPR(uint8_t *input, uint32_t input_len)
+static inline bool FTPIsPPR(const uint8_t *input, uint32_t input_len)
{
return input_len >= 4 && isdigit(input[0]) && input[0] == '1' &&
isdigit(input[1]) && isdigit(input[2]) && isspace(input[3]);
* \retval 1 when the command is parsed, 0 otherwise
*/
static int FTPParseResponse(Flow *f, void *ftp_state, AppLayerParserState *pstate,
- uint8_t *input, uint32_t input_len,
+ const uint8_t *input, uint32_t input_len,
void *local_data, const uint8_t flags)
{
FtpState *state = (FtpState *)ftp_state;
*/
static int FTPDataParse(Flow *f, FtpDataState *ftpdata_state,
AppLayerParserState *pstate,
- uint8_t *input, uint32_t input_len,
+ const uint8_t *input, uint32_t input_len,
void *local_data, int direction)
{
uint16_t flags = FileFlowToFlags(f, direction);
}
static int FTPDataParseRequest(Flow *f, void *ftp_state,
AppLayerParserState *pstate,
- uint8_t *input, uint32_t input_len,
+ const uint8_t *input, uint32_t input_len,
void *local_data, const uint8_t flags)
{
return FTPDataParse(f, ftp_state, pstate, input, input_len,
static int FTPDataParseResponse(Flow *f, void *ftp_state,
AppLayerParserState *pstate,
- uint8_t *input, uint32_t input_len,
+ const uint8_t *input, uint32_t input_len,
void *local_data, const uint8_t flags)
{
return FTPDataParse(f, ftp_state, pstate, input, input_len,
/** FTP State for app layer parser */
typedef struct FtpState_ {
- uint8_t *input;
+ const uint8_t *input;
int32_t input_len;
uint8_t direction;
bool active;
/* --parser details-- */
/** current line extracted by the parser from the call to FTPGetline() */
- uint8_t *current_line;
+ const uint8_t *current_line;
/** length of the line in current_line. Doesn't include the delimiter */
uint32_t current_line_len;
uint8_t current_line_delimiter_len;
*/
static int HTPHandleRequestData(Flow *f, void *htp_state,
AppLayerParserState *pstate,
- uint8_t *input, uint32_t input_len,
+ const uint8_t *input, uint32_t input_len,
void *local_data, const uint8_t flags)
{
SCEnter();
*/
static int HTPHandleResponseData(Flow *f, void *htp_state,
AppLayerParserState *pstate,
- uint8_t *input, uint32_t input_len,
+ const uint8_t *input, uint32_t input_len,
void *local_data, const uint8_t flags)
{
SCEnter();
*/
static int ModbusExtractUint8(ModbusState *modbus,
uint8_t *res,
- uint8_t *input,
+ const uint8_t *input,
uint32_t input_len,
uint16_t *offset) {
SCEnter();
*/
static int ModbusExtractUint16(ModbusState *modbus,
uint16_t *res,
- uint8_t *input,
+ const uint8_t *input,
uint32_t input_len,
uint16_t *offset) {
SCEnter();
*/
static void ModbusExceptionResponse(ModbusTransaction *tx,
ModbusState *modbus,
- uint8_t *input,
+ const uint8_t *input,
uint32_t input_len,
uint16_t *offset)
{
*/
static void ModbusParseReadRequest(ModbusTransaction *tx,
ModbusState *modbus,
- uint8_t *input,
+ const uint8_t *input,
uint32_t input_len,
uint16_t *offset)
{
*/
static void ModbusParseReadResponse(ModbusTransaction *tx,
ModbusState *modbus,
- uint8_t *input,
+ const uint8_t *input,
uint32_t input_len,
uint16_t *offset)
{
*/
static int ModbusParseWriteRequest(ModbusTransaction *tx,
ModbusState *modbus,
- uint8_t *input,
+ const uint8_t *input,
uint32_t input_len,
uint16_t *offset)
{
*/
static void ModbusParseWriteResponse(ModbusTransaction *tx,
ModbusState *modbus,
- uint8_t *input,
+ const uint8_t *input,
uint32_t input_len,
uint16_t *offset)
{
*/
static int ModbusParseDiagnosticRequest(ModbusTransaction *tx,
ModbusState *modbus,
- uint8_t *input,
+ const uint8_t *input,
uint32_t input_len,
uint16_t *offset)
{
*/
static void ModbusParseRequestPDU(ModbusTransaction *tx,
ModbusState *modbus,
- uint8_t *input,
+ const uint8_t *input,
uint32_t input_len)
{
SCEnter();
*/
static void ModbusParseResponsePDU(ModbusTransaction *tx,
ModbusState *modbus,
- uint8_t *input,
+ const uint8_t *input,
uint32_t input_len)
{
SCEnter();
*/
static int ModbusParseHeader(ModbusState *modbus,
ModbusHeader *header,
- uint8_t *input,
+ const uint8_t *input,
uint32_t input_len)
{
SCEnter();
static int ModbusParseRequest(Flow *f,
void *state,
AppLayerParserState *pstate,
- uint8_t *input,
+ const uint8_t *input,
uint32_t input_len,
void *local_data,
const uint8_t flags)
while (input_len > 0) {
uint32_t adu_len = input_len;
- uint8_t *adu = input;
+ const uint8_t *adu = input;
/* Extract MODBUS Header */
if (ModbusParseHeader(modbus, &header, adu, adu_len))
static int ModbusParseResponse(Flow *f,
void *state,
AppLayerParserState *pstate,
- uint8_t *input,
+ const uint8_t *input,
uint32_t input_len,
void *local_data,
const uint8_t flags)
while (input_len > 0) {
uint32_t adu_len = input_len;
- uint8_t *adu = input;
+ const uint8_t *adu = input;
/* Extract MODBUS Header */
if (ModbusParseHeader(modbus, &header, adu, adu_len))
static uint16_t ModbusProbingParser(Flow *f,
uint8_t direction,
- uint8_t *input,
+ const uint8_t *input,
uint32_t input_len,
uint8_t *rdir)
{
*/
static AppProto NFSTCPProbingParserMidstream(Flow *f,
uint8_t direction,
- uint8_t *input, uint32_t input_len,
+ const uint8_t *input, uint32_t input_len,
uint8_t *rdir)
{
if (input_len < NFSTCP_MIN_FRAME_LEN) {
*/
static AppProto NFSTCPProbingParser(Flow *f,
uint8_t direction,
- uint8_t *input, uint32_t input_len,
+ const uint8_t *input, uint32_t input_len,
uint8_t *rdir)
{
if (input_len < NFSTCP_MIN_FRAME_LEN) {
}
static int NFSTCPParseRequest(Flow *f, void *state,
- AppLayerParserState *pstate, uint8_t *input, uint32_t input_len,
+ AppLayerParserState *pstate, const uint8_t *input, uint32_t input_len,
void *local_data, const uint8_t flags)
{
uint16_t file_flags = FileFlowToFlags(f, STREAM_TOSERVER);
}
static int NFSTCPParseResponse(Flow *f, void *state, AppLayerParserState *pstate,
- uint8_t *input, uint32_t input_len, void *local_data,
+ const uint8_t *input, uint32_t input_len, void *local_data,
const uint8_t flags)
{
uint16_t file_flags = FileFlowToFlags(f, STREAM_TOCLIENT);
* ALPROTO_UNKNOWN.
*/
static AppProto NFSProbingParser(Flow *f, uint8_t direction,
- uint8_t *input, uint32_t input_len, uint8_t *rdir)
+ const uint8_t *input, uint32_t input_len, uint8_t *rdir)
{
SCLogDebug("probing");
if (input_len < NFS_MIN_FRAME_LEN) {
}
static int NFSParseRequest(Flow *f, void *state,
- AppLayerParserState *pstate, uint8_t *input, uint32_t input_len,
+ AppLayerParserState *pstate, const uint8_t *input, uint32_t input_len,
void *local_data, const uint8_t flags)
{
uint16_t file_flags = FileFlowToFlags(f, STREAM_TOSERVER);
}
static int NFSParseResponse(Flow *f, void *state, AppLayerParserState *pstate,
- uint8_t *input, uint32_t input_len, void *local_data,
+ const uint8_t *input, uint32_t input_len, void *local_data,
const uint8_t flags)
{
uint16_t file_flags = FileFlowToFlags(f, STREAM_TOCLIENT);
/***** General *****/
int AppLayerParserParse(ThreadVars *tv, AppLayerParserThreadCtx *alp_tctx, Flow *f, AppProto alproto,
- uint8_t flags, uint8_t *input, uint32_t input_len)
+ uint8_t flags, const uint8_t *input, uint32_t input_len)
{
SCEnter();
#ifdef DEBUG_VALIDATION
* parser of occurence of an error.
*/
static int TestProtocolParser(Flow *f, void *test_state, AppLayerParserState *pstate,
- uint8_t *input, uint32_t input_len,
+ const uint8_t *input, uint32_t input_len,
void *local_data, const uint8_t flags)
{
SCEnter();
/** \brief Prototype for parsing functions */
typedef int (*AppLayerParserFPtr)(Flow *f, void *protocol_state,
AppLayerParserState *pstate,
- uint8_t *buf, uint32_t buf_len,
+ const uint8_t *buf, uint32_t buf_len,
void *local_storage, const uint8_t flags);
typedef struct AppLayerGetTxIterTuple {
/***** General *****/
int AppLayerParserParse(ThreadVars *tv, AppLayerParserThreadCtx *tctx, Flow *f, AppProto alproto,
- uint8_t flags, uint8_t *input, uint32_t input_len);
+ uint8_t flags, const uint8_t *input, uint32_t input_len);
void AppLayerParserSetEOF(AppLayerParserState *pstate);
bool AppLayerParserHasDecoderEvents(AppLayerParserState *pstate);
int AppLayerParserIsTxAware(AppProto alproto);
#define MIN_REC_SIZE 32+4 // SMB hdr + nbss hdr
static int SMBTCPParseRequest(Flow *f, void *state,
- AppLayerParserState *pstate, uint8_t *input, uint32_t input_len,
+ AppLayerParserState *pstate, const uint8_t *input, uint32_t input_len,
void *local_data, const uint8_t flags)
{
SCLogDebug("SMBTCPParseRequest");
}
static int SMBTCPParseResponse(Flow *f, void *state,
- AppLayerParserState *pstate, uint8_t *input, uint32_t input_len,
+ AppLayerParserState *pstate, const uint8_t *input, uint32_t input_len,
void *local_data, const uint8_t flags)
{
SCLogDebug("SMBTCPParseResponse");
}
static uint16_t SMBTCPProbe(Flow *f, uint8_t direction,
- uint8_t *input, uint32_t len, uint8_t *rdir)
+ const uint8_t *input, uint32_t len, uint8_t *rdir)
{
SCLogDebug("SMBTCPProbe");
* back to the port numbers for a hint
*/
static uint16_t SMB3TCPProbe(Flow *f, uint8_t direction,
- uint8_t *input, uint32_t len, uint8_t *rdir)
+ const uint8_t *input, uint32_t len, uint8_t *rdir)
{
SCEnter();
}
static int SMTPParse(int direction, Flow *f, SMTPState *state,
- AppLayerParserState *pstate, uint8_t *input,
+ AppLayerParserState *pstate, const uint8_t *input,
uint32_t input_len,
SMTPThreadCtx *thread_data)
{
static int SMTPParseClientRecord(Flow *f, void *alstate,
AppLayerParserState *pstate,
- uint8_t *input, uint32_t input_len,
+ const uint8_t *input, uint32_t input_len,
void *local_data, const uint8_t flags)
{
SCEnter();
static int SMTPParseServerRecord(Flow *f, void *alstate,
AppLayerParserState *pstate,
- uint8_t *input, uint32_t input_len,
+ const uint8_t *input, uint32_t input_len,
void *local_data, const uint8_t flags)
{
SCEnter();
uint64_t tx_cnt;
/* current input that is being parsed */
- uint8_t *input;
+ const uint8_t *input;
int32_t input_len;
uint8_t direction;
/* --parser details-- */
/** current line extracted by the parser from the call to SMTPGetline() */
- uint8_t *current_line;
+ const uint8_t *current_line;
/** length of the line in current_line. Doesn't include the delimiter */
int32_t current_line_len;
uint8_t current_line_delimiter_len;
* \param input Pointer the received input data
* \param input_len Length in bytes of the received data
*/
-static int SSHParseRecord(SshState *state, SshHeader *header, uint8_t *input, uint32_t input_len)
+static int SSHParseRecord(SshState *state, SshHeader *header, const uint8_t *input, uint32_t input_len)
{
SCEnter();
int ret = 0;
SCReturnInt(0);
}
-static int EnoughData(uint8_t *input, uint32_t input_len)
+static int EnoughData(const uint8_t *input, uint32_t input_len)
{
uint32_t u;
for (u = 0; u < input_len; u++) {
#define MAX_BANNER_LEN 256
static int SSHParseData(SshState *state, SshHeader *header,
- uint8_t *input, uint32_t input_len)
+ const uint8_t *input, uint32_t input_len)
{
/* we're looking for the banner */
if (!(header->flags & SSH_FLAG_VERSION_PARSED))
}
static int SSHParseRequest(Flow *f, void *state, AppLayerParserState *pstate,
- uint8_t *input, uint32_t input_len,
+ const uint8_t *input, uint32_t input_len,
void *local_data, const uint8_t flags)
{
SshState *ssh_state = (SshState *)state;
}
static int SSHParseResponse(Flow *f, void *state, AppLayerParserState *pstate,
- uint8_t *input, uint32_t input_len,
+ const uint8_t *input, uint32_t input_len,
void *local_data, const uint8_t flags)
{
SshState *ssh_state = (SshState *)state;
return 0;
}
-static int SSLv3ParseHandshakeType(SSLState *ssl_state, uint8_t *input,
+static int SSLv3ParseHandshakeType(SSLState *ssl_state, const uint8_t *input,
uint32_t input_len, uint8_t direction)
{
void *ptmp;
- uint8_t *initial_input = input;
+ const uint8_t *initial_input = input;
uint32_t parsed = 0;
int rc;
}
}
-static int SSLv3ParseHandshakeProtocol(SSLState *ssl_state, uint8_t *input,
+static int SSLv3ParseHandshakeProtocol(SSLState *ssl_state, const uint8_t *input,
uint32_t input_len, uint8_t direction)
{
- uint8_t *initial_input = input;
+ const uint8_t *initial_input = input;
int retval;
if (input_len == 0 || ssl_state->curr_connp->bytes_processed ==
*
* \retval The number of bytes parsed on success, 0 if nothing parsed, -1 on failure.
*/
-static int SSLv3ParseHeartbeatProtocol(SSLState *ssl_state, uint8_t *input,
+static int SSLv3ParseHeartbeatProtocol(SSLState *ssl_state, const uint8_t *input,
uint32_t input_len, uint8_t direction)
{
uint8_t hb_type;
}
static int SSLv3ParseRecord(uint8_t direction, SSLState *ssl_state,
- uint8_t *input, uint32_t input_len)
+ const uint8_t *input, uint32_t input_len)
{
- uint8_t *initial_input = input;
+ const uint8_t *initial_input = input;
if (input_len == 0) {
return 0;
}
static int SSLv2ParseRecord(uint8_t direction, SSLState *ssl_state,
- uint8_t *input, uint32_t input_len)
+ const uint8_t *input, uint32_t input_len)
{
- uint8_t *initial_input = input;
+ const uint8_t *initial_input = input;
if (input_len == 0) {
return 0;
}
static int SSLv2Decode(uint8_t direction, SSLState *ssl_state,
- AppLayerParserState *pstate, uint8_t *input,
+ AppLayerParserState *pstate, const uint8_t *input,
uint32_t input_len)
{
int retval = 0;
- uint8_t *initial_input = input;
+ const uint8_t *initial_input = input;
if (ssl_state->curr_connp->bytes_processed == 0) {
if (input[0] & 0x80) {
}
static int SSLv3Decode(uint8_t direction, SSLState *ssl_state,
- AppLayerParserState *pstate, uint8_t *input,
+ AppLayerParserState *pstate, const uint8_t *input,
uint32_t input_len)
{
int retval = 0;
* \retval >=0 On success.
*/
static int SSLDecode(Flow *f, uint8_t direction, void *alstate, AppLayerParserState *pstate,
- uint8_t *input, uint32_t ilen)
+ const uint8_t *input, uint32_t ilen)
{
SSLState *ssl_state = (SSLState *)alstate;
int retval = 0;
}
static int SSLParseClientRecord(Flow *f, void *alstate, AppLayerParserState *pstate,
- uint8_t *input, uint32_t input_len,
+ const uint8_t *input, uint32_t input_len,
void *local_data, const uint8_t flags)
{
return SSLDecode(f, 0 /* toserver */, alstate, pstate, input, input_len);
}
static int SSLParseServerRecord(Flow *f, void *alstate, AppLayerParserState *pstate,
- uint8_t *input, uint32_t input_len,
+ const uint8_t *input, uint32_t input_len,
void *local_data, const uint8_t flags)
{
return SSLDecode(f, 1 /* toclient */, alstate, pstate, input, input_len);
}
static AppProto SSLProbingParser(Flow *f, uint8_t direction,
- uint8_t *input, uint32_t ilen, uint8_t *rdir)
+ const uint8_t *input, uint32_t ilen, uint8_t *rdir)
{
/* probably a rst/fin sending an eof */
if (ilen < 3)
* otherwise ALPROTO_UNKNOWN.
*/
static AppProto TemplateProbingParserTs(Flow *f, uint8_t direction,
- uint8_t *input, uint32_t input_len, uint8_t *rdir)
+ const uint8_t *input, uint32_t input_len, uint8_t *rdir)
{
/* Very simple test - if there is input, this is template. */
if (input_len >= TEMPLATE_MIN_FRAME_LEN) {
* otherwise ALPROTO_UNKNOWN.
*/
static AppProto TemplateProbingParserTc(Flow *f, uint8_t direction,
- uint8_t *input, uint32_t input_len, uint8_t *rdir)
+ const uint8_t *input, uint32_t input_len, uint8_t *rdir)
{
/* Very simple test - if there is input, this is template. */
if (input_len >= TEMPLATE_MIN_FRAME_LEN) {
}
static int TemplateParseRequest(Flow *f, void *statev,
- AppLayerParserState *pstate, uint8_t *input, uint32_t input_len,
+ AppLayerParserState *pstate, const uint8_t *input, uint32_t input_len,
void *local_data, const uint8_t flags)
{
TemplateState *state = statev;
}
static int TemplateParseResponse(Flow *f, void *statev, AppLayerParserState *pstate,
- uint8_t *input, uint32_t input_len, void *local_data,
+ const uint8_t *input, uint32_t input_len, void *local_data,
const uint8_t flags)
{
TemplateState *state = statev;
* ALPROTO_UNKNOWN.
*/
static AppProto TFTPProbingParser(Flow *f, uint8_t direction,
- uint8_t *input, uint32_t input_len, uint8_t *rdir)
+ const uint8_t *input, uint32_t input_len, uint8_t *rdir)
{
/* Very simple test - if there is input, this is tftp.
* Also check if it's starting by a zero */
}
static int TFTPParseRequest(Flow *f, void *state,
- AppLayerParserState *pstate, uint8_t *input, uint32_t input_len,
+ AppLayerParserState *pstate, const uint8_t *input, uint32_t input_len,
void *local_data, const uint8_t flags)
{
SCLogDebug("Parsing echo request: len=%"PRIu32, input_len);
* \brief Response parsing is not implemented
*/
static int TFTPParseResponse(Flow *f, void *state, AppLayerParserState *pstate,
- uint8_t *input, uint32_t input_len, void *local_data,
+ const uint8_t *input, uint32_t input_len, void *local_data,
const uint8_t flags)
{
return 0;
* \brief Function to decode ERSPAN packets
*/
-int DecodeERSPAN(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, uint32_t len, PacketQueue *pq)
+int DecodeERSPAN(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len, PacketQueue *pq)
{
StatsIncr(tv, dtv->counter_erspan);
#include "util-debug.h"
int DecodeEthernet(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
- uint8_t *pkt, uint32_t len, PacketQueue *pq)
+ const uint8_t *pkt, uint32_t len, PacketQueue *pq)
{
StatsIncr(tv, dtv->counter_eth);
* \brief Function to decode GRE packets
*/
-int DecodeGRE(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, uint32_t len, PacketQueue *pq)
+int DecodeGRE(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len, PacketQueue *pq)
{
uint32_t header_len = GRE_HDR_LEN;
GRESreHdr *gsre = NULL;
/** DecodeICMPV4
* \brief Main ICMPv4 decoding function
*/
-int DecodeICMPV4(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, uint32_t len, PacketQueue *pq)
+int DecodeICMPV4(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len, PacketQueue *pq)
{
StatsIncr(tv, dtv->counter_icmpv4);
p->proto = IPPROTO_ICMP;
p->icmp_s.type = p->icmpv4h->type;
p->icmp_s.code = p->icmpv4h->code;
- p->payload = pkt + ICMPV4_HEADER_LEN;
+ p->payload = (uint8_t *)pkt + ICMPV4_HEADER_LEN;
p->payload_len = len - ICMPV4_HEADER_LEN;
int ctype = ICMPv4GetCounterpart(p->icmp_s.type);
* \retval void No return value
*/
int DecodeICMPV6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
- uint8_t *pkt, uint32_t len, PacketQueue *pq)
+ const uint8_t *pkt, uint32_t len, PacketQueue *pq)
{
int full_hdr = 0;
StatsIncr(tv, dtv->counter_icmpv6);
p->icmp_s.type = p->icmpv6h->type;
p->icmp_s.code = p->icmpv6h->code;
p->payload_len = len - ICMPV6_HEADER_LEN;
- p->payload = pkt + ICMPV6_HEADER_LEN;
+ p->payload = (uint8_t *)pkt + ICMPV6_HEADER_LEN;
int ctype = ICMPv6GetCounterpart(p->icmp_s.type);
if (ctype != -1) {
if (!full_hdr) {
if (p->payload_len >= 4) {
p->payload_len -= 4;
- p->payload = pkt + 4;
+ p->payload = (uint8_t *)pkt + 4;
} else {
p->payload_len = 0;
p->payload = NULL;
static int IPV4OptValidateCIPSO(Packet *p, const IPV4Opt *o)
{
// uint32_t doi;
- uint8_t *tag;
+ const uint8_t *tag;
uint16_t len;
/* Check length */
/**
* Decode/Validate IPv4 Options.
*/
-static void DecodeIPV4Options(Packet *p, uint8_t *pkt, uint16_t len, IPV4Options *opts)
+static void DecodeIPV4Options(Packet *p, const uint8_t *pkt, uint16_t len, IPV4Options *opts)
{
uint16_t plen = len;
}
-static int DecodeIPV4Packet(Packet *p, uint8_t *pkt, uint16_t len)
+static int DecodeIPV4Packet(Packet *p, const uint8_t *pkt, uint16_t len)
{
if (unlikely(len < IPV4_HEADER_LEN)) {
ENGINE_SET_INVALID_EVENT(p, IPV4_PKT_TOO_SMALL);
return 0;
}
-int DecodeIPV4(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, uint16_t len, PacketQueue *pq)
+int DecodeIPV4(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
+ const uint8_t *pkt, uint16_t len, PacketQueue *pq)
{
StatsIncr(tv, dtv->counter_ipv4);
*/
uint8_t type; /**< option type */
uint8_t len; /**< option length (type+len+data) */
- uint8_t *data; /**< option data */
+ const uint8_t *data; /**< option data */
} IPV4Opt;
typedef struct IPV4Hdr_
* \brief Function to decode IPv4 in IPv6 packets
*
*/
-static void DecodeIPv4inIPv6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, uint16_t plen, PacketQueue *pq)
+static void DecodeIPv4inIPv6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint16_t plen, PacketQueue *pq)
{
if (unlikely(plen < IPV4_HEADER_LEN)) {
* \brief Function to decode IPv6 in IPv6 packets
*
*/
-static int DecodeIP6inIP6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, uint16_t plen, PacketQueue *pq)
+static int DecodeIP6inIP6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
+ const uint8_t *pkt, uint16_t plen, PacketQueue *pq)
{
if (unlikely(plen < IPV6_HEADER_LEN)) {
#ifndef UNITTESTS // ugly, but we need this in defrag tests
static inline
#endif
-void DecodeIPV6FragHeader(Packet *p, uint8_t *pkt,
+void DecodeIPV6FragHeader(Packet *p, const uint8_t *pkt,
uint16_t hdrextlen, uint16_t plen,
uint16_t prev_hdrextlen)
{
}
static void
-DecodeIPV6ExtHdrs(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, uint16_t len, PacketQueue *pq)
+DecodeIPV6ExtHdrs(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
+ const uint8_t *pkt, uint16_t len, PacketQueue *pq)
{
SCEnter();
- uint8_t *orig_pkt = pkt;
+ const uint8_t *orig_pkt = pkt;
uint8_t nh = IPV6_GET_NH(p); /* careful, 0 is actually a real type */
uint16_t hdrextlen = 0;
uint16_t plen = len;
SCReturn;
}
- uint8_t *ptr = pkt + 2; /* +2 to go past nxthdr and len */
+ const uint8_t *ptr = pkt + 2; /* +2 to go past nxthdr and len */
/* point the pointers to right structures
* in Packet. */
SCReturn;
}
-static int DecodeIPV6Packet (ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, uint16_t len)
+static int DecodeIPV6Packet (ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint16_t len)
{
if (unlikely(len < IPV6_HEADER_LEN)) {
return -1;
return 0;
}
-int DecodeIPV6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, uint16_t len, PacketQueue *pq)
+int DecodeIPV6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint16_t len, PacketQueue *pq)
{
StatsIncr(tv, dtv->counter_ipv6);
#define MPLS_PROTO_IPV4 4
#define MPLS_PROTO_IPV6 6
-int DecodeMPLS(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt,
- uint32_t len, PacketQueue *pq)
+int DecodeMPLS(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
+ const uint8_t *pkt, uint32_t len, PacketQueue *pq)
{
uint32_t shim;
int label;
#define HDR_SIZE 4
-int DecodeNull(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, uint32_t len, PacketQueue *pq)
+int DecodeNull(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
+ const uint8_t *pkt, uint32_t len, PacketQueue *pq)
{
StatsIncr(tv, dtv->counter_null);
#include "util-unittest.h"
#include "util-debug.h"
-int DecodePPP(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, uint32_t len, PacketQueue *pq)
+int DecodePPP(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
+ const uint8_t *pkt, uint32_t len, PacketQueue *pq)
{
StatsIncr(tv, dtv->counter_ppp);
/**
* \brief Main decoding function for PPPOE Discovery packets
*/
-int DecodePPPOEDiscovery(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, uint32_t len, PacketQueue *pq)
+int DecodePPPOEDiscovery(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
+ const uint8_t *pkt, uint32_t len, PacketQueue *pq)
{
StatsIncr(tv, dtv->counter_pppoe);
/**
* \brief Main decoding function for PPPOE Session packets
*/
-int DecodePPPOESession(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, uint32_t len, PacketQueue *pq)
+int DecodePPPOESession(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
+ const uint8_t *pkt, uint32_t len, PacketQueue *pq)
{
StatsIncr(tv, dtv->counter_pppoe);
#include "host.h"
-int DecodeRaw(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, uint32_t len, PacketQueue *pq)
+int DecodeRaw(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
+ const uint8_t *pkt, uint32_t len, PacketQueue *pq)
{
StatsIncr(tv, dtv->counter_raw);
#include "util-optimize.h"
#include "flow.h"
-static int DecodeSCTPPacket(ThreadVars *tv, Packet *p, uint8_t *pkt, uint16_t len)
+static int DecodeSCTPPacket(ThreadVars *tv, Packet *p, const uint8_t *pkt, uint16_t len)
{
if (unlikely(len < SCTP_HEADER_LEN)) {
ENGINE_SET_INVALID_EVENT(p, SCTP_PKT_TOO_SMALL);
SET_SCTP_SRC_PORT(p,&p->sp);
SET_SCTP_DST_PORT(p,&p->dp);
- p->payload = pkt + sizeof(SCTPHdr);
+ p->payload = (uint8_t *)pkt + sizeof(SCTPHdr);
p->payload_len = len - sizeof(SCTPHdr);
p->proto = IPPROTO_SCTP;
return 0;
}
-int DecodeSCTP(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, uint16_t len, PacketQueue *pq)
+int DecodeSCTP(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
+ const uint8_t *pkt, uint16_t len, PacketQueue *pq)
{
StatsIncr(tv, dtv->counter_sctp);
#include "decode-events.h"
#include "util-debug.h"
-int DecodeSll(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, uint32_t len, PacketQueue *pq)
+int DecodeSll(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
+ const uint8_t *pkt, uint32_t len, PacketQueue *pq)
{
StatsIncr(tv, dtv->counter_sll);
(dst).len = (src).len; \
(dst).data = (src).data
-static void DecodeTCPOptions(Packet *p, uint8_t *pkt, uint16_t pktlen)
+static void DecodeTCPOptions(Packet *p, const uint8_t *pkt, uint16_t pktlen)
{
uint8_t tcp_opt_cnt = 0;
TCPOpt tcp_opts[TCP_OPTMAX];
}
}
-static int DecodeTCPPacket(ThreadVars *tv, Packet *p, uint8_t *pkt, uint16_t len)
+static int DecodeTCPPacket(ThreadVars *tv, Packet *p, const uint8_t *pkt, uint16_t len)
{
if (unlikely(len < TCP_HEADER_LEN)) {
ENGINE_SET_INVALID_EVENT(p, TCP_PKT_TOO_SMALL);
p->proto = IPPROTO_TCP;
- p->payload = pkt + hlen;
+ p->payload = (uint8_t *)pkt + hlen;
p->payload_len = len - hlen;
return 0;
}
-int DecodeTCP(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, uint16_t len, PacketQueue *pq)
+int DecodeTCP(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
+ const uint8_t *pkt, uint16_t len, PacketQueue *pq)
{
StatsIncr(tv, dtv->counter_tcp);
- if (unlikely(DecodeTCPPacket(tv, p,pkt,len) < 0)) {
+ if (unlikely(DecodeTCPPacket(tv, p, pkt,len) < 0)) {
SCLogDebug("invalid TCP packet");
p->tcph = NULL;
return TM_ECODE_FAILED;
goto end;
}
- uint8_t *sackptr = TCP_GET_SACK_PTR(p);
+ const uint8_t *sackptr = TCP_GET_SACK_PTR(p);
if (sackptr == NULL) {
printf("no sack data: ");
goto end;
typedef struct TCPOpt_ {
uint8_t type;
uint8_t len;
- uint8_t *data;
+ const uint8_t *data;
} TCPOpt;
typedef struct TCPOptSackRecord_ {
*
* \retval TM_ECODE_FAILED if packet is not a Teredo packet, TM_ECODE_OK if it is
*/
-int DecodeTeredo(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, uint16_t len, PacketQueue *pq)
+int DecodeTeredo(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
+ const uint8_t *pkt, uint16_t len, PacketQueue *pq)
{
if (!g_teredo_enabled)
return TM_ECODE_FAILED;
- uint8_t *start = pkt;
+ const uint8_t *start = pkt;
/* Is this packet to short to contain an IPv6 packet ? */
if (len < IPV6_HEADER_LEN)
#define __DECODE_TEREDO_H__
int DecodeTeredo(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
- uint8_t *pkt, uint16_t len, PacketQueue *pq);
+ const uint8_t *pkt, uint16_t len, PacketQueue *pq);
void DecodeTeredoConfig(void);
#endif
#include "flow.h"
#include "app-layer.h"
-static int DecodeUDPPacket(ThreadVars *t, Packet *p, uint8_t *pkt, uint16_t len)
+static int DecodeUDPPacket(ThreadVars *t, Packet *p, const uint8_t *pkt, uint16_t len)
{
if (unlikely(len < UDP_HEADER_LEN)) {
ENGINE_SET_INVALID_EVENT(p, UDP_HLEN_TOO_SMALL);
SET_UDP_SRC_PORT(p,&p->sp);
SET_UDP_DST_PORT(p,&p->dp);
- p->payload = pkt + UDP_HEADER_LEN;
+ p->payload = (uint8_t *)pkt + UDP_HEADER_LEN;
p->payload_len = len - UDP_HEADER_LEN;
p->proto = IPPROTO_UDP;
return 0;
}
-int DecodeUDP(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, uint16_t len, PacketQueue *pq)
+int DecodeUDP(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
+ const uint8_t *pkt, uint16_t len, PacketQueue *pq)
{
StatsIncr(tv, dtv->counter_udp);
- if (unlikely(DecodeUDPPacket(tv, p,pkt,len) < 0)) {
+ if (unlikely(DecodeUDPPacket(tv, p, pkt,len) < 0)) {
p->udph = NULL;
return TM_ECODE_FAILED;
}
#include "host.h"
static int DecodeIEEE8021ah(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
- uint8_t *pkt, uint16_t len, PacketQueue *pq);
+ const uint8_t *pkt, uint16_t len, PacketQueue *pq);
/**
* \internal
* \param pq pointer to the packet queue
*
*/
-int DecodeVLAN(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, uint32_t len, PacketQueue *pq)
+int DecodeVLAN(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
+ const uint8_t *pkt, uint32_t len, PacketQueue *pq)
{
uint32_t proto;
#define IEEE8021AH_HEADER_LEN sizeof(IEEE8021ahHdr)
-static int DecodeIEEE8021ah(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, uint16_t len, PacketQueue *pq)
+static int DecodeIEEE8021ah(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
+ const uint8_t *pkt, uint16_t len, PacketQueue *pq)
{
StatsIncr(tv, dtv->counter_ieee8021ah);
/** \param pkt payload data directly above UDP header
* \param len length in bytes of pkt
*/
-int DecodeVXLAN(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt,
- uint32_t len, PacketQueue *pq)
+int DecodeVXLAN(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
+ const uint8_t *pkt, uint32_t len, PacketQueue *pq)
{
if (unlikely(!g_vxlan_enabled))
return TM_ECODE_FAILED;
extern bool stats_stream_events;
int DecodeTunnel(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
- uint8_t *pkt, uint32_t len, PacketQueue *pq, enum DecodeTunnelProto proto)
+ const uint8_t *pkt, uint32_t len, PacketQueue *pq, enum DecodeTunnelProto proto)
{
switch (proto) {
case DECODE_TUNNEL_PPP:
* \param Pointer to the data to copy
* \param Length of the data to copy
*/
-inline int PacketCopyDataOffset(Packet *p, uint32_t offset, uint8_t *data, uint32_t datalen)
+inline int PacketCopyDataOffset(Packet *p, uint32_t offset, const uint8_t *data, uint32_t datalen)
{
if (unlikely(offset + datalen > MAX_PAYLOAD_SIZE)) {
/* too big */
* \param Pointer to the data to copy
* \param Length of the data to copy
*/
-inline int PacketCopyData(Packet *p, uint8_t *pktdata, uint32_t pktlen)
+inline int PacketCopyData(Packet *p, const uint8_t *pktdata, uint32_t pktlen)
{
SET_PKT_LEN(p, (size_t)pktlen);
return PacketCopyDataOffset(p, 0, pktdata, pktlen);
* \retval p the pseudo packet or NULL if out of memory
*/
Packet *PacketTunnelPktSetup(ThreadVars *tv, DecodeThreadVars *dtv, Packet *parent,
- uint8_t *pkt, uint32_t len, enum DecodeTunnelProto proto,
+ const uint8_t *pkt, uint32_t len, enum DecodeTunnelProto proto,
PacketQueue *pq)
{
int ret;
*
* \retval p the pseudo packet or NULL if out of memory
*/
-Packet *PacketDefragPktSetup(Packet *parent, uint8_t *pkt, uint32_t len, uint8_t proto)
+Packet *PacketDefragPktSetup(Packet *parent, const uint8_t *pkt, uint32_t len, uint8_t proto)
{
SCEnter();
* \param Pointer to the data
* \param Length of the data
*/
-inline int PacketSetData(Packet *p, uint8_t *pktdata, uint32_t pktlen)
+inline int PacketSetData(Packet *p, const uint8_t *pktdata, uint32_t pktlen)
{
SET_PKT_LEN(p, (size_t)pktlen);
if (unlikely(!pktdata)) {
return -1;
}
- p->ext_pkt = pktdata;
+ p->ext_pkt = (uint8_t *)pktdata;
p->flags |= PKT_ZERO_COPY;
return 0;
};
Packet *PacketTunnelPktSetup(ThreadVars *tv, DecodeThreadVars *dtv, Packet *parent,
- uint8_t *pkt, uint32_t len, enum DecodeTunnelProto proto, PacketQueue *pq);
-Packet *PacketDefragPktSetup(Packet *parent, uint8_t *pkt, uint32_t len, uint8_t proto);
+ const uint8_t *pkt, uint32_t len, enum DecodeTunnelProto proto, PacketQueue *pq);
+Packet *PacketDefragPktSetup(Packet *parent, const uint8_t *pkt, uint32_t len, uint8_t proto);
void PacketDefragPktSetupParent(Packet *parent);
void DecodeRegisterPerfCounters(DecodeThreadVars *, ThreadVars *);
Packet *PacketGetFromQueueOrAlloc(void);
void PacketFree(Packet *p);
void PacketFreeOrRelease(Packet *p);
int PacketCallocExtPkt(Packet *p, int datalen);
-int PacketCopyData(Packet *p, uint8_t *pktdata, uint32_t pktlen);
-int PacketSetData(Packet *p, uint8_t *pktdata, uint32_t pktlen);
-int PacketCopyDataOffset(Packet *p, uint32_t offset, uint8_t *data, uint32_t datalen);
+int PacketCopyData(Packet *p, const uint8_t *pktdata, uint32_t pktlen);
+int PacketSetData(Packet *p, const uint8_t *pktdata, uint32_t pktlen);
+int PacketCopyDataOffset(Packet *p, uint32_t offset, const uint8_t *data, uint32_t datalen);
const char *PktSrcToString(enum PktSrcEnum pkt_src);
void PacketBypassCallback(Packet *p);
void PacketSwap(Packet *p);
const DecodeThreadVars *dtv, const Packet *p);
/* decoder functions */
-int DecodeEthernet(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint32_t, PacketQueue *);
-int DecodeSll(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint32_t, PacketQueue *);
-int DecodePPP(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint32_t, PacketQueue *);
-int DecodePPPOESession(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint32_t, PacketQueue *);
-int DecodePPPOEDiscovery(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint32_t, PacketQueue *);
-int DecodeTunnel(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint32_t, PacketQueue *, enum DecodeTunnelProto) __attribute__ ((warn_unused_result));
-int DecodeNull(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint32_t, PacketQueue *);
-int DecodeRaw(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint32_t, PacketQueue *);
-int DecodeIPV4(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint16_t, PacketQueue *);
-int DecodeIPV6(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint16_t, PacketQueue *);
-int DecodeICMPV4(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint32_t, PacketQueue *);
-int DecodeICMPV6(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint32_t, PacketQueue *);
-int DecodeTCP(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint16_t, PacketQueue *);
-int DecodeUDP(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint16_t, PacketQueue *);
-int DecodeSCTP(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint16_t, PacketQueue *);
-int DecodeGRE(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint32_t, PacketQueue *);
-int DecodeVLAN(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint32_t, PacketQueue *);
-int DecodeVXLAN(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint32_t, PacketQueue *);
-int DecodeMPLS(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint32_t, PacketQueue *);
-int DecodeERSPAN(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint32_t, PacketQueue *);
+int DecodeEthernet(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t, PacketQueue *);
+int DecodeSll(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t, PacketQueue *);
+int DecodePPP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t, PacketQueue *);
+int DecodePPPOESession(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t, PacketQueue *);
+int DecodePPPOEDiscovery(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t, PacketQueue *);
+int DecodeTunnel(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t, PacketQueue *, enum DecodeTunnelProto) __attribute__ ((warn_unused_result));
+int DecodeNull(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t, PacketQueue *);
+int DecodeRaw(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t, PacketQueue *);
+int DecodeIPV4(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t, PacketQueue *);
+int DecodeIPV6(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t, PacketQueue *);
+int DecodeICMPV4(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t, PacketQueue *);
+int DecodeICMPV6(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t, PacketQueue *);
+int DecodeTCP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t, PacketQueue *);
+int DecodeUDP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t, PacketQueue *);
+int DecodeSCTP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t, PacketQueue *);
+int DecodeGRE(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t, PacketQueue *);
+int DecodeVLAN(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t, PacketQueue *);
+int DecodeVXLAN(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t, PacketQueue *);
+int DecodeMPLS(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t, PacketQueue *);
+int DecodeERSPAN(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t, PacketQueue *);
int DecodeTEMPLATE(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t, PacketQueue *);
#ifdef UNITTESTS
-void DecodeIPV6FragHeader(Packet *p, uint8_t *pkt,
+void DecodeIPV6FragHeader(Packet *p, const uint8_t *pkt,
uint16_t hdrextlen, uint16_t plen,
uint16_t prev_hdrextlen);
#endif
}
int DetectBase64DecodeDoMatch(DetectEngineThreadCtx *det_ctx, const Signature *s,
- const SigMatchData *smd, uint8_t *payload, uint32_t payload_len)
+ const SigMatchData *smd, const uint8_t *payload, uint32_t payload_len)
{
DetectBase64Decode *data = (DetectBase64Decode *)smd->ctx;
int decode_len;
void DetectBase64DecodeRegister(void);
int DetectBase64DecodeDoMatch(DetectEngineThreadCtx *, const Signature *,
- const SigMatchData *, uint8_t *, uint32_t);
+ const SigMatchData *, const uint8_t *, uint32_t);
#endif /* __DETECT_BASE64_DECODE_H__ */
}
int DetectByteExtractDoMatch(DetectEngineThreadCtx *det_ctx, const SigMatchData *smd,
- const Signature *s, uint8_t *payload,
+ const Signature *s, const uint8_t *payload,
uint16_t payload_len, uint64_t *value,
uint8_t endian)
{
DetectByteExtractData *data = (DetectByteExtractData *)smd->ctx;
- uint8_t *ptr = NULL;
+ const uint8_t *ptr = NULL;
int32_t len = 0;
uint64_t val = 0;
int extbytes;
SigMatch *DetectByteExtractRetrieveSMVar(const char *, const Signature *);
int DetectByteExtractDoMatch(DetectEngineThreadCtx *, const SigMatchData *, const Signature *,
- uint8_t *, uint16_t, uint64_t *, uint8_t);
+ const uint8_t *, uint16_t, uint64_t *, uint8_t);
#endif /* __DETECT_BYTEEXTRACT_H__ */
* \retval 0 no match
*/
int DetectBytejumpDoMatch(DetectEngineThreadCtx *det_ctx, const Signature *s,
- const SigMatchCtx *ctx, uint8_t *payload, uint32_t payload_len,
+ const SigMatchCtx *ctx, const uint8_t *payload, uint32_t payload_len,
uint8_t flags, int32_t offset)
{
SCEnter();
const DetectBytejumpData *data = (const DetectBytejumpData *)ctx;
- uint8_t *ptr = NULL;
- uint8_t *jumpptr = NULL;
+ const uint8_t *ptr = NULL;
+ const uint8_t *jumpptr = NULL;
int32_t len = 0;
uint64_t val = 0;
int extbytes;
#ifdef DEBUG
if (SCLogDebugEnabled()) {
- uint8_t *sptr = (flags & DETECT_BYTEJUMP_BEGIN) ? payload : ptr;
+ const uint8_t *sptr = (flags & DETECT_BYTEJUMP_BEGIN) ? payload : ptr;
SCLogDebug("jumping %" PRId64 " bytes from %p (%08x) to %p (%08x)",
val, sptr, (int)(sptr - payload),
jumpptr, (int)(jumpptr - payload));
Packet *p, const Signature *s, const SigMatchCtx *ctx)
{
const DetectBytejumpData *data = (const DetectBytejumpData *)ctx;
- uint8_t *ptr = NULL;
- uint8_t *jumpptr = NULL;
+ const uint8_t *ptr = NULL;
+ const uint8_t *jumpptr = NULL;
uint16_t len = 0;
uint64_t val = 0;
int extbytes;
#ifdef DEBUG
if (SCLogDebugEnabled()) {
- uint8_t *sptr = (data->flags & DETECT_BYTEJUMP_BEGIN) ? p->payload
+ const uint8_t *sptr = (data->flags & DETECT_BYTEJUMP_BEGIN) ? p->payload
: ptr;
SCLogDebug("jumping %" PRId64 " bytes from %p (%08x) to %p (%08x)",
val, sptr, (int)(sptr - p->payload),
* error as a match.
*/
int DetectBytejumpDoMatch(DetectEngineThreadCtx *, const Signature *, const SigMatchCtx *,
- uint8_t *, uint32_t, uint8_t, int32_t);
+ const uint8_t *, uint32_t, uint8_t, int32_t);
#endif /* __DETECT_BYTEJUMP_H__ */
*/
int DetectBytetestDoMatch(DetectEngineThreadCtx *det_ctx,
const Signature *s, const SigMatchCtx *ctx,
- uint8_t *payload, uint32_t payload_len,
+ const uint8_t *payload, uint32_t payload_len,
uint8_t flags, int32_t offset, uint64_t value)
{
SCEnter();
const DetectBytetestData *data = (const DetectBytetestData *)ctx;
- uint8_t *ptr = NULL;
+ const uint8_t *ptr = NULL;
int32_t len = 0;
uint64_t val = 0;
int extbytes;
void DetectBytetestRegister (void);
int DetectBytetestDoMatch(DetectEngineThreadCtx *, const Signature *,
- const SigMatchCtx *ctx, uint8_t *, uint32_t,
+ const SigMatchCtx *ctx, const uint8_t *, uint32_t,
uint8_t, int32_t, uint64_t);
#endif /* __DETECT_BYTETEST_H__ */
int DetectEngineContentInspection(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
const Signature *s, const SigMatchData *smd,
Packet *p, Flow *f,
- uint8_t *buffer, uint32_t buffer_len,
+ const uint8_t *buffer, uint32_t buffer_len,
uint32_t stream_start_offset, uint8_t flags,
uint8_t inspection_mode)
{
/* search for our pattern, checking the matches recursively.
* if we match we look for the next SigMatch as well */
- uint8_t *found = NULL;
+ const uint8_t *found = NULL;
uint32_t offset = 0;
uint32_t depth = buffer_len;
uint32_t prev_offset = 0; /**< used in recursive searching */
}
}
- uint8_t *sbuffer = buffer + offset;
+ const uint8_t *sbuffer = buffer + offset;
uint32_t sbuffer_len = depth - offset;
uint32_t match_offset = 0;
SCLogDebug("sbuffer_len %"PRIu32, sbuffer_len);
/* Match branch, add replace to the list if needed */
if (cd->flags & DETECT_CONTENT_REPLACE) {
if (inspection_mode == DETECT_ENGINE_CONTENT_INSPECTION_MODE_PAYLOAD) {
- /* we will need to replace content if match is confirmed */
- det_ctx->replist = DetectReplaceAddToList(det_ctx->replist, found, cd);
+ /* we will need to replace content if match is confirmed
+ * cast to non-const as replace writes to it. */
+ det_ctx->replist = DetectReplaceAddToList(det_ctx->replist, (uint8_t *)found, cd);
} else {
SCLogWarning(SC_ERR_INVALID_VALUE, "Can't modify payload without packet");
}
int DetectEngineContentInspection(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
const Signature *s, const SigMatchData *smd,
Packet *p, Flow *f,
- uint8_t *buffer, uint32_t buffer_len,
+ const uint8_t *buffer, uint32_t buffer_len,
uint32_t stream_start_offset, uint8_t flags,
uint8_t inspection_mode);
int DetectLuaMatchBuffer(DetectEngineThreadCtx *det_ctx,
const Signature *s, const SigMatchData *smd,
- uint8_t *buffer, uint32_t buffer_len, uint32_t offset,
+ const uint8_t *buffer, uint32_t buffer_len, uint32_t offset,
Flow *f)
{
SCEnter();
void DetectLuaRegister (void);
int DetectLuaMatchBuffer(DetectEngineThreadCtx *det_ctx,
const Signature *s, const SigMatchData *smd,
- uint8_t *buffer, uint32_t buffer_len, uint32_t offset,
+ const uint8_t *buffer, uint32_t buffer_len, uint32_t offset,
Flow *f);
void DetectLuaPostSetup(Signature *s);
*/
int DetectPcrePayloadMatch(DetectEngineThreadCtx *det_ctx, const Signature *s,
const SigMatchData *smd, Packet *p, Flow *f,
- uint8_t *payload, uint32_t payload_len)
+ const uint8_t *payload, uint32_t payload_len)
{
SCEnter();
#define MAX_SUBSTRINGS 30
int ret = 0;
int ov[MAX_SUBSTRINGS];
- uint8_t *ptr = NULL;
+ const uint8_t *ptr = NULL;
uint16_t len = 0;
uint16_t capture_len = 0;
int DetectPcrePayloadMatch(DetectEngineThreadCtx *,
const Signature *, const SigMatchData *,
- Packet *, Flow *, uint8_t *, uint32_t);
+ Packet *, Flow *, const uint8_t *, uint32_t);
-int DetectPcrePacketPayloadMatch(DetectEngineThreadCtx *, Packet *, Signature *, SigMatch *);
-int DetectPcrePayloadDoMatch(DetectEngineThreadCtx *, Signature *, SigMatch *,
- Packet *, uint8_t *, uint16_t);
void DetectPcreRegister (void);
#endif /* __DETECT_PCRE_H__ */
pfv->datalink = pcap_datalink(pfv->pcap_handle);
SCLogDebug("datalink %" PRId32 "", pfv->datalink);
- Decoder temp;
+ DecoderFunc temp;
TmEcode validated = ValidateLinkType(pfv->datalink, &temp);
SCReturnInt(validated);
}
-TmEcode ValidateLinkType(int datalink, Decoder *decoder)
+TmEcode ValidateLinkType(int datalink, DecoderFunc *decoder)
{
switch (datalink) {
case LINKTYPE_LINUX_SLL:
PcapFileSharedVars *shared;
} PcapFileFileVars;
-typedef int (*Decoder)(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint32_t, PacketQueue *);
-
/**
* Dispatch a file for processing, where the information necessary to process that
* file is as PcapFileFileVars object.
* @param decoder Pointer to decoder to set if valid
* @return TM_ECODE_OK if valid datalink type and decoder has been set.
*/
-TmEcode ValidateLinkType(int datalink, Decoder *decoder);
+TmEcode ValidateLinkType(int datalink, DecoderFunc *decoder);
#endif /* __SOURCE_PCAP_FILE_HELPER_H__ */
FlowWakeupFlowManagerThread();
}
- Decoder decoder;
+ DecoderFunc decoder;
if(ValidateLinkType(p->datalink, &decoder) == TM_ECODE_OK) {
/* call the decoder */
node->len.len = 0;
ac->iter++;
- uint8_t *tmp_iter = ac->iter;
+ const uint8_t *tmp_iter = ac->iter;
/* Check that e-o-c is in bounds */
for (; tmp_iter < ac->end - 1; tmp_iter++) {
*
* \retval void
*/
-void SCAsn1CtxInit(Asn1Ctx *ac, uint8_t *data, uint16_t length)
+void SCAsn1CtxInit(Asn1Ctx *ac, const uint8_t *data, uint16_t length)
{
ac->data = data;
ac->iter = data;
typedef struct Asn1Len_ {
uint8_t form;
uint32_t len;
- uint8_t *ptr;
+ const uint8_t *ptr;
} Asn1Len;
typedef struct Asn1Id_ {
- uint8_t *ptr;
+ const uint8_t *ptr;
uint8_t class_tag;
uint8_t tag_type;
uint32_t tag_num;
} Asn1Id;
typedef struct Asn1Data_ {
- uint8_t *ptr;
+ const uint8_t *ptr;
uint32_t len;
uint8_t type;
} Asn1Data;
} Asn1Node;
typedef struct Asn1Ctx_ {
- uint8_t *data;
- uint8_t *end;
+ const uint8_t *data;
+ const uint8_t *end;
uint16_t len;
- uint8_t *iter;
+ const uint8_t *iter;
uint16_t cur_frame;
Asn1Node *asn1_stack2[ASN1_MAX_FRAMES];
void SCPrintByteBin(uint8_t);
Asn1Ctx *SCAsn1CtxNew(void);
-void SCAsn1CtxInit(Asn1Ctx *, uint8_t *, uint16_t);
+void SCAsn1CtxInit(Asn1Ctx *, const uint8_t *, uint16_t);
void SCAsn1CtxDestroy(Asn1Ctx *);
uint8_t SCAsn1Decode(Asn1Ctx *, uint16_t);