diff options
-rw-r--r-- | packet-ip.c | 12 | ||||
-rw-r--r-- | packet-ipsec.c | 51 | ||||
-rw-r--r-- | packet-ipsec.h | 5 | ||||
-rw-r--r-- | packet-ipv6.c | 4 |
4 files changed, 55 insertions, 17 deletions
diff --git a/packet-ip.c b/packet-ip.c index 223b98dda8..b81e08a8d9 100644 --- a/packet-ip.c +++ b/packet-ip.c @@ -1,7 +1,7 @@ /* packet-ip.c * Routines for IP and miscellaneous IP protocol packet disassembly * - * $Id: packet-ip.c,v 1.91 2000/06/02 16:43:46 gram Exp $ + * $Id: packet-ip.c,v 1.92 2000/06/05 03:21:01 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -805,7 +805,6 @@ dissect_ip(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { gchar tos_str[32]; guint hlen, optlen, len; guint16 flags; - int advance; guint8 nxt; /* To do: check for errs, etc. */ @@ -945,15 +944,6 @@ dissect_ip(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { return; } -again: - switch (nxt) { - case IP_PROTO_AH: - advance = dissect_ah(pd, offset, fd, tree); - nxt = pd[offset]; - offset += advance; - goto again; - } - /* do lookup with the subdissector table */ if (!dissector_try_port(ip_dissector_table, nxt, pd, offset, fd, tree)) { /* Unknown protocol */ diff --git a/packet-ipsec.c b/packet-ipsec.c index a555432fcf..a40ea5940e 100644 --- a/packet-ipsec.c +++ b/packet-ipsec.c @@ -1,7 +1,7 @@ /* packet-ipsec.c * Routines for IPsec/IPComp packet disassembly * - * $Id: packet-ipsec.c,v 1.16 2000/05/31 05:07:09 guy Exp $ + * $Id: packet-ipsec.c,v 1.17 2000/06/05 03:21:02 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -101,7 +101,7 @@ static const value_string cpi2val[] = { #endif int -dissect_ah(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) +dissect_ah_old(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { proto_tree *ah_tree; proto_item *ti; @@ -141,6 +141,52 @@ dissect_ah(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) return advance; } +void +dissect_ah(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) +{ + proto_tree *ah_tree; + proto_item *ti; + struct newah ah; + int advance; + + memcpy(&ah, (void *) &pd[offset], sizeof(ah)); + advance = sizeof(ah) + ((ah.ah_len - 1) << 2); + + if (check_col(fd, COL_PROTOCOL)) + col_add_str(fd, COL_PROTOCOL, "AH"); + if (check_col(fd, COL_INFO)) { + col_add_fstr(fd, COL_INFO, "AH (SPI=0x%08x)", + (guint32)ntohl(ah.ah_spi)); + } + + if (tree) { + /* !!! specify length */ + ti = proto_tree_add_item(tree, proto_ah, NullTVB, offset, advance, FALSE); + ah_tree = proto_item_add_subtree(ti, ett_ah); + + proto_tree_add_text(ah_tree, NullTVB, offset + offsetof(struct newah, ah_nxt), 1, + "Next Header: %s (0x%02x)", ipprotostr(ah.ah_nxt), ah.ah_nxt); + proto_tree_add_text(ah_tree, NullTVB, offset + offsetof(struct newah, ah_len), 1, + "Length: %d", ah.ah_len << 2); + proto_tree_add_uint(ah_tree, hf_ah_spi, NullTVB, + offset + offsetof(struct newah, ah_spi), 4, + (guint32)ntohl(ah.ah_spi)); + proto_tree_add_uint(ah_tree, hf_ah_sequence, NullTVB, + offset + offsetof(struct newah, ah_seq), 4, + (guint32)ntohl(ah.ah_seq)); + proto_tree_add_text(ah_tree, NullTVB, offset + sizeof(ah), (ah.ah_len - 1) << 2, + "ICV"); + } + + /* start of the new header (could be a extension header) */ + offset += advance; + + /* do lookup with the subdissector table */ + if (!dissector_try_port(ip_dissector_table, ah.ah_nxt, pd, offset, fd, tree)) { + dissect_data(pd, offset, fd, tree); + } +} + static void dissect_esp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { @@ -286,6 +332,7 @@ proto_register_ipsec(void) void proto_reg_handoff_ipsec(void) { + dissector_add("ip.proto", IP_PROTO_AH, dissect_ah); dissector_add("ip.proto", IP_PROTO_ESP, dissect_esp); dissector_add("ip.proto", IP_PROTO_IPCOMP, dissect_ipcomp); } diff --git a/packet-ipsec.h b/packet-ipsec.h index 38bea778b8..64b7f5a4fa 100644 --- a/packet-ipsec.h +++ b/packet-ipsec.h @@ -1,6 +1,6 @@ /* packet-ipsec.h * - * $Id: packet-ipsec.h,v 1.2 2000/04/20 07:05:55 guy Exp $ + * $Id: packet-ipsec.h,v 1.3 2000/06/05 03:21:02 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -23,4 +23,5 @@ */ -int dissect_ah(const u_char *, int, frame_data *, proto_tree *); +int dissect_ah_old(const u_char *, int, frame_data *, proto_tree *); +void dissect_ah(const u_char *, int, frame_data *, proto_tree *); diff --git a/packet-ipv6.c b/packet-ipv6.c index df1ee69bc2..6f5cd881b9 100644 --- a/packet-ipv6.c +++ b/packet-ipv6.c @@ -1,7 +1,7 @@ /* packet-ipv6.c * Routines for IPv6 packet disassembly * - * $Id: packet-ipv6.c,v 1.38 2000/05/31 05:07:09 guy Exp $ + * $Id: packet-ipv6.c,v 1.39 2000/06/05 03:21:03 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -351,7 +351,7 @@ again: offset += advance; goto again; case IP_PROTO_AH: - advance = dissect_ah(pd, offset, fd, tree); + advance = dissect_ah_old(pd, offset, fd, tree); nxt = pd[poffset = offset]; offset += advance; goto again; |