Wireshark 4.5.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
io_graph_dialog.h
Go to the documentation of this file.
1
10#ifndef IO_GRAPH_DIALOG_H
11#define IO_GRAPH_DIALOG_H
12
13#include <config.h>
14
15#include "epan/epan_dissect.h"
16#include "epan/prefs.h"
17#include "ui/preference_utils.h"
18
19#include "ui/io_graph_item.h"
20
21#include "wireshark_dialog.h"
22
25
26#include <wsutil/str_util.h>
27
28#include <QPointer>
29#include <QIcon>
30#include <QMenu>
31#include <QTextStream>
32#include <QItemSelection>
33
34#include <vector>
35
36class QRubberBand;
37class QTimer;
38class QAbstractButton;
40
41class QCPBars;
42class QCPGraph;
43class QCPItemTracer;
44class QCustomPlot;
45class QCPAxisTicker;
46class QCPAxisTickerDateTime;
47
48// GTK+ set this to 100000 (NUM_IO_ITEMS) before raising it to unlimited
49// in commit 524583298beb671f43e972476693866754d38a38.
50// This is the maximum index returned from get_io_graph_index that will
51// be added to the graph. Thus, for a minimum interval size of 1 μs no
52// more than 33.55 s.
53// Each io_graph_item_t is 88 bytes on a system with 64 bit time_t, so
54// the max size we'll attempt to allocate for the array of items is 2.75 GiB
55// (plus a tiny amount extra for the std::vector bookkeeping.)
56// 2^25 = 16777216
57const int max_io_items_ = 1 << 25;
58
59/* define I/O Graph specific UAT columns */
60enum UatColumnsIOG {colEnabled = 0, colAOT, colName, colDFilter, colColor, colStyle, colYAxis, colYField, colSMAPeriod, colYAxisFactor, colMaxNum};
61
62// XXX - Move to its own file?
63class IOGraph : public QObject {
64Q_OBJECT
65public:
66 // COUNT_TYPE_* in gtk/io_graph.c
67 enum PlotStyles { psLine, psDotLine, psStepLine, psDotStepLine, psImpulse, psBar, psStackedBar, psDot, psSquare, psDiamond, psCross, psPlus, psCircle };
68
69 explicit IOGraph(QCustomPlot *parent);
70 ~IOGraph();
71 QString configError() const { return config_err_; }
72 QString name() const { return name_; }
73 void setName(const QString &name);
74 void setAOT(bool asAOT);
75 bool getAOT() const { return asAOT_; }
76 QString filter() const { return filter_; }
77 bool setFilter(const QString &filter);
78 void applyCurrentColor();
79 bool visible() const { return visible_; }
80 void setVisible(bool visible);
81 bool needRetap() const { return need_retap_; }
82 void setNeedRetap(bool retap);
83 QRgb color() const;
84 void setColor(const QRgb color);
85 void setPlotStyle(int style);
86 QString valueUnitLabel() const;
87 format_size_units_e formatUnits() const;
88 io_graph_item_unit_t valueUnits() const { return val_units_; }
89 void setValueUnits(int val_units);
90 QString valueUnitField() const { return vu_field_; }
91 void setValueUnitField(const QString &vu_field);
92 unsigned int movingAveragePeriod() const { return moving_avg_period_; }
93 void setInterval(int interval);
94 bool addToLegend();
95 bool removeFromLegend();
96 QCPGraph *graph() const { return graph_; }
97 QCPBars *bars() const { return bars_; }
98 double startOffset() const;
99 nstime_t startTime() const;
100 int packetFromTime(double ts) const;
101 bool hasItemToShow(int idx, double value) const;
102 double getItemValue(int idx, const capture_file *cap_file) const;
103 int maxInterval () const { return cur_idx_; }
104
105 void clearAllData();
106
107 unsigned int moving_avg_period_;
108 unsigned int y_axis_factor_;
109
110public slots:
111 void recalcGraphData(capture_file *cap_file);
112 void captureEvent(CaptureEvent e);
113 void reloadValueUnitField();
114
115signals:
116 void requestReplot();
117 void requestRecalc();
118 void requestRetap();
119
120private:
121 // Callbacks for register_tap_listener
122 static void tapReset(void *iog_ptr);
123 static tap_packet_status tapPacket(void *iog_ptr, packet_info *pinfo, epan_dissect_t *edt, const void *data, tap_flags_t flags);
124 static void tapDraw(void *iog_ptr);
125
126 void removeTapListener();
127
128 bool showsZero() const;
129
130 template<class DataMap> double maxValueFromGraphData(const DataMap &map);
131 template<class DataMap> void scaleGraphData(DataMap &map, int scalar);
132
133 QCustomPlot *parent_;
134 QString config_err_;
135 QString name_;
136 bool tap_registered_;
137 bool visible_;
138 bool need_retap_;
139 QCPGraph *graph_;
140 QCPBars *bars_;
141 QString filter_;
142 QString full_filter_; // Includes vu_field_ if used
143 QBrush color_;
144 io_graph_item_unit_t val_units_;
145 QString vu_field_;
146 int hf_index_;
147 int interval_;
148 nstime_t start_time_;
149 bool asAOT_; // Average Over Time interpretation
150
151 // Cached data. We should be able to change the Y axis without retapping as
152 // much as is feasible.
153 std::vector<io_graph_item_t> items_;
154 int cur_idx_;
155};
156
157namespace Ui {
158class IOGraphDialog;
159}
160
162{
163 Q_OBJECT
164
165public:
166 explicit IOGraphDialog(QWidget &parent, CaptureFile &cf, QString displayFilter = QString(), io_graph_item_unit_t value_units = IOG_ITEM_UNIT_PACKETS, QString yfield = QString());
168
169 void addGraph(bool checked, bool asAOT, QString name, QString dfilter, QRgb color_idx, IOGraph::PlotStyles style,
170 io_graph_item_unit_t value_units, QString yfield, int moving_average, int yaxisfactor);
171 void addGraph(bool checked, bool asAOT, QString dfilter, io_graph_item_unit_t value_units, QString yfield);
172 void addGraph(bool copy_from_current = false);
173 void addDefaultGraph(bool enabled, int idx = 0);
174 void syncGraphSettings(int row);
175 qsizetype graphCount() const;
176
177public slots:
178 void scheduleReplot(bool now = false);
179 void scheduleRecalc(bool now = false);
180 void scheduleRetap(bool now = false);
181 void reloadFields();
182
183protected:
184 void captureFileClosing();
185 void keyPressEvent(QKeyEvent *event);
186 void reject();
187
188protected slots:
189 void modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles);
190 void modelRowsReset();
191 void modelRowsInserted(const QModelIndex &parent, int first, int last);
192 void modelRowsRemoved(const QModelIndex &parent, int first, int last);
193 void modelRowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow);
194
195signals:
196 void goToPacket(int packet_num);
197 void recalcGraphData(capture_file *cap_file);
198 void intervalChanged(int interval);
199 void reloadValueUnitFields();
200
201private:
202 Ui::IOGraphDialog *ui;
203 CopyFromProfileButton *copy_profile_bt_;
204
205 //Model and delegate were chosen over UatFrame because add/remove/copy
206 //buttons would need realignment (UatFrame has its own)
207 QPointer<UatModel> uat_model_;
208 UatDelegate *uat_delegate_;
209
210 // XXX - This needs to stay synced with UAT index
211 QVector<IOGraph*> ioGraphs_;
212
213 QString hint_err_;
214 QCPGraph *base_graph_;
215 QCPItemTracer *tracer_;
216 uint32_t packet_num_;
217 nstime_t start_time_;
218 bool mouse_drags_;
219 QRubberBand *rubber_band_;
220 QPoint rb_origin_;
221 QMenu ctx_menu_;
222 QTimer *stat_timer_;
223 bool need_replot_; // Light weight: tell QCP to replot existing data
224 bool need_recalc_; // Medium weight: recalculate values, then replot
225 bool need_retap_; // Heavy weight: re-read packet data
226 bool auto_axes_;
227 int precision_;
228
229 QSharedPointer<QCPAxisTicker> number_ticker_;
230 QSharedPointer<QCPAxisTickerDateTime> datetime_ticker_;
231
232
233// void fillGraph();
234 void zoomAxes(bool in);
235 void zoomXAxis(bool in);
236 void zoomYAxis(bool in);
237 void panAxes(int x_pixels, int y_pixels);
238 void toggleTracerStyle(bool force_default = false);
239 void getGraphInfo();
240 void updateHint();
241 void updateLegend();
242 QRectF getZoomRanges(QRect zoom_rect);
243 void createIOGraph(int currentRow);
244 void loadProfileGraphs();
245 void makeCsv(QTextStream &stream) const;
246 bool saveCsv(const QString &file_name) const;
247 IOGraph *currentActiveGraph() const;
248 bool graphIsEnabled(int row) const;
249 bool graphAsAOT(int row) const;
250
251private slots:
252 static void applyChanges();
253
254 void copyFromProfile(QString filename);
255 void updateWidgets();
256 void showContextMenu(const QPoint &pos);
257 void graphClicked(QMouseEvent *event);
258 void mouseMoved(QMouseEvent *event);
259 void mouseReleased(QMouseEvent *event);
260 void selectedFrameChanged(QList<int> frames);
261 void moveLegend();
262
263 void resetAxes();
264 void updateStatistics(void);
265 void copyAsCsvClicked();
266
267 void graphUatSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
268 void on_intervalComboBox_currentIndexChanged(int index);
269 void on_graphUat_currentItemChanged(const QModelIndex &current, const QModelIndex &previous);
270
271 void on_automaticUpdateCheckBox_toggled(bool checked);
272 void on_newToolButton_clicked();
273 void on_deleteToolButton_clicked();
274 void on_copyToolButton_clicked();
275 void on_clearToolButton_clicked();
276 void on_moveUpwardsToolButton_clicked();
277 void on_moveDownwardsToolButton_clicked();
278 void on_dragRadioButton_toggled(bool checked);
279 void on_zoomRadioButton_toggled(bool checked);
280 void on_actionReset_triggered();
281 void on_actionZoomIn_triggered();
282 void on_actionZoomInX_triggered();
283 void on_actionZoomInY_triggered();
284 void on_actionZoomOut_triggered();
285 void on_actionZoomOutX_triggered();
286 void on_actionZoomOutY_triggered();
287 void on_actionMoveUp10_triggered();
288 void on_actionMoveLeft10_triggered();
289 void on_actionMoveRight10_triggered();
290 void on_actionMoveDown10_triggered();
291 void on_actionMoveUp1_triggered();
292 void on_actionMoveLeft1_triggered();
293 void on_actionMoveRight1_triggered();
294 void on_actionMoveDown1_triggered();
295 void on_actionGoToPacket_triggered();
296 void on_actionDragZoom_triggered();
297 void on_actionToggleTimeOrigin_triggered();
298 void on_actionCrosshairs_triggered();
299 void on_buttonBox_helpRequested();
300 void on_buttonBox_accepted();
301 void buttonBoxClicked(QAbstractButton *button);
302 void actionLegendTriggered(bool checked);
303 void actionTimeOfDayTriggered(bool checked);
304 void actionLogScaleTriggered(bool checked);
305};
306
307#endif // IO_GRAPH_DIALOG_H
Definition capture_event.h:21
Definition capture_file.h:21
Definition copy_from_profile_button.h:21
Definition io_graph_dialog.h:162
void captureFileClosing()
Called when the capture file is about to close. This can be used to disconnect taps and similar actio...
Definition io_graph_dialog.cpp:835
Definition io_graph_dialog.h:63
Definition uat_delegate.h:24
Definition wireshark_dialog.h:35
format_size_units_e
Definition str_util.h:231
Definition cfile.h:67
Definition packet_info.h:43
Definition epan_dissect.h:28
Definition nstime.h:26
Definition stream.c:41
tap_packet_status
Definition tap.h:25