aboutsummaryrefslogtreecommitdiffstats
path: root/packet-yhoo.c
diff options
context:
space:
mode:
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2000-05-05 09:32:36 +0000
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2000-05-05 09:32:36 +0000
commit449d904e572464df76fdee2852368db15b1465eb (patch)
tree950d9eb832f91889530022ffd446ddf3b4772801 /packet-yhoo.c
parentbba60bca8ccf55df30c451bbc4d8ef343c0987b9 (diff)
Add routines to:
register lists of "heuristic" dissectors, which are handed a frame that may or may contain a payload for the protocol they dissect, and that return FALSE if it's not or dissect the packet and return TRUE if it is; add a dissector to such a list; go through such a list, calling each dissector until either a dissector returns TRUE, in which case the routine returns TRUE, or it runs out of entries in the list, in which case the routine returns FALSE. Have lists of heuristic dissectors for TCP and for COTP when used with the Inactive Subset of CLNP, and add the GIOP and Yahoo Messenger dissectors to the first list and the Sinec H1 dissector to the second list. Make the dissector name argument to "dissector_add()" and "dissector_delete()" a "const char *" rarther than just a "char *". Add "heur_dissector_add()", the routine to add a heuristic dissector to a list of heuristic dissectors, to the set of routines we can export to plugins through a table on platforms where dynamically-loaded code can't call stuff in the main program, and initialize the element in the table in question for "dissector_add()" (which we'd forgotten to do). git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@1909 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'packet-yhoo.c')
-rw-r--r--packet-yhoo.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/packet-yhoo.c b/packet-yhoo.c
index 4dcc965c51..5f6361b694 100644
--- a/packet-yhoo.c
+++ b/packet-yhoo.c
@@ -2,7 +2,7 @@
* Routines for yahoo messenger packet dissection
* Copyright 1999, Nathan Neulinger <nneul@umr.edu>
*
- * $Id: packet-yhoo.c,v 1.5 2000/01/07 22:05:42 guy Exp $
+ * $Id: packet-yhoo.c,v 1.6 2000/05/05 09:32:06 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -58,6 +58,8 @@ static int hf_yhoo_content = -1;
static gint ett_yhoo = -1;
+#define TCP_PORT_YHOO 5050
+
static const value_string yhoo_service_vals[] = {
{YAHOO_SERVICE_LOGON, "Pager Logon"},
{YAHOO_SERVICE_LOGOFF, "Pager Logoff"},
@@ -102,15 +104,30 @@ static const value_string yhoo_msgtype_vals[] = {
{0, NULL}
};
-void
+static gboolean
dissect_yhoo(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
{
proto_tree *yhoo_tree, *ti;
struct yahoo_rawpacket *pkt;
+ if (pi.srcport != TCP_PORT_YHOO && pi.destport != TCP_PORT_YHOO) {
+ /* Not the Yahoo port - not a Yahoo Messenger packet. */
+ return FALSE;
+ }
+
/* get at least a full packet structure */
- if ( !BYTES_ARE_IN_FRAME(offset, sizeof(struct yahoo_rawpacket)) )
- return;
+ if ( !BYTES_ARE_IN_FRAME(offset, sizeof(struct yahoo_rawpacket)) ) {
+ /* Not enough data captured; maybe it is a Yahoo
+ Messenger packet, but it contains too little data to
+ tell. */
+ return FALSE;
+ }
+
+ if (memcmp(&pd[offset], "YPNS", 4) != 0 &&
+ memcmp(&pd[offset], "YHOO", 4) != 0) {
+ /* Not a Yahoo Messenger packet. */
+ return FALSE;
+ }
pkt = (struct yahoo_rawpacket *) &pd[offset];
@@ -150,6 +167,8 @@ dissect_yhoo(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
proto_tree_add_item(yhoo_tree, hf_yhoo_content,
offset+104, END_OF_FRAME, pkt->content);
}
+
+ return TRUE;
}
void
@@ -197,3 +216,9 @@ proto_register_yhoo(void)
proto_register_subtree_array(ett, array_length(ett));
}
+
+void
+proto_reg_handoff_yhoo(void)
+{
+ heur_dissector_add("tcp", dissect_yhoo);
+}