Get rid of check_col() in some of the more frequently used dissectors.
authoretxrab <etxrab@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 22 Jul 2009 21:33:47 +0000 (21:33 +0000)
committeretxrab <etxrab@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 22 Jul 2009 21:33:47 +0000 (21:33 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@29170 f5534014-38df-0310-8fa8-9805f1628bb7

epan/dissectors/packet-eth.c
epan/dissectors/packet-frame.c
epan/dissectors/packet-ip.c
epan/dissectors/packet-udp.c

index d3afa4498b7340352f0b4a13b3f62b1cf46d3598..f1c44dbc54a6ad5b2f4ddb87c8cf864abb7c51fb 100644 (file)
@@ -204,8 +204,7 @@ dissect_eth_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
 
   tree=parent_tree;
 
-  if (check_col(pinfo->cinfo, COL_PROTOCOL))
-    col_set_str(pinfo->cinfo, COL_PROTOCOL, "Ethernet");
+  col_set_str(pinfo->cinfo, COL_PROTOCOL, "Ethernet");
 
   src_addr=tvb_get_ptr(tvb, 6, 6);
   SET_ADDRESS(&pinfo->dl_src,  AT_ETHER, 6, src_addr);
@@ -265,10 +264,8 @@ dissect_eth_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
 
     is_802_2 = check_is_802_2(tvb);
 
-    if (check_col(pinfo->cinfo, COL_INFO)) {
-      col_add_fstr(pinfo->cinfo, COL_INFO, "IEEE 802.3 Ethernet %s",
+     col_add_fstr(pinfo->cinfo, COL_INFO, "IEEE 802.3 Ethernet %s",
                (is_802_2 ? "" : "Raw "));
-    }
     if (tree) {
       ti = proto_tree_add_protocol_format(tree, proto_eth, tvb, 0, ETH_HEADER_SIZE,
                "IEEE 802.3 Ethernet %s", (is_802_2 ? "" : "Raw "));
@@ -312,8 +309,7 @@ dissect_eth_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
        }
     }
 
-    if (check_col(pinfo->cinfo, COL_INFO)) 
-      col_set_str(pinfo->cinfo, COL_INFO, "Ethernet II");
+    col_set_str(pinfo->cinfo, COL_INFO, "Ethernet II");
     if (parent_tree) {
       if (PTREE_DATA(parent_tree)->visible) {
           ti = proto_tree_add_protocol_format(parent_tree, proto_eth, tvb, 0, ETH_HEADER_SIZE,
index 3a8d617d5ef713f0d275c97303387bfab9807214..f7cf10729517c99478a77b7ea2a9082cc5433787 100644 (file)
@@ -328,9 +328,7 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
             if (!dissector_try_port(wtap_encap_dissector_table, pinfo->fd->lnk_t,
                 tvb, pinfo, parent_tree)) {
 
-                       if (check_col(pinfo->cinfo, COL_PROTOCOL))
                                col_set_str(pinfo->cinfo, COL_PROTOCOL, "UNKNOWN");
-                       if (check_col(pinfo->cinfo, COL_INFO))
                                col_add_fstr(pinfo->cinfo, COL_INFO, "WTAP_ENCAP = %u",
                                    pinfo->fd->lnk_t);
                        call_dissector(data_handle,tvb, pinfo, parent_tree);
@@ -440,8 +438,7 @@ show_exception(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
        switch (exception) {
 
        case ScsiBoundsError:
-               if (check_col(pinfo->cinfo, COL_INFO))
-                       col_append_str(pinfo->cinfo, COL_INFO, "[SCSI transfer limited due to allocation_length too small]");
+               col_append_str(pinfo->cinfo, COL_INFO, "[SCSI transfer limited due to allocation_length too small]");
                /*item =*/ proto_tree_add_protocol_format(tree, proto_short, tvb, 0, 0,
                                "SCSI transfer limited due to allocation_length too small: %s truncated]", pinfo->current_proto);
                /* Don't record ScsiBoundsError exceptions as expert events - they merely
@@ -451,8 +448,7 @@ show_exception(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
                break;
 
        case BoundsError:
-               if (check_col(pinfo->cinfo, COL_INFO))
-                       col_append_str(pinfo->cinfo, COL_INFO, "[Packet size limited during capture]");
+               col_append_str(pinfo->cinfo, COL_INFO, "[Packet size limited during capture]");
                /*item =*/ proto_tree_add_protocol_format(tree, proto_short, tvb, 0, 0,
                                "[Packet size limited during capture: %s truncated]", pinfo->current_proto);
                /* Don't record BoundsError exceptions as expert events - they merely
@@ -467,12 +463,11 @@ show_exception(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
                break;
 
        case DissectorError:
-               if (check_col(pinfo->cinfo, COL_INFO))
-                       col_append_fstr(pinfo->cinfo, COL_INFO,
-                           "[Dissector bug, protocol %s: %s]",
-                           pinfo->current_proto,
-                           exception_message == NULL ?
-                               dissector_error_nomsg : exception_message);
+               col_append_fstr(pinfo->cinfo, COL_INFO,
+                   "[Dissector bug, protocol %s: %s]",
+                   pinfo->current_proto,
+                   exception_message == NULL ?
+                       dissector_error_nomsg : exception_message);
                item = proto_tree_add_protocol_format(tree, proto_malformed, tvb, 0, 0,
                    "[Dissector bug, protocol %s: %s]",
                    pinfo->current_proto,
@@ -508,18 +503,16 @@ show_reported_bounds_error(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                 * problem is that the dissector expected something
                 * but it wasn't in the fragment we dissected.
                 */
-               if (check_col(pinfo->cinfo, COL_INFO))
-                       col_append_fstr(pinfo->cinfo, COL_INFO,
-                           "[Unreassembled Packet%s] ",
-                           pinfo->noreassembly_reason);
+               col_append_fstr(pinfo->cinfo, COL_INFO,
+                   "[Unreassembled Packet%s] ",
+                   pinfo->noreassembly_reason);
                item = proto_tree_add_protocol_format(tree, proto_unreassembled,
                    tvb, 0, 0, "[Unreassembled Packet%s: %s]",
                    pinfo->noreassembly_reason, pinfo->current_proto);
                expert_add_info_format(pinfo, item, PI_REASSEMBLE, PI_WARN, "Unreassembled Packet (Exception occurred)");
        } else {
-               if (check_col(pinfo->cinfo, COL_INFO))
-                       col_append_str(pinfo->cinfo, COL_INFO,
-                           "[Malformed Packet]");
+               col_append_str(pinfo->cinfo, COL_INFO,
+                   "[Malformed Packet]");
                item = proto_tree_add_protocol_format(tree, proto_malformed,
                    tvb, 0, 0, "[Malformed Packet: %s]", pinfo->current_proto);
                expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR, "Malformed Packet (Exception occurred)");
index b77d6244322dfbf459626eb9944577144eff3f4a..77e2e53309ca0d392a4102c3206e2011f341611e 100644 (file)
@@ -1283,10 +1283,8 @@ dissect_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
 
   iph=ep_alloc(sizeof(ws_ip));
 
-  if (check_col(pinfo->cinfo, COL_PROTOCOL))
-    col_set_str(pinfo->cinfo, COL_PROTOCOL, "IP");
-  if (check_col(pinfo->cinfo, COL_INFO))
-    col_clear(pinfo->cinfo, COL_INFO);
+  col_set_str(pinfo->cinfo, COL_PROTOCOL, "IP");
+  col_clear(pinfo->cinfo, COL_INFO);
 
   iph->ip_v_hl = tvb_get_guint8(tvb, offset);
   if ( hi_nibble(iph->ip_v_hl) == 6){
@@ -1313,8 +1311,7 @@ dissect_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
   }
 
   if (hlen < IPH_MIN_LEN) {
-    if (check_col(pinfo->cinfo, COL_INFO))
-      col_add_fstr(pinfo->cinfo, COL_INFO, "Bogus IP header length (%u, must be at least %u)",
+    col_add_fstr(pinfo->cinfo, COL_INFO, "Bogus IP header length (%u, must be at least %u)",
        hlen, IPH_MIN_LEN);
     if (tree) {
       proto_tree_add_uint_format(ip_tree, hf_ip_hdr_len, tvb, offset, 1, hlen,
@@ -1330,9 +1327,7 @@ dissect_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
   }
 
   iph->ip_tos = tvb_get_guint8(tvb, offset + 1);
-  if (check_col(pinfo->cinfo, COL_DSCP_VALUE)) {
-       col_add_fstr(pinfo->cinfo, COL_DSCP_VALUE, "%u", IPDSFIELD_DSCP(iph->ip_tos));
-  }
+  col_add_fstr(pinfo->cinfo, COL_DSCP_VALUE, "%u", IPDSFIELD_DSCP(iph->ip_tos));
 
   if (tree) {
     if (g_ip_dscp_actif) {
@@ -1375,8 +1370,7 @@ dissect_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
          iph->ip_len = tvb_reported_length(tvb);
 
   if (iph->ip_len < hlen) {
-    if (check_col(pinfo->cinfo, COL_INFO))
-      col_add_fstr(pinfo->cinfo, COL_INFO, "Bogus IP length (%u, less than header length %u)",
+    col_add_fstr(pinfo->cinfo, COL_INFO, "Bogus IP length (%u, less than header length %u)",
        iph->ip_len, hlen);
     if (tree) {
       proto_tree_add_uint_format(ip_tree, hf_ip_len, tvb, offset + 2, 2, iph->ip_len,
@@ -1619,16 +1613,12 @@ dissect_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
 
   if (next_tvb == NULL) {
     /* Just show this as a fragment. */
-    if (check_col(pinfo->cinfo, COL_INFO)) {
-      col_add_fstr(pinfo->cinfo, COL_INFO, "Fragmented IP protocol (proto=%s 0x%02x, off=%u, ID=%04x)",
-       ipprotostr(iph->ip_p), iph->ip_p, (iph->ip_off & IP_OFFSET) * 8,
-       iph->ip_id);
-    }
+    col_add_fstr(pinfo->cinfo, COL_INFO, "Fragmented IP protocol (proto=%s 0x%02x, off=%u, ID=%04x)",
+               ipprotostr(iph->ip_p), iph->ip_p, (iph->ip_off & IP_OFFSET) * 8,
+               iph->ip_id);
     if( ipfd_head && ipfd_head->reassembled_in != pinfo->fd->num ){
-      if (check_col(pinfo->cinfo, COL_INFO)) {
-        col_append_fstr(pinfo->cinfo, COL_INFO, " [Reassembled in #%u]",
+      col_append_fstr(pinfo->cinfo, COL_INFO, " [Reassembled in #%u]",
           ipfd_head->reassembled_in);
-      }
     }
 
     call_dissector(data_handle, tvb_new_subset(tvb, offset, -1, -1), pinfo,
@@ -1658,8 +1648,7 @@ dissect_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
   } else if (!dissector_try_port(ip_dissector_table, nxt, next_tvb, pinfo, parent_tree)) {
     /* Unknown protocol */
     if (update_col_info) {
-      if (check_col(pinfo->cinfo, COL_INFO))
-        col_add_fstr(pinfo->cinfo, COL_INFO, "%s (0x%02x)", ipprotostr(iph->ip_p), iph->ip_p);
+      col_add_fstr(pinfo->cinfo, COL_INFO, "%s (0x%02x)", ipprotostr(iph->ip_p), iph->ip_p);
     }
     call_dissector(data_handle,next_tvb, pinfo, parent_tree);
   }
index caeb000f004ac04342b259d071b0e958070fd9a7..bf483de062050cbe87b91596cc617bc469f1d4c3 100644 (file)
@@ -322,17 +322,14 @@ dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 ip_proto)
   SET_ADDRESS(&udph->ip_src, pinfo->src.type, pinfo->src.len, pinfo->src.data);
   SET_ADDRESS(&udph->ip_dst, pinfo->dst.type, pinfo->dst.len, pinfo->dst.data);
 
-  if (check_col(pinfo->cinfo, COL_PROTOCOL))
-    col_set_str(pinfo->cinfo, COL_PROTOCOL, (ip_proto == IP_PROTO_UDP) ? "UDP" : "UDPlite");
-  if (check_col(pinfo->cinfo, COL_INFO))
-    col_clear(pinfo->cinfo, COL_INFO);
+  col_set_str(pinfo->cinfo, COL_PROTOCOL, (ip_proto == IP_PROTO_UDP) ? "UDP" : "UDPlite");
+  col_clear(pinfo->cinfo, COL_INFO);
 
   udph->uh_sport=tvb_get_ntohs(tvb, offset);
   udph->uh_dport=tvb_get_ntohs(tvb, offset+2);
 
-  if (check_col(pinfo->cinfo, COL_INFO))
-    col_add_fstr(pinfo->cinfo, COL_INFO, "Source port: %s  Destination port: %s",
-           get_udp_port(udph->uh_sport), get_udp_port(udph->uh_dport));
+  col_add_fstr(pinfo->cinfo, COL_INFO, "Source port: %s  Destination port: %s",
+    get_udp_port(udph->uh_sport), get_udp_port(udph->uh_dport));
 
   if (tree) {
     if (udp_summary_in_tree) {
@@ -369,8 +366,7 @@ dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 ip_proto)
       item = proto_tree_add_uint_format(udp_tree, hf_udp_length, tvb, offset + 4, 2,
           udph->uh_ulen, "Length: %u (bogus, must be >= 8)", udph->uh_ulen);
       expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR, "Bad length value %u < 8", udph->uh_ulen);
-      if (check_col(pinfo->cinfo, COL_INFO))
-        col_append_fstr(pinfo->cinfo, COL_INFO, " [BAD UDP LENGTH %u < 8]", udph->uh_ulen);
+      col_append_fstr(pinfo->cinfo, COL_INFO, " [BAD UDP LENGTH %u < 8]", udph->uh_ulen);
       return;
     }
     if ((udph->uh_ulen > tvb_reported_length(tvb)) && ! pinfo->fragmented && ! pinfo->in_error_pkt) {
@@ -378,8 +374,7 @@ dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 ip_proto)
       item = proto_tree_add_uint_format(udp_tree, hf_udp_length, tvb, offset + 4, 2,
           udph->uh_ulen, "Length: %u (bogus, payload length %u)", udph->uh_ulen, tvb_reported_length(tvb));
       expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR, "Bad length value %u > IP payload length", udph->uh_ulen);
-      if (check_col(pinfo->cinfo, COL_INFO))
-        col_append_fstr(pinfo->cinfo, COL_INFO, " [BAD UDP LENGTH %u > IP PAYLOAD LENGTH]", udph->uh_ulen);
+      col_append_fstr(pinfo->cinfo, COL_INFO, " [BAD UDP LENGTH %u > IP PAYLOAD LENGTH]", udph->uh_ulen);
     } else {
       if (tree) {
         proto_tree_add_uint(udp_tree, hf_udp_length, tvb, offset + 4, 2, udph->uh_ulen);
@@ -405,8 +400,7 @@ dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 ip_proto)
           udph->uh_sum_cov, udph->uh_ulen);
       expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR, "Bad checksum coverage length value %u < 8 or > %u",
                              udph->uh_sum_cov, udph->uh_ulen);
-      if (check_col(pinfo->cinfo, COL_INFO))
-        col_append_fstr(pinfo->cinfo, COL_INFO, " [BAD LIGHTWEIGHT UDP CHECKSUM COVERAGE LENGTH %u < 8 or > %u]",
+      col_append_fstr(pinfo->cinfo, COL_INFO, " [BAD LIGHTWEIGHT UDP CHECKSUM COVERAGE LENGTH %u < 8 or > %u]",
                         udph->uh_sum_cov, udph->uh_ulen);
       if (!udplite_ignore_checksum_coverage)
         return;
@@ -438,8 +432,7 @@ dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 ip_proto)
       item = proto_tree_add_uint_format(udp_tree, hf_udp_checksum, tvb, offset + 6, 2, 0,
         "Checksum: 0x%04x (Illegal)", 0);
       expert_add_info_format(pinfo, item, PI_CHECKSUM, PI_ERROR, "Illegal Checksum value (0)");
-      if (check_col(pinfo->cinfo, COL_INFO))
-        col_append_fstr(pinfo->cinfo, COL_INFO, " [ILLEGAL CHECKSUM (0)]");
+      col_append_fstr(pinfo->cinfo, COL_INFO, " [ILLEGAL CHECKSUM (0)]");
 
       checksum_tree = proto_item_add_subtree(item, ett_udp_checksum);
       item = proto_tree_add_boolean(checksum_tree, hf_udp_checksum_good, tvb,
@@ -512,8 +505,7 @@ dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 ip_proto)
         PROTO_ITEM_SET_GENERATED(item);
         expert_add_info_format(pinfo, item, PI_CHECKSUM, PI_ERROR, "Bad checksum");
 
-        if (check_col(pinfo->cinfo, COL_INFO))
-          col_append_fstr(pinfo->cinfo, COL_INFO, " [UDP CHECKSUM INCORRECT]");
+        col_append_fstr(pinfo->cinfo, COL_INFO, " [UDP CHECKSUM INCORRECT]");
       }
     } else {
       item = proto_tree_add_uint_format(udp_tree, hf_udp_checksum, tvb,