httpd: devlist.c: also add hostname to devlist()

arm-sdk7
pedro 5 years ago
parent 1f3ee744da
commit c461dca358

@ -13,6 +13,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <string.h> #include <string.h>
#include <netdb.h>
#include <wlutils.h> #include <wlutils.h>
@ -39,7 +40,9 @@ void asp_arplist(int argc, char **argv)
char ip[16]; char ip[16];
char mac[18]; char mac[18];
char dev[17]; char dev[17];
char host[NI_MAXHOST];
char comma; char comma;
char *c;
unsigned int flags; unsigned int flags;
/* /*
@ -61,8 +64,14 @@ void asp_arplist(int argc, char **argv)
if (flags == 0) if (flags == 0)
continue; continue;
if ((resolve_addr(ip, host) != 0) || (strcmp(ip, host) == 0))
strcpy(host, "");
if ((c = strchr(host, '.')) != NULL)
*c = 0;
strupr(mac); strupr(mac);
web_printf("%c['%s','%s','%s']", comma, ip, mac, dev); web_printf("%c['%s','%s','%s','%s']", comma, ip, mac, dev, host);
comma = ','; comma = ',';
} }
fclose(f); fclose(f);
@ -82,9 +91,7 @@ static int get_wds_ifname(const struct ether_addr *ea, char *ifname)
/* wds doesn't show up under SIOCGIFCONF; seems to start at 17 (?) */ /* wds doesn't show up under SIOCGIFCONF; seems to start at 17 (?) */
for (i = 1; i < 32; ++i) { for (i = 1; i < 32; ++i) {
ifr.ifr_ifindex = i; ifr.ifr_ifindex = i;
if ((ioctl(sd, SIOCGIFNAME, &ifr) == 0) && if ((ioctl(sd, SIOCGIFNAME, &ifr) == 0) && (strncmp(ifr.ifr_name, "wds", 3) == 0) && (wl_ioctl(ifr.ifr_name, WLC_WDS_GET_REMOTE_HWADDR, &e.octet, sizeof(e.octet)) == 0)) {
(strncmp(ifr.ifr_name, "wds", 3) == 0) &&
(wl_ioctl(ifr.ifr_name, WLC_WDS_GET_REMOTE_HWADDR, &e.octet, sizeof(e.octet)) == 0)) {
if (memcmp(ea->octet, e.octet, sizeof(e.octet)) == 0) { if (memcmp(ea->octet, e.octet, sizeof(e.octet)) == 0) {
close(sd); close(sd);
strlcpy(ifname, ifr.ifr_name, 16); strlcpy(ifname, ifr.ifr_name, 16);

@ -230,8 +230,8 @@ REMOVE-END */
s = f[5].value.trim().replace(/\s+/g, ' '); s = f[5].value.trim().replace(/\s+/g, ' ');
if (s.length > 0) { if (s.length > 0) {
if (s.search(/^[.a-zA-Z0-9_\- ]+$/) == -1) { if (s.search(/^[a-zA-Z0-9_\- ]+$/) == -1) {
ferror.set(f[5], 'Invalid hostname. Only characters "A-Z 0-9 . - _" are allowed', quiet); ferror.set(f[5], 'Invalid hostname. Only characters "A-Z 0-9 - _" are allowed', quiet);
return 0; return 0;
} }
if (this.existName(s)) { if (this.existName(s)) {

@ -307,7 +307,7 @@ dg.populate = function() {
e.name = a[0]; e.name = a[0];
} }
/* [ "IP", "MAC", "wwan0/br0/1" ] */ /* [ "IP", "MAC", "br0/wwan0", "name" ] */
for (i = arplist.length - 1; i >= 0; --i) { for (i = arplist.length - 1; i >= 0; --i) {
a = arplist[i]; a = arplist[i];
if ((e = get(a[1], a[0])) != null) { if ((e = get(a[1], a[0])) != null) {
@ -315,6 +315,8 @@ dg.populate = function() {
e.ifname = a[2]; e.ifname = a[2];
e.bridge = a[2]; e.bridge = a[2];
if (e.name == '')
e.name = a[3];
} }
} }

Loading…
Cancel
Save