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
base/net/web-net6-script.inc@142:b472ba95b018, 2020-12-23 (annotated)
- Committer:
- andrewboyson
- Date:
- Wed Dec 23 09:57:17 2020 +0000
- Revision:
- 142:b472ba95b018
- Parent:
- 136:be1d42268b5d
- Child:
- 144:7106252b7abf
Added parameters for the change to the net RA (Link unique prefixes)
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| andrewboyson | 96:eb2eb75bad0f | 1 | "//Net6 script\n" |
| andrewboyson | 86:f3c9beec4ee7 | 2 | "'use strict';\n" |
| andrewboyson | 86:f3c9beec4ee7 | 3 | "\n" |
| andrewboyson | 96:eb2eb75bad0f | 4 | "let arp = '';\n" |
| andrewboyson | 96:eb2eb75bad0f | 5 | "let dns = '';\n" |
| andrewboyson | 142:b472ba95b018 | 6 | "\n" |
| andrewboyson | 96:eb2eb75bad0f | 7 | "let hopLimit = '';\n" |
| andrewboyson | 142:b472ba95b018 | 8 | "let mtu = '';\n" |
| andrewboyson | 96:eb2eb75bad0f | 9 | "let managed = false;\n" |
| andrewboyson | 96:eb2eb75bad0f | 10 | "let other = false;\n" |
| andrewboyson | 96:eb2eb75bad0f | 11 | "let routerMac = '';\n" |
| andrewboyson | 96:eb2eb75bad0f | 12 | "let dnsLife = '';\n" |
| andrewboyson | 96:eb2eb75bad0f | 13 | "let dnsIp = '';\n" |
| andrewboyson | 96:eb2eb75bad0f | 14 | "let ndpLease = '';\n" |
| andrewboyson | 96:eb2eb75bad0f | 15 | "let ndpElapsed = '';\n" |
| andrewboyson | 96:eb2eb75bad0f | 16 | "let slaac = '';\n" |
| andrewboyson | 142:b472ba95b018 | 17 | "\n" |
| andrewboyson | 142:b472ba95b018 | 18 | "let uniquePrefixLength = '';\n" |
| andrewboyson | 142:b472ba95b018 | 19 | "let uniquePrefixL = false;\n" |
| andrewboyson | 142:b472ba95b018 | 20 | "let uniquePrefixA = false;\n" |
| andrewboyson | 142:b472ba95b018 | 21 | "let uniquePrefixLimit = '';\n" |
| andrewboyson | 142:b472ba95b018 | 22 | "let uniquePrefixPreferred = '';\n" |
| andrewboyson | 142:b472ba95b018 | 23 | "let uniquePrefix = '';\n" |
| andrewboyson | 142:b472ba95b018 | 24 | "let globalPrefixLength = '';\n" |
| andrewboyson | 142:b472ba95b018 | 25 | "let globalPrefixL = false;\n" |
| andrewboyson | 142:b472ba95b018 | 26 | "let globalPrefixA = false;\n" |
| andrewboyson | 142:b472ba95b018 | 27 | "let globalPrefixLimit = '';\n" |
| andrewboyson | 142:b472ba95b018 | 28 | "let globalPrefixPreferred = '';\n" |
| andrewboyson | 142:b472ba95b018 | 29 | "let globalPrefix = '';\n" |
| andrewboyson | 86:f3c9beec4ee7 | 30 | "\n" |
| andrewboyson | 88:2857259fc2b4 | 31 | "function parseArpLine(line)\n" |
| andrewboyson | 88:2857259fc2b4 | 32 | "{\n" |
| andrewboyson | 88:2857259fc2b4 | 33 | " if (line.length == 0) return;\n" |
| andrewboyson | 136:be1d42268b5d | 34 | " let fields = line.split('\\t');\n" |
| andrewboyson | 136:be1d42268b5d | 35 | " \n" |
| andrewboyson | 136:be1d42268b5d | 36 | " arp += parseInt(fields[0], 16).toString().padStart(2, ' ');\n" |
| andrewboyson | 136:be1d42268b5d | 37 | " \n" |
| andrewboyson | 136:be1d42268b5d | 38 | " let minutes = parseInt(fields[1], 16) / 1000 / 60;\n" |
| andrewboyson | 88:2857259fc2b4 | 39 | " arp += Math.floor(minutes).toString().padStart(4, ' ');\n" |
| andrewboyson | 88:2857259fc2b4 | 40 | " arp += ' ';\n" |
| andrewboyson | 136:be1d42268b5d | 41 | " \n" |
| andrewboyson | 136:be1d42268b5d | 42 | " arp += Net.makeIp6(fields[2]).padEnd(40, ' ');\n" |
| andrewboyson | 88:2857259fc2b4 | 43 | " arp += ' ';\n" |
| andrewboyson | 136:be1d42268b5d | 44 | " \n" |
| andrewboyson | 136:be1d42268b5d | 45 | " arp += Net.makeMac(fields[3]);\n" |
| andrewboyson | 88:2857259fc2b4 | 46 | " arp += '\\r\\n';\n" |
| andrewboyson | 88:2857259fc2b4 | 47 | "}\n" |
| andrewboyson | 88:2857259fc2b4 | 48 | "function parseDnsLine(line)\n" |
| andrewboyson | 88:2857259fc2b4 | 49 | "{\n" |
| andrewboyson | 88:2857259fc2b4 | 50 | " if (line.length == 0) return;\n" |
| andrewboyson | 136:be1d42268b5d | 51 | " let fields = line.split('\\t');\n" |
| andrewboyson | 136:be1d42268b5d | 52 | " \n" |
| andrewboyson | 136:be1d42268b5d | 53 | " dns += parseInt(fields[0], 16).toString().padStart(2, ' ');\n" |
| andrewboyson | 136:be1d42268b5d | 54 | " let minutes = parseInt(fields[1], 16) / 1000 / 60;\n" |
| andrewboyson | 88:2857259fc2b4 | 55 | " dns += Math.floor(minutes).toString().padStart(4, ' ');\n" |
| andrewboyson | 88:2857259fc2b4 | 56 | " dns += ' ';\n" |
| andrewboyson | 136:be1d42268b5d | 57 | " dns += Net.makeIp6(fields[2]).padEnd(40, ' ');\n" |
| andrewboyson | 88:2857259fc2b4 | 58 | " dns += ' ';\n" |
| andrewboyson | 136:be1d42268b5d | 59 | " dns += fields[3];\n" |
| andrewboyson | 88:2857259fc2b4 | 60 | " dns += ' ';\n" |
| andrewboyson | 136:be1d42268b5d | 61 | " dns += fields[4];\n" |
| andrewboyson | 88:2857259fc2b4 | 62 | " dns += '\\r\\n';\n" |
| andrewboyson | 88:2857259fc2b4 | 63 | "}\n" |
| andrewboyson | 88:2857259fc2b4 | 64 | "function parseArpLines(text)\n" |
| andrewboyson | 88:2857259fc2b4 | 65 | "{\n" |
| andrewboyson | 88:2857259fc2b4 | 66 | " arp = '';\n" |
| andrewboyson | 88:2857259fc2b4 | 67 | " text.split('\\n').forEach(parseArpLine);\n" |
| andrewboyson | 88:2857259fc2b4 | 68 | "}\n" |
| andrewboyson | 88:2857259fc2b4 | 69 | "function parseDnsLines(text)\n" |
| andrewboyson | 88:2857259fc2b4 | 70 | "{\n" |
| andrewboyson | 88:2857259fc2b4 | 71 | " dns = '';\n" |
| andrewboyson | 88:2857259fc2b4 | 72 | " text.split('\\n').forEach(parseDnsLine);\n" |
| andrewboyson | 88:2857259fc2b4 | 73 | "}\n" |
| andrewboyson | 89:615fb951df69 | 74 | "function parseGenLines(text)\n" |
| andrewboyson | 89:615fb951df69 | 75 | "{\n" |
| andrewboyson | 96:eb2eb75bad0f | 76 | " let lines = text.split('\\n');\n" |
| andrewboyson | 89:615fb951df69 | 77 | " \n" |
| andrewboyson | 142:b472ba95b018 | 78 | " slaac = Net.makeIp6 (lines[ 0] );\n" |
| andrewboyson | 142:b472ba95b018 | 79 | " \n" |
| andrewboyson | 142:b472ba95b018 | 80 | " hopLimit = parseInt(lines[ 1], 16);\n" |
| andrewboyson | 142:b472ba95b018 | 81 | " mtu = parseInt(lines[ 2], 16);\n" |
| andrewboyson | 142:b472ba95b018 | 82 | " managed = Net.hexToBit(lines[ 3], 0);\n" |
| andrewboyson | 142:b472ba95b018 | 83 | " other = Net.hexToBit(lines[ 3], 1);\n" |
| andrewboyson | 142:b472ba95b018 | 84 | " routerMac = Net.makeMac (lines[ 4], 16);\n" |
| andrewboyson | 142:b472ba95b018 | 85 | " ndpLease = parseInt(lines[ 5], 16);\n" |
| andrewboyson | 142:b472ba95b018 | 86 | " ndpElapsed = parseInt(lines[ 6], 16);\n" |
| andrewboyson | 142:b472ba95b018 | 87 | " \n" |
| andrewboyson | 142:b472ba95b018 | 88 | " dnsIp = Net.makeIp6 (lines[ 7] );\n" |
| andrewboyson | 142:b472ba95b018 | 89 | " dnsLife = parseInt(lines[ 8], 16);\n" |
| andrewboyson | 142:b472ba95b018 | 90 | " \n" |
| andrewboyson | 142:b472ba95b018 | 91 | " uniquePrefixL = Net.hexToBit(lines[ 9], 0);\n" |
| andrewboyson | 142:b472ba95b018 | 92 | " uniquePrefixA = Net.hexToBit(lines[ 9], 1);\n" |
| andrewboyson | 142:b472ba95b018 | 93 | " uniquePrefixLength = parseInt(lines[10], 16);\n" |
| andrewboyson | 142:b472ba95b018 | 94 | " uniquePrefix = Net.makeIp6 (lines[11] );\n" |
| andrewboyson | 142:b472ba95b018 | 95 | " uniquePrefixLimit = parseInt(lines[12], 16);\n" |
| andrewboyson | 142:b472ba95b018 | 96 | " uniquePrefixPreferred = parseInt(lines[13], 16);\n" |
| andrewboyson | 142:b472ba95b018 | 97 | " \n" |
| andrewboyson | 142:b472ba95b018 | 98 | " globalPrefixL = Net.hexToBit(lines[14], 0);\n" |
| andrewboyson | 142:b472ba95b018 | 99 | " globalPrefixA = Net.hexToBit(lines[14], 1);\n" |
| andrewboyson | 142:b472ba95b018 | 100 | " globalPrefixLength = parseInt(lines[15], 16);\n" |
| andrewboyson | 142:b472ba95b018 | 101 | " globalPrefix = Net.makeIp6 (lines[16] );\n" |
| andrewboyson | 142:b472ba95b018 | 102 | " globalPrefixLimit = parseInt(lines[17], 16);\n" |
| andrewboyson | 142:b472ba95b018 | 103 | " globalPrefixPreferred = parseInt(lines[18], 16);\n" |
| andrewboyson | 89:615fb951df69 | 104 | "}\n" |
| andrewboyson | 96:eb2eb75bad0f | 105 | "function parse()\n" |
| andrewboyson | 86:f3c9beec4ee7 | 106 | "{\n" |
| andrewboyson | 96:eb2eb75bad0f | 107 | " let topics = Ajax.response.split('\\f');\n" |
| andrewboyson | 89:615fb951df69 | 108 | " parseGenLines(topics[0]);\n" |
| andrewboyson | 89:615fb951df69 | 109 | " parseArpLines(topics[1]);\n" |
| andrewboyson | 89:615fb951df69 | 110 | " parseDnsLines(topics[2]);\n" |
| andrewboyson | 86:f3c9beec4ee7 | 111 | "}\n" |
| andrewboyson | 96:eb2eb75bad0f | 112 | "function display()\n" |
| andrewboyson | 86:f3c9beec4ee7 | 113 | "{\n" |
| andrewboyson | 96:eb2eb75bad0f | 114 | " let elem;\n" |
| andrewboyson | 89:615fb951df69 | 115 | " \n" |
| andrewboyson | 96:eb2eb75bad0f | 116 | " elem = Ajax.getElementOrNull('ajax-arp' ); if (elem) elem.textContent = arp;\n" |
| andrewboyson | 96:eb2eb75bad0f | 117 | " elem = Ajax.getElementOrNull('ajax-dns' ); if (elem) elem.textContent = dns;\n" |
| andrewboyson | 142:b472ba95b018 | 118 | " elem = Ajax.getElementOrNull('ajax-slaac' ); if (elem) elem.textContent = slaac;\n" |
| andrewboyson | 96:eb2eb75bad0f | 119 | " elem = Ajax.getElementOrNull('ajax-hop-limit' ); if (elem) elem.textContent = hopLimit;\n" |
| andrewboyson | 142:b472ba95b018 | 120 | " elem = Ajax.getElementOrNull('ajax-mtu' ); if (elem) elem.textContent = mtu;\n" |
| andrewboyson | 96:eb2eb75bad0f | 121 | " elem = Ajax.getElementOrNull('ajax-managed' ); if (elem) elem.setAttribute('dir', managed ? 'rtl' : 'ltr');\n" |
| andrewboyson | 96:eb2eb75bad0f | 122 | " elem = Ajax.getElementOrNull('ajax-other' ); if (elem) elem.setAttribute('dir', other ? 'rtl' : 'ltr');\n" |
| andrewboyson | 96:eb2eb75bad0f | 123 | " elem = Ajax.getElementOrNull('ajax-router-mac' ); if (elem) elem.textContent = routerMac;\n" |
| andrewboyson | 142:b472ba95b018 | 124 | " elem = Ajax.getElementOrNull('ajax-ndp-lease' ); if (elem) elem.textContent = ndpLease;\n" |
| andrewboyson | 142:b472ba95b018 | 125 | " elem = Ajax.getElementOrNull('ajax-ndp-elapsed' ); if (elem) elem.textContent = ndpElapsed;\n" |
| andrewboyson | 96:eb2eb75bad0f | 126 | " elem = Ajax.getElementOrNull('ajax-dns-life' ); if (elem) elem.textContent = dnsLife;\n" |
| andrewboyson | 96:eb2eb75bad0f | 127 | " elem = Ajax.getElementOrNull('ajax-dns-ip' ); if (elem) elem.textContent = dnsIp;\n" |
| andrewboyson | 142:b472ba95b018 | 128 | " \n" |
| andrewboyson | 142:b472ba95b018 | 129 | " elem = Ajax.getElementOrNull('ajax-unique-prefix-l' ); if (elem) elem.setAttribute('dir', uniquePrefixL ? 'rtl' : 'ltr');\n" |
| andrewboyson | 142:b472ba95b018 | 130 | " elem = Ajax.getElementOrNull('ajax-unique-prefix-a' ); if (elem) elem.setAttribute('dir', uniquePrefixA ? 'rtl' : 'ltr');\n" |
| andrewboyson | 142:b472ba95b018 | 131 | " elem = Ajax.getElementOrNull('ajax-unique-prefix-length' ); if (elem) elem.textContent = uniquePrefixLength;\n" |
| andrewboyson | 142:b472ba95b018 | 132 | " elem = Ajax.getElementOrNull('ajax-unique-prefix' ); if (elem) elem.textContent = uniquePrefix;\n" |
| andrewboyson | 142:b472ba95b018 | 133 | " elem = Ajax.getElementOrNull('ajax-unique-prefix-limit' ); if (elem) elem.textContent = uniquePrefixLimit;\n" |
| andrewboyson | 142:b472ba95b018 | 134 | " elem = Ajax.getElementOrNull('ajax-unique-prefix-preferred'); if (elem) elem.textContent = uniquePrefixPreferred;\n" |
| andrewboyson | 142:b472ba95b018 | 135 | " \n" |
| andrewboyson | 142:b472ba95b018 | 136 | " elem = Ajax.getElementOrNull('ajax-global-prefix-l' ); if (elem) elem.setAttribute('dir', globalPrefixL ? 'rtl' : 'ltr');\n" |
| andrewboyson | 142:b472ba95b018 | 137 | " elem = Ajax.getElementOrNull('ajax-global-prefix-a' ); if (elem) elem.setAttribute('dir', globalPrefixA ? 'rtl' : 'ltr');\n" |
| andrewboyson | 142:b472ba95b018 | 138 | " elem = Ajax.getElementOrNull('ajax-global-prefix-length' ); if (elem) elem.textContent = globalPrefixLength;\n" |
| andrewboyson | 142:b472ba95b018 | 139 | " elem = Ajax.getElementOrNull('ajax-global-prefix' ); if (elem) elem.textContent = globalPrefix;\n" |
| andrewboyson | 142:b472ba95b018 | 140 | " elem = Ajax.getElementOrNull('ajax-global-prefix-limit' ); if (elem) elem.textContent = globalPrefixLimit;\n" |
| andrewboyson | 142:b472ba95b018 | 141 | " elem = Ajax.getElementOrNull('ajax-global-prefix-preferred'); if (elem) elem.textContent = globalPrefixPreferred;\n" |
| andrewboyson | 86:f3c9beec4ee7 | 142 | "}\n" |
| andrewboyson | 86:f3c9beec4ee7 | 143 | "\n" |
| andrewboyson | 96:eb2eb75bad0f | 144 | "Ajax.server = '/net6-ajax';\n" |
| andrewboyson | 96:eb2eb75bad0f | 145 | "Ajax.onResponse = function() { parse(); display(); };\n" |
| andrewboyson | 96:eb2eb75bad0f | 146 | "Ajax.init();" |