@@ -63,6 +63,8 @@ enum cfg_timeout_mode {
6363 CFG_TIMEOUT_HALF_WAIT = -3 /**< Block only if some client is connected */
6464};
6565
66+ /** Filename of IPFIX-to-UniRec */
67+ #define DEF_CONF_FILENAME "unirec-elements.txt"
6668/** Default maximum number of connections over TCP/TCP-TLS/Unix */
6769#define DEF_MAX_CONNECTIONS 64
6870/** Default output interface timeout */
@@ -84,6 +86,7 @@ struct ifc_common {
8486
8587/*
8688 * <params>
89+ * <mappingFile>/etc/ipfixcol2/unirec-elements.txt</mappingFile>
8790 * <uniRecFormat>DST_IP,SRC_IP,BYTES,DST_PORT,?TCP_FLAGS,SRC_PORT,PROTOCOL</uniRecFormat>
8891 * <splitBiflow>true</splitBiflow>
8992 * <trapIfcCommon> <!-- optional -->
@@ -123,6 +126,7 @@ enum params_xml_nodes {
123126 // Main parameters
124127 NODE_UNIREC_FMT = 1 ,
125128 NODE_BIFLOW_SPLIT ,
129+ NODE_MAPPING_FILE ,
126130 NODE_TRAP_COMMON ,
127131 NODE_TRAP_SPEC ,
128132 // TRAP common parameters
@@ -208,6 +212,7 @@ static const struct fds_xml_args args_params[] = {
208212 FDS_OPTS_ROOT ("params" ),
209213 FDS_OPTS_ELEM (NODE_UNIREC_FMT , "uniRecFormat" , FDS_OPTS_T_STRING , 0 ),
210214 FDS_OPTS_ELEM (NODE_BIFLOW_SPLIT , "splitBiflow" , FDS_OPTS_T_BOOL , FDS_OPTS_P_OPT ),
215+ FDS_OPTS_ELEM (NODE_MAPPING_FILE , "mappingFile" , FDS_OPTS_T_STRING , FDS_OPTS_P_OPT ),
211216 FDS_OPTS_NESTED (NODE_TRAP_COMMON , "trapIfcCommon" , args_trap_common , FDS_OPTS_P_OPT ),
212217 FDS_OPTS_NESTED (NODE_TRAP_SPEC , "trapIfcSpec" , args_trap_spec , 0 ),
213218 FDS_OPTS_END
@@ -781,6 +786,13 @@ cfg_parse_params(ipx_ctx_t *ctx, fds_xml_ctx_t *root, struct conf_params *cfg)
781786
782787 // Set default values
783788 cfg -> biflow_split = true;
789+ cfg -> mapping_file = NULL ;
790+
791+ rc = cfg_str_append (& cfg -> mapping_file , "%s/%s" , ipx_api_cfg_dir (), DEF_CONF_FILENAME );
792+ if (rc != FDS_OK ) {
793+ IPX_CTX_ERROR (ctx , "Unable to allocate memory (%s:%d)" , __FILE__ , __LINE__ );
794+ return rc ;
795+ }
784796
785797 // Set default TRAP common parameters
786798 struct ifc_common common ;
@@ -807,6 +819,16 @@ cfg_parse_params(ipx_ctx_t *ctx, fds_xml_ctx_t *root, struct conf_params *cfg)
807819 assert (content -> type == FDS_OPTS_T_BOOL );
808820 cfg -> biflow_split = content -> val_bool ;
809821 break ;
822+ case NODE_MAPPING_FILE :
823+ // Mapping file
824+ assert (content -> type == FDS_OPTS_T_STRING );
825+ free (cfg -> mapping_file );
826+ cfg -> mapping_file = strdup (content -> ptr_string );
827+ if (cfg -> mapping_file == NULL ) {
828+ IPX_CTX_ERROR (ctx , "Unable to allocate memory (%s:%d)" , __FILE__ , __LINE__ );
829+ return IPX_ERR_NOMEM ;
830+ }
831+ break ;
810832 case NODE_TRAP_SPEC :
811833 // TRAP output interface specifier
812834 assert (content -> type == FDS_OPTS_T_CONTEXT );
@@ -920,6 +942,7 @@ configuration_free(struct conf_params *cfg)
920942 return ;
921943 }
922944
945+ free (cfg -> mapping_file );
923946 free (cfg -> trap_ifc_spec );
924947 free (cfg -> unirec_fmt );
925948 free (cfg -> unirec_spec );
0 commit comments