/* packet-null.c
* Routines for null packet disassembly
*
- * $Id: packet-null.c,v 1.39 2001/01/18 07:44:39 guy Exp $
+ * $Id: packet-null.c,v 1.55 2002/08/03 19:49:30 guy Exp $
*
* Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
*
- * This file created and by Mike Hall <mlh@io.com>
+ * This file created by Mike Hall <mlh@io.com>
* Copyright 1998
*
* This program is free software; you can redistribute it and/or
# include "config.h"
#endif
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
#include <glib.h>
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-
#include <string.h>
-#include "packet.h"
+#include <epan/packet.h>
#include "packet-null.h"
-#include "packet-atalk.h"
+#include <epan/atalk-utils.h>
#include "packet-ip.h"
-#include "packet-ipv6.h"
#include "packet-ipx.h"
#include "packet-osi.h"
#include "packet-ppp.h"
static dissector_table_t null_dissector_table;
-extern const value_string etype_vals[];
-
/* protocols and header fields */
static int proto_null = -1;
static int hf_null_etype = -1;
{BSD_AF_IPX, "Netware IPX/SPX"},
{BSD_AF_INET6_BSD, "IPv6" },
{BSD_AF_INET6_FREEBSD, "IPv6" },
+ {BSD_AF_INET6_DARWIN, "IPv6" },
{0, NULL }
};
-static dissector_handle_t ppp_handle;
-
+static dissector_handle_t ppp_hdlc_handle;
+static dissector_handle_t data_handle;
void
-capture_null( const u_char *pd, packet_counts *ld )
+capture_null( const guchar *pd, int len, packet_counts *ld )
{
guint32 null_header;
* given that the effect of inserting the two 0 bytes depends only
* on the byte order of the machine reading the file.)
*/
+ if (!BYTES_ARE_IN_FRAME(0, len, 2)) {
+ ld->other++;
+ return;
+ }
if (pd[0] == 0xFF && pd[1] == 0x03) {
/*
* Hand it to PPP.
*/
- capture_ppp(pd, 0, ld);
+ capture_ppp_hdlc(pd, 0, len, ld);
} else {
/*
* Treat it as a normal DLT_NULL header.
*/
+ if (!BYTES_ARE_IN_FRAME(0, len, (int)sizeof(null_header))) {
+ ld->other++;
+ return;
+ }
memcpy((char *)&null_header, (char *)&pd[0], sizeof(null_header));
if ((null_header & 0xFFFF0000) != 0) {
* BSD derivatives have different values?).
*/
if (null_header > IEEE_802_3_MAX_LEN)
- capture_ethertype(null_header, 4, pd, ld);
+ capture_ethertype(null_header, pd, 4, len, ld);
else {
switch (null_header) {
case BSD_AF_INET:
- capture_ip(pd, 4, ld);
+ capture_ip(pd, 4, len, ld);
break;
default:
proto_item *ti;
tvbuff_t *next_tvb;
- CHECK_DISPLAY_AS_DATA(proto_null, tvb, pinfo, tree);
-
- pinfo->current_proto = "Null";
-
/*
* See comment in "capture_null()" for an explanation of what we're
* doing.
/*
* Hand it to PPP.
*/
- call_dissector(ppp_handle, tvb, pinfo, tree);
+ call_dissector(ppp_hdlc_handle, tvb, pinfo, tree);
} else {
/* load the top pane info. This should be overwritten by
the next protocol in the stack */
- if(check_col(pinfo->fd, COL_RES_DL_SRC))
- col_set_str(pinfo->fd, COL_RES_DL_SRC, "N/A" );
- if(check_col(pinfo->fd, COL_RES_DL_DST))
- col_set_str(pinfo->fd, COL_RES_DL_DST, "N/A" );
- if(check_col(pinfo->fd, COL_PROTOCOL))
- col_set_str(pinfo->fd, COL_PROTOCOL, "N/A" );
- if(check_col(pinfo->fd, COL_INFO))
- col_set_str(pinfo->fd, COL_INFO, "Null/Loopback" );
+ if(check_col(pinfo->cinfo, COL_RES_DL_SRC))
+ col_set_str(pinfo->cinfo, COL_RES_DL_SRC, "N/A" );
+ if(check_col(pinfo->cinfo, COL_RES_DL_DST))
+ col_set_str(pinfo->cinfo, COL_RES_DL_DST, "N/A" );
+ if(check_col(pinfo->cinfo, COL_PROTOCOL))
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "N/A" );
+ if(check_col(pinfo->cinfo, COL_INFO))
+ col_set_str(pinfo->cinfo, COL_INFO, "Null/Loopback" );
/*
* Treat it as a normal DLT_NULL header.
if (!dissector_try_port(null_dissector_table, null_header,
next_tvb, pinfo, tree)) {
/* No sub-dissector found. Label rest of packet as "Data" */
- dissect_data(next_tvb, 0, pinfo, tree);
+ call_dissector(data_handle,next_tvb, pinfo, tree);
}
}
}
/* registered here but handled in ethertype.c */
{ &hf_null_etype,
{ "Type", "null.type", FT_UINT16, BASE_HEX, VALS(etype_vals), 0x0,
- "" }},
+ "", HFILL }},
{ &hf_null_family,
{ "Family", "null.family", FT_UINT32, BASE_HEX, VALS(family_vals), 0x0,
- "" }}
+ "", HFILL }}
};
static gint *ett[] = {
&ett_null,
proto_register_subtree_array(ett, array_length(ett));
/* subdissector code */
- null_dissector_table = register_dissector_table("null.type");
+ null_dissector_table = register_dissector_table("null.type",
+ "BSD AF_ type", FT_UINT32, BASE_DEC);
}
void
proto_reg_handoff_null(void)
{
+ dissector_handle_t null_handle;
+
/*
- * Get a handle for the PPP dissector.
+ * Get a handle for the PPP-in-HDLC-like-framing dissector.
*/
- ppp_handle = find_dissector("ppp");
- dissector_add("wtap_encap", WTAP_ENCAP_NULL, dissect_null, proto_null);
+ ppp_hdlc_handle = find_dissector("ppp_hdlc");
+ data_handle = find_dissector("data");
+ null_handle = create_dissector_handle(dissect_null, proto_null);
+ dissector_add("wtap_encap", WTAP_ENCAP_NULL, null_handle);
}