|
6 | 6 | * \author Tomas Jansky <[email protected]> |
7 | 7 | * \author Martin Zadnik <[email protected]> |
8 | 8 | * \author Tomas Cejka <[email protected]> |
| 9 | + * \date 2024 |
9 | 10 | * \date 2017 |
10 | 11 | */ |
11 | 12 | /* |
12 | | - * Copyright (C) 2013-2018 CESNET |
| 13 | + * Copyright (C) 2013-2024 CESNET |
13 | 14 | * |
14 | 15 | * LICENSE TERMS |
15 | 16 | * |
@@ -71,10 +72,15 @@ trap_module_info_t *module_info = NULL; |
71 | 72 | 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") \ |
72 | 73 | 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") \ |
73 | 74 | 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") \ |
74 | 77 | PARAM('d', "de-anonym", "Switch to de-anonymization mode.", no_argument, "none") |
75 | 78 |
|
76 | 79 | static int stop = 0; |
77 | 80 |
|
| 81 | +static int disable_src_ip = 0; |
| 82 | +static int disable_dst_ip = 0; |
| 83 | + |
78 | 84 | TRAP_DEFAULT_SIGNAL_HANDLER(stop = 1); |
79 | 85 |
|
80 | 86 | 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) |
331 | 337 | int j = 0; |
332 | 338 |
|
333 | 339 | 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 | + } |
334 | 347 | anon_fields[j] = ur_get_id_by_name(anon_field_names[i]); |
335 | 348 | if (anon_fields[j] != UR_E_INVALID_NAME && ur_is_present(tmplt, anon_fields[j])) { |
336 | 349 | j++; |
@@ -415,6 +428,12 @@ int main(int argc, char **argv) |
415 | 428 | case 'd': |
416 | 429 | mode = DEANONYMIZATION; |
417 | 430 | break; |
| 431 | + case 'S': |
| 432 | + disable_src_ip = 1; |
| 433 | + break; |
| 434 | + case 'D': |
| 435 | + disable_dst_ip = 1; |
| 436 | + break; |
418 | 437 | default: |
419 | 438 | fprintf(stderr, "Invalid arguments.\n"); |
420 | 439 | ret = 1; |
|
0 commit comments