39 #include "rust-tftp-tftp-gen.h" 42 #define TFTP_DEFAULT_PORT "69" 46 #define TFTP_MIN_FRAME_LEN 4 48 static void *TFTPStateAlloc(
void)
50 return rs_tftp_state_alloc();
53 static void TFTPStateFree(
void *state)
55 rs_tftp_state_free(state);
64 static void TFTPStateTxFree(
void *state, uint64_t
tx_id)
66 rs_tftp_state_tx_free(state, tx_id);
69 static int TFTPStateGetEventInfo(
const char *event_name,
int *event_id,
86 static AppProto TFTPProbingParser(
Flow *f, uint8_t direction,
87 const uint8_t *input, uint32_t input_len, uint8_t *rdir)
96 SCLogDebug(
"Protocol not detected as ALPROTO_TFTP.");
100 static int TFTPParseRequest(
Flow *f,
void *state,
102 void *local_data,
const uint8_t
flags)
104 SCLogDebug(
"Parsing echo request: len=%"PRIu32, input_len);
107 if ((input == NULL || input_len == 0) &&
114 if (input == NULL || input_len == 0) {
118 return rs_tftp_request(state, input, input_len);
125 const uint8_t *input, uint32_t input_len,
void *local_data,
131 static uint64_t TFTPGetTxCnt(
void *state)
133 return rs_tftp_get_tx_cnt(state);
136 static void *TFTPGetTx(
void *state, uint64_t
tx_id)
138 return rs_tftp_get_tx(state, tx_id);
141 static void TFTPSetTxLogged(
void *state,
void *vtx, uint32_t logger)
143 rs_tftp_set_tx_logged(state, vtx, logger);
146 static LoggerId TFTPGetTxLogged(
void *state,
void *vtx)
148 return rs_tftp_get_tx_logged(state, vtx);
156 static int TFTPGetAlstateProgressCompletionStatus(uint8_t direction) {
173 static int TFTPGetStateProgress(
void *tx, uint8_t direction)
183 static int TFTPSetTxDetectState(
void *vtx,
191 const char *proto_name =
"tftp";
197 SCLogDebug(
"TFTP UDP protocol detection enabled.");
202 SCLogDebug(
"Unittest mode, registeringd default configuration.");
211 TFTPProbingParser, TFTPProbingParser)) {
212 SCLogDebug(
"No echo app-layer configuration, enabling echo" 213 " detection UDP detection on port %s.",
223 SCLogDebug(
"Protocol detecter and parser disabled for TFTP.");
229 SCLogDebug(
"Registering TFTP protocol parser.");
234 TFTPStateAlloc, TFTPStateFree);
250 TFTPGetTxLogged, TFTPSetTxLogged);
258 TFTPGetAlstateProgressCompletionStatus);
261 TFTPGetStateProgress);
267 TFTPGetTxDetectState,
268 TFTPSetTxDetectState);
271 TFTPStateGetEventInfo);
276 SCLogDebug(
"TFTP protocol parsing disabled.");
void RegisterTFTPParsers(void)
enum AppLayerEventType_ AppLayerEventType
void AppLayerProtoDetectPPRegister(uint8_t ipproto, const char *portstr, AppProto alproto, uint16_t min_depth, uint16_t max_depth, uint8_t direction, ProbingParserFPtr ProbingParser1, ProbingParserFPtr ProbingParser2)
register parser at a port
#define TFTP_MIN_FRAME_LEN
void AppLayerParserRegisterGetStateProgressFunc(uint8_t ipproto, AppProto alproto, int(*StateGetProgress)(void *alstate, uint8_t direction))
int AppLayerProtoDetectConfProtoDetectionEnabled(const char *ipproto, const char *alproto)
Given a protocol name, checks if proto detection is enabled in the conf file.
int AppLayerParserStateIssetFlag(AppLayerParserState *pstate, uint8_t flag)
void AppLayerParserRegisterDetectStateFuncs(uint8_t ipproto, AppProto alproto, DetectEngineState *(*GetTxDetectState)(void *tx), int(*SetTxDetectState)(void *tx, DetectEngineState *))
void AppLayerParserRegisterGetEventsFunc(uint8_t ipproto, AppProto alproto, AppLayerDecoderEvents *(*StateGetEvents)(void *))
void AppLayerParserRegisterLoggerFuncs(uint8_t ipproto, AppProto alproto, LoggerId(*StateGetTxLogged)(void *, void *), void(*StateSetTxLogged)(void *, void *, LoggerId))
#define TFTP_DEFAULT_PORT
int AppLayerParserConfParserEnabled(const char *ipproto, const char *alproto_name)
check if a parser is enabled in the config Returns enabled always if: were running unittests and when...
Data structure to store app layer decoder events.
int AppLayerParserRegisterParser(uint8_t ipproto, AppProto alproto, uint8_t direction, AppLayerParserFPtr Parser)
Register app layer parser for the protocol.
void AppLayerParserRegisterGetTx(uint8_t ipproto, AppProto alproto, void *(StateGetTx)(void *alstate, uint64_t tx_id))
int AppLayerProtoDetectPPParseConfPorts(const char *ipproto_name, uint8_t ipproto, const char *alproto_name, AppProto alproto, uint16_t min_depth, uint16_t max_depth, ProbingParserFPtr ProbingParserTs, ProbingParserFPtr ProbingParserTc)
void AppLayerParserRegisterGetEventInfo(uint8_t ipproto, AppProto alproto, int(*StateGetEventInfo)(const char *event_name, int *event_id, AppLayerEventType *event_type))
void AppLayerParserRegisterGetStateProgressCompletionStatus(AppProto alproto, int(*StateGetProgressCompletionStatus)(uint8_t direction))
int RunmodeIsUnittests(void)
void AppLayerProtoDetectRegisterProtocol(AppProto alproto, const char *alproto_name)
Registers a protocol for protocol detection phase.
#define APP_LAYER_PARSER_EOF
void AppLayerParserRegisterGetTxCnt(uint8_t ipproto, AppProto alproto, uint64_t(*StateGetTxCnt)(void *alstate))
void AppLayerParserRegisterStateFuncs(uint8_t ipproto, AppProto alproto, void *(*StateAlloc)(void), void(*StateFree)(void *))
void AppLayerParserRegisterTxFreeFunc(uint8_t ipproto, AppProto alproto, void(*StateTransactionFree)(void *, uint64_t))