Skip to content

Commit 70ece2e

Browse files
committed
Add Subdir -S to dynamic FlowSource -M. Replaces pull request #615
1 parent 3eb3043 commit 70ece2e

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

src/libnffile/flist.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ static const char *subdir_def[] = {"", // default index 0 - no subdir hierarchy
192192
#define AcceptedFormatChar "YymdjHMsUWwuF"
193193

194194
static mode_t mode, dir_mode;
195-
static const char *subdir_format;
195+
static const char *subdir_format = NULL;
196+
static int subdir_index = 0;
196197

197198
static struct entry_filter_s {
198199
char *first_entry;
@@ -1030,6 +1031,7 @@ int InitHierPath(int num) {
10301031
}
10311032

10321033
subdir_format = subdir_def[i];
1034+
subdir_index = i;
10331035

10341036
/*
10351037
* The default file mode is a=rwx (0777) with selected permissions
@@ -1115,6 +1117,8 @@ char *GetSubDir(struct tm *now) {
11151117

11161118
} // End of GetSubDir
11171119

1120+
int GetSubDirIndex(void) { return subdir_index; }
1121+
11181122
int SetupSubDir(char *dir, char *subdir, char *error, size_t errlen) {
11191123
char *p, path[MAXPATHLEN];
11201124
struct stat stat_buf;

src/libnffile/flist.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009-2024, Peter Haag
2+
* Copyright (c) 2009-2025, Peter Haag
33
* Copyright (c) 2004-2008, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
44
* All rights reserved.
55
*
@@ -48,6 +48,8 @@ int InitHierPath(int num);
4848

4949
char *GetSubDir(struct tm *now);
5050

51+
int GetSubDirIndex(void);
52+
5153
int SetupSubDir(char *dir, char *subdir, char *error, size_t errlen);
5254

5355
queue_t *SetupInputFileSequence(flist_t *flist);

src/nfcapd/nfcapd.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ static void run(packet_function_t receive_packet, int socket, int pfd, int rfd,
412412
// fatal error
413413
return;
414414
}
415+
fs->subdir = GetSubDirIndex();
415416
fs->nffile = OpenNewFile(fs->current, NULL, CREATOR_NFCAPD, compress, NOT_ENCRYPTED);
416417
if (!fs->nffile) {
417418
LogError("Failed to open new collector file");

0 commit comments

Comments
 (0)