1999-07-28 23:16:42 +00:00
|
|
|
/* packet-clip.c
|
|
|
|
* Routines for clip packet disassembly
|
|
|
|
*
|
2006-05-21 04:49:01 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
1999-07-28 23:16:42 +00:00
|
|
|
*
|
|
|
|
* This file created by Thierry Andry <Thierry.Andry@advalvas.be>
|
|
|
|
* from nearly-the-same packet-raw.c created by Mike Hall <mlh@io.com>
|
|
|
|
* Copyright 1999
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-07-28 23:16:42 +00:00
|
|
|
* 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.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-07-28 23:16:42 +00:00
|
|
|
* 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.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-07-28 23:16:42 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2012-06-28 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
1999-07-28 23:16:42 +00:00
|
|
|
*/
|
|
|
|
|
2012-09-20 02:03:38 +00:00
|
|
|
#include "config.h"
|
1999-07-28 23:16:42 +00:00
|
|
|
|
|
|
|
#include <glib.h>
|
2013-11-29 20:53:00 +00:00
|
|
|
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/packet.h>
|
2014-08-01 14:08:57 +00:00
|
|
|
#include <epan/expert.h>
|
2013-11-29 20:53:00 +00:00
|
|
|
#include <wiretap/wtap.h>
|
|
|
|
|
2000-05-19 05:29:44 +00:00
|
|
|
#include "packet-clip.h"
|
2000-02-15 21:06:58 +00:00
|
|
|
#include "packet-ip.h"
|
1999-07-28 23:16:42 +00:00
|
|
|
|
2013-03-15 06:26:47 +00:00
|
|
|
void proto_register_clip(void);
|
|
|
|
void proto_reg_handoff_clip(void);
|
|
|
|
|
2014-08-01 14:08:57 +00:00
|
|
|
static int proto_clip = -1;
|
|
|
|
|
1999-11-16 11:44:20 +00:00
|
|
|
static gint ett_clip = -1;
|
|
|
|
|
2014-08-01 14:08:57 +00:00
|
|
|
static expert_field ei_no_link_info = EI_INIT;
|
|
|
|
|
Tvbuffify the IP, ICMP, TCP, UDP, OSI CLNP, OSI COTP, OSI CLTP, and OSI
ESIS dissectors.
Register the IP dissector and have dissectors that call it directly
(rather than through a port table) call it through a handle.
Add a routine "tvb_set_reported_length()" which a dissector can use if
it was handed a tvbuff that contains more data than is actually in its
part of the packet - for example, handing a padded Ethernet frame to IP;
the routine sets the reported length of the tvbuff (and also adjusts the
actual length, as appropriate). Then use it in IP.
Given that, "ethertype()" can determine how much of the Ethernet frame
was actually part of an IP datagram (and can do the same for other
protocols under Ethernet that use "tvb_set_reported_length()"; have it
return the actual length, and have "dissect_eth()" and "dissect_vlan()"
use that to mark trailer data in Ethernet II frames as well as in 802.3
frames.
svn path=/trunk/; revision=2658
2000-11-18 10:38:33 +00:00
|
|
|
static dissector_handle_t ip_handle;
|
|
|
|
|
1999-07-28 23:16:42 +00:00
|
|
|
void
|
2002-08-02 23:36:07 +00:00
|
|
|
capture_clip( const guchar *pd, int len, packet_counts *ld ) {
|
1999-07-28 23:16:42 +00:00
|
|
|
|
2001-11-20 21:59:18 +00:00
|
|
|
capture_ip(pd, 0, len, ld);
|
1999-07-28 23:16:42 +00:00
|
|
|
}
|
|
|
|
|
2000-11-29 05:16:15 +00:00
|
|
|
static void
|
2000-05-25 14:55:22 +00:00
|
|
|
dissect_clip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
2014-09-30 23:12:26 +00:00
|
|
|
proto_item *fh_item;
|
1999-07-28 23:16:42 +00:00
|
|
|
|
2000-05-25 18:32:06 +00:00
|
|
|
pinfo->current_proto = "CLIP";
|
2000-05-25 15:11:11 +00:00
|
|
|
|
1999-07-28 23:16:42 +00:00
|
|
|
/* load the top pane info. This should be overwritten by
|
|
|
|
the next protocol in the stack */
|
2009-08-09 07:14:16 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_RES_DL_SRC, "N/A");
|
|
|
|
col_set_str(pinfo->cinfo, COL_RES_DL_DST, "N/A");
|
2009-08-09 06:47:24 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "CLIP");
|
2009-08-09 07:01:26 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_INFO, "Classical IP frame");
|
1999-07-28 23:16:42 +00:00
|
|
|
|
|
|
|
/* populate a tree in the second pane with the status of the link
|
|
|
|
layer (ie none)
|
|
|
|
|
2001-09-23 23:10:30 +00:00
|
|
|
XXX - the Linux Classical IP code supports both LLC Encapsulation,
|
|
|
|
which puts an LLC header and possibly a SNAP header in front of
|
|
|
|
the network-layer header, and VC Based Multiplexing, which puts
|
|
|
|
no headers in front of the network-layer header.
|
|
|
|
|
|
|
|
The ATM on Linux code includes a patch to "tcpdump"
|
1999-07-28 23:16:42 +00:00
|
|
|
that compares the first few bytes of the packet with the
|
|
|
|
LLC header that Classical IP frames may have and, if there's
|
|
|
|
a SNAP LLC header at the beginning of the packet, it gets
|
|
|
|
the packet type from that header and uses that, otherwise
|
|
|
|
it treats the packet as being raw IP with no link-level
|
2001-09-23 23:10:30 +00:00
|
|
|
header, in order to handle both of those.
|
|
|
|
|
|
|
|
This code, however, won't handle LLC Encapsulation. We've
|
|
|
|
not yet seen a capture taken on a machine using LLC Encapsulation,
|
|
|
|
however. If we see one, we can modify the code.
|
|
|
|
|
|
|
|
A future version of libpcap, however, will probably use DLT_LINUX_SLL
|
|
|
|
for both of those cases, to avoid the headache of having to
|
|
|
|
generate capture-filter code to handle both of those cases. */
|
2014-08-01 14:08:57 +00:00
|
|
|
fh_item = proto_tree_add_item(tree, proto_clip, tvb, 0, 0, ENC_NA);
|
|
|
|
expert_add_info(pinfo, fh_item, &ei_no_link_info);
|
|
|
|
|
Tvbuffify the IP, ICMP, TCP, UDP, OSI CLNP, OSI COTP, OSI CLTP, and OSI
ESIS dissectors.
Register the IP dissector and have dissectors that call it directly
(rather than through a port table) call it through a handle.
Add a routine "tvb_set_reported_length()" which a dissector can use if
it was handed a tvbuff that contains more data than is actually in its
part of the packet - for example, handing a padded Ethernet frame to IP;
the routine sets the reported length of the tvbuff (and also adjusts the
actual length, as appropriate). Then use it in IP.
Given that, "ethertype()" can determine how much of the Ethernet frame
was actually part of an IP datagram (and can do the same for other
protocols under Ethernet that use "tvb_set_reported_length()"; have it
return the actual length, and have "dissect_eth()" and "dissect_vlan()"
use that to mark trailer data in Ethernet II frames as well as in 802.3
frames.
svn path=/trunk/; revision=2658
2000-11-18 10:38:33 +00:00
|
|
|
call_dissector(ip_handle, tvb, pinfo, tree);
|
1999-07-28 23:16:42 +00:00
|
|
|
}
|
1999-11-16 11:44:20 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
proto_register_clip(void)
|
|
|
|
{
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_clip,
|
|
|
|
};
|
|
|
|
|
2014-08-01 14:08:57 +00:00
|
|
|
static ei_register_info ei[] = {
|
|
|
|
{ &ei_no_link_info, { "clip.no_link_info", PI_PROTOCOL, PI_NOTE, "No link information available", EXPFILL }},
|
|
|
|
};
|
|
|
|
|
|
|
|
expert_module_t* expert_clip;
|
|
|
|
|
|
|
|
proto_clip = proto_register_protocol("Classical IP frame", "CLIP", "clip");
|
|
|
|
|
1999-11-16 11:44:20 +00:00
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
2014-08-01 14:08:57 +00:00
|
|
|
expert_clip = expert_register_protocol(proto_clip);
|
|
|
|
expert_register_field_array(expert_clip, ei, array_length(ei));
|
1999-11-16 11:44:20 +00:00
|
|
|
}
|
Tvbuffify the IP, ICMP, TCP, UDP, OSI CLNP, OSI COTP, OSI CLTP, and OSI
ESIS dissectors.
Register the IP dissector and have dissectors that call it directly
(rather than through a port table) call it through a handle.
Add a routine "tvb_set_reported_length()" which a dissector can use if
it was handed a tvbuff that contains more data than is actually in its
part of the packet - for example, handing a padded Ethernet frame to IP;
the routine sets the reported length of the tvbuff (and also adjusts the
actual length, as appropriate). Then use it in IP.
Given that, "ethertype()" can determine how much of the Ethernet frame
was actually part of an IP datagram (and can do the same for other
protocols under Ethernet that use "tvb_set_reported_length()"; have it
return the actual length, and have "dissect_eth()" and "dissect_vlan()"
use that to mark trailer data in Ethernet II frames as well as in 802.3
frames.
svn path=/trunk/; revision=2658
2000-11-18 10:38:33 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
proto_reg_handoff_clip(void)
|
|
|
|
{
|
2001-12-03 04:00:26 +00:00
|
|
|
dissector_handle_t clip_handle;
|
|
|
|
|
Tvbuffify the IP, ICMP, TCP, UDP, OSI CLNP, OSI COTP, OSI CLTP, and OSI
ESIS dissectors.
Register the IP dissector and have dissectors that call it directly
(rather than through a port table) call it through a handle.
Add a routine "tvb_set_reported_length()" which a dissector can use if
it was handed a tvbuff that contains more data than is actually in its
part of the packet - for example, handing a padded Ethernet frame to IP;
the routine sets the reported length of the tvbuff (and also adjusts the
actual length, as appropriate). Then use it in IP.
Given that, "ethertype()" can determine how much of the Ethernet frame
was actually part of an IP datagram (and can do the same for other
protocols under Ethernet that use "tvb_set_reported_length()"; have it
return the actual length, and have "dissect_eth()" and "dissect_vlan()"
use that to mark trailer data in Ethernet II frames as well as in 802.3
frames.
svn path=/trunk/; revision=2658
2000-11-18 10:38:33 +00:00
|
|
|
/*
|
|
|
|
* Get a handle for the IP dissector.
|
|
|
|
*/
|
|
|
|
ip_handle = find_dissector("ip");
|
2001-12-03 04:00:26 +00:00
|
|
|
|
|
|
|
clip_handle = create_dissector_handle(dissect_clip, -1);
|
|
|
|
/* XXX - no protocol, can't be disabled */
|
2010-12-20 05:35:29 +00:00
|
|
|
dissector_add_uint("wtap_encap", WTAP_ENCAP_LINUX_ATM_CLIP, clip_handle);
|
Tvbuffify the IP, ICMP, TCP, UDP, OSI CLNP, OSI COTP, OSI CLTP, and OSI
ESIS dissectors.
Register the IP dissector and have dissectors that call it directly
(rather than through a port table) call it through a handle.
Add a routine "tvb_set_reported_length()" which a dissector can use if
it was handed a tvbuff that contains more data than is actually in its
part of the packet - for example, handing a padded Ethernet frame to IP;
the routine sets the reported length of the tvbuff (and also adjusts the
actual length, as appropriate). Then use it in IP.
Given that, "ethertype()" can determine how much of the Ethernet frame
was actually part of an IP datagram (and can do the same for other
protocols under Ethernet that use "tvb_set_reported_length()"; have it
return the actual length, and have "dissect_eth()" and "dissect_vlan()"
use that to mark trailer data in Ethernet II frames as well as in 802.3
frames.
svn path=/trunk/; revision=2658
2000-11-18 10:38:33 +00:00
|
|
|
}
|
2014-09-30 23:12:26 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
|
|
|
*
|
|
|
|
* Local Variables:
|
|
|
|
* c-basic-offset: 2
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* ex: set shiftwidth=2 tabstop=8 expandtab:
|
|
|
|
* :indentSize=2:tabSize=8:noTabs=true:
|
|
|
|
*/
|