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.
*/
/* The global app layer proto detection context. */
static AppLayerProtoDetectCtx alpd_ctx;
+static AppLayerProtoDetectAliases *alpda_ctx = NULL;
static void AppLayerProtoDetectPEGetIpprotos(AppProto alproto,
uint8_t *ipprotos);
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)
SpmDestroyGlobalThreadCtx(alpd_ctx.spm_global_thread_ctx);
+ AppLayerProtoDetectFreeAliases();
+
AppLayerProtoDetectFreeProbingParsers(alpd_ctx.ctx_pp);
SCReturnInt(0);
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.
*
{
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++) {