Skip to content

Commit

Permalink
Move code. Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
phaag committed Jan 6, 2024
1 parent 272c235 commit 05430dd
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 21 deletions.
21 changes: 21 additions & 0 deletions src/include/nfdump.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,27 @@ typedef struct ip_addr_s {
typedef struct exporter_info_record_s exporter_info_record_t;
typedef struct extension_map_s extension_map_t;

#define EXlocal MAXEXTENSIONS
typedef struct recordHandle_s {
recordHeaderV3_t *recordHeaderV3;
void *extensionList[MAXEXTENSIONS + 1];
uint8_t ja3[16];
#define OFFja3 offsetof(recordHandle_t, ja3)
#define SIZEja3 MemberSize(recordHandle_t, ja3)
char geo[16];
#define OFFgeo offsetof(recordHandle_t, geo)
#define OFFgeoSrcIP offsetof(recordHandle_t, geo)
#define OFFgeoDstIP offsetof(recordHandle_t, geo) + 2
#define OFFgeoSrcNatIP offsetof(recordHandle_t, geo) + 4
#define OFFgeoDstNatIP offsetof(recordHandle_t, geo) + 6
#define OFFgeoSrcTunIP offsetof(recordHandle_t, geo) + 8
#define OFFgeoDstTunIP offsetof(recordHandle_t, geo) + 10
#define SizeGEOloc 2
uint32_t flowCount;
#define OFFflowCount offsetof(recordHandle_t, flowCount)
#define SIZEflowCount MemberSize(recordHandle_t, flowCount)
} recordHandle_t;

/* the master record contains all possible records unpacked */
typedef struct master_record_s {
// common information from all netflow versions
Expand Down
19 changes: 0 additions & 19 deletions src/lib/output_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,25 +321,6 @@ char *FlowEndString(uint8_t endReason) {

} // End of FlowEndString

void CondenseV6(char *s) {
size_t len = strlen(s);
char *p, *q;

if (len <= 16) return;

// orig: 2001:620:1000:cafe:20e:35ff:fec0:fed5 len = 37
// condensed: 2001:62..e0:fed5
p = s + 7;
*p++ = '.';
*p++ = '.';
q = s + len - 7;
while (*q) {
*p++ = *q++;
}
*p = 0;

} // End of CondenseV6

char *FwEventString(int event) {
switch (event) {
#ifdef JUNOS
Expand Down
2 changes: 0 additions & 2 deletions src/lib/output_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ char *biFlowString(uint8_t biFlow);

char *FlowEndString(uint8_t biFlow);

void CondenseV6(char *s);

char *FwEventString(int event);

#define SHORTNAME 0
Expand Down
19 changes: 19 additions & 0 deletions src/output/output_fmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,25 @@ static void InitFormatParser(void) {

} // End of InitFormatParser

void CondenseV6(char *s) {
size_t len = strlen(s);
char *p, *q;

if (len <= 16) return;

// orig: 2001:620:1000:cafe:20e:35ff:fec0:fed5 len = 37
// condensed: 2001:62..e0:fed5
p = s + 7;
*p++ = '.';
*p++ = '.';
q = s + len - 7;
while (*q) {
*p++ = *q++;
}
*p = 0;

} // End of CondenseV6

static void AddToken(int index, char *s) {
if (token_index >= max_token_index) { // no slot available - expand table
max_token_index += BLOCK_SIZE;
Expand Down
2 changes: 2 additions & 0 deletions src/output/output_fmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ void fmt_prolog(void);

void fmt_epilog(void);

void CondenseV6(char *s);

int ParseOutputFormat(char *format, int printPlain, printmap_t *printmap);

void fmt_record(FILE *stream, void *record, int tag);
Expand Down

0 comments on commit 05430dd

Please sign in to comment.