Ethereal-dev: Re: [ethereal-dev] LAPB/X.25 patch

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

From: Olivier Abad <abad@xxxxxxxxxxxxx>
Date: Tue, 3 Aug 1999 12:05:34 +0200
On Mon, Aug 02, 1999 at 11:26:40PM -0700, Guy Harris wrote:
> Here's a patch to the current CVS tree, which adds "xdlc.c and
> "xdlc.h" files; "xdlc.c" defines a routine "dissect_xdlc_control()" to
> dissect the control field of a frame in an SDLC-derived protocol
> (although there may be some places where the processing has to be
> protocol-dependent). 
> 
> I modified "packet-llc.c" and "packet-lapb.c" to use it; it creates a
> subtree for the control field, giving a bitfield decode if you open up
> the subtree.  It *should* handle both basic and extended mode - its
> caller passes in an argument to specify which mode it is (although I
> guess they should pass in a pointer to that flag, and it should set
> that flag if it sees one of the Set XXX Mode Extended commands;
> there'd still be a need to set it from outside, though, as you might
> not have that command in the capture).
> 
> Olivier, feel free to change it; the only frames I deal with that have
> SDLC-derived protocols in them are FDDI and 802.3 frames, and I'm not
> sure I've seen any one other than a Boring Old Unnumbered Information
> field.  I'm not checking it in, so that people can review it first (so
> if you want changes, tell me what you want changed, or send in a patch
> to do the change).

Here is a small patch against your modified tree. It seems to work well
for me, but my captures only contain Receive Ready and Information
frames (I included shifting in decode_numeric_bitfield ; you may want to
remove it...).

diff -uNr ethereal.xdlc2/packet-lapb.c ethereal.xdlc/packet-lapb.c
--- ethereal.xdlc2/packet-lapb.c	Tue Aug  3 11:07:15 1999
+++ ethereal.xdlc/packet-lapb.c	Tue Aug  3 10:57:42 1999
@@ -82,7 +82,7 @@
     else
         lapb_tree = NULL;
     dissect_xdlc_control(pd, 1, fd, lapb_tree, hf_lapb_control,
-	    is_response, FALSE);
+	    FALSE, is_response);
 
     /* not end of frame ==> X.25 */
     if (fd->cap_len > 2) dissect_x25(pd, 2, fd, tree);
diff -uNr ethereal.xdlc2/packet.c ethereal.xdlc/packet.c
--- ethereal.xdlc2/packet.c	Tue Aug  3 11:07:19 1999
+++ ethereal.xdlc/packet.c	Tue Aug  3 09:59:27 1999
@@ -530,12 +530,9 @@
 {
   static char buf[1025];
   char *p;
-  int shift=0;
-
-  while ((mask & (1<<shift)) == 0) shift++;
 
   p = decode_bitfield_value(buf, val, mask, width);
-  sprintf(p, fmt, (val & mask) >> shift);
+  sprintf(p, fmt, val & mask);
   return buf;
 }
 
diff -uNr ethereal.xdlc2/xdlc.c ethereal.xdlc/xdlc.c
--- ethereal.xdlc2/xdlc.c	Tue Aug  3 11:07:28 1999
+++ ethereal.xdlc/xdlc.c	Tue Aug  3 10:57:42 1999
@@ -183,15 +183,15 @@
 	    break;
 	}
 	if (is_extended) {
-	    sprintf(info, "S%s, %sN(R) = %u", frame_type,
+	    sprintf(info, "S%s, func = %s, N(R) = %u", frame_type,
 		 	((control & XDLC_P_F_EXT) ?
-		 	    (is_response ? "func = F, " : "func = P, ") :
+		 	    (is_response ? " F" : " P") :
 		 	    ""),
 			(control & XDLC_N_R_EXT_MASK) >> XDLC_N_R_EXT_SHIFT);
 	} else {
-	    sprintf(info, "S%s, %sN(R) = %u", frame_type,
+	    sprintf(info, "S%s, func = %s, N(R) = %u", frame_type,
 		 	((control & XDLC_P_F) ?
-		 	    (is_response ? "func = F, " : "func = P, ") :
+		 	    (is_response ? " F" : " P") :
 		 	    ""),
 			(control & XDLC_N_R_MASK) >> XDLC_N_R_SHIFT);
 	}



-- 
The number of arguments is unimportant unless some of them are correct.
		-- Ralph Hartley