Ethereal-dev: Re: [ethereal-dev] Possible bug in packet-ppp.c

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

From: Gilbert Ramirez <gram@xxxxxxxxxx>
Date: Mon, 27 Mar 2000 12:12:34 -0600
On Mon, Mar 27, 2000 at 04:49:52AM -0600, Paul Ionescu wrote:
> 
> 
> I tried to spy a PPTP connection between a linux and a W2K. (The capture
> is attached to email)
> I think that maybe there is a bug somwhere because the ppp packed is not
> dissected correctly.
> There should be a valid PPP/LCP packet, but instead is reported as
> unknown PPP.
> The same capture dissected with Microsoft Netmon 2.0 reports unknown ppp
> too, but after that it shows the LCP frame.
> 
>  - pptp.cap

I have committed the change to fix this problem. Attached is a patch against
the current CVS tree.

I changed dissect_ppp() to accept an offset. I change the GRE code to
call dissect_ppp() instead of dissect_payload_ppp().

I left the PPPoE dissector as it is, calling dissect_payload_ppp(). If someone
has some traces of PPPoE, perhaps they can fiddle with the code to see
if its better to call dissect_ppp() now that it takes an offset. The current
code is this:

        /* dissect_ppp is apparently done as a 'top level' dissector,
                * so this doesn't work:  
                * dissect_ppp(pd,offset+6,fd,tree);
                * Im gonna try fudging it.
                */

        dissect_payload_ppp(pd,offset+6,fd,tree);

--gilbert
? VRU.CAP.gz
? netmon.txt.gz
Index: packet-ascend.c
===================================================================
RCS file: /usr/local/cvsroot/ethereal/packet-ascend.c,v
retrieving revision 1.9
diff -u -r1.9 packet-ascend.c
--- packet-ascend.c	2000/02/15 21:01:58	1.9
+++ packet-ascend.c	2000/03/27 17:52:30
@@ -93,7 +93,7 @@
   switch (fd->pseudo_header.ascend.type) {
     case ASCEND_PFX_WDS_X:
     case ASCEND_PFX_WDS_R:
-      dissect_ppp(pd, fd, tree);
+      dissect_ppp(pd, 0, fd, tree);
       break;
     case ASCEND_PFX_WDD:
       dissect_eth(pd, 0, fd, tree);
Index: packet-gre.c
===================================================================
RCS file: /usr/local/cvsroot/ethereal/packet-gre.c,v
retrieving revision 1.16
diff -u -r1.16 packet-gre.c
--- packet-gre.c	2000/03/12 04:47:38	1.16
+++ packet-gre.c	2000/03/27 17:52:30
@@ -202,7 +202,7 @@
 
     switch (type) {
       case GRE_PPP:
-        dissect_payload_ppp(pd, offset, fd, tree);
+        dissect_ppp(pd, offset, fd, tree);
  	break;
       case GRE_IP:
         dissect_ip(pd, offset, fd, tree);
Index: packet-null.c
===================================================================
RCS file: /usr/local/cvsroot/ethereal/packet-null.c,v
retrieving revision 1.19
diff -u -r1.19 packet-null.c
--- packet-null.c	2000/02/15 21:02:44	1.19
+++ packet-null.c	2000/03/27 17:52:30
@@ -232,7 +232,7 @@
     /*
      * Hand it to PPP.
      */
-    dissect_ppp(pd, fd, tree);
+    dissect_ppp(pd, 0, fd, tree);
   } else {
     /*
      * Treat it as a normal DLT_NULL header.
Index: packet-ppp.c
===================================================================
RCS file: /usr/local/cvsroot/ethereal/packet-ppp.c,v
retrieving revision 1.29
diff -u -r1.29 packet-ppp.c
--- packet-ppp.c	2000/03/12 04:47:48	1.29
+++ packet-ppp.c	2000/03/27 17:52:30
@@ -1131,14 +1131,14 @@
 }
 
 void
-dissect_ppp( const u_char *pd, frame_data *fd, proto_tree *tree ) {
+dissect_ppp( const u_char *pd, int offset, frame_data *fd, proto_tree *tree ) {
   e_ppphdr   ph;
   proto_item *ti;
   proto_tree *fh_tree = NULL;
 
-  ph.ppp_addr = pd[0];
-  ph.ppp_ctl  = pd[1];
-  ph.ppp_prot = pntohs(&pd[2]);
+  ph.ppp_addr = pd[offset+0];
+  ph.ppp_ctl  = pd[offset+1];
+  ph.ppp_prot = pntohs(&pd[offset+2]);
 
   /* load the top pane info. This should be overwritten by
      the next protocol in the stack */
@@ -1159,7 +1159,7 @@
     proto_tree_add_text(fh_tree, 1, 1, "Control: %02x", ph.ppp_ctl);
   }
 
-  if (!dissect_ppp_stuff(pd, 2, fd, tree, fh_tree)) {
+  if (!dissect_ppp_stuff(pd, offset+2, fd, tree, fh_tree)) {
     if (check_col(fd, COL_PROTOCOL))
       col_add_fstr(fd, COL_PROTOCOL, "0x%04x", ph.ppp_prot);
   }
Index: packet-ppp.h
===================================================================
RCS file: /usr/local/cvsroot/ethereal/packet-ppp.h,v
retrieving revision 1.1
diff -u -r1.1 packet-ppp.h
--- packet-ppp.h	2000/02/15 21:02:53	1.1
+++ packet-ppp.h	2000/03/27 17:52:30
@@ -23,5 +23,5 @@
  */
 
 void capture_ppp(const u_char *, packet_counts *);
-void dissect_ppp(const u_char *, frame_data *, proto_tree *);
+void dissect_ppp(const u_char *, int, frame_data *, proto_tree *);
 void dissect_payload_ppp(const u_char *, int, frame_data *, proto_tree *);
Index: packet.c
===================================================================
RCS file: /usr/local/cvsroot/ethereal/packet.c,v
retrieving revision 1.68
diff -u -r1.68 packet.c
--- packet.c	2000/03/26 07:59:47	1.68
+++ packet.c	2000/03/27 17:52:31
@@ -1129,7 +1129,7 @@
 			dissect_null(pd, fd, tree);
 			break;
 		case WTAP_ENCAP_PPP :
-			dissect_ppp(pd, fd, tree);
+			dissect_ppp(pd, 0, fd, tree);
 			break;
 		case WTAP_ENCAP_LAPB :
 			dissect_lapb(pd, fd, tree);