PAP support, from Laurent Rabret.

svn path=/trunk/; revision=3555
This commit is contained in:
Guy Harris 2001-06-15 20:35:08 +00:00
parent 4a5b324abb
commit 2bb26e5d5b
2 changed files with 157 additions and 7 deletions

View File

@ -688,7 +688,12 @@ Francisco Javier Cabello <fjcabello@vtools.es> {
}
Laurent Rabret <laurent.rabret@rd.francetelecom.fr> {
LCP-over Ethernet and IPCP-over-Ethernet support
LCP-over Ethernet and IPCP-over-Ethernet support (to handle
captures on Windows; PPP packets show up as Ethernet
packets, courtesy of NDISWAN, and apparently internal-to-PPP
protocols get passed through, with PPP protocol types
appearing in the Ethernet protocol type field)
PAP support
}
Alain Magloire <alainm@rcsm.ece.mcgill.ca> was kind enough to

View File

@ -1,7 +1,7 @@
/* packet-ppp.c
* Routines for ppp packet disassembly
*
* $Id: packet-ppp.c,v 1.65 2001/06/15 20:23:41 guy Exp $
* $Id: packet-ppp.c,v 1.66 2001/06/15 20:35:08 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -45,6 +45,8 @@
#include "packet-vines.h"
#include "nlpid.h"
#define ppp_min(a, b) ((a<b) ? a : b)
static int proto_ppp = -1;
static gint ett_ppp = -1;
@ -79,6 +81,13 @@ static int hf_mp_sequence_num = -1;
static int ett_mp = -1;
static int ett_mp_flags = -1;
static int proto_pap = -1; /* PAP vars */
static gint ett_pap = -1;
static gint ett_pap_data = -1;
static gint ett_pap_peer_id = -1;
static gint ett_pap_password = -1;
static gint ett_pap_message = -1;
static dissector_table_t subdissector_table;
static dissector_handle_t chdlc_handle;
@ -526,6 +535,15 @@ static const ip_tcp_opt ipcp_opts[] = {
static void dissect_ppp(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *tree);
static const value_string pap_vals[] = {
{CONFREQ, "Authenticate-Request" },
{CONFACK, "Authenticate-Ack" },
{CONFNAK, "Authenticate-Nak" },
{0, NULL } };
static void dissect_pap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
const unsigned int fcstab_32[256] =
{
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
@ -1377,6 +1395,105 @@ dissect_ppp_hdlc( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree ) {
}
}
/*
* Handles PAP just as a protocol field
*/
static void
dissect_pap( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree ) {
proto_item *ti;
proto_tree *fh_tree = NULL;
proto_item *tf;
proto_tree *field_tree;
proto_item *tm;
proto_tree *message_tree;
proto_item *tp;
proto_tree *peer_id_tree;
proto_item *tpw;
proto_tree *passwd_tree;
guint8 code;
guint8 id, peer_id_length, password_length, msg_length;
int length, offset;
code = tvb_get_guint8(tvb, 0);
id = tvb_get_guint8(tvb, 1);
length = tvb_get_ntohs(tvb, 2);
if(check_col(pinfo->fd, COL_INFO))
col_add_fstr(pinfo->fd, COL_INFO, "%s %s",
proto_get_protocol_short_name(proto_pap),
val_to_str(code, pap_vals, "Unknown"));
if(tree) {
ti = proto_tree_add_item(tree, proto_pap, tvb, 0, length, FALSE);
fh_tree = proto_item_add_subtree(ti, ett_pap);
proto_tree_add_text(fh_tree, tvb, 0, 1, "Code: %s (0x%02x)",
val_to_str(code, pap_vals, "Unknown"), code);
proto_tree_add_text(fh_tree, tvb, 1, 1, "Identifier: 0x%02x",
id);
proto_tree_add_text(fh_tree, tvb, 2, 2, "Length: %u",
length);
}
offset = 4;
length -= 4;
switch (code) {
case CONFREQ:
if(tree) {
if (length > 0) {
tf = proto_tree_add_text(fh_tree, tvb, offset, length,
"Data: (%d byte%s)", length, plurality(length, "", "s"));
field_tree = proto_item_add_subtree(tf, ett_pap_data);
peer_id_length = tvb_get_guint8(tvb, offset);
tp = proto_tree_add_text(field_tree, tvb, offset, 1,
"Peer ID length: %d byte%s", peer_id_length, plurality(peer_id_length, "", "s"));
if (--length > 0) {
peer_id_tree = proto_item_add_subtree(tp, ett_pap_peer_id);
proto_tree_add_text(peer_id_tree, tvb, ++offset, ppp_min(peer_id_length, length),
"Peer-ID (%d byte%s)", peer_id_length, plurality(peer_id_length, "", "s"));
offset+=peer_id_length;
length-=peer_id_length;
if (length > 0) {
password_length = tvb_get_guint8(tvb, offset);
if (--length > 0) {
tpw = proto_tree_add_text(field_tree, tvb, offset, 1,
"Password length: %d byte%s", password_length, plurality(password_length, "", "s"));
passwd_tree = proto_item_add_subtree(tpw, ett_pap_password);
proto_tree_add_text(passwd_tree, tvb, ++offset, ppp_min(password_length, length),
"Password (%d byte%s)", password_length, plurality(password_length, "", "s"));
}
}
}
}
}
break;
case CONFACK:
case CONFNAK:
if(tree) {
if (length > 0) {
tf = proto_tree_add_text(fh_tree, tvb, offset, length,
"Data: (%d byte%s)", length, plurality(length, "", "s"));
field_tree = proto_item_add_subtree(tf, ett_pap_data);
msg_length = tvb_get_guint8(tvb, offset);
tm = proto_tree_add_text(field_tree, tvb, offset, 1,
"Message length: %d byte%s", msg_length, plurality(msg_length, "", "s"));
if (--length > 0) {
message_tree = proto_item_add_subtree(tm, ett_pap_message);
proto_tree_add_text(message_tree, tvb, ++offset, ppp_min(msg_length, length),
"Message (%d byte%s)", msg_length, plurality(msg_length, "", "s"));
}
}
}
break;
default:
if (length > 0)
proto_tree_add_text(fh_tree, tvb, offset, length, "Stuff (%d byte%s)",
length, plurality(length, "", "s"));
break;
}
}
void
proto_register_ppp(void)
{
@ -1389,12 +1506,12 @@ proto_register_ppp(void)
};
static enum_val_t ppp_options[] = {
{"None", 0},
{"16-Bit", 1},
{"None", 0},
{"16-Bit", 1},
{"32-Bit", 2},
{NULL, -1}
};
module_t *ppp_module;
proto_ppp = proto_register_protocol("Point-to-Point Protocol",
@ -1411,10 +1528,10 @@ proto_register_ppp(void)
/* Register the preferences for the ppp protocol */
ppp_module = prefs_register_protocol(proto_ppp, NULL);
prefs_register_enum_preference(ppp_module,
prefs_register_enum_preference(ppp_module,
"ppp_fcs",
"PPP Frame Checksum",
"PPP Frame Checksum",
"PPP Frame Checksum",
&ppp_fcs_decode,
ppp_options, FALSE);
}
@ -1538,3 +1655,31 @@ proto_reg_handoff_ipcp(void)
*/
dissector_add("ethertype", PPP_IPCP, dissect_ipcp, proto_ipcp);
}
void
proto_register_pap(void)
{
static gint *ett[] = {
&ett_pap,
&ett_pap_data,
&ett_pap_peer_id,
&ett_pap_password,
&ett_pap_message,
};
proto_pap = proto_register_protocol("PPP Password Authentication Protocol", "PPP PAP",
"pap");
proto_register_subtree_array(ett, array_length(ett));
}
void
proto_reg_handoff_pap(void)
{
dissector_add("ppp.protocol", PPP_PAP, dissect_pap, proto_pap);
/*
* See above comment about NDISWAN for an explanation of why we're
* registering with the "ethertype" dissector table.
*/
dissector_add("ethertype", PPP_PAP, dissect_pap, proto_pap);
}