Add BSD bridge interface detection
This commit is contained in:
parent
00a5ca6022
commit
40dd2b1a6c
1 changed files with 39 additions and 0 deletions
39
ethsock.c
39
ethsock.c
|
|
@ -44,6 +44,13 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef NMRPFLASH_BSD
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <netinet/if_ether.h>
|
||||||
|
#include <net/if_bridgevar.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
struct ethsock
|
struct ethsock
|
||||||
{
|
{
|
||||||
const char *intf;
|
const char *intf;
|
||||||
|
|
@ -155,6 +162,33 @@ static bool set_stp_enabled(const char *intf, bool enabled)
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
static bool is_bridge(const char *intf)
|
||||||
|
{
|
||||||
|
#ifdef NMRPFLASH_BSD
|
||||||
|
struct ifdrv ifd;
|
||||||
|
struct ifbropreq ifbop;
|
||||||
|
int err, fd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
|
if (fd < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
strncpy(ifd.ifd_name, intf, sizeof(ifd.ifd_name));
|
||||||
|
ifd.ifd_cmd = BRDGPARAM;
|
||||||
|
ifd.ifd_data = &ifbop;
|
||||||
|
ifd.ifd_len = sizeof(ifbop);
|
||||||
|
|
||||||
|
err = ioctl(fd, SIOCGDRVSPEC, &ifd);
|
||||||
|
if (err && verbosity) {
|
||||||
|
xperror("ioctl(SIOCGDRVSPEC)");
|
||||||
|
}
|
||||||
|
|
||||||
|
close(fd);
|
||||||
|
return !err;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static bool get_intf_info(const char *intf, uint8_t *hwaddr, void *dummy)
|
static bool get_intf_info(const char *intf, uint8_t *hwaddr, void *dummy)
|
||||||
|
|
@ -425,6 +459,11 @@ struct ethsock *ethsock_create(const char *intf, uint16_t protocol)
|
||||||
fprintf(stderr, "Warning: failed to disable STP on %s.\n", intf);
|
fprintf(stderr, "Warning: failed to disable STP on %s.\n", intf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
if (is_bridge(intf)) {
|
||||||
|
fprintf(stderr, "Warning: bridge interfaces are not fully "
|
||||||
|
"supported on this platform.\n");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return sock;
|
return sock;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue