Don't wait for physical connection on WiFi interfaces
This commit is contained in:
parent
440362fa71
commit
b70de725ca
3 changed files with 21 additions and 0 deletions
15
ethsock.c
15
ethsock.c
|
@ -546,6 +546,21 @@ inline uint8_t *ethsock_get_hwaddr(struct ethsock *sock)
|
|||
return sock->hwaddr;
|
||||
}
|
||||
|
||||
bool ethsock_is_wifi(struct ethsock *sock)
|
||||
{
|
||||
#if defined(NMRPFLASH_WINDOWS)
|
||||
MIB_IF_ROW2 row;
|
||||
|
||||
if (intf_get_if_row(sock->index, &row)) {
|
||||
return row.Type == IF_TYPE_IEEE80211;
|
||||
}
|
||||
|
||||
return false;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool ethsock_is_unplugged(struct ethsock *sock)
|
||||
{
|
||||
#if defined(NMRPFLASH_LINUX)
|
||||
|
|
5
nmrp.c
5
nmrp.c
|
@ -448,6 +448,11 @@ int nmrp_do(struct nmrpd_args *args)
|
|||
sigh_orig = signal(SIGINT, sigh);
|
||||
|
||||
if (ethsock_is_unplugged(sock)) {
|
||||
if (ethsock_is_wifi(sock)) {
|
||||
fprintf(stderr, "Error: WiFi not connected.\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
printf("Waiting for Ethernet connection.\n");
|
||||
|
||||
bool unplugged = true;
|
||||
|
|
1
nmrpd.h
1
nmrpd.h
|
@ -126,6 +126,7 @@ struct ethsock_ip_undo;
|
|||
|
||||
struct ethsock *ethsock_create(const char *intf, uint16_t protocol);
|
||||
bool ethsock_is_unplugged(struct ethsock *sock);
|
||||
bool ethsock_is_wifi(struct ethsock *sock);
|
||||
int ethsock_close(struct ethsock *sock);
|
||||
int ethsock_send(struct ethsock *sock, void *buf, size_t len);
|
||||
ssize_t ethsock_recv(struct ethsock *sock, void *buf, size_t len);
|
||||
|
|
Loading…
Add table
Reference in a new issue