mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-06 00:13:33 +00:00
Syned changes with meshcmd, and fixed bug with AMTUUID
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2018-2020 Intel Corporation
|
||||
Copyright 2018-2021 Intel Corporation
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -117,7 +117,11 @@ function lme_heci(options) {
|
||||
emitterUtils.createEvent('notify');
|
||||
emitterUtils.createEvent('bind');
|
||||
|
||||
this.on('newListener', function (name, func) { if (name == 'connect' && this._LME._connected == true) { func.call(this);} });
|
||||
this.on('newListener', function (name, func)
|
||||
{
|
||||
if (name == 'connect' && this._LME._connected == true) { func.call(this); }
|
||||
if (name == 'error' && this._LME._error !=null) { func.call(this, this._LME._error); }
|
||||
});
|
||||
if ((options != null) && (options.debug == true)) { lme_port_offset = -100; } // LMS debug mode
|
||||
|
||||
var heci = require('heci');
|
||||
@@ -126,10 +130,11 @@ function lme_heci(options) {
|
||||
this._ObjectID = "lme";
|
||||
this._LME = heci.create();
|
||||
this._LME._connected = false;
|
||||
this._LME._error = null;
|
||||
this._LME.descriptorMetadata = "amt-lme";
|
||||
this._LME._binded = {};
|
||||
this._LME.LMS = this;
|
||||
this._LME.on('error', function (e) { this.LMS.emit('error', e); });
|
||||
this._LME.on('error', function (e) { this._error = e; this.LMS.emit('error', e); });
|
||||
this._LME.on('connect', function ()
|
||||
{
|
||||
this._connected = true;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2018-2020 Intel Corporation
|
||||
Copyright 2018-2021 Intel Corporation
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -17,6 +17,21 @@ limitations under the License.
|
||||
var Q = require('queue');
|
||||
var g_internal = null;
|
||||
|
||||
function retry_pthi_later()
|
||||
{
|
||||
if (++g_internal.errorCount < 20)
|
||||
{
|
||||
g_internal.timeout = setTimeout(function (p)
|
||||
{
|
||||
p.connect(require('heci').GUIDS.AMT, { noPipeline: 1 });
|
||||
}, 250, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Parent.emit('error', 'PTHI Connection could not be established');
|
||||
}
|
||||
}
|
||||
|
||||
function amt_heci()
|
||||
{
|
||||
var emitterUtils = require('events').inherits(this);
|
||||
@@ -29,7 +44,7 @@ function amt_heci()
|
||||
var that = this;
|
||||
if (g_internal == null)
|
||||
{
|
||||
g_internal = { _rq: new Q(), _amt: null };
|
||||
g_internal = { _rq: new Q(), _amt: null, errorCount: 0 };
|
||||
g_internal._setupPTHI = function _g_setupPTHI()
|
||||
{
|
||||
console.info1('setupPTHI()');
|
||||
@@ -42,7 +57,7 @@ function amt_heci()
|
||||
this._amt.on('error', function _amtOnError(e)
|
||||
{
|
||||
console.info1('PTHIError: ' + e);
|
||||
if (this.Parent._rq.isEmpty())
|
||||
if (g_internal._rq.isEmpty())
|
||||
{
|
||||
console.info1(' Queue is empty');
|
||||
this.Parent.emit('error', e); // No pending requests, so propagate the error up
|
||||
@@ -51,22 +66,13 @@ function amt_heci()
|
||||
{
|
||||
console.info1(' Queue is NOT empty');
|
||||
|
||||
// There is a pending request, so fail the pending request
|
||||
var user = this.Parent._rq.deQueue();
|
||||
var params = user.optional;
|
||||
var callback = user.func;
|
||||
params.unshift({ Status: -1 }); // Relay an error
|
||||
callback.apply(this.Parent, params);
|
||||
|
||||
if (!this.Parent._rq.isEmpty())
|
||||
{
|
||||
// There are still more pending requests, so try to re-helpconnect MEI
|
||||
this.connect(heci.GUIDS.AMT, { noPipeline: 1 });
|
||||
}
|
||||
// Try again
|
||||
retry_pthi_later.call(this);
|
||||
}
|
||||
});
|
||||
this._amt.on('connect', function _amtOnConnect()
|
||||
{
|
||||
g_internal.errorCount = 0;
|
||||
this.on('data', function _amtOnData(chunk)
|
||||
{
|
||||
//console.log("Received: " + chunk.length + " bytes");
|
||||
@@ -108,7 +114,7 @@ function amt_heci()
|
||||
|
||||
function trim(x) { var y = x.indexOf('\0'); if (y >= 0) { return x.substring(0, y); } else { return x; } }
|
||||
this.getCommand = function getCommand(chunk) {
|
||||
var command = chunk.length == 0 ? (this._rq.peekQueue().cmd | 0x800000) : chunk.readUInt32LE(4);
|
||||
var command = chunk.length == 0 ? (g_internal._rq.peekQueue().cmd | 0x800000) : chunk.readUInt32LE(4);
|
||||
var ret = { IsResponse: (command & 0x800000) == 0x800000 ? true : false, Command: (command & 0x7FFFFF), Status: chunk.length != 0 ? chunk.readUInt32LE(12) : -1, Data: chunk.length != 0 ? chunk.slice(16) : null };
|
||||
return (ret);
|
||||
};
|
||||
@@ -125,13 +131,6 @@ function amt_heci()
|
||||
header.writeUInt32LE(arguments[0] | 0x04000000, 4);
|
||||
header.writeUInt32LE(arguments[1] == null ? 0 : arguments[1].length, 8);
|
||||
|
||||
//this._rq.enQueue({ cmd: arguments[0], func: arguments[2], optional: args, send: (arguments[1] == null ? header : Buffer.concat([header, arguments[1]])) });
|
||||
//if(!this._amt)
|
||||
//{
|
||||
// this._setupPTHI();
|
||||
// this._amt.connect(heci.GUIDS.AMT, { noPipeline: 1 });
|
||||
//}
|
||||
|
||||
g_internal._rq.enQueue({ cmd: arguments[0], func: arguments[2], optional: args, send: (arguments[1] == null ? header : Buffer.concat([header, arguments[1]])) });
|
||||
if (!g_internal._amt)
|
||||
{
|
||||
@@ -332,34 +331,27 @@ function amt_heci()
|
||||
this.getLocalSystemAccount = function getLocalSystemAccount(callback) {
|
||||
var optional = [];
|
||||
for (var i = 1; i < arguments.length; ++i) { optional.push(arguments[i]); }
|
||||
this.sendCommand(103, Buffer.alloc(40), function (header, fn, opt)
|
||||
{
|
||||
if (header.Status == 0 && header.Data.length == 68)
|
||||
{
|
||||
this.sendCommand(103, Buffer.alloc(40), function (header, fn, opt) {
|
||||
if (header.Status == 0 && header.Data.length == 68) {
|
||||
opt.unshift({ user: trim(header.Data.slice(0, 33).toString()), pass: trim(header.Data.slice(33, 67).toString()), raw: header.Data });
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
opt.unshift(null);
|
||||
}
|
||||
fn.apply(this, opt);
|
||||
}, callback, optional);
|
||||
}
|
||||
this.getLanInterfaceSettings = function getLanInterfaceSettings(index, callback)
|
||||
{
|
||||
this.getLanInterfaceSettings = function getLanInterfaceSettings(index, callback) {
|
||||
var optional = [];
|
||||
for (var i = 2; i < arguments.length; ++i) { optional.push(arguments[i]); }
|
||||
var ifx = Buffer.alloc(4);
|
||||
ifx.writeUInt32LE(index);
|
||||
this.sendCommand(0x48, ifx, function onGetLanInterfaceSettings(header, fn, opt)
|
||||
{
|
||||
if(header.Status == 0)
|
||||
{
|
||||
this.sendCommand(0x48, ifx, function onGetLanInterfaceSettings(header, fn, opt) {
|
||||
if (header.Status == 0) {
|
||||
var info = {};
|
||||
info.enabled = header.Data.readUInt32LE(0);
|
||||
info.dhcpEnabled = header.Data.readUInt32LE(8);
|
||||
switch(header.Data[12])
|
||||
{
|
||||
switch (header.Data[12]) {
|
||||
case 1:
|
||||
info.dhcpMode = 'ACTIVE'
|
||||
break;
|
||||
@@ -371,14 +363,13 @@ function amt_heci()
|
||||
break;
|
||||
}
|
||||
info.mac = header.Data.slice(14).toString('hex:');
|
||||
|
||||
|
||||
var addr = header.Data.readUInt32LE(4);
|
||||
info.address = ((addr >> 24) & 255) + '.' + ((addr >> 16) & 255) + '.' + ((addr >> 8) & 255) + '.' + (addr & 255);
|
||||
opt.unshift(info);
|
||||
fn.apply(this, opt);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
opt.unshift(null);
|
||||
fn.apply(this, opt);
|
||||
}
|
||||
@@ -395,32 +386,32 @@ function amt_heci()
|
||||
fn.apply(this, opt);
|
||||
}, callback, optional);
|
||||
}
|
||||
this.startConfiguration = function startConfiguration() {
|
||||
this.startConfiguration = function startConfiguration(callback) {
|
||||
var optional = [];
|
||||
for (var i = 2; i < arguments.length; ++i) { optional.push(arguments[i]); }
|
||||
this.sendCommand(0x29, data, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional);
|
||||
for (var i = 1; i < arguments.length; ++i) { optional.push(arguments[i]); }
|
||||
this.sendCommand(0x29, null, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional);
|
||||
}
|
||||
this.stopConfiguration = function stopConfiguration() {
|
||||
this.stopConfiguration = function stopConfiguration(callback) {
|
||||
var optional = [];
|
||||
for (var i = 2; i < arguments.length; ++i) { optional.push(arguments[i]); }
|
||||
this.sendCommand(0x5E, data, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional);
|
||||
for (var i = 1; i < arguments.length; ++i) { optional.push(arguments[i]); }
|
||||
this.sendCommand(0x5E, null, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional);
|
||||
}
|
||||
this.openUserInitiatedConnection = function openUserInitiatedConnection() {
|
||||
this.openUserInitiatedConnection = function openUserInitiatedConnection(callback) {
|
||||
var optional = [];
|
||||
for (var i = 2; i < arguments.length; ++i) { optional.push(arguments[i]); }
|
||||
this.sendCommand(0x44, data, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional);
|
||||
for (var i = 1; i < arguments.length; ++i) { optional.push(arguments[i]); }
|
||||
this.sendCommand(0x44, null, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional);
|
||||
}
|
||||
this.closeUserInitiatedConnection = function closeUnserInitiatedConnected() {
|
||||
this.closeUserInitiatedConnection = function closeUnserInitiatedConnected(callback) {
|
||||
var optional = [];
|
||||
for (var i = 2; i < arguments.length; ++i) { optional.push(arguments[i]); }
|
||||
this.sendCommand(0x45, data, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional);
|
||||
for (var i = 1; i < arguments.length; ++i) { optional.push(arguments[i]); }
|
||||
this.sendCommand(0x45, null, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional);
|
||||
}
|
||||
this.getRemoteAccessConnectionStatus = function getRemoteAccessConnectionStatus() {
|
||||
this.getRemoteAccessConnectionStatus = function getRemoteAccessConnectionStatus(callback) {
|
||||
var optional = [];
|
||||
for (var i = 2; i < arguments.length; ++i) { optional.push(arguments[i]); }
|
||||
this.sendCommand(0x46, data, function (header, fn, opt) {
|
||||
for (var i = 1; i < arguments.length; ++i) { optional.push(arguments[i]); }
|
||||
this.sendCommand(0x46, null, function (header, fn, opt) {
|
||||
if (header.Status == 0) {
|
||||
var hostname = v.slice(14, header.Data.readUInt16LE(12) + 14).toString()
|
||||
var hostname = header.Data.slice(14, header.Data.readUInt16LE(12) + 14).toString()
|
||||
opt.unshift({ status: header.Status, networkStatus: header.Data.readUInt32LE(0), remoteAccessStatus: header.Data.readUInt32LE(4), remoteAccessTrigger: header.Data.readUInt32LE(8), mpsHostname: hostname, raw: header.Data });
|
||||
} else {
|
||||
opt.unshift({ status: header.Status });
|
||||
@@ -428,27 +419,81 @@ function amt_heci()
|
||||
fn.apply(this, opt);
|
||||
}, callback, optional);
|
||||
}
|
||||
this.getProtocolVersion = function getProtocolVersion(callback)
|
||||
{
|
||||
this.getProtocolVersion = function getProtocolVersion(callback) {
|
||||
var optional = [];
|
||||
for (var i = 1; i < arguments.length; ++i) { opt.push(arguments[i]); }
|
||||
|
||||
if (!this._tmpSession) { this._tmpSession = heci.create(); this._tmpSession.parent = this;}
|
||||
this._tmpSession.doIoctl(heci.IOCTL.HECI_VERSION, Buffer.alloc(5), Buffer.alloc(5), function (status, buffer, self, fn, opt)
|
||||
{
|
||||
if (!this._tmpSession) { this._tmpSession = heci.create(); this._tmpSession.parent = this; }
|
||||
this._tmpSession.doIoctl(heci.IOCTL.HECI_VERSION, Buffer.alloc(5), Buffer.alloc(5), function (status, buffer, self, fn, opt) {
|
||||
if (status == 0) {
|
||||
var result = buffer.readUInt8(0).toString() + '.' + buffer.readUInt8(1).toString() + '.' + buffer.readUInt8(2).toString() + '.' + buffer.readUInt16BE(3).toString();
|
||||
opt.unshift(result);
|
||||
fn.apply(self, opt);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
opt.unshift(null);
|
||||
fn.apply(self, opt);
|
||||
}
|
||||
|
||||
}, this, callback, optional);
|
||||
}
|
||||
this.startConfigurationHBased = function startConfigurationHBased(certHash, hostVpn, dnsSuffixList, func) {
|
||||
if ((certHash == null) || ((certHash.length != 32) && (certHash.length != 48))) { func({ status: -101 }); }
|
||||
this.stopConfiguration(function (status) {
|
||||
if (status == 0) {
|
||||
// We stopped the configuration, wait 20 seconds before starting up again.
|
||||
var f = function tf() { delete tf.parent.xtimeout; tf.parent.startConfigurationHBasedEx(certHash, hostVpn, dnsSuffixList, func); }
|
||||
f.parent = this;
|
||||
this.xtimeout = setTimeout(f, 20000);
|
||||
} else {
|
||||
// We are not in the connect mode, this is good, start configuration right away.
|
||||
this.startConfigurationHBasedEx(certHash, hostVpn, dnsSuffixList, func);
|
||||
}
|
||||
})
|
||||
}
|
||||
this.startConfigurationHBasedEx = function startConfigurationHBased(certHash, hostVpn, dnsSuffixList, func) {
|
||||
var optional = [];
|
||||
for (var i = 4; i < arguments.length; ++i) { optional.push(arguments[i]); }
|
||||
|
||||
// Format the command
|
||||
var data = Buffer.alloc(4 + 64 + 4 + 4 + 320);
|
||||
data.writeUInt32LE((certHash.length == 48) ? 3 : 2, 0); // Write certificate hash type: SHA256 = 2, SHA384 = 3
|
||||
certHash.copy(data, 4); // Write the hash
|
||||
data.writeUInt32LE(hostVpn ? 1 : 0, 68); // Write is HostVPN is enabled
|
||||
if (dnsSuffixList != null) {
|
||||
data.writeUInt32LE(dnsSuffixList.length, 72); // Write the number of DNS Suffix, from 0 to 4
|
||||
var ptr = 76;
|
||||
for (var i = 0; i < dnsSuffixList.length; i++) { ptr += data.write(dnsSuffixList[i], ptr) + 1; } // Write up to 4 DNS Suffix with null seperation.
|
||||
}
|
||||
|
||||
// Send the command
|
||||
this.sendCommand(139, data, function (header, fn, opt) {
|
||||
if (header.Status == 0) {
|
||||
var amtHash = null;
|
||||
if (header.Data[0] == 2) { amtHash = header.Data.slice(1, 33); } // SHA256
|
||||
if (header.Data[0] == 3) { amtHash = header.Data.slice(1, 49); } // SHA384
|
||||
opt.unshift({ status: header.Status, hash: amtHash.toString('hex') });
|
||||
} else {
|
||||
opt.unshift({ status: header.Status });
|
||||
}
|
||||
fn.apply(this, opt);
|
||||
}, func, optional);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = amt_heci;
|
||||
module.exports = amt_heci;
|
||||
|
||||
|
||||
/*
|
||||
AMT_STATUS_SUCCESS = 0,
|
||||
AMT_STATUS_INTERNAL_ERROR = 1,
|
||||
AMT_STATUS_INVALID_AMT_MODE = 3,
|
||||
AMT_STATUS_INVALID_MESSAGE_LENGTH = 4,
|
||||
AMT_STATUS_MAX_LIMIT_REACHED = 23,
|
||||
AMT_STATUS_INVALID_PARAMETER = 36,
|
||||
AMT_STATUS_RNG_GENERATION_IN_PROGRESS = 47,
|
||||
AMT_STATUS_RNG_NOT_READY = 48,
|
||||
AMT_STATUS_CERTIFICATE_NOT_READY = 49,
|
||||
AMT_STATUS_INVALID_HANDLE = 2053
|
||||
AMT_STATUS_NOT_FOUND = 2068,
|
||||
*/
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2018-2020 Intel Corporation
|
||||
Copyright 2018-2021 Intel Corporation
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2018-2020 Intel Corporation
|
||||
Copyright 2018-2021 Intel Corporation
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -21,8 +21,7 @@ limitations under the License.
|
||||
*/
|
||||
|
||||
// Construct a WSMAN communication object
|
||||
function CreateWsmanComm(/*host, port, user, pass, tls, extra*/)
|
||||
{
|
||||
function CreateWsmanComm(/*host, port, user, pass, tls, extra*/) {
|
||||
var obj = {};
|
||||
obj.PendingAjax = []; // List of pending AJAX calls. When one frees up, another will start.
|
||||
obj.ActiveAjaxCount = 0; // Number of currently active AJAX calls
|
||||
@@ -31,15 +30,13 @@ function CreateWsmanComm(/*host, port, user, pass, tls, extra*/)
|
||||
obj.digest = null;
|
||||
obj.RequestCount = 0;
|
||||
|
||||
if (arguments.length == 1 && typeof(arguments[0] == 'object'))
|
||||
{
|
||||
if (arguments.length == 1 && typeof (arguments[0] == 'object')) {
|
||||
obj.host = arguments[0].host;
|
||||
obj.port = arguments[0].port;
|
||||
obj.authToken = arguments[0].authToken;
|
||||
obj.tls = arguments[0].tls;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
obj.host = arguments[0];
|
||||
obj.port = arguments[1];
|
||||
obj.user = arguments[2];
|
||||
@@ -69,34 +66,32 @@ function CreateWsmanComm(/*host, port, user, pass, tls, extra*/)
|
||||
}
|
||||
|
||||
// Private method
|
||||
obj.PerformAjaxEx = function (postdata, callback, tag, url, action) {
|
||||
obj.PerformAjaxEx = function (postdata, callback, tag, url, action)
|
||||
{
|
||||
if (obj.FailAllError != 0) { if (obj.FailAllError != 999) { obj.gotNextMessagesError({ status: obj.FailAllError }, 'error', null, [postdata, callback, tag]); } return; }
|
||||
if (!postdata) postdata = "";
|
||||
//console.log("SEND: " + postdata); // DEBUG
|
||||
if (globalDebugFlags & 1) { console.log("SEND: " + postdata + "\r\n\r\n"); } // DEBUG
|
||||
|
||||
// We are in a DukTape environement
|
||||
if (obj.digest == null)
|
||||
{
|
||||
if (obj.authToken)
|
||||
{
|
||||
if (obj.digest == null) {
|
||||
if (obj.authToken) {
|
||||
obj.digest = require('http-digest').create({ authToken: obj.authToken });
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
obj.digest = require('http-digest').create(obj.user, obj.pass);
|
||||
}
|
||||
obj.digest.http = require('http');
|
||||
}
|
||||
var request = { protocol: (obj.tls == 1 ? 'https:' : 'http:'), method: 'POST', host: obj.host, path: '/wsman', port: obj.port, rejectUnauthorized: false, checkServerIdentity: function (cert) { console.log('checkServerIdentity', JSON.stringify(cert)); } };
|
||||
|
||||
var request = { delayWrite: true, protocol: (obj.tls == 1 ? 'https:' : 'http:'), method: 'POST', host: obj.host, path: '/wsman', port: obj.port, rejectUnauthorized: false, checkServerIdentity: function (cert) { /*console.log('checkServerIdentity', JSON.stringify(cert));*/ } };
|
||||
var req = obj.digest.request(request);
|
||||
//console.log('Request ' + (obj.RequestCount++));
|
||||
if (globalDebugFlags & 1) { console.log('Request ' + (obj.RequestCount++)); } // DEBUG
|
||||
|
||||
req.on('error', function (e) { obj.gotNextMessagesError({ status: 600 }, 'error', null, [postdata, callback, tag]); });
|
||||
req.on('response', function (response) {
|
||||
//console.log('Response: ' + response.statusCode);
|
||||
//console.log(JSON.stringify(response, null, 2));
|
||||
if (globalDebugFlags & 1) { console.log('Response: ' + response.statusCode); }
|
||||
if (response.statusCode != 200) {
|
||||
//console.log('ERR:' + JSON.stringify(response));
|
||||
if (globalDebugFlags & 1) { console.log('ERR:' + JSON.stringify(response)); }
|
||||
obj.gotNextMessagesError({ status: response.statusCode }, 'error', null, [postdata, callback, tag]);
|
||||
} else {
|
||||
response.acc = '';
|
||||
@@ -107,7 +102,6 @@ function CreateWsmanComm(/*host, port, user, pass, tls, extra*/)
|
||||
|
||||
// Send POST body, this work with binary.
|
||||
req.end(postdata);
|
||||
|
||||
obj.ActiveAjaxCount++;
|
||||
return req;
|
||||
}
|
||||
@@ -119,7 +113,7 @@ function CreateWsmanComm(/*host, port, user, pass, tls, extra*/)
|
||||
obj.gotNextMessages = function (data, status, request, callArgs) {
|
||||
obj.ActiveAjaxCount--;
|
||||
if (obj.FailAllError == 999) return;
|
||||
//console.log("RECV: " + data); // DEBUG
|
||||
if (globalDebugFlags & 1) { console.log("RECV: " + data + "\r\n\r\n"); } // DEBUG
|
||||
if (obj.FailAllError != 0) { callArgs[1](null, obj.FailAllError, callArgs[2]); return; }
|
||||
if (request.status != 200) { callArgs[1](null, request.status, callArgs[2]); return; }
|
||||
callArgs[1](data, 200, callArgs[2]);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2018-2020 Intel Corporation
|
||||
Copyright 2018-2021 Intel Corporation
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2018-2020 Intel Corporation
|
||||
Copyright 2018-2021 Intel Corporation
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -33,7 +33,8 @@ module.exports.ParseWsman = function (xml) {
|
||||
if (!body) return null;
|
||||
if (body.childNodes.length > 0) {
|
||||
t = body.childNodes[0].localName;
|
||||
if (t.indexOf("_OUTPUT") == t.length - 7) { t = t.substring(0, t.length - 7); }
|
||||
var x = t.indexOf('_OUTPUT');
|
||||
if ((x != -1) && (x == (t.length - 7))) { t = t.substring(0, t.length - 7); }
|
||||
r.Header['Method'] = t;
|
||||
r.Body = _ParseWsmanRec(body.childNodes[0]);
|
||||
}
|
||||
@@ -130,19 +131,19 @@ function _turnToXmlRec(text) {
|
||||
if (elementName[0] != '/') {
|
||||
var attributes = [], localName, localname2 = elementName.split(' ')[0].split(':'), localName = (localname2.length > 1) ? localname2[1] : localname2[0];
|
||||
Object.defineProperty(attributes, "get",
|
||||
{
|
||||
value: function () {
|
||||
if (arguments.length == 1) {
|
||||
for (var a in this) { if (this[a].name == arguments[0]) { return (this[a]); } }
|
||||
{
|
||||
value: function () {
|
||||
if (arguments.length == 1) {
|
||||
for (var a in this) { if (this[a].name == arguments[0]) { return (this[a]); } }
|
||||
}
|
||||
else if (arguments.length == 2) {
|
||||
for (var a in this) { if (this[a].name == arguments[1] && (arguments[0] == '*' || this[a].namespace == arguments[0])) { return (this[a]); } }
|
||||
}
|
||||
else {
|
||||
throw ('attributes.get(): Invalid number of parameters');
|
||||
}
|
||||
}
|
||||
else if (arguments.length == 2) {
|
||||
for (var a in this) { if (this[a].name == arguments[1] && (arguments[0] == '*' || this[a].namespace == arguments[0])) { return (this[a]); } }
|
||||
}
|
||||
else {
|
||||
throw ('attributes.get(): Invalid number of parameters');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
elementStack.push({ name: elementName, localName: localName, getChildElementsByTagName: _getChildElementsByTagName, getElementsByTagNameNS: _getElementsByTagNameNS, getChildElementsByTagNameNS: _getChildElementsByTagNameNS, attributes: attributes, childNodes: [], nsTable: {} });
|
||||
// Parse Attributes
|
||||
if (x3.length > 0) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2018-2020 Intel Corporation
|
||||
Copyright 2018-2021 Intel Corporation
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -300,6 +300,7 @@ function AmtStackCreateService(wsmanStack) {
|
||||
obj.CIM_AccountManagementService_CreateAccount = function (System, AccountTemplate, callback_func) { obj.Exec("CIM_AccountManagementService", "CreateAccount", { "System": System, "AccountTemplate": AccountTemplate }, callback_func); }
|
||||
obj.CIM_BootConfigSetting_ChangeBootOrder = function (Source, callback_func) { obj.Exec("CIM_BootConfigSetting", "ChangeBootOrder", { "Source": Source }, callback_func); }
|
||||
obj.CIM_BootService_SetBootConfigRole = function (BootConfigSetting, Role, callback_func) { obj.Exec("CIM_BootService", "SetBootConfigRole", { "BootConfigSetting": BootConfigSetting, "Role": Role }, callback_func, 0, 1); }
|
||||
obj.CIM_BootService_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec('CIM_BootService', 'RequestStateChange', { 'RequestedState': RequestedState, 'TimeoutPeriod': TimeoutPeriod }, callback_func, 0, 1); }
|
||||
obj.CIM_Card_ConnectorPower = function (Connector, PoweredOn, callback_func) { obj.Exec("CIM_Card", "ConnectorPower", { "Connector": Connector, "PoweredOn": PoweredOn }, callback_func); }
|
||||
obj.CIM_Card_IsCompatible = function (ElementToCheck, callback_func) { obj.Exec("CIM_Card", "IsCompatible", { "ElementToCheck": ElementToCheck }, callback_func); }
|
||||
obj.CIM_Chassis_IsCompatible = function (ElementToCheck, callback_func) { obj.Exec("CIM_Chassis", "IsCompatible", { "ElementToCheck": ElementToCheck }, callback_func); }
|
||||
@@ -487,7 +488,7 @@ function AmtStackCreateService(wsmanStack) {
|
||||
function _GetMessageLog1(stack, name, responses, status, tag) {
|
||||
if (status != 200 || responses.Body["ReturnValue"] != '0') { tag[0](obj, null, tag[2], status); return; }
|
||||
var i, j, x, e, AmtMessages = tag[2], t = new Date(), TimeStamp, ra = responses.Body["RecordArray"];
|
||||
if (typeof ra === 'string') { responses.Body["RecordArray"] = [responses.Body["RecordArray"]]; }
|
||||
if (typeof ra === 'string') { ra = [ra]; }
|
||||
|
||||
for (i in ra) {
|
||||
e = Buffer.from(ra[i], 'base64');
|
||||
@@ -613,7 +614,7 @@ function AmtStackCreateService(wsmanStack) {
|
||||
1611: 'TLS Trusted Root Certificate Removed',
|
||||
1612: 'TLS Preshared Key Set',
|
||||
1613: 'Kerberos Settings Modified',
|
||||
1614: 'Kerberos Master Key Modified',
|
||||
1614: 'Kerberos Main Key Modified',
|
||||
1615: 'Flash Wear out Counters Reset',
|
||||
1616: 'Power Package Modified',
|
||||
1617: 'Set Realm Authentication Mode',
|
||||
|
||||
Reference in New Issue
Block a user