* Copyright (c) 1988, 1991 The Regents of the University of California.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
"@(#) Copyright (c) 1988, 1991 The Regents of the University of California.\n\
static char sccsid
[] = "@(#)pk_dump.c 7.2 (Berkeley) 5/9/91";
* This is a kernel debugging aid.
* dumps out a cache of mbufs.
#include <sys/socketvar.h>
#include <netccitt/x25.h>
#include <netccitt/pk_var.h>
* This procedure decodes the X.25 level 3 packet returning a
* code to be used in switchs or arrays.
register struct x25_packet
*xp
;
if (xp
-> fmt_identifier
!= 1)
* Make sure that the logical channel group number is 0.
* This restriction may be removed at some later date.
if (xp
-> lc_group_number
!= 0)
* Test for data packet first.
if (!(xp
-> packet_type
& DATA_PACKET_DESIGNATOR
))
* Test if flow control packet (RR or RNR).
if (!(xp
-> packet_type
& RR_OR_RNR_PACKET_DESIGNATOR
))
switch (xp
-> packet_type
& 0x1f) {
* Determine the rest of the packet types.
switch (xp
-> packet_type
) {
case X25_INTERRUPT_CONFIRM
:
case X25_RESTART_CONFIRM
:
"Listen", "Ready", "Received-Call",
"Sent-Call", "Data-Transfer","Received-Clear",
"Call", "Call-Conf", "Clear",
"Clear-Conf", "Data", "Intr", "Intr-Conf",
"Rr", "Rnr", "Reset", "Reset-Conf",
"Restart", "Restart-Conf", "Reject", "Diagnostic",
int pk_lengths
[] = {0, 0, 0,
struct x25_packet
*xp
= mtod(m
, struct x25_packet
*);
register int i
, len
= 0, cnt
= 0;
i
= pk_decode (xp
) / MAXSTATES
;
if ((len
= pk_lengths
[i
]) || (len
= m
-> m_len
))
printf ("%s LCN=%d: %s (", dir
, LCN(xp
), pk_name
[i
]);
for (s
= (char *) xp
, i
= 0; i
< len
; ++i
, ++s
)
printf ("%x ", (int) * s
& 0xff);
for (; (i
= *s
) > 32; s
++)
int verbose
= 0; /* so you can adb -w the binary */
char *vmunix
= _PATH_UNIX
;
if (kvm_openfiles(vmunix
, kmemf
, NULL
) == -1) {
fprintf(stderr
, "netstat: kvm_openfiles: %s\n", kvm_geterr());
if (kvm_nlist(nl
) < 0 || nl
[0].n_type
== 0) {
fprintf(stderr
, "%s: no namelist\n", vmunix
);
(kvm_read((void *)(p), &(d), sizeof (d)))
printf("Dumping %s:\n", nl
->n_name
);
if (cache_size
= c
.mbc_size
* sizeof(m
))
mbvec
= (struct mbuf
**)malloc(cache_size
);
if (mbvec
== 0 || c
.mbc_cache
== 0)
kvm_read(c
.mbc_cache
, mbvec
, cache_size
);
register struct x25_packet
*xp
;
for (; m
; m
= n
.m_next
) {
bprintf(stdout
, n
.m_flags
,
"\1M_EXT\2M_PKTHDR\3M_EOR\4M_BCAST\5M_MCAST");
printf(" chained %x", n
.m_nextpkt
);
printf(" next %x len %d", n
.m_next
, n
.m_len
);
if (n
.m_flags
& M_PKTHDR
) {
printf(" total %d", n
.m_pkthdr
.len
);
printf(" rcvif %x", n
.m_pkthdr
.rcvif
);
kvm_read(n
.m_ext
.ext_buf
, extbuf
, sizeof(extbuf
));
n
.m_data
= extbuf
+ (n
.m_data
- n
.m_ext
.ext_buf
);
} else if (n
.m_data
< m
->m_dat
+ MLEN
)
n
.m_data
= n
.m_dat
+ (n
.m_data
- m
->m_dat
);
printf("mbuf screwup\n");
dumpit("data: ",n
.m_data
, n
.m_len
);
char *what
; unsigned short *where
; int n
;
unsigned short *s
= where
;
unsigned short *z
= where
+ (n
+1)/2;