/* traffic_table_ui.c * Helper routines common to conversation/endpoint tables. * * Wireshark - Network traffic analyzer * By Gerald Combs * Copyright 1998 Gerald Combs * * SPDX-License-Identifier: GPL-2.0-or-later */ #include "config.h" #include #include "traffic_table_ui.h" #include #ifdef HAVE_MAXMINDDB #include #include "wsutil/filesystem.h" #include "wsutil/file_util.h" #include "wsutil/json_dumper.h" #endif const char *conv_column_titles[CONV_NUM_COLUMNS] = { "Address A", "Port A", "Address B", "Port B", "Packets", "Bytes", "Packets A " UTF8_RIGHTWARDS_ARROW " B", "Bytes A " UTF8_RIGHTWARDS_ARROW " B", "Packets B " UTF8_RIGHTWARDS_ARROW " A", "Bytes B " UTF8_RIGHTWARDS_ARROW " A", "Rel Start", "Duration", "Bits/s A " UTF8_RIGHTWARDS_ARROW " B", "Bits/s B " UTF8_RIGHTWARDS_ARROW " A" }; const char *conv_conn_a_title = "Connection A"; const char *conv_conn_b_title = "Connection B"; const char *conv_abs_start_title = "Abs Start"; const char *endp_column_titles[ENDP_NUM_GEO_COLUMNS] = { "Address", "Port", "Packets", "Bytes", "Tx Packets", "Tx Bytes", "Rx Packets", "Rx Bytes", "Country", "City", "AS Number", "AS Organization" }; const char *endp_conn_title = "Connection"; #ifdef HAVE_MAXMINDDB gboolean write_endpoint_geoip_map(FILE *fp, gboolean json_only, hostlist_talker_t *const *hosts, gchar **err_str) { if (!json_only) { char *base_html_path = get_datafile_path("ipmap.html"); FILE *base_html_fp = ws_fopen(base_html_path, "rb"); if (!base_html_fp) { *err_str = g_strdup_printf("Could not open base file %s for reading: %s", base_html_path, g_strerror(errno)); g_free(base_html_path); return FALSE; } g_free(base_html_path); /* Copy ipmap.html to map file. */ size_t n; char buf[4096]; while ((n = fread(buf, 1, sizeof(buf), base_html_fp)) != 0) { if (fwrite(buf, 1, n, fp) != n) { *err_str = g_strdup_printf("Failed to write to map file: %s", g_strerror(errno)); fclose(base_html_fp); return FALSE; } } if (ferror(base_html_fp)) { *err_str = g_strdup_printf("Failed to read base file: %s", g_strerror(errno)); fclose(base_html_fp); return FALSE; } fclose(base_html_fp); fputs("\n", fp); } if (count == 0) { *err_str = g_strdup("No endpoints available to map"); return FALSE; } return TRUE; } #endif /* * Editor modelines - https://www.wireshark.org/tools/modelines.html * * Local variables: * c-basic-offset: 4 * tab-width: 8 * indent-tabs-mode: nil * End: * * vi: set shiftwidth=4 tabstop=8 expandtab: * :indentSize=4:tabSize=8:noTabs=true: */