Updated the frame relay dissector - dissect-fr.c
authorJeff Foster <jfoste@woodward.com>
Fri, 23 Mar 2001 19:22:02 +0000 (19:22 -0000)
committerJeff Foster <jfoste@woodward.com>
Fri, 23 Mar 2001 19:22:02 +0000 (19:22 -0000)
Added the LMI dissector for frame relay - dissect-lmi.c
Added Wellfleet compression dissector - dissect-wcp.c

svn path=/trunk/; revision=3168

Makefile.am
packet-fr.c
packet-lmi.c [new file with mode: 0644]
packet-wcp.c [new file with mode: 0644]

index cfbe9ebbdc45a2e184a6f97f8a99e5cb11cf651d..18e2c060a6c383072c65bfe9991bc45345cb4049 100644 (file)
@@ -1,7 +1,7 @@
 # Makefile.am
 # Automake file for Ethereal
 #
-# $Id: Makefile.am,v 1.294 2001/03/22 23:54:44 gram Exp $
+# $Id: Makefile.am,v 1.295 2001/03/23 19:22:02 jfoster Exp $
 #
 # Ethereal - Network traffic analyzer
 # By Gerald Combs <gerald@zing.org>
@@ -141,6 +141,7 @@ DISSECTOR_SOURCES = \
        packet-ldap.c  \
        packet-ldp.c   \
        packet-llc.c   \
+       packet-lmi.c   \
        packet-lpd.c   \
        packet-m3ua.c  \
        packet-mapi.c  \
@@ -220,6 +221,7 @@ DISSECTOR_SOURCES = \
        packet-vrrp.c \
        packet-vtp.c  \
        packet-wccp.c \
+       packet-wcp.c \
        packet-who.c  \
        packet-wap.c \
        packet-wtls.c \
index 35705c4119c8dda8e4253de4ccf9bd08e5e6e1e1..9fde78281e96ac9b2610b99bcbcc4000a19f458c 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright 2001, Paul Ionescu        <paul@acorp.ro>
  *
- * $Id: packet-fr.c,v 1.9 2001/03/15 09:11:00 guy Exp $
+ * $Id: packet-fr.c,v 1.10 2001/03/23 19:22:02 jfoster Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ *
+ * References:
+ *
+ * http://www.protocols.com/pbook/frame.htm
+ * http://www.frforum.com/5000/Approved/FRF.3/FRF.3.2.pdf
+ * RFC-1490 
+ * RFC-2427 
+ * Cisco encapsulation
+ * http://www.trillium.com/whats-new/wp_frmrly.html
+ *
  */
 
 #ifdef HAVE_CONFIG_H
 #include "oui.h"
 #include "nlpid.h"
 #include "greproto.h"
+#include "conversation.h"
+
+/*
+ * Bits in the address field.
+ */
+#define        FRELAY_DLCI     0xfcf0          /* 2 byte DLCI Address */
+#define        FRELAY_CR       0x0200          /* Command/Response bit */
+#define        FRELAY_EA       0x0001          /* Address Extension bit */
+#define        FRELAY_FECN     0x0008          /* Forward Explicit Congestion Notification */
+#define        FRELAY_BECN     0x0004          /* Backward Explicit Congestion Notification */
+#define        FRELAY_DE       0x0002          /* Discard Eligibility */
+#define        FRELAY_DC       0x0002          /* Control bits */
+
+#define FROM_DCE       0x80            /* for direction setting */
+
+#define NLPID_WCP 0xb0                         /* Wellfleet compression ip */
 
 static gint proto_fr    = -1;
 static gint ett_fr      = -1;
@@ -50,50 +77,95 @@ static gint hf_fr_cr        = -1;
 static gint hf_fr_becn  = -1;
 static gint hf_fr_fecn  = -1;
 static gint hf_fr_de    = -1;
+static gint hf_fr_ea    = -1;
+static gint hf_fr_dc    = -1;
 static gint hf_fr_nlpid = -1;
 static gint hf_fr_oui   = -1;
 static gint hf_fr_pid   = -1;
 static gint hf_fr_snaptype = -1;
 static gint hf_fr_chdlctype = -1;
 
-static dissector_table_t fr_subdissector_table;
+static const true_false_string cmd_string = {
+                "Command",
+                "Response"
+        };
+static const true_false_string ctrl_string = {
+                "DLCI Address",
+                "Control"
+        };
+static const true_false_string ea_string = {
+                "Last Octet",
+                "More Follows"
+        };
+
+dissector_table_t fr_subdissector_table;
 
 static void dissect_lapf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
 static void dissect_fr_xid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
 
-/* see RFC2427 / RFC1490 and Cisco encapsulation */
+
+static void add_dlci( tvbuff_t *tvb, proto_tree *tree) {
+
+/* Display this DLCI address. Use special format because the DLCI address */
+/* is a masked bit field with unused bits in the middle. */
+
+
+   char buf[32];
+   guint16 address = (( tvb_get_guint8( tvb, 0)& 0xfc) << 2) 
+                       | ((tvb_get_guint8( tvb, 1) & 0xf0) >> 4);
+
+   decode_bitfield_value( buf, tvb_get_ntohs(tvb, 0), FRELAY_DLCI, 16);
+   proto_tree_add_uint_format( tree, hf_fr_dlci, tvb, 0, 2, address, "%sDLCI: %d", 
+      buf, address);
+}
+
 
 static void dissect_fr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 {
   proto_item *ti;
   proto_tree *fr_tree = NULL;
   guint16 fr_header,fr_type,offset=2; /* default header length of FR is 2 bytes */
-  
+  guint16 address;
   guint8  fr_nlpid,fr_ctrl;
-    
+
+  CHECK_DISPLAY_AS_DATA(proto_fr, tvb, pinfo, tree);
+
+  pinfo->current_proto = "Frame Relay";
   if (check_col(pinfo->fd, COL_PROTOCOL)) 
       col_set_str(pinfo->fd, COL_PROTOCOL, "FR");
-  if (check_col(pinfo->fd, COL_INFO)) 
-      col_clear(pinfo->fd, COL_INFO);
 
-  fr_header = tvb_get_ntohs( tvb, 0 );
+  if (pinfo->pseudo_header->x25.flags & FROM_DCE) {
+        if(check_col(pinfo->fd, COL_RES_DL_DST))
+            col_set_str(pinfo->fd, COL_RES_DL_DST, "DTE");
+        if(check_col(pinfo->fd, COL_RES_DL_SRC))
+            col_set_str(pinfo->fd, COL_RES_DL_SRC, "DCE");
+    }
+    else {
+        if(check_col(pinfo->fd, COL_RES_DL_DST))
+            col_set_str(pinfo->fd, COL_RES_DL_DST, "DCE");
+        if(check_col(pinfo->fd, COL_RES_DL_SRC))
+            col_set_str(pinfo->fd, COL_RES_DL_SRC, "DTE");
+    }
+
+/*XXX We should check the EA bits and use that to generate the address. */
+
+  fr_header = tvb_get_ntohs(tvb, 0);
+  fr_ctrl = tvb_get_guint8( tvb, 2);
+  address = ((fr_header & 0xfc00) >> 6) | ((fr_header & 0xf0) >> 4);
+
   if (check_col(pinfo->fd, COL_INFO)) 
-      col_add_fstr(pinfo->fd, COL_INFO, "DLCI %u",
-                  ((fr_header&0x00FF)>>4)+((fr_header&0xFC00)>>6));
-  
-  fr_header = tvb_get_ntohs( tvb, 0 );
-  fr_ctrl   = tvb_get_guint8( tvb,offset);
-               
+      col_add_fstr(pinfo->fd, COL_INFO, "DLCI %u", address);
+
   if (tree) {
       ti = proto_tree_add_protocol_format(tree, proto_fr, tvb, 0, 4, "Frame Relay");
       fr_tree = proto_item_add_subtree(ti, ett_fr);
-     
-      proto_tree_add_text(fr_tree,tvb,0,2,"The real DLCI is %u",((fr_header&0x00FF)>>4)+((fr_header&0xFC00)>>6));
-      proto_tree_add_uint(fr_tree, hf_fr_dlci, tvb, 0, 2, fr_header);
-      proto_tree_add_boolean(fr_tree, hf_fr_cr,   tvb, 0, 1, fr_header);
-      proto_tree_add_boolean(fr_tree, hf_fr_fecn, tvb, 1, 1, fr_header);
-      proto_tree_add_boolean(fr_tree, hf_fr_becn, tvb, 1, 1, fr_header);
-      proto_tree_add_boolean(fr_tree, hf_fr_de,   tvb, 1, 1, fr_header);
+
+      add_dlci(tvb, fr_tree); 
+      proto_tree_add_boolean(fr_tree, hf_fr_cr,   tvb, 0, offset, fr_header);
+      proto_tree_add_boolean(fr_tree, hf_fr_fecn, tvb, 0, offset, fr_header);
+      proto_tree_add_boolean(fr_tree, hf_fr_becn, tvb, 0, offset, fr_header);
+      proto_tree_add_boolean(fr_tree, hf_fr_de,   tvb, 0, offset, fr_header);
+      proto_tree_add_boolean(fr_tree, hf_fr_ea,   tvb, 0, offset, fr_header);
   }
 
   if (fr_ctrl == XDLC_U) {
@@ -118,6 +190,8 @@ static void dissect_fr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                proto_tree_add_uint(fr_tree, hf_fr_nlpid, tvb, offset, 1, fr_nlpid );
       offset++;
 
+      SET_ADDRESS(&pinfo->dl_src, AT_DLCI, 2, (guint8*)&address);
+
       if (fr_nlpid == NLPID_SNAP) {
                dissect_snap(tvb, offset, pinfo, tree, fr_tree, fr_ctrl,
                      hf_fr_oui, hf_fr_snaptype, hf_fr_pid, 0);
@@ -186,21 +260,29 @@ static void dissect_fr_xid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 void proto_register_fr(void)
 {                 
   static hf_register_info hf[] = {
+
         { &hf_fr_dlci, { 
            "DLCI", "fr.dlci", FT_UINT16, BASE_DEC, 
-            NULL, 0xFCF0, "Data-Link Connection Identifier" }},
+            NULL, FRELAY_DLCI, "Data-Link Connection Identifier" }},
         { &hf_fr_cr, { 
-           "CR", "fr.cr", FT_BOOLEAN, 16, 
-            NULL, 0x0200, "Command/Response" }},
+           "CR", "fr.cr", FT_BOOLEAN, 16, TFS(&cmd_string),
+            FRELAY_CR, "Command/Response" }},
+        { &hf_fr_dc, { 
+           "DC", "fr.dc", FT_BOOLEAN, 16, TFS(&ctrl_string),
+            FRELAY_CR, "Address/Control" }},
+
         { &hf_fr_fecn, { 
            "FECN", "fr.fecn", FT_BOOLEAN, 16, 
-            NULL, 0x0008, "Forward Explicit Congestion Notification" }},
+            NULL, FRELAY_FECN, "Forward Explicit Congestion Notification" }},
         { &hf_fr_becn, { 
            "BECN", "fr.becn", FT_BOOLEAN, 16, 
-            NULL, 0x0004, "Backward Explicit Congestion Notification" }},
+            NULL, FRELAY_BECN, "Backward Explicit Congestion Notification" }},
         { &hf_fr_de, { 
            "DE", "fr.de", FT_BOOLEAN, 16, 
-            NULL, 0x0002, "Discard Eligibility" }},
+            NULL, FRELAY_DE, "Discard Eligibility" }},
+        { &hf_fr_ea, { 
+           "EA", "fr.ea", FT_BOOLEAN, 16, TFS(&ea_string),
+            FRELAY_EA, "Extended Address" }},
         { &hf_fr_nlpid, { 
            "NLPID", "fr.nlpid", FT_UINT8, BASE_HEX, 
             NULL, 0x0, "FrameRelay Encapsulated Protocol NLPID" }},
diff --git a/packet-lmi.c b/packet-lmi.c
new file mode 100644 (file)
index 0000000..a2841b2
--- /dev/null
@@ -0,0 +1,254 @@
+/* packet-lmi.c
+ * Routines for Frame Relay Local Management Interface (LMI) disassembly
+ * Copyright 2001, Jeffrey C. Foster <jfoste@woodward.com>
+ *
+ * $Id: packet-lmi.c,v 1.1 2001/03/23 19:22:02 jfoster Exp $
+ *
+ * Ethereal - Network traffic analyzer
+ * By Gerald Combs <gerald@zing.org>
+ * Copyright 1998
+ *
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * ToDo:
+ *
+ * References:
+ *
+ * http://www.techfest.com/networking/wan/frrel.htm
+ * http://www.frforum.com/5000/frf1_2.pdf
+ * http://www.cisco.com/univercd/cc/td/doc/cisintwk/ito_doc/frame.htm#xtocid125314
+ * http://www.net.aapt.com.au/techref/lmimess.htm
+ * http://www.raleigh.ibm.com:80/cgi-bin/bookmgr/BOOKS/EZ305800/1.2.4.4
+ */
+
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
+#include <stdio.h>
+#include <glib.h>
+#include <string.h>
+#include "packet.h"
+#include "packet-osi.h"
+
+
+static int proto_lmi = -1;
+static int hf_lmi_call_ref = -1;
+static int hf_lmi_msg_type = -1;
+static int hf_lmi_inf_ele = -1;
+static int hf_lmi_inf_len = -1;
+                       
+static int hf_lmi_rcd_type = -1;
+static int hf_lmi_send_seq = -1;
+static int hf_lmi_recv_seq = -1;
+static int hf_lmi_dlci_high = -1;
+static int hf_lmi_dlci_low = -1;
+static int hf_lmi_new = -1;
+static int hf_lmi_act = -1;
+
+static gint ett_lmi = -1;
+static gint ett_lmi_ele = -1;
+
+#define NLPID_LMI 0x09         /* NLPID value for LMI */
+
+#ifdef _OLD_
+/*
+ * Bits in the address field.
+ */
+#define        LMI_CMD         0xf000  /* LMI Command */
+#define        LMI_SEQ         0x0fff  /* LMI Sequence number */
+
+#endif
+
+static const value_string msg_type_str[] = {
+       {0x75, "Status Enquiry"},
+        {0x7D, "Status"},
+       { 0,       NULL }
+        };
+
+static const value_string element_type_str[] = {
+
+/*** These are the ANSI values ***/
+       {0x01, "Report"},
+        {0x03, "Keep Alive"},
+        {0x07, "PVC Status"},
+
+/*** These are the ITU values ***/
+        {0x51, "Report"},
+        {0x53, "Keep Alive"},
+        {0x07, "PVC Status"},
+
+       { 0,       NULL }
+        };
+
+static const value_string record_type_str[] = {
+        {0x00, "Full Status"},
+        {0x01, "Link Integrity Verification Only"},
+        {0x02, "Single PVC"},
+       { 0,       NULL }
+        };
+
+static const value_string pvc_status_new_str[] = {
+        {0x00, "PVC already present"},
+        {0x01, "PVC is new"},
+       { 0,       NULL }
+        };
+
+static const value_string pvc_status_act_str[] = {
+        {0x00, "PVC is Inactive"},
+        {0x01, "PVC is Acive"},
+       { 0,       NULL }
+        };
+
+static void
+dissect_lmi_report_type(tvbuff_t *tvb, int offset, proto_tree *tree)
+{
+       proto_tree_add_uint(tree, hf_lmi_rcd_type, tvb, offset, 1, tvb_get_guint8( tvb, offset));
+}
+
+static void
+dissect_lmi_link_int(tvbuff_t *tvb, int offset, proto_tree *tree)
+{
+       proto_tree_add_uint(tree, hf_lmi_send_seq, tvb, offset, 1, tvb_get_guint8( tvb, offset));
+       ++offset;
+       proto_tree_add_uint(tree, hf_lmi_recv_seq, tvb, offset, 0, tvb_get_guint8( tvb, offset));
+
+}
+
+static void
+dissect_lmi_pvc_status(tvbuff_t *tvb, int offset, proto_tree *tree)
+{
+        proto_tree_add_uint(tree, hf_lmi_dlci_high, tvb, offset, 1, tvb_get_guint8( tvb, offset));
+       ++offset;
+        proto_tree_add_uint(tree, hf_lmi_dlci_low, tvb, offset, 1, tvb_get_guint8( tvb, offset));
+       ++offset;
+        proto_tree_add_uint(tree, hf_lmi_new, tvb, offset, 1, tvb_get_guint8( tvb, offset));
+        proto_tree_add_uint(tree, hf_lmi_act, tvb, offset, 1, tvb_get_guint8( tvb, offset));
+}
+
+static void
+dissect_lmi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+{
+       proto_tree      *lmi_tree, *lmi_subtree;
+       proto_item      *ti;
+       int             offset = 2, len;
+       guint8          ele_id;
+
+       if (check_col(pinfo->fd, COL_PROTOCOL))
+               col_set_str(pinfo->fd, COL_PROTOCOL, "LMI");
+
+       if (tree) {
+               ti = proto_tree_add_item(tree, proto_lmi, tvb, 0, 3, FALSE);
+               lmi_tree = proto_item_add_subtree(ti, ett_lmi_ele);
+
+               proto_tree_add_uint(lmi_tree, hf_lmi_call_ref, tvb, 0, 1, tvb_get_guint8( tvb, 0));
+               proto_tree_add_uint(lmi_tree, hf_lmi_msg_type,  tvb, 1, 1,  tvb_get_guint8( tvb, 1));
+
+       /* Display the LMI elements */
+               while( offset < tvb_length( tvb)){
+                       ele_id = tvb_get_guint8( tvb, offset);
+                       len =  tvb_get_guint8( tvb, offset + 1);
+
+                       ti = proto_tree_add_uint(lmi_tree, hf_lmi_inf_ele, tvb, offset, len + 2, 
+                               tvb_get_guint8( tvb, offset));
+
+                       lmi_subtree = proto_item_add_subtree(ti, ett_lmi_ele);
+
+                       proto_tree_add_uint(lmi_subtree, hf_lmi_inf_ele, tvb, offset, 1,
+                               tvb_get_guint8( tvb, offset));
+                       ++offset;
+                       len =  tvb_get_guint8( tvb, offset);
+                       proto_tree_add_uint(lmi_subtree, hf_lmi_inf_len, tvb, offset, 1, len);
+                       ++offset;
+                       if (( ele_id == 1) || (ele_id == 51))   
+                               dissect_lmi_report_type( tvb, offset, lmi_subtree);
+                       else if (( ele_id == 3) || (ele_id == 53))      
+                               dissect_lmi_link_int( tvb, offset, lmi_subtree);
+                       else if (( ele_id == 7) || (ele_id == 57))      
+                               dissect_lmi_pvc_status( tvb, offset, lmi_subtree);
+                       offset += len;
+               }       
+       }
+       else {
+               lmi_tree = NULL;
+       }
+}
+
+
+void
+proto_register_lmi(void)
+{
+    static hf_register_info hf[] = {
+       { &hf_lmi_call_ref,
+         { "Call reference", "lmi.cmd", FT_UINT8, BASE_HEX, NULL, 0, 
+               "Call Reference" }},
+
+       { &hf_lmi_msg_type,
+         { "Message Type", "lmi.msg_type", FT_UINT8, BASE_HEX, VALS(msg_type_str), 0, 
+               "Message Type" }},
+
+       { &hf_lmi_inf_ele,
+         { "Information Element", "lmi.inf_ele", FT_UINT8, BASE_DEC, VALS(element_type_str), 0,
+               "Information Element" }},
+       { &hf_lmi_inf_ele,
+         { "Type", "lmi.inf_ele_type", FT_UINT8, BASE_DEC, VALS(element_type_str), 0,
+               "Information Element Type" }},
+       { &hf_lmi_inf_len,
+         { "Length", "lmi.inf_ele_len", FT_UINT8, BASE_DEC, NULL, 0,
+               "Information Element Length" }},
+
+       { &hf_lmi_rcd_type,
+         { "Record Type", "lmi.ele_rcd_type", FT_UINT8, BASE_DEC, VALS(record_type_str), 0,
+               "Record Type" }},
+       { &hf_lmi_send_seq,
+         { "Send Seq", "lmi.send_seq", FT_UINT8, BASE_DEC, NULL, 0,
+               "Send Sequence" }},
+       { &hf_lmi_recv_seq,
+         { "Recv Seq", "lmi.recv_seq", FT_UINT8, BASE_DEC, NULL, 0,
+               "Receive Sequence" }},
+       { &hf_lmi_dlci_high,
+         { "DLCI High", "lmi.dlci_hi", FT_UINT8, BASE_DEC, NULL, 0x3f,
+               "DLCI High bits" }},
+       { &hf_lmi_dlci_low,
+         { "DLCI Low", "lmi.dlci_low", FT_UINT8, BASE_DEC, NULL, 0x78,
+               "DLCI Low bits" }},
+       { &hf_lmi_new,
+         { "DLCI New", "lmi.dlci_new", FT_UINT8, BASE_DEC, VALS(pvc_status_new_str), 0x08,
+               "DLCI New Flag" }},
+       { &hf_lmi_act,
+         { "DLCI Active","lmi.dlci_act", FT_UINT8, BASE_DEC, VALS(pvc_status_act_str), 0x02,
+               "DLCI Active Flag" }},
+    };
+    static gint *ett[] = {
+        &ett_lmi,
+        &ett_lmi_ele,
+    };
+    proto_lmi = proto_register_protocol ("Local Management Interface", "LMI", "lmi");
+    proto_register_field_array (proto_lmi, hf, array_length(hf));
+    proto_register_subtree_array(ett, array_length(ett));
+
+}
+
+void
+proto_reg_handoff_lmi(void)
+{
+       dissector_add("fr.ietf", NLPID_LMI, dissect_lmi, proto_lmi);
+}
diff --git a/packet-wcp.c b/packet-wcp.c
new file mode 100644 (file)
index 0000000..9665cfe
--- /dev/null
@@ -0,0 +1,756 @@
+/* packet-wcp.c
+ * Routines for Wellfleet Compression frame disassembly
+ * Copyright 2001, Jeffrey C. Foster <jfoste@woodward.com>
+ *
+ * $Id: packet-wcp.c,v 1.1 2001/03/23 19:22:02 jfoster Exp $
+ *
+ * Ethereal - Network traffic analyzer
+ * By Gerald Combs <gerald@zing.org>
+ * Copyright 1998
+ *
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * ToDo:
+ *     Add preference to allow/disallow decompression
+ *     Calculate and verify check byte (last byte), if only we knew how!
+ *     Handle Wellfleet compression over PPP links.
+ *             - This will require changing the sub-dissector call
+ *               routine to determine if layer 2 is frame relay or
+ *               or PPP and different sub-dissector routines for each.
+ *
+ * Based upon information in the Nortel TCL based Pcaptap code.
+ *http://www.mynetworkforum.com/tools/PCAPTAP/pcaptap-Win32-3.00.exe
+ *
+ * And lzss algorithm
+ *http://www.rasip.fer.hr/research/compress/algorithms/fund/lz/lzss.html
+ */
+
+/*
+ * Wellfleet compression is a variation on LZSS encoding.
+ *
+ * Compression is done by keeping a sliding window of previous 
+ * data transmited. The sender will use a pattern match to 
+ * encode repeated data as a data pointer field. Then a stream
+ * of pointers and actual data bytes. The pointer values include
+ * an offset to previous data in the stream and the length of the
+ *  matching data.
+ *
+ * The data pattern matching is done on the octects. 
+ *
+ * The data is encoded as 8 field blocks with a compression flag
+ * byte at the beginning.  If the bit is set in the compression
+ * flag, then that field has a compression field. If it isn't set
+ * then the byte is raw data.
+ *
+ * The compression field is either 2 or 3 bytes long. The length
+ * is determined by the length of the matching data, for short
+ * matches the match length is encoded in the high nibble of the
+ * first byte. Otherwise the third byte of the field contains 
+ * the match length.
+ *
+ * First byte -
+ * lower 4 bits:
+ *             High order nibble of the offset
+ *
+ * upper 4 bits:
+ *             1   = length is in 3rd byte 
+ *             2-F = length of matching data - 1
+ *             
+ * Second byte - 
+ *  Lower byte of the source offset.
+ *
+ * Third byte - 
+ *  Length of match - 1 if First byte upper nibble = 1, otherwise
+ *  this byte isn't added to data stream.
+ *
+ * Example:
+ *     Uncompressed data (hex):  11 22 22 22 22 33 44 55 66 77
+ *
+ *
+ *     Compression data :
+ *                     Flag bits:      0x20 (third field is compressed)
+ *                     Data:   11 22 20 00 33 44 55
+ *                             /  /  /  /
+ *             raw data ------+--+  /  /               
+ *              (Comp length - 1)<<4+  /
+ *             Data offset ----------+
+ *
+ *     Output data (hex):  20 11 22 20 00 33 44 55 66 77
+ *
+ * In this example the copy src is one byte behind the copy destination
+ * so if appears as if output is being loaded with the source byte.
+ *
+ */
+
+
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
+#include <stdio.h>
+#include <glib.h>
+#include <string.h>
+#include "packet.h"
+#include "packet-frame.h"
+#include "packet-osi.h"
+#include "conversation.h"
+#include "nlpid.h"
+#include "oui.h"
+#include "packet-llc.h"
+
+#define MAX_WIN_BUF_LEN 0x7fff         /* storage size for decompressed data */
+#define MAX_WCP_BUF_LEN 2048           /* storage size for decompressed data */
+#define FROM_DCE       0x80            /* for direction setting */
+
+typedef struct {
+
+       guint8  *buf_cur;
+       guint8  buffer[MAX_WIN_BUF_LEN];
+
+}wcp_window_t;
+
+/*XXX do I really want the length in here  */
+typedef struct {
+
+       guint16  len;
+       guint8  buffer[MAX_WCP_BUF_LEN];
+
+}wcp_pdata_t;
+
+
+#define wcp_win_init_count 4
+#define wcp_packet_init_count 10
+
+#define wcp_win_length (sizeof(wcp_window_t))
+#define wcp_packet_length (sizeof(wcp_pdata_t))
+
+static GMemChunk *wcp_window = NULL;
+static GMemChunk *wcp_pdata = NULL;
+
+extern dissector_table_t fr_subdissector_table;
+
+static int proto_wcp = -1;
+static int hf_wcp_cmd = -1;
+static int hf_wcp_ext_cmd = -1;
+static int hf_wcp_seq = -1;
+static int hf_wcp_chksum = -1;
+static int hf_wcp_tid = -1;
+static int hf_wcp_rev = -1;
+static int hf_wcp_init = -1;
+static int hf_wcp_seq_size = -1;
+static int hf_wcp_alg = -1;
+static int hf_wcp_alg_cnt = -1;
+static int hf_wcp_alg_a = -1;
+static int hf_wcp_alg_b = -1;
+static int hf_wcp_alg_c = -1;
+static int hf_wcp_alg_d = -1;
+static int hf_wcp_rexmit = -1;
+
+static int hf_wcp_hist_size = -1;
+static int hf_wcp_ppc = -1;
+static int hf_wcp_pib = -1;
+
+static int hf_wcp_comp_bits = -1;
+static int hf_wcp_comp_marker = -1;
+static int hf_wcp_short_len = -1;
+static int hf_wcp_long_len = -1;
+static int hf_wcp_short_run = -1;
+static int hf_wcp_long_run = -1;
+static int hf_wcp_offset = -1;
+
+/*$$ are these needed or should the Frame relay stuff be used (call a decoder in frame relay)?? */
+static int hf_wcp_oui = -1;
+static int hf_wcp_pid = -1;
+static int hf_wcp_type = -1;
+
+static gint ett_wcp = -1;
+static gint ett_wcp_field = -1;
+
+#define NLPID_WCP 0xb0                 /* NLPID value for WCP */
+#define ETHERTYPE_WCP 0x80ff           /* ether snap value for WCP */
+
+/*
+ * Bits in the address field.
+ */
+#define        WCP_CMD                 0xf0    /* WCP Command */
+#define        WCP_EXT_CMD             0x0f    /* WCP Extended Command */
+#define        WCP_SEQ                 0x0fff  /* WCP Sequence number */
+#define        WCP_OFFSET_MASK         0x0fff  /* WCP Pattern source offset */
+
+#define PPC_COMPRESSED_IND             0x0
+#define        PPC_UNCOMPRESSED_IND            0x1
+#define        PPC_TPPC_COMPRESSED_IND         0x2
+#define        PPC_TPPC_UNCOMPRESSED_IND       0x3
+#define CONNECT_REQ                    0x4
+#define        CONNECT_ACK                     0x5
+#define        CONNECT_NAK                     0x6
+#define        DISCONNECT_REQ                  0x7
+#define        DISCONNECT_ACK                  0x8
+#define        INIT_REQ                        0x9
+#define        INIT_ACK                        0xa
+#define        RESET_REQ                       0xb
+#define        RESET_ACK                       0xc
+#define        REXMIT_NAK                      0xd
+
+
+static const value_string cmd_string[] = {
+       {0, "Compressed Data"},
+        {1, "Uncompressed Data"},
+        {15, "Extended"},
+       { 0,       NULL }
+        };
+
+static const value_string ext_cmd_string[] = {
+       {0, "Per Packet Compression"},
+       {4, "Connect Req"},
+       {5, "Connect Ack"},
+       {9, "Init Req"},
+       {0x0a, "Init Ack"},
+
+       { 0,       NULL }
+        };
+
+
+
+static tvbuff_t *wcp_uncompress( tvbuff_t *src_tvb, int offset, packet_info *pinfo, proto_tree *tree);
+static wcp_window_t *get_wcp_window_ptr( packet_info *pinfo);
+
+static void
+dissect_wcp_con_req(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree) {
+
+/* WCP connector request message */
+
+       guint alg_cnt = tvb_get_guint8(tvb, 5);
+
+       proto_tree_add_uint(tree, hf_wcp_tid, tvb, offset, 2, tvb_get_ntohs(tvb, offset));
+       proto_tree_add_uint(tree, hf_wcp_rev, tvb, offset + 2, 1, tvb_get_guint8(tvb, offset + 2));
+       proto_tree_add_uint(tree, hf_wcp_init, tvb, offset + 3, 1, tvb_get_guint8(tvb, offset + 3));
+       proto_tree_add_uint(tree, hf_wcp_seq_size, tvb, offset + 4, 1, tvb_get_guint8(tvb, offset + 4));
+       proto_tree_add_uint(tree, hf_wcp_alg_cnt, tvb, offset + 5, 1, alg_cnt);
+       proto_tree_add_uint(tree, hf_wcp_alg_a, tvb, offset + 6, 1, tvb_get_guint8(tvb, offset + 6));
+       if ( alg_cnt > 1)
+               proto_tree_add_uint(tree, hf_wcp_alg_b, tvb, offset + 7, 1, tvb_get_guint8(tvb, offset + 7));
+       if ( alg_cnt > 2)
+               proto_tree_add_uint(tree, hf_wcp_alg_c, tvb, offset + 8, 1, tvb_get_guint8(tvb, offset + 8));
+       if ( alg_cnt > 3)
+               proto_tree_add_uint(tree, hf_wcp_alg_d, tvb, offset + 9, 1, tvb_get_guint8(tvb, offset + 9));
+}
+
+static void
+dissect_wcp_con_ack( tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree){
+
+/* WCP connector ack message */
+
+       proto_tree_add_uint(tree, hf_wcp_tid, tvb, offset, 2, tvb_get_ntohs(tvb, offset));
+       proto_tree_add_uint(tree, hf_wcp_rev, tvb, offset + 2, 1, tvb_get_guint8(tvb, offset + 2));
+       proto_tree_add_uint(tree, hf_wcp_seq_size, tvb, offset + 3, 1, tvb_get_guint8(tvb, offset + 3));
+       proto_tree_add_uint(tree, hf_wcp_alg, tvb, offset + 4, 1, tvb_get_guint8(tvb, offset + 4));
+}
+
+static void
+dissect_wcp_init( tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree){
+
+/* WCP Initiate Request/Ack message */
+
+       proto_tree_add_uint(tree, hf_wcp_tid, tvb, offset, 2, tvb_get_ntohs(tvb, offset));
+       proto_tree_add_uint(tree, hf_wcp_rev, tvb, offset + 2, 1, tvb_get_guint8(tvb, offset + 2));
+       proto_tree_add_uint(tree, hf_wcp_hist_size, tvb, offset + 3, 1, tvb_get_guint8(tvb, offset + 3));
+       proto_tree_add_uint(tree, hf_wcp_ppc, tvb, offset + 4, 1, tvb_get_guint8(tvb, offset + 4));
+       proto_tree_add_uint(tree, hf_wcp_pib, tvb, offset + 5, 1, tvb_get_guint8(tvb, offset + 5));
+}
+
+
+static void
+dissect_wcp_reset( tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree){
+
+/* Process WCP Reset Request/Ack message */
+
+       proto_tree_add_uint(tree, hf_wcp_tid, tvb, offset, 2, tvb_get_ntohs(tvb, offset));
+}
+
+
+void wcp_save_data( tvbuff_t *tvb, packet_info *pinfo){
+
+       wcp_window_t *buf_ptr = 0;
+       int len; 
+
+       /* discard first 2 bytes, header and last byte (check byte) */
+       len = tvb_reported_length( tvb)-3;
+       buf_ptr = get_wcp_window_ptr( pinfo); 
+
+       if (( buf_ptr->buf_cur + len) <= (buf_ptr->buffer + MAX_WIN_BUF_LEN)){
+               tvb_memcpy( tvb, buf_ptr->buf_cur, 2, len);
+               buf_ptr->buf_cur = buf_ptr->buf_cur + len;
+       
+       } else {
+               guint8 *buf_end = buf_ptr->buffer + MAX_WIN_BUF_LEN; 
+               tvb_memcpy( tvb, buf_ptr->buf_cur, 2, buf_end - buf_ptr->buf_cur);
+               tvb_memcpy( tvb, buf_ptr->buffer, buf_end - buf_ptr->buf_cur-2,
+                       len - (int)(buf_end - buf_ptr->buf_cur));
+               buf_ptr->buf_cur = buf_ptr->buf_cur + len - MAX_WIN_BUF_LEN;
+       }
+
+}
+
+
+void dissect_wcp( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
+
+       proto_tree      *wcp_tree;
+       proto_item      *ti;
+       int             wcp_header_len;
+       guint16         temp, cmd, ext_cmd, seq;
+       tvbuff_t        *next_tvb;
+       guint8          protocol_id;
+
+       temp = tvb_get_guint8(tvb, 0);
+
+        if (!proto_is_protocol_enabled(proto_wcp))
+                return;
+
+       temp =tvb_get_ntohs(tvb, 0); 
+       pinfo->current_proto = "WCP";
+
+       if (check_col(pinfo->fd, COL_PROTOCOL))
+               col_set_str(pinfo->fd, COL_PROTOCOL, "WCP");
+
+
+       cmd = (temp & 0xf000) >> 12;
+       ext_cmd = (temp & 0x0f00) >> 8;
+
+       if ( cmd == 0xf)
+               wcp_header_len= 1;
+       else 
+               wcp_header_len= 2;
+
+       seq = temp & 0x0fff;
+
+/*XXX should test seq to be sure it the last + 1 !! */
+
+       if (check_col(pinfo->fd, COL_INFO)){
+               col_add_str(pinfo->fd, COL_INFO, val_to_str(cmd, cmd_string, "Unknown"));
+               if ( cmd == 0xf)
+                       col_append_fstr(pinfo->fd, COL_INFO, ", %s",
+                               val_to_str(ext_cmd, ext_cmd_string, "Unknown"));
+       }       
+
+       if (tree) {
+               ti = proto_tree_add_item(tree, proto_wcp, tvb, 0, wcp_header_len, FALSE);
+
+               wcp_tree = proto_item_add_subtree(ti, ett_wcp);
+
+               proto_tree_add_uint(wcp_tree, hf_wcp_cmd, tvb, 0, 1, tvb_get_guint8( tvb, 0));
+               if ( cmd == 0xf){
+                       proto_tree_add_uint(wcp_tree, hf_wcp_ext_cmd, tvb, 1, 1,
+                                       tvb_get_guint8( tvb, 0));
+                       switch (ext_cmd){
+                       case CONNECT_REQ:
+                               dissect_wcp_con_req( tvb, 1, pinfo, wcp_tree);
+                               break;
+
+                       case CONNECT_ACK:
+                               dissect_wcp_con_ack( tvb, 1, pinfo, wcp_tree);
+                               break;
+                       case INIT_REQ:
+                       case INIT_ACK:
+                               dissect_wcp_init( tvb, 1, pinfo, wcp_tree);
+                               break;
+                       case RESET_REQ:
+                       case RESET_ACK:
+                               dissect_wcp_reset( tvb, 1, pinfo, wcp_tree);
+                               break;
+                       default:
+                               break;
+                       }
+               }else { 
+                       proto_tree_add_uint(wcp_tree, hf_wcp_seq,  tvb, 0, 2, seq);
+               }
+       }
+       else {
+               wcp_tree = NULL;
+       }
+
+
+                                       /* exit if done */
+       if ( cmd != 1 && cmd != 0 && !(cmd == 0xf && ext_cmd == 0)) 
+               return;
+
+       if ( cmd == 1) {                /* uncompressed data */
+               if ( !pinfo->fd->flags.visited){        /* if first pass */
+                       wcp_save_data( tvb, pinfo);
+               }
+               next_tvb = tvb_new_subset(tvb, wcp_header_len, -1, -1);
+       }
+       else {          /* cmd == 0 || (cmd == 0xf && ext_cmd == 0) */
+
+               next_tvb = wcp_uncompress( tvb, wcp_header_len, pinfo, wcp_tree);
+
+               if ( !next_tvb){
+                       proto_tree_add_protocol_format(tree, proto_malformed, tvb, 0, 0,
+                                       "[Malformed Frame: Bad WCP compressed data]" );
+                       return;
+               }
+       }
+
+       if ( tree)                      /* add the check byte */
+               proto_tree_add_uint(wcp_tree, hf_wcp_chksum, tvb,
+                       tvb_reported_length( tvb)-1, 1,
+                       tvb_get_guint8( tvb, tvb_reported_length(tvb)-1));
+
+       protocol_id = tvb_get_guint8( next_tvb, 0);
+
+/*XXX This isn't really what we want to do !! Should be able to call a decoder */
+/*     routine in the frame relay code or PPP (if that is added).              */
+
+       if (!dissector_try_port(fr_subdissector_table, protocol_id,
+                       tvb_new_subset(next_tvb, 1,-1,-1), pinfo, tree))
+               dissect_snap(next_tvb, 0, pinfo, tree, wcp_tree, 0,
+                       hf_wcp_oui, hf_wcp_type, hf_wcp_pid, 0);
+
+       return;
+}
+
+
+guint8 *decompressed_entry( guint8 *src, guint8 *dst, int *len, guint8 * buf_start, guint8 *buf_end){
+
+/* do the decompression for one field */
+
+       guint16 data_offset, data_cnt;
+       guint8 tmp = *src;
+
+       data_offset = (*(src++) & 0xf) << 8;    /* get high byte */
+       data_offset += *(src++);                /* add next byte */
+
+       if (( tmp & 0xf0) == 0x10){             /* 2 byte count */
+               data_cnt = *src;
+               data_cnt++;
+
+       }else {                                 /* one byte count */
+               data_cnt = tmp >> 4;
+               data_cnt++;
+       }               
+
+       
+       src = (dst - 1 - data_offset);
+       if ( src < buf_start)
+               src += MAX_WIN_BUF_LEN;
+
+
+/*XXX could do some fancy memory moves, later if speed is problem */
+
+       while( data_cnt--){
+               *dst = *src;
+               if ( ++(*len) >MAX_WCP_BUF_LEN){
+                       printf("decomp failed, len = %d\n",  *len);
+
+                       return NULL;    /* end of buffer error */
+               }
+               if ( dst++ == buf_end)
+                       dst = buf_start;
+               if ( src++ == buf_end)
+                       src = buf_start;
+
+       }
+       return dst;
+}
+
+
+static 
+wcp_window_t *get_wcp_window_ptr( packet_info *pinfo){
+
+/* find the conversation for this side of the DLCI, create one if needed */
+/* and return the wcp_window data structure pointer */
+
+       conversation_t *conv = find_conversation( &pinfo->dl_src, &pinfo->dl_src, PT_NONE, 
+               ((pinfo->pseudo_header->x25.flags & FROM_DCE)? 1:0), 
+               ((pinfo->pseudo_header->x25.flags & FROM_DCE)? 1:0), 0);
+
+       if ( !conv){
+
+               conv = conversation_new( &pinfo->dl_src, &pinfo->dl_src, PT_NONE, 
+                       ((pinfo->pseudo_header->x25.flags & FROM_DCE)? 1:0), 
+                       ((pinfo->pseudo_header->x25.flags & FROM_DCE)? 1:0),
+                       g_mem_chunk_alloc( wcp_window), 0);
+                       
+               ((wcp_window_t*)conv->data)->buf_cur = ((wcp_window_t*)conv->data)->buffer;
+       }
+
+       return (wcp_window_t*)conv->data;
+}
+
+
+static tvbuff_t *wcp_uncompress( tvbuff_t *src_tvb, int offset, packet_info *pinfo, proto_tree *tree) {
+
+/* do the packet data uncompression and load it into the dst buffer */
+
+       proto_tree      *sub_tree;
+       proto_item      *ti;
+
+       int len=0, i = -1;
+       int cnt = tvb_reported_length( src_tvb)-1;      /* don't include check byte */
+
+       guint8 *buf = 0, *dst, *src, *buf_start, *buf_end,  *tmp, comp_flag_bits = 0;
+       guint8 src_buf[ MAX_WCP_BUF_LEN];
+       tvbuff_t *tvb = 0;
+       wcp_window_t *buf_ptr = 0;
+       wcp_pdata_t *pdata_ptr;
+
+       buf_ptr = get_wcp_window_ptr( pinfo); 
+
+       buf_start = buf_ptr->buffer;
+       buf_end = buf_start + MAX_WIN_BUF_LEN;
+       tmp = buf_ptr->buf_cur;
+
+       src = tvb_memcpy(src_tvb, src_buf, offset, cnt - offset);
+       dst = buf_ptr->buf_cur;
+
+       while( offset++ < cnt){
+
+               if ( --i >= 0){
+                       if ( comp_flag_bits & 0x80){    /* if this is a compressed entry */
+
+                               if ( !pinfo->fd->flags.visited){        /* if first pass */
+                                       dst = decompressed_entry( src, dst, &len, buf_start, buf_end);
+                               }
+                               if ((*src & 0xf0) == 0x10){
+                                       ti = proto_tree_add_item( tree, hf_wcp_long_run, src_tvb,
+                                                        offset-1, 3, 0);
+                                       sub_tree = proto_item_add_subtree(ti, ett_wcp_field);
+                                       proto_tree_add_uint(sub_tree, hf_wcp_offset, src_tvb,
+                                                        offset-1, 2, pntohs(src));
+
+                                       proto_tree_add_item( sub_tree, hf_wcp_long_len, src_tvb,
+                                                        offset+1, 1, pntohs(src));
+                                       src += 3;
+                                       offset += 2;
+                               }else{
+                                       ti = proto_tree_add_item( tree, hf_wcp_short_run, src_tvb,
+                                                        offset - 1, 2, *src);
+                                       sub_tree = proto_item_add_subtree(ti, ett_wcp_field);
+                                       proto_tree_add_item( sub_tree, hf_wcp_short_len, src_tvb,
+                                                        offset-1, 1, *src);
+                                       proto_tree_add_uint(sub_tree, hf_wcp_offset, src_tvb,
+                                                        offset-1, 2, pntohs(src));
+                                       src += 2;
+                                       offset += 1;
+                               }
+                       }else {
+                               if ( !pinfo->fd->flags.visited){        /* if first pass */
+                                       *dst = *src;
+                                       if ( dst++ == buf_end)
+                                               dst = buf_start;
+                               }
+                               ++src;
+                               ++len;
+
+                       }
+
+                       if ( len >MAX_WCP_BUF_LEN){
+                               return NULL;
+                       }
+
+                       comp_flag_bits <<= 1;
+
+               }else { /* compressed data flag */
+
+                       comp_flag_bits = *src++;
+                       proto_tree_add_uint( tree, hf_wcp_comp_bits,  src_tvb, offset-1, 1, comp_flag_bits);
+                               
+                       i = 8;
+               }
+       }
+
+       if ( pinfo->fd->flags.visited){ /* if not first pass */
+                                       /* get uncompressed data */
+               pdata_ptr = p_get_proto_data( pinfo->fd, proto_wcp);
+
+               if ( !pdata_ptr)        /* exit if no data */
+                       return NULL;
+               len = pdata_ptr->len;   
+       } else {
+
+       /* save the new data as per packet data */
+               pdata_ptr = g_mem_chunk_alloc( wcp_pdata);
+               memcpy( &pdata_ptr->buffer, buf_ptr->buf_cur,  len);
+               pdata_ptr->len = len;
+
+               p_add_proto_data( pinfo->fd, proto_wcp, (void*)pdata_ptr);      
+
+               buf_ptr->buf_cur = dst;
+       }
+
+
+        TRY {
+                tvb = tvb_new_real_data( pdata_ptr->buffer, pdata_ptr->len, pdata_ptr->len, "uncompressed");
+
+        }
+        CATCH(BoundsError) {
+                g_assert_not_reached();
+               g_free(buf);
+               return NULL;
+        }
+        CATCH(ReportedBoundsError) {
+               g_free(buf);
+               return NULL;
+        }
+        ENDTRY; 
+
+       /* Add new data to the data source list */
+       pinfo->fd->data_src = g_slist_append( pinfo->fd->data_src, tvb);
+       return tvb;
+
+}
+
+
+static void wcp_reinit( void){
+
+/* Do the cleanup work when a new pass through the packet list is       */
+/* performed. re-initialize the  memory chunks.                         */
+
+        if (wcp_window)
+                g_mem_chunk_destroy(wcp_window);
+
+        wcp_window = g_mem_chunk_new("wcp_window", wcp_win_length,
+                wcp_win_init_count * wcp_win_length,
+                G_ALLOC_AND_FREE);
+
+        if (wcp_pdata)
+                g_mem_chunk_destroy(wcp_pdata);
+
+        wcp_pdata = g_mem_chunk_new("wcp_pdata", wcp_packet_length,
+                wcp_packet_init_count * wcp_packet_length,
+                G_ALLOC_AND_FREE);
+
+}
+
+
+void
+proto_register_wcp(void)
+{
+    static hf_register_info hf[] = {
+       { &hf_wcp_cmd,
+         { "Command", "wcp.cmd", FT_UINT8, BASE_HEX, VALS(cmd_string), WCP_CMD, 
+               "Compression Command" }},
+       { &hf_wcp_ext_cmd,
+         { "Extended Command", "wcp.ext_cmd", FT_UINT8, BASE_HEX, VALS(ext_cmd_string), WCP_EXT_CMD, 
+               "Extended Compression Command" }},
+       { &hf_wcp_seq,
+         { "SEQ", "wcp.seq", FT_UINT16, BASE_HEX, NULL, WCP_SEQ, 
+               "Sequence Number" }},
+       { &hf_wcp_chksum,
+         { "Checksum", "wcp.checksum", FT_UINT8, BASE_DEC, NULL, 0,
+               "Packet Checksum" }},
+       { &hf_wcp_tid,
+         { "TID", "wcp.tid", FT_UINT16, BASE_DEC, NULL, 0,
+               "TID" }},
+       { &hf_wcp_rev,
+         { "Revision", "wcp.rev", FT_UINT8, BASE_DEC, NULL, 0,
+               "Revision" }},
+       { &hf_wcp_init,
+         { "Initiator", "wcp.init", FT_UINT8, BASE_DEC, NULL, 0,
+               "Initiator" }},
+       { &hf_wcp_seq_size,
+         { "Seq Size", "wcp.seq_size", FT_UINT8, BASE_DEC, NULL, 0,
+               "Sequence Size"}},
+       { &hf_wcp_alg_cnt,
+         { "Alg Count", "wcp.alg_cnt", FT_UINT8, BASE_DEC, NULL, 0,
+               "Algorithm Count"}},
+       { &hf_wcp_alg_a,
+         { "Alg 1", "wcp.alg1", FT_UINT8, BASE_DEC, NULL, 0,
+               "Algorithm #1"}},
+       { &hf_wcp_alg_b,
+         { "Alg 2", "wcp.alg2", FT_UINT8, BASE_DEC, NULL, 0,
+               "Algorithm #2"}},
+       { &hf_wcp_alg_c,
+         { "Alg 3", "wcp.alg3", FT_UINT8, BASE_DEC, NULL, 0,
+               "Algorithm #3"}},
+       { &hf_wcp_alg_d,
+         { "Alg 4", "wcp.alg4", FT_UINT8, BASE_DEC, NULL, 0,
+               "Algorithm #4"}},
+       { &hf_wcp_alg,
+         { "Alg", "wcp.alg", FT_UINT8, BASE_DEC, NULL, 0,
+               "Algorithm"}},
+       { &hf_wcp_rexmit,
+         { "Rexmit", "wcp.rexmit", FT_UINT8, BASE_DEC, NULL, 0,
+               "Retransmit"}},
+       { &hf_wcp_hist_size,
+         { "History", "wcp.hist", FT_UINT8, BASE_DEC, NULL, 0,
+               "History Size"}},
+       { &hf_wcp_ppc,
+         { "PerPackComp", "wcp.ppc", FT_UINT8, BASE_DEC, NULL, 0,
+               "Per Packet Compression"}},
+       { &hf_wcp_pib,
+         { "PIB", "wcp.pib", FT_UINT8, BASE_DEC, NULL, 0,
+               "PIB"}},
+       { &hf_wcp_comp_bits,
+         { "Compress Flag", "wcp.flag", FT_UINT8, BASE_HEX, NULL, 0,
+               "Compressed byte flag"}},
+       { &hf_wcp_comp_marker,
+         { "Compress Marker", "wcp.mark", FT_UINT8, BASE_BIN, NULL, 0,
+               "Compressed marker"}},
+       { &hf_wcp_offset,
+         { "Source offset", "wcp.off", FT_UINT16, BASE_HEX, NULL, WCP_OFFSET_MASK,
+               "Data source offset"}},
+       { &hf_wcp_short_len,
+         { "Compress Length", "wcp.short_len", FT_UINT8, BASE_HEX, NULL, 0xf0,
+               "Compressed length"}},
+       { &hf_wcp_long_len,
+         { "Compress Length", "wcp.long_len", FT_UINT8, BASE_HEX, NULL, 0,
+               "Compressed length"}},
+       { &hf_wcp_long_run,
+         { "Long Compression", "wcp.long_comp", FT_UINT16, BASE_HEX, NULL, 0,
+               "Long Compression type"}},
+       { &hf_wcp_short_run,
+         { "Short Compression", "wcp.short_comp", FT_UINT8, BASE_HEX, NULL, 0,
+               "Short Compression type"}},
+       { &hf_wcp_oui, {
+          "Organization Code", "wcp.snap.oui", FT_UINT24, BASE_HEX, 
+          VALS(oui_vals), 0x0, ""}},
+       { &hf_wcp_pid, {
+          "Protocol ID", "wcp.snap.pid", FT_UINT16, BASE_HEX, 
+          NULL, 0x0, ""}},
+        { &hf_wcp_type, { 
+           "Type", "wcp.type", FT_UINT16, BASE_HEX, 
+            NULL, 0x0, "WCP SNAP Encapsulated Protocol" }},
+
+   };
+
+
+    static gint *ett[] = {
+        &ett_wcp,
+       &ett_wcp_field,
+    };
+
+    proto_wcp = proto_register_protocol ("Wellfleet Compression", "WCP", "wcp");
+    proto_register_field_array (proto_wcp, hf, array_length(hf));
+    proto_register_subtree_array(ett, array_length(ett));
+    register_init_routine(&wcp_reinit);
+}
+
+
+void
+proto_reg_handoff_wcp(void) {
+
+    dissector_add("fr.ietf", NLPID_WCP, dissect_wcp, proto_wcp);
+    dissector_add("ethertype",  ETHERTYPE_WCP, dissect_wcp, proto_wcp);
+}
+
+
+