/* setsockopt with optname unknown */
packet_mreq_membership(-1, NULL, 0);
+#if XLAT_RAW
+ printf("setsockopt(-1, %#x, %#x, NULL, 0) = %s\n",
+ SOL_PACKET, -1, errstr);
+#elif XLAT_VERBOSE
+ printf("setsockopt(-1, %#x /* SOL_PACKET */, %#x /* PACKET_??? */"
+ ", NULL, 0) = %s\n", SOL_PACKET, -1, errstr);
+#else
printf("setsockopt(-1, SOL_PACKET, %#x /* PACKET_??? */, NULL, 0) = %s\n",
-1, errstr);
+#endif
/* setsockopt with mr_type unknown */
pmreq->mr_ifindex = 0;
pmreq->mr_alen = ARRAY_SIZE(pmreq->mr_address);
packet_mreq_membership(optname, pmreq, len);
+#if XLAT_RAW
+ printf("setsockopt(-1, %#x, %#x, {mr_ifindex=%d,"
+ " mr_type=%#x, mr_alen=%d, mr_address=",
+ SOL_PACKET, optname, pmreq->mr_ifindex,
+ pmreq->mr_type, pmreq->mr_alen);
+ print_quoted_hex((const void *) pmreq->mr_address,
+ ARRAY_SIZE(pmreq->mr_address));
+ printf("}, %d) = %s\n", len, errstr);
+#elif XLAT_VERBOSE
+ printf("setsockopt(-1, %#x /* SOL_PACKET */, %#x /* %s */"
+ ", {mr_ifindex=%d, mr_type=%#x /* PACKET_MR_??? */"
+ ", mr_alen=%d, mr_address=",
+ SOL_PACKET, optname, optname_str, pmreq->mr_ifindex,
+ pmreq->mr_type, pmreq->mr_alen);
+ print_quoted_hex((const void *) pmreq->mr_address,
+ ARRAY_SIZE(pmreq->mr_address));
+ printf(" /* ");
+ for (unsigned int i = 0; i < ARRAY_SIZE(pmreq->mr_address); i++)
+ printf("%s%02x", i > 0 ? ":" : "", pmreq->mr_address[i]);
+ printf(" */}, %d) = %s\n", len, errstr);
+#else
printf("setsockopt(-1, SOL_PACKET, %s, {mr_ifindex=%d,"
" mr_type=%#x /* PACKET_MR_??? */, mr_alen=%d, mr_address=",
optname_str, pmreq->mr_ifindex, pmreq->mr_type, pmreq->mr_alen);
for (unsigned int i = 0; i < ARRAY_SIZE(pmreq->mr_address); i++)
printf("%s%02x", i > 0 ? ":" : "", pmreq->mr_address[i]);
printf("}, %d) = %s\n", len, errstr);
+#endif
/* setsockopt with mr_type unknown and mr_alen > sizeof(mr_address) */
pmreq->mr_alen = ARRAY_SIZE(pmreq->mr_address) + 1;
packet_mreq_membership(optname, pmreq, len);
+#if XLAT_RAW
+ printf("setsockopt(-1, %#x, %#x, {mr_ifindex=%d,"
+ " mr_type=%#x, mr_alen=%d, mr_address=",
+ SOL_PACKET, optname, pmreq->mr_ifindex,
+ pmreq->mr_type, pmreq->mr_alen);
+ print_quoted_hex((const void *) pmreq->mr_address,
+ ARRAY_SIZE(pmreq->mr_address));
+ printf("}, %d) = %s\n", len, errstr);
+#elif XLAT_VERBOSE
+ printf("setsockopt(-1, %#x /* SOL_PACKET */, %#x /* %s */"
+ ", {mr_ifindex=%d, mr_type=%#x /* PACKET_MR_??? */"
+ ", mr_alen=%d, mr_address=",
+ SOL_PACKET, optname, optname_str, pmreq->mr_ifindex,
+ pmreq->mr_type, pmreq->mr_alen);
+ print_quoted_hex((const void *) pmreq->mr_address,
+ ARRAY_SIZE(pmreq->mr_address));
+ printf(" /* ");
+ for (unsigned int i = 0; i < ARRAY_SIZE(pmreq->mr_address); i++)
+ printf("%s%02x", i > 0 ? ":" : "", pmreq->mr_address[i]);
+ printf(" */}, %d) = %s\n", len, errstr);
+#else
printf("setsockopt(-1, SOL_PACKET, %s, {mr_ifindex=%d,"
" mr_type=%#x /* PACKET_MR_??? */, mr_alen=%d, mr_address=",
optname_str, pmreq->mr_ifindex, pmreq->mr_type, pmreq->mr_alen);
for (unsigned int i = 0; i < ARRAY_SIZE(pmreq->mr_address); i++)
printf("%s%02x", i > 0 ? ":" : "", pmreq->mr_address[i]);
printf("}, %d) = %s\n", len, errstr);
+#endif
/* setsockopt with mr_type unknown and mr_alen < sizeof(mr_address) */
pmreq->mr_alen = ARRAY_SIZE(pmreq->mr_address) - 1;
packet_mreq_membership(optname, pmreq, len);
+#if XLAT_RAW
+ printf("setsockopt(-1, %#x, %#x, {mr_ifindex=%d,"
+ " mr_type=%#x, mr_alen=%d, mr_address=",
+ SOL_PACKET, optname, pmreq->mr_ifindex,
+ pmreq->mr_type, pmreq->mr_alen);
+ print_quoted_hex((const void *) pmreq->mr_address, pmreq->mr_alen);
+ printf("}, %d) = %s\n", len, errstr);
+#elif XLAT_VERBOSE
+ printf("setsockopt(-1, %#x /* SOL_PACKET */, %#x /* %s */"
+ ", {mr_ifindex=%d, mr_type=%#x /* PACKET_MR_??? */"
+ ", mr_alen=%d, mr_address=",
+ SOL_PACKET, optname, optname_str, pmreq->mr_ifindex,
+ pmreq->mr_type, pmreq->mr_alen);
+ print_quoted_hex((const void *) pmreq->mr_address, pmreq->mr_alen);
+ printf(" /* ");
+ for (unsigned int i = 0; i < pmreq->mr_alen; i++)
+ printf("%s%02x", i > 0 ? ":" : "", pmreq->mr_address[i]);
+ printf(" */}, %d) = %s\n", len, errstr);
+#else
printf("setsockopt(-1, SOL_PACKET, %s, {mr_ifindex=%d,"
" mr_type=%#x /* PACKET_MR_??? */, mr_alen=%d, mr_address=",
optname_str, pmreq->mr_ifindex, pmreq->mr_type, pmreq->mr_alen);
for (unsigned int i = 0; i < pmreq->mr_alen; i++)
printf("%s%02x", i > 0 ? ":" : "", pmreq->mr_address[i]);
printf("}, %d) = %s\n", len, errstr);
+#endif
/* setsockopt with valid mr_type */
pmreq->mr_alen = ARRAY_SIZE(pmreq->mr_address);
for (unsigned int i = 0; i < ARRAY_SIZE(a); i++) {
pmreq->mr_type = a[i].type;
packet_mreq_membership(optname, pmreq, len);
+#if XLAT_RAW
+ printf("setsockopt(-1, %#x, %#x, {mr_ifindex=%d,"
+ " mr_type=%#x, mr_alen=%d, mr_address=",
+ SOL_PACKET, optname, pmreq->mr_ifindex,
+ pmreq->mr_type, pmreq->mr_alen);
+ print_quoted_hex((const void *) pmreq->mr_address, pmreq->mr_alen);
+ printf("}, %d) = %s\n", len, errstr);
+#elif XLAT_VERBOSE
+ printf("setsockopt(-1, %#x /* SOL_PACKET */, %#x /* %s */"
+ ", {mr_ifindex=%d, mr_type=%#x /* %s */"
+ ", mr_alen=%d, mr_address=",
+ SOL_PACKET, optname, optname_str, pmreq->mr_ifindex,
+ pmreq->mr_type, a[i].type_str, pmreq->mr_alen);
+ print_quoted_hex((const void *) pmreq->mr_address, pmreq->mr_alen);
+ printf(" /* ");
+ for (unsigned int i = 0; i < pmreq->mr_alen; i++)
+ printf("%s%02x", i > 0 ? ":" : "", pmreq->mr_address[i]);
+ printf(" */}, %d) = %s\n", len, errstr);
+#else
printf("setsockopt(-1, SOL_PACKET, %s, {mr_ifindex=%d,"
" mr_type=%s, mr_alen=%d, mr_address=",
optname_str, pmreq->mr_ifindex, a[i].type_str, pmreq->mr_alen);
for (unsigned int i = 0; i < pmreq->mr_alen; i++)
printf("%s%02x", i > 0 ? ":" : "", pmreq->mr_address[i]);
printf("}, %d) = %s\n", len, errstr);
+#endif
}
/* setsockopt with optlen larger than usual */
len = len + 1;
packet_mreq_membership(optname, pmreq, len);
+#if XLAT_RAW
+ printf("setsockopt(-1, %#x, %#x, %p, %d) = %s\n",
+ SOL_PACKET, optname, pmreq, len, errstr);
+#elif XLAT_VERBOSE
+ printf("setsockopt(-1, %#x /* SOL_PACKET */, %#x /* %s */"
+ ", %p, %d) = %s\n", SOL_PACKET, optname, optname_str,
+ pmreq, len, errstr);
+#else
printf("setsockopt(-1, SOL_PACKET, %s, %p,"
" %d) = %s\n", optname_str, pmreq, len, errstr);
+#endif
}
int
#include <linux/if_arp.h>
#include <linux/if_ether.h>
#include <linux/if_packet.h>
+#ifdef HAVE_BLUETOOTH_BLUETOOTH_H
+# include <bluetooth/bluetooth.h>
+# include <bluetooth/hci.h>
+# include <bluetooth/l2cap.h>
+# include <bluetooth/rfcomm.h>
+# include <bluetooth/sco.h>
+#endif
static void
check_ll(void)
validate_in6(&in6, "::1");
}
+#ifdef HAVE_BLUETOOTH_BLUETOOTH_H
+static void
+check_sco(void)
+{
+ const struct sockaddr_sco c_sco = {
+ .sco_family = AF_BLUETOOTH,
+ .sco_bdaddr.b = "abcdef"
+ };
+ void *sco = tail_memdup(&c_sco, sizeof(c_sco));
+ unsigned int len = sizeof(c_sco);
+ int ret = connect(-1, sco, len);
+ const char *errstr = sprintrc(ret);
+# if XLAT_RAW
+ printf("connect(-1, {sa_family=%#x, sco_bdaddr=", AF_BLUETOOTH);
+ print_quoted_hex((const void *) &c_sco.sco_bdaddr,
+ sizeof(c_sco.sco_bdaddr));
+ printf("}, %u) = %s\n", len, errstr);
+# elif XLAT_VERBOSE
+ printf("connect(-1, {sa_family=%#x /* AF_BLUETOOTH */"
+ ", sco_bdaddr=", AF_BLUETOOTH);
+ print_quoted_hex((const void *) &c_sco.sco_bdaddr,
+ sizeof(c_sco.sco_bdaddr));
+ printf(" /* %02x:%02x:%02x:%02x:%02x:%02x */"
+ "}, %u) = %s\n",
+ c_sco.sco_bdaddr.b[0], c_sco.sco_bdaddr.b[1],
+ c_sco.sco_bdaddr.b[2], c_sco.sco_bdaddr.b[3],
+ c_sco.sco_bdaddr.b[4], c_sco.sco_bdaddr.b[5],
+ len, errstr);
+# else
+ printf("connect(-1, {sa_family=AF_BLUETOOTH"
+ ", sco_bdaddr=%02x:%02x:%02x:%02x:%02x:%02x"
+ "}, %u) = %s\n",
+ c_sco.sco_bdaddr.b[0], c_sco.sco_bdaddr.b[1],
+ c_sco.sco_bdaddr.b[2], c_sco.sco_bdaddr.b[3],
+ c_sco.sco_bdaddr.b[4], c_sco.sco_bdaddr.b[5],
+ len, errstr);
+# endif
+}
+
+static void
+check_rc(void)
+{
+ const struct sockaddr_rc c_rc = {
+ .rc_family = AF_BLUETOOTH,
+ .rc_bdaddr.b = "abcdef",
+ .rc_channel = 42
+ };
+ void *rc = tail_memdup(&c_rc, sizeof(c_rc));
+ unsigned int len = sizeof(c_rc);
+ int ret = connect(-1, rc, len);
+ const char *errstr = sprintrc(ret);
+# if XLAT_RAW
+ printf("connect(-1, {sa_family=%#x, rc_bdaddr=", AF_BLUETOOTH);
+ print_quoted_hex((const void *) &c_rc.rc_bdaddr,
+ sizeof(c_rc.rc_bdaddr));
+ printf(", rc_channel=%u}, %u) = %s\n", c_rc.rc_channel, len, errstr);
+# elif XLAT_VERBOSE
+ printf("connect(-1, {sa_family=%#x /* AF_BLUETOOTH */"
+ ", rc_bdaddr=", AF_BLUETOOTH);
+ print_quoted_hex((const void *) &c_rc.rc_bdaddr,
+ sizeof(c_rc.rc_bdaddr));
+ printf(" /* %02x:%02x:%02x:%02x:%02x:%02x */"
+ ", rc_channel=%u}, %u) = %s\n",
+ c_rc.rc_bdaddr.b[0], c_rc.rc_bdaddr.b[1],
+ c_rc.rc_bdaddr.b[2], c_rc.rc_bdaddr.b[3],
+ c_rc.rc_bdaddr.b[4], c_rc.rc_bdaddr.b[5],
+ c_rc.rc_channel, len, errstr);
+# else
+ printf("connect(-1, {sa_family=AF_BLUETOOTH"
+ ", rc_bdaddr=%02x:%02x:%02x:%02x:%02x:%02x"
+ ", rc_channel=%u}, %u) = %s\n",
+ c_rc.rc_bdaddr.b[0], c_rc.rc_bdaddr.b[1],
+ c_rc.rc_bdaddr.b[2], c_rc.rc_bdaddr.b[3],
+ c_rc.rc_bdaddr.b[4], c_rc.rc_bdaddr.b[5],
+ c_rc.rc_channel, len, errstr);
+# endif
+}
+#endif /* HAVE_BLUETOOTH_BLUETOOTH_H */
+
int
main(void)
{
check_ll();
check_in();
check_in6();
+#ifdef HAVE_BLUETOOTH_BLUETOOTH_H
+ check_sco();
+ check_rc();
+#endif
puts("+++ exited with 0 +++");
return 0;
}