Go to the documentation of this file.
38 #define TFTP_DEFAULT_PORT "69"
42 #define TFTP_MIN_FRAME_LEN 4
44 static void *TFTPStateAlloc(
void *orig_state,
AppProto proto_orig)
46 return rs_tftp_state_alloc();
49 static void TFTPStateFree(
void *state)
51 rs_tftp_state_free(state);
60 static void TFTPStateTxFree(
void *state, uint64_t tx_id)
62 rs_tftp_state_tx_free(state, tx_id);
65 static int TFTPStateGetEventInfo(
66 const char *event_name, uint8_t *event_id, AppLayerEventType *event_type)
77 static AppProto TFTPProbingParser(
Flow *f, uint8_t direction,
78 const uint8_t *input, uint32_t input_len, uint8_t *rdir)
87 SCLogDebug(
"Protocol not detected as ALPROTO_TFTP.");
92 StreamSlice stream_slice,
void *local_data)
94 const uint8_t *input = StreamSliceGetData(&stream_slice);
95 uint32_t input_len = StreamSliceGetDataLen(&stream_slice);
97 SCLogDebug(
"Parsing tftp request: len=%" PRIu32, input_len);
100 if ((input == NULL || input_len == 0) &&
107 if (input == NULL || input_len == 0) {
111 int64_t res = rs_tftp_request(state, input, input_len);
122 StreamSlice stream_slice,
void *local_data)
127 static uint64_t TFTPGetTxCnt(
void *state)
129 return rs_tftp_get_tx_cnt(state);
132 static void *TFTPGetTx(
void *state, uint64_t tx_id)
134 return rs_tftp_get_tx(state, tx_id);
150 static int TFTPGetStateProgress(
void *tx, uint8_t direction)
157 const char *proto_name =
"tftp";
163 SCLogDebug(
"TFTP UDP protocol detection enabled.");
168 SCLogDebug(
"Unittest mode, registering default configuration.");
171 STREAM_TOSERVER, TFTPProbingParser,
177 TFTPProbingParser, TFTPProbingParser)) {
178 SCLogDebug(
"No tftp app-layer configuration, enabling tftp"
179 " detection UDP detection on port %s.",
184 STREAM_TOSERVER,TFTPProbingParser,
190 SCLogDebug(
"Protocol detector and parser disabled for TFTP.");
196 SCLogDebug(
"Registering TFTP protocol parser.");
201 TFTPStateAlloc, TFTPStateFree);
205 STREAM_TOSERVER, TFTPParseRequest);
209 STREAM_TOCLIENT, TFTPParseResponse);
224 TFTPGetStateProgress);
229 TFTPStateGetEventInfo);
232 rs_tftp_get_tx_data);
236 SCLogDebug(
"TFTP protocol parsing disabled.");
void AppLayerParserRegisterGetStateProgressFunc(uint8_t ipproto, AppProto alproto, int(*StateGetProgress)(void *alstate, uint8_t direction))
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)
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
void AppLayerParserRegisterStateProgressCompletionStatus(AppProto alproto, const int ts, const int tc)
void AppLayerParserRegisterTxFreeFunc(uint8_t ipproto, AppProto alproto, void(*StateTransactionFree)(void *, uint64_t))
#define APP_LAYER_PARSER_EOF_TS
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
void AppLayerParserRegisterLogger(uint8_t ipproto, AppProto alproto)
void AppLayerParserRegisterStateFuncs(uint8_t ipproto, AppProto alproto, void *(*StateAlloc)(void *, AppProto), void(*StateFree)(void *))
void AppLayerParserRegisterGetEventInfo(uint8_t ipproto, AppProto alproto, int(*StateGetEventInfo)(const char *event_name, uint8_t *event_id, AppLayerEventType *event_type))
void RegisterTFTPParsers(void)
#define TFTP_DEFAULT_PORT
void AppLayerProtoDetectRegisterProtocol(AppProto alproto, const char *alproto_name)
Registers a protocol for protocol detection phase.
int RunmodeIsUnittests(void)
#define TFTP_MIN_FRAME_LEN
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))
#define SCReturnStruct(x)
void AppLayerParserRegisterStateDataFunc(uint8_t ipproto, AppProto alproto, AppLayerStateData *(*GetStateData)(void *state))
void AppLayerParserRegisterTxDataFunc(uint8_t ipproto, AppProto alproto, AppLayerTxData *(*GetTxData)(void *tx))
void AppLayerParserRegisterGetTxCnt(uint8_t ipproto, AppProto alproto, uint64_t(*StateGetTxCnt)(void *alstate))
uint16_t AppLayerParserStateIssetFlag(AppLayerParserState *pstate, uint16_t flag)
int AppLayerProtoDetectConfProtoDetectionEnabled(const char *ipproto, const char *alproto)
Given a protocol name, checks if proto detection is enabled in the conf file.