aboutsummaryrefslogtreecommitdiffstats
path: root/epan/osi-utils.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2017-03-31 14:47:49 -0700
committerGuy Harris <guy@alum.mit.edu>2017-03-31 21:48:25 +0000
commit02f74e47ed3e542f4aff9fc6a7a9c44e29be5c7b (patch)
tree6de9af3de29042cea7a675f2ed0441c7783381af /epan/osi-utils.c
parent7dc065397a5a18715dd1cf70dc4cfbccb550fa90 (diff)
Fix some dissection errors.
"XXX supported" for a metric type is a Boolean, not an int; add it as such. Add the value of the item without the extra bits. The length of an address prefix is in semi-octets (nibbles/hex digits), not in octets. Change-Id: I642f0dab5030f7609e89f45cf2cff15cd74dfbda Reviewed-on: https://code.wireshark.org/review/20819 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan/osi-utils.c')
-rw-r--r--epan/osi-utils.c52
1 files changed, 41 insertions, 11 deletions
diff --git a/epan/osi-utils.c b/epan/osi-utils.c
index 82a4216b86..46d20caf0e 100644
--- a/epan/osi-utils.c
+++ b/epan/osi-utils.c
@@ -37,6 +37,7 @@
static void print_nsap_net_buf( const guint8 *, int, gchar *, int);
static void print_area_buf ( const guint8 *, int, gchar *, int);
+static void print_address_prefix_buf ( const guint8 *, int, gchar *, int);
/*
* XXX - shouldn't there be a centralized routine for dissecting NSAPs?
@@ -152,16 +153,40 @@ print_area(tvbuff_t *tvb, const gint offset, int length)
return cur;
}
+/*
+ * Note: length is in units of half-octets.
+ */
+gchar *
+print_address_prefix(tvbuff_t *tvb, const gint offset, int length)
+{
+ gchar *cur;
+
+ cur = (gchar *)wmem_alloc(wmem_packet_scope(), MAX_AREA_LEN * 3 + 20);
+ print_address_prefix_buf(tvb_get_ptr(tvb, offset, (length+1)/2), length, cur, MAX_AREA_LEN * 3 + 20);
+ return cur;
+}
+
+/*
+ * Note: length is in units of octets.
+ */
static void
print_area_buf(const guint8 *ad, int length, gchar *buf, int buf_len)
{
+ print_address_prefix_buf(ad, length*2, buf, buf_len);
+}
+
+/*
+ * Note: length is in units of half-octets.
+ */
+static void
+print_address_prefix_buf(const guint8 *ad, int length, gchar *buf, int buf_len)
+{
gchar *cur;
int tmp = 0;
/* to do : all real area decoding now: NET is assumed if id len is 1 more byte
- * and take away all these stupid resource consuming local statics
*/
- if (length <= 0 || length > MAX_AREA_LEN) {
+ if (length <= 0 || length > MAX_AREA_LEN*2) {
g_strlcpy(buf, "<Invalid length of AREA>", buf_len);
return;
}
@@ -171,8 +196,8 @@ print_area_buf(const guint8 *ad, int length, gchar *buf, int buf_len)
|| ( NSAP_IDI_ISO_6523_ICD_BIN == *ad )
)
&&
- ( ( RFC1237_FULLAREA_LEN == length )
- || ( RFC1237_FULLAREA_LEN + 1 == length )
+ ( ( RFC1237_FULLAREA_LEN*2 == length )
+ || ( (RFC1237_FULLAREA_LEN + 1)*2 == length )
)
) { /* AFI is good and length is long enough */
@@ -187,35 +212,40 @@ print_area_buf(const guint8 *ad, int length, gchar *buf, int buf_len)
ad[5], ad[6], ad[7], ad[8] );
cur += g_snprintf(cur, (gulong) (buf_len-(cur-buf)), "[%02x:%02x|%02x:%02x]",
ad[9], ad[10], ad[11], ad[12] );
- if ( RFC1237_FULLAREA_LEN + 1 == length )
+ if ( (RFC1237_FULLAREA_LEN + 1)*2 == length )
g_snprintf(cur, (gulong) (buf_len-(cur-buf)), "-[%02x]", ad[20] );
}
else { /* print standard format */
- if ( length == RFC1237_AREA_LEN ) {
+ if ( length == RFC1237_AREA_LEN*2 ) {
g_snprintf(buf, buf_len, "%02x.%02x%02x", ad[0], ad[1], ad[2] );
return;
}
- if ( length == 4 ) {
+ if ( length == 4*2 ) {
g_snprintf(buf, buf_len, "%02x%02x%02x%02x", ad[0], ad[1], ad[2], ad[3] );
return;
}
- while ( tmp < length / 4 ) { /* 16/4==4 > four Octets left to print */
+ while ( tmp < length / 8 ) { /* 32/8==4 > four Octets left to print */
cur += g_snprintf(cur, (gulong) (buf_len-(cur-buf)), "%02x", ad[tmp++] );
cur += g_snprintf(cur, (gulong) (buf_len-(cur-buf)), "%02x", ad[tmp++] );
cur += g_snprintf(cur, (gulong) (buf_len-(cur-buf)), "%02x", ad[tmp++] );
cur += g_snprintf(cur, (gulong) (buf_len-(cur-buf)), "%02x.", ad[tmp++] );
}
- if ( 1 == tmp ) { /* Special case for Designated IS */
+ if ( 2 == tmp ) { /* Special case for Designated IS */
cur--;
g_snprintf(cur, (gulong) (buf_len-(cur-buf)), "-%02x", ad[tmp] );
}
else {
- for ( ; tmp < length; ) { /* print the rest without dot or dash */
+ for ( ; tmp < length / 2; ) { /* print the rest without dot or dash */
cur += g_snprintf(cur, (gulong) (buf_len-(cur-buf)), "%02x", ad[tmp++] );
}
+ /* Odd half-octet? */
+ if (length & 1) {
+ /* Yes - print it (it's the upper half-octet) */
+ cur += g_snprintf(cur, (gulong) (buf_len-(cur-buf)), "%x", (ad[tmp] & 0xF0)>>4 );
+ }
}
}
-} /* print_area_buf */
+} /* print_address_prefix_buf */
/******************************************************************************
* OSI Address Type