/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
*/
#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 <stdarg.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 *
{
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_title;
void
{
prot_prefix = pref;
prot_title = str;
}
void
{
xdr_totlen = len;
}
/* Note: begin+end are ignored in get_detail_line */
char *
{
char *line;
}
int
get_line_remain(void)
{
}
void
{
}
void
{
}
char
{
char s;
return (s);
/* NOTREACHED */
}
char
{
pos = getxdr_pos();
val = getxdr_char();
return (val);
}
{
uchar_t s;
if (xdr_u_char(&xdrm, &s))
return (s);
/* NOTREACHED */
}
{
int pos;
pos = getxdr_pos();
val = getxdr_u_char();
return (val);
}
short
{
short s;
return (s);
/* NOTREACHED */
}
short
{
pos = getxdr_pos();
val = getxdr_short();
return (val);
}
{
ushort_t s;
if (xdr_u_short(&xdrm, &s))
return (s);
/* NOTREACHED */
}
{
int pos;
pos = getxdr_pos();
val = getxdr_u_short();
return (val);
}
long
{
long l;
return (l);
/* NOTREACHED */
}
long
{
pos = getxdr_pos();
val = getxdr_long();
return (val);
}
{
ulong_t l;
if (xdr_u_long(&xdrm, &l))
return (l);
/* NOTREACHED */
}
{
int pos;
pos = getxdr_pos();
val = getxdr_u_long();
return (val);
}
{
longlong_t l;
if (xdr_longlong_t(&xdrm, &l))
return (l);
/* NOTREACHED */
}
{
pos = getxdr_pos();
val = getxdr_longlong();
return (val);
}
{
u_longlong_t l;
if (xdr_u_longlong_t(&xdrm, &l))
return (l);
/* NOTREACHED */
}
{
pos = getxdr_pos();
val = getxdr_u_longlong();
return (val);
}
{
bool_t b;
return (b);
/* NOTREACHED */
}
{
pos = getxdr_pos();
val = getxdr_bool();
return (val);
}
char *
{
return (p);
/* NOTREACHED */
}
char *
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 *
{
char *p = buff;
return (buff);
/* NOTREACHED */
}
char *
{
size = getxdr_u_short();
return (p);
/* NOTREACHED */
}
char *
{
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
{
}
void
{
(void) get_line(0, 0);
}
void
{
show_space();
}
char *
{
int usec;
char *p;
/* between gmtime and strftime */
sec = getxdr_long();
usec = getxdr_long();
if (sec == -1)
return ("-1 ");
} else {
}
return (buff);
}
char *
{
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 *
{
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 *
{
int pos;
char *p;
pos = getxdr_pos();
p = getxdr_date_ns();
return (p);
}
char *
{
/* between gmtime and strftime */
sec = getxdr_long();
if (sec == -1)
return ("-1 ");
} else {
}
return (buff);
}
char *
{
int pos;
char *p;
pos = getxdr_pos();
p = getxdr_time();
return (p);
}
char *
{
int i, j;
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");
}
char *
/*
* Prints len bytes from str enclosed in quotes.
* If len is negative, length is taken from strlen(str).
* No more than maxlen bytes will be printed. Longer
* strings are flagged with ".." after the closing quote.
* Non-printing characters are converted to C-style escape
* codes or octal digits.
*/
{
const char *p;
char *pp;
int printable = 0;
int c, len;
switch (c = *p & 0xFF) {
default:
*pp++ = c;
printable++;
} else {
isdigit(*(p + 1)) ?
"\\%03o" : "\\%o", c);
}
break;
}
*pp = '\0';
/*
* Check for overflow of temporary buffer. Allow for
* the next character to be a \nnn followed by a trailing
* null. If not, then just bail with what we have.
*/
break;
}
}
}