/*******************************************************************************
* 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
*
* - 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.
*******************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cerrno>
#include <fcntl.h>
#include <unistd.h>
#include <stdint.h>
#include <aio.h>
#ifdef __sun
#include <stdio.h>
#include <stdlib.h>
#endif // __sun
#include "HECIUnix.h"
#pragma pack(1)
typedef struct heci_ioctl_data
{
char *data;
#ifndef _LP64
/*
* If lms is compiled in 32-bit, padding is needed to
* talk to the driver which is 64-bit only.
*/
char *pad;
#endif
/* IOCTL commands */
#define IOCTL_HECI_GET_VERSION \
#define IOCTL_HECI_CONNECT_CLIENT \
#define IOCTL_HECI_WD \
#define IAMT_HECI_GET_RECEIVED_MESSAGE_DATA \
#pragma pack(0)
/***************************** public functions *****************************/
_fd(-1),
m_haveHeciVersion(false)
{
}
{
if (_fd != -1) {
}
}
{
if (m_haveHeciVersion) {
return true;
}
return false;
}
{
int result;
bool return_result = true;
m_haveHeciVersion = false;
if (_initialized) {
Deinit();
}
if (_fd == -1 ) {
if (_verbose) {
}
return false;
}
_initialized = true;
if (!version_response.data) {
if (_verbose) {
}
return_result = false;
Deinit();
goto heci_free;
}
if (result) {
if (_verbose) {
}
return_result = false;
Deinit();
goto heci_free;
}
m_haveHeciVersion = true;
if (_verbose) {
}
if (!client_connect.data) {
if (_verbose) {
}
return_result = false;
Deinit();
goto heci_free;
}
if (result) {
if (_verbose) {
}
return_result = false;
Deinit();
goto heci_free;
}
if (_verbose) {
}
if (_verbose) {
}
return_result = false;
Deinit();
goto heci_free;
}
}
}
return return_result;
}
{
if (_fd != -1) {
_fd = -1;
}
_bufSize = 0;
_protocolVersion = 0;
_initialized = false;
}
{
int rv = 0;
int error = 0;
if (_verbose) {
}
if (rv < 0) {
if (_verbose) {
}
Deinit();
} else {
if (_verbose) {
}
}
return rv;
}
{
int rv = 0;
int return_length =0;
int error = 0;
if (_verbose) {
}
if (rv < 0) {
if (_verbose) {
}
goto out;
}
return_length = rv;
if (_verbose) {
}
}
else if (rv == 0) {
if (_verbose) {
}
goto out;
}
else { //rv<0
if (_verbose) {
}
goto out;
}
rv = return_length;
out:
if (rv < 0) {
Deinit();
}
return rv;
}