Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions tests/sys/netinet/broadcast.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,33 @@
ATF_TC_WITHOUT_HEAD(INADDR_BROADCAST);
ATF_TC_BODY(INADDR_BROADCAST, tc)
{
struct ifaddrs *ifa0, *ifa;
bool skip = true;

struct sockaddr_in sin = {
.sin_family = AF_INET,
.sin_len = sizeof(struct sockaddr_in),
};
socklen_t slen = sizeof(sin);
int l, s;

ATF_REQUIRE(getifaddrs(&ifa0) == 0);
for (ifa = ifa0; ifa != NULL; ifa = ifa->ifa_next) {
if (!(ifa->ifa_flags & IFF_UP))
continue;
if (ifa->ifa_addr == NULL || ifa->ifa_addr->sa_family != AF_INET)

Check warning on line 110 in tests/sys/netinet/broadcast.c

View workflow job for this annotation

GitHub Actions / Style Checker

line over 80 characters

Check warning on line 110 in tests/sys/netinet/broadcast.c

View workflow job for this annotation

GitHub Actions / Style Checker

line over 80 characters
continue;
if (!(ifa->ifa_flags & IFF_BROADCAST))
continue;
skip = false;
printf("Found broadcast on interface: %s\n", ifa->ifa_name);
break;
}
freeifaddrs(ifa0);

if (skip)
atf_tc_skip("No interface with IFF_BROADCAST found");

l = bcastsock();
ATF_REQUIRE(bind(l, (struct sockaddr *)&sin, sizeof(sin)) == 0);
ATF_REQUIRE(getsockname(l, (struct sockaddr *)&sin, &slen) == 0);
Expand Down
Loading