diff --git a/ethsock.c b/ethsock.c index bb05599..cee3815 100644 --- a/ethsock.c +++ b/ethsock.c @@ -553,6 +553,20 @@ bool ethsock_is_unplugged(struct ethsock *sock) } return false; +#elif defined(NMRPFLASH_BSD) + struct ifmediareq ifmr; + + memset(&ifmr, 0, sizeof(ifmr)); + strncpy(ifmr.ifr_name, name, sizeof(ifmr.ifr_name)); + + if (ioctl(fd, SIOCGIFMEDIA, &ifmr) < 0) { + if (verbosity > 1) { + perror("ioctl(SIOCGIFMEDIA)"); + } + return false; + } + + return (ifmr.ifm_status & IFM_AVALID) && !(ifmr.ifm_status & IFM_ACTIVE); #else return false; #endif diff --git a/nmrp.c b/nmrp.c index 5f9e670..bdd827c 100644 --- a/nmrp.c +++ b/nmrp.c @@ -447,7 +447,7 @@ int nmrp_do(struct nmrpd_args *args) sigh_orig = signal(SIGINT, sigh); if (ethsock_is_unplugged(sock)) { - printf("Waiting for Ethernet cable to be plugged in.\n"); + printf("Waiting for phyiscal connection.\n"); bool unplugged = true; time_t beg = time_monotonic(); @@ -460,7 +460,9 @@ int nmrp_do(struct nmrpd_args *args) } if (unplugged) { - fprintf(stderr, "Error: Ethernet cable is unplugged."); + if (!g_interrupted) { + fprintf(stderr, "Error: Ethernet cable is unplugged."); + } goto out; } } diff --git a/nmrpd.h b/nmrpd.h index ad678e8..f53fd22 100644 --- a/nmrpd.h +++ b/nmrpd.h @@ -34,7 +34,7 @@ # if defined(__linux__) # define NMRPFLASH_LINUX # elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) -# define NMRPFLASH_BSD +# define NMRPFLASH_BSD # else # warning "nmrpflash is not fully supported on this platform" # endif