summaryrefslogtreecommitdiffstats
path: root/contrib/tcpdump/print-wb.c
diff options
context:
space:
mode:
authorbms <bms@FreeBSD.org>2004-03-31 09:17:26 +0000
committerbms <bms@FreeBSD.org>2004-03-31 09:17:26 +0000
commit281e9d71408deb6e8c5046c746c2e97002b0e7fe (patch)
treeeb08e08f0f875c3b16f8e1aec86091f100906f1c /contrib/tcpdump/print-wb.c
parentbe6faec6d07fc3a2a54836e76d0309c36192dfad (diff)
downloadFreeBSD-src-281e9d71408deb6e8c5046c746c2e97002b0e7fe.zip
FreeBSD-src-281e9d71408deb6e8c5046c746c2e97002b0e7fe.tar.gz
Import tcpdump 3.8.3, from http://www.tcpdump.org/releases/tcpdump-3.8.3.tar.gz
Diffstat (limited to 'contrib/tcpdump/print-wb.c')
-rw-r--r--contrib/tcpdump/print-wb.c79
1 files changed, 40 insertions, 39 deletions
diff --git a/contrib/tcpdump/print-wb.c b/contrib/tcpdump/print-wb.c
index 7b0281b..678e325 100644
--- a/contrib/tcpdump/print-wb.c
+++ b/contrib/tcpdump/print-wb.c
@@ -20,25 +20,24 @@
*/
#ifndef lint
-static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-wb.c,v 1.26 2001/06/27 05:37:19 guy Exp $ (LBL)";
+static const char rcsid[] _U_ =
+ "@(#) $Header: /tcpdump/master/tcpdump/print-wb.c,v 1.30.2.3 2004/03/24 04:06:52 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <sys/types.h>
-#include <sys/time.h>
-
-#include <netinet/in.h>
+#include <tcpdump-stdinc.h>
#include <stdio.h>
#include "interface.h"
#include "addrtoname.h"
+#include "extract.h"
/* XXX need to add byte-swapping macros! */
+/* XXX - you mean like the ones in "extract.h"? */
/*
* Largest packet size. Everything should fit within this space.
@@ -54,7 +53,7 @@ static const char rcsid[] =
#define DOP_ROUNDUP(x) ((((int)(x)) + (DOP_ALIGN - 1)) & ~(DOP_ALIGN - 1))
#define DOP_NEXT(d)\
((struct dophdr *)((u_char *)(d) + \
- DOP_ROUNDUP(ntohs((d)->dh_len) + sizeof(*(d)))))
+ DOP_ROUNDUP(EXTRACT_16BITS(&(d)->dh_len) + sizeof(*(d)))))
/*
* Format of the whiteboard packet header.
@@ -63,7 +62,7 @@ static const char rcsid[] =
struct pkt_hdr {
u_int32_t ph_src; /* site id of source */
u_int32_t ph_ts; /* time stamp (for skew computation) */
- u_short ph_version; /* version number */
+ u_int16_t ph_version; /* version number */
u_char ph_type; /* message type */
u_char ph_flags; /* message flags */
};
@@ -92,7 +91,7 @@ struct PageID {
struct dophdr {
u_int32_t dh_ts; /* sender's timestamp */
- u_short dh_len; /* body length */
+ u_int16_t dh_len; /* body length */
u_char dh_flags;
u_char dh_type; /* body type */
/* body follows */
@@ -153,8 +152,8 @@ struct id_off {
struct pgstate {
u_int32_t slot;
struct PageID page;
- u_short nid;
- u_short rsvd;
+ u_int16_t nid;
+ u_int16_t rsvd;
/* seqptr's */
};
@@ -195,14 +194,14 @@ wb_id(const struct pkt_id *id, u_int len)
len -= sizeof(*id);
printf(" %u/%s:%u (max %u/%s:%u) ",
- (u_int32_t)ntohl(id->pi_ps.slot),
+ EXTRACT_32BITS(&id->pi_ps.slot),
ipaddr_string(&id->pi_ps.page.p_sid),
- (u_int32_t)ntohl(id->pi_ps.page.p_uid),
- (u_int32_t)ntohl(id->pi_mslot),
+ EXTRACT_32BITS(&id->pi_ps.page.p_uid),
+ EXTRACT_32BITS(&id->pi_mslot),
ipaddr_string(&id->pi_mpage.p_sid),
- (u_int32_t)ntohl(id->pi_mpage.p_uid));
+ EXTRACT_32BITS(&id->pi_mpage.p_uid));
- nid = ntohs(id->pi_ps.nid);
+ nid = EXTRACT_16BITS(&id->pi_ps.nid);
len -= sizeof(*io) * nid;
io = (struct id_off *)(id + 1);
cp = (char *)(io + nid);
@@ -213,9 +212,9 @@ wb_id(const struct pkt_id *id, u_int len)
}
c = '<';
- for (i = 0; i < nid && (u_char *)io < snapend; ++io, ++i) {
+ for (i = 0; i < nid && (u_char *)(io + 1) <= snapend; ++io, ++i) {
printf("%c%s:%u",
- c, ipaddr_string(&io->id), (u_int32_t)ntohl(io->off));
+ c, ipaddr_string(&io->id), EXTRACT_32BITS(&io->off));
c = ',';
}
if (i >= nid) {
@@ -235,9 +234,9 @@ wb_rreq(const struct pkt_rreq *rreq, u_int len)
printf(" please repair %s %s:%u<%u:%u>",
ipaddr_string(&rreq->pr_id),
ipaddr_string(&rreq->pr_page.p_sid),
- (u_int32_t)ntohl(rreq->pr_page.p_uid),
- (u_int32_t)ntohl(rreq->pr_sseq),
- (u_int32_t)ntohl(rreq->pr_eseq));
+ EXTRACT_32BITS(&rreq->pr_page.p_uid),
+ EXTRACT_32BITS(&rreq->pr_sseq),
+ EXTRACT_32BITS(&rreq->pr_eseq));
return (0);
}
@@ -249,9 +248,9 @@ wb_preq(const struct pkt_preq *preq, u_int len)
return (-1);
printf(" need %u/%s:%u",
- (u_int32_t)ntohl(preq->pp_low),
+ EXTRACT_32BITS(&preq->pp_low),
ipaddr_string(&preq->pp_page.p_sid),
- (u_int32_t)ntohl(preq->pp_page.p_uid));
+ EXTRACT_32BITS(&preq->pp_page.p_uid));
return (0);
}
@@ -266,20 +265,20 @@ wb_prep(const struct pkt_prep *prep, u_int len)
if (len < sizeof(*prep)) {
return (-1);
}
- n = ntohl(prep->pp_n);
+ n = EXTRACT_32BITS(&prep->pp_n);
ps = (const struct pgstate *)(prep + 1);
- while (--n >= 0 && (u_char *)ps < ep) {
+ while (--n >= 0 && (u_char *)(ps + 1) <= ep) {
const struct id_off *io, *ie;
char c = '<';
printf(" %u/%s:%u",
- (u_int32_t)ntohl(ps->slot),
+ EXTRACT_32BITS(&ps->slot),
ipaddr_string(&ps->page.p_sid),
- (u_int32_t)ntohl(ps->page.p_uid));
+ EXTRACT_32BITS(&ps->page.p_uid));
io = (struct id_off *)(ps + 1);
- for (ie = io + ps->nid; io < ie && (u_char *)io < ep; ++io) {
+ for (ie = io + ps->nid; io < ie && (u_char *)(io + 1) <= ep; ++io) {
printf("%c%s:%u", c, ipaddr_string(&io->id),
- (u_int32_t)ntohl(io->off));
+ EXTRACT_32BITS(&io->off));
c = ',';
}
printf(">");
@@ -289,7 +288,7 @@ wb_prep(const struct pkt_prep *prep, u_int len)
}
-char *dopstr[] = {
+const char *dopstr[] = {
"dop-0!",
"dop-1!",
"RECT",
@@ -320,7 +319,7 @@ wb_dops(const struct dophdr *dh, u_int32_t ss, u_int32_t es)
else {
printf(" %s", dopstr[t]);
if (t == DT_SKIP || t == DT_HOLE) {
- int ts = ntohl(dh->dh_ts);
+ u_int32_t ts = EXTRACT_32BITS(&dh->dh_ts);
printf("%d", ts - ss + 1);
if (ss > ts || ts > es) {
printf("[|]");
@@ -353,13 +352,14 @@ wb_rrep(const struct pkt_rrep *rrep, u_int len)
printf(" for %s %s:%u<%u:%u>",
ipaddr_string(&rrep->pr_id),
ipaddr_string(&dop->pd_page.p_sid),
- (u_int32_t)ntohl(dop->pd_page.p_uid),
- (u_int32_t)ntohl(dop->pd_sseq),
- (u_int32_t)ntohl(dop->pd_eseq));
+ EXTRACT_32BITS(&dop->pd_page.p_uid),
+ EXTRACT_32BITS(&dop->pd_sseq),
+ EXTRACT_32BITS(&dop->pd_eseq));
if (vflag)
return (wb_dops((const struct dophdr *)(dop + 1),
- ntohl(dop->pd_sseq), ntohl(dop->pd_eseq)));
+ EXTRACT_32BITS(&dop->pd_sseq),
+ EXTRACT_32BITS(&dop->pd_eseq)));
return (0);
}
@@ -373,13 +373,14 @@ wb_drawop(const struct pkt_dop *dop, u_int len)
printf(" %s:%u<%u:%u>",
ipaddr_string(&dop->pd_page.p_sid),
- (u_int32_t)ntohl(dop->pd_page.p_uid),
- (u_int32_t)ntohl(dop->pd_sseq),
- (u_int32_t)ntohl(dop->pd_eseq));
+ EXTRACT_32BITS(&dop->pd_page.p_uid),
+ EXTRACT_32BITS(&dop->pd_sseq),
+ EXTRACT_32BITS(&dop->pd_eseq));
if (vflag)
return (wb_dops((const struct dophdr *)(dop + 1),
- ntohl(dop->pd_sseq), ntohl(dop->pd_eseq)));
+ EXTRACT_32BITS(&dop->pd_sseq),
+ EXTRACT_32BITS(&dop->pd_eseq)));
return (0);
}
OpenPOWER on IntegriCloud