Developer Experience Release. Added LMS and code refactor.

This commit is contained in:
Mudit Vats
2020-09-01 16:04:04 -07:00
parent 958096a375
commit 23fe0e1663
53 changed files with 20738 additions and 895 deletions

434
MicroLMS/heci/HECILinux.c Normal file
View File

@@ -0,0 +1,434 @@
/******************************************************************************
* Intel Management Engine Interface (Intel MEI) Linux driver
* Intel MEI Interface Header
*
* This file is provided under a dual BSD/GPLv2 license. When using or
* redistributing this file, you may do so under either license.
*
* GPL LICENSE SUMMARY
*
* Copyright(c) 2012 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
* USA
*
* The full GNU General Public License is included in this distribution
* in the file called LICENSE.GPL.
*
* Contact Information:
* Intel Corporation.
* linux-mei@linux.intel.com
* http://www.intel.com
*
* BSD LICENSE
*
* Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <errno.h>
#include <stdint.h>
#include <stdbool.h>
#include "HECILinux.h"
#include "../core/utils.h"
/*****************************************************************************
* Intel Management Engine Interface
*****************************************************************************/
#ifdef _HECIDEBUG
#define mei_msg(_me, fmt, ARGS...) do { printf(fmt, ##ARGS); } while (0)
#define mei_err(_me, fmt, ARGS...) do { printf(fmt, ##ARGS); } while (0)
#else
#define mei_msg(_me, fmt, ARGS...)
#define mei_err(_me, fmt, ARGS...)
#endif
static void mei_deinit(struct mei *cl)
{
// mei_err(cl, "mei_deinit()\n");
if (cl->initialized == false) return;
cl->initialized = false;
if (cl->fd != -1) close(cl->fd);
cl->fd = -1;
cl->buf_size = 0;
cl->prot_ver = 0;
sem_destroy(&(cl->Lock));
}
static bool mei_init(struct mei *me, const uuid_le *guid, unsigned char req_protocol_version, bool verbose)
{
int result;
struct mei_client *cl;
struct mei_connect_client_data data;
mei_deinit(me);
me->verbose = verbose;
// open me
me->fd = open("/dev/mei0", O_RDWR);
if (me->fd == -1) {
// mei_err(me, "Cannot establish a handle to the Intel MEI driver\n");
goto err;
}
memcpy(&me->guid, guid, sizeof(*guid));
memset(&data, 0, sizeof(data));
me->initialized = true;
memcpy(&data.in_client_uuid, &me->guid, sizeof(me->guid));
result = ioctl(me->fd, IOCTL_MEI_CONNECT_CLIENT, &data);
if (result) {
mei_err(me, "IOCTL_MEI_CONNECT_CLIENT receive message. err=%d,%d\n", result, errno);
goto err;
}
cl = &data.out_client_properties;
//mei_msg(me, "max_message_length %d\n", cl->max_msg_length);
//mei_msg(me, "protocol_version %d\n", cl->protocol_version);
if ((req_protocol_version > 0) && (cl->protocol_version != req_protocol_version)) {
mei_err(me, "Intel MEI protocol version not supported\n");
goto err;
}
me->buf_size = cl->max_msg_length;
me->prot_ver = cl->protocol_version;
sem_init(&(me->Lock), 0, 1);
mei_msg(me, "mei init succ");
return true;
err:
mei_deinit(me);
return false;
}
static ssize_t mei_recv_msg(struct mei *me, unsigned char *buffer, ssize_t len, unsigned long timeout)
{
ssize_t rc;
mei_msg(me, "call read length = %zd\n", len);
rc = read(me->fd, buffer, len);
if (rc < 0) {
mei_err(me, "read failed with status %zd %s\n", rc, strerror(errno));
mei_deinit(me);
} else {
mei_msg(me, "read succeeded with result %zd\n", rc);
}
return rc;
}
static ssize_t mei_send_msg(struct mei *me, const unsigned char *buffer, ssize_t len, unsigned long timeout)
{
struct timeval tv;
ssize_t written;
ssize_t rc;
fd_set set;
tv.tv_sec = timeout / 1000;
tv.tv_usec = (timeout % 1000) * 1000000;
mei_msg(me, "call write length = %zd, cmd=%d\n", len, (int)buffer[0]);
sem_wait(&(me->Lock));
written = write(me->fd, buffer, len);
if (written < 0) {
rc = -errno;
mei_err(me, "write failed with status %zd %s\n", written, strerror(errno));
goto out;
}
FD_ZERO(&set);
FD_SET(me->fd, &set);
rc = select(me->fd + 1 , NULL, &set, NULL, &tv);
if (rc > 0 && FD_ISSET(me->fd, &set)) {
mei_msg(me, "write success\n");
} else if (rc == 0) {
mei_err(me, "write failed on timeout with status 0, timeout = %ld, written=%ld, cmd=%d\n", timeout, written, (int)buffer[0]);
goto out;
} else { // rc < 0
mei_err(me, "write failed on select with status %zd\n", rc);
goto out;
}
rc = written;
out:
sem_post(&(me->Lock));
mei_msg(me, "call write written = %zd\n", written);
if (rc < 0) mei_deinit(me);
return rc;
}
/***************************************************************************
* Intel Advanced Management Technology Host Interface
***************************************************************************/
struct amt_host_if_msg_header {
struct amt_version version;
uint16_t _reserved;
uint32_t command;
uint32_t length;
} __attribute__((packed));
struct amt_host_if_resp_header {
struct amt_host_if_msg_header header;
uint32_t status;
unsigned char data[0];
} __attribute__((packed));
const uuid_le MEI_IAMTHIF = {.b={0x28, 0x00, 0xf8, 0x12, 0xb7, 0xb4, 0x2d, 0x4b, 0xac, 0xa8, 0x46, 0xe0, 0xff, 0x65, 0x81, 0x4c}};
const uuid_le MEI_LMEIF = {.b={0xdb, 0xa4, 0x33, 0x67, 0x76, 0x04, 0x7b, 0x4e, 0xb3, 0xaf, 0xbc, 0xfc, 0x29, 0xbe, 0xe7, 0xa7}};
#define AMT_HOST_IF_CODE_VERSIONS_REQUEST 0x0400001A
#define AMT_HOST_IF_CODE_VERSIONS_RESPONSE 0x0480001A
const struct amt_host_if_msg_header CODE_VERSION_REQ = {
.version = {AMT_MAJOR_VERSION, AMT_MINOR_VERSION},
._reserved = 0,
.command = AMT_HOST_IF_CODE_VERSIONS_REQUEST,
.length = 0
};
static bool amt_host_if_init(struct amt_host_if *acmd, unsigned long send_timeout, bool verbose, int client)
{
acmd->send_timeout = (send_timeout) ? send_timeout : 20000;
if (client == 0) { acmd->initialized = mei_init(&acmd->mei_cl, &MEI_IAMTHIF, 0, verbose); }
else if (client == 1) { acmd->initialized = mei_init(&acmd->mei_cl, &MEI_LMEIF, 0, verbose); }
return acmd->initialized;
}
static void amt_host_if_deinit(struct amt_host_if *acmd)
{
mei_deinit(&acmd->mei_cl);
acmd->initialized = false;
}
static uint32_t amt_verify_code_versions(const struct amt_host_if_resp_header *resp)
{
uint32_t status = AMT_STATUS_SUCCESS;
struct amt_code_versions *code_ver;
size_t code_ver_len;
uint32_t ver_type_cnt;
uint32_t len;
uint32_t i;
code_ver = (struct amt_code_versions *)resp->data;
/* length - sizeof(status) */
code_ver_len = resp->header.length - sizeof(uint32_t);
ver_type_cnt = code_ver_len -
sizeof(code_ver->bios) -
sizeof(code_ver->count);
if (code_ver->count != ver_type_cnt / sizeof(struct amt_version_type)) {
status = AMT_STATUS_INTERNAL_ERROR;
goto out;
}
for (i = 0; i < code_ver->count; i++) {
len = code_ver->versions[i].description.length;
if (len > AMT_UNICODE_STRING_LEN) {
status = AMT_STATUS_INTERNAL_ERROR;
goto out;
}
len = code_ver->versions[i].version.length;
if (code_ver->versions[i].version.string[len] != '\0' ||
len != strlen(code_ver->versions[i].version.string)) {
status = AMT_STATUS_INTERNAL_ERROR;
goto out;
}
}
out:
return status;
}
static uint32_t amt_verify_response_header(uint32_t command, const struct amt_host_if_msg_header *resp_hdr, uint32_t response_size)
{
if (response_size < sizeof(struct amt_host_if_resp_header)) {
return AMT_STATUS_INTERNAL_ERROR;
} else if (response_size != (resp_hdr->length +
sizeof(struct amt_host_if_msg_header))) {
return AMT_STATUS_INTERNAL_ERROR;
} else if (resp_hdr->command != command) {
return AMT_STATUS_INTERNAL_ERROR;
} else if (resp_hdr->_reserved != 0) {
return AMT_STATUS_INTERNAL_ERROR;
} else if (resp_hdr->version.major != AMT_MAJOR_VERSION ||
resp_hdr->version.minor < AMT_MINOR_VERSION) {
return AMT_STATUS_INTERNAL_ERROR;
}
return AMT_STATUS_SUCCESS;
}
static uint32_t amt_host_if_call(struct amt_host_if *acmd, const unsigned char *command, ssize_t command_sz, uint8_t **read_buf, uint32_t rcmd, unsigned int expected_sz)
{
uint32_t in_buf_sz;
uint32_t out_buf_sz;
ssize_t written;
uint32_t status;
struct amt_host_if_resp_header *msg_hdr;
in_buf_sz = acmd->mei_cl.buf_size;
*read_buf = (uint8_t *)malloc(sizeof(uint8_t) * in_buf_sz);
if (*read_buf == NULL) return AMT_STATUS_SDK_RESOURCES;
memset(*read_buf, 0, in_buf_sz);
msg_hdr = (struct amt_host_if_resp_header *)*read_buf;
written = mei_send_msg(&acmd->mei_cl, command, command_sz, acmd->send_timeout);
if (written != command_sz)
return AMT_STATUS_INTERNAL_ERROR;
out_buf_sz = mei_recv_msg(&acmd->mei_cl, *read_buf, in_buf_sz, 2000);
if (out_buf_sz <= 0)
return AMT_STATUS_HOST_IF_EMPTY_RESPONSE;
status = msg_hdr->status;
if (status != AMT_STATUS_SUCCESS)
return status;
status = amt_verify_response_header(rcmd, &msg_hdr->header, out_buf_sz);
if (status != AMT_STATUS_SUCCESS)
return status;
if (expected_sz && expected_sz != out_buf_sz)
return AMT_STATUS_INTERNAL_ERROR;
return AMT_STATUS_SUCCESS;
}
static uint32_t amt_get_code_versions(struct amt_host_if *cmd, struct amt_code_versions *versions)
{
struct amt_host_if_resp_header *response = NULL;
uint32_t status;
status = amt_host_if_call(cmd,
(const unsigned char *)&CODE_VERSION_REQ,
sizeof(CODE_VERSION_REQ),
(uint8_t **)&response,
AMT_HOST_IF_CODE_VERSIONS_RESPONSE, 0);
if (status != AMT_STATUS_SUCCESS)
goto out;
status = amt_verify_code_versions(response);
if (status != AMT_STATUS_SUCCESS)
goto out;
memcpy(versions, response->data, sizeof(struct amt_code_versions));
out:
if (response != NULL)
free(response);
return status;
}
/************************** end of amt_host_if_command ***********************/
int MEI_globalSetup = 0;
struct MEImodule MEI_global;
bool heci_Init(struct MEImodule* module, int client)
{
if (module == NULL && client != 0) return false;
if (module == NULL) { module = &MEI_global; if (MEI_globalSetup == 1) return true; }
memset(module, 0 , sizeof(struct MEImodule));
if (!amt_host_if_init(&(module->acmd), 5000, module->verbose, client)) return false;
if (module == &MEI_global) MEI_globalSetup = 1;
module->inited = true;
if (client == 0) module->status = amt_get_code_versions(&(module->acmd), &(module->ver));
return true;
}
void heci_Deinit(struct MEImodule* module)
{
if (module == NULL) { module = &MEI_global; MEI_globalSetup = 0; }
amt_host_if_deinit(&(module->acmd));
memset(module, 0, sizeof(struct MEImodule));
}
int heci_ReceiveMessage(struct MEImodule* module, unsigned char *buffer, int len, unsigned long timeout) // Timeout default is 2000
{
if (module == NULL) module = &MEI_global;
return mei_recv_msg(&(module->acmd.mei_cl), buffer, len, timeout);
}
int heci_SendMessage(struct MEImodule* module, const unsigned char *buffer, int len, unsigned long timeout) // Timeout default is 2000
{
if (module == NULL) module = &MEI_global;
return mei_send_msg(&(module->acmd.mei_cl), buffer, len, timeout);
}
unsigned int heci_GetBufferSize(struct MEImodule* module)
{
if (module == NULL) module = &MEI_global;
if (module->inited) return module->acmd.mei_cl.buf_size;
return -1;
}
unsigned char heci_GetProtocolVersion(struct MEImodule* module)
{
if (module == NULL) module = &MEI_global;
if (module->inited) return module->acmd.mei_cl.prot_ver;
return 0;
}
// Get the version of MEI from the last MEI init.
bool heci_GetHeciVersion(struct MEImodule* module, HECI_VERSION *version)
{
version->major = AMT_MAJOR_VERSION;
version->minor = AMT_MINOR_VERSION;
return true;
}
bool heci_IsInitialized(struct MEImodule* module)
{
return module->inited;
}

128
MicroLMS/heci/HECILinux.h Normal file
View File

@@ -0,0 +1,128 @@
/*******************************************************************************
* Copyright (C) 2004-2008 Intel Corp. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* - Neither the name of Intel Corp. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/
#ifndef __HECI_LINUX_H__
#define __HECI_LINUX_H__
#include "HECI_if.h"
#include "mei.h"
#include <semaphore.h>
#include <stdint.h>
#ifndef bool
#define bool int
#endif
/***************************************************************************
* Intel Advanced Management Technology ME Client
***************************************************************************/
#define AMT_MAJOR_VERSION 1
#define AMT_MINOR_VERSION 1
#define AMT_STATUS_SUCCESS 0x0
#define AMT_STATUS_INTERNAL_ERROR 0x1
#define AMT_STATUS_NOT_READY 0x2
#define AMT_STATUS_INVALID_AMT_MODE 0x3
#define AMT_STATUS_INVALID_MESSAGE_LENGTH 0x4
#define AMT_STATUS_HOST_IF_EMPTY_RESPONSE 0x4000
#define AMT_STATUS_SDK_RESOURCES 0x1004
#define AMT_BIOS_VERSION_LEN 65
#define AMT_VERSIONS_NUMBER 50
#define AMT_UNICODE_STRING_LEN 20
typedef enum
{
PTHI_CLIENT,
LMS_CLIENT,
MKHI_CLIENT
} HECI_CLIENTS;
struct amt_unicode_string {
uint16_t length;
char string[AMT_UNICODE_STRING_LEN];
} __attribute__((packed));
struct amt_version_type {
struct amt_unicode_string description;
struct amt_unicode_string version;
} __attribute__((packed));
struct amt_version {
uint8_t major;
uint8_t minor;
} __attribute__((packed));
struct amt_code_versions {
uint8_t bios[AMT_BIOS_VERSION_LEN];
uint32_t count;
struct amt_version_type versions[AMT_VERSIONS_NUMBER];
} __attribute__((packed));
struct mei {
uuid_le guid;
bool initialized;
bool verbose;
unsigned int buf_size;
unsigned char prot_ver;
int fd;
sem_t Lock;
};
struct amt_host_if {
struct mei mei_cl;
unsigned long send_timeout;
bool initialized;
};
struct MEImodule
{
struct amt_code_versions ver;
struct amt_host_if acmd;
unsigned int i;
unsigned int status;
bool verbose;
bool inited;
};
bool heci_Init(struct MEImodule* module, int client);
void heci_Deinit(struct MEImodule* module);
int heci_ReceiveMessage(struct MEImodule* module, unsigned char *buffer, int len, unsigned long timeout); // Timeout default is 2000
int heci_SendMessage(struct MEImodule* module, const unsigned char *buffer, int len, unsigned long timeout); // Timeout default is 2000
unsigned int heci_GetBufferSize(struct MEImodule* module);
unsigned char heci_GetProtocolVersion(struct MEImodule* module);
bool heci_GetHeciVersion(struct MEImodule* module, HECI_VERSION *version);
bool heci_IsInitialized(struct MEImodule* module);
#endif // __HECI_LINUX_H__

377
MicroLMS/heci/HECIWin.c Normal file
View File

@@ -0,0 +1,377 @@
/* INTEL CONFIDENTIAL
* Copyright 2011 - 2019 Intel Corporation.
* This software and the related documents are Intel copyrighted materials, and your use of them is governed by the express license under which they were provided to you ("License"). Unless the License provides otherwise, you may not use, modify, copy, publish, distribute, disclose or transmit this software or the related documents without Intel's prior written permission.
* This software and the related documents are provided as is, with no express or implied warranties, other than those that are expressly stated in the License.
*/
#ifndef _MINCORE
#include <windows.h>
#include <setupapi.h>
#include <initguid.h>
#include <winioctl.h>
#include "HECIWin.h"
#include "heci_if.h"
#define false 0
#define true 1
#define HECI_MAX_LINE_LEN 300
DEFINE_GUID(GUID_DEVINTERFACE_HECI, 0xE2D1FF34, 0x3458, 0x49A9, 0x88, 0xDA, 0x8E, 0x69, 0x15, 0xCE, 0x9B, 0xE5);
DEFINE_GUID(HECI_PTHI_GUID , 0x12F80028, 0xB4B7, 0x4b2d, 0xAC, 0xA8, 0x46, 0xE0, 0xFF, 0x65, 0x81, 0x4c);
DEFINE_GUID(LMS_GUID , 0x6733a4db, 0x0476, 0x4e7b, 0xb3, 0xaf, 0xbc, 0xfc, 0x29, 0xbe, 0xe7, 0xa7);
DEFINE_GUID(MKHI_GUID , 0x8E6A6715, 0x9ABC, 0x4043, 0x88, 0xEF, 0x9E, 0x39, 0xC6, 0xF6, 0x3E, 0x0F);
//VOID _displayHECIError(UINT32 errorCode,DWORD lastError);
//VOID _displayHECIData(UINT32 messageId);
int heci_doIoctl(struct MEImodule* module, DWORD code, void *inbuf, int inlen, void *outbuf, int outlen);
struct MEImodule MEI_global;
/***************************** public functions *****************************/
unsigned int heci_GetBufferSize(struct MEImodule* module) { if (module != NULL) return module->_bufSize; else return MEI_global._bufSize; }
unsigned char heci_GetProtocolVersion(struct MEImodule* module) { if (module != NULL) return module->_protocolVersion; else return MEI_global._protocolVersion; }
bool heci_IsInitialized(struct MEImodule* module) { if (module != NULL) return module->_initialized; else return MEI_global._initialized; }
bool heci_GetHeciVersion(struct MEImodule* module, HECI_VERSION *version)
{
if (module == NULL) module = &MEI_global;
if (module->m_haveHeciVersion)
{
memcpy_s(version, sizeof(HECI_VERSION), &(module->m_heciVersion), sizeof(HECI_VERSION));
return true;
}
return false;
}
bool heci_Init(struct MEImodule* module, HECI_CLIENTS client)
{
PSP_DEVICE_INTERFACE_DETAIL_DATA deviceDetail = NULL;
HDEVINFO hDeviceInfo;
DWORD bufferSize;
SP_DEVICE_INTERFACE_DATA interfaceData;
LONG ii = 0;
int result;
HECI_CLIENT properties;
GUID guid;
if (client == PTHI_CLIENT) guid = HECI_PTHI_GUID;
if (client == LMS_CLIENT) guid = LMS_GUID;
if (client == MKHI_CLIENT) guid = MKHI_GUID;
if (module == NULL) module = &MEI_global;
module->_verbose = false;
if (module->_initialized) {
heci_Deinit(module);
}
// Find all devices that have our interface
hDeviceInfo = SetupDiGetClassDevs((LPGUID)&GUID_DEVINTERFACE_HECI, NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
if (hDeviceInfo == INVALID_HANDLE_VALUE) {
if (module->_verbose) {
//_displayHECIError(GET_CLASS_DEVS,GetLastError());
}
return false; //GET_CLASS_DEVS;
}
// Setup the interface data struct
interfaceData.cbSize = sizeof(interfaceData);
for (ii = 0;
SetupDiEnumDeviceInterfaces(hDeviceInfo, NULL, (LPGUID)&GUID_DEVINTERFACE_HECI, ii, &interfaceData);
++ii) {
// Found our device instance
if (!SetupDiGetDeviceInterfaceDetail(hDeviceInfo, &interfaceData, NULL, 0, &bufferSize, NULL)) {
DWORD err = GetLastError();
if (err != ERROR_INSUFFICIENT_BUFFER) {
if (module->_verbose) {
//_displayHECIError(GET_INTERFACE_DETAIL,err);
}
continue;
}
}
// Allocate a big enough buffer to get detail data
deviceDetail = (PSP_DEVICE_INTERFACE_DETAIL_DATA) malloc(bufferSize);
if (deviceDetail == NULL) {
if (module->_verbose) {
//_displayHECIError(ALLOCATE_MEMORY_ERROR,0);
}
continue;
}
// Setup the device interface struct
deviceDetail->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
// Try again to get the device interface detail info
if (!SetupDiGetDeviceInterfaceDetail(hDeviceInfo, &interfaceData, deviceDetail, bufferSize, NULL, NULL))
{
/*
if (_verbose)
{
DWORD err = GetLastError();
_displayHECIError(GET_INTERFACE_DETAIL,err);
}
*/
free(deviceDetail);
deviceDetail = NULL;
continue;
}
break;
}
SetupDiDestroyDeviceInfoList(hDeviceInfo);
if (deviceDetail == NULL) {
if (module->_verbose) {
//_displayHECIError(FIND_HECI_FAILURE,0);
}
return false; //FIND_HECI_FAILURE;
}
module->_handle = CreateFile(deviceDetail->DevicePath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
free(deviceDetail);
if (module->_handle == INVALID_HANDLE_VALUE) {
if (module->_verbose) {
//_displayHECIError(CREATE_HECI_FILE_FAILURE,GetLastError());
}
return false; //CREATE_HECI_FILE_FAILURE;
}
module->_initialized = true;
result = heci_doIoctl(module, (DWORD)IOCTL_HECI_GET_VERSION, NULL, 0, &(module->m_heciVersion), sizeof(HECI_VERSION));
if (result != sizeof(HECI_VERSION)) {
if (module->_verbose) {
//_displayHECIError(GET_HECI_DRIVER_VERSION_FAILURE,0);
}
heci_Deinit(module);
return false; //GET_HECI_DRIVER_VERSION_FAILURE;
}
module->m_haveHeciVersion = true;
if (module->_verbose) {
//_displayHECIData(HECI_DRIVER_VERSION);
//_ftprintf(stdout,_T("%d.%d.%d.%d\n"), (m_heciVersion).major, (m_heciVersion).minor, (m_heciVersion).hotfix, (m_heciVersion).build);
}
memset(&properties, 0, sizeof(properties));
result = heci_doIoctl(module, (DWORD)IOCTL_HECI_CONNECT_CLIENT, (void*)(&guid), sizeof(GUID), &properties, sizeof(properties));
if (result != sizeof(properties))
{
if (module->_verbose) {
//_displayHECIError(HECI_CONNECT_TO_PTHI_CLIENT_FAILURE,0);
}
//Deinit();
return false; //HECI_CONNECT_TO_PTHI_CLIENT_FAILURE;
}
module->_bufSize = properties.MaxMessageLength;
return true;
}
void heci_Deinit(struct MEImodule* module)
{
if (module == NULL) module = &MEI_global;
if (module->_initialized == false) return;
module->_initialized = false;
module->_bufSize = 0;
if (module->_handle != INVALID_HANDLE_VALUE)
{
CloseHandle(module->_handle);
module->_handle = INVALID_HANDLE_VALUE;
}
}
int heci_ReceiveMessage(struct MEImodule* module, unsigned char *buffer, int len, unsigned long timeout) // Timeout default is 2000
{
DWORD bytesRead = 0;
int res;
HANDLE h_event = NULL;
OVERLAPPED overlapped;
DWORD error;
DWORD eventRes;
if (module == NULL) module = &MEI_global;
if ((h_event = CreateEvent(NULL, FALSE, FALSE, NULL)) == 0) goto out;
overlapped.hEvent = h_event;
overlapped.Offset = 0;
overlapped.OffsetHigh = 0;
res = ReadFile(module->_handle, buffer, len, &bytesRead, &overlapped);
error = GetLastError();
if ((0 == res) && (ERROR_IO_PENDING != error)) {
if (module->_verbose) {
//_displayHECIError(READ_FILE,GetLastError());
}
bytesRead = (DWORD)-1;
goto out;
}
eventRes = WaitForSingleObject(h_event, timeout);
if (eventRes == WAIT_TIMEOUT) {
bytesRead = 0;
goto out;
}
res = GetOverlappedResult(module->_handle, &overlapped, &bytesRead, true);
if (res == 0) {
if (module->_verbose) {
//_displayHECIError(READ_FILE,GetLastError());
}
bytesRead = (DWORD)-1;
goto out;
}
out:
if (h_event != NULL) CloseHandle(h_event);
if (bytesRead <= 0) heci_Deinit(module);
return bytesRead;
}
int heci_SendMessage(struct MEImodule* module, const unsigned char *buffer, int len, unsigned long timeout) // Timeout default is 2000
{
DWORD bytesWritten = 0;
int res;
HANDLE h_event = NULL;
OVERLAPPED overlapped;
DWORD lastError;
DWORD eventRes;
if (module == NULL) module = &MEI_global;
if ((h_event = CreateEvent(NULL, FALSE, FALSE, NULL)) == 0) goto out;
overlapped.hEvent = h_event;
overlapped.Offset = 0;
overlapped.OffsetHigh = 0;
res = WriteFile(module->_handle, buffer, len, &bytesWritten, &overlapped);
lastError = GetLastError();
if ((0 == res) && (ERROR_IO_PENDING !=lastError )) {
if (module->_verbose) {
//_displayHECIError(WRITE_FILE,GetLastError());
}
bytesWritten = (DWORD)-1;
goto out;
}
eventRes = WaitForSingleObject(h_event, timeout);
if (eventRes == WAIT_TIMEOUT) {
if (module->_verbose) {
//_displayHECIError(WRITE_FILE_TIME_OUT,0);
}
bytesWritten = 0;
goto out;
}
res = GetOverlappedResult(module->_handle, &overlapped, &bytesWritten, false);
if (res == 0) {
if (module->_verbose) {
//_displayHECIError(WRITE_FILE,GetLastError());
}
bytesWritten = (DWORD)-1;
goto out;
}
out:
if (h_event != NULL) CloseHandle(h_event);
if (bytesWritten <= 0) heci_Deinit(module);
return bytesWritten;
}
int heci_doIoctl(struct MEImodule* module, DWORD code, void *inbuf, int inlen, void *outbuf, int outlen)
{
int res;
DWORD bytesRead = 0;
HANDLE h_event = NULL;
OVERLAPPED overlapped;
if (module == NULL) module = &MEI_global;
if (!module->_initialized) return -1;
if ((h_event = CreateEvent(NULL, FALSE, FALSE, NULL)) == 0) goto out;
overlapped.hEvent = h_event;
overlapped.Offset = 0;
overlapped.OffsetHigh = 0;
res = DeviceIoControl(module->_handle, code, inbuf, inlen, outbuf, outlen, &bytesRead, &overlapped);
if ((0 == res) && (ERROR_IO_PENDING != GetLastError())) {
if (module->_verbose) {
//_displayHECIError(IOCTL_COMMAND,GetLastError());
}
bytesRead = (DWORD)-1;
goto out;
}
WaitForSingleObject(h_event, INFINITE);
res = GetOverlappedResult(module->_handle, &overlapped, &bytesRead, true);
if (res == 0) {
if (module->_verbose) {
//_displayHECIError(IOCTL_COMMAND,GetLastError());
}
bytesRead = (DWORD)-1;
goto out;
}
out:
if (h_event != NULL) CloseHandle(h_event);
if (bytesRead == (DWORD)-1) heci_Deinit(module);
return bytesRead;
}
TCHAR *_getErrMsg(DWORD err)
{
static TCHAR buffer[1024];
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
err,
0,
buffer,
sizeof(buffer) - 1,
0);
return buffer;
}
/*
// Display a HECI error message
void _displayHECIError(UINT32 errorCode, DWORD lastError)
{
TCHAR str[HECI_MAX_LINE_LEN];
TCHAR *msg;
LoadString(GetModuleHandle(NULL), HECI_ERROR_MESSAGE, str, sizeof(str)/sizeof(TCHAR));
_ftprintf(stderr, _T("%s"), str);
_ftprintf(stderr, _T("%s"), L" ");
LoadString(GetModuleHandle(NULL), errorCode , str, sizeof(str)/sizeof(TCHAR));
if(0!= lastError)
{
msg = _getErrMsg(lastError);
_ftprintf(stderr, _T("%s (%d): %s\n"),str, lastError, msg);
}
else
{
_ftprintf(stderr, _T("%s\n"),str);
}
}
// Display a HECI data message
void _displayHECIData(UINT32 messageId)
{
TCHAR str[HECI_MAX_LINE_LEN];
LoadString(GetModuleHandle(NULL), messageId , str, sizeof(str)/sizeof(TCHAR));
_ftprintf(stdout,_T("%s"),str);
_ftprintf(stdout,_T("%s"),L" ");
}
*/
#endif

49
MicroLMS/heci/HECIWin.h Normal file
View File

@@ -0,0 +1,49 @@
/* INTEL CONFIDENTIAL
* Copyright 2011 - 2019 Intel Corporation.
* This software and the related documents are Intel copyrighted materials, and your use of them is governed by the express license under which they were provided to you ("License"). Unless the License provides otherwise, you may not use, modify, copy, publish, distribute, disclose or transmit this software or the related documents without Intel's prior written permission.
* This software and the related documents are provided as is, with no express or implied warranties, other than those that are expressly stated in the License.
*/
#ifndef _MINCORE
#ifndef __HECI_WIN_H__
#define __HECI_WIN_H__
#include "HECI_if.h"
#include <stdio.h>
#include <windows.h>
#define bool int
typedef enum
{
PTHI_CLIENT,
LMS_CLIENT,
MKHI_CLIENT
} HECI_CLIENTS;
struct MEImodule
{
bool _initialized;
bool _verbose;
unsigned int _bufSize;
unsigned char _protocolVersion;
int _fd;
bool m_haveHeciVersion;
HECI_VERSION m_heciVersion;
HANDLE _handle;
OVERLAPPED overlapped;
};
bool heci_Init(struct MEImodule* module, HECI_CLIENTS client);
void heci_Deinit(struct MEImodule* module);
int heci_ReceiveMessage(struct MEImodule* module, unsigned char *buffer, int len, unsigned long timeout); // Timeout default is 2000
int heci_SendMessage(struct MEImodule* module, const unsigned char *buffer, int len, unsigned long timeout); // Timeout default is 2000
unsigned int heci_GetBufferSize(struct MEImodule* module);
unsigned char heci_GetProtocolVersion(struct MEImodule* module);
bool heci_GetHeciVersion(struct MEImodule* module, HECI_VERSION *version);
bool heci_IsInitialized(struct MEImodule* module);
#endif // __HECI_WIN_H__
#endif

199
MicroLMS/heci/HECI_if.h Normal file
View File

@@ -0,0 +1,199 @@
/* INTEL CONFIDENTIAL
* Copyright 2011 - 2019 Intel Corporation.
* This software and the related documents are Intel copyrighted materials, and your use of them is governed by the express license under which they were provided to you ("License"). Unless the License provides otherwise, you may not use, modify, copy, publish, distribute, disclose or transmit this software or the related documents without Intel's prior written permission.
* This software and the related documents are provided as is, with no express or implied warranties, other than those that are expressly stated in the License.
*/
#ifndef _MINCORE
#ifndef __HECI_INTRFACE_H__
#define __HECI_INTRFACE_H__
typedef unsigned char UINT8;
typedef unsigned short UINT16;
typedef unsigned int UINT32;
typedef char CHAR;
typedef unsigned long ULONG;
typedef UINT32 AMT_STATUS;
typedef UINT32 AMT_BOOLEAN;
typedef enum _HECI_STATUS {
HECI_STATUS_OK = 0x0,
HECI_STATUS_GENERAL_ERROR = 0x2000,
HECI_STATUS_LOCATE_DEVICE_ERROR,
HECI_STATUS_MEMORY_ACCESS_ERROR,
HECI_STATUS_WRITE_REGISTER_ERROR,
HECI_STATUS_MEMORY_ALLOCATION_ERROR,
HECI_STATUS_BUFFER_OVEREFLOW_ERROR,
HECI_STATUS_NOT_ENOUGH_MEMORY,
HECI_STATUS_MSG_TRANSMISSION_ERROR,
HECI_STATUS_VERSION_MISMATCH,
HECI_STATUS_UNEXPECTED_INTERRUPT_REASON,
HECI_STATUS_TIMEOUT_ERROR,
HECI_STATUS_UNEXPECTED_RESPONSE,
HECI_STATUS_UNKNOWN_MESSAGE,
HECI_STATUS_CANNOT_FOUND_HOST_CLIENT,
HECI_STATUS_CANNOT_FOUND_ME_CLIENT,
HECI_STATUS_CLIENT_ALREADY_CONNECTED,
HECI_STATUS_NO_FREE_CONNECTION,
HECI_STATUS_ILLEGAL_PARAMETER,
HECI_STATUS_FLOW_CONTROL_ERROR,
HECI_STATUS_NO_MESSAGE,
HECI_STATUS_BUFFER_TOO_LARGE,
HECI_STATUS_BUFFER_TOO_SMALL,
HECI_STATUS_BUFFER_NOT_EMPTY,
NUM_OF_HECI_STATUSES
} HECI_STATUS;
#ifdef WIN32
// Win32 code
#define AMT_LOCAL_AGENT_STATUS_SUCCESS 0
#define USAGE 1
#define ERROR_MESSAGE 2
#define VERSION_MESSAGE 3
#define HECI_ERROR_MESSAGE 4
#define UNKNOWN 5
#define HECI_CONNECT_TO_FWU_CLIENT_FAILURE 6
#define WRITE_FILE_TIME_OUT 7
#define ME_FW_INFO 8
#define ME_MODE 9
#define IOCTL_COMMAND 10
#define WRITE_FILE 11
#define READ_FILE 12
#define GET_CLASS_DEVS 13
#define GET_INTERFACE_DETAIL 14
#define ICH_VERSION 15
#define FIND_HECI_FAILURE 16
#define CREATE_HECI_FILE 17
#define CREATE_HECI_FILE_FAILURE 17
#define GET_HECI_DRIVER_VERSION_FAILURE 18
#define LA_STATUS_INTERNAL_ERROR 19
#define HECI_CONNECT_TO_PTHI_CLIENT_FAILURE 20
#define LA_HECI_ERROR 21
#define ALLOCATE_MEMORY_ERROR 22
#define LA_HECI_NOT_INSTALLED_ERROR 23
#define FW_BUFFER_IS_TO_SMALL 24
#define SEND_DATA_TO_FW_FAILURE 25
#define RECEIVE_DATA_FROM_FW_FAILURE 26
#define GET_INFO_FROM_HECI_FAILURE 27
#define MCH_VERSION 28
#define OEM_VENDOR 29
#define HECI_DRIVER_VERSION 30
#define CODE_MAJOR_VERSION 31
#define CODE_MINOR_VERSION 32
#define CODE_HOTFIX_VERSION 33
#define CODE_BUID_VERSION 34
#define BIOS_VERSION 35
#define AMT_CODE_VERSION 36
#define AMT_MODE 37
#define AMT_MODE_1 38
#define IDS_STRING39 39
#define AMT_MODE_2 39
#define PROVISIONING_STATE 40
#define STATE_PRE 41
#define STATE_IN 42
#define STATE_POST 43
#define IDS_STRING44 44
#define PARSE_KEYWORD_DISCOVERY_TEST 44
#define DISCOVERY_PASS 45
#define IDS_STRING46 46
#define DISCOVERY_FAILED 46
#define IDS_STRING47 47
#define PARSE_KEYWORD_ACTIVATE 47
#define PARSE_KEYWORD_OTP 48
#define PARSE_KEYWORD_DNS 49
#define PARSE_KEYWORD_VERBOSE 50
#define INVALID_PARAM_INPUT 51
#define USAGE_LOCAL_AGENT 52
#define USAGE_OPTIONS 53
#define USAGE_OPTIONS_OTP 54
#define USAGE_OPTIONS_DNS 55
#define USAGE_OPTIONS_DISCOVERY 56
#define USAGE_OPTIONS_ACTIVATE 57
#define USAGE_OPTIONS_VERBOSE 58
#define WORD_ZTC 59
#define WORD_ENABLED 60
#define WORD_DISABLED 61
#define WORD_PROVISIONING_TLS_MODE 62
#define WORD_PKI 63
#define WORD_PSK 64
#define WORD_RNG_SEED_STATUS 65
#define WORD_EXIST 66
#define WORD_IN_PROGRESS 67
#define WORD_NOT_EXIST 68
#define WORD_AMT_CONFIG_ACTIVATE 69
#define WORD_SUCCESS 70
#define IDS_STRING71 71
#define WORD_FAILURE 71
#define WORD_NOT_READY 72
#define IDS_STRING73 73
#define HASH_ENTRY 73
#define HECI_CONNECT_TO_WD_CLIENT_FAILURE 74
#define CHANGE_TO_AMT_FAILURE 75
#define IDS_STRING76 76
#define WORD_CHANGE_TO_AMT 76
#define FOUND 77
#define CERT_HASHES_IN_FW 78
#define NO_HANDLES_FOUND 79
#define CERT_HASH 80
#define FRIENDLY_NAME 81
#define FILE_DEVICE_HECI 0x8000
#define HECI_IOCTL(index) CTL_CODE(FILE_DEVICE_HECI, index, METHOD_BUFFERED, FILE_READ_DATA)
#define IOCTL_HECI_GET_VERSION CTL_CODE(FILE_DEVICE_HECI, 0x800, METHOD_BUFFERED, FILE_READ_ACCESS|FILE_WRITE_ACCESS)
#define IOCTL_HECI_CONNECT_CLIENT CTL_CODE(FILE_DEVICE_HECI, 0x801, METHOD_BUFFERED, FILE_READ_ACCESS|FILE_WRITE_ACCESS)
#define IOCTL_HECI_WD CTL_CODE(FILE_DEVICE_HECI, 0x802, METHOD_BUFFERED, FILE_READ_ACCESS|FILE_WRITE_ACCESS)
#endif
#pragma pack(1)
typedef struct _HECI_VERSION {
UINT8 major;
UINT8 minor;
UINT8 hotfix;
UINT16 build;
} HECI_VERSION;
typedef struct _HECI_CLIENT {
UINT32 MaxMessageLength;
UINT8 ProtocolVersion;
} HECI_CLIENT;
typedef union _MEFWCAPS_SKU
{
UINT32 Data;
struct {
UINT32 Reserved :1; //Legacy
UINT32 Qst :1; //QST
UINT32 Asf :1; //ASF2
UINT32 Amt :1; //AMT Professional
UINT32 AmtFund :1; //AMT Fundamental
UINT32 Tpm :1; //TPM
UINT32 Dt :1;
UINT32 Fps :1; //Fingerprint Sensor
UINT32 HomeIT :1; //Home IT
UINT32 Mctp :1; //MCTP
UINT32 WoX :1;
UINT32 PmcPatch :1; //PMC Patch
UINT32 Ve :1; //VE
UINT32 Tdt :1; //Theft Deterrent Technology
UINT32 Corp :1; //Corporate
UINT32 Reserved2 :17;
} Fields;
} MEFWCAPS_SKU;
typedef enum _MEFWCAPS_MANAGEABILITY_SUPP
{
MEFWCAPS_MANAGEABILITY_SUPP_NONE = 0,
MEFWCAPS_MANAGEABILITY_SUPP_AMT,
MEFWCAPS_MANAGEABILITY_SUPP_ASF,
MEFWCAPS_MANAGEABILITY_SUPP_CP
} MEFWCAPS_MANAGEABILITY_SUPP;
#pragma pack()
#endif // __HECI_INTRFACE_H__
#endif

View File

@@ -0,0 +1,554 @@
/* INTEL CONFIDENTIAL
* Copyright 2011 - 2019 Intel Corporation.
* This software and the related documents are Intel copyrighted materials, and your use of them is governed by the express license under which they were provided to you ("License"). Unless the License provides otherwise, you may not use, modify, copy, publish, distribute, disclose or transmit this software or the related documents without Intel's prior written permission.
* This software and the related documents are provided as is, with no express or implied warranties, other than those that are expressly stated in the License.
*/
#ifndef _MINCORE
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "LMEConnection.h"
#include "LMS_if.h"
#include "../microstack/ILibParsers.h"
#ifdef _POSIX
#define UNREFERENCED_PARAMETER(P) (P)
#endif
#define MEI_IO_TIMEOUT 1000
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
const unsigned int LME_RX_WINDOW_SIZE = 4096;
int LME_sendMessage(struct LMEConnection* module, unsigned char *buffer, int len);
void LME_doRX(struct LMEConnection* module, unsigned char *rxBuffer, unsigned int bytesRead);
void LME_apfGlobalRequest(struct LMEConnection* module, unsigned char *rxBuffer, unsigned int bytesRead, int *status);
void LME_Deinit(struct LMEConnection* module);
bool LME_IsInitialized(struct LMEConnection* module)
{
// Lock il(_initLock);
bool ret = (bool)(module->initState == INIT_STATE_CONNECTED);
return ret;
}
#ifdef WIN32
DWORD WINAPI LME_Thread(void* obj)
#else
void LME_Thread(void* obj)
#endif
{
#ifdef WIN32
HECI_VERSION version;
#endif
int len = 0;
int bufsize = 0;
unsigned char* data = NULL;
struct LMEConnection* module = (struct LMEConnection*)obj;
//printf("LMS THREAD START\r\n");
do {
bufsize = heci_GetBufferSize(&(module->mei));
if ((data = (unsigned char*)malloc(bufsize)) == NULL) ILIBCRITICALEXIT(254);
do {
len = heci_ReceiveMessage(&(module->mei), data, bufsize, 0xFFFFFFFF);
//printf("LMS THREAD READ LEN=%d\r\n", len);
if (len > 0 && data != NULL) LME_doRX(module, data, len);
} while (len >= 0);
module->cb(module, module->cbParam, NULL, 0);
module->initState = INIT_STATE_DISCONNECTED;
free(data);
// printf("LMS TRYING RECONNECT\r\n");
while (module->exit == 0 && module->initState == INIT_STATE_DISCONNECTED)
{
// Setup the MEI interface with the LME GUID
#ifdef WIN32
if (heci_Init(&(module->mei), LMS_CLIENT) == TRUE && heci_GetHeciVersion(&(module->mei), &version) == TRUE && version.major >= LMS_PROTOCOL_VERSION) { module->initState = INIT_STATE_CONNECTED; }
#else
if (heci_Init(&(module->mei), 1) == TRUE && heci_GetProtocolVersion(&(module->mei)) >= LMS_PROTOCOL_VERSION) { module->initState = INIT_STATE_CONNECTED; }
#endif
if (module->exit == 0 && module->initState == INIT_STATE_DISCONNECTED)
{
// printf("LMS THREAD SLEEP\r\n");
#ifdef WIN32
Sleep(2000);
#else
sleep(2);
#endif
}
//if (module->initState == INIT_STATE_CONNECTED) printf("LMS THREAD RECONNECT\r\n");
}
}
while (module->exit == 0);
// printf("LMS THREAD QUIT\r\n");
module->exit = 2;
#ifdef WIN32
return 0;
#endif
}
// Setup the LME connection
bool LME_Init(struct LMEConnection* module, MEICallback cb, void *param)
{
#ifdef WIN32
HECI_VERSION version;
#endif
// Setup the state object
memset(module, 0, sizeof(struct LMEConnection));
module->initState = INIT_STATE_DISCONNECTED;
module->cb = cb;
module->cbParam = param;
// Setup the MEI interface with the LME GUID
#ifdef WIN32
if (heci_Init(&(module->mei), LMS_CLIENT) == FALSE || heci_GetHeciVersion(&(module->mei), &version) == FALSE || version.major < LMS_PROTOCOL_VERSION) { module->initState = INIT_STATE_DISCONNECTED; return FALSE; }
#else
if (heci_Init(&(module->mei), 1) == FALSE || heci_GetProtocolVersion(&(module->mei)) < LMS_PROTOCOL_VERSION) { module->initState = INIT_STATE_DISCONNECTED; return FALSE; }
#endif
module->initState = INIT_STATE_CONNECTED;
if ((module->txBuffer = (unsigned char*)malloc(LME_GetMeiBufferSize(module))) == NULL) ILIBCRITICALEXIT(254);
// Create the thread that will read the MEI/LME stream
ILibSpawnNormalThread((voidfp)(&LME_Thread), module);
return TRUE;
}
// Disconnect the LME connection
void LME_Deinit(struct LMEConnection* module)
{
//printf("LME_Deinit()\r\n");
if (module == NULL) return;
if (module->initState == INIT_STATE_CONNECTED) { heci_Deinit(&(module->mei)); }
module->initState = INIT_STATE_DISCONNECTED;
}
// Exit LME
void LME_Exit(struct LMEConnection* module)
{
int l = 0;
//printf("LME_Exit()\r\n");
if (module == NULL) return;
if (module->exit == 0) module->exit = 1;
LME_Deinit(module);
#ifdef WIN32
while (module->exit != 2 && l < 40) { Sleep(100); l++; }
#else
/*
while (module->exit != 2 && l < 4)
{
printf("LME_Holding %d\r\n", l);
Sleep(1);
l++;
}
*/
#endif
if (module->txBuffer != NULL && l < 40) { free(module->txBuffer); module->txBuffer = NULL; }
}
// Send the APF disconnect message to the MEI
bool LME_Disconnect(struct LMEConnection* module, APF_DISCONNECT_REASON_CODE reasonCode)
{
unsigned char buf[sizeof(APF_DISCONNECT_MESSAGE)];
APF_DISCONNECT_MESSAGE *disconnectMessage = (APF_DISCONNECT_MESSAGE *)buf;
memset(disconnectMessage, 0, sizeof(buf));
disconnectMessage->MessageType = APF_DISCONNECT;
disconnectMessage->ReasonCode = htonl(reasonCode);
return (LME_sendMessage(module, buf, sizeof(buf)) == sizeof(buf));
}
// Send the AFP service accept message to the MEI
bool LME_ServiceAccept(struct LMEConnection* module, char* serviceName)
{
int len;
int res;
int servicenamelen = (int)strnlen_s(serviceName, _MAX_PATH);
unsigned char *buf;
unsigned char *pCurrent;
if (!LME_IsInitialized(module)) return FALSE;
if ((buf = (unsigned char*)malloc(sizeof(APF_SERVICE_ACCEPT_MESSAGE) + servicenamelen)) == NULL) ILIBCRITICALEXIT(254);
pCurrent = buf;
*pCurrent = APF_SERVICE_ACCEPT;
++pCurrent;
*((unsigned int *)pCurrent) = htonl(servicenamelen);
pCurrent += 4;
memcpy_s(pCurrent, sizeof(APF_SERVICE_ACCEPT_MESSAGE) + servicenamelen, serviceName, servicenamelen);
pCurrent += servicenamelen;
len = (int)(pCurrent - buf);
res = LME_sendMessage(module, buf, len);
free(buf);
return (res == len);
}
bool LME_ProtocolVersion(struct LMEConnection* module, unsigned int majorversion, unsigned int minorversion, unsigned int triggerreason)
{
APF_PROTOCOL_VERSION_MESSAGE protVersion;
memset(&protVersion, 0, sizeof(protVersion));
protVersion.MessageType = APF_PROTOCOLVERSION;
protVersion.MajorVersion = htonl(majorversion);
protVersion.MinorVersion = htonl(minorversion);
protVersion.TriggerReason = htonl(triggerreason);
return (LME_sendMessage(module, (unsigned char *)&protVersion, sizeof(protVersion)) == sizeof(protVersion));
}
bool LME_TcpForwardReplySuccess(struct LMEConnection* module, unsigned int port)
{
APF_TCP_FORWARD_REPLY_MESSAGE message;
memset(&message, 0, sizeof(message));
message.MessageType = APF_REQUEST_SUCCESS;
message.PortBound = htonl(port);
return (LME_sendMessage(module, (unsigned char *)&message, sizeof(message)) == sizeof(message));
}
bool LME_SendShortMessage(struct LMEConnection* module, unsigned char buf)
{
return (LME_sendMessage(module, &buf, sizeof(buf)) == sizeof(buf));
}
#define pCurrentOffset ((int)(pCurrent - buf))
bool LME_ChannelOpenForwardedRequest(struct LMEConnection* module, unsigned int senderChannel, char* connectedIP, unsigned int connectedPort, char* originatorIP, unsigned int originatorPort)
{
int res;
int connectedIPlen = (int)strnlen_s(connectedIP, _MAX_PATH);
int originatorIPlen = (int)strnlen_s(originatorIP, _MAX_PATH);
unsigned char *buf;
unsigned char *pCurrent;
int mallocSize = 5 + APF_STR_SIZE_OF(APF_OPEN_CHANNEL_REQUEST_FORWARDED) + 16 + connectedIPlen + 8 + originatorIPlen + 4;
if (!LME_IsInitialized(module)) return FALSE;
if ((buf = (unsigned char*)malloc(mallocSize)) == NULL) ILIBCRITICALEXIT(254);
pCurrent = buf;
if (strnlen_s(originatorIP, _MAX_PATH) > 63) { free(buf); return FALSE; }
*pCurrent = APF_CHANNEL_OPEN;
++pCurrent;
*((unsigned int *)pCurrent) = htonl(APF_STR_SIZE_OF(APF_OPEN_CHANNEL_REQUEST_FORWARDED));
pCurrent += sizeof(unsigned int);
memcpy_s(pCurrent, mallocSize - pCurrentOffset, APF_OPEN_CHANNEL_REQUEST_FORWARDED, APF_STR_SIZE_OF(APF_OPEN_CHANNEL_REQUEST_FORWARDED));
pCurrent += APF_STR_SIZE_OF(APF_OPEN_CHANNEL_REQUEST_FORWARDED);
*((unsigned int *)pCurrent) = htonl(senderChannel);
pCurrent += sizeof(unsigned int);
*((unsigned int *)pCurrent) = htonl(LME_RX_WINDOW_SIZE);
pCurrent += sizeof(unsigned int);
*((unsigned int *)pCurrent) = 0xFFFFFFFF;
pCurrent += sizeof(unsigned int);
*((unsigned int *)pCurrent) = htonl(connectedIPlen);
pCurrent += sizeof(unsigned int);
memcpy_s(pCurrent, mallocSize - pCurrentOffset, connectedIP, connectedIPlen);
pCurrent += connectedIPlen;
*((unsigned int *)pCurrent) = htonl(connectedPort);
pCurrent += sizeof(unsigned int);
*((unsigned int *)pCurrent) = htonl((unsigned int)originatorIPlen);
pCurrent += sizeof(unsigned int);
memcpy_s(pCurrent, mallocSize - pCurrentOffset, originatorIP, originatorIPlen);
pCurrent += originatorIPlen;
*((unsigned int *)pCurrent) = htonl(originatorPort);
pCurrent += sizeof(unsigned int);
res = LME_sendMessage(module, buf, (int)(pCurrent - buf));
free(buf);
return (res == pCurrent - buf);
}
bool LME_ChannelOpenReplySuccess(struct LMEConnection* module, unsigned int recipientChannel, unsigned int senderChannel)
{
APF_CHANNEL_OPEN_CONFIRMATION_MESSAGE message;
message.MessageType = APF_CHANNEL_OPEN_CONFIRMATION;
message.RecipientChannel = htonl(recipientChannel);
message.SenderChannel = htonl(senderChannel);
message.InitialWindowSize = htonl(LME_RX_WINDOW_SIZE);
message.Reserved = 0xFFFFFFFF;
return (LME_sendMessage(module, (unsigned char*)&message, sizeof(message)) == sizeof(message));
}
bool LME_ChannelOpenReplyFailure(struct LMEConnection* module, unsigned int recipientChannel, unsigned int reason)
{
APF_CHANNEL_OPEN_FAILURE_MESSAGE message;
message.MessageType = APF_CHANNEL_OPEN_FAILURE;
message.RecipientChannel = htonl(recipientChannel);
message.ReasonCode = htonl(reason);
message.Reserved = 0x00000000;
message.Reserved2 = 0x00000000;
return (LME_sendMessage(module, (unsigned char*)&message, sizeof(message)) == sizeof(message));
}
bool LME_ChannelClose(struct LMEConnection* module, unsigned int recipientChannel, unsigned int senderChannel )
{
APF_CHANNEL_CLOSE_MESSAGE message;
UNREFERENCED_PARAMETER( senderChannel );
message.MessageType = APF_CHANNEL_CLOSE;
message.RecipientChannel = htonl(recipientChannel);
return (LME_sendMessage(module, (unsigned char*)&message, sizeof(message)) == sizeof(message));
}
int LME_ChannelData(struct LMEConnection* module, unsigned int recipientChannel, unsigned int len, unsigned char *buffer)
{
APF_CHANNEL_DATA_MESSAGE *message;
if (len > (LME_GetMeiBufferSize(module) - sizeof(APF_CHANNEL_DATA_MESSAGE)) || module->txBuffer == NULL) return -1;
message = (APF_CHANNEL_DATA_MESSAGE*)module->txBuffer;
message->MessageType = APF_CHANNEL_DATA;
message->RecipientChannel = htonl(recipientChannel);
message->DataLength = htonl(len);
memcpy_s(module->txBuffer + sizeof(APF_CHANNEL_DATA_MESSAGE), LME_GetMeiBufferSize(module) - sizeof(APF_CHANNEL_DATA_MESSAGE), buffer, len);
return LME_sendMessage(module, (unsigned char *)message, sizeof(APF_CHANNEL_DATA_MESSAGE) + len) - sizeof(APF_CHANNEL_DATA_MESSAGE);
}
bool LME_ChannelWindowAdjust(struct LMEConnection* module, unsigned int recipientChannel, unsigned int len)
{
APF_WINDOW_ADJUST_MESSAGE message;
message.MessageType = APF_CHANNEL_WINDOW_ADJUST;
message.RecipientChannel = htonl(recipientChannel);
message.BytesToAdd = htonl(len);
return (LME_sendMessage(module, (unsigned char *)&message, sizeof(message)) == sizeof(message));
}
int LME_sendMessage(struct LMEConnection* module, unsigned char *buffer, int len)
{
int result;
if (!LME_IsInitialized(module)) { return -1; }
result = heci_SendMessage(&(module->mei), buffer, len, MEI_IO_TIMEOUT);
if (result < 0) LME_Deinit(module);
return result;
}
bool LME_checkMinMsgSize(unsigned char *buf, unsigned int bytesRead)
{
switch (buf[0]) {
case APF_DISCONNECT:
if (bytesRead < sizeof(APF_DISCONNECT_MESSAGE)) { return FALSE; }
break;
case APF_SERVICE_REQUEST:
if (bytesRead < sizeof(APF_SERVICE_REQUEST_MESSAGE)) { return FALSE; }
if (bytesRead < (sizeof(APF_SERVICE_REQUEST_MESSAGE) + ntohl(((APF_SERVICE_REQUEST_MESSAGE *)buf)->ServiceNameLength))) { return FALSE; }
break;
case APF_USERAUTH_REQUEST:
if (bytesRead < (3 * sizeof(unsigned int))) { return FALSE; }
break;
case APF_GLOBAL_REQUEST:
if (bytesRead < (sizeof(APF_GENERIC_HEADER) + sizeof(UINT8))) { return FALSE; }
if (bytesRead < (sizeof(APF_GENERIC_HEADER) + sizeof(UINT8) + ntohl(((APF_GENERIC_HEADER *)buf)->StringLength))) { return FALSE; }
break;
case APF_CHANNEL_OPEN:
if (bytesRead < sizeof(APF_GENERIC_HEADER)) { return FALSE; }
if (bytesRead < (sizeof(APF_GENERIC_HEADER) + ntohl(((APF_GENERIC_HEADER *)buf)->StringLength))) { return FALSE; }
break;
case APF_CHANNEL_OPEN_CONFIRMATION:
if (bytesRead < sizeof(APF_CHANNEL_OPEN_CONFIRMATION_MESSAGE)) { return FALSE; }
break;
case APF_CHANNEL_OPEN_FAILURE:
if (bytesRead < sizeof(APF_CHANNEL_OPEN_FAILURE_MESSAGE)) { return FALSE; }
break;
case APF_CHANNEL_CLOSE:
if (bytesRead < sizeof(APF_CHANNEL_CLOSE_MESSAGE)) { return FALSE; }
break;
case APF_CHANNEL_DATA:
if (bytesRead < sizeof(APF_CHANNEL_DATA_MESSAGE)) { return FALSE; }
if (bytesRead < (sizeof(APF_CHANNEL_DATA_MESSAGE) + ntohl(((APF_CHANNEL_DATA_MESSAGE *)buf)->DataLength))) { return FALSE; }
break;
case APF_CHANNEL_WINDOW_ADJUST:
if (bytesRead < sizeof(APF_WINDOW_ADJUST_MESSAGE)) { return FALSE; }
break;
case APF_PROTOCOLVERSION:
if (bytesRead < sizeof(APF_PROTOCOL_VERSION_MESSAGE)) { return FALSE; }
break;
default:
return FALSE;
}
return TRUE;
}
void LME_doRX(struct LMEConnection* module, unsigned char *rxBuffer, unsigned int bytesRead)
{
if (bytesRead == 0) return;
if (!LME_checkMinMsgSize(rxBuffer, bytesRead)) { LME_Deinit(module); return; }
module->cb(module, module->cbParam, rxBuffer, bytesRead);
}
/*
void LME_apfChannelOpen(struct LMEConnection* module, unsigned char *rxBuffer, unsigned int bytesRead, int *status)
{
APF_GENERIC_HEADER *pHeader = (APF_GENERIC_HEADER *)rxBuffer;
if (_strnicmp((char *)pHeader->String, APF_OPEN_CHANNEL_REQUEST_DIRECT, APF_STR_SIZE_OF(APF_OPEN_CHANNEL_REQUEST_DIRECT)) == 0)
{
unsigned int senderChannel = 0;
LME_apfChannelOpenDirect(module, rxBuffer, bytesRead, &senderChannel, status);
if (LME_IsInitialized(module) && (*status == 1)) {
if (plugin.retry(rxBuffer, bytesRead) != LMS_DROPPED) { LME_apfChannelOpenDirect(module, rxBuffer, bytesRead, NULL, status); }
}
if (LME_IsInitialized(module) && (*status == 1)) {
LME_ChannelOpenReplyFailure(module, senderChannel, OPEN_FAILURE_REASON_CONNECT_FAILED);
}
}
}
void LME_apfChannelOpenDirect(struct LMEConnection* module, unsigned char *rxBuffer, unsigned int bytesRead, unsigned int *senderChannel, int *status)
{
unsigned char *pCurrent;
APF_GENERIC_HEADER *pHeader = (APF_GENERIC_HEADER *)rxBuffer;
if (bytesRead < sizeof(APF_GENERIC_HEADER) +
ntohl(pHeader->StringLength) +
7 + (5 * sizeof(unsigned int))) {
ILIBMESSAGE("apfChannelOpenDirect: Error receiving data from MEI\n");
LME_Deinit(module);
return;
}
pCurrent = rxBuffer + sizeof(APF_GENERIC_HEADER) +
APF_STR_SIZE_OF(APF_OPEN_CHANNEL_REQUEST_DIRECT);
LMEChannelOpenRequestMessage channelOpenRequest;
channelOpenRequest.ChannelType = APF_CHANNEL_DIRECT;
channelOpenRequest.SenderChannel = ntohl(*((unsigned int *)pCurrent));
if (senderChannel) {
*senderChannel = channelOpenRequest.SenderChannel;
}
pCurrent += sizeof(unsigned int);
channelOpenRequest.InitialWindow = ntohl(*((unsigned int *)pCurrent));
pCurrent += 2 * sizeof(unsigned int);
unsigned int len = ntohl(*((unsigned int *)pCurrent));
pCurrent += sizeof(unsigned int);
channelOpenRequest.Address.append((char *)pCurrent, len);
pCurrent += len;
channelOpenRequest.Port = ntohl(*((unsigned int *)pCurrent));
pCurrent += sizeof(unsigned int);
module->_cb(module, module->_cbParam, &channelOpenRequest, sizeof(channelOpenRequest), status);
}
*/
/*
void LME_apfUserAuthRequest(struct LMEConnection* module, unsigned char *rxBuffer, unsigned int bytesRead, int *status)
{
unsigned char *pCurrent = rxBuffer;
++pCurrent;
LMEUserAuthRequestMessage userAuthRequest;
unsigned int len = ntohl(*((unsigned int *)pCurrent));
pCurrent += sizeof(unsigned int);
if ((bytesRead - (pCurrent - rxBuffer)) < len) {
ILIBMESSAGE("_apfUserAuthRequest1: Error receiving data from MEI\n");
LME_Deinit(module);
return;
}
userAuthRequest.Username.append((char *)pCurrent, len);
pCurrent += len;
if ((unsigned int)(bytesRead - (pCurrent - rxBuffer)) < sizeof(unsigned int)) {
ILIBMESSAGE("_apfUserAuthRequest2: Error receiving data from MEI\n");
LME_Deinit(module);
return;
}
len = ntohl(*((unsigned int *)pCurrent));
pCurrent += sizeof(unsigned int);
if ((bytesRead - (pCurrent - rxBuffer)) < len) {
ILIBMESSAGE("_apfUserAuthRequest3: Error receiving data from MEI\n");
LME_Deinit(module);
return;
}
userAuthRequest.ServiceName.append((char *)pCurrent, len);
pCurrent += len;
if ((unsigned int)(bytesRead - (pCurrent - rxBuffer)) < sizeof(unsigned int)) {
ILIBMESSAGE("_apfUserAuthRequest4: Error receiving data from MEI\n");
LME_Deinit(module);
return;
}
len = ntohl(*((unsigned int *)pCurrent));
pCurrent += sizeof(unsigned int);
if ((bytesRead - (pCurrent - rxBuffer)) < len) {
ILIBMESSAGE("_apfUserAuthRequest5: Error receiving data from MEI\n");
LME_Deinit(module);
return;
}
userAuthRequest.MethodName.append((char *)pCurrent, len);
pCurrent += len;
if (_strnicmp(userAuthRequest.MethodName.c_str(), APF_AUTH_PASSWORD,
userAuthRequest.MethodName.size()) == 0) {
if ((unsigned int)(bytesRead - (pCurrent - rxBuffer)) < sizeof(unsigned int) + 1) {
ILIBMESSAGE("_apfUserAuthRequest6: Error receiving data from MEI\n");
LME_Deinit(module);
return;
}
++pCurrent;
len = ntohl(*((unsigned int *)pCurrent));
pCurrent += sizeof(unsigned int);
if ((bytesRead - (pCurrent - rxBuffer)) < len) {
ILIBMESSAGE("_apfUserAuthRequest7: Error receiving data from MEI\n");
LME_Deinit(module);
return;
}
AuthPasswordData authData;
authData.Password.append((char *)pCurrent, len);
pCurrent += len;
userAuthRequest.MethodData = &authData;
}
module->_cb(module, module->_cbParam, &userAuthRequest, sizeof(userAuthRequest), status);
}
*/
unsigned int LME_GetMeiBufferSize(struct LMEConnection* module)
{
return heci_GetBufferSize(&(module->mei));
}
#endif

View File

@@ -0,0 +1,185 @@
/* INTEL CONFIDENTIAL
* Copyright 2011 - 2019 Intel Corporation.
* This software and the related documents are Intel copyrighted materials, and your use of them is governed by the express license under which they were provided to you ("License"). Unless the License provides otherwise, you may not use, modify, copy, publish, distribute, disclose or transmit this software or the related documents without Intel's prior written permission.
* This software and the related documents are provided as is, with no express or implied warranties, other than those that are expressly stated in the License.
*/
#ifndef _MINCORE
#ifndef __LME_CONNECTION_H__
#define __LME_CONNECTION_H__
#ifdef WIN32
#include "HECIWin.h"
#else
#include "HECILinux.h"
#endif
#include "LMS_if.h"
enum INIT_STATES {
INIT_STATE_DISCONNECTED = 0,
INIT_STATE_CONNECTING,
INIT_STATE_CONNECTED
};
struct LMEConnection;
typedef void (*MEICallback)(struct LMEConnection* module, void *param, void *buffer, unsigned int len);
struct LMEConnection
{
unsigned char reqID;
unsigned char *txBuffer;
MEICallback cb;
void* cbParam;
enum INIT_STATES initState;
unsigned char protocolVer;
struct MEImodule mei;
unsigned char exit;
};
struct LMEDisconnectMessage
{
APF_MESSAGE_TYPE MessageType;
APF_DISCONNECT_REASON_CODE ReasonCode;
};
struct LMEServiceRequestMessage
{
APF_MESSAGE_TYPE MessageType;
char* ServiceName;
};
typedef enum APF_REQUEST_ENUM {
TCP_FORWARD_REQUEST,
TCP_FORWARD_CANCEL_REQUEST,
UDP_SEND_TO
} APF_REQUEST_TYPE;
struct LMEGlobalRequestMessage
{
APF_MESSAGE_TYPE MessageType;
APF_REQUEST_TYPE RequestType;
};
struct LMEProtocolVersionMessage
{
APF_MESSAGE_TYPE MessageType;
unsigned int MajorVersion;
unsigned int MinorVersion;
APF_TRIGGER_REASON TriggerReason;
};
struct LMEUserAuthRequestMessage
{
APF_MESSAGE_TYPE MessageType;
char* Username;
char* ServiceName;
char* MethodName;
char* MethodData;
};
struct LMETcpForwardRequestMessage
{
APF_MESSAGE_TYPE MessageType;
APF_REQUEST_TYPE RequestType;
char* Address;
unsigned int Port;
};
struct LMETcpForwardCancelRequestMessage {
APF_MESSAGE_TYPE MessageType;
APF_REQUEST_TYPE RequestType;
char* Address;
unsigned int Port;
};
struct LMEUdpSendToMessage
{
APF_MESSAGE_TYPE MessageType;
APF_REQUEST_TYPE RequestType;
char* Address;
unsigned int Port;
unsigned int DataLength;
unsigned char *Data;
};
typedef enum APF_CHANNEL_ENUM {
APF_CHANNEL_FORWARDED,
APF_CHANNEL_DIRECT
} APF_CHANNEL_TYPE;
struct LMEChannelOpenRequestMessage
{
APF_MESSAGE_TYPE MessageType;
APF_CHANNEL_TYPE ChannelType;
unsigned int SenderChannel;
unsigned int InitialWindow;
char* Address;
unsigned int Port;
};
struct LMEChannelOpenReplySuccessMessage
{
APF_MESSAGE_TYPE MessageType;
unsigned int RecipientChannel;
unsigned int SenderChannel;
unsigned int InitialWindow;
};
struct LMEChannelOpenReplyFailureMessage
{
APF_MESSAGE_TYPE MessageType;
unsigned int RecipientChannel;
OPEN_FAILURE_REASON ReasonCode;
};
struct LMEChannelCloseMessage
{
APF_MESSAGE_TYPE MessageType;
unsigned int RecipientChannel;
};
struct LMEChannelDataMessage
{
APF_MESSAGE_TYPE MessageType;
unsigned int RecipientChannel;
unsigned int DataLength;
unsigned char *Data;
};
struct LMEChannelWindowAdjustMessage
{
APF_MESSAGE_TYPE MessageType;
unsigned int RecipientChannel;
unsigned int BytesToAdd;
};
bool LME_Init(struct LMEConnection* module, MEICallback cb, void *param);
void LME_Deinit(struct LMEConnection* module);
bool LME_IsInitialized(struct LMEConnection* module);
bool LME_Disconnect(struct LMEConnection* module, APF_DISCONNECT_REASON_CODE reasonCode);
bool LME_ServiceAccept(struct LMEConnection* module, char* serviceName);
bool LME_ProtocolVersion(struct LMEConnection* module, unsigned int majorversion, unsigned int minorversion, unsigned int triggerreason);
bool LME_TcpForwardReplySuccess(struct LMEConnection* module, unsigned int port);
bool LME_SendShortMessage(struct LMEConnection* module, unsigned char buf);
bool LME_ChannelOpenForwardedRequest(struct LMEConnection* module, unsigned int sender, char* connectedIP, unsigned int connectedPort, char* originatorIP, unsigned int originatorPort);
bool LME_ChannelOpenReplySuccess(struct LMEConnection* module, unsigned int recipient, unsigned int sender);
bool LME_ChannelOpenReplyFailure(struct LMEConnection* module, unsigned int recipient, unsigned int reason);
bool LME_ChannelClose(struct LMEConnection* module, unsigned int recipient, unsigned int sender);
int LME_ChannelData(struct LMEConnection* module, unsigned int recipient, unsigned int len, unsigned char *buffer);
bool LME_ChannelWindowAdjust(struct LMEConnection* module, unsigned int recipient, unsigned int len);
void LME_Deinit(struct LMEConnection* module);
void LME_Exit(struct LMEConnection* module);
unsigned int LME_GetMeiBufferSize(struct LMEConnection* module);
#define LME_UserAuthSuccess(module) LME_SendShortMessage(module, APF_USERAUTH_SUCCESS)
#define LME_TcpForwardReplyFailure(module) LME_SendShortMessage(module, APF_REQUEST_FAILURE)
#define LME_TcpForwardCancelReplySuccess(module) LME_SendShortMessage(module, APF_REQUEST_SUCCESS)
#define LME_TcpForwardCancelReplyFailure(module) LME_SendShortMessage(module, APF_REQUEST_FAILURE)
#endif
#endif

173
MicroLMS/heci/LMS_if.h Normal file
View File

@@ -0,0 +1,173 @@
/* INTEL CONFIDENTIAL
* Copyright 2011 - 2019 Intel Corporation.
* This software and the related documents are Intel copyrighted materials, and your use of them is governed by the express license under which they were provided to you ("License"). Unless the License provides otherwise, you may not use, modify, copy, publish, distribute, disclose or transmit this software or the related documents without Intel's prior written permission.
* This software and the related documents are provided as is, with no express or implied warranties, other than those that are expressly stated in the License.
*/
#ifndef _MINCORE
#ifndef _LMS_IF_H_
#define _LMS_IF_H_
#include "LMS_if_constants.h"
#pragma pack(1)
typedef struct {
unsigned char MessageType;
} APF_MESSAGE_HEADER;
/**
* APF_GENERIC_HEADER - generic request header (note that its not complete header per protocol (missing WantReply)
*
* @MessageType:
* @RequestStringLength: length of the string identifies the request
* @RequestString: the string that identifies the request
**/
typedef struct {
unsigned char MessageType;
unsigned int StringLength;
unsigned char String[0];
} APF_GENERIC_HEADER;
/**
* TCP forward reply message
* @MessageType - Protocol's Major version
* @PortBound - the TCP port was bound on the server
**/
typedef struct {
unsigned char MessageType;
unsigned int PortBound;
} APF_TCP_FORWARD_REPLY_MESSAGE;
/**
* response to ChannelOpen when channel open succeed
* @MessageType - APF_CHANNEL_OPEN_CONFIRMATION
* @RecipientChannel - channel number given in the open request
* @SenderChannel - channel number assigned by the sender
* @InitialWindowSize - Number of bytes in the window
* @Reserved - Reserved
**/
typedef struct {
unsigned char MessageType;
unsigned int RecipientChannel;
unsigned int SenderChannel;
unsigned int InitialWindowSize;
unsigned int Reserved;
} APF_CHANNEL_OPEN_CONFIRMATION_MESSAGE;
/**
* response to ChannelOpen when a channel open failed
* @MessageType - APF_CHANNEL_OPEN_FAILURE
* @RecipientChannel - channel number given in the open request
* @ReasonCode - code for the reason channel could not be open
* @Reserved - Reserved
**/
typedef struct {
unsigned char MessageType;
unsigned int RecipientChannel;
unsigned int ReasonCode;
unsigned int Reserved;
unsigned int Reserved2;
} APF_CHANNEL_OPEN_FAILURE_MESSAGE;
/**
* close channel message
* @MessageType - APF_CHANNEL_CLOSE
* @RecipientChannel - channel number given in the open request
**/
typedef struct {
unsigned char MessageType;
unsigned int RecipientChannel;
} APF_CHANNEL_CLOSE_MESSAGE;
/**
* used to send/receive data.
* @MessageType - APF_CHANNEL_DATA
* @RecipientChannel - channel number given in the open request
* @Length - Length of the data in the message
* @Data - The data in the message
**/
typedef struct {
unsigned char MessageType;
unsigned int RecipientChannel;
unsigned int DataLength;
// unsigned char Data[0];
} APF_CHANNEL_DATA_MESSAGE;
/**
* used to adjust receive window size.
* @MessageType - APF_WINDOW_ADJUST
* @RecipientChannel - channel number given in the open request
* @BytesToAdd - number of bytes to add to current window size value
**/
typedef struct {
unsigned char MessageType;
unsigned int RecipientChannel;
unsigned int BytesToAdd;
} APF_WINDOW_ADJUST_MESSAGE;
/**
* This message causes immediate termination of the connection with AMT.
* @ReasonCode - A Reason code for the disconnection event
* @Reserved - Reserved must be set to 0
**/
typedef struct {
unsigned char MessageType;
unsigned int ReasonCode;
unsigned short Reserved;
} APF_DISCONNECT_MESSAGE;
/**
* Used to request a service identified by name
* @ServiceNameLength - The length of the service name string.
* @ServiceName - The name of the service being requested.
**/
typedef struct {
unsigned char MessageType;
unsigned int ServiceNameLength;
unsigned char ServiceName[0];
} APF_SERVICE_REQUEST_MESSAGE;
/**
* Used to send a service accept identified by name
* @ServiceNameLength - The length of the service name string.
* @ServiceName - The name of the service being requested.
**/
typedef struct {
unsigned char MessageType;
unsigned int ServiceNameLength;
unsigned char ServiceName[0];
} APF_SERVICE_ACCEPT_MESSAGE;
/**
* holds the protocl major and minor version implemented by AMT.
* @MajorVersion - Protocol's Major version
* @MinorVersion - Protocol's Minor version
* @Trigger - The open session reason
* @UUID - System Id
**/
typedef struct {
unsigned char MessageType;
unsigned int MajorVersion;
unsigned int MinorVersion;
unsigned int TriggerReason;
unsigned char UUID[16];
unsigned char Reserved[64];
} APF_PROTOCOL_VERSION_MESSAGE;
/**
* holds the user authentication request success reponse.
**/
typedef struct {
unsigned char MessageType;
} APF_USERAUTH_SUCCESS_MESSAGE;
#pragma pack()
#endif
#endif

View File

@@ -0,0 +1,92 @@
/* INTEL CONFIDENTIAL
* Copyright 2011 - 2019 Intel Corporation.
* This software and the related documents are Intel copyrighted materials, and your use of them is governed by the express license under which they were provided to you ("License"). Unless the License provides otherwise, you may not use, modify, copy, publish, distribute, disclose or transmit this software or the related documents without Intel's prior written permission.
* This software and the related documents are provided as is, with no express or implied warranties, other than those that are expressly stated in the License.
*/
#ifndef _MINCORE
#ifndef _LMS_IF_CONSTANTS_H_
#define _LMS_IF_CONSTANTS_H_
#define LMS_PROTOCOL_VERSION 4
//
// messages opcodes
//
typedef enum {
APF_DISCONNECT = 1,
APF_SERVICE_REQUEST = 5,
APF_SERVICE_ACCEPT = 6,
APF_USERAUTH_REQUEST = 50,
APF_USERAUTH_FAILURE = 51,
APF_USERAUTH_SUCCESS = 52,
APF_GLOBAL_REQUEST = 80,
APF_REQUEST_SUCCESS = 81,
APF_REQUEST_FAILURE = 82,
APF_CHANNEL_OPEN = 90,
APF_CHANNEL_OPEN_CONFIRMATION = 91,
APF_CHANNEL_OPEN_FAILURE = 92,
APF_CHANNEL_WINDOW_ADJUST = 93,
APF_CHANNEL_DATA = 94,
APF_CHANNEL_CLOSE = 97,
APF_PROTOCOLVERSION = 192
} APF_MESSAGE_TYPE;
typedef enum {
APF_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT = 1,
APF_DISCONNECT_PROTOCOL_ERROR = 2,
APF_DISCONNECT_KEY_EXCHANGE_FAILED = 3,
APF_DISCONNECT_RESERVED = 4,
APF_DISCONNECT_MAC_ERROR = 5,
APF_DISCONNECT_COMPRESSION_ERROR = 6,
APF_DISCONNECT_SERVICE_NOT_AVAILABLE = 7,
APF_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED = 8,
APF_DISCONNECT_HOST_KEY_NOT_VERIFIABLE = 9,
APF_DISCONNECT_CONNECTION_LOST = 10,
APF_DISCONNECT_BY_APPLICATION = 11,
APF_DISCONNECT_TOO_MANY_CONNECTIONS = 12,
APF_DISCONNECT_AUTH_CANCELLED_BY_USER = 13,
APF_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE = 14,
APF_DISCONNECT_ILLEGAL_USER_NAME = 15
} APF_DISCONNECT_REASON_CODE;
//
//strings used in global messages
//
#define APF_GLOBAL_REQUEST_STR_TCP_FORWARD_REQUEST "tcpip-forward"
#define APF_GLOBAL_REQUEST_STR_TCP_FORWARD_CANCEL_REQUEST "cancel-tcpip-forward"
#define APF_GLOBAL_REQUEST_STR_UDP_SEND_TO "udp-send-to@amt.intel.com"
#define APF_OPEN_CHANNEL_REQUEST_FORWARDED "forwarded-tcpip"
#define APF_OPEN_CHANNEL_REQUEST_DIRECT "direct-tcpip"
// APF service names
#define APF_SERVICE_PFWD "pfwd@amt.intel.com"
#define APF_SERVICE_AUTH "auth@amt.intel.com"
// APF Authentication method
#define APF_AUTH_NONE "none"
#define APF_AUTH_PASSWORD "password"
//calculate string length without the NULL terminator
#define APF_STR_SIZE_OF(s) (sizeof(s)-1)
// Trigger reason code
typedef enum {
USER_INITIATED_REQUEST = 1,
ALERT_REQUEST = 2,
HIT_PROVISIONING_REQUEST = 3,
PERIODIC_REQUEST = 4,
LME_REQUEST = 254
} APF_TRIGGER_REASON;
typedef enum {
OPEN_FAILURE_REASON_ADMINISTRATIVELY_PROHIBITED = 1,
OPEN_FAILURE_REASON_CONNECT_FAILED = 2,
OPEN_FAILURE_REASON_UNKNOWN_CHANNEL_TYPE = 3,
OPEN_FAILURE_REASON_RESOURCE_SHORTAGE = 4
} OPEN_FAILURE_REASON;
#endif
#endif

1457
MicroLMS/heci/PTHICommand.c Normal file

File diff suppressed because it is too large Load Diff

815
MicroLMS/heci/PTHICommand.h Normal file
View File

@@ -0,0 +1,815 @@
/* INTEL CONFIDENTIAL
* Copyright 2011 - 2019 Intel Corporation.
* This software and the related documents are Intel copyrighted materials, and your use of them is governed by the express license under which they were provided to you ("License"). Unless the License provides otherwise, you may not use, modify, copy, publish, distribute, disclose or transmit this software or the related documents without Intel's prior written permission.
* This software and the related documents are provided as is, with no express or implied warranties, other than those that are expressly stated in the License.
*/
#ifndef _MINCORE
//----------------------------------------------------------------------------
//
// File: PTHICommand.h
//
// Contents: header file of PTHICommand class
//
//----------------------------------------------------------------------------
#ifndef __PTHI_COMMAND_H__
#define __PTHI_COMMAND_H__
#include "StatusCodeDefinitions.h"
#ifdef WIN32
#include <windows.h>
#include "HECIwin.h"
#endif
#ifdef _POSIX
#include "HECILinux.h"
#endif
#define CERT_HASH_MAX_LENGTH 64
#define CERT_HASH_MAX_NUMBER 23
#define NET_TLS_CERT_PKI_MAX_SERIAL_NUMS 3
#define NET_TLS_CERT_PKI_MAX_SERIAL_NUM_LENGTH 16
#define MPS_HOSTNAME_LENGTH 256
#define CFG_MAX_ACL_USER_LENGTH 33
#define CFG_MAX_ACL_PWD_LENGTH 33
#pragma pack(1)
typedef struct _LOCAL_SYSTEM_ACCOUNT
{
// contain null terminated string
char username[CFG_MAX_ACL_USER_LENGTH];
// contain null terminated string
char password[CFG_MAX_ACL_PWD_LENGTH];
}LOCAL_SYSTEM_ACCOUNT;
#pragma pack()
/*
* Constants
*/
/*
static #define IDER_LOG_ENTRIES = 16;
const UINT8 MAJOR_VERSION = 1;
const UINT8 MINOR_VERSION = 1;
const UINT8 AMT_MAJOR_VERSION = 1;
const UINT8 AMT_MINOR_VERSION = 1;
*/
#define IDER_LOG_ENTRIES 16
#define MAJOR_VERSION 1
#define MINOR_VERSION 1
#define AMT_MAJOR_VERSION 1
#define AMT_MINOR_VERSION 1
typedef enum _CFG_PROVISIONING_MODE
{
CFG_PROVISIONING_MODE_NONE = 0,
CFG_PROVISIONING_MODE_ENTERPRISE,
CFG_PROVISIONING_MODE_SMALL_BUSINESS,
CFG_PROVISIONING_MODE_REMOTE_ASSISTANCE
} CFG_PROVISIONING_MODE;
typedef enum _AMT_PROVISIONING_STATE
{
PROVISIONING_STATE_PRE = 0,
PROVISIONING_STATE_IN = 1,
PROVISIONING_STATE_POST = 2
} AMT_PROVISIONING_STATE;
typedef enum _AMT_EHBC_STATE
{
EHBC_STATE_DISABLED = 0,
EHBC_STATE_ENABLED = 1
} AMT_EHBC_STATE;
typedef enum _AMT_FEATURE_STATE_REQUEST
{
REDIRECTION_SESSION = 0,
SYSTEM_DEFENSE = 1,
WEB_UI = 2
} AMT_FEATURE_STATE_REQUEST;
typedef enum _AMT_LAST_HOST_RESET_REASON
{
RemoteControl = 0,
Other = 1
} AMT_LAST_HOST_RESET_REASON;
typedef enum _AMT_INTERFACE_INDEX
{
WIRED = 0,
WIRELESS = 1
} AMT_INTERFACE_INDEX;
typedef enum _AMT_DHCP_IP_ADDRESS
{
ACTIVE = 1,
PASSIVE = 2
} AMT_DHCP_IP_MODE;
//typedef UINT32 CFG_IPv4_ADDRESS
#define CFG_IPv4_ADDRESS UINT32
/*
static #define BIOS_VERSION_LEN = 65;
static #define VERSIONS_NUMBER = 50;
static #define UNICODE_STRING_LEN = 20;
*/
#define BIOS_VERSION_LEN 65
#define VERSIONS_NUMBER 50
#define UNICODE_STRING_LEN 20
typedef enum _AMT_PROVISIONING_TLS_MODE
{
NOT_READY = 0,
PSK = 1,
PKI = 2
} AMT_PROVISIONING_TLS_MODE;
typedef enum _AMT_RNG_STATUS
{
RNG_STATUS_EXIST = 0,
RNG_STATUS_IN_PROGRESS = 1,
RNG_STATUS_NOT_EXIST = 2
} AMT_RNG_STATUS;
#pragma pack(1)
typedef struct _AMT_UNICODE_STRING
{
UINT16 Length;
UINT8 String[UNICODE_STRING_LEN];
} AMT_UNICODE_STRING;
typedef struct _AMT_VERSION_TYPE
{
AMT_UNICODE_STRING Description;
AMT_UNICODE_STRING Version;
} AMT_VERSION_TYPE;
typedef struct _PTHI_VERSION
{
UINT8 MajorNumber;
UINT8 MinorNumber;
} PTHI_VERSION;
typedef struct _CODE_VERSIONS
{
UINT8 BiosVersion[BIOS_VERSION_LEN];
UINT32 VersionsCount;
AMT_VERSION_TYPE Versions[VERSIONS_NUMBER];
} CODE_VERSIONS;
typedef struct _COMMAND_FMT
{
union
{
UINT32 val;
struct
{
UINT32 Operation : 23;
UINT32 IsResponse : 1;
UINT32 Class : 8;
} fields;
} cmd;
} COMMAND_FMT;
typedef struct _AMT_ANSI_STRING
{
UINT16 Length;
CHAR *Buffer;
} AMT_ANSI_STRING;
typedef struct _PTHI_MESSAGE_HEADER
{
PTHI_VERSION Version;
UINT16 Reserved;
COMMAND_FMT Command;
UINT32 Length;
} PTHI_MESSAGE_HEADER;
typedef struct _PTHI_RESPONSE_MESSAGE_HEADER
{
PTHI_MESSAGE_HEADER Header;
AMT_STATUS Status;
} PTHI_RESPONSE_MESSAGE_HEADER;
typedef struct _CFG_GET_CODE_VERSIONS_RESPONSE
{
PTHI_RESPONSE_MESSAGE_HEADER Header;
CODE_VERSIONS CodeVersions;
} CFG_GET_CODE_VERSIONS_RESPONSE;
typedef struct _CFG_GET_PROVISIONING_MODE_RESPONSE
{
PTHI_RESPONSE_MESSAGE_HEADER Header;
CFG_PROVISIONING_MODE ProvisioningMode;
AMT_BOOLEAN LegacyMode;
} CFG_GET_PROVISIONING_MODE_RESPONSE;
typedef struct _CFG_GET_PROVISIONING_STATE_RESPONSE
{
PTHI_RESPONSE_MESSAGE_HEADER Header;
AMT_PROVISIONING_STATE ProvisioningState;
} CFG_GET_PROVISIONING_STATE_RESPONSE;
typedef struct _CFG_GET_MAC_ADDRESSES_RESPONSE
{
PTHI_RESPONSE_MESSAGE_HEADER Header;
UINT8 DedicatedMac[6];
UINT8 HostMac[6];
} CFG_GET_MAC_ADDRESSES_RESPONSE;
typedef struct _CFG_GET_FEATURES_STATE_REQUEST
{
PTHI_MESSAGE_HEADER Header;
UINT32 RequestID;
} CFG_GET_FEATURES_STATE_REQUEST;
typedef struct _GET_FEATURES_REDIRECTION_SESSION_STATUS
{
AMT_BOOLEAN IderOpen;
AMT_BOOLEAN SolOpen;
AMT_BOOLEAN Reserved;
} GET_FEATURES_REDIRECTION_SESSION_STATUS;
typedef struct _GET_FEATURES_SYSTEM_DEFENSE_STATE_RESPONSE
{
AMT_BOOLEAN SystemDefenseActivated;
} GET_FEATURES_SYSTEM_DEFENSE_STATUS_RESPONSE;
typedef struct _GET_FEATURES_WEB_UI_STATE_RESPONSE
{
AMT_BOOLEAN WebUiEnabled;
} GET_FEATURES_WEB_UI_STATUS_RESPONSE;
typedef union _FEATURES_STATUS_DATA
{
GET_FEATURES_REDIRECTION_SESSION_STATUS rs;
GET_FEATURES_SYSTEM_DEFENSE_STATUS_RESPONSE sd;
GET_FEATURES_WEB_UI_STATUS_RESPONSE webUI;
} FEATURES_STATUS_DATA;
typedef struct _CFG_GET_FEATURES_STATE_RESPONSE
{
PTHI_RESPONSE_MESSAGE_HEADER Header;
UINT32 RequestID;
FEATURES_STATUS_DATA Data;
} CFG_GET_FEATURES_STATE_RESPONSE;
typedef struct _CFG_GET_CURRENT_POWER_POLICY_REQUEST
{
PTHI_MESSAGE_HEADER Header;
} CFG_GET_CURRENT_POWER_POLICY_REQUEST;
typedef struct _CFG_GET_CURRENT_POWER_POLICY_RESPONSE
{
PTHI_RESPONSE_MESSAGE_HEADER Header;
AMT_ANSI_STRING PolicyName;
} CFG_GET_CURRENT_POWER_POLICY_RESPONSE;
typedef struct _CFG_GET_LAST_HOST_RESET_REASON_REQUEST
{
PTHI_MESSAGE_HEADER Header;
} CFG_GET_LAST_HOST_RESET_REASON_REQUEST;
typedef struct _CFG_GET_LAST_HOST_RESET_REASON_RESPONSE
{
PTHI_RESPONSE_MESSAGE_HEADER Header;
UINT32 Reason;
UINT32 RemoteControlTimeStamp;
} CFG_GET_LAST_HOST_RESET_REASON_RESPONSE;
typedef struct _LAN_SETTINGS
{
AMT_BOOLEAN Enabled;
CFG_IPv4_ADDRESS Ipv4Address;
AMT_BOOLEAN DhcpEnabled;
UINT8 DhcpIpMode;
UINT8 LinkStatus;
UINT8 MacAddress[6];
} LAN_SETTINGS;
typedef struct _CFG_GET_LAN_INTERFACE_SETTINGS_REQUEST
{
PTHI_MESSAGE_HEADER Header;
UINT32 InterfaceIndex;
} CFG_GET_LAN_INTERFACE_SETTINGS_REQUEST;
typedef struct _CFG_GET_LAN_INTERFACE_SETTINGS_RESPONSE
{
PTHI_RESPONSE_MESSAGE_HEADER Header;
AMT_BOOLEAN Enabled;
CFG_IPv4_ADDRESS Ipv4Address;
AMT_BOOLEAN DhcpEnabled;
UINT8 DhcpIpMode;
UINT8 LinkStatus;
UINT8 MacAddress[6];
} CFG_GET_LAN_INTERFACE_SETTINGS_RESPONSE;
typedef struct _CFG_GET_SECURITY_PARAMETERS_REQUEST
{
PTHI_MESSAGE_HEADER Header;
} CFG_GET_SECURITY_PARAMETERS_REQUEST;
typedef struct _CFG_GET_SECURITY_PARAMETERS_RESPONSE
{
PTHI_RESPONSE_MESSAGE_HEADER Header;
AMT_BOOLEAN EnterpriseMode;
AMT_BOOLEAN TLSEnabled;
AMT_BOOLEAN HWCryptoEnabled;
AMT_PROVISIONING_STATE ProvisioningState;
AMT_BOOLEAN NetworkInterfaceEnabled;
AMT_BOOLEAN SOLEnabled;
AMT_BOOLEAN IDEREnabled;
AMT_BOOLEAN FWUpdateEnabled;
AMT_BOOLEAN LinkIsUp;
AMT_BOOLEAN Reserved[8];
} CFG_GET_SECURITY_PARAMETERS_RESPONSE;
typedef struct _CFG_GET_DNS_SUFFIX_LIST_REQUEST
{
PTHI_MESSAGE_HEADER Header;
} CFG_GET_DNS_SUFFIX_LIST_REQUEST;
typedef struct _CFG_GET_DNS_SUFFIX_LIST_RESPONSE
{
PTHI_RESPONSE_MESSAGE_HEADER Header;
UINT16 DataLength;
UINT8 Data[0];
} CFG_GET_DNS_SUFFIX_LIST_RESPONSE;
/**
* CFG_SET_ENTERPRISE_ACCESS_REQUEST
*
* Flags Bit 0 - If this bit is set then HostIPAddress is IPv6, otherwise HostIPAddress is IPv4 address.
* Bits 1..7 - Reserved, should be zero.
* HostIPAddress IPv4 / IPv6 address
* EnterpriseAccess 1 if LMS has access to enterprise network, otherwise 0.
*/
typedef struct _CFG_SET_ENTERPRISE_ACCESS_REQUEST
{
PTHI_MESSAGE_HEADER Header;
UINT8 Flags;
UINT8 HostIPAddress[16];
UINT8 EnterpriseAccess;
} CFG_SET_ENTERPRISE_ACCESS_REQUEST;
typedef struct _CFG_SET_ENTERPRISE_ACCESS_RESPONSE
{
PTHI_RESPONSE_MESSAGE_HEADER Header;
} CFG_SET_ENTERPRISE_ACCESS_RESPONSE;
typedef struct _CFG_OPEN_USER_INITIATED_CONNECTION_REQUEST
{
PTHI_MESSAGE_HEADER Header;
} CFG_OPEN_USER_INITIATED_CONNECTION_REQUEST;
typedef struct _CFG_OPEN_USER_INITIATED_CONNECTION_RESPONSE
{
PTHI_RESPONSE_MESSAGE_HEADER Header;
} CFG_OPEN_USER_INITIATED_CONNECTION_RESPONSE;
typedef struct _CFG_CLOSE_USER_INITIATED_CONNECTION_REQUEST
{
PTHI_MESSAGE_HEADER Header;
} CFG_CLOSE_USER_INITIATED_CONNECTION_REQUEST;
typedef struct _CFG_CLOSE_USER_INITIATED_CONNECTION_RESPONSE
{
PTHI_RESPONSE_MESSAGE_HEADER Header;
} CFG_CLOSE_USER_INITIATED_CONNECTION_RESPONSE;
typedef enum
{
AMT_NETWORK_CONNECTION_DIRECT = 0,
AMT_NETWORK_CONNECTION_VPN,
AMT_NETWORK_CONNECTION_OUTSIDE_ENTERPRISE
} AMT_NETWORK_CONNECTION_STATUS;
typedef enum
{
REMOTE_ACCESS_CONNECTION_STATUS_NOT_CONNECTED = 0,
REMOTE_ACCESS_CONNECTION_STATUS_CONNECTING,
REMOTE_ACCESS_CONNECTION_STATUS_CONNECTED
} REMOTE_ACCESS_CONNECTION_STATUS;
typedef enum
{
REMOTE_ACCESS_CONNECTION_TRIGGER_USER_INITIATED = 0,
REMOTE_ACCESS_CONNECTION_TRIGGER_ALERT,
REMOTE_ACCESS_CONNECTION_TRIGGER_PROVISIONING,
REMOTE_ACCESS_CONNECTION_TRIGGER_PERIODIC
} REMOTE_ACCESS_CONNECTION_TRIGGER;
typedef struct _CFG_GET_REMOTE_ACCESS_CONNECTION_STATUS_REQUEST
{
PTHI_MESSAGE_HEADER Header;
} CFG_GET_REMOTE_ACCESS_CONNECTION_STATUS_REQUEST;
typedef struct _CFG_GET_REMOTE_ACCESS_CONNECTION_STATUS_RESPONSE
{
PTHI_RESPONSE_MESSAGE_HEADER Header;
AMT_NETWORK_CONNECTION_STATUS AmtNetworkConnectionStatus;
REMOTE_ACCESS_CONNECTION_STATUS RemoteAccessConnectionStatus;
REMOTE_ACCESS_CONNECTION_TRIGGER RemoteAccessConnectionTrigger;
AMT_ANSI_STRING MpsHostname;
} CFG_GET_REMOTE_ACCESS_CONNECTION_STATUS_RESPONSE;
typedef struct _REMOTE_ACCESS_STATUS
{
AMT_NETWORK_CONNECTION_STATUS AmtNetworkConnectionStatus;
REMOTE_ACCESS_CONNECTION_STATUS RemoteAccessConnectionStatus;
REMOTE_ACCESS_CONNECTION_TRIGGER RemoteAccessConnectionTrigger;
AMT_ANSI_STRING MpsHostname;
} REMOTE_ACCESS_STATUS;
typedef UINT8 AMT_UUID[16];
//const AMT_UUID AMT_UUID_LINK_STATE;
typedef struct _STATE_DATA
{
UINT8 LinkStatus; // (0 - down; 1 - up)
UINT8 HardSKU;
UINT8 CryptoFuse; // (0 - disabled; 1 - enabled)
UINT8 FlashProtaction; // (0 - disabled; 1 - enabled)
UINT8 LastMEResetReason;
} STATE_DATA;
typedef struct _STATE_GET_AMT_STATE_REQUEST
{
PTHI_MESSAGE_HEADER Header;
AMT_UUID StateVariableIdentifier;
} STATE_GET_AMT_STATE_REQUEST;
typedef struct _STATE_GET_AMT_STATE_RESPONSE
{
PTHI_RESPONSE_MESSAGE_HEADER Header;
AMT_UUID StateDataIdentifier;
UINT32 ByteCount;
STATE_DATA StateData;
} STATE_GET_AMT_STATE_RESPONSE;
typedef struct _AMT_HASH_HANDLES
{
UINT32 Length;
UINT32 Handles[CERT_HASH_MAX_NUMBER];
} AMT_HASH_HANDLES;
typedef struct _CERTHASH_ENTRY
{
AMT_BOOLEAN IsDefault;
AMT_BOOLEAN IsActive;
UINT8 CertificateHash[CERT_HASH_MAX_LENGTH];
UINT8 HashAlgorithm;
AMT_ANSI_STRING Name;
} CERTHASH_ENTRY;
typedef enum
{
CERT_HASH_ALGORITHM_MD5 = 0, // 16 bytes
CERT_HASH_ALGORITHM_SHA1, // 20 bytes
CERT_HASH_ALGORITHM_SHA256, // 32 bytes
CERT_HASH_ALGORITHM_SHA512, // 64 bytes
} CERT_HASH_ALGORITHM;
typedef struct
{
UINT16 Year;
UINT16 Month;
UINT16 DayOfWeek;
UINT16 Day;
UINT16 Hour;
UINT16 Minute;
UINT16 Second;
} TIME_DATE;
typedef struct _AMT_PROV_AUDIT_RECORD
{
UINT8 ProvisioningTLSMode;
AMT_BOOLEAN SecureDNS;
AMT_BOOLEAN HostInitiated;
CERT_HASH_ALGORITHM SelectedHashType;
UINT8 SelectedHashData[CERT_HASH_MAX_LENGTH];
UINT8 CaCertificateSerials[NET_TLS_CERT_PKI_MAX_SERIAL_NUMS*NET_TLS_CERT_PKI_MAX_SERIAL_NUM_LENGTH];
AMT_BOOLEAN AdditionalCaSerialNums;
AMT_BOOLEAN IsOemDefault;
AMT_BOOLEAN IsTimeValid;
UINT32 ProvServerIP;
TIME_DATE TlsStartTime;
AMT_ANSI_STRING ProvServerFQDN;
} AMT_PROV_AUDIT_RECORD;
typedef struct _CFG_GENERATE_RNG_SEED_RESPONSE
{
PTHI_RESPONSE_MESSAGE_HEADER Header;
} CFG_GENERATE_RNG_SEED_RESPONSE;
typedef struct _CFG_GET_RNG_SEED_STATUS_RESPONSE
{
PTHI_RESPONSE_MESSAGE_HEADER Header;
AMT_RNG_STATUS RngStatus;
} CFG_GET_RNG_SEED_STATUS_RESPONSE;
typedef struct _CFG_GET_ZERO_TOUCH_ENABLED_RESPONSE
{
PTHI_RESPONSE_MESSAGE_HEADER Header;
AMT_BOOLEAN ZeroTouchEnabled;
} CFG_GET_ZERO_TOUCH_ENABLED_RESPONSE;
typedef struct _CFG_GET_PROVISIONING_TLS_MODE_RESPONSE
{
PTHI_RESPONSE_MESSAGE_HEADER Header;
AMT_PROVISIONING_TLS_MODE ProvisioningTlsMode;
} CFG_GET_PROVISIONING_TLS_MODE_RESPONSE;
typedef struct _CFG_START_CONFIGURATION_RESPONSE
{
PTHI_RESPONSE_MESSAGE_HEADER Header;
} CFG_START_CONFIGURATION_RESPONSE;
typedef struct _CFG_STOP_CONFIGURATION_RESPONSE
{
PTHI_RESPONSE_MESSAGE_HEADER Header;
} CFG_STOP_CONFIGURATION_RESPONSE;
typedef struct _CFG_SET_PROVISIONING_SERVER_OTP_RESPONSE
{
PTHI_RESPONSE_MESSAGE_HEADER Header;
} CFG_SET_PROVISIONING_SERVER_OTP_RESPONSE;
typedef struct _CFG_SET_DNS_SUFFIX_RESPONSE
{
PTHI_RESPONSE_MESSAGE_HEADER Header;
} CFG_SET_DNS_SUFFIX_RESPONSE;
typedef struct _CFG_GET_HASH_HANDLES_RESPONSE
{
PTHI_RESPONSE_MESSAGE_HEADER Header;
AMT_HASH_HANDLES HashHandles;
} CFG_GET_HASH_HANDLES_RESPONSE;
typedef struct _CFG_GET_CERTHASH_ENTRY_REQUEST
{
PTHI_MESSAGE_HEADER Header;
UINT32 HashHandle;
} CFG_GET_CERTHASH_ENTRY_REQUEST;
typedef struct _CFG_GET_CERTHASH_ENTRY_RESPONSE
{
PTHI_RESPONSE_MESSAGE_HEADER Header;
CERTHASH_ENTRY Hash;
} CFG_GET_CERTHASH_ENTRY_RESPONSE;
typedef struct _CFG_GET_PKI_FQDN_SUFFIX_RESPONSE
{
PTHI_RESPONSE_MESSAGE_HEADER Header;
AMT_ANSI_STRING Suffix;
} CFG_GET_PKI_FQDN_SUFFIX_RESPONSE;
typedef struct CFG_SET_HOST_FQDN_REQUEST
{
PTHI_MESSAGE_HEADER Header;
UINT16 FQDNL;
char FQDN[256];
}CFG_SET_HOST_FQDN_REQUEST;
typedef struct _CFG_SET_HOST_FQDN_RESPONSE
{
PTHI_MESSAGE_HEADER Header;
AMT_STATUS Status;
} CFG_SET_HOST_FQDN_RESPONSE;
typedef struct _CFG_GET_LOCAL_SYSTEM_ACCOUNT_RESPONSE
{
PTHI_MESSAGE_HEADER Header;
AMT_STATUS Status;
LOCAL_SYSTEM_ACCOUNT Account;
} CFG_GET_LOCAL_SYSTEM_ACCOUNT_RESPONSE;
typedef struct _CFG_GET_LOCAL_SYSTEM_ACCOUNT_REQUEST
{
PTHI_MESSAGE_HEADER Header;
UINT8 Reserved[40];
} CFG_GET_LOCAL_SYSTEM_ACCOUNT_REQUEST;
typedef struct _CFG_UNPROVISION_RESPONSE
{
PTHI_MESSAGE_HEADER Header;
AMT_STATUS Status;
} CFG_UNPROVISION_RESPONSE;
typedef struct _CFG_UNPROVISION_REQUEST
{
PTHI_MESSAGE_HEADER Header;
UINT32 Mode;
} CFG_UNPROVISION_REQUEST;
typedef struct _CFG_GETEHBPSTATE_REQUEST
{
PTHI_MESSAGE_HEADER Header;
} CFG_GETEHBPSTATE_REQUEST;
typedef struct _CFG_GETEHBPSTATE_RESPONSE
{
PTHI_RESPONSE_MESSAGE_HEADER Header;
AMT_EHBC_STATE EHBCState;
} CFG_GETEHBPSTATE_RESPONSE;
typedef struct _CFG_GET_CONTROL_MODE_REQUEST
{
PTHI_MESSAGE_HEADER Header;
} CFG_GET_CONTROL_MODE_REQUEST;
typedef struct _CFG_GET_CONTROL_MODE_RESPONSE
{
PTHI_RESPONSE_MESSAGE_HEADER Header;
int state;
} CFG_GET_CONTROL_MODE_RESPONSE;
typedef struct _CFG_GET_UUID_REQUEST
{
PTHI_MESSAGE_HEADER Header;
} CFG_GET_UUID_REQUEST;
typedef struct _CFG_GET_UUID_RESPONSE
{
PTHI_RESPONSE_MESSAGE_HEADER Header;
AMT_UUID UUID;
} CFG_GET_UUID_RESPONSE;
#pragma pack()
AMT_STATUS pthi_GetCodeVersions(CODE_VERSIONS *codeVersions);
AMT_STATUS pthi_GetProvisioningMode(CFG_PROVISIONING_MODE *provisioningMode, AMT_BOOLEAN *legacy);
AMT_STATUS pthi_GetProvisioningState(AMT_PROVISIONING_STATE *state);
AMT_STATUS pthi_GetMacAddresses(UINT8 DedicatedMac[6], UINT8 HostMac[6]);
AMT_STATUS pthi_GetFeaturesState(UINT32 requestID, AMT_BOOLEAN (*requestStatus)[2]);
AMT_STATUS pthi_GetLastHostResetReason(UINT32 *Reason, UINT32 *RemoteControlTimeStamp);
AMT_STATUS pthi_GetCurrentPowerPolicy(AMT_ANSI_STRING *policyName);
AMT_STATUS pthi_GetLanInterfaceSettings(UINT32 interfaceSettings, LAN_SETTINGS *lanSettings);
AMT_STATUS pthi_GetHeciVersion(HECI_VERSION *hecVersion);
AMT_STATUS pthi_GetTLSEnabled(AMT_BOOLEAN *tlsEnabled);
//AMT_STATUS pthi_GetDNSSuffixList(std::list<std::string> *dnsSuffixList);
AMT_STATUS pthi_SetEnterpriseAccess(UINT8 Flags, UINT8 HostIPAddress[16], UINT8 EnterpriseAccess);
AMT_STATUS pthi_GetFWResetReason(UINT8 *MEResetReason);
AMT_STATUS pthi_OpenUserInitiatedConnection();
AMT_STATUS pthi_CloseUserInitiatedConnection();
AMT_STATUS pthi_GetRemoteAccessConnectionStatus(REMOTE_ACCESS_STATUS *remoteAccessStatus);
AMT_STATUS pthi_GenerateRngKey();
AMT_STATUS pthi_GetRngSeedStatus(AMT_RNG_STATUS *rngStatus);
AMT_STATUS pthi_GetZeroTouchEnabled(AMT_BOOLEAN *zeroTouchEnabled);
AMT_STATUS pthi_GetProvisioningTlsMode(AMT_PROVISIONING_TLS_MODE *provisioningTlsMode);
AMT_STATUS pthi_StartConfiguration();
AMT_STATUS pthi_StopConfiguration();
AMT_STATUS pthi_SetProvisioningServerOTP(AMT_ANSI_STRING passwordOTP);
AMT_STATUS pthi_SetDnsSuffix(AMT_ANSI_STRING dnsSuffix);
AMT_STATUS pthi_EnumerateHashHandles(AMT_HASH_HANDLES *hashHandles);
AMT_STATUS pthi_GetCertificateHashEntry(UINT32 hashHandle, CERTHASH_ENTRY *hashEntry);
AMT_STATUS pthi_GetDnsSuffix(AMT_ANSI_STRING *dnsSuffix);
AMT_STATUS pthi_SetHostFQDN(char* str);
AMT_STATUS pthi_GetLocalSystemAccount(LOCAL_SYSTEM_ACCOUNT *localAccount);
AMT_STATUS pthi_Unprovision(CFG_PROVISIONING_MODE provisionMode);
AMT_STATUS pthi_GetStateEHBC(AMT_EHBC_STATE *state);
AMT_STATUS pthi_GetControlMode(int *state);
AMT_STATUS pthi_GetUUID(AMT_UUID *uuid);
#define PROVISIONING_MODE_REQUEST 0x04000008
#define PROVISIONING_MODE_RESPONSE 0x04800008
const PTHI_MESSAGE_HEADER GET_PROVISIONING_MODE_HEADER;
#define UNPROVISION_REQUEST 0x04000010
#define UNPROVISION_RESPONSE 0x04800010
const PTHI_MESSAGE_HEADER UNPROVISION_HEADER;
#define PROVISIONING_STATE_REQUEST 0x04000011
#define PROVISIONING_STATE_RESPONSE 0x04800011
const PTHI_MESSAGE_HEADER GET_PROVISIONING_STATE_HEADER;
#define CODE_VERSIONS_REQUEST 0x0400001A
#define CODE_VERSIONS_RESPONSE 0x0480001A
const PTHI_MESSAGE_HEADER GET_CODE_VERSION_HEADER;
#define GET_SECURITY_PARAMETERS_REQUEST 0x0400001B
#define GET_SECURITY_PARAMETERS_RESPONSE 0x0480001B
//const PTHI_MESSAGE_HEADER GET_SECURITY_PARAMETERS_HEADER;
#define GET_MAC_ADDRESSES_REQUEST 0x04000025
#define GET_MAC_ADDRESSES_RESPONSE 0x04800025
const PTHI_MESSAGE_HEADER GET_MAC_ADDRESSES_HEADER;
#define GENERATE_RNG_SEED_REQUEST 0x04000028
#define GENERATE_RNG_SEED_RESPONSE 0x04800028
//const PTHI_MESSAGE_HEADER GENERATE_RNG_SEED_HEADER;
#define SET_PROVISIONING_SERVER_OTP_REQUEST 0x0400002A
#define SET_PROVISIONING_SERVER_OTP_RESPONSE 0x0480002A
#define SET_DNS_SUFFIX_REQUEST 0x0400002F
#define SET_DNS_SUFFIX_RESPONSE 0x0480002F
#define ENUMERATE_HASH_HANDLES_REQUEST 0x0400002C
#define ENUMERATE_HASH_HANDLES_RESPONSE 0x0480002C
//const PTHI_MESSAGE_HEADER ENUMERATE_HASH_HANDLES_HEADER;
#define GET_RNG_SEED_STATUS_REQUEST 0x0400002E
#define GET_RNG_SEED_STATUS_RESPONSE 0x0480002E
//const PTHI_MESSAGE_HEADER GET_RNG_SEED_STATUS_HEADER;
#define GET_DNS_SUFFIX_LIST_REQUEST 0x0400003E
#define GET_DNS_SUFFIX_LIST_RESPONSE 0x0480003E
//const PTHI_MESSAGE_HEADER GET_DNS_SUFFIX_LIST_HEADER;
#define SET_ENTERPRISE_ACCESS_REQUEST 0x0400003F
#define SET_ENTERPRISE_ACCESS_RESPONSE 0x0480003F
//const PTHI_MESSAGE_HEADER SET_ENTERPRISE_ACCESS_HEADER;
#define OPEN_USER_INITIATED_CONNECTION_REQUEST 0x04000044
#define OPEN_USER_INITIATED_CONNECTION_RESPONSE 0x04800044
//const PTHI_MESSAGE_HEADER OPEN_USER_INITIATED_CONNECTION_HEADER;
#define CLOSE_USER_INITIATED_CONNECTION_REQUEST 0x04000045
#define CLOSE_USER_INITIATED_CONNECTION_RESPONSE 0x04800045
//const PTHI_MESSAGE_HEADER CLOSE_USER_INITIATED_CONNECTION_HEADER;
#define GET_REMOTE_ACCESS_CONNECTION_STATUS_REQUEST 0x04000046
#define GET_REMOTE_ACCESS_CONNECTION_STATUS_RESPONSE 0x04800046
//const PTHI_MESSAGE_HEADER GET_REMOTE_ACCESS_CONNECTION_STATUS_HEADER;
#define GET_CURRENT_POWER_POLICY_REQUEST 0x04000047
#define GET_CURRENT_POWER_POLICY_RESPONSE 0x04800047
const PTHI_MESSAGE_HEADER GET_CURRENT_POWER_POLICY_HEADER;
#define GET_LAN_INTERFACE_SETTINGS_REQUEST 0x04000048
#define GET_LAN_INTERFACE_SETTINGS_RESPONSE 0x04800048
//const PTHI_MESSAGE_HEADER GET_LAN_INTERFACE_SETTINGS_HEADER;
#define GET_FEATURES_STATE_REQUEST 0x04000049
#define GET_FEATURES_STATE_RESPONSE 0x04800049
const PTHI_MESSAGE_HEADER GET_FEATURES_STATE_HEADER;
#define GET_LAST_HOST_RESET_REASON_REQUEST 0x0400004A
#define GET_LAST_HOST_RESET_REASON_RESPONSE 0x0480004A
//const PTHI_MESSAGE_HEADER GET_LAST_HOST_RESET_REASON_HEADER;
#define GET_AMT_STATE_REQUEST 0x01000001
#define GET_AMT_STATE_RESPONSE 0x01800001
//const PTHI_MESSAGE_HEADER GET_AMT_STATE_HEADER;
#define GET_ZERO_TOUCH_ENABLED_REQUEST 0x04000030
#define GET_ZERO_TOUCH_ENABLED_RESPONSE 0x04800030
//const PTHI_MESSAGE_HEADER GET_ZERO_TOUCH_ENABLED_HEADER;
#define GET_PROVISIONING_TLS_MODE_REQUEST 0x0400002B
#define GET_PROVISIONING_TLS_MODE_RESPONSE 0x0480002B
//const PTHI_MESSAGE_HEADER GET_PROVISIONING_TLS_MODE_HEADER;
#define START_CONFIGURATION_REQUEST 0x04000029
#define START_CONFIGURATION_RESPONSE 0x04800029
//const PTHI_MESSAGE_HEADER START_CONFIGURATION_HEADER;
#define GET_CERTHASH_ENTRY_REQUEST 0x0400002D
#define GET_CERTHASH_ENTRY_RESPONSE 0x0480002D
//const PTHI_MESSAGE_HEADER GET_CERTHASH_ENTRY_HEADER;
#define GET_PKI_FQDN_SUFFIX_REQUEST 0x04000036
#define GET_PKI_FQDN_SUFFIX_RESPONSE 0x04800036
//
#define SET_HOST_FQDN_REQUEST 0x0400005b
#define SET_HOST_FQDN_RESPONSE 0x0480005b
//const PTHI_MESSAGE_HEADER GET_PKI_FQDN_SUFFIX_HEADER;
#define GET_LOCAL_SYSTEM_ACCOUNT_REQUEST 0x04000067
#define GET_LOCAL_SYSTEM_ACCOUNT_RESPONSE 0x04800067
//const PTHI_MESSAGE_HEADER GET_LOCAL_SYSTEM_ACCOUNT_HEADER;
#define GET_EHBC_STATE_REQUEST 0x4000084
#define GET_EHBC_STATE_RESPONSE 0x4800084
const PTHI_MESSAGE_HEADER GET_EHBC_STATE_HEADER;
#define GET_CONTROL_MODE_REQUEST 0x400006b
#define GET_CONTROL_MODE_RESPONSE 0x480006b
const PTHI_MESSAGE_HEADER GET_CONTROL_MODE_HEADER;
#define STOP_CONFIGURATION_REQUEST 0x400005e
#define STOP_CONFIGURATION_RESPONSE 0x480005e
#define GET_UUID_REQUEST 0x400005c
#define GET_UUID_RESPONSE 0x480005c
#endif
#endif

View File

@@ -0,0 +1,403 @@
/* INTEL CONFIDENTIAL
* Copyright 2011 - 2019 Intel Corporation.
* This software and the related documents are Intel copyrighted materials, and your use of them is governed by the express license under which they were provided to you ("License"). Unless the License provides otherwise, you may not use, modify, copy, publish, distribute, disclose or transmit this software or the related documents without Intel's prior written permission.
* This software and the related documents are provided as is, with no express or implied warranties, other than those that are expressly stated in the License.
*/
#ifndef _MINCORE
//----------------------------------------------------------------------------
//
// File: StatusCodeDefinitions.h
//
// Notes: This file contains the definitions of the status codes
// as defined in the Intel<65> AMT Network Design Guide.
//
//----------------------------------------------------------------------------
#ifndef STATUS_CODE_DEFINITIONS_H
#define STATUS_CODE_DEFINITIONS_H
typedef unsigned int PT_STATUS;
//typedef unsigned int AMT_STATUS;
//Request succeeded
#define PT_STATUS_SUCCESS 0x0
#define AMT_STATUS_SUCCESS 0x0
//An internal error in the Intel<65> AMT device has occurred
#define PT_STATUS_INTERNAL_ERROR 0x1
#define AMT_STATUS_INTERNAL_ERROR 0x1
//Intel<65> AMT device has not progressed far enough in its
//initialization to process the command.
#define PT_STATUS_NOT_READY 0x2
#define AMT_STATUS_NOT_READY 0x2
//Command is not permitted in current operating mode.
#define PT_STATUS_INVALID_PT_MODE 0x3
#define AMT_STATUS_INVALID_PT_MODE 0x3
//Length field of header is invalid.
#define PT_STATUS_INVALID_MESSAGE_LENGTH 0x4
#define AMT_STATUS_INVALID_MESSAGE_LENGTH 0x4
//The requested hardware asset inventory table
//checksum is not available.
#define PT_STATUS_TABLE_FINGERPRINT_NOT_AVAILABLE 0x5
#define AMT_STATUS_TABLE_FINGERPRINT_NOT_AVAILABLE 0x5
//The Integrity Check Value field of the request
//message sent by Intel<65> AMT enabled device is invalid.
#define PT_STATUS_INTEGRITY_CHECK_FAILED 0x6
#define AMT_STATUS_INTEGRITY_CHECK_FAILED 0x6
//The specified ISV version is not supported
#define PT_STATUS_UNSUPPORTED_ISVS_VERSION 0x7
#define AMT_STATUS_UNSUPPORTED_ISVS_VERSION 0x7
//The specified queried application is not registered.
#define PT_STATUS_APPLICATION_NOT_REGISTERED 0x8
#define AMT_STATUS_APPLICATION_NOT_REGISTERED 0x8
//Either an invalid name or a not previously registered
//<2F>Enterprise<73> name was specified
#define PT_STATUS_INVALID_REGISTRATION_DATA 0x9
#define AMT_STATUS_INVALID_REGISTRATION_DATA 0x9
//The application handle provided in the request
//message has never been allocated.
#define PT_STATUS_APPLICATION_DOES_NOT_EXIST 0xA
#define AMT_STATUS_APPLICATION_DOES_NOT_EXIST 0xA
//The requested number of bytes cannot be allocated in ISV storage.
#define PT_STATUS_NOT_ENOUGH_STORAGE 0xB
#define AMT_STATUS_NOT_ENOUGH_STORAGE 0xB
//The specified name is invalid.
#define PT_STATUS_INVALID_NAME 0xC
#define AMT_STATUS_INVALID_NAME 0xC
//The specified block does not exist.
#define PT_STATUS_BLOCK_DOES_NOT_EXIST 0xD
#define AMT_STATUS_BLOCK_DOES_NOT_EXIST 0xD
//The specified byte offset is invalid.
#define PT_STATUS_INVALID_BYTE_OFFSET 0xE
#define AMT_STATUS_INVALID_BYTE_OFFSET 0xE
//The specified byte count is invalid.
#define PT_STATUS_INVALID_BYTE_COUNT 0xF
#define AMT_STATUS_INVALID_BYTE_COUNT 0xF
//The requesting application is not
//permitted to request execution of the specified operation.
#define PT_STATUS_NOT_PERMITTED 0x10
#define AMT_STATUS_NOT_PERMITTED 0x10
//The requesting application is not the owner of the block
//as required for the requested operation.
#define PT_STATUS_NOT_OWNER 0x11
#define AMT_STATUS_NOT_OWNER 0x11
//The specified block is locked by another application.
#define PT_STATUS_BLOCK_LOCKED_BY_OTHER 0x12
#define AMT_STATUS_BLOCK_LOCKED_BY_OTHER 0x12
//The specified block is not locked.
#define PT_STATUS_BLOCK_NOT_LOCKED 0x13
#define AMT_STATUS_BLOCK_NOT_LOCKED 0x13
//The specified group permission bits are invalid.
#define PT_STATUS_INVALID_GROUP_PERMISSIONS 0x14
#define AMT_STATUS_INVALID_GROUP_PERMISSIONS 0x14
//The specified group does not exist.
#define PT_STATUS_GROUP_DOES_NOT_EXIST 0x15
#define AMT_STATUS_GROUP_DOES_NOT_EXIST 0x15
//The specified member count is invalid.
#define PT_STATUS_INVALID_MEMBER_COUNT 0x16
#define AMT_STATUS_INVALID_MEMBER_COUNT 0x16
//The request cannot be satisfied because a maximum
//limit associated with the request has been reached.
#define PT_STATUS_MAX_LIMIT_REACHED 0x17
#define AMT_STATUS_MAX_LIMIT_REACHED 0x17
//specified key algorithm is invalid.
#define PT_STATUS_INVALID_AUTH_TYPE 0x18
#define AMT_STATUS_INVALID_AUTH_TYPE 0x18
//Not Used
#define PT_STATUS_AUTHENTICATION_FAILED 0x19
#define AMT_STATUS_AUTHENTICATION_FAILED 0x19
//The specified DHCP mode is invalid.
#define PT_STATUS_INVALID_DHCP_MODE 0x1A
#define AMT_STATUS_INVALID_DHCP_MODE 0x1A
//The specified IP address is not a valid IP unicast address.
#define PT_STATUS_INVALID_IP_ADDRESS 0x1B
#define AMT_STATUS_INVALID_IP_ADDRESS 0x1B
//The specified domain name is not a valid domain name.
#define PT_STATUS_INVALID_DOMAIN_NAME 0x1C
#define AMT_STATUS_INVALID_DOMAIN_NAME 0x1C
//Not Used
#define PT_STATUS_UNSUPPORTED_VERSION 0x1D
#define AMT_STATUS_UNSUPPORTED_VERSION 0x1D
//The requested operation cannot be performed because a
//prerequisite request message has not been received.
#define PT_STATUS_REQUEST_UNEXPECTED 0x1E
#define AMT_STATUS_REQUEST_UNEXPECTED 0x1E
//Not Used
#define PT_STATUS_INVALID_TABLE_TYPE 0x1F
#define AMT_STATUS_INVALID_TABLE_TYPE 0x1F
//The specified provisioning mode code is undefined.
#define PT_STATUS_INVALID_PROVISIONING_STATE 0x20
#define AMT_STATUS_INVALID_PROVISIONING_STATE 0x20
//Not Used
#define PT_STATUS_UNSUPPORTED_OBJECT 0x21
#define AMT_STATUS_UNSUPPORTED_OBJECT 0x21
//The specified time was not accepted by the Intel<65> AMT device
//since it is earlier than the baseline time set for the device.
#define PT_STATUS_INVALID_TIME 0x22
#define AMT_STATUS_INVALID_TIME 0x22
//StartingIndex is invalid.
#define PT_STATUS_INVALID_INDEX 0x23
#define AMT_STATUS_INVALID_INDEX 0x23
//A parameter is invalid.
#define PT_STATUS_INVALID_PARAMETER 0x24
#define AMT_STATUS_INVALID_PARAMETER 0x24
//An invalid netmask was supplied
//(a valid netmask is an IP address in which all <20>1<EFBFBD>s are before
//the <20>0<EFBFBD> <20> e.g. FFFC0000h is valid, FF0C0000h is invalid).
#define PT_STATUS_INVALID_NETMASK 0x25
#define AMT_STATUS_INVALID_NETMASK 0x25
//The operation failed because the Flash wear-out
//protection mechanism prevented a write to an NVRAM sector.
#define PT_STATUS_FLASH_WRITE_LIMIT_EXCEEDED 0x26
#define AMT_STATUS_FLASH_WRITE_LIMIT_EXCEEDED 0x26
//ME FW did not receive the entire image file.
#define PT_STATUS_INVALID_IMAGE_LENGTH 0x27
#define AMT_STATUS_INVALID_IMAGE_LENGTH 0x27
//ME FW received an image file with an invalid signature.
#define PT_STATUS_INVALID_IMAGE_SIGNATURE 0x28
#define AMT_STATUS_INVALID_IMAGE_SIGNATURE 0x28
//LME can not support the requested version.
#define PT_STATUS_PROPOSE_ANOTHER_VERSION 0x29
#define AMT_STATUS_PROPOSE_ANOTHER_VERSION 0x29
//The PID must be a 64 bit quantity made up of ASCII codes
//of some combination of 8 characters <20>
//capital alphabets (A<>Z), and numbers (0<>9).
#define PT_STATUS_INVALID_PID_FORMAT 0x2A
#define AMT_STATUS_INVALID_PID_FORMAT 0x2A
//The PPS must be a 256 bit quantity made up of ASCII codes
//of some combination of 32 characters <20>
//capital alphabets (A<>Z), and numbers (0<>9).
#define PT_STATUS_INVALID_PPS_FORMAT 0x2B
#define AMT_STATUS_INVALID_PPS_FORMAT 0x2B
//Full BIST test has been blocked
#define PT_STATUS_BIST_COMMAND_BLOCKED 0x2C
#define AMT_STATUS_BIST_COMMAND_BLOCKED 0x2C
//A TCP/IP connection could not be opened on with the selected port.
#define PT_STATUS_CONNECTION_FAILED 0x2D
#define AMT_STATUS_CONNECTION_FAILED 0x2D
//Max number of connection reached.
//LME can not open the requested connection.
#define PT_STATUS_CONNECTION_TOO_MANY 0x2E
#define AMT_STATUS_CONNECTION_TOO_MANY 0x2E
//Random key generation is in progress.
#define PT_STATUS_RNG_GENERATION_IN_PROGRESS 0x2F
#define AMT_STATUS_RNG_GENERATION_IN_PROGRESS 0x2F
//A randomly generated key does not exist.
#define PT_STATUS_RNG_NOT_READY 0x30
#define AMT_STATUS_RNG_NOT_READY 0x30
//Self-generated AMT certificate does not exist.
#define PT_STATUS_CERTIFICATE_NOT_READY 0x31
#define AMT_STATUS_CERTIFICATE_NOT_READY 0x31
//This code establishes a dividing line between
//status codes which are common to host interface and
//network interface and status codes which are used by
//network interface only.
#define PT_STATUS_NETWORK_IF_ERROR_BASE 0x800
#define AMT_STATUS_NETWORK_IF_ERROR_BASE 0x800
//The OEM number specified in the remote control
//command is not supported by the Intel<65> AMT device
#define PT_STATUS_UNSUPPORTED_OEM_NUMBER 0x801
#define AMT_STATUS_UNSUPPORTED_OEM_NUMBER 0x801
//The boot option specified in the remote control command
//is not supported by the Intel<65> AMT device
#define PT_STATUS_UNSUPPORTED_BOOT_OPTION 0x802
#define AMT_STATUS_UNSUPPORTED_BOOT_OPTION 0x802
//The command specified in the remote control command
//is not supported by the Intel<65> AMT device
#define PT_STATUS_INVALID_COMMAND 0x803
#define AMT_STATUS_INVALID_COMMAND 0x803
//The special command specified in the remote control command
//is not supported by the Intel<65> AMT device
#define PT_STATUS_INVALID_SPECIAL_COMMAND 0x804
#define AMT_STATUS_INVALID_SPECIAL_COMMAND 0x804
//The handle specified in the command is invalid
#define PT_STATUS_INVALID_HANDLE 0x805
#define AMT_STATUS_INVALID_HANDLE 0x805
//The password specified in the User ACL is invalid
#define PT_STATUS_INVALID_PASSWORD 0x806
#define AMT_STATUS_INVALID_PASSWORD 0x806
//The realm specified in the User ACL is invalid
#define PT_STATUS_INVALID_REALM 0x807
#define AMT_STATUS_INVALID_REALM 0x807
//The FPACL or EACL entry is used by an active
//registration and cannot be removed or modified.
#define PT_STATUS_STORAGE_ACL_ENTRY_IN_USE 0x808
#define AMT_STATUS_STORAGE_ACL_ENTRY_IN_USE 0x808
//Essential data is missing on CommitChanges command.
#define PT_STATUS_DATA_MISSING 0x809
#define AMT_STATUS_DATA_MISSING 0x809
//The parameter specified is a duplicate of an existing value.
//Returned for a case where duplicate entries are added to FPACL
//(Factory Partner Allocation Control List) or EACL
//(Enterprise Access Control List) lists.
#define PT_STATUS_DUPLICATE 0x80A
#define AMT_STATUS_DUPLICATE 0x80A
//Event Log operation failed due to the current freeze status of the log.
#define PT_STATUS_EVENTLOG_FROZEN 0x80B
#define AMT_STATUS_EVENTLOG_FROZEN 0x80B
//The device is missing private key material.
#define PT_STATUS_PKI_MISSING_KEYS 0x80C
#define AMT_STATUS_PKI_MISSING_KEYS 0x80C
//The device is currently generating a keypair.
//Caller may try repeating this operation at a later time.
#define PT_STATUS_PKI_GENERATING_KEYS 0x80D
#define AMT_STATUS_PKI_GENERATING_KEYS 0x80D
//An invalid Key was entered.
#define PT_STATUS_INVALID_KEY 0x80E
#define AMT_STATUS_INVALID_KEY 0x80E
//An invalid X.509 certificate was entered.
#define PT_STATUS_INVALID_CERT 0x80F
#define AMT_STATUS_INVALID_CERT 0x80F
//Certificate Chain and Private Key do not match.
#define PT_STATUS_CERT_KEY_NOT_MATCH 0x810
#define AMT_STATUS_CERT_KEY_NOT_MATCH 0x810
//The request cannot be satisfied because the maximum
//number of allowed Kerberos domains has been reached.
//(The domain is determined by the first 24 Bytes of the SID.)
#define PT_STATUS_MAX_KERB_DOMAIN_REACHED 0x811
#define AMT_STATUS_MAX_KERB_DOMAIN_REACHED 0x811
// The requested configuration is unsupported
#define PT_STATUS_UNSUPPORTED 0x812
#define AMT_STATUS_UNSUPPORTED 0x812
// A profile with the requested priority already exists
#define PT_STATUS_INVALID_PRIORITY 0x813
#define AMT_STATUS_INVALID_PRIORITY 0x813
// Unable to find specified element
#define PT_STATUS_NOT_FOUND 0x814
#define AMT_STATUS_NOT_FOUND 0x814
// Invalid User credentials
#define PT_STATUS_INVALID_CREDENTIALS 0x815
#define AMT_STATUS_INVALID_CREDENTIALS 0x815
// Passphrase is invalid
#define PT_STATUS_INVALID_PASSPHRASE 0x816
#define AMT_STATUS_INVALID_PASSPHRASE 0x816
// A certificate handle must be chosen before the
// operation can be completed.
#define PT_STATUS_NO_ASSOCIATION 0x818
#define AMT_STATUS_NO_ASSOCIATION 0x818
// The command is defined as Audit Log event and can not be
// logged.
#define PT_STATUS_AUDIT_FAIL 0x81B
#define AMT_STATUS_AUDIT_FAIL 0x81B
// One of the ME components is not ready for unprovisioning.
#define PT_STATUS_BLOCKING_COMPONENT 0x81C
#define AMT_STATUS_BLOCKING_COMPONENT 0x81C
//The application has identified an internal error
#define PTSDK_STATUS_INTERNAL_ERROR 0x1000
//An ISV operation was called while the library is not
//initialized
#define PTSDK_STATUS_NOT_INITIALIZED 0x1001
//The requested library I/F is not supported by the current library
//implementation.
#define PTSDK_STATUS_LIB_VERSION_UNSUPPORTED 0x1002
//One of the parameters is invalid (usually indicates a
//NULL pointer or an invalid session handle is specified)
#define PTSDK_STATUS_INVALID_PARAM 0x1003
//The SDK could not allocate sufficient resources to complete the operation.
#define PTSDK_STATUS_RESOURCES 0x1004
//The Library has identified a HW Internal error.
#define PTSDK_STATUS_HARDWARE_ACCESS_ERROR 0x1005
//The application that sent the request message is not registered.
//Usually indicates the registration timeout has elapsed.
//The caller should reregister with the Intel AMT enabled device.
#define PTSDK_STATUS_REQUESTOR_NOT_REGISTERED 0x1006
//A network error has occurred while processing the call.
#define PTSDK_STATUS_NETWORK_ERROR 0x1007
//Specified container can not hold the requested string
#define PTSDK_STATUS_PARAM_BUFFER_TOO_SHORT 0x1008
//For Windows only.
//ISVS_InitializeCOMinThread was not called by the current thread.
#define PTSDK_STATUS_COM_NOT_INITIALIZED_IN_THREAD 0x1009
//The URL parameter was not optional in current configuration.
#define PTSDK_STATUS_URL_REQUIRED 0x100A
#endif
#endif

57
MicroLMS/heci/mei.h Normal file
View File

@@ -0,0 +1,57 @@
/****************************************************************************
****************************************************************************
***
*** This header was automatically generated from a Linux kernel header
*** of the same name, to make information necessary for userspace to
*** call into the kernel available to libc. It contains only constants,
*** structures, and macros generated from the original header, and thus,
*** contains no copyrightable information.
***
*** To edit the content of this header, modify the corresponding
*** source file (e.g. under external/kernel-headers/original/) then
*** run bionic/libc/kernel/tools/update_all.py
***
*** Any manual change here will be lost the next time this script will
*** be run. You've been warned!
***
****************************************************************************
****************************************************************************/
#ifndef _LINUX_MEI_H
#define _LINUX_MEI_H
// #include <linux/types.h>
// #include <linux/string.h>
typedef struct {
unsigned char b[16];
} uuid_le;
#define IOCTL_MEI_CONNECT_CLIENT _IOWR('H' , 0x01, struct mei_connect_client_data)
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
struct mei_client {
unsigned int max_msg_length;
unsigned char protocol_version;
unsigned char reserved[3];
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
};
struct mei_connect_client_data {
union {
uuid_le in_client_uuid;
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
struct mei_client out_client_properties;
};
};
#define IOCTL_MEI_SETUP_DMA_BUF _IOWR('H' , 0x02, struct mei_client_dma_data)
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define IOCTL_MEI_UNSET_DMA_BUF _IOW('H' , 0x03, struct mei_client_dma_handle)
struct mei_client_dma_data {
union {
unsigned long userptr;
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
};
unsigned int length;
unsigned int handle;
};
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
struct mei_client_dma_handle {
unsigned int handle;
};
#endif
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */