aboutsummaryrefslogtreecommitdiffstats
path: root/packet.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>1999-05-11 08:21:39 +0000
committerGuy Harris <guy@alum.mit.edu>1999-05-11 08:21:39 +0000
commite638eb378fb8d7e2da48f5ce8af9ac9c987a0bab (patch)
treec85ff76c2364a0c5fc07e94bce892928f8391b1e /packet.c
parent45394e744efe3552b1871ff6cc24cd4c8189d48d (diff)
Turn "arpaddr_to_str()" into "bytes_to_str()", and make it public, so it
can be used by dissectors other than ARP to display byte arrays as strings of hex digits. Add a routine to extract a null-terminated Unicode string and turn it into an ISO 8859-1 string for display. (Ultimately, we should determine what character sets the X server or printer or whatever can handle, and turn it into the appropriate character set.) Display the challenge in "core-to-LANMAN-2.1" Negotiate Protocol responses as a string of hex digits - but only if the length is non-zero. (It's a counted array, not a null-terminated string.) Display some additional security mode bits in an NT LM 0.12 Negotiate Protocol response. Display some additional bits in the "capabilities" field of the Negotiate Protocol response. Display the challenge in an NT LM 0.12 Negotiate Protocol response as a string of hex digits (it's a counted array, not a null-terminated string). Display the domain name as Unicode in an NT LM 0.12 Negotiate Protocol response if the capabilities field has the "supports Unicode" bit set (no, not the "Unicode" bit in the "flags2" field - NT doesn't set that in the response, even though it sends the domain name over in Unicode!). Display some additional bits in the "flags2" field of an SMB. svn path=/trunk/; revision=275
Diffstat (limited to 'packet.c')
-rw-r--r--packet.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/packet.c b/packet.c
index 6f8762a24b..daa30104a0 100644
--- a/packet.c
+++ b/packet.c
@@ -1,7 +1,7 @@
/* packet.c
* Routines for packet disassembly
*
- * $Id: packet.c,v 1.24 1999/03/31 08:20:28 guy Exp $
+ * $Id: packet.c,v 1.25 1999/05/11 08:21:38 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -136,6 +136,45 @@ time_secs_to_str(guint32 time)
return cur;
}
+/* Max string length for displaying byte string. */
+#define MAX_BYTE_STR_LEN 16
+
+/* Turn an array of bytes into a string showing the bytes in hex. */
+gchar *
+bytes_to_str(const guint8 *bd, int bd_len) {
+ static gchar str[3][MAX_BYTE_STR_LEN+3+1];
+ static gchar *cur;
+ gchar *p;
+ int len;
+ static const char hex[16] = { '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
+
+ if (cur == &str[0][0]) {
+ cur = &str[1][0];
+ } else if (cur == &str[1][0]) {
+ cur = &str[2][0];
+ } else {
+ cur = &str[0][0];
+ }
+ p = cur;
+ len = MAX_BYTE_STR_LEN;
+ while (bd_len > 0 && len > 0) {
+ *p++ = hex[(*bd) >> 4];
+ *p++ = hex[(*bd) & 0xF];
+ len -= 2;
+ bd++;
+ bd_len--;
+ }
+ if (bd_len != 0) {
+ /* Note that we're not showing the full string. */
+ *p++ = '.';
+ *p++ = '.';
+ *p++ = '.';
+ }
+ *p = '\0';
+ return cur;
+}
+
/*
* Given a pointer into a data buffer, and to the end of the buffer,
* find the end of the (putative) line at that position in the data