Skip to content

Commit

Permalink
Remove some old 1.6 code and clean up compat reader
Browse files Browse the repository at this point in the history
  • Loading branch information
phaag committed Apr 14, 2024
1 parent ea0286a commit 686f749
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 23 deletions.
6 changes: 1 addition & 5 deletions src/nfdump/compat_1_6_x/nfdump_1_6_x.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,4 @@
#include "nffileV2.h"
#include "nfxV3.h"

// forward declaration
// typedef struct exporter_info_record_s exporter_info_record_t;
// typedef struct extension_map_s extension_map_t;

#endif //_NFDUMP_H
#endif // _NFDUMP_1_6_x_H
2 changes: 2 additions & 0 deletions src/nfdump/compat_1_6_x/nffile_compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
*
*/

static extension_map_list_t *extension_map_list = NULL;

static inline record_header_t *ConvertRecordV2(recordHandle_t *handle, common_record_t *input_record, uint32_t flowCount);

#define MapExtension(extID, p) handle->extensionList[extID] = (void *)(p)
Expand Down
12 changes: 4 additions & 8 deletions src/nfdump/compat_1_6_x/nfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,28 @@
*
*/

#include "nfx.h"

#include <ctype.h>
#include <errno.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>

#include "config.h"

#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif

#include "nfdump.h"
#include "nffile.h"
#include "nfx.h"
#include "util.h"

/* global vars */

/*
* see nffile.h for detailed extension description
*/
extension_descriptor_t extension_descriptor[] = {
static extension_descriptor_t const extension_descriptor[] = {
// fill indices 0 - 3
{COMMON_BLOCK_ID, 0, 0, 1, "Required extension: Common record"},
{EX_IPv4v6, 0, 0, 1, "Required extension: IPv4/IPv6 src/dst address"},
Expand Down
2 changes: 1 addition & 1 deletion src/nfdump/compat_1_6_x/nfx.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2020, Peter Haag
* Copyright (c) 2009-2024, Peter Haag
* Copyright (c) 2004-2008, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
* All rights reserved.
*
Expand Down
10 changes: 9 additions & 1 deletion src/nfdump/exporter.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#include "util.h"

/* global */
exporter_t **exporter_list = NULL;
static exporter_t **exporter_list = NULL;

/* local variables */
#define MAX_EXPORTERS 65536
Expand Down Expand Up @@ -90,6 +90,8 @@ int AddExporterInfo(exporter_info_record_t *exporter_record) {
return 0;
}

if (exporter_list == NULL) InitExporterList();

// sanity check
uint32_t id = exporter_record->sysid;
if (id >= MAX_EXPORTERS) {
Expand Down Expand Up @@ -201,6 +203,8 @@ int AddSamplerRecord(sampler_record_t *sampler_record) {
return 0;
}

if (exporter_list == NULL) InitExporterList();

if (!exporter_list[id]) {
LogError("Exporter SysID: %u not found! - Skip sampler record", id);
return 0;
Expand Down Expand Up @@ -271,6 +275,7 @@ int AddExporterStat(exporter_stats_record_t *stat_record) {
use_copy = 0;
}

if (exporter_list == NULL) InitExporterList();
for (int i = 0; i < rec->stat_count; i++) {
uint32_t id = rec->stat[i].sysid;
if (id >= MAX_EXPORTERS) {
Expand Down Expand Up @@ -306,6 +311,9 @@ exporter_t *GetExporterInfo(int exporterID) {

dataBlock_t *ExportExporterList(nffile_t *nffile, dataBlock_t *dataBlock) {
// sysid 0 unused -> no exporter available

if (exporter_list == NULL) return dataBlock;

int i = 1;
while (i < MAX_EXPORTERS && exporter_list[i] != NULL) {
exporter_info_record_t *exporter;
Expand Down
13 changes: 5 additions & 8 deletions src/nfdump/nfdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
#include "nbar.h"
#include "netflow_v5_v7.h"
#include "netflow_v9.h"
#include "nfdump_1_6_x.h"
// #include "nfdump_1_6_x.h"
#include "nffile.h"
#include "nflowcache.h"
#include "nfnet.h"
Expand All @@ -82,8 +82,6 @@ static uint32_t passed = 0;
static uint32_t skipped_blocks = 0;
static uint64_t t_first_flow, t_last_flow;

extension_map_list_t *extension_map_list;

enum processType { FLOWSTAT = 1, ELEMENTSTAT, ELEMENTFLOWSTAT, SORTRECORDS, WRITEFILE, PRINTRECORD };

extern exporter_t **exporter_list;
Expand Down Expand Up @@ -304,6 +302,10 @@ static stat_record_t process_data(void *engine, int processwMode, char *wfile, R
goto SKIP;
break;
case DATA_BLOCK_TYPE_2:
// auto init old extension maps
if (extension_map_list == NULL) {
extension_map_list = InitExtensionMaps(NEEDS_EXTENSION_LIST);
}
case DATA_BLOCK_TYPE_3:
// processed blocks
break;
Expand Down Expand Up @@ -853,11 +855,6 @@ int main(int argc, char **argv) {
aggregate = 1;
}

extension_map_list = InitExtensionMaps(NEEDS_EXTENSION_LIST);
if (!InitExporterList()) {
exit(EXIT_FAILURE);
}

if (tstring) {
flist.timeWindow = ScanTimeFrame(tstring);
if (!flist.timeWindow) exit(EXIT_FAILURE);
Expand Down

0 comments on commit 686f749

Please sign in to comment.