"Fossies" - the Fresh Open Source Software Archive 
Member "tcpflow-1.6.1/src/scan_netviz.cpp" (19 Feb 2021, 2300 Bytes) of package /linux/misc/tcpflow-1.6.1.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "scan_netviz.cpp" see the
Fossies "Dox" file reference documentation and the last
Fossies "Diffs" side-by-side code changes report:
1.4.4_vs_1.4.5.
1 /**
2 * scan_netviz:
3 *
4 * Our first try at a pcap visualization engine.
5 * Requires LIBCAIRO
6 */
7
8 #include "config.h"
9 #include <iostream>
10 #include <sys/types.h>
11
12 #include "bulk_extractor_i.h"
13
14 #ifdef HAVE_LIBCAIRO
15 #include "netviz/one_page_report.h"
16
17 /* These control the size of the iptable histogram
18 * and whether or not it is dumped. The histogram should be kept
19 * either small enough that it is not expensive to maintain, or large
20 * enough so that it never needs to be pruned.
21 */
22
23 #define HISTOGRAM_SIZE "netviz_histogram_size"
24 #define HISTOGRAM_DUMP "netviz_histogram_dump"
25 #define DEFAULT_MAX_HISTOGRAM_SIZE 1000
26
27 static one_page_report *report=0;
28 static void netviz_process_packet(void *user,const be13::packet_info &pi)
29 {
30 report->ingest_packet(pi);
31 }
32
33 #endif
34
35 #ifdef HAVE_LIBCAIRO
36 static int histogram_dump = 0;
37 #endif
38
39 extern "C"
40 void scan_netviz(const class scanner_params &sp,const recursion_control_block &rcb)
41 {
42 if(sp.sp_version!=scanner_params::CURRENT_SP_VERSION){
43 std::cout << "scan_timehistogram requires sp version "
44 << scanner_params::CURRENT_SP_VERSION << "; "
45 << "got version " << sp.sp_version << "\n";
46 exit(1);
47 }
48
49 if(sp.phase==scanner_params::PHASE_STARTUP){
50 sp.info->name = "netviz";
51 sp.info->flags = scanner_info::SCANNER_DISABLED; // disabled by default
52 sp.info->author= "Mike Shick";
53 sp.info->packet_user = 0;
54 #ifdef HAVE_LIBCAIRO
55 sp.info->description = "Performs 1-page visualization of network packets";
56 sp.info->packet_cb = netviz_process_packet;
57 sp.info->get_config(HISTOGRAM_DUMP,&histogram_dump,"Dumps the histogram");
58 int max_histogram_size = DEFAULT_MAX_HISTOGRAM_SIZE;
59 sp.info->get_config(HISTOGRAM_SIZE,&max_histogram_size,"Maximum histogram size");
60 report = new one_page_report(max_histogram_size);
61 #else
62 sp.info->description = "Disabled (compiled without libcairo";
63 #endif
64 }
65 #ifdef HAVE_LIBCAIRO
66
67 if(sp.phase==scanner_params::PHASE_SHUTDOWN){
68 assert(report!=0);
69 if(histogram_dump){
70 report->src_tree.dump_stats(std::cout);
71 report->dump(histogram_dump);
72 }
73 report->source_identifier = sp.fs.get_input_fname();
74 report->render(sp.fs.get_outdir());
75 delete report;
76 report = 0;
77 }
78 #endif
79 }
80