Skip to content

Commit

Permalink
Parameterize the interface name in reactivatetest. [skip appveyor]
Browse files Browse the repository at this point in the history
> uname -sr
Haiku 1
> ./testprogs/reactivatetest
reactivatetest: Neither lo0 nor lo could be opened: lo: No such device
  exists (SIOCGIFSTATS: Invalid Argument)

The loopback interface is "lo" in Linux and "lo0" in BSD systems, but in
Haiku it is "loop", so instead of hard-coding or guessing let's just
make it a mandatory command-line argument.  Also the user may want to
run the test on a non-loopback interface.
  • Loading branch information
infrastation committed Aug 6, 2024
1 parent a0d02f0 commit 07ca0b8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ DayOfTheWeek, Month DD, YYYY / The Tcpdump Group
Make Sun C build warning-free.
Make FreeBSD, Linux and macOS builds warning-free.
Print MAC addresses in findalldevstest.
Parameterize the interface name in reactivatetest.
When necessary, trust the OS to implement ffs().
Fix HCI_CHANNEL_MONITOR detection with musl libc.
At build time require a proof of suitable snprintf(3) implementation in
Expand Down
16 changes: 9 additions & 7 deletions testprogs/reactivatetest.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,22 @@ The Regents of the University of California. All rights reserved.\n";
static void PCAP_NORETURN error(PCAP_FORMAT_STRING(const char *), ...) PCAP_PRINTFLIKE(1,2);

int
main(void)
main(int argc, char **argv)
{
char ebuf[PCAP_ERRBUF_SIZE];
pcap_t *pd;
int status = 0;

pd = pcap_open_live("lo0", 65535, 0, 1000, ebuf);
if (argc != 2)
error("expecting exactly one command-line argument with the interface name");
char *ifname = argv[1];

pd = pcap_open_live(ifname, 65535, 0, 1000, ebuf);
if (pd == NULL) {
pd = pcap_open_live("lo", 65535, 0, 1000, ebuf);
if (pd == NULL) {
error("Neither lo0 nor lo could be opened: %s",
ebuf);
}
error("pcap_open_live() failed: %s",
ebuf);
}

status = pcap_activate(pd);
if (status != PCAP_ERROR_ACTIVATED) {
if (status == 0)
Expand Down

0 comments on commit 07ca0b8

Please sign in to comment.