Guy,
From: Guy Harris <guy@xxxxxxxxxx>
Subject: Re: [Ethereal-dev] PPP patch
Date: Sun, 5 Aug 2001 03:09:55 -0700 (PDT)
> > Here's a simple patch against current cvs repository to support:
>
> Checked in.
Thanks! Here's one more. This adds the capability to decode an
"algorithm" in case of CHAP.
=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=
+----+----+
|.. .| | Motonori Shindo
|_~__| |
| .. |~~_~| Sr. Systems Engineer
| . | | CoSine Communications Inc.
+----+----+
C o S i n e e-mail: mshindo@xxxxxxxxxxxxx
Communications
=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=
Index: packet-ppp.c
===================================================================
RCS file: /cvsroot/ethereal/packet-ppp.c,v
retrieving revision 1.69
diff -u -r1.69 packet-ppp.c
--- packet-ppp.c 2001/08/05 10:09:38 1.69
+++ packet-ppp.c 2001/08/05 13:46:27
@@ -220,6 +220,9 @@
static void dissect_lcp_protocol_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
int offset, guint length, frame_data *fd,
proto_tree *tree);
+static void dissect_lcp_authprot_opt(const ip_tcp_opt *optp, tvbuff_t *tvb,
+ int offset, guint length, frame_data *fd,
+ proto_tree *tree);
static void dissect_lcp_magicnumber_opt(const ip_tcp_opt *optp,
tvbuff_t *tvb, int offset, guint length,
frame_data *fd, proto_tree *tree);
@@ -272,7 +275,7 @@
&ett_lcp_authprot_opt,
VARIABLE_LENGTH,
4,
- dissect_lcp_protocol_opt
+ dissect_lcp_authprot_opt
},
{
CI_QUALITY,
@@ -446,6 +449,21 @@
#define N_LCP_OPTS (sizeof lcp_opts / sizeof lcp_opts[0])
+/*
+ * CHAP Algorithms
+ */
+#define CHAP_ALG_MD5 0x05 /* CHAP with MD5 */
+#define CHAP_ALG_MSV1 0x80 /* MS-CHAPv1 */
+#define CHAP_ALG_MSV2 0x81 /* MS-CHAPv2 */
+
+static const value_string chap_alg_vals[] = {
+ {CHAP_ALG_MD5, "CHAP with MD5" },
+ {CHAP_ALG_MSV1, "MS-CHAP" },
+ {CHAP_ALG_MSV2, "MS-CHAP-2" },
+ {0, NULL }
+};
+
+
/*
* Options. (IPCP)
*/
@@ -757,6 +775,40 @@
if (length > 0)
proto_tree_add_text(field_tree, tvb, offset, length, "Data (%d byte%s)", length,
plurality(length, "", "s"));
+}
+
+static void
+dissect_lcp_authprot_opt(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset,
+ guint length, frame_data *fd, proto_tree *tree)
+{
+ guint16 protocol;
+ guint8 algorithm;
+ proto_item *tf;
+ proto_tree *field_tree = NULL;
+
+ tf = proto_tree_add_text(tree, tvb, offset, length, "%s: %u byte%s",
+ optp->name, length, plurality(length, "", "s"));
+ field_tree = proto_item_add_subtree(tf, *optp->subtree_index);
+ offset += 2;
+ length -= 2;
+ protocol = tvb_get_ntohs(tvb, offset);
+ proto_tree_add_text(field_tree, tvb, offset, 2, "%s: %s (0x%02x)", optp->name,
+ val_to_str(protocol, ppp_vals, "Unknown"), protocol);
+ offset += 2;
+ length -= 2;
+ if (length > 0) {
+ if (protocol == PPP_CHAP) {
+ algorithm = tvb_get_guint8(tvb, offset);
+ proto_tree_add_text(field_tree, tvb, offset, length,
+ "Algorithm: %s (0x%02x)",
+ val_to_str(algorithm, chap_alg_vals, "Unknown"),
+ algorithm);
+ offset++;
+ } else {
+ proto_tree_add_text(field_tree, tvb, offset, length, "Data (%d byte%s)", length,
+ plurality(length, "", "s"));
+ }
+ }
}
static void