forked from osmocom/wireshark
Check the checksum on GRE packets, if possible and if the Checksum
Present flag is set. svn path=/trunk/; revision=2761
This commit is contained in:
parent
0f68b651b1
commit
ada46b7434
35
packet-gre.c
35
packet-gre.c
|
@ -2,7 +2,7 @@
|
||||||
* Routines for the Generic Routing Encapsulation (GRE) protocol
|
* Routines for the Generic Routing Encapsulation (GRE) protocol
|
||||||
* Brad Robel-Forrest <brad.robel-forrest@watchguard.com>
|
* Brad Robel-Forrest <brad.robel-forrest@watchguard.com>
|
||||||
*
|
*
|
||||||
* $Id: packet-gre.c,v 1.31 2000/11/29 07:42:35 guy Exp $
|
* $Id: packet-gre.c,v 1.32 2000/12/15 00:03:09 guy Exp $
|
||||||
*
|
*
|
||||||
* Ethereal - Network traffic analyzer
|
* Ethereal - Network traffic analyzer
|
||||||
* By Gerald Combs <gerald@zing.org>
|
* By Gerald Combs <gerald@zing.org>
|
||||||
|
@ -40,6 +40,7 @@
|
||||||
#include "packet-ip.h"
|
#include "packet-ip.h"
|
||||||
#include "packet-ipx.h"
|
#include "packet-ipx.h"
|
||||||
#include "packet-wccp.h"
|
#include "packet-wccp.h"
|
||||||
|
#include "in_cksum.h"
|
||||||
|
|
||||||
static int proto_gre = -1;
|
static int proto_gre = -1;
|
||||||
static int hf_gre_proto = -1;
|
static int hf_gre_proto = -1;
|
||||||
|
@ -147,10 +148,34 @@ dissect_gre(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
||||||
offset += sizeof(type);
|
offset += sizeof(type);
|
||||||
|
|
||||||
if (flags_and_ver & GH_B_C || flags_and_ver & GH_B_R) {
|
if (flags_and_ver & GH_B_C || flags_and_ver & GH_B_R) {
|
||||||
guint16 checksum = tvb_get_ntohs(tvb, offset);
|
guint length, reported_length;
|
||||||
proto_tree_add_text(gre_tree, tvb, offset, sizeof(checksum),
|
vec_t cksum_vec[1];
|
||||||
"Checksum: %u", checksum);
|
guint16 cksum, computed_cksum;
|
||||||
offset += sizeof(checksum);
|
|
||||||
|
cksum = tvb_get_ntohs(tvb, offset);
|
||||||
|
length = tvb_length(tvb);
|
||||||
|
reported_length = tvb_reported_length(tvb);
|
||||||
|
if ((flags_and_ver & GH_B_C) && !pinfo->fragmented
|
||||||
|
&& length >= reported_length) {
|
||||||
|
/* The Checksum Present bit is set, and the packet isn't part of a
|
||||||
|
fragmented datagram and isn't truncated, so we can checksum it. */
|
||||||
|
|
||||||
|
cksum_vec[0].ptr = tvb_get_ptr(tvb, 0, reported_length);
|
||||||
|
cksum_vec[0].len = reported_length;
|
||||||
|
computed_cksum = in_cksum(cksum_vec, 1);
|
||||||
|
if (computed_cksum == 0) {
|
||||||
|
proto_tree_add_text(gre_tree, tvb, offset, sizeof(cksum),
|
||||||
|
"Checksum: 0x%04x (correct)", cksum);
|
||||||
|
} else {
|
||||||
|
proto_tree_add_text(gre_tree, tvb, offset, sizeof(cksum),
|
||||||
|
"Checksum: 0x%04x (incorrect, should be 0x%04x)",
|
||||||
|
cksum, in_cksum_shouldbe(cksum, computed_cksum));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
proto_tree_add_text(gre_tree, tvb, offset, sizeof(cksum),
|
||||||
|
"Checksum: 0x%04x", cksum);
|
||||||
|
}
|
||||||
|
offset += sizeof(cksum);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags_and_ver & GH_B_C || flags_and_ver & GH_B_R) {
|
if (flags_and_ver & GH_B_C || flags_and_ver & GH_B_R) {
|
||||||
|
|
Loading…
Reference in New Issue