Index: packet-ranap.c
===================================================================
RCS file: /cvsroot/ethereal/packet-ranap.c,v
retrieving revision 1.20
diff -u -r1.20 packet-ranap.c
--- packet-ranap.c	6 Oct 2003 08:35:30 -0000	1.20
+++ packet-ranap.c	1 Dec 2003 21:24:19 -0000
@@ -4115,6 +4115,39 @@
 }
 
 
+static gboolean
+dissect_sccp_ranap_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+{
+    guint8 temp;
+
+    /* Is it a ranap packet?
+     *
+     * 4th octet should be the length of the rest of the message.
+     *    note: I believe the length octet may actually be represented
+     *          by more than one octet.  Something like...
+     *          bit 01234567          octets
+     *              0xxxxxxx             1
+     *              10xxxxxx xxxxxxxx    2
+     *          For now, we have ignored this.  I hope that's safe.
+     *
+     * 2nd octet is the message-type e Z[0, 28]
+     * (obviously there must be at least four octets)
+     *
+     * If both hold true we'll assume its RANAP
+     */
+
+    #define LENGTH_OFFSET 3
+    #define MSG_TYPE_OFFSET 1
+    if (tvb_length(tvb) < 4) { return FALSE; }
+    if (tvb_get_guint8(tvb, LENGTH_OFFSET) != (tvb_length(tvb) - 4)) { return FALSE; }
+    temp = tvb_get_guint8(tvb, MSG_TYPE_OFFSET);
+    if (temp > 28) { return FALSE; }
+
+    dissect_ranap(tvb, pinfo, tree);
+
+    return TRUE;
+}
+
 
 /*****************************************************************************/
 /*                                                                           */
@@ -4822,4 +4855,10 @@
   dissector_add("sua.ssn",  SCCP_SSN_RANAP, ranap_handle);
   */
   dissector_add("sccp.ssn", SCCP_SSN_RANAP, ranap_handle);
+
+  /* Add heuristic dissector
+   * Perhaps we want a preference whether the heuristic dissector
+   * is or isn't enabled
+   */
+  heur_dissector_add("sccp", dissect_sccp_ranap_heur, proto_ranap);
 }
