aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGilbert Ramirez <gram@alumni.rice.edu>2000-05-25 07:42:26 +0000
committerGilbert Ramirez <gram@alumni.rice.edu>2000-05-25 07:42:26 +0000
commit40c5ed378fe8c500efe36717b4ef7fe9c30102f4 (patch)
treea6a26b30c3725ce60138c644de65403f85e9b6b1
parent2a0cd3825428646d640b6ea27660bb5f4d05589b (diff)
Convert dissect_ppp() and friends to use tvbuffs.
(the ip_tcp_options stuff is still non-tvbuff until I convert ip and tcp). Add preliminary fix for Linux ISDN ippp devices (similar watch was posted to ethereal-users, but did not use tvbuffs). Change packet-raw.c to call capture_ppp()/dissect_ppp() in the case where the frame starts with FF:03. We had been calling capture_ip()/dissect_ip() at byte offset 4, but I think this is for historical reasons of packet-raw.c and packet-ip.c existing before packet-ppp.c. svn path=/trunk/; revision=1998
-rw-r--r--capture.c4
-rw-r--r--packet-ascend.c7
-rw-r--r--packet-gre.c6
-rw-r--r--packet-null.c7
-rw-r--r--packet-ppp.c222
-rw-r--r--packet-ppp.h6
-rw-r--r--packet-raw.c32
-rw-r--r--packet.c4
8 files changed, 160 insertions, 128 deletions
diff --git a/capture.c b/capture.c
index cad5e76439..87c95540f7 100644
--- a/capture.c
+++ b/capture.c
@@ -1,7 +1,7 @@
/* capture.c
* Routines for packet capture windows
*
- * $Id: capture.c,v 1.104 2000/05/19 22:37:57 guy Exp $
+ * $Id: capture.c,v 1.105 2000/05/25 07:42:23 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -987,7 +987,7 @@ capture_pcap_cb(u_char *user, const struct pcap_pkthdr *phdr,
capture_null(pd, &ld->counts);
break;
case WTAP_ENCAP_PPP:
- capture_ppp(pd, &ld->counts);
+ capture_ppp(pd, 0, &ld->counts);
break;
case WTAP_ENCAP_RAW_IP:
capture_raw(pd, &ld->counts);
diff --git a/packet-ascend.c b/packet-ascend.c
index 2bd557aa4b..c4561532ba 100644
--- a/packet-ascend.c
+++ b/packet-ascend.c
@@ -1,7 +1,7 @@
/* packet-ascend.c
* Routines for decoding Lucent/Ascend packet traces
*
- * $Id: packet-ascend.c,v 1.14 2000/05/19 23:06:08 gram Exp $
+ * $Id: packet-ascend.c,v 1.15 2000/05/25 07:42:24 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -57,8 +57,6 @@ dissect_ascend(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_tree *fh_tree;
proto_item *ti;
- const guint8 *pd;
- int offset;
union wtap_pseudo_header *pseudo_header = pinfo->pseudo_header;
pinfo->current_proto = "Lucent/Ascend";
@@ -100,8 +98,7 @@ dissect_ascend(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
switch (pseudo_header->ascend.type) {
case ASCEND_PFX_WDS_X:
case ASCEND_PFX_WDS_R:
- tvb_compat(tvb, &pd, &offset);
- dissect_ppp(pd, offset, pinfo->fd, tree);
+ dissect_ppp(tvb, pinfo, tree);
break;
case ASCEND_PFX_WDD:
dissect_eth(tvb, pinfo, tree);
diff --git a/packet-gre.c b/packet-gre.c
index 7af6b079a1..263aec7445 100644
--- a/packet-gre.c
+++ b/packet-gre.c
@@ -2,7 +2,7 @@
* Routines for the Generic Routing Encapsulation (GRE) protocol
* Brad Robel-Forrest <brad.robel-forrest@watchguard.com>
*
- * $Id: packet-gre.c,v 1.20 2000/05/18 08:41:13 guy Exp $
+ * $Id: packet-gre.c,v 1.21 2000/05/25 07:42:24 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -81,6 +81,7 @@ dissect_gre(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
guint16 type = pntohs(pd + offset + sizeof(flags_and_ver));
guint16 sre_af;
guint8 sre_length;
+ tvbuff_t *next_tvb;
if (check_col(fd, COL_PROTOCOL))
col_add_str(fd, COL_PROTOCOL, "GRE");
@@ -205,7 +206,8 @@ dissect_gre(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
switch (type) {
case GRE_PPP:
- dissect_ppp(pd, offset, fd, tree);
+ next_tvb = tvb_new_subset(pi.compat_top_tvb, offset, -1, -1);
+ dissect_ppp(next_tvb, &pi, tree);
break;
case GRE_IP:
dissect_ip(pd, offset, fd, tree);
diff --git a/packet-null.c b/packet-null.c
index 9c26f51294..ac910d9105 100644
--- a/packet-null.c
+++ b/packet-null.c
@@ -1,7 +1,7 @@
/* packet-null.c
* Routines for null packet disassembly
*
- * $Id: packet-null.c,v 1.23 2000/05/19 05:18:26 guy Exp $
+ * $Id: packet-null.c,v 1.24 2000/05/25 07:42:24 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -179,7 +179,7 @@ capture_null( const u_char *pd, packet_counts *ld )
/*
* Hand it to PPP.
*/
- capture_ppp(pd, ld);
+ capture_ppp(pd, 0, ld);
} else {
/*
* Treat it as a normal DLT_NULL header.
@@ -236,8 +236,7 @@ dissect_null(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/*
* Hand it to PPP.
*/
- tvb_compat(tvb, &next_pd, &next_offset);
- dissect_ppp(next_pd, next_offset, pinfo->fd, tree);
+ dissect_ppp(tvb, pinfo, tree);
} else {
/* load the top pane info. This should be overwritten by
diff --git a/packet-ppp.c b/packet-ppp.c
index 2d98b3a06b..e0c4e1e3d7 100644
--- a/packet-ppp.c
+++ b/packet-ppp.c
@@ -1,7 +1,7 @@
/* packet-ppp.c
* Routines for ppp packet disassembly
*
- * $Id: packet-ppp.c,v 1.34 2000/05/19 05:29:43 guy Exp $
+ * $Id: packet-ppp.c,v 1.35 2000/05/25 07:42:25 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -216,8 +216,7 @@ static void dissect_lcp_bap_link_discriminator_opt(const ip_tcp_opt *optp,
static void dissect_lcp_internationalization_opt(const ip_tcp_opt *optp,
const u_char *opd, int offset, guint length,
proto_tree *tree);
-static void dissect_mp(const u_char *pd, int offset, frame_data *fd,
- proto_tree *tree, proto_tree *fh_tree);
+static void dissect_mp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
static const ip_tcp_opt lcp_opts[] = {
{
@@ -503,16 +502,16 @@ static const ip_tcp_opt ipcp_opts[] = {
#define N_IPCP_OPTS (sizeof ipcp_opts / sizeof ipcp_opts[0])
void
-capture_ppp( const u_char *pd, packet_counts *ld ) {
- switch (pntohs(&pd[2])) {
+capture_ppp( const u_char *pd, int offset, packet_counts *ld ) {
+ switch (pntohs(&pd[offset + 2])) {
case PPP_IP:
- capture_ip(pd, 4, ld);
+ capture_ip(pd, offset + 4, ld);
break;
case PPP_IPX:
- capture_ipx(pd, 4, ld);
+ capture_ipx(pd, offset + 4, ld);
break;
case PPP_VINES:
- capture_ipx(pd, 4, ld);
+ capture_vines(pd, offset + 4, ld);
break;
default:
ld->other++;
@@ -844,10 +843,10 @@ static void dissect_ipcp_addr_opt(const ip_tcp_opt *optp, const u_char *opd,
}
static void
-dissect_cp( const u_char *pd, int offset, const char *proto_short_name,
+dissect_cp( tvbuff_t *tvb, const char *proto_short_name,
const char *proto_long_name, int proto_subtree_index,
const value_string *proto_vals, int options_subtree_index,
- const ip_tcp_opt *opts, int nopts, frame_data *fd, proto_tree *tree ) {
+ const ip_tcp_opt *opts, int nopts, packet_info *pinfo, proto_tree *tree ) {
proto_item *ti;
proto_tree *fh_tree = NULL;
proto_item *tf;
@@ -855,29 +854,29 @@ dissect_cp( const u_char *pd, int offset, const char *proto_short_name,
guint8 code;
guint8 id;
- int length;
+ int length, offset;
guint16 protocol;
- code = pd[0+offset];
- id = pd[1+offset];
- length = pntohs(&pd[2+offset]);
+ code = tvb_get_guint8(tvb, 0);
+ id = tvb_get_guint8(tvb, 1);
+ length = tvb_get_ntohs(tvb, 2);
- if(check_col(fd, COL_INFO))
- col_add_fstr(fd, COL_INFO, "%sCP %s", proto_short_name,
+ if(check_col(pinfo->fd, COL_INFO))
+ col_add_fstr(pinfo->fd, COL_INFO, "%sCP %s", proto_short_name,
val_to_str(code, proto_vals, "Unknown"));
if(tree) {
- ti = proto_tree_add_text(tree, NullTVB, 0+offset, 4, "%s Control Protocol",
+ ti = proto_tree_add_text(tree, tvb, 0, 4, "%s Control Protocol",
proto_long_name);
fh_tree = proto_item_add_subtree(ti, proto_subtree_index);
- proto_tree_add_text(fh_tree, NullTVB, 0+offset, 1, "Code: %s (0x%02x)",
+ proto_tree_add_text(fh_tree, tvb, 0, 1, "Code: %s (0x%02x)",
val_to_str(code, proto_vals, "Unknown"), code);
- proto_tree_add_text(fh_tree, NullTVB, 1+offset, 1, "Identifier: 0x%02x",
+ proto_tree_add_text(fh_tree, tvb, 1, 1, "Identifier: 0x%02x",
id);
- proto_tree_add_text(fh_tree, NullTVB, 2+offset, 2, "Length: %u",
+ proto_tree_add_text(fh_tree, tvb, 2, 2, "Length: %u",
length);
}
- offset += 4;
+ offset = 4;
length -= 4;
switch (code) {
@@ -887,11 +886,16 @@ dissect_cp( const u_char *pd, int offset, const char *proto_short_name,
case CONFREJ:
if(tree) {
if (length > 0) {
- tf = proto_tree_add_text(fh_tree, NullTVB, offset, length,
+ const guint8 *this_pd;
+ int this_offset;
+
+ tvb_compat(tvb, &this_pd, &this_offset);
+
+ tf = proto_tree_add_text(fh_tree, tvb, offset, length,
"Options: (%d byte%s)", length, plurality(length, "", "s"));
field_tree = proto_item_add_subtree(tf, options_subtree_index);
- dissect_ip_tcp_options(&pd[offset], offset, length, opts, nopts,
- -1, field_tree);
+ dissect_ip_tcp_options(&this_pd[this_offset + offset],this_offset + offset,
+ length, opts, nopts, -1, field_tree);
}
}
break;
@@ -901,41 +905,41 @@ dissect_cp( const u_char *pd, int offset, const char *proto_short_name,
case DISCREQ:
case IDENT:
if(tree) {
- proto_tree_add_text(fh_tree, NullTVB, offset, 4, "Magic number: 0x%08x",
- pntohl(&pd[offset]));
+ proto_tree_add_text(fh_tree, tvb, offset, 4, "Magic number: 0x%08x",
+ tvb_get_ntohl(tvb, offset));
offset += 4;
length -= 4;
if (length > 0)
- proto_tree_add_text(fh_tree, NullTVB, offset, length, "Message (%d byte%s)",
+ proto_tree_add_text(fh_tree, tvb, offset, length, "Message (%d byte%s)",
length, plurality(length, "", "s"));
}
break;
case TIMEREMAIN:
if(tree) {
- proto_tree_add_text(fh_tree, NullTVB, offset, 4, "Magic number: 0x%08x",
- pntohl(&pd[offset]));
+ proto_tree_add_text(fh_tree, tvb, offset, 4, "Magic number: 0x%08x",
+ tvb_get_ntohl(tvb, offset));
offset += 4;
length -= 4;
- proto_tree_add_text(fh_tree, NullTVB, offset, 4, "Seconds remaining: %u",
- pntohl(&pd[offset]));
+ proto_tree_add_text(fh_tree, tvb, offset, 4, "Seconds remaining: %u",
+ tvb_get_ntohl(tvb, offset));
offset += 4;
length -= 4;
if (length > 0)
- proto_tree_add_text(fh_tree, NullTVB, offset, length, "Message (%d byte%s)",
+ proto_tree_add_text(fh_tree, tvb, offset, length, "Message (%d byte%s)",
length, plurality(length, "", "s"));
}
break;
case PROTREJ:
if(tree) {
- protocol = pntohs(&pd[offset]);
- proto_tree_add_text(fh_tree, NullTVB, offset, 2, "Rejected protocol: %s (0x%04x)",
+ protocol = tvb_get_ntohs(tvb, offset);
+ proto_tree_add_text(fh_tree, tvb, offset, 2, "Rejected protocol: %s (0x%04x)",
val_to_str(protocol, ppp_vals, "Unknown"), protocol);
offset += 2;
length -= 2;
if (length > 0)
- proto_tree_add_text(fh_tree, NullTVB, offset, length, "Rejected packet (%d byte%s)",
+ proto_tree_add_text(fh_tree, tvb, offset, length, "Rejected packet (%d byte%s)",
length, plurality(length, "", "s"));
/* XXX - should be dissected as a PPP packet */
}
@@ -944,20 +948,20 @@ dissect_cp( const u_char *pd, int offset, const char *proto_short_name,
case CODEREJ:
/* decode the rejected LCP packet here. */
if (length > 0)
- proto_tree_add_text(fh_tree, NullTVB, offset, length, "Rejected packet (%d byte%s)",
+ proto_tree_add_text(fh_tree, tvb, offset, length, "Rejected packet (%d byte%s)",
length, plurality(length, "", "s"));
break;
case TERMREQ:
case TERMACK:
if (length > 0)
- proto_tree_add_text(fh_tree, NullTVB, offset, length, "Data (%d byte%s)",
+ proto_tree_add_text(fh_tree, tvb, offset, length, "Data (%d byte%s)",
length, plurality(length, "", "s"));
break;
default:
if (length > 0)
- proto_tree_add_text(fh_tree, NullTVB, offset, length, "Stuff (%d byte%s)",
+ proto_tree_add_text(fh_tree, tvb, offset, length, "Stuff (%d byte%s)",
length, plurality(length, "", "s"));
break;
}
@@ -967,51 +971,55 @@ dissect_cp( const u_char *pd, int offset, const char *proto_short_name,
#define PFC_BIT 0x01
static gboolean
-dissect_ppp_stuff( const u_char *pd, int offset, frame_data *fd,
+dissect_ppp_stuff( tvbuff_t *tvb, packet_info *pinfo,
proto_tree *tree, proto_tree *fh_tree ) {
guint16 ppp_prot;
int proto_len;
+ tvbuff_t *next_tvb;
+ const guint8 *next_pd;
+ int next_offset;
- if (pd[offset] & PFC_BIT) {
- ppp_prot = pd[offset];
+ if (tvb_get_guint8(tvb, 0) & PFC_BIT) {
+ ppp_prot = tvb_get_guint8(tvb, 0);
proto_len = 1;
} else {
- ppp_prot = pntohs(&pd[offset]);
+ ppp_prot = tvb_get_ntohs(tvb, 0);
proto_len = 2;
}
if (tree) {
- proto_tree_add_text(fh_tree, NullTVB, offset, proto_len, "Protocol: %s (0x%04x)",
+ proto_tree_add_text(fh_tree, tvb, 0, proto_len, "Protocol: %s (0x%04x)",
val_to_str(ppp_prot, ppp_vals, "Unknown"), ppp_prot);
}
- offset += proto_len;
+
+ next_tvb = tvb_new_subset(tvb, proto_len, -1, -1);
+ tvb_compat(next_tvb, &next_pd, &next_offset);
/* do lookup with the subdissector table */
- if (dissector_try_port(subdissector_table, ppp_prot, pd, offset, fd, tree))
+ if (dissector_try_port(subdissector_table, ppp_prot, next_pd, next_offset, pinfo->fd, tree))
return TRUE;
/* XXX - make "dissect_lcp()" and "dissect_ipcp()", have them just
call "dissect_cp()", and register them as well?
- We can't do that for "dissect_mp()", though, as it takes an additional
- argument. */
+ We can do that for "dissect_mp()", too. */
switch (ppp_prot) {
case PPP_MP:
- dissect_mp(pd, offset, fd, tree, fh_tree);
+ dissect_mp(next_tvb, pinfo, tree);
return TRUE;
case PPP_LCP:
- dissect_cp(pd, offset, "L", "Link", ett_lcp, lcp_vals, ett_lcp_options,
- lcp_opts, N_LCP_OPTS, fd, tree);
+ dissect_cp(next_tvb, "L", "Link", ett_lcp, lcp_vals, ett_lcp_options,
+ lcp_opts, N_LCP_OPTS, pinfo, tree);
return TRUE;
case PPP_IPCP:
- dissect_cp(pd, offset, "IP", "IP", ett_ipcp, cp_vals, ett_ipcp_options,
- ipcp_opts, N_IPCP_OPTS, fd, tree);
+ dissect_cp(next_tvb, "IP", "IP", ett_ipcp, cp_vals, ett_ipcp_options,
+ ipcp_opts, N_IPCP_OPTS, pinfo, tree);
return TRUE;
default:
- if (check_col(fd, COL_INFO))
- col_add_fstr(fd, COL_INFO, "PPP %s (0x%04x)",
+ if (check_col(pinfo->fd, COL_INFO))
+ col_add_fstr(pinfo->fd, COL_INFO, "PPP %s (0x%04x)",
val_to_str(ppp_prot, ppp_vals, "Unknown"), ppp_prot);
- dissect_data(pd, offset, fd, tree);
+ dissect_data_tvb(next_tvb, pinfo, tree);
return FALSE;
}
}
@@ -1028,63 +1036,64 @@ dissect_ppp_stuff( const u_char *pd, int offset, frame_data *fd,
headers are four bytes. - gcc
*/
static void
-dissect_mp(const u_char *pd, int offset, frame_data *fd,
- proto_tree *tree, proto_tree *fh_tree)
+dissect_mp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
- proto_tree *ti, *mp_tree, *hdr_tree;
+ proto_tree *mp_tree, *hdr_tree, *fh_tree = NULL;
+ proto_item *ti;
guint8 flags;
guint32 seq;
- gchar flag_str[12];
+ gchar *flag_str;
int first, last;
+ tvbuff_t *next_tvb;
- flags = pd[offset];
+ flags = tvb_get_guint8(tvb, 0);
first = flags && MP_FRAG_FIRST;
last = flags && MP_FRAG_LAST;
- seq = pd[offset+1] << 16 | pd[offset+2] << 8 | pd[offset+3];
+ seq = tvb_get_ntoh24(tvb, 1);
- if (check_col(fd, COL_INFO))
- col_add_fstr(fd, COL_INFO, "PPP Multilink");
+ if (check_col(pinfo->fd, COL_INFO))
+ col_add_fstr(pinfo->fd, COL_INFO, "PPP Multilink");
if (tree) {
switch (flags) {
case MP_FRAG_FIRST:
- strcpy(flag_str, "First");
+ flag_str = "First";
break;
case MP_FRAG_LAST:
- strcpy(flag_str, "Last");
+ flag_str = "Last";
break;
case MP_FRAG_FIRST|MP_FRAG_LAST:
- strcpy(flag_str, "First, Last");
+ flag_str = "First, Last";
break;
default:
- strcpy(flag_str, "Unknown");
+ flag_str = "Unknown";
break;
}
- ti = proto_tree_add_item(tree, proto_mp, NullTVB, offset, 4, NULL);
+ ti = proto_tree_add_item(tree, proto_mp, tvb, 0, 4, NULL);
mp_tree = proto_item_add_subtree(ti, ett_mp);
- ti = proto_tree_add_text(mp_tree, NullTVB, offset, 1, "Fragment: 0x%2X (%s)",
+ ti = proto_tree_add_text(mp_tree, tvb, 0, 1, "Fragment: 0x%2X (%s)",
flags, flag_str);
hdr_tree = proto_item_add_subtree(ti, ett_mp_flags);
- proto_tree_add_boolean_format(hdr_tree, hf_mp_frag_first, NullTVB, offset, 1, first,
+ proto_tree_add_boolean_format(hdr_tree, hf_mp_frag_first, tvb, 0, 1, first,
"%s", decode_boolean_bitfield(flags, MP_FRAG_FIRST, sizeof(flags) * 8,
"first", "not first"));
- proto_tree_add_boolean_format(hdr_tree, hf_mp_frag_last, NullTVB, offset, 1, last,
+ proto_tree_add_boolean_format(hdr_tree, hf_mp_frag_last, tvb, 0, 1, last,
"%s", decode_boolean_bitfield(flags, MP_FRAG_LAST, sizeof(flags) * 8,
"last", "not last"));
- proto_tree_add_text(hdr_tree, NullTVB, offset, 1, "%s",
+ proto_tree_add_text(hdr_tree, tvb, 0, 1, "%s",
decode_boolean_bitfield(flags, MP_FRAG_RESERVED, sizeof(flags) * 8,
"reserved", "reserved"));
- proto_tree_add_item(mp_tree, hf_mp_sequence_num, NullTVB, offset + 1, 3, seq);
+ proto_tree_add_item(mp_tree, hf_mp_sequence_num, tvb, 1, 3, seq);
}
- offset += 4;
+ next_tvb = tvb_new_subset(tvb, 4, -1, -1);
- if (IS_DATA_IN_FRAME(offset)) {
- if (tree) {
- ti = proto_tree_add_item(tree, proto_ppp, NullTVB, offset, 1, NULL);
- fh_tree = proto_item_add_subtree(ti, ett_ppp);
- }
- dissect_ppp_stuff(pd, offset, fd, tree, fh_tree);
+ if (tvb_length(next_tvb) > 0) {
+ if (tree) {
+ ti = proto_tree_add_item(tree, proto_ppp, next_tvb, 0, 1, NULL);
+ fh_tree = proto_item_add_subtree(ti, ett_ppp);
+ }
+ dissect_ppp_stuff(next_tvb, pinfo, tree, fh_tree);
}
}
@@ -1092,6 +1101,7 @@ void
dissect_payload_ppp( const u_char *pd, int offset, frame_data *fd, proto_tree *tree ) {
proto_item *ti;
proto_tree *fh_tree = NULL;
+ tvbuff_t *next_tvb;
/* populate a tree in the second pane with the status of the link
layer (ie none) */
@@ -1100,52 +1110,60 @@ dissect_payload_ppp( const u_char *pd, int offset, frame_data *fd, proto_tree *t
fh_tree = proto_item_add_subtree(ti, ett_ppp);
}
- dissect_ppp_stuff(pd, offset, fd, tree, fh_tree);
+ next_tvb = tvb_new_subset(pi.compat_top_tvb, offset, -1, -1);
+ dissect_ppp_stuff(next_tvb, &pi, tree, fh_tree);
}
void
-dissect_ppp( const u_char *pd, int offset, frame_data *fd, proto_tree *tree ) {
+dissect_ppp( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree ) {
e_ppphdr ph;
proto_item *ti;
proto_tree *fh_tree = NULL;
int proto_offset;
+ tvbuff_t *next_tvb;
+ guint8 byte0;
- if (pd[offset] == 0xff) {
- ph.ppp_addr = pd[offset+0];
- ph.ppp_ctl = pd[offset+1];
- ph.ppp_prot = pntohs(&pd[offset+2]);
- proto_offset = offset + 2;
+ pinfo->current_proto = "PPP";
+ byte0 = tvb_get_guint8(tvb, 0);
+
+ if (byte0 == 0xff) {
+ ph.ppp_addr = tvb_get_guint8(tvb, 0);
+ ph.ppp_ctl = tvb_get_guint8(tvb, 1);
+ ph.ppp_prot = tvb_get_ntohs(tvb, 2);
+ proto_offset = 2;
}
else {
/* address and control are compressed (NULL) */
- ph.ppp_prot = pntohs(&pd[offset]);
- proto_offset = offset;
+ ph.ppp_prot = tvb_get_ntohs(tvb, 0);
+ proto_offset = 0;
}
/* load the top pane info. This should be overwritten by
the next protocol in the stack */
- if(check_col(fd, COL_RES_DL_SRC))
- col_add_str(fd, COL_RES_DL_SRC, "N/A" );
- if(check_col(fd, COL_RES_DL_DST))
- col_add_str(fd, COL_RES_DL_DST, "N/A" );
- if(check_col(fd, COL_PROTOCOL))
- col_add_str(fd, COL_PROTOCOL, "PPP" );
+ if(check_col(pinfo->fd, COL_RES_DL_SRC))
+ col_add_str(pinfo->fd, COL_RES_DL_SRC, "N/A" );
+ if(check_col(pinfo->fd, COL_RES_DL_DST))
+ col_add_str(pinfo->fd, COL_RES_DL_DST, "N/A" );
+ if(check_col(pinfo->fd, COL_PROTOCOL))
+ col_add_str(pinfo->fd, COL_PROTOCOL, "PPP" );
/* populate a tree in the second pane with the status of the link
layer (ie none) */
if(tree) {
- ti = proto_tree_add_item(tree, proto_ppp, NullTVB, 0, 4, NULL);
+ ti = proto_tree_add_item(tree, proto_ppp, tvb, 0, 4, NULL);
fh_tree = proto_item_add_subtree(ti, ett_ppp);
- if (pd[offset] == 0xff) {
- proto_tree_add_text(fh_tree, NullTVB, 0, 1, "Address: %02x", ph.ppp_addr);
- proto_tree_add_text(fh_tree, NullTVB, 1, 1, "Control: %02x", ph.ppp_ctl);
+ if (byte0 == 0xff) {
+ proto_tree_add_text(fh_tree, tvb, 0, 1, "Address: %02x", ph.ppp_addr);
+ proto_tree_add_text(fh_tree, tvb, 1, 1, "Control: %02x", ph.ppp_ctl);
}
}
- if (!dissect_ppp_stuff(pd, proto_offset, fd, tree, fh_tree)) {
- if (check_col(fd, COL_PROTOCOL))
- col_add_fstr(fd, COL_PROTOCOL, "0x%04x", ph.ppp_prot);
+ next_tvb = tvb_new_subset(tvb, proto_offset, -1, -1);
+
+ if (!dissect_ppp_stuff(next_tvb, pinfo, tree, fh_tree)) {
+ if (check_col(pinfo->fd, COL_PROTOCOL))
+ col_add_fstr(pinfo->fd, COL_PROTOCOL, "0x%04x", ph.ppp_prot);
}
}
diff --git a/packet-ppp.h b/packet-ppp.h
index 14e01b8d1a..7dddd37a2b 100644
--- a/packet-ppp.h
+++ b/packet-ppp.h
@@ -1,6 +1,6 @@
/* packet-ppp.h
*
- * $Id: packet-ppp.h,v 1.2 2000/03/27 17:53:20 gram Exp $
+ * $Id: packet-ppp.h,v 1.3 2000/05/25 07:42:25 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -22,6 +22,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-void capture_ppp(const u_char *, packet_counts *);
-void dissect_ppp(const u_char *, int, frame_data *, proto_tree *);
+void capture_ppp(const u_char *, int, packet_counts *);
+void dissect_ppp(tvbuff_t *, packet_info *, proto_tree *);
void dissect_payload_ppp(const u_char *, int, frame_data *, proto_tree *);
diff --git a/packet-raw.c b/packet-raw.c
index 7730d27436..4e92c43890 100644
--- a/packet-raw.c
+++ b/packet-raw.c
@@ -1,7 +1,7 @@
/* packet-raw.c
* Routines for raw packet disassembly
*
- * $Id: packet-raw.c,v 1.16 2000/05/19 21:47:37 gram Exp $
+ * $Id: packet-raw.c,v 1.17 2000/05/25 07:42:25 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -36,6 +36,7 @@
#include "packet.h"
#include "packet-raw.h"
#include "packet-ip.h"
+#include "packet-ppp.h"
static gint ett_raw = -1;
@@ -50,10 +51,17 @@ capture_raw( const u_char *pd, packet_counts *ld ) {
/* Currently, the Linux 2.1.xxx PPP driver passes back some of the header
* sometimes. This check should be removed when 2.2 is out.
*/
- if (pd[0] == 0xff && pd[1] == 0x03)
- capture_ip(pd, 4, ld);
- else
+ if (BYTES_ARE_IN_FRAME(0,2) && pd[0] == 0xff && pd[1] == 0x03) {
+ capture_ppp(pd, 0, ld);
+ }
+ /* The Linux ISDN driver sends a fake MAC address before the PPP header
+ * on its ippp interfaces. */
+ else if (BYTES_ARE_IN_FRAME(0,8) && pd[6] == 0xff && pd[7] == 0x03) {
+ capture_ppp(pd, 6, ld);
+ }
+ else {
capture_ip(pd, 0, ld);
+ }
}
void
@@ -93,14 +101,22 @@ dissect_raw(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
* sometimes. This check should be removed when 2.2 is out.
*/
if (tvb_get_ntohs(tvb, 0) == 0xff03) {
- next_tvb = tvb_new_subset(tvb, 4, -1, -1);
- tvb_compat(next_tvb, &next_pd, &next_offset);
+ dissect_ppp(tvb, pinfo, tree);
+ return;
+ }
+ /* The Linux ISDN driver sends a fake MAC address before the PPP header
+ * on its ippp interfaces. */
+ else if (tvb_get_ntohs(tvb, 6) == 0xff03) {
+ next_tvb = tvb_new_subset(tvb, 6, -1, -1);
+ dissect_ppp(next_tvb, pinfo, tree);
+ return;
}
else {
tvb_compat(tvb, &next_pd, &next_offset);
+ dissect_ip(next_pd, next_offset, pinfo->fd, tree);
+ return;
}
-
- dissect_ip(next_pd, next_offset, pinfo->fd, tree);
+ g_assert_not_reached();
}
void
diff --git a/packet.c b/packet.c
index f09ae353e2..76457bc26d 100644
--- a/packet.c
+++ b/packet.c
@@ -1,7 +1,7 @@
/* packet.c
* Routines for packet disassembly
*
- * $Id: packet.c,v 1.88 2000/05/19 23:06:10 gram Exp $
+ * $Id: packet.c,v 1.89 2000/05/25 07:42:26 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -1191,7 +1191,7 @@ dissect_packet(union wtap_pseudo_header *pseudo_header, const u_char *pd,
dissect_null(tvb, &pi, tree);
break;
case WTAP_ENCAP_PPP :
- dissect_ppp(pd, 0, fd, tree);
+ dissect_ppp(tvb, &pi, tree);
break;
case WTAP_ENCAP_LAPB :
dissect_lapb(pseudo_header, pd, fd, tree);