Declare the "packet_info" structure "pi" in "packet.h", rather than in a
bunch of source files. Replace the "payload" field of a "packet_info" structure with "len" and "captured_len" fields, which contain the total packet length and total captured packet length (including all headers) at the current protocol layer (i.e., if a given layer has a length field, and that length field says its shorter than the length we got from the capture, reduce the "pi.len" and "pi.captured_len" values appropriately). Those fields can be used in the future if we add checks to make sure a field we're extracting from a packet doesn't go past the end of the packet, or past the captured part of the packet. Get rid of the additional payload argument to some dissection functions; use "pi.captured_len - offset" instead. Have the END_OF_FRAME macro use "pi.captured_len" rather than "fd->cap_len", so that "dissect the rest of the frame" becomes "dissect the rest of the packet", and doesn't dissect end-of-frame padding such as padding added to make an Ethernet frame 60 or more octets long. (We might want to rename it END_OF_PACKET; if we ever want to label the end-of-frame padding for the benefit of people curious what that extra gunk is, we could have a separate END_OF_FRAME macro that uses "fd->cap_len".) svn path=/trunk/; revision=506
This commit is contained in:
parent
d4331d4329
commit
ac4f87218d
|
@ -33,8 +33,6 @@
|
|||
# include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
extern packet_info pi;
|
||||
|
||||
static int proto_ddp = -1;
|
||||
|
||||
/* P = Padding, H = Hops, L = Len */
|
||||
|
|
29
packet-eth.c
29
packet-eth.c
|
@ -1,7 +1,7 @@
|
|||
/* packet-eth.c
|
||||
* Routines for ethernet packet disassembly
|
||||
*
|
||||
* $Id: packet-eth.c,v 1.14 1999/08/01 04:28:08 gram Exp $
|
||||
* $Id: packet-eth.c,v 1.15 1999/08/18 00:57:50 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -47,6 +47,8 @@ static int hf_eth_type = -1;
|
|||
|
||||
#define IEEE_802_3_MAX_LEN 1500
|
||||
|
||||
#define ETH_HEADER_SIZE 14
|
||||
|
||||
/* These are the Netware-ish names for the different Ethernet frame types.
|
||||
EthernetII: The ethernet with a Type field instead of a length field
|
||||
Ethernet802.2: An 802.3 header followed by an 802.3 header
|
||||
|
@ -64,8 +66,8 @@ static int hf_eth_type = -1;
|
|||
void
|
||||
capture_eth(const u_char *pd, guint32 cap_len, packet_counts *ld) {
|
||||
guint16 etype;
|
||||
int offset = 14;
|
||||
int ethhdr_type; /* the type of ethernet frame */
|
||||
int offset = ETH_HEADER_SIZE;
|
||||
int ethhdr_type; /* the type of ethernet frame */
|
||||
|
||||
etype = (pd[12] << 8) | pd[13];
|
||||
|
||||
|
@ -104,10 +106,10 @@ capture_eth(const u_char *pd, guint32 cap_len, packet_counts *ld) {
|
|||
void
|
||||
dissect_eth(const u_char *pd, frame_data *fd, proto_tree *tree) {
|
||||
guint16 etype, length;
|
||||
int offset = 14;
|
||||
int offset = ETH_HEADER_SIZE;
|
||||
proto_tree *fh_tree = NULL;
|
||||
proto_item *ti;
|
||||
int ethhdr_type; /* the type of ethernet frame */
|
||||
int ethhdr_type; /* the type of ethernet frame */
|
||||
|
||||
if (check_col(fd, COL_RES_DL_DST))
|
||||
col_add_str(fd, COL_RES_DL_DST, get_ether_name((u_char *)&pd[0]));
|
||||
|
@ -145,7 +147,7 @@ dissect_eth(const u_char *pd, frame_data *fd, proto_tree *tree) {
|
|||
col_add_str(fd, COL_INFO, "802.3");
|
||||
if (tree) {
|
||||
|
||||
ti = proto_tree_add_item_format(tree, proto_eth, 0, offset,
|
||||
ti = proto_tree_add_item_format(tree, proto_eth, 0, ETH_HEADER_SIZE,
|
||||
NULL, "IEEE 802.3 %s", (ethhdr_type == ETHERNET_802_3 ? "Raw " : ""));
|
||||
|
||||
fh_tree = proto_item_add_subtree(ti, ETT_IEEE8023);
|
||||
|
@ -153,14 +155,24 @@ dissect_eth(const u_char *pd, frame_data *fd, proto_tree *tree) {
|
|||
proto_tree_add_item(fh_tree, hf_eth_dst, 0, 6, &pd[0]);
|
||||
proto_tree_add_item(fh_tree, hf_eth_src, 6, 6, &pd[6]);
|
||||
proto_tree_add_item(fh_tree, hf_eth_len, 12, 2, length);
|
||||
|
||||
/* Convert the LLC length from the 802.3 header to a total
|
||||
length, by adding in the Ethernet header size, and set
|
||||
the payload and captured-payload lengths to the minima
|
||||
of the total length and the frame lengths. */
|
||||
length += ETH_HEADER_SIZE;
|
||||
if (pi.len > length)
|
||||
pi.len = length;
|
||||
if (pi.captured_len > length)
|
||||
pi.captured_len = length;
|
||||
}
|
||||
|
||||
} else {
|
||||
ethhdr_type = ETHERNET_II;
|
||||
if (tree) {
|
||||
|
||||
ti = proto_tree_add_item_format(tree, proto_eth, 0, 14, NULL,
|
||||
"Ethernet II");
|
||||
ti = proto_tree_add_item_format(tree, proto_eth, 0, ETH_HEADER_SIZE,
|
||||
NULL, "Ethernet II");
|
||||
|
||||
fh_tree = proto_item_add_subtree(ti, ETT_ETHER2);
|
||||
|
||||
|
@ -171,7 +183,6 @@ dissect_eth(const u_char *pd, frame_data *fd, proto_tree *tree) {
|
|||
proto_tree_add_item_format(fh_tree, hf_eth_src, 6, 6, &pd[6],
|
||||
"Source: %s (%s)", ether_to_str((guint8 *) &pd[6]),
|
||||
get_ether_name((u_char *) &pd[6]));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Routines for ftp packet dissection
|
||||
* Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
|
||||
*
|
||||
* $Id: packet-ftp.c,v 1.5 1999/07/29 05:46:54 gram Exp $
|
||||
* $Id: packet-ftp.c,v 1.6 1999/08/18 00:57:50 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@unicom.net>
|
||||
|
@ -44,17 +44,16 @@
|
|||
#include "packet.h"
|
||||
#include "etypes.h"
|
||||
|
||||
extern packet_info pi;
|
||||
|
||||
static int proto_ftp = -1;
|
||||
|
||||
void
|
||||
dissect_ftp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int max_data)
|
||||
dissect_ftp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
|
||||
{
|
||||
proto_tree *ftp_tree, *ti;
|
||||
gchar rr[50], rd[1500];
|
||||
int i1 = (u_char *)strchr(pd + offset, ' ') - (pd + offset); /* Where is that space */
|
||||
int i2;
|
||||
int max_data = pi.captured_len - offset;
|
||||
|
||||
memset(rr, '\0', sizeof(rr));
|
||||
memset(rd, '\0', sizeof(rd));
|
||||
|
@ -115,7 +114,7 @@ dissect_ftp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int
|
|||
}
|
||||
|
||||
void
|
||||
dissect_ftpdata(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int max_data)
|
||||
dissect_ftpdata(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
|
||||
{
|
||||
proto_tree *ti;
|
||||
|
||||
|
|
23
packet-ip.c
23
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.37 1999/08/17 03:09:39 gram Exp $
|
||||
* $Id: packet-ip.c,v 1.38 1999/08/18 00:57:50 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -46,8 +46,6 @@
|
|||
#include "packet-ip.h"
|
||||
#endif
|
||||
|
||||
extern packet_info pi;
|
||||
|
||||
static int proto_ip = -1;
|
||||
static int hf_ip_version = -1;
|
||||
static int hf_ip_hdr_len = -1;
|
||||
|
@ -627,10 +625,10 @@ dissect_ip(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
|
|||
proto_tree *ip_tree, *field_tree;
|
||||
proto_item *ti, *tf;
|
||||
gchar tos_str[32];
|
||||
guint hlen, optlen;
|
||||
guint hlen, optlen, len;
|
||||
guint16 flags;
|
||||
int advance;
|
||||
guint8 nxt;
|
||||
int advance;
|
||||
guint8 nxt;
|
||||
|
||||
/* To do: check for runts, errs, etc. */
|
||||
/* Avoids alignment problems on many architectures. */
|
||||
|
@ -640,6 +638,17 @@ dissect_ip(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
|
|||
iph.ip_off = ntohs(iph.ip_off);
|
||||
iph.ip_sum = ntohs(iph.ip_sum);
|
||||
|
||||
/* Length of IP datagram plus headers above it. */
|
||||
len = iph.ip_len + offset;
|
||||
|
||||
/* Set the payload and captured-payload lengths to the minima of (the
|
||||
IP length plus the length of the headers above it) and the frame
|
||||
lengths. */
|
||||
if (pi.len > len)
|
||||
pi.len = len;
|
||||
if (pi.captured_len > len)
|
||||
pi.captured_len = len;
|
||||
|
||||
hlen = lo_nibble(iph.ip_v_hl) * 4; /* IP header length, in bytes */
|
||||
|
||||
switch (iph.ip_p) {
|
||||
|
@ -768,8 +777,8 @@ dissect_ip(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
|
|||
pi.iphdrlen = lo_nibble(iph.ip_v_hl);
|
||||
pi.ip_src = iph.ip_src;
|
||||
pi.ip_dst = iph.ip_dst;
|
||||
pi.payload = pi.iplen - hlen;
|
||||
|
||||
/* Skip over header + options */
|
||||
offset += hlen;
|
||||
nxt = iph.ip_p;
|
||||
if (iph.ip_off & IP_OFFSET) {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* Gilbert Ramirez <gram@verdict.uthscsa.edu>
|
||||
* Much stuff added by Guy Harris <guy@netapp.com>
|
||||
*
|
||||
* $Id: packet-nbns.c,v 1.23 1999/07/29 05:46:58 gram Exp $
|
||||
* $Id: packet-nbns.c,v 1.24 1999/08/18 00:57:51 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -977,14 +977,14 @@ struct nbdgm_header {
|
|||
};
|
||||
|
||||
void
|
||||
dissect_nbdgm(const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
|
||||
int max_data)
|
||||
dissect_nbdgm(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
|
||||
{
|
||||
proto_tree *nbdgm_tree = NULL;
|
||||
proto_item *ti;
|
||||
struct nbdgm_header header;
|
||||
int flags;
|
||||
int message_index;
|
||||
int max_data = pi.captured_len - offset;
|
||||
|
||||
char *message[] = {
|
||||
"Unknown",
|
||||
|
@ -1263,12 +1263,13 @@ dissect_nbss_packet(const u_char *pd, int offset, frame_data *fd, proto_tree *tr
|
|||
}
|
||||
|
||||
void
|
||||
dissect_nbss(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int max_data)
|
||||
dissect_nbss(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
|
||||
{
|
||||
guint8 msg_type;
|
||||
guint8 flags;
|
||||
guint16 length;
|
||||
int len;
|
||||
int max_data;
|
||||
|
||||
msg_type = pd[offset];
|
||||
flags = pd[offset + 1];
|
||||
|
@ -1283,10 +1284,11 @@ dissect_nbss(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int
|
|||
val_to_str(msg_type, message_types, "Unknown (%x)"));
|
||||
}
|
||||
|
||||
while (max_data > 0) {
|
||||
len = dissect_nbss_packet(pd, offset, fd, tree, max_data);
|
||||
offset += len;
|
||||
max_data -= len;
|
||||
max_data = pi.captured_len - offset;
|
||||
while (max_data > 0) {
|
||||
len = dissect_nbss_packet(pd, offset, fd, tree, max_data);
|
||||
offset += len;
|
||||
max_data -= len;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Routines for nntp packet dissection
|
||||
* Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
|
||||
*
|
||||
* $Id: packet-nntp.c,v 1.3 1999/07/29 05:47:00 gram Exp $
|
||||
* $Id: packet-nntp.c,v 1.4 1999/08/18 00:57:52 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@unicom.net>
|
||||
|
@ -41,18 +41,17 @@
|
|||
#include <glib.h>
|
||||
#include "packet.h"
|
||||
|
||||
extern packet_info pi;
|
||||
|
||||
static int proto_nntp = -1;
|
||||
|
||||
void
|
||||
dissect_nntp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int max_data)
|
||||
dissect_nntp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
|
||||
{
|
||||
gchar *type;
|
||||
proto_tree *nntp_tree, *ti;
|
||||
const u_char *data, *dataend;
|
||||
const u_char *lineend, *eol;
|
||||
int linelen;
|
||||
int max_data = pi.captured_len - offset;
|
||||
|
||||
data = &pd[offset];
|
||||
dataend = data + END_OF_FRAME;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Routines for pop packet dissection
|
||||
* Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
|
||||
*
|
||||
* $Id: packet-pop.c,v 1.5 1999/07/29 05:47:01 gram Exp $
|
||||
* $Id: packet-pop.c,v 1.6 1999/08/18 00:57:52 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@unicom.net>
|
||||
|
@ -44,17 +44,16 @@
|
|||
#include "packet.h"
|
||||
#include "etypes.h"
|
||||
|
||||
extern packet_info pi;
|
||||
|
||||
static int proto_pop = -1;
|
||||
|
||||
void
|
||||
dissect_pop(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int max_data)
|
||||
dissect_pop(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
|
||||
{
|
||||
proto_tree *pop_tree, *ti;
|
||||
gchar rr[50], rd[1500];
|
||||
int i1 = (u_char *)strchr(pd + offset, ' ') - (pd + offset); /* Where is that space */
|
||||
int i2;
|
||||
int max_data = pi.captured_len - offset;
|
||||
|
||||
memset(rr, '\0', sizeof(rr));
|
||||
memset(rd, '\0', sizeof(rd));
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Routines for smb packet dissection
|
||||
* Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
|
||||
*
|
||||
* $Id: packet-smb.c,v 1.21 1999/07/29 05:47:04 gram Exp $
|
||||
* $Id: packet-smb.c,v 1.22 1999/08/18 00:57:52 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@unicom.net>
|
||||
|
@ -46,8 +46,6 @@
|
|||
#include "smb.h"
|
||||
#include "alignment.h"
|
||||
|
||||
extern packet_info pi;
|
||||
|
||||
static int proto_smb = -1;
|
||||
|
||||
char *decode_smb_name(unsigned char);
|
||||
|
|
20
packet-tcp.c
20
packet-tcp.c
|
@ -1,7 +1,7 @@
|
|||
/* packet-tcp.c
|
||||
* Routines for TCP packet disassembly
|
||||
*
|
||||
* $Id: packet-tcp.c,v 1.29 1999/07/31 13:55:16 deniel Exp $
|
||||
* $Id: packet-tcp.c,v 1.30 1999/08/18 00:57:53 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -56,7 +56,6 @@
|
|||
#endif
|
||||
|
||||
extern FILE* data_out_file;
|
||||
extern packet_info pi;
|
||||
|
||||
static gchar info_str[COL_MAX_LEN];
|
||||
static int info_len;
|
||||
|
@ -335,8 +334,7 @@ dissect_tcp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
|
|||
guint bpos;
|
||||
guint hlen;
|
||||
guint optlen;
|
||||
guint packet_max = pi.payload + offset;
|
||||
guint payload;
|
||||
guint packet_max = pi.len;
|
||||
|
||||
/* To do: Check for {cap len,pkt len} < struct len */
|
||||
/* Avoids alignment problems on many architectures. */
|
||||
|
@ -368,8 +366,6 @@ dissect_tcp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
|
|||
|
||||
hlen = hi_nibble(th.th_off_x2) * 4; /* TCP header length, in bytes */
|
||||
|
||||
payload = pi.payload - hlen;
|
||||
|
||||
if (check_col(fd, COL_RES_SRC_PORT))
|
||||
col_add_str(fd, COL_RES_SRC_PORT, get_tcp_port(th.th_sport));
|
||||
if (check_col(fd, COL_UNRES_SRC_PORT))
|
||||
|
@ -465,19 +461,19 @@ dissect_tcp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
|
|||
dissect_lpd(pd, offset, fd, tree);
|
||||
else if (PORT_IS(TCP_PORT_TELNET)) {
|
||||
pi.match_port = TCP_PORT_TELNET;
|
||||
dissect_telnet(pd, offset, fd, tree, payload);
|
||||
dissect_telnet(pd, offset, fd, tree);
|
||||
} else if (PORT_IS(TCP_PORT_FTPDATA)) {
|
||||
pi.match_port = TCP_PORT_FTPDATA;
|
||||
dissect_ftpdata(pd, offset, fd, tree, payload);
|
||||
dissect_ftpdata(pd, offset, fd, tree);
|
||||
} else if (PORT_IS(TCP_PORT_FTP)) {
|
||||
pi.match_port = TCP_PORT_FTP;
|
||||
dissect_ftp(pd, offset, fd, tree, payload);
|
||||
dissect_ftp(pd, offset, fd, tree);
|
||||
} else if (PORT_IS(TCP_PORT_POP)) {
|
||||
pi.match_port = TCP_PORT_POP;
|
||||
dissect_pop(pd, offset, fd, tree, payload);
|
||||
dissect_pop(pd, offset, fd, tree);
|
||||
} else if (PORT_IS(TCP_PORT_NNTP)) {
|
||||
pi.match_port = TCP_PORT_NNTP;
|
||||
dissect_nntp(pd, offset, fd, tree, payload);
|
||||
dissect_nntp(pd, offset, fd, tree);
|
||||
} else if (PORT_IS(TCP_PORT_PPTP)) {
|
||||
pi.match_port = TCP_PORT_PPTP;
|
||||
dissect_pptp(pd, offset, fd, tree);
|
||||
|
@ -485,7 +481,7 @@ dissect_tcp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
|
|||
dissect_http(pd, offset, fd, tree);
|
||||
else if (PORT_IS(TCP_PORT_NBSS)) {
|
||||
pi.match_port = TCP_PORT_NBSS;
|
||||
dissect_nbss(pd, offset, fd, tree, payload);
|
||||
dissect_nbss(pd, offset, fd, tree);
|
||||
} else if (PORT_IS(TCP_PORT_RTSP))
|
||||
dissect_rtsp(pd, offset, fd, tree);
|
||||
else {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/* packet-pop.c
|
||||
/* packet-telnet.c
|
||||
* Routines for telnet packet dissection
|
||||
* Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
|
||||
*
|
||||
* $Id: packet-telnet.c,v 1.4 1999/07/29 05:47:05 gram Exp $
|
||||
* $Id: packet-telnet.c,v 1.5 1999/08/18 00:57:53 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@unicom.net>
|
||||
|
@ -113,8 +113,6 @@ char *options[] = {
|
|||
"TN3270E"
|
||||
};
|
||||
|
||||
extern packet_info pi;
|
||||
|
||||
void telnet_sub_option(proto_tree *telnet_tree, char *rr, int *i, int offset, int max_data)
|
||||
{
|
||||
proto_tree *ti, *option_tree;
|
||||
|
@ -306,12 +304,13 @@ void telnet_command(proto_tree *telnet_tree, char *rr, int *i, int offset, int m
|
|||
}
|
||||
|
||||
void
|
||||
dissect_telnet(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int max_data)
|
||||
dissect_telnet(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
|
||||
{
|
||||
proto_tree *telnet_tree, *ti;
|
||||
gchar rr[1500];
|
||||
int i1;
|
||||
int i2;
|
||||
int max_data = pi.captured_len - offset;
|
||||
|
||||
memset(rr, '\0', sizeof(rr));
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* packet-udp.c
|
||||
* Routines for UDP packet disassembly
|
||||
*
|
||||
* $Id: packet-udp.c,v 1.22 1999/08/05 00:05:00 guy Exp $
|
||||
* $Id: packet-udp.c,v 1.23 1999/08/18 00:57:54 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -44,8 +44,6 @@
|
|||
#include "packet.h"
|
||||
#include "resolv.h"
|
||||
|
||||
extern packet_info pi;
|
||||
|
||||
int proto_udp = -1;
|
||||
int hf_udp_srcport = -1;
|
||||
int hf_udp_dstport = -1;
|
||||
|
@ -175,7 +173,6 @@ dissect_udp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
|
|||
struct hash_struct *dissect_routine = NULL;
|
||||
proto_tree *udp_tree;
|
||||
proto_item *ti;
|
||||
guint payload;
|
||||
|
||||
/* To do: Check for {cap len,pkt len} < struct len */
|
||||
/* Avoids alignment problems on many architectures. */
|
||||
|
@ -185,8 +182,6 @@ dissect_udp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
|
|||
uh_ulen = ntohs(uh.uh_ulen);
|
||||
uh_sum = ntohs(uh.uh_sum);
|
||||
|
||||
payload = pi.payload - sizeof(e_udphdr);
|
||||
|
||||
if (check_col(fd, COL_PROTOCOL))
|
||||
col_add_str(fd, COL_PROTOCOL, "UDP");
|
||||
if (check_col(fd, COL_INFO))
|
||||
|
@ -235,7 +230,7 @@ dissect_udp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
|
|||
} else if (PORT_IS(UDP_PORT_NBNS))
|
||||
dissect_nbns(pd, offset, fd, tree);
|
||||
else if (PORT_IS(UDP_PORT_NBDGM))
|
||||
dissect_nbdgm(pd, offset, fd, tree, payload);
|
||||
dissect_nbdgm(pd, offset, fd, tree);
|
||||
else if (PORT_IS(UDP_PORT_IPX)) /* RFC 1234 */
|
||||
dissect_ipx(pd, offset, fd, tree);
|
||||
#if defined(HAVE_UCD_SNMP_SNMP_H) || defined(HAVE_SNMP_SNMP_H)
|
||||
|
|
8
packet.c
8
packet.c
|
@ -1,7 +1,7 @@
|
|||
/* packet.c
|
||||
* Routines for packet disassembly
|
||||
*
|
||||
* $Id: packet.c,v 1.36 1999/08/14 04:23:21 guy Exp $
|
||||
* $Id: packet.c,v 1.37 1999/08/18 00:57:54 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -647,6 +647,12 @@ dissect_packet(const u_char *pd, frame_data *fd, proto_tree *tree)
|
|||
plurality(fd->cap_len, "", "s"));
|
||||
}
|
||||
|
||||
/* Set the initial payload to the packet length, and the initial
|
||||
captured payload to the capture length (other protocols may
|
||||
reduce them if their headers say they're less). */
|
||||
pi.len = fd->pkt_len;
|
||||
pi.captured_len = fd->cap_len;
|
||||
|
||||
switch (fd->lnk_t) {
|
||||
case WTAP_ENCAP_ETHERNET :
|
||||
dissect_eth(pd, fd, tree);
|
||||
|
|
26
packet.h
26
packet.h
|
@ -1,7 +1,7 @@
|
|||
/* packet.h
|
||||
* Definitions for packet disassembly structures and routines
|
||||
*
|
||||
* $Id: packet.h,v 1.83 1999/08/14 23:47:20 guy Exp $
|
||||
* $Id: packet.h,v 1.84 1999/08/18 00:57:54 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -75,9 +75,10 @@
|
|||
|
||||
/* Useful when highlighting regions inside a dissect_*() function. With this
|
||||
* macro, you can highlight from an arbitrary offset to the end of the
|
||||
* frame. See dissect_data() for an example.
|
||||
* packet (which may come before the end of the frame).
|
||||
* See dissect_data() for an example.
|
||||
*/
|
||||
#define END_OF_FRAME (fd->cap_len - offset)
|
||||
#define END_OF_FRAME (pi.captured_len - offset)
|
||||
|
||||
/* To pass one of two strings, singular or plural */
|
||||
#define plurality(d,s,p) ((d) == 1 ? (s) : (p))
|
||||
|
@ -122,6 +123,8 @@ typedef struct _frame_data {
|
|||
} frame_data;
|
||||
|
||||
typedef struct _packet_info {
|
||||
int len;
|
||||
int captured_len;
|
||||
guint32 ip_src;
|
||||
guint32 ip_dst;
|
||||
guint32 ipproto;
|
||||
|
@ -130,9 +133,10 @@ typedef struct _packet_info {
|
|||
guint32 match_port;
|
||||
int iplen;
|
||||
int iphdrlen;
|
||||
int payload;
|
||||
} packet_info;
|
||||
|
||||
extern packet_info pi;
|
||||
|
||||
/* Struct for the match_strval function */
|
||||
|
||||
typedef struct _value_string {
|
||||
|
@ -412,6 +416,8 @@ void dissect_data(const u_char *, int, frame_data *, proto_tree *);
|
|||
void dissect_ddp(const u_char *, int, frame_data *, proto_tree *);
|
||||
void dissect_dns(const u_char *, int, frame_data *, proto_tree *);
|
||||
void dissect_esp(const u_char *, int, frame_data *, proto_tree *);
|
||||
void dissect_ftp(const u_char *, int, frame_data *, proto_tree *);
|
||||
void dissect_ftpdata(const u_char *, int, frame_data *, proto_tree *);
|
||||
void dissect_giop(const u_char *, int, frame_data *, proto_tree *);
|
||||
void dissect_http(const u_char *, int, frame_data *, proto_tree *);
|
||||
void dissect_icmp(const u_char *, int, frame_data *, proto_tree *);
|
||||
|
@ -422,15 +428,18 @@ void dissect_ipv6(const u_char *, int, frame_data *, proto_tree *);
|
|||
void dissect_ipx(const u_char *, int, frame_data *, proto_tree *);
|
||||
void dissect_llc(const u_char *, int, frame_data *, proto_tree *);
|
||||
void dissect_lpd(const u_char *, int, frame_data *, proto_tree *);
|
||||
void dissect_nbdgm(const u_char *, int, frame_data *, proto_tree *, int);
|
||||
void dissect_nbdgm(const u_char *, int, frame_data *, proto_tree *);
|
||||
void dissect_netbios(const u_char *, int, frame_data *, proto_tree *);
|
||||
void dissect_nbipx_ns(const u_char *, int, frame_data *, proto_tree *, int);
|
||||
void dissect_nbns(const u_char *, int, frame_data *, proto_tree *);
|
||||
void dissect_nbss(const u_char *, int, frame_data *, proto_tree *);
|
||||
void dissect_ncp(const u_char *, int, frame_data *, proto_tree *, int);
|
||||
void dissect_nntp(const u_char *, int, frame_data *, proto_tree *);
|
||||
void dissect_nwlink_dg(const u_char *, int, frame_data *, proto_tree *, int);
|
||||
void dissect_osi(const u_char *, int, frame_data *, proto_tree *);
|
||||
void dissect_ospf(const u_char *, int, frame_data *, proto_tree *);
|
||||
void dissect_ospf_hello(const u_char *, int, frame_data *, proto_tree *);
|
||||
void dissect_pop(const u_char *, int, frame_data *, proto_tree *);
|
||||
void dissect_pppoed(const u_char *, int, frame_data *, proto_tree *);
|
||||
void dissect_pppoes(const u_char *, int, frame_data *, proto_tree *);
|
||||
void dissect_isakmp(const u_char *, int, frame_data *, proto_tree *);
|
||||
|
@ -441,6 +450,7 @@ void dissect_rtsp(const u_char *, int, frame_data *, proto_tree *);
|
|||
void dissect_sdp(const u_char *, int, frame_data *, proto_tree *);
|
||||
void dissect_snmp(const u_char *, int, frame_data *, proto_tree *);
|
||||
void dissect_tcp(const u_char *, int, frame_data *, proto_tree *);
|
||||
void dissect_telnet(const u_char *, int, frame_data *, proto_tree *);
|
||||
void dissect_tftp(const u_char *, int, frame_data *, proto_tree *);
|
||||
void dissect_trmac(const u_char *, int, frame_data *, proto_tree *);
|
||||
void dissect_udp(const u_char *, int, frame_data *, proto_tree *);
|
||||
|
@ -454,13 +464,7 @@ void dissect_vines_spp(const u_char *, int, frame_data *, proto_tree *);
|
|||
void dissect_payload_ppp(const u_char *, int, frame_data *, proto_tree *);
|
||||
void dissect_x25(const u_char *, int, frame_data *, proto_tree *);
|
||||
|
||||
void dissect_ftp(const u_char *, int, frame_data *, proto_tree *, int);
|
||||
void dissect_ftpdata(const u_char *, int, frame_data *, proto_tree *, int);
|
||||
void dissect_nbss(const u_char *, int, frame_data *, proto_tree *, int);
|
||||
void dissect_nntp(const u_char *, int, frame_data *, proto_tree *, int);
|
||||
void dissect_pop(const u_char *, int, frame_data *, proto_tree *, int);
|
||||
void dissect_smb(const u_char *, int, frame_data *, proto_tree *, int);
|
||||
void dissect_telnet(const u_char *, int, frame_data *, proto_tree *, int);
|
||||
void dissect_pptp(const u_char *, int, frame_data *, proto_tree *);
|
||||
void dissect_gre(const u_char *, int, frame_data *, proto_tree *);
|
||||
|
||||
|
|
Loading…
Reference in New Issue