Don't guard col_set_str (COL_INFO/COL_PROTOCOL) with col_check
[obnox/wireshark/wip.git] / epan / dissectors / packet-acn.c
index a6461adbc5bf91a6d5f2ca90874fbf521f080a1a..ae9f179205ca7551d5de021e848e05b22bcecf99 100644 (file)
@@ -47,7 +47,6 @@
 
 #include <epan/packet.h>
 #include <epan/prefs.h>
-#include <epan/emem.h>
 #include <epan/packet.h>
 #include <epan/ipv6-utils.h>
 #include <string.h>
@@ -479,7 +478,7 @@ acn_add_address(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int off
     break;
   case ACN_ADDR_IPV4:
     /* Build tree and add type*/
-    pi = proto_tree_add_text(tree, tvb, offset, 7, label);
+    pi = proto_tree_add_text(tree, tvb, offset, 7, "%s", label);
     addr_tree = proto_item_add_subtree(pi, ett_acn_address);
     proto_tree_add_item(addr_tree, hf_acn_ip_address_type, tvb, offset, 1, FALSE);
     offset +=1;
@@ -497,7 +496,7 @@ acn_add_address(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int off
     break;
   case ACN_ADDR_IPV6:
     /* Build tree and add type*/
-    pi = proto_tree_add_text(tree, tvb, offset, 19, label);
+    pi = proto_tree_add_text(tree, tvb, offset, 19, "%s", label);
     addr_tree = proto_item_add_subtree(pi, ett_acn_address);
     proto_tree_add_item(addr_tree, hf_acn_ip_address_type, tvb, offset, 1, FALSE);
     offset +=1;
@@ -515,7 +514,7 @@ acn_add_address(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int off
     break;
   case ACN_ADDR_IPPORT:
     /* Build tree and add type*/
-    pi = proto_tree_add_text(tree, tvb, offset, 3, label);
+    pi = proto_tree_add_text(tree, tvb, offset, 3, "%s", label);
     addr_tree = proto_item_add_subtree(pi, ett_acn_address);
     proto_tree_add_item(addr_tree, hf_acn_ip_address_type, tvb, offset, 1, FALSE);
     offset +=1;
@@ -806,25 +805,26 @@ acn_add_dmp_data(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int of
           g_snprintf(buffer, BUFFER_SIZE, "Addr 0x%8.8X ->", data_address);
           break;
         default: /* and ACN_DMP_ADT_A_R, this reserved....so it has no meaning yet */
+          offset += data_size;
           return offset;
       }
 
       switch (data_size) {
         case 1:
           data_value = tvb_get_guint8(tvb, offset);
-          proto_tree_add_int_format(tree, hf_acn_data8, tvb, offset, 1, data_value, "%s %2.2X", buffer, data_value);
+          proto_tree_add_uint_format(tree, hf_acn_data8, tvb, offset, 1, data_value, "%s %2.2X", buffer, data_value);
           break;
         case 2:
           data_value = tvb_get_ntohs(tvb, offset);
-          proto_tree_add_int_format(tree, hf_acn_data16, tvb, offset, 2, data_value, "%s %4.4X", buffer, data_value);
+          proto_tree_add_uint_format(tree, hf_acn_data16, tvb, offset, 2, data_value, "%s %4.4X", buffer, data_value);
           break;
         case 3:
           data_value = tvb_get_ntoh24(tvb, offset);
-          proto_tree_add_int_format(tree, hf_acn_data24, tvb, offset, 3, data_value, "%s %6.6X", buffer, data_value);
+          proto_tree_add_uint_format(tree, hf_acn_data24, tvb, offset, 3, data_value, "%s %6.6X", buffer, data_value);
           break;
         case 4:
           data_value = tvb_get_ntohl(tvb, offset);
-          proto_tree_add_int_format(tree, hf_acn_data32, tvb, offset, 4, data_value, "%s %8.8X", buffer, data_value);
+          proto_tree_add_uint_format(tree, hf_acn_data32, tvb, offset, 4, data_value, "%s %8.8X", buffer, data_value);
           break;
         default:
           /* build string of values */
@@ -865,19 +865,19 @@ acn_add_dmp_data(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int of
         switch (data_size) {
           case 1:
             data_value = tvb_get_guint8(tvb, offset);
-            proto_tree_add_int_format(tree, hf_acn_data8, tvb, offset, 1, data_value, "%s %2.2X", buffer, data_value);
+            proto_tree_add_uint_format(tree, hf_acn_data8, tvb, offset, 1, data_value, "%s %2.2X", buffer, data_value);
             break;
           case 2:
             data_value = tvb_get_ntohs(tvb, offset);
-            proto_tree_add_int_format(tree, hf_acn_data8, tvb, offset, 2, data_value, "%s %4.4X", buffer, data_value);
+            proto_tree_add_uint_format(tree, hf_acn_data8, tvb, offset, 2, data_value, "%s %4.4X", buffer, data_value);
             break;
           case 3:
             data_value = tvb_get_ntoh24(tvb, offset);
-            proto_tree_add_int_format(tree, hf_acn_data8, tvb, offset, 3, data_value, "%s %6.6X", buffer, data_value);
+            proto_tree_add_uint_format(tree, hf_acn_data8, tvb, offset, 3, data_value, "%s %6.6X", buffer, data_value);
             break;
           case 4:
             data_value = tvb_get_ntohl(tvb, offset);
-            proto_tree_add_int_format(tree, hf_acn_data8, tvb, offset, 4, data_value, "%s %8.8X", buffer, data_value);
+            proto_tree_add_uint_format(tree, hf_acn_data8, tvb, offset, 4, data_value, "%s %8.8X", buffer, data_value);
             break;
           default:
             /* build string of values */
@@ -919,19 +919,19 @@ acn_add_dmp_data(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int of
         switch (data_size) {
           case 1:
             data_value = tvb_get_guint8(tvb, offset);
-            proto_tree_add_int_format(tree, hf_acn_data8, tvb, offset, 1, data_value, "%s %2.2X", buffer, data_value);
+            proto_tree_add_uint_format(tree, hf_acn_data8, tvb, offset, 1, data_value, "%s %2.2X", buffer, data_value);
             break;
           case 2:
             data_value = tvb_get_ntohs(tvb, offset);
-            proto_tree_add_int_format(tree, hf_acn_data8, tvb, offset, 2, data_value, "%s %4.4X", buffer, data_value);
+            proto_tree_add_uint_format(tree, hf_acn_data8, tvb, offset, 2, data_value, "%s %4.4X", buffer, data_value);
             break;
           case 3:
             data_value = tvb_get_ntoh24(tvb, offset);
-            proto_tree_add_int_format(tree, hf_acn_data8, tvb, offset, 3, data_value, "%s %6.6X", buffer, data_value);
+            proto_tree_add_uint_format(tree, hf_acn_data8, tvb, offset, 3, data_value, "%s %6.6X", buffer, data_value);
             break;
           case 4:
             data_value = tvb_get_ntohl(tvb, offset);
-            proto_tree_add_int_format(tree, hf_acn_data8, tvb, offset, 4, data_value, "%s %8.8X", buffer, data_value);
+            proto_tree_add_uint_format(tree, hf_acn_data8, tvb, offset, 4, data_value, "%s %8.8X", buffer, data_value);
             break;
           default:
             /* build string of values */
@@ -1005,7 +1005,7 @@ acn_add_dmp_reason_codes(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree
       /* convert to string */
       name = val_to_str(data_value, acn_dmp_reason_code_vals, "reason not valid (%d)");
       /* Add item */
-      proto_tree_add_int_format(tree, hf_acn_data8, tvb, offset, 1, data_value, "%s %s", buffer, name);
+      proto_tree_add_uint_format(tree, hf_acn_data8, tvb, offset, 1, data_value, "%s %s", buffer, name);
       offset++;
       break;
 
@@ -1031,7 +1031,7 @@ acn_add_dmp_reason_codes(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree
         /* convert to string */
         name = val_to_str(data_value, acn_dmp_reason_code_vals, "reason not valid (%d)");
         /* Add item */
-        proto_tree_add_int_format(tree, hf_acn_data8, tvb, offset, 1, data_value, "%s %s", buffer, name);
+        proto_tree_add_uint_format(tree, hf_acn_data8, tvb, offset, 1, data_value, "%s %s", buffer, name);
 
         data_address += adt->increment;
       } /* of (x=0;x<adt->count;x++) */
@@ -1060,7 +1060,7 @@ acn_add_dmp_reason_codes(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree
         /* convert to string */
         name = val_to_str(data_value, acn_dmp_reason_code_vals, "reason not valid (%d)");
         /* Add item */
-        proto_tree_add_int_format(tree, hf_acn_data8, tvb, offset, 1, data_value, "%s %s", buffer, name);
+        proto_tree_add_uint_format(tree, hf_acn_data8, tvb, offset, 1, data_value, "%s %s", buffer, name);
         data_address += adt->increment;
         offset++;
       } /* of (x=0;x<adt->count;x++) */
@@ -1162,7 +1162,7 @@ dissect_acn_dmp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int off
   /* Add Vector item to tree*/
   name = val_to_str(vector, acn_dmp_vector_vals, "not valid (%d)");
   proto_item_append_text(ti, ": ");
-  proto_item_append_text(ti, name);
+  proto_item_append_text(ti, "%s", name);
 
   /* Set header offset */
   if (pdu_flags & ACN_PDU_FLAG_H) {
@@ -1470,7 +1470,7 @@ dissect_acn_sdt_wrapped_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree
   /* Add Vector item to tree*/
   name = val_to_str(vector, acn_sdt_vector_vals, "not valid (%d)");
   proto_item_append_text(ti, ": ");
-  proto_item_append_text(ti, name);
+  proto_item_append_text(ti, "%s", name);
 
   /* NO HEADER DATA ON THESE* (at least so far) */
 
@@ -1645,7 +1645,7 @@ dissect_acn_sdt_client_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
   /* Add protocol to tree*/
   name = val_to_str(protocol_id, acn_protocol_id_vals, "id not valid (%d)");
   proto_item_append_text(ti, ": ");
-  proto_item_append_text(ti, name);
+  proto_item_append_text(ti, "%s", name);
 
   /* add association item */
   association = tvb_get_ntohs(tvb, header_offset);
@@ -1686,21 +1686,6 @@ dissect_acn_sdt_client_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
 }
 
 
-/******************************************************************************/
-/* reverses the characters in a string */
-static void
-reverse(char *s)
-{
-       char c;
-  long i,j;
-  for (i=0, j=strlen(s)-1; i < j; i++, j--) {
-    c = s[i];
-    s[i] = s[j];
-    s[j] = c;
-  }
-}
-
-
 /******************************************************************************/
 /* level to string (ascii)                                                    */
 /*  level    : 8 bit value                                                    */
@@ -1745,7 +1730,7 @@ ltos(guint8 level, gchar *string, guint8 base, gchar leading_char, guint8 min_ch
   string[i] = '\0';
 
   /* now reverse (and correct) the order */
-  reverse(string);
+  g_strreverse(string);
 
   /* add a space at the end (ok its at the start but it will be at the end)*/
   string[i++] = ' ';
@@ -1860,7 +1845,7 @@ dissect_acn_dmx_data_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, in
   /* Add Vector item to tree*/
   name = val_to_str(vector, acn_dmp_vector_vals, "not valid (%d)");
   proto_item_append_text(ti, ": ");
-  proto_item_append_text(ti, name);
+  proto_item_append_text(ti, "%s", name);
 
   /* Set header offset */
   if (pdu_flags & ACN_PDU_FLAG_H) {
@@ -1958,7 +1943,7 @@ dissect_acn_dmx_data_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, in
         }
       }
       *buf_ptr = '\0';
-      proto_tree_add_text(pdu_tree, tvb, data_offset, dmx_count, buffer);
+      proto_tree_add_text(pdu_tree, tvb, data_offset, dmx_count, "%s", buffer);
 
       /* start our line */
       g_snprintf(buffer, BUFFER_SIZE, "001-%03d: ", perline);
@@ -1981,7 +1966,7 @@ dissect_acn_dmx_data_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, in
 
         if (item_cnt == perline || x == (end_offset-1)) {
           /* add leader... */
-          proto_tree_add_text(pdu_tree, tvb, data_offset, item_cnt, buffer);
+          proto_tree_add_text(pdu_tree, tvb, data_offset, item_cnt, "%s", buffer);
           data_offset += perline;
           g_snprintf(buffer, BUFFER_SIZE, "%03d-%03d: ",total_cnt, total_cnt+perline);
           buf_ptr = buffer + 9;
@@ -2242,7 +2227,7 @@ dissect_acn_sdt_base_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, in
   /* Add Vector item to tree*/
   name = val_to_str(vector, acn_sdt_vector_vals, "not valid (%d)");
   proto_item_append_text(ti, ": ");
-  proto_item_append_text(ti, name);
+  proto_item_append_text(ti, "%s", name);
 
   /* NO HEADER DATA ON THESE* (at least so far) */
 
@@ -2602,9 +2587,7 @@ dissect_acn(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 /*   }                   */
 
   /* Set the protocol column */
-  if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
-    col_set_str(pinfo->cinfo, COL_PROTOCOL, "ACN");
-  }
+  col_set_str(pinfo->cinfo, COL_PROTOCOL, "ACN");
 
   /* Clear out stuff in the info column */
   if(check_col(pinfo->cinfo,COL_INFO)){
@@ -2678,7 +2661,7 @@ void proto_register_acn(void)
     /* DMP data */
     { &hf_acn_data,
       { "Data", "acn.dmp_data",
-        FT_BYTES, BASE_HEX, NULL, 0x0,
+        FT_BYTES, BASE_NONE, NULL, 0x0,
         NULL, HFILL }
     },
     { &hf_acn_data8,
@@ -2704,7 +2687,7 @@ void proto_register_acn(void)
 
     { &hf_acn_dmp_address_data_pairs,
       { "Address-Data Pairs", "acn.dmp_address_data_pairs",
-        FT_BYTES, BASE_DEC, NULL, 0x0,
+        FT_BYTES, BASE_NONE, NULL, 0x0,
         "More address-data pairs", HFILL }
     },
 
@@ -3040,14 +3023,12 @@ void proto_register_acn(void)
   };
 
   module_t *acn_module;
-  if (proto_acn == -1) {
-    proto_acn = proto_register_protocol (
-      "Architecture for Control Networks", /* name */
-      "ACN",                               /* short name */
-      "acn"                                /* abbrev */
-      );
-  }
-
+  proto_acn = proto_register_protocol (
+    "Architecture for Control Networks", /* name */
+    "ACN",                               /* short name */
+    "acn"                                /* abbrev */
+    );
+  
   proto_register_field_array(proto_acn, hf, array_length(hf));
   proto_register_subtree_array(ett, array_length(ett));