IPv6: extend GUI status page (status-overview.asp) - show DUID

arm-sdk7
M_ars 3 years ago committed by pedro
parent b7837d3b3f
commit e05fbfc296

@ -86,6 +86,10 @@
#include <common.h>
#include <timer.h>
#ifdef TOMATO
#include <ipv6_shared.h>
#endif
#ifdef __linux__
/* from /usr/include/linux/ipv6.h */
@ -995,6 +999,10 @@ get_duid(idfile, duid)
struct duid *duid;
{
FILE *fp = NULL;
#ifdef TOMATO
FILE *fp2 = NULL;
char duid_buf[TOMATO_DUID_MAX_LEN] = { 0 };
#endif
u_int16_t len = 0, hwtype;
int hwlen = 0;
char tmpbuf[256]; /* HWID should be no more than 256 bytes */
@ -1068,6 +1076,18 @@ get_duid(idfile, duid)
duidstr(duid));
}
#ifdef TOMATO
if ((fp2 = fopen(TOMATO_DUID_GUI, "w+")) == NULL) { /* if file already exists override it (empty it) */
dprintf(LOG_ERR, FNAME, "failed to open TOMATO_DUID_GUI file for save");
}
else {
snprintf(duid_buf, TOMATO_DUID_MAX_LEN-1, "%s", duidstr(duid));
duid_buf[TOMATO_DUID_MAX_LEN-1] = '\0';
fputs(duid_buf, fp2);
fclose(fp2);
}
#endif
/* save the (new) ID to the file for next time */
if (!fp) {
if ((fp = fopen(idfile, "w+")) == NULL) {

@ -303,7 +303,9 @@ static char* get_cfeversion(char *buf)
}
#ifdef TCONFIG_IPV6
static void print_ipv6_addrs(void) /* show IPv6 addresses: wan, dns, lan, lan-ll, lan1, lan1-ll, lan2, lan2-ll, lan3, lan3-ll */
#define NOT_AVAIL "--"
static void print_ipv6_infos(void) /* show IPv6 DUID and addresses: wan, dns, lan, lan-ll, lan1, lan1-ll, lan2, lan2-ll, lan3, lan3-ll */
{
char buffer[INET6_ADDRSTRLEN];
char buffer2[16];
@ -313,10 +315,22 @@ static void print_ipv6_addrs(void) /* show IPv6 addresses: wan, dns, lan, lan-ll
struct in6_addr addr;
int cnt = 0;
char br;
FILE *fp = NULL;
char line[TOMATO_DUID_MAX_LEN];
if (!ipv6_enabled())
return;
/* DUID */
if ((fp = fopen(TOMATO_DUID_GUI, "r")) != NULL) {
fgets(line, sizeof(line), fp);
web_printf("\tip6_duid: '%s',\n", line);
fclose(fp);
}
else {
web_printf("\tip6_duid: '%s',\n", NOT_AVAIL);
}
/* check LAN */
for (br = 0; br < BRIDGE_COUNT; br++) {
char bridge[2] = "0";
@ -603,7 +617,7 @@ void asp_sysinfo(int argc, char **argv)
web_puts("\nsysinfo = {\n");
#ifdef TCONFIG_IPV6
print_ipv6_addrs();
print_ipv6_infos();
#endif
sysinfo(&si);
get_memory(&mem);

@ -7,6 +7,9 @@
#ifndef _ipv6_shared_h_
#define _ipv6_shared_h_
#define TOMATO_DUID_MAX_LEN 64
#define TOMATO_DUID_GUI "/var/dhcp6c_duid_gui"
#define IPV6_MIN_LIFETIME 120
#define ONEMONTH_LIFETIME (30 * 24 * 60 * 60)
#define INFINITE_LIFETIME 0xffffffff

@ -141,6 +141,7 @@ for (var uidx = 1; uidx <= nvram.mwan_num; ++uidx) {
}
/* IPV6-BEGIN */
stats.ip6_duid = ((typeof(sysinfo.ip6_duid) != 'undefined') ? sysinfo.ip6_duid : '')+'';
stats.ip6_wan = ((typeof(sysinfo.ip6_wan) != 'undefined') ? sysinfo.ip6_wan : '')+'';
stats.ip6_wan_dns1 = ((typeof(sysinfo.ip6_wan_dns1) != 'undefined') ? sysinfo.ip6_wan_dns1 : '')+'';
stats.ip6_wan_dns2 = ((typeof(sysinfo.ip6_wan_dns2) != 'undefined') ? sysinfo.ip6_wan_dns2 : '')+'';

@ -295,6 +295,8 @@ function show() {
elem.display('swap', stats.swap != '');
c('nvram_stat', scaleSize(nvstat.size - nvstat.free)+' / '+scaleSize(nvstat.size)+' <small>('+((nvstat.size - nvstat.free) / nvstat.size * 100.0).toFixed(2)+'%)<\/small><div class="progress-wrapper"><div class="progress-container"><div class="progress-bar" style="background-color:'+setColor(((nvstat.size - nvstat.free) / nvstat.size * 100.0).toFixed(2))+';width:'+((nvstat.size - nvstat.free) / nvstat.size * 100.0).toFixed(2)+'%"><\/div><\/div><\/div>');
/* IPV6-BEGIN */
c('ip6_duid', stats.ip6_duid);
elem.display('ip6_duid', stats.ip6_duid != '');
c('ip6_wan', stats.ip6_wan);
elem.display('ip6_wan', stats.ip6_wan != '');
c('ip6_wan_dns1', stats.ip6_wan_dns1);
@ -532,6 +534,7 @@ function init() {
{ title: 'Subnet Mask', rid: 'wan'+u+'netmask', text: stats.wannetmask[uidx - 1] },
{ title: 'Gateway', rid: 'wan'+u+'gateway', text: stats.wangateway[uidx - 1] },
/* IPV6-BEGIN */
{ title: 'IPv6 DUID', rid: 'ip6_duid', text: stats.ip6_duid, hidden: (stats.ip6_duid == '') },
{ title: 'IPv6 Address', rid: 'ip6_wan', text: stats.ip6_wan, hidden: (stats.ip6_wan == '') },
{ title: 'IPv6 DNS1', rid: 'ip6_wan_dns1', text: stats.ip6_wan_dns1, hidden: (stats.ip6_wan_dns1 == '') },
{ title: 'IPv6 DNS2', rid: 'ip6_wan_dns2', text: stats.ip6_wan_dns2, hidden: (stats.ip6_wan_dns2 == '') },

Loading…
Cancel
Save