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