====== SDK Script webpage.are ====== /* DESC: This script will generate a page which can be viewed in the Web Manager * Copyright (C) 2012 NetModule AG, Switzerland */ ID = 1; /* show interface overview */ void show_interfaces () { interfaces = mkarray(); nr_interfaces = 0; status = nb_status("lan"); stlist = qsort(struct_fields(status)); for (j = 0; j < length(stlist); j++) { key = stlist[j]; pos = strstr(key, "_ADDRESS"); if (!is_void(pos)) { ifc = left(key, pos); interfaces[nr_interfaces++] = ifc; } } nb_page_respond(page, '

LAN Interfaces Overview

\n'); nb_page_respond(page, '\n'); interfaces = qsort(interfaces); for (i=0; i\n'); nb_page_respond(page, '', ifc); nb_page_respond(page, '\n', ID, ifc); nb_page_respond(page, '\n'); } nb_page_respond(page, '
%sview
\n'); nb_page_finish(page); } /* show interface status */ void show_interface (string ifc) { status = nb_status("lan"); stlist = struct_fields(status); nb_page_respond(page, '

Interface %s Status

\n', ifc); nb_page_respond(page, '\n'); pattern = strcat(ifc, "_"); plen = strlen(pattern); for (j = 0; j < length(stlist); j++) { key = stlist[j]; if (left(key, plen) == pattern) { nb_page_respond(page, '\n'); nb_page_respond(page, '', substr(key, plen)); nb_page_respond(page, '', struct_get(status, key)); nb_page_respond(page, '\n'); } } nb_page_respond(page, '
%s%s
\n'); nb_page_respond(page, '

back\n', ID); nb_page_finish(page); } /* register page */ page = nb_page_register(ID, "LAN Interfaces", "Network Overview"); if (is_void(page)) { printf("unable to register page\n"); exit(1); } printf("waiting for requests...\n"); while (1) { /* wait for page request */ request = nb_page_request(page); if (!is_void(request)) { /* evaluate GET params */ GET = struct_get(request, "GET"); ifc = ""; for (k = 0; k < length(GET); k++) { key = struct_get(GET[k], "key"); if (key == "ifc") { ifc = struct_get(GET[k], "value"); break; } } if (ifc != "") { /* show requested interface */ show_interface(ifc); } else { /* show interface overview */ show_interfaces(); } } sleep(1); } nb_page_unregister(page); exit(0);