# /* in_logpkt.c */ /* EMACS_MODES: c !fill */ /* Internet protocol layer for the MIT network system. The following * routines are included: * in_logpkt Log packets to standard error. * * Note that use of this package requires the use of the standard I/O * library. */ #include #include #include #include #include #define min(x, y) ((x) < (y) ? (x) : (y)) in_logpkt (ppkt, len, dir) /* Log the specified packet out to the standard error. * * Arguments: */ reg char *ppkt; /* ptr. to packet */ int len; /* length of data part in bytes */ int dir; /* packet direction: */ /* INPKT - input */ /* OUTPKT - output */ { reg int totallen; /* total packet length in bytes */ reg int i; /* bytes per line counter */ int linelen; /* temp for bytes per line */ struct ip *pip; /* ptr. to in header */ if (dir == INPKT) fprintf (stderr, "Input packet:\r\n"); else fprintf (stderr, "Output packet:\r\n"); pip = in_head(ppkt); totallen = len + lnhsiz + lntsiz + (pip->ip_ihl << 2); while (totallen > 0) { linelen = min(16, totallen); for (i = 0; i < linelen; i++, totallen--) fprintf (stderr, "%3o ", (*ppkt++ & 0377)); fprintf (stderr, "\r\n"); } }