@@ -56,6 +56,16 @@ DLT_STATIC void dlt_logstorage_filter_config_free(DltLogStorageFilterConfig *dat
5656 data -> ctids = NULL ;
5757 }
5858
59+ if (data -> excluded_apids ) {
60+ free (data -> excluded_apids );
61+ data -> excluded_apids = NULL ;
62+ }
63+
64+ if (data -> excluded_ctids ) {
65+ free (data -> excluded_ctids );
66+ data -> excluded_ctids = NULL ;
67+ }
68+
5969 if (data -> file_name ) {
6070 free (data -> file_name );
6171 data -> file_name = NULL ;
@@ -162,6 +172,12 @@ DLT_STATIC int dlt_logstorage_list_add_config(DltLogStorageFilterConfig *data,
162172 if (data -> ctids != NULL )
163173 (* listdata )-> ctids = strdup (data -> ctids );
164174
175+ if (data -> excluded_apids != NULL )
176+ (* listdata )-> excluded_apids = strdup (data -> excluded_apids );
177+
178+ if (data -> excluded_ctids != NULL )
179+ (* listdata )-> excluded_ctids = strdup (data -> excluded_ctids );
180+
165181 if (data -> file_name != NULL )
166182 (* listdata )-> file_name = strdup (data -> file_name );
167183
@@ -529,6 +545,45 @@ DLT_STATIC int dlt_logstorage_get_keys_list(char *ids, char *sep, char **list,
529545 return 0 ;
530546}
531547
548+ DLT_STATIC bool dlt_logstorage_check_excluded_ids (char * id , char * delim , char * excluded_ids )
549+ {
550+ char * token = NULL ;
551+ char * tmp_token = NULL ;
552+ char * ids_local = NULL ;
553+
554+ if ((id == NULL ) || (delim == NULL ) || (excluded_ids == NULL )) {
555+ dlt_vlog (LOG_ERR , "%s: Invalid parameters\n" , __func__ );
556+ return false;
557+ }
558+
559+ ids_local = strdup (excluded_ids );
560+
561+ if (ids_local == NULL ) {
562+ dlt_vlog (LOG_ERR , "%s: Cannot duplicate string.\n" , __func__ );
563+ return false;
564+ }
565+
566+ token = strtok_r (ids_local , delim , & tmp_token );
567+
568+ if (token == NULL ) {
569+ dlt_vlog (LOG_ERR , "%s: %s could not be parsed.\n" , __func__ , ids_local );
570+ free (ids_local );
571+ return false;
572+ }
573+
574+ while (token != NULL ) {
575+ if (strncmp (id , token , DLT_ID_SIZE ) == 0 ) {
576+ free (ids_local );
577+ return true;
578+ }
579+
580+ token = strtok_r (NULL , delim , & tmp_token );
581+ }
582+
583+ free (ids_local );
584+ return false;
585+ }
586+
532587/**
533588 * dlt_logstorage_create_keys_only_ctid
534589 *
@@ -969,6 +1024,28 @@ DLT_STATIC int dlt_logstorage_check_ctids(DltLogStorageFilterConfig *config,
9691024 return dlt_logstorage_read_list_of_names (& config -> ctids , (const char * )value );
9701025}
9711026
1027+ DLT_STATIC int dlt_logstorage_store_config_excluded_apids (DltLogStorageFilterConfig * config ,
1028+ char * value )
1029+ {
1030+ if ((config == NULL ) || (value == NULL )) {
1031+ dlt_vlog (LOG_ERR , "%s: Invalid parameters\n" , __func__ );
1032+ return -1 ;
1033+ }
1034+
1035+ return dlt_logstorage_read_list_of_names (& config -> excluded_apids , value );
1036+ }
1037+
1038+ DLT_STATIC int dlt_logstorage_store_config_excluded_ctids (DltLogStorageFilterConfig * config ,
1039+ char * value )
1040+ {
1041+ if ((config == NULL ) || (value == NULL )) {
1042+ dlt_vlog (LOG_ERR , "%s: Invalid parameters\n" , __func__ );
1043+ return -1 ;
1044+ }
1045+
1046+ return dlt_logstorage_read_list_of_names (& config -> excluded_ctids , (const char * )value );
1047+ }
1048+
9721049DLT_STATIC int dlt_logstorage_set_loglevel (int * log_level ,
9731050 int value )
9741051{
@@ -1327,6 +1404,16 @@ DLT_STATIC DltLogstorageFilterConf
13271404 .func = dlt_logstorage_check_ctids ,
13281405 .is_opt = 1
13291406 },
1407+ [DLT_LOGSTORAGE_FILTER_CONF_EXCLUDED_LOGAPPNAME ] = {
1408+ .key = "ExcludedLogAppName" ,
1409+ .func = dlt_logstorage_store_config_excluded_apids ,
1410+ .is_opt = 1
1411+ },
1412+ [DLT_LOGSTORAGE_FILTER_CONF_EXCLUDED_CONTEXTNAME ] = {
1413+ .key = "ExcludedContextName" ,
1414+ .func = dlt_logstorage_store_config_excluded_ctids ,
1415+ .is_opt = 1
1416+ },
13301417 [DLT_LOGSTORAGE_FILTER_CONF_LOGLEVEL ] = {
13311418 .key = "LogLevel" ,
13321419 .func = dlt_logstorage_check_loglevel ,
@@ -1397,6 +1484,16 @@ DLT_STATIC DltLogstorageFilterConf
13971484 .func = dlt_logstorage_check_ctids ,
13981485 .is_opt = 0
13991486 },
1487+ [DLT_LOGSTORAGE_FILTER_CONF_EXCLUDED_LOGAPPNAME ] = {
1488+ .key = NULL ,
1489+ .func = dlt_logstorage_store_config_excluded_apids ,
1490+ .is_opt = 1
1491+ },
1492+ [DLT_LOGSTORAGE_FILTER_CONF_EXCLUDED_CONTEXTNAME ] = {
1493+ .key = NULL ,
1494+ .func = dlt_logstorage_store_config_excluded_ctids ,
1495+ .is_opt = 1
1496+ },
14001497 [DLT_LOGSTORAGE_FILTER_CONF_LOGLEVEL ] = {
14011498 .key = NULL ,
14021499 .func = dlt_logstorage_check_loglevel ,
@@ -1466,6 +1563,16 @@ DLT_STATIC DltLogstorageFilterConf
14661563 .func = dlt_logstorage_check_ctids ,
14671564 .is_opt = 0
14681565 },
1566+ [DLT_LOGSTORAGE_FILTER_CONF_EXCLUDED_LOGAPPNAME ] = {
1567+ .key = NULL ,
1568+ .func = dlt_logstorage_store_config_excluded_apids ,
1569+ .is_opt = 1
1570+ },
1571+ [DLT_LOGSTORAGE_FILTER_CONF_EXCLUDED_CONTEXTNAME ] = {
1572+ .key = NULL ,
1573+ .func = dlt_logstorage_store_config_excluded_ctids ,
1574+ .is_opt = 1
1575+ },
14691576 [DLT_LOGSTORAGE_FILTER_CONF_LOGLEVEL ] = {
14701577 .key = "LogLevel" ,
14711578 .func = dlt_logstorage_check_loglevel ,
@@ -1685,6 +1792,16 @@ DLT_STATIC int dlt_daemon_offline_setup_filter_properties(DltLogStorage *handle,
16851792 tmp_data .ctids = NULL ;
16861793 }
16871794
1795+ if (tmp_data .excluded_apids != NULL ) {
1796+ free (tmp_data .excluded_apids );
1797+ tmp_data .excluded_apids = NULL ;
1798+ }
1799+
1800+ if (tmp_data .excluded_ctids != NULL ) {
1801+ free (tmp_data .excluded_ctids );
1802+ tmp_data .excluded_ctids = NULL ;
1803+ }
1804+
16881805 if (tmp_data .file_name != NULL ) {
16891806 free (tmp_data .file_name );
16901807 tmp_data .file_name = NULL ;
@@ -1704,6 +1821,11 @@ DLT_STATIC int dlt_daemon_offline_setup_filter_properties(DltLogStorage *handle,
17041821 }
17051822 }
17061823
1824+ if (dlt_logstorage_count_ids (tmp_data .excluded_apids ) > 1 && dlt_logstorage_count_ids (tmp_data .excluded_ctids ) > 1 ) {
1825+ dlt_vlog (LOG_WARNING , "%s: Logstorage does not support both multiple excluded applications and contexts\n" , __func__ );
1826+ return DLT_OFFLINE_LOGSTORAGE_FILTER_ERROR ;
1827+ }
1828+
17071829 /* filter configuration is valid */
17081830 ret = dlt_logstorage_setup_table (handle , & tmp_data );
17091831
@@ -2339,6 +2461,33 @@ DLT_STATIC int dlt_logstorage_filter(DltLogStorage *handle,
23392461 "%s: ECUID does not match (Requested=%s, config[%d]=%s). Set the config to NULL and continue the filter loop\n" ,
23402462 __func__ , ecuid , i , config [i ]-> ecuid );
23412463 config [i ] = NULL ;
2464+ continue ;
2465+ }
2466+ }
2467+
2468+ if (config [i ]-> excluded_apids != NULL && config [i ]-> excluded_ctids != NULL ) {
2469+ /* Filter on excluded application and context */
2470+ if (apid != NULL && ctid != NULL && dlt_logstorage_check_excluded_ids (apid , "," , config [i ]-> excluded_apids )
2471+ && dlt_logstorage_check_excluded_ids (ctid , "," , config [i ]-> excluded_ctids )) {
2472+ dlt_vlog (LOG_DEBUG , "%s: %s matches with [%s] and %s matches with [%s]. Set the config to NULL and continue the filter loop\n" ,
2473+ __func__ , apid , config [i ]-> excluded_apids , ctid , config [i ]-> excluded_ctids );
2474+ config [i ] = NULL ;
2475+ }
2476+ }
2477+ else if (config [i ]-> excluded_apids == NULL ) {
2478+ /* Only filter on excluded contexts */
2479+ if (ctid != NULL && config [i ]-> excluded_ctids != NULL && dlt_logstorage_check_excluded_ids (ctid , "," , config [i ]-> excluded_ctids )) {
2480+ dlt_vlog (LOG_DEBUG , "%s: %s matches with [%s]. Set the config to NULL and continue the filter loop\n" ,
2481+ __func__ , ctid , config [i ]-> excluded_ctids );
2482+ config [i ] = NULL ;
2483+ }
2484+ }
2485+ else if (config [i ]-> excluded_ctids == NULL ) {
2486+ /* Only filter on excluded applications */
2487+ if (apid != NULL && config [i ]-> excluded_apids != NULL && dlt_logstorage_check_excluded_ids (apid , "," , config [i ]-> excluded_apids )) {
2488+ dlt_vlog (LOG_DEBUG , "%s: %s matches with [%s]. Set the config to NULL and continue the filter loop\n" ,
2489+ __func__ , apid , config [i ]-> excluded_apids );
2490+ config [i ] = NULL ;
23422491 }
23432492 }
23442493 }
0 commit comments