|
|
|
@ -163,6 +163,12 @@ typedef struct AppLayerProtoDetectCtx_ {
|
|
|
|
|
const char *alproto_names[ALPROTO_MAX];
|
|
|
|
|
} AppLayerProtoDetectCtx;
|
|
|
|
|
|
|
|
|
|
typedef struct AppLayerProtoDetectAliases_ {
|
|
|
|
|
const char *proto_name;
|
|
|
|
|
const char *proto_alias;
|
|
|
|
|
struct AppLayerProtoDetectAliases_ *next;
|
|
|
|
|
} AppLayerProtoDetectAliases;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \brief The app layer protocol detection thread context.
|
|
|
|
|
*/
|
|
|
|
@ -175,6 +181,7 @@ struct AppLayerProtoDetectThreadCtx_ {
|
|
|
|
|
|
|
|
|
|
/* The global app layer proto detection context. */
|
|
|
|
|
static AppLayerProtoDetectCtx alpd_ctx;
|
|
|
|
|
static AppLayerProtoDetectAliases *alpda_ctx = NULL;
|
|
|
|
|
|
|
|
|
|
static void AppLayerProtoDetectPEGetIpprotos(AppProto alproto,
|
|
|
|
|
uint8_t *ipprotos);
|
|
|
|
@ -1600,6 +1607,27 @@ static void AppLayerProtoDetectFreeProbingParsers(AppLayerProtoDetectProbingPars
|
|
|
|
|
SCReturn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void AppLayerProtoDetectFreeAliases(void)
|
|
|
|
|
{
|
|
|
|
|
SCEnter();
|
|
|
|
|
|
|
|
|
|
AppLayerProtoDetectAliases *cur_alias = alpda_ctx;
|
|
|
|
|
if (cur_alias == NULL)
|
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
|
|
AppLayerProtoDetectAliases *next_alias = NULL;
|
|
|
|
|
while (cur_alias != NULL) {
|
|
|
|
|
next_alias = cur_alias->next;
|
|
|
|
|
SCFree(cur_alias);
|
|
|
|
|
cur_alias = next_alias;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
alpda_ctx = NULL;
|
|
|
|
|
|
|
|
|
|
end:
|
|
|
|
|
SCReturn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** State Preparation *****/
|
|
|
|
|
|
|
|
|
|
int AppLayerProtoDetectPrepareState(void)
|
|
|
|
@ -1851,6 +1879,8 @@ int AppLayerProtoDetectDeSetup(void)
|
|
|
|
|
|
|
|
|
|
SpmDestroyGlobalThreadCtx(alpd_ctx.spm_global_thread_ctx);
|
|
|
|
|
|
|
|
|
|
AppLayerProtoDetectFreeAliases();
|
|
|
|
|
|
|
|
|
|
AppLayerProtoDetectFreeProbingParsers(alpd_ctx.ctx_pp);
|
|
|
|
|
|
|
|
|
|
SCReturnInt(0);
|
|
|
|
@ -1866,6 +1896,32 @@ void AppLayerProtoDetectRegisterProtocol(AppProto alproto, const char *alproto_n
|
|
|
|
|
SCReturn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppLayerProtoDetectRegisterAlias(const char *proto_name, const char *proto_alias)
|
|
|
|
|
{
|
|
|
|
|
SCEnter();
|
|
|
|
|
|
|
|
|
|
AppLayerProtoDetectAliases *new_alias = SCMalloc(sizeof(AppLayerProtoDetectAliases));
|
|
|
|
|
if (unlikely(new_alias == NULL)) {
|
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
new_alias->proto_name = proto_name;
|
|
|
|
|
new_alias->proto_alias = proto_alias;
|
|
|
|
|
new_alias->next = NULL;
|
|
|
|
|
|
|
|
|
|
if (alpda_ctx == NULL) {
|
|
|
|
|
alpda_ctx = new_alias;
|
|
|
|
|
} else {
|
|
|
|
|
AppLayerProtoDetectAliases *cur_alias = alpda_ctx;
|
|
|
|
|
while (cur_alias->next != NULL) {
|
|
|
|
|
cur_alias = cur_alias->next;
|
|
|
|
|
}
|
|
|
|
|
cur_alias->next = new_alias;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SCReturn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** \brief request applayer to wrap up this protocol and rerun protocol
|
|
|
|
|
* detection.
|
|
|
|
|
*
|
|
|
|
@ -2090,6 +2146,15 @@ AppProto AppLayerProtoDetectGetProtoByName(const char *alproto_name)
|
|
|
|
|
{
|
|
|
|
|
SCEnter();
|
|
|
|
|
|
|
|
|
|
AppLayerProtoDetectAliases *cur_alias = alpda_ctx;
|
|
|
|
|
while (cur_alias != NULL) {
|
|
|
|
|
if (strcasecmp(alproto_name, cur_alias->proto_alias) == 0) {
|
|
|
|
|
alproto_name = cur_alias->proto_name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cur_alias = cur_alias->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AppProto a;
|
|
|
|
|
AppProto b = StringToAppProto(alproto_name);
|
|
|
|
|
for (a = 0; a < ALPROTO_MAX; a++) {
|
|
|
|
|