I removed the bit-fields that depended upon gcc's ability to use any type
of variable as a bit field container. ANSI specs only allow unsigned ints to host bit fields; IBM's C compiler is very ANSI-strict. svn path=/trunk/; revision=183
This commit is contained in:
parent
3384ac4a63
commit
facb503960
|
@ -41,12 +41,18 @@
|
|||
|
||||
extern packet_info pi;
|
||||
|
||||
typedef struct _e_ddp {
|
||||
/* P = Padding, H = Hops, L = Len */
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
guint16 pad:2,hops:4,len:10;
|
||||
/* PPHHHHLL LLLLLLLL */
|
||||
#define ddp_hops(x) ( ( x >> 10) & 0x3C )
|
||||
#define ddp_len(x) ( x & 0x03ff )
|
||||
#else
|
||||
guint16 len:10,hops:4,pad:2;
|
||||
/* LLLLLLLL PPHHHHLL*/
|
||||
#define ddp_hops(x) ( x & 0x3C )
|
||||
#define ddp_len(x) ( ntohs(x) & 0x03ff )
|
||||
#endif
|
||||
typedef struct _e_ddp {
|
||||
guint16 hops_len; /* combines pad, hops, and len */
|
||||
guint16 sum,dnet,snet;
|
||||
guint8 dnode,snode;
|
||||
guint8 dport,sport;
|
||||
|
@ -94,8 +100,8 @@ dissect_ddp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
|
|||
"Datagram Delivery Protocol");
|
||||
ddp_tree = gtk_tree_new();
|
||||
add_subtree(ti, ddp_tree, ETT_IP);
|
||||
add_item_to_tree(ddp_tree, offset, 1, "Hop count: %d", ddp.hops);
|
||||
add_item_to_tree(ddp_tree, offset, 2, "Datagram length: %d", ddp.len);
|
||||
add_item_to_tree(ddp_tree, offset, 1, "Hop count: %d", ddp_hops(ddp.hops_len));
|
||||
add_item_to_tree(ddp_tree, offset, 2, "Datagram length: %d", ddp_len(ddp.hops_len));
|
||||
add_item_to_tree(ddp_tree, offset + 2, 2, "Checksum: %d",ddp.sum);
|
||||
add_item_to_tree(ddp_tree, offset + 4, 2, "Destination Net: %d",ddp.dnet);
|
||||
add_item_to_tree(ddp_tree, offset + 6, 2, "Source Net: %d",ddp.snet);
|
||||
|
|
14
packet-ip.c
14
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.13 1998/12/29 04:05:35 gerald Exp $
|
||||
* $Id: packet-ip.c,v 1.14 1999/02/08 20:02:34 gram Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -411,7 +411,7 @@ dissect_ip(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
|
|||
iph.ip_off = ntohs(iph.ip_off);
|
||||
iph.ip_sum = ntohs(iph.ip_sum);
|
||||
|
||||
hlen = iph.ip_hl * 4; /* IP header length, in bytes */
|
||||
hlen = lo_nibble(iph.ip_v_hl) * 4; /* IP header length, in bytes */
|
||||
|
||||
switch (iph.ip_p) {
|
||||
case IP_PROTO_ICMP:
|
||||
|
@ -466,7 +466,7 @@ dissect_ip(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
|
|||
ti = add_item_to_tree(GTK_WIDGET(tree), offset, hlen, "Internet Protocol");
|
||||
ip_tree = gtk_tree_new();
|
||||
add_subtree(ti, ip_tree, ETT_IP);
|
||||
add_item_to_tree(ip_tree, offset, 1, "Version: %d", iph.ip_v);
|
||||
add_item_to_tree(ip_tree, offset, 1, "Version: %d", hi_nibble(iph.ip_v_hl));
|
||||
add_item_to_tree(ip_tree, offset, 1, "Header length: %d bytes", hlen);
|
||||
tf = add_item_to_tree(ip_tree, offset + 1, 1, "Type of service: 0x%02x (%s)",
|
||||
iph.ip_tos, tos_str);
|
||||
|
@ -534,7 +534,7 @@ dissect_ip(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
|
|||
pi.destip = ip_to_str( (guint8 *) &iph.ip_dst);
|
||||
pi.ipproto = iph.ip_p;
|
||||
pi.iplen = iph.ip_len;
|
||||
pi.iphdrlen = iph.ip_hl;
|
||||
pi.iphdrlen = lo_nibble(iph.ip_v_hl);
|
||||
pi.ip_src = iph.ip_src;
|
||||
|
||||
offset += hlen;
|
||||
|
@ -682,7 +682,7 @@ dissect_igmp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
|
|||
/* To do: check for runts, errs, etc. */
|
||||
cksum = ntohs(ih.igmp_cksum);
|
||||
|
||||
switch (ih.igmp_t) {
|
||||
switch (lo_nibble(ih.igmp_v_t)) {
|
||||
case IGMP_M_QRY:
|
||||
strcpy(type_str, "Router query");
|
||||
break;
|
||||
|
@ -722,9 +722,9 @@ dissect_igmp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
|
|||
igmp_tree = gtk_tree_new();
|
||||
add_subtree(ti, igmp_tree, ETT_IGMP);
|
||||
add_item_to_tree(igmp_tree, offset, 1, "Version: %d",
|
||||
ih.igmp_v);
|
||||
hi_nibble(ih.igmp_v_t));
|
||||
add_item_to_tree(igmp_tree, offset , 1, "Type: %d (%s)",
|
||||
ih.igmp_t, type_str);
|
||||
lo_nibble(ih.igmp_v_t), type_str);
|
||||
add_item_to_tree(igmp_tree, offset + 1, 1, "Unused: 0x%02x",
|
||||
ih.igmp_unused);
|
||||
add_item_to_tree(igmp_tree, offset + 2, 2, "Checksum: 0x%04x",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* packet-tcp.c
|
||||
* Routines for TCP packet disassembly
|
||||
*
|
||||
* $Id: packet-tcp.c,v 1.13 1999/01/04 08:45:22 guy Exp $
|
||||
* $Id: packet-tcp.c,v 1.14 1999/02/08 20:02:34 gram Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -288,7 +288,7 @@ dissect_tcp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
|
|||
flags[fpos] = '\0';
|
||||
}
|
||||
|
||||
hlen = th.th_off * 4; /* TCP header length, in bytes */
|
||||
hlen = hi_nibble(th.th_off_x2) * 4; /* TCP header length, in bytes */
|
||||
|
||||
if (check_col(fd, COL_RES_SRC_PORT))
|
||||
col_add_str(fd, COL_RES_SRC_PORT, get_tcp_port(th.th_sport));
|
||||
|
@ -402,7 +402,7 @@ dissect_tcp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
|
|||
|
||||
if( data_out_file ) {
|
||||
reassemble_tcp( th.th_seq, /* sequence number */
|
||||
( pi.iplen -( pi.iphdrlen * 4 )-( th.th_off * 4 ) ), /* length */
|
||||
( pi.iplen -( pi.iphdrlen * 4 )-( hi_nibble(th.th_off_x2) * 4 ) ), /* length */
|
||||
( pd+offset ), /* data */
|
||||
( th.th_flags & 0x02 ), /* is syn set? */
|
||||
pi.ip_src ); /* src ip */
|
||||
|
|
29
packet.h
29
packet.h
|
@ -1,7 +1,7 @@
|
|||
/* packet.h
|
||||
* Definitions for packet disassembly structures and routines
|
||||
*
|
||||
* $Id: packet.h,v 1.34 1999/01/28 21:29:36 gram Exp $
|
||||
* $Id: packet.h,v 1.35 1999/02/08 20:02:33 gram Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -51,6 +51,9 @@
|
|||
(guint32)*((guint8 *)p+0)<<0)
|
||||
|
||||
|
||||
#define hi_nibble(b) ((b & 0xf0) >> 4)
|
||||
#define lo_nibble(b) (b & 0x0f)
|
||||
|
||||
/* Useful when highlighting regions inside a dissect_*() function. With this
|
||||
* macro, you can highlight from the start of the packet to the end of the
|
||||
* frame. See dissect_data() for an example.
|
||||
|
@ -161,13 +164,7 @@ typedef struct _e_icmp {
|
|||
/* IGMP structs and definitions */
|
||||
|
||||
typedef struct _e_igmp {
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
guint8 igmp_v:4;
|
||||
guint8 igmp_t:4;
|
||||
#else /* Little endian */
|
||||
guint8 igmp_t:4;
|
||||
guint8 igmp_v:4;
|
||||
#endif
|
||||
guint8 igmp_v_t; /* combines igmp_v and igmp_t */
|
||||
guint8 igmp_unused;
|
||||
guint16 igmp_cksum;
|
||||
guint32 igmp_gaddr;
|
||||
|
@ -185,13 +182,7 @@ typedef struct _e_igmp {
|
|||
/* IP structs and definitions */
|
||||
|
||||
typedef struct _e_ip {
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
guint8 ip_v:4;
|
||||
guint8 ip_hl:4;
|
||||
#else /* Little endian */
|
||||
guint8 ip_hl:4;
|
||||
guint8 ip_v:4;
|
||||
#endif
|
||||
guint8 ip_v_hl; /* combines ip_v and ip_hl */
|
||||
guint8 ip_tos;
|
||||
guint16 ip_len;
|
||||
guint16 ip_id;
|
||||
|
@ -304,13 +295,7 @@ typedef struct _e_tcphdr {
|
|||
guint16 th_dport;
|
||||
guint32 th_seq;
|
||||
guint32 th_ack;
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
guint8 th_x2:4;
|
||||
guint8 th_off:4;
|
||||
#else
|
||||
guint8 th_off:4;
|
||||
guint8 th_x2:4;
|
||||
#endif
|
||||
guint8 th_off_x2; /* combines th_off and th_x2 */
|
||||
guint8 th_flags;
|
||||
#define TH_FIN 0x01
|
||||
#define TH_SYN 0x02
|
||||
|
|
Loading…
Reference in New Issue