return 0;
}
+/**
+ * \brief App-layer support.
+ */
+static int DNP3StateGetEventInfoById(int event_id, const char **event_name,
+ AppLayerEventType *event_type)
+{
+ *event_name = SCMapEnumValueToName(event_id, dnp3_decoder_event_table);
+ if (*event_name == NULL) {
+ SCLogError(SC_ERR_INVALID_ENUM_MAP, "Event \"%d\" not present in "
+ "the DNP3 enum event map table.", event_id);
+ return -1;
+ }
+
+ *event_type = APP_LAYER_EVENT_TYPE_TRANSACTION;
+
+ return 0;
+}
+
/**
* \brief App-layer support.
*/
AppLayerParserRegisterGetEventInfo(IPPROTO_TCP, ALPROTO_DNP3,
DNP3StateGetEventInfo);
+ AppLayerParserRegisterGetEventInfoById(IPPROTO_TCP, ALPROTO_DNP3,
+ DNP3StateGetEventInfoById);
AppLayerParserRegisterLoggerFuncs(IPPROTO_TCP, ALPROTO_DNP3,
DNP3GetTxLogged, DNP3SetTxLogged);
return 0;
}
+int DNSStateGetEventInfoById(int event_id, const char **event_name,
+ AppLayerEventType *event_type)
+{
+ *event_name = SCMapEnumValueToName(event_id, dns_decoder_event_table);
+ if (*event_name == NULL) {
+ SCLogError(SC_ERR_INVALID_ENUM_MAP, "event \"%d\" not present in "
+ "dns's enum map table.", event_id);
+ /* this should be treated as fatal */
+ return -1;
+ }
+
+ *event_type = APP_LAYER_EVENT_TYPE_TRANSACTION;
+
+ return 0;
+}
+
void DNSAppLayerRegisterGetEventInfo(uint8_t ipproto, AppProto alproto)
{
AppLayerParserRegisterGetEventInfo(ipproto, alproto, DNSStateGetEventInfo);
return;
}
+void DNSAppLayerRegisterGetEventInfoById(uint8_t ipproto, AppProto alproto)
+{
+ AppLayerParserRegisterGetEventInfoById(ipproto, alproto, DNSStateGetEventInfoById);
+
+ return;
+}
+
void DNSCreateTypeString(uint16_t type, char *str, size_t str_size)
{
switch (type) {
int DNSStateGetEventInfo(const char *event_name,
int *event_id, AppLayerEventType *event_type);
+int DNSStateGetEventInfoById(int event_id, const char **event_name,
+ AppLayerEventType *event_type);
void DNSAppLayerRegisterGetEventInfo(uint8_t ipproto, AppProto alproto);
+void DNSAppLayerRegisterGetEventInfoById(uint8_t ipproto, AppProto alproto);
void DNSCreateTypeString(uint16_t type, char *str, size_t str_size);
void DNSCreateRcodeString(uint8_t rcode, char *str, size_t str_size);
return 0;
}
+static int ENIPStateGetEventInfoById(int event_id, const char **event_name,
+ AppLayerEventType *event_type)
+{
+ *event_name = SCMapEnumValueToName(event_id, enip_decoder_event_table);
+ if (*event_name == NULL) {
+ SCLogError(SC_ERR_INVALID_ENUM_MAP, "event \"%d\" not present in "
+ "enip's enum map table.", event_id);
+ /* yes this is fatal */
+ return -1;
+ }
+
+ *event_type = APP_LAYER_EVENT_TYPE_TRANSACTION;
+
+ return 0;
+}
+
/** \brief Allocate enip state
*
* return state
AppLayerParserRegisterGetStateProgressCompletionStatus(ALPROTO_ENIP, ENIPGetAlstateProgressCompletionStatus);
AppLayerParserRegisterGetEventInfo(IPPROTO_UDP, ALPROTO_ENIP, ENIPStateGetEventInfo);
+ AppLayerParserRegisterGetEventInfoById(IPPROTO_UDP, ALPROTO_ENIP, ENIPStateGetEventInfoById);
AppLayerParserRegisterParserAcceptableDataDirection(IPPROTO_UDP,
ALPROTO_ENIP, STREAM_TOSERVER | STREAM_TOCLIENT);
return 0;
}
+static int HTPStateGetEventInfoById(int event_id, const char **event_name,
+ AppLayerEventType *event_type)
+{
+ *event_name = SCMapEnumValueToName(event_id, http_decoder_event_table);
+ if (*event_name == NULL) {
+ SCLogError(SC_ERR_INVALID_ENUM_MAP, "event \"%d\" not present in "
+ "http's enum map table.", event_id);
+ /* this should be treated as fatal */
+ return -1;
+ }
+
+ *event_type = APP_LAYER_EVENT_TYPE_TRANSACTION;
+
+ return 0;
+}
+
static void HTPStateTruncate(void *state, uint8_t direction)
{
FileContainer *fc = HTPStateGetFiles(state, direction);
HTPStateGetAlstateProgressCompletionStatus);
AppLayerParserRegisterGetEventsFunc(IPPROTO_TCP, ALPROTO_HTTP, HTPGetEvents);
AppLayerParserRegisterGetEventInfo(IPPROTO_TCP, ALPROTO_HTTP, HTPStateGetEventInfo);
+ AppLayerParserRegisterGetEventInfoById(IPPROTO_TCP, ALPROTO_HTTP, HTPStateGetEventInfoById);
AppLayerParserRegisterTruncateFunc(IPPROTO_TCP, ALPROTO_HTTP, HTPStateTruncate);
AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_HTTP,
return 0;
}
+static int ModbusStateGetEventInfoById(int event_id, const char **event_name,
+ AppLayerEventType *event_type)
+{
+ *event_name = SCMapEnumValueToName(event_id, modbus_decoder_event_table);
+
+ if (*event_name == NULL) {
+ SCLogError(SC_ERR_INVALID_ENUM_MAP, "event \"%d\" not present in "
+ "modbus's enum map table.", event_id);
+ /* yes this is fatal */
+ return -1;
+ }
+
+ *event_type = APP_LAYER_EVENT_TYPE_TRANSACTION;
+
+ return 0;
+}
+
static void ModbusSetEvent(ModbusState *modbus, uint8_t e)
{
if (modbus && modbus->curr) {
ModbusGetAlstateProgressCompletionStatus);
AppLayerParserRegisterGetEventInfo(IPPROTO_TCP, ALPROTO_MODBUS, ModbusStateGetEventInfo);
+ AppLayerParserRegisterGetEventInfoById(IPPROTO_TCP, ALPROTO_MODBUS, ModbusStateGetEventInfoById);
AppLayerParserRegisterParserAcceptableDataDirection(IPPROTO_TCP, ALPROTO_MODBUS, STREAM_TOSERVER);
return 0;
}
+static int SMTPStateGetEventInfoById(int event_id, const char **event_name,
+ AppLayerEventType *event_type)
+{
+ *event_name = SCMapEnumValueToName(event_id, smtp_decoder_event_table);
+ if (*event_name == NULL) {
+ SCLogError(SC_ERR_INVALID_ENUM_MAP, "event \"%d\" not present in "
+ "smtp's enum map table.", event_id);
+ /* yes this is fatal */
+ return -1;
+ }
+
+ *event_type = APP_LAYER_EVENT_TYPE_TRANSACTION;
+
+ return 0;
+}
+
static int SMTPRegisterPatternsForProtocolDetection(void)
{
if (AppLayerProtoDetectPMRegisterPatternCI(IPPROTO_TCP, ALPROTO_SMTP,
SMTPParseServerRecord);
AppLayerParserRegisterGetEventInfo(IPPROTO_TCP, ALPROTO_SMTP, SMTPStateGetEventInfo);
+ AppLayerParserRegisterGetEventInfoById(IPPROTO_TCP, ALPROTO_SMTP, SMTPStateGetEventInfoById);
AppLayerParserRegisterGetEventsFunc(IPPROTO_TCP, ALPROTO_SMTP, SMTPGetEvents);
AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_SMTP,
SMTPGetTxDetectState, SMTPSetTxDetectState);
return 0;
}
+static int SSLStateGetEventInfoById(int event_id, const char **event_name,
+ AppLayerEventType *event_type)
+{
+ *event_name = SCMapEnumValueToName(event_id, tls_decoder_event_table);
+ if (*event_name == NULL) {
+ SCLogError(SC_ERR_INVALID_ENUM_MAP, "event \"%d\" not present in "
+ "ssl's enum map table.", event_id);
+ /* yes this is fatal */
+ return -1;
+ }
+
+ *event_type = APP_LAYER_EVENT_TYPE_TRANSACTION;
+
+ return 0;
+}
+
static int SSLRegisterPatternsForProtocolDetection(void)
{
if (AppLayerProtoDetectPMRegisterPatternCS(IPPROTO_TCP, ALPROTO_TLS,
SSLParseServerRecord);
AppLayerParserRegisterGetEventInfo(IPPROTO_TCP, ALPROTO_TLS, SSLStateGetEventInfo);
+ AppLayerParserRegisterGetEventInfoById(IPPROTO_TCP, ALPROTO_TLS, SSLStateGetEventInfoById);
AppLayerParserRegisterStateFuncs(IPPROTO_TCP, ALPROTO_TLS, SSLStateAlloc, SSLStateFree);