2 * Definitions and functions for IO graph items
4 * Copied from gtk/io_stat.c, (c) 2002 Ronnie Sahlberg
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 #include <epan/epan_dissect.h>
30 #include "ui/io_graph_item.h"
32 int get_io_graph_index(packet_info *pinfo, int interval) {
36 * Find in which interval this is supposed to go and store the interval index as idx
38 time_delta = pinfo->rel_ts;
39 if (time_delta.nsecs<0) {
41 time_delta.nsecs += 1000000000;
43 if (time_delta.secs<0) {
46 return (int) ((time_delta.secs*1000 + time_delta.nsecs/1000000) / interval);
49 GString *check_field_unit(const char *field_name, int *hf_index, io_graph_item_unit_t item_unit)
51 GString *err_str = NULL;
52 if (item_unit >= IOG_ITEM_UNIT_CALC_SUM) {
53 header_field_info *hfi;
55 const char *item_unit_names[NUM_IOG_ITEM_UNITS] = {
68 /* There was no field specified */
69 if ((field_name == NULL) || (field_name[0] == 0)) {
70 err_str = g_string_new("You didn't specify a field name.");
74 /* The field could not be found */
75 hfi = proto_registrar_get_byname(field_name);
77 err_str = g_string_new("");
78 g_string_printf(err_str, "There is no field named '%s'.", field_name);
82 if (hf_index) *hf_index = hfi->id;
84 /* Check that the type is compatible */
98 /* These values support all calculations except LOAD */
100 case IOG_ITEM_UNIT_CALC_LOAD:
101 err_str = g_string_new("LOAD is only supported for relative-time fields.");
105 /* These types support all calculations */
107 case FT_RELATIVE_TIME:
108 /* This type only supports COUNT, MAX, MIN, AVG */
110 case IOG_ITEM_UNIT_CALC_SUM:
111 case IOG_ITEM_UNIT_CALC_FRAMES:
112 case IOG_ITEM_UNIT_CALC_FIELDS:
113 case IOG_ITEM_UNIT_CALC_MAX:
114 case IOG_ITEM_UNIT_CALC_MIN:
115 case IOG_ITEM_UNIT_CALC_AVERAGE:
116 case IOG_ITEM_UNIT_CALC_LOAD:
119 err_str = g_string_new("");
120 g_string_printf(err_str, "\"%s\" is a relative-time field. %s calculations are not supported on it.",
122 item_unit_names[item_unit]);
126 if ((item_unit != IOG_ITEM_UNIT_CALC_FRAMES) &&
127 (item_unit != IOG_ITEM_UNIT_CALC_FIELDS)) {
128 err_str = g_string_new("");
129 g_string_printf(err_str, "\"%s\" doesn't have integral or float values. %s calculations are not supported on it.",
131 item_unit_names[item_unit]);
145 * indent-tabs-mode: nil
148 * ex: set shiftwidth=4 tabstop=8 expandtab:
149 * :indentSize=4:tabSize=8:noTabs=true: