Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: oldheating gps motorhome heating
Diff: base/net/web-net-script.inc
- Revision:
- 146:6bc151bd7063
- Parent:
- 145:d2bd78be00b2
- Child:
- 147:ea6f647725a1
--- a/base/net/web-net-script.inc Sun Dec 27 16:18:19 2020 +0000
+++ b/base/net/web-net-script.inc Mon Jan 04 16:09:03 2021 +0000
@@ -4,6 +4,8 @@
"let mac = '';\n"
"let tcp = '';\n"
"let dns = '';\n"
+"let a4s = null;\n"
+"let a6s = null;\n"
"\n"
"function parseTcpLine(line)\n"
"{\n"
@@ -41,11 +43,6 @@
" tcp += bytesSent.toString().padStart(6, ' ');\n"
" tcp += '\\r\\n';\n"
"}\n"
-"function parseTcpLines(text)\n"
-"{\n"
-" tcp = \"State Idle Protocol ARI Port-Loc Port-Rem Rcvd Sent\\n\";\n"
-" text.split('\\n').forEach(parseTcpLine);\n"
-"}\n"
"function parseDnsLine(line)\n"
"{\n"
" if (line.length == 0) return;\n"
@@ -55,42 +52,107 @@
" let minutes = parseInt(fields[1], 16) / 1000 / 60;\n"
" dns += Math.floor(minutes).toString().padStart(4, ' ');\n"
" dns += ' ';\n"
+" let addr = '';\n"
+" let mac = '';\n"
" if (fields[2].substr( 0, 2) === '00') //Is empty or IP4\n"
" {\n"
" if (fields[2].substr(24, 2) === '00') //Is empty\n"
" {\n"
-" dns += ' '.padEnd(40, ' ');\n"
+" addr = '';\n"
" }\n"
" else //Is Ip4\n"
" {\n"
-" dns += Net.makeIp4Rev(fields[2].substr(24, 8)).padEnd(40, ' ');\n"
+" addr = Net.makeIp4Rev(fields[2].substr(24, 8));\n"
+" if (a4s.has(addr)) mac = a4s.get(addr);\n"
" }\n"
" }\n"
" else //Is IP6\n"
" {\n"
-" dns += Net.makeIp6(fields[2]).padEnd(40, ' ');\n"
+" addr = Net.makeIp6(fields[2]);\n"
+" if (a6s.has(addr)) mac = a6s.get(addr)\n"
" }\n"
+" dns += addr.padEnd(40, ' ');\n"
+" \n"
+" dns += ' ';\n"
+" dns += fields[3]; //DNS protocol used\n"
" dns += ' ';\n"
-" dns += fields[3];\n"
-" dns += ' ';\n"
-" dns += fields[4];\n"
+" dns += fields[4].padEnd(20, ' '); //Resolved name\n"
+" \n"
+" if (mac != '')\n"
+" {\n"
+" dns += ' ';\n"
+" dns += mac;\n"
+" dns += ' ';\n"
+" \n"
+" let vendor = Net.getVendorFromLocalStorage(mac);\n"
+" if (vendor)\n"
+" {\n"
+" dns += ' ';\n"
+" dns += vendor;\n"
+" }\n"
+" else\n"
+" {\n"
+" Net.addVendorToLocalStorage(mac);\n"
+" }\n"
+" }\n"
" dns += '\\r\\n';\n"
"}\n"
+"function parseAr4Line(line)\n"
+"{\n"
+" if (line.length == 0) return;\n"
+" let fields = line.split('\\t');\n"
+" \n"
+" let index = parseInt(fields[0], 16);\n"
+" let ms = parseInt(fields[1], 16);\n"
+" let addr = Net.makeIp4(fields[2]);\n"
+" let mac = Net.makeMac(fields[3]);\n"
+" \n"
+" a4s.set(addr, mac);\n"
+"}\n"
+"function parseAr6Line(line)\n"
+"{\n"
+" if (line.length == 0) return;\n"
+" let fields = line.split('\\t');\n"
+" \n"
+" let index = parseInt(fields[0], 16);\n"
+" let ms = parseInt(fields[1], 16);\n"
+" let addr = Net.makeIp6(fields[2]);\n"
+" let mac = Net.makeMac(fields[3]);\n"
+" \n"
+" a6s.set(addr, mac);\n"
+"}\n"
+"function parseGenLines(text)\n"
+"{\n"
+" let lines = text.split('\\n');\n"
+" mac = Net.makeMac(lines[ 0]);\n"
+"}\n"
+"function parseTcpLines(text)\n"
+"{\n"
+" tcp = \"State Idle Protocol ARI Port-Loc Port-Rem Rcvd Sent\\n\";\n"
+" text.split('\\n').forEach(parseTcpLine);\n"
+"}\n"
"function parseDnsLines(text)\n"
"{\n"
" dns = '';\n"
" text.split('\\n').forEach(parseDnsLine);\n"
"}\n"
-"function parseGenLines(text)\n"
+"function parseAr4Lines(text)\n"
"{\n"
-" let lines = text.split('\\n');\n"
-" mac = Net.makeMac(lines[ 0]);\n"
+" a4s = new Map();\n"
+" text.split('\\n').forEach(parseAr4Line);\n"
+"}\n"
+"function parseAr6Lines(text)\n"
+"{\n"
+" a6s = new Map();\n"
+" text.split('\\n').forEach(parseAr6Line);\n"
"}\n"
"function parse()\n"
"{\n"
" let topics = Ajax.response.split('\\f');\n"
" parseGenLines(topics[0]);\n"
" parseTcpLines(topics[1]);\n"
+" parseAr4Lines(topics[3]);\n"
+" parseAr6Lines(topics[4]);\n"
" parseDnsLines(topics[2]);\n"
"}\n"
"function display()\n"