aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2015-01-09 12:51:15 -0500
committerMichael Mann <mmann78@netscape.net>2015-01-10 19:57:59 +0000
commit59c1e32d2c6dbdd353ae996d9538141bb029d6d0 (patch)
tree91e0422d3b1eed7ec887522fc6845ef94955d291 /epan
parenteffc8266ce2a87c5987018511f9bb2f61c34ba57 (diff)
Add BASE_SPACE for FT_BYTES
It's just like BASE_DOT, BASE_DASH and BASE_SEMICOLON, only its a space between bytes. Since this seems pretty specific to FT_BYTES, perhaps there is a better was to represent the functionality (like FT_BOOLEAN uses numeric values for number of bits)? Change-Id: I1a8f1ab263ece2736a8012b66fdd6a9105db7282 Reviewed-on: https://code.wireshark.org/review/6451 Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan')
-rw-r--r--epan/ftypes/ftype-bytes.c1
-rw-r--r--epan/proto.c75
-rw-r--r--epan/proto.h3
3 files changed, 34 insertions, 45 deletions
diff --git a/epan/ftypes/ftype-bytes.c b/epan/ftypes/ftype-bytes.c
index 22e677e56f..469311e044 100644
--- a/epan/ftypes/ftype-bytes.c
+++ b/epan/ftypes/ftype-bytes.c
@@ -160,6 +160,7 @@ bytes_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, int field_display, char *buf)
case BASE_DASH:
separator = '-';
break;
+ case BASE_SPACE:
case BASE_SEMICOLON:
case BASE_NONE:
default:
diff --git a/epan/proto.c b/epan/proto.c
index bc322eff46..0c078fb2c6 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -4164,7 +4164,7 @@ proto_custom_set(proto_tree* tree, GSList *field_ids, gint occurrence,
const char *hf_str_val;
char number_buf[32];
const char *number_out;
- char *tmpbuf;
+ char *tmpbuf, *str;
int *field_idx;
int field_id;
int ii = 0;
@@ -4249,39 +4249,23 @@ proto_custom_set(proto_tree* tree, GSList *field_ids, gint occurrence,
case FT_UINT_BYTES:
case FT_BYTES:
bytes = (guint8 *)fvalue_get(&finfo->value);
- switch(hfinfo->display)
- {
- case BASE_DOT:
- if (bytes) {
- char* str = (char*)bytestring_to_str(NULL, bytes, fvalue_length(&finfo->value), '.');
- offset_r += protoo_strlcpy(result+offset_r, str, size-offset_r);
- wmem_free(NULL, str);
- } else {
- offset_r += protoo_strlcpy(result+offset_r, "<MISSING>", size-offset_r);
- }
- break;
- case BASE_DASH:
- if (bytes) {
- char* str = (char*)bytestring_to_str(NULL, bytes, fvalue_length(&finfo->value), '-');
- offset_r += protoo_strlcpy(result+offset_r, str, size-offset_r);
- wmem_free(NULL, str);
- } else {
- offset_r += protoo_strlcpy(result+offset_r, "<MISSING>", size-offset_r);
- }
- break;
- case BASE_SEMICOLON:
- if (bytes) {
- char* str = (char*)bytestring_to_str(NULL, bytes, fvalue_length(&finfo->value), ':');
- offset_r += protoo_strlcpy(result+offset_r, str, size-offset_r);
- wmem_free(NULL, str);
- } else {
- offset_r += protoo_strlcpy(result+offset_r, "<MISSING>", size-offset_r);
- }
- break;
- case BASE_NONE:
- default:
- if (bytes) {
- char* str;
+ if (bytes) {
+ switch(hfinfo->display)
+ {
+ case BASE_DOT:
+ str = (char*)bytestring_to_str(NULL, bytes, fvalue_length(&finfo->value), '.');
+ break;
+ case BASE_DASH:
+ str = (char*)bytestring_to_str(NULL, bytes, fvalue_length(&finfo->value), '-');
+ break;
+ case BASE_SEMICOLON:
+ str = (char*)bytestring_to_str(NULL, bytes, fvalue_length(&finfo->value), ':');
+ break;
+ case BASE_SPACE:
+ str = (char*)bytestring_to_str(NULL, bytes, fvalue_length(&finfo->value), ' ');
+ break;
+ case BASE_NONE:
+ default:
if (prefs.display_byte_fields_with_spaces)
{
str = (char*)bytestring_to_str(NULL, bytes, fvalue_length(&finfo->value), ' ');
@@ -4290,12 +4274,13 @@ proto_custom_set(proto_tree* tree, GSList *field_ids, gint occurrence,
{
str = (char*)bytes_to_str(NULL, bytes, fvalue_length(&finfo->value));
}
- offset_r += protoo_strlcpy(result+offset_r, str, size-offset_r);
- wmem_free(NULL, str);
- } else {
- offset_r += protoo_strlcpy(result+offset_r, "<MISSING>", size-offset_r);
+ break;
}
- break;
+ offset_r += protoo_strlcpy(result+offset_r, str, size-offset_r);
+ wmem_free(NULL, str);
+ }
+ else {
+ offset_r += protoo_strlcpy(result+offset_r, "<MISSING>", size-offset_r);
}
break;
@@ -4394,11 +4379,9 @@ proto_custom_set(proto_tree* tree, GSList *field_ids, gint occurrence,
offset_r = (int)strlen(result);
break;
case FT_EUI64:
- {
- char* str = eui64_to_str(NULL, fvalue_get_integer64(&finfo->value));
+ str = eui64_to_str(NULL, fvalue_get_integer64(&finfo->value));
offset_r += protoo_strlcpy(result+offset_r, str, size-offset_r);
wmem_free(NULL, str);
- }
break;
case FT_IPv4:
@@ -4430,7 +4413,7 @@ proto_custom_set(proto_tree* tree, GSList *field_ids, gint occurrence,
case FT_GUID:
{
- char* str = guid_to_str(NULL, (e_guid_t *)fvalue_get(&finfo->value));
+ str = guid_to_str(NULL, (e_guid_t *)fvalue_get(&finfo->value));
offset_r += protoo_strlcpy(result+offset_r, str, size-offset_r);
wmem_free(NULL, str);
}
@@ -5648,9 +5631,10 @@ tmp_fld_check_assert(header_field_info *hfinfo)
case BASE_DOT:
case BASE_DASH:
case BASE_SEMICOLON:
+ case BASE_SPACE:
break;
default:
- g_error("Field '%s' (%s) is an byte array but is being displayed as %s instead of BASE_NONE, BASE_DOT, BASE_DASH, or BASE_SEMICOLON\n",
+ g_error("Field '%s' (%s) is an byte array but is being displayed as %s instead of BASE_NONE, BASE_DOT, BASE_DASH, BASE_SEMICOLON, or BASE_SPACE\n",
hfinfo->name, hfinfo->abbrev,
val_to_str(hfinfo->display, hf_display, "(Bit count: %d)"));
}
@@ -6049,6 +6033,9 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
case BASE_SEMICOLON:
str = (char*)bytestring_to_str(NULL, bytes, fvalue_length(&fi->value), ':');
break;
+ case BASE_SPACE:
+ str = (char*)bytestring_to_str(NULL, bytes, fvalue_length(&fi->value), ' ');
+ break;
case BASE_NONE:
default:
if (prefs.display_byte_fields_with_spaces)
diff --git a/epan/proto.h b/epan/proto.h
index 5a5b1aed2b..eec5e099ec 100644
--- a/epan/proto.h
+++ b/epan/proto.h
@@ -499,7 +499,8 @@ typedef enum {
/* Byte types */
BASE_DOT = 8, /**< hexadecimal bytes with a period (.) between each byte */
BASE_DASH = 9, /**< hexadecimal bytes with a dash (-) between each byte */
- BASE_SEMICOLON = 10 /**< hexadecimal bytes with a dash (:) between each byte */
+ BASE_SEMICOLON = 10, /**< hexadecimal bytes with a dash (:) between each byte */
+ BASE_SPACE = 11 /**< hexadecimal bytes with a space between each byte */
} field_display_e;
/* Following constants have to be ORed with a field_display_e when dissector