Ethereal-dev: [Ethereal-dev] patch for packet-bacnet.c

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Herbert Lischka <Herbert@xxxxxxxxxxxxxxxxx>
Date: Wed, 12 May 2004 20:48:42 +0200
Hi list,

made some minor changes to packet-bacnet.c just to give packet-bacapp.c
the chance to display the info field correctly

if (!tree) calculate offset to start with apdu at the end of npdu

best regards
Herbert
-- 
Herbert Lischka
Berlin
Homepage: www.lischka-berlin.de
EMail: Herbert[at]lischka-berlin.de

Index: packet-bacnet.c
===================================================================
RCS file: /cvsroot/ethereal/packet-bacnet.c,v
retrieving revision 1.17
diff -u -r1.17 packet-bacnet.c
--- packet-bacnet.c	25 Jan 2003 00:06:12 -0000	1.17
+++ packet-bacnet.c	12 May 2004 18:41:25 -0000
@@ -1,6 +1,7 @@
 /* packet-bacnet.c
  * Routines for BACnet (NPDU) dissection
  * Copyright 2001, Hartmut Mueller <hartmut@xxxxxxxxxxxx>, FH Dortmund
+ * modified 2004, Herbert Lischka <herbert@xxxxxxxxxxxxxxxxx>
  *
  * $Id: packet-bacnet.c,v 1.17 2003/01/25 00:06:12 guy Exp $
  *
@@ -204,6 +205,72 @@
 	bacnet_pinfolen =0;
 	i = 0;
 	j = 0;
+	
+	if (!tree) {
+		offset += 2;
+		if (bacnet_control & BAC_CONTROL_DEST) { /* DNET, DLEN, DADR */
+			offset += 2;
+			bacnet_dlen = tvb_get_guint8(tvb, offset);
+			/* DLEN = 0 is broadcast on dest.network */
+			offset += bacnet_dlen + 1;
+		}
+		if (bacnet_control & BAC_CONTROL_SRC) { /* SNET, SLEN, SADR */
+			/* SNET */
+			offset += 2;
+			bacnet_slen = tvb_get_guint8(tvb, offset);
+			offset += bacnet_slen + 1;
+		}
+		if (bacnet_control & BAC_CONTROL_DEST) { /* Hopcount */
+			offset ++;
+		}
+		/* Network Layer Message Type */
+		if (bacnet_control & BAC_CONTROL_NET) {
+			bacnet_mesgtyp =  tvb_get_guint8(tvb, offset);
+			offset ++;
+		}
+		/* Vendor ID */
+		if ((bacnet_mesgtyp > 0x7f) && (bacnet_control == BAC_CONTROL_NET)) {
+			offset += 2;
+			/* attention: does work here because of if(!tree) */
+			call_dissector(data_handle,
+			    tvb_new_subset(tvb, offset, -1, -1), pinfo, tree);
+		}
+		/* Performance Index (in I-Could-Be-Router-To-Network) */
+		if (bacnet_mesgtyp == BAC_NET_ICB_R) {
+			offset ++;
+		}
+		/* Reason, DNET (in Reject-Message-To-Network) */
+		if (bacnet_mesgtyp == BAC_NET_REJ) {
+			bacnet_rejectreason = tvb_get_guint8(tvb, offset);
+			offset += 3;
+		}
+		/* N*DNET (in Router-Busy-To-Network,Router-Available-To-Network) */
+		if ((bacnet_mesgtyp == BAC_NET_R_BUSY) ||
+		(bacnet_mesgtyp == BAC_NET_R_AVA) || (bacnet_mesgtyp == BAC_NET_IAM_R) ) {
+		    while(tvb_reported_length_remaining(tvb, offset) > 1 ) {
+			offset += 2;
+		    }
+		}
+		/* Initialize-Routing-Table */
+		if ( (bacnet_mesgtyp == BAC_NET_INIT_RTAB) ||
+		    (bacnet_mesgtyp == BAC_NET_INIT_RTAB_ACK) ) {
+		    bacnet_rportnum = tvb_get_guint8(tvb, offset);
+		    /* number of ports */
+		    offset ++;
+		    for(i=0; i>bacnet_rportnum; i++) {
+		    	/* Connected DNET */
+		    	offset += 3;
+		    	/* Port Info Length */
+			bacnet_pinfolen = tvb_get_guint8(tvb, offset);
+		    	offset ++;
+			for(j=0; j>bacnet_pinfolen; j++){
+		    	    /* Port Info */
+		    	    offset ++;
+			}
+		    }
+
+		}
+	}
 
 	if (tree) {