Ethereal-dev: [Ethereal-dev] Patch to add RFC3518 PPP/BCP dissector

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

From: Kirby Files <kfiles@xxxxxxxxxxx>
Date: Thu, 16 Feb 2006 17:13:28 -0500
Folks, attached is a patch (against 0.10.14) to remove the STP PDU dissector for ppp.protocol type PPP_BPDU, and add a real BCP bridged PDU dissector in packet-ppp.c.

I'm just working with the ethereal source for the first time, so please provide any feedback necessary about the appropriate use of APIs, conventions or style.

Thanks,
  --kirby
diff -ur dissectors-orig/packet-bpdu.c dissectors/packet-bpdu.c
--- dissectors-orig/packet-bpdu.c       2006-02-16 17:03:38.000000000 -0500
+++ dissectors/packet-bpdu.c    2006-02-16 17:03:03.000000000 -0500
@@ -822,7 +822,6 @@

   bpdu_handle = find_dissector("bpdu");
   dissector_add("llc.dsap", SAP_BPDU, bpdu_handle);
-  dissector_add("ppp.protocol", PPP_BPDU, bpdu_handle);
   dissector_add("chdlctype", CHDLCTYPE_BPDU, bpdu_handle);
   dissector_add("llc.cisco_pid", 0x010b, bpdu_handle);
 }
diff -ur dissectors-orig/packet-ppp.c dissectors/packet-ppp.c
--- dissectors-orig/packet-ppp.c        2006-02-16 17:03:38.000000000 -0500
+++ dissectors/packet-ppp.c     2006-02-16 17:03:02.000000000 -0500
@@ -86,6 +86,8 @@
 static gint ett_osicp_options = -1;
 static gint ett_osicp_align_npdu_opt = -1;

+static int proto_bcp = -1;
+
 static int proto_ccp = -1;

 static gint ett_ccp = -1;
@@ -186,6 +188,8 @@
 static dissector_table_t ppp_subdissector_table;
 static dissector_handle_t chdlc_handle;
 static dissector_handle_t data_handle;
+static dissector_handle_t eth_withfcs_handle;
+

 /* options */
 static gint ppp_fcs_decode = 0; /* 0 = No FCS, 1 = 16 bit FCS, 2 = 32 bit FCS */
@@ -2818,6 +2822,17 @@
 }

 /*
+ * RFC 3518
+ */
+static void
+dissect_bcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+{
+  tvbuff_t    *next_tvb;
+  next_tvb = tvb_new_subset(tvb, 2, -1, -1);
+  call_dissector(eth_withfcs_handle, next_tvb, pinfo, tree);
+}
+
+/*
  * RFC 1377.
  */
 static void
@@ -3901,6 +3916,12 @@
 }

 void
+proto_register_bcp(void)
+{
+  proto_bcp = proto_register_protocol("PPP Bridge Control Protocol", "PPP BCP",                                      "bcp");
+}
+
+void
 proto_register_osicp(void)
 {
   static gint *ett[] = {
@@ -3915,6 +3936,16 @@
 }

 void
+proto_reg_handoff_bcp(void)
+{
+  dissector_handle_t bcp_handle;
+  eth_withfcs_handle = find_dissector("eth_withfcs");
+
+  bcp_handle = create_dissector_handle(dissect_bcp, proto_bcp);
+  dissector_add("ppp.protocol", PPP_BPDU, bcp_handle);
+}
+
+void
 proto_reg_handoff_osicp(void)
 {
   dissector_handle_t osicp_handle;