snoop_display.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 1991-2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <fcntl.h>
#include <string.h>
#include <time.h>
#include <setjmp.h>
#include <varargs.h>
#include <netinet/in_systm.h>
#include <netinet/if_ether.h>
#include <inttypes.h>
#include "snoop.h"
char *dlc_header;
int pi_frame;
int pi_time_hour;
int pi_time_min;
int pi_time_sec;
int pi_time_usec;
#ifndef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
static void hexdump(char *, int);
/*
* This routine invokes the packet interpreters
* on a packet. There's some messing around
* setting up a few packet-externals before
* starting with the ethernet interpreter.
* Yes, we assume here that all packets will
* be ethernet packets.
*/
void
{
extern int x_offset;
extern int x_length;
return;
if (pktlen <= 0)
return;
/* set up externals */
dlc_header = pktp;
src_name = "?";
dst_name = "*";
hdrp->sbh_origlen);
hdrp->sbh_origlen);
if (x_offset >= 0) {
}
}
/*
* *************************************************************
* The following routines constitute a library
* used by the packet interpreters to facilitate
* the display of packet data. This library
* of routines helps provide a consistent
* "look and feel".
*/
/*
* Display the value of a flag bit in
* a byte together with some text that
* corresponds to its value - whether
* true or false.
*/
char *
{
static char buff[80];
char *p;
int set;
if (*p == ' ')
p--;
if (mask & 0x1) {
break;
}
mask >>= 1;
val >>= 1;
}
return (buff);
}
int xdr_totlen;
char *prot_prefix;
char *prot_nest_prefix = "";
char *prot_title;
void
{
prot_prefix = pref;
prot_title = str;
}
void
{
xdr_totlen = len;
}
char *
{
char *line;
}
int
get_line_remain(void)
{
}
void
{
}
char
{
char s;
return (s);
/* NOTREACHED */
}
char
showxdr_char(char *fmt)
{
pos = getxdr_pos();
val = getxdr_char();
return (val);
}
{
uchar_t s;
if (xdr_u_char(&xdrm, &s))
return (s);
/* NOTREACHED */
}
showxdr_u_char(char *fmt)
{
int pos;
pos = getxdr_pos();
val = getxdr_u_char();
return (val);
}
short
{
short s;
return (s);
/* NOTREACHED */
}
short
showxdr_short(char *fmt)
{
pos = getxdr_pos();
val = getxdr_short();
return (val);
}
{
ushort_t s;
if (xdr_u_short(&xdrm, &s))
return (s);
/* NOTREACHED */
}
showxdr_u_short(char *fmt)
{
int pos;
pos = getxdr_pos();
val = getxdr_u_short();
return (val);
}
long
{
long l;
return (l);
/* NOTREACHED */
}
long
showxdr_long(char *fmt)
{
pos = getxdr_pos();
val = getxdr_long();
return (val);
}
{
ulong_t l;
if (xdr_u_long(&xdrm, &l))
return (l);
/* NOTREACHED */
}
showxdr_u_long(char *fmt)
{
int pos;
pos = getxdr_pos();
val = getxdr_u_long();
return (val);
}
{
longlong_t l;
if (xdr_longlong_t(&xdrm, &l))
return (l);
/* NOTREACHED */
}
showxdr_longlong(char *fmt)
{
pos = getxdr_pos();
val = getxdr_longlong();
return (val);
}
{
u_longlong_t l;
if (xdr_u_longlong_t(&xdrm, &l))
return (l);
/* NOTREACHED */
}
showxdr_u_longlong(char *fmt)
{
pos = getxdr_pos();
val = getxdr_u_longlong();
return (val);
}
{
bool_t b;
return (b);
/* NOTREACHED */
}
showxdr_bool(char *fmt)
{
pos = getxdr_pos();
val = getxdr_bool();
return (val);
}
char *
getxdr_opaque(char *p, int len)
{
return (p);
/* NOTREACHED */
}
char *
getxdr_string(char *p, /* len+1 bytes or longer */
int len)
{
return (p);
/* NOTREACHED */
}
char *
char *fmt)
{
static int buff_len = 0;
int pos;
/*
* XDR strings don't necessarily have a trailing null over the
* wire. However, the XDR code will put one in for us. Make sure
* we have allocated room for it.
*/
len++;
if (buff)
pr_err("showxdr_string: no mem");
}
pos = getxdr_pos();
return (buff);
}
char *
{
static char buff[1024];
char *p = buff;
return (buff);
/* NOTREACHED */
}
char *
getxdr_context(char *p, int len)
{
size = getxdr_u_short();
return (p);
/* NOTREACHED */
}
char *
showxdr_context(char *fmt)
{
static char buff[1024];
int pos;
pos = getxdr_pos();
size = getxdr_u_short();
return (buff);
}
/* NOTREACHED */
}
{
enum_t e;
return (e);
/* NOTREACHED */
}
void
{
/* Check for overflow */
/* xdr_setpos() checks for buffer overrun */
}
int
{
return (xdr_getpos(&xdrm));
}
void
setxdr_pos(int pos)
{
}
void
{
(void) get_line(0, 0);
}
void
{
show_space();
}
char *
{
int usec;
static char buff[64];
char *p;
/* between gmtime and strftime */
sec = getxdr_long();
usec = getxdr_long();
if (sec == -1)
return ("-1 ");
} else {
}
return (buff);
}
char *
showxdr_date(char *fmt)
{
int pos;
char *p;
pos = getxdr_pos();
p = getxdr_date();
return (p);
}
char *
getxdr_date_ns(void)
{
sec = getxdr_long();
nsec = getxdr_long();
if (sec == -1)
return ("-1 ");
else
}
/*
* Format the given time.
*/
char *
{
static char buff[64];
char *p;
/* between gmtime and strftime */
/* assume not a date; includes negative times */
/*
* XXX No routines are available yet for formatting 64-bit
* times.
*/
} else {
}
return (buff);
}
char *
showxdr_date_ns(char *fmt)
{
int pos;
char *p;
pos = getxdr_pos();
p = getxdr_date_ns();
return (p);
}
char *
{
static char buff[64];
/* between gmtime and strftime */
sec = getxdr_long();
if (sec == -1)
return ("-1 ");
} else {
}
return (buff);
}
char *
showxdr_time(char *fmt)
{
int pos;
char *p;
pos = getxdr_pos();
p = getxdr_time();
return (p);
}
char *
getxdr_hex(int len)
{
int i, j;
static char hbuff[1024];
char rbuff[1024];
static char *hexstr = "0123456789ABCDEF";
char toobig = 0;
if (len == 0) {
hbuff[0] = '\0';
return (hbuff);
}
if (len > 1024)
len = 1024;
}
toobig++;
}
j = 0;
for (i = 0; i < len; i++) {
}
if (toobig) {
} else
hbuff[j] = '\0';
return (hbuff);
}
char *
{
int pos;
char *p;
pos = getxdr_pos();
p = getxdr_hex(len);
return (p);
}
static void
{
char *p;
printf("\n");
for (i = 0; i < (len / 2); i++)
if (len % 2) {
}
printf(" ");
printf(" ");
printf("\n");
}
printf("\n");
}