I noticed that Asus' networkmap.c has some code that is cut and pasted from libpcap (even the comments), yet Asus does not supply the sources. I know the BSD license doesn't require distributing the sources, but my understanding was that when you mixed GPL and BSD licenses it required the GPL to apply to the whole. Since a lot of the Asuswrt firmware package is GPL, doesn't that any BSD licensed code also has to be GPL? Is it because networkmap is a standalone executable that GPL doesn't apply to it?
Example from libpcap pcap-linux.c:
And Asus' networkmap.c:
Example from libpcap pcap-linux.c:
Code:
iface_get_id(int fd, const char *device, char *ebuf)
{
struct ifreq ifr;
memset(&ifr, 0, sizeof(ifr));
pcap_strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
if (ioctl(fd, SIOCGIFINDEX, &ifr) == -1) {
pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE,
errno, "SIOCGIFINDEX");
return -1;
}
return ifr.ifr_ifindex;
}
/*
* Bind the socket associated with FD to the given device.
* Return 0 on success or a PCAP_ERROR_ value on a hard error.
*/
static int
iface_bind(int fd, int ifindex, char *ebuf, int protocol)
{
struct sockaddr_ll sll;
int ret, err;
socklen_t errlen = sizeof(err);
memset(&sll, 0, sizeof(sll));
sll.sll_family = AF_PACKET;
sll.sll_ifindex = ifindex < 0 ? 0 : ifindex;
sll.sll_protocol = protocol;
if (bind(fd, (struct sockaddr *) &sll, sizeof(sll)) == -1) {
if (errno == ENETDOWN) {
/*
* Return a "network down" indication, so that
* the application can report that rather than
* saying we had a mysterious failure and
* suggest that they report a problem to the
* libpcap developers.
*/
return PCAP_ERROR_IFACE_NOT_UP;
}
if (errno == ENODEV)
ret = PCAP_ERROR_NO_SUCH_DEVICE;
else
ret = PCAP_ERROR;
pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE,
errno, "bind");
return ret;
}
/* Any pending errors, e.g., network is down? */
if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &err, &errlen) == -1) {
pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE,
errno, "getsockopt (SO_ERROR)");
return PCAP_ERROR;
}
if (err == ENETDOWN) {
/*
* Return a "network down" indication, so that
* the application can report that rather than
* saying we had a mysterious failure and
* suggest that they report a problem to the
* libpcap developers.
*/
return PCAP_ERROR_IFACE_NOT_UP;
} else if (err > 0) {
pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE,
err, "bind");
return PCAP_ERROR;
}
return 0;
}
static int
And Asus' networkmap.c:
Code:
iface_get_id(int fd, const char *device)
{
struct ifreq ifr;
memset(&ifr, 0, sizeof(ifr));
strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
if (ioctl(fd, SIOCGIFINDEX, &ifr) == -1) {
perror("iface_get_id ERR:\n");
return -1;
}
return ifr.ifr_ifindex;
}
/*
* Bind the socket associated with FD to the given device.
*/
static int
iface_bind(int fd, int ifindex)
{
int err;
socklen_t errlen = sizeof(err);
memset(&src_sockll, 0, sizeof(src_sockll));
src_sockll.sll_family = AF_PACKET;
src_sockll.sll_ifindex = ifindex;
src_sockll.sll_protocol = htons(ETH_P_ARP);
if (bind(fd, (struct sockaddr *) &src_sockll, sizeof(src_sockll)) == -1) {
perror("bind device ERR:\n");
return -1;
}
/* Any pending errors, e.g., network is down? */
if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &err, &errlen) == -1) {
return -2;
}
if (err > 0) {
return -2;
}
int alen = sizeof(src_sockll);
if (getsockname(fd, (struct sockaddr*)&src_sockll, (socklen_t *)&alen) == -1) {
perror("getsockname");
exit(2);
}
if (src_sockll.sll_halen == 0) {
printf("Interface is not ARPable (no ll address)\n");
exit(2);
}
dst_sockll = src_sockll;
return 0;
}
static int