Go to the documentation of this file.
43 #define TFTP_DEFAULT_PORT "69"
47 #define TFTP_MIN_FRAME_LEN 4
49 static void *TFTPStateAlloc(
void *orig_state,
AppProto proto_orig)
51 return rs_tftp_state_alloc();
54 static void TFTPStateFree(
void *state)
56 rs_tftp_state_free(state);
65 static void TFTPStateTxFree(
void *state, uint64_t tx_id)
67 rs_tftp_state_tx_free(state, tx_id);
70 static int TFTPStateGetEventInfo(
const char *event_name,
int *event_id,
82 static AppProto TFTPProbingParser(
Flow *f, uint8_t direction,
83 const uint8_t *input, uint32_t input_len, uint8_t *rdir)
92 SCLogDebug(
"Protocol not detected as ALPROTO_TFTP.");
97 StreamSlice stream_slice,
void *local_data)
99 const uint8_t *input = StreamSliceGetData(&stream_slice);
100 uint32_t input_len = StreamSliceGetDataLen(&stream_slice);
102 SCLogDebug(
"Parsing tftp request: len=%" PRIu32, input_len);
105 if ((input == NULL || input_len == 0) &&
112 if (input == NULL || input_len == 0) {
116 int res = rs_tftp_request(state, input, input_len);
127 StreamSlice stream_slice,
void *local_data)
132 static uint64_t TFTPGetTxCnt(
void *state)
134 return rs_tftp_get_tx_cnt(state);
137 static void *TFTPGetTx(
void *state, uint64_t tx_id)
139 return rs_tftp_get_tx(state, tx_id);
155 static int TFTPGetStateProgress(
void *tx, uint8_t direction)
162 const char *proto_name =
"tftp";
168 SCLogDebug(
"TFTP UDP protocol detection enabled.");
173 SCLogDebug(
"Unittest mode, registering default configuration.");
176 STREAM_TOSERVER, TFTPProbingParser,
182 TFTPProbingParser, TFTPProbingParser)) {
183 SCLogDebug(
"No tftp app-layer configuration, enabling tftp"
184 " detection UDP detection on port %s.",
189 STREAM_TOSERVER,TFTPProbingParser,
194 SCLogDebug(
"Protocol detector and parser disabled for TFTP.");
200 SCLogDebug(
"Registering TFTP protocol parser.");
205 TFTPStateAlloc, TFTPStateFree);
209 STREAM_TOSERVER, TFTPParseRequest);
213 STREAM_TOCLIENT, TFTPParseResponse);
228 TFTPGetStateProgress);
233 TFTPStateGetEventInfo);
236 rs_tftp_get_tx_data);
240 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
enum AppLayerEventType_ AppLayerEventType
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 AppLayerParserRegisterStateFuncs(uint8_t ipproto, AppProto alproto, void *(*StateAlloc)(void *, AppProto), void(*StateFree)(void *))
void RegisterTFTPParsers(void)
#define TFTP_DEFAULT_PORT
void AppLayerParserRegisterGetEventInfo(uint8_t ipproto, AppProto alproto, int(*StateGetEventInfo)(const char *event_name, int *event_id, AppLayerEventType *event_type))
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.