1999-06-11 15:30:55 +00:00
|
|
|
/* packet-gre.c
|
|
|
|
* Routines for the Generic Routing Encapsulation (GRE) protocol
|
|
|
|
* Brad Robel-Forrest <brad.robel-forrest@watchguard.com>
|
|
|
|
*
|
2000-11-19 08:54:37 +00:00
|
|
|
* $Id: packet-gre.c,v 1.29 2000/11/19 08:53:57 guy Exp $
|
1999-06-11 15:30:55 +00:00
|
|
|
*
|
|
|
|
* Ethereal - Network traffic analyzer
|
2000-01-07 22:05:43 +00:00
|
|
|
* By Gerald Combs <gerald@zing.org>
|
1999-06-11 15:30:55 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
|
|
|
# include <sys/types.h>
|
|
|
|
#endif
|
|
|
|
|
1999-07-13 02:53:26 +00:00
|
|
|
#ifdef HAVE_NETINET_IN_H
|
1999-06-11 15:30:55 +00:00
|
|
|
#include <netinet/in.h>
|
1999-07-13 02:53:26 +00:00
|
|
|
#endif
|
1999-06-11 15:30:55 +00:00
|
|
|
#include <glib.h>
|
|
|
|
#include "packet.h"
|
2000-02-15 21:06:58 +00:00
|
|
|
#include "packet-ip.h"
|
2000-05-18 08:41:22 +00:00
|
|
|
#include "packet-ipx.h"
|
1999-06-11 15:30:55 +00:00
|
|
|
|
1999-07-29 05:47:07 +00:00
|
|
|
static int proto_gre = -1;
|
1999-12-12 03:05:57 +00:00
|
|
|
static int hf_gre_proto = -1;
|
1999-07-29 05:47:07 +00:00
|
|
|
|
1999-11-16 11:44:20 +00:00
|
|
|
static gint ett_gre = -1;
|
|
|
|
static gint ett_gre_flags = -1;
|
|
|
|
|
1999-06-11 15:30:55 +00:00
|
|
|
/* bit positions for flags in header */
|
|
|
|
#define GH_B_C 0x8000
|
|
|
|
#define GH_B_R 0x4000
|
|
|
|
#define GH_B_K 0x2000
|
|
|
|
#define GH_B_S 0x1000
|
|
|
|
#define GH_B_s 0x0800
|
|
|
|
#define GH_B_RECUR 0x0700
|
|
|
|
#define GH_P_A 0x0080 /* only in special PPTPized GRE header */
|
|
|
|
#define GH_P_FLAGS 0x0078 /* only in special PPTPized GRE header */
|
|
|
|
#define GH_R_FLAGS 0x00F8
|
|
|
|
#define GH_B_VER 0x0007
|
|
|
|
|
|
|
|
#define GRE_PPP 0x880B
|
1999-12-09 02:53:33 +00:00
|
|
|
#define GRE_IP 0x0800
|
1999-12-12 03:05:57 +00:00
|
|
|
#define GRE_WCCP 0x883E
|
2000-05-18 08:41:22 +00:00
|
|
|
#define GRE_IPX 0x8137
|
1999-06-11 15:30:55 +00:00
|
|
|
|
|
|
|
static void add_flags_and_ver(proto_tree *, guint16, int, int);
|
|
|
|
|
1999-12-12 03:05:57 +00:00
|
|
|
static const value_string typevals[] = {
|
|
|
|
{ GRE_PPP, "PPP" },
|
|
|
|
{ GRE_IP, "IP" },
|
|
|
|
{ GRE_WCCP, "WCCP"},
|
2000-05-18 08:41:22 +00:00
|
|
|
{ GRE_IPX, "IPX"},
|
1999-12-12 03:05:57 +00:00
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
|
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;
|
2000-11-19 02:00:03 +00:00
|
|
|
static dissector_handle_t ppp_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
|
|
|
|
2000-04-16 22:46:25 +00:00
|
|
|
static void
|
1999-06-11 15:30:55 +00:00
|
|
|
dissect_gre(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
|
|
|
|
|
|
|
|
guint16 flags_and_ver = pntohs(pd + offset);
|
|
|
|
guint16 type = pntohs(pd + offset + sizeof(flags_and_ver));
|
1999-12-09 02:53:33 +00:00
|
|
|
guint16 sre_af;
|
|
|
|
guint8 sre_length;
|
2000-05-25 07:42:26 +00:00
|
|
|
tvbuff_t *next_tvb;
|
1999-06-11 15:30:55 +00:00
|
|
|
|
Add the "Edit:Protocols..." feature which currently only implements
the following:
It is now possible to enable/disable a particular protocol decoding
(i.e. the protocol dissector is void or not). When a protocol
is disabled, it is displayed as Data and of course, all linked
sub-protocols are disabled as well.
Disabling a protocol could be interesting:
- in case of buggy dissectors
- in case of wrong heuristics
- for performance reasons
- to decode the data as another protocol (TODO)
Currently (if I am not wrong), all dissectors but NFS can be disabled
(and dissectors that do not register protocols :-)
I do not like the way the RPC sub-dissectors are disabled (in the
sub-dissectors) since this could be done in the RPC dissector itself,
knowing the sub-protocol hfinfo entry (this is why, I've not modified
the NFS one yet).
Two functions are added in proto.c :
gboolean proto_is_protocol_enabled(int n);
void proto_set_decoding(int n, gboolean enabled);
and two MACROs which can be used in dissectors:
OLD_CHECK_DISPLAY_AS_DATA(index, pd, offset, fd, tree)
CHECK_DISPLAY_AS_DATA(index, tvb, pinfo, tree)
See also the XXX in proto_dlg.c and proto.c around the new functions.
svn path=/trunk/; revision=2267
2000-08-13 14:09:15 +00:00
|
|
|
OLD_CHECK_DISPLAY_AS_DATA(proto_gre, pd, offset, fd, tree);
|
|
|
|
|
1999-06-11 15:30:55 +00:00
|
|
|
if (check_col(fd, COL_PROTOCOL))
|
2000-11-19 08:54:37 +00:00
|
|
|
col_set_str(fd, COL_PROTOCOL, "GRE");
|
1999-06-11 15:30:55 +00:00
|
|
|
|
|
|
|
if (check_col(fd, COL_INFO)) {
|
1999-12-09 02:53:33 +00:00
|
|
|
col_add_fstr(fd, COL_INFO, "Encapsulated %s",
|
|
|
|
val_to_str(type, typevals, "0x%04X (unknown)"));
|
1999-06-11 15:30:55 +00:00
|
|
|
}
|
|
|
|
|
1999-09-17 05:56:58 +00:00
|
|
|
if (IS_DATA_IN_FRAME(offset) && tree) {
|
1999-12-12 03:05:57 +00:00
|
|
|
gboolean is_ppp = FALSE;
|
|
|
|
gboolean is_wccp2 = FALSE;
|
1999-06-11 15:30:55 +00:00
|
|
|
proto_item * ti;
|
|
|
|
proto_tree * gre_tree;
|
1999-12-12 03:05:57 +00:00
|
|
|
guint len = 4;
|
|
|
|
|
|
|
|
if (flags_and_ver & GH_B_C || flags_and_ver & GH_B_R)
|
|
|
|
len += 4;
|
|
|
|
if (flags_and_ver & GH_B_K)
|
|
|
|
len += 4;
|
|
|
|
if (flags_and_ver & GH_B_S)
|
|
|
|
len += 4;
|
|
|
|
switch (type) {
|
1999-06-11 15:30:55 +00:00
|
|
|
|
1999-12-12 03:05:57 +00:00
|
|
|
case GRE_PPP:
|
|
|
|
if (flags_and_ver & GH_P_A)
|
|
|
|
len += 4;
|
|
|
|
is_ppp = TRUE;
|
|
|
|
break;
|
1999-12-10 21:27:13 +00:00
|
|
|
|
1999-12-12 03:05:57 +00:00
|
|
|
case GRE_WCCP:
|
|
|
|
/* WCCP2 apparently puts an extra 4 octets into the header, but uses
|
|
|
|
the same encapsulation type; if it looks as if the first octet of
|
|
|
|
the packet isn't the beginning of an IPv4 header, assume it's
|
|
|
|
WCCP2. */
|
|
|
|
if ((pd[offset + sizeof(flags_and_ver) + sizeof(type)] & 0xF0) != 0x40) {
|
|
|
|
len += 4;
|
|
|
|
is_wccp2 = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2000-05-11 08:18:09 +00:00
|
|
|
ti = proto_tree_add_protocol_format(tree, proto_gre, NullTVB, offset, len,
|
1999-12-10 21:27:13 +00:00
|
|
|
"Generic Routing Encapsulation (%s)",
|
|
|
|
val_to_str(type, typevals, "0x%04X - unknown"));
|
|
|
|
gre_tree = proto_item_add_subtree(ti, ett_gre);
|
|
|
|
add_flags_and_ver(gre_tree, flags_and_ver, offset, is_ppp);
|
1999-06-11 15:30:55 +00:00
|
|
|
|
|
|
|
offset += sizeof(flags_and_ver);
|
|
|
|
|
2000-05-31 05:09:07 +00:00
|
|
|
proto_tree_add_uint(gre_tree, hf_gre_proto, NullTVB, offset, sizeof(type), type);
|
1999-12-12 03:05:57 +00:00
|
|
|
offset += sizeof(type);
|
1999-06-11 15:30:55 +00:00
|
|
|
|
|
|
|
if (flags_and_ver & GH_B_C || flags_and_ver & GH_B_R) {
|
|
|
|
guint16 checksum = pntohs(pd + offset);
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(gre_tree, NullTVB, offset, sizeof(checksum),
|
1999-06-11 15:30:55 +00:00
|
|
|
"Checksum: %u", checksum);
|
|
|
|
offset += sizeof(checksum);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags_and_ver & GH_B_C || flags_and_ver & GH_B_R) {
|
|
|
|
guint16 rtoffset = pntohs(pd + offset);
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(gre_tree, NullTVB, offset, sizeof(rtoffset),
|
1999-06-11 15:30:55 +00:00
|
|
|
"Offset: %u", rtoffset);
|
|
|
|
offset += sizeof(rtoffset);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags_and_ver & GH_B_K) {
|
|
|
|
if (is_ppp) {
|
|
|
|
guint16 paylen;
|
|
|
|
guint16 callid;
|
|
|
|
|
|
|
|
paylen = pntohs(pd + offset);
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(gre_tree, NullTVB, offset, sizeof(paylen),
|
1999-06-11 15:30:55 +00:00
|
|
|
"Payload length: %u", paylen);
|
|
|
|
offset += sizeof(paylen);
|
|
|
|
|
|
|
|
callid = pntohs(pd + offset);
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(gre_tree, NullTVB, offset, sizeof(callid),
|
1999-06-11 15:30:55 +00:00
|
|
|
"Call ID: %u", callid);
|
|
|
|
offset += sizeof(callid);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
guint32 key = pntohl(pd + offset);
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(gre_tree, NullTVB, offset, sizeof(key),
|
1999-06-11 15:30:55 +00:00
|
|
|
"Key: %u", key);
|
|
|
|
offset += sizeof(key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags_and_ver & GH_B_S) {
|
|
|
|
guint32 seqnum = pntohl(pd + offset);
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(gre_tree, NullTVB, offset, sizeof(seqnum),
|
1999-06-11 15:30:55 +00:00
|
|
|
"Sequence number: %u", seqnum);
|
|
|
|
offset += sizeof(seqnum);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is_ppp && flags_and_ver & GH_P_A) {
|
|
|
|
guint32 acknum = pntohl(pd + offset);
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(gre_tree, NullTVB, offset, sizeof(acknum),
|
1999-06-11 15:30:55 +00:00
|
|
|
"Acknowledgement number: %u", acknum);
|
|
|
|
offset += sizeof(acknum);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags_and_ver & GH_B_R) {
|
1999-12-09 02:53:33 +00:00
|
|
|
for (;;) {
|
|
|
|
sre_af = pntohs(pd + offset);
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(gre_tree, NullTVB, offset, sizeof(guint16),
|
1999-12-09 02:53:33 +00:00
|
|
|
"Address family: %u", sre_af);
|
|
|
|
offset += sizeof(guint16);
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(gre_tree, NullTVB, offset, 1,
|
1999-06-11 15:30:55 +00:00
|
|
|
"SRE offset: %u", pd[offset++]);
|
1999-12-09 02:53:33 +00:00
|
|
|
sre_length = pd[offset];
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(gre_tree, NullTVB, offset, sizeof(guint8),
|
1999-12-09 02:53:33 +00:00
|
|
|
"SRE length: %u", sre_length);
|
|
|
|
offset += sizeof(guint8);
|
|
|
|
if (sre_af == 0 && sre_length == 0)
|
|
|
|
break;
|
|
|
|
offset += sre_length;
|
|
|
|
}
|
1999-06-11 15:30:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (type) {
|
1999-12-10 21:27:13 +00:00
|
|
|
case GRE_PPP:
|
2000-11-19 02:00:03 +00:00
|
|
|
old_call_dissector(ppp_handle, pd, offset, fd, tree);
|
1999-06-11 15:30:55 +00:00
|
|
|
break;
|
1999-12-10 21:27:13 +00:00
|
|
|
case GRE_IP:
|
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
|
|
|
old_call_dissector(ip_handle, pd, offset, fd, tree);
|
1999-12-14 00:27:29 +00:00
|
|
|
break;
|
1999-12-12 03:05:57 +00:00
|
|
|
case GRE_WCCP:
|
1999-12-14 00:27:29 +00:00
|
|
|
if (is_wccp2) {
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(gre_tree, NullTVB, offset, sizeof(guint32), "WCCPv2 Data");
|
1999-12-14 00:27:29 +00:00
|
|
|
offset += 4;
|
|
|
|
}
|
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
|
|
|
old_call_dissector(ip_handle, pd, offset, fd, tree);
|
1999-12-09 02:53:33 +00:00
|
|
|
break;
|
2000-05-18 08:41:22 +00:00
|
|
|
case GRE_IPX:
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
next_tvb = tvb_create_from_top(offset);
|
|
|
|
dissect_ipx(next_tvb, &pi, tree);
|
2000-05-18 08:41:22 +00:00
|
|
|
break;
|
1999-06-11 15:30:55 +00:00
|
|
|
default:
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
next_tvb = tvb_create_from_top(offset);
|
2000-11-16 07:35:43 +00:00
|
|
|
dissect_data(next_tvb, 0, &pi, gre_tree);
|
1999-12-12 03:05:57 +00:00
|
|
|
break;
|
1999-06-11 15:30:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
add_flags_and_ver(proto_tree *tree, guint16 flags_and_ver, int offset, int is_ppp) {
|
|
|
|
|
|
|
|
proto_item * ti;
|
|
|
|
proto_tree * fv_tree;
|
|
|
|
int nbits = sizeof(flags_and_ver) * 8;
|
|
|
|
|
2000-05-11 08:18:09 +00:00
|
|
|
ti = proto_tree_add_text(tree, NullTVB, offset, 2,
|
1999-12-10 02:29:48 +00:00
|
|
|
"Flags and version: %#04x", flags_and_ver);
|
1999-11-16 11:44:20 +00:00
|
|
|
fv_tree = proto_item_add_subtree(ti, ett_gre_flags);
|
1999-06-11 15:30:55 +00:00
|
|
|
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(fv_tree, NullTVB, offset, sizeof(flags_and_ver), "%s",
|
1999-06-11 15:30:55 +00:00
|
|
|
decode_boolean_bitfield(flags_and_ver, GH_B_C, nbits,
|
|
|
|
"Checksum", "No checksum"));
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(fv_tree, NullTVB, offset, sizeof(flags_and_ver), "%s",
|
1999-06-11 15:30:55 +00:00
|
|
|
decode_boolean_bitfield(flags_and_ver, GH_B_R, nbits,
|
|
|
|
"Routing", "No routing"));
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(fv_tree, NullTVB, offset, sizeof(flags_and_ver), "%s",
|
1999-06-11 15:30:55 +00:00
|
|
|
decode_boolean_bitfield(flags_and_ver, GH_B_K, nbits,
|
|
|
|
"Key", "No key"));
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(fv_tree, NullTVB, offset, sizeof(flags_and_ver), "%s",
|
1999-06-11 15:30:55 +00:00
|
|
|
decode_boolean_bitfield(flags_and_ver, GH_B_S, nbits,
|
|
|
|
"Sequence number", "No sequence number"));
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(fv_tree, NullTVB, offset, sizeof(flags_and_ver), "%s",
|
1999-06-11 15:30:55 +00:00
|
|
|
decode_boolean_bitfield(flags_and_ver, GH_B_s, nbits,
|
|
|
|
"Strict source route", "No strict source route"));
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(fv_tree, NullTVB, offset, sizeof(flags_and_ver), "%s",
|
1999-06-11 15:30:55 +00:00
|
|
|
decode_numeric_bitfield(flags_and_ver, GH_B_RECUR, nbits,
|
|
|
|
"Recursion control: %u"));
|
|
|
|
if (is_ppp) {
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(fv_tree, NullTVB, offset, sizeof(flags_and_ver), "%s",
|
1999-06-11 15:30:55 +00:00
|
|
|
decode_boolean_bitfield(flags_and_ver, GH_P_A, nbits,
|
|
|
|
"Acknowledgment number", "No acknowledgment number"));
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(fv_tree, NullTVB, offset, sizeof(flags_and_ver), "%s",
|
1999-06-11 15:30:55 +00:00
|
|
|
decode_numeric_bitfield(flags_and_ver, GH_P_FLAGS, nbits,
|
|
|
|
"Flags: %u"));
|
|
|
|
}
|
|
|
|
else {
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(fv_tree, NullTVB, offset, sizeof(flags_and_ver), "%s",
|
1999-06-11 15:30:55 +00:00
|
|
|
decode_numeric_bitfield(flags_and_ver, GH_R_FLAGS, nbits,
|
|
|
|
"Flags: %u"));
|
|
|
|
}
|
|
|
|
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(fv_tree, NullTVB, offset, sizeof(flags_and_ver), "%s",
|
1999-06-11 15:30:55 +00:00
|
|
|
decode_numeric_bitfield(flags_and_ver, GH_B_VER, nbits,
|
|
|
|
"Version: %u"));
|
|
|
|
}
|
|
|
|
|
1999-07-29 05:47:07 +00:00
|
|
|
void
|
|
|
|
proto_register_gre(void)
|
|
|
|
{
|
1999-12-12 03:05:57 +00:00
|
|
|
static hf_register_info hf[] = {
|
|
|
|
{ &hf_gre_proto,
|
|
|
|
{ "Protocol Type", "gre.proto", FT_UINT16, BASE_HEX, VALS(typevals), 0x0,
|
|
|
|
"The protocol that is GRE encapsulated"}
|
|
|
|
},
|
|
|
|
};
|
1999-11-16 11:44:20 +00:00
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_gre,
|
1999-12-08 21:38:14 +00:00
|
|
|
&ett_gre_flags,
|
1999-11-16 11:44:20 +00:00
|
|
|
};
|
1999-07-29 05:47:07 +00:00
|
|
|
|
|
|
|
proto_gre = proto_register_protocol("Generic Routing Encapsulation", "gre");
|
1999-12-12 03:05:57 +00:00
|
|
|
proto_register_field_array(proto_gre, hf, array_length(hf));
|
1999-11-16 11:44:20 +00:00
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
1999-07-29 05:47:07 +00:00
|
|
|
}
|
2000-04-16 22:46:25 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
proto_reg_handoff_gre(void)
|
|
|
|
{
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
old_dissector_add("ip.proto", IP_PROTO_GRE, dissect_gre);
|
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
|
|
|
|
|
|
|
/*
|
2000-11-19 02:00:03 +00:00
|
|
|
* Get handles for the IP and PPP dissectors.
|
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
|
|
|
*/
|
|
|
|
ip_handle = find_dissector("ip");
|
2000-11-19 02:00:03 +00:00
|
|
|
ppp_handle = find_dissector("ppp");
|
2000-04-16 22:46:25 +00:00
|
|
|
}
|