#include <stdlib.h>#include <unistd.h>#include <assert.h>#include <sys/time.h>#include "util.h"#include "net_util.h"#include "md5.h"#include "Anon.h"#include "Val.h"#include "NetVar.h"#include "Event.h"Include dependency graph for Anon.cc:

Go to the source code of this file.
Defines | |
| #define | first_n_bit_mask(n) (~(0xFFFFFFFFU >> n)) |
Functions | |
| uint32 | rand32 () |
| int | bi_ffs (uint32 value) |
| void | init_ip_addr_anonymizers () |
| ipaddr32_t | anonymize_ip (ipaddr32_t ip, enum ip_addr_anonymization_class_t cl) |
| void | log_anonymization_mapping (ipaddr32_t input, ipaddr32_t output) |
Variables | |
| AnonymizeIPAddr * | ip_anonymizer [NUM_ADDR_ANONYMIZATION_METHODS] = {0} |
|
|
Definition at line 54 of file Anon.cc. Referenced by AnonymizeIPAddr_A50::PreservePrefix(). |
|
||||||||||||
|
Definition at line 343 of file Anon.cc. References addr, AnonymizeIPAddr::Anonymize(), internal_error(), ip_anonymizer, ipaddr32_t, KEEP_ORIG_ADDR, log_anonymization_mapping(), TableVal::Lookup(), NUM_ADDR_ANONYMIZATION_METHODS, ORIG_ADDR, orig_addr_anonymization, other_addr_anonymization, preserve_orig_addr, preserve_other_addr, preserve_resp_addr, RESP_ADDR, and resp_addr_anonymization. Referenced by TCP_Rewriter::TCP_Rewriter().
00344 {
00345 TableVal* preserve_addr = 0;
00346 AddrVal addr(ip);
00347
00348 int method = -1;
00349
00350 switch ( cl ) {
00351 case ORIG_ADDR: // client address
00352 preserve_addr = preserve_orig_addr;
00353 method = orig_addr_anonymization;
00354 break;
00355
00356 case RESP_ADDR: // server address
00357 preserve_addr = preserve_resp_addr;
00358 method = resp_addr_anonymization;
00359 break;
00360
00361 default:
00362 preserve_addr = preserve_other_addr;
00363 method = other_addr_anonymization;
00364 break;
00365 }
00366
00367 ipaddr32_t new_ip = 0;
00368
00369 if ( preserve_addr && preserve_addr->Lookup(&addr) )
00370 new_ip = ip;
00371
00372 else if ( method >= 0 && method < NUM_ADDR_ANONYMIZATION_METHODS )
00373 {
00374 if ( method == KEEP_ORIG_ADDR )
00375 new_ip = ip;
00376
00377 else if ( ! ip_anonymizer[method] )
00378 internal_error("IP anonymizer not initialized");
00379
00380 else
00381 new_ip = ip_anonymizer[method]->Anonymize(ip);
00382 }
00383
00384 else
00385 internal_error("invalid IP anonymization method");
00386
00387 #ifdef LOG_ANONYMIZATION_MAPPING
00388 log_anonymization_mapping(ip, new_ip);
00389 #endif
00390 return new_ip;
00391 }
|
|
|
Definition at line 24 of file Anon.cc. References uint32, uint8, and value. Referenced by AnonymizeIPAddr_A50::find_node(), and AnonymizeIPAddr_A50::make_peer().
00025 {
00026 int add = 0;
00027 static uint8 bvals[] = { 0, 4, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1 };
00028
00029 if ( (value & 0xFFFF0000) == 0 )
00030 {
00031 if ( value == 0 )
00032 // zero input ==> zero output.
00033 return 0;
00034
00035 add += 16;
00036 }
00037
00038 else
00039 value >>= 16;
00040
00041 if ( (value & 0xFF00) == 0 )
00042 add += 8;
00043 else
00044 value >>= 8;
00045
00046 if ( (value & 0xF0) == 0 )
00047 add += 4;
00048 else
00049 value >>= 4;
00050
00051 return add + bvals[value & 0xf];
00052 }
|
|
|
Definition at line 334 of file Anon.cc. References ip_anonymizer, KEEP_ORIG_ADDR, PREFIX_PRESERVING_A50, PREFIX_PRESERVING_MD5, RANDOM_MD5, and SEQUENTIALLY_NUMBERED. Referenced by net_init().
00335 {
00336 ip_anonymizer[KEEP_ORIG_ADDR] = 0;
00337 ip_anonymizer[SEQUENTIALLY_NUMBERED] = new AnonymizeIPAddr_Seq();
00338 ip_anonymizer[RANDOM_MD5] = new AnonymizeIPAddr_RandomMD5();
00339 ip_anonymizer[PREFIX_PRESERVING_A50] = new AnonymizeIPAddr_A50();
00340 ip_anonymizer[PREFIX_PRESERVING_MD5] = new AnonymizeIPAddr_PrefixMD5();
00341 }
|
|
||||||||||||
|
Definition at line 398 of file Anon.cc. References ipaddr32_t, mgr, and EventMgr::QueueEvent(). Referenced by anonymize_ip().
00399 {
00400 if ( anonymization_mapping )
00401 {
00402 val_list* vl = new val_list;
00403 vl->append(new AddrVal(input));
00404 vl->append(new AddrVal(output));
00405 mgr.QueueEvent(anonymization_mapping, vl);
00406 }
00407 }
|
|
|
Definition at line 18 of file Anon.cc. References random(), and uint32. Referenced by AnonymizeIPAddr_A50::find_node(), AnonymizeIPAddr_A50::make_output(), and AnonymizeIPAddr_A50::PreservePrefix().
|
|
|
Definition at line 16 of file Anon.cc. Referenced by anonymize_ip(), init_ip_addr_anonymizers(), net_delete(), and net_init(). |
1.3.5