Exemplo n.º 1
0
static void
print_mreq6(struct tcb *tcp, long addr, unsigned int len)
{
	struct ipv6_mreq mreq;

	if (len < sizeof(mreq))
		goto fail;

	if (umove_or_printaddr(tcp, addr, &mreq))
		return;

#ifdef HAVE_INET_NTOP
	const struct in6_addr *in6 = &mreq.ipv6mr_multiaddr;
	char address[INET6_ADDRSTRLEN];

	if (!inet_ntop(AF_INET6, in6, address, sizeof(address)))
		goto fail;

	tprints("{ipv6mr_multiaddr=inet_pton(");
	print_quoted_string(address, sizeof(address), QUOTE_0_TERMINATED);
	tprints("), ipv6mr_interface=");
	print_ifindex(mreq.ipv6mr_interface);
	tprints("}");
	return;
#endif /* HAVE_INET_NTOP */

fail:
	printstr(tcp, addr, len);
}
Exemplo n.º 2
0
static void
print_cmsg_ip_pktinfo(struct tcb *tcp, const void *cmsg_data,
		      const size_t data_len)
{
	const struct in_pktinfo *info = cmsg_data;

	tprints("{ipi_ifindex=");
	print_ifindex(info->ipi_ifindex);
	tprintf(", ipi_spec_dst=inet_addr(\"%s\")",
		inet_ntoa(info->ipi_spec_dst));
	tprintf(", ipi_addr=inet_addr(\"%s\")}",
		inet_ntoa(info->ipi_addr));
}
Exemplo n.º 3
0
static void
decode_bytecode_data(struct tcb *const tcp,
		     const kernel_ulong_t addr,
		     const unsigned int len,
		     const unsigned char code)
{
	switch (code) {
	case INET_DIAG_BC_S_COND:
	case INET_DIAG_BC_D_COND:
		decode_inet_diag_hostcond(tcp, addr, len);
		break;
	case INET_DIAG_BC_DEV_COND: {
		uint32_t ifindex;

		if (len < sizeof(ifindex))
			printstr_ex(tcp, addr, len, QUOTE_FORCE_HEX);
		else if (!umove_or_printaddr(tcp, addr, &ifindex))
			print_ifindex(ifindex);
		break;
	}
	case INET_DIAG_BC_S_GE:
	case INET_DIAG_BC_S_LE:
	case INET_DIAG_BC_D_GE:
	case INET_DIAG_BC_D_LE: {
		struct inet_diag_bc_op op;

		if (len < sizeof(op))
			printstr_ex(tcp, addr, len, QUOTE_FORCE_HEX);
		else if (!umove_or_printaddr(tcp, addr, &op))
			print_inet_diag_bc_op(&op);
		break;
	}
	case INET_DIAG_BC_MARK_COND:
		decode_inet_diag_markcond(tcp, addr, len);
		break;
	case INET_DIAG_BC_AUTO:
	case INET_DIAG_BC_JMP:
	case INET_DIAG_BC_NOP:
	default:
		printstr_ex(tcp, addr, len, QUOTE_FORCE_HEX);
		break;
	}
}
Exemplo n.º 4
0
static void
print_sockaddr(struct tcb *tcp, const sockaddr_buf_t *addr, const int addrlen)
{
	tprints("{sa_family=");
	printxval(addrfams, addr->sa.sa_family, "AF_???");
	tprints(", ");

	switch (addr->sa.sa_family) {
	case AF_UNIX:
		if (addrlen == 2) {
			tprints("NULL");
		} else if (addr->sau.sun_path[0]) {
			tprints("sun_path=");
			print_quoted_string(addr->sau.sun_path,
					    sizeof(addr->sau.sun_path) + 1,
					    QUOTE_0_TERMINATED);
		} else {
			tprints("sun_path=@");
			print_quoted_string(addr->sau.sun_path + 1,
					    sizeof(addr->sau.sun_path),
					    QUOTE_0_TERMINATED);
		}
		break;
	case AF_INET:
		tprintf("sin_port=htons(%u), sin_addr=inet_addr(\"%s\")",
			ntohs(addr->sin.sin_port), inet_ntoa(addr->sin.sin_addr));
		break;
#ifdef HAVE_INET_NTOP
	case AF_INET6:
		{
			char string_addr[100];
			inet_ntop(AF_INET6, &addr->sa6.sin6_addr,
				  string_addr, sizeof(string_addr));
			tprintf("sin6_port=htons(%u), inet_pton(AF_INET6"
				", \"%s\", &sin6_addr), sin6_flowinfo=%u",
				ntohs(addr->sa6.sin6_port), string_addr,
				addr->sa6.sin6_flowinfo);
# ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID
			tprints(", sin6_scope_id=");
#  if defined IN6_IS_ADDR_LINKLOCAL && defined IN6_IS_ADDR_MC_LINKLOCAL
			if (IN6_IS_ADDR_LINKLOCAL(&addr->sa6.sin6_addr)
			    || IN6_IS_ADDR_MC_LINKLOCAL(&addr->sa6.sin6_addr))
				print_ifindex(addr->sa6.sin6_scope_id);
			else
#  endif
				tprintf("%u", addr->sa6.sin6_scope_id);
# endif /* HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID */
		}
		break;
#endif
#if defined(AF_IPX)
	case AF_IPX:
		{
			int i;
			tprintf("sipx_port=htons(%u), ",
					ntohs(addr->sipx.sipx_port));
			/* Yes, I know, this does not look too
			 * strace-ish, but otherwise the IPX
			 * addresses just look monstrous...
			 * Anyways, feel free if you don't like
			 * this way.. :)
			 */
			tprintf("%08lx:", (unsigned long)ntohl(addr->sipx.sipx_network));
			for (i = 0; i < IPX_NODE_LEN; i++)
				tprintf("%02x", addr->sipx.sipx_node[i]);
			tprintf("/[%02x]", addr->sipx.sipx_type);
		}
		break;
#endif /* AF_IPX */
#ifdef AF_PACKET
	case AF_PACKET:
		{
			int i;
			tprintf("proto=%#04x, if%d, pkttype=",
					ntohs(addr->ll.sll_protocol),
					addr->ll.sll_ifindex);
			printxval(af_packet_types, addr->ll.sll_pkttype, "PACKET_???");
			tprintf(", addr(%d)={%d, ",
					addr->ll.sll_halen,
					addr->ll.sll_hatype);
			for (i = 0; i < addr->ll.sll_halen; i++)
				tprintf("%02x", addr->ll.sll_addr[i]);
		}
		break;

#endif /* AF_PACKET */
#ifdef AF_NETLINK
	case AF_NETLINK:
		tprintf("pid=%d, groups=%08x", addr->nl.nl_pid, addr->nl.nl_groups);
		break;
#endif /* AF_NETLINK */
#if defined(AF_BLUETOOTH) && defined(HAVE_BLUETOOTH_BLUETOOTH_H)
	case AF_BLUETOOTH:
		tprintf("{sco_bdaddr=%02X:%02X:%02X:%02X:%02X:%02X} or "
			"{rc_bdaddr=%02X:%02X:%02X:%02X:%02X:%02X, rc_channel=%d} or "
			"{l2_psm=htobs(%d), l2_bdaddr=%02X:%02X:%02X:%02X:%02X:%02X, l2_cid=htobs(%d)} or "
			"{hci_dev=htobs(%d)}",
			addr->sco.sco_bdaddr.b[0], addr->sco.sco_bdaddr.b[1],
			addr->sco.sco_bdaddr.b[2], addr->sco.sco_bdaddr.b[3],
			addr->sco.sco_bdaddr.b[4], addr->sco.sco_bdaddr.b[5],
			addr->rc.rc_bdaddr.b[0], addr->rc.rc_bdaddr.b[1],
			addr->rc.rc_bdaddr.b[2], addr->rc.rc_bdaddr.b[3],
			addr->rc.rc_bdaddr.b[4], addr->rc.rc_bdaddr.b[5],
			addr->rc.rc_channel,
			btohs(addr->l2.l2_psm), addr->l2.l2_bdaddr.b[0],
			addr->l2.l2_bdaddr.b[1], addr->l2.l2_bdaddr.b[2],
			addr->l2.l2_bdaddr.b[3], addr->l2.l2_bdaddr.b[4],
			addr->l2.l2_bdaddr.b[5], btohs(addr->l2.l2_cid),
			btohs(addr->hci.hci_dev));
		break;
#endif /* AF_BLUETOOTH && HAVE_BLUETOOTH_BLUETOOTH_H */
	/* AF_AX25 AF_APPLETALK AF_NETROM AF_BRIDGE AF_AAL5
	AF_X25 AF_ROSE etc. still need to be done */

	default:
		tprints("sa_data=");
		print_quoted_string(addr->sa.sa_data,
				    sizeof(addr->sa.sa_data), 0);
		break;
	}
	tprints("}");
}