version 1.14, 2010/04/28 18:22:11 |
version 1.15, 2010/10/30 23:06:05 |
|
|
#include <kvm.h> |
#include <kvm.h> |
#include "netstat.h" |
#include "netstat.h" |
|
|
static void unixdomainpr(struct socket *, caddr_t); |
static void unixdomainpr(struct socket *, caddr_t, u_long); |
|
|
static struct file *file, *fileNFILE; |
static struct file *file, *fileNFILE; |
static int fcnt; |
static int fcnt; |
extern kvm_t *kvmd; |
extern kvm_t *kvmd; |
|
|
void |
void |
unixpr(u_long off) |
unixpr(u_long off, u_long pcbaddr) |
{ |
{ |
struct file *fp; |
struct file *fp; |
struct socket sock, *so = &sock; |
struct socket sock, *so = &sock; |
|
|
/* kludge */ |
/* kludge */ |
if (so->so_proto >= unixsw && so->so_proto <= unixsw + 2) |
if (so->so_proto >= unixsw && so->so_proto <= unixsw + 2) |
if (so->so_pcb) |
if (so->so_pcb) |
unixdomainpr(so, fp->f_data); |
unixdomainpr(so, fp->f_data, pcbaddr); |
} |
} |
} |
} |
|
|
|
|
{ "#0", "stream", "dgram", "raw", "rdm", "seqpacket" }; |
{ "#0", "stream", "dgram", "raw", "rdm", "seqpacket" }; |
|
|
static void |
static void |
unixdomainpr(struct socket *so, caddr_t soaddr) |
unixdomainpr(struct socket *so, caddr_t soaddr, u_long pcbaddr) |
{ |
{ |
struct unpcb unpcb, *unp = &unpcb; |
struct unpcb unpcb, *unp = &unpcb; |
struct mbuf mbuf, *m; |
struct mbuf mbuf, *m; |
struct sockaddr_un *sa = NULL; |
struct sockaddr_un *sa = NULL; |
static int first = 1; |
static int first = 1; |
|
|
|
if (Pflag) { |
|
if (pcbaddr == (u_long)soaddr) |
|
socket_dump(pcbaddr); |
|
return; |
|
} |
|
|
if (kread((u_long)so->so_pcb, unp, sizeof (*unp))) |
if (kread((u_long)so->so_pcb, unp, sizeof (*unp))) |
return; |
return; |
if (unp->unp_addr) { |
if (unp->unp_addr) { |
|
|
(int)(m->m_len - (int)(sizeof(*sa) - sizeof(sa->sun_path))), |
(int)(m->m_len - (int)(sizeof(*sa) - sizeof(sa->sun_path))), |
sa->sun_path); |
sa->sun_path); |
putchar('\n'); |
putchar('\n'); |
|
} |
|
|
|
/* |
|
* Dump the contents of a UNIX PCB |
|
*/ |
|
void |
|
unpcb_dump(u_long off) |
|
{ |
|
struct unpcb unp; |
|
|
|
if (off == 0) |
|
return; |
|
kread(off, &unp, sizeof(unp)); |
|
|
|
#define p(fmt, v, sep) printf(#v " " fmt sep, unp.v); |
|
printf("unpcb %#lx\n ", off); |
|
p("%p", unp_socket, "\n "); |
|
p("%p", unp_vnode, ", "); |
|
p("%u", unp_ino, "\n "); |
|
p("%p", unp_conn, ", "); |
|
p("%p", unp_refs, ", "); |
|
p("%p", unp_nextref, "\n "); |
|
p("%p", unp_addr, "\n "); |
|
p("%#0.8x", unp_flags, "\n "); |
|
p("%u", unp_connid.uid, ", "); |
|
p("%u", unp_connid.gid, ", "); |
|
p("%d", unp_connid.pid, "\n "); |
|
p("%d", unp_cc, ", "); |
|
p("%d", unp_mbcnt, "\n "); |
|
p("%d", unp_ctime.tv_sec, ", "); |
|
p("%ld", unp_ctime.tv_nsec, "\n"); |
|
#undef p |
} |
} |