fix fields print format

This commit is contained in:
Peter Hatina 2014-09-03 11:07:42 +02:00
parent 81ac0f4c77
commit ed57f9451d
2 changed files with 99 additions and 1 deletions

View File

@ -0,0 +1,92 @@
diff --git a/epan/ftypes/ftype-integer.c b/epan/ftypes/ftype-integer.c
index 2bf81d6..3f9bbc1 100644
--- a/epan/ftypes/ftype-integer.c
+++ b/epan/ftypes/ftype-integer.c
@@ -230,7 +230,7 @@ integer_repr_len(fvalue_t *fv _U_, ftrepr_t rtype _U_)
}
static void
-integer_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, char *buf)
+integer_to_repr(fvalue_t *fv, ftrepr_t rtype, char *buf)
{
guint32 val;
@@ -240,7 +240,12 @@ integer_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, char *buf)
} else
val = fv->value.sinteger;
- guint32_to_str_buf(val, buf, 11);
+ if (rtype == FTREPR_DISPLAY_HEX) {
+ // This format perfectly fits into 11 bytes.
+ g_sprintf(buf, "0x%08x", val);
+ } else {
+ guint32_to_str_buf(val, buf, 11);
+ }
}
static int
@@ -250,9 +255,14 @@ uinteger_repr_len(fvalue_t *fv _U_, ftrepr_t rtype _U_)
}
static void
-uinteger_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, char *buf)
+uinteger_to_repr(fvalue_t *fv, ftrepr_t rtype, char *buf)
{
- guint32_to_str_buf(fv->value.uinteger, buf, 11);
+ if (rtype == FTREPR_DISPLAY_HEX) {
+ // This format perfectly fits into 11 bytes.
+ g_sprintf(buf, "0x%08x", fv->value.uinteger);
+ } else {
+ guint32_to_str_buf(fv->value.uinteger, buf, 11);
+ }
}
static gboolean
diff --git a/epan/ftypes/ftype-string.c b/epan/ftypes/ftype-string.c
index 3893823..7e67292 100644
--- a/epan/ftypes/ftype-string.c
+++ b/epan/ftypes/ftype-string.c
@@ -58,6 +58,7 @@ string_repr_len(fvalue_t *fv, ftrepr_t rtype)
{
switch (rtype) {
case FTREPR_DISPLAY:
+ case FTREPR_DISPLAY_HEX:
return (int)strlen(fv->value.string);
case FTREPR_DFILTER:
@@ -72,6 +73,7 @@ string_to_repr(fvalue_t *fv, ftrepr_t rtype, char *buf)
{
switch (rtype) {
case FTREPR_DISPLAY:
+ case FTREPR_DISPLAY_HEX:
strcpy(buf, fv->value.string);
return;
diff --git a/epan/ftypes/ftypes.h b/epan/ftypes/ftypes.h
index 5304277..63b7d0a 100644
--- a/epan/ftypes/ftypes.h
+++ b/epan/ftypes/ftypes.h
@@ -95,6 +95,7 @@ typedef struct _ftype_t ftype_t;
/* String representation types. */
enum ftrepr {
FTREPR_DISPLAY,
+ FTREPR_DISPLAY_HEX,
FTREPR_DFILTER
};
diff --git a/epan/print.c b/epan/print.c
index 5a7ed61..6dd2222 100644
--- a/epan/print.c
+++ b/epan/print.c
@@ -1797,7 +1797,10 @@ gchar* get_node_field_value(field_info* fi, epan_dissect_t* edt)
* FT_NONE can be checked when using -T fields */
return g_strdup("1");
default:
- dfilter_string = fvalue_to_string_repr(&fi->value, FTREPR_DISPLAY, NULL);
+ dfilter_string = fvalue_to_string_repr(
+ &fi->value,
+ fi->hfinfo->display == BASE_HEX ? FTREPR_DISPLAY_HEX : FTREPR_DISPLAY,
+ NULL);
if (dfilter_string != NULL) {
return dfilter_string;
} else {

View File

@ -21,7 +21,7 @@
Summary: Network traffic analyzer Summary: Network traffic analyzer
Name: wireshark Name: wireshark
Version: 1.12.0 Version: 1.12.0
Release: 3%{?dist} Release: 4%{?dist}
License: GPL+ License: GPL+
Group: Applications/Internet Group: Applications/Internet
Source0: http://wireshark.org/download/src/%{name}-%{version}.tar.bz2 Source0: http://wireshark.org/download/src/%{name}-%{version}.tar.bz2
@ -44,6 +44,8 @@ Patch7: wireshark-0007-Install-autoconf-related-file.patch
Patch8: wireshark-0008-move-default-temporary-directory-to-var-tmp.patch Patch8: wireshark-0008-move-default-temporary-directory-to-var-tmp.patch
# Fedora-specific # Fedora-specific
Patch9: wireshark-0009-Fix-paths-in-a-wireshark.desktop-file.patch Patch9: wireshark-0009-Fix-paths-in-a-wireshark.desktop-file.patch
# Update, when pushed upstream: https://code.wireshark.org/review/#/c/3770/
Patch10: wireshark-0010-fields-print-format.patch
Url: http://www.wireshark.org/ Url: http://www.wireshark.org/
BuildRequires: libpcap-devel >= 0.9 BuildRequires: libpcap-devel >= 0.9
@ -164,6 +166,7 @@ Cflags: -I\${includedir}" > wireshark.pc.in
%patch7 -p1 -b .install_autoconf %patch7 -p1 -b .install_autoconf
%patch8 -p1 -b .tmp_dir %patch8 -p1 -b .tmp_dir
%patch9 -p1 -b .fix_paths %patch9 -p1 -b .fix_paths
%patch10 -p1 -b .fields-print-format
%build %build
%ifarch s390 s390x sparcv9 sparc64 %ifarch s390 s390x sparcv9 sparc64
@ -365,6 +368,9 @@ update-mime-database %{?fedora:-n} %{_datadir}/mime &> /dev/null || :
%{_datadir}/aclocal/* %{_datadir}/aclocal/*
%changelog %changelog
* Wed Sep 3 2014 Peter Hatina <phatina@redhat.com> - 1.12.0-3
- fix fields print format
* Mon Aug 18 2014 Rex Dieter <rdieter@fedoraproject.org> 1.12.0-3 * Mon Aug 18 2014 Rex Dieter <rdieter@fedoraproject.org> 1.12.0-3
- update mime scriptlets - update mime scriptlets