Beispiel #1
0
static void
pfiles_print_addr(struct sockaddr *addr)
{
	struct sockaddr_in *s_in;
	struct sockaddr_un *s_un;
	struct sockaddr_in6 *s_in6;
	in_port_t port;

	switch (addr->sa_family) {
	case AF_INET:
		/* LINTED: alignment */
		s_in = (struct sockaddr_in *)addr;
		mdb_nhconvert(&port, &s_in->sin_port, sizeof (port));
		mdb_printf("AF_INET %I %d ", s_in->sin_addr.s_addr, port);
		break;

	case AF_INET6:
		/* LINTED: alignment */
		s_in6 = (struct sockaddr_in6 *)addr;
		mdb_nhconvert(&port, &s_in6->sin6_port, sizeof (port));
		mdb_printf("AF_INET6 %N %d ", &(s_in6->sin6_addr), port);
		break;

	case AF_UNIX:
		s_un = (struct sockaddr_un *)addr;
		mdb_printf("AF_UNIX %s ", s_un->sun_path);
		break;
	default:
		mdb_printf("AF_?? (%d) ", addr->sa_family);
		break;
	}
}
Beispiel #2
0
/*
 * Print an IPv4 address and port number in a compact and easy to read format
 * The arguments are in network byte order
 */
static void
net_ipv4addrport_pr(const in6_addr_t *nipv6addr, in_port_t nport)
{
	uint32_t naddr = V4_PART_OF_V6((*nipv6addr));

	mdb_nhconvert(&nport, &nport, sizeof (nport));
	mdb_printf("%*I.%-5hu", ADDR_V4_WIDTH, naddr, nport);
}
Beispiel #3
0
static void
nvpair_print_value(char *data, int32_t elem_size, int32_t nelem,
    data_type_t type)
{
	int32_t i;

	if (elem_size == 0) {
		char *p = data;

		/* print out all the strings */
		for (i = 0; i < nelem - 1; i++) {
			mdb_printf("'%s' + ", p);
			p += strlen(p) + 1;
		}
		mdb_printf("'%s'", p);
	} else if (type == DATA_TYPE_BOOLEAN_VALUE ||
	    type == DATA_TYPE_BOOLEAN_ARRAY) {
		/* LINTED - pointer alignment */
		boolean_t *p = (boolean_t *)data;

		for (i = 0; i < nelem; i++) {
			if (i > 0)
				mdb_printf(".");
			mdb_printf("%d", p[i]);
		}
	} else {
		unsigned char	*p = (unsigned char *)data;
		int		size = elem_size * nelem;

		/*
		 * if elem_size != 0 then we are printing out an array
		 * where each element is of elem_size
		 */
		mdb_nhconvert(p, p, elem_size);
		mdb_printf("%02x", *p);
		for (i = 1; i < size; i++) {
			if ((i % elem_size) == 0) {
				mdb_nhconvert(&p[i], &p[i], elem_size);
				mdb_printf(".");
			}
			mdb_printf("%02x", p[i]);
		}
	}
	mdb_printf("\n");
}
Beispiel #4
0
/*
 * Print the core TCP-related fields in an NCA nca_conn_t.  With the "-t"
 * argument, skips all nca_conn_t's that are in the TIME_WAIT state.
 */
static int
nca_tcpconn(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
{
	nca_conn_t		conn;
	unsigned int	show_timewait = TRUE;

	if (!(flags & DCMD_ADDRSPEC))
		return (DCMD_USAGE);

	if (mdb_getopts(argc, argv, 't', MDB_OPT_CLRBITS, TRUE, &show_timewait,
	    NULL) != argc)
		return (DCMD_USAGE);

	if (DCMD_HDRSPEC(flags)) {
		mdb_printf("%<u>%-*s %21s %5s %8s %5s %8s %5s %-9s%</u>\n",
		    NCA_ADDR_WIDTH, "ADDR", "REMOTE_ADDR", "SWIND", "SUNASEQ",
		    "SNSEQ", "RACKSEQ", "RNSEQ", "STATE");
	}

	if (mdb_vread(&conn, sizeof (nca_conn_t), addr) == -1) {
		mdb_warn("cannot read nca_conn_t at %p", addr);
		return (DCMD_ERR);
	}

	if (!show_timewait && conn.tcp_state == TCPS_TIME_WAIT)
		return (DCMD_OK);

	mdb_nhconvert(&conn.conn_fport, &conn.conn_fport, sizeof (in_port_t));

	mdb_printf("%0*p %15I:%05hu %5u %08x %+5d %08x %+5d %-9s\n",
	    NCA_ADDR_WIDTH, addr, conn.faddr, conn.conn_fport, conn.tcp_swnd,
	    conn.tcp_suna, conn.tcp_snxt - conn.tcp_suna, conn.tcp_rack,
	    conn.tcp_rnxt - conn.tcp_rack, state2name(conn.tcp_state));

	return (DCMD_OK);
}
Beispiel #5
0
/*
 * Print an IPv6 address and port number in a compact and easy to read format
 * The arguments are in network byte order
 */
static void
net_ipv6addrport_pr(const in6_addr_t *naddr, in_port_t nport)
{
	mdb_nhconvert(&nport, &nport, sizeof (nport));
	mdb_printf("%*N.%-5hu", ADDR_V6_WIDTH, naddr, nport);
}
Beispiel #6
0
static int
tcpip_sock_print(struct sonode *socknode)
{
	switch (socknode->so_family) {
	case AF_INET:
	{
		conn_t conn_t;
		in_port_t port;

		if (mdb_vread(&conn_t, sizeof (conn_t),
		    (uintptr_t)socknode->so_proto_handle) == -1) {
			mdb_warn("failed to read conn_t V4");
			return (-1);
		}

		mdb_printf("socket: ");
		mdb_nhconvert(&port, &conn_t.conn_lport, sizeof (port));
		mdb_printf("AF_INET %I %d ", conn_t.conn_laddr_v4, port);

		/*
		 * If this is a listening socket, we don't print
		 * the remote address.
		 */
		if (IPCL_IS_TCP(&conn_t) && IPCL_IS_BOUND(&conn_t) == 0 ||
		    IPCL_IS_UDP(&conn_t) && IPCL_IS_CONNECTED(&conn_t)) {
			mdb_printf("remote: ");
			mdb_nhconvert(&port, &conn_t.conn_fport, sizeof (port));
			mdb_printf("AF_INET %I %d ", conn_t.conn_faddr_v4,
			    port);
		}

		break;
	}

	case AF_INET6:
	{
		conn_t conn_t;
		in_port_t port;

		if (mdb_vread(&conn_t, sizeof (conn_t),
		    (uintptr_t)socknode->so_proto_handle) == -1) {
			mdb_warn("failed to read conn_t V6");
			return (-1);
		}

		mdb_printf("socket: ");
		mdb_nhconvert(&port, &conn_t.conn_lport, sizeof (port));
		mdb_printf("AF_INET6 %N %d ", &conn_t.conn_laddr_v4, port);

		/*
		 * If this is a listening socket, we don't print
		 * the remote address.
		 */
		if (IPCL_IS_TCP(&conn_t) && IPCL_IS_BOUND(&conn_t) == 0 ||
		    IPCL_IS_UDP(&conn_t) && IPCL_IS_CONNECTED(&conn_t)) {
			mdb_printf("remote: ");
			mdb_nhconvert(&port, &conn_t.conn_fport, sizeof (port));
			mdb_printf("AF_INET6 %N %d ", &conn_t.conn_faddr_v6,
			    port);
		}

		break;
	}

	default:
		mdb_printf("AF_?? (%d)", socknode->so_family);
		break;
	}

	return (0);
}
Beispiel #7
0
static uint64_t
nhconvert_8bytes(const void *src) {
    uint64_t dest;
    mdb_nhconvert(&dest, src, 8);
    return (dest);
}