Skip to content

Commit 58eb6c5

Browse files
authored
Merge pull request #236 from CESNET/anonymizer_skipopts
anonymizer: option to skip SRC_IP (-S)/DST_IP (-D)
2 parents 1873c23 + b59ae36 commit 58eb6c5

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

anonymizer/README

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,7 @@ Anonymization key: 32 characters long string or 32B sized hex string starting wi
2828

2929
Parameters: -k KEY Specify anonymization key.
3030
-f FILE Specify file containg anonymization key.
31+
-S Disable anonymization of SRC_IP.
32+
-D Disable anonymization of DST_IP.
3133
-M Use MurmurHash3 instead of Rijndael cipher.
3234
-d Switch to de-anonymization mode, i.e. do reverse transofmration of the addresses.

anonymizer/anonymizer.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
* \author Tomas Jansky <[email protected]>
77
* \author Martin Zadnik <[email protected]>
88
* \author Tomas Cejka <[email protected]>
9+
* \date 2024
910
* \date 2017
1011
*/
1112
/*
12-
* Copyright (C) 2013-2018 CESNET
13+
* Copyright (C) 2013-2024 CESNET
1314
*
1415
* LICENSE TERMS
1516
*
@@ -71,10 +72,15 @@ trap_module_info_t *module_info = NULL;
7172
PARAM('k', "key", "Specify secret key, the key must be 32 characters long string or 32B sized hex string starting with 0x", required_argument, "string") \
7273
PARAM('f', "file", "Specify file containing secret key, the key must be 32 characters long string or 32B sized hex string starting with 0x", required_argument, "string") \
7374
PARAM('M', "murmur", "Use MurmurHash3 instead of Rijndael cipher.", no_argument, "none") \
75+
PARAM('S', "srcip", "Disable anonymization of SRC_IP.", no_argument, "none") \
76+
PARAM('D', "dstip", "Disable anonymization of DST_IP.", no_argument, "none") \
7477
PARAM('d', "de-anonym", "Switch to de-anonymization mode.", no_argument, "none")
7578

7679
static int stop = 0;
7780

81+
static int disable_src_ip = 0;
82+
static int disable_dst_ip = 0;
83+
7884
TRAP_DEFAULT_SIGNAL_HANDLER(stop = 1);
7985

8086
const char *anon_field_names[] = {"SRC_IP", "DST_IP", "SIP_CALLED_PARTY", "SIP_CALLING_PARTY", "SIP_CALL_ID", "SIP_REQUEST_URI", "SIP_VIA"};
@@ -331,6 +337,13 @@ int set_fields_present(ur_template_t *tmplt)
331337
int j = 0;
332338

333339
for (i = 0; i < ANON_FIELDS_COUNT; i++) {
340+
// check skip flags for src_ip and dst_ip (-S / -D) and skip these fields
341+
if (disable_src_ip == 1 && strncmp(anon_field_names[i], "SRC_IP", 7) == 0) {
342+
continue;
343+
}
344+
if (disable_dst_ip == 1 && strncmp(anon_field_names[i], "DST_IP", 7) == 0) {
345+
continue;
346+
}
334347
anon_fields[j] = ur_get_id_by_name(anon_field_names[i]);
335348
if (anon_fields[j] != UR_E_INVALID_NAME && ur_is_present(tmplt, anon_fields[j])) {
336349
j++;
@@ -415,6 +428,12 @@ int main(int argc, char **argv)
415428
case 'd':
416429
mode = DEANONYMIZATION;
417430
break;
431+
case 'S':
432+
disable_src_ip = 1;
433+
break;
434+
case 'D':
435+
disable_dst_ip = 1;
436+
break;
418437
default:
419438
fprintf(stderr, "Invalid arguments.\n");
420439
ret = 1;

0 commit comments

Comments
 (0)