Hello Peter,I've made a patch that adds a command-line option to nfanon to preserve AS numbers. See [0] or attached. Feel free to merge, ignore, ...
Best regards Tillmann[0] https://github.com/Tilka/nfdump/commit/417c9281fab1a7ac4e23cc8d7f3d952b98c1cafe
From 417c9281fab1a7ac4e23cc8d7f3d952b98c1cafe Mon Sep 17 00:00:00 2001 From: Tillmann Karras <[email protected]> Date: Tue, 9 Apr 2013 20:34:31 +0200 Subject: [PATCH] nfanon: add -p option to preserve AS numbers --- bin/nfanon.c | 21 ++++++++++++++++----- man/nfanon.1 | 5 ++++- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/bin/nfanon.c b/bin/nfanon.c index 891735f..4a8e60f 100755 --- a/bin/nfanon.c +++ b/bin/nfanon.c @@ -92,9 +92,12 @@ static void usage(char *name) { "-M <expr>\tRead input from multiple directories.\n" "-R <expr>\tRead input from sequence of files.\n" "-w <file>\tName of output file. Defaults to input file.\n" + "-p\t\tpreserve AS numbers\n" , name); } /* usage */ +static int anon_as; + static inline void AnonRecord(master_record_t *master_record) { extension_map_t *extension_map = master_record->map_ref; int i; @@ -122,12 +125,16 @@ int i; while ( extension_map->ex_id[i] ) { switch (extension_map->ex_id[i++]) { case EX_AS_2: // srcas/dstas 2 byte - master_record->srcas = 0; - master_record->dstas = 0; + if (anon_as) { + master_record->srcas = 0; + master_record->dstas = 0; + } break; case EX_AS_4: // srcas/dstas 4 byte - master_record->srcas = 0; - master_record->dstas = 0; + if (anon_as) { + master_record->srcas = 0; + master_record->dstas = 0; + } break; case EX_NEXT_HOP_v4: master_record->ip_nexthop.v4 = anonymize(master_record->ip_nexthop.v4); @@ -401,7 +408,8 @@ int c; char CryptoPAnKey[32]; rfile = Rfile = Mdirs = wfile = NULL; - while ((c = getopt(argc, argv, "K:L:r:M:R:w:")) != EOF) { + anon_as = 1; + while ((c = getopt(argc, argv, "K:L:r:M:R:w:p")) != EOF) { switch (c) { case 'h': usage(argv[0]); @@ -433,6 +441,9 @@ char CryptoPAnKey[32]; case 'w': wfile = optarg; break; + case 'p': + anon_as = 0; + break; default: usage(argv[0]); exit(0); diff --git a/man/nfanon.1 b/man/nfanon.1 index 67c775e..c6c255d 100755 --- a/man/nfanon.1 +++ b/man/nfanon.1 @@ -1,4 +1,4 @@ -.TH nfexpire 1 2009\-09\-09 "" "" +.TH nfanon 1 2009\-09\-09 "" "" .SH NAME nfanon \- netflow anonymisation .SH SYNOPSIS @@ -66,6 +66,9 @@ If specified writes anonymised netflow records to \fIoutputfile\fR. .B -K \fIkey The key is used to initialize the Rijndael cipher. \fIkey\fR is either a 32 character string, or a 64 hex digit string starting with 0x. +.TP 3 +.B -p +Preserve AS numbers. Default is to replace them with 0. .P .SH "RETURN VALUE" Returns -- 1.7.10.4
------------------------------------------------------------------------------ Precog is a next-generation analytics platform capable of advanced analytics on semi-structured data. The platform includes APIs for building apps and a phenomenal toolset for data science. Developers can use our toolset for easy data analysis & visualization. Get a free account! http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________ Nfdump-discuss mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nfdump-discuss
