@@ -963,71 +963,77 @@ class SINSP_PUBLIC sinsp : public capture_stats_source, public wmi_handle_source
963
963
* - `EF_SKIPPARSERESET`
964
964
* - `EF_UNUSED`
965
965
*
966
- * @param event_type type of event we want to check
966
+ * @param event_type type of event we want to check (must be less than `PPM_EVENT_MAX`)
967
967
* @return true if the event type has at least one of these flags.
968
968
*/
969
969
static inline bool is_unused_event (uint16_t event_type)
970
970
{
971
+ ASSERT (event_type < PPM_EVENT_MAX);
971
972
enum ppm_event_flags flags = g_infotables.m_event_info [event_type].flags ;
972
973
return (flags & (EF_SKIPPARSERESET | EF_UNUSED));
973
974
}
974
975
975
976
/* *
976
977
* @brief Return true if the event has the `EF_OLD_VERSION` flag
977
978
*
978
- * @param event_type type of event we want to check
979
+ * @param event_type type of event we want to check (must be less than `PPM_EVENT_MAX`)
979
980
* @return true if the event type has the `EF_OLD_VERSION` flag.
980
981
*/
981
982
static inline bool is_old_version_event (uint16_t event_type)
982
983
{
984
+ ASSERT (event_type < PPM_EVENT_MAX);
983
985
enum ppm_event_flags flags = g_infotables.m_event_info [event_type].flags ;
984
986
return (flags & EF_OLD_VERSION);
985
987
}
986
988
987
989
/* *
988
990
* @brief Return true if the event belongs to the `EC_SYSCALL` category
989
991
*
990
- * @param event_type type of event we want to check
992
+ * @param event_type type of event we want to check (must be less than `PPM_EVENT_MAX`)
991
993
* @return true if the event type has the `EC_SYSCALL` category.
992
994
*/
993
995
static inline bool is_syscall_event (uint16_t event_type)
994
996
{
997
+ ASSERT (event_type < PPM_EVENT_MAX);
995
998
enum ppm_event_category category = g_infotables.m_event_info [event_type].category ;
996
999
return (category & EC_SYSCALL);
997
1000
}
998
1001
999
1002
/* *
1000
1003
* @brief Return true if the event belongs to the `EC_TRACEPOINT` category
1001
1004
*
1002
- * @param event_type type of event we want to check
1005
+ * @param event_type type of event we want to check (must be less than `PPM_EVENT_MAX`)
1003
1006
* @return true if the event type has the `EC_TRACEPOINT` category.
1004
1007
*/
1005
1008
static inline bool is_tracepoint_event (uint16_t event_type)
1006
1009
{
1010
+ ASSERT (event_type < PPM_EVENT_MAX);
1007
1011
enum ppm_event_category category = g_infotables.m_event_info [event_type].category ;
1008
1012
return (category & EC_TRACEPOINT);
1009
1013
}
1010
1014
1011
1015
/* *
1012
1016
* @brief Return true if the event belongs to the `EC_METAEVENT` category
1013
1017
*
1014
- * @param event_type type of event we want to check
1018
+ * @param event_type type of event we want to check (must be less than `PPM_EVENT_MAX`)
1015
1019
* @return true if the event type has the `EC_METAEVENT` category.
1016
1020
*/
1017
1021
static inline bool is_metaevent (uint16_t event_type)
1018
1022
{
1023
+ ASSERT (event_type < PPM_EVENT_MAX);
1019
1024
enum ppm_event_category category = g_infotables.m_event_info [event_type].category ;
1020
1025
return (category & EC_METAEVENT);
1021
1026
}
1022
1027
1023
1028
/* *
1024
1029
* @brief Return true if the event belongs to the `EC_UNKNOWN` category
1025
1030
*
1026
- * @param event_type type of event we want to check
1031
+ * @param event_type type of event we want to check (must be less than `PPM_EVENT_MAX`)
1027
1032
* @return true if the event type has the `EC_UNKNOWN` category.
1028
1033
*/
1029
1034
static inline bool is_unknown_event (uint16_t event_type)
1030
1035
{
1036
+ ASSERT (event_type < PPM_EVENT_MAX);
1031
1037
enum ppm_event_category category = g_infotables.m_event_info [event_type].category ;
1032
1038
/* Please note this is not an `&` but an `==` if one event has
1033
1039
* the `EC_UNKNOWN` category, it must have only this category!
@@ -1038,15 +1044,28 @@ class SINSP_PUBLIC sinsp : public capture_stats_source, public wmi_handle_source
1038
1044
/* *
1039
1045
* @brief Return true if the event belongs to the `EC_PLUGIN` category
1040
1046
*
1041
- * @param event_type type of event we want to check
1047
+ * @param event_type type of event we want to check (must be less than `PPM_EVENT_MAX`)
1042
1048
* @return true if the event type has the `EC_PLUGIN` category.
1043
1049
*/
1044
1050
static inline bool is_plugin_event (uint16_t event_type)
1045
1051
{
1052
+ ASSERT (event_type < PPM_EVENT_MAX);
1046
1053
enum ppm_event_category category = g_infotables.m_event_info [event_type].category ;
1047
1054
return (category & EC_PLUGIN);
1048
1055
}
1049
1056
1057
+ /* *
1058
+ * @brief Return true if the event is generable by the live system instrumentation.
1059
+ *
1060
+ * @param event_type type of event we want to check (must be less than `PPM_EVENT_MAX`)
1061
+ * @return true if the event is generable by the live system.
1062
+ */
1063
+ static inline bool is_generable_event (uint16_t event_type)
1064
+ {
1065
+ ASSERT (event_type < PPM_EVENT_MAX);
1066
+ return scap_is_generable_event (event_type);
1067
+ }
1068
+
1050
1069
/* =============================== Events related ===============================*/
1051
1070
1052
1071
bool setup_cycle_writer (std::string base_file_name, int rollover_mb, int duration_seconds, int file_limit, unsigned long event_limit, bool compress);
0 commit comments