2021-11-30 13:01:36 +00:00
|
|
|
/** @file
|
2016-02-07 21:15:12 +00:00
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
2018-04-30 07:47:58 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2016-02-07 21:15:12 +00:00
|
|
|
|
|
|
|
#ifndef SHOW_PACKET_BYTES_DIALOG_H
|
|
|
|
#define SHOW_PACKET_BYTES_DIALOG_H
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include <glib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "file.h"
|
|
|
|
#include "wireshark_dialog.h"
|
|
|
|
|
2016-02-14 22:01:09 +00:00
|
|
|
#include <QLineEdit>
|
2016-02-07 21:15:12 +00:00
|
|
|
#include <QPushButton>
|
2016-02-14 22:01:09 +00:00
|
|
|
#include <QTextEdit>
|
2021-11-20 03:51:05 +00:00
|
|
|
#include <QTextCodec>
|
2016-02-07 21:15:12 +00:00
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class ShowPacketBytesDialog;
|
2016-02-14 22:01:09 +00:00
|
|
|
class ShowPacketBytesTextEdit;
|
2016-02-07 21:15:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class ShowPacketBytesDialog : public WiresharkDialog
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit ShowPacketBytesDialog(QWidget &parent, CaptureFile &cf);
|
|
|
|
~ShowPacketBytesDialog();
|
|
|
|
|
2020-07-05 11:35:57 +00:00
|
|
|
void addCodecs(const QMap<QString, QTextCodec *> &codecMap);
|
|
|
|
|
2016-02-07 21:15:12 +00:00
|
|
|
protected:
|
|
|
|
bool eventFilter(QObject *obj, QEvent *event);
|
|
|
|
void keyPressEvent(QKeyEvent *event);
|
2021-01-10 20:57:47 +00:00
|
|
|
void captureFileClosing();
|
|
|
|
void captureFileClosed();
|
2016-02-07 21:15:12 +00:00
|
|
|
|
|
|
|
private slots:
|
2016-02-14 22:01:09 +00:00
|
|
|
void on_sbStart_valueChanged(int value);
|
|
|
|
void on_sbEnd_valueChanged(int value);
|
|
|
|
void on_cbDecodeAs_currentIndexChanged(int idx);
|
2016-02-07 21:15:12 +00:00
|
|
|
void on_cbShowAs_currentIndexChanged(int idx);
|
|
|
|
void on_leFind_returnPressed();
|
|
|
|
void on_bFind_clicked();
|
|
|
|
void on_buttonBox_rejected();
|
|
|
|
|
2016-02-14 22:01:09 +00:00
|
|
|
void showSelected(int start, int end);
|
2016-02-14 18:34:11 +00:00
|
|
|
void useRegexFind(bool use_regex);
|
2016-02-07 21:15:12 +00:00
|
|
|
void findText(bool go_back = true);
|
|
|
|
void helpButton();
|
|
|
|
void printBytes();
|
|
|
|
void copyBytes();
|
|
|
|
void saveAs();
|
|
|
|
|
|
|
|
private:
|
2023-02-02 02:15:41 +00:00
|
|
|
/* Keep these enums in the same order (generally alphabetically)
|
|
|
|
* that they are added to the combo boxes.
|
|
|
|
*/
|
2016-02-14 22:01:09 +00:00
|
|
|
enum DecodeAsType {
|
|
|
|
DecodeAsNone,
|
|
|
|
DecodeAsBASE64,
|
|
|
|
DecodeAsCompressed,
|
2021-09-11 12:36:20 +00:00
|
|
|
DecodeAsHexDigits,
|
2022-08-30 01:25:35 +00:00
|
|
|
DecodeAsPercentEncoding,
|
2016-05-19 10:09:33 +00:00
|
|
|
DecodeAsQuotedPrintable,
|
2016-02-14 22:01:09 +00:00
|
|
|
DecodeAsROT13
|
|
|
|
};
|
2016-02-07 21:15:12 +00:00
|
|
|
enum ShowAsType {
|
|
|
|
ShowAsASCII,
|
2016-02-28 12:38:08 +00:00
|
|
|
ShowAsASCIIandControl,
|
2016-02-11 20:08:51 +00:00
|
|
|
ShowAsCArray,
|
2016-02-07 21:15:12 +00:00
|
|
|
ShowAsEBCDIC,
|
2016-02-10 08:07:13 +00:00
|
|
|
ShowAsHexDump,
|
2016-02-07 21:15:12 +00:00
|
|
|
ShowAsHTML,
|
|
|
|
ShowAsImage,
|
2022-02-06 10:44:19 +00:00
|
|
|
ShowAsJson,
|
2016-02-07 21:15:12 +00:00
|
|
|
ShowAsRAW,
|
2023-02-02 02:15:41 +00:00
|
|
|
ShowAsRustArray,
|
2020-07-05 11:35:57 +00:00
|
|
|
ShowAsCodec, // Ordered to match the UTF-8 combobox index
|
|
|
|
ShowAsYAML,
|
2016-02-07 21:15:12 +00:00
|
|
|
};
|
|
|
|
|
2016-02-14 22:01:09 +00:00
|
|
|
void setStartAndEnd(int start, int end);
|
|
|
|
bool enableShowSelected();
|
2016-02-07 21:15:12 +00:00
|
|
|
void updateWidgets(); // Needed for WiresharkDialog?
|
2016-02-14 22:01:09 +00:00
|
|
|
void updateHintLabel();
|
2016-02-28 12:38:08 +00:00
|
|
|
void sanitizeBuffer(QByteArray &ba, bool handle_CR);
|
|
|
|
void symbolizeBuffer(QByteArray &ba);
|
2016-05-19 10:09:33 +00:00
|
|
|
QByteArray decodeQuotedPrintable(const guint8 *bytes, int length);
|
2016-02-14 22:01:09 +00:00
|
|
|
void rot13(QByteArray &ba);
|
|
|
|
void updateFieldBytes(bool initialization = false);
|
|
|
|
void updatePacketBytes();
|
2016-02-07 21:15:12 +00:00
|
|
|
|
|
|
|
Ui::ShowPacketBytesDialog *ui;
|
|
|
|
|
2016-02-14 22:01:09 +00:00
|
|
|
const field_info *finfo_;
|
2016-02-07 21:15:12 +00:00
|
|
|
QByteArray field_bytes_;
|
2016-02-14 22:01:09 +00:00
|
|
|
QString hint_label_;
|
2016-02-07 21:15:12 +00:00
|
|
|
QPushButton *print_button_;
|
|
|
|
QPushButton *copy_button_;
|
|
|
|
QPushButton *save_as_button_;
|
2016-02-14 22:01:09 +00:00
|
|
|
DecodeAsType decode_as_;
|
2016-02-07 21:15:12 +00:00
|
|
|
ShowAsType show_as_;
|
2016-02-14 18:34:11 +00:00
|
|
|
bool use_regex_find_;
|
2016-02-14 22:01:09 +00:00
|
|
|
int start_;
|
|
|
|
int end_;
|
2016-02-07 21:15:12 +00:00
|
|
|
QImage image_;
|
|
|
|
};
|
|
|
|
|
2016-02-14 22:01:09 +00:00
|
|
|
class ShowPacketBytesTextEdit : public QTextEdit
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit ShowPacketBytesTextEdit(QWidget *parent = 0) :
|
|
|
|
QTextEdit(parent), show_selected_enabled_(true), menus_enabled_(true) { }
|
|
|
|
~ShowPacketBytesTextEdit() { }
|
|
|
|
|
|
|
|
void setShowSelectedEnabled(bool enabled) { show_selected_enabled_ = enabled; }
|
|
|
|
void setMenusEnabled(bool enabled) { menus_enabled_ = enabled; }
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void showSelected(int, int);
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void contextMenuEvent(QContextMenuEvent *event);
|
|
|
|
void showSelected();
|
|
|
|
void showAll();
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool show_selected_enabled_;
|
|
|
|
bool menus_enabled_;
|
|
|
|
};
|
|
|
|
|
2016-02-07 21:15:12 +00:00
|
|
|
#endif // SHOW_PACKET_BYTES_DIALOG_H
|