app-layer: add substate support to list hooks

Add substates to the --list-app-layer-hooks option.
pull/15846/head
Victor Julien 3 weeks ago
parent 8a5e8c63b2
commit 8455efd9ac

@ -92,35 +92,57 @@ int ListAppLayerHooks(const char *conf_filename)
if (alprotos[a] != 1) if (alprotos[a] != 1)
continue; continue;
const char *alproto_name = AppProtoToString(a); if (AppLayerParserSupportsSubStates(a)) {
if (strcmp(alproto_name, "http") == 0) const uint8_t max_sub_state = AppLayerParserGetMaxSubState(a);
alproto_name = "http1"; for (uint8_t sub_state = 1; sub_state <= max_sub_state; sub_state++) {
SCLogDebug("alproto %u/%s", a, alproto_name); const char *sub_state_name = AppLayerParserGetSubStateName(a, sub_state);
const uint8_t max_progress = AppLayerParserGetSubStateCompletion(a, sub_state);
const int max_progress_ts = for (uint8_t state = 0; state <= max_progress; state++) {
AppLayerParserGetStateProgressCompletionStatus(a, STREAM_TOSERVER); const char *name = AppLayerParserGetSubStateProgressName(
const int max_progress_tc = a, sub_state, state, STREAM_TOSERVER);
AppLayerParserGetStateProgressCompletionStatus(a, STREAM_TOCLIENT); if (name != NULL) {
printf("%s:%s:%s\n", AppProtoToString(a), sub_state_name, name);
printf("%s:%s\n", alproto_name, "request_started"); }
for (int p = 0; p <= max_progress_ts; p++) { }
const char *name = AppLayerParserGetStateNameById( for (uint8_t state = 0; state <= max_progress; state++) {
IPPROTO_TCP /* TODO no ipproto */, a, p, STREAM_TOSERVER); const char *name = AppLayerParserGetSubStateProgressName(
if (name != NULL && !IsBuiltIn(name)) { a, sub_state, state, STREAM_TOCLIENT);
printf("%s:%s\n", alproto_name, name); if (name != NULL) {
printf("%s:%s:%s\n", AppProtoToString(a), sub_state_name, name);
}
}
} }
} } else {
printf("%s:%s\n", alproto_name, "request_complete"); const char *alproto_name = AppProtoToString(a);
if (strcmp(alproto_name, "http") == 0)
printf("%s:%s\n", alproto_name, "response_started"); alproto_name = "http1";
for (int p = 0; p <= max_progress_tc; p++) { SCLogDebug("alproto %u/%s", a, alproto_name);
const char *name = AppLayerParserGetStateNameById(
IPPROTO_TCP /* TODO no ipproto */, a, p, STREAM_TOCLIENT); const int max_progress_ts =
if (name != NULL && !IsBuiltIn(name)) { AppLayerParserGetStateProgressCompletionStatus(a, STREAM_TOSERVER);
printf("%s:%s\n", alproto_name, name); const int max_progress_tc =
AppLayerParserGetStateProgressCompletionStatus(a, STREAM_TOCLIENT);
printf("%s:%s\n", alproto_name, "request_started");
for (int p = 0; p <= max_progress_ts; p++) {
const char *name = AppLayerParserGetStateNameById(
IPPROTO_TCP /* TODO no ipproto */, a, p, STREAM_TOSERVER);
if (name != NULL && !IsBuiltIn(name)) {
printf("%s:%s\n", alproto_name, name);
}
}
printf("%s:%s\n", alproto_name, "request_complete");
printf("%s:%s\n", alproto_name, "response_started");
for (int p = 0; p <= max_progress_tc; p++) {
const char *name = AppLayerParserGetStateNameById(
IPPROTO_TCP /* TODO no ipproto */, a, p, STREAM_TOCLIENT);
if (name != NULL && !IsBuiltIn(name)) {
printf("%s:%s\n", alproto_name, name);
}
} }
printf("%s:%s\n", alproto_name, "response_complete");
} }
printf("%s:%s\n", alproto_name, "response_complete");
} }
return TM_ECODE_DONE; return TM_ECODE_DONE;
} }

Loading…
Cancel
Save