1*617e2443SMark Logan /*******************************************************************************
2*617e2443SMark Logan * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
3*617e2443SMark Logan *
4*617e2443SMark Logan * Redistribution and use in source and binary forms, with or without
5*617e2443SMark Logan * modification, are permitted provided that the following conditions are met:
6*617e2443SMark Logan *
7*617e2443SMark Logan * - Redistributions of source code must retain the above copyright notice,
8*617e2443SMark Logan * this list of conditions and the following disclaimer.
9*617e2443SMark Logan *
10*617e2443SMark Logan * - Redistributions in binary form must reproduce the above copyright notice,
11*617e2443SMark Logan * this list of conditions and the following disclaimer in the documentation
12*617e2443SMark Logan * and/or other materials provided with the distribution.
13*617e2443SMark Logan *
14*617e2443SMark Logan * - Neither the name of Intel Corp. nor the names of its
15*617e2443SMark Logan * contributors may be used to endorse or promote products derived from this
16*617e2443SMark Logan * software without specific prior written permission.
17*617e2443SMark Logan *
18*617e2443SMark Logan * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
19*617e2443SMark Logan * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20*617e2443SMark Logan * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21*617e2443SMark Logan * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
22*617e2443SMark Logan * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23*617e2443SMark Logan * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24*617e2443SMark Logan * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25*617e2443SMark Logan * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26*617e2443SMark Logan * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27*617e2443SMark Logan * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28*617e2443SMark Logan * POSSIBILITY OF SUCH DAMAGE.
29*617e2443SMark Logan *******************************************************************************/
30*617e2443SMark Logan
31*617e2443SMark Logan //----------------------------------------------------------------------------
32*617e2443SMark Logan //
33*617e2443SMark Logan // File: PTHICommand.cpp
34*617e2443SMark Logan //
35*617e2443SMark Logan //----------------------------------------------------------------------------
36*617e2443SMark Logan
37*617e2443SMark Logan #ifdef HAVE_CONFIG_H
38*617e2443SMark Logan #include "config.h"
39*617e2443SMark Logan #endif
40*617e2443SMark Logan #include <cstdio>
41*617e2443SMark Logan #include <cstdlib>
42*617e2443SMark Logan #include "PTHICommand.h"
43*617e2443SMark Logan
44*617e2443SMark Logan
PTHICommand(bool verbose,unsigned long sendTimeout)45*617e2443SMark Logan PTHICommand::PTHICommand(bool verbose, unsigned long sendTimeout) :
46*617e2443SMark Logan PTHIClient(HECI_PTHI, verbose),
47*617e2443SMark Logan m_sendTimeout(sendTimeout)
48*617e2443SMark Logan {
49*617e2443SMark Logan }
50*617e2443SMark Logan
~PTHICommand(void)51*617e2443SMark Logan PTHICommand::~PTHICommand(void)
52*617e2443SMark Logan {
53*617e2443SMark Logan }
54*617e2443SMark Logan
_call(const unsigned char * command,UINT32 command_size,UINT8 ** readBuffer,UINT32 rcmd,unsigned int expSize)55*617e2443SMark Logan AMT_STATUS PTHICommand::_call(const unsigned char *command, UINT32 command_size, UINT8 **readBuffer, UINT32 rcmd, unsigned int expSize)
56*617e2443SMark Logan {
57*617e2443SMark Logan UINT32 inBuffSize;
58*617e2443SMark Logan UINT32 outBuffSize = 0;
59*617e2443SMark Logan
60*617e2443SMark Logan inBuffSize = PTHIClient.GetBufferSize();
61*617e2443SMark Logan *readBuffer = (UINT8 *)malloc(sizeof(UINT8) * inBuffSize);
62*617e2443SMark Logan if (NULL == *readBuffer)
63*617e2443SMark Logan {
64*617e2443SMark Logan return PTSDK_STATUS_RESOURCES;
65*617e2443SMark Logan }
66*617e2443SMark Logan memset(*readBuffer, 0, inBuffSize);
67*617e2443SMark Logan
68*617e2443SMark Logan int bytesWritten = PTHIClient.SendMessage(command, command_size, m_sendTimeout);
69*617e2443SMark Logan if ((UINT32)bytesWritten != command_size)
70*617e2443SMark Logan {
71*617e2443SMark Logan return AMT_STATUS_INTERNAL_ERROR;
72*617e2443SMark Logan }
73*617e2443SMark Logan outBuffSize = PTHIClient.ReceiveMessage(*readBuffer, inBuffSize);
74*617e2443SMark Logan if (0 == outBuffSize)
75*617e2443SMark Logan {
76*617e2443SMark Logan return PTHI_STATUS_EMPTY_RESPONSE;
77*617e2443SMark Logan }
78*617e2443SMark Logan AMT_STATUS status = ((PTHI_RESPONSE_MESSAGE_HEADER *)*readBuffer)->Status;
79*617e2443SMark Logan if (status != AMT_STATUS_SUCCESS)
80*617e2443SMark Logan {
81*617e2443SMark Logan return status;
82*617e2443SMark Logan }
83*617e2443SMark Logan status = _verifyResponseHeader(rcmd, ((PTHI_RESPONSE_MESSAGE_HEADER *)*readBuffer)->Header, outBuffSize);
84*617e2443SMark Logan if (status != AMT_STATUS_SUCCESS)
85*617e2443SMark Logan {
86*617e2443SMark Logan return status;
87*617e2443SMark Logan }
88*617e2443SMark Logan if ((expSize != 0) && (expSize != outBuffSize))
89*617e2443SMark Logan {
90*617e2443SMark Logan return PTSDK_STATUS_INTERNAL_ERROR;
91*617e2443SMark Logan }
92*617e2443SMark Logan return AMT_STATUS_SUCCESS;
93*617e2443SMark Logan }
94*617e2443SMark Logan
95*617e2443SMark Logan /*
96*617e2443SMark Logan * Confirms the correctness of the response message header
97*617e2443SMark Logan * and the response message size
98*617e2443SMark Logan * Arguments:
99*617e2443SMark Logan * command - appropriate Host interface command
100*617e2443SMark Logan * response_header - reference to the response message header
101*617e2443SMark Logan * response_size - value that holds the actual size of the
102*617e2443SMark Logan * response message
103*617e2443SMark Logan * expected_size - value that holds the expected size of the
104*617e2443SMark Logan * response message
105*617e2443SMark Logan * Return values:
106*617e2443SMark Logan * AMT_STATUS_SUCCESS - on success
107*617e2443SMark Logan * PTSDK_STATUS_INTERNAL_ERROR - on failure
108*617e2443SMark Logan */
_verifyResponseHeader(const UINT32 command,const PTHI_MESSAGE_HEADER & response_header,UINT32 response_size)109*617e2443SMark Logan AMT_STATUS PTHICommand::_verifyResponseHeader(
110*617e2443SMark Logan const UINT32 command, const PTHI_MESSAGE_HEADER &response_header,
111*617e2443SMark Logan UINT32 response_size)
112*617e2443SMark Logan {
113*617e2443SMark Logan AMT_STATUS status = AMT_STATUS_SUCCESS;
114*617e2443SMark Logan
115*617e2443SMark Logan if (response_size < sizeof(PTHI_RESPONSE_MESSAGE_HEADER)) {
116*617e2443SMark Logan status = AMT_STATUS_INTERNAL_ERROR;
117*617e2443SMark Logan } else if (response_size != (response_header.Length + sizeof(PTHI_MESSAGE_HEADER))) {
118*617e2443SMark Logan status = AMT_STATUS_INTERNAL_ERROR;
119*617e2443SMark Logan } else if (response_header.Command.cmd.val != command) {
120*617e2443SMark Logan status = AMT_STATUS_INTERNAL_ERROR;
121*617e2443SMark Logan } else if (response_header.Reserved != 0) {
122*617e2443SMark Logan status = AMT_STATUS_INTERNAL_ERROR;
123*617e2443SMark Logan } else if (response_header.Version.MajorNumber != AMT_MAJOR_VERSION
124*617e2443SMark Logan || response_header.Version.MinorNumber < AMT_MINOR_VERSION) {
125*617e2443SMark Logan status = AMT_STATUS_INTERNAL_ERROR;
126*617e2443SMark Logan }
127*617e2443SMark Logan
128*617e2443SMark Logan return status;
129*617e2443SMark Logan }
130*617e2443SMark Logan
131*617e2443SMark Logan /*
132*617e2443SMark Logan * Confirms the correctness of the GetCodeVersions response message
133*617e2443SMark Logan * Arguments:
134*617e2443SMark Logan * response - reference to the response message
135*617e2443SMark Logan * Return values:
136*617e2443SMark Logan * AMT_STATUS_SUCCESS - on success
137*617e2443SMark Logan * PTSDK_STATUS_INTERNAL_ERROR - on failure
138*617e2443SMark Logan */
_verifyCodeVersions(const CFG_GET_CODE_VERSIONS_RESPONSE & response)139*617e2443SMark Logan AMT_STATUS PTHICommand::_verifyCodeVersions(
140*617e2443SMark Logan const CFG_GET_CODE_VERSIONS_RESPONSE &response)
141*617e2443SMark Logan {
142*617e2443SMark Logan AMT_STATUS status = AMT_STATUS_SUCCESS;
143*617e2443SMark Logan UINT32 codeVerLen;
144*617e2443SMark Logan UINT32 ptVerTypeCount;
145*617e2443SMark Logan UINT32 len = 0;
146*617e2443SMark Logan UINT32 i;
147*617e2443SMark Logan
148*617e2443SMark Logan do {
149*617e2443SMark Logan codeVerLen = response.Header.Header.Length - sizeof(AMT_STATUS);
150*617e2443SMark Logan ptVerTypeCount = codeVerLen - sizeof(response.CodeVersions.BiosVersion)- sizeof(response.CodeVersions.VersionsCount);
151*617e2443SMark Logan if (response.CodeVersions.VersionsCount != (ptVerTypeCount/sizeof(AMT_VERSION_TYPE)))
152*617e2443SMark Logan {
153*617e2443SMark Logan status = AMT_STATUS_INTERNAL_ERROR;
154*617e2443SMark Logan break;
155*617e2443SMark Logan }
156*617e2443SMark Logan
157*617e2443SMark Logan for (i = 0; i < (response.CodeVersions.VersionsCount); i ++)
158*617e2443SMark Logan {
159*617e2443SMark Logan len = response.CodeVersions.Versions[i].Description.Length;
160*617e2443SMark Logan
161*617e2443SMark Logan if (len > UNICODE_STRING_LEN)
162*617e2443SMark Logan {
163*617e2443SMark Logan status = AMT_STATUS_INTERNAL_ERROR;
164*617e2443SMark Logan break;
165*617e2443SMark Logan }
166*617e2443SMark Logan
167*617e2443SMark Logan len = response.CodeVersions.Versions[i].Version.Length;
168*617e2443SMark Logan if (response.CodeVersions.Versions[i].Version.String[len] != '\0' ||
169*617e2443SMark Logan (len != strlen((CHAR *)(response.CodeVersions.Versions[i].Version.String))))
170*617e2443SMark Logan {
171*617e2443SMark Logan status = AMT_STATUS_INTERNAL_ERROR;
172*617e2443SMark Logan break;
173*617e2443SMark Logan }
174*617e2443SMark Logan }
175*617e2443SMark Logan } while (0);
176*617e2443SMark Logan
177*617e2443SMark Logan return status;
178*617e2443SMark Logan }
179*617e2443SMark Logan
180*617e2443SMark Logan /*
181*617e2443SMark Logan * GetVersions response message PTHI command
182*617e2443SMark Logan * Arguments:
183*617e2443SMark Logan * response - reference to the CODE_VERSIONS struct
184*617e2443SMark Logan * Return values:
185*617e2443SMark Logan * AMT_STATUS_SUCCESS - on success
186*617e2443SMark Logan * AMT_STATUS_INTERNAL_ERROR - on failure
187*617e2443SMark Logan */
GetCodeVersions(CODE_VERSIONS & codeVersions)188*617e2443SMark Logan AMT_STATUS PTHICommand::GetCodeVersions(CODE_VERSIONS &codeVersions)
189*617e2443SMark Logan {
190*617e2443SMark Logan UINT8 *readBuffer = NULL;
191*617e2443SMark Logan const UINT32 command_size = sizeof(GET_CODE_VERSION_HEADER);
192*617e2443SMark Logan unsigned char command[command_size];
193*617e2443SMark Logan memcpy(command, &(GET_CODE_VERSION_HEADER), sizeof(GET_CODE_VERSION_HEADER));
194*617e2443SMark Logan
195*617e2443SMark Logan AMT_STATUS status = _call(command, command_size, &readBuffer, CODE_VERSIONS_RESPONSE, 0);
196*617e2443SMark Logan do {
197*617e2443SMark Logan if (status != AMT_STATUS_SUCCESS)
198*617e2443SMark Logan {
199*617e2443SMark Logan break;
200*617e2443SMark Logan }
201*617e2443SMark Logan CFG_GET_CODE_VERSIONS_RESPONSE *tmp_response = (CFG_GET_CODE_VERSIONS_RESPONSE *)readBuffer;
202*617e2443SMark Logan status = _verifyCodeVersions(*tmp_response);
203*617e2443SMark Logan if (status != AMT_STATUS_SUCCESS)
204*617e2443SMark Logan {
205*617e2443SMark Logan break;
206*617e2443SMark Logan }
207*617e2443SMark Logan
208*617e2443SMark Logan memcpy(&codeVersions, &(tmp_response->CodeVersions), sizeof(CODE_VERSIONS));
209*617e2443SMark Logan
210*617e2443SMark Logan } while (0);
211*617e2443SMark Logan if (readBuffer != NULL)
212*617e2443SMark Logan {
213*617e2443SMark Logan free(readBuffer);
214*617e2443SMark Logan }
215*617e2443SMark Logan return status;
216*617e2443SMark Logan }
217*617e2443SMark Logan
218*617e2443SMark Logan /*
219*617e2443SMark Logan * Calls to GetProvisioningMode Host interface command
220*617e2443SMark Logan * Arguments:
221*617e2443SMark Logan * mode - reference to the pre-allocated structure
222*617e2443SMark Logan * which will hold the result
223*617e2443SMark Logan * Return values:
224*617e2443SMark Logan * AMT_STATUS_SUCCESS - on success
225*617e2443SMark Logan * appropriate error value defined in StatusCodeDefinitions.h - on failure
226*617e2443SMark Logan */
GetProvisioningMode(CFG_PROVISIONING_MODE & mode)227*617e2443SMark Logan AMT_STATUS PTHICommand::GetProvisioningMode(CFG_PROVISIONING_MODE &mode)
228*617e2443SMark Logan {
229*617e2443SMark Logan UINT8 *readBuffer = NULL;
230*617e2443SMark Logan const UINT32 command_size = sizeof(GET_PROVISIONING_MODE_HEADER);
231*617e2443SMark Logan unsigned char command[command_size];
232*617e2443SMark Logan memcpy(command, &(GET_PROVISIONING_MODE_HEADER), sizeof(GET_PROVISIONING_MODE_HEADER));
233*617e2443SMark Logan
234*617e2443SMark Logan AMT_STATUS status = _call(command, command_size, &readBuffer, PROVISIONING_MODE_RESPONSE, sizeof(CFG_GET_PROVISIONING_MODE_RESPONSE));
235*617e2443SMark Logan do {
236*617e2443SMark Logan if (status != AMT_STATUS_SUCCESS)
237*617e2443SMark Logan {
238*617e2443SMark Logan break;
239*617e2443SMark Logan }
240*617e2443SMark Logan CFG_GET_PROVISIONING_MODE_RESPONSE *tmp_response = (CFG_GET_PROVISIONING_MODE_RESPONSE *)readBuffer;
241*617e2443SMark Logan
242*617e2443SMark Logan mode = tmp_response->ProvisioningMode;
243*617e2443SMark Logan
244*617e2443SMark Logan } while (0);
245*617e2443SMark Logan if (readBuffer != NULL)
246*617e2443SMark Logan {
247*617e2443SMark Logan free(readBuffer);
248*617e2443SMark Logan }
249*617e2443SMark Logan return status;
250*617e2443SMark Logan }
GetProvisioningMode(CFG_PROVISIONING_MODE & mode,AMT_BOOLEAN & legacy)251*617e2443SMark Logan AMT_STATUS PTHICommand::GetProvisioningMode(CFG_PROVISIONING_MODE &mode, AMT_BOOLEAN &legacy)
252*617e2443SMark Logan {
253*617e2443SMark Logan UINT8 *readBuffer = NULL;
254*617e2443SMark Logan const UINT32 command_size = sizeof(GET_PROVISIONING_MODE_HEADER);
255*617e2443SMark Logan unsigned char command[command_size];
256*617e2443SMark Logan memcpy(command, &(GET_PROVISIONING_MODE_HEADER), sizeof(GET_PROVISIONING_MODE_HEADER));
257*617e2443SMark Logan
258*617e2443SMark Logan AMT_STATUS status = _call(command, command_size, &readBuffer, PROVISIONING_MODE_RESPONSE, sizeof(CFG_GET_PROVISIONING_MODE_RESPONSE));
259*617e2443SMark Logan do {
260*617e2443SMark Logan if (status != AMT_STATUS_SUCCESS)
261*617e2443SMark Logan {
262*617e2443SMark Logan break;
263*617e2443SMark Logan }
264*617e2443SMark Logan CFG_GET_PROVISIONING_MODE_RESPONSE *tmp_response = (CFG_GET_PROVISIONING_MODE_RESPONSE *)readBuffer;
265*617e2443SMark Logan
266*617e2443SMark Logan mode = tmp_response->ProvisioningMode;
267*617e2443SMark Logan legacy = tmp_response->LegacyMode;
268*617e2443SMark Logan
269*617e2443SMark Logan } while (0);
270*617e2443SMark Logan if (readBuffer != NULL)
271*617e2443SMark Logan {
272*617e2443SMark Logan free(readBuffer);
273*617e2443SMark Logan }
274*617e2443SMark Logan return status;
275*617e2443SMark Logan }
276*617e2443SMark Logan
277*617e2443SMark Logan /*
278*617e2443SMark Logan * Calls to GetProvisioningState Host interface command
279*617e2443SMark Logan * Arguments:
280*617e2443SMark Logan * state - reference to the pre-allocated structure
281*617e2443SMark Logan * which will hold the result
282*617e2443SMark Logan * Return values:
283*617e2443SMark Logan * AMT_STATUS_SUCCESS - on success
284*617e2443SMark Logan * appropriate error value defined in StatusCodeDefinitions.h - on failure
285*617e2443SMark Logan */
GetProvisioningState(AMT_PROVISIONING_STATE & state)286*617e2443SMark Logan AMT_STATUS PTHICommand::GetProvisioningState(AMT_PROVISIONING_STATE &state)
287*617e2443SMark Logan {
288*617e2443SMark Logan UINT8 *readBuffer = NULL;
289*617e2443SMark Logan const UINT32 command_size = sizeof(GET_PROVISIONING_STATE_HEADER);
290*617e2443SMark Logan unsigned char command[command_size];
291*617e2443SMark Logan memcpy(command, &(GET_PROVISIONING_STATE_HEADER), sizeof(GET_PROVISIONING_STATE_HEADER));
292*617e2443SMark Logan
293*617e2443SMark Logan AMT_STATUS status = _call(command, command_size, &readBuffer, PROVISIONING_STATE_RESPONSE, sizeof(CFG_GET_PROVISIONING_STATE_RESPONSE));
294*617e2443SMark Logan do {
295*617e2443SMark Logan if (status != AMT_STATUS_SUCCESS)
296*617e2443SMark Logan {
297*617e2443SMark Logan break;
298*617e2443SMark Logan }
299*617e2443SMark Logan CFG_GET_PROVISIONING_STATE_RESPONSE *tmp_response = (CFG_GET_PROVISIONING_STATE_RESPONSE *)readBuffer;
300*617e2443SMark Logan
301*617e2443SMark Logan state = tmp_response->ProvisioningState;
302*617e2443SMark Logan
303*617e2443SMark Logan } while (0);
304*617e2443SMark Logan if (readBuffer != NULL)
305*617e2443SMark Logan {
306*617e2443SMark Logan free(readBuffer);
307*617e2443SMark Logan }
308*617e2443SMark Logan return status;
309*617e2443SMark Logan }
310*617e2443SMark Logan
311*617e2443SMark Logan /*
312*617e2443SMark Logan * Calls to GetFeatureState Host interface command
313*617e2443SMark Logan * Arguments:
314*617e2443SMark Logan * requestID Indicates what feature status to query:
315*617e2443SMark Logan * 0 Redirection Sessions Status
316*617e2443SMark Logan * 1 System Defense Status
317*617e2443SMark Logan * 2 WebUI Status
318*617e2443SMark Logan * requestStatus The requested feature state(the size depand on the requestID).(OUT)
319*617e2443SMark Logan *
320*617e2443SMark Logan * Return values:
321*617e2443SMark Logan * AMT_STATUS_SUCCESS - on success
322*617e2443SMark Logan * appropriate error value defined in StatusCodeDefinitions.h - on failure
323*617e2443SMark Logan */
GetFeaturesState(UINT32 requestID,AMT_BOOLEAN (& requestStatus)[2])324*617e2443SMark Logan AMT_STATUS PTHICommand::GetFeaturesState(UINT32 requestID, AMT_BOOLEAN (&requestStatus)[2])
325*617e2443SMark Logan {
326*617e2443SMark Logan UINT8 *readBuffer = NULL;
327*617e2443SMark Logan const UINT32 command_size = sizeof(CFG_GET_FEATURES_STATE_REQUEST);
328*617e2443SMark Logan unsigned char command[command_size];
329*617e2443SMark Logan
330*617e2443SMark Logan memcpy(command, &GET_FEATURES_STATE_HEADER, sizeof(GET_FEATURES_STATE_HEADER));
331*617e2443SMark Logan memcpy(command + sizeof(GET_FEATURES_STATE_HEADER), &(requestID), sizeof(UINT32));
332*617e2443SMark Logan
333*617e2443SMark Logan AMT_STATUS status = _call(command, command_size, &readBuffer, GET_FEATURES_STATE_RESPONSE, sizeof(CFG_GET_FEATURES_STATE_RESPONSE));
334*617e2443SMark Logan do {
335*617e2443SMark Logan if (status != AMT_STATUS_SUCCESS)
336*617e2443SMark Logan {
337*617e2443SMark Logan break;
338*617e2443SMark Logan }
339*617e2443SMark Logan CFG_GET_FEATURES_STATE_RESPONSE *tmp_response = (CFG_GET_FEATURES_STATE_RESPONSE *)readBuffer;
340*617e2443SMark Logan
341*617e2443SMark Logan GET_FEATURES_REDIRECTION_SESSION_STATUS redirectionState;
342*617e2443SMark Logan GET_FEATURES_SYSTEM_DEFENSE_STATUS_RESPONSE systemDefenseState;
343*617e2443SMark Logan GET_FEATURES_WEB_UI_STATUS_RESPONSE webUIState;
344*617e2443SMark Logan switch (requestID)
345*617e2443SMark Logan {
346*617e2443SMark Logan case REDIRECTION_SESSION:
347*617e2443SMark Logan redirectionState = tmp_response->Data.rs;
348*617e2443SMark Logan requestStatus[0] = redirectionState.SolOpen;
349*617e2443SMark Logan requestStatus[1] = redirectionState.IderOpen;
350*617e2443SMark Logan break;
351*617e2443SMark Logan
352*617e2443SMark Logan case SYSTEM_DEFENSE:
353*617e2443SMark Logan systemDefenseState = tmp_response->Data.sd;
354*617e2443SMark Logan requestStatus[0] = systemDefenseState.SystemDefenseActivated;
355*617e2443SMark Logan break;
356*617e2443SMark Logan
357*617e2443SMark Logan case WEB_UI:
358*617e2443SMark Logan webUIState = tmp_response->Data.webUI;
359*617e2443SMark Logan requestStatus[0] = webUIState.WebUiEnabled;
360*617e2443SMark Logan break;
361*617e2443SMark Logan }
362*617e2443SMark Logan } while (0);
363*617e2443SMark Logan if (readBuffer != NULL)
364*617e2443SMark Logan {
365*617e2443SMark Logan free(readBuffer);
366*617e2443SMark Logan }
367*617e2443SMark Logan return status;
368*617e2443SMark Logan }
369*617e2443SMark Logan
370*617e2443SMark Logan /*
371*617e2443SMark Logan * Calls to GetLastHostResetReason Host interface command
372*617e2443SMark Logan * Arguments:
373*617e2443SMark Logan * reason Indicates whether the last host reason was because of remote control operation(0)
374*617e2443SMark Logan * or other reason(1). (OUT)
375*617e2443SMark Logan * remoteControlTimeStamp In case the reason was due to remote control then this field
376*617e2443SMark Logan * indicates the timestamp of when the remote control command has been executed.
377*617e2443SMark Logan * (The timestamp is the number of seconds since 1/1/1970)
378*617e2443SMark Logan *
379*617e2443SMark Logan * Return values:
380*617e2443SMark Logan * AMT_STATUS_SUCCESS - on success
381*617e2443SMark Logan * appropriate error value defined in StatusCodeDefinitions.h - on failure
382*617e2443SMark Logan */
GetLastHostResetReason(UINT32 & reason,UINT32 & remoteControlTimeStamp)383*617e2443SMark Logan AMT_STATUS PTHICommand::GetLastHostResetReason(UINT32 &reason, UINT32 &remoteControlTimeStamp)
384*617e2443SMark Logan {
385*617e2443SMark Logan UINT8 *readBuffer = NULL;
386*617e2443SMark Logan const UINT32 command_size = sizeof(GET_LAST_HOST_RESET_REASON_HEADER);
387*617e2443SMark Logan unsigned char command[command_size];
388*617e2443SMark Logan memcpy(command, &(GET_LAST_HOST_RESET_REASON_HEADER), sizeof(GET_LAST_HOST_RESET_REASON_HEADER));
389*617e2443SMark Logan
390*617e2443SMark Logan AMT_STATUS status = _call(command, command_size, &readBuffer, GET_LAST_HOST_RESET_REASON_RESPONSE, sizeof(CFG_GET_LAST_HOST_RESET_REASON_RESPONSE));
391*617e2443SMark Logan do {
392*617e2443SMark Logan if (status != AMT_STATUS_SUCCESS)
393*617e2443SMark Logan {
394*617e2443SMark Logan break;
395*617e2443SMark Logan }
396*617e2443SMark Logan CFG_GET_LAST_HOST_RESET_REASON_RESPONSE *tmp_response = (CFG_GET_LAST_HOST_RESET_REASON_RESPONSE *)readBuffer;
397*617e2443SMark Logan
398*617e2443SMark Logan reason = tmp_response->Reason;
399*617e2443SMark Logan remoteControlTimeStamp = tmp_response->RemoteControlTimeStamp;
400*617e2443SMark Logan
401*617e2443SMark Logan } while (0);
402*617e2443SMark Logan if (readBuffer != NULL)
403*617e2443SMark Logan {
404*617e2443SMark Logan free(readBuffer);
405*617e2443SMark Logan }
406*617e2443SMark Logan return status;
407*617e2443SMark Logan }
408*617e2443SMark Logan
409*617e2443SMark Logan /*
410*617e2443SMark Logan * Calls to GetCurrentPowerPolicy Host interface command
411*617e2443SMark Logan * Arguments:
412*617e2443SMark Logan * policyName The power policy name. (OUT)
413*617e2443SMark Logan * Return values:
414*617e2443SMark Logan * AMT_STATUS_SUCCESS - on success
415*617e2443SMark Logan * appropriate error value defined in StatusCodeDefinitions.h - on failure
416*617e2443SMark Logan */
GetCurrentPowerPolicy(AMT_ANSI_STRING & policyName)417*617e2443SMark Logan AMT_STATUS PTHICommand::GetCurrentPowerPolicy(AMT_ANSI_STRING &policyName)
418*617e2443SMark Logan {
419*617e2443SMark Logan UINT8 *readBuffer = NULL;
420*617e2443SMark Logan const UINT32 command_size = sizeof(GET_CURRENT_POWER_POLICY_HEADER);
421*617e2443SMark Logan unsigned char command[command_size];
422*617e2443SMark Logan memcpy(command, &(GET_CURRENT_POWER_POLICY_HEADER), sizeof(GET_CURRENT_POWER_POLICY_HEADER));
423*617e2443SMark Logan
424*617e2443SMark Logan AMT_STATUS status = _call(command, command_size, &readBuffer, GET_CURRENT_POWER_POLICY_RESPONSE, 0);
425*617e2443SMark Logan do {
426*617e2443SMark Logan if (status != AMT_STATUS_SUCCESS)
427*617e2443SMark Logan {
428*617e2443SMark Logan break;
429*617e2443SMark Logan }
430*617e2443SMark Logan CFG_GET_CURRENT_POWER_POLICY_RESPONSE *tmp_response = (CFG_GET_CURRENT_POWER_POLICY_RESPONSE *)readBuffer;
431*617e2443SMark Logan status = _verifyCurrentPowerPolicy(*tmp_response);
432*617e2443SMark Logan if (status != AMT_STATUS_SUCCESS)
433*617e2443SMark Logan {
434*617e2443SMark Logan break;
435*617e2443SMark Logan }
436*617e2443SMark Logan
437*617e2443SMark Logan policyName.Length = tmp_response->PolicyName.Length;
438*617e2443SMark Logan policyName.Buffer = (CHAR *)malloc(policyName.Length * sizeof(CHAR));
439*617e2443SMark Logan if (NULL == policyName.Buffer) {
440*617e2443SMark Logan status = AMT_STATUS_INTERNAL_ERROR;
441*617e2443SMark Logan } else {
442*617e2443SMark Logan memcpy(policyName.Buffer, &(tmp_response->PolicyName.Buffer),
443*617e2443SMark Logan policyName.Length * sizeof(CHAR));
444*617e2443SMark Logan }
445*617e2443SMark Logan } while (0);
446*617e2443SMark Logan if (readBuffer != NULL)
447*617e2443SMark Logan {
448*617e2443SMark Logan free(readBuffer);
449*617e2443SMark Logan }
450*617e2443SMark Logan return status;
451*617e2443SMark Logan }
452*617e2443SMark Logan
453*617e2443SMark Logan /*
454*617e2443SMark Logan * Confirms the correctness of the GetCurrentPowerPolicy response message
455*617e2443SMark Logan * Arguments:
456*617e2443SMark Logan * response - reference to the response message
457*617e2443SMark Logan * Return values:
458*617e2443SMark Logan * AMT_STATUS_SUCCESS - on success
459*617e2443SMark Logan * PTSDK_STATUS_INTERNAL_ERROR - on failure
460*617e2443SMark Logan */
_verifyCurrentPowerPolicy(const CFG_GET_CURRENT_POWER_POLICY_RESPONSE & response)461*617e2443SMark Logan AMT_STATUS PTHICommand::_verifyCurrentPowerPolicy(const CFG_GET_CURRENT_POWER_POLICY_RESPONSE &response)
462*617e2443SMark Logan {
463*617e2443SMark Logan ULONG ByteCount = response.Header.Header.Length;
464*617e2443SMark Logan if (ByteCount != (sizeof(CFG_GET_CURRENT_POWER_POLICY_RESPONSE)
465*617e2443SMark Logan - sizeof(PTHI_MESSAGE_HEADER) - sizeof(CHAR *)
466*617e2443SMark Logan + response.PolicyName.Length))
467*617e2443SMark Logan {
468*617e2443SMark Logan return PTSDK_STATUS_INTERNAL_ERROR;
469*617e2443SMark Logan }
470*617e2443SMark Logan return AMT_STATUS_SUCCESS;
471*617e2443SMark Logan }
472*617e2443SMark Logan
473*617e2443SMark Logan /*
474*617e2443SMark Logan * Calls to GetLanInterfaceSttings Host interface command
475*617e2443SMark Logan * Arguments:
476*617e2443SMark Logan * interfaceSettings The interface to get the settings for.
477*617e2443SMark Logan * lanSettings reference to a pre allocated struct which will hold the lan settings. (OUT)
478*617e2443SMark Logan * Return values:
479*617e2443SMark Logan * AMT_STATUS_SUCCESS - on success
480*617e2443SMark Logan * appropriate error value defined in StatusCodeDefinitions.h - on failure
481*617e2443SMark Logan */
GetLanInterfaceSettings(UINT32 interfaceSettings,LAN_SETTINGS & lanSettings)482*617e2443SMark Logan AMT_STATUS PTHICommand::GetLanInterfaceSettings(UINT32 interfaceSettings, LAN_SETTINGS &lanSettings)
483*617e2443SMark Logan {
484*617e2443SMark Logan UINT8 *readBuffer = NULL;
485*617e2443SMark Logan const UINT32 command_size = sizeof(CFG_GET_LAN_INTERFACE_SETTINGS_REQUEST);
486*617e2443SMark Logan unsigned char command[command_size];
487*617e2443SMark Logan
488*617e2443SMark Logan memcpy(command, &(GET_LAN_INTERFACE_SETTINGS_HEADER), sizeof(GET_LAN_INTERFACE_SETTINGS_HEADER));
489*617e2443SMark Logan memcpy(command + sizeof(GET_LAN_INTERFACE_SETTINGS_HEADER),
490*617e2443SMark Logan &(interfaceSettings), sizeof(UINT32));
491*617e2443SMark Logan
492*617e2443SMark Logan AMT_STATUS status = _call(command, command_size, &readBuffer, GET_LAN_INTERFACE_SETTINGS_RESPONSE, sizeof(CFG_GET_LAN_INTERFACE_SETTINGS_RESPONSE));
493*617e2443SMark Logan do {
494*617e2443SMark Logan if (status != AMT_STATUS_SUCCESS)
495*617e2443SMark Logan {
496*617e2443SMark Logan break;
497*617e2443SMark Logan }
498*617e2443SMark Logan CFG_GET_LAN_INTERFACE_SETTINGS_RESPONSE *tmp_response = (CFG_GET_LAN_INTERFACE_SETTINGS_RESPONSE *)readBuffer;
499*617e2443SMark Logan
500*617e2443SMark Logan lanSettings.Enabled = tmp_response->Enabled;
501*617e2443SMark Logan lanSettings.Ipv4Address = tmp_response->Ipv4Address;
502*617e2443SMark Logan lanSettings.DhcpEnabled = tmp_response->DhcpEnabled;
503*617e2443SMark Logan lanSettings.DhcpIpMode = tmp_response->DhcpIpMode;
504*617e2443SMark Logan lanSettings.LinkStatus = tmp_response->LinkStatus;
505*617e2443SMark Logan memcpy(lanSettings.MacAddress, tmp_response->MacAddress, sizeof(tmp_response->MacAddress));
506*617e2443SMark Logan
507*617e2443SMark Logan } while (0);
508*617e2443SMark Logan if (readBuffer != NULL)
509*617e2443SMark Logan {
510*617e2443SMark Logan free(readBuffer);
511*617e2443SMark Logan }
512*617e2443SMark Logan return status;
513*617e2443SMark Logan }
514*617e2443SMark Logan
515*617e2443SMark Logan /**
516*617e2443SMark Logan * Gets the HECI driver version
517*617e2443SMark Logan * Arguments:
518*617e2443SMark Logan * heciVersion - pointewr to HECI_VERSION struct (out)
519*617e2443SMark Logan * Return values:
520*617e2443SMark Logan * AMT_STATUS_SUCCESS - on success
521*617e2443SMark Logan * PTSDK_STATUS_INVALID_PARAM - on failure
522*617e2443SMark Logan */
GetHeciVersion(HECI_VERSION & heciVersion)523*617e2443SMark Logan AMT_STATUS PTHICommand::GetHeciVersion(HECI_VERSION &heciVersion)
524*617e2443SMark Logan {
525*617e2443SMark Logan if (PTHIClient.GetHeciVersion(heciVersion)) {
526*617e2443SMark Logan return AMT_STATUS_SUCCESS;
527*617e2443SMark Logan }
528*617e2443SMark Logan return AMT_STATUS_INTERNAL_ERROR;
529*617e2443SMark Logan }
530*617e2443SMark Logan
531*617e2443SMark Logan /*
532*617e2443SMark Logan * Calls to GetSecurityParameters Host interface command
533*617e2443SMark Logan * Arguments:
534*617e2443SMark Logan * tlsEnabled true if AMT on TLS mode. (OUT)
535*617e2443SMark Logan * Return values:
536*617e2443SMark Logan * AMT_STATUS_SUCCESS - on success
537*617e2443SMark Logan * appropriate error value defined in StatusCodeDefinitions.h - on failure
538*617e2443SMark Logan */
GetTLSEnabled(AMT_BOOLEAN & tlsEnabled)539*617e2443SMark Logan AMT_STATUS PTHICommand::GetTLSEnabled(AMT_BOOLEAN &tlsEnabled)
540*617e2443SMark Logan {
541*617e2443SMark Logan UINT8 *readBuffer = NULL;
542*617e2443SMark Logan const UINT32 command_size = sizeof(GET_SECURITY_PARAMETERS_HEADER);
543*617e2443SMark Logan unsigned char command[command_size];
544*617e2443SMark Logan memcpy(command, &(GET_SECURITY_PARAMETERS_HEADER), sizeof(GET_SECURITY_PARAMETERS_HEADER));
545*617e2443SMark Logan
546*617e2443SMark Logan AMT_STATUS status = _call(command, command_size, &readBuffer, GET_SECURITY_PARAMETERS_RESPONSE, sizeof(CFG_GET_SECURITY_PARAMETERS_RESPONSE));
547*617e2443SMark Logan do {
548*617e2443SMark Logan if (status != AMT_STATUS_SUCCESS)
549*617e2443SMark Logan {
550*617e2443SMark Logan break;
551*617e2443SMark Logan }
552*617e2443SMark Logan CFG_GET_SECURITY_PARAMETERS_RESPONSE *tmp_response = (CFG_GET_SECURITY_PARAMETERS_RESPONSE *)readBuffer;
553*617e2443SMark Logan
554*617e2443SMark Logan tlsEnabled = tmp_response->TLSEnabled;
555*617e2443SMark Logan
556*617e2443SMark Logan } while (0);
557*617e2443SMark Logan if (readBuffer != NULL)
558*617e2443SMark Logan {
559*617e2443SMark Logan free(readBuffer);
560*617e2443SMark Logan }
561*617e2443SMark Logan return status;
562*617e2443SMark Logan }
563*617e2443SMark Logan
564*617e2443SMark Logan /*
565*617e2443SMark Logan * Calls to GetDNSSuffixList Host interface command
566*617e2443SMark Logan * Arguments:
567*617e2443SMark Logan * dnsSuffixList reference to list of DNS suffix strings. (OUT)
568*617e2443SMark Logan * Return values:
569*617e2443SMark Logan * AMT_STATUS_SUCCESS - on success
570*617e2443SMark Logan * appropriate error value defined in StatusCodeDefinitions.h - on failure
571*617e2443SMark Logan */
GetDNSSuffixList(std::list<std::string> & dnsSuffixList)572*617e2443SMark Logan AMT_STATUS PTHICommand::GetDNSSuffixList(std::list<std::string> &dnsSuffixList)
573*617e2443SMark Logan {
574*617e2443SMark Logan UINT8 *readBuffer = NULL;
575*617e2443SMark Logan const UINT32 command_size = sizeof(GET_DNS_SUFFIX_LIST_HEADER);
576*617e2443SMark Logan unsigned char command[command_size];
577*617e2443SMark Logan memcpy(command, &(GET_DNS_SUFFIX_LIST_HEADER), sizeof(GET_DNS_SUFFIX_LIST_HEADER));
578*617e2443SMark Logan
579*617e2443SMark Logan AMT_STATUS status = _call(command, command_size, &readBuffer, GET_DNS_SUFFIX_LIST_RESPONSE, 0);
580*617e2443SMark Logan do {
581*617e2443SMark Logan if (status != AMT_STATUS_SUCCESS)
582*617e2443SMark Logan {
583*617e2443SMark Logan break;
584*617e2443SMark Logan }
585*617e2443SMark Logan CFG_GET_DNS_SUFFIX_LIST_RESPONSE *tmp_response = (CFG_GET_DNS_SUFFIX_LIST_RESPONSE *)readBuffer;
586*617e2443SMark Logan status = _verifyGetDNSSuffixList(*tmp_response);
587*617e2443SMark Logan if (status != AMT_STATUS_SUCCESS)
588*617e2443SMark Logan {
589*617e2443SMark Logan break;
590*617e2443SMark Logan }
591*617e2443SMark Logan
592*617e2443SMark Logan char *current = (char *)tmp_response->Data;
593*617e2443SMark Logan while (current < (char *)tmp_response->Data + tmp_response->DataLength)
594*617e2443SMark Logan {
595*617e2443SMark Logan std::string dnsSuffix = current;
596*617e2443SMark Logan if (dnsSuffix.length() > tmp_response->DataLength)
597*617e2443SMark Logan {
598*617e2443SMark Logan status = PTSDK_STATUS_INTERNAL_ERROR;
599*617e2443SMark Logan break;
600*617e2443SMark Logan }
601*617e2443SMark Logan if (!dnsSuffix.empty())
602*617e2443SMark Logan {
603*617e2443SMark Logan dnsSuffixList.push_back(dnsSuffix);
604*617e2443SMark Logan }
605*617e2443SMark Logan current += dnsSuffix.length() + 1;
606*617e2443SMark Logan }
607*617e2443SMark Logan } while (0);
608*617e2443SMark Logan
609*617e2443SMark Logan if (readBuffer != NULL)
610*617e2443SMark Logan {
611*617e2443SMark Logan free(readBuffer);
612*617e2443SMark Logan }
613*617e2443SMark Logan return status;
614*617e2443SMark Logan }
615*617e2443SMark Logan
616*617e2443SMark Logan /*
617*617e2443SMark Logan * Confirms the correctness of the GetDNSSuffixList response message
618*617e2443SMark Logan * Arguments:
619*617e2443SMark Logan * response - reference to the response message
620*617e2443SMark Logan * Return values:
621*617e2443SMark Logan * AMT_STATUS_SUCCESS - on success
622*617e2443SMark Logan * PTSDK_STATUS_INTERNAL_ERROR - on failure
623*617e2443SMark Logan */
_verifyGetDNSSuffixList(const CFG_GET_DNS_SUFFIX_LIST_RESPONSE & response)624*617e2443SMark Logan AMT_STATUS PTHICommand::_verifyGetDNSSuffixList(const CFG_GET_DNS_SUFFIX_LIST_RESPONSE &response)
625*617e2443SMark Logan {
626*617e2443SMark Logan ULONG ByteCount = response.Header.Header.Length;
627*617e2443SMark Logan if (ByteCount != (sizeof(CFG_GET_DNS_SUFFIX_LIST_RESPONSE)
628*617e2443SMark Logan - sizeof(PTHI_MESSAGE_HEADER)
629*617e2443SMark Logan + response.DataLength))
630*617e2443SMark Logan {
631*617e2443SMark Logan return PTSDK_STATUS_INTERNAL_ERROR;
632*617e2443SMark Logan }
633*617e2443SMark Logan return AMT_STATUS_SUCCESS;
634*617e2443SMark Logan }
635*617e2443SMark Logan
636*617e2443SMark Logan /*
637*617e2443SMark Logan * Calls to SetEnterpriseAccess Host interface command
638*617e2443SMark Logan * Arguments:
639*617e2443SMark Logan * Flags flags
640*617e2443SMark Logan * HostIPAddress host IP address for enterprise access
641*617e2443SMark Logan * EnterpriseAccess enterprise access mode
642*617e2443SMark Logan * Return values:
643*617e2443SMark Logan * AMT_STATUS_SUCCESS - on success
644*617e2443SMark Logan * appropriate error value defined in StatusCodeDefinitions.h - on failure
645*617e2443SMark Logan */
SetEnterpriseAccess(UINT8 Flags,UINT8 HostIPAddress[16],UINT8 EnterpriseAccess)646*617e2443SMark Logan AMT_STATUS PTHICommand::SetEnterpriseAccess(UINT8 Flags, UINT8 HostIPAddress[16], UINT8 EnterpriseAccess)
647*617e2443SMark Logan {
648*617e2443SMark Logan UINT8 *readBuffer = NULL;
649*617e2443SMark Logan const UINT32 command_size = sizeof(CFG_SET_ENTERPRISE_ACCESS_REQUEST);
650*617e2443SMark Logan unsigned char command[command_size];
651*617e2443SMark Logan
652*617e2443SMark Logan memcpy(command, &(SET_ENTERPRISE_ACCESS_HEADER), sizeof(SET_ENTERPRISE_ACCESS_HEADER));
653*617e2443SMark Logan memcpy(command + sizeof(SET_ENTERPRISE_ACCESS_HEADER), &(Flags), sizeof(UINT8));
654*617e2443SMark Logan memcpy(command + sizeof(SET_ENTERPRISE_ACCESS_HEADER) + sizeof(UINT8), HostIPAddress, sizeof(HostIPAddress));
655*617e2443SMark Logan memcpy(command + sizeof(SET_ENTERPRISE_ACCESS_HEADER) + sizeof(UINT8) + sizeof(HostIPAddress), &(EnterpriseAccess), sizeof(UINT8));
656*617e2443SMark Logan
657*617e2443SMark Logan AMT_STATUS status = _call(command, command_size, &readBuffer, SET_ENTERPRISE_ACCESS_RESPONSE, sizeof(CFG_SET_ENTERPRISE_ACCESS_RESPONSE));
658*617e2443SMark Logan
659*617e2443SMark Logan if (readBuffer != NULL)
660*617e2443SMark Logan {
661*617e2443SMark Logan free(readBuffer);
662*617e2443SMark Logan }
663*617e2443SMark Logan return status;
664*617e2443SMark Logan }
665*617e2443SMark Logan
666*617e2443SMark Logan /*
667*617e2443SMark Logan * Get FW last reset reason
668*617e2443SMark Logan * Arguments:
669*617e2443SMark Logan * reason - last FW reason
670*617e2443SMark Logan * Return values:
671*617e2443SMark Logan * AMT_STATUS_SUCCESS - on success
672*617e2443SMark Logan * appropriate error value defined in StatusCodeDefinitions.h - on failure
673*617e2443SMark Logan */
GetFWResetReason(UINT8 & MEResetReason)674*617e2443SMark Logan AMT_STATUS PTHICommand::GetFWResetReason(UINT8 &MEResetReason)
675*617e2443SMark Logan {
676*617e2443SMark Logan UINT8 *readBuffer = NULL;
677*617e2443SMark Logan const UINT32 command_size = sizeof(STATE_GET_AMT_STATE_REQUEST);
678*617e2443SMark Logan unsigned char command[command_size];
679*617e2443SMark Logan memcpy(command, &(GET_AMT_STATE_HEADER), sizeof(GET_AMT_STATE_HEADER));
680*617e2443SMark Logan memcpy(command + sizeof(GET_AMT_STATE_HEADER), &(AMT_UUID_LINK_STATE), sizeof(AMT_UUID));
681*617e2443SMark Logan
682*617e2443SMark Logan AMT_STATUS status = _call(command, command_size, &readBuffer, GET_AMT_STATE_RESPONSE, sizeof(STATE_GET_AMT_STATE_RESPONSE));
683*617e2443SMark Logan do {
684*617e2443SMark Logan if (status != AMT_STATUS_SUCCESS)
685*617e2443SMark Logan {
686*617e2443SMark Logan break;
687*617e2443SMark Logan }
688*617e2443SMark Logan STATE_GET_AMT_STATE_RESPONSE *tmp_response = (STATE_GET_AMT_STATE_RESPONSE *)readBuffer;
689*617e2443SMark Logan
690*617e2443SMark Logan MEResetReason = tmp_response->StateData.LastMEResetReason;
691*617e2443SMark Logan
692*617e2443SMark Logan } while (0);
693*617e2443SMark Logan if (readBuffer != NULL)
694*617e2443SMark Logan {
695*617e2443SMark Logan free(readBuffer);
696*617e2443SMark Logan }
697*617e2443SMark Logan return status;
698*617e2443SMark Logan }
699*617e2443SMark Logan
700*617e2443SMark Logan /* Calls to OpenUserInitiatedConnection Host interface command
701*617e2443SMark Logan * Return values:
702*617e2443SMark Logan * AMT_STATUS_SUCCESS - on success
703*617e2443SMark Logan * appropriate error value defined in StatusCodeDefinitions.h - on failure
704*617e2443SMark Logan */
OpenUserInitiatedConnection()705*617e2443SMark Logan AMT_STATUS PTHICommand::OpenUserInitiatedConnection()
706*617e2443SMark Logan {
707*617e2443SMark Logan UINT8 *readBuffer = NULL;
708*617e2443SMark Logan const UINT32 command_size = sizeof(OPEN_USER_INITIATED_CONNECTION_HEADER);
709*617e2443SMark Logan unsigned char command[command_size];
710*617e2443SMark Logan memcpy(command, &(OPEN_USER_INITIATED_CONNECTION_HEADER), sizeof(OPEN_USER_INITIATED_CONNECTION_HEADER));
711*617e2443SMark Logan
712*617e2443SMark Logan AMT_STATUS status = _call(command, command_size, &readBuffer, OPEN_USER_INITIATED_CONNECTION_RESPONSE, sizeof(CFG_OPEN_USER_INITIATED_CONNECTION_RESPONSE));
713*617e2443SMark Logan
714*617e2443SMark Logan if (readBuffer != NULL)
715*617e2443SMark Logan {
716*617e2443SMark Logan free(readBuffer);
717*617e2443SMark Logan }
718*617e2443SMark Logan return status;
719*617e2443SMark Logan }
720*617e2443SMark Logan
721*617e2443SMark Logan /* Calls to CloseUserInitiatedConnection Host interface command
722*617e2443SMark Logan * Return values:
723*617e2443SMark Logan * AMT_STATUS_SUCCESS - on success
724*617e2443SMark Logan * appropriate error value defined in StatusCodeDefinitions.h - on failure
725*617e2443SMark Logan */
CloseUserInitiatedConnection()726*617e2443SMark Logan AMT_STATUS PTHICommand::CloseUserInitiatedConnection()
727*617e2443SMark Logan {
728*617e2443SMark Logan UINT8 *readBuffer = NULL;
729*617e2443SMark Logan const UINT32 command_size = sizeof(CLOSE_USER_INITIATED_CONNECTION_HEADER);
730*617e2443SMark Logan unsigned char command[command_size];
731*617e2443SMark Logan memcpy(command, &(CLOSE_USER_INITIATED_CONNECTION_HEADER), sizeof(CLOSE_USER_INITIATED_CONNECTION_HEADER));
732*617e2443SMark Logan
733*617e2443SMark Logan AMT_STATUS status = _call(command, command_size, &readBuffer, CLOSE_USER_INITIATED_CONNECTION_RESPONSE, sizeof(CFG_CLOSE_USER_INITIATED_CONNECTION_RESPONSE));
734*617e2443SMark Logan
735*617e2443SMark Logan if (readBuffer != NULL)
736*617e2443SMark Logan {
737*617e2443SMark Logan free(readBuffer);
738*617e2443SMark Logan }
739*617e2443SMark Logan return status;
740*617e2443SMark Logan }
741*617e2443SMark Logan
742*617e2443SMark Logan /* Calls to GetRemoteAccessConnectionStatus Host interface command
743*617e2443SMark Logan * Return values:
744*617e2443SMark Logan * AMT_STATUS_SUCCESS - on success
745*617e2443SMark Logan * appropriate error value defined in StatusCodeDefinitions.h - on failure
746*617e2443SMark Logan */
GetRemoteAccessConnectionStatus(REMOTE_ACCESS_STATUS & remoteAccessStatus)747*617e2443SMark Logan AMT_STATUS PTHICommand::GetRemoteAccessConnectionStatus(REMOTE_ACCESS_STATUS &remoteAccessStatus)
748*617e2443SMark Logan {
749*617e2443SMark Logan UINT8 *readBuffer = NULL;
750*617e2443SMark Logan const UINT32 command_size = sizeof(GET_REMOTE_ACCESS_CONNECTION_STATUS_HEADER);
751*617e2443SMark Logan unsigned char command[command_size];
752*617e2443SMark Logan memcpy(command, &(GET_REMOTE_ACCESS_CONNECTION_STATUS_HEADER), sizeof(GET_REMOTE_ACCESS_CONNECTION_STATUS_HEADER));
753*617e2443SMark Logan
754*617e2443SMark Logan AMT_STATUS status = _call(command, command_size, &readBuffer, GET_REMOTE_ACCESS_CONNECTION_STATUS_RESPONSE, 0);
755*617e2443SMark Logan do {
756*617e2443SMark Logan if (status != AMT_STATUS_SUCCESS)
757*617e2443SMark Logan {
758*617e2443SMark Logan break;
759*617e2443SMark Logan }
760*617e2443SMark Logan CFG_GET_REMOTE_ACCESS_CONNECTION_STATUS_RESPONSE *tmp_response = (CFG_GET_REMOTE_ACCESS_CONNECTION_STATUS_RESPONSE *)readBuffer;
761*617e2443SMark Logan status = _verifyRemoteAccessConnectionStatus(*tmp_response);
762*617e2443SMark Logan if (status != AMT_STATUS_SUCCESS)
763*617e2443SMark Logan {
764*617e2443SMark Logan break;
765*617e2443SMark Logan }
766*617e2443SMark Logan
767*617e2443SMark Logan remoteAccessStatus.AmtNetworkConnectionStatus = tmp_response->AmtNetworkConnectionStatus;
768*617e2443SMark Logan remoteAccessStatus.RemoteAccessConnectionStatus = tmp_response->RemoteAccessConnectionStatus;
769*617e2443SMark Logan remoteAccessStatus.RemoteAccessConnectionTrigger = tmp_response->RemoteAccessConnectionTrigger;
770*617e2443SMark Logan
771*617e2443SMark Logan remoteAccessStatus.MpsHostname.Length = tmp_response->MpsHostname.Length;
772*617e2443SMark Logan remoteAccessStatus.MpsHostname.Buffer = (CHAR *)malloc(remoteAccessStatus.MpsHostname.Length * sizeof(CHAR));
773*617e2443SMark Logan if (NULL == remoteAccessStatus.MpsHostname.Buffer) {
774*617e2443SMark Logan status = AMT_STATUS_INTERNAL_ERROR;
775*617e2443SMark Logan } else {
776*617e2443SMark Logan memcpy(remoteAccessStatus.MpsHostname.Buffer,
777*617e2443SMark Logan &(tmp_response->MpsHostname.Buffer),
778*617e2443SMark Logan tmp_response->MpsHostname.Length * sizeof(CHAR));
779*617e2443SMark Logan }
780*617e2443SMark Logan } while (0);
781*617e2443SMark Logan if (readBuffer != NULL)
782*617e2443SMark Logan {
783*617e2443SMark Logan free(readBuffer);
784*617e2443SMark Logan }
785*617e2443SMark Logan return status;
786*617e2443SMark Logan }
787*617e2443SMark Logan
788*617e2443SMark Logan /*
789*617e2443SMark Logan * Confirms the correctness of the GetRemoteAccessConnectionStatus response message
790*617e2443SMark Logan * Arguments:
791*617e2443SMark Logan * response - reference to the response message
792*617e2443SMark Logan * Return values:
793*617e2443SMark Logan * AMT_STATUS_SUCCESS - on success
794*617e2443SMark Logan * PTSDK_STATUS_INTERNAL_ERROR - on failure
795*617e2443SMark Logan */
_verifyRemoteAccessConnectionStatus(const CFG_GET_REMOTE_ACCESS_CONNECTION_STATUS_RESPONSE & response)796*617e2443SMark Logan AMT_STATUS PTHICommand::_verifyRemoteAccessConnectionStatus(const CFG_GET_REMOTE_ACCESS_CONNECTION_STATUS_RESPONSE &response)
797*617e2443SMark Logan {
798*617e2443SMark Logan ULONG ByteCount = response.Header.Header.Length;
799*617e2443SMark Logan if (ByteCount != (sizeof(CFG_GET_REMOTE_ACCESS_CONNECTION_STATUS_RESPONSE)
800*617e2443SMark Logan - sizeof(PTHI_MESSAGE_HEADER) - sizeof(CHAR *)
801*617e2443SMark Logan + response.MpsHostname.Length))
802*617e2443SMark Logan {
803*617e2443SMark Logan return PTSDK_STATUS_INTERNAL_ERROR;
804*617e2443SMark Logan }
805*617e2443SMark Logan return AMT_STATUS_SUCCESS;
806*617e2443SMark Logan }
807*617e2443SMark Logan
808*617e2443SMark Logan /*
809*617e2443SMark Logan * Calls to GenerateRngKey Host interface command
810*617e2443SMark Logan * Arguments:
811*617e2443SMark Logan * None
812*617e2443SMark Logan * Return values:
813*617e2443SMark Logan * AMT_STATUS_SUCCESS - or AMT_STATUS_IN_PROGRESS on success
814*617e2443SMark Logan * appropriate error value defined in StatusCodeDefinitions.h - on failure
815*617e2443SMark Logan */
GenerateRngKey()816*617e2443SMark Logan AMT_STATUS PTHICommand::GenerateRngKey()
817*617e2443SMark Logan {
818*617e2443SMark Logan UINT8 *readBuffer = NULL;
819*617e2443SMark Logan const UINT32 command_size = sizeof(GENERATE_RNG_SEED_HEADER);
820*617e2443SMark Logan unsigned char command[command_size];
821*617e2443SMark Logan memcpy(command, &(GENERATE_RNG_SEED_HEADER), sizeof(GENERATE_RNG_SEED_HEADER));
822*617e2443SMark Logan
823*617e2443SMark Logan AMT_STATUS status = _call(command, command_size, &readBuffer, GENERATE_RNG_SEED_RESPONSE, sizeof(CFG_GENERATE_RNG_SEED_RESPONSE));
824*617e2443SMark Logan
825*617e2443SMark Logan if (readBuffer != NULL)
826*617e2443SMark Logan {
827*617e2443SMark Logan free(readBuffer);
828*617e2443SMark Logan }
829*617e2443SMark Logan return status;
830*617e2443SMark Logan }
831*617e2443SMark Logan
832*617e2443SMark Logan /*
833*617e2443SMark Logan * Calls to GetRngSeedStatus Host interface command
834*617e2443SMark Logan * Arguments:
835*617e2443SMark Logan * rngStatus - reference to the pre-allocated structure
836*617e2443SMark Logan * which will hold the result
837*617e2443SMark Logan * Return values:
838*617e2443SMark Logan * AMT_STATUS_SUCCESS - on success
839*617e2443SMark Logan * appropriate error value defined in StatusCodeDefinitions.h - on failure
840*617e2443SMark Logan */
GetRngSeedStatus(AMT_RNG_STATUS & rngStatus)841*617e2443SMark Logan AMT_STATUS PTHICommand::GetRngSeedStatus(AMT_RNG_STATUS &rngStatus)
842*617e2443SMark Logan {
843*617e2443SMark Logan UINT8 *readBuffer = NULL;
844*617e2443SMark Logan const UINT32 command_size = sizeof(GET_RNG_SEED_STATUS_HEADER);
845*617e2443SMark Logan unsigned char command[command_size];
846*617e2443SMark Logan memcpy(command, &(GET_RNG_SEED_STATUS_HEADER), sizeof(GET_RNG_SEED_STATUS_HEADER));
847*617e2443SMark Logan
848*617e2443SMark Logan AMT_STATUS status = _call(command, command_size, &readBuffer, GET_RNG_SEED_STATUS_RESPONSE, sizeof(CFG_GET_RNG_SEED_STATUS_RESPONSE));
849*617e2443SMark Logan
850*617e2443SMark Logan CFG_GET_RNG_SEED_STATUS_RESPONSE *tmp_response = (CFG_GET_RNG_SEED_STATUS_RESPONSE *)readBuffer;
851*617e2443SMark Logan
852*617e2443SMark Logan rngStatus = tmp_response->RngStatus;
853*617e2443SMark Logan
854*617e2443SMark Logan if (readBuffer != NULL)
855*617e2443SMark Logan {
856*617e2443SMark Logan free(readBuffer);
857*617e2443SMark Logan }
858*617e2443SMark Logan return status;
859*617e2443SMark Logan }
860*617e2443SMark Logan
861*617e2443SMark Logan /*
862*617e2443SMark Logan * Calls to ZeroTouchEnabled Host interface command
863*617e2443SMark Logan * Arguments:
864*617e2443SMark Logan * zeroTouchEnabled - reference to the pre-allocated structure
865*617e2443SMark Logan * which will hold the result
866*617e2443SMark Logan * Return values:
867*617e2443SMark Logan * AMT_STATUS_SUCCESS - on success
868*617e2443SMark Logan * appropriate error value defined in StatusCodeDefinitions.h - on failure
869*617e2443SMark Logan */
GetZeroTouchEnabled(AMT_BOOLEAN & zeroTouchEnabled)870*617e2443SMark Logan AMT_STATUS PTHICommand::GetZeroTouchEnabled(AMT_BOOLEAN &zeroTouchEnabled)
871*617e2443SMark Logan {
872*617e2443SMark Logan UINT8 *readBuffer = NULL;
873*617e2443SMark Logan const UINT32 command_size = sizeof(GET_ZERO_TOUCH_ENABLED_HEADER);
874*617e2443SMark Logan unsigned char command[command_size];
875*617e2443SMark Logan memcpy(command, &(GET_ZERO_TOUCH_ENABLED_HEADER), sizeof(GET_ZERO_TOUCH_ENABLED_HEADER));
876*617e2443SMark Logan
877*617e2443SMark Logan AMT_STATUS status = _call(command, command_size, &readBuffer, GET_ZERO_TOUCH_ENABLED_RESPONSE, sizeof(CFG_GET_ZERO_TOUCH_ENABLED_RESPONSE));
878*617e2443SMark Logan
879*617e2443SMark Logan CFG_GET_ZERO_TOUCH_ENABLED_RESPONSE *tmp_response = (CFG_GET_ZERO_TOUCH_ENABLED_RESPONSE *)readBuffer;
880*617e2443SMark Logan
881*617e2443SMark Logan zeroTouchEnabled = tmp_response->ZeroTouchEnabled;
882*617e2443SMark Logan
883*617e2443SMark Logan if (readBuffer != NULL)
884*617e2443SMark Logan {
885*617e2443SMark Logan free(readBuffer);
886*617e2443SMark Logan }
887*617e2443SMark Logan return status;
888*617e2443SMark Logan }
889*617e2443SMark Logan
890*617e2443SMark Logan /*
891*617e2443SMark Logan * Calls to GetProvisioningTlsMode Host interface command
892*617e2443SMark Logan * Arguments:
893*617e2443SMark Logan * provisioningTlsMode - reference to the pre-allocated structure
894*617e2443SMark Logan * which will hold the result
895*617e2443SMark Logan * Return values:
896*617e2443SMark Logan * AMT_STATUS_SUCCESS - on success
897*617e2443SMark Logan * appropriate error value defined in StatusCodeDefinitions.h - on failure
898*617e2443SMark Logan */
GetProvisioningTlsMode(AMT_PROVISIONING_TLS_MODE & provisioningTlsMode)899*617e2443SMark Logan AMT_STATUS PTHICommand::GetProvisioningTlsMode(AMT_PROVISIONING_TLS_MODE &provisioningTlsMode)
900*617e2443SMark Logan {
901*617e2443SMark Logan UINT8 *readBuffer = NULL;
902*617e2443SMark Logan const UINT32 command_size = sizeof(GET_PROVISIONING_TLS_MODE_HEADER);
903*617e2443SMark Logan unsigned char command[command_size];
904*617e2443SMark Logan memcpy(command, &(GET_PROVISIONING_TLS_MODE_HEADER), sizeof(GET_PROVISIONING_TLS_MODE_HEADER));
905*617e2443SMark Logan
906*617e2443SMark Logan AMT_STATUS status = _call(command, command_size, &readBuffer, GET_PROVISIONING_TLS_MODE_RESPONSE, sizeof(CFG_GET_PROVISIONING_TLS_MODE_RESPONSE));
907*617e2443SMark Logan
908*617e2443SMark Logan CFG_GET_PROVISIONING_TLS_MODE_RESPONSE *tmp_response = (CFG_GET_PROVISIONING_TLS_MODE_RESPONSE *)readBuffer;
909*617e2443SMark Logan
910*617e2443SMark Logan provisioningTlsMode = tmp_response->ProvisioningTlsMode;
911*617e2443SMark Logan
912*617e2443SMark Logan if (readBuffer != NULL)
913*617e2443SMark Logan {
914*617e2443SMark Logan free(readBuffer);
915*617e2443SMark Logan }
916*617e2443SMark Logan return status;
917*617e2443SMark Logan }
918*617e2443SMark Logan
919*617e2443SMark Logan /*
920*617e2443SMark Logan * Calls to StartConfiguration Host interface command
921*617e2443SMark Logan * Arguments:
922*617e2443SMark Logan * None
923*617e2443SMark Logan * Return values:
924*617e2443SMark Logan * AMT_STATUS_SUCCESS - or AMT_STATUS_CERTIFICATE_NOT_READY on success
925*617e2443SMark Logan * appropriate error value defined in StatusCodeDefinitions.h - on failure
926*617e2443SMark Logan */
StartConfiguration()927*617e2443SMark Logan AMT_STATUS PTHICommand::StartConfiguration()
928*617e2443SMark Logan {
929*617e2443SMark Logan UINT8 *readBuffer = NULL;
930*617e2443SMark Logan const UINT32 command_size = sizeof(START_CONFIGURATION_HEADER);
931*617e2443SMark Logan unsigned char command[command_size];
932*617e2443SMark Logan memcpy(command, &(START_CONFIGURATION_HEADER), sizeof(START_CONFIGURATION_HEADER));
933*617e2443SMark Logan
934*617e2443SMark Logan AMT_STATUS status = _call(command, command_size, &readBuffer, START_CONFIGURATION_RESPONSE, sizeof(CFG_START_CONFIGURATION_RESPONSE));
935*617e2443SMark Logan
936*617e2443SMark Logan if (readBuffer != NULL)
937*617e2443SMark Logan {
938*617e2443SMark Logan free(readBuffer);
939*617e2443SMark Logan }
940*617e2443SMark Logan return status;
941*617e2443SMark Logan }
942*617e2443SMark Logan
943*617e2443SMark Logan /*
944*617e2443SMark Logan * Calls to SetProvisioningServerOTP Host interface command
945*617e2443SMark Logan * Arguments:
946*617e2443SMark Logan * passwordOTP AMT_ANSI_STRING structure of OTP password
947*617e2443SMark Logan * Return values:
948*617e2443SMark Logan * AMT_STATUS_SUCCESS - on success
949*617e2443SMark Logan * appropriate error value defined in StatusCodeDefinitions.h - on failure
950*617e2443SMark Logan */
SetProvisioningServerOTP(AMT_ANSI_STRING passwordOTP)951*617e2443SMark Logan AMT_STATUS PTHICommand::SetProvisioningServerOTP(AMT_ANSI_STRING passwordOTP)
952*617e2443SMark Logan {
953*617e2443SMark Logan if (NULL == passwordOTP.Buffer)
954*617e2443SMark Logan {
955*617e2443SMark Logan return PTSDK_STATUS_INVALID_PARAM;
956*617e2443SMark Logan }
957*617e2443SMark Logan
958*617e2443SMark Logan UINT8 *readBuffer = NULL;
959*617e2443SMark Logan UINT32 msgLength = sizeof(passwordOTP.Length) + (passwordOTP.Length * sizeof(CHAR));
960*617e2443SMark Logan PTHI_MESSAGE_HEADER SET_PROVISIONING_SERVER_OTP_HEADER = {
961*617e2443SMark Logan {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{SET_PROVISIONING_SERVER_OTP_REQUEST}}, msgLength
962*617e2443SMark Logan };
963*617e2443SMark Logan
964*617e2443SMark Logan const UINT32 command_size = sizeof(SET_PROVISIONING_SERVER_OTP_HEADER) + msgLength;
965*617e2443SMark Logan unsigned char *command;
966*617e2443SMark Logan command = (unsigned char *)malloc(command_size);
967*617e2443SMark Logan if (NULL == command)
968*617e2443SMark Logan {
969*617e2443SMark Logan return PTSDK_STATUS_INTERNAL_ERROR;
970*617e2443SMark Logan }
971*617e2443SMark Logan memcpy(command, &SET_PROVISIONING_SERVER_OTP_HEADER, sizeof(SET_PROVISIONING_SERVER_OTP_HEADER));
972*617e2443SMark Logan memcpy(command + sizeof(SET_PROVISIONING_SERVER_OTP_HEADER), &(passwordOTP.Length), sizeof(passwordOTP.Length));
973*617e2443SMark Logan memcpy(command + sizeof(SET_PROVISIONING_SERVER_OTP_HEADER) + sizeof(passwordOTP.Length),
974*617e2443SMark Logan passwordOTP.Buffer, passwordOTP.Length);
975*617e2443SMark Logan
976*617e2443SMark Logan AMT_STATUS status = _call(command, command_size, &readBuffer, SET_PROVISIONING_SERVER_OTP_RESPONSE, sizeof(CFG_SET_PROVISIONING_SERVER_OTP_RESPONSE));
977*617e2443SMark Logan
978*617e2443SMark Logan if (NULL != command)
979*617e2443SMark Logan {
980*617e2443SMark Logan free(command);
981*617e2443SMark Logan }
982*617e2443SMark Logan if (readBuffer != NULL)
983*617e2443SMark Logan {
984*617e2443SMark Logan free(readBuffer);
985*617e2443SMark Logan }
986*617e2443SMark Logan return status;
987*617e2443SMark Logan }
988*617e2443SMark Logan
989*617e2443SMark Logan /*
990*617e2443SMark Logan * Calls to SetDnsSuffix Host interface command
991*617e2443SMark Logan * Arguments:
992*617e2443SMark Logan * dnsSuffix AMT_ANSI_STRING structure of DNS suffix
993*617e2443SMark Logan * Return values:
994*617e2443SMark Logan * AMT_STATUS_SUCCESS - on success
995*617e2443SMark Logan * appropriate error value defined in StatusCodeDefinitions.h - on failure
996*617e2443SMark Logan */
SetDnsSuffix(AMT_ANSI_STRING dnsSuffix)997*617e2443SMark Logan AMT_STATUS PTHICommand::SetDnsSuffix(AMT_ANSI_STRING dnsSuffix)
998*617e2443SMark Logan {
999*617e2443SMark Logan if (NULL == dnsSuffix.Buffer)
1000*617e2443SMark Logan {
1001*617e2443SMark Logan return PTSDK_STATUS_INVALID_PARAM;
1002*617e2443SMark Logan }
1003*617e2443SMark Logan
1004*617e2443SMark Logan UINT8 *readBuffer = NULL;
1005*617e2443SMark Logan UINT32 msgLength = sizeof(dnsSuffix.Length) + (dnsSuffix.Length * sizeof(CHAR));
1006*617e2443SMark Logan PTHI_MESSAGE_HEADER SET_DNS_SUFFIX_HEADER = {
1007*617e2443SMark Logan {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{SET_DNS_SUFFIX_REQUEST}}, msgLength
1008*617e2443SMark Logan };
1009*617e2443SMark Logan
1010*617e2443SMark Logan const UINT32 command_size = sizeof(SET_DNS_SUFFIX_HEADER) + msgLength;
1011*617e2443SMark Logan unsigned char *command;
1012*617e2443SMark Logan command = (unsigned char *)malloc(command_size);
1013*617e2443SMark Logan if (NULL == command)
1014*617e2443SMark Logan {
1015*617e2443SMark Logan return PTSDK_STATUS_INTERNAL_ERROR;
1016*617e2443SMark Logan }
1017*617e2443SMark Logan memcpy(command, &SET_DNS_SUFFIX_HEADER, sizeof(SET_DNS_SUFFIX_HEADER));
1018*617e2443SMark Logan memcpy(command + sizeof(SET_DNS_SUFFIX_HEADER), &(dnsSuffix.Length), sizeof(dnsSuffix.Length));
1019*617e2443SMark Logan memcpy(command + sizeof(SET_DNS_SUFFIX_HEADER) + sizeof(dnsSuffix.Length), dnsSuffix.Buffer, dnsSuffix.Length);
1020*617e2443SMark Logan
1021*617e2443SMark Logan AMT_STATUS status = _call(command, command_size, &readBuffer, SET_DNS_SUFFIX_RESPONSE, sizeof(CFG_SET_DNS_SUFFIX_RESPONSE));
1022*617e2443SMark Logan
1023*617e2443SMark Logan if (NULL != command)
1024*617e2443SMark Logan {
1025*617e2443SMark Logan free(command);
1026*617e2443SMark Logan }
1027*617e2443SMark Logan if (readBuffer != NULL)
1028*617e2443SMark Logan {
1029*617e2443SMark Logan free(readBuffer);
1030*617e2443SMark Logan }
1031*617e2443SMark Logan return status;
1032*617e2443SMark Logan }
1033*617e2443SMark Logan
1034*617e2443SMark Logan /*
1035*617e2443SMark Logan * Calls to EnumerateHashHandles Host interface command
1036*617e2443SMark Logan * Arguments:
1037*617e2443SMark Logan * hashHandles - reference to the pre-allocated structure
1038*617e2443SMark Logan * which will hold the result
1039*617e2443SMark Logan * Return values:
1040*617e2443SMark Logan * AMT_STATUS_SUCCESS - on success
1041*617e2443SMark Logan * appropriate error value defined in StatusCodeDefinitions.h - on failure
1042*617e2443SMark Logan */
EnumerateHashHandles(AMT_HASH_HANDLES & hashHandles)1043*617e2443SMark Logan AMT_STATUS PTHICommand::EnumerateHashHandles(AMT_HASH_HANDLES &hashHandles)
1044*617e2443SMark Logan {
1045*617e2443SMark Logan UINT8 *readBuffer = NULL;
1046*617e2443SMark Logan const UINT32 command_size = sizeof(ENUMERATE_HASH_HANDLES_HEADER);
1047*617e2443SMark Logan unsigned char command[command_size];
1048*617e2443SMark Logan memcpy(command, &(ENUMERATE_HASH_HANDLES_HEADER), sizeof(ENUMERATE_HASH_HANDLES_HEADER));
1049*617e2443SMark Logan
1050*617e2443SMark Logan AMT_STATUS status = _call(command, command_size, &readBuffer, ENUMERATE_HASH_HANDLES_RESPONSE, 0);
1051*617e2443SMark Logan do {
1052*617e2443SMark Logan if (status != AMT_STATUS_SUCCESS)
1053*617e2443SMark Logan {
1054*617e2443SMark Logan break;
1055*617e2443SMark Logan }
1056*617e2443SMark Logan CFG_GET_HASH_HANDLES_RESPONSE *tmp_response = (CFG_GET_HASH_HANDLES_RESPONSE *)readBuffer;
1057*617e2443SMark Logan status = _verifyHashHandles(*tmp_response);
1058*617e2443SMark Logan if (status != AMT_STATUS_SUCCESS)
1059*617e2443SMark Logan {
1060*617e2443SMark Logan break;
1061*617e2443SMark Logan }
1062*617e2443SMark Logan
1063*617e2443SMark Logan memset(hashHandles.Handles, 0, sizeof(UINT32) * CERT_HASH_MAX_NUMBER);
1064*617e2443SMark Logan hashHandles.Length = tmp_response->HashHandles.Length;
1065*617e2443SMark Logan if (CERT_HASH_MAX_NUMBER < hashHandles.Length)
1066*617e2443SMark Logan {
1067*617e2443SMark Logan status = PTSDK_STATUS_INTERNAL_ERROR;
1068*617e2443SMark Logan break;
1069*617e2443SMark Logan }
1070*617e2443SMark Logan
1071*617e2443SMark Logan memcpy(hashHandles.Handles, tmp_response->HashHandles.Handles, sizeof(UINT32) * hashHandles.Length);
1072*617e2443SMark Logan
1073*617e2443SMark Logan } while (0);
1074*617e2443SMark Logan if (readBuffer != NULL)
1075*617e2443SMark Logan {
1076*617e2443SMark Logan free(readBuffer);
1077*617e2443SMark Logan }
1078*617e2443SMark Logan return status;
1079*617e2443SMark Logan }
1080*617e2443SMark Logan
1081*617e2443SMark Logan /*
1082*617e2443SMark Logan * Confirms the correctness of the EnumerateHashHandles response message
1083*617e2443SMark Logan * Arguments:
1084*617e2443SMark Logan * response - reference to the response message
1085*617e2443SMark Logan * Return values:
1086*617e2443SMark Logan * AMT_STATUS_SUCCESS - on success
1087*617e2443SMark Logan * PTSDK_STATUS_INTERNAL_ERROR - on failure
1088*617e2443SMark Logan */
_verifyHashHandles(const CFG_GET_HASH_HANDLES_RESPONSE & response)1089*617e2443SMark Logan AMT_STATUS PTHICommand::_verifyHashHandles(const CFG_GET_HASH_HANDLES_RESPONSE &response)
1090*617e2443SMark Logan {
1091*617e2443SMark Logan ULONG ByteCount = response.Header.Header.Length;
1092*617e2443SMark Logan
1093*617e2443SMark Logan if (ByteCount !=
1094*617e2443SMark Logan sizeof(AMT_STATUS) + sizeof(response.HashHandles.Length) + (sizeof(UINT32) * response.HashHandles.Length))
1095*617e2443SMark Logan {
1096*617e2443SMark Logan return PTSDK_STATUS_INTERNAL_ERROR;
1097*617e2443SMark Logan }
1098*617e2443SMark Logan return AMT_STATUS_SUCCESS;
1099*617e2443SMark Logan }
1100*617e2443SMark Logan
1101*617e2443SMark Logan
1102*617e2443SMark Logan /*
1103*617e2443SMark Logan * Calls to GetCertificateHashEntry Host interface command
1104*617e2443SMark Logan * Arguments:
1105*617e2443SMark Logan * passwordOTP AMT_ANSI_STRING structure of DNS suffix
1106*617e2443SMark Logan * Return values:
1107*617e2443SMark Logan * AMT_STATUS_SUCCESS - on success
1108*617e2443SMark Logan * appropriate error value defined in StatusCodeDefinitions.h - on failure
1109*617e2443SMark Logan */
GetCertificateHashEntry(UINT32 hashHandle,CERTHASH_ENTRY & hashEntry)1110*617e2443SMark Logan AMT_STATUS PTHICommand::GetCertificateHashEntry(UINT32 hashHandle, CERTHASH_ENTRY &hashEntry)
1111*617e2443SMark Logan {
1112*617e2443SMark Logan UINT8 *readBuffer = NULL;
1113*617e2443SMark Logan const UINT32 command_size = sizeof(CFG_GET_CERTHASH_ENTRY_REQUEST);
1114*617e2443SMark Logan unsigned char command[command_size];
1115*617e2443SMark Logan memcpy(command, &(GET_CERTHASH_ENTRY_HEADER), sizeof(GET_CERTHASH_ENTRY_HEADER));
1116*617e2443SMark Logan memcpy(command + sizeof(GET_CERTHASH_ENTRY_HEADER), &(hashHandle), sizeof(hashHandle));
1117*617e2443SMark Logan
1118*617e2443SMark Logan AMT_STATUS status = _call(command, command_size, &readBuffer, GET_CERTHASH_ENTRY_RESPONSE, 0);
1119*617e2443SMark Logan do {
1120*617e2443SMark Logan if (status != AMT_STATUS_SUCCESS)
1121*617e2443SMark Logan {
1122*617e2443SMark Logan break;
1123*617e2443SMark Logan }
1124*617e2443SMark Logan CFG_GET_CERTHASH_ENTRY_RESPONSE *tmp_response = (CFG_GET_CERTHASH_ENTRY_RESPONSE *)readBuffer;
1125*617e2443SMark Logan status = _verifyGetCertificateHashEntry(*tmp_response);
1126*617e2443SMark Logan if (status != AMT_STATUS_SUCCESS)
1127*617e2443SMark Logan {
1128*617e2443SMark Logan break;
1129*617e2443SMark Logan }
1130*617e2443SMark Logan
1131*617e2443SMark Logan hashEntry.IsActive = tmp_response->Hash.IsActive;
1132*617e2443SMark Logan hashEntry.IsDefault = tmp_response->Hash.IsDefault;
1133*617e2443SMark Logan hashEntry.Name.Length = tmp_response->Hash.Name.Length;
1134*617e2443SMark Logan hashEntry.HashAlgorithm = tmp_response->Hash.HashAlgorithm;
1135*617e2443SMark Logan memcpy(hashEntry.CertificateHash, tmp_response->Hash.CertificateHash, sizeof(tmp_response->Hash.CertificateHash));
1136*617e2443SMark Logan hashEntry.Name.Buffer = (CHAR *)malloc(hashEntry.Name.Length * sizeof(CHAR));
1137*617e2443SMark Logan if (NULL == hashEntry.Name.Buffer)
1138*617e2443SMark Logan {
1139*617e2443SMark Logan status = PTSDK_STATUS_INTERNAL_ERROR;
1140*617e2443SMark Logan break;
1141*617e2443SMark Logan }
1142*617e2443SMark Logan memcpy(hashEntry.Name.Buffer, &(tmp_response->Hash.Name.Buffer), hashEntry.Name.Length * sizeof(CHAR));
1143*617e2443SMark Logan
1144*617e2443SMark Logan } while (0);
1145*617e2443SMark Logan if (readBuffer != NULL)
1146*617e2443SMark Logan {
1147*617e2443SMark Logan free(readBuffer);
1148*617e2443SMark Logan }
1149*617e2443SMark Logan return status;
1150*617e2443SMark Logan }
1151*617e2443SMark Logan /*
1152*617e2443SMark Logan * Confirms the correctness of the GetCertificateHashEntry response message
1153*617e2443SMark Logan * Arguments:
1154*617e2443SMark Logan * response - reference to the response message
1155*617e2443SMark Logan * Return values:
1156*617e2443SMark Logan * AMT_STATUS_SUCCESS - on success
1157*617e2443SMark Logan * PTSDK_STATUS_INTERNAL_ERROR - on failure
1158*617e2443SMark Logan */
_verifyGetCertificateHashEntry(const CFG_GET_CERTHASH_ENTRY_RESPONSE & response)1159*617e2443SMark Logan AMT_STATUS PTHICommand::_verifyGetCertificateHashEntry(const CFG_GET_CERTHASH_ENTRY_RESPONSE &response)
1160*617e2443SMark Logan {
1161*617e2443SMark Logan ULONG ByteCount = response.Header.Header.Length;
1162*617e2443SMark Logan
1163*617e2443SMark Logan if (ByteCount !=
1164*617e2443SMark Logan (sizeof(CFG_GET_CERTHASH_ENTRY_RESPONSE) - sizeof(PTHI_MESSAGE_HEADER)
1165*617e2443SMark Logan - sizeof(CHAR *) + response.Hash.Name.Length))
1166*617e2443SMark Logan {
1167*617e2443SMark Logan return PTSDK_STATUS_INTERNAL_ERROR;
1168*617e2443SMark Logan }
1169*617e2443SMark Logan return AMT_STATUS_SUCCESS;
1170*617e2443SMark Logan }
1171*617e2443SMark Logan
1172*617e2443SMark Logan /*
1173*617e2443SMark Logan * Calls to GetDnsSuffix Host interface command
1174*617e2443SMark Logan * Arguments:
1175*617e2443SMark Logan * dnsSuffix - reference to the pre-allocated structure
1176*617e2443SMark Logan * which will hold the result
1177*617e2443SMark Logan * Return values:
1178*617e2443SMark Logan * AMT_STATUS_SUCCESS - on success
1179*617e2443SMark Logan * appropriate error value defined in StatusCodeDefinitions.h - on failure
1180*617e2443SMark Logan */
GetDnsSuffix(AMT_ANSI_STRING & dnsSuffix)1181*617e2443SMark Logan AMT_STATUS PTHICommand::GetDnsSuffix(AMT_ANSI_STRING &dnsSuffix)
1182*617e2443SMark Logan {
1183*617e2443SMark Logan UINT8 *readBuffer = NULL;
1184*617e2443SMark Logan const UINT32 command_size = sizeof(GET_PKI_FQDN_SUFFIX_HEADER);
1185*617e2443SMark Logan unsigned char command[command_size];
1186*617e2443SMark Logan memcpy(command, &(GET_PKI_FQDN_SUFFIX_HEADER), sizeof(GET_PKI_FQDN_SUFFIX_HEADER));
1187*617e2443SMark Logan
1188*617e2443SMark Logan AMT_STATUS status = _call(command, command_size, &readBuffer, GET_PKI_FQDN_SUFFIX_RESPONSE, 0);
1189*617e2443SMark Logan do {
1190*617e2443SMark Logan if (status != AMT_STATUS_SUCCESS)
1191*617e2443SMark Logan {
1192*617e2443SMark Logan break;
1193*617e2443SMark Logan }
1194*617e2443SMark Logan CFG_GET_PKI_FQDN_SUFFIX_RESPONSE *tmp_response = (CFG_GET_PKI_FQDN_SUFFIX_RESPONSE *)readBuffer;
1195*617e2443SMark Logan status = _verifyGetDnsSuffix(*tmp_response);
1196*617e2443SMark Logan if (status != AMT_STATUS_SUCCESS)
1197*617e2443SMark Logan {
1198*617e2443SMark Logan break;
1199*617e2443SMark Logan }
1200*617e2443SMark Logan
1201*617e2443SMark Logan dnsSuffix.Length = tmp_response->Suffix.Length;
1202*617e2443SMark Logan dnsSuffix.Buffer = (CHAR *)malloc(dnsSuffix.Length * sizeof(CHAR));
1203*617e2443SMark Logan if (NULL == dnsSuffix.Buffer)
1204*617e2443SMark Logan {
1205*617e2443SMark Logan status = PTSDK_STATUS_INTERNAL_ERROR;
1206*617e2443SMark Logan break;
1207*617e2443SMark Logan }
1208*617e2443SMark Logan memcpy(dnsSuffix.Buffer, &(tmp_response->Suffix.Buffer), dnsSuffix.Length * sizeof(CHAR));
1209*617e2443SMark Logan
1210*617e2443SMark Logan } while (0);
1211*617e2443SMark Logan if (readBuffer != NULL)
1212*617e2443SMark Logan {
1213*617e2443SMark Logan free(readBuffer);
1214*617e2443SMark Logan }
1215*617e2443SMark Logan return status;
1216*617e2443SMark Logan }
1217*617e2443SMark Logan /*
1218*617e2443SMark Logan * Confirms the correctness of the GetDnsSuffix response message
1219*617e2443SMark Logan * Arguments:
1220*617e2443SMark Logan * response - reference to the response message
1221*617e2443SMark Logan * Return values:
1222*617e2443SMark Logan * AMT_STATUS_SUCCESS - on success
1223*617e2443SMark Logan * PTSDK_STATUS_INTERNAL_ERROR - on failure
1224*617e2443SMark Logan */
_verifyGetDnsSuffix(const CFG_GET_PKI_FQDN_SUFFIX_RESPONSE & response)1225*617e2443SMark Logan AMT_STATUS PTHICommand::_verifyGetDnsSuffix(const CFG_GET_PKI_FQDN_SUFFIX_RESPONSE &response)
1226*617e2443SMark Logan {
1227*617e2443SMark Logan ULONG ByteCount = response.Header.Header.Length;
1228*617e2443SMark Logan
1229*617e2443SMark Logan if (ByteCount !=
1230*617e2443SMark Logan sizeof(AMT_STATUS) + sizeof(response.Suffix.Length) + response.Suffix.Length * sizeof(CHAR))
1231*617e2443SMark Logan {
1232*617e2443SMark Logan return PTSDK_STATUS_INTERNAL_ERROR;
1233*617e2443SMark Logan }
1234*617e2443SMark Logan return AMT_STATUS_SUCCESS;
1235*617e2443SMark Logan }
1236*617e2443SMark Logan
1237