"Fossies" - the Fresh Open Source Software Archive

Member "tcpflow-1.6.1/src/netviz/net_map.cpp" (19 Feb 2021, 1031 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 "net_map.cpp" see the Fossies "Dox" file reference documentation.

    1 /**
    2  * net_map.cpp: 
    3  * Show map of network traffic by host
    4  *
    5  * This source file is public domain, as it is not based on the original tcpflow.
    6  *
    7  * Author: Michael Shick <mike@shick.in>
    8  *
    9  */
   10 
   11 #include "config.h"
   12 
   13 #ifdef HAVE_LIBCAIRO
   14 #include "tcpflow.h"
   15 
   16 #include "net_map.h"
   17 
   18 void net_map::ingest_packet(const be13::packet_info &pi)
   19 {
   20 }
   21 
   22 void net_map::render(cairo_t *cr, const plot_view::bounds_t &bounds)
   23 {
   24     cairo_set_source_rgb(cr, 0.67, 0.67, 0.67);
   25     cairo_rectangle(cr, bounds.x, bounds.y, bounds.width, bounds.height);
   26     cairo_fill(cr);
   27 
   28     double font_size = 16.0;
   29     std::string label = "pretty map";
   30     cairo_text_extents_t extents;
   31 
   32     cairo_set_font_size(cr, font_size);
   33     cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
   34 
   35     cairo_text_extents(cr, label.c_str(), &extents);
   36 
   37     double text_x = bounds.x + (bounds.width - extents.width) / 2.0;
   38     double text_y = bounds.y + (bounds.height + extents.height) / 2.0;
   39 
   40     cairo_move_to(cr, text_x, text_y);
   41     cairo_show_text(cr, label.c_str());
   42 
   43 }
   44 #endif