aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--epan/dissectors/packet-mq.c18
-rw-r--r--epan/libwireshark.def1
-rw-r--r--epan/proto.h19
-rw-r--r--epan/tvbuff.c22
-rw-r--r--epan/tvbuff.h5
5 files changed, 42 insertions, 23 deletions
diff --git a/epan/dissectors/packet-mq.c b/epan/dissectors/packet-mq.c
index 350c42655b..9501aa7284 100644
--- a/epan/dissectors/packet-mq.c
+++ b/epan/dissectors/packet-mq.c
@@ -1062,7 +1062,7 @@ dissect_mq_gmo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint int_rep
if (check_col(pinfo->cinfo, COL_INFO))
{
guint8* sQueue;
- sQueue = tvb_get_ephemeral_string(tvb, offset + 24, 48);
+ sQueue = tvb_get_ephemeral_string_enc(tvb, offset + 24, 48, string_rep);
if (strip_trailing_blanks(sQueue, 48) != 0)
{
col_append_fstr(pinfo->cinfo, COL_INFO, " Q=%s", sQueue);
@@ -1138,7 +1138,7 @@ dissect_mq_pmo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint int_rep
if (check_col(pinfo->cinfo, COL_INFO))
{
guint8* sQueue;
- sQueue = tvb_get_ephemeral_string(tvb, offset + 32, 48);
+ sQueue = tvb_get_ephemeral_string_enc(tvb, offset + 32, 48, string_rep);
if (strip_trailing_blanks(sQueue, 48) != 0)
{
col_append_fstr(pinfo->cinfo, COL_INFO, " Q=%s", sQueue);
@@ -1438,12 +1438,12 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
guint8* sApplicationName;
guint8* sQueueManager;
- sApplicationName = tvb_get_ephemeral_string(tvb, offset + 48, 28);
+ sApplicationName = tvb_get_ephemeral_string_enc(tvb, offset + 48, 28, string_rep);
if (strip_trailing_blanks(sApplicationName, 28) != 0)
{
col_append_fstr(pinfo->cinfo, COL_INFO, ": App=%s", sApplicationName);
}
- sQueueManager = tvb_get_ephemeral_string(tvb, offset, 48);
+ sQueueManager = tvb_get_ephemeral_string_enc(tvb, offset, 48, string_rep);
if (strip_trailing_blanks(sQueueManager, 48) != 0)
{
col_append_fstr(pinfo->cinfo, COL_INFO, " QM=%s", sQueueManager);
@@ -1787,7 +1787,7 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
if (check_col(pinfo->cinfo, COL_INFO))
{
guint8* sChannel;
- sChannel = tvb_get_ephemeral_string(tvb, offset + 24, 20);
+ sChannel = tvb_get_ephemeral_string_enc(tvb, offset + 24, 20, string_rep);
if (strip_trailing_blanks(sChannel, 20) != 0)
{
col_append_fstr(pinfo->cinfo, COL_INFO, ": CHL=%s", sChannel);
@@ -1853,7 +1853,7 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
if (check_col(pinfo->cinfo, COL_INFO))
{
guint8* sQueueManager;
- sQueueManager = tvb_get_ephemeral_string(tvb, offset + 48, 48);
+ sQueueManager = tvb_get_ephemeral_string_enc(tvb, offset + 48, 48, string_rep);
if (strip_trailing_blanks(sQueueManager,48) != 0)
{
col_append_fstr(pinfo->cinfo, COL_INFO, " QM=%s", sQueueManager);
@@ -1887,7 +1887,7 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
if (check_col(pinfo->cinfo, COL_INFO))
{
guint8* sUserId;
- sUserId = tvb_get_ephemeral_string(tvb, offset + 4, 12);
+ sUserId = tvb_get_ephemeral_string_enc(tvb, offset + 4, 12, string_rep);
if (strip_trailing_blanks(sUserId, 12) != 0)
{
col_append_fstr(pinfo->cinfo, COL_INFO, ": User=%s", sUserId);
@@ -1938,7 +1938,7 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
if (check_col(pinfo->cinfo, COL_INFO))
{
guint8* sQueue;
- sQueue = tvb_get_ephemeral_string(tvb, offset + 12, 48);
+ sQueue = tvb_get_ephemeral_string_enc(tvb, offset + 12, 48, string_rep);
if (strip_trailing_blanks(sQueue,48) != 0)
{
col_append_fstr(pinfo->cinfo, COL_INFO, " Obj=%s", sQueue);
@@ -2243,7 +2243,7 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
if (tMsgProps.iOffsetFormat != 0)
{
guint8* sFormat = NULL;
- sFormat = tvb_get_ephemeral_string(tvb, tMsgProps.iOffsetFormat, 8);
+ sFormat = tvb_get_ephemeral_string_enc(tvb, tMsgProps.iOffsetFormat, 8, string_rep);
if (strip_trailing_blanks(sFormat, 8) == 0) sFormat = (guint8*)g_strdup("MQNONE");
if (check_col(pinfo->cinfo, COL_INFO))
{
diff --git a/epan/libwireshark.def b/epan/libwireshark.def
index 86d6d7d318..4631b0a31f 100644
--- a/epan/libwireshark.def
+++ b/epan/libwireshark.def
@@ -1094,6 +1094,7 @@ tvb_get_const_stringz
tvb_get_ds_tvb
tvb_get_ephemeral_faked_unicode
tvb_get_ephemeral_string
+tvb_get_ephemeral_string_enc
tvb_get_ephemeral_stringz
tvb_get_guid
tvb_get_guint8
diff --git a/epan/proto.h b/epan/proto.h
index fd54b3f179..a3abafe976 100644
--- a/epan/proto.h
+++ b/epan/proto.h
@@ -210,12 +210,6 @@ typedef struct _protocol protocol_t;
* ENC_LITTLE_ENDIAN as 0x80000000 - we're using the high-order bit
* so that we could put a field type and/or a value such as a character
* encoding in the lower bits.
- *
- * For protocols (FT_PROTOCOL), aggregate items with subtrees (FT_NONE),
- * opaque byte-array fields (FT_BYTES), and other fields where there
- * is no choice of encoding (either because it's "just a bucket
- * of bytes" or because the encoding is completely fixed), we
- * have ENC_NA (for "Not Applicable").
*/
#define ENC_BIG_ENDIAN 0x00000000
#define ENC_LITTLE_ENDIAN 0x80000000
@@ -230,8 +224,6 @@ typedef struct _protocol protocol_t;
#define ENC_TIME_TIMESPEC 0
#define ENC_TIME_NTP 2
-#define ENC_NA 0x00000000
-
/*
* Historically, the only place the representation mattered for strings
* was with FT_UINT_STRINGs, where we had FALSE for the string length
@@ -251,7 +243,16 @@ typedef struct _protocol protocol_t;
*/
#define ENC_CHARENCODING_MASK 0x7FFFFFFE /* mask out byte-order bits */
#define ENC_UTF_8 0x00000000
-#define ENC_EBCDIC 0x0EBCD1C0 /* XXX - multiple flavors of EBCDIC? */
+#define ENC_EBCDIC 0x0EBCD1C0
+
+/*
+ * For protocols (FT_PROTOCOL), aggregate items with subtrees (FT_NONE),
+ * opaque byte-array fields (FT_BYTES), and other fields where there
+ * is no choice of encoding (either because it's "just a bucket
+ * of bytes" or because the encoding is completely fixed), we
+ * have ENC_NA (for "Not Applicable").
+ */
+#define ENC_NA 0x00000000
/* Values for header_field_info.display */
diff --git a/epan/tvbuff.c b/epan/tvbuff.c
index cec87ce17e..7bbcc7a2bc 100644
--- a/epan/tvbuff.c
+++ b/epan/tvbuff.c
@@ -50,6 +50,7 @@
#include "tvbuff-int.h"
#include "strutil.h"
#include "emem.h"
+#include "charsets.h"
#include "proto.h" /* XXX - only used for DISSECTOR_ASSERT, probably a new header file? */
static const guint8*
@@ -2448,10 +2449,11 @@ tvb_get_unicode_string(tvbuff_t *tvb, const gint offset, gint length, const guin
}
/*
- * Given a tvbuff, an offset, and a length, allocate a buffer big enough
- * to hold a non-null-terminated string of that length at that offset,
- * plus a trailing '\0', copy the string into it, and return a pointer
- * to the string.
+ * Given a tvbuff, an offset, a length, and an encoding, allocate a
+ * buffer big enough to hold a non-null-terminated string of that length
+ * at that offset, plus a trailing '\0', copy the string into it, and
+ * return a pointer to the string; if the encoding is EBCDIC, map
+ * the string from EBCDIC to ASCII.
*
* Throws an exception if the tvbuff ends before the string does.
*
@@ -2462,7 +2464,8 @@ tvb_get_unicode_string(tvbuff_t *tvb, const gint offset, gint length, const guin
* after the current packet has been dissected.
*/
guint8 *
-tvb_get_ephemeral_string(tvbuff_t *tvb, const gint offset, const gint length)
+tvb_get_ephemeral_string_enc(tvbuff_t *tvb, const gint offset,
+ const gint length, const gint encoding)
{
const guint8 *ptr;
guint8 *strbuf = NULL;
@@ -2474,10 +2477,19 @@ tvb_get_ephemeral_string(tvbuff_t *tvb, const gint offset, const gint length)
if (length != 0) {
memcpy(strbuf, ptr, length);
}
+ if ((encoding & ENC_CHARENCODING_MASK) == ENC_EBCDIC)
+ EBCDIC_to_ASCII(strbuf, length);
strbuf[length] = '\0';
return strbuf;
}
+guint8 *
+tvb_get_ephemeral_string(tvbuff_t *tvb, const gint offset,
+ const gint length)
+{
+ return tvb_get_ephemeral_string_enc(tvb, offset, length, ENC_UTF_8|ENC_NA);
+}
+
/*
* Unicode (UTF-16) version of tvb_get_ephemeral_string()
*
diff --git a/epan/tvbuff.h b/epan/tvbuff.h
index 4a187332cb..8552e2dc78 100644
--- a/epan/tvbuff.h
+++ b/epan/tvbuff.h
@@ -442,6 +442,9 @@ extern gchar *tvb_format_stringzpad_wsp(tvbuff_t *tvb, const gint offset, const
* instead it will automatically be freed once the next
* packet is dissected.
*
+ * tvb_get_ephemeral_string_enc() takes a string encoding as well, and
+ * converts to UTF-8 from the encoding (only UTF-8 and EBCDIC supported)
+ *
* tvb_get_ephemeral_unicode_string() Unicode (UTF-16) version of above
*
* tvb_get_seasonal_string() returns a string that does not need to be freed,
@@ -451,6 +454,8 @@ extern gchar *tvb_format_stringzpad_wsp(tvbuff_t *tvb, const gint offset, const
extern guint8 *tvb_get_string(tvbuff_t *tvb, const gint offset, const gint length);
extern gchar *tvb_get_unicode_string(tvbuff_t *tvb, const gint offset, gint length, const guint encoding);
extern guint8 *tvb_get_ephemeral_string(tvbuff_t *tvb, const gint offset, const gint length);
+extern guint8 *tvb_get_ephemeral_string_enc(tvbuff_t *tvb, const gint offset,
+ const gint length, const gint encoding);
extern gchar *tvb_get_ephemeral_unicode_string(tvbuff_t *tvb, const gint offset, gint length, const guint encoding);
extern guint8 *tvb_get_seasonal_string(tvbuff_t *tvb, const gint offset, const gint length);