Rename "fake_unicode()" to "tvb_fake_unicode()" as it works on a tvbuff,
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 24 Feb 2003 01:22:30 +0000 (01:22 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 24 Feb 2003 01:22:30 +0000 (01:22 +0000)
give it a byte-order argument, and move it to "epan/tvbuff.c".

Use it to handle UCS-2 strings in version 1 of the Service Location
Protocol.  In SRVLOC V1, use registered fields that are already there
for SRVLOC V2, and add some as needed.  Fix some field names.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@7186 f5534014-38df-0310-8fa8-9805f1628bb7

epan/tvbuff.c
epan/tvbuff.h
packet-dcerpc-nt.c
packet-dcerpc-spoolss.c
packet-dcerpc.c
packet-dcerpc.h
packet-srvloc.c

index 94d707ccb981419641fd6dccb14d105d1383f9d9..4e8a2c2f0db31289edaabc4d19a02ff9e51542fb 100644 (file)
@@ -9,7 +9,7 @@
  *             the data of a backing tvbuff, or can be a composite of
  *             other tvbuffs.
  *
- * $Id: tvbuff.c,v 1.40 2002/08/28 20:40:45 jmayer Exp $
+ * $Id: tvbuff.c,v 1.41 2003/02/24 01:22:26 guy Exp $
  *
  * Copyright (c) 2000 by Gilbert Ramirez <gram@alumni.rice.edu>
  *
@@ -1617,6 +1617,41 @@ tvb_memeql(tvbuff_t *tvb, gint offset, const guint8 *str, gint size)
        }
 }
 
+/* Convert a string from Unicode to ASCII.  At the moment we fake it by
+ * assuming all characters are ASCII  )-:  The caller must free the
+ * result returned.  The len parameter is the number of guint16's to
+ * convert from Unicode. */
+char *
+tvb_fake_unicode(tvbuff_t *tvb, int offset, int len, gboolean little_endian)
+{
+       char *buffer;
+       int i;
+       guint16 character;
+
+       /* Make sure we have enough data before allocating the buffer,
+          so we don't blow up if the length is huge.
+          We do so by attempting to fetch the last character; it'll
+          throw an exception if it's past the end.
+
+           The byte order we use to fetch it is irrelevant here. */
+       tvb_get_letohs(tvb, offset + 2*(len - 1));
+
+       /* We know we won't throw an exception, so we don't have to worry
+          about leaking this buffer. */
+       buffer = g_malloc(len + 1);
+
+       for (i = 0; i < len; i++) {
+               character = little_endian ? tvb_get_letohs(tvb, offset)
+                                         : tvb_get_ntohs(tvb, offset);
+               buffer[i] = character & 0xff;
+               offset += 2;
+       }
+
+       buffer[len] = 0;
+
+       return buffer;
+}
+
 /*
  * Format the data in the tvb from offset for length ...
  */
index 1283692d44a9b3e02883b091a0abd54622ce6e34..1f1fc31201cd5fb5efea2c4f5035c6e298b5b375 100644 (file)
@@ -9,7 +9,7 @@
  *             the data of a backing tvbuff, or can be a composite of
  *             other tvbuffs.
  *
- * $Id: tvbuff.h,v 1.29 2002/08/28 20:40:45 jmayer Exp $
+ * $Id: tvbuff.h,v 1.30 2003/02/24 01:22:30 guy Exp $
  *
  * Copyright (c) 2000 by Gilbert Ramirez <gram@alumni.rice.edu>
  *
@@ -306,6 +306,13 @@ extern guint tvb_strsize(tvbuff_t *tvb, gint offset);
  * Returns -1 if 'maxlength' reached before finding EOS. */
 extern gint tvb_strnlen(tvbuff_t*, gint offset, guint maxlength);
 
+/* Convert a string from Unicode to ASCII.  At the moment we fake it by
+ * assuming all characters are ASCII  )-:  The caller must free the
+ * result returned.  The len parameter is the number of guint16's to
+ * convert from Unicode. */
+extern char *tvb_fake_unicode(tvbuff_t *tvb, int offset, int len,
+                              gboolean little_endian);
+
 /*
  * Format the data in the tvb from offset for size ...
  */
index 08115bbd03844f22d0f055b3f9085c594e3a4188..c4ae095b02384cdcbfe1d00566f15b205560a5eb 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for DCERPC over SMB packet disassembly
  * Copyright 2001-2003, Tim Potter <tpot@samba.org>
  *
- * $Id: packet-dcerpc-nt.c,v 1.67 2003/02/08 09:41:44 guy Exp $
+ * $Id: packet-dcerpc-nt.c,v 1.68 2003/02/24 01:22:14 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -682,8 +682,9 @@ void cb_str_postprocess(packet_info *pinfo, proto_tree *tree _U_,
        if ((end_offset - start_offset) <= 12)
                return;         /* XXX: Use unistr2 dissector instead? */
 
-       s = fake_unicode(
-               tvb, start_offset + 12, (end_offset - start_offset - 12) / 2);
+       s = tvb_fake_unicode(
+               tvb, start_offset + 12, (end_offset - start_offset - 12) / 2,
+               TRUE);
 
        /* Append string to COL_INFO */
 
index b85854038189b3f31669370ae1e6cceaacb11b67..cf94d369104f5f27436f7d88f36afd62c0ade26d 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for SMB \PIPE\spoolss packet disassembly
  * Copyright 2001-2003, Tim Potter <tpot@samba.org>
  *
- * $Id: packet-dcerpc-spoolss.c,v 1.89 2003/02/14 06:23:45 tpot Exp $
+ * $Id: packet-dcerpc-spoolss.c,v 1.90 2003/02/24 01:22:15 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -575,7 +575,7 @@ static int dissect_printerdata_data(tvbuff_t *tvb, int offset,
                
                switch(type) {
                case DCERPC_REG_SZ: {
-                       char *data = fake_unicode(tvb, offset - size, size/2);
+                       char *data = tvb_fake_unicode(tvb, offset - size, size/2, TRUE);
                        
                        proto_item_append_text(item, ": %s", data);
 
@@ -944,7 +944,7 @@ static int SpoolssSetPrinterDataEx_r(tvbuff_t *tvb, int offset,
 /* Yet another way to represent a unicode string - sheesh. This function
    dissects a NULL terminate unicode string at the current offset and
    returns the (char *) equivalent.  This really should return UTF8 or
-   something but we use fake_unicode() instead. */
+   something but we use tvb_fake_unicode() instead. */
 
 /* XXX - "name" should be an hf_ value for an FT_STRING. */
 static int
@@ -961,7 +961,7 @@ dissect_spoolss_uint16uni(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
        /* Get remaining data in buffer as a string */
 
        remaining = tvb_length_remaining(tvb, offset) / 2;
-       text = fake_unicode(tvb, offset, remaining);
+       text = tvb_fake_unicode(tvb, offset, remaining, TRUE);
        len = strlen(text);
 
        proto_tree_add_text(tree, tvb, offset, len * 2, "%s: %s",
@@ -5442,8 +5442,8 @@ static void cb_notify_str_postprocess(packet_info *pinfo _U_,
 
        len = tvb_get_letohl(tvb, start_offset);
 
-       s = fake_unicode(
-               tvb, start_offset + 4, (end_offset - start_offset - 4) / 2);
+       s = tvb_fake_unicode(
+               tvb, start_offset + 4, (end_offset - start_offset - 4) / 2, TRUE);
 
        /* Append string to upper-level proto_items */
 
index 31b0d938a5cf7391bb9f768e0e9ad5baa5da7ba5..1f8402812431f3166c8b148e4147e337ecb7eed7 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for DCERPC packet disassembly
  * Copyright 2001, Todd Sabin <tas@webspan.net>
  *
- * $Id: packet-dcerpc.c,v 1.109 2003/02/21 04:31:38 guy Exp $
+ * $Id: packet-dcerpc.c,v 1.110 2003/02/24 01:22:20 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -962,39 +962,6 @@ dissect_ndr_byte_array(tvbuff_t *tvb, int offset, packet_info *pinfo,
 
 /* For dissecting arrays that are to be interpreted as strings.  */
 
-/* Convert a string from little-endian unicode to ascii.  At the moment we
-   fake it by taking every odd byte.  )-:  The caller must free the
-   result returned.  The len parameter is the number of guint16's to
-   convert from unicode. */
-
-char *
-fake_unicode(tvbuff_t *tvb, int offset, int len)
-{
-       char *buffer;
-       int i;
-       guint16 character;
-
-       /* Make sure we have enough data before allocating the buffer,
-          so we don't blow up if the length is huge.
-          We do so by attempting to fetch the last character; it'll
-          throw an exception if it's past the end. */
-       tvb_get_letohs(tvb, offset + 2*(len - 1));
-
-       /* We know we won't throw an exception, so we don't have to worry
-          about leaking this buffer. */
-       buffer = g_malloc(len + 1);
-
-       for (i = 0; i < len; i++) {
-               character = tvb_get_letohs(tvb, offset);
-               buffer[i] = character & 0xff;
-               offset += 2;
-       }
-
-       buffer[len] = 0;
-
-       return buffer;
-}
-
 /* Dissect an NDR conformant varying string of elements.
    The length of each element is given by the 'size_is' parameter;
    the elements are assumed to be characters or wide characters.
@@ -1046,7 +1013,8 @@ dissect_ndr_cvstring(tvbuff_t *tvb, int offset, packet_info *pinfo,
         offset += size_is - (offset % size_is);
 
     if (size_is == sizeof(guint16)) {
-            s = fake_unicode(tvb, offset, buffer_len / 2);
+            /* XXX - use drep to determine the byte order? */
+            s = tvb_fake_unicode(tvb, offset, buffer_len / 2, TRUE);
             /*
              * XXX - we don't support a string type with Unicode
              * characters, so if this is a string item, we make
index 1c240906609fbe0bc7294e481212084bf8259f57..9f25f1cdbb456a2aa7922f948860baea78a0a273 100644 (file)
@@ -1,7 +1,7 @@
 /* packet-dcerpc.h
  * Copyright 2001, Todd Sabin <tas@webspan.net>
  *
- * $Id: packet-dcerpc.h,v 1.30 2003/02/10 02:06:28 tpot Exp $
+ * $Id: packet-dcerpc.h,v 1.31 2003/02/24 01:22:20 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -191,8 +191,6 @@ int dissect_ndr_ucvarray(tvbuff_t *tvb, gint offset, packet_info *pinfo,
 int dissect_ndr_byte_array(tvbuff_t *tvb, int offset, packet_info *pinfo, 
                            proto_tree *tree, char *drep);
 
-char *fake_unicode(tvbuff_t *tvb, int offset, int len);
-
 int dissect_ndr_cvstring(tvbuff_t *tvb, int offset, packet_info *pinfo, 
                         proto_tree *tree, char *drep, int size_is,
                         int hfinfo, gboolean add_subtree,
index 54cd8fc21e1df0b5f089af3fe83f449ebe73458a..410d83cd5c04ad0f3a02bb2647b74b9a387bf27e 100644 (file)
@@ -7,7 +7,7 @@
  *       In particular I have not had an opportunity to see how it
  *       responds to SRVLOC over TCP.
  *
- * $Id: packet-srvloc.c,v 1.36 2003/02/14 07:20:40 guy Exp $
+ * $Id: packet-srvloc.c,v 1.37 2003/02/24 01:22:20 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -89,6 +89,8 @@ static int hf_srvloc_srvreg_srvtypelen = -1;
 static int hf_srvloc_srvreg_srvtype = -1;
 static int hf_srvloc_srvreg_scopelistlen = -1;
 static int hf_srvloc_srvreg_scopelist = -1;
+static int hf_srvloc_srvdereg_attrlistlen = -1;
+static int hf_srvloc_srvdereg_attrlist = -1;
 static int hf_srvloc_srvdereg_scopelistlen = -1;
 static int hf_srvloc_srvdereg_scopelist = -1;
 static int hf_srvloc_srvdereg_taglistlen = -1;
@@ -99,6 +101,8 @@ static int hf_srvloc_attrreq_urllen  = -1;
 static int hf_srvloc_attrreq_url  = -1;
 static int hf_srvloc_attrreq_scopelistlen  = -1;
 static int hf_srvloc_attrreq_scopelist  = -1;
+static int hf_srvloc_attrreq_attrlistlen = -1;
+static int hf_srvloc_attrreq_attrlist = -1;
 static int hf_srvloc_attrreq_taglistlen  = -1;
 static int hf_srvloc_attrreq_taglist  = -1;
 static int hf_srvloc_attrreq_slpspilen = -1;
@@ -108,13 +112,15 @@ static int hf_srvloc_attrrply_attrlist = -1;
 static int hf_srvloc_attrrply_attrauthcount = -1;
 static int hf_srvloc_srvtypereq_prlistlen = -1;
 static int hf_srvloc_srvtypereq_prlist = -1;
-static int hf_srvloc_srvtypereq_authlistlen = -1;
-static int hf_srvloc_srvtypereq_authlistlenall = -1;
-static int hf_srvloc_srvtypereq_authlist = -1;
+static int hf_srvloc_srvtypereq_nameauthlistlen = -1;
+static int hf_srvloc_srvtypereq_nameauthlistlenall = -1;
+static int hf_srvloc_srvtypereq_nameauthlist = -1;
 static int hf_srvloc_srvtypereq_scopelistlen = -1;
 static int hf_srvloc_srvtypereq_scopelist = -1;
-static int hf_srvloc_srvtyperply_len = -1;
-static int hf_srvloc_srvtyperply_type = -1;
+static int hf_srvloc_srvtyperply_srvtypelen = -1;
+static int hf_srvloc_srvtyperply_srvtype = -1;
+static int hf_srvloc_srvtyperply_srvtypelistlen = -1;
+static int hf_srvloc_srvtyperply_srvtypelist = -1;
 static int hf_srvloc_saadvert_urllen = -1;
 static int hf_srvloc_saadvert_url = -1;
 static int hf_srvloc_saadvert_scopelistlen = -1;
@@ -375,11 +381,51 @@ dissect_attrauthblk_v2(tvbuff_t *tvb, int offset, proto_tree *tree)
     return offset;
 }
 
+static void
+add_v1_string(proto_tree *tree, int hf, tvbuff_t *tvb, int offset, int length,
+    guint16 encoding)
+{
+        char *unicode_str;
+
+        switch (encoding) {
+
+        case CHARSET_ISO_10646_UCS_2:
+                unicode_str = tvb_fake_unicode(tvb, offset, length/2, FALSE);
+                proto_tree_add_string(tree, hf, tvb, offset, length,
+                                    unicode_str);
+                g_free(unicode_str);
+                break;
+
+        default:
+                proto_tree_add_item(tree, hf, tvb, offset, length, TRUE);
+                break;
+        }
+}
+
+static int
+dissect_url_entry(tvbuff_t *tvb, int offset, proto_tree *tree, guint16 encoding,
+                  guint16 flags)
+{
+    guint16    url_len;
+
+    proto_tree_add_item(tree, hf_srvloc_url_lifetime, tvb, offset, 2,
+                       FALSE);
+    offset += 2;
+    url_len = tvb_get_ntohs(tvb, offset);
+    proto_tree_add_uint(tree, hf_srvloc_url_urllen, tvb, offset, 2,
+                       url_len);
+    offset += 2;
+    add_v1_string(tree, hf_srvloc_url_url, tvb, offset, url_len, encoding);
+    offset += url_len;
+    if ( (flags & FLAG_U) == FLAG_U )
+        offset = dissect_authblk(tvb, offset, tree);
+    return offset;
+}
+
 static int
-dissect_url_entry(tvbuff_t *tvb, int offset, proto_tree *tree)
+dissect_url_entry_v2(tvbuff_t *tvb, int offset, proto_tree *tree)
 {
     guint8     reserved;
-    guint16    lifetime;
     guint16    url_len;
     guint8     num_auths;
 
@@ -387,9 +433,8 @@ dissect_url_entry(tvbuff_t *tvb, int offset, proto_tree *tree)
     proto_tree_add_uint(tree, hf_srvloc_url_reserved, tvb, offset, 1,
                        reserved);
     offset += 1;
-    lifetime = tvb_get_ntohs(tvb, offset);
-    proto_tree_add_uint(tree, hf_srvloc_url_lifetime, tvb, offset, 2,
-                       lifetime);
+    proto_tree_add_item(tree, hf_srvloc_url_lifetime, tvb, offset, 2,
+                       FALSE);
     offset += 2;
     url_len = tvb_get_ntohs(tvb, offset);
     proto_tree_add_uint(tree, hf_srvloc_url_urllen, tvb, offset, 2,
@@ -449,7 +494,7 @@ dissect_srvloc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                             function);
        if (version < 2) {
            length = tvb_get_ntohs(tvb, offset + 2);
-           proto_tree_add_text(srvloc_tree, tvb, offset + 2, 2, "Length: %u",
+           proto_tree_add_uint(srvloc_tree, hf_srvloc_pktlen, tvb, offset + 2, 2,
                                length);
            flags = tvb_get_guint8(tvb, offset + 4);
            tf = proto_tree_add_uint(srvloc_tree, hf_srvloc_flags, tvb, offset + 4, 1,
@@ -476,18 +521,14 @@ dissect_srvloc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
             case SRVREQ:
                 proto_tree_add_text(srvloc_tree, tvb, offset, 0, "Service Request");
                 length = tvb_get_ntohs(tvb, offset);
-                proto_tree_add_text(srvloc_tree, tvb, offset, 2, "Previous Response List Length: %u",
-                                    length);
+                proto_tree_add_uint(srvloc_tree, hf_srvloc_srvreq_prlistlen, tvb, offset, 2, length);
                 offset += 2;
-                proto_tree_add_text(srvloc_tree, tvb, offset, length, "Previous Response List: %s",
-                                    tvb_format_text(tvb, offset, length));
+                add_v1_string(srvloc_tree, hf_srvloc_srvreq_prlist, tvb, offset, length, encoding);
                 offset += length;
                 length = tvb_get_ntohs(tvb, offset);
-                proto_tree_add_text(srvloc_tree, tvb, offset, 2, "Predicate length: %u",
-                                    length);
+                proto_tree_add_uint(srvloc_tree, hf_srvloc_srvreq_predicatelen, tvb, offset, 2, length);
                 offset += 2;
-                proto_tree_add_text(srvloc_tree, tvb, offset, length, "Predicate: %s",
-                                    tvb_format_text(tvb, offset, length));
+                add_v1_string(srvloc_tree, hf_srvloc_srvreq_predicate, tvb, offset, length, encoding);
                 offset += length;
                break;
                
@@ -496,46 +537,23 @@ dissect_srvloc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                 proto_tree_add_item(srvloc_tree, hf_srvloc_error, tvb, offset, 2, FALSE);
                 offset += 2;
                 count = tvb_get_ntohs(tvb, offset);
-                proto_tree_add_text(srvloc_tree, tvb, offset, 2, "URL Count: %u",
-                                    count);
+                proto_tree_add_uint(srvloc_tree, hf_srvloc_srvrply_urlcount, tvb, offset, 2, count);
                 offset += 2;
                 while (count > 0) {
-                    proto_tree_add_text(srvloc_tree, tvb, offset, 2, "URL lifetime: %u",
-                                        tvb_get_ntohs(tvb, offset));
-                    offset += 2;
-                    length = tvb_get_ntohs(tvb, offset);
-                    proto_tree_add_text(srvloc_tree, tvb, offset, 2, "URL length: %u",
-                                        length);
-                    offset += 2;
-                    proto_tree_add_text(srvloc_tree, tvb, offset, length, "Service URL: %s",
-                                        tvb_format_text(tvb, offset, length));
-                    offset += length;
-                    if ( (flags & FLAG_U) == FLAG_U )
-                        offset = dissect_authblk(tvb, offset, srvloc_tree);
+                    offset = dissect_url_entry(tvb, offset, srvloc_tree,
+                                               encoding, flags);
                     count--;
                 };
             break;
 
             case SRVREG:
                 proto_tree_add_text(srvloc_tree, tvb, offset, 0, "Service Registration");
-                proto_tree_add_text(srvloc_tree, tvb, offset, 2, "URL lifetime: %u",
-                                    tvb_get_ntohs(tvb, offset));
-                offset += 2;
-                length = tvb_get_ntohs(tvb, offset);
-                proto_tree_add_text(srvloc_tree, tvb, offset, 2, "URL length: %u",
-                                    length);
-                offset += 2;
-                proto_tree_add_text(srvloc_tree, tvb, offset, length, "Service URL: %s",
-                                    tvb_format_text(tvb, offset, length));
-                offset += length;
-                if ( (flags & FLAG_U) == FLAG_U )
-                    offset = dissect_authblk(tvb, offset, srvloc_tree);
+                offset = dissect_url_entry(tvb, offset, srvloc_tree, encoding,
+                                           flags);
                 length = tvb_get_ntohs(tvb, offset);
-                proto_tree_add_text(srvloc_tree, tvb, offset, 2, "Attribute List length: %u",
-                                    length);
+                proto_tree_add_uint(srvloc_tree, hf_srvloc_srvreg_attrlistlen, tvb, offset, 2, length);
                 offset += 2;
-                proto_tree_add_text(srvloc_tree, tvb, offset, length, "Attribute List: %s",
-                                    tvb_format_text(tvb, offset, length));
+                add_v1_string(srvloc_tree, hf_srvloc_srvreg_attrlist, tvb, offset, length, encoding);
                 offset += length;
                 if ( (flags & FLAG_A) == FLAG_A )
                     offset = dissect_authblk(tvb, offset, srvloc_tree);
@@ -543,21 +561,11 @@ dissect_srvloc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 
             case SRVDEREG:
                 proto_tree_add_text(srvloc_tree, tvb, offset, 0, "Service Deregister");
+                offset = dissect_url_entry(tvb, offset, srvloc_tree, encoding,
+                                           flags);
                 length = tvb_get_ntohs(tvb, offset);
-                proto_tree_add_text(srvloc_tree, tvb, offset, 2, "URL length: %u",
-                                    length);
-                offset += 2;
-                proto_tree_add_text(srvloc_tree, tvb, offset, length, "Service URL: %s",
-                                    tvb_format_text(tvb, offset, length));
-                offset += length;
-                if ( (flags & FLAG_U) == FLAG_U )
-                    offset = dissect_authblk(tvb, offset, srvloc_tree);
-                length = tvb_get_ntohs(tvb, offset);
-                proto_tree_add_text(srvloc_tree, tvb, offset, 2, "Attribute List length: %u",
-                                    length);
-                offset += 2;
-                proto_tree_add_text(srvloc_tree, tvb, offset, length, "Attribute List: %s",
-                                    tvb_format_text(tvb, offset, length));
+                proto_tree_add_uint(srvloc_tree, hf_srvloc_srvdereg_attrlistlen, tvb, offset, 2, length);
+                add_v1_string(srvloc_tree, hf_srvloc_srvdereg_attrlist, tvb, offset, length, encoding);
                 offset += length;
                 if ( (flags & FLAG_A) == FLAG_A )
                     offset = dissect_authblk(tvb, offset, srvloc_tree);
@@ -572,32 +580,24 @@ dissect_srvloc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
             case ATTRRQST:
                 proto_tree_add_text(srvloc_tree, tvb, offset, 0, "Attribute Request");
                 length = tvb_get_ntohs(tvb, offset);
-                proto_tree_add_text(srvloc_tree, tvb, offset, 2, "Previous Response List Length: %u",
-                                    length);
+                proto_tree_add_uint(srvloc_tree, hf_srvloc_attrreq_prlistlen, tvb, offset, 2, length);
                 offset += 2;
-                proto_tree_add_text(srvloc_tree, tvb, offset, length, "Previous Response List: %s",
-                                    tvb_format_text(tvb, offset, length));
+                add_v1_string(srvloc_tree, hf_srvloc_attrreq_prlist, tvb, offset, length, encoding);
                 offset += length;
                 length = tvb_get_ntohs(tvb, offset);
-                proto_tree_add_text(srvloc_tree, tvb, offset, 2, "URL length: %u",
-                                    length);
+                proto_tree_add_uint(srvloc_tree, hf_srvloc_attrreq_urllen, tvb, offset, 2, length);
                 offset += 2;
-                proto_tree_add_text(srvloc_tree, tvb, offset, length, "Service URL: %s",
-                                    tvb_format_text(tvb, offset, length));
+                add_v1_string(srvloc_tree, hf_srvloc_attrreq_url, tvb, offset, length, encoding);
                 offset += length;
                 length = tvb_get_ntohs(tvb, offset);
-                proto_tree_add_text(srvloc_tree, tvb, offset, 2, "Scope List Length: %u",
-                                    length);
+                proto_tree_add_uint(srvloc_tree, hf_srvloc_attrreq_scopelistlen, tvb, offset, 2, length);
                 offset += 2;
-                proto_tree_add_text(srvloc_tree, tvb, offset, length, "Scope Response List: %s",
-                                    tvb_format_text(tvb, offset, length));
+                add_v1_string(srvloc_tree, hf_srvloc_attrreq_scopelist, tvb, offset, length, encoding);
                 offset += length;
                 length = tvb_get_ntohs(tvb, offset);
-                proto_tree_add_text(srvloc_tree, tvb, offset, 2, "Attribute List length: %u",
-                                    length);
+                proto_tree_add_uint(srvloc_tree, hf_srvloc_attrreq_attrlistlen, tvb, offset, 2, length);
                 offset += 2;
-                proto_tree_add_text(srvloc_tree, tvb, offset, length, "Attribute List: %s",
-                                    tvb_format_text(tvb, offset, length));
+                add_v1_string(srvloc_tree, hf_srvloc_attrreq_attrlist, tvb, offset, length, encoding);
                 offset += length;
             break;
 
@@ -606,11 +606,9 @@ dissect_srvloc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                 proto_tree_add_item(srvloc_tree, hf_srvloc_error_v2, tvb, offset, 2, FALSE);
                 offset += 2;
                 length = tvb_get_ntohs(tvb, offset);
-                proto_tree_add_text(srvloc_tree, tvb, offset, 2, "Attribute List length: %u",
-                                    length);
+                proto_tree_add_uint(srvloc_tree, hf_srvloc_attrrply_attrlistlen, tvb, offset, 2, length);
                 offset += 2;
-                proto_tree_add_text(srvloc_tree, tvb, offset, length, "Attribute List: %s",
-                                    tvb_format_text(tvb, offset, length));
+                add_v1_string(srvloc_tree, hf_srvloc_attrrply_attrlist, tvb, offset, length, encoding);
                 offset += length;
                 if ( (flags & FLAG_A) == FLAG_A )
                     offset = dissect_authblk(tvb, offset, srvloc_tree);
@@ -621,43 +619,33 @@ dissect_srvloc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                 proto_tree_add_item(srvloc_tree, hf_srvloc_error, tvb, offset, 2, FALSE);
                 offset += 2;
                 length = tvb_get_ntohs(tvb, offset);
-                proto_tree_add_text(srvloc_tree, tvb, offset, 2, "URL length: %u",
-                                    length);
+                proto_tree_add_uint(srvloc_tree, hf_srvloc_daadvert_urllen, tvb, offset, 2, length);
                 offset += 2;
-                proto_tree_add_text(srvloc_tree, tvb, offset, length, "Service URL: %s",
-                                    tvb_format_text(tvb, offset, length));
+                add_v1_string(srvloc_tree, hf_srvloc_daadvert_url, tvb, offset, length, encoding);
                 offset += length;
                 length = tvb_get_ntohs(tvb, offset);
-                proto_tree_add_text(srvloc_tree, tvb, offset, 2, "Scope List Length: %u",
-                                    length);
+                proto_tree_add_uint(srvloc_tree, hf_srvloc_daadvert_scopelistlen, tvb, offset, 2, length);
                 offset += 2;
-                proto_tree_add_text(srvloc_tree, tvb, offset, length, "Scope Response List: %s",
-                                    tvb_format_text(tvb, offset, length));
+                add_v1_string(srvloc_tree, hf_srvloc_daadvert_scopelist, tvb, offset, length, encoding);
                 offset += length;
             break;
 
             case SRVTYPERQST:
                 proto_tree_add_text(srvloc_tree, tvb, offset, 0, "Service Type Request");
                 length = tvb_get_ntohs(tvb, offset);
-                proto_tree_add_text(srvloc_tree, tvb, offset, 2, "Previous Response List Length: %u",
-                                    length);
+                proto_tree_add_uint(srvloc_tree, hf_srvloc_srvtypereq_prlistlen, tvb, offset, 2, length);
                 offset += 2;
-                proto_tree_add_text(srvloc_tree, tvb, offset, length, "Previous Response List: %s",
-                                    tvb_format_text(tvb, offset, length));
+                add_v1_string(srvloc_tree, hf_srvloc_srvtypereq_prlist, tvb, offset, length, encoding);
                 offset += length;
                 length = tvb_get_ntohs(tvb, offset);
-                proto_tree_add_text(srvloc_tree, tvb, offset, 2, "Naming Authority List length: %u",
-                                    length);
+                proto_tree_add_uint(srvloc_tree, hf_srvloc_srvtypereq_nameauthlistlen, tvb, offset, 2, length);
                 offset += 2;
-                proto_tree_add_text(srvloc_tree, tvb, offset, length, "Naming Authority List: %s",
-                                    tvb_format_text(tvb, offset, length));
+                add_v1_string(srvloc_tree, hf_srvloc_srvtypereq_nameauthlist, tvb, offset, length, encoding);
                 offset += length;
                 length = tvb_get_ntohs(tvb, offset);
-                proto_tree_add_text(srvloc_tree, tvb, offset, 2, "Scope List Length: %u",
-                                    length);
+                proto_tree_add_uint(srvloc_tree, hf_srvloc_srvtypereq_scopelistlen, tvb, offset, 2, length);
                 offset += 2;
-                proto_tree_add_text(srvloc_tree, tvb, offset, length, "Scope Response List: %s",
-                                    tvb_format_text(tvb, offset, length));
+                add_v1_string(srvloc_tree, hf_srvloc_srvtypereq_scopelist, tvb, offset, length, encoding);
                 offset += length;
             break;
 
@@ -671,11 +659,9 @@ dissect_srvloc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                 offset += 2;
                 while (count > 0) {
                     length = tvb_get_ntohs(tvb, offset);
-                    proto_tree_add_text(srvloc_tree, tvb, offset, 2, "Service Type List length: %u",
-                                        length);
+                    proto_tree_add_uint(srvloc_tree, hf_srvloc_srvtyperply_srvtypelen, tvb, offset, 2, length);
                     offset += 2;
-                    proto_tree_add_text(srvloc_tree, tvb, offset, length, "Service Type List: %s",
-                                        tvb_format_text(tvb, offset, length));
+                    add_v1_string(srvloc_tree, hf_srvloc_srvtyperply_srvtype, tvb, offset, length, encoding);
                     offset += length;
                     count--;
                 };
@@ -746,13 +732,13 @@ dissect_srvloc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                 proto_tree_add_uint(srvloc_tree, hf_srvloc_srvrply_urlcount, tvb, offset, 2, count);
                 offset += 2;
                 while (count > 0) {
-                   offset = dissect_url_entry(tvb, offset, srvloc_tree);
+                   offset = dissect_url_entry_v2(tvb, offset, srvloc_tree);
                     count--;
                 };
             break;
 
             case SRVREG: /* RFC2608 8.3 */
-               offset = dissect_url_entry(tvb, offset, srvloc_tree);
+               offset = dissect_url_entry_v2(tvb, offset, srvloc_tree);
                 length = tvb_get_ntohs(tvb, offset);
                 proto_tree_add_uint(srvloc_tree, hf_srvloc_srvreg_srvtypelen, tvb, offset, 2, length);
                 offset += 2;
@@ -783,7 +769,7 @@ dissect_srvloc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                 offset += 2;
                 proto_tree_add_item(srvloc_tree, hf_srvloc_srvdereg_scopelist, tvb, offset, length, TRUE);
                 offset += length;
-               offset = dissect_url_entry(tvb, offset, srvloc_tree);
+               offset = dissect_url_entry_v2(tvb, offset, srvloc_tree);
                 length = tvb_get_ntohs(tvb, offset);
                 proto_tree_add_uint(srvloc_tree, hf_srvloc_srvdereg_taglistlen, tvb, offset, 2, length);
                 offset += 2;
@@ -886,12 +872,12 @@ dissect_srvloc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                 offset += length;
                 length = tvb_get_ntohs(tvb, offset);
                if (0xFFFF == length) {
-                   proto_tree_add_uint(srvloc_tree, hf_srvloc_srvtypereq_authlistlenall, tvb, offset, 2, length);
+                   proto_tree_add_uint(srvloc_tree, hf_srvloc_srvtypereq_nameauthlistlenall, tvb, offset, 2, length);
                    offset += 2;
                } else {
-                   proto_tree_add_uint(srvloc_tree, hf_srvloc_srvtypereq_authlistlen, tvb, offset, 2, length);
+                   proto_tree_add_uint(srvloc_tree, hf_srvloc_srvtypereq_nameauthlistlen, tvb, offset, 2, length);
                    offset += 2;
-                   proto_tree_add_item(srvloc_tree, hf_srvloc_srvtypereq_authlist, tvb, offset, length, TRUE);
+                   proto_tree_add_item(srvloc_tree, hf_srvloc_srvtypereq_nameauthlist, tvb, offset, length, TRUE);
                    offset += length;
                }
                 length = tvb_get_ntohs(tvb, offset);
@@ -905,9 +891,9 @@ dissect_srvloc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                 proto_tree_add_item(srvloc_tree, hf_srvloc_error_v2, tvb, offset, 2, FALSE);
                 offset += 2;
                 length = tvb_get_ntohs(tvb, offset);
-                proto_tree_add_uint(srvloc_tree, hf_srvloc_srvtyperply_len, tvb, offset, 2, length);
+                proto_tree_add_uint(srvloc_tree, hf_srvloc_srvtyperply_srvtypelistlen, tvb, offset, 2, length);
                 offset += 2;
-               proto_tree_add_item(srvloc_tree, hf_srvloc_srvtyperply_type, tvb, offset, length, TRUE);
+               proto_tree_add_item(srvloc_tree, hf_srvloc_srvtyperply_srvtypelist, tvb, offset, length, TRUE);
             break;
 
            case SAADVERT: /* rfc2608 10.2 */
@@ -981,13 +967,14 @@ proto_register_srvloc(void)
             FT_UINT24, BASE_DEC, NULL, 0x0, 
             "", HFILL }
         },
-       /* Helper functions for URL parsing - Version 2 */
+
+       /* Helper functions for URL and URL Entry parsing - both versions */
        {&hf_srvloc_url_reserved,
         {"Reserved", "srvloc.url.reserved",
          FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL }
        },
        {&hf_srvloc_url_lifetime,
-        {"Lifetime", "srvloc.url.lifetime",
+        {"URL lifetime", "srvloc.url.lifetime",
          FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }
        },
        {&hf_srvloc_url_urllen,
@@ -1070,11 +1057,11 @@ proto_register_srvloc(void)
 
        /* collection of helper functions for Service Request */
        { &hf_srvloc_srvreq_prlistlen,
-         { "PR List Length", "srvloc.srvreq.prlistlen", FT_UINT16, BASE_DEC, NULL, 0x0,
+         { "Previous Response List Length", "srvloc.srvreq.prlistlen", FT_UINT16, BASE_DEC, NULL, 0x0,
            "Length of Previous Response List", HFILL}
        },
        { &hf_srvloc_srvreq_prlist,
-         { "PR List", "srvloc.srvreq.prlist", FT_STRING, BASE_DEC, NULL, 0x0,
+         { "Previous Response List", "srvloc.srvreq.prlist", FT_STRING, BASE_DEC, NULL, 0x0,
            "Previous Response List", HFILL}
        },
        { &hf_srvloc_srvreq_srvtypelen,
@@ -1147,6 +1134,14 @@ proto_register_srvloc(void)
        },
 
        /* Helper functions for Service Deregistration */
+       { &hf_srvloc_srvdereg_attrlistlen,
+         { "Attribute List Length", "srvloc.srvdereg.attrlistlen", FT_UINT16, BASE_DEC, NULL, 0x0,
+           "", HFILL}
+       },
+       { &hf_srvloc_srvdereg_attrlist,
+         { "Attribute List", "srvloc.srvdereg.attrlist", FT_STRING, BASE_DEC, NULL, 0x0,
+           "", HFILL}
+       },
        { &hf_srvloc_srvdereg_scopelistlen,
          { "Scope List Length", "srvloc.srvdereq.scopelistlen", FT_UINT16, BASE_DEC, NULL, 0x0,
            "", HFILL}
@@ -1167,11 +1162,11 @@ proto_register_srvloc(void)
 
        /* collection of helper functions for Attribute Request */
        { &hf_srvloc_attrreq_prlistlen,
-         { "PR List Length", "srvloc.attrreq.prlistlen", FT_UINT16, BASE_DEC, NULL, 0x0,
+         { "Previous Response List Length", "srvloc.attrreq.prlistlen", FT_UINT16, BASE_DEC, NULL, 0x0,
            "Length of Previous Response List", HFILL}
        },
        { &hf_srvloc_attrreq_prlist,
-         { "PR List", "srvloc.attrreq.prlist", FT_STRING, BASE_DEC, NULL, 0x0,
+         { "Previous Response List", "srvloc.attrreq.prlist", FT_STRING, BASE_DEC, NULL, 0x0,
            "Previous Response List", HFILL}
        },
        { &hf_srvloc_attrreq_urllen,
@@ -1179,7 +1174,7 @@ proto_register_srvloc(void)
            "", HFILL}
        },
        { &hf_srvloc_attrreq_url,
-         { "URL", "srvloc.attrreq.url", FT_STRING, BASE_DEC, NULL, 0x0,
+         { "Service URL", "srvloc.attrreq.url", FT_STRING, BASE_DEC, NULL, 0x0,
            "URL of service", HFILL}
        },
        { &hf_srvloc_attrreq_scopelistlen,
@@ -1190,6 +1185,14 @@ proto_register_srvloc(void)
          { "Scope List", "srvloc.attrreq.scopelist", FT_STRING, BASE_DEC, NULL, 0x0,
            "", HFILL}
        },
+       { &hf_srvloc_attrreq_attrlistlen,
+         { "Attribute List Length", "srvloc.attrreq.attrlistlen", FT_UINT16, BASE_DEC, NULL, 0x0,
+           "", HFILL}
+       },
+       { &hf_srvloc_attrreq_attrlist,
+         { "Attribute List", "srvloc.attrreq.attrlist", FT_STRING, BASE_DEC, NULL, 0x0,
+           "", HFILL}
+       },
        { &hf_srvloc_attrreq_taglistlen,
          { "Tag List Length", "srvloc.attrreq.taglistlen", FT_UINT16, BASE_DEC, NULL, 0x0,
            "", HFILL}
@@ -1213,7 +1216,7 @@ proto_register_srvloc(void)
            "Length of Attribute List", HFILL}
        },
        { &hf_srvloc_attrrply_attrlist,
-         { "Attribute Reply", "srvloc.attrrply.attrlist", FT_STRING, BASE_DEC, NULL, 0x0,
+         { "Attribute List", "srvloc.attrrply.attrlist", FT_STRING, BASE_DEC, NULL, 0x0,
            "", HFILL}
        },
        { &hf_srvloc_attrrply_attrauthcount,
@@ -1272,15 +1275,15 @@ proto_register_srvloc(void)
          { "PR List", "srvloc.srvtypereq.prlist", FT_STRING, BASE_DEC, NULL, 0x0,
            "Previous Response List", HFILL}
        },
-       { &hf_srvloc_srvtypereq_authlistlen,
+       { &hf_srvloc_srvtypereq_nameauthlistlen,
          { "Naming Authority List Length", "srvloc.srvtypereq.nameauthlistlen", FT_UINT16, BASE_DEC, NULL, 0x0,
            "Length of the Naming Authority List", HFILL}
        },
-       { &hf_srvloc_srvtypereq_authlistlenall,
+       { &hf_srvloc_srvtypereq_nameauthlistlenall,
          { "Naming Authority List Length (All Naming Authorities)", "srvloc.srvtypereq.nameauthlistlen", FT_UINT16, BASE_DEC, NULL, 0x0,
            "Length of the Naming Authority List", HFILL}
        },
-       { &hf_srvloc_srvtypereq_authlist,
+       { &hf_srvloc_srvtypereq_nameauthlist,
          { "Naming Authority List", "srvloc.srvtypereq.nameauthlist", FT_STRING, BASE_DEC, NULL, 0x0,
            "", HFILL}
        },
@@ -1294,12 +1297,20 @@ proto_register_srvloc(void)
        },
 
        /* collection of helper functions for Service Type Replies */
-       { &hf_srvloc_srvtyperply_len,
-         { "Service Length", "srvloc.srvtypereq.len", FT_UINT16, BASE_DEC, NULL, 0x0,
-           "Length of the Scope List", HFILL}
+       { &hf_srvloc_srvtyperply_srvtypelen,
+         { "Service Type Length", "srvloc.srvtypereq.srvtypelen", FT_UINT16, BASE_DEC, NULL, 0x0,
+           "Length of the Service Type", HFILL}
+       },
+       { &hf_srvloc_srvtyperply_srvtype,
+         { "Service Type", "srvloc.srvtyperply.srvtype", FT_STRING, BASE_DEC, NULL, 0x0,
+           "", HFILL}
+       },
+       { &hf_srvloc_srvtyperply_srvtypelistlen,
+         { "Service Type List Length", "srvloc.srvtypereq.srvtypelistlen", FT_UINT16, BASE_DEC, NULL, 0x0,
+           "Length of the Service Type List", HFILL}
        },
-       { &hf_srvloc_srvtyperply_type,
-         { "Service", "srvloc.srvtyperply.type", FT_STRING, BASE_DEC, NULL, 0x0,
+       { &hf_srvloc_srvtyperply_srvtypelist,
+         { "Service Type List", "srvloc.srvtyperply.srvtypelist", FT_STRING, BASE_DEC, NULL, 0x0,
            "", HFILL}
        },