*/
#ifndef lint
-static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-wb.c,v 1.28 2002-09-05 00:00:24 guy Exp $ (LBL)";
+static const char rcsid[] _U_ =
+ "@(#) $Header: /tcpdump/master/tcpdump/print-wb.c,v 1.33 2004-03-24 04:06:28 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_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.
#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.
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 */
};
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 */
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 */
};
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);
}
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) {
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);
}
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);
}
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(">");
else {
printf(" %s", dopstr[t]);
if (t == DT_SKIP || t == DT_HOLE) {
- u_int32_t 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("[|]");
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);
}
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);
}