/* packet-mrdisc.c 2001 Ronnie Sahlberg <See AUTHORS for email>
* Routines for IGMP/MRDISC packet disassembly
*
- * $Id: packet-mrdisc.c,v 1.5 2002/01/20 22:12:26 guy Exp $
+ * $Id: packet-mrdisc.c,v 1.10 2003/11/16 23:17:19 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
* 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.
MRDISC
- code
+ code
- 0x24 x
+ 0x24 x
0x25 x
0x26 x
# include "config.h"
#endif
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
#include <stdio.h>
#include <string.h>
#include <glib.h>
-#include "packet.h"
-#include "in_cksum.h"
+#include <epan/packet.h>
+#include "packet-igmp.h"
#include "packet-mrdisc.h"
};
-static void mrdisc_checksum(proto_tree *tree,tvbuff_t *tvb, int len)
-{
- guint16 cksum,hdrcksum;
- vec_t cksum_vec[1];
-
- cksum_vec[0].ptr = tvb_get_ptr(tvb, 0, len);
- cksum_vec[0].len = len;
-
- hdrcksum = tvb_get_ntohs(tvb, 2);
- cksum = in_cksum(&cksum_vec[0],1);
-
- if (cksum==0) {
- proto_tree_add_uint_format(tree, hf_checksum, tvb, 2, 2, hdrcksum, "Header checksum: 0x%04x (correct)", hdrcksum);
- } else {
- proto_tree_add_item_hidden(tree, hf_checksum_bad, tvb, 2, 2, TRUE);
- proto_tree_add_uint_format(tree, hf_checksum, tvb, 2, 2, hdrcksum, "Header checksum: 0x%04x (incorrect, should be 0x%04x)", hdrcksum,in_cksum_shouldbe(hdrcksum,cksum));
- }
-
- return;
-}
-
-
static int
dissect_mrdisc_mra(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset)
{
offset += 1;
/* checksum */
- mrdisc_checksum(parent_tree, tvb, tvb_length_remaining(tvb, 0));
+ igmp_checksum(parent_tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 0);
offset += 2;
/* skip unused bytes */
guint8 type,len;
int old_offset = offset;
- item = proto_tree_add_item(parent_tree, hf_options,
+ item = proto_tree_add_item(parent_tree, hf_options,
tvb, offset, -1, FALSE);
tree = proto_item_add_subtree(item, ett_options);
proto_item_set_len(item, offset-old_offset);
}
}
-
+
return offset;
}
offset += 1;
/* checksum */
- mrdisc_checksum(parent_tree, tvb, tvb_length_remaining(tvb, 0));
+ igmp_checksum(parent_tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 0);
offset += 2;
return offset;
proto_item *item;
guint8 type;
- if (!proto_is_protocol_enabled(proto_mrdisc)) {
+ if (!proto_is_protocol_enabled(find_protocol_by_id(proto_mrdisc))) {
/* we are not enabled, skip entire packet to be nice
to the igmp layer. (so clicking on IGMP will display the data)
*/
type = tvb_get_guint8(tvb, offset);
if (check_col(pinfo->cinfo, COL_INFO)) {
col_add_fstr(pinfo->cinfo, COL_INFO,
- "%s",val_to_str(type, mrdisc_types,
+ "%s",val_to_str(type, mrdisc_types,
"Unknown Type:0x%02x"));
}