/* packet_panes.c
* Routines for GTK+ packet display (packet details and hex dump panes)
*
- * $Id$
- *
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
#include "config.h"
-#include <ctype.h>
-
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#if GTK_CHECK_VERSION(3,0,0)
#include <epan/packet.h>
#include <epan/charsets.h>
#include <epan/prefs.h>
-#include <epan/filesystem.h>
-
-#include "../isprint.h"
+#include <wsutil/filesystem.h>
#include "ui/alert_box.h"
#include "ui/last_open_dir.h"
#include "ui/ui_util.h"
#include <wsutil/file_util.h>
+#include <wsutil/str_util.h>
#include "ui/gtk/keys.h"
#include "ui/gtk/color_utils.h"
#define E_BYTE_VIEW_TVBUFF_KEY "byte_view_tvbuff"
#define E_BYTE_VIEW_START_KEY "byte_view_start"
#define E_BYTE_VIEW_END_KEY "byte_view_end"
-#define E_BYTE_VIEW_MASK_KEY "byte_view_mask"
+#define E_BYTE_VIEW_MASK_LO_KEY "byte_view_mask_lo"
+#define E_BYTE_VIEW_MASK_HI_KEY "byte_view_mask_hi"
#define E_BYTE_VIEW_MASKLE_KEY "byte_view_mask_le"
#define E_BYTE_VIEW_APP_START_KEY "byte_view_app_start"
#define E_BYTE_VIEW_APP_END_KEY "byte_view_app_end"
if (byte_view_tvb == NULL)
return NULL;
- if ((*data_len = tvb_length(byte_view_tvb))) {
+ if ((*data_len = tvb_captured_length(byte_view_tvb))) {
data_ptr = tvb_get_ptr(byte_view_tvb, 0, -1);
return data_ptr;
} else
{
GSList *src_le;
struct data_source *src;
+ char* src_name;
/*
* Get rid of all the old notebook tabs.
*/
for (src_le = edt->pi.data_src; src_le != NULL; src_le = src_le->next) {
src = (struct data_source *)src_le->data;
- add_byte_tab(byte_nb_ptr, get_data_source_name(src), get_data_source_tvb(src), edt->tree,
+ src_name = get_data_source_name(src);
+ add_byte_tab(byte_nb_ptr, src_name, get_data_source_tvb(src), edt->tree,
tree_view);
+ wmem_free(NULL, src_name);
}
/*
g_string_append_printf(hex_str," %02x",*data_p);
if(append_text) {
- g_string_append_printf(char_str,"%c",isprint(*data_p) ? *data_p : '.');
+ g_string_append_printf(char_str,"%c",g_ascii_isprint(*data_p) ? *data_p : '.');
}
++data_p;
gchar to_append;
/* Copy printable characters, newlines, and (horizontal) tabs. */
- if(isprint(*data_p)) {
+ if(g_ascii_isprint(*data_p)) {
to_append = *data_p;
} else if(*data_p==0x0a) {
to_append = '\n';
void
savehex_cb(GtkWidget * w _U_, gpointer data _U_)
{
- win32_export_raw_file(GDK_WINDOW_HWND(gtk_widget_get_window(top_level)));
+ win32_export_raw_file(GDK_WINDOW_HWND(gtk_widget_get_window(top_level)), &cfile);
return;
}
#else
static void
packet_hex_update(GtkWidget *bv, const guint8 *pd, int len, int bstart,
- int bend, guint32 bmask, int bmask_le,
+ int bend, guint64 bmask, int bmask_le,
int astart, int aend,
int pstart, int pend,
- int encoding)
+ packet_char_enc encoding)
{
bytes_view_set_encoding(BYTES_VIEW(bv), encoding);
bytes_view_set_format(BYTES_VIEW(bv), recent.gui_bytes_view);
/* to redraw the display if preferences change. */
int bstart = -1, bend = -1, blen = -1;
- guint32 bmask = 0x00; int bmask_le = 0;
+ guint64 bmask = 0x00; int bmask_le = 0;
int astart = -1, aend = -1, alen = -1;
int pstart = -1, pend = -1, plen = -1;
bstart = finfo->start;
}
- /* bmask = finfo->hfinfo->bitmask << finfo->hfinfo->bitshift; */ /* (value & mask) >> shift */
+ /* bmask = finfo->hfinfo->bitmask << hfinfo_bitshift(finfo->hfinfo); */ /* (value & mask) >> shift */
if (finfo->hfinfo) bmask = finfo->hfinfo->bitmask;
astart = finfo->appendix_start;
alen = finfo->appendix_length;
/* XXX, mask has only 32 bit, later we can store bito&bitc, and use them (which should be faster) */
if (bitt > 0 && bitt < 32) {
- bmask = ((1 << bitc) - 1) << ((8-bitt) & 7);
+ bmask = ((G_GUINT64_CONSTANT(1) << bitc) - 1) << ((8-bitt) & 7);
bmask_le = 0; /* ? */
}
}
/* should we save the fd & finfo pointers instead ?? */
g_object_set_data(G_OBJECT(bv), E_BYTE_VIEW_START_KEY, GINT_TO_POINTER(bstart));
g_object_set_data(G_OBJECT(bv), E_BYTE_VIEW_END_KEY, GINT_TO_POINTER(bend));
- g_object_set_data(G_OBJECT(bv), E_BYTE_VIEW_MASK_KEY, GINT_TO_POINTER(bmask));
+ g_object_set_data(G_OBJECT(bv), E_BYTE_VIEW_MASK_LO_KEY, GINT_TO_POINTER((guint32) bmask));
+ g_object_set_data(G_OBJECT(bv), E_BYTE_VIEW_MASK_HI_KEY, GINT_TO_POINTER((guint32)(bmask >> 32)));
g_object_set_data(G_OBJECT(bv), E_BYTE_VIEW_MASKLE_KEY, GINT_TO_POINTER(bmask_le));
g_object_set_data(G_OBJECT(bv), E_BYTE_VIEW_APP_START_KEY, GINT_TO_POINTER(astart));
g_object_set_data(G_OBJECT(bv), E_BYTE_VIEW_APP_END_KEY, GINT_TO_POINTER(aend));
/* stig: it should be done only for bitview... */
if (recent.gui_bytes_view != BYTES_BITS)
bmask = 0x00;
- packet_hex_update(bv, pd, len, bstart, bend, bmask, bmask_le, astart, aend, pstart, pend, fd->flags.encoding);
+ packet_hex_update(bv, pd, len, bstart, bend, bmask, bmask_le, astart, aend, pstart, pend, (packet_char_enc)fd->flags.encoding);
}
void
/* to redraw the display if preferences change. */
int bstart = offset, bend = (bstart != -1) ? offset+1 : -1;
- guint32 bmask=0; int bmask_le = 0;
+ guint64 bmask=0; int bmask_le = 0;
int astart = -1, aend = -1;
int pstart = -1, pend = -1;
break;
case BYTES_BITS:
- bmask = (1 << (7-bitoffset));
+ bmask = (G_GUINT64_CONSTANT(1) << (7-bitoffset));
break;
default:
/* save the information needed to redraw the text */
g_object_set_data(G_OBJECT(bv), E_BYTE_VIEW_START_KEY, GINT_TO_POINTER(bstart));
g_object_set_data(G_OBJECT(bv), E_BYTE_VIEW_END_KEY, GINT_TO_POINTER(bend));
- g_object_set_data(G_OBJECT(bv), E_BYTE_VIEW_MASK_KEY, GINT_TO_POINTER(bmask));
+ g_object_set_data(G_OBJECT(bv), E_BYTE_VIEW_MASK_LO_KEY, GINT_TO_POINTER((guint32) bmask));
+ g_object_set_data(G_OBJECT(bv), E_BYTE_VIEW_MASK_HI_KEY, GINT_TO_POINTER((guint32)(bmask >> 32)));
g_object_set_data(G_OBJECT(bv), E_BYTE_VIEW_MASKLE_KEY, GINT_TO_POINTER(bmask_le));
g_object_set_data(G_OBJECT(bv), E_BYTE_VIEW_APP_START_KEY, GINT_TO_POINTER(astart));
g_object_set_data(G_OBJECT(bv), E_BYTE_VIEW_APP_END_KEY, GINT_TO_POINTER(aend));
g_object_set_data(G_OBJECT(bv), E_BYTE_VIEW_PROTO_START_KEY, GINT_TO_POINTER(pstart));
g_object_set_data(G_OBJECT(bv), E_BYTE_VIEW_PROTO_END_KEY, GINT_TO_POINTER(pend));
- packet_hex_update(bv, pd, len, bstart, bend, bmask, bmask_le, astart, aend, pstart, pend, fd->flags.encoding);
+ packet_hex_update(bv, pd, len, bstart, bend, bmask, bmask_le, astart, aend, pstart, pend, (packet_char_enc)fd->flags.encoding);
}
/*
void
packet_hex_reprint(GtkWidget *bv)
{
- int start, end, mask, mask_le, encoding;
+ int start, end, mask_le;
+ packet_char_enc encoding;
int astart, aend;
int pstart, pend;
+ guint64 mask;
const guint8 *data;
guint len = 0;
start = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(bv), E_BYTE_VIEW_START_KEY));
end = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(bv), E_BYTE_VIEW_END_KEY));
- mask = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(bv), E_BYTE_VIEW_MASK_KEY));
+ mask = (guint64) GPOINTER_TO_INT(g_object_get_data(G_OBJECT(bv), E_BYTE_VIEW_MASK_HI_KEY)) << 32 |
+ GPOINTER_TO_INT(g_object_get_data(G_OBJECT(bv), E_BYTE_VIEW_MASK_LO_KEY));
mask_le = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(bv), E_BYTE_VIEW_MASKLE_KEY));
astart = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(bv), E_BYTE_VIEW_APP_START_KEY));
aend = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(bv), E_BYTE_VIEW_APP_END_KEY));
pend = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(bv), E_BYTE_VIEW_PROTO_END_KEY));
data = get_byte_view_data_and_length(bv, &len);
g_assert(data != NULL);
- encoding = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(bv), E_BYTE_VIEW_ENCODE_KEY));
+ encoding = (packet_char_enc) GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(bv), E_BYTE_VIEW_ENCODE_KEY));
/* stig: it should be done only for bitview... */
if (recent.gui_bytes_view != BYTES_BITS)
if(colors_ok) {
return;
}
-#if 0
- /* Allocating collor isn't necessary? */
- get_color(&expert_color_chat);
- get_color(&expert_color_note);
- get_color(&expert_color_warn);
- get_color(&expert_color_error);
- get_color(&expert_color_foreground);
-#endif
expert_color_comment_str = gdk_color_to_string(&expert_color_comment);
expert_color_chat_str = gdk_color_to_string(&expert_color_chat);
expert_color_note_str = gdk_color_to_string(&expert_color_note);
expert_color_error_str = gdk_color_to_string(&expert_color_error);
expert_color_foreground_str = gdk_color_to_string(&expert_color_foreground);
-#if 0
- get_color(&hidden_proto_item);
-#endif
colors_ok = TRUE;
}
cf_goto_frame(&cfile, fi->value.value.uinteger);
}
if(FI_GET_FLAG(fi, FI_URL) && IS_FT_STRING(fi->hfinfo->type)) {
- url = fvalue_to_string_repr(&fi->value, FTREPR_DISPLAY, NULL);
+ url = fvalue_to_string_repr(NULL, &fi->value, FTREPR_DISPLAY, fi->hfinfo->display);
if(url){
browser_open_url(url);
- g_free(url);
+ wmem_free(NULL, url);
}
}
}
}
void
-select_bytes_view (GtkWidget *w _U_, gpointer data _U_, gint view)
+select_bytes_view (GtkWidget *w _U_, gpointer data _U_, bytes_view_type view)
{
if (recent.gui_bytes_view != view) {
recent.gui_bytes_view = view;
redraw_packet_bytes_all();
}
}
+
+/*
+ * Editor modelines - http://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:
+ */