For proto_tree_add_item(..., proto_xxx, ...)use ENC_NA as the encoding arg.
[obnox/wireshark/wip.git] / epan / dissectors / packet-bacnet.c
index 63fb759f92c829900739025b778e69f3b1951de9..3ca710f537931854a52253e61a7d21d45a5c70ae 100644 (file)
@@ -30,8 +30,6 @@
 # include "config.h"
 #endif
 
-#include <stdlib.h>
-
 #include <glib.h>
 
 #include <epan/packet.h>
@@ -185,7 +183,6 @@ dissect_bacnet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        guint8 bacnet_rportnum;
        guint8 bacnet_pinfolen;
        guint8 i;
-       guint8 j;
        tvbuff_t *next_tvb;
 
        col_set_str(pinfo->cinfo, COL_PROTOCOL, "BACnet-NPDU");
@@ -202,10 +199,9 @@ dissect_bacnet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        bacnet_rportnum = 0;
        bacnet_pinfolen =0;
        i = 0;
-       j = 0;
 
        /* I don't know the length of the NPDU yet; Setting the length after dissection */
-       ti = proto_tree_add_item(tree, proto_bacnet, tvb, 0, -1, FALSE);
+       ti = proto_tree_add_item(tree, proto_bacnet, tvb, 0, -1, ENC_NA);
 
        bacnet_tree = proto_item_add_subtree(ti, ett_bacnet);
 
@@ -236,7 +232,7 @@ dissect_bacnet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        offset ++;
        if (bacnet_control & BAC_CONTROL_DEST) { /* DNET, DLEN, DADR */
                proto_tree_add_item(bacnet_tree, hf_bacnet_dnet,
-                       tvb, offset, 2, FALSE);
+                       tvb, offset, 2, ENC_BIG_ENDIAN);
                offset += 2;
                bacnet_dlen = tvb_get_guint8(tvb, offset);
                /* DLEN = 0 is broadcast on dest.network */
@@ -255,7 +251,7 @@ dissect_bacnet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                        /* Ethernet MAC */
                        proto_tree_add_item(bacnet_tree,
                                hf_bacnet_dadr_eth, tvb, offset,
-                               bacnet_dlen, FALSE);
+                               bacnet_dlen, ENC_NA);
                        offset += bacnet_dlen;
                } else if (bacnet_dlen==1) {
                        proto_tree_add_uint(bacnet_tree, hf_bacnet_dlen,
@@ -264,7 +260,7 @@ dissect_bacnet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                        /* MS/TP or ARCNET MAC */
                        proto_tree_add_item(bacnet_tree,
                                hf_bacnet_dadr_mstp, tvb, offset,
-                               bacnet_dlen, FALSE);
+                               bacnet_dlen, ENC_BIG_ENDIAN);
                        offset += bacnet_dlen;
                } else if (bacnet_dlen<7) {
                        proto_tree_add_uint(bacnet_tree, hf_bacnet_dlen,
@@ -273,7 +269,7 @@ dissect_bacnet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                        /* Other MAC formats should be included here */
                        proto_tree_add_item(bacnet_tree,
                                hf_bacnet_dadr_tmp, tvb, offset,
-                               bacnet_dlen, FALSE);
+                               bacnet_dlen, ENC_NA);
                        offset += bacnet_dlen;
                } else {
                        proto_tree_add_uint_format_value(bacnet_tree,
@@ -302,7 +298,7 @@ dissect_bacnet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                        /* Ethernet MAC */
                        proto_tree_add_item(bacnet_tree,
                                hf_bacnet_sadr_eth, tvb, offset,
-                               bacnet_slen, FALSE);
+                               bacnet_slen, ENC_NA);
                        offset += bacnet_slen;
                } else if (bacnet_slen==1) {
                        /* SLEN */
@@ -312,7 +308,7 @@ dissect_bacnet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                        /* MS/TP or ARCNET MAC */
                        proto_tree_add_item(bacnet_tree,
                                hf_bacnet_sadr_mstp, tvb, offset,
-                               bacnet_slen, FALSE);
+                               bacnet_slen, ENC_BIG_ENDIAN);
                        offset += bacnet_slen;
                } else if (bacnet_slen<6) { /* LON MAC */
                        /* SLEN */
@@ -322,7 +318,7 @@ dissect_bacnet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                        /* Other MAC formats should be included here */
                        proto_tree_add_item(bacnet_tree,
                                hf_bacnet_sadr_tmp, tvb, offset,
-                               bacnet_slen, FALSE);
+                               bacnet_slen, ENC_NA);
                        offset += bacnet_slen;
                } else {
                        proto_tree_add_uint_format_value(bacnet_tree,
@@ -334,7 +330,7 @@ dissect_bacnet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        }
        if (bacnet_control & BAC_CONTROL_DEST) { /* Hopcount */
                proto_tree_add_item(bacnet_tree, hf_bacnet_hopc,
-                       tvb, offset, 1, FALSE);
+                       tvb, offset, 1, ENC_BIG_ENDIAN);
                offset ++;
        }
        /* Network Layer Message Type */
@@ -357,7 +353,7 @@ dissect_bacnet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                */
                if (bacnet_mesgtyp > 0x7f) {
                        proto_tree_add_item(bacnet_tree, hf_bacnet_vendor,
-                               tvb, offset, 2, FALSE);
+                               tvb, offset, 2, ENC_BIG_ENDIAN);
                        offset += 2;
                        call_dissector(data_handle,
                                tvb_new_subset_remaining(tvb, offset), pinfo, tree);
@@ -365,10 +361,10 @@ dissect_bacnet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                /* Performance Index (in I-Could-Be-Router-To-Network) */
                if (bacnet_mesgtyp == BAC_NET_ICB_R) {
                        proto_tree_add_item(bacnet_tree, hf_bacnet_dnet,
-                               tvb, offset, 2, FALSE);
+                               tvb, offset, 2, ENC_BIG_ENDIAN);
                        offset += 2;
                        proto_tree_add_item(bacnet_tree, hf_bacnet_perf,
-                               tvb, offset, 1, FALSE);
+                               tvb, offset, 1, ENC_BIG_ENDIAN);
                        offset ++;
                }
                /* Reason, DNET (in Reject-Message-To-Network) */
@@ -382,7 +378,7 @@ dissect_bacnet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                                bacnet_rejectreason_name(bacnet_rejectreason));
                        offset ++;
                        proto_tree_add_item(bacnet_tree, hf_bacnet_dnet,
-                               tvb, offset, 2, FALSE);
+                               tvb, offset, 2, ENC_BIG_ENDIAN);
                        offset += 2;
                }
                /* N*DNET (in Router-Busy-To-Network,Router-Available-To-Network) */
@@ -392,7 +388,7 @@ dissect_bacnet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                        (bacnet_mesgtyp == BAC_NET_IAM_R) ) {
                        while(tvb_reported_length_remaining(tvb, offset) > 1 ) {
                                proto_tree_add_item(bacnet_tree, hf_bacnet_dnet,
-                                       tvb, offset, 2, FALSE);
+                                       tvb, offset, 2, ENC_BIG_ENDIAN);
                                offset += 2;
                        }
                }
@@ -407,11 +403,11 @@ dissect_bacnet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                        for(i=0; i<bacnet_rportnum; i++) {
                                        /* Connected DNET */
                                        proto_tree_add_item(bacnet_tree, hf_bacnet_dnet,
-                                       tvb, offset, 2, FALSE);
+                                       tvb, offset, 2, ENC_BIG_ENDIAN);
                                        offset += 2;
                                        /* Port ID */
                                        proto_tree_add_item(bacnet_tree, hf_bacnet_portid,
-                                       tvb, offset, 1, FALSE);
+                                       tvb, offset, 1, ENC_BIG_ENDIAN);
                                        offset ++;
                                        /* Port Info Length */
                                        bacnet_pinfolen = tvb_get_guint8(tvb, offset);
@@ -427,16 +423,16 @@ dissect_bacnet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                /* Establish-Connection-To-Network */
                if (bacnet_mesgtyp == BAC_NET_EST_CON) {
                        proto_tree_add_item(bacnet_tree, hf_bacnet_dnet,
-                               tvb, offset, 2, FALSE);
+                               tvb, offset, 2, ENC_BIG_ENDIAN);
                        offset += 2;
                        proto_tree_add_item(bacnet_tree, hf_bacnet_term_time_value,
-                               tvb, offset, 1, FALSE);
+                               tvb, offset, 1, ENC_BIG_ENDIAN);
                        offset ++;
                }
                /* Disconnect-Connection-To-Network */
                if (bacnet_mesgtyp == BAC_NET_DISC_CON) {
                        proto_tree_add_item(bacnet_tree, hf_bacnet_dnet,
-                               tvb, offset, 2, FALSE);
+                               tvb, offset, 2, ENC_BIG_ENDIAN);
                        offset += 2;
                }
        }
@@ -633,11 +629,11 @@ proto_reg_handoff_bacnet(void)
        dissector_handle_t bacnet_handle;
 
        bacnet_handle = find_dissector("bacnet");
-       dissector_add("bvlc.function", 0x04, bacnet_handle);
-       dissector_add("bvlc.function", 0x09, bacnet_handle);
-       dissector_add("bvlc.function", 0x0a, bacnet_handle);
-       dissector_add("bvlc.function", 0x0b, bacnet_handle);
-       dissector_add("llc.dsap", SAP_BACNET, bacnet_handle);
+       dissector_add_uint("bvlc.function", 0x04, bacnet_handle);
+       dissector_add_uint("bvlc.function", 0x09, bacnet_handle);
+       dissector_add_uint("bvlc.function", 0x0a, bacnet_handle);
+       dissector_add_uint("bvlc.function", 0x0b, bacnet_handle);
+       dissector_add_uint("llc.dsap", SAP_BACNET, bacnet_handle);
        bacapp_handle = find_dissector("bacapp");
        data_handle = find_dissector("data");
 }