Added Intel AMT LMS event support and parsing.

Ylian Saint-Hilaire committed Feb 1, 2018 at 13:45 UTC 007f150be0de4d4fc07df22ea73145eed04e13f4
9 files changed +1390 -206
MeshCentralServer.njsproj
+5 -3
@@ -20,6 +20,7 @@
20 <PropertyGroup Condition="'$(Configuration)' == 'Debug'" />
21 <PropertyGroup Condition="'$(Configuration)' == 'Release'" />
22 <ItemGroup>
23 + <Compile Include="agents\meshcmd.js" />
24 <Compile Include="agents\meshcore.js" />
25 <Compile Include="agents\modules_meshcmd\amt-0.2.0.js" />
26 <Compile Include="agents\modules_meshcmd\amt-scanner.js" />
@@ -28,10 +29,11 @@
29 <Compile Include="agents\modules_meshcmd\amt-wsman-duk-0.2.0.js" />
30 <Compile Include="agents\modules_meshcmd\amt_heci.js" />
31 <Compile Include="agents\modules_meshcmd\lme_heci.js" />
32 + <Compile Include="agents\modules_meshcore\amt-lme.js" />
33 + <Compile Include="agents\modules_meshcore\amt-mei.js" />
34 <Compile Include="agents\modules_meshcore\amt-scanner.js" />
32 - <Compile Include="agents\modules_meshcore\amt_heci.js" />
33 - <Compile Include="agents\modules_meshcore\lme_heci.js" />
34 - <Compile Include="agents\modules_meshcore\WifiScanner.js" />
35 + <Compile Include="agents\modules_meshcore\amt-xml.js" />
36 + <Compile Include="agents\modules_meshcore\wifi-scanner.js" />
37 <Compile Include="agents\tinycore.js" />
38 <Compile Include="amtevents.js" />
39 <Compile Include="amtscanner.js" />
agents/meshcmd.js
+2 -2
@@ -317,8 +317,8 @@ function startLms(func) {
317 //console.log('LME connection failed', e);
318 if (func) { func(amtLms.connected == false?0:3); }
319 });
320 - amtLms.on('notify', function (data, options) {
321 - //console.log('notify', data, options);
320 + amtLms.on('notify', function (data, options, str) {
321 + if (str != null) { console.log(str); } else { console.log(JSON.stringify(data)); }
322 });
323 //console.log('LME Connecting...');
324 amtLms.on('connect', function () {
agents/meshcore.js
+19 -38
@@ -37,6 +37,7 @@ function createMeshCore(agent) {
37 var networkMonitor = null;
38 var amtscanner = null;
39 var nextTunnelIndex = 1;
40 + var lastException = null;
41
42 /*
43 var AMTScanner = require("AMTScanner");
@@ -78,14 +79,14 @@ function createMeshCore(agent) {
79 amtMei = new amtMeiLib();
80 amtMei.on('error', function (e) { amtMeiLib = null; amtMei = null; sendPeriodicServerUpdate(); });
81 amtMei.on('connect', function () { amtMeiConnected = 2; getAmtInfo(); });
81 - } catch (e) { amtMeiLib = null; amtMei = null; amtMeiConnected = -1; }
82 + } catch (e) { lastException = e; amtMeiLib = null; amtMei = null; amtMeiConnected = -1; }
83
84 // Try to load up the WIFI scanner
85 try {
86 var wifiScannerLib = require('wifi-scanner');
87 wifiScanner = new wifiScannerLib();
88 wifiScanner.on('accessPoint', function (data) { sendConsoleText(JSON.stringify(data)); });
88 - } catch (e) { wifiScannerLib = null; wifiScanner = null; }
89 + } catch (e) { lastException = e; wifiScannerLib = null; wifiScanner = null; }
90
91 // If we are running in Duktape, agent will be null
92 if (agent == null) {
@@ -800,12 +801,13 @@ function createMeshCore(agent) {
801 }
802 case 'info': { // Return information about the agent and agent core module
803 response = 'Current Core: ' + obj.meshCoreInfo + '.\r\nAgent Time: ' + Date() + '.\r\nUser Rights: 0x' + rights.toString(16) + '.\r\nPlatform Info: ' + process.platform + '.\r\nCapabilities: ' + obj.meshCoreCapabilities + '.\r\nServer URL: ' + mesh.ServerUrl + '.';
803 - if (amtLmsState >= 0) { response += '\r\nBuilt-in LMS: ' + ['Disabled', 'Connecting..', 'Connected'][amtLmsState] + '.'; }
804 + if (amtLmsState >= 0) { response += '\r\nBuilt-in LMS: ' + ['Disabled', 'Connecting..', 'Connected', 'Exception'][amtLmsState] + '.'; }
805 response += '\r\nModules: ' + JSON.stringify(addedModules) + '';
806 response += '\r\nServerConnected: ' + mesh.isControlChannelConnected + '';
807 var oldNodeId = db.Get('OldNodeId');
808 if (oldNodeId != null) { response += '\r\nOldNodeID: ' + oldNodeId + '.'; }
809 response += '\r\ServerState: ' + meshServerConnectionState + '.';
810 + if (lastException != null) { response += '\r\LastException: ' + JSON.stringify(lastException) + '.'; }
811 break;
812 }
813 case 'selfinfo': { // Return self information block
@@ -1161,42 +1163,17 @@ function createMeshCore(agent) {
1163 }
1164
1165 // Called on MicroLMS Intel AMT user notification
1164 - function handleAmtNotification(notification) {
1165 - var amtMessage = notification.messageId;
1166 - var amtMessageArg = notification.messageArguments;
1167 - var notify = null;
1168 -
1166 + function handleAmtNotification(notifyMsg) {
1167 + if ((notifyMsg == null) || (notifyMsg.Body == null) || (notifyMsg.Body.MessageID == null) || (notifyMsg.Body.MessageArguments == null)) return null;
1168 + var amtMessage = notifyMsg.Body.MessageID, amtMessageArg = notifyMsg.Body.MessageArguments[0], notify = null;
1169 +
1170 switch (amtMessage) {
1170 - case 'iAMT0050': {
1171 - // Serial over lan
1172 - if (amtMessageArg == '48') {
1173 - // Connected
1174 - notify = 'Intel&reg; AMT Serial-over-LAN connected';
1175 - }
1176 - else if (amtMessageArg == '49') {
1177 - // Disconnected
1178 - notify = 'Intel&reg; AMT Serial-over-LAN disconnected';
1179 - }
1180 - }
1181 - case 'iAMT0052': {
1182 - // HWKVM
1183 - if (amtMessageArg == '1') {
1184 - // Connected
1185 - notify = 'Intel&reg; AMT KVM connected';
1186 - }
1187 - else if (amtMessageArg == '2') {
1188 - // Disconnected
1189 - notify = 'Intel&reg; AMT KVM disconnected';
1190 - }
1191 - break;
1192 - }
1193 - }
1194 -
1195 - if (notify != null) {
1196 - var notification = { "action": "msg", "type": "notify", "value": notify, "tag": "general" };
1197 - //mesh.SendCommand(notification); // no sessionid or userid specified, notification will go to the entire mesh
1198 - //console.log("handleAmtNotification", JSON.stringify(notification));
1171 + case 'iAMT0050': { if (amtMessageArg == '48') { notify = 'Intel&reg; AMT Serial-over-LAN connected'; } else if (amtMessageArg == '49') { notify = 'Intel&reg; AMT Serial-over-LAN disconnected'; } break; } // SOL
1172 + case 'iAMT0052': { if (amtMessageArg == '1') { notify = 'Intel&reg; AMT KVM connected'; } else if (amtMessageArg == '2') { notify = 'Intel&reg; AMT KVM disconnected'; } break; } // KVM
1173 }
1174 +
1175 + // Send to the entire mesh, no sessionid or userid specified.
1176 + if (notify != null) { mesh.SendCommand({ "action": "msg", "type": "notify", "value": notify, "tag": "general" }); }
1177 }
1178
1179 // Starting function
@@ -1216,7 +1193,11 @@ function createMeshCore(agent) {
1193 amtLms = new lme_heci();
1194 amtLms.on('error', function (e) { amtLmsState = 0; amtLms = null; });
1195 amtLms.on('connect', function () { amtLmsState = 2; });
1219 - } catch (e) { amtLmsState = -1; amtLms = null; }
1196 + amtLms.on('notify', function (data, options, str) {
1197 + if (str != null) { sendConsoleText('Intel AMT LMS: ' + str); }
1198 + handleAmtNotification(data);
1199 + });
1200 + } catch (e) { lastException = e; amtLmsState = 3; amtLms = null; }
1201
1202 // Check if the control channel is connected
1203 if (mesh.isControlChannelConnected) {
agents/modules_meshcmd/amt-lme.js
+453 -3
@@ -17,6 +17,7 @@ limitations under the License.
17 var MemoryStream = require('MemoryStream');
18 var lme_id = 0; // Our next channel identifier
19 var lme_port_offset = 0; // Debug: Set this to "-100" to bind to 16892 & 16893 and IN_ADDRANY. This is for LMS debugging.
20 +var xmlParser = require('amt-xml');
21
22 // Documented in: https://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide/HTMLDocuments/MPSDocuments/Intel%20AMT%20Port%20Forwarding%20Protocol%20Reference%20Manual.pdf
23 var APF_DISCONNECT = 1;
@@ -115,7 +116,7 @@ function lme_heci(options) {
116 emitterUtils.createEvent('connect');
117 emitterUtils.createEvent('notify');
118
118 - if (options.debug == true) { lme_port_offset = -100; } // LMS debug mode
119 + if ((options != null) && (options.debug == true)) { lme_port_offset = -100; } // LMS debug mode
120
121 var heci = require('heci');
122 this.INITIAL_RXWINDOW_SIZE = 4096;
@@ -267,7 +268,7 @@ function lme_heci(options) {
268 var rChannelId = chunk.readUInt32BE(1);
269 var dataLen = chunk.readUInt32BE(5);
270 var data = chunk.slice(9, 9 + dataLen);
270 - if (this.sockets[rChannelId] != undefined) {
271 + if ((this.sockets != null) && (this.sockets[rChannelId] != undefined)) {
272 this.sockets[rChannelId].pendingBytes.push(data.length);
273 this.sockets[rChannelId].write(data, function () {
274 var written = this.pendingBytes.shift();
@@ -285,8 +286,15 @@ function lme_heci(options) {
286 //console.log('IN DATA', channel.rxWindow, channel.data.length, dataLen, channel.amtId, data.toString());
287 var httpData = parseHttp(channel.data);
288 if ((httpData != null) || (channel.data.length >= 8000)) {
289 + // Parse the WSMAN
290 + var notify = null;
291 + try { notify = xmlParser.ParseWsman(httpData); } catch (e) { }
292 +
293 + // Translate the event
294 + var notifyString = _lmsNotifyToString(notify);
295 +
296 // Event the http data
289 - this.LMS.emit('notify', httpData, channel.options);
297 + if (notify != null) { this.LMS.emit('notify', notify, channel.options, notifyString); }
298
299 // Send channel close
300 var buffer = Buffer.alloc(5);
@@ -417,4 +425,446 @@ function parseHttp(httpData) {
425 return null;
426 }
427
428 +function _lmsNotifyToString(notify) {
429 + if ((notify == null) || (notify.Body == null) || (notify.Body.MessageID == null)) return null;
430 + var msgid = notify.Body.MessageID;
431 + try { msgid += '-' + notify.Body.MessageArguments[0]; } catch (e) { }
432 + if (lmsEvents[msgid]) { return lmsEvents[msgid]; }
433 + return null;
434 +}
435 +
436 +var lmsEvents = {
437 + "iAMT0001": "System Defense Policy %1s triggered.",
438 + "iAMT0002": "Agent Presence Agent %1s not started.",
439 + "iAMT0003": "Agent Presence Agent %1s stopped.",
440 + "iAMT0004": "Agent Presence Agent %1s running.",
441 + "iAMT0005": "Agent Presence Agent %1s expired.",
442 + "iAMT0006": "Agent Presence Agent %1s suspended.",
443 + "iAMT0007": "Host software attempt to disable AMT Network link detected.",
444 + "iAMT0008": "Host software attempt to disable AMT Network link detected -- Host Network link blocked.",
445 + "iAMT0009": "AMT clock or FLASH wear-out protection disabled.",
446 + "iAMT0010": "Intel(R) AMT Network Interface %1s heuristics defense slow threshold trespassed.",
447 + "iAMT0011": "Intel(R) AMT Network Interface %1s heuristics defense fast threshold trespassed.",
448 + "iAMT0012": "Intel(R) AMT Network Interface %1s heuristics defense factory defined threshold trespassed.",
449 + "iAMT0013": "Intel(R) AMT Network Interface %1s heuristics defense Encounter timeout expired.",
450 + "iAMT0014": "General certificate error.",
451 + "iAMT0015": "Certificate expired.",
452 + "iAMT0016": "No trusted root certificate.",
453 + "iAMT0017": "Not configured to work with server certificate.",
454 + "iAMT0018": "Certificate revoked.",
455 + "iAMT0019": "RSA exponent too large.",
456 + "iAMT0020": "RSA modulus too large.",
457 + "iAMT0021": "Unsupported digest.",
458 + "iAMT0022": "Distinguished name too long.",
459 + "iAMT0023": "Key usage missing.",
460 + "iAMT0024": "General SSL handshake error.",
461 + "iAMT0025": "General 802.1x error.",
462 + "iAMT0026": "AMT Diagnostic AlertEAC error - General NAC error.",
463 + "iAMT0027": "AMT Diagnostic AlertEAC error - attempt to get a NAC posture while AMT NAC is disabled.",
464 + "iAMT0028": "AMT Diagnostic AlertEAC error - attempt to get a posture of an unsupported type.",
465 + "iAMT0029": "Audit log storage is 50% full.",
466 + "iAMT0030": "Audit log storage is 75% full.",
467 + "iAMT0031": "Audit log storage is 85% full.",
468 + "iAMT0032": "Audit log storage is 95% full.",
469 + "iAMT0033": "Audit log storage is full.",
470 + "iAMT0034": "Firmware Update Event - Partial.",
471 + "iAMT0035": "Firmware Update Event - Failure.",
472 + "iAMT0036": "Remote connectivity initiated.",
473 + "iAMT0037": "ME Presence event.",
474 + "iAMT0038-0": "AMT is being unprovisioned using BIOS command.",
475 + "iAMT0038-1": "AMT is being unprovisioned using Local MEI command.",
476 + "iAMT0038-2": "AMT is being unprovisioned using Local WS-MAN/SOAP command.",
477 + "iAMT0038-3": "AMT is being unprovisioned using Remote WS-MAN/SOAP command.",
478 + "iAMT0039": "HW Asset Error.",
479 + "iAMT0050": "User Notification Alert - General Notification.",
480 + "iAMT0050-16": "User Notification Alert - Circuit Breaker notification (CB Drop TX filter hit.).",
481 + "iAMT0050-17": "User Notification Alert - Circuit Breaker notification (CB Rate Limit TX filter hit.).",
482 + "iAMT0050-18": "User Notification Alert - Circuit Breaker notification (CB Drop RX filter hit.).",
483 + "iAMT0050-19": "User Notification Alert - Circuit Breaker notification (CB Rate Limit RX filter hit.).",
484 + "iAMT0050-32": "User Notification Alert - EAC notification.",
485 + "iAMT0050-48": "User Notification Alert - Remote diagnostics - (Remote Redirection session started - SOL).",
486 + "iAMT0050-49": "User Notification Alert - Remote diagnostics - (Remote Redirection session stopped - SOL).",
487 + "iAMT0050-50": "User Notification Alert - Remote diagnostics. (Remote Redirection session started - IDE-R).",
488 + "iAMT0050-51": "User Notification Alert - Remote diagnostics. (Remote Redirection session stopped - IDE-R).",
489 + "iAMT0050-66": "User Notification Alert - WLAN notification (Host profile mismatch - Management Interface ignored).",
490 + "iAMT0050-67": "User Notification Alert - WLAN notification (Management device overrides host radio).",
491 + "iAMT0050-68": "User Notification Alert - WLAN notification (Host profile security mismatch).",
492 + "iAMT0050-69": "User Notification Alert - WLAN notification (Management device relinquishes control over host Radio).",
493 + "iAMT0051": "User Notification Alert - SecIo event.",
494 + "iAMT0051-0": "User Notification Alert - SecIo event semaphore at host.",
495 + "iAMT0051-1": "User Notification Alert - semaphore at ME.",
496 + "iAMT0051-2": "User Notification Alert - SecIo event - semaphore timeout.",
497 + "iAMT0052": "User Notification Alert - KVM session event.",
498 + "iAMT0052-0": "User Notification Alert - KVM session requested.",
499 + "iAMT0052-1": "User Notification Alert - KVM session started.",
500 + "iAMT0052-2": "User Notification Alert - KVM session stopped.",
501 + "iAMT0053": "User Notification Alert - RCS notification.",
502 + "iAMT0053-50": "User Notification Alert - RCS notification (HW button pressed. Connection initiated automatically).",
503 + "iAMT0053-52": "User Notification Alert - RCS notification (HW button pressed. Connection wasn't initiated automatically).",
504 + "iAMT0053-53": "User Notification Alert - RCS notification (Contracts updated).",
505 + "iAMT0054": "User Notification Alert - WLAN notification. Wireless Profile sync enablement state changed.",
506 + "iAMT0055": "User Notification Alert - Provisioning state change notification.",
507 + "iAMT0055-0": "User Notification Alert - Provisioning state change notification - Pre-configuration.",
508 + "iAMT0055-1": "User Notification Alert - Provisioning state change notification - In configuration.",
509 + "iAMT0055-2": "User Notification Alert - Provisioning state change notification - Post-configuration.",
510 + "iAMT0055-3": "User Notification Alert - Provisioning state change notification - unprovision process has started.",
511 + "iAMT0056": "User Notification Alert - System Defense change notification.",
512 + "iAMT0057": "User Notification Alert - Network State change notification.",
513 + "iAMT0058": "User Notification Alert - Remote Access change notification.",
514 + "iAMT0058-1": "User Notification Alert - Remote Access change notification - tunnel is closed.",
515 + //"iAMT0058-1": "User Notification Alert - Remote Access change notification - tunnel is open.",
516 + "iAMT0059": "User Notification Alert - KVM enabled event.",
517 + "iAMT0059-0": "User Notification Alert - KVM enabled event - KVM disabled.",
518 + "iAMT0059-1": "User Notification Alert - KVM enabled event - KVM enabled (both from MEBx and PTNI).",
519 + "iAMT0060": "User Notification Alert - SecIO configuration event.",
520 + "iAMT0061": "ME FW reset occurred.",
521 + "iAMT0062": "User Notification Alert - IpSyncEnabled event.",
522 + "iAMT0062-0": "User Notification Alert - IpSyncEnabled event - IpSync disabled.",
523 + "iAMT0062-1": "User Notification Alert - IpSyncEnabled event - IpSync enabled.",
524 + "iAMT0063": "User Notification Alert - HTTP Proxy sync enabled event.",
525 + "iAMT0063-0": "User Notification Alert - HTTP Proxy sync enabled event - HTTP Proxy Sync disabled.",
526 + "iAMT0063-1": "User Notification Alert - HTTP Proxy sync enabled event - HTTP Proxy Sync enabled.",
527 + "iAMT0064": "User Notification Alert - User Consent event.",
528 + "iAMT0064-1": "User Notification Alert - User Consent event - User Consent granted.",
529 + "iAMT0064-2": "User Notification Alert - User Consent event - User Consent ended.",
530 + "iAMT0067-0": "Graceful Remote Control Operation - Shutdown.",
531 + "iAMT0067-1": "Graceful Remote Control Operation - Reset.",
532 + "iAMT0067-2": "Graceful Remote Control Operation - Hibernate.",
533 + "iAMT0068-0": "Link Protection Notification - No link protection.",
534 + "iAMT0068-1": "Link Protection Notification - Passive link protection.",
535 + "iAMT0068-2": "Link Protection Notification - High link protection.",
536 + "iAMT0069-0": "Local Time Sync Enablement Notification - Local Time Sync Disabled.",
537 + "iAMT0069-1": "Local Time Sync Enablement Notification - Local Time Sync Enabled.",
538 + "iAMT0070": "Host Reset Triggered by WD Expiration Notification.",
539 + "PLAT0004": "The chassis %1s was opened.",
540 + "PLAT0005": "The chassis %1s was closed.",
541 + "PLAT0006": "The drive bay %1s was opened.",
542 + "PLAT0007": "The drive bay %1s was closed.",
543 + "PLAT0008": "The I/O card area %1s was opened.",
544 + "PLAT0009": "The I/O card area %1s was closed.",
545 + "PLAT0010": "The processor area %1s was opened.",
546 + "PLAT0011": "The processor area %1s was closed.",
547 + "PLAT0012": "The LAN %1s has been disconnected.",
548 + "PLAT0013": "The LAN %1s has been connected.",
549 + "PLAT0016": "The permission to insert package %1s has been granted.",
550 + "PLAT0017": "The permission to insert package %1s has been removed.",
551 + "PLAT0018": "The fan card area %1s is open.",
552 + "PLAT0019": "The fan card area %1s is closed.",
553 + "PLAT0022": "The computer system %1s has detected a secure mode violation.",
554 + "PLAT0024": "The computer system %1s has detected a pre-boot user password violation.",
555 + "PLAT0026": "The computer system %1s has detected a pre-boot setup password violation.",
556 + "PLAT0028": "The computer system %1s has detected a network boot password violation.",
557 + "PLAT0030": "The computer system %1s has detected a password violation.",
558 + "PLAT0032": "The management controller %1s has detected an out-of-band password violation.",
559 + "PLAT0034": "The processor %1s has been added.",
560 + "PLAT0035": "The processor %1s has been removed.",
561 + "PLAT0036": "An over-temperature condition has been detected on the processor %1s.",
562 + "PLAT0037": "An over-temperature condition has been removed on the processor %1s.",
563 + "PLAT0038": "The processor %1s is operating in a degraded State.",
564 + "PLAT0039": "The processor %1s is no longer operating in a degraded State.",
565 + "PLAT0040": "The processor %1s has failed.",
566 + "PLAT0042": "The processor %1s has failed.",
567 + "PLAT0044": "The processor %1s has failed.",
568 + "PLAT0046": "The processor %1s has failed.",
569 + "PLAT0048": "The processor %1s has failed.",
570 + "PLAT0060": "The processor %1s has been enabled.",
571 + "PLAT0061": "The processor %1s has been disabled.",
572 + "PLAT0062": "The processor %1s has a configuration mismatch.",
573 + "PLAT0064": "A terminator has been detected on the processor %1s.",
574 + "PLAT0084": "The Power Supply %1s has been added.",
575 + "PLAT0085": "The Power Supply %1s has been removed.",
576 + "PLAT0086": "The Power Supply %1s has failed.",
577 + "PLAT0088": "Failure predicted on power supply %1s.",
578 + "PLAT0096": "The input to power supply %1s has been lost or fallen out of range.",
579 + "PLAT0098": "The power supply %1s is operating in an input state that is out of range.",
580 + "PLAT0099": "The power supply %1s has returned to a normal input state.",
581 + "PLAT0100": "The power supply %1s has lost input.",
582 + "PLAT0104": "The power supply %1s has a configuration mismatch.",
583 + "PLAT0106": "Power supply %1s has been disabled.",
584 + "PLAT0107": "Power supply %1s has been enabled.",
585 + "PLAT0108": "Power supply %1s has been power cycled.",
586 + "PLAT0110": "Power supply %1s has encountered an error during power down.",
587 + "PLAT0112": "Power supply %1s has lost power.",
588 + "PLAT0114": "Soft power control has failed for power supply %1s.",
589 + "PLAT0116": "Power supply %1s has failed.",
590 + "PLAT0118": "Failure predicted on power supply %1s.",
591 + "PLAT0120": "Memory subsystem failure.",
592 + "PLAT0122": "DIMM missing.",
593 + "PLAT0124": "Memory error detected & corrected for DIMM %1s.",
594 + "PLAT0128": "Memory DIMM %1s added.",
595 + "PLAT0129": "Memory DIMM %1s removed.",
596 + "PLAT0130": "Memory DIMM %1s enabled.",
597 + "PLAT0131": "Memory DIMM %1s disabled.",
598 + "PLAT0134": "Memory parity error for DIMM %1s.",
599 + "PLAT0136": "Memory scrub failure for DIMM %1s.",
600 + "PLAT0138": "Memory uncorrectable error detected for DIMM %1s.",
601 + "PLAT0140": "Memory sparing initiated for DIMM %1s.",
602 + "PLAT0141": "Memory sparing concluded for DIMM %1s.",
603 + "PLAT0142": "Memory DIMM %1s Throttled.",
604 + "PLAT0144": "Memory logging limit reached for DIMM %1s.",
605 + "PLAT0145": "Memory logging limit removed for DIMM %1s.",
606 + "PLAT0146": "An over-temperature condition has been detected on the Memory DIMM %1s.",
607 + "PLAT0147": "An over-temperature condition has been removed on the Memory DIMM %1s.",
608 + "PLAT0162": "The drive %1s has been added.",
609 + "PLAT0163": "The drive %1s has been removed.",
610 + "PLAT0164": "The drive %1s has been disabled due to a detected fault.",
611 + "PLAT0167": "The drive %1s has been enabled.",
612 + "PLAT0168": "Failure predicted on drive %1s.",
613 + "PLAT0170": "Hot spare enabled for %1s.",
614 + "PLAT0171": "Hot spare disabled for %1s.",
615 + "PLAT0172": "Consistency check has begun for %1s.",
616 + "PLAT0173": "Consistency check completed for %1s.",
617 + "PLAT0174": "Array %1s is in critical condition.",
618 + "PLAT0176": "Array %1s has failed.",
619 + "PLAT0177": "Array %1s has been restored.",
620 + "PLAT0178": "Rebuild in progress for array %1s.",
621 + "PLAT0179": "Rebuild completed for array %1s.",
622 + "PLAT0180": "Rebuild Aborted for array %1s.",
623 + "PLAT0184": "The system %1s encountered a POST error.",
624 + "PLAT0186": "The system %1s encountered a firmware hang.",
625 + "PLAT0188": "The system %1s encountered firmware progress.",
626 + "PLAT0192": "The log %1s has been disabled.",
627 + "PLAT0193": "The log %1s has been enabled.",
628 + "PLAT0194": "The log %1s has been disabled.",
629 + "PLAT0195": "The log %1s has been enabled.",
630 + "PLAT0196": "The log %1s has been disabled.",
631 + "PLAT0198": "The log %1s has been enabled.",
632 + "PLAT0200": "The log %1s has been cleared.",
633 + "PLAT0202": "The log %1s is full.",
634 + "PLAT0203": "The log %1s is no longer full.",
635 + "PLAT0204": "The log %1s is almost full.",
636 + "PLAT0208": "The log %1s has a configuration error.",
637 + "PLAT0210": "The system %1s has been reconfigured.",
638 + "PLAT0212": "The system %1s has encountered an OEM system boot event.",
639 + "PLAT0214": "The system %1s has encountered an unknown system hardware fault.",
640 + "PLAT0216": "The system %1s has generated an auxiliary log entry.",
641 + "PLAT0218": "The system %1s has executed a PEF action.",
642 + "PLAT0220": "The system %1s has synchronized the system clock.",
643 + "PLAT0222": "A diagnostic interrupt has occurred on system %1s.",
644 + "PLAT0224": "A bus timeout has occurred on system %1s.",
645 + "PLAT0226": "An I/O channel check NMI has occurred on system %1s.",
646 + "PLAT0228": "A software NMI has occurred on system %1s.",
647 + "PLAT0230": "System %1s has recovered from an NMI.",
648 + "PLAT0232": "A PCI PERR has occurred on system %1s.",
649 + "PLAT0234": "A PCI SERR has occurred on system %1s.",
650 + "PLAT0236": "An EISA fail safe timeout occurred on system %1s.",
651 + "PLAT0238": "A correctable bus error has occurred on system %1s.",
652 + "PLAT0240": "An uncorrectable bus error has occurred on system %1s.",
653 + "PLAT0242": "A fatal NMI error has occurred on system %1s.",
654 + "PLAT0244": "A fatal bus error has occurred on system %1s.",
655 + "PLAT0246": "A bus on system %1s is operating in a degraded state.",
656 + "PLAT0247": "A bus on system %1s is no longer operating in a degraded state.",
657 + "PLAT0248": "The power button %1s has been pressed.",
658 + "PLAT0249": "The power button %1s has been released.",
659 + "PLAT0250": "The sleep button %1s has been pressed.",
660 + "PLAT0251": "The sleep button %1s has been released.",
661 + "PLAT0252": "The reset button %1s has been pressed.",
662 + "PLAT0253": "The reset button %1s has been released.",
663 + "PLAT0254": "The latch to %1s has been opened.",
664 + "PLAT0255": "The latch to %1s has been closed.",
665 + "PLAT0256": "The service request %1s has been enabled.",
666 + "PLAT0257": "The service request %1s has been completed.",
667 + "PLAT0258": "Power control of system %1s has failed.",
668 + "PLAT0262": "The network port %1s has been connected.",
669 + "PLAT0263": "The network port %1s has been disconnected.",
670 + "PLAT0266": "The connector %1s has encountered a configuration error.",
671 + "PLAT0267": "The connector %1s configuration error has been repaired.",
672 + "PLAT0272": "Power on for system %1s.",
673 + "PLAT0274": "Power cycle hard requested for system %1s.",
674 + "PLAT0276": "Power cycle soft requested for system %1s.",
675 + "PLAT0278": "PXE boot requested for system %1s.",
676 + "PLAT0280": "Diagnostics boot requested for system %1s.",
677 + "PLAT0282": "System restart requested for system %1s.",
678 + "PLAT0284": "System restart begun for system %1s.",
679 + "PLAT0286": "No bootable media available for system %1s.",
680 + "PLAT0288": "Non-bootable media selected for system %1s.",
681 + "PLAT0290": "PXE server not found for system %1s.",
682 + "PLAT0292": "User timeout on boot for system %1s.",
683 + "PLAT0296": "System %1s boot from floppy initiated.",
684 + "PLAT0298": "System %1s boot from local drive initiated.",
685 + "PLAT0300": "System %1s boot from PXE on network port initiated.",
686 + "PLAT0302": "System %1s boot diagnostics initiated.",
687 + "PLAT0304": "System %1s boot from CD initiated.",
688 + "PLAT0306": "System %1s boot from ROM initiated.",
689 + "PLAT0312": "System %1s boot initiated.",
690 + "PLAT0320": "Critical stop during OS load on system %1s.",
691 + "PLAT0322": "Run-time critical stop on system %1s.",
692 + "PLAT0324": "OS graceful stop on system %1s.",
693 + "PLAT0326": "OS graceful shutdown begun on system %1s.",
694 + "PLAT0327": "OS graceful shutdown completed on system %1s.",
695 + "PLAT0328": "Agent not responding on system %1s.",
696 + "PLAT0329": "Agent has begun responding on system %1s.",
697 + "PLAT0330": "Fault in slot on system %1s.",
698 + "PLAT0331": "Fault condition removed on system %1s.",
699 + "PLAT0332": "Identifying slot on system %1s.",
700 + "PLAT0333": "Identify stopped on slot for system %1s.",
701 + "PLAT0334": "Package installed in slot for system %1s.",
702 + "PLAT0336": "Slot empty system %1s.",
703 + "PLAT0338": "Slot in system %1s is ready for installation.",
704 + "PLAT0340": "Slot in system %1s is ready for removal.",
705 + "PLAT0342": "Power is off on slot of system %1s.",
706 + "PLAT0344": "Power is on for slot of system %1s.",
707 + "PLAT0346": "Removal requested for slot of system %1s.",
708 + "PLAT0348": "Interlock activated on slot of system %1s.",
709 + "PLAT0349": "Interlock de-asserted on slot of system %1s.",
710 + "PLAT0350": "Slot disabled on system %1s.",
711 + "PLAT0351": "Slot enabled on system %1s.",
712 + "PLAT0352": "Slot of system %1s holds spare.",
713 + "PLAT0353": "Slot of system %1s no longer holds spare.",
714 + "PLAT0354": "Computer system %1s enabled.",
715 + "PLAT0356": "Computer system %1s is in sleep - light mode.",
716 + "PLAT0358": "Computer system %1s is in hibernate.",
717 + "PLAT0360": "Computer system %1s is in standby.",
718 + "PLAT0362": "Computer system %1s is in soft off mode.",
719 + "PLAT0364": "Computer system %1s is in hard off mode.",
720 + "PLAT0366": "Computer system %1s is sleeping.",
721 + "PLAT0368": "Watchdog timer expired for %1s.",
722 + "PLAT0370": "Reboot of system initiated by watchdog %1s.",
723 + "PLAT0372": "Powering off system initiated by watchdog %1s.",
724 + "PLAT0374": "Power cycle of system initiated by watchdog %1s.",
725 + "PLAT0376": "Watchdog timer interrupt occurred for %1s.",
726 + "PLAT0378": "A page alert has been generated for system %1s.",
727 + "PLAT0380": "A LAN alert has been generated for system %1s.",
728 + "PLAT0382": "An event trap has been generated for system %1s.",
729 + "PLAT0384": "An SNMP trap has been generated for system %1s.",
730 + "PLAT0390": "%1s detected as present.",
731 + "PLAT0392": "%1s detected as absent.",
732 + "PLAT0394": "%1s has been disabled.",
733 + "PLAT0395": "%1s has been enabled.",
734 + "PLAT0396": "Heartbeat lost for LAN %1s.",
735 + "PLAT0397": "Heartbeat detected for LAN %1s.",
736 + "PLAT0398": "Sensor %1s is unavailable or degraded on management system.",
737 + "PLAT0399": "Sensor %1s has returned to normal on management system.",
738 + "PLAT0400": "Controller %1s is unavailable or degraded on management system.",
739 + "PLAT0401": "Controller %1s has returned to normal on management system.",
740 + "PLAT0402": "Management system %1s is off-line.",
741 + "PLAT0404": "Management system %1s is disabled.",
742 + "PLAT0405": "Management system %1s is enabled.",
743 + "PLAT0406": "Sensor %1s has failed on management system.",
744 + "PLAT0408": "FRU %1s has failed on management system.",
745 + "PLAT0424": "The battery %1s is critically low.",
746 + "PLAT0427": "The battery %1s is no longer critically low.",
747 + "PLAT0430": "The battery %1s has been removed from unit.",
748 + "PLAT0431": "The battery %1s has been added.",
749 + "PLAT0432": "The battery %1s has failed.",
750 + "PLAT0434": "Session audit is deactivated on system %1s.",
751 + "PLAT0435": "Session audit is activated on system %1s.",
752 + "PLAT0436": "A hardware change occurred on system %1s.",
753 + "PLAT0438": "A firmware or software change occurred on system %1s.",
754 + "PLAT0440": "A hardware incompatibility was detected on system %1s.",
755 + "PLAT0442": "A firmware or software incompatibility was detected on system %1s.",
756 + "PLAT0444": "Invalid or unsupported hardware was detected on system %1s.",
757 + "PLAT0446": "Invalid or unsupported firmware or software was detected on system %1s.",
758 + "PLAT0448": "A successful hardware change was detected on system %1s.",
759 + "PLAT0450": "A successful software or firmware change was detected on system %1s.",
760 + "PLAT0464": "FRU %1s not installed on system.",
761 + "PLAT0465": "FRU %1s installed on system.",
762 + "PLAT0466": "Activation requested for FRU %1s on system.",
763 + "PLAT0467": "FRU %1s on system is active.",
764 + "PLAT0468": "Activation in progress for FRU %1s on system.",
765 + "PLAT0470": "Deactivation request for FRU %1s on system.",
766 + "PLAT0471": "FRU %1s on system is in standby or \"hot spare\" state.",
767 + "PLAT0472": "Deactivation in progress for FRU %1s on system.",
768 + "PLAT0474": "Communication lost with FRU %1s on system.",
769 + "PLAT0476": "Numeric sensor %1s going low (lower non-critical).",
770 + "PLAT0478": "Numeric sensor %1s going high (lower non-critical).",
771 + "PLAT0480": "Numeric sensor %1s going low (lower critical).",
772 + "PLAT0482": "Numeric sensor %1s going high (lower critical).",
773 + "PLAT0484": "Numeric sensor %1s going low (lower non-recoverable).",
774 + "PLAT0486": "Numeric sensor %1s going high (lower non-critical).",
775 + "PLAT0488": "Numeric sensor %1s going low (upper non-critical).",
776 + "PLAT0490": "Numeric sensor %1s going high (upper non-critical).",
777 + "PLAT0492": "Numeric sensor %1s going low (upper critical).",
778 + "PLAT0494": "Numeric sensor %1s going high (upper critical).",
779 + "PLAT0496": "Numeric sensor %1s going low (upper non-recoverable).",
780 + "PLAT0498": "Numeric sensor %1s going high (upper non-recoverable).",
781 + "PLAT0500": "Sensor %1s has transitioned to idle.",
782 + "PLAT0502": "Sensor %1s has transitioned to active.",
783 + "PLAT0504": "Sensor %1s has transitioned to busy.",
784 + "PLAT0508": "Sensor %1s has asserted.",
785 + "PLAT0509": "Sensor %1s has de-asserted.",
786 + "PLAT0510": "Sensor %1s is asserting predictive failure.",
787 + "PLAT0511": "Sensor %1s is de-asserting predictive failure.",
788 + "PLAT0512": "Sensor %1s has indicated limit exceeded.",
789 + "PLAT0513": "Sensor %1s has indicated limit no longer exceeded.",
790 + "PLAT0514": "Sensor %1s has indicated performance met.",
791 + "PLAT0516": "Sensor %1s has indicated performance lags.",
792 + "PLAT0518": "Sensor %1s has transitioned to normal state.",
793 + "PLAT0520": "Sensor %1s has transitioned from normal to non-critical state.",
794 + "PLAT0522": "Sensor %1s has transitioned to critical from a less severe state.",
795 + "PLAT0524": "Sensor %1s has transitioned to non-recoverable from a less severe state.",
796 + "PLAT0526": "Sensor %1s has transitioned to non-critical from a more severe state.",
797 + "PLAT0528": "Sensor %1s has transitioned to critical from a non-recoverable state.",
798 + "PLAT0530": "Sensor %1s has transitioned to non-recoverable.",
799 + "PLAT0532": "Sensor %1s indicates a monitor state.",
800 + "PLAT0534": "Sensor %1s has an informational state.",
801 + "PLAT0536": "Device %1s has been added.",
802 + "PLAT0537": "Device %1s has been removed from unit.",
803 + "PLAT0538": "Device %1s has been enabled.",
804 + "PLAT0539": "Device %1s has been disabled.",
805 + "PLAT0540": "Sensor %1s has indicated a running state.",
806 + "PLAT0544": "Sensor %1s has indicated a power off state.",
807 + "PLAT0546": "Sensor %1s has indicated an on-line state.",
808 + "PLAT0548": "Sensor %1s has indicated an off-line state.",
809 + "PLAT0550": "Sensor %1s has indicated an off-duty state.",
810 + "PLAT0552": "Sensor %1s has indicated a degraded state.",
811 + "PLAT0554": "Sensor %1s has indicated a power save state.",
812 + "PLAT0556": "Sensor %1s has indicated an install error.",
813 + "PLAT0558": "Redundancy %1s has been lost.",
814 + "PLAT0560": "Redundancy %1s has been reduced.",
815 + "PLAT0561": "Redundancy %1s has been restored.",
816 + "PLAT0562": "%1s has transitioned to a D0 power state.",
817 + "PLAT0564": "%1s has transitioned to a D1 power state.",
818 + "PLAT0566": "%1s has transitioned to a D2 power state.",
819 + "PLAT0568": "%1s has transitioned to a D3 power state.",
820 + "PLAT0720": "The System %1s encountered firmware progress - memory initialization entry.",
821 + "PLAT0721": "The System %1s encountered firmware progress - memory initialization exit.",
822 + "PLAT0722": "The System %1s encountered firmware progress - hard drive initialization entry.",
823 + "PLAT0723": "The System %1s encountered firmware progress - hard drive initialization exit.",
824 + "PLAT0724": "The System %1s encountered firmware progress - user authentication.",
825 + "PLAT0728": "The System %1s encountered firmware progress - USR resource configuration entry.",
826 + "PLAT0729": "The System %1s encountered firmware progress - USR resource configuration exit.",
827 + "PLAT0730": "The System %1s encountered firmware progress - PCI recource configuration entry.",
828 + "PLAT0731": "The System %1s encountered firmware progress - PCI recource configuration exit.",
829 + "PLAT0732": "The System %1s encountered firmware progress - Option ROM initialization entry.",
830 + "PLAT0733": "The System %1s encountered firmware progress - Option ROM initialization entry exit.",
831 + "PLAT0734": "The System %1s encountered firmware progress -video initialization entry entry.",
832 + "PLAT0735": "The System %1s encountered firmware progress - video initialization entry exit.",
833 + "PLAT0736": "The System %1s encountered firmware progress - cache initialization entry.",
834 + "PLAT0737": "The System %1s encountered firmware progress - cache initialization exit.",
835 + "PLAT0738": "The System %1s encountered firmware progress - keyboard controller initialization entry.",
836 + "PLAT0739": "The System %1s encountered firmware progress - keyboard controller initialization exit.",
837 + "PLAT0740": "The System %1s encountered firmware progress - motherboard initialization entry.",
838 + "PLAT0741": "The System %1s encountered firmware progress - motherboard initialization exit.",
839 + "PLAT0742": "The System %1s encountered firmware progress - floppy disk initialization entry.",
840 + "PLAT0743": "The System %1s encountered firmware progress - floppy disk initialization exit.",
841 + "PLAT0744": "The System %1s encountered firmware progress - keyboard test entry.",
842 + "PLAT0745": "The System %1s encountered firmware progress - keyboard test exit.",
843 + "PLAT0746": "The System %1s encountered firmware progress - pointing device test entry.",
844 + "PLAT0747": "The System %1s encountered firmware progress - pointing device test exit.",
845 + "PLAT0750": "The System %1s encountered firmware progress - dock enable entry.",
846 + "PLAT0751": "The System %1s encountered firmware progress - dock enable exit.",
847 + "PLAT0752": "The System %1s encountered firmware progress - dock disable entry.",
848 + "PLAT0753": "The System %1s encountered firmware progress - dock disable exit.",
849 + "PLAT0760": "The System %1s encountered firmware progress - start OS boot process.",
850 + "PLAT0762": "The System %1s encountered firmware progress - call OS wake vector.",
851 + "PLAT0764": "The System %1s encountered firmware progress - unrecoverable keyboard failure.",
852 + "PLAT0766": "The System %1s encountered firmware progress - no video device detected.",
853 + "PLAT0768": "The System %1s encountered firmware progress - SMART alert detected on drive.",
854 + "PLAT0770": "The System %1s encountered firmware progress - unrecoverable boot device failure.",
855 + "PLAT0789": "Corrupt BIOS detected.",
856 + "PLAT0790": "The System %1s encountered PCI configuration failure.",
857 + "PLAT0791": "The System %1s encountered a video subsystem failure.",
858 + "PLAT0792": "The System %1s encountered a storage subsystem failure.",
859 + "PLAT0793": "The System %1s encountered a USB subsystem failure.",
860 + "PLAT0794": "The System %1s has detected no memory in the system.",
861 + "PLAT0795": "The System %1s encountered a motherboard failure.",
862 + "PLAT0796": "The System %1s encountered a memory Regulator Voltage Bad.",
863 + "PLAT0797": "%1s PCI reset is not deasserting.",
864 + "PLAT0798": "%1s Non-Motherboard Regulator Failure.",
865 + "PLAT0799": "%1s Power Supply Cable failure.",
866 + "PLAT0800": "%1s Motherboard regulator failure.",
867 + "PLAT0801": "%1s System component compatibility mismatch."
868 +}
869 +
870 module.exports = lme_heci;
agents/modules_meshcmd/amt-wsman.js
+3 -134
@@ -26,13 +26,14 @@ function WsmanStackCreateService(CreateWsmanComm, host, port, user, pass, tls, e
26 //obj.onDebugMessage = null; // Set to a function if you want to get debug messages.
27 obj.NextMessageId = 1; // Next message number, used to label WSMAN calls.
28 obj.Address = '/wsman';
29 - obj.comm = new CreateWsmanComm(host, port, user, pass, tls, extra);
29 + obj.xmlParser = require('amt-xml');
30 + if (CreateWsmanComm) { obj.comm = new CreateWsmanComm(host, port, user, pass, tls, extra); }
31
32 obj.PerformAjax = function (postdata, callback, tag, pri, namespaces) {
33 if (namespaces == null) namespaces = '';
34 obj.comm.PerformAjax('<?xml version=\"1.0\" encoding=\"utf-8\"?><Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:w="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd" xmlns=\"http://www.w3.org/2003/05/soap-envelope\" ' + namespaces + '><Header><a:Action>' + postdata, function (data, status, tag) {
35 if (status != 200) { callback(obj, null, { Header: { HttpError: status } }, status, tag); return; }
35 - var wsresponse = obj.ParseWsman(data);
36 + var wsresponse = obj.xmlParser.ParseWsman(data);
37 if (!wsresponse || wsresponse == null) { callback(obj, null, { Header: { HttpError: status } }, 601, tag); } else { callback(obj, wsresponse.Header["ResourceURI"], wsresponse, 200, tag); }
38 }, tag, pri);
39 }
@@ -112,58 +113,6 @@ function WsmanStackCreateService(CreateWsmanComm, host, port, user, pass, tls, e
113 obj.PerformAjax("http://schemas.xmlsoap.org/ws/2004/09/enumeration/Pull</a:Action><a:To>" + obj.Address + "</a:To><w:ResourceURI>" + resuri + "</w:ResourceURI><a:MessageID>" + (obj.NextMessageId++) + "</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout></Header><Body><Pull xmlns=\"http://schemas.xmlsoap.org/ws/2004/09/enumeration\"><EnumerationContext>" + enumctx + "</EnumerationContext><MaxElements>999</MaxElements><MaxCharacters>99999</MaxCharacters></Pull></Body></Envelope>", callback, tag, pri);
114 }
115
115 - // Private method
116 - obj.ParseWsman = function (xml) {
117 - try {
118 - if (!xml.childNodes) xml = _turnToXml(xml);
119 - var r = { Header:{} }, header = xml.getElementsByTagName("Header")[0], t;
120 - if (!header) header = xml.getElementsByTagName("a:Header")[0];
121 - if (!header) return null;
122 - for (var i = 0; i < header.childNodes.length; i++) {
123 - var child = header.childNodes[i];
124 - r.Header[child.localName] = child.textContent;
125 - }
126 - var body = xml.getElementsByTagName("Body")[0];
127 - if (!body) body = xml.getElementsByTagName("a:Body")[0];
128 - if (!body) return null;
129 - if (body.childNodes.length > 0) {
130 - t = body.childNodes[0].localName;
131 - if (t.indexOf("_OUTPUT") == t.length - 7) { t = t.substring(0, t.length - 7); }
132 - r.Header['Method'] = t;
133 - r.Body = _ParseWsmanRec(body.childNodes[0]);
134 - }
135 - return r;
136 - } catch (e) {
137 - console.log("Unable to parse XML: " + xml);
138 - return null;
139 - }
140 - }
141 -
142 - // Private method
143 - function _ParseWsmanRec(node) {
144 - var data, r = {};
145 - for (var i = 0; i < node.childNodes.length; i++) {
146 - var child = node.childNodes[i];
147 - if ((child.childElementCount == null) || (child.childElementCount == 0)) { data = child.textContent; } else { data = _ParseWsmanRec(child); }
148 - if (data == 'true') data = true; // Convert 'true' into true
149 - if (data == 'false') data = false; // Convert 'false' into false
150 - if ((parseInt(data) + '') === data) data = parseInt(data); // Convert integers
151 -
152 - var childObj = data;
153 - if ((child.attributes != null) && (child.attributes.length > 0)) {
154 - childObj = { 'Value': data };
155 - for(var j = 0; j < child.attributes.length; j++) {
156 - childObj['@' + child.attributes[j].name] = child.attributes[j].value;
157 - }
158 - }
159 -
160 - if (r[child.localName] instanceof Array) { r[child.localName].push(childObj); }
161 - else if (r[child.localName] == null) { r[child.localName] = childObj; }
162 - else { r[child.localName] = [r[child.localName], childObj]; }
163 - }
164 - return r;
165 - }
166 -
116 function _PutObjToBodyXml(resuri, putObj) {
117 if (!resuri || putObj == null) return '';
118 var objname = obj.GetNameFromUrl(resuri);
@@ -246,86 +195,6 @@ function WsmanStackCreateService(CreateWsmanComm, host, port, user, pass, tls, e
195 return result;
196 }
197
249 - // This is a drop-in replacement to _turnToXml() that works without xml parser dependency.
250 - Object.defineProperty(Array.prototype, "peek", { value: function () { return (this.length > 0 ? this[this.length - 1] : null); } });
251 - function _treeBuilder() {
252 - this.tree = [];
253 - this.push = function (element) { this.tree.push(element); };
254 - this.pop = function () { var element = this.tree.pop(); if (this.tree.length > 0) { var x = this.tree.peek(); x.childNodes.push(element); x.childElementCount = x.childNodes.length; } return (element); };
255 - this.peek = function () { return (this.tree.peek()); }
256 - this.addNamespace = function (prefix, namespace) { this.tree.peek().nsTable[prefix] = namespace; if (this.tree.peek().attributes.length > 0) { for (var i = 0; i < this.tree.peek().attributes; ++i) { var a = this.tree.peek().attributes[i]; if (prefix == '*' && a.name == a.localName) { a.namespace = namespace; } else if (prefix != '*' && a.name != a.localName) { var pfx = a.name.split(':')[0]; if (pfx == prefix) { a.namespace = namespace; } } } } }
257 - this.getNamespace = function (prefix) { for (var i = this.tree.length - 1; i >= 0; --i) { if (this.tree[i].nsTable[prefix] != null) { return (this.tree[i].nsTable[prefix]); } } return null; }
258 - }
259 - function _turnToXml(text) { if (text == null) return null; return ({ childNodes: [_turnToXmlRec(text)], getElementsByTagName: _getElementsByTagName, getChildElementsByTagName: _getChildElementsByTagName, getElementsByTagNameNS: _getElementsByTagNameNS }); }
260 - function _getElementsByTagNameNS(ns, name) { var ret = []; _xmlTraverseAllRec(this.childNodes, function (node) { if (node.localName == name && (node.namespace == ns || ns == '*')) { ret.push(node); } }); return ret; }
261 - function _getElementsByTagName(name) { var ret = []; _xmlTraverseAllRec(this.childNodes, function (node) { if (node.localName == name) { ret.push(node); } }); return ret; }
262 - function _getChildElementsByTagName(name) { var ret = []; if (this.childNodes != null) { for (var node in this.childNodes) { if (this.childNodes[node].localName == name) { ret.push(this.childNodes[node]); } } } return (ret); }
263 - function _getChildElementsByTagNameNS(ns, name) { var ret = []; if (this.childNodes != null) { for (var node in this.childNodes) { if (this.childNodes[node].localName == name && (ns == '*' || this.childNodes[node].namespace == ns)) { ret.push(this.childNodes[node]); } } } return (ret); }
264 - function _xmlTraverseAllRec(nodes, func) { for (var i in nodes) { func(nodes[i]); if (nodes[i].childNodes) { _xmlTraverseAllRec(nodes[i].childNodes, func); } } }
265 - function _turnToXmlRec(text) {
266 - var elementStack = new _treeBuilder(), lastElement = null, x1 = text.split('<'), ret = [], element = null, currentElementName = null;
267 - for (var i in x1) {
268 - var x2 = x1[i].split('>'), x3 = x2[0].split(' '), elementName = x3[0];
269 - if ((elementName.length > 0) && (elementName[0] != '?')) {
270 - if (elementName[0] != '/') {
271 - var attributes = [], localName, localname2 = elementName.split(' ')[0].split(':'), localName = (localname2.length > 1) ? localname2[1] : localname2[0];
272 - Object.defineProperty(attributes, "get",
273 - {
274 - value: function () {
275 - if (arguments.length == 1) {
276 - for (var a in this) { if (this[a].name == arguments[0]) { return (this[a]); } }
277 - }
278 - else if (arguments.length == 2) {
279 - for (var a in this) { if (this[a].name == arguments[1] && (arguments[0] == '*' || this[a].namespace == arguments[0])) { return (this[a]); } }
280 - }
281 - else {
282 - throw ('attributes.get(): Invalid number of parameters');
283 - }
284 - }
285 - });
286 - elementStack.push({ name: elementName, localName: localName, getChildElementsByTagName: _getChildElementsByTagName, getElementsByTagNameNS: _getElementsByTagNameNS, getChildElementsByTagNameNS: _getChildElementsByTagNameNS, attributes: attributes, childNodes: [], nsTable: {} });
287 - // Parse Attributes
288 - if (x3.length > 0) {
289 - var skip = false;
290 - for (var j in x3) {
291 - if (x3[j] == '/') {
292 - // This is an empty Element
293 - elementStack.peek().namespace = elementStack.peek().name == elementStack.peek().localName ? elementStack.getNamespace('*') : elementStack.getNamespace(elementStack.peek().name.substring(0, elementStack.peek().name.indexOf(':')));
294 - elementStack.peek().textContent = '';
295 - lastElement = elementStack.pop();
296 - skip = true;
297 - break;
298 - }
299 - var k = x3[j].indexOf('=');
300 - if (k > 0) {
301 - var attrName = x3[j].substring(0, k);
302 - var attrValue = x3[j].substring(k + 2, x3[j].length - 1);
303 - var attrNS = elementStack.getNamespace('*');
304 -
305 - if (attrName == 'xmlns') {
306 - elementStack.addNamespace('*', attrValue);
307 - attrNS = attrValue;
308 - } else if (attrName.startsWith('xmlns:')) {
309 - elementStack.addNamespace(attrName.substring(6), attrValue);
310 - } else {
311 - var ax = attrName.split(':');
312 - if (ax.length == 2) { attrName = ax[1]; attrNS = elementStack.getNamespace(ax[0]); }
313 - }
314 - var x = { name: attrName, value: attrValue }
315 - if (attrNS != null) x.namespace = attrNS;
316 - elementStack.peek().attributes.push(x);
317 - }
318 - }
319 - if (skip) { continue; }
320 - }
321 - elementStack.peek().namespace = elementStack.peek().name == elementStack.peek().localName ? elementStack.getNamespace('*') : elementStack.getNamespace(elementStack.peek().name.substring(0, elementStack.peek().name.indexOf(':')));
322 - if (x2[1]) { elementStack.peek().textContent = x2[1]; }
323 - } else { lastElement = elementStack.pop(); }
324 - }
325 - }
326 - return lastElement;
327 - }
328 -
198 return obj;
199 }
200
agents/modules_meshcmd/amt-xml.js new
+168
@@ -0,0 +1,168 @@
1 +
2 +// Parse XML and return JSON
3 +module.exports.ParseWsman = function (xml) {
4 + try {
5 + if (!xml.childNodes) xml = _turnToXml(xml);
6 + var r = { Header: {} }, header = xml.getElementsByTagName("Header")[0], t;
7 + if (!header) header = xml.getElementsByTagName("a:Header")[0];
8 + if (!header) return null;
9 + for (var i = 0; i < header.childNodes.length; i++) {
10 + var child = header.childNodes[i];
11 + r.Header[child.localName] = child.textContent;
12 + }
13 + var body = xml.getElementsByTagName("Body")[0];
14 + if (!body) body = xml.getElementsByTagName("a:Body")[0];
15 + if (!body) return null;
16 + if (body.childNodes.length > 0) {
17 + t = body.childNodes[0].localName;
18 + if (t.indexOf("_OUTPUT") == t.length - 7) { t = t.substring(0, t.length - 7); }
19 + r.Header['Method'] = t;
20 + r.Body = _ParseWsmanRec(body.childNodes[0]);
21 + }
22 + return r;
23 + } catch (e) {
24 + console.log("Unable to parse XML: " + xml);
25 + return null;
26 + }
27 +}
28 +
29 +// Private method
30 +function _ParseWsmanRec(node) {
31 + var data, r = {};
32 + for (var i = 0; i < node.childNodes.length; i++) {
33 + var child = node.childNodes[i];
34 + if ((child.childElementCount == null) || (child.childElementCount == 0)) { data = child.textContent; } else { data = _ParseWsmanRec(child); }
35 + if (data == 'true') data = true; // Convert 'true' into true
36 + if (data == 'false') data = false; // Convert 'false' into false
37 + if ((parseInt(data) + '') === data) data = parseInt(data); // Convert integers
38 +
39 + var childObj = data;
40 + if ((child.attributes != null) && (child.attributes.length > 0)) {
41 + childObj = { 'Value': data };
42 + for (var j = 0; j < child.attributes.length; j++) {
43 + childObj['@' + child.attributes[j].name] = child.attributes[j].value;
44 + }
45 + }
46 +
47 + if (r[child.localName] instanceof Array) { r[child.localName].push(childObj); }
48 + else if (r[child.localName] == null) { r[child.localName] = childObj; }
49 + else { r[child.localName] = [r[child.localName], childObj]; }
50 + }
51 + return r;
52 +}
53 +
54 +function _PutObjToBodyXml(resuri, putObj) {
55 + if (!resuri || putObj == null) return '';
56 + var objname = obj.GetNameFromUrl(resuri);
57 + var result = '<r:' + objname + ' xmlns:r="' + resuri + '">';
58 +
59 + for (var prop in putObj) {
60 + if (!putObj.hasOwnProperty(prop) || prop.indexOf('__') === 0 || prop.indexOf('@') === 0) continue;
61 + if (putObj[prop] == null || typeof putObj[prop] === 'function') continue;
62 + if (typeof putObj[prop] === 'object' && putObj[prop]['ReferenceParameters']) {
63 + result += '<r:' + prop + '><a:Address>' + putObj[prop].Address + '</a:Address><a:ReferenceParameters><w:ResourceURI>' + putObj[prop]['ReferenceParameters']["ResourceURI"] + '</w:ResourceURI><w:SelectorSet>';
64 + var selectorArray = putObj[prop]['ReferenceParameters']['SelectorSet']['Selector'];
65 + if (Array.isArray(selectorArray)) {
66 + for (var i = 0; i < selectorArray.length; i++) {
67 + result += '<w:Selector' + _ObjectToXmlAttributes(selectorArray[i]) + '>' + selectorArray[i]['Value'] + '</w:Selector>';
68 + }
69 + }
70 + else {
71 + result += '<w:Selector' + _ObjectToXmlAttributes(selectorArray) + '>' + selectorArray['Value'] + '</w:Selector>';
72 + }
73 + result += '</w:SelectorSet></a:ReferenceParameters></r:' + prop + '>';
74 + }
75 + else {
76 + if (Array.isArray(putObj[prop])) {
77 + for (var i = 0; i < putObj[prop].length; i++) {
78 + result += '<r:' + prop + '>' + putObj[prop][i].toString() + '</r:' + prop + '>';
79 + }
80 + } else {
81 + result += '<r:' + prop + '>' + putObj[prop].toString() + '</r:' + prop + '>';
82 + }
83 + }
84 + }
85 +
86 + result += '</r:' + objname + '>';
87 + return result;
88 +}
89 +
90 +// This is a drop-in replacement to _turnToXml() that works without xml parser dependency.
91 +Object.defineProperty(Array.prototype, "peek", { value: function () { return (this.length > 0 ? this[this.length - 1] : null); } });
92 +function _treeBuilder() {
93 + this.tree = [];
94 + this.push = function (element) { this.tree.push(element); };
95 + this.pop = function () { var element = this.tree.pop(); if (this.tree.length > 0) { var x = this.tree.peek(); x.childNodes.push(element); x.childElementCount = x.childNodes.length; } return (element); };
96 + this.peek = function () { return (this.tree.peek()); }
97 + this.addNamespace = function (prefix, namespace) { this.tree.peek().nsTable[prefix] = namespace; if (this.tree.peek().attributes.length > 0) { for (var i = 0; i < this.tree.peek().attributes; ++i) { var a = this.tree.peek().attributes[i]; if (prefix == '*' && a.name == a.localName) { a.namespace = namespace; } else if (prefix != '*' && a.name != a.localName) { var pfx = a.name.split(':')[0]; if (pfx == prefix) { a.namespace = namespace; } } } } }
98 + this.getNamespace = function (prefix) { for (var i = this.tree.length - 1; i >= 0; --i) { if (this.tree[i].nsTable[prefix] != null) { return (this.tree[i].nsTable[prefix]); } } return null; }
99 +}
100 +function _turnToXml(text) { if (text == null) return null; return ({ childNodes: [_turnToXmlRec(text)], getElementsByTagName: _getElementsByTagName, getChildElementsByTagName: _getChildElementsByTagName, getElementsByTagNameNS: _getElementsByTagNameNS }); }
101 +function _getElementsByTagNameNS(ns, name) { var ret = []; _xmlTraverseAllRec(this.childNodes, function (node) { if (node.localName == name && (node.namespace == ns || ns == '*')) { ret.push(node); } }); return ret; }
102 +function _getElementsByTagName(name) { var ret = []; _xmlTraverseAllRec(this.childNodes, function (node) { if (node.localName == name) { ret.push(node); } }); return ret; }
103 +function _getChildElementsByTagName(name) { var ret = []; if (this.childNodes != null) { for (var node in this.childNodes) { if (this.childNodes[node].localName == name) { ret.push(this.childNodes[node]); } } } return (ret); }
104 +function _getChildElementsByTagNameNS(ns, name) { var ret = []; if (this.childNodes != null) { for (var node in this.childNodes) { if (this.childNodes[node].localName == name && (ns == '*' || this.childNodes[node].namespace == ns)) { ret.push(this.childNodes[node]); } } } return (ret); }
105 +function _xmlTraverseAllRec(nodes, func) { for (var i in nodes) { func(nodes[i]); if (nodes[i].childNodes) { _xmlTraverseAllRec(nodes[i].childNodes, func); } } }
106 +function _turnToXmlRec(text) {
107 + var elementStack = new _treeBuilder(), lastElement = null, x1 = text.split('<'), ret = [], element = null, currentElementName = null;
108 + for (var i in x1) {
109 + var x2 = x1[i].split('>'), x3 = x2[0].split(' '), elementName = x3[0];
110 + if ((elementName.length > 0) && (elementName[0] != '?')) {
111 + if (elementName[0] != '/') {
112 + var attributes = [], localName, localname2 = elementName.split(' ')[0].split(':'), localName = (localname2.length > 1) ? localname2[1] : localname2[0];
113 + Object.defineProperty(attributes, "get",
114 + {
115 + value: function () {
116 + if (arguments.length == 1) {
117 + for (var a in this) { if (this[a].name == arguments[0]) { return (this[a]); } }
118 + }
119 + else if (arguments.length == 2) {
120 + for (var a in this) { if (this[a].name == arguments[1] && (arguments[0] == '*' || this[a].namespace == arguments[0])) { return (this[a]); } }
121 + }
122 + else {
123 + throw ('attributes.get(): Invalid number of parameters');
124 + }
125 + }
126 + });
127 + elementStack.push({ name: elementName, localName: localName, getChildElementsByTagName: _getChildElementsByTagName, getElementsByTagNameNS: _getElementsByTagNameNS, getChildElementsByTagNameNS: _getChildElementsByTagNameNS, attributes: attributes, childNodes: [], nsTable: {} });
128 + // Parse Attributes
129 + if (x3.length > 0) {
130 + var skip = false;
131 + for (var j in x3) {
132 + if (x3[j] == '/') {
133 + // This is an empty Element
134 + elementStack.peek().namespace = elementStack.peek().name == elementStack.peek().localName ? elementStack.getNamespace('*') : elementStack.getNamespace(elementStack.peek().name.substring(0, elementStack.peek().name.indexOf(':')));
135 + elementStack.peek().textContent = '';
136 + lastElement = elementStack.pop();
137 + skip = true;
138 + break;
139 + }
140 + var k = x3[j].indexOf('=');
141 + if (k > 0) {
142 + var attrName = x3[j].substring(0, k);
143 + var attrValue = x3[j].substring(k + 2, x3[j].length - 1);
144 + var attrNS = elementStack.getNamespace('*');
145 +
146 + if (attrName == 'xmlns') {
147 + elementStack.addNamespace('*', attrValue);
148 + attrNS = attrValue;
149 + } else if (attrName.startsWith('xmlns:')) {
150 + elementStack.addNamespace(attrName.substring(6), attrValue);
151 + } else {
152 + var ax = attrName.split(':');
153 + if (ax.length == 2) { attrName = ax[1]; attrNS = elementStack.getNamespace(ax[0]); }
154 + }
155 + var x = { name: attrName, value: attrValue }
156 + if (attrNS != null) x.namespace = attrNS;
157 + elementStack.peek().attributes.push(x);
158 + }
159 + }
160 + if (skip) { continue; }
161 + }
162 + elementStack.peek().namespace = elementStack.peek().name == elementStack.peek().localName ? elementStack.getNamespace('*') : elementStack.getNamespace(elementStack.peek().name.substring(0, elementStack.peek().name.indexOf(':')));
163 + if (x2[1]) { elementStack.peek().textContent = x2[1]; }
164 + } else { lastElement = elementStack.pop(); }
165 + }
166 + }
167 + return lastElement;
168 +}
agents/modules_meshcore/amt-lme.js
+570 -24
@@ -15,10 +15,11 @@ limitations under the License.
15 */
16
17 var MemoryStream = require('MemoryStream');
18 -var lme_id = 0;
19 -var lme_port_offset = 0; // Debug: Set this to "-100" to bind to 16892 & 16893 and IN_ADDRANY. This is for LMS debugging.
20 -
18 +var lme_id = 0; // Our next channel identifier
19 +var lme_port_offset = 0; // Debug: Set this to "-100" to bind to 16892 & 16893 and IN_ADDRANY. This is for LMS debugging.
20 +var xmlParser = require('amt-xml');
21
22 +// Documented in: https://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide/HTMLDocuments/MPSDocuments/Intel%20AMT%20Port%20Forwarding%20Protocol%20Reference%20Manual.pdf
23 var APF_DISCONNECT = 1;
24 var APF_SERVICE_REQUEST = 5;
25 var APF_SERVICE_ACCEPT = 6;
@@ -113,8 +114,9 @@ function lme_heci(options) {
114 var emitterUtils = require('events').inherits(this);
115 emitterUtils.createEvent('error');
116 emitterUtils.createEvent('connect');
117 + emitterUtils.createEvent('notify');
118
117 - if (options.debug == true) { lme_port_offset = -100; } // LMS debug mode
119 + if ((options != null) && (options.debug == true)) { lme_port_offset = -100; } // LMS debug mode
120
121 var heci = require('heci');
122 this.INITIAL_RXWINDOW_SIZE = 4096;
@@ -127,11 +129,11 @@ function lme_heci(options) {
129 this.on('data', function (chunk) {
130 // this = HECI
131 var cmd = chunk.readUInt8(0);
132 + //console.log('LME Command ' + cmd + ', ' + chunk.length + ' byte(s).');
133
134 switch (cmd) {
135 default:
133 - //console.log('Received ' + chunk.length + ' bytes of data for LMS');
134 - //console.log('Command = ' + cmd);
136 + console.log('Unhandled LME Command ' + cmd + ', ' + chunk.length + ' byte(s).');
137 break;
138 case APF_SERVICE_REQUEST:
139 var nameLen = chunk.readUInt32BE(1);
@@ -151,34 +153,46 @@ function lme_heci(options) {
153 case APF_GLOBAL_REQUEST:
154 var nameLen = chunk.readUInt32BE(1);
155 var name = chunk.slice(5, nameLen + 5).toString();
154 -
156 +
157 switch (name) {
158 case 'tcpip-forward':
159 var len = chunk.readUInt32BE(nameLen + 6);
160 var port = chunk.readUInt32BE(nameLen + 10 + len);
161 //console.log("[" + chunk.length + "/" + len + "] APF_GLOBAL_REQUEST for: " + name + " on port " + port);
160 - if (this[name] == undefined) {
161 - this[name] = {};
162 + if (this[name] == undefined) { this[name] = {}; }
163 + if (this[name][port] != null) { // Close the existing binding
164 + for (var i in this.sockets) {
165 + var channel = this.sockets[i];
166 + if (channel.localPort == port) { this.sockets[i].end(); delete this.sockets[i]; } // Close this socket
167 + }
168 }
163 - this[name][port] = require('net').createServer();
164 - this[name][port].HECI = this;
165 - if (lme_port_offset == 0) {
166 - this[name][port].listen({ port: port, host: '127.0.0.1' }); // Normal mode
167 - } else {
168 - this[name][port].listen({ port: (port + lme_port_offset) }); // Debug mode
169 + if (this[name][port] == null) { // Bind a new server socket if not already present
170 + this[name][port] = require('net').createServer();
171 + this[name][port].HECI = this;
172 + if (lme_port_offset == 0) {
173 + this[name][port].listen({ port: port, host: '127.0.0.1' }); // Normal mode
174 + } else {
175 + this[name][port].listen({ port: (port + lme_port_offset) }); // Debug mode
176 + }
177 + this[name][port].on('connection', function (socket) {
178 + //console.log('New [' + socket.remoteFamily + '] TCP Connection on: ' + socket.remoteAddress + ' :' + socket.localPort);
179 + this.HECI.LMS.bindDuplexStream(socket, socket.remoteFamily, socket.localPort - lme_port_offset);
180 + });
181 }
170 - this[name][port].on('connection', function (socket) {
171 - //console.log('New [' + socket.remoteFamily + '] TCP Connection on: ' + socket.remoteAddress + ' :' + socket.localPort);
172 - this.HECI.LMS.bindDuplexStream(socket, socket.remoteFamily, socket.localPort - lme_port_offset);
173 - });
182 var outBuffer = Buffer.alloc(5);
183 outBuffer.writeUInt8(81, 0);
184 outBuffer.writeUInt32BE(port, 1);
185 this.write(outBuffer);
186 break;
187 case 'cancel-tcpip-forward':
188 + var outBuffer = Buffer.alloc(1);
189 + outBuffer.writeUInt8(APF_REQUEST_SUCCESS, 0);
190 + this.write(outBuffer);
191 break;
192 case 'udp-send-to@amt.intel.com':
193 + var outBuffer = Buffer.alloc(1);
194 + outBuffer.writeUInt8(APF_REQUEST_FAILURE, 0);
195 + this.write(outBuffer);
196 break;
197 default:
198 //console.log("Unknown APF_GLOBAL_REQUEST for: " + name);
@@ -247,25 +261,59 @@ function lme_heci(options) {
261 this.sockets[rChannelId].bufferedStream.emit('readable');
262 }
263 } else {
250 - //console.log('Unknown Recipient ID/' + rChannelId + ' for APF_CHANNEL_WINDOW_ADJUST');
264 + console.log('Unknown Recipient ID/' + rChannelId + ' for APF_CHANNEL_WINDOW_ADJUST');
265 }
266 break;
267 case APF_CHANNEL_DATA:
268 var rChannelId = chunk.readUInt32BE(1);
269 var dataLen = chunk.readUInt32BE(5);
270 var data = chunk.slice(9, 9 + dataLen);
257 - if (this.sockets[rChannelId] != undefined) {
271 + if ((this.sockets != null) && (this.sockets[rChannelId] != undefined)) {
272 this.sockets[rChannelId].pendingBytes.push(data.length);
273 this.sockets[rChannelId].write(data, function () {
274 var written = this.pendingBytes.shift();
275 + //console.log('adjust', this.lme.amtId, written);
276 var outBuffer = Buffer.alloc(9);
277 outBuffer.writeUInt8(APF_CHANNEL_WINDOW_ADJUST, 0);
278 outBuffer.writeUInt32BE(this.lme.amtId, 1);
279 outBuffer.writeUInt32BE(written, 5);
280 this.HECI.write(outBuffer);
281 });
282 + } else if ((this.insockets != null) && (this.insockets[rChannelId] != undefined)) {
283 + var channel = this.insockets[rChannelId];
284 + if (channel.data == null) { channel.data = data.toString(); } else { channel.data += data.toString(); }
285 + channel.rxWindow += dataLen;
286 + //console.log('IN DATA', channel.rxWindow, channel.data.length, dataLen, channel.amtId, data.toString());
287 + var httpData = parseHttp(channel.data);
288 + if ((httpData != null) || (channel.data.length >= 8000)) {
289 + // Parse the WSMAN
290 + var notify = null;
291 + try { notify = xmlParser.ParseWsman(httpData); } catch (e) { }
292 +
293 + // Translate the event
294 + var notifyString = _lmsNotifyToString(notify);
295 +
296 + // Event the http data
297 + if (notify != null) { this.LMS.emit('notify', notify, channel.options, notifyString); }
298 +
299 + // Send channel close
300 + var buffer = Buffer.alloc(5);
301 + buffer.writeUInt8(APF_CHANNEL_CLOSE, 0);
302 + buffer.writeUInt32BE(amtId, 1);
303 + this.write(buffer);
304 + } else {
305 + if (channel.rxWindow > 6000) {
306 + // Send window adjust
307 + var buffer = Buffer.alloc(9);
308 + buffer.writeUInt8(APF_CHANNEL_WINDOW_ADJUST, 0);
309 + buffer.writeUInt32BE(channel.amtId, 1);
310 + buffer.writeUInt32BE(channel.rxWindow, 5);
311 + this.write(buffer);
312 + channel.rxWindow = 0;
313 + }
314 + }
315 } else {
268 - //console.log('Unknown Recipient ID/' + rChannelId + ' for APF_CHANNEL_DATA');
316 + console.log('Unknown Recipient ID/' + rChannelId + ' for APF_CHANNEL_DATA');
317 }
318 break;
319 case APF_CHANNEL_CLOSE:
@@ -276,12 +324,58 @@ function lme_heci(options) {
324 var buffer = Buffer.alloc(5);
325 delete this.sockets[rChannelId];
326
279 - buffer.writeUInt8(APF_CHANNEL_CLOSE, 0);
327 + buffer.writeUInt8(APF_CHANNEL_CLOSE, 0); // ????????????????????????????
328 buffer.writeUInt32BE(amtId, 1);
329 this.write(buffer);
330 + } else if ((this.insockets != null) && (this.insockets[rChannelId] != undefined)) {
331 + delete this.insockets[rChannelId];
332 + // Should I send a close back????
333 } else {
283 - //console.log('Unknown Recipient ID/' + rChannelId + ' for APF_CHANNEL_CLOSE');
334 + console.log('Unknown Recipient ID/' + rChannelId + ' for APF_CHANNEL_CLOSE');
335 }
336 + break;
337 + case APF_CHANNEL_OPEN:
338 + var nameLen = chunk.readUInt32BE(1);
339 + var name = chunk.slice(5, nameLen + 5).toString();
340 + var channelSender = chunk.readUInt32BE(nameLen + 5);
341 + var initialWindowSize = chunk.readUInt32BE(nameLen + 9);
342 + var hostToConnectLen = chunk.readUInt32BE(nameLen + 17);
343 + var hostToConnect = chunk.slice(nameLen + 21, nameLen + 21 + hostToConnectLen).toString();
344 + var portToConnect = chunk.readUInt32BE(nameLen + 21 + hostToConnectLen);
345 + var originatorIpLen = chunk.readUInt32BE(nameLen + 25 + hostToConnectLen);
346 + var originatorIp = chunk.slice(nameLen + 29 + hostToConnectLen, nameLen + 29 + hostToConnectLen + originatorIpLen).toString();
347 + var originatorPort = chunk.readUInt32BE(nameLen + 29 + hostToConnectLen + originatorIpLen);
348 + //console.log('APF_CHANNEL_OPEN', name, channelSender, initialWindowSize, 'From: ' + originatorIp + ':' + originatorPort, 'To: ' + hostToConnect + ':' + portToConnect);
349 +
350 + if (this.insockets == null) { this.insockets = {}; }
351 + var ourId = ++lme_id;
352 + var insocket = new lme_object();
353 + insocket.ourId = ourId;
354 + insocket.amtId = channelSender;
355 + insocket.txWindow = initialWindowSize;
356 + insocket.rxWindow = 0;
357 + insocket.options = { target: hostToConnect, targetPort: portToConnect, source: originatorIp, sourcePort: originatorPort };
358 + this.insockets[ourId] = insocket;
359 +
360 + var buffer = Buffer.alloc(17);
361 + buffer.writeUInt8(APF_CHANNEL_OPEN_CONFIRMATION, 0);
362 + buffer.writeUInt32BE(channelSender, 1); // Intel AMT sender channel
363 + buffer.writeUInt32BE(ourId, 5); // Our receiver channel id
364 + buffer.writeUInt32BE(4000, 9); // Initial Window Size
365 + buffer.writeUInt32BE(0xFFFFFFFF, 13); // Reserved
366 + this.write(buffer);
367 +
368 + /*
369 + var buffer = Buffer.alloc(17);
370 + buffer.writeUInt8(APF_CHANNEL_OPEN_FAILURE, 0);
371 + buffer.writeUInt32BE(channelSender, 1); // Intel AMT sender channel
372 + buffer.writeUInt32BE(2, 5); // Reason code
373 + buffer.writeUInt32BE(0, 9); // Reserved
374 + buffer.writeUInt32BE(0, 13); // Reserved
375 + this.write(buffer);
376 + console.log('Sent APF_CHANNEL_OPEN_FAILURE', channelSender);
377 + */
378 +
379 break;
380 }
381 });
@@ -295,6 +389,7 @@ function lme_heci(options) {
389 socket.LMS = this;
390 socket.lme = new lme_object();
391 socket.lme.Socket = socket;
392 + socket.localPort = localPort;
393 var buffer = new MemoryStream();
394 buffer.writeUInt8(0x5A);
395 buffer.writeUInt32BE(15);
@@ -321,4 +416,455 @@ function lme_heci(options) {
416 this._LME.connect(heci.GUIDS.LME, { noPipeline: 0 });
417 }
418
419 +function parseHttp(httpData) {
420 + var i = httpData.indexOf('\r\n\r\n');
421 + if ((i == -1) || (httpData.length < (i + 2))) { return null; }
422 + var headers = require('http-headers')(httpData.substring(0, i), true);
423 + var contentLength = parseInt(headers['content-length']);
424 + if (httpData.length >= contentLength + i + 4) { return httpData.substring(i + 4, i + 4 + contentLength); }
425 + return null;
426 +}
427 +
428 +function _lmsNotifyToString(notify) {
429 + if ((notify == null) || (notify.Body == null) || (notify.Body.MessageID == null)) return null;
430 + var msgid = notify.Body.MessageID;
431 + try { msgid += '-' + notify.Body.MessageArguments[0]; } catch (e) { }
432 + if (lmsEvents[msgid]) { return lmsEvents[msgid]; }
433 + return null;
434 +}
435 +
436 +var lmsEvents = {
437 + "iAMT0001": "System Defense Policy %1s triggered.",
438 + "iAMT0002": "Agent Presence Agent %1s not started.",
439 + "iAMT0003": "Agent Presence Agent %1s stopped.",
440 + "iAMT0004": "Agent Presence Agent %1s running.",
441 + "iAMT0005": "Agent Presence Agent %1s expired.",
442 + "iAMT0006": "Agent Presence Agent %1s suspended.",
443 + "iAMT0007": "Host software attempt to disable AMT Network link detected.",
444 + "iAMT0008": "Host software attempt to disable AMT Network link detected -- Host Network link blocked.",
445 + "iAMT0009": "AMT clock or FLASH wear-out protection disabled.",
446 + "iAMT0010": "Intel(R) AMT Network Interface %1s heuristics defense slow threshold trespassed.",
447 + "iAMT0011": "Intel(R) AMT Network Interface %1s heuristics defense fast threshold trespassed.",
448 + "iAMT0012": "Intel(R) AMT Network Interface %1s heuristics defense factory defined threshold trespassed.",
449 + "iAMT0013": "Intel(R) AMT Network Interface %1s heuristics defense Encounter timeout expired.",
450 + "iAMT0014": "General certificate error.",
451 + "iAMT0015": "Certificate expired.",
452 + "iAMT0016": "No trusted root certificate.",
453 + "iAMT0017": "Not configured to work with server certificate.",
454 + "iAMT0018": "Certificate revoked.",
455 + "iAMT0019": "RSA exponent too large.",
456 + "iAMT0020": "RSA modulus too large.",
457 + "iAMT0021": "Unsupported digest.",
458 + "iAMT0022": "Distinguished name too long.",
459 + "iAMT0023": "Key usage missing.",
460 + "iAMT0024": "General SSL handshake error.",
461 + "iAMT0025": "General 802.1x error.",
462 + "iAMT0026": "AMT Diagnostic AlertEAC error - General NAC error.",
463 + "iAMT0027": "AMT Diagnostic AlertEAC error - attempt to get a NAC posture while AMT NAC is disabled.",
464 + "iAMT0028": "AMT Diagnostic AlertEAC error - attempt to get a posture of an unsupported type.",
465 + "iAMT0029": "Audit log storage is 50% full.",
466 + "iAMT0030": "Audit log storage is 75% full.",
467 + "iAMT0031": "Audit log storage is 85% full.",
468 + "iAMT0032": "Audit log storage is 95% full.",
469 + "iAMT0033": "Audit log storage is full.",
470 + "iAMT0034": "Firmware Update Event - Partial.",
471 + "iAMT0035": "Firmware Update Event - Failure.",
472 + "iAMT0036": "Remote connectivity initiated.",
473 + "iAMT0037": "ME Presence event.",
474 + "iAMT0038-0": "AMT is being unprovisioned using BIOS command.",
475 + "iAMT0038-1": "AMT is being unprovisioned using Local MEI command.",
476 + "iAMT0038-2": "AMT is being unprovisioned using Local WS-MAN/SOAP command.",
477 + "iAMT0038-3": "AMT is being unprovisioned using Remote WS-MAN/SOAP command.",
478 + "iAMT0039": "HW Asset Error.",
479 + "iAMT0050": "User Notification Alert - General Notification.",
480 + "iAMT0050-16": "User Notification Alert - Circuit Breaker notification (CB Drop TX filter hit.).",
481 + "iAMT0050-17": "User Notification Alert - Circuit Breaker notification (CB Rate Limit TX filter hit.).",
482 + "iAMT0050-18": "User Notification Alert - Circuit Breaker notification (CB Drop RX filter hit.).",
483 + "iAMT0050-19": "User Notification Alert - Circuit Breaker notification (CB Rate Limit RX filter hit.).",
484 + "iAMT0050-32": "User Notification Alert - EAC notification.",
485 + "iAMT0050-48": "User Notification Alert - Remote diagnostics - (Remote Redirection session started - SOL).",
486 + "iAMT0050-49": "User Notification Alert - Remote diagnostics - (Remote Redirection session stopped - SOL).",
487 + "iAMT0050-50": "User Notification Alert - Remote diagnostics. (Remote Redirection session started - IDE-R).",
488 + "iAMT0050-51": "User Notification Alert - Remote diagnostics. (Remote Redirection session stopped - IDE-R).",
489 + "iAMT0050-66": "User Notification Alert - WLAN notification (Host profile mismatch - Management Interface ignored).",
490 + "iAMT0050-67": "User Notification Alert - WLAN notification (Management device overrides host radio).",
491 + "iAMT0050-68": "User Notification Alert - WLAN notification (Host profile security mismatch).",
492 + "iAMT0050-69": "User Notification Alert - WLAN notification (Management device relinquishes control over host Radio).",
493 + "iAMT0051": "User Notification Alert - SecIo event.",
494 + "iAMT0051-0": "User Notification Alert - SecIo event semaphore at host.",
495 + "iAMT0051-1": "User Notification Alert - semaphore at ME.",
496 + "iAMT0051-2": "User Notification Alert - SecIo event - semaphore timeout.",
497 + "iAMT0052": "User Notification Alert - KVM session event.",
498 + "iAMT0052-0": "User Notification Alert - KVM session requested.",
499 + "iAMT0052-1": "User Notification Alert - KVM session started.",
500 + "iAMT0052-2": "User Notification Alert - KVM session stopped.",
501 + "iAMT0053": "User Notification Alert - RCS notification.",
502 + "iAMT0053-50": "User Notification Alert - RCS notification (HW button pressed. Connection initiated automatically).",
503 + "iAMT0053-52": "User Notification Alert - RCS notification (HW button pressed. Connection wasn't initiated automatically).",
504 + "iAMT0053-53": "User Notification Alert - RCS notification (Contracts updated).",
505 + "iAMT0054": "User Notification Alert - WLAN notification. Wireless Profile sync enablement state changed.",
506 + "iAMT0055": "User Notification Alert - Provisioning state change notification.",
507 + "iAMT0055-0": "User Notification Alert - Provisioning state change notification - Pre-configuration.",
508 + "iAMT0055-1": "User Notification Alert - Provisioning state change notification - In configuration.",
509 + "iAMT0055-2": "User Notification Alert - Provisioning state change notification - Post-configuration.",
510 + "iAMT0055-3": "User Notification Alert - Provisioning state change notification - unprovision process has started.",
511 + "iAMT0056": "User Notification Alert - System Defense change notification.",
512 + "iAMT0057": "User Notification Alert - Network State change notification.",
513 + "iAMT0058": "User Notification Alert - Remote Access change notification.",
514 + "iAMT0058-1": "User Notification Alert - Remote Access change notification - tunnel is closed.",
515 + //"iAMT0058-1": "User Notification Alert - Remote Access change notification - tunnel is open.",
516 + "iAMT0059": "User Notification Alert - KVM enabled event.",
517 + "iAMT0059-0": "User Notification Alert - KVM enabled event - KVM disabled.",
518 + "iAMT0059-1": "User Notification Alert - KVM enabled event - KVM enabled (both from MEBx and PTNI).",
519 + "iAMT0060": "User Notification Alert - SecIO configuration event.",
520 + "iAMT0061": "ME FW reset occurred.",
521 + "iAMT0062": "User Notification Alert - IpSyncEnabled event.",
522 + "iAMT0062-0": "User Notification Alert - IpSyncEnabled event - IpSync disabled.",
523 + "iAMT0062-1": "User Notification Alert - IpSyncEnabled event - IpSync enabled.",
524 + "iAMT0063": "User Notification Alert - HTTP Proxy sync enabled event.",
525 + "iAMT0063-0": "User Notification Alert - HTTP Proxy sync enabled event - HTTP Proxy Sync disabled.",
526 + "iAMT0063-1": "User Notification Alert - HTTP Proxy sync enabled event - HTTP Proxy Sync enabled.",
527 + "iAMT0064": "User Notification Alert - User Consent event.",
528 + "iAMT0064-1": "User Notification Alert - User Consent event - User Consent granted.",
529 + "iAMT0064-2": "User Notification Alert - User Consent event - User Consent ended.",
530 + "iAMT0067-0": "Graceful Remote Control Operation - Shutdown.",
531 + "iAMT0067-1": "Graceful Remote Control Operation - Reset.",
532 + "iAMT0067-2": "Graceful Remote Control Operation - Hibernate.",
533 + "iAMT0068-0": "Link Protection Notification - No link protection.",
534 + "iAMT0068-1": "Link Protection Notification - Passive link protection.",
535 + "iAMT0068-2": "Link Protection Notification - High link protection.",
536 + "iAMT0069-0": "Local Time Sync Enablement Notification - Local Time Sync Disabled.",
537 + "iAMT0069-1": "Local Time Sync Enablement Notification - Local Time Sync Enabled.",
538 + "iAMT0070": "Host Reset Triggered by WD Expiration Notification.",
539 + "PLAT0004": "The chassis %1s was opened.",
540 + "PLAT0005": "The chassis %1s was closed.",
541 + "PLAT0006": "The drive bay %1s was opened.",
542 + "PLAT0007": "The drive bay %1s was closed.",
543 + "PLAT0008": "The I/O card area %1s was opened.",
544 + "PLAT0009": "The I/O card area %1s was closed.",
545 + "PLAT0010": "The processor area %1s was opened.",
546 + "PLAT0011": "The processor area %1s was closed.",
547 + "PLAT0012": "The LAN %1s has been disconnected.",
548 + "PLAT0013": "The LAN %1s has been connected.",
549 + "PLAT0016": "The permission to insert package %1s has been granted.",
550 + "PLAT0017": "The permission to insert package %1s has been removed.",
551 + "PLAT0018": "The fan card area %1s is open.",
552 + "PLAT0019": "The fan card area %1s is closed.",
553 + "PLAT0022": "The computer system %1s has detected a secure mode violation.",
554 + "PLAT0024": "The computer system %1s has detected a pre-boot user password violation.",
555 + "PLAT0026": "The computer system %1s has detected a pre-boot setup password violation.",
556 + "PLAT0028": "The computer system %1s has detected a network boot password violation.",
557 + "PLAT0030": "The computer system %1s has detected a password violation.",
558 + "PLAT0032": "The management controller %1s has detected an out-of-band password violation.",
559 + "PLAT0034": "The processor %1s has been added.",
560 + "PLAT0035": "The processor %1s has been removed.",
561 + "PLAT0036": "An over-temperature condition has been detected on the processor %1s.",
562 + "PLAT0037": "An over-temperature condition has been removed on the processor %1s.",
563 + "PLAT0038": "The processor %1s is operating in a degraded State.",
564 + "PLAT0039": "The processor %1s is no longer operating in a degraded State.",
565 + "PLAT0040": "The processor %1s has failed.",
566 + "PLAT0042": "The processor %1s has failed.",
567 + "PLAT0044": "The processor %1s has failed.",
568 + "PLAT0046": "The processor %1s has failed.",
569 + "PLAT0048": "The processor %1s has failed.",
570 + "PLAT0060": "The processor %1s has been enabled.",
571 + "PLAT0061": "The processor %1s has been disabled.",
572 + "PLAT0062": "The processor %1s has a configuration mismatch.",
573 + "PLAT0064": "A terminator has been detected on the processor %1s.",
574 + "PLAT0084": "The Power Supply %1s has been added.",
575 + "PLAT0085": "The Power Supply %1s has been removed.",
576 + "PLAT0086": "The Power Supply %1s has failed.",
577 + "PLAT0088": "Failure predicted on power supply %1s.",
578 + "PLAT0096": "The input to power supply %1s has been lost or fallen out of range.",
579 + "PLAT0098": "The power supply %1s is operating in an input state that is out of range.",
580 + "PLAT0099": "The power supply %1s has returned to a normal input state.",
581 + "PLAT0100": "The power supply %1s has lost input.",
582 + "PLAT0104": "The power supply %1s has a configuration mismatch.",
583 + "PLAT0106": "Power supply %1s has been disabled.",
584 + "PLAT0107": "Power supply %1s has been enabled.",
585 + "PLAT0108": "Power supply %1s has been power cycled.",
586 + "PLAT0110": "Power supply %1s has encountered an error during power down.",
587 + "PLAT0112": "Power supply %1s has lost power.",
588 + "PLAT0114": "Soft power control has failed for power supply %1s.",
589 + "PLAT0116": "Power supply %1s has failed.",
590 + "PLAT0118": "Failure predicted on power supply %1s.",
591 + "PLAT0120": "Memory subsystem failure.",
592 + "PLAT0122": "DIMM missing.",
593 + "PLAT0124": "Memory error detected & corrected for DIMM %1s.",
594 + "PLAT0128": "Memory DIMM %1s added.",
595 + "PLAT0129": "Memory DIMM %1s removed.",
596 + "PLAT0130": "Memory DIMM %1s enabled.",
597 + "PLAT0131": "Memory DIMM %1s disabled.",
598 + "PLAT0134": "Memory parity error for DIMM %1s.",
599 + "PLAT0136": "Memory scrub failure for DIMM %1s.",
600 + "PLAT0138": "Memory uncorrectable error detected for DIMM %1s.",
601 + "PLAT0140": "Memory sparing initiated for DIMM %1s.",
602 + "PLAT0141": "Memory sparing concluded for DIMM %1s.",
603 + "PLAT0142": "Memory DIMM %1s Throttled.",
604 + "PLAT0144": "Memory logging limit reached for DIMM %1s.",
605 + "PLAT0145": "Memory logging limit removed for DIMM %1s.",
606 + "PLAT0146": "An over-temperature condition has been detected on the Memory DIMM %1s.",
607 + "PLAT0147": "An over-temperature condition has been removed on the Memory DIMM %1s.",
608 + "PLAT0162": "The drive %1s has been added.",
609 + "PLAT0163": "The drive %1s has been removed.",
610 + "PLAT0164": "The drive %1s has been disabled due to a detected fault.",
611 + "PLAT0167": "The drive %1s has been enabled.",
612 + "PLAT0168": "Failure predicted on drive %1s.",
613 + "PLAT0170": "Hot spare enabled for %1s.",
614 + "PLAT0171": "Hot spare disabled for %1s.",
615 + "PLAT0172": "Consistency check has begun for %1s.",
616 + "PLAT0173": "Consistency check completed for %1s.",
617 + "PLAT0174": "Array %1s is in critical condition.",
618 + "PLAT0176": "Array %1s has failed.",
619 + "PLAT0177": "Array %1s has been restored.",
620 + "PLAT0178": "Rebuild in progress for array %1s.",
621 + "PLAT0179": "Rebuild completed for array %1s.",
622 + "PLAT0180": "Rebuild Aborted for array %1s.",
623 + "PLAT0184": "The system %1s encountered a POST error.",
624 + "PLAT0186": "The system %1s encountered a firmware hang.",
625 + "PLAT0188": "The system %1s encountered firmware progress.",
626 + "PLAT0192": "The log %1s has been disabled.",
627 + "PLAT0193": "The log %1s has been enabled.",
628 + "PLAT0194": "The log %1s has been disabled.",
629 + "PLAT0195": "The log %1s has been enabled.",
630 + "PLAT0196": "The log %1s has been disabled.",
631 + "PLAT0198": "The log %1s has been enabled.",
632 + "PLAT0200": "The log %1s has been cleared.",
633 + "PLAT0202": "The log %1s is full.",
634 + "PLAT0203": "The log %1s is no longer full.",
635 + "PLAT0204": "The log %1s is almost full.",
636 + "PLAT0208": "The log %1s has a configuration error.",
637 + "PLAT0210": "The system %1s has been reconfigured.",
638 + "PLAT0212": "The system %1s has encountered an OEM system boot event.",
639 + "PLAT0214": "The system %1s has encountered an unknown system hardware fault.",
640 + "PLAT0216": "The system %1s has generated an auxiliary log entry.",
641 + "PLAT0218": "The system %1s has executed a PEF action.",
642 + "PLAT0220": "The system %1s has synchronized the system clock.",
643 + "PLAT0222": "A diagnostic interrupt has occurred on system %1s.",
644 + "PLAT0224": "A bus timeout has occurred on system %1s.",
645 + "PLAT0226": "An I/O channel check NMI has occurred on system %1s.",
646 + "PLAT0228": "A software NMI has occurred on system %1s.",
647 + "PLAT0230": "System %1s has recovered from an NMI.",
648 + "PLAT0232": "A PCI PERR has occurred on system %1s.",
649 + "PLAT0234": "A PCI SERR has occurred on system %1s.",
650 + "PLAT0236": "An EISA fail safe timeout occurred on system %1s.",
651 + "PLAT0238": "A correctable bus error has occurred on system %1s.",
652 + "PLAT0240": "An uncorrectable bus error has occurred on system %1s.",
653 + "PLAT0242": "A fatal NMI error has occurred on system %1s.",
654 + "PLAT0244": "A fatal bus error has occurred on system %1s.",
655 + "PLAT0246": "A bus on system %1s is operating in a degraded state.",
656 + "PLAT0247": "A bus on system %1s is no longer operating in a degraded state.",
657 + "PLAT0248": "The power button %1s has been pressed.",
658 + "PLAT0249": "The power button %1s has been released.",
659 + "PLAT0250": "The sleep button %1s has been pressed.",
660 + "PLAT0251": "The sleep button %1s has been released.",
661 + "PLAT0252": "The reset button %1s has been pressed.",
662 + "PLAT0253": "The reset button %1s has been released.",
663 + "PLAT0254": "The latch to %1s has been opened.",
664 + "PLAT0255": "The latch to %1s has been closed.",
665 + "PLAT0256": "The service request %1s has been enabled.",
666 + "PLAT0257": "The service request %1s has been completed.",
667 + "PLAT0258": "Power control of system %1s has failed.",
668 + "PLAT0262": "The network port %1s has been connected.",
669 + "PLAT0263": "The network port %1s has been disconnected.",
670 + "PLAT0266": "The connector %1s has encountered a configuration error.",
671 + "PLAT0267": "The connector %1s configuration error has been repaired.",
672 + "PLAT0272": "Power on for system %1s.",
673 + "PLAT0274": "Power cycle hard requested for system %1s.",
674 + "PLAT0276": "Power cycle soft requested for system %1s.",
675 + "PLAT0278": "PXE boot requested for system %1s.",
676 + "PLAT0280": "Diagnostics boot requested for system %1s.",
677 + "PLAT0282": "System restart requested for system %1s.",
678 + "PLAT0284": "System restart begun for system %1s.",
679 + "PLAT0286": "No bootable media available for system %1s.",
680 + "PLAT0288": "Non-bootable media selected for system %1s.",
681 + "PLAT0290": "PXE server not found for system %1s.",
682 + "PLAT0292": "User timeout on boot for system %1s.",
683 + "PLAT0296": "System %1s boot from floppy initiated.",
684 + "PLAT0298": "System %1s boot from local drive initiated.",
685 + "PLAT0300": "System %1s boot from PXE on network port initiated.",
686 + "PLAT0302": "System %1s boot diagnostics initiated.",
687 + "PLAT0304": "System %1s boot from CD initiated.",
688 + "PLAT0306": "System %1s boot from ROM initiated.",
689 + "PLAT0312": "System %1s boot initiated.",
690 + "PLAT0320": "Critical stop during OS load on system %1s.",
691 + "PLAT0322": "Run-time critical stop on system %1s.",
692 + "PLAT0324": "OS graceful stop on system %1s.",
693 + "PLAT0326": "OS graceful shutdown begun on system %1s.",
694 + "PLAT0327": "OS graceful shutdown completed on system %1s.",
695 + "PLAT0328": "Agent not responding on system %1s.",
696 + "PLAT0329": "Agent has begun responding on system %1s.",
697 + "PLAT0330": "Fault in slot on system %1s.",
698 + "PLAT0331": "Fault condition removed on system %1s.",
699 + "PLAT0332": "Identifying slot on system %1s.",
700 + "PLAT0333": "Identify stopped on slot for system %1s.",
701 + "PLAT0334": "Package installed in slot for system %1s.",
702 + "PLAT0336": "Slot empty system %1s.",
703 + "PLAT0338": "Slot in system %1s is ready for installation.",
704 + "PLAT0340": "Slot in system %1s is ready for removal.",
705 + "PLAT0342": "Power is off on slot of system %1s.",
706 + "PLAT0344": "Power is on for slot of system %1s.",
707 + "PLAT0346": "Removal requested for slot of system %1s.",
708 + "PLAT0348": "Interlock activated on slot of system %1s.",
709 + "PLAT0349": "Interlock de-asserted on slot of system %1s.",
710 + "PLAT0350": "Slot disabled on system %1s.",
711 + "PLAT0351": "Slot enabled on system %1s.",
712 + "PLAT0352": "Slot of system %1s holds spare.",
713 + "PLAT0353": "Slot of system %1s no longer holds spare.",
714 + "PLAT0354": "Computer system %1s enabled.",
715 + "PLAT0356": "Computer system %1s is in sleep - light mode.",
716 + "PLAT0358": "Computer system %1s is in hibernate.",
717 + "PLAT0360": "Computer system %1s is in standby.",
718 + "PLAT0362": "Computer system %1s is in soft off mode.",
719 + "PLAT0364": "Computer system %1s is in hard off mode.",
720 + "PLAT0366": "Computer system %1s is sleeping.",
721 + "PLAT0368": "Watchdog timer expired for %1s.",
722 + "PLAT0370": "Reboot of system initiated by watchdog %1s.",
723 + "PLAT0372": "Powering off system initiated by watchdog %1s.",
724 + "PLAT0374": "Power cycle of system initiated by watchdog %1s.",
725 + "PLAT0376": "Watchdog timer interrupt occurred for %1s.",
726 + "PLAT0378": "A page alert has been generated for system %1s.",
727 + "PLAT0380": "A LAN alert has been generated for system %1s.",
728 + "PLAT0382": "An event trap has been generated for system %1s.",
729 + "PLAT0384": "An SNMP trap has been generated for system %1s.",
730 + "PLAT0390": "%1s detected as present.",
731 + "PLAT0392": "%1s detected as absent.",
732 + "PLAT0394": "%1s has been disabled.",
733 + "PLAT0395": "%1s has been enabled.",
734 + "PLAT0396": "Heartbeat lost for LAN %1s.",
735 + "PLAT0397": "Heartbeat detected for LAN %1s.",
736 + "PLAT0398": "Sensor %1s is unavailable or degraded on management system.",
737 + "PLAT0399": "Sensor %1s has returned to normal on management system.",
738 + "PLAT0400": "Controller %1s is unavailable or degraded on management system.",
739 + "PLAT0401": "Controller %1s has returned to normal on management system.",
740 + "PLAT0402": "Management system %1s is off-line.",
741 + "PLAT0404": "Management system %1s is disabled.",
742 + "PLAT0405": "Management system %1s is enabled.",
743 + "PLAT0406": "Sensor %1s has failed on management system.",
744 + "PLAT0408": "FRU %1s has failed on management system.",
745 + "PLAT0424": "The battery %1s is critically low.",
746 + "PLAT0427": "The battery %1s is no longer critically low.",
747 + "PLAT0430": "The battery %1s has been removed from unit.",
748 + "PLAT0431": "The battery %1s has been added.",
749 + "PLAT0432": "The battery %1s has failed.",
750 + "PLAT0434": "Session audit is deactivated on system %1s.",
751 + "PLAT0435": "Session audit is activated on system %1s.",
752 + "PLAT0436": "A hardware change occurred on system %1s.",
753 + "PLAT0438": "A firmware or software change occurred on system %1s.",
754 + "PLAT0440": "A hardware incompatibility was detected on system %1s.",
755 + "PLAT0442": "A firmware or software incompatibility was detected on system %1s.",
756 + "PLAT0444": "Invalid or unsupported hardware was detected on system %1s.",
757 + "PLAT0446": "Invalid or unsupported firmware or software was detected on system %1s.",
758 + "PLAT0448": "A successful hardware change was detected on system %1s.",
759 + "PLAT0450": "A successful software or firmware change was detected on system %1s.",
760 + "PLAT0464": "FRU %1s not installed on system.",
761 + "PLAT0465": "FRU %1s installed on system.",
762 + "PLAT0466": "Activation requested for FRU %1s on system.",
763 + "PLAT0467": "FRU %1s on system is active.",
764 + "PLAT0468": "Activation in progress for FRU %1s on system.",
765 + "PLAT0470": "Deactivation request for FRU %1s on system.",
766 + "PLAT0471": "FRU %1s on system is in standby or \"hot spare\" state.",
767 + "PLAT0472": "Deactivation in progress for FRU %1s on system.",
768 + "PLAT0474": "Communication lost with FRU %1s on system.",
769 + "PLAT0476": "Numeric sensor %1s going low (lower non-critical).",
770 + "PLAT0478": "Numeric sensor %1s going high (lower non-critical).",
771 + "PLAT0480": "Numeric sensor %1s going low (lower critical).",
772 + "PLAT0482": "Numeric sensor %1s going high (lower critical).",
773 + "PLAT0484": "Numeric sensor %1s going low (lower non-recoverable).",
774 + "PLAT0486": "Numeric sensor %1s going high (lower non-critical).",
775 + "PLAT0488": "Numeric sensor %1s going low (upper non-critical).",
776 + "PLAT0490": "Numeric sensor %1s going high (upper non-critical).",
777 + "PLAT0492": "Numeric sensor %1s going low (upper critical).",
778 + "PLAT0494": "Numeric sensor %1s going high (upper critical).",
779 + "PLAT0496": "Numeric sensor %1s going low (upper non-recoverable).",
780 + "PLAT0498": "Numeric sensor %1s going high (upper non-recoverable).",
781 + "PLAT0500": "Sensor %1s has transitioned to idle.",
782 + "PLAT0502": "Sensor %1s has transitioned to active.",
783 + "PLAT0504": "Sensor %1s has transitioned to busy.",
784 + "PLAT0508": "Sensor %1s has asserted.",
785 + "PLAT0509": "Sensor %1s has de-asserted.",
786 + "PLAT0510": "Sensor %1s is asserting predictive failure.",
787 + "PLAT0511": "Sensor %1s is de-asserting predictive failure.",
788 + "PLAT0512": "Sensor %1s has indicated limit exceeded.",
789 + "PLAT0513": "Sensor %1s has indicated limit no longer exceeded.",
790 + "PLAT0514": "Sensor %1s has indicated performance met.",
791 + "PLAT0516": "Sensor %1s has indicated performance lags.",
792 + "PLAT0518": "Sensor %1s has transitioned to normal state.",
793 + "PLAT0520": "Sensor %1s has transitioned from normal to non-critical state.",
794 + "PLAT0522": "Sensor %1s has transitioned to critical from a less severe state.",
795 + "PLAT0524": "Sensor %1s has transitioned to non-recoverable from a less severe state.",
796 + "PLAT0526": "Sensor %1s has transitioned to non-critical from a more severe state.",
797 + "PLAT0528": "Sensor %1s has transitioned to critical from a non-recoverable state.",
798 + "PLAT0530": "Sensor %1s has transitioned to non-recoverable.",
799 + "PLAT0532": "Sensor %1s indicates a monitor state.",
800 + "PLAT0534": "Sensor %1s has an informational state.",
801 + "PLAT0536": "Device %1s has been added.",
802 + "PLAT0537": "Device %1s has been removed from unit.",
803 + "PLAT0538": "Device %1s has been enabled.",
804 + "PLAT0539": "Device %1s has been disabled.",
805 + "PLAT0540": "Sensor %1s has indicated a running state.",
806 + "PLAT0544": "Sensor %1s has indicated a power off state.",
807 + "PLAT0546": "Sensor %1s has indicated an on-line state.",
808 + "PLAT0548": "Sensor %1s has indicated an off-line state.",
809 + "PLAT0550": "Sensor %1s has indicated an off-duty state.",
810 + "PLAT0552": "Sensor %1s has indicated a degraded state.",
811 + "PLAT0554": "Sensor %1s has indicated a power save state.",
812 + "PLAT0556": "Sensor %1s has indicated an install error.",
813 + "PLAT0558": "Redundancy %1s has been lost.",
814 + "PLAT0560": "Redundancy %1s has been reduced.",
815 + "PLAT0561": "Redundancy %1s has been restored.",
816 + "PLAT0562": "%1s has transitioned to a D0 power state.",
817 + "PLAT0564": "%1s has transitioned to a D1 power state.",
818 + "PLAT0566": "%1s has transitioned to a D2 power state.",
819 + "PLAT0568": "%1s has transitioned to a D3 power state.",
820 + "PLAT0720": "The System %1s encountered firmware progress - memory initialization entry.",
821 + "PLAT0721": "The System %1s encountered firmware progress - memory initialization exit.",
822 + "PLAT0722": "The System %1s encountered firmware progress - hard drive initialization entry.",
823 + "PLAT0723": "The System %1s encountered firmware progress - hard drive initialization exit.",
824 + "PLAT0724": "The System %1s encountered firmware progress - user authentication.",
825 + "PLAT0728": "The System %1s encountered firmware progress - USR resource configuration entry.",
826 + "PLAT0729": "The System %1s encountered firmware progress - USR resource configuration exit.",
827 + "PLAT0730": "The System %1s encountered firmware progress - PCI recource configuration entry.",
828 + "PLAT0731": "The System %1s encountered firmware progress - PCI recource configuration exit.",
829 + "PLAT0732": "The System %1s encountered firmware progress - Option ROM initialization entry.",
830 + "PLAT0733": "The System %1s encountered firmware progress - Option ROM initialization entry exit.",
831 + "PLAT0734": "The System %1s encountered firmware progress -video initialization entry entry.",
832 + "PLAT0735": "The System %1s encountered firmware progress - video initialization entry exit.",
833 + "PLAT0736": "The System %1s encountered firmware progress - cache initialization entry.",
834 + "PLAT0737": "The System %1s encountered firmware progress - cache initialization exit.",
835 + "PLAT0738": "The System %1s encountered firmware progress - keyboard controller initialization entry.",
836 + "PLAT0739": "The System %1s encountered firmware progress - keyboard controller initialization exit.",
837 + "PLAT0740": "The System %1s encountered firmware progress - motherboard initialization entry.",
838 + "PLAT0741": "The System %1s encountered firmware progress - motherboard initialization exit.",
839 + "PLAT0742": "The System %1s encountered firmware progress - floppy disk initialization entry.",
840 + "PLAT0743": "The System %1s encountered firmware progress - floppy disk initialization exit.",
841 + "PLAT0744": "The System %1s encountered firmware progress - keyboard test entry.",
842 + "PLAT0745": "The System %1s encountered firmware progress - keyboard test exit.",
843 + "PLAT0746": "The System %1s encountered firmware progress - pointing device test entry.",
844 + "PLAT0747": "The System %1s encountered firmware progress - pointing device test exit.",
845 + "PLAT0750": "The System %1s encountered firmware progress - dock enable entry.",
846 + "PLAT0751": "The System %1s encountered firmware progress - dock enable exit.",
847 + "PLAT0752": "The System %1s encountered firmware progress - dock disable entry.",
848 + "PLAT0753": "The System %1s encountered firmware progress - dock disable exit.",
849 + "PLAT0760": "The System %1s encountered firmware progress - start OS boot process.",
850 + "PLAT0762": "The System %1s encountered firmware progress - call OS wake vector.",
851 + "PLAT0764": "The System %1s encountered firmware progress - unrecoverable keyboard failure.",
852 + "PLAT0766": "The System %1s encountered firmware progress - no video device detected.",
853 + "PLAT0768": "The System %1s encountered firmware progress - SMART alert detected on drive.",
854 + "PLAT0770": "The System %1s encountered firmware progress - unrecoverable boot device failure.",
855 + "PLAT0789": "Corrupt BIOS detected.",
856 + "PLAT0790": "The System %1s encountered PCI configuration failure.",
857 + "PLAT0791": "The System %1s encountered a video subsystem failure.",
858 + "PLAT0792": "The System %1s encountered a storage subsystem failure.",
859 + "PLAT0793": "The System %1s encountered a USB subsystem failure.",
860 + "PLAT0794": "The System %1s has detected no memory in the system.",
861 + "PLAT0795": "The System %1s encountered a motherboard failure.",
862 + "PLAT0796": "The System %1s encountered a memory Regulator Voltage Bad.",
863 + "PLAT0797": "%1s PCI reset is not deasserting.",
864 + "PLAT0798": "%1s Non-Motherboard Regulator Failure.",
865 + "PLAT0799": "%1s Power Supply Cable failure.",
866 + "PLAT0800": "%1s Motherboard regulator failure.",
867 + "PLAT0801": "%1s System component compatibility mismatch."
868 +}
869 +
870 module.exports = lme_heci;
agents/modules_meshcore/amt-xml.js new
+168
@@ -0,0 +1,168 @@
1 +
2 +// Parse XML and return JSON
3 +module.exports.ParseWsman = function (xml) {
4 + try {
5 + if (!xml.childNodes) xml = _turnToXml(xml);
6 + var r = { Header: {} }, header = xml.getElementsByTagName("Header")[0], t;
7 + if (!header) header = xml.getElementsByTagName("a:Header")[0];
8 + if (!header) return null;
9 + for (var i = 0; i < header.childNodes.length; i++) {
10 + var child = header.childNodes[i];
11 + r.Header[child.localName] = child.textContent;
12 + }
13 + var body = xml.getElementsByTagName("Body")[0];
14 + if (!body) body = xml.getElementsByTagName("a:Body")[0];
15 + if (!body) return null;
16 + if (body.childNodes.length > 0) {
17 + t = body.childNodes[0].localName;
18 + if (t.indexOf("_OUTPUT") == t.length - 7) { t = t.substring(0, t.length - 7); }
19 + r.Header['Method'] = t;
20 + r.Body = _ParseWsmanRec(body.childNodes[0]);
21 + }
22 + return r;
23 + } catch (e) {
24 + console.log("Unable to parse XML: " + xml);
25 + return null;
26 + }
27 +}
28 +
29 +// Private method
30 +function _ParseWsmanRec(node) {
31 + var data, r = {};
32 + for (var i = 0; i < node.childNodes.length; i++) {
33 + var child = node.childNodes[i];
34 + if ((child.childElementCount == null) || (child.childElementCount == 0)) { data = child.textContent; } else { data = _ParseWsmanRec(child); }
35 + if (data == 'true') data = true; // Convert 'true' into true
36 + if (data == 'false') data = false; // Convert 'false' into false
37 + if ((parseInt(data) + '') === data) data = parseInt(data); // Convert integers
38 +
39 + var childObj = data;
40 + if ((child.attributes != null) && (child.attributes.length > 0)) {
41 + childObj = { 'Value': data };
42 + for (var j = 0; j < child.attributes.length; j++) {
43 + childObj['@' + child.attributes[j].name] = child.attributes[j].value;
44 + }
45 + }
46 +
47 + if (r[child.localName] instanceof Array) { r[child.localName].push(childObj); }
48 + else if (r[child.localName] == null) { r[child.localName] = childObj; }
49 + else { r[child.localName] = [r[child.localName], childObj]; }
50 + }
51 + return r;
52 +}
53 +
54 +function _PutObjToBodyXml(resuri, putObj) {
55 + if (!resuri || putObj == null) return '';
56 + var objname = obj.GetNameFromUrl(resuri);
57 + var result = '<r:' + objname + ' xmlns:r="' + resuri + '">';
58 +
59 + for (var prop in putObj) {
60 + if (!putObj.hasOwnProperty(prop) || prop.indexOf('__') === 0 || prop.indexOf('@') === 0) continue;
61 + if (putObj[prop] == null || typeof putObj[prop] === 'function') continue;
62 + if (typeof putObj[prop] === 'object' && putObj[prop]['ReferenceParameters']) {
63 + result += '<r:' + prop + '><a:Address>' + putObj[prop].Address + '</a:Address><a:ReferenceParameters><w:ResourceURI>' + putObj[prop]['ReferenceParameters']["ResourceURI"] + '</w:ResourceURI><w:SelectorSet>';
64 + var selectorArray = putObj[prop]['ReferenceParameters']['SelectorSet']['Selector'];
65 + if (Array.isArray(selectorArray)) {
66 + for (var i = 0; i < selectorArray.length; i++) {
67 + result += '<w:Selector' + _ObjectToXmlAttributes(selectorArray[i]) + '>' + selectorArray[i]['Value'] + '</w:Selector>';
68 + }
69 + }
70 + else {
71 + result += '<w:Selector' + _ObjectToXmlAttributes(selectorArray) + '>' + selectorArray['Value'] + '</w:Selector>';
72 + }
73 + result += '</w:SelectorSet></a:ReferenceParameters></r:' + prop + '>';
74 + }
75 + else {
76 + if (Array.isArray(putObj[prop])) {
77 + for (var i = 0; i < putObj[prop].length; i++) {
78 + result += '<r:' + prop + '>' + putObj[prop][i].toString() + '</r:' + prop + '>';
79 + }
80 + } else {
81 + result += '<r:' + prop + '>' + putObj[prop].toString() + '</r:' + prop + '>';
82 + }
83 + }
84 + }
85 +
86 + result += '</r:' + objname + '>';
87 + return result;
88 +}
89 +
90 +// This is a drop-in replacement to _turnToXml() that works without xml parser dependency.
91 +Object.defineProperty(Array.prototype, "peek", { value: function () { return (this.length > 0 ? this[this.length - 1] : null); } });
92 +function _treeBuilder() {
93 + this.tree = [];
94 + this.push = function (element) { this.tree.push(element); };
95 + this.pop = function () { var element = this.tree.pop(); if (this.tree.length > 0) { var x = this.tree.peek(); x.childNodes.push(element); x.childElementCount = x.childNodes.length; } return (element); };
96 + this.peek = function () { return (this.tree.peek()); }
97 + this.addNamespace = function (prefix, namespace) { this.tree.peek().nsTable[prefix] = namespace; if (this.tree.peek().attributes.length > 0) { for (var i = 0; i < this.tree.peek().attributes; ++i) { var a = this.tree.peek().attributes[i]; if (prefix == '*' && a.name == a.localName) { a.namespace = namespace; } else if (prefix != '*' && a.name != a.localName) { var pfx = a.name.split(':')[0]; if (pfx == prefix) { a.namespace = namespace; } } } } }
98 + this.getNamespace = function (prefix) { for (var i = this.tree.length - 1; i >= 0; --i) { if (this.tree[i].nsTable[prefix] != null) { return (this.tree[i].nsTable[prefix]); } } return null; }
99 +}
100 +function _turnToXml(text) { if (text == null) return null; return ({ childNodes: [_turnToXmlRec(text)], getElementsByTagName: _getElementsByTagName, getChildElementsByTagName: _getChildElementsByTagName, getElementsByTagNameNS: _getElementsByTagNameNS }); }
101 +function _getElementsByTagNameNS(ns, name) { var ret = []; _xmlTraverseAllRec(this.childNodes, function (node) { if (node.localName == name && (node.namespace == ns || ns == '*')) { ret.push(node); } }); return ret; }
102 +function _getElementsByTagName(name) { var ret = []; _xmlTraverseAllRec(this.childNodes, function (node) { if (node.localName == name) { ret.push(node); } }); return ret; }
103 +function _getChildElementsByTagName(name) { var ret = []; if (this.childNodes != null) { for (var node in this.childNodes) { if (this.childNodes[node].localName == name) { ret.push(this.childNodes[node]); } } } return (ret); }
104 +function _getChildElementsByTagNameNS(ns, name) { var ret = []; if (this.childNodes != null) { for (var node in this.childNodes) { if (this.childNodes[node].localName == name && (ns == '*' || this.childNodes[node].namespace == ns)) { ret.push(this.childNodes[node]); } } } return (ret); }
105 +function _xmlTraverseAllRec(nodes, func) { for (var i in nodes) { func(nodes[i]); if (nodes[i].childNodes) { _xmlTraverseAllRec(nodes[i].childNodes, func); } } }
106 +function _turnToXmlRec(text) {
107 + var elementStack = new _treeBuilder(), lastElement = null, x1 = text.split('<'), ret = [], element = null, currentElementName = null;
108 + for (var i in x1) {
109 + var x2 = x1[i].split('>'), x3 = x2[0].split(' '), elementName = x3[0];
110 + if ((elementName.length > 0) && (elementName[0] != '?')) {
111 + if (elementName[0] != '/') {
112 + var attributes = [], localName, localname2 = elementName.split(' ')[0].split(':'), localName = (localname2.length > 1) ? localname2[1] : localname2[0];
113 + Object.defineProperty(attributes, "get",
114 + {
115 + value: function () {
116 + if (arguments.length == 1) {
117 + for (var a in this) { if (this[a].name == arguments[0]) { return (this[a]); } }
118 + }
119 + else if (arguments.length == 2) {
120 + for (var a in this) { if (this[a].name == arguments[1] && (arguments[0] == '*' || this[a].namespace == arguments[0])) { return (this[a]); } }
121 + }
122 + else {
123 + throw ('attributes.get(): Invalid number of parameters');
124 + }
125 + }
126 + });
127 + elementStack.push({ name: elementName, localName: localName, getChildElementsByTagName: _getChildElementsByTagName, getElementsByTagNameNS: _getElementsByTagNameNS, getChildElementsByTagNameNS: _getChildElementsByTagNameNS, attributes: attributes, childNodes: [], nsTable: {} });
128 + // Parse Attributes
129 + if (x3.length > 0) {
130 + var skip = false;
131 + for (var j in x3) {
132 + if (x3[j] == '/') {
133 + // This is an empty Element
134 + elementStack.peek().namespace = elementStack.peek().name == elementStack.peek().localName ? elementStack.getNamespace('*') : elementStack.getNamespace(elementStack.peek().name.substring(0, elementStack.peek().name.indexOf(':')));
135 + elementStack.peek().textContent = '';
136 + lastElement = elementStack.pop();
137 + skip = true;
138 + break;
139 + }
140 + var k = x3[j].indexOf('=');
141 + if (k > 0) {
142 + var attrName = x3[j].substring(0, k);
143 + var attrValue = x3[j].substring(k + 2, x3[j].length - 1);
144 + var attrNS = elementStack.getNamespace('*');
145 +
146 + if (attrName == 'xmlns') {
147 + elementStack.addNamespace('*', attrValue);
148 + attrNS = attrValue;
149 + } else if (attrName.startsWith('xmlns:')) {
150 + elementStack.addNamespace(attrName.substring(6), attrValue);
151 + } else {
152 + var ax = attrName.split(':');
153 + if (ax.length == 2) { attrName = ax[1]; attrNS = elementStack.getNamespace(ax[0]); }
154 + }
155 + var x = { name: attrName, value: attrValue }
156 + if (attrNS != null) x.namespace = attrNS;
157 + elementStack.peek().attributes.push(x);
158 + }
159 + }
160 + if (skip) { continue; }
161 + }
162 + elementStack.peek().namespace = elementStack.peek().name == elementStack.peek().localName ? elementStack.getNamespace('*') : elementStack.getNamespace(elementStack.peek().name.substring(0, elementStack.peek().name.indexOf(':')));
163 + if (x2[1]) { elementStack.peek().textContent = x2[1]; }
164 + } else { lastElement = elementStack.pop(); }
165 + }
166 + }
167 + return lastElement;
168 +}
views/default.handlebars
+2 -2
@@ -3695,7 +3695,7 @@
3695 }
3696
3697 //
3698 - // MESH AGENT CONSOLE
3698 + // CONSOLE
3699 //
3700
3701 function agentConsoleHandleKeys(e) {
@@ -3790,7 +3790,7 @@
3790
3791 // Handle Mesh Agent console data
3792 function p15consoleReceive(node, data) {
3793 - data = '<div>' + EscapeHtmlBreaks(data) + '</div>'
3793 + data = '<div>' + data + '</div>'
3794 if (node.consoleText == null) { node.consoleText = data; } else { node.consoleText += data; }
3795 if (consoleNode == node) {
3796 Q('p15agentConsoleText').innerHTML += data;