summaryrefslogtreecommitdiff
path: root/usr/src/cmd
diff options
context:
space:
mode:
authorYuri Pankov <yuri.pankov@nexenta.com>2017-03-29 10:15:09 +0300
committerRichard Lowe <richlowe@richlowe.net>2017-03-30 12:07:44 -0400
commita6ab12d6f9f3977ca030fee8770f9fec7ec48bd2 (patch)
treef1c0830ac81447c31666ed8eb0b9bd1cc55e482d /usr/src/cmd
parent56350fe51602d105c19353b8bf580ddd591726d5 (diff)
downloadillumos-joyent-a6ab12d6f9f3977ca030fee8770f9fec7ec48bd2.tar.gz
4678 lms and heci can probably be EOF'd
Reviewed by: Toomas Soome <tsoome@me.com> Reviewed by: Peter Tribble <peter.tribble@gmail.com> Approved by: Richard Lowe <richlowe@richlowe.net>
Diffstat (limited to 'usr/src/cmd')
-rw-r--r--usr/src/cmd/Makefile1
-rw-r--r--usr/src/cmd/Makefile.check3
-rw-r--r--usr/src/cmd/devfsadm/i386/misc_link_i386.c13
-rw-r--r--usr/src/cmd/lms/Channel.h107
-rw-r--r--usr/src/cmd/lms/ConfigConnection.cpp191
-rw-r--r--usr/src/cmd/lms/ConfigConnection.h80
-rw-r--r--usr/src/cmd/lms/LMEConnection.cpp1049
-rw-r--r--usr/src/cmd/lms/LMEConnection.h412
-rw-r--r--usr/src/cmd/lms/LMEConnectionCompat.cpp335
-rw-r--r--usr/src/cmd/lms/LMS_if.h232
-rw-r--r--usr/src/cmd/lms/LMS_if_compat.h273
-rw-r--r--usr/src/cmd/lms/LMS_if_constants.h114
-rw-r--r--usr/src/cmd/lms/Makefile82
-rw-r--r--usr/src/cmd/lms/PortForwardRequest.h102
-rw-r--r--usr/src/cmd/lms/Protocol.cpp1815
-rw-r--r--usr/src/cmd/lms/Protocol.h191
-rw-r--r--usr/src/cmd/lms/ProtocolCompat.cpp162
-rw-r--r--usr/src/cmd/lms/SyncLib/Include/Event.h63
-rw-r--r--usr/src/cmd/lms/SyncLib/Include/Lock.h97
-rw-r--r--usr/src/cmd/lms/SyncLib/Include/RWLock.h58
-rw-r--r--usr/src/cmd/lms/SyncLib/Include/SPtr.h196
-rw-r--r--usr/src/cmd/lms/SyncLib/Include/Semaphore.h59
-rw-r--r--usr/src/cmd/lms/SyncLib/Include/Thread.h104
-rw-r--r--usr/src/cmd/lms/SyncLib/src/EventUnix.cpp177
-rw-r--r--usr/src/cmd/lms/SyncLib/src/RWLock.cpp95
-rw-r--r--usr/src/cmd/lms/SyncLib/src/SemaphoreUnix.cpp76
-rw-r--r--usr/src/cmd/lms/SyncLib/src/ThreadUnix.cpp191
-rw-r--r--usr/src/cmd/lms/THIRDPARTYLICENSE27
-rw-r--r--usr/src/cmd/lms/THIRDPARTYLICENSE.descrip1
-rw-r--r--usr/src/cmd/lms/glue.cpp349
-rw-r--r--usr/src/cmd/lms/glue.h70
-rw-r--r--usr/src/cmd/lms/heci/FWULCommand.cpp233
-rw-r--r--usr/src/cmd/lms/heci/FWULCommand.h147
-rw-r--r--usr/src/cmd/lms/heci/HECIUnix.cpp295
-rw-r--r--usr/src/cmd/lms/heci/HECIUnix.h57
-rw-r--r--usr/src/cmd/lms/heci/HECI_if.h126
-rw-r--r--usr/src/cmd/lms/heci/MNGCommand.cpp147
-rw-r--r--usr/src/cmd/lms/heci/MNGCommand.h78
-rw-r--r--usr/src/cmd/lms/heci/PTHICommand.cpp1236
-rw-r--r--usr/src/cmd/lms/heci/PTHICommand.h770
-rw-r--r--usr/src/cmd/lms/heci/StatusCodeDefinitions.h421
-rw-r--r--usr/src/cmd/lms/heci/heci.h84
-rw-r--r--usr/src/cmd/lms/iatshareddata.h37
-rw-r--r--usr/src/cmd/lms/lms.xml100
-rw-r--r--usr/src/cmd/lms/main.cpp384
-rw-r--r--usr/src/cmd/lms/plugin.h65
-rw-r--r--usr/src/cmd/lms/svc-lms39
-rw-r--r--usr/src/cmd/lms/tools/ATNetworkTool.cpp735
-rw-r--r--usr/src/cmd/lms/tools/ATNetworkTool.h553
-rw-r--r--usr/src/cmd/lms/tools/ATVersion.cpp204
-rw-r--r--usr/src/cmd/lms/tools/ATVersion.h87
-rw-r--r--usr/src/cmd/lms/tools/daemonize.cpp138
-rw-r--r--usr/src/cmd/lms/tools/daemonize.h40
-rw-r--r--usr/src/cmd/lms/types.h168
-rw-r--r--usr/src/cmd/lms/version.h45
55 files changed, 1 insertions, 12913 deletions
diff --git a/usr/src/cmd/Makefile b/usr/src/cmd/Makefile
index 7b538ec1fb..22a031cbdb 100644
--- a/usr/src/cmd/Makefile
+++ b/usr/src/cmd/Makefile
@@ -482,7 +482,6 @@ i386_SUBDIRS= \
addbadsec \
biosdev \
diskscan \
- lms \
rtc \
ucodeadm \
xvm
diff --git a/usr/src/cmd/Makefile.check b/usr/src/cmd/Makefile.check
index fbe01f3b28..2ad038596b 100644
--- a/usr/src/cmd/Makefile.check
+++ b/usr/src/cmd/Makefile.check
@@ -22,7 +22,7 @@
#
# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright 2014 Garrett D'Amore <garrett@damore.org>
-# Copyright 2016 Nexenta Systems, Inc.
+# Copyright 2017 Nexenta Systems, Inc.
#
include ../Makefile.master
@@ -53,7 +53,6 @@ MANIFEST_TOPDIRS= \
keyserv \
ldapcachemgr \
ldmad \
- lms \
dlmgmtd \
ndmpd \
nscd \
diff --git a/usr/src/cmd/devfsadm/i386/misc_link_i386.c b/usr/src/cmd/devfsadm/i386/misc_link_i386.c
index 84a24b1092..67d06ee101 100644
--- a/usr/src/cmd/devfsadm/i386/misc_link_i386.c
+++ b/usr/src/cmd/devfsadm/i386/misc_link_i386.c
@@ -48,7 +48,6 @@ static int mc_node(di_minor_t minor, di_node_t node);
static int xsvc(di_minor_t minor, di_node_t node);
static int srn(di_minor_t minor, di_node_t node);
static int ucode(di_minor_t minor, di_node_t node);
-static int heci(di_minor_t minor, di_node_t node);
static devfsadm_create_t misc_cbt[] = {
@@ -89,9 +88,6 @@ static devfsadm_create_t misc_cbt[] = {
{ "pseudo", "ddi_pseudo", "ucode",
TYPE_EXACT | DRV_EXACT, ILEVEL_0, ucode,
},
- { "pseudo", "ddi_pseudo", "heci",
- TYPE_EXACT | DRV_EXACT, ILEVEL_0, heci,
- }
};
DEVFSADM_CREATE_INIT_V0(misc_cbt);
@@ -397,12 +393,3 @@ ucode(di_minor_t minor, di_node_t node)
(void) devfsadm_mklink("ucode", node, minor, 0);
return (DEVFSADM_CONTINUE);
}
-
-static int
-heci(di_minor_t minor, di_node_t node)
-{
- if (strcmp(di_minor_name(minor), "AMT") == 0) {
- (void) devfsadm_mklink("heci", node, minor, 0);
- }
- return (DEVFSADM_CONTINUE);
-}
diff --git a/usr/src/cmd/lms/Channel.h b/usr/src/cmd/lms/Channel.h
deleted file mode 100644
index 936db35827..0000000000
--- a/usr/src/cmd/lms/Channel.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * 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 _CHANNEL_H_
-#define _CHANNEL_H_
-
-#include "PortForwardRequest.h"
-
-#ifdef _LINUX
-#ifndef SOCKET
-#define SOCKET int
-#endif
-#endif
-
-class Channel
-{
-public:
- enum CHANNEL_STATUS {
- NOT_OPENED,
- OPEN,
- WAITING_CLOSE,
- CLOSED
- };
-
- static const unsigned int LMS_WINDOW_SIZE = 4095;
-
- Channel(PortForwardRequest *portForwardRequest, SOCKET socket) :
- _recipientChannel(0),
- _senderChannel((unsigned int)socket),
- _socket(socket),
- _txWindow(0),
- _rxWindow(LMS_WINDOW_SIZE),
- _status(NOT_OPENED),
- _portForwardRequest(portForwardRequest) {}
-
- unsigned int GetRecipientChannel() const { return _recipientChannel; }
- unsigned int GetSenderChannel() const { return _senderChannel; }
- bool SetRecipientChannel(unsigned int recipientChannel) { _recipientChannel = recipientChannel; return true; }
- unsigned int GetTxWindow() const { return _txWindow; }
- unsigned int GetRxWindow() const { return _rxWindow; }
-
- bool AddBytesTxWindow(const int bytesToAdd)
- {
- if (_txWindow + bytesToAdd < 0) {
- _txWindow = 0;
- return true;
- }
- _txWindow += bytesToAdd;
- return true;
- }
-
- bool AddBytesRxWindow(const int bytesToAdd)
- {
- if (_rxWindow + bytesToAdd < 0) {
- _rxWindow = 0;
- return true;
- }
- _rxWindow = (_rxWindow + bytesToAdd > LMS_WINDOW_SIZE) ?
- (LMS_WINDOW_SIZE) :
- (_rxWindow + bytesToAdd);
- return true;
- }
-
- SOCKET GetSocket() const { return _socket; }
- CHANNEL_STATUS GetStatus() const { return _status; }
- bool SetStatus(const CHANNEL_STATUS newStatus) { _status = newStatus; return true; }
- PortForwardRequest * GetPortForwardRequest() const { return _portForwardRequest; }
-
-
-private:
- unsigned int _recipientChannel;
- const unsigned int _senderChannel;
- const SOCKET _socket;
- unsigned int _txWindow;
- unsigned int _rxWindow;
- CHANNEL_STATUS _status;
- PortForwardRequest *_portForwardRequest;
-};
-
-#endif
diff --git a/usr/src/cmd/lms/ConfigConnection.cpp b/usr/src/cmd/lms/ConfigConnection.cpp
deleted file mode 100644
index c2ff34a593..0000000000
--- a/usr/src/cmd/lms/ConfigConnection.cpp
+++ /dev/null
@@ -1,191 +0,0 @@
-/*******************************************************************************
- * 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.
- *******************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include "ConfigConnection.h"
-#include "Lock.h"
-
-ConfigConnection::ConfigConnection(bool verbose) :
-_initState(ConfigConnection::INIT_STATE_DISCONNECTED),
-_pthiCommand(verbose, 5000),
-_fwulCommand(verbose)
-{
-}
-
-ConfigConnection::~ConfigConnection()
-{
-}
-
-bool ConfigConnection::IsInitialized()
-{
- Lock il(_initLock);
- return ((_initState == INIT_STATE_CONNECTED) ? true : false);
-}
-
-int ConfigConnection::IsAMTEnabled(bool useOpenPTHI)
-{
- FWU_GET_VERSION_MSG_REPLY verMsg;
- FWU_GET_INFO_MSG_REPLY infoMsg;
- HECI_STATUS heciRet;
- int ret = _CFCON_AMT_UNKNOWN;
-
- if (useOpenPTHI) {
- CODE_VERSIONS ver;
- AMT_STATUS ast = _pthiCommand.GetCodeVersions(ver);
- if (PTHI_STATUS_EMPTY_RESPONSE == ast) {
- return _CFCON_AMT_DISABLED;
- }
- if (AMT_STATUS_SUCCESS == ast) {
- return _CFCON_AMT_ENABLED;
- }
- return ret;
- }
-
- if (_fwulCommand.FWULClient.Init()) {
- heciRet = _fwulCommand.GetFWUVersionAndInfo(verMsg, infoMsg);
- _fwulCommand.FWULClient.Deinit();
- if (HECI_STATUS_OK == heciRet) {
- if (infoMsg.MessageType == FWU_GET_INFO_REPLY) {
- return ((MEFWCAPS_MANAGEABILITY_SUPP_AMT
- == infoMsg.ManageabilityMode)
- ? _CFCON_AMT_ENABLED
- : _CFCON_AMT_DISABLED);
- }
- ret = _CFCON_AMT_AT3;
- }
- }
-
- return ret;
-}
-
-bool ConfigConnection::Init(bool checkEnabled)
-{
- {
- Lock il(_initLock);
- if (_initState == INIT_STATE_CONNECTING) {
- return false;
- }
- _initState = INIT_STATE_CONNECTING;
- }
-
- if (!(_pthiCommand.PTHIClient.Init(1))) {
- Deinit();
- return false;
- }
-
- if (checkEnabled) {
- if (_CFCON_AMT_ENABLED != IsAMTEnabled(true)) {
- Deinit();
- return false;
- }
- }
-
- {
- Lock il(_initLock);
- if (_initState != INIT_STATE_CONNECTING) {
- _pthiCommand.PTHIClient.Deinit();
- return false;
- }
- _initState = INIT_STATE_CONNECTED;
- }
-
- return true;
-}
-
-void ConfigConnection::Deinit()
-{
- Lock il(_initLock);
- if (_initState != INIT_STATE_CONNECTING) {
- _pthiCommand.PTHIClient.Deinit();
- }
- _initState = INIT_STATE_DISCONNECTED;
-}
-
-#ifdef _REMOTE_SUPPORT
-
-AMT_STATUS ConfigConnection::RequestEntDNSSuffixList(std::list<std::string> &dnsSuffixList)
-{
- Lock l(_requestLock);
-
- {
- Lock il(_initLock);
- if (_initState != INIT_STATE_CONNECTED) {
- return PTSDK_STATUS_INTERNAL_ERROR;
- }
- }
-
- AMT_STATUS result = _pthiCommand.GetDNSSuffixList(dnsSuffixList);
-
- if (result == AMT_STATUS_INTERNAL_ERROR) {
- Lock il(_initLock);
- if (!_pthiCommand.PTHIClient.IsInitialized()) {
- _initState = INIT_STATE_DISCONNECTED;
- }
- }
-
- return result;
-}
-
-AMT_STATUS ConfigConnection::SendEnterpriseAccess(bool access, ATAddress &localIp)
-{
- UINT8 hlocalIP[16];
- const struct sockaddr *addr = localIp.addr();
-
- Lock l(_requestLock);
-
- {
- Lock il(_initLock);
- if (_initState != INIT_STATE_CONNECTED) {
- return PTSDK_STATUS_INTERNAL_ERROR;
- }
- }
-
- memset(hlocalIP, 0, sizeof(hlocalIP));
- memcpy(hlocalIP, addr->sa_data, localIp.size());
-
- AMT_STATUS result = _pthiCommand.SetEnterpriseAccess(
- ((localIp.family() == AF_INET6) ? 1 : 0),
- hlocalIP,
- ((access) ? 1 : 0));
-
- if (result == AMT_STATUS_INTERNAL_ERROR) {
- Lock il(_initLock);
- if (!_pthiCommand.PTHIClient.IsInitialized()) {
- _initState = INIT_STATE_DISCONNECTED;
- }
- }
-
- return result;
-}
-
-#endif
-
diff --git a/usr/src/cmd/lms/ConfigConnection.h b/usr/src/cmd/lms/ConfigConnection.h
deleted file mode 100644
index a6c31686ab..0000000000
--- a/usr/src/cmd/lms/ConfigConnection.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * 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 __CONFIG_CONNECTION_H__
-#define __CONFIG_CONNECTION_H__
-
-#include <list>
-#include <string>
-#include "Semaphore.h"
-#include "PTHICommand.h"
-#include "FWULCommand.h"
-#ifdef _REMOTE_SUPPORT
-#include "ATNetworkTool.h"
-#endif
-
-#define _CFCON_AMT_DISABLED 0
-#define _CFCON_AMT_ENABLED 1
-#define _CFCON_AMT_UNKNOWN 2
-#define _CFCON_AMT_AT3 3
-
-class ConfigConnection
-{
-public:
- ConfigConnection(bool verbose = false);
- ~ConfigConnection();
-
- bool Init(bool checkEnabled = true);
- bool IsInitialized();
- void Deinit();
- int IsAMTEnabled(bool useOpenPTHI = false);
-
-#ifdef _REMOTE_SUPPORT
- AMT_STATUS RequestEntDNSSuffixList(std::list<std::string> &dnsSuffixList);
- AMT_STATUS SendEnterpriseAccess(bool access, ATAddress &localIp);
-#endif
-
- enum INIT_STATES {
- INIT_STATE_DISCONNECTED = 0,
- INIT_STATE_CONNECTING,
- INIT_STATE_CONNECTED
- };
-
-private:
- Semaphore _initLock;
- Semaphore _requestLock;
- INIT_STATES _initState;
-
- PTHICommand _pthiCommand;
- FWULCommand _fwulCommand;
-};
-
-#endif
-
diff --git a/usr/src/cmd/lms/LMEConnection.cpp b/usr/src/cmd/lms/LMEConnection.cpp
deleted file mode 100644
index e0a669de8e..0000000000
--- a/usr/src/cmd/lms/LMEConnection.cpp
+++ /dev/null
@@ -1,1049 +0,0 @@
-/*******************************************************************************
- * 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.
- *******************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include <cerrno>
-#include "types.h"
-#include "LMEConnection.h"
-#include "LMS_if.h"
-#include "Lock.h"
-#include "glue.h"
-
-#if defined(__sun) || defined(_LINUX)
-#include <netinet/in.h>
-#define _strnicmp strncasecmp
-#endif // __sun || _LINUX
-
-#define HECI_IO_TIMEOUT 5000
-
-extern glue plugin;
-
-const GUID LMEConnection::_guid = {0x6733a4db, 0x0476, 0x4e7b, {0xb3, 0xaf, 0xbc, 0xfc, 0x29, 0xbe, 0xe7, 0xa7}};
-
-const UINT32 LMEConnection::RX_WINDOW_SIZE = 1024;
-
-LMEConnection::LMEConnection(bool verbose) :
-_reqID(0),
-_txBuffer(NULL),
-_rxThread(NULL),
-_cb(NULL),
-_cbParam(NULL),
-_initState(INIT_STATE_DISCONNECTED),
-_heci(_guid, verbose),
-_heciCompat(_guidCompat, verbose),
-_pHeci(NULL)
-{
-}
-
-LMEConnection::~LMEConnection()
-{
-}
-
-bool LMEConnection::IsInitialized()
-{
- Lock il(_initLock);
- return ((_initState == INIT_STATE_CONNECTED) ? true : false);
-}
-
-bool LMEConnection::Init(HECICallback cb, void *param)
-{
- Lock il(_initLock);
-
- if (_initState == INIT_STATE_CONNECTING) {
- return false;
- }
- _initState = INIT_STATE_CONNECTING;
-
- _cb = cb;
- _cbParam = param;
-
- if (_heci.Init(LMS_PROCOL_VERSION)) {
- protocolVer = _heci.GetProtocolVersion();
- _pHeci = &_heci;
- } else if (_heciCompat.Init()) {
- protocolVer = _heciCompat.GetProtocolVersion();
- if (protocolVer > LMS_PROCOL_VERSION_COMPAT) {
- _heciCompat.Deinit();
- _initState = INIT_STATE_DISCONNECTED;
- return false;
- }
- _pHeci = &_heciCompat;
- } else {
- _initState = INIT_STATE_DISCONNECTED;
- return false;
- }
-
- _initState = INIT_STATE_CONNECTED;
-
- plugin.version(protocolVer);
-
- // launch RX thread
- _txBuffer = new unsigned char[_pHeci->GetBufferSize()];
- _rxThread = new Thread(_rxThreadFunc, this);
- _rxThread->start();
-
- _threadStartedEvent.wait();
- return true;
-}
-
-void LMEConnection::Deinit()
-{
- Lock il(_initLock);
-
- _initState = INIT_STATE_DISCONNECTED;
-
- if (_pHeci != NULL) {
- _pHeci->Deinit();
- _pHeci = NULL;
- }
-
- if (_rxThread != NULL) {
- delete _rxThread;
- _rxThread = NULL;
- }
-
- if (_txBuffer != NULL) {
- delete[] _txBuffer;
- _txBuffer = NULL;
- }
-}
-
-bool LMEConnection::Disconnect(APF_DISCONNECT_REASON_CODE reasonCode)
-{
- if (!IsInitialized()) {
- PRINT("State: not connected to HECI.\n");
- return false;
- }
-
- 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);
-
- PRINT("Sending disconnect to LME.\n");
- int res = _sendMessage(buf, sizeof(buf));
-
- return (res == sizeof(buf));
-}
-
-bool LMEConnection::ServiceAccept(std::string serviceName)
-{
- if (!IsInitialized()) {
- PRINT("State: not connected to HECI.\n");
- return false;
- }
-
- //APF_SERVICE_ACCEPT_MESSAGE
- //memcpy(pCurrent, "127.0.0.1", APF_STR_SIZE_OF("127.0.0.1"));
- //pCurrent += APF_STR_SIZE_OF("127.0.0.1");
- unsigned char *buf = new unsigned char[sizeof(APF_SERVICE_ACCEPT_MESSAGE) + serviceName.length()];
- if (buf == NULL) {
- PRINT("Failed to allocate memory for ServiceAccept.\n");
- return false;
- }
-
- unsigned char *pCurrent = buf;
- *pCurrent = APF_SERVICE_ACCEPT;
- ++pCurrent;
- *((UINT32 *)pCurrent) = htonl(serviceName.size());
- pCurrent += 4;
-
- memcpy(pCurrent, serviceName.c_str(), serviceName.size());
- pCurrent += serviceName.size();
-
- PRINT("Sending service accept to LME: %s\n", serviceName.c_str());
- int len = pCurrent - buf;
- int res = _sendMessage(buf, len);
-
- delete [] buf;
-
- return (res == len);
-}
-
-bool LMEConnection::UserAuthSuccess()
-{
- if (!IsInitialized()) {
- PRINT("State: not connected to HECI.\n");
- return false;
- }
-
- unsigned char buf = APF_USERAUTH_SUCCESS;
-
- PRINT("Sending user authentication success to LME.\n");
- int res = _sendMessage(&buf, sizeof(buf));
-
- return (res == sizeof(buf));
-}
-
-bool LMEConnection::ProtocolVersion(const LMEProtocolVersionMessage versionMessage)
-{
- if (!IsInitialized()) {
- PRINT("State: not connected to HECI.\n");
- return false;
- }
-
- APF_PROTOCOL_VERSION_MESSAGE protVersion;
- memset(&protVersion, 0, sizeof(protVersion));
-
- protVersion.MessageType = APF_PROTOCOLVERSION;
- protVersion.MajorVersion = htonl(versionMessage.MajorVersion);
- protVersion.MinorVersion = htonl(versionMessage.MinorVersion);
- protVersion.TriggerReason = htonl(versionMessage.TriggerReason);
-
- PRINT("Sending protocol version to LME: %d.%d\n", versionMessage.MajorVersion, versionMessage.MinorVersion);
- int res = _sendMessage((unsigned char *)&protVersion, sizeof(protVersion));
-
- return (res == sizeof(protVersion));
-}
-
-bool LMEConnection::TcpForwardReplySuccess(UINT32 port)
-{
- if (!IsInitialized()) {
- PRINT("State: not connected to HECI.\n");
- return false;
- }
-
- APF_TCP_FORWARD_REPLY_MESSAGE message;
-
- message.MessageType = APF_REQUEST_SUCCESS;
- message.PortBound = htonl(port);
-
- PRINT("Sending TCP forward replay success to LME: Port %d.\n", port);
- int res = _sendMessage((unsigned char *)&message, sizeof(message));
-
- return (res == sizeof(message));
-}
-
-bool LMEConnection::TcpForwardReplyFailure()
-{
- if (!IsInitialized()) {
- PRINT("State: not connected to HECI.\n");
- return false;
- }
-
- unsigned char buf = APF_REQUEST_FAILURE;
-
- PRINT("Sending TCP forward replay failure to LME.\n");
- int res = _sendMessage(&buf, sizeof(buf));
-
- return (res == sizeof(buf));
-}
-
-bool LMEConnection::TcpForwardCancelReplySuccess()
-{
- if (!IsInitialized()) {
- PRINT("State: not connected to HECI.\n");
- return false;
- }
-
- unsigned char buf = APF_REQUEST_SUCCESS;
-
- PRINT("Sending TCP forward cancel replay success to LME.\n");
- int res = _sendMessage(&buf, sizeof(buf));
-
- return (res == sizeof(buf));
-}
-
-bool LMEConnection::TcpForwardCancelReplyFailure()
-{
- if (!IsInitialized()) {
- PRINT("State: not connected to HECI.\n");
- return false;
- }
-
- unsigned char buf = APF_REQUEST_FAILURE;
-
- PRINT("Sending TCP forward cancel replay failure to LME.\n");
- int res = _sendMessage(&buf, sizeof(buf));
-
- return (res == sizeof(buf));
-}
-
-bool LMEConnection::ChannelOpenForwardedRequest(UINT32 senderChannel,
- UINT32 connectedPort,
- std::string originatorIP,
- UINT32 originatorPort)
-{
- if (!IsInitialized()) {
- PRINT("State: not connected to HECI.\n");
- return false;
- }
-
- unsigned char buf[5 + APF_STR_SIZE_OF(APF_OPEN_CHANNEL_REQUEST_FORWARDED) + 16 +
- APF_STR_SIZE_OF("127.0.0.1") + 8 + 16 + 4];
- unsigned char *pCurrent = buf;
-
- if (originatorIP.size() > 16) {
- return false;
- }
-
- *pCurrent = APF_CHANNEL_OPEN;
- ++pCurrent;
-
- *((UINT32 *)pCurrent) = htonl(APF_STR_SIZE_OF(APF_OPEN_CHANNEL_REQUEST_FORWARDED));
- pCurrent += sizeof(UINT32);
-
- memcpy(pCurrent, APF_OPEN_CHANNEL_REQUEST_FORWARDED, APF_STR_SIZE_OF(APF_OPEN_CHANNEL_REQUEST_FORWARDED));
- pCurrent += APF_STR_SIZE_OF(APF_OPEN_CHANNEL_REQUEST_FORWARDED);
-
- *((UINT32 *)pCurrent) = htonl(senderChannel);
- pCurrent += sizeof(UINT32);
-
- *((UINT32 *)pCurrent) = htonl(RX_WINDOW_SIZE);
- pCurrent += sizeof(UINT32);
-
- *((UINT32 *)pCurrent) = 0xFFFFFFFF;
- pCurrent += sizeof(UINT32);
-
- *((UINT32 *)pCurrent) = htonl(APF_STR_SIZE_OF("127.0.0.1"));
- pCurrent += sizeof(UINT32);
-
- memcpy(pCurrent, "127.0.0.1", APF_STR_SIZE_OF("127.0.0.1"));
- pCurrent += APF_STR_SIZE_OF("127.0.0.1");
-
- *((UINT32 *)pCurrent) = htonl(connectedPort);
- pCurrent += sizeof(UINT32);
-
- *((UINT32 *)pCurrent) = htonl((UINT32)originatorIP.size());
- pCurrent += sizeof(UINT32);
-
- memcpy(pCurrent, originatorIP.c_str(), originatorIP.size());
- pCurrent += originatorIP.size();
-
- *((UINT32 *)pCurrent) = htonl(originatorPort);
- pCurrent += sizeof(UINT32);
-
- PRINT("Sending channel open request to LME. Address: %s, requested port: %d.\n",
- originatorIP.c_str(), connectedPort);
- int res = _sendMessage(buf, (int)(pCurrent - buf));
-
- return (res == pCurrent - buf);
-}
-
-bool LMEConnection::ChannelOpenReplaySuccess(UINT32 recipientChannel,
- UINT32 senderChannel)
-{
- if (!IsInitialized()) {
- PRINT("State: not connected to HECI.\n");
- return false;
- }
-
- APF_CHANNEL_OPEN_CONFIRMATION_MESSAGE message;
-
- message.MessageType = APF_CHANNEL_OPEN_CONFIRMATION;
- message.RecipientChannel = htonl(recipientChannel);
- message.SenderChannel = htonl(senderChannel);
- message.InitialWindowSize = htonl(RX_WINDOW_SIZE);
- message.Reserved = 0xFFFFFFFF;
-
- PRINT("Sending channel open replay success to LME. Recipient: %d.\n", recipientChannel);
- int res = _sendMessage((unsigned char *)&message, sizeof(message));
-
- return (res == sizeof(message));
-}
-
-bool LMEConnection::ChannelOpenReplayFailure(UINT32 recipientChannel,
- UINT32 reason)
-{
- if (!IsInitialized()) {
- PRINT("State: not connected to HECI.\n");
- return false;
- }
-
- 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;
-
- PRINT("Sending channel open replay failure to LME. Recipient: %d, Reason: %d.\n", recipientChannel, reason);
- int res = _sendMessage((unsigned char *)&message, sizeof(message));
-
- return (res == sizeof(message));
-}
-
-bool LMEConnection::ChannelClose(UINT32 recipientChannel)
-{
- if (!IsInitialized()) {
- PRINT("State: not connected to HECI.\n");
- return false;
- }
-
- APF_CHANNEL_CLOSE_MESSAGE message;
-
- message.MessageType = APF_CHANNEL_CLOSE;
- message.RecipientChannel = htonl(recipientChannel);
-
- PRINT("Sending channel close to LME. Recipient: %d.\n", recipientChannel);
- int res = _sendMessage((unsigned char *)&message, sizeof(message));
-
- return (res == sizeof(message));
-}
-
-int LMEConnection::ChannelData(UINT32 recipientChannel,
- UINT32 len, unsigned char *buffer)
-{
- if (!IsInitialized()) {
- PRINT("State: not connected to HECI.\n");
- return false;
- }
-
- APF_CHANNEL_DATA_MESSAGE *message;
-
- if (len > _heci.GetBufferSize() - sizeof(APF_CHANNEL_DATA_MESSAGE)) {
- return -1;
- }
-
- message = (APF_CHANNEL_DATA_MESSAGE *)_txBuffer;
- message->MessageType = APF_CHANNEL_DATA;
- message->RecipientChannel = htonl(recipientChannel);
- message->DataLength = htonl(len);
- memcpy(message->Data, buffer, len);
-
- PRINT("Sending %d bytes to recipient channel %d.\n", len, recipientChannel);
- return _sendMessage((unsigned char *)message, sizeof(APF_CHANNEL_DATA_MESSAGE) + len);
-}
-
-bool LMEConnection::ChannelWindowAdjust(UINT32 recipientChannel, UINT32 len)
-{
- if (!IsInitialized()) {
- PRINT("State: not connected to HECI.\n");
- return false;
- }
-
- APF_WINDOW_ADJUST_MESSAGE message;
-
- message.MessageType = APF_CHANNEL_WINDOW_ADJUST;
- message.RecipientChannel = htonl(recipientChannel);
- message.BytesToAdd = htonl(len);
-
- PRINT("Sending Window Adjust with %d bytes to recipient channel %d.\n", len, recipientChannel);
- int res = _sendMessage((unsigned char *)&message, sizeof(message));
-
- return (res == sizeof(message));
-}
-
-int LMEConnection::_receiveMessage(unsigned char *buffer, int len)
-{
- int result;
-
- if (!IsInitialized()) {
- return -1;
- }
-
- result = _pHeci->ReceiveMessage(buffer, len, WAIT_INFINITE);
-
- if (result < 0 && errno == ENOENT) {
- Lock il(_initLock);
- _initState = INIT_STATE_DISCONNECTED;
- }
-
- return result;
-}
-
-int LMEConnection::_sendMessage(unsigned char *buffer, int len)
-{
- int result;
-
- if (!IsInitialized()) {
- return -1;
- }
-
- _sendMessageLock.acquire();
- result = _pHeci->SendMessage(buffer, len, HECI_IO_TIMEOUT);
- _sendMessageLock.release();
-
- if (result < 0 && errno == ENOENT) {
- Lock il(_initLock);
- _initState = INIT_STATE_DISCONNECTED;
- }
-
- return result;
-}
-
-void LMEConnection::_rxThreadFunc(void *param)
-{
- LMEConnection *connection = (LMEConnection *)param;
-
- try {
- if (LMS_PROCOL_VERSION == connection->protocolVer) {
- connection->_doRX();
- } else if (LMS_PROCOL_VERSION_COMPAT == connection->protocolVer) {
- connection->_doRXCompat();
- }
- }
- catch (...) {
- PRINT("LMEConnection do RX exception\n");
- }
- pthread_exit(NULL);
-}
-
-bool LMEConnection::_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)) {
- return false;
- }
- if (bytesRead < (sizeof(APF_SERVICE_REQUEST) +
- ntohl(((APF_SERVICE_REQUEST_MESSAGE *)buf)->ServiceNameLength))) {
- return false;
- }
- break;
- case APF_USERAUTH_REQUEST:
- if (bytesRead < (3 * sizeof(UINT32))) {
- 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 LMEConnection::_doRX()
-{
- unsigned int bytesRead;
- int status = 1;
-
- _threadStartedEvent.set();
-
- unsigned char *rxBuffer = new unsigned char[_heci.GetBufferSize()];
-
- while (true) {
- bytesRead = (unsigned int)_receiveMessage(rxBuffer, _heci.GetBufferSize());
-
- if ((int)bytesRead < 0) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- break;
- }
-
- if (bytesRead == 0) {
- // ERROR
- continue;
- }
-
- PRINT("Received from LME %d bytes (msg type %02d)\n", bytesRead, rxBuffer[0]);
-
- if (!_checkMinMsgSize(rxBuffer, bytesRead)) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- break;
- }
-
- if (plugin.preprocess(rxBuffer, bytesRead) == LMS_DROPPED) {
- continue;
- }
-
- switch (rxBuffer[0]) {
- case APF_DISCONNECT:
- {
- LMEDisconnectMessage disconnectMessage(
- (APF_DISCONNECT_REASON_CODE)ntohl(
- ((APF_DISCONNECT_MESSAGE *)rxBuffer)->ReasonCode));
-
- _cb(_cbParam, &disconnectMessage, sizeof(disconnectMessage), &status);
- }
- break;
-
- case APF_SERVICE_REQUEST:
- {
- APF_SERVICE_REQUEST_MESSAGE *pMessage =
- (APF_SERVICE_REQUEST_MESSAGE *)rxBuffer;
- LMEServiceRequestMessage serviceRequestMessage;
-
- serviceRequestMessage.ServiceName.append(
- (char *)(pMessage->ServiceName),
- ntohl(pMessage->ServiceNameLength));
-
- _cb(_cbParam, &serviceRequestMessage, sizeof(serviceRequestMessage), &status);
- }
- break;
-
- case APF_USERAUTH_REQUEST:
- _apfUserAuthRequest(rxBuffer, bytesRead, &status);
- break;
-
- case APF_GLOBAL_REQUEST:
- _apfGlobalRequest(rxBuffer, bytesRead, &status);
- break;
-
- case APF_CHANNEL_OPEN:
- _apfChannelOpen(rxBuffer, bytesRead, &status);
- break;
-
- case APF_CHANNEL_OPEN_CONFIRMATION:
- {
- APF_CHANNEL_OPEN_CONFIRMATION_MESSAGE *pMessage =
- (APF_CHANNEL_OPEN_CONFIRMATION_MESSAGE *)rxBuffer;
- LMEChannelOpenReplaySuccessMessage channelOpenReply;
-
- channelOpenReply.RecipientChannel = ntohl(pMessage->RecipientChannel);
- channelOpenReply.SenderChannel = ntohl(pMessage->SenderChannel);
- channelOpenReply.InitialWindow = ntohl(pMessage->InitialWindowSize);
- _cb(_cbParam, &channelOpenReply, sizeof(channelOpenReply), &status);
- }
- break;
-
- case APF_CHANNEL_OPEN_FAILURE:
- {
- APF_CHANNEL_OPEN_FAILURE_MESSAGE *pMessage =
- (APF_CHANNEL_OPEN_FAILURE_MESSAGE *)rxBuffer;
- LMEChannelOpenReplayFailureMessage channelOpenReply;
-
- channelOpenReply.RecipientChannel = ntohl(pMessage->RecipientChannel);
- channelOpenReply.ReasonCode =
- (OPEN_FAILURE_REASON)(ntohl(pMessage->ReasonCode));
- _cb(_cbParam, &channelOpenReply, sizeof(channelOpenReply), &status);
- }
- break;
-
- case APF_CHANNEL_CLOSE:
- {
- APF_CHANNEL_CLOSE_MESSAGE *pMessage =
- (APF_CHANNEL_CLOSE_MESSAGE *)rxBuffer;
- LMEChannelCloseMessage channelClose;
-
- channelClose.RecipientChannel = ntohl(pMessage->RecipientChannel);
- _cb(_cbParam, &channelClose, sizeof(channelClose), &status);
- }
- break;
-
- case APF_CHANNEL_DATA:
- {
- APF_CHANNEL_DATA_MESSAGE *pMessage =
- (APF_CHANNEL_DATA_MESSAGE *)rxBuffer;
- LMEChannelDataMessage channelData(ntohl(pMessage->RecipientChannel),
- ntohl(pMessage->DataLength),
- pMessage->Data);
- _cb(_cbParam, &channelData, sizeof(channelData), &status);
- }
- break;
-
- case APF_CHANNEL_WINDOW_ADJUST:
- {
- APF_WINDOW_ADJUST_MESSAGE *pMessage =
- (APF_WINDOW_ADJUST_MESSAGE *)rxBuffer;
- LMEChannelWindowAdjustMessage channelWindowAdjust;
-
- channelWindowAdjust.RecipientChannel = ntohl(pMessage->RecipientChannel);
- channelWindowAdjust.BytesToAdd = ntohl(pMessage->BytesToAdd);
- _cb(_cbParam, &channelWindowAdjust, sizeof(channelWindowAdjust), &status);
- }
- break;
-
- case APF_PROTOCOLVERSION:
- {
- APF_PROTOCOL_VERSION_MESSAGE *pMessage =
- (APF_PROTOCOL_VERSION_MESSAGE *)rxBuffer;
- LMEProtocolVersionMessage protVersion;
-
- protVersion.MajorVersion = ntohl(pMessage->MajorVersion);
- protVersion.MinorVersion = ntohl(pMessage->MinorVersion);
- protVersion.TriggerReason =
- (APF_TRIGGER_REASON)ntohl(pMessage->TriggerReason);
- _cb(_cbParam, &protVersion, sizeof(protVersion), &status);
- }
- break;
-
- default:
- // Uknown request. Ignore
- break;
- }
-
- if (IsInitialized()) {
- plugin.postprocess(rxBuffer, bytesRead, status);
- }
- }
-
- if (rxBuffer != NULL) {
- delete[] rxBuffer;
- }
-}
-
-void LMEConnection::_apfChannelOpen(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) {
-
- UINT32 senderChannel = 0;
-
- _apfChannelOpenDirect(rxBuffer, bytesRead, &senderChannel, status);
- if (IsInitialized() && (*status == 1)) {
- if (plugin.retry(rxBuffer, bytesRead) != LMS_DROPPED) {
- _apfChannelOpenDirect(rxBuffer, bytesRead, NULL, status);
- }
- }
- if (IsInitialized() && (*status == 1)) {
- ChannelOpenReplayFailure(senderChannel,
- OPEN_FAILURE_REASON_CONNECT_FAILED);
- }
- }
-}
-
-void LMEConnection::_apfChannelOpenDirect(unsigned char *rxBuffer, unsigned int bytesRead, UINT32 *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(UINT32))) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- return;
- }
-
- pCurrent = rxBuffer + sizeof(APF_GENERIC_HEADER) +
- APF_STR_SIZE_OF(APF_OPEN_CHANNEL_REQUEST_DIRECT);
-
- LMEChannelOpenRequestMessage channelOpenRequest;
- channelOpenRequest.ChannelType = LMEChannelOpenRequestMessage::DIRECT;
-
- channelOpenRequest.SenderChannel = ntohl(*((UINT32 *)pCurrent));
- if (senderChannel) {
- *senderChannel = channelOpenRequest.SenderChannel;
- }
- pCurrent += sizeof(UINT32);
- channelOpenRequest.InitialWindow = ntohl(*((UINT32 *)pCurrent));
- pCurrent += 2 * sizeof(UINT32);
-
- UINT32 len = ntohl(*((UINT32 *)pCurrent));
- pCurrent += sizeof(UINT32);
- channelOpenRequest.Address.append((char *)pCurrent, len);
- pCurrent += len;
- channelOpenRequest.Port = ntohl(*((UINT32 *)pCurrent));
- pCurrent += sizeof(UINT32);
-
- _cb(_cbParam, &channelOpenRequest, sizeof(channelOpenRequest), status);
-}
-
-void LMEConnection::_apfGlobalRequest(unsigned char *rxBuffer, unsigned int bytesRead, int *status)
-{
- unsigned char *pCurrent;
- APF_GENERIC_HEADER *pHeader = (APF_GENERIC_HEADER *)rxBuffer;
-
- if (_strnicmp((char *)pHeader->String,
- APF_GLOBAL_REQUEST_STR_TCP_FORWARD_REQUEST,
- APF_STR_SIZE_OF(APF_GLOBAL_REQUEST_STR_TCP_FORWARD_REQUEST)) == 0) {
- LMETcpForwardRequestMessage tcpForwardRequest;
- unsigned int hsize = sizeof(APF_GENERIC_HEADER) +
- APF_STR_SIZE_OF(APF_GLOBAL_REQUEST_STR_TCP_FORWARD_REQUEST) +
- sizeof(UINT8);
- pCurrent = rxBuffer + hsize;
- bytesRead -= hsize;
-
- if (bytesRead < sizeof(UINT32)) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- return;
- }
-
- UINT32 len = ntohl(*((UINT32 *)pCurrent));
- pCurrent += sizeof(UINT32);
-
- if (bytesRead < (sizeof(UINT32) + len + sizeof(UINT32))) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- return;
- }
-
- tcpForwardRequest.Address.append((char *)pCurrent, len);
- pCurrent += len;
- tcpForwardRequest.Port = ntohl(*((UINT32 *)pCurrent));
-
- _cb(_cbParam, &tcpForwardRequest, sizeof(tcpForwardRequest), status);
- }
- else if (_strnicmp((char *)pHeader->String,
- APF_GLOBAL_REQUEST_STR_TCP_FORWARD_CANCEL_REQUEST,
- APF_STR_SIZE_OF(APF_GLOBAL_REQUEST_STR_TCP_FORWARD_CANCEL_REQUEST)) == 0) {
- LMETcpForwardCancelRequestMessage tcpForwardCancelRequest;
- unsigned int hsize = sizeof(APF_GENERIC_HEADER) +
- APF_STR_SIZE_OF(APF_GLOBAL_REQUEST_STR_TCP_FORWARD_CANCEL_REQUEST) +
- sizeof(UINT8);
- pCurrent = rxBuffer + hsize;
- bytesRead -= hsize;
-
- if (bytesRead < sizeof(UINT32)) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- return;
- }
-
- UINT32 len = ntohl(*((UINT32 *)pCurrent));
- pCurrent += sizeof(UINT32);
-
- if (bytesRead < (sizeof(UINT32) + len + sizeof(UINT32))) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- return;
- }
-
- tcpForwardCancelRequest.Address.append((char *)pCurrent, len);
- pCurrent += len;
- tcpForwardCancelRequest.Port = ntohl(*((UINT32 *)pCurrent));
-
- _cb(_cbParam, &tcpForwardCancelRequest, sizeof(tcpForwardCancelRequest), status);
- }
- else if (_strnicmp((char *)pHeader->String,
- APF_GLOBAL_REQUEST_STR_UDP_SEND_TO,
- APF_STR_SIZE_OF(APF_GLOBAL_REQUEST_STR_UDP_SEND_TO)) == 0) {
- unsigned int hsize = sizeof(APF_GENERIC_HEADER) +
- APF_STR_SIZE_OF(APF_GLOBAL_REQUEST_STR_UDP_SEND_TO) +
- sizeof(UINT8);
- pCurrent = rxBuffer + hsize;
- bytesRead -= hsize;
-
- if (bytesRead < sizeof(UINT32)) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- return;
- }
-
- UINT32 len = ntohl(*((UINT32 *)pCurrent));
- pCurrent += sizeof(UINT32);
-
- if (bytesRead < (sizeof(UINT32) + len + sizeof(UINT32))) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- return;
- }
- bytesRead -= (sizeof(UINT32) + len + sizeof(UINT32));
-
- std::string address;
- address.append((char *)pCurrent, len);
- pCurrent += len;
- UINT32 port = ntohl(*((UINT32 *)pCurrent));
- pCurrent += sizeof(UINT32);
-
- if (bytesRead < sizeof(UINT32)) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- return;
- }
-
- // Skip Originator IP and Port
- len = ntohl(*((UINT32 *)pCurrent));
- pCurrent += sizeof(UINT32);
-
- if (bytesRead < (sizeof(UINT32) + len + sizeof(UINT32))) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- return;
- }
- bytesRead -= (sizeof(UINT32) + len + sizeof(UINT32));
-
- pCurrent += len;
- pCurrent += sizeof(UINT32);
-
- if (bytesRead < sizeof(UINT32)) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- return;
- }
-
- // Retrieve Data
- len = ntohl(*((UINT32 *)pCurrent));
- pCurrent += sizeof(UINT32);
-
- if (bytesRead < (sizeof(UINT32) + len)) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- return;
- }
-
- LMEUdpSendToMessage udpSendTo(address, port, len, pCurrent);
-
- _cb(_cbParam, &udpSendTo, sizeof(udpSendTo), status);
- }
-}
-
-void LMEConnection::_apfUserAuthRequest(unsigned char *rxBuffer, unsigned int bytesRead, int *status)
-{
- unsigned char *pCurrent = rxBuffer;
-
- ++pCurrent;
-
- LMEUserAuthRequestMessage userAuthRequest;
-
- UINT32 len = ntohl(*((UINT32 *)pCurrent));
- pCurrent += sizeof(UINT32);
-
- if ((bytesRead - (pCurrent - rxBuffer)) < len) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- return;
- }
-
- userAuthRequest.Username.append((char *)pCurrent, len);
- pCurrent += len;
-
- if ((unsigned int)(bytesRead - (pCurrent - rxBuffer)) < sizeof(UINT32)) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- return;
- }
-
- len = ntohl(*((UINT32 *)pCurrent));
- pCurrent += sizeof(UINT32);
-
- if ((bytesRead - (pCurrent - rxBuffer)) < len) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- return;
- }
-
- userAuthRequest.ServiceName.append((char *)pCurrent, len);
- pCurrent += len;
-
- if ((unsigned int)(bytesRead - (pCurrent - rxBuffer)) < sizeof(UINT32)) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- return;
- }
-
- len = ntohl(*((UINT32 *)pCurrent));
- pCurrent += sizeof(UINT32);
-
- if ((bytesRead - (pCurrent - rxBuffer)) < len) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- 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(UINT32) + 1) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- return;
- }
-
- ++pCurrent;
-
- len = ntohl(*((UINT32 *)pCurrent));
- pCurrent += sizeof(UINT32);
-
- if ((bytesRead - (pCurrent - rxBuffer)) < len) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- return;
- }
-
- AuthPasswordData authData;
- authData.Password.append((char *)pCurrent, len);
- pCurrent += len;
-
- userAuthRequest.MethodData = &authData;
- }
-
- _cb(_cbParam, &userAuthRequest, sizeof(userAuthRequest), status);
-}
-
-unsigned int LMEConnection::GetHeciBufferSize() const
-{
- if (_pHeci == NULL) {
- return 0;
- }
- return _pHeci->GetBufferSize();
-}
-
diff --git a/usr/src/cmd/lms/LMEConnection.h b/usr/src/cmd/lms/LMEConnection.h
deleted file mode 100644
index c71bc3a8d6..0000000000
--- a/usr/src/cmd/lms/LMEConnection.h
+++ /dev/null
@@ -1,412 +0,0 @@
-/*******************************************************************************
- * 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 __LME_CONNECTION_H__
-#define __LME_CONNECTION_H__
-
-#if defined(__sun) || defined(_LINUX)
-#include "HECIUnix.h"
-#else
-#include "HECIWin.h"
-#endif
-
-#include <map>
-#include <string>
-#include "LMS_if.h"
-#include "Thread.h"
-#include "Semaphore.h"
-#include "Event.h"
-#include "ATNetworkTool.h"
-
-
-struct AuthMethodData {
-};
-
-struct AuthPasswordData : AuthMethodData {
- std::string Password;
-};
-
-struct LMEMessage {
-
- LMEMessage(APF_MESSAGE_TYPE type) :
- MessageType(type) {}
-
- const APF_MESSAGE_TYPE MessageType;
-};
-
-struct LMEDisconnectMessage : LMEMessage {
-
- LMEDisconnectMessage(APF_DISCONNECT_REASON_CODE reasonCode) :
- LMEMessage(APF_DISCONNECT),
- ReasonCode(reasonCode) {}
-
- APF_DISCONNECT_REASON_CODE ReasonCode;
-};
-
-struct LMEServiceRequestMessage : LMEMessage {
-
- LMEServiceRequestMessage(std::string serviceName = "") :
- LMEMessage(APF_SERVICE_REQUEST),
- ServiceName(serviceName) {}
-
- std::string ServiceName;
-};
-
-struct LMEGlobalRequestMessage : LMEMessage {
-
- enum REQUEST_TYPE {
- TCP_FORWARD_REQUEST,
- TCP_FORWARD_CANCEL_REQUEST,
- UDP_SEND_TO
- };
-
- LMEGlobalRequestMessage(REQUEST_TYPE type) :
- LMEMessage(APF_GLOBAL_REQUEST),
- RequestType(type) {}
-
- const REQUEST_TYPE RequestType;
-};
-
-struct LMEProtocolVersionMessage : LMEMessage {
-
- LMEProtocolVersionMessage(UINT32 majorVersion = 0,
- UINT32 minorVersion = 0,
- APF_TRIGGER_REASON triggerReason = LME_REQUEST) :
- LMEMessage(APF_PROTOCOLVERSION),
- MajorVersion(majorVersion),
- MinorVersion(minorVersion),
- TriggerReason(triggerReason) {}
-
- UINT32 MajorVersion;
- UINT32 MinorVersion;
- APF_TRIGGER_REASON TriggerReason;
-
- struct LMEProtocolVersionMessage &operator=(const struct LMEProtocolVersionMessage &y)
- {
- if (this != &y) {
- this->MajorVersion = y.MajorVersion;
- this->MinorVersion = y.MinorVersion;
- }
- return *this;
- };
- bool operator<(const struct LMEProtocolVersionMessage &y) const
- {
- if (this->MajorVersion != y.MajorVersion) {
- return (this->MajorVersion < y.MajorVersion);
- }
- return (this->MinorVersion < y.MinorVersion);
- }
- bool operator>(const struct LMEProtocolVersionMessage &y) const
- {
- if (this->MajorVersion != y.MajorVersion) {
- return (this->MajorVersion > y.MajorVersion);
- }
- return (this->MinorVersion > y.MinorVersion);
- }
-};
-
-struct LMEUserAuthRequestMessage : LMEMessage {
-
- LMEUserAuthRequestMessage(std::string username = "",
- std::string serviceName = "",
- std::string methodName = "",
- AuthMethodData *methodData = NULL) :
- LMEMessage(APF_USERAUTH_REQUEST),
- Username(username),
- ServiceName(ServiceName),
- MethodName(methodName),
- MethodData(methodData) {}
-
- std::string Username;
- std::string ServiceName;
- std::string MethodName;
-
- AuthMethodData *MethodData;
-};
-
-
-struct LMETcpForwardRequestMessage : LMEGlobalRequestMessage {
-
- LMETcpForwardRequestMessage(std::string address = "", UINT32 port = 0) :
- LMEGlobalRequestMessage(TCP_FORWARD_REQUEST),
- Address(address),
- Port(port) {}
-
- std::string Address;
- UINT32 Port;
-};
-
-struct LMETcpForwardCancelRequestMessage : LMEGlobalRequestMessage {
-
- LMETcpForwardCancelRequestMessage(std::string address = "", UINT32 port = 0) :
- LMEGlobalRequestMessage(TCP_FORWARD_CANCEL_REQUEST),
- Address(address),
- Port(port) {}
-
- std::string Address;
- UINT32 Port;
-};
-
-struct LMEUdpSendToMessage : LMEGlobalRequestMessage {
-
- LMEUdpSendToMessage(std::string address = "", UINT32 port = 0,
- UINT32 dataLength = 0, UINT8 *data = NULL) :
- LMEGlobalRequestMessage(UDP_SEND_TO),
- Address(address),
- Port(port),
- DataLength(dataLength)
- {
- if ((data != NULL) && (dataLength != 0)) {
- Data = new UINT8[dataLength];
- memcpy(Data, data, dataLength);
- } else {
- Data = NULL;
- }
-
- }
-
- ~LMEUdpSendToMessage()
- {
- if (Data != NULL) {
- delete[] Data;
- Data = NULL;
- }
- }
-
- std::string Address;
- UINT32 Port;
- UINT32 DataLength;
- UINT8 *Data;
-};
-
-struct LMEChannelOpenRequestMessage : LMEMessage {
-
- enum CHANNEL_TYPE {
- FORWARDED,
- DIRECT
- };
-
- LMEChannelOpenRequestMessage(CHANNEL_TYPE channelType = FORWARDED,
- UINT32 senderChannel = 0,
- UINT32 initialWindow = 0,
- std::string address = "", UINT32 port = 0) :
- LMEMessage(APF_CHANNEL_OPEN),
- ChannelType(channelType),
- SenderChannel(senderChannel),
- InitialWindow(initialWindow),
- Address(address),
- Port(port) {}
-
- CHANNEL_TYPE ChannelType;
- UINT32 SenderChannel;
- UINT32 InitialWindow;
- std::string Address;
- UINT32 Port;
-};
-
-struct LMEChannelOpenReplaySuccessMessage : LMEMessage {
-
- LMEChannelOpenReplaySuccessMessage(UINT32 recipientChannel = 0,
- UINT32 senderChannel = 0,
- UINT32 initialWindow = 0) :
- LMEMessage(APF_CHANNEL_OPEN_CONFIRMATION),
- RecipientChannel(recipientChannel),
- SenderChannel(senderChannel),
- InitialWindow(initialWindow) {}
-
- UINT32 RecipientChannel;
- UINT32 SenderChannel;
- UINT32 InitialWindow;
-};
-
-struct LMEChannelOpenReplayFailureMessage : LMEMessage {
-
- LMEChannelOpenReplayFailureMessage(UINT32 recipientChannel = 0,
- OPEN_FAILURE_REASON reasonCode = OPEN_FAILURE_REASON_ADMINISTRATIVELY_PROHIBITED) :
- LMEMessage(APF_CHANNEL_OPEN_FAILURE),
- RecipientChannel(recipientChannel),
- ReasonCode(reasonCode) {}
-
- UINT32 RecipientChannel;
- OPEN_FAILURE_REASON ReasonCode;
-};
-
-struct LMEChannelCloseMessage : LMEMessage {
-
- LMEChannelCloseMessage(UINT32 recipientChannel = 0) :
- LMEMessage(APF_CHANNEL_CLOSE),
- RecipientChannel(recipientChannel) {}
-
- UINT32 RecipientChannel;
-};
-
-struct LMEChannelDataMessage : LMEMessage {
-
- LMEChannelDataMessage(UINT32 recipientChannel = 0,
- UINT32 dataLength = 0,
- UINT8 *data = NULL) :
- LMEMessage(APF_CHANNEL_DATA),
- RecipientChannel(recipientChannel),
- DataLength(dataLength)
- {
- if ((data != NULL) && (dataLength != 0)) {
- Data = new UINT8[dataLength];
- memcpy(Data, data, dataLength);
- } else {
- Data = NULL;
- }
- }
-
- ~LMEChannelDataMessage()
- {
- if (Data != NULL) {
- delete[] Data;
- Data = NULL;
- }
- }
-
- const UINT32 RecipientChannel;
- const UINT32 DataLength;
- UINT8 *Data;
-};
-
-struct LMEChannelWindowAdjustMessage : LMEMessage {
-
- LMEChannelWindowAdjustMessage(UINT32 recipientChannel = 0,
- UINT32 bytesToAdd = 0) :
- LMEMessage(APF_CHANNEL_WINDOW_ADJUST),
- RecipientChannel(recipientChannel),
- BytesToAdd(bytesToAdd) {}
-
- UINT32 RecipientChannel;
- UINT32 BytesToAdd;
-};
-
-typedef void (*HECICallback)(void *param, void *buffer, unsigned int len, int *status);
-
-class LMEConnection
-{
-public:
- LMEConnection(bool verbose = false);
- ~LMEConnection();
-
- bool Init(HECICallback cb, void *param);
- bool IsInitialized();
- bool Disconnect(APF_DISCONNECT_REASON_CODE reasonCode);
- bool ServiceAccept(std::string serviceName);
- bool UserAuthSuccess();
- bool ProtocolVersion(const LMEProtocolVersionMessage versionMessage);
- bool TcpForwardReplySuccess(UINT32 port);
- bool TcpForwardReplyFailure();
- bool TcpForwardCancelReplySuccess();
- bool TcpForwardCancelReplyFailure();
- bool ChannelOpenForwardedRequest(UINT32 sender, UINT32 connectedPort,
- std::string originatorIP, UINT32 originatorPort);
- bool ChannelOpenReplaySuccess(UINT32 recipient, UINT32 sender);
- bool ChannelOpenReplayFailure(UINT32 recipient, UINT32 reason);
- bool ChannelClose(UINT32 recipient);
- int ChannelData(UINT32 recipient, UINT32 len, unsigned char *buffer);
- bool ChannelWindowAdjust(UINT32 recipient, UINT32 len);
-
- //BACKWARD COMPATIBLE PUBLIC - BEGIN
- bool CompatProtocolVersion();
- bool CompatRequestIPFQDN();
- bool CompatOpenConnection(in_port_t mePort, ATAddress addr, unsigned int &connID);
- int CompatSendMessage(UINT8 connID, UINT32 len, unsigned char *buffer);
- void CompatCloseConnection(int connID, int status);
- //BACKWARD COMPATIBLE PUBLIC - END
-
- void Deinit();
- unsigned int GetHeciBufferSize() const;
-
- enum INIT_STATES {
- INIT_STATE_DISCONNECTED = 0,
- INIT_STATE_CONNECTING,
- INIT_STATE_CONNECTED
- };
-
- static const UINT32 RX_WINDOW_SIZE;
-
- unsigned char protocolVer;
-
-private:
- static const GUID _guid;
-
- static void _rxThreadFunc(void *param);
-
- void _doRX();
- int _receiveMessage(unsigned char *buffer, int len);
- int _sendMessage(unsigned char *buffer, int len);
- bool _checkMinMsgSize(unsigned char *buf, unsigned int bytesRead);
- void _apfGlobalRequest(unsigned char *rxBuffer, unsigned int bytesRead, int *status);
- void _apfUserAuthRequest(unsigned char *rxBuffer, unsigned int bytesRead, int *status);
- void _apfChannelOpen(unsigned char *rxBuffer, unsigned int bytesRead, int *status);
- void _apfChannelOpenDirect(unsigned char *rxBuffer, unsigned int bytesRead, UINT32 *senderChannel, int *status);
-
-
- unsigned char _reqID;
- unsigned char *_txBuffer;
- Thread *_rxThread;
- HECICallback _cb;
- void *_cbParam;
- Semaphore _initLock;
- Semaphore _sendMessageLock;
- INIT_STATES _initState;
- Event _threadStartedEvent;
-#if defined(__sun) || defined(_LINUX)
- HECILinux _heci;
-#else
- HECIWin _heci;
-#endif
-
- //BACKWARD COMPATIBLE PRIVATE - BEGIN
- static const GUID _guidCompat;
-
- void _doRXCompat();
-
- struct CompatConnection {
- Event *event;
- int connID;
- UINT8 status;
- };
- typedef std::map<int, CompatConnection> CompatConnMap;
- CompatConnMap _compatPendingConnections;
- Semaphore _compatMapLock;
-#if defined(__sun) || defined(_LINUX)
- HECILinux _heciCompat;
-#else
- HECIWin _heciCompat;
-#endif
- //BACKWARD COMPATIBLE PRIVATE - END
-
- HECI *_pHeci;
-};
-
-#endif
diff --git a/usr/src/cmd/lms/LMEConnectionCompat.cpp b/usr/src/cmd/lms/LMEConnectionCompat.cpp
deleted file mode 100644
index 6a91067872..0000000000
--- a/usr/src/cmd/lms/LMEConnectionCompat.cpp
+++ /dev/null
@@ -1,335 +0,0 @@
-/*******************************************************************************
- * 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.
- *******************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include <cerrno>
-#include "types.h"
-#include "LMEConnection.h"
-#include "LMS_if_compat.h"
-#include "Lock.h"
-#include "glue.h"
-
-#ifdef _LINUX
-#define _strnicmp strncasecmp
-#endif
-
-extern glue plugin;
-
-const GUID LMEConnection::_guidCompat = {0x3d98d9b7, 0x1ce8, 0x4252, {0xb3, 0x37, 0x2e, 0xff, 0x10, 0x6e, 0xf2, 0x9f}};
-
-int LMEConnection::CompatSendMessage(UINT8 connID, UINT32 len, unsigned char *buffer)
-{
- if (!IsInitialized()) {
- PRINT("[Compat]State: not connected to HECI.\n");
- return -1;
- }
-
- unsigned char sendBuf[1024 + sizeof(LMS_SEND_DATA_MESSAGE)];
- LMS_SEND_DATA_MESSAGE *msg;
-
- if (len > 1024) {
- return -1;
- }
-
- msg = (LMS_SEND_DATA_MESSAGE *)sendBuf;
- msg->MessageType = LMS_MESSAGE_TYPE_SEND_DATA;
- msg->ConnectionId = connID;
- msg->DataLength = htons(len);
- memcpy(msg->Data, buffer, len);
-
- return _sendMessage(sendBuf, sizeof(LMS_SEND_DATA_MESSAGE) + len);
-}
-
-void LMEConnection::CompatCloseConnection(int connID, int status)
-{
- if (!IsInitialized()) {
- PRINT("[Compat]State: not connected to HECI.\n");
- return;
- }
-
- LMS_CLOSE_CONNECTION_MESSAGE msg;
-
- msg.MessageType = LMS_MESSAGE_TYPE_CLOSE_CONNECTION;
- msg.ConnectionId = connID;
- msg.ClosingReason = status;
-
- _sendMessage((unsigned char *)&msg, sizeof(msg));
-}
-
-bool LMEConnection::CompatProtocolVersion()
-{
- if (!IsInitialized()) {
- PRINT("[Compat]State: not connected to HECI.\n");
- return false;
- }
-
- LMS_PROTO_VERSION_MESSAGE msg;
-
- memset(&msg, 0, sizeof(msg));
- msg.MessageType = LMS_MESSAGE_TYPE_PROTO_VERSION;
- msg.ConnectionId = 0;
- msg.Protocol = 0;
-
- PRINT("[Compat]Sending Protocol Version to LME\n");
- int bytesWritten = _sendMessage((unsigned char *)&msg, sizeof(msg));
- return (bytesWritten == sizeof(msg));
-}
-
-bool LMEConnection::CompatRequestIPFQDN()
-{
- if (!IsInitialized()) {
- PRINT("[Compat]State: not connected to HECI.\n");
- return false;
- }
-
- LMS_IP_FQDN_REQUEST_MESSAGE msg;
-
- memset(&msg, 0, sizeof(msg));
- msg.MessageType = LMS_MESSAGE_TYPE_IP_FQDN_REQUEST;
- msg.ConnectionId = 0;
-
- PRINT("[Compat]Sending IP_FQDN request to LME\n");
- int bytesWritten = _sendMessage((unsigned char *)&msg, sizeof(msg));
- return (bytesWritten == sizeof(msg));
-}
-
-bool LMEConnection::CompatOpenConnection(in_port_t mePort, ATAddress addr, unsigned int &connID)
-{
- if (!IsInitialized()) {
- PRINT("[Compat]State: not connected to HECI.\n");
- return false;
- }
-
- unsigned char currReqID = _reqID++;
- bool ret = false;
- LMS_OPEN_CONNECTION_EX_MESSAGE openConnectionExMsg;
- LMS_OPEN_CONNECTION_MESSAGE openConnectionMsg;
- unsigned char *msg = NULL;
- int msgLen = 0;
- size_t addrSize = 0;
- const void *inAddr = addr.inAddr(addrSize);
-
- if (protocolVer == LMS_PROCOL_VERSION_COMPAT) {
- memset(&openConnectionExMsg, 0, sizeof(openConnectionExMsg));
- openConnectionExMsg.MessageType = LMS_MESSAGE_TYPE_OPEN_CONNECTION_EX;
- openConnectionExMsg.ConnectionId = 0;
- openConnectionExMsg.Protocol = LMS_PROTOCOL_TYPE_TCP_IPV4;
- openConnectionExMsg.Flags = 0;
- openConnectionExMsg.OpenRequestId = currReqID;
- memcpy(openConnectionExMsg.Host, inAddr, addrSize);
- openConnectionExMsg.HostPort = htons(addr.inPort());
- openConnectionExMsg.MEPort = htons(mePort);
-
- msg = (unsigned char *)&openConnectionExMsg;
- msgLen = sizeof(openConnectionExMsg);
- PRINT("[Compat]OpenConnectionEx %x (%d) p=%d mp=%d\n",
- *(int *)inAddr, addrSize, addr.inPort(), mePort);
- }
- else {
- memset(&openConnectionMsg, 0, sizeof(openConnectionMsg));
- openConnectionMsg.MessageType = LMS_MESSAGE_TYPE_OPEN_CONNECTION;
- openConnectionMsg.ConnectionId = 0;
- openConnectionMsg.Protocol = LMS_PROTOCOL_TYPE_TCP_IPV4;
- openConnectionMsg.OpenRequestId = currReqID;
- memcpy(openConnectionMsg.HostIPAddress, inAddr, addrSize);
- openConnectionMsg.HostPort = htons(addr.inPort());
- openConnectionMsg.MEPort = htons(mePort);
-
- msg = (unsigned char *)&openConnectionMsg;
- msgLen = sizeof(openConnectionMsg);
- PRINT("[Compat]OpenConnection %x (%d) p=%d mp=%d\n",
- *(int *)inAddr, addrSize, addr.inPort(), mePort);
- }
-
- // save as pending request
- CompatConnection conn;
- conn.event = new Event();
- conn.status = LMS_CONNECTION_STATUS_FAILED;
- conn.connID = 0;
-
- _compatMapLock.acquire();
- _compatPendingConnections[currReqID] = conn;
- _compatMapLock.release();
-
- int bytesWritten;
- bytesWritten = _sendMessage(msg, msgLen);
- if (bytesWritten != msgLen) {
- goto out;
- }
-
- if (conn.event->wait(10000) == false) {
- // no response from FW
- goto out;
- }
-
- ret = true;
-
-out:
- {
- Lock ml(_compatMapLock);
-
- if (_compatPendingConnections[currReqID].status != LMS_CONNECTION_STATUS_OK) {
- ret = false;
- } else {
- connID = _compatPendingConnections[currReqID].connID;
- }
- _compatPendingConnections.erase(currReqID);
- }
-
- delete conn.event;
- conn.event = NULL;
-
- return ret;
-}
-
-void LMEConnection::_doRXCompat()
-{
- unsigned int bytesRead;
- int status = 1;
-
- _threadStartedEvent.set();
-
- unsigned char *rxBuffer = new unsigned char[_heciCompat.GetBufferSize()];
-
- while (true) {
- bytesRead = (unsigned int)_receiveMessage(rxBuffer, _heciCompat.GetBufferSize());
-
- if ((int)bytesRead < 0) {
- PRINT("[Compat]Error receiving data from HECI\n");
- Deinit();
- break;
- }
-
- if (bytesRead == 0) {
- // ERROR
- continue;
- }
-
- PRINT("[Compat]Received from LME %d bytes (msg type %02d)\n", bytesRead, rxBuffer[0]);
-
- if (bytesRead < 2) {
- // ERROR
- continue;
- }
-
- if (plugin.preprocess(rxBuffer, bytesRead) == LMS_DROPPED) {
- continue;
- }
-
- switch (rxBuffer[0]) {
- case LMS_MESSAGE_TYPE_PROTO_VERSION_REPLY:
- CompatRequestIPFQDN();
- break;
-
- case LMS_MESSAGE_TYPE_CLOSE_CONNECTION:
- case LMS_MESSAGE_TYPE_SEND_DATA:
- case LMS_MESSAGE_TYPE_IP_FQDN:
- _cb(_cbParam, rxBuffer, bytesRead, &status);
- break;
-
- case LMS_MESSAGE_TYPE_OPEN_CONNECTION_REPLY:
- {
- LMS_OPEN_CONNECTION_REPLY_MESSAGE *repMsg =
- (LMS_OPEN_CONNECTION_REPLY_MESSAGE *)rxBuffer;
-
- Lock ml(_compatMapLock);
-
- CompatConnMap::iterator itr;
- itr = _compatPendingConnections.find(repMsg->OpenRequestId);
- if (itr != _compatPendingConnections.end()) {
- (*itr).second.connID = repMsg->ConnectionId;
- (*itr).second.status = repMsg->Status;
- (*itr).second.event->set();
- PRINT("[Compat]Open connection reply %d %d =%d\n", repMsg->OpenRequestId, repMsg->ConnectionId, repMsg->Status);
- }
- }
- break;
-
- case LMS_MESSAGE_TYPE_OPEN_CONNECTION_EX:
- {
- // report incoming connection request
- _cb(_cbParam, rxBuffer, bytesRead, &status);
-
- if (IsInitialized() && (status == 1)) {
- if (plugin.retry(rxBuffer, bytesRead) == LMS_DROPPED) {
- continue;
- } else {
- _cb(_cbParam, rxBuffer, bytesRead, &status);
- }
- }
-
- LMS_OPEN_CONNECTION_EX_MESSAGE *msg =
- (LMS_OPEN_CONNECTION_EX_MESSAGE *)rxBuffer;
-
- if ((msg->Flags & HOSTNAME_BIT) != 0) {
- PRINT("[Compat]Got client connection request %d for host %s, port %d\n",
- msg->ConnectionId, msg->Host, ntohs(msg->HostPort));
- }
- else {
- PRINT("[Compat]Got client connection request %d for IP %s, port %d\n",
- msg->ConnectionId, inet_ntoa(*((struct in_addr *)msg->Host)), ntohs(msg->HostPort));
- }
-
- LMS_OPEN_CONNECTION_REPLY_MESSAGE repMsg;
- memset(&repMsg, 0, sizeof(repMsg));
-
- repMsg.MessageType = LMS_MESSAGE_TYPE_OPEN_CONNECTION_REPLY;
- repMsg.ConnectionId = msg->ConnectionId;
- if (status == 0) {
- repMsg.Status = LMS_CONNECTION_STATUS_OK;
- } else {
- repMsg.Status = LMS_CONNECTION_STATUS_FAILED;
- }
-
- DWORD bytesWritten;
- bytesWritten = _sendMessage((unsigned char *)&repMsg, sizeof(repMsg));
- if (bytesWritten != sizeof(repMsg)) {
- PRINT("[Compat]Send Open Connection Reply failed: bytesWritten: %lu\n", bytesWritten);
- }
- }
- break;
-
- default:
- // Uknown request. Ignore
- break;
- }
-
- if (IsInitialized()) {
- plugin.postprocess(rxBuffer, bytesRead, status);
- }
- }
-
- if (rxBuffer != NULL) {
- delete[] rxBuffer;
- }
-}
-
diff --git a/usr/src/cmd/lms/LMS_if.h b/usr/src/cmd/lms/LMS_if.h
deleted file mode 100644
index a1d7ceefc2..0000000000
--- a/usr/src/cmd/lms/LMS_if.h
+++ /dev/null
@@ -1,232 +0,0 @@
-/*******************************************************************************
- * 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 _LMS_IF_H_
-#define _LMS_IF_H_
-
-#include "types.h"
-#include "LMS_if_constants.h"
-
-// disable the "zero-sized array" warning in Visual C++
-#ifdef _MSC_VER
-#pragma warning(disable:4200)
-#endif
-
-#pragma pack(1)
-
-typedef struct {
- UINT8 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 {
- UINT8 MessageType;
- UINT32 StringLength;
- UINT8 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 {
- UINT8 MessageType;
- UINT32 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 {
- UINT8 MessageType;
- UINT32 RecipientChannel;
- UINT32 SenderChannel;
- UINT32 InitialWindowSize;
- UINT32 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 {
- UINT8 MessageType;
- UINT32 RecipientChannel;
- UINT32 ReasonCode;
- UINT32 Reserved;
- UINT32 Reserved2;
-} APF_CHANNEL_OPEN_FAILURE_MESSAGE;
-
-/**
- * close channel message
- * @MessageType - APF_CHANNEL_CLOSE
- * @RecipientChannel - channel number given in the open request
- **/
-typedef struct {
- UINT8 MessageType;
- UINT32 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 {
- UINT8 MessageType;
- UINT32 RecipientChannel;
- UINT32 DataLength;
- UINT8 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 {
- UINT8 MessageType;
- UINT32 RecipientChannel;
- UINT32 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 {
- UINT8 MessageType;
- UINT32 ReasonCode;
- UINT16 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 {
- UINT8 MessageType;
- UINT32 ServiceNameLength;
- UINT8 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 {
- UINT8 MessageType;
- UINT32 ServiceNameLength;
- UINT8 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 {
- UINT8 MessageType;
- UINT32 MajorVersion;
- UINT32 MinorVersion;
- UINT32 TriggerReason;
- UINT8 UUID[16];
- UINT8 Reserved[64];
-} APF_PROTOCOL_VERSION_MESSAGE;
-
-/**
- * holds the user authentication request.
- * @UsernameLength - The length of the user name string.
- * @Username - The name of the user in ASCII encoding.
- * Maximum allowed size is 64 bytes.
- * @ServiceNameLength - The length of the service name string.
- * @ServiceName - The name of the service to authorize.
- * @MethodNameLength - The length of the method name string.
- * @MethodName - The authentication method to use.
- **/
-//typedef struct {
-// UINT8 MessageType;
-// UINT32 UsernameLength;
-// UINT8 Username[0];
-// UINT32 ServiceNameLength;
-// UINT8 ServiceName[0];
-// UINT32 MethodNameLength;
-// UINT8 MethodName[0];
-//} APF_USERAUTH_REQUEST_MESSAGE;
-
-/**
- * holds the user authentication request failure reponse.
- * @MethodNameListLength - The length of the methods list string.
- * @MethodNameList - A comma seperated string of authentication
- * methods supported by the server in ASCII.
- **/
-//typedef struct {
-// UINT8 MessageType;
-// UINT32 MethodNameListLength;
-// UINT8 MethodNameList[0];
-// UINT8 Reserved;
-//} APF_USERAUTH_FAILURE_MESSAGE;
-
-/**
- * holds the user authentication request success reponse.
- **/
-typedef struct {
- UINT8 MessageType;
-} APF_USERAUTH_SUCCESS_MESSAGE;
-
-#pragma pack()
-
-#endif
-
diff --git a/usr/src/cmd/lms/LMS_if_compat.h b/usr/src/cmd/lms/LMS_if_compat.h
deleted file mode 100644
index b6224fa470..0000000000
--- a/usr/src/cmd/lms/LMS_if_compat.h
+++ /dev/null
@@ -1,273 +0,0 @@
-/*******************************************************************************
- * 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 _LMS_IF_COMPAT_H_
-#define _LMS_IF_COMPAT_H_
-
-#include "types.h"
-
-// disable the "zero-sized array" warning in Visual C++
-#ifdef _MSC_VER
-#pragma warning(disable:4200)
-#endif
-
-#pragma pack(1)
-
-typedef enum {
- LMS_MESSAGE_TYPE_OPEN_CONNECTION = 0x01,
- LMS_MESSAGE_TYPE_OPEN_CONNECTION_REPLY = 0x02,
- LMS_MESSAGE_TYPE_CLOSE_CONNECTION = 0x03,
- LMS_MESSAGE_TYPE_SEND_DATA = 0x04,
- LMS_MESSAGE_TYPE_IP_FQDN_REQUEST = 0x05,
- LMS_MESSAGE_TYPE_IP_FQDN = 0x06,
- LMS_MESSAGE_TYPE_PROTO_VERSION = 0x07,
- LMS_MESSAGE_TYPE_PROTO_VERSION_REPLY = 0x08,
- LMS_MESSAGE_TYPE_OPEN_CONNECTION_EX = 0x0a
-} LMS_MESSAGE_TYPE;
-
-typedef enum {
- LMS_PROTOCOL_TYPE_TCP_IPV4 = 0x00,
- LMS_PROTOCOL_TYPE_UDP_IPV4 = 0x01,
- LMS_PROTOCOL_TYPE_TCP_IPV6 = 0x02,
- LMS_PROTOCOL_TYPE_UDP_IPV6 = 0x03
-} LMS_PROTOCOL_TYPE;
-
-typedef enum {
- LMS_CONNECTION_STATUS_OK = 0x00,
- LMS_CONNECTION_STATUS_FAILED = 0x01,
- LMS_CONNECTION_STATUS_TOO_MANY = 0x02
-} LMS_CONNECTION_STATUS;
-
-typedef enum {
- LMS_CLOSE_STATUS_CLIENT = 0x00,
- LMS_CLOSE_STATUS_INTERNAL = 0x01,
- LMS_CLOSE_STATUS_SOCKET = 0x02,
- LMS_CLOSE_STATUS_SHUTDOWN = 0x03
-} LMS_CLOSE_STATUS;
-
-typedef enum {
- LMS_IP_ADDRESS_SHARED = 0x00,
- LMS_IP_ADDRESS_DUAL_IPV4 = 0x01,
- LMS_IP_ADDRESS_DUAL_IPV6 = 0x02
-} LMS_IP_ADDRESS_TYPE;
-
-typedef enum {
- LMS_PROTOCOL_STATUS_OK = 0x00,
- LMS_PROTOCOL_STATUS_PROPOSE_ANOTHER = 0x01
-} LMS_PROTOCOL_STATUS;
-
-/**
- * LMS_OPEN_CONNECTION_MESSAGE - open connection request
- *
- * @MessageType: LMS_MESSAGE_TYPE_OPEN_CONNECTION
- * @ConnectionId: 0 if sent from LMS, positive if sent from LME
- * @Protocol: One of LMS_PROTOCOL_TYPE
- * @OpenRequestId: Any number; used to match the request to the response
- * @HostIPAddress: Source IP address of the initiating application, in network
- * order (Big Endian). If IPv4, only the first 4 bytes are used
- * and the rest must be 0.
- * @HostPort: Source port of the initiating application, in network order (Big
- * Endian).
- * @MEPort: Destination port of the initiating application, in network order
- * (Big Endian).
- */
-typedef struct {
- UINT8 MessageType;
- UINT8 ConnectionId;
- UINT8 Protocol;
- UINT8 OpenRequestId;
- UINT8 HostIPAddress[16];
- UINT16 HostPort;
- UINT16 MEPort;
-} LMS_OPEN_CONNECTION_MESSAGE;
-
-/**
- * LMS_OPEN_CONNECTION_REPLY_MESSAGE - open connection reply
- *
- * @MessageType: LMS_MESSAGE_TYPE_OPEN_CONNECTION_REPLY
- * @ConnectionId: Assigned by LME
- * @Status: One of LMS_CONNECTION_STATUS
- * @OpenRequestId: The same as the OpenRequestID value in the open connection
- * request message.
- */
-typedef struct {
- UINT8 MessageType;
- UINT8 ConnectionId;
- UINT8 Status;
- UINT8 OpenRequestId;
-} LMS_OPEN_CONNECTION_REPLY_MESSAGE;
-
-/**
- * LMS_OPEN_CONNECTION_EX_MESSAGE - open connection request
- *
- * @MessageType: LMS_MESSAGE_TYPE_OPEN_CONNECTION_EX
- * @ConnectionId: Unique identifier
- * @Protocol: One of LMS_PROTOCOL_TYPE
- * @Flags: If first bit is set then Host is an hostname, otherwise Host is an IP address.
- * If second bit is set then connection is from remote console, otherwise
- * it is from local application. The other bits must be zero.
- * @Reserved: Must be zero
- * @OpenRequestId: Any number; used to match the request to the response
- * @Host: Source IP address of the initiating application, in network
- * order (Big Endian). If IPv4, only the first 4 bytes are used
- * and the rest must be 0.
- * @HostPort: Source port of the initiating application, in network order (Big
- * Endian).
- * @MEPort: Destination port of the initiating application, in network order
- * (Big Endian).
- */
-
-#define HOSTNAME_BIT 0x1
-#define REMOTE_BIT 0x2
-
-#define FQDN_MAX_SIZE 256
-
-typedef struct {
- UINT8 MessageType;
- UINT8 ConnectionId;
- UINT8 Protocol;
- UINT8 Flags;
- UINT32 Reserved;
- UINT8 OpenRequestId;
- UINT8 Host[FQDN_MAX_SIZE];
- UINT16 HostPort;
- UINT16 MEPort;
-} LMS_OPEN_CONNECTION_EX_MESSAGE;
-
-///**
-// * LMS_OPEN_CONNECTION_EX_REPLY_MESSAGE - open connection reply
-// *
-// * @MessageType: LMS_MESSAGE_TYPE_OPEN_CONNECTION_EX_REPLY
-// * @ConnectionId: Should match value in connection request
-// * @Status: One of LMS_CONNECTION_STATUS
-// * @OpenRequestId: The same as the OpenRequestID value in the open connection
-// * request message.
-// */
-//typedef struct {
-// UINT8 MessageType;
-// UINT8 ConnectionId;
-// UINT8 Status;
-// UINT8 OpenRequestId;
-//} LMS_OPEN_CONNECTION_EX_REPLY_MESSAGE;
-
-/**
- * LMS_CLOSE_CONNECTION_MESSAGE - close connection request
- *
- * @MessageType: LMS_MESSAGE_TYPE_CLOSE_CONNECTION
- * @ConnectionId: The connection ID chosen by the LME when the connection
- * was established.
- * @ClosingReason: One of LMS_CLOSE_STATUS
- */
-typedef struct {
- UINT8 MessageType;
- UINT8 ConnectionId;
- UINT8 ClosingReason;
-} LMS_CLOSE_CONNECTION_MESSAGE;
-
-/**
- * LMS_SEND_DATA_MESSAGE - sends data betwen LMS and LME
- *
- * @MessageType: LMS_MESSAGE_TYPE_SEND_DATA
- * @ConnectionId: The connection ID chosen by the LME when the connection
- * was established.
- * @DataLength: Length of data field, in Big Endian.
- * @Data: The data to transfer
- */
-typedef struct {
- UINT8 MessageType;
- UINT8 ConnectionId;
- UINT16 DataLength;
- UINT8 Data[0];
-} LMS_SEND_DATA_MESSAGE;
-
-/**
- * LMS_IP_FQDN_REQUEST_MESSAGE - Requests IP/FQDN data
- *
- * @MessageType: LMS_MESSAGE_TYPE_IP_FQDN_REQUEST
- * @ConnectionId: Must be 0.
- */
-typedef struct {
- UINT8 MessageType;
- UINT8 ConnectionId;
-} LMS_IP_FQDN_REQUEST_MESSAGE;
-
-/**
- * LMS_IP_FQDN_MESSAGE - sends IP/FQDN info
- *
- * @MessageType: LMS_MESSAGE_TYPE_IP_FQDN
- * @ConnectionId: Must be 0.
- * @IPType: One of LMS_IP_ADDRESS_TYPE.
- * @Reserved: Must be 0.
- * @AMTIPAddress: The Intel(R) AMT IP address, in network order (Big Endian).
- * If IPv4, then only the first 4 bytes are used and the rest
- * must be 0.
- * @FQDN: A NUL terminated string specifying the Fully Qualified Domain Name.
- */
-typedef struct {
- UINT8 MessageType;
- UINT8 ConnectionId;
- UINT8 IPType;
- UINT8 Reserved;
- UINT8 AMTIPAddress[16];
- UINT8 FQDN[FQDN_MAX_SIZE];
-} LMS_IP_FQDN_MESSAGE;
-
-/**
- * LMS_PROTO_VERSION_MESSAGE - sends protocol version information
- *
- * @MessageType: LMS_MESSAGE_TYPE_PROTO_VERSION
- * @ConnectionId: Must be 0.
- * @Protocol: Protocol version.
- */
-typedef struct {
- UINT8 MessageType;
- UINT8 ConnectionId;
- UINT8 Protocol;
-} LMS_PROTO_VERSION_MESSAGE;
-
-/**
- * LMS_PROTO_VERSION_REPLY_MESSAGE - sends protocol version information
- *
- * @MessageType: LMS_MESSAGE_TYPE_PROTO_VERSION_REPLY
- * @ConnectionId: Must be 0.
- * @Protocol: Protocol version.
- * @Status: One of LMS_PROTOCOL_STATUS.
- */
-typedef struct {
- UINT8 MessageType;
- UINT8 ConnectionId;
- UINT8 Protocol;
- UINT8 Status;
-} LMS_PROTO_VERSION_REPLY_MESSAGE;
-
-#pragma pack()
-
-#endif
-
diff --git a/usr/src/cmd/lms/LMS_if_constants.h b/usr/src/cmd/lms/LMS_if_constants.h
deleted file mode 100644
index 6cc34c850a..0000000000
--- a/usr/src/cmd/lms/LMS_if_constants.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * 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 _LMS_IF_CONSTANTS_H_
-#define _LMS_IF_CONSTANTS_H_
-
-#define LMS_PROCOL_VERSION 4
-#define LMS_PROCOL_VERSION_COMPAT 2
-
-//
-// 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
-
diff --git a/usr/src/cmd/lms/Makefile b/usr/src/cmd/lms/Makefile
deleted file mode 100644
index 03c52c4b31..0000000000
--- a/usr/src/cmd/lms/Makefile
+++ /dev/null
@@ -1,82 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-
-PROG= lms
-MANIFEST= lms.xml
-
-include ../Makefile.cmd
-
-LMSOBJS= ConfigConnection.o Protocol.o main.o \
- LMEConnection.o ProtocolCompat.o \
- LMEConnectionCompat.o glue.o \
- SyncLib/src/EventUnix.o SyncLib/src/RWLock.o \
- SyncLib/src/SemaphoreUnix.o SyncLib/src/ThreadUnix.o \
- heci/FWULCommand.o heci/HECIUnix.o \
- heci/MNGCommand.o heci/PTHICommand.o \
- tools/ATNetworkTool.o tools/ATVersion.o \
- tools/daemonize.o
-
-ROOTMANIFESTDIR= $(ROOTSVCNETWORK)
-ROOTMETHOD= $(ROOTLIBSVCMETHOD)/svc-lms
-$(ROOTMANIFEST) := FILEMODE= 444
-
-SYNCLIB_SRCDIR=SyncLib/src
-SYNCLIB_HDRDIR=SyncLib/Include
-HECI_DIR=heci
-TOOLS_DIR=tools
-
-CPPFLAGS= -DBSD_COMP -D_REMOTE_SUPPORT \
- -I. -I$(SYNCLIB_HDRDIR) -I$(HECI_DIR) -I$(TOOLS_DIR)
-CCFLAGS += -compat=5 -features=zla
-$(__SUNC)CCNEEDED= $(CCEXTNEEDED)
-LDFLAGS += $(ZIGNORE) -norunpath
-LDLIBS += -lsocket -lnsl
-
-.KEEP_STATE:
-
-all: $(PROG)
-
-$(PROG): $(LMSOBJS)
- $(LINK.cc) -o $@ $(LMSOBJS) $(LDLIBS) -lc
- $(POST_PROCESS)
-
-%.o: %.cpp
- $(COMPILE.cc) $(OUTPUT_OPTION) -o $@ $<
- $(POST_PROCESS_O)
-
-install: all $(ROOTLIBPROG) $(ROOTMANIFEST) $(ROOTMETHOD)
-
-check: $(CHKMANIFEST)
-
-clean:
- $(RM) $(OBJS) $(LMSOBJS)
-
-include ../Makefile.targ
-
-#
-# we're not linting lms. it's all C++.
-#
-
-lint:
diff --git a/usr/src/cmd/lms/PortForwardRequest.h b/usr/src/cmd/lms/PortForwardRequest.h
deleted file mode 100644
index ce95dc1797..0000000000
--- a/usr/src/cmd/lms/PortForwardRequest.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * 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 _PORT_FORWARD_REQUEST_H_
-#define _PORT_FORWARD_REQUEST_H_
-
-#include <string>
-
-#if defined(__sun) || defined(_LINUX)
-#ifndef SOCKET
-#define SOCKET int
-#endif
-#endif
-
-typedef int (*IsConnectionPermittedCallback)(void * const param, SOCKET s);
-
-class PortForwardRequest
-{
-public:
- enum PORT_FORWARD_REQUEST_STATUS {
- NOT_ACTIVE,
- PENDING_REQUEST,
- LISTENING
- };
-
- PortForwardRequest(std::string bindedAddress, int port,
- SOCKET listeningSocket,
- IsConnectionPermittedCallback cb, bool isLocal) :
- _bindedAddress(bindedAddress),
- _port(port),
- _local(isLocal),
- _listeningSocket(listeningSocket),
- _cb(cb),
- _status(NOT_ACTIVE),
- _channelCount(0) {}
-
- const std::string GetBindedAddress() const { return _bindedAddress; }
- const unsigned int GetPort() const { return _port; }
- SOCKET GetListeningSocket() const { return _listeningSocket; }
-
- int IsConnectionPermitted(void *param, SOCKET s)
- {
- if (_cb != NULL) {
- return _cb(param, s);
- } else {
- return -1;
- }
- }
-
- PORT_FORWARD_REQUEST_STATUS GetStatus() { return _status; }
- bool IsLocal() { return _local; }
- bool SetStatus(PORT_FORWARD_REQUEST_STATUS newStatus) { _status = newStatus; return true; }
- unsigned int GetChannelCount() { return _channelCount; }
- unsigned int IncreaseChannelCount() { return ++_channelCount; }
-
- unsigned int DecreaseChannelCount()
- {
- if (_channelCount > 0) {
- --_channelCount;
- }
- return _channelCount;
- }
-
-
-private:
- const std::string _bindedAddress;
- const unsigned int _port;
- const bool _local;
- const SOCKET _listeningSocket;
- const IsConnectionPermittedCallback _cb;
- PORT_FORWARD_REQUEST_STATUS _status;
- unsigned int _channelCount;
-};
-
-#endif
diff --git a/usr/src/cmd/lms/Protocol.cpp b/usr/src/cmd/lms/Protocol.cpp
deleted file mode 100644
index 3b611c9f6e..0000000000
--- a/usr/src/cmd/lms/Protocol.cpp
+++ /dev/null
@@ -1,1815 +0,0 @@
-/*******************************************************************************
- * 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.
- *******************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#if defined(__sun) || defined(_LINUX)
-#include <cerrno>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <net/if.h>
-#include <sys/ioctl.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <netdb.h>
-#include <syslog.h>
-
-#define _stprintf_s snprintf
-#define strnicmp strncasecmp
-#else
-
-#include <winsock2.h>
-#include <iphlpapi.h>
-#include <Ws2tcpip.h>
-#include <tchar.h>
-
-#endif // __sun || _LINUX
-
-#include <fstream>
-#include <algorithm>
-#include "Protocol.h"
-#include "LMS_if.h"
-#include "LMS_if_compat.h"
-#include "Lock.h"
-#include "ATNetworkTool.h"
-
-const LMEProtocolVersionMessage Protocol::MIN_PROT_VERSION(1, 0);
-const LMEProtocolVersionMessage Protocol::MAX_PROT_VERSION(1, 0);
-
-Protocol::Protocol() :
-#if DEBUGLOG
-_lme(true),
-#else
-_lme(false),
-#endif
-_rxSocketBuffer(NULL),
-_rxSocketBufferSize(0)
-#ifdef _REMOTE_SUPPORT
-, _cfg(true)
-#endif
-{
- _serverSignalSocket = INVALID_SOCKET;
- _clientSignalSocket = INVALID_SOCKET;
- _sockets_active = false;
- _handshakingStatus = NOT_INITIATED;
- _pfwdService = NOT_STARTED;
- _AmtProtVersion.MajorVersion = 0;
- _AmtProtVersion.MinorVersion = 0;
-#ifdef _REMOTE_SUPPORT
- _remoteAccessEnabled = false;
-#endif
- memset(_AMTFQDN, 0, sizeof(_AMTFQDN));
- oldProtocolMode = false;
- _deinitReq = false;
- _listenFailReported.clear();
-}
-
-Protocol::~Protocol()
-{
- if (!oldProtocolMode) {
- _lme.Disconnect(APF_DISCONNECT_BY_APPLICATION);
- }
- DeinitFull();
- DestroySockets();
- _listenFailReported.clear();
-}
-
-bool Protocol::Init(EventLogCallback cb, void *param)
-{
- _eventLog = cb;
- _eventLogParam = param;
-
- DeinitFull();
-
- {
- Lock dl(_deinitLock);
- _deinitReq = false;
- }
-
- if (!_lme.Init(_LmeCallback, this)) {
- return false;
- }
-
- oldProtocolMode = (LMS_PROCOL_VERSION != _lme.protocolVer);
-
- {
- Lock l(_versionLock);
-
- if (_handshakingStatus == NOT_INITIATED) {
- if (oldProtocolMode) {
- _lme.CompatProtocolVersion();
- } else {
- _lme.ProtocolVersion(MAX_PROT_VERSION);
- }
- _handshakingStatus = INITIATED;
- }
- }
-
- if (!oldProtocolMode) {
-#ifdef _REMOTE_SUPPORT
- if (!_cfg.Init(true)) {
-#else
- if (!_cfg.IsAMTEnabled(false)) {
-#endif
- _lme.Deinit();
- return false;
- }
- }
-
- long bufSize = _lme.GetHeciBufferSize() - sizeof(APF_CHANNEL_DATA_MESSAGE);
- if (bufSize > 0) {
- _rxSocketBuffer = new char[bufSize];
- _rxSocketBufferSize = bufSize;
- } else {
- DeinitFull();
- return false;
- }
-
-#ifdef _REMOTE_SUPPORT
- if (!oldProtocolMode) {
- _checkRemoteSupport(true);
- }
-#endif
- return true;
-}
-
-Channel *Protocol::_getSockOpenChannel(SOCKET s)
-{
- if (oldProtocolMode) {
- ChannelMap::iterator it = _openChannels.begin();
- for (; it != _openChannels.end(); it++) {
- if (it->second->GetSocket() == s) {
- return it->second;
- }
- }
- } else {
- ChannelMap::iterator it = _openChannels.find(s);
- if (it != _openChannels.end()) {
- return it->second;
- }
- }
- return NULL;
-}
-
-bool Protocol::IsDeInitialized()
-{
- Lock dl(_deinitLock);
- return _deinitReq;
-}
-
-
-bool Protocol::IsInitialized()
-{
- if (IsDeInitialized()) {
- return false;
- }
-
- return _lme.IsInitialized();
-}
-
-void Protocol::Deinit()
-{
- Lock dl(_deinitLock);
- _deinitReq = true;
-
- ATNetworkTool::CloseSocket(_serverSignalSocket);
- ATNetworkTool::CloseSocket(_clientSignalSocket);
-
- {
- Lock l(_channelsLock);
-
- ChannelMap::iterator it = _openChannels.begin();
-
- for (; it != _openChannels.end(); it++) {
- ATNetworkTool::CloseSocket(it->second->GetSocket());
- delete it->second;
- }
-
- _openChannels.clear();
- }
-
- {
- Lock l(_portsLock);
- PortMap::iterator it = _openPorts.begin();
-
- for (; it != _openPorts.end(); it++) {
- if (it->second.size() > 0) {
- ATNetworkTool::CloseSocket(it->second[0]->GetListeningSocket());
-
- PortForwardRequestList::iterator it2 = it->second.begin();
- for (; it2 != it->second.end(); it2++) {
- delete *it2;
- }
- }
- }
- _openPorts.clear();
- }
-
- _lme.Deinit();
-
-#ifdef _REMOTE_SUPPORT
- if (!oldProtocolMode) {
- _cfg.Deinit();
- }
-#endif
-
- {
- Lock vl(_versionLock);
- _handshakingStatus = NOT_INITIATED;
- _pfwdService = NOT_STARTED;
- _AmtProtVersion.MajorVersion = 0;
- _AmtProtVersion.MinorVersion = 0;
- }
-
-}
-
-void Protocol::DeinitFull()
-{
- Deinit();
-
- if (_rxSocketBuffer != NULL) {
- delete []_rxSocketBuffer;
- _rxSocketBuffer = NULL;
- _rxSocketBufferSize = 0;
- }
-
- _serverSignalSocket = INVALID_SOCKET;
- _clientSignalSocket = INVALID_SOCKET;
- _sockets_active = false;
-
-#ifdef _REMOTE_SUPPORT
- _remoteAccessEnabled = false;
-#endif
- memset(_AMTFQDN, 0, sizeof(_AMTFQDN));
-}
-
-bool Protocol::_checkListen(std::string address, in_port_t port, int &socket)
-{
- bool exists = false;
-
- PortMap::iterator it = _openPorts.find(port);
- if (it != _openPorts.end()) {
- if (it->second.size() > 0) {
- socket = it->second[0]->GetListeningSocket();
- PortForwardRequestList::iterator it2 = it->second.begin();
-
- for (; it2 != it->second.end(); it2++) {
- if (((*it2)->GetStatus() != PortForwardRequest::NOT_ACTIVE) &&
- ((*it2)->GetBindedAddress().compare(address) == 0)) {
- exists = true;
- break;
- }
- }
-
- }
- } else {
- PortForwardRequestList portForwardRequestList;
- _openPorts[port] = portForwardRequestList;
- }
-
- return exists;
-}
-
-int Protocol::_listenPort(in_port_t port, int &error)
-{
- return ATNetworkTool::CreateServerSocket(
- port,
- error,
- false, true, PF_INET);
-}
-
-bool Protocol::_localListen(in_port_t port)
-{
- int error;
- int socket = INVALID_SOCKET;
- bool exists = _checkListen("127.0.0.1", port, socket);
-
- int serverSocket = _listenPort(port, error);
- if (serverSocket == INVALID_SOCKET) {
- PRINT("[Compat]LMS Service cannot listen at port %d.\n", (int)port);
- if (exists) {
- //already listening
- }
- return false;
- }
- PRINT("[Compat]Listening at port %d at local interface.\n", (int)port);
-
- PortForwardRequest *portForwardRequest =
- new PortForwardRequest("127.0.0.1", port,
- serverSocket, _isLocalCallback, true);
-
- _openPorts[port].push_back(portForwardRequest);
- portForwardRequest->SetStatus(PortForwardRequest::LISTENING);
-
- return true;
-}
-
-bool Protocol::CreateSockets()
-{
- int error;
- _sockets_active = false;
-
- ATNetworkTool::CloseSocket(_serverSignalSocket);
- _serverSignalSocket = ATNetworkTool::CreateServerSocket((in_port_t)0, error, true);
- if (_serverSignalSocket == INVALID_SOCKET) {
- return false;
- }
-
- ATNetworkTool::CloseSocket(_clientSignalSocket);
- _clientSignalSocket = ATNetworkTool::ConnectToSocket(_serverSignalSocket, error);
- if (_clientSignalSocket == INVALID_SOCKET) {
- ATNetworkTool::CloseSocket(_serverSignalSocket);
- _serverSignalSocket = INVALID_SOCKET;
- return false;
- }
-
- struct sockaddr_storage addr;
- socklen_t addrLen = sizeof(addr);
- SOCKET s_new = accept(_serverSignalSocket, (struct sockaddr *)&addr, &addrLen);
- if (s_new == INVALID_SOCKET) {
- ATNetworkTool::CloseSocket(_serverSignalSocket);
- ATNetworkTool::CloseSocket(_clientSignalSocket);
- _serverSignalSocket = INVALID_SOCKET;
- _clientSignalSocket = INVALID_SOCKET;
- return false;
- }
-
- ATNetworkTool::CloseSocket(_serverSignalSocket);
- _serverSignalSocket = s_new;
-
- if (oldProtocolMode) {
- if (!_localListen(16992)) {
- return false;
- }
- if (!_localListen(16993)) {
- return false;
- }
- }
-
- _sockets_active = true;
- return true;
-}
-
-void Protocol::DestroySockets()
-{
- _sockets_active = false;
-
- if (_serverSignalSocket != INVALID_SOCKET) {
- ATNetworkTool::CloseSocket(_serverSignalSocket);
- _serverSignalSocket = INVALID_SOCKET;
- }
-}
-
-bool Protocol::_acceptConnection(SOCKET s, unsigned int port)
-{
- ATAddress addr;
- int error = 0;
- char buf[NI_MAXHOST];
-
- if (!IsInitialized()) {
- return false;
- }
-
- SOCKET s_new = ATNetworkTool::Accept(s, addr, error);
- if (s_new == INVALID_SOCKET) {
-#if DEBUGLOG
- char *msg = _getErrMsg(error);
- PRINT("Error accepting new connection (%d): %s\n", error, msg);
-#endif
- return false;
- }
-
- const char *addrStr = addr.inNtoP(buf, NI_MAXHOST);
- if (addrStr == NULL) {
- PRINT("Error: ntop failed for new connection\n");
- ATNetworkTool::CloseSocket(s_new);
- return false;
- }
-
- PortForwardRequest *portForwardRequest = NULL;
-
- //_portsLock is already aquired by the calling function: Select().
- PortMap::iterator it = _openPorts.find(port);
- if (it != _openPorts.end()) {
- PortForwardRequestList::iterator it2 = it->second.begin();
-
- for (; it2 != it->second.end(); it2++) {
- if (((*it2)->GetStatus() == PortForwardRequest::LISTENING) &&
- (1 == (*it2)->IsConnectionPermitted(this, s_new))) {
- portForwardRequest = *it2;
- break;
- }
- }
-
- }
-
- if (portForwardRequest == NULL) {
- PRINT("Error: new connection is denied (addr %s)\n", addrStr);
- ATNetworkTool::CloseSocket(s_new);
- return false;
- }
-
- if (oldProtocolMode) {
- unsigned int connId;
- bool oret = _lme.CompatOpenConnection(port, addr, connId);
- if (!oret) {
- PRINT("[Compat]Error: failed to open new LME MEI connection\n");
- ATNetworkTool::CloseSocket(s_new);
- return false;
- }
- PRINT("[Compat]Send open connection to LME. Sender %d.\n", (int)s_new);
-
- Channel *c = new Channel(portForwardRequest, s_new);
- c->SetStatus(Channel::OPEN);
- c->SetRecipientChannel(connId);
- c->AddBytesTxWindow(1024);
-
- Lock l(_channelsLock);
- _openChannels[connId] = c;
- c->GetPortForwardRequest()->IncreaseChannelCount();
- } else {
- Channel *c = new Channel(portForwardRequest, s_new);
- c->SetStatus(Channel::NOT_OPENED);
-
- Lock l(_channelsLock);
- _openChannels[s_new] = c;
- c->GetPortForwardRequest()->IncreaseChannelCount();
-
- _lme.ChannelOpenForwardedRequest((UINT32)s_new,
- port,
- ((portForwardRequest->IsLocal()) ? "127.0.0.1" : addrStr),
- addr.inPort());
- PRINT("Send channel open request to LME. Sender %d.\n", (int)s_new);
- }
-
- return true;
-}
-
-int Protocol::Select()
-{
- fd_set rset;
- struct timeval tv;
- int res;
- int fdCount = 0;
- int fdMin = -1;
-
- tv.tv_sec = 1;
- tv.tv_usec = 0;
-
- FD_ZERO(&rset);
-
- FD_SET(_serverSignalSocket, &rset);
- if ((int)_serverSignalSocket > fdCount) {
- fdCount = (int)_serverSignalSocket;
- }
-
- {
- Lock l(_portsLock);
- PortMap::iterator it = _openPorts.begin();
-
- for (; it != _openPorts.end(); it++) {
- if (it->second.size() > 0) {
- SOCKET serverSocket = it->second[0]->GetListeningSocket();
- FD_SET(serverSocket, &rset);
- if ((int)serverSocket > fdCount) {
- fdCount = (int)serverSocket;
- }
- }
- }
- }
-
- {
- Lock l(_channelsLock);
-
- ChannelMap::iterator it = _openChannels.begin();
-
- for (; it != _openChannels.end(); it++) {
- if ((it->second->GetStatus() == Channel::OPEN) &&
- (it->second->GetTxWindow() > 0)) {
- SOCKET socket = it->second->GetSocket();
- FD_SET(socket, &rset);
- if ((int)socket > fdCount) {
- fdCount = (int)socket;
- }
- if ((fdMin == -1) || ((int)socket < fdMin)) {
- fdMin = (int)socket;
- }
- }
- }
- }
-
- fdCount++;
- res = select(fdCount, &rset, NULL, NULL, &tv);
- if (res == -1) {
-#if DEBUGLOG
-#if defined(__sun) || defined(_LINUX)
- int err = errno;
-#else
- int err = GetLastError();
-#endif // __sun || _LINUX
-
- char *msg = _getErrMsg(err);
- PRINT("Select error (%d): %s\n", err, msg);
-#endif
- return -1;
- }
-
- if (res == 0) {
- return 0;
- }
-
- if (!IsInitialized()) {
- return 0;
- }
-
- if (FD_ISSET(_serverSignalSocket, &rset)) { // Received a 'signal'
- char c = 0;
- res = recv(_serverSignalSocket, &c, 1, 0);
- FD_CLR(_serverSignalSocket, &rset);
- res--;
- }
-
- {
- Lock l(_portsLock);
- PortMap::iterator it = _openPorts.begin();
-
- for (; it != _openPorts.end(); it++) {
- if (it->second.size() > 0) {
- SOCKET serverSocket = it->second[0]->GetListeningSocket();
- if (FD_ISSET(serverSocket, &rset)) {
- // connection request
- PRINT("Connection requested on port %d\n", it->first);
- _acceptConnection(serverSocket, it->first);
- FD_CLR(serverSocket, &rset);
- res--;
- }
- }
- }
- }
-
- int i;
- for (i = fdMin/*0*/; (res > 0) && (i < fdCount); i++) {
- if (FD_ISSET(i, &rset)) {
- _rxFromSocket(i);
- res--;
- }
- }
-
- return 1;
-}
-
-int Protocol::_rxFromSocket(SOCKET s)
-{
- Channel *c = NULL;
-
- if (!IsInitialized()) {
- return 0;
- }
-
- {
- Lock l(_channelsLock);
-
- Channel *cx = _getSockOpenChannel(s);
-
- if (cx == NULL) {
- // Data received from a socket that is not in the map.
- // Since we only select on our sockets, this means it was
- // in the map, but was removed, probably because we received
- // an End Connection message from the HECI.
- return 0;
- }
-
- c = new Channel(*cx);
- }
-
- int res = 0;
-
- int len = std::min(c->GetTxWindow(), _rxSocketBufferSize);
- res = recv(s, _rxSocketBuffer, len, 0);
- if (res > 0) {
- // send data to LME
- PRINT("Received %d bytes from socket %d. Sending to LME\n", res, (int)s);
- if (oldProtocolMode) {
- _lme.CompatSendMessage((UINT8)c->GetRecipientChannel(), res, (unsigned char *)_rxSocketBuffer);
- } else {
- _lme.ChannelData(c->GetRecipientChannel(), res, (unsigned char *)_rxSocketBuffer);
- }
- goto out;
- } else if (res == 0) {
- // connection closed
- PRINT("Received 0 bytes from socket %d.\n", (int)s);
- goto out;
- } else {
-#if DEBUGLOG
-#if defined(__sun) || defined(_LINUX)
- int err = errno;
-#else
- int err = GetLastError();
-#endif // __sun || _LINUX
-
- char *msg = _getErrMsg(err);
- PRINT("Receive error on socket %d (%d): %s\n", (int)s, err, msg);
-#endif
-#ifdef __sun
- ATNetworkTool::CloseSocket(s);
-#endif
- goto out;
- }
-
-out:
- {
- Lock l(_channelsLock);
-
- Channel *cx = _getSockOpenChannel(s);
-
- if (cx == NULL) {
- // Data received from a socket that is not in the map.
- // Since we only select on our sockets, this means it was
- // in the map, but was removed, probably because we received
- // an End Connection message from the HECI.
- delete c;
- return 0;
- }
- if (res > 0) {
- if (!oldProtocolMode) {
- cx->AddBytesTxWindow(-res);
- }
- }
- else {
- cx->SetStatus(Channel::WAITING_CLOSE);
- if (oldProtocolMode) {
- if (res == 0) {
- _closeMChannel(cx);
-
- ChannelMap::iterator it = _openChannels.begin();
- for (; it != _openChannels.end(); it++) {
- if (it->second == cx) {
- break;
- }
- }
- if (it != _openChannels.end()) {
- _openChannels.erase(it);
- }
- }
- _lme.CompatCloseConnection(c->GetRecipientChannel(),
- ((res == 0) ? LMS_CLOSE_STATUS_CLIENT :
- LMS_CLOSE_STATUS_SOCKET));
- } else {
- _lme.ChannelClose(c->GetRecipientChannel());
- }
- }
- }
- delete c;
-
- return 0;
-}
-
-void Protocol::_signalSelect()
-{
- int senderr = 0;
-
- _send(_clientSignalSocket, "s", 1, senderr); //Enforce a new execution of Select()
-}
-
-void Protocol::_closePortForwardRequest(PortForwardRequest *p)
-{
- PortMap::iterator it = _openPorts.find(p->GetPort());
- if (it == _openPorts.end()) {
- return;
- }
-
- bool found = false;
- PortForwardRequestList::iterator it2 = it->second.begin();
- for (; it2 != it->second.end(); it2++) {
- if ((*it2) == p) {
- found = true;
- break;
- }
- }
-
- if ((*it2)->GetStatus() == PortForwardRequest::NOT_ACTIVE) {
-
- SOCKET serverSocket = (*it2)->GetListeningSocket();
- delete (*it2);
- it->second.erase(it2);
-
- if (it->second.size() == 0) {
- int res = ATNetworkTool::CloseSocket(serverSocket);
- if (res != 0) {
- int err;
-
-#if defined(__sun) || defined(_LINUX)
- err = errno;
-#else
- err = WSAGetLastError()
-#endif
- PRINT("Error %d in closing server socket at port %d.\n", err, p->GetPort());
- }
- _openPorts.erase(it);
- }
- }
-}
-
-bool Protocol::_checkProtocolFlow(LMEMessage *message)
-{
- switch (message->MessageType) {
- case APF_SERVICE_REQUEST:
- case APF_USERAUTH_REQUEST:
- {
- Lock l(_versionLock);
- if (_handshakingStatus != AGREED) {
- _lme.Disconnect(APF_DISCONNECT_PROTOCOL_ERROR);
- Deinit();
- return false;
- }
- return true;
- }
- break;
-
- case APF_GLOBAL_REQUEST:
- case APF_CHANNEL_OPEN:
- case APF_CHANNEL_OPEN_CONFIRMATION:
- case APF_CHANNEL_OPEN_FAILURE:
- case APF_CHANNEL_CLOSE:
- case APF_CHANNEL_DATA:
- case APF_CHANNEL_WINDOW_ADJUST:
- {
- Lock l(_versionLock);
- if ((_handshakingStatus != AGREED) || (_pfwdService != STARTED)) {
- _lme.Disconnect(APF_DISCONNECT_PROTOCOL_ERROR);
- Deinit();
- return false;
- }
- return true;
- }
- break;
-
- case APF_DISCONNECT:
- case APF_PROTOCOLVERSION:
- return true;
- break;
-
- default:
- {
- _lme.Disconnect(APF_DISCONNECT_PROTOCOL_ERROR);
- Deinit();
- return false;
- }
- break;
- }
-
- return false;
-}
-
-unsigned int Protocol::_getMinMessageLen(LMEMessage *message)
-{
- switch (message->MessageType) {
- case APF_SERVICE_REQUEST:
- return sizeof(LMEServiceRequestMessage);
- break;
- case APF_USERAUTH_REQUEST:
- return sizeof(LMEUserAuthRequestMessage);
- break;
- case APF_GLOBAL_REQUEST:
- return sizeof(LMEGlobalRequestMessage);
- break;
- case APF_CHANNEL_OPEN:
- return sizeof(LMEChannelOpenRequestMessage);
- break;
- case APF_CHANNEL_OPEN_CONFIRMATION:
- return sizeof(LMEChannelOpenReplaySuccessMessage);
- break;
- case APF_CHANNEL_OPEN_FAILURE:
- return sizeof(LMEChannelOpenReplayFailureMessage);
- break;
- case APF_CHANNEL_CLOSE:
- return sizeof(LMEChannelCloseMessage);
- break;
- case APF_CHANNEL_DATA:
- return sizeof(LMEChannelDataMessage);
- break;
- case APF_CHANNEL_WINDOW_ADJUST:
- return sizeof(LMEChannelWindowAdjustMessage);
- break;
- case APF_DISCONNECT:
- return sizeof(LMEDisconnectMessage);
- break;
- case APF_PROTOCOLVERSION:
- return sizeof(LMEProtocolVersionMessage);
- break;
- default:
- return 0;
- }
-
- return 0;
-}
-
-bool Protocol::_checkMessageAndProtocol(LMEMessage *message, unsigned int len)
-{
- if (len < sizeof(LMEMessage)) {
- _lme.Disconnect(APF_DISCONNECT_PROTOCOL_ERROR);
- Deinit();
- return false;
- }
-
- if (!_checkProtocolFlow(message)) {
- return false;
- }
- if (len < _getMinMessageLen(message)) {
- _lme.Disconnect(APF_DISCONNECT_PROTOCOL_ERROR);
- Deinit();
- return false;
- }
- return true;
-}
-
-void Protocol::_LmeCallback(void *param, void *buffer, unsigned int len, int *status)
-{
- Protocol *prot = (Protocol *)param;
-
- if (prot->oldProtocolMode) {
- prot->_LmeReceiveCompat((char *)buffer, len, status);
- } else {
- prot->_LmeReceive(buffer, len, status);
- }
-}
-
-void Protocol::_LmeReceive(void *buffer, unsigned int len, int *status)
-{
- LMEMessage *message = (LMEMessage *)buffer;
- *status = 0;
-
- if (!_checkMessageAndProtocol(message, len)) {
- return;
- }
-
- switch (message->MessageType) {
- case APF_DISCONNECT:
- {
- PRINT("LME requested to disconnect with reason code 0x%08x\n",
- ((LMEDisconnectMessage *)message)->ReasonCode);
- Deinit();
- return;
- }
- break;
-
- case APF_SERVICE_REQUEST:
- {
- LMEServiceRequestMessage *sRMsg =
- (LMEServiceRequestMessage *)message;
-
- if ((sRMsg->ServiceName.compare(APF_SERVICE_AUTH) == 0) ||
- (sRMsg->ServiceName.compare(APF_SERVICE_PFWD) == 0)) {
-
- _lme.ServiceAccept(sRMsg->ServiceName);
- PRINT("Accepting service: %s\n",
- sRMsg->ServiceName.c_str());
- if (sRMsg->ServiceName.compare(APF_SERVICE_PFWD) == 0) {
- Lock l(_versionLock);
- _pfwdService = STARTED;
- }
- } else {
- PRINT("Requesting to disconnect from LME with reason code 0x%08x\n",
- APF_DISCONNECT_SERVICE_NOT_AVAILABLE);
- _lme.Disconnect(APF_DISCONNECT_SERVICE_NOT_AVAILABLE);
- Deinit();
- return;
- }
- }
- break;
-
- case APF_USERAUTH_REQUEST:
- {
- PRINT("Sending Userauth success message\n");
- _lme.UserAuthSuccess();
- }
- break;
-
- case APF_PROTOCOLVERSION:
- _apfProtocolVersion((LMEProtocolVersionMessage *)message);
- break;
-
- case APF_GLOBAL_REQUEST:
- _apfGlobalRequest((LMEGlobalRequestMessage *)message, len, status);
- break;
-
- case APF_CHANNEL_OPEN:
- _apfChannelOpen((LMEChannelOpenRequestMessage *)message, status);
- break;
-
- case APF_CHANNEL_OPEN_CONFIRMATION:
- {
- LMEChannelOpenReplaySuccessMessage *chOpenSuccMsg =
- (LMEChannelOpenReplaySuccessMessage *)message;
-
- Lock l(_channelsLock);
-
- ChannelMap::iterator it = _openChannels.find(chOpenSuccMsg->RecipientChannel);
- if (it != _openChannels.end()) {
- it->second->SetStatus(Channel::OPEN);
- it->second->SetRecipientChannel(chOpenSuccMsg->SenderChannel);
- it->second->AddBytesTxWindow(chOpenSuccMsg->InitialWindow);
- }
-
- _signalSelect();
- }
- break;
-
- case APF_CHANNEL_OPEN_FAILURE:
- {
- PortForwardRequest *clPFwdReq =
- _apfChannelOFail((LMEChannelOpenReplayFailureMessage *)message);
- if (clPFwdReq != NULL) {
- Lock l(_portsLock);
- _closePortForwardRequest(clPFwdReq);
- }
- }
- break;
-
- case APF_CHANNEL_CLOSE:
- {
- PortForwardRequest *clPFwdReq =
- _apfChannelClose((LMEChannelCloseMessage *)message);
- if (clPFwdReq != NULL) {
- Lock l(_portsLock);
- _closePortForwardRequest(clPFwdReq);
- }
- }
- break;
-
- case APF_CHANNEL_DATA:
- {
- PortForwardRequest *clPFwdReq =
- _apfChannelData((LMEChannelDataMessage *)message, status);
- if (clPFwdReq != NULL) {
- Lock l(_portsLock);
- _closePortForwardRequest(clPFwdReq);
- }
- }
- break;
-
- case APF_CHANNEL_WINDOW_ADJUST:
- {
- LMEChannelWindowAdjustMessage *channelWindowMessage = (LMEChannelWindowAdjustMessage *)message;
-
- Lock l(_channelsLock);
-
- ChannelMap::iterator it = _openChannels.find(channelWindowMessage->RecipientChannel);
- if (it != _openChannels.end()) {
- it->second->AddBytesTxWindow(channelWindowMessage->BytesToAdd);
- _signalSelect();
- }
- }
- break;
-
- default:
- _lme.Disconnect(APF_DISCONNECT_PROTOCOL_ERROR);
- Deinit();
- break;
- }
-}
-
-unsigned int Protocol::_getMinGlobalMsgLen(LMEGlobalRequestMessage *globalMessage)
-{
- switch (globalMessage->RequestType) {
- case LMEGlobalRequestMessage::TCP_FORWARD_REQUEST:
- return sizeof(LMETcpForwardRequestMessage);
- break;
- case LMEGlobalRequestMessage::TCP_FORWARD_CANCEL_REQUEST:
- return sizeof(LMETcpForwardCancelRequestMessage);
- break;
- case LMEGlobalRequestMessage::UDP_SEND_TO:
- return sizeof(LMEUdpSendToMessage);
- break;
- default:
- return 0;
- }
- return 0;
-}
-
-void Protocol::_apfGlobalRequest(LMEGlobalRequestMessage *globalMessage,
- unsigned int len, int *status)
-{
- PRINT("Global Request type 0x%02x\n", globalMessage->RequestType);
-
- if (len < _getMinGlobalMsgLen(globalMessage)) {
- _lme.Disconnect(APF_DISCONNECT_PROTOCOL_ERROR);
- Deinit();
- return;
- }
-
- switch (globalMessage->RequestType) {
- case LMEGlobalRequestMessage::TCP_FORWARD_REQUEST:
- _apfTcpForwardRequest((LMETcpForwardRequestMessage *)globalMessage, status);
- break;
-
- case LMEGlobalRequestMessage::TCP_FORWARD_CANCEL_REQUEST:
- _apfTcpForwardCancel((LMETcpForwardCancelRequestMessage *)globalMessage);
- break;
-
- case LMEGlobalRequestMessage::UDP_SEND_TO:
- _aptSendUdp((LMEUdpSendToMessage *)globalMessage, status);
- break;
-
- default:
- _lme.Disconnect(APF_DISCONNECT_PROTOCOL_ERROR);
- Deinit();
- break;
- }
-}
-
-void Protocol::_apfTcpForwardRequest(LMETcpForwardRequestMessage *tcpFwdReqMsg, int *status)
-{
- IsConnectionPermittedCallback cb = NULL;
- bool failure = false;
-
-#ifdef _REMOTE_SUPPORT
- if (tcpFwdReqMsg->Address.compare("0.0.0.0") == 0) {
- cb = _isRemoteCallback;
- }
- else
-#endif
- {
- cb = _isLocalCallback;
- }
-
- {
- Lock l(_portsLock);
- SOCKET serverSocket = INVALID_SOCKET;
- listenPortSet::iterator lpi;
-
- if (_checkListen(tcpFwdReqMsg->Address, tcpFwdReqMsg->Port, serverSocket)) {
- *status = 1;
- // Log in Event Log
- TCHAR message[1024];
- _stprintf_s(message, 1024,
- TEXT("LMS Service already accepted a request at %s:%d\n"),
- tcpFwdReqMsg->Address.c_str(),
- tcpFwdReqMsg->Port);
- _eventLog(_eventLogParam, message, EVENTLOG_ERROR_TYPE);
- PRINT(message);
- // Send Failure replay to LME
- _lme.TcpForwardReplyFailure();
- return;
- }
-
- lpi = _listenFailReported.find(tcpFwdReqMsg->Port);
-
- if (serverSocket == INVALID_SOCKET) {
- int error;
- serverSocket = _listenPort(tcpFwdReqMsg->Port, error);
- if (serverSocket == INVALID_SOCKET) {
- *status = 1;
- // Log in Event Log
- TCHAR message[1024];
- _stprintf_s(message, 1024,
- TEXT("LMS Service cannot listen at port %d.\n"),
- tcpFwdReqMsg->Port);
- if (lpi == _listenFailReported.end()) {
- _eventLog(_eventLogParam, message, EVENTLOG_ERROR_TYPE);
- _listenFailReported.insert(tcpFwdReqMsg->Port);
- }
- PRINT(message);
- // Send Failure replay to LME
- _lme.TcpForwardReplyFailure();
- failure = true;
- }
- }
-
- if (failure != true) {
- PRINT("Listening at port %d at %s interface.\n",
- tcpFwdReqMsg->Port,
- ((cb == _isLocalCallback) ? "local" : "remote"));
-
- PortForwardRequest *portForwardRequest =
- new PortForwardRequest(tcpFwdReqMsg->Address,
- tcpFwdReqMsg->Port,
- serverSocket, cb, (cb == _isLocalCallback));
-
- _openPorts[tcpFwdReqMsg->Port].push_back(portForwardRequest);
-
- // Send Success replay to LME
- _lme.TcpForwardReplySuccess(tcpFwdReqMsg->Port);
-
- portForwardRequest->SetStatus(
- (cb == _isLocalCallback) ?
- PortForwardRequest::LISTENING :
- PortForwardRequest::PENDING_REQUEST);
- if (lpi != _listenFailReported.end()) {
- _listenFailReported.erase(lpi);
- }
-
- _signalSelect();
- }
- }
-
- if (failure == true) {
- _lme.Disconnect(APF_DISCONNECT_PROTOCOL_ERROR);
- Deinit();
- return;
- }
-
- if (cb == _isLocalCallback) {
- if (_listenFailReported.empty()) {
- _updateIPFQDN(tcpFwdReqMsg->Address.c_str());
- }
- }
-#ifdef _REMOTE_SUPPORT
- else {
- _checkRemoteSupport(true);
- }
-#endif
-}
-
-void Protocol::_apfTcpForwardCancel(LMETcpForwardCancelRequestMessage *tcpFwdCnclMsg)
-{
- bool found = false;
- Lock l(_portsLock);
-
- PortMap::iterator it = _openPorts.find(tcpFwdCnclMsg->Port);
- if (it == _openPorts.end()) {
- PRINT("Previous request on address %s and port %d doesn't exist.\n",
- tcpFwdCnclMsg->Address.c_str(), tcpFwdCnclMsg->Port);
- _lme.TcpForwardCancelReplyFailure();
- return;
- }
-
- PortForwardRequestList::iterator it2 = it->second.begin();
- for (; it2 != it->second.end(); it2++) {
- if (((*it2)->GetBindedAddress().compare(tcpFwdCnclMsg->Address) == 0) &&
- //((*it2)->GetPort() == tcpFwdCnclMsg->Port)) {
- ((*it2)->GetStatus() != PortForwardRequest::NOT_ACTIVE)) {
- found = true;
- break;
- }
- }
-
- if (found) {
- (*it2)->SetStatus(PortForwardRequest::NOT_ACTIVE);
- if ((*it2)->GetChannelCount() == 0) {
- _closePortForwardRequest(*it2);
- }
- _lme.TcpForwardCancelReplySuccess();
- } else {
- PRINT("Previous request on address %s and port %d doesn't exist.\n",
- tcpFwdCnclMsg->Address.c_str(), tcpFwdCnclMsg->Port);
- _lme.TcpForwardCancelReplyFailure();
- }
-}
-
-void Protocol::_aptSendUdp(LMEUdpSendToMessage *udpSendToMessage, int *status)
-{
- int error = 0;
-
- SOCKET s = ATNetworkTool::Connect(udpSendToMessage->Address.c_str(),
- udpSendToMessage->Port, error,
- PF_INET, SOCK_DGRAM);
- if (s == INVALID_SOCKET) {
- *status = 1;
- PRINT("Unable to send UDP data.\n");
- return;
- }
-
- int count = _send(s, (char *)udpSendToMessage->Data, udpSendToMessage->DataLength, error);
- PRINT("Sent UDP data: %d bytes of %d.\n", count, udpSendToMessage->DataLength);
-
- ATNetworkTool::CloseSocket(s);
-}
-
-void Protocol::_apfProtocolVersion(LMEProtocolVersionMessage *verMsg)
-{
- Lock l(_versionLock);
-
- switch (_handshakingStatus) {
- case AGREED:
- case NOT_INITIATED:
- _lme.ProtocolVersion(MAX_PROT_VERSION);
- case INITIATED:
- if (*verMsg < MIN_PROT_VERSION) {
- PRINT("Version %d.%d is not supported.\n",
- verMsg->MajorVersion, verMsg->MinorVersion);
- _lme.Disconnect(APF_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED);
- Deinit();
- return;
- }
- if (*verMsg > MAX_PROT_VERSION) {
- _AmtProtVersion = MAX_PROT_VERSION;
- } else {
- _AmtProtVersion = (*verMsg);
- }
- _handshakingStatus = AGREED;
- break;
-
- default:
- _lme.Disconnect(APF_DISCONNECT_BY_APPLICATION);
- Deinit();
- break;
- }
-}
-
-void Protocol::_apfChannelOpen(LMEChannelOpenRequestMessage *chOpenMsg, int *status)
-{
- int error = 0;
-
- PRINT("Got channel request from AMT. "
- " Recipient channel %d for address %s, port %d.\n",
- chOpenMsg->SenderChannel,
- chOpenMsg->Address.c_str(), chOpenMsg->Port);
-
- SOCKET s = ATNetworkTool::Connect(chOpenMsg->Address.c_str(),
- chOpenMsg->Port, error, PF_INET);
- if (s == INVALID_SOCKET) {
- *status = 1;
- PRINT("Unable to open direct channel to address %s.\n",
- chOpenMsg->Address.c_str());
- return;
- }
-
- ATNetworkTool::SetNonBlocking(s);
-
- Channel *c = new Channel(NULL, s);
- c->AddBytesTxWindow(chOpenMsg->InitialWindow);
- c->SetRecipientChannel(chOpenMsg->SenderChannel);
- c->SetStatus(Channel::OPEN);
-
- {
- Lock l(_channelsLock);
- _openChannels[c->GetSenderChannel()] = c;
- _lme.ChannelOpenReplaySuccess(c->GetRecipientChannel(), c->GetSenderChannel());
- }
-
- _signalSelect();
-}
-
-PortForwardRequest *Protocol::_closeMChannel(Channel *c)
-{
- PortForwardRequest *clPFwdReq = NULL;
-
- ATNetworkTool::CloseSocket(c->GetSocket());
- PortForwardRequest *p = c->GetPortForwardRequest();
- if ((p != NULL) && (p->DecreaseChannelCount() == 0)) {
- clPFwdReq = p;
- }
- delete c;
-
- return clPFwdReq;
-}
-
-PortForwardRequest *Protocol::_apfChannelOFail(LMEChannelOpenReplayFailureMessage *chFailMsg)
-{
- PortForwardRequest *clPFwdReq = NULL;
-
- Lock l(_channelsLock);
-
- ChannelMap::iterator it = _openChannels.find(chFailMsg->RecipientChannel);
- if (it != _openChannels.end()) {
- clPFwdReq = _closeMChannel(it->second);
- _openChannels.erase(it);
- PRINT("Channel open request was refused. Reason code: 0x%02x reason.\n",
- chFailMsg->ReasonCode);
- }
-
- return clPFwdReq;
-}
-
-PortForwardRequest *Protocol::_apfChannelClose(LMEChannelCloseMessage *chClMsg)
-{
- PortForwardRequest *clPFwdReq = NULL;
-
- Lock l(_channelsLock);
-
- ChannelMap::iterator it = _openChannels.find(chClMsg->RecipientChannel);
- if (it != _openChannels.end()) {
- Channel *c = it->second;
- switch(c->GetStatus()) {
- case Channel::OPEN:
- c->SetStatus(Channel::CLOSED);
- _lme.ChannelClose(c->GetRecipientChannel());
- PRINT("Channel %d was closed by AMT.\n", c->GetSenderChannel());
- break;
-
- case Channel::WAITING_CLOSE:
- PRINT("Received reply by AMT on closing channel %d.\n", c->GetSenderChannel());
- break;
-
- case Channel::CLOSED:
- case Channel::NOT_OPENED:
- break;
- }
-
- clPFwdReq = _closeMChannel(c);
- _openChannels.erase(it);
- }
-
- return clPFwdReq;
-}
-
-PortForwardRequest *Protocol::_apfChannelData(LMEChannelDataMessage *chDMsg, int *status)
-{
- PortForwardRequest *clPFwdReq = NULL;
-
- do {
- Lock l(_channelsLock);
-
- ChannelMap::iterator it = _openChannels.find(chDMsg->RecipientChannel);
- if (it == _openChannels.end()) {
- break;
- }
-
- if ((it->second->GetStatus() != Channel::OPEN) &&
- (it->second->GetStatus() != Channel::WAITING_CLOSE)) {
- break;
- }
-
- if (it->second->GetRxWindow() < chDMsg->DataLength) {
- break;
- }
-
- int senderr = 0;
- int count = _send(it->second->GetSocket(), (char *)chDMsg->Data,
- chDMsg->DataLength, senderr);
- PRINT("Sent %d bytes of %d from AMT to channel %d with socket %d.\n",
- count, chDMsg->DataLength, chDMsg->RecipientChannel,
- it->second->GetSocket());
-
- if ((count == -1) && (senderr == EPIPE)) {
- *status = 1;
- clPFwdReq = _closeMChannel(it->second);
- _openChannels.erase(it);
- PRINT("Channel send data request was refused. Broken pipe.\n");
- break;
- }
- //it->second->AddBytesRxWindow(-count);
- //if (it->second->GetRxWindow() < Channel::LMS_WINDOW_SIZE / 2) {
- _lme.ChannelWindowAdjust(it->second->GetRecipientChannel(), chDMsg->DataLength);
- //Channel::LMS_WINDOW_SIZE - it->second->GetRxWindow());
- //}
- } while (0);
-
- return clPFwdReq;
-}
-
-#ifdef _REMOTE_SUPPORT
-
-bool Protocol::_compareDNSSuffix(std::string AMTDNSSuffix, std::string suffix)
-{
- if (AMTDNSSuffix.size() > suffix.size()) {
- return false;
- }
-
- if ((AMTDNSSuffix.size() < suffix.size()) &&
- (suffix[suffix.size()-AMTDNSSuffix.size()-1] != '.')) {
- return false;
- }
-
- if (strnicmp(suffix.c_str() + suffix.size()-AMTDNSSuffix.size(),
- AMTDNSSuffix.c_str(),
- AMTDNSSuffix.size()) == 0) {
- return true;
- }
-
- return false;
-}
-
-bool Protocol::_checkRemoteSupport(bool requestDnsFromAmt)
-{
- if (requestDnsFromAmt) {
- std::list<std::string> amtDnsSuffixes;
-
- AMT_STATUS status = _cfg.RequestEntDNSSuffixList(amtDnsSuffixes);
-
- if (status != AMT_STATUS_SUCCESS) {
- PRINT("Remote access is disabled - AMT is not configured [%x]\n", status);
- return false;
- }
-
- _AMTDNSLock.acquire();
- _AMTDNSSuffixes.clear();
- _AMTDNSSuffixes.assign(amtDnsSuffixes.begin(), amtDnsSuffixes.end());
- _AMTDNSLock.release();
-
- amtDnsSuffixes.clear();
- }
-
- ATDomainMap domains;
- int error = 0;
- ATNetworkTool::GetLocalNetDomains(domains, error, PF_INET);
- _updateEnterpriseAccessStatus(domains);
-
- return true;
-}
-
-void Protocol::_updateEnterpriseAccessStatus(const ATDomainMap &localDNSSuffixes)
-{
- _AMTDNSLock.acquire();
-
- std::list<std::string>::iterator remIt;
- std::list<std::string>::iterator startIt = _AMTDNSSuffixes.begin();
- std::list<std::string>::iterator endIt = _AMTDNSSuffixes.end();
- ATDomainMap::const_iterator locIt;
-
- bool access = false;
- ATAddress localIp;
-
- for (locIt = localDNSSuffixes.begin(); locIt != localDNSSuffixes.end(); locIt++) {
- remIt = find_if(startIt, endIt, bind2nd(ptr_fun(_compareDNSSuffix), locIt->second));
- if (remIt != _AMTDNSSuffixes.end()) {
- access = true;
- localIp = locIt->first;
- break;
- }
- }
-
- _AMTDNSLock.release();
-
- bool sendEntAccessMessage = true;
- if (access) {
- Lock l(_portsLock);
- for (PortMap::iterator it = _openPorts.begin(); it != _openPorts.end(); it++) {
- for (PortForwardRequestList::iterator it2 = it->second.begin();
- it2 != it->second.end(); it2++) {
-
- if ((*it2)->GetStatus() == PortForwardRequest::PENDING_REQUEST) {
- (*it2)->SetStatus(PortForwardRequest::LISTENING);
- sendEntAccessMessage = false;
- break; // Assuming that there is a such request one per port
- }
- }
- }
-
- _signalSelect();
- }
-
- if (sendEntAccessMessage == false) {
- return;
- }
-
- AMT_STATUS status = _cfg.SendEnterpriseAccess(access, localIp);
-
- Lock l(_remoteAccessLock);
- _remoteAccessEnabled = (status == AMT_STATUS_SUCCESS);
- switch (status) {
- case AMT_STATUS_SUCCESS:
- PRINT("Remote access is allowed.\n");
- break;
- case AMT_STATUS_REMOTE_ACCESS_NOT_GRANTED:
- PRINT("Remote access is denied because AMT is directly connected "
- "to enterprise network.\n");
- break;
- case AMT_STATUS_REMOTE_ACCESS_HOST_VPN_IS_DISABLED:
- PRINT("Remote access is disabled.\n");
- break;
- default:
- PRINT("Remote access is disabled.\n");
- break;
- }
-
- //if (_remoteAccessEnabled) {
- // Lock l(_portsLock);
- // for (PortMap::iterator it = _openPorts.begin(); it != _openPorts.end(); it++) {
- // for (PortForwardRequestList::iterator it2 = it->second.begin();
- // it2 != it->second.end(); it2++) {
-
- // if ((*it2)->GetStatus() == PortForwardRequest::PENDING_REQUEST) {
- // (*it2)->SetStatus(PortForwardRequest::LISTENING);
- // break; // Assuming that there is a such request one per port
- // }
- // }
- // }
-
- // _signalSelect();
- //}
-
-}
-
-#endif
-
-int Protocol::_isLocalCallback(void *const param, SOCKET s)
-{
- int error = 0;
-
- return ((1 == ATNetworkTool::IsSockPeerLocal(s, error, PF_INET)) ? 1 : -1);
-}
-
-#ifdef _REMOTE_SUPPORT
-
-int Protocol::_isRemoteCallback(void *const param, SOCKET s)
-{
- Protocol *prot = (Protocol *)param;
-
- return prot->_isRemote(s);
-}
-
-int Protocol::_isRemote(SOCKET s) const
-{
- int result = 0;
- int error = 0;
- int ret;
- std::string dnsSuffix;
-
- ret = ATNetworkTool::GetSockDomain(s, dnsSuffix, error);
- if (ret != 1) {
- return ret;
- }
-
- Lock l(_remoteAccessLock);
-
- if (_remoteAccessEnabled) {
-
- _AMTDNSLock.acquire();
-
- std::list<std::string>::const_iterator it = _AMTDNSSuffixes.begin();
- for (; it != _AMTDNSSuffixes.end(); it++) {
- if (_compareDNSSuffix(*it, dnsSuffix)) {
- result = 1;
- break;
- }
- }
-
- _AMTDNSLock.release();
- }
-
- return result;
-}
-#endif
-
-int Protocol::_updateIPFQDN(const char *fqdn)
-{
- if (strcmp(fqdn, _AMTFQDN) != 0) {
- char localName[FQDN_MAX_SIZE] = "\0";
- int res = gethostname(localName, sizeof(localName));
-
- // If AMT FQDN is equal to local FQDN than we don't do anything
- if ((res == -1) || (strcmp(fqdn, localName) != 0)) {
- if (_handleFQDNChange(fqdn) < 0) {
- ERROR("Error: failed to update FQDN info\n");
- return -1;
- }
- } else {
- if (_handleFQDNChange("") < 0) {
- ERROR("Error: failed to update FQDN info\n");
- return -1;
- }
- }
- }
-
- memcpy(_AMTFQDN, fqdn, sizeof(_AMTFQDN));
-
- PRINT("Got FQDN: %s\n", _AMTFQDN);
-
- return 0;
-}
-
-
-char *Protocol::_getErrMsg(DWORD err)
-{
- static char buffer[1024];
-
-#if defined(__sun) || defined(_LINUX)
- strerror_r(err, buffer, sizeof(buffer) - 1);
-#else
- FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
- NULL,
- err,
- 0,
- buffer,
- sizeof(buffer) - 1,
- 0);
-#endif // __sun || _LINUX
-
- return buffer;
-}
-
-
-int Protocol::_handleFQDNChange(const char *fqdn)
-{
- const char *hostFile = "hosts";
- const char *tmpFile = "hosts-lms.tmp";
- bool hasFqdn = false;
-#define LMS_MAX_FILENAME_LEN 1024
- char inFileName[LMS_MAX_FILENAME_LEN] = "";
- char oldFqdn[FQDN_MAX_SIZE + 1];
- char outFileName[LMS_MAX_FILENAME_LEN] = "";
- char host[FQDN_MAX_SIZE + 1];
-#define LMS_MAX_LINE_LEN 1023
- char line[LMS_MAX_LINE_LEN + 1];
-#define LMS_LINE_SIG_FIRST_WORDS "# LMS GENERATED "
-#define LMS_LINE_SIG_LAST_WORD "LINE"
-#define LMS_LINE_SIG_LAST_WORD_LEN 4
-#define LMS_LINE_SIG LMS_LINE_SIG_FIRST_WORDS LMS_LINE_SIG_LAST_WORD
-#define lmsstr(s) lmsname(s)
-#define lmsname(s) #s
-#define LMS_LINE_FORMAT "127.0.0.1 %s %s " LMS_LINE_SIG
-#define LMS_LINE_SCAN_FORMAT "127.0.0.1 %" lmsstr(FQDN_MAX_SIZE) "s %" lmsstr(FQDN_MAX_SIZE) "s " LMS_LINE_SIG_FIRST_WORDS "%" lmsstr(LMS_LINE_SIG_LAST_WORD_LEN) "c"
- char tmpsige[LMS_LINE_SIG_LAST_WORD_LEN];
-
-#if defined(__sun) || defined(_LINUX)
-
- const char *dir = "/etc/";
-
-#else
-
- char *sysDrive;
- const char *dir = "\\system32\\drivers\\etc\\";
-
- sysDrive = getenv("SystemRoot");
- if (NULL == sysDrive) {
- return -1;
- }
-
- // sanity check before string copying
- if (LMS_MAX_FILENAME_LEN < (strnlen(sysDrive, LMS_MAX_FILENAME_LEN)
- + strnlen(dir, LMS_MAX_FILENAME_LEN)
- + strnlen(hostFile, LMS_MAX_FILENAME_LEN) + 1)) {
- return -1;
- }
- // sanity check before string copying
- if (LMS_MAX_FILENAME_LEN < (strnlen(sysDrive, LMS_MAX_FILENAME_LEN)
- + strnlen(dir, LMS_MAX_FILENAME_LEN)
- + strnlen(tmpFile, LMS_MAX_FILENAME_LEN) + 1)) {
- return -1;
- }
-
- strncpy(inFileName, sysDrive, LMS_MAX_FILENAME_LEN - 1);
- strncpy(outFileName, sysDrive, LMS_MAX_FILENAME_LEN - 1);
-
-#endif // __sun || _LINUX
-
- strncat(inFileName, dir, LMS_MAX_FILENAME_LEN - 1);
- strncat(outFileName, dir, LMS_MAX_FILENAME_LEN - 1);
- strncat(inFileName, hostFile, LMS_MAX_FILENAME_LEN - 1);
- strncat(outFileName, tmpFile, LMS_MAX_FILENAME_LEN - 1);
-
- FILE *ifp = fopen(inFileName, "r");
- if (NULL == ifp) {
- _eventLog(_eventLogParam, TEXT("Error: Can't open hosts file"), EVENTLOG_ERROR_TYPE);
- return -1;
- }
-
- FILE *ofp = fopen(outFileName, "w");
- if (NULL == ofp) {
- _eventLog(_eventLogParam, TEXT("Error: Can't create temporary hosts file"), EVENTLOG_ERROR_TYPE);
- fclose(ifp);
- return -1;
- }
-
- // First create a copy of the hosts file, without lines that were
- // previously added by the LMS.
- // Go over each line and copy it to the tmp file.
- while (fgets(line, sizeof(line), ifp)) {
- // don't copy the line if it was generated by the LMS
- memset(oldFqdn, 0, sizeof(oldFqdn));
- memset(tmpsige, 0, sizeof(tmpsige));
- if (0 == (
- (3 == sscanf(line, LMS_LINE_SCAN_FORMAT, oldFqdn, host, tmpsige))
- ? strncmp(tmpsige, LMS_LINE_SIG_LAST_WORD, LMS_LINE_SIG_LAST_WORD_LEN)
- : (-2))
- ) {
- if (0 == strncmp((char *)fqdn, oldFqdn, FQDN_MAX_SIZE)) {
- // copy the old LMS line too, since it's up to date
- fprintf(ofp, "%s", line);
- hasFqdn = true;
- }
- continue;
- }
-
- fprintf(ofp, "%s", line);
-
- while ((LMS_MAX_LINE_LEN == strnlen(line, LMS_MAX_LINE_LEN))
- && ('\n' != line[LMS_MAX_LINE_LEN - 1])
- && (fgets(line, sizeof(line), ifp))) {
- fprintf(ofp, "%s", line);
- }
- }
-
- if (hasFqdn) {
- fclose(ofp);
- fclose(ifp);
- unlink(outFileName);
- return 0;
- }
-
- // If the original hosts file does not end with a new line character,
- // add a new line at the end of the new file before adding our line.
- fseek(ifp, -1, SEEK_END);
- char lastChar = fgetc(ifp);
- if ('\n' != lastChar) {
- fprintf(ofp, "\n");
- }
-
- memset(host, 0, FQDN_MAX_SIZE + 1);
- strncpy(host, fqdn, FQDN_MAX_SIZE);
- char *lmsdot = strchr(host, '.');
- if (NULL != lmsdot) {
- lmsdot[0] = '\0';
- }
-
- if ((fqdn != NULL) && (fqdn[0] != 0)) {
- // Add the specified FQDN to the end of the tmp file
- fprintf(ofp, LMS_LINE_FORMAT "\n", fqdn, host);
- }
-
- fclose(ofp);
- fclose(ifp);
-
- if (0 != std::rename(outFileName, inFileName)) {
- std::string tmp2FileName = std::string(inFileName) + ".~tmp";
- std::ifstream mfile(inFileName, std::ios_base::in);
- if (!mfile.is_open()) {
- _eventLog(_eventLogParam, TEXT("Error: Can't update hosts file [1]"), EVENTLOG_ERROR_TYPE);
- return -1;
- }
- std::ofstream wfile(tmp2FileName.c_str(), std::ios_base::out | std::ios_base::trunc);
- if (!wfile.is_open()) {
- mfile.close();
- _eventLog(_eventLogParam, TEXT("Error: Can't update hosts file [2]"), EVENTLOG_ERROR_TYPE);
- return -1;
- }
- wfile << mfile.rdbuf();
- if (wfile.bad()) {
- mfile.close();
- wfile.close();
- _eventLog(_eventLogParam, TEXT("Error: Can't update hosts file [3]"), EVENTLOG_ERROR_TYPE);
- return -1;
- }
- mfile.close();
- wfile.close();
- std::ifstream sfile(outFileName, std::ios_base::in);
- if (!sfile.is_open()) {
- _eventLog(_eventLogParam, TEXT("Error: Can't update hosts file [4]"), EVENTLOG_ERROR_TYPE);
- return -1;
- }
- std::ofstream dfile(inFileName, std::ios_base::out | std::ios_base::trunc);
- if (!dfile.is_open()) {
- sfile.close();
- _eventLog(_eventLogParam, TEXT("Error: Can't update hosts file [5]"), EVENTLOG_ERROR_TYPE);
- return -1;
- }
- dfile << sfile.rdbuf();
- if (dfile.bad()) {
- sfile.close();
- dfile.close();
- unlink(inFileName);
- if (0 != std::rename(outFileName, inFileName)) {
- std::rename(tmp2FileName.c_str(), inFileName);
- _eventLog(_eventLogParam, TEXT("Error: Can't update hosts file [6]"), EVENTLOG_ERROR_TYPE);
- return -1;
- }
- }
- sfile.close();
- dfile.close();
- }
-
- _eventLog(_eventLogParam, TEXT("hosts file updated"), EVENTLOG_INFORMATION_TYPE);
-
- return 0;
-}
-
-ssize_t Protocol::_send(int s, const void *buf, size_t len, int &senderr)
-{
- ssize_t result;
-
-#if defined(_LINUX)
- if (-1 == (result = send(s, buf, len, MSG_NOSIGNAL))) {
- senderr = errno;
- }
-#elif defined(__sun)
- if (-1 == (result = send(s, buf, len, 0))) {
- senderr = errno;
- }
-#else
- result = send(s, buf, len);
-#endif // _LINUX
-
- return result;
-}
-
diff --git a/usr/src/cmd/lms/Protocol.h b/usr/src/cmd/lms/Protocol.h
deleted file mode 100644
index b681888248..0000000000
--- a/usr/src/cmd/lms/Protocol.h
+++ /dev/null
@@ -1,191 +0,0 @@
-/*******************************************************************************
- * 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 _PROTOCOL_H_
-#define _PROTOCOL_H_
-
-#include <map>
-#include <vector>
-#include <set>
-#include <string>
-#include "types.h"
-#include "LMS_if.h"
-#include "LMEConnection.h"
-#include "PortForwardRequest.h"
-#include "Channel.h"
-#include "Semaphore.h"
-
-#if defined(__sun) || defined(_LINUX)
-
-#define SOCKET int
-#define INVALID_SOCKET (SOCKET)(~0)
-#define SOCKET_ERROR (-1)
-#else
-#include <windows.h>
-#endif // __sun || _LINUX
-
-#ifdef _REMOTE_SUPPORT
-#include "ConfigConnection.h"
-#endif
-
-#define FQDN_MAX_SIZE 256
-
-typedef void (*EventLogCallback)(void *param, LPCTSTR message, WORD eventType);
-
-class Protocol
-{
-public:
-
- static const LMEProtocolVersionMessage MIN_PROT_VERSION;
- static const LMEProtocolVersionMessage MAX_PROT_VERSION;
-
- enum SOCKET_STATUS {
- ACTIVE = 0,
- NOT_CREATED,
- LINGER_ERROR,
- NOT_BINDED,
- NOT_EXCLUSIVE_ADDRESS,
- NOT_LISTENED
- };
-
- Protocol();
- ~Protocol();
-
- bool CreateSockets();
- void DestroySockets();
- bool SocketsCreated() { return _sockets_active; }
- bool IsDeInitialized();
- bool IsInitialized();
- bool Init(EventLogCallback cb, void *param);
- int Select();
- void Deinit();
- void DeinitFull();
-
- bool oldProtocolMode;
-
-private:
- static void _LmeCallback(void *param, void *buffer, unsigned int len, int *status);
- static int _isLocalCallback(void *const param, SOCKET s);
-#ifdef _REMOTE_SUPPORT
- static int _isRemoteCallback(void *const param, SOCKET s);
-#endif
- static char *_getErrMsg(DWORD err);
-
- bool _checkProtocolFlow(LMEMessage *message);
- unsigned int _getMinMessageLen(LMEMessage *message);
- unsigned int _getMinGlobalMsgLen(LMEGlobalRequestMessage *globalMessage);
- bool _checkMessageAndProtocol(LMEMessage *message, unsigned int len);
- void _closePortForwardRequest(PortForwardRequest *p);
- void _apfGlobalRequest(LMEGlobalRequestMessage *globalMessage, unsigned int len, int *status);
- void _apfTcpForwardRequest(LMETcpForwardRequestMessage *tcpFwdReqMsg, int *status);
- void _apfTcpForwardCancel(LMETcpForwardCancelRequestMessage *tcpFwdCnclMsg);
- void _aptSendUdp(LMEUdpSendToMessage *udpSendToMessage, int *status);
- void _apfProtocolVersion(LMEProtocolVersionMessage *verMsg);
- void _apfChannelOpen(LMEChannelOpenRequestMessage *chOpenMsg, int *status);
- PortForwardRequest *_closeMChannel(Channel *c);
- PortForwardRequest *_apfChannelOFail(LMEChannelOpenReplayFailureMessage *chFailMsg);
- PortForwardRequest *_apfChannelClose(LMEChannelCloseMessage *chClMsg);
- PortForwardRequest *_apfChannelData(LMEChannelDataMessage *chDMsg, int *status);
- void _LmeReceive(void *buffer, unsigned int len, int *status);
- void _LmeReceiveCompat(char *buffer, unsigned int len, int *status);
- void _signalSelect();
- bool _acceptConnection(SOCKET s, unsigned int port);
- int _rxFromSocket(SOCKET s);
- int _handleFQDNChange(const char *fqdn);
- int _updateIPFQDN(const char *fqdn);
-#ifdef _REMOTE_SUPPORT
- static bool _compareDNSSuffix(std::string AMTDNSSuffix, std::string suffix);
- int _isRemote(SOCKET s) const;
- bool _checkRemoteSupport(bool requestDnsFromAmt = false);
- void _updateEnterpriseAccessStatus(const ATDomainMap &localDNSSuffixes);
-#endif
- ssize_t _send(int s, const void *buf, size_t len, int &senderr);
- bool _checkListen(std::string address, in_port_t port, int &socket);
- int _listenPort(in_port_t port, int &error);
- bool _localListen(in_port_t port);
- Channel *_getSockOpenChannel(SOCKET s);
-
-
- struct Connection {
- SOCKET s;
- };
-
- typedef std::vector<PortForwardRequest *> PortForwardRequestList;
- typedef std::map<unsigned int, PortForwardRequestList> PortMap;
- typedef std::map<unsigned int, Channel *> ChannelMap;
-
- LMEConnection _lme;
- char *_rxSocketBuffer;
- unsigned int _rxSocketBufferSize;
-#ifdef _REMOTE_SUPPORT
- ConfigConnection _cfg;
-#endif
- SOCKET _serverSignalSocket;
- SOCKET _clientSignalSocket; // Used to notify Select() to check new available channels
- bool _sockets_active;
- PortMap _openPorts;
- ChannelMap _openChannels;
- Semaphore _portsLock;
- Semaphore _channelsLock;
-#ifdef _REMOTE_SUPPORT
- std::list<std::string> _AMTDNSSuffixes;
- mutable Semaphore _AMTDNSLock;
- bool _remoteAccessEnabled;
- mutable Semaphore _remoteAccessLock;
-#endif
-
- enum VERSION_HANDSHAKING {
- NOT_INITIATED,
- INITIATED,
- AGREED
- };
-
- enum SERVICE_STATUS {
- NOT_STARTED,
- STARTED
- };
-
- VERSION_HANDSHAKING _handshakingStatus;
- SERVICE_STATUS _pfwdService;
- LMEProtocolVersionMessage _AmtProtVersion;
- Semaphore _versionLock;
-
- char _AMTFQDN[FQDN_MAX_SIZE];
- EventLogCallback _eventLog;
- void *_eventLogParam;
-
- bool _deinitReq;
- Semaphore _deinitLock;
-
- typedef std::set<unsigned int> listenPortSet;
- listenPortSet _listenFailReported;
-};
-
-#endif
diff --git a/usr/src/cmd/lms/ProtocolCompat.cpp b/usr/src/cmd/lms/ProtocolCompat.cpp
deleted file mode 100644
index 7264bf100e..0000000000
--- a/usr/src/cmd/lms/ProtocolCompat.cpp
+++ /dev/null
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * 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.
- *******************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#if defined(__sun) || defined(_LINUX)
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#else
-#include <winsock2.h>
-#endif // __sun || _LINUX
-
-#include <cerrno>
-#include "Protocol.h"
-#include "LMS_if_compat.h"
-#include "Lock.h"
-#include "ATNetworkTool.h"
-
-void Protocol::_LmeReceiveCompat(char *buffer, unsigned int len, int *status)
-{
- int error = 0;
-
- PRINT("[Compat]HECI receive %d bytes (msg type 0x%02x)\n", len, buffer[0]);
- *status = 0;
-
- switch (buffer[0]) {
- case LMS_MESSAGE_TYPE_OPEN_CONNECTION_EX:
- {
- SOCKET s_new = INVALID_SOCKET;
- LMS_OPEN_CONNECTION_EX_MESSAGE *msg =
- (LMS_OPEN_CONNECTION_EX_MESSAGE *)buffer;
-
- int type;
- switch (msg->Protocol) {
- case LMS_PROTOCOL_TYPE_UDP_IPV4:
- type = SOCK_DGRAM;
- break;
- case LMS_PROTOCOL_TYPE_TCP_IPV4:
- default:
- type = SOCK_STREAM;
- break;
- }
-
- if ((msg->Flags & HOSTNAME_BIT) != 0) {
- PRINT("[Compat]Got client connection request %d for host %s, port %d\n",
- msg->ConnectionId,
- msg->Host,
- ntohs(msg->HostPort));
-
- s_new = ATNetworkTool::Connect(
- (const char *)msg->Host,
- ntohs(msg->HostPort),
- error, PF_INET, type);
- } else {
- PRINT("[Compat]Got client connection request %d for IP %s, port %d\n",
- msg->ConnectionId,
- inet_ntoa(*((struct in_addr *)msg->Host)),
- ntohs(msg->HostPort));
-
- s_new = ATNetworkTool::Connect(
- inet_ntoa(*((struct in_addr *)msg->Host)),
- ntohs(msg->HostPort),
- error, PF_INET, type);
- }
-
- if (s_new == INVALID_SOCKET) {
- *status = 1;
- break;
- }
-
- Channel *c = new Channel(NULL, s_new);
- c->SetRecipientChannel(msg->ConnectionId);
- c->SetStatus(Channel::OPEN);
- c->AddBytesTxWindow(1024);
- {
- Lock l(_channelsLock);
- _openChannels[msg->ConnectionId] = c;
- }
-
- _signalSelect();
- }
- break;
-
- case LMS_MESSAGE_TYPE_CLOSE_CONNECTION:
- {
- LMS_CLOSE_CONNECTION_MESSAGE *msg =
- (LMS_CLOSE_CONNECTION_MESSAGE *)buffer;
-
- PRINT("[Compat]received close connection msg from HECI for connection %d\n", msg->ConnectionId);
-
- Lock l(_channelsLock);
-
- ChannelMap::iterator it = _openChannels.find(msg->ConnectionId);
- if (it != _openChannels.end()) {
- _closeMChannel(it->second);
- _openChannels.erase(it);
- }
- }
- break;
-
- case LMS_MESSAGE_TYPE_SEND_DATA:
- {
- LMS_SEND_DATA_MESSAGE *msg =
- (LMS_SEND_DATA_MESSAGE *)buffer;
-
- Lock l(_channelsLock);
-
- ChannelMap::iterator it = _openChannels.find(msg->ConnectionId);
- if (it != _openChannels.end()) {
- PRINT("[Compat]sending %d bytes from HECI connection %d to socket %d\n", ntohs(msg->DataLength), msg->ConnectionId, it->second->GetSocket());
- if (-1 == _send(it->second->GetSocket(), (char *)msg->Data, ntohs(msg->DataLength), error)) {
- if (EPIPE == error) {
- _closeMChannel(it->second);
- _openChannels.erase(it);
- *status = 1;
- }
- }
- }
- }
- break;
-
- case LMS_MESSAGE_TYPE_IP_FQDN:
- if (_updateIPFQDN((const char *)((LMS_IP_FQDN_MESSAGE *)buffer)->FQDN) != 0) {
- ERROR("[Compat]Error: failed to update IP/FQDN info\n");
- }
- break;
-
- default:
- *status = 1;
- break;
- }
-}
-
diff --git a/usr/src/cmd/lms/SyncLib/Include/Event.h b/usr/src/cmd/lms/SyncLib/Include/Event.h
deleted file mode 100644
index 6c00153c48..0000000000
--- a/usr/src/cmd/lms/SyncLib/Include/Event.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * 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.
- *******************************************************************************/
-
-//////////////////////////////////////////////////////////////////////////
-// Event.h
-//
-// This file contains the definition of the Event class (for thread
-// synchronization)
-//////////////////////////////////////////////////////////////////////////
-#ifndef _LAD_EVENT_H
-#define _LAD_EVENT_H
-
-#ifndef WAIT_INFINITE
-#define WAIT_INFINITE 0xffffffff
-#endif
-
-class OSEvent;
-
-class Event
-{
-public:
- Event(bool manual = false);
- Event(const Event &rhs);
- ~Event();
-
- void set();
- void reset();
- bool wait(unsigned long msecs = WAIT_INFINITE);
- Event& operator=(const Event &rhs);
-
-private:
- OSEvent *_osEvent;
-};
-
-#endif //_LAD_EVENT_H
-
diff --git a/usr/src/cmd/lms/SyncLib/Include/Lock.h b/usr/src/cmd/lms/SyncLib/Include/Lock.h
deleted file mode 100644
index 4a59bd9ed1..0000000000
--- a/usr/src/cmd/lms/SyncLib/Include/Lock.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * 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.
- *******************************************************************************/
-
-//////////////////////////////////////////////////////////////////////////
-// Lock.h
-//
-// This file contains the definition and implementation of the Lock class
-// and the TryLock class
-//////////////////////////////////////////////////////////////////////////
-#ifndef _LAD_LOCK_H
-#define _LAD_LOCK_H
-#include "RWLock.h"
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-class Lock
-{
-public:
- Lock(Semaphore &sem) : _sem(&sem), _rw_lock(NULL)
- {
- _sem->acquire();
- }
-
- Lock(RWLock &rw_lock, RWLock::RWMode mode = RWLock::READ_ONLY) :
- _sem(NULL), _rw_lock(&rw_lock)
- {
- _rw_lock->acquire(mode);
- }
-
- ~Lock()
- {
- if (_sem) {
- _sem->release();
- }
- if (_rw_lock) {
- _rw_lock->release();
- }
-
- }
-
-private:
- Semaphore *_sem;
- RWLock *_rw_lock;
-};
-
-class TryLock
-{
-public:
- TryLock(Semaphore &sem, bool &is_locked) : _sem(&sem)
- {
- _locked = _sem->acquireTry();
- is_locked = _locked;
- }
-
- ~TryLock()
- {
- if (_locked) {
- _sem->release();
- }
- }
-
-private:
- bool _locked;
- Semaphore *_sem;
-};
-
-#endif //_LAD_LOCK_H
-
diff --git a/usr/src/cmd/lms/SyncLib/Include/RWLock.h b/usr/src/cmd/lms/SyncLib/Include/RWLock.h
deleted file mode 100644
index be1f653dc2..0000000000
--- a/usr/src/cmd/lms/SyncLib/Include/RWLock.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * 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 _RW_LOCK_H_
-#define _RW_LOCK_H_
-
-#include "Semaphore.h"
-
-class RWLock
-{
-public:
- enum RWMode {
- READ_ONLY,
- READ_WRITE
- };
-
- RWLock();
- ~RWLock() {}
-
- void acquire(const RWMode mode_p = READ_ONLY);
- void release();
- void switch2RO();
-
-private:
- Semaphore _readSem;
- Semaphore _writeSem;
- Semaphore _countSem;
- unsigned int _counter;
-};
-
-#endif //_RW_LOCK_H_
diff --git a/usr/src/cmd/lms/SyncLib/Include/SPtr.h b/usr/src/cmd/lms/SyncLib/Include/SPtr.h
deleted file mode 100644
index f1d4405ddf..0000000000
--- a/usr/src/cmd/lms/SyncLib/Include/SPtr.h
+++ /dev/null
@@ -1,196 +0,0 @@
-/*******************************************************************************
- * 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.
- *******************************************************************************/
-
-//////////////////////////////////////////////////////////////////////////
-// SPtr.h
-//
-// This is a smart pointer class. It receives an initialized object in
-// the constructor, and maintains a reference count to this object. It
-// deletes the object only when the reference count reaches 0.
-//
-//////////////////////////////////////////////////////////////////////////
-
-#ifndef _SPTR_H_
-#define _SPTR_H_
-
-#include <memory>
-#include "Semaphore.h"
-
-template
-<class T>
-class SPtr
-{
-public:
- // constructor
- explicit SPtr(T *ptr_p = 0) :
- _ptr(ptr_p),
- _pref_count(new int(1)),
- _psem(new Semaphore(1)) {}
-
- // copy constructor
- template<class X>
- SPtr(const SPtr<X> &other_sptr_p)
- {
- other_sptr_p.getSem()->acquire();
- _ptr = other_sptr_p.get();
- _pref_count = other_sptr_p.getRefcnt();
- _psem = other_sptr_p.getSem();
- ++(*_pref_count);
- _psem->release();
- }
-
- SPtr(const SPtr &other_sptr_p)
- {
- other_sptr_p.getSem()->acquire();
- _ptr = other_sptr_p.get();
- _pref_count = other_sptr_p.getRefcnt();
- _psem = other_sptr_p.getSem();
- ++(*_pref_count);
- _psem->release();
- }
-
- // destructor
- ~SPtr()
- {
- _psem->acquire();
- if (--(*_pref_count) == 0) {
- // delete pointer only on last destruction
- delete _pref_count;
- delete _psem;
- if (_ptr) {
- delete _ptr;
- }
- _ptr = 0;
- } else {
- _psem->release();
- }
- }
-
- // operator=
- // if 'this' already points to an object, unreference it
- template<class X>
- SPtr &operator= (const SPtr<X> &other_sptr_p)
- {
- if ((void *)&other_sptr_p == this) {
- return *this;
- }
- _psem->acquire();
- if (--(*_pref_count) == 0) {
- delete _pref_count;
- delete _psem;
- if (_ptr) {
- delete _ptr;
- }
- } else {
- _psem->release();
- }
- other_sptr_p.getSem()->acquire();
- _ptr = (T *)other_sptr_p.get();
- _pref_count = other_sptr_p.getRefcnt();
- _psem = other_sptr_p.getSem();
- ++(*_pref_count);
- _psem->release();
- return *this;
- }
-
- SPtr &operator=(const SPtr &other_sptr_p)
- {
- if (&other_sptr_p == this) {
- return *this;
- }
- _psem->acquire();
- if (--(*_pref_count) == 0) {
- delete _pref_count;
- delete _psem;
- if (_ptr) {
- delete _ptr;
- }
- } else {
- _psem->release();
- }
- other_sptr_p.getSem()->acquire();
- _ptr = other_sptr_p.get();
- _pref_count = other_sptr_p.getRefcnt();
- _psem = other_sptr_p.getSem();
- ++(*_pref_count);
- _psem->release();
- return *this;
- }
-
- // operator*
- T &operator*() const
- {
- return *_ptr;
- }
-
- // operator->
- T *operator->() const
- {
- return _ptr;
- }
-
- // get - return inner pointer
- T *get() const
- {
- return _ptr;
- }
-
- int *getRefcnt() const
- {
- return _pref_count;
- }
-
- Semaphore *getSem() const
- {
- return _psem;
- }
-
-private:
- // the pointer itself
- T *_ptr;
- // a pointer to the reference count
- int *_pref_count;
- Semaphore *_psem;
-} ;
-
-template
-<class T>
-inline bool operator==(const SPtr<T> &x, const SPtr<T> &y) {
- return(x.get() == y.get());
-}
-
-template
-<class T>
-inline bool operator!=(const SPtr<T> &x, const SPtr<T> &y) {
- return(x.get() != y.get());
-}
-
-#endif // _SPTR_H_
-
diff --git a/usr/src/cmd/lms/SyncLib/Include/Semaphore.h b/usr/src/cmd/lms/SyncLib/Include/Semaphore.h
deleted file mode 100644
index 0155f02289..0000000000
--- a/usr/src/cmd/lms/SyncLib/Include/Semaphore.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * 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.
- *******************************************************************************/
-
-//////////////////////////////////////////////////////////////////////////
-// Semaphore.h
-//
-// This file contains the definition of the Semaphore class
-//////////////////////////////////////////////////////////////////////////
-#ifndef _LAD_SEMAPHORE_H
-#define _LAD_SEMAPHORE_H
-
-class OSSemaphore;
-
-class Semaphore
-{
-public:
- Semaphore(int maxval = 1);
- Semaphore (const Semaphore &rhs);
- ~Semaphore();
-
- void acquire(); // blocks until value !=0, and decrements the value
- void release(); // increments the value by 1
- bool acquireTry(); // try to acquire the semaphore: return 'true' if succeded
-
- Semaphore &operator=(const Semaphore &rhs);
-
-private:
- OSSemaphore *_osSemaphore;
-};
-
-#endif //_LAD_SEMAPHORE_H
-
diff --git a/usr/src/cmd/lms/SyncLib/Include/Thread.h b/usr/src/cmd/lms/SyncLib/Include/Thread.h
deleted file mode 100644
index c6060ec592..0000000000
--- a/usr/src/cmd/lms/SyncLib/Include/Thread.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * 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.
- *******************************************************************************/
-
-//////////////////////////////////////////////////////////////////////////
-// Thread.h
-//
-// This file contains an OS independent interface for thread manipulation
-// A Thread class is defined for easy usage.
-//
-// Usage:
-//
-// Option 1: Construct an instance of the "Thread" class with an external
-// callback function. When calling the "start" method, the thread will be
-// started on the callback function
-//
-// Option 2: Subclass the "Thread" class and reimplement the virtual "run"
-// method. When calling the "start" method, the thread will be started
-// on the "run" function.
-//
-// Implementation overview:
-// Calling the "start" method will start the new thread, which will call the
-// "run" method. The default implementation of the "run" method will call
-// the Callback function given in the constructor.
-//
-//////////////////////////////////////////////////////////////////////////
-#ifndef _LAD_THREAD_H
-#define _LAD_THREAD_H
-
-#ifndef WAIT_INFINITE
-#define WAIT_INFINITE 0xffffffff
-#endif
-#ifndef NULL
-#define NULL 0
-#endif
-
-typedef void (*CallbackFunction) (void *);
-
-class OSThread;
-
-class Thread
-{
- friend class OSThread;
-
-public:
- Thread(CallbackFunction func = NULL, void *param = NULL);
- Thread(const Thread &rhs);
- virtual ~Thread();
-
- // wait for the thread to complete; return true if the thread completed,
- // false on timeout
- bool wait(unsigned long msecs = WAIT_INFINITE) const;
- // start the new thread, return true on success
- bool start();
- // true if the thread is in running state
- bool running() const;
- // measure the time (in msecs) from thread start-time
- long elapsedTime() const;
-
- // return ID for the current thread
- static unsigned long currentThread();
- // put the current thread to sleep
- static void msleep(long msecs);
-
- Thread &operator=(const Thread &rhs);
-
-protected:
- virtual void run();
-
-private:
- CallbackFunction _func;
- void *_param;
- long _startTime;
- OSThread *_osThread;
-};
-
-#endif //_LAD_THREAD_H
-
diff --git a/usr/src/cmd/lms/SyncLib/src/EventUnix.cpp b/usr/src/cmd/lms/SyncLib/src/EventUnix.cpp
deleted file mode 100644
index 8a704a19f1..0000000000
--- a/usr/src/cmd/lms/SyncLib/src/EventUnix.cpp
+++ /dev/null
@@ -1,177 +0,0 @@
-/*******************************************************************************
- * 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.
- *******************************************************************************/
-
-//////////////////////////////////////////////////////////////////////////
-// EventLinux.cpp
-//
-// This file contains the linux implementation of the Event class
-//////////////////////////////////////////////////////////////////////////
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include "Event.h"
-#include "SPtr.h"
-#include <pthread.h>
-#include <cerrno>
-#include <sys/time.h>
-#include <iostream>
-
-class OSEvent_s
-{
-public:
- OSEvent_s()
- {
- pthread_mutex_init(&_mut, NULL);
- pthread_cond_init(&_cond, NULL);
- _set = false;
- }
-
- ~OSEvent_s()
- {
- pthread_cond_destroy(&_cond);
- pthread_mutex_destroy(&_mut);
- }
-
- pthread_mutex_t _mut;
- pthread_cond_t _cond;
- bool _set;
-};
-
-class OSEvent
-{
-public:
- OSEvent()
- {
- _ose = SPtr<OSEvent_s>(new OSEvent_s);
- }
-
- ~OSEvent()
- {
- _ose = SPtr<OSEvent_s>(NULL);
- }
-
- SPtr<OSEvent_s> _ose;
-};
-
-Event::Event(bool manual)
-{
- _osEvent = new OSEvent;
-
- /*
- _osEvent->ose->_set = false;
- pthread_mutex_init(&_osEvent->ose->_mut, NULL);
- pthread_cond_init(&_osEvent->ose->_cond, NULL);
- */
-}
-
-Event::Event(const Event &rhs)
-{
- _osEvent = new OSEvent;
- _osEvent->_ose = rhs._osEvent->_ose;
- /*
- _osEvent->_mut = rhs._osEvent->_mut;
- _osEvent->_cond = rhs._osEvent->_cond;
- */
-}
-
-Event::~Event()
-{
- /*
- pthread_cond_destroy(&_osEvent->ose->_cond);
- pthread_mutex_destroy(&_osEvent->ose->_mut);
- */
- delete _osEvent;
-}
-
-bool Event::wait(unsigned long msecs_p)
-{
- int retcode = 0;
-
- if (msecs_p != WAIT_INFINITE) {
- timeval now;
- timespec timeout, time;
-
- gettimeofday(&now, NULL);
- time.tv_sec = msecs_p / 1000;
- time.tv_nsec = (msecs_p % 1000) * 1000000;
- timeout.tv_sec = now.tv_sec + time.tv_sec;
- timeout.tv_nsec = now.tv_usec + time.tv_nsec;
-
- pthread_mutex_lock(&_osEvent->_ose->_mut);
- //printf("@@@@ Event (%p) wait (cond %p), set: %d (to %d)\n",
- // this, &_osEvent->_ose->_cond, _osEvent->_ose->_set, msecs_p);
- if (!_osEvent->_ose->_set) {
- retcode = pthread_cond_timedwait(&_osEvent->_ose->_cond,
- &_osEvent->_ose->_mut,
- &timeout);
- //printf("@@@@ Event (%p) after wait, set: %d\n", this, _osEvent->_ose->_set);
- _osEvent->_ose->_set = false;
- }
- //printf("@@@@ Event (%p) after wait, set: %d\n", this, _osEvent->_ose->_set);
- pthread_mutex_unlock(&_osEvent->_ose->_mut);
-
- if (retcode == ETIMEDOUT) {
- return false;
- } else {
- return true;
- }
- } else {
- pthread_mutex_lock(&_osEvent->_ose->_mut);
- //printf("@@@@ Event (%p) wait (cond %p), set: %d\n",
- // this, &_osEvent->_ose->_cond, _osEvent->_ose->_set);
- if (!_osEvent->_ose->_set) {
- pthread_cond_wait(&_osEvent->_ose->_cond, &_osEvent->_ose->_mut);
- }
- _osEvent->_ose->_set = false;
- //printf("@@@@ Event (%p) after wait, set: %d\n", this, _osEvent->_ose->_set);
- pthread_mutex_unlock(&_osEvent->_ose->_mut);
- return true;
- }
-
-}
-
-void Event::set()
-{
- pthread_mutex_lock(&_osEvent->_ose->_mut);
- pthread_cond_signal(&_osEvent->_ose->_cond);
- //printf("@@@@ Event (%p) set (cond %p)\n", this, &_osEvent->_ose->_cond);
- _osEvent->_ose->_set = true;
- pthread_mutex_unlock(&_osEvent->_ose->_mut);
-}
-
-void Event::reset()
-{
- pthread_mutex_lock(&_osEvent->_ose->_mut);
- // only way to reset the condition is to destroy it and restart it
- pthread_cond_destroy(&_osEvent->_ose->_cond);
- pthread_cond_init(&_osEvent->_ose->_cond, NULL);
- _osEvent->_ose->_set = false;
- pthread_mutex_unlock(&_osEvent->_ose->_mut);
-}
diff --git a/usr/src/cmd/lms/SyncLib/src/RWLock.cpp b/usr/src/cmd/lms/SyncLib/src/RWLock.cpp
deleted file mode 100644
index 0cfedfe322..0000000000
--- a/usr/src/cmd/lms/SyncLib/src/RWLock.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * 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.
- *******************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include "RWLock.h"
-
-RWLock::RWLock() : _counter(0) {}
-
-void RWLock::acquire(const RWMode mode_p)
-{
-
- if (mode_p == READ_ONLY) {
- //wait for writer's exit
- _writeSem.acquire();
- //might be blocked only to decrement _counter and _readSem.release() in release()
- _countSem.acquire();
- int tmp = ++_counter;
- _countSem.release();
- if (tmp == 1) {
- //never blocks, no writers, first reader
- _readSem.acquire();
- }
- _writeSem.release();
- } else {
- _writeSem.acquire();
- //wait for reader's exit
- _readSem.acquire();
- }
-
- return;
-}
-
-//will do nothing if no read-write lock was acquired
-void RWLock::switch2RO()
-{
- _countSem.acquire();
- if (!_counter) {
- _counter = 1;
- _writeSem.release();
- }
- _countSem.release();
-}
-
-//will do nothing if no lock was acquired
-void RWLock::release()
-{
-
- //might be blocked only to increment _counter in read-only mode
- _countSem.acquire();
- if (_counter) {
- //read-only mode
- _counter--;
- if (!_counter) {
- //the last reader
- _readSem.release();
- }
- } else {
- //read-write mode
- _readSem.release();
- _writeSem.release();
- }
- _countSem.release();
-
- return;
-}
-
diff --git a/usr/src/cmd/lms/SyncLib/src/SemaphoreUnix.cpp b/usr/src/cmd/lms/SyncLib/src/SemaphoreUnix.cpp
deleted file mode 100644
index cff933922c..0000000000
--- a/usr/src/cmd/lms/SyncLib/src/SemaphoreUnix.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * 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.
- *******************************************************************************/
-
-//////////////////////////////////////////////////////////////////////////
-// SemaphoreLinux.cpp
-//
-// This file contains the linux implementation of the Semaphore class
-//////////////////////////////////////////////////////////////////////////
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include "Semaphore.h"
-#include <semaphore.h>
-
-class OSSemaphore {
-public:
- sem_t _sem;
-};
-
-Semaphore::Semaphore(int maxval)
-{
- _osSemaphore = new OSSemaphore;
- sem_init(&_osSemaphore->_sem, 0, maxval);
-}
-
-Semaphore::~Semaphore()
-{
- sem_destroy(&_osSemaphore->_sem);
- delete _osSemaphore;
-}
-
-void Semaphore::acquire()
-{
- // blocks until value !=0, and decrements the value
- sem_wait(&_osSemaphore->_sem);
-}
-
-void Semaphore::release()
-{
- // increments the value by 1
- sem_post(&_osSemaphore->_sem);
-}
-
-bool Semaphore::acquireTry()
-{
- // try to acquire the semaphore: return 'true' if succeded
- return (sem_trywait(&_osSemaphore->_sem) == 0);
-}
-
diff --git a/usr/src/cmd/lms/SyncLib/src/ThreadUnix.cpp b/usr/src/cmd/lms/SyncLib/src/ThreadUnix.cpp
deleted file mode 100644
index ce92afae13..0000000000
--- a/usr/src/cmd/lms/SyncLib/src/ThreadUnix.cpp
+++ /dev/null
@@ -1,191 +0,0 @@
-/*******************************************************************************
- * 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.
- *******************************************************************************/
-
-//////////////////////////////////////////////////////////////////////////
-// ThreadLinux.cpp
-//
-// This file contains the linux implementation of the Thread class
-///////////////////////////////////////////////////////////////////////////
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include "Thread.h"
-#include <pthread.h>
-#include <sys/time.h>
-#include <cerrno>
-#include <cstdio>
-
-
-class OSThread
-{
-public:
- pthread_t _handle;
- pthread_cond_t _cond;
- pthread_mutex_t _mut;
- bool _running;
- static void *threadFunc(void * thread_p);
-};
-
-
-void *OSThread::threadFunc(void *thread_p)
-{
- if (thread_p) {
- Thread *t = (Thread*)thread_p;
- //printf("@@@@ OSThread::threadFunc (%p)\n", t->_osThread);
- t->run();
- //printf("@@@@ OSThread::threadFunc (%p) after run\n", t->_osThread);
- pthread_mutex_lock(&t->_osThread->_mut);
- t->_osThread->_running = false;
- //printf("@@@@ OSThread::threadFunc setting signal\n");
- pthread_cond_signal(&t->_osThread->_cond);
- pthread_mutex_unlock(&t->_osThread->_mut);
- }
- return (void *)0;
-}
-
-Thread::Thread(CallbackFunction func_p, void* param_p)
-{
- _osThread = new OSThread;
- _osThread->_handle = 0;
- _osThread->_running = false;
- pthread_mutex_init(&_osThread->_mut, NULL);
- pthread_cond_init(&_osThread->_cond, NULL);
- _func = func_p;
- _param = param_p;
-}
-
-Thread::~Thread()
-{
- pthread_cond_destroy(&_osThread->_cond);
- pthread_mutex_destroy(&_osThread->_mut);
- delete _osThread;
-}
-
-unsigned long Thread::currentThread()
-{
- return pthread_self();
-}
-
-bool Thread::wait(unsigned long msecs_p) const
-{
- int retcode = 0;
-
- if (msecs_p != WAIT_INFINITE) {
- timeval now;
- timespec timeout, time;
-
- gettimeofday(&now, NULL);
- time.tv_sec = msecs_p / 1000;
- time.tv_nsec = (msecs_p % 1000) * 1000000;
- timeout.tv_sec = now.tv_sec + time.tv_sec;
- timeout.tv_nsec = now.tv_usec + time.tv_nsec;
-
- pthread_mutex_lock(&_osThread->_mut);
- if (_osThread->_running) {
- retcode = pthread_cond_timedwait(&_osThread->_cond, &_osThread->_mut, &timeout);
- }
- pthread_mutex_unlock(&_osThread->_mut);
-
- if (retcode == ETIMEDOUT) {
- return false;
- } else {
- return true;
- }
- } else {
- pthread_mutex_lock(&_osThread->_mut);
- //printf("@@@@ Thread wait (%p), running: %d\n", _osThread, _osThread->_running);
- if (_osThread->_running) {
- pthread_cond_wait(&_osThread->_cond, &_osThread->_mut);
- _osThread->_running = false;
- }
- //printf("@@@@ Thread after wait\n");
- pthread_mutex_unlock(&_osThread->_mut);
- return true;
- }
-}
-
-bool Thread::start()
-{
- if (running() == false) {
- timeval now;
- struct timezone tz;
-
- gettimeofday(&now, &tz);
- _startTime = now.tv_sec;
- _osThread->_running = true;
- if (pthread_create(&_osThread->_handle, NULL, OSThread::threadFunc, this) != 0) {
- return false;
- }
- }
-
- return true;
-}
-
-bool Thread::running() const
-{
- return (_osThread->_running);
-}
-
-void Thread::msleep(long msecs_p)
-{
- timespec time, rem;
- int counter = 5; // givin it 5 tries
-
- time.tv_sec = msecs_p / 1000;
- time.tv_nsec = (msecs_p % 1000) * 1000000;
- while (counter > 0) {
- // nanosleep might return due to a signal, in which case
- // rem will include the remaining time
- if (nanosleep(&time, &rem) == -1) {
- time.tv_sec = rem.tv_sec;
- time.tv_nsec = rem.tv_nsec;
- --counter;
- } else {
- break;
- }
- }
-}
-
-void Thread::run()
-{
- if (_func != NULL) {
- _func(_param);
- }
-}
-
-long Thread::elapsedTime() const
-{
- struct timezone tz;
- timeval now;
-
- gettimeofday(&now, &tz);
- return ((now.tv_sec - _startTime)*1000);
-}
-
diff --git a/usr/src/cmd/lms/THIRDPARTYLICENSE b/usr/src/cmd/lms/THIRDPARTYLICENSE
deleted file mode 100644
index 211d58eec2..0000000000
--- a/usr/src/cmd/lms/THIRDPARTYLICENSE
+++ /dev/null
@@ -1,27 +0,0 @@
-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.
diff --git a/usr/src/cmd/lms/THIRDPARTYLICENSE.descrip b/usr/src/cmd/lms/THIRDPARTYLICENSE.descrip
deleted file mode 100644
index 5dc6a98f71..0000000000
--- a/usr/src/cmd/lms/THIRDPARTYLICENSE.descrip
+++ /dev/null
@@ -1 +0,0 @@
-INTEL ACTIVE MANAGEMENT TECHNOLOGY LOCAL MANAGEABILITY SERVICE SOFTWARE
diff --git a/usr/src/cmd/lms/glue.cpp b/usr/src/cmd/lms/glue.cpp
deleted file mode 100644
index 53cf442a19..0000000000
--- a/usr/src/cmd/lms/glue.cpp
+++ /dev/null
@@ -1,349 +0,0 @@
-/*******************************************************************************
- * 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.
- *******************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include <cstdlib>
-#include <cstdio>
-#include <cstring>
-#include <sys/types.h>
-#include <dlfcn.h>
-#include "glue.h"
-
-#ifdef __sun
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#endif // __sun
-
-#define PARSER_MAX 32
-
-typedef struct parser_s {
- unsigned int count;
- char *line[PARSER_MAX];
-} parser_t;
-
-
-static void parser_init(parser_t *cfg)
-{
- if (!cfg) {
- return;
- }
-
- cfg->count = 0;
-}
-
-static int parser_add(parser_t *cfg, char *buf)
-{
- if ((!cfg) || (cfg->count > PARSER_MAX)) {
- return -1;
- }
-
- cfg->line[cfg->count] = strdup(buf);
- if (cfg->line[cfg->count]) {
- cfg->count ++;
- }
-
- return 0;
-}
-
-static int parser_length(parser_t *cfg)
-{
- if (!cfg) {
- return 0;
- }
-
- return cfg->count;
-}
-
-static char *parser_get(parser_t *cfg, unsigned int index)
-{
- if ((!cfg) || (index >= cfg->count)) {
- return NULL;
- }
-
- return (cfg->line[index]);
-}
-
-
-static int parser_read(parser_t *cfg, FILE *fp)
-{
- char line[512];
- char *head, *tail;
- int len;
-
- if ((!fp) || (!cfg)) {
- return -1;
- }
-
- while (fgets(line, 511, fp)) {
- head = line;
- while (*head == 0x20 || *head == '\t') {
- head ++;
- }
- if ((*head == '#') || (*head == '\n') ||
- (*head == '\r') || (*head == '\0')) {
- continue;
- }
- len = strlen(head);
- tail = head + len - 1;
- if (tail <= head) {
- continue;
- }
- while ((*tail == '\r') || (*tail == '\n')) {
- tail --;
- }
- *(tail + 1) = '\0';
-
- parser_add(cfg, head);
- }
- return 0;
-}
-
-static void parser_free(parser_t *cfg)
-{
- unsigned int i;
-
- for (i = 0; i < cfg->count; i ++) {
- free(cfg->line[i]);
- }
-}
-
-
-/* glue functions */
-
-void glue::handle_init(int index, const char *file)
-{
- int i = index;
-
- if (!file) {
- return;
- }
- printf("file:%s\n", file);
-
- funcs[i].handle = dlopen(file, RTLD_NOW);
- if (!funcs[i].handle) {
- printf("can't open:%s, %s\n", file, dlerror());
- return;
- }
-
- funcs[i].init_funcs = (lms_init_t)dlsym(funcs[i].handle,
- LMS_INIT_FUNC_NAME);
- if (!funcs[i].init_funcs) {
- printf("dl error:%s\n", dlerror());
- return;
- }
-
- if (LMS_OK != funcs[i].init_funcs()) {
- return;
- }
-
- funcs[i].version_funcs = (lms_version_t)dlsym(funcs[i].handle,
- LMS_VERSION_FUNC_NAME);
- funcs[i].pre_funcs = (lms_pre_t)dlsym(funcs[i].handle,
- LMS_PRE_FUNC_NAME);
- funcs[i].retry_funcs = (lms_retry_t)dlsym(funcs[i].handle,
- LMS_RETRY_FUNC_NAME);
- funcs[i].post_funcs = (lms_post_t)dlsym(funcs[i].handle,
- LMS_POST_FUNC_NAME);
- funcs[i].deinit_funcs = (lms_deinit_t)dlsym(funcs[i].handle,
- LMS_DEINIT_FUNC_NAME);
-}
-
-int glue::mem_init(void)
-{
- int i;
-
- funcs = new glue_funcs[cnt];
- if (!funcs) {
- return LMS_ERROR;
- }
-
- for (i = 0;i < cnt; i++) {
- funcs[i].handle = NULL;
- funcs[i].init_funcs = NULL;
- funcs[i].version_funcs = NULL;
- funcs[i].pre_funcs = NULL;
- funcs[i].retry_funcs = NULL;
- funcs[i].post_funcs = NULL;
- funcs[i].deinit_funcs = NULL;
- }
-
- return LMS_OK;
-}
-
-glue::glue() : funcs(NULL)
-{
-}
-
-glue::~glue()
-{
-}
-
-
-int glue::init(void)
-{
- FILE *fp;
- parser_t cfg;
- int i;
-
- parser_init(&cfg);
-
- fp = fopen(LMS_PLUGIN_CONFIG_FILE, "rb");
- if ((!fp) || (parser_read(&cfg, fp) != 0)) {
- cnt = 0;
- if (fp) {
- fclose(fp);
- }
- return LMS_OK;
- }
-
- do {
- cnt = parser_length(&cfg);
- if (0 == cnt) {
- break;
- }
- if (mem_init()) {
- break;
- }
- for (i = 0; i < cnt; i++) {
- handle_init(i, parser_get(&cfg, i));
- }
- } while (0);
-
- fclose(fp);
- parser_free(&cfg);
- return LMS_OK;
-}
-
-void glue::deinit(void)
-{
- int i;
-
- if (!funcs) {
- return;
- }
-
- for (i = 0; i < cnt; i++) {
- if (funcs[i].deinit_funcs) {
- funcs[i].deinit_funcs();
- }
- if (funcs[i].handle) {
- dlclose(funcs[i].handle);
- }
- }
-
- delete[] funcs;
-}
-
-void glue::version(unsigned char version)
-{
- int i;
-
- if (!funcs) {
- return;
- }
-
- for (i = 0; i < cnt; i++) {
- if (!funcs[i].version_funcs) {
- continue;
- }
- funcs[i].version_funcs(version);
- }
-}
-
-int glue::preprocess(unsigned char *buff, int len)
-{
- int i;
- int ret = LMS_ACCEPTED;
-
- if (!funcs) {
- return ret;
- }
-
- for (i = 0; i < cnt; i++) {
- if (!funcs[i].pre_funcs) {
- continue;
- }
- ret = funcs[i].pre_funcs(buff, len);
- if (ret != LMS_ACCEPTED) {
- return ret;
- }
- }
-
- return LMS_ACCEPTED;
-}
-
-int glue::retry(unsigned char *buff, int len)
-{
- int i;
- int ret = LMS_ACCEPTED;
-
- if (!funcs) {
- return ret;
- }
-
- for (i = 0; i < cnt; i++) {
- if (!funcs[i].retry_funcs) {
- continue;
- }
- ret = funcs[i].retry_funcs(buff, len);
- if (ret != LMS_ACCEPTED) {
- return ret;
- }
- }
-
- return LMS_ACCEPTED;
-}
-
-
-int glue::postprocess(unsigned char *buff, int len, int status)
-{
- int i;
- int ret = LMS_ACCEPTED;
-
- if (!funcs) {
- return ret;
- }
-
- for (i = 0; i < cnt; i++) {
- if (!funcs[i].post_funcs) {
- continue;
- }
- ret = funcs[i].post_funcs(buff, len, status);
- if (ret != LMS_ACCEPTED) {
- return ret;
- }
- }
-
- return LMS_ACCEPTED;
-}
-
diff --git a/usr/src/cmd/lms/glue.h b/usr/src/cmd/lms/glue.h
deleted file mode 100644
index daa6d138b4..0000000000
--- a/usr/src/cmd/lms/glue.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * 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 __LMS_GLUE_H__
-#define __LMS_GLUE_H__
-
-#include "plugin.h"
-
-
-class glue_funcs
-{
-public:
- void *handle;
- lms_init_t init_funcs;
- lms_version_t version_funcs;
- lms_pre_t pre_funcs;
- lms_retry_t retry_funcs;
- lms_post_t post_funcs;
- lms_deinit_t deinit_funcs;
-};
-
-
-class glue
-{
-public:
- glue();
- ~glue();
-
- int init(void);
- void deinit(void);
- void version(unsigned char version);
- int preprocess(unsigned char *buff, int len);
- int retry(unsigned char *buff, int len);
- int postprocess(unsigned char *buff, int len, int status);
-
-private:
- int cnt;
- int mem_init(void);
- void handle_init(int index, const char *file);
- glue_funcs *funcs;
-};
-
-#endif
diff --git a/usr/src/cmd/lms/heci/FWULCommand.cpp b/usr/src/cmd/lms/heci/FWULCommand.cpp
deleted file mode 100644
index 790ce7e5b8..0000000000
--- a/usr/src/cmd/lms/heci/FWULCommand.cpp
+++ /dev/null
@@ -1,233 +0,0 @@
-/*******************************************************************************
- * 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.
- *******************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include <cstdio>
-#include <cstdlib>
-
-#ifdef __sun
-#include <stdio.h>
-#include <stdlib.h>
-#endif // __sun
-
-#include "FWULCommand.h"
-
-FWULCommand::FWULCommand(bool verbose) :
-FWULClient(FW_UPDATE_GUID, verbose)
-{
- _verbose = verbose;
-}
-
-FWULCommand::~FWULCommand(void)
-{
-}
-
-HECI_STATUS FWULCommand::_call(const unsigned char *command, UINT32 command_size, UINT8 **readBuffer, UINT32 *outBuffSize)
-{
- UINT32 inBuffSize;
- *outBuffSize = 0;
-
- inBuffSize = FWULClient.GetBufferSize();
- if (NULL == *readBuffer)
- {
- *readBuffer = (UINT8 *)malloc(sizeof(UINT8) * inBuffSize);
- if (NULL == *readBuffer)
- {
- if (_verbose)
- {
- fprintf(stderr, "Error: Malloc failed\n");
- }
- return HECI_STATUS_MEMORY_ALLOCATION_ERROR;
- }
- }
- memset(*readBuffer, 0, inBuffSize);
-
- int bytesWritten = FWULClient.SendMessage(command, command_size);
- if ((UINT32)bytesWritten != command_size)
- {
- if (_verbose)
- {
- fprintf(stderr, "Error: Could not send data to FWUpdate client through MEI\n");
- }
- return HECI_STATUS_MSG_TRANSMISSION_ERROR;
- }
- *outBuffSize = FWULClient.ReceiveMessage(*readBuffer, inBuffSize, 15000);
- if (0 == *outBuffSize)
- {
- if (_verbose)
- {
- fprintf(stderr, "Error: Could not read data from FWUpdate client through MEI\n");
- }
- return HECI_STATUS_UNEXPECTED_RESPONSE;
- }
- if (_verbose)
- {
- fprintf(stdout, "Data received from FWUpdate Client. %d bytes read\n", *outBuffSize);
- }
- return HECI_STATUS_OK;
-}
-
-
-/*
- * Get ME data information from FW update client using AMTCommunication class
- */
-HECI_STATUS
-FWULCommand::GetFWUVersionAndInfo(FWU_GET_VERSION_MSG_REPLY &verMsg, FWU_GET_INFO_MSG_REPLY &infoMsg)
-{
- UINT8 *readBuffer = NULL;
- UINT32 command_size = sizeof(ME_GET_FW_UPDATE_INFO_REQUEST);
- UINT32 replySize = 0;
- ME_GET_FW_UPDATE_INFO_REQUEST msg;
- HECI_STATUS status;
-
- msg.MessageID = FWU_GET_VERSION;
- status = _call((const unsigned char *)&msg, command_size,
- &readBuffer, &replySize);
- if (status != HECI_STATUS_OK)
- {
- goto fwuvend;
- }
- if (replySize == sizeof(FWU_GET_VERSION_MSG_REPLY))
- {
- if (((FWU_MSG_REPLY_HEADER *)readBuffer)->MessageType != FWU_GET_VERSION_REPLY)
- {
- if (_verbose)
- {
- fprintf(stderr, "Error: MessageType in MEI response is not as expected\n");
- }
- status = HECI_STATUS_UNEXPECTED_RESPONSE;
- goto fwuvend;
- }
- if (((FWU_MSG_REPLY_HEADER *)readBuffer)->Status != PT_STATUS_SUCCESS)
- {
- if (_verbose)
- {
- fprintf(stderr, "Error: Status in MEI response is not as expected\n");
- }
- status = HECI_STATUS_UNEXPECTED_RESPONSE;
- goto fwuvend;
- }
-
- memcpy(&verMsg, readBuffer, sizeof(FWU_GET_VERSION_MSG_REPLY));
-
- msg.MessageID = FWU_GET_INFO;
- status = _call((const unsigned char *)&msg, command_size,
- &readBuffer, &replySize);
- if (status != HECI_STATUS_OK)
- {
- goto fwuvend;
- }
- if (replySize != sizeof(FWU_GET_INFO_MSG_REPLY))
- {
- if (_verbose)
- {
- fprintf(stderr, "Error: MEI response size is not as expected\n");
- }
- status = HECI_STATUS_UNEXPECTED_RESPONSE;
- goto fwuvend;
- }
- if (((FWU_MSG_REPLY_HEADER *)readBuffer)->MessageType != FWU_GET_INFO_REPLY)
- {
- if (_verbose)
- {
- fprintf(stderr, "Error: MessageType in MEI response is not as expected\n");
- }
- status = HECI_STATUS_UNEXPECTED_RESPONSE;
- goto fwuvend;
- }
- if (((FWU_MSG_REPLY_HEADER *)readBuffer)->Status != PT_STATUS_SUCCESS)
- {
- if (_verbose)
- {
- fprintf(stderr, "Error: Status in MEI response is not as expected\n");
- }
- status = HECI_STATUS_UNEXPECTED_RESPONSE;
- goto fwuvend;
- }
-
- memcpy(&infoMsg, readBuffer, sizeof(FWU_GET_INFO_MSG_REPLY));
-
- }
- else if (replySize == sizeof(FWU_GET_VERSION_MSG_REPLY_V3))
- {
- if (((FWU_MSG_REPLY_HEADER_V3 *)readBuffer)->MessageType != FWU_GET_VERSION_REPLY)
- {
- if (_verbose)
- {
- fprintf(stderr, "Error: MessageType in MEI response is not as expected\n");
- }
- status = HECI_STATUS_UNEXPECTED_RESPONSE;
- goto fwuvend;
- }
- if (((FWU_MSG_REPLY_HEADER_V3 *)readBuffer)->Status != PT_STATUS_SUCCESS)
- {
- if (_verbose)
- {
- fprintf(stderr, "Error: Status in MEI response is not as expected\n");
- }
- status = HECI_STATUS_UNEXPECTED_RESPONSE;
- goto fwuvend;
- }
-
- FWU_GET_VERSION_MSG_REPLY_V3 *rep = (FWU_GET_VERSION_MSG_REPLY_V3 *)readBuffer;
- verMsg.MessageType = FWU_GET_VERSION_REPLY;
- verMsg.Status = rep->Status;
- verMsg.Sku = rep->Sku;
- verMsg.ICHVer = rep->ICHVer;
- verMsg.MCHVer = rep->MCHVer;
- verMsg.Vendor = rep->Vendor;
- verMsg.LastFwUpdateStatus = rep->LastFwUpdateStatus;
- verMsg.HwSku = rep->Sku;
- memcpy(&verMsg.CodeVersion, &(rep->CodeVersion), sizeof(verMsg.CodeVersion));
- memset(&verMsg.AMTVersion, 0, sizeof(verMsg.AMTVersion));
- verMsg.EnabledUpdateInterfaces = rep->EnabledUpdateInterfaces;
- verMsg.Reserved = 0;
-
- memset(&infoMsg, 0, sizeof(infoMsg));
- } else {
- if (_verbose)
- {
- fprintf(stderr, "Error: MEI response size is not as expected\n");
- }
- status = HECI_STATUS_UNEXPECTED_RESPONSE;
- goto fwuvend;
- }
-
-fwuvend:
-
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
-
- return status;
-}
diff --git a/usr/src/cmd/lms/heci/FWULCommand.h b/usr/src/cmd/lms/heci/FWULCommand.h
deleted file mode 100644
index a8049da338..0000000000
--- a/usr/src/cmd/lms/heci/FWULCommand.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/*******************************************************************************
- * 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 __FWUL_COMMAND_H__
-#define __FWUL_COMMAND_H__
-
-#include "HECIUnix.h"
-#include "StatusCodeDefinitions.h"
-
-#pragma pack(1)
-
-typedef struct _FWU_VERSION
-{
- UINT16 Major;
- UINT16 Minor;
- UINT16 Hotfix;
- UINT16 Build;
-} FWU_VERSION;
-
-typedef enum
-{
- FWU_GET_VERSION = 0,
- FWU_GET_VERSION_REPLY,
- FWU_START,
- FWU_START_REPLY,
- FWU_DATA,
- FWU_DATA_REPLY,
- FWU_END,
- FWU_END_REPLY,
- FWU_GET_INFO,
- FWU_GET_INFO_REPLY
-} FWU_HECI_MESSAGE_TYPE;
-
-typedef struct _ME_GET_FW_UPDATE_INFO_REQUEST
-{
- UINT32 MessageID;
-} ME_GET_FW_UPDATE_INFO_REQUEST;
-
-typedef struct _FWU_MSG_REPLY_HEADER
-{
- UINT32 MessageType;
- UINT32 Status;
-} FWU_MSG_REPLY_HEADER;
-
-typedef struct _FWU_MSG_REPLY_HEADER_V3
-{
- UINT8 MessageType;
- UINT32 Status;
-} FWU_MSG_REPLY_HEADER_V3;
-
-typedef struct _FWU_GET_VERSION_MSG_REPLY
-{
- UINT32 MessageType;
- UINT32 Status;
- UINT32 Sku;
- UINT32 ICHVer;
- UINT32 MCHVer;
- UINT32 Vendor;
- UINT32 LastFwUpdateStatus;
- UINT32 HwSku;
- FWU_VERSION CodeVersion;
- FWU_VERSION AMTVersion;
- UINT16 EnabledUpdateInterfaces;
- UINT16 Reserved;
-} FWU_GET_VERSION_MSG_REPLY;
-
-typedef struct _FWU_GET_VERSION_MSG_REPLY_V3
-{
- UINT8 MessageType;
- UINT32 Status;
- UINT32 Sku;
- UINT32 ICHVer;
- UINT32 MCHVer;
- UINT32 Vendor;
- FWU_VERSION CodeVersion;
- FWU_VERSION RcvyVersion;
- UINT16 EnabledUpdateInterfaces;
- UINT32 LastFwUpdateStatus;
- UINT32 Reserved;
-} FWU_GET_VERSION_MSG_REPLY_V3;
-
-typedef struct _FWU_GET_INFO_MSG_REPLY
-{
- UINT32 MessageType;
- UINT32 Status;
- FWU_VERSION MEBxVersion;
- UINT32 FlashOverridePolicy;
- UINT32 ManageabilityMode;
- UINT32 BiosBootState;
- struct {
- UINT32 CryptoFuse :1;
- UINT32 FlashProtection:1;
- UINT32 FwOverrideQualifier:2;
- UINT32 MeResetReason:2;
- UINT32 FwOverrideCounter:8;
- UINT32 reserved:18;
- } Fields;
- UINT8 BiosVersion[20];
-} FWU_GET_INFO_MSG_REPLY;
-
-#pragma pack(0)
-
-class FWULCommand
-{
-public:
- FWULCommand(bool verbose = false);
- ~FWULCommand();
-
- HECI_STATUS GetFWUVersionAndInfo(FWU_GET_VERSION_MSG_REPLY &verMsg, FWU_GET_INFO_MSG_REPLY &infoMsg);
-
- HECILinux FWULClient;
-
-private:
- HECI_STATUS _call(const unsigned char *command, UINT32 command_size, UINT8 **readBuffer, UINT32 *outBuffSize);
-
- bool _verbose;
-};
-
-#endif //__FWUL_COMMAND_H__
-
diff --git a/usr/src/cmd/lms/heci/HECIUnix.cpp b/usr/src/cmd/lms/heci/HECIUnix.cpp
deleted file mode 100644
index 1334ef1352..0000000000
--- a/usr/src/cmd/lms/heci/HECIUnix.cpp
+++ /dev/null
@@ -1,295 +0,0 @@
-/*******************************************************************************
- * 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.
- *******************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include <cstdio>
-#include <cstring>
-#include <cstdlib>
-#include <cerrno>
-#include <fcntl.h>
-#include <sys/ioctl.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
-{
- uint32_t size;
- 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
-} heci_ioctl_data_t;
-
-/* IOCTL commands */
-#undef HECI_IOCTL
-#undef IOCTL_HECI_GET_VERSION
-#undef IOCTL_HECI_CONNECT_CLIENT
-#undef IOCTL_HECI_WD
-#define HECI_IOCTL_TYPE 0x48
-#define IOCTL_HECI_GET_VERSION \
- _IOWR(HECI_IOCTL_TYPE, 0x0, heci_ioctl_data_t)
-#define IOCTL_HECI_CONNECT_CLIENT \
- _IOWR(HECI_IOCTL_TYPE, 0x01, heci_ioctl_data_t)
-#define IOCTL_HECI_WD \
- _IOWR(HECI_IOCTL_TYPE, 0x02, heci_ioctl_data_t)
-#define IAMT_HECI_GET_RECEIVED_MESSAGE_DATA \
- _IOW(HECI_IOCTL_TYPE, 0x03, heci_ioctl_data_t)
-
-#pragma pack(0)
-
-/***************************** public functions *****************************/
-
-HECILinux::HECILinux(const GUID guid, bool verbose) :
-HECI(guid, verbose),
-_fd(-1),
-m_haveHeciVersion(false)
-{
-}
-
-HECILinux::~HECILinux()
-{
- if (_fd != -1) {
- close(_fd);
- }
-}
-
-bool HECILinux::GetHeciVersion(HECI_VERSION &version) const
-{
- if (m_haveHeciVersion) {
- memcpy(&version, &m_heciVersion, sizeof(HECI_VERSION));
- return true;
- }
- return false;
-}
-
-bool HECILinux::Init(unsigned char reqProtocolVersion)
-{
- int result;
- HECI_CLIENT *heci_client;
- bool return_result = true;
- heci_ioctl_data_t version_response;
- heci_ioctl_data_t client_connect;
-
- m_haveHeciVersion = false;
- if (_initialized) {
- Deinit();
- }
-
- _fd = open("/dev/heci", O_RDWR);
-
- if (_fd == -1 ) {
- if (_verbose) {
- fprintf(stderr, "Error: Cannot establish a handle to the HECI driver\n");
- }
- return false;
- }
- _initialized = true;
- version_response.size = sizeof(HECI_VERSION);
- version_response.data = (char *)malloc(version_response.size);
- if (!version_response.data) {
- if (_verbose) {
- fprintf(stderr, "malloc failure.\n");
- }
- return_result = false;
- Deinit();
- goto heci_free;
- }
-
- result = ioctl(_fd, IOCTL_HECI_GET_VERSION, &version_response);
- if (result) {
- if (_verbose) {
- fprintf(stderr, "error in IOCTL_HECI_GET_VERSION recieve message. err=%d\n", result);
- }
- return_result = false;
- Deinit();
- goto heci_free;
- }
- memcpy(&m_heciVersion, version_response.data, sizeof(HECI_VERSION));
- m_haveHeciVersion = true;
- if (_verbose) {
- fprintf(stdout, "Connected to HECI driver, version: %d.%d.%d.%d\n",
- m_heciVersion.major, m_heciVersion.minor, m_heciVersion.hotfix, m_heciVersion.build);
- fprintf(stdout, "Size of guid = %lu\n", (unsigned long)sizeof(_guid));
- }
- client_connect.size = sizeof(_guid);
- client_connect.data = (char *)malloc(client_connect.size);
- if (!client_connect.data) {
- if (_verbose) {
- fprintf(stderr, "malloc failure.\n");
- }
- return_result = false;
- Deinit();
- goto heci_free;
- }
- memcpy(client_connect.data, &_guid, sizeof(_guid));
- result = ioctl(_fd, IOCTL_HECI_CONNECT_CLIENT, &client_connect);
- if (result) {
- if (_verbose) {
- fprintf(stderr, "error in IOCTL_HECI_CONNECT_CLIENT recieve message. err=%d\n", result);
- }
- return_result = false;
- Deinit();
- goto heci_free;
- }
- heci_client = (HECI_CLIENT *) client_connect.data;
- if (_verbose) {
- fprintf(stdout, "max_message_length %d \n", (heci_client->MaxMessageLength));
- fprintf(stdout, "protocol_version %d \n", (heci_client->ProtocolVersion));
- }
-
- if ((reqProtocolVersion > 0) && (heci_client->ProtocolVersion != reqProtocolVersion)) {
- if (_verbose) {
- fprintf(stderr, "Error: MEI protocol version not supported\n");
- }
- return_result = false;
- Deinit();
- goto heci_free;
- }
-
- _protocolVersion = heci_client->ProtocolVersion;
- _bufSize = heci_client->MaxMessageLength;
-
-heci_free:
- if (NULL != version_response.data) {
- free(version_response.data);
- }
- if (NULL != client_connect.data) {
- free(client_connect.data);
- }
- return return_result;
-}
-
-void HECILinux::Deinit()
-{
- if (_fd != -1) {
- close(_fd);
- _fd = -1;
- }
-
- _bufSize = 0;
- _protocolVersion = 0;
- _initialized = false;
-}
-
-int HECILinux::ReceiveMessage(unsigned char *buffer, int len, unsigned long timeout)
-{
- int rv = 0;
- int error = 0;
-
- if (_verbose) {
- fprintf(stdout, "call read length = %d\n", len);
- }
- rv = read(_fd, (void*)buffer, len);
- if (rv < 0) {
- error = errno;
- if (_verbose) {
- fprintf(stderr, "read failed with status %d %d\n", rv, error);
- }
- Deinit();
- } else {
- if (_verbose) {
- fprintf(stderr, "read succeded with result %d\n", rv);
- }
- }
- return rv;
-}
-
-int HECILinux::SendMessage(const unsigned char *buffer, int len, unsigned long timeout)
-{
- int rv = 0;
- int return_length =0;
- int error = 0;
- fd_set set;
- struct timeval tv;
-
- tv.tv_sec = timeout / 1000;
- tv.tv_usec =(timeout % 1000) * 1000000;
-
- if (_verbose) {
- fprintf(stdout, "call write length = %d\n", len);
- }
- rv = write(_fd, (void *)buffer, len);
- if (rv < 0) {
- error = errno;
- if (_verbose) {
- fprintf(stderr,"write failed with status %d %d\n", rv, error);
- }
- goto out;
- }
-
- return_length = rv;
-
- FD_ZERO(&set);
- FD_SET(_fd, &set);
- rv = select(_fd+1 ,&set, NULL, NULL, &tv);
- if (rv > 0 && FD_ISSET(_fd, &set)) {
- if (_verbose) {
- fprintf(stderr, "write success\n");
- }
- }
- else if (rv == 0) {
- if (_verbose) {
- fprintf(stderr, "write failed on timeout with status\n");
- }
- goto out;
- }
- else { //rv<0
- if (_verbose) {
- fprintf(stderr, "write failed on select with status %d\n", rv);
- }
- goto out;
- }
-
- rv = return_length;
-
-out:
- if (rv < 0) {
- Deinit();
- }
-
- return rv;
-}
-
diff --git a/usr/src/cmd/lms/heci/HECIUnix.h b/usr/src/cmd/lms/heci/HECIUnix.h
deleted file mode 100644
index 670beb1809..0000000000
--- a/usr/src/cmd/lms/heci/HECIUnix.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * 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_UNIX_H__
-#define __HECI_UNIX_H__
-
-#include "heci.h"
-
-class HECILinux : public HECI
-{
-public:
- HECILinux(const GUID guid, bool verbose = false);
- virtual ~HECILinux();
-
- virtual bool Init(unsigned char reqProtocolVersion = 0);
- virtual void Deinit();
- virtual int ReceiveMessage(unsigned char *buffer, int len, unsigned long timeout = 2000);
- virtual int SendMessage(const unsigned char *buffer, int len, unsigned long timeout = 2000);
- virtual unsigned int GetBufferSize() const { return _bufSize; }
- virtual unsigned char GetProtocolVersion() const { return _protocolVersion; }
- virtual bool GetHeciVersion(HECI_VERSION &version) const;
- virtual bool IsInitialized() const { return _initialized; }
-
-private:
- int _fd;
- bool m_haveHeciVersion;
- HECI_VERSION m_heciVersion;
-};
-
-#endif // __HECI_UNIX_H__
diff --git a/usr/src/cmd/lms/heci/HECI_if.h b/usr/src/cmd/lms/heci/HECI_if.h
deleted file mode 100644
index 5dd1fa824f..0000000000
--- a/usr/src/cmd/lms/heci/HECI_if.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/*******************************************************************************
- * 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_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;
-
-const GUID HECI_PTHI = {0x12f80028, 0xb4b7, 0x4b2d, {0xac, 0xa8, 0x46, 0xe0, 0xff, 0x65, 0x81, 0x4c}};
-
-// Define GUID used to connect to the FWUpdate client (via the HECI device)
-// {309DCDE8-CCB1-4062-8F78-600115A34327}
-const GUID FW_UPDATE_GUID = {0x309dcde8, 0xccb1, 0x4062, {0x8f, 0x78, 0x60, 0x1, 0x15, 0xa3, 0x43, 0x27}};
-
-const GUID WD_GUID = {0x05B79A6F, 0x4628, 0x4D7F, {0x89, 0x9D, 0xA9, 0x15, 0x14, 0xCB, 0x32, 0xAB}};
-
-#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; //Danbury Technology
- UINT32 Fps :1; //Fingerprint Sensor
- UINT32 HomeIT :1; //Home IT
- UINT32 Mctp :1; //MCTP
- UINT32 WoX :1; //Wake on X
- 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__
diff --git a/usr/src/cmd/lms/heci/MNGCommand.cpp b/usr/src/cmd/lms/heci/MNGCommand.cpp
deleted file mode 100644
index fc60cc79eb..0000000000
--- a/usr/src/cmd/lms/heci/MNGCommand.cpp
+++ /dev/null
@@ -1,147 +0,0 @@
-/*******************************************************************************
- * 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.
- *******************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include <cstdio>
-#include <cstdlib>
-
-#ifdef __sun
-#include <stdio.h>
-#include <stdlib.h>
-#endif // __sun
-
-#include "MNGCommand.h"
-
-MNGCommand::MNGCommand(bool verbose) :
-MNGClient(WD_GUID, verbose)
-{
- _verbose = verbose;
-}
-
-MNGCommand::~MNGCommand(void)
-{
-}
-
-HECI_STATUS MNGCommand::_call(const unsigned char *command, UINT32 command_size, UINT8 **readBuffer, UINT32 *outBuffSize)
-{
- UINT32 inBuffSize;
- *outBuffSize = 0;
-
- inBuffSize = MNGClient.GetBufferSize();
- if (NULL == *readBuffer)
- {
- *readBuffer = (UINT8 *)malloc(sizeof(UINT8) * inBuffSize);
- if (NULL == *readBuffer)
- {
- if (_verbose)
- {
- fprintf(stderr, "Error: Malloc failed\n");
- }
- return HECI_STATUS_MEMORY_ALLOCATION_ERROR;
- }
- }
- memset(*readBuffer, 0, inBuffSize);
-
- int bytesWritten = MNGClient.SendMessage(command, command_size);
- if ((UINT32)bytesWritten != command_size)
- {
- if (_verbose)
- {
- fprintf(stderr, "Error: Could not send data to MNG client through MEI\n");
- }
- return HECI_STATUS_MSG_TRANSMISSION_ERROR;
- }
- *outBuffSize = MNGClient.ReceiveMessage(*readBuffer, inBuffSize, 15000);
- if (0 == *outBuffSize)
- {
- if (_verbose)
- {
- fprintf(stderr, "Error: Could not read data from MNG client through MEI\n");
- }
- return HECI_STATUS_UNEXPECTED_RESPONSE;
- }
- if (_verbose)
- {
- fprintf(stdout, "Data received from MNG Client. %d bytes read\n", *outBuffSize);
- }
- return HECI_STATUS_OK;
-}
-
-
-/*
- * Get ME data information from MNG client
- */
-HECI_STATUS
-MNGCommand::GetMEInfo(MNG_GET_ME_INFORMATION_RESPONSE &infoMsg)
-{
- UINT8 *readBuffer = NULL;
- UINT32 command_size = sizeof(MNG_GET_ME_INFO_HEADER);
- UINT32 replySize = 0;
- MNG_REQUEST msg = MNG_GET_ME_INFO_HEADER;
- HECI_STATUS status;
-
- status = _call((const unsigned char *)&msg, command_size,
- &readBuffer, &replySize);
-
- if (status != HECI_STATUS_OK)
- {
- goto mngend;
- }
- if (replySize != sizeof(MNG_GET_ME_INFORMATION_RESPONSE))
- {
- if (_verbose)
- {
- fprintf(stderr, "Error: Size of MEI response is not as expected\n");
- }
- status = HECI_STATUS_UNEXPECTED_RESPONSE;
- goto mngend;
- }
- if (((MNG_GET_ME_INFORMATION_RESPONSE *)readBuffer)->Version != MNG_GET_ME_INFO_Version)
- {
- if (_verbose)
- {
- fprintf(stderr, "Error: MEI response size is not as expected\n");
- }
- status = HECI_STATUS_UNEXPECTED_RESPONSE;
- goto mngend;
- }
- memcpy(&infoMsg, readBuffer, sizeof(MNG_GET_ME_INFORMATION_RESPONSE));
-
-mngend:
-
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
-
- return status;
-}
diff --git a/usr/src/cmd/lms/heci/MNGCommand.h b/usr/src/cmd/lms/heci/MNGCommand.h
deleted file mode 100644
index fbd83b0b23..0000000000
--- a/usr/src/cmd/lms/heci/MNGCommand.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * 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 __MNG_COMMAND_H__
-#define __MNG_COMMAND_H__
-
-#include "HECIUnix.h"
-#include "StatusCodeDefinitions.h"
-
-#pragma pack(1)
-
-typedef struct _MNG_REQUEST
-{
- UINT8 Cmd;
- UINT8 ByteCount;
- UINT8 SubCmd;
- UINT8 Version;
-} MNG_REQUEST;
-
-typedef struct _MNG_GET_ME_INFORMATION_RESPONSE
-{
- UINT32 Version;
- MEFWCAPS_SKU Sku;
- MEFWCAPS_MANAGEABILITY_SUPP MngMode;
-} MNG_GET_ME_INFORMATION_RESPONSE;
-
-#pragma pack(0)
-
-class MNGCommand
-{
-public:
- MNGCommand(bool verbose = false);
- ~MNGCommand();
-
- HECI_STATUS GetMEInfo(MNG_GET_ME_INFORMATION_RESPONSE &infoMsg);
-
- HECILinux MNGClient;
-
-private:
- HECI_STATUS _call(const unsigned char *command, UINT32 command_size, UINT8 **readBuffer, UINT32 *outBuffSize);
-
- bool _verbose;
-
-};
-
-const MNG_REQUEST MNG_GET_ME_INFO_HEADER = {0x07, 0x02, 0x01, 0x10};
-const UINT32 MNG_GET_ME_INFO_Version = 0x00010000;
-
-
-#endif //__MNG_COMMAND_H__
-
diff --git a/usr/src/cmd/lms/heci/PTHICommand.cpp b/usr/src/cmd/lms/heci/PTHICommand.cpp
deleted file mode 100644
index 8fabac6bb9..0000000000
--- a/usr/src/cmd/lms/heci/PTHICommand.cpp
+++ /dev/null
@@ -1,1236 +0,0 @@
-/*******************************************************************************
- * 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.
- *******************************************************************************/
-
-//----------------------------------------------------------------------------
-//
-// File: PTHICommand.cpp
-//
-//----------------------------------------------------------------------------
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include <cstdio>
-#include <cstdlib>
-#include "PTHICommand.h"
-
-
-PTHICommand::PTHICommand(bool verbose, unsigned long sendTimeout) :
-PTHIClient(HECI_PTHI, verbose),
-m_sendTimeout(sendTimeout)
-{
-}
-
-PTHICommand::~PTHICommand(void)
-{
-}
-
-AMT_STATUS PTHICommand::_call(const unsigned char *command, UINT32 command_size, UINT8 **readBuffer, UINT32 rcmd, unsigned int expSize)
-{
- UINT32 inBuffSize;
- UINT32 outBuffSize = 0;
-
- inBuffSize = PTHIClient.GetBufferSize();
- *readBuffer = (UINT8 *)malloc(sizeof(UINT8) * inBuffSize);
- if (NULL == *readBuffer)
- {
- return PTSDK_STATUS_RESOURCES;
- }
- memset(*readBuffer, 0, inBuffSize);
-
- int bytesWritten = PTHIClient.SendMessage(command, command_size, m_sendTimeout);
- if ((UINT32)bytesWritten != command_size)
- {
- return AMT_STATUS_INTERNAL_ERROR;
- }
- outBuffSize = PTHIClient.ReceiveMessage(*readBuffer, inBuffSize);
- if (0 == outBuffSize)
- {
- return PTHI_STATUS_EMPTY_RESPONSE;
- }
- AMT_STATUS status = ((PTHI_RESPONSE_MESSAGE_HEADER *)*readBuffer)->Status;
- if (status != AMT_STATUS_SUCCESS)
- {
- return status;
- }
- status = _verifyResponseHeader(rcmd, ((PTHI_RESPONSE_MESSAGE_HEADER *)*readBuffer)->Header, outBuffSize);
- if (status != AMT_STATUS_SUCCESS)
- {
- return status;
- }
- if ((expSize != 0) && (expSize != outBuffSize))
- {
- return PTSDK_STATUS_INTERNAL_ERROR;
- }
- return AMT_STATUS_SUCCESS;
-}
-
-/*
-* Confirms the correctness of the response message header
-* and the response message size
-* Arguments:
-* command - appropriate Host interface command
-* response_header - reference to the response message header
-* response_size - value that holds the actual size of the
-* response message
-* expected_size - value that holds the expected size of the
-* response message
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* PTSDK_STATUS_INTERNAL_ERROR - on failure
-*/
-AMT_STATUS PTHICommand::_verifyResponseHeader(
- const UINT32 command, const PTHI_MESSAGE_HEADER &response_header,
- UINT32 response_size)
-{
- AMT_STATUS status = AMT_STATUS_SUCCESS;
-
- if (response_size < sizeof(PTHI_RESPONSE_MESSAGE_HEADER)) {
- status = AMT_STATUS_INTERNAL_ERROR;
- } else if (response_size != (response_header.Length + sizeof(PTHI_MESSAGE_HEADER))) {
- status = AMT_STATUS_INTERNAL_ERROR;
- } else if (response_header.Command.cmd.val != command) {
- status = AMT_STATUS_INTERNAL_ERROR;
- } else if (response_header.Reserved != 0) {
- status = AMT_STATUS_INTERNAL_ERROR;
- } else if (response_header.Version.MajorNumber != AMT_MAJOR_VERSION
- || response_header.Version.MinorNumber < AMT_MINOR_VERSION) {
- status = AMT_STATUS_INTERNAL_ERROR;
- }
-
- return status;
-}
-
-/*
-* Confirms the correctness of the GetCodeVersions response message
-* Arguments:
-* response - reference to the response message
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* PTSDK_STATUS_INTERNAL_ERROR - on failure
-*/
-AMT_STATUS PTHICommand::_verifyCodeVersions(
- const CFG_GET_CODE_VERSIONS_RESPONSE &response)
-{
- AMT_STATUS status = AMT_STATUS_SUCCESS;
- UINT32 codeVerLen;
- UINT32 ptVerTypeCount;
- UINT32 len = 0;
- UINT32 i;
-
- do {
- codeVerLen = response.Header.Header.Length - sizeof(AMT_STATUS);
- ptVerTypeCount = codeVerLen - sizeof(response.CodeVersions.BiosVersion)- sizeof(response.CodeVersions.VersionsCount);
- if (response.CodeVersions.VersionsCount != (ptVerTypeCount/sizeof(AMT_VERSION_TYPE)))
- {
- status = AMT_STATUS_INTERNAL_ERROR;
- break;
- }
-
- for (i = 0; i < (response.CodeVersions.VersionsCount); i ++)
- {
- len = response.CodeVersions.Versions[i].Description.Length;
-
- if (len > UNICODE_STRING_LEN)
- {
- status = AMT_STATUS_INTERNAL_ERROR;
- break;
- }
-
- len = response.CodeVersions.Versions[i].Version.Length;
- if (response.CodeVersions.Versions[i].Version.String[len] != '\0' ||
- (len != strlen((CHAR *)(response.CodeVersions.Versions[i].Version.String))))
- {
- status = AMT_STATUS_INTERNAL_ERROR;
- break;
- }
- }
- } while (0);
-
- return status;
-}
-
-/*
-* GetVersions response message PTHI command
-* Arguments:
-* response - reference to the CODE_VERSIONS struct
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* AMT_STATUS_INTERNAL_ERROR - on failure
-*/
-AMT_STATUS PTHICommand::GetCodeVersions(CODE_VERSIONS &codeVersions)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(GET_CODE_VERSION_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(GET_CODE_VERSION_HEADER), sizeof(GET_CODE_VERSION_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, CODE_VERSIONS_RESPONSE, 0);
- do {
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
- CFG_GET_CODE_VERSIONS_RESPONSE *tmp_response = (CFG_GET_CODE_VERSIONS_RESPONSE *)readBuffer;
- status = _verifyCodeVersions(*tmp_response);
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
-
- memcpy(&codeVersions, &(tmp_response->CodeVersions), sizeof(CODE_VERSIONS));
-
- } while (0);
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Calls to GetProvisioningMode Host interface command
-* Arguments:
-* mode - reference to the pre-allocated structure
-* which will hold the result
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::GetProvisioningMode(CFG_PROVISIONING_MODE &mode)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(GET_PROVISIONING_MODE_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(GET_PROVISIONING_MODE_HEADER), sizeof(GET_PROVISIONING_MODE_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, PROVISIONING_MODE_RESPONSE, sizeof(CFG_GET_PROVISIONING_MODE_RESPONSE));
- do {
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
- CFG_GET_PROVISIONING_MODE_RESPONSE *tmp_response = (CFG_GET_PROVISIONING_MODE_RESPONSE *)readBuffer;
-
- mode = tmp_response->ProvisioningMode;
-
- } while (0);
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-AMT_STATUS PTHICommand::GetProvisioningMode(CFG_PROVISIONING_MODE &mode, AMT_BOOLEAN &legacy)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(GET_PROVISIONING_MODE_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(GET_PROVISIONING_MODE_HEADER), sizeof(GET_PROVISIONING_MODE_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, PROVISIONING_MODE_RESPONSE, sizeof(CFG_GET_PROVISIONING_MODE_RESPONSE));
- do {
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
- CFG_GET_PROVISIONING_MODE_RESPONSE *tmp_response = (CFG_GET_PROVISIONING_MODE_RESPONSE *)readBuffer;
-
- mode = tmp_response->ProvisioningMode;
- legacy = tmp_response->LegacyMode;
-
- } while (0);
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Calls to GetProvisioningState Host interface command
-* Arguments:
-* state - reference to the pre-allocated structure
-* which will hold the result
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::GetProvisioningState(AMT_PROVISIONING_STATE &state)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(GET_PROVISIONING_STATE_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(GET_PROVISIONING_STATE_HEADER), sizeof(GET_PROVISIONING_STATE_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, PROVISIONING_STATE_RESPONSE, sizeof(CFG_GET_PROVISIONING_STATE_RESPONSE));
- do {
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
- CFG_GET_PROVISIONING_STATE_RESPONSE *tmp_response = (CFG_GET_PROVISIONING_STATE_RESPONSE *)readBuffer;
-
- state = tmp_response->ProvisioningState;
-
- } while (0);
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Calls to GetFeatureState Host interface command
-* Arguments:
-* requestID Indicates what feature status to query:
-* 0 Redirection Sessions Status
-* 1 System Defense Status
-* 2 WebUI Status
-* requestStatus The requested feature state(the size depand on the requestID).(OUT)
-*
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::GetFeaturesState(UINT32 requestID, AMT_BOOLEAN (&requestStatus)[2])
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(CFG_GET_FEATURES_STATE_REQUEST);
- unsigned char command[command_size];
-
- memcpy(command, &GET_FEATURES_STATE_HEADER, sizeof(GET_FEATURES_STATE_HEADER));
- memcpy(command + sizeof(GET_FEATURES_STATE_HEADER), &(requestID), sizeof(UINT32));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, GET_FEATURES_STATE_RESPONSE, sizeof(CFG_GET_FEATURES_STATE_RESPONSE));
- do {
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
- CFG_GET_FEATURES_STATE_RESPONSE *tmp_response = (CFG_GET_FEATURES_STATE_RESPONSE *)readBuffer;
-
- GET_FEATURES_REDIRECTION_SESSION_STATUS redirectionState;
- GET_FEATURES_SYSTEM_DEFENSE_STATUS_RESPONSE systemDefenseState;
- GET_FEATURES_WEB_UI_STATUS_RESPONSE webUIState;
- switch (requestID)
- {
- case REDIRECTION_SESSION:
- redirectionState = tmp_response->Data.rs;
- requestStatus[0] = redirectionState.SolOpen;
- requestStatus[1] = redirectionState.IderOpen;
- break;
-
- case SYSTEM_DEFENSE:
- systemDefenseState = tmp_response->Data.sd;
- requestStatus[0] = systemDefenseState.SystemDefenseActivated;
- break;
-
- case WEB_UI:
- webUIState = tmp_response->Data.webUI;
- requestStatus[0] = webUIState.WebUiEnabled;
- break;
- }
- } while (0);
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Calls to GetLastHostResetReason Host interface command
-* Arguments:
-* reason Indicates whether the last host reason was because of remote control operation(0)
-* or other reason(1). (OUT)
-* remoteControlTimeStamp In case the reason was due to remote control then this field
-* indicates the timestamp of when the remote control command has been executed.
-* (The timestamp is the number of seconds since 1/1/1970)
-*
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::GetLastHostResetReason(UINT32 &reason, UINT32 &remoteControlTimeStamp)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(GET_LAST_HOST_RESET_REASON_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(GET_LAST_HOST_RESET_REASON_HEADER), sizeof(GET_LAST_HOST_RESET_REASON_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, GET_LAST_HOST_RESET_REASON_RESPONSE, sizeof(CFG_GET_LAST_HOST_RESET_REASON_RESPONSE));
- do {
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
- CFG_GET_LAST_HOST_RESET_REASON_RESPONSE *tmp_response = (CFG_GET_LAST_HOST_RESET_REASON_RESPONSE *)readBuffer;
-
- reason = tmp_response->Reason;
- remoteControlTimeStamp = tmp_response->RemoteControlTimeStamp;
-
- } while (0);
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Calls to GetCurrentPowerPolicy Host interface command
-* Arguments:
-* policyName The power policy name. (OUT)
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::GetCurrentPowerPolicy(AMT_ANSI_STRING &policyName)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(GET_CURRENT_POWER_POLICY_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(GET_CURRENT_POWER_POLICY_HEADER), sizeof(GET_CURRENT_POWER_POLICY_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, GET_CURRENT_POWER_POLICY_RESPONSE, 0);
- do {
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
- CFG_GET_CURRENT_POWER_POLICY_RESPONSE *tmp_response = (CFG_GET_CURRENT_POWER_POLICY_RESPONSE *)readBuffer;
- status = _verifyCurrentPowerPolicy(*tmp_response);
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
-
- policyName.Length = tmp_response->PolicyName.Length;
- policyName.Buffer = (CHAR *)malloc(policyName.Length * sizeof(CHAR));
- if (NULL == policyName.Buffer) {
- status = AMT_STATUS_INTERNAL_ERROR;
- } else {
- memcpy(policyName.Buffer, &(tmp_response->PolicyName.Buffer),
- policyName.Length * sizeof(CHAR));
- }
- } while (0);
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Confirms the correctness of the GetCurrentPowerPolicy response message
-* Arguments:
-* response - reference to the response message
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* PTSDK_STATUS_INTERNAL_ERROR - on failure
-*/
-AMT_STATUS PTHICommand::_verifyCurrentPowerPolicy(const CFG_GET_CURRENT_POWER_POLICY_RESPONSE &response)
-{
- ULONG ByteCount = response.Header.Header.Length;
- if (ByteCount != (sizeof(CFG_GET_CURRENT_POWER_POLICY_RESPONSE)
- - sizeof(PTHI_MESSAGE_HEADER) - sizeof(CHAR *)
- + response.PolicyName.Length))
- {
- return PTSDK_STATUS_INTERNAL_ERROR;
- }
- return AMT_STATUS_SUCCESS;
-}
-
-/*
-* Calls to GetLanInterfaceSttings Host interface command
-* Arguments:
-* interfaceSettings The interface to get the settings for.
-* lanSettings reference to a pre allocated struct which will hold the lan settings. (OUT)
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::GetLanInterfaceSettings(UINT32 interfaceSettings, LAN_SETTINGS &lanSettings)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(CFG_GET_LAN_INTERFACE_SETTINGS_REQUEST);
- unsigned char command[command_size];
-
- memcpy(command, &(GET_LAN_INTERFACE_SETTINGS_HEADER), sizeof(GET_LAN_INTERFACE_SETTINGS_HEADER));
- memcpy(command + sizeof(GET_LAN_INTERFACE_SETTINGS_HEADER),
- &(interfaceSettings), sizeof(UINT32));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, GET_LAN_INTERFACE_SETTINGS_RESPONSE, sizeof(CFG_GET_LAN_INTERFACE_SETTINGS_RESPONSE));
- do {
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
- CFG_GET_LAN_INTERFACE_SETTINGS_RESPONSE *tmp_response = (CFG_GET_LAN_INTERFACE_SETTINGS_RESPONSE *)readBuffer;
-
- lanSettings.Enabled = tmp_response->Enabled;
- lanSettings.Ipv4Address = tmp_response->Ipv4Address;
- lanSettings.DhcpEnabled = tmp_response->DhcpEnabled;
- lanSettings.DhcpIpMode = tmp_response->DhcpIpMode;
- lanSettings.LinkStatus = tmp_response->LinkStatus;
- memcpy(lanSettings.MacAddress, tmp_response->MacAddress, sizeof(tmp_response->MacAddress));
-
- } while (0);
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/**
-* Gets the HECI driver version
-* Arguments:
-* heciVersion - pointewr to HECI_VERSION struct (out)
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* PTSDK_STATUS_INVALID_PARAM - on failure
-*/
-AMT_STATUS PTHICommand::GetHeciVersion(HECI_VERSION &heciVersion)
-{
- if (PTHIClient.GetHeciVersion(heciVersion)) {
- return AMT_STATUS_SUCCESS;
- }
- return AMT_STATUS_INTERNAL_ERROR;
-}
-
-/*
-* Calls to GetSecurityParameters Host interface command
-* Arguments:
-* tlsEnabled true if AMT on TLS mode. (OUT)
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::GetTLSEnabled(AMT_BOOLEAN &tlsEnabled)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(GET_SECURITY_PARAMETERS_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(GET_SECURITY_PARAMETERS_HEADER), sizeof(GET_SECURITY_PARAMETERS_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, GET_SECURITY_PARAMETERS_RESPONSE, sizeof(CFG_GET_SECURITY_PARAMETERS_RESPONSE));
- do {
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
- CFG_GET_SECURITY_PARAMETERS_RESPONSE *tmp_response = (CFG_GET_SECURITY_PARAMETERS_RESPONSE *)readBuffer;
-
- tlsEnabled = tmp_response->TLSEnabled;
-
- } while (0);
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Calls to GetDNSSuffixList Host interface command
-* Arguments:
-* dnsSuffixList reference to list of DNS suffix strings. (OUT)
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::GetDNSSuffixList(std::list<std::string> &dnsSuffixList)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(GET_DNS_SUFFIX_LIST_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(GET_DNS_SUFFIX_LIST_HEADER), sizeof(GET_DNS_SUFFIX_LIST_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, GET_DNS_SUFFIX_LIST_RESPONSE, 0);
- do {
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
- CFG_GET_DNS_SUFFIX_LIST_RESPONSE *tmp_response = (CFG_GET_DNS_SUFFIX_LIST_RESPONSE *)readBuffer;
- status = _verifyGetDNSSuffixList(*tmp_response);
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
-
- char *current = (char *)tmp_response->Data;
- while (current < (char *)tmp_response->Data + tmp_response->DataLength)
- {
- std::string dnsSuffix = current;
- if (dnsSuffix.length() > tmp_response->DataLength)
- {
- status = PTSDK_STATUS_INTERNAL_ERROR;
- break;
- }
- if (!dnsSuffix.empty())
- {
- dnsSuffixList.push_back(dnsSuffix);
- }
- current += dnsSuffix.length() + 1;
- }
- } while (0);
-
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Confirms the correctness of the GetDNSSuffixList response message
-* Arguments:
-* response - reference to the response message
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* PTSDK_STATUS_INTERNAL_ERROR - on failure
-*/
-AMT_STATUS PTHICommand::_verifyGetDNSSuffixList(const CFG_GET_DNS_SUFFIX_LIST_RESPONSE &response)
-{
- ULONG ByteCount = response.Header.Header.Length;
- if (ByteCount != (sizeof(CFG_GET_DNS_SUFFIX_LIST_RESPONSE)
- - sizeof(PTHI_MESSAGE_HEADER)
- + response.DataLength))
- {
- return PTSDK_STATUS_INTERNAL_ERROR;
- }
- return AMT_STATUS_SUCCESS;
-}
-
-/*
-* Calls to SetEnterpriseAccess Host interface command
-* Arguments:
-* Flags flags
-* HostIPAddress host IP address for enterprise access
-* EnterpriseAccess enterprise access mode
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::SetEnterpriseAccess(UINT8 Flags, UINT8 HostIPAddress[16], UINT8 EnterpriseAccess)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(CFG_SET_ENTERPRISE_ACCESS_REQUEST);
- unsigned char command[command_size];
-
- memcpy(command, &(SET_ENTERPRISE_ACCESS_HEADER), sizeof(SET_ENTERPRISE_ACCESS_HEADER));
- memcpy(command + sizeof(SET_ENTERPRISE_ACCESS_HEADER), &(Flags), sizeof(UINT8));
- memcpy(command + sizeof(SET_ENTERPRISE_ACCESS_HEADER) + sizeof(UINT8), HostIPAddress, sizeof(HostIPAddress));
- memcpy(command + sizeof(SET_ENTERPRISE_ACCESS_HEADER) + sizeof(UINT8) + sizeof(HostIPAddress), &(EnterpriseAccess), sizeof(UINT8));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, SET_ENTERPRISE_ACCESS_RESPONSE, sizeof(CFG_SET_ENTERPRISE_ACCESS_RESPONSE));
-
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Get FW last reset reason
-* Arguments:
-* reason - last FW reason
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::GetFWResetReason(UINT8 &MEResetReason)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(STATE_GET_AMT_STATE_REQUEST);
- unsigned char command[command_size];
- memcpy(command, &(GET_AMT_STATE_HEADER), sizeof(GET_AMT_STATE_HEADER));
- memcpy(command + sizeof(GET_AMT_STATE_HEADER), &(AMT_UUID_LINK_STATE), sizeof(AMT_UUID));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, GET_AMT_STATE_RESPONSE, sizeof(STATE_GET_AMT_STATE_RESPONSE));
- do {
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
- STATE_GET_AMT_STATE_RESPONSE *tmp_response = (STATE_GET_AMT_STATE_RESPONSE *)readBuffer;
-
- MEResetReason = tmp_response->StateData.LastMEResetReason;
-
- } while (0);
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/* Calls to OpenUserInitiatedConnection Host interface command
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::OpenUserInitiatedConnection()
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(OPEN_USER_INITIATED_CONNECTION_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(OPEN_USER_INITIATED_CONNECTION_HEADER), sizeof(OPEN_USER_INITIATED_CONNECTION_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, OPEN_USER_INITIATED_CONNECTION_RESPONSE, sizeof(CFG_OPEN_USER_INITIATED_CONNECTION_RESPONSE));
-
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/* Calls to CloseUserInitiatedConnection Host interface command
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::CloseUserInitiatedConnection()
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(CLOSE_USER_INITIATED_CONNECTION_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(CLOSE_USER_INITIATED_CONNECTION_HEADER), sizeof(CLOSE_USER_INITIATED_CONNECTION_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, CLOSE_USER_INITIATED_CONNECTION_RESPONSE, sizeof(CFG_CLOSE_USER_INITIATED_CONNECTION_RESPONSE));
-
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/* Calls to GetRemoteAccessConnectionStatus Host interface command
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::GetRemoteAccessConnectionStatus(REMOTE_ACCESS_STATUS &remoteAccessStatus)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(GET_REMOTE_ACCESS_CONNECTION_STATUS_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(GET_REMOTE_ACCESS_CONNECTION_STATUS_HEADER), sizeof(GET_REMOTE_ACCESS_CONNECTION_STATUS_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, GET_REMOTE_ACCESS_CONNECTION_STATUS_RESPONSE, 0);
- do {
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
- CFG_GET_REMOTE_ACCESS_CONNECTION_STATUS_RESPONSE *tmp_response = (CFG_GET_REMOTE_ACCESS_CONNECTION_STATUS_RESPONSE *)readBuffer;
- status = _verifyRemoteAccessConnectionStatus(*tmp_response);
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
-
- remoteAccessStatus.AmtNetworkConnectionStatus = tmp_response->AmtNetworkConnectionStatus;
- remoteAccessStatus.RemoteAccessConnectionStatus = tmp_response->RemoteAccessConnectionStatus;
- remoteAccessStatus.RemoteAccessConnectionTrigger = tmp_response->RemoteAccessConnectionTrigger;
-
- remoteAccessStatus.MpsHostname.Length = tmp_response->MpsHostname.Length;
- remoteAccessStatus.MpsHostname.Buffer = (CHAR *)malloc(remoteAccessStatus.MpsHostname.Length * sizeof(CHAR));
- if (NULL == remoteAccessStatus.MpsHostname.Buffer) {
- status = AMT_STATUS_INTERNAL_ERROR;
- } else {
- memcpy(remoteAccessStatus.MpsHostname.Buffer,
- &(tmp_response->MpsHostname.Buffer),
- tmp_response->MpsHostname.Length * sizeof(CHAR));
- }
- } while (0);
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Confirms the correctness of the GetRemoteAccessConnectionStatus response message
-* Arguments:
-* response - reference to the response message
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* PTSDK_STATUS_INTERNAL_ERROR - on failure
-*/
-AMT_STATUS PTHICommand::_verifyRemoteAccessConnectionStatus(const CFG_GET_REMOTE_ACCESS_CONNECTION_STATUS_RESPONSE &response)
-{
- ULONG ByteCount = response.Header.Header.Length;
- if (ByteCount != (sizeof(CFG_GET_REMOTE_ACCESS_CONNECTION_STATUS_RESPONSE)
- - sizeof(PTHI_MESSAGE_HEADER) - sizeof(CHAR *)
- + response.MpsHostname.Length))
- {
- return PTSDK_STATUS_INTERNAL_ERROR;
- }
- return AMT_STATUS_SUCCESS;
-}
-
-/*
-* Calls to GenerateRngKey Host interface command
-* Arguments:
-* None
-* Return values:
-* AMT_STATUS_SUCCESS - or AMT_STATUS_IN_PROGRESS on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::GenerateRngKey()
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(GENERATE_RNG_SEED_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(GENERATE_RNG_SEED_HEADER), sizeof(GENERATE_RNG_SEED_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, GENERATE_RNG_SEED_RESPONSE, sizeof(CFG_GENERATE_RNG_SEED_RESPONSE));
-
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Calls to GetRngSeedStatus Host interface command
-* Arguments:
-* rngStatus - reference to the pre-allocated structure
-* which will hold the result
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::GetRngSeedStatus(AMT_RNG_STATUS &rngStatus)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(GET_RNG_SEED_STATUS_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(GET_RNG_SEED_STATUS_HEADER), sizeof(GET_RNG_SEED_STATUS_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, GET_RNG_SEED_STATUS_RESPONSE, sizeof(CFG_GET_RNG_SEED_STATUS_RESPONSE));
-
- CFG_GET_RNG_SEED_STATUS_RESPONSE *tmp_response = (CFG_GET_RNG_SEED_STATUS_RESPONSE *)readBuffer;
-
- rngStatus = tmp_response->RngStatus;
-
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Calls to ZeroTouchEnabled Host interface command
-* Arguments:
-* zeroTouchEnabled - reference to the pre-allocated structure
-* which will hold the result
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::GetZeroTouchEnabled(AMT_BOOLEAN &zeroTouchEnabled)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(GET_ZERO_TOUCH_ENABLED_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(GET_ZERO_TOUCH_ENABLED_HEADER), sizeof(GET_ZERO_TOUCH_ENABLED_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, GET_ZERO_TOUCH_ENABLED_RESPONSE, sizeof(CFG_GET_ZERO_TOUCH_ENABLED_RESPONSE));
-
- CFG_GET_ZERO_TOUCH_ENABLED_RESPONSE *tmp_response = (CFG_GET_ZERO_TOUCH_ENABLED_RESPONSE *)readBuffer;
-
- zeroTouchEnabled = tmp_response->ZeroTouchEnabled;
-
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Calls to GetProvisioningTlsMode Host interface command
-* Arguments:
-* provisioningTlsMode - reference to the pre-allocated structure
-* which will hold the result
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::GetProvisioningTlsMode(AMT_PROVISIONING_TLS_MODE &provisioningTlsMode)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(GET_PROVISIONING_TLS_MODE_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(GET_PROVISIONING_TLS_MODE_HEADER), sizeof(GET_PROVISIONING_TLS_MODE_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, GET_PROVISIONING_TLS_MODE_RESPONSE, sizeof(CFG_GET_PROVISIONING_TLS_MODE_RESPONSE));
-
- CFG_GET_PROVISIONING_TLS_MODE_RESPONSE *tmp_response = (CFG_GET_PROVISIONING_TLS_MODE_RESPONSE *)readBuffer;
-
- provisioningTlsMode = tmp_response->ProvisioningTlsMode;
-
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Calls to StartConfiguration Host interface command
-* Arguments:
-* None
-* Return values:
-* AMT_STATUS_SUCCESS - or AMT_STATUS_CERTIFICATE_NOT_READY on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::StartConfiguration()
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(START_CONFIGURATION_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(START_CONFIGURATION_HEADER), sizeof(START_CONFIGURATION_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, START_CONFIGURATION_RESPONSE, sizeof(CFG_START_CONFIGURATION_RESPONSE));
-
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Calls to SetProvisioningServerOTP Host interface command
-* Arguments:
-* passwordOTP AMT_ANSI_STRING structure of OTP password
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::SetProvisioningServerOTP(AMT_ANSI_STRING passwordOTP)
-{
- if (NULL == passwordOTP.Buffer)
- {
- return PTSDK_STATUS_INVALID_PARAM;
- }
-
- UINT8 *readBuffer = NULL;
- UINT32 msgLength = sizeof(passwordOTP.Length) + (passwordOTP.Length * sizeof(CHAR));
- PTHI_MESSAGE_HEADER SET_PROVISIONING_SERVER_OTP_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{SET_PROVISIONING_SERVER_OTP_REQUEST}}, msgLength
- };
-
- const UINT32 command_size = sizeof(SET_PROVISIONING_SERVER_OTP_HEADER) + msgLength;
- unsigned char *command;
- command = (unsigned char *)malloc(command_size);
- if (NULL == command)
- {
- return PTSDK_STATUS_INTERNAL_ERROR;
- }
- memcpy(command, &SET_PROVISIONING_SERVER_OTP_HEADER, sizeof(SET_PROVISIONING_SERVER_OTP_HEADER));
- memcpy(command + sizeof(SET_PROVISIONING_SERVER_OTP_HEADER), &(passwordOTP.Length), sizeof(passwordOTP.Length));
- memcpy(command + sizeof(SET_PROVISIONING_SERVER_OTP_HEADER) + sizeof(passwordOTP.Length),
- passwordOTP.Buffer, passwordOTP.Length);
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, SET_PROVISIONING_SERVER_OTP_RESPONSE, sizeof(CFG_SET_PROVISIONING_SERVER_OTP_RESPONSE));
-
- if (NULL != command)
- {
- free(command);
- }
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Calls to SetDnsSuffix Host interface command
-* Arguments:
-* dnsSuffix AMT_ANSI_STRING structure of DNS suffix
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::SetDnsSuffix(AMT_ANSI_STRING dnsSuffix)
-{
- if (NULL == dnsSuffix.Buffer)
- {
- return PTSDK_STATUS_INVALID_PARAM;
- }
-
- UINT8 *readBuffer = NULL;
- UINT32 msgLength = sizeof(dnsSuffix.Length) + (dnsSuffix.Length * sizeof(CHAR));
- PTHI_MESSAGE_HEADER SET_DNS_SUFFIX_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{SET_DNS_SUFFIX_REQUEST}}, msgLength
- };
-
- const UINT32 command_size = sizeof(SET_DNS_SUFFIX_HEADER) + msgLength;
- unsigned char *command;
- command = (unsigned char *)malloc(command_size);
- if (NULL == command)
- {
- return PTSDK_STATUS_INTERNAL_ERROR;
- }
- memcpy(command, &SET_DNS_SUFFIX_HEADER, sizeof(SET_DNS_SUFFIX_HEADER));
- memcpy(command + sizeof(SET_DNS_SUFFIX_HEADER), &(dnsSuffix.Length), sizeof(dnsSuffix.Length));
- memcpy(command + sizeof(SET_DNS_SUFFIX_HEADER) + sizeof(dnsSuffix.Length), dnsSuffix.Buffer, dnsSuffix.Length);
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, SET_DNS_SUFFIX_RESPONSE, sizeof(CFG_SET_DNS_SUFFIX_RESPONSE));
-
- if (NULL != command)
- {
- free(command);
- }
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Calls to EnumerateHashHandles Host interface command
-* Arguments:
-* hashHandles - reference to the pre-allocated structure
-* which will hold the result
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::EnumerateHashHandles(AMT_HASH_HANDLES &hashHandles)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(ENUMERATE_HASH_HANDLES_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(ENUMERATE_HASH_HANDLES_HEADER), sizeof(ENUMERATE_HASH_HANDLES_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, ENUMERATE_HASH_HANDLES_RESPONSE, 0);
- do {
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
- CFG_GET_HASH_HANDLES_RESPONSE *tmp_response = (CFG_GET_HASH_HANDLES_RESPONSE *)readBuffer;
- status = _verifyHashHandles(*tmp_response);
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
-
- memset(hashHandles.Handles, 0, sizeof(UINT32) * CERT_HASH_MAX_NUMBER);
- hashHandles.Length = tmp_response->HashHandles.Length;
- if (CERT_HASH_MAX_NUMBER < hashHandles.Length)
- {
- status = PTSDK_STATUS_INTERNAL_ERROR;
- break;
- }
-
- memcpy(hashHandles.Handles, tmp_response->HashHandles.Handles, sizeof(UINT32) * hashHandles.Length);
-
- } while (0);
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Confirms the correctness of the EnumerateHashHandles response message
-* Arguments:
-* response - reference to the response message
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* PTSDK_STATUS_INTERNAL_ERROR - on failure
-*/
-AMT_STATUS PTHICommand::_verifyHashHandles(const CFG_GET_HASH_HANDLES_RESPONSE &response)
-{
- ULONG ByteCount = response.Header.Header.Length;
-
- if (ByteCount !=
- sizeof(AMT_STATUS) + sizeof(response.HashHandles.Length) + (sizeof(UINT32) * response.HashHandles.Length))
- {
- return PTSDK_STATUS_INTERNAL_ERROR;
- }
- return AMT_STATUS_SUCCESS;
-}
-
-
-/*
-* Calls to GetCertificateHashEntry Host interface command
-* Arguments:
-* passwordOTP AMT_ANSI_STRING structure of DNS suffix
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::GetCertificateHashEntry(UINT32 hashHandle, CERTHASH_ENTRY &hashEntry)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(CFG_GET_CERTHASH_ENTRY_REQUEST);
- unsigned char command[command_size];
- memcpy(command, &(GET_CERTHASH_ENTRY_HEADER), sizeof(GET_CERTHASH_ENTRY_HEADER));
- memcpy(command + sizeof(GET_CERTHASH_ENTRY_HEADER), &(hashHandle), sizeof(hashHandle));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, GET_CERTHASH_ENTRY_RESPONSE, 0);
- do {
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
- CFG_GET_CERTHASH_ENTRY_RESPONSE *tmp_response = (CFG_GET_CERTHASH_ENTRY_RESPONSE *)readBuffer;
- status = _verifyGetCertificateHashEntry(*tmp_response);
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
-
- hashEntry.IsActive = tmp_response->Hash.IsActive;
- hashEntry.IsDefault = tmp_response->Hash.IsDefault;
- hashEntry.Name.Length = tmp_response->Hash.Name.Length;
- hashEntry.HashAlgorithm = tmp_response->Hash.HashAlgorithm;
- memcpy(hashEntry.CertificateHash, tmp_response->Hash.CertificateHash, sizeof(tmp_response->Hash.CertificateHash));
- hashEntry.Name.Buffer = (CHAR *)malloc(hashEntry.Name.Length * sizeof(CHAR));
- if (NULL == hashEntry.Name.Buffer)
- {
- status = PTSDK_STATUS_INTERNAL_ERROR;
- break;
- }
- memcpy(hashEntry.Name.Buffer, &(tmp_response->Hash.Name.Buffer), hashEntry.Name.Length * sizeof(CHAR));
-
- } while (0);
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-/*
-* Confirms the correctness of the GetCertificateHashEntry response message
-* Arguments:
-* response - reference to the response message
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* PTSDK_STATUS_INTERNAL_ERROR - on failure
-*/
-AMT_STATUS PTHICommand::_verifyGetCertificateHashEntry(const CFG_GET_CERTHASH_ENTRY_RESPONSE &response)
-{
- ULONG ByteCount = response.Header.Header.Length;
-
- if (ByteCount !=
- (sizeof(CFG_GET_CERTHASH_ENTRY_RESPONSE) - sizeof(PTHI_MESSAGE_HEADER)
- - sizeof(CHAR *) + response.Hash.Name.Length))
- {
- return PTSDK_STATUS_INTERNAL_ERROR;
- }
- return AMT_STATUS_SUCCESS;
-}
-
-/*
-* Calls to GetDnsSuffix Host interface command
-* Arguments:
-* dnsSuffix - reference to the pre-allocated structure
-* which will hold the result
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::GetDnsSuffix(AMT_ANSI_STRING &dnsSuffix)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(GET_PKI_FQDN_SUFFIX_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(GET_PKI_FQDN_SUFFIX_HEADER), sizeof(GET_PKI_FQDN_SUFFIX_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, GET_PKI_FQDN_SUFFIX_RESPONSE, 0);
- do {
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
- CFG_GET_PKI_FQDN_SUFFIX_RESPONSE *tmp_response = (CFG_GET_PKI_FQDN_SUFFIX_RESPONSE *)readBuffer;
- status = _verifyGetDnsSuffix(*tmp_response);
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
-
- dnsSuffix.Length = tmp_response->Suffix.Length;
- dnsSuffix.Buffer = (CHAR *)malloc(dnsSuffix.Length * sizeof(CHAR));
- if (NULL == dnsSuffix.Buffer)
- {
- status = PTSDK_STATUS_INTERNAL_ERROR;
- break;
- }
- memcpy(dnsSuffix.Buffer, &(tmp_response->Suffix.Buffer), dnsSuffix.Length * sizeof(CHAR));
-
- } while (0);
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-/*
-* Confirms the correctness of the GetDnsSuffix response message
-* Arguments:
-* response - reference to the response message
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* PTSDK_STATUS_INTERNAL_ERROR - on failure
-*/
-AMT_STATUS PTHICommand::_verifyGetDnsSuffix(const CFG_GET_PKI_FQDN_SUFFIX_RESPONSE &response)
-{
- ULONG ByteCount = response.Header.Header.Length;
-
- if (ByteCount !=
- sizeof(AMT_STATUS) + sizeof(response.Suffix.Length) + response.Suffix.Length * sizeof(CHAR))
- {
- return PTSDK_STATUS_INTERNAL_ERROR;
- }
- return AMT_STATUS_SUCCESS;
-}
-
diff --git a/usr/src/cmd/lms/heci/PTHICommand.h b/usr/src/cmd/lms/heci/PTHICommand.h
deleted file mode 100644
index 66f2e57f51..0000000000
--- a/usr/src/cmd/lms/heci/PTHICommand.h
+++ /dev/null
@@ -1,770 +0,0 @@
-/*******************************************************************************
- * 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.
- *******************************************************************************/
-
-//----------------------------------------------------------------------------
-//
-// File: PTHICommand.h
-//
-// Contents: header file of PTHICommand class
-//
-//----------------------------------------------------------------------------
-#ifndef __PTHI_COMMAND_H__
-#define __PTHI_COMMAND_H__
-
-#include "HECIUnix.h"
-#include "StatusCodeDefinitions.h"
-#include <list>
-#include <string>
-
-#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
-
-/*
-* Constants
-*/
-
-static const UINT32 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;
-
-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_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;
-
-static const UINT32 BIOS_VERSION_LEN = 65;
-static const UINT32 VERSIONS_NUMBER = 50;
-static const UINT32 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_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 =
- {0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01};
-
-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_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;
-
-#pragma pack()
-
-class PTHICommand
-{
-public:
- PTHICommand(bool verbose = false, unsigned long sendTimeout = 2000);
- ~PTHICommand();
-
- AMT_STATUS GetCodeVersions(CODE_VERSIONS &codeVersions);
- AMT_STATUS GetProvisioningMode(CFG_PROVISIONING_MODE &provisioningMode);
- AMT_STATUS GetProvisioningMode(CFG_PROVISIONING_MODE &provisioningMode, AMT_BOOLEAN &legacy);
- AMT_STATUS GetProvisioningState(AMT_PROVISIONING_STATE &state);
- AMT_STATUS GetFeaturesState(UINT32 requestID, AMT_BOOLEAN (&requestStatus)[2]);
- AMT_STATUS GetLastHostResetReason(UINT32 &Reason, UINT32 &RemoteControlTimeStamp);
- AMT_STATUS GetCurrentPowerPolicy(AMT_ANSI_STRING &policyName);
- AMT_STATUS GetLanInterfaceSettings(UINT32 interfaceSettings, LAN_SETTINGS &lanSettings);
- AMT_STATUS GetHeciVersion(HECI_VERSION &hecVersion);
- AMT_STATUS GetTLSEnabled(AMT_BOOLEAN &tlsEnabled);
- AMT_STATUS GetDNSSuffixList(std::list<std::string> &dnsSuffixList);
- AMT_STATUS SetEnterpriseAccess(UINT8 Flags, UINT8 HostIPAddress[16], UINT8 EnterpriseAccess);
- AMT_STATUS GetFWResetReason(UINT8 &MEResetReason);
- AMT_STATUS OpenUserInitiatedConnection();
- AMT_STATUS CloseUserInitiatedConnection();
- AMT_STATUS GetRemoteAccessConnectionStatus(REMOTE_ACCESS_STATUS &remoteAccessStatus);
- AMT_STATUS GenerateRngKey();
- AMT_STATUS GetRngSeedStatus(AMT_RNG_STATUS &rngStatus);
- AMT_STATUS GetZeroTouchEnabled(AMT_BOOLEAN &zeroTouchEnabled);
- AMT_STATUS GetProvisioningTlsMode(AMT_PROVISIONING_TLS_MODE &provisioningTlsMode);
- AMT_STATUS StartConfiguration();
- AMT_STATUS SetProvisioningServerOTP(AMT_ANSI_STRING passwordOTP);
- AMT_STATUS SetDnsSuffix(AMT_ANSI_STRING dnsSuffix);
- AMT_STATUS EnumerateHashHandles(AMT_HASH_HANDLES &hashHandles);
- AMT_STATUS GetCertificateHashEntry(UINT32 hashHandle, CERTHASH_ENTRY &hashEntry);
- AMT_STATUS GetDnsSuffix(AMT_ANSI_STRING &dnsSuffix);
-
- HECILinux PTHIClient;
-
-private:
- AMT_STATUS _call(const unsigned char *command, UINT32 command_size, UINT8 **readBuffer, UINT32 rcmd, unsigned int expSize = 0);
- AMT_STATUS _verifyResponseHeader(const UINT32 command, const PTHI_MESSAGE_HEADER &response_header, UINT32 response_size);
- AMT_STATUS _verifyCodeVersions(const CFG_GET_CODE_VERSIONS_RESPONSE &response);
- AMT_STATUS _verifyCurrentPowerPolicy(const CFG_GET_CURRENT_POWER_POLICY_RESPONSE &response);
- AMT_STATUS _verifyGetDNSSuffixList(const CFG_GET_DNS_SUFFIX_LIST_RESPONSE &response);
- AMT_STATUS _verifyRemoteAccessConnectionStatus(const CFG_GET_REMOTE_ACCESS_CONNECTION_STATUS_RESPONSE &response);
- AMT_STATUS _verifyHashHandles(const CFG_GET_HASH_HANDLES_RESPONSE &response);
- AMT_STATUS _verifyGetCertificateHashEntry(const CFG_GET_CERTHASH_ENTRY_RESPONSE &response);
- AMT_STATUS _verifyGetDnsSuffix(const CFG_GET_PKI_FQDN_SUFFIX_RESPONSE &response);
-
- unsigned long m_sendTimeout;
-};
-
-/*
-* Constants
-*/
-
-
-const UINT32 CODE_VERSIONS_REQUEST = 0x0400001A;
-const UINT32 CODE_VERSIONS_RESPONSE = 0x0480001A;
-
-const PTHI_MESSAGE_HEADER GET_CODE_VERSION_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{CODE_VERSIONS_REQUEST}}, 0
-};
-
-const UINT32 PROVISIONING_MODE_REQUEST = 0x04000008;
-const UINT32 PROVISIONING_MODE_RESPONSE = 0x04800008;
-
-const PTHI_MESSAGE_HEADER GET_PROVISIONING_MODE_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{PROVISIONING_MODE_REQUEST}}, 0
-};
-
-const UINT32 PROVISIONING_STATE_REQUEST = 0x04000011;
-const UINT32 PROVISIONING_STATE_RESPONSE = 0x04800011;
-
-const PTHI_MESSAGE_HEADER GET_PROVISIONING_STATE_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{PROVISIONING_STATE_REQUEST}}, 0
-};
-
-const UINT32 GET_FEATURES_STATE_REQUEST = 0x04000049;
-const UINT32 GET_FEATURES_STATE_RESPONSE = 0x04800049;
-
-const PTHI_MESSAGE_HEADER GET_FEATURES_STATE_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{GET_FEATURES_STATE_REQUEST}}, (sizeof(CFG_GET_FEATURES_STATE_REQUEST) - sizeof(PTHI_MESSAGE_HEADER))
-};
-
-const UINT32 GET_CURRENT_POWER_POLICY_REQUEST = 0x04000047;
-const UINT32 GET_CURRENT_POWER_POLICY_RESPONSE = 0x04800047;
-
-const PTHI_MESSAGE_HEADER GET_CURRENT_POWER_POLICY_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{GET_CURRENT_POWER_POLICY_REQUEST}}, 0
-};
-
-const UINT32 GET_LAST_HOST_RESET_REASON_REQUEST = 0x0400004A;
-const UINT32 GET_LAST_HOST_RESET_REASON_RESPONSE = 0x0480004A;
-
-const PTHI_MESSAGE_HEADER GET_LAST_HOST_RESET_REASON_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{GET_LAST_HOST_RESET_REASON_REQUEST}}, 0
-};
-
-const UINT32 GET_LAN_INTERFACE_SETTINGS_REQUEST = 0x04000048;
-const UINT32 GET_LAN_INTERFACE_SETTINGS_RESPONSE = 0x04800048;
-
-const PTHI_MESSAGE_HEADER GET_LAN_INTERFACE_SETTINGS_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{GET_LAN_INTERFACE_SETTINGS_REQUEST}}, (sizeof(CFG_GET_LAN_INTERFACE_SETTINGS_REQUEST) - sizeof(PTHI_MESSAGE_HEADER))
-};
-
-const UINT32 GET_SECURITY_PARAMETERS_REQUEST =0x0400001B;
-const UINT32 GET_SECURITY_PARAMETERS_RESPONSE =0x0480001B;
-
-const PTHI_MESSAGE_HEADER GET_SECURITY_PARAMETERS_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{GET_SECURITY_PARAMETERS_REQUEST}}, 0
-};
-
-const UINT32 GET_DNS_SUFFIX_LIST_REQUEST = 0x0400003E;
-const UINT32 GET_DNS_SUFFIX_LIST_RESPONSE = 0x0480003E;
-
-const PTHI_MESSAGE_HEADER GET_DNS_SUFFIX_LIST_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{GET_DNS_SUFFIX_LIST_REQUEST}}, 0
-};
-
-const UINT32 SET_ENTERPRISE_ACCESS_REQUEST = 0x0400003F;
-const UINT32 SET_ENTERPRISE_ACCESS_RESPONSE = 0x0480003F;
-
-const PTHI_MESSAGE_HEADER SET_ENTERPRISE_ACCESS_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{SET_ENTERPRISE_ACCESS_REQUEST}}, (sizeof(CFG_SET_ENTERPRISE_ACCESS_REQUEST) - sizeof(PTHI_MESSAGE_HEADER))
-};
-
-const UINT32 OPEN_USER_INITIATED_CONNECTION_REQUEST = 0x04000044;
-const UINT32 OPEN_USER_INITIATED_CONNECTION_RESPONSE = 0x04800044;
-
-const PTHI_MESSAGE_HEADER OPEN_USER_INITIATED_CONNECTION_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{OPEN_USER_INITIATED_CONNECTION_REQUEST}}, 0
-};
-
-const UINT32 CLOSE_USER_INITIATED_CONNECTION_REQUEST = 0x04000045;
-const UINT32 CLOSE_USER_INITIATED_CONNECTION_RESPONSE = 0x04800045;
-
-const PTHI_MESSAGE_HEADER CLOSE_USER_INITIATED_CONNECTION_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{CLOSE_USER_INITIATED_CONNECTION_REQUEST}}, 0
-};
-
-const UINT32 GET_REMOTE_ACCESS_CONNECTION_STATUS_REQUEST = 0x04000046;
-const UINT32 GET_REMOTE_ACCESS_CONNECTION_STATUS_RESPONSE = 0x04800046;
-
-const PTHI_MESSAGE_HEADER GET_REMOTE_ACCESS_CONNECTION_STATUS_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{GET_REMOTE_ACCESS_CONNECTION_STATUS_REQUEST}}, 0
-};
-
-const UINT32 GET_AMT_STATE_REQUEST = 0x01000001;
-const UINT32 GET_AMT_STATE_RESPONSE = 0x01800001;
-
-const PTHI_MESSAGE_HEADER GET_AMT_STATE_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{GET_AMT_STATE_REQUEST}}, sizeof(AMT_UUID)
-};
-
-const UINT32 GENERATE_RNG_SEED_REQUEST = 0x04000028;
-const UINT32 GENERATE_RNG_SEED_RESPONSE = 0x04800028;
-
-const PTHI_MESSAGE_HEADER GENERATE_RNG_SEED_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{GENERATE_RNG_SEED_REQUEST}}, 0
-};
-
-const UINT32 GET_RNG_SEED_STATUS_REQUEST = 0x0400002E;
-const UINT32 GET_RNG_SEED_STATUS_RESPONSE = 0x0480002E;
-
-const PTHI_MESSAGE_HEADER GET_RNG_SEED_STATUS_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{GET_RNG_SEED_STATUS_REQUEST}}, 0
-};
-
-const UINT32 GET_ZERO_TOUCH_ENABLED_REQUEST = 0x04000030;
-const UINT32 GET_ZERO_TOUCH_ENABLED_RESPONSE = 0x04800030;
-
-const PTHI_MESSAGE_HEADER GET_ZERO_TOUCH_ENABLED_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{GET_ZERO_TOUCH_ENABLED_REQUEST}}, 0
-};
-
-const UINT32 GET_PROVISIONING_TLS_MODE_REQUEST = 0x0400002B;
-const UINT32 GET_PROVISIONING_TLS_MODE_RESPONSE = 0x0480002B;
-
-const PTHI_MESSAGE_HEADER GET_PROVISIONING_TLS_MODE_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{GET_PROVISIONING_TLS_MODE_REQUEST}}, 0
-};
-
-const UINT32 START_CONFIGURATION_REQUEST = 0x04000029;
-const UINT32 START_CONFIGURATION_RESPONSE = 0x04800029;
-
-const PTHI_MESSAGE_HEADER START_CONFIGURATION_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{START_CONFIGURATION_REQUEST}}, 0
-};
-
-const UINT32 SET_PROVISIONING_SERVER_OTP_REQUEST = 0x0400002A;
-const UINT32 SET_PROVISIONING_SERVER_OTP_RESPONSE = 0x0480002A;
-
-const UINT32 SET_DNS_SUFFIX_REQUEST = 0x0400002F;
-const UINT32 SET_DNS_SUFFIX_RESPONSE = 0x0480002F;
-
-const UINT32 ENUMERATE_HASH_HANDLES_REQUEST = 0x0400002C;
-const UINT32 ENUMERATE_HASH_HANDLES_RESPONSE = 0x0480002C;
-
-const PTHI_MESSAGE_HEADER ENUMERATE_HASH_HANDLES_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{ENUMERATE_HASH_HANDLES_REQUEST}}, 0
-};
-
-const UINT32 GET_CERTHASH_ENTRY_REQUEST = 0x0400002D;
-const UINT32 GET_CERTHASH_ENTRY_RESPONSE = 0x0480002D;
-
-const PTHI_MESSAGE_HEADER GET_CERTHASH_ENTRY_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{GET_CERTHASH_ENTRY_REQUEST}}, sizeof(UINT32)
-};
-
-const UINT32 GET_PKI_FQDN_SUFFIX_REQUEST = 0x04000036;
-const UINT32 GET_PKI_FQDN_SUFFIX_RESPONSE = 0x04800036;
-
-const PTHI_MESSAGE_HEADER GET_PKI_FQDN_SUFFIX_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{GET_PKI_FQDN_SUFFIX_REQUEST}}, 0
-};
-
-#endif
-
diff --git a/usr/src/cmd/lms/heci/StatusCodeDefinitions.h b/usr/src/cmd/lms/heci/StatusCodeDefinitions.h
deleted file mode 100644
index 84e49ee22f..0000000000
--- a/usr/src/cmd/lms/heci/StatusCodeDefinitions.h
+++ /dev/null
@@ -1,421 +0,0 @@
-/*******************************************************************************
- * 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.
- *******************************************************************************/
-
-//----------------------------------------------------------------------------
-//
-// File: StatusCodeDefinitions.h
-//
-// Notes: This file contains the definitions of the status codes
-// as defined in the Intel® 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® AMT device has occurred
-#define PT_STATUS_INTERNAL_ERROR 0x1
-#define AMT_STATUS_INTERNAL_ERROR 0x1
-
-//Intel® 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_AMT_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® 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
-//'Enterprise' 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® 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 '1's are before
-//the '0' - 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 -
-//capital alphabets (A-Z), and numbers (0-9).
-#define PT_STATUS_INVALID_PID_FORMAT 0x2A
-#define AMT_STATUS_INVALID_PID_FORMAT 0x2A
-
-//The PID must be a 256 bit quantity made up of ASCII codes
-//of some combination of 8 characters -
-//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
-
-// A process rng generation started.
-#define PT_STATUS_RNG_GENERATION_IN_PROGRESS 0x002F
-#define AMT_STATUS_RNG_GENERATION_IN_PROGRESS 0x002F
-
-//rng doesn't exist
-#define PT_STATUS_RNG_NOT_READY 0x0030
-#define AMT_STATUS_RNG_NOT_READY 0x0030
-
-//Certificate doesn't exist
-#define PT_STATUS_CERTIFICATE_NOT_READY 0x0031
-#define AMT_STATUS_CERTIFICATE_NOT_READY 0x0031
-
-//AMT doesn't grant remote access
-//(AMT has a direct connection to enterprise network).
-#define PT_STATUS_REMOTE_ACCESS_NOT_GRANTED 0x0200
-#define AMT_STATUS_REMOTE_ACCESS_NOT_GRANTED 0x0200
-
-//VPN is disabled (via the AMT Network Interface)
-#define PT_STATUS_REMOTE_ACCESS_HOST_VPN_IS_DISABLED 0x0201
-#define AMT_STATUS_REMOTE_ACCESS_HOST_VPN_IS_DISABLED 0x0201
-
-//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® 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® 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® 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® 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
-
-//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
-
-//Empty response from PTHI interface
-#define PTHI_STATUS_EMPTY_RESPONSE 0x4000
-
-#endif
diff --git a/usr/src/cmd/lms/heci/heci.h b/usr/src/cmd/lms/heci/heci.h
deleted file mode 100644
index d346a9f627..0000000000
--- a/usr/src/cmd/lms/heci/heci.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * 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_H__
-#define __HECI_H__
-
-#include <cstring>
-
-#ifdef __sun
-#include <string.h>
-#endif // __sun
-
-#ifndef GUID_DEFINED
-#define GUID_DEFINED
-
-typedef struct guid {
- unsigned int data1;
- unsigned short data2;
- unsigned short data3;
- unsigned char data4[8];
-} GUID;
-
-#endif
-
-#include "HECI_if.h"
-
-class HECI
-{
-public:
- HECI(const GUID guid, bool verbose = true) :
- _initialized(false),
- _verbose(verbose),
- _bufSize(0),
- _protocolVersion(0)
- {
- memcpy(&_guid, &guid, sizeof(_guid));
- }
- virtual ~HECI() {}
-
- virtual bool Init(unsigned char maxProtocolVersion = 0) = 0;
- virtual void Deinit() = 0;
- virtual int ReceiveMessage(unsigned char *buffer, int len, unsigned long timeout = 2000) = 0;
- virtual int SendMessage(const unsigned char *buffer, int len, unsigned long timeout = 2000) = 0;
- virtual unsigned int GetBufferSize() const = 0;
- virtual unsigned char GetProtocolVersion() const = 0;
- virtual bool GetHeciVersion(HECI_VERSION &version) const = 0;
- virtual bool IsInitialized() const = 0;
-
-protected:
- GUID _guid;
- bool _initialized;
- bool _verbose;
- unsigned int _bufSize;
- unsigned char _protocolVersion;
-};
-
-#endif
diff --git a/usr/src/cmd/lms/iatshareddata.h b/usr/src/cmd/lms/iatshareddata.h
deleted file mode 100644
index 0c3c8e73a8..0000000000
--- a/usr/src/cmd/lms/iatshareddata.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * 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.
- *******************************************************************************/
-
-#ifdef __sun
-#define IATSTATERUNDIR "/var/run/"
-#else
-#define IATSHAREDDATADIR "@prefix@/share"
-#define IATSTATERUNDIR "@IATSTATERUNDIR@"
-#endif
-
diff --git a/usr/src/cmd/lms/lms.xml b/usr/src/cmd/lms/lms.xml
deleted file mode 100644
index 1953589c24..0000000000
--- a/usr/src/cmd/lms/lms.xml
+++ /dev/null
@@ -1,100 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
-<!--
- Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- Use is subject to license terms.
-
- CDDL HEADER START
-
- The contents of this file are subject to the terms of the
- Common Development and Distribution License (the "License").
- You may not use this file except in compliance with the License.
-
- You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- or http://www.opensolaris.org/os/licensing.
- See the License for the specific language governing permissions
- and limitations under the License.
-
- When distributing Covered Code, include this CDDL HEADER in each
- file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- If applicable, add the following below this CDDL HEADER, with the
- fields enclosed by brackets "[]" replaced with your own identifying
- information: Portions Copyright [yyyy] [name of copyright owner]
-
- CDDL HEADER END
-
- NOTE: This service manifest is not editable; its contents will
- be overwritten by package or patch operations, including
- operating system upgrade. Make customizations in a different
- file.
--->
-
-<service_bundle type='manifest' name='SUNWxxxx:lms'>
-
-<service
- name='network/lms'
- type='service'
- version='1'>
-
- <create_default_instance enabled='false' />
-
- <single_instance/>
-
- <!--
- Wait for network interfaces to be initialized.
- -->
- <dependency name='network'
- grouping='require_all'
- restart_on='error'
- type='service'>
- <service_fmri value='svc:/milestone/network:default'/>
- </dependency>
-
- <!--
- Wait for all local filesystems to be mounted.
- -->
- <dependency name='filesystem-local'
- grouping='require_all'
- restart_on='none'
- type='service'>
- <service_fmri
- value='svc:/system/filesystem/local:default'/>
- </dependency>
-
- <exec_method
- type='method'
- name='start'
- exec='/lib/svc/method/svc-lms'
- timeout_seconds='60' >
- <method_context>
- <method_credential
- user='root'
- group='root'
- limit_privileges=':default'
- privileges='basic,net_privaddr'
- />
- </method_context>
- </exec_method>
-
- <exec_method
- type='method'
- name='stop'
- exec=':kill'
- timeout_seconds='60' />
-
- <stability value='External' />
-
- <template>
- <common_name>
- <loctext xml:lang='C'>
- Local Manageability Service
- </loctext>
- </common_name>
- <documentation>
- <manpage title='lms' section='1M'
- manpath='/usr/share/man' />
- </documentation>
- </template>
-</service>
-
-</service_bundle>
diff --git a/usr/src/cmd/lms/main.cpp b/usr/src/cmd/lms/main.cpp
deleted file mode 100644
index 74ae8b128c..0000000000
--- a/usr/src/cmd/lms/main.cpp
+++ /dev/null
@@ -1,384 +0,0 @@
-/*******************************************************************************
- * 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.
- *******************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include "iatshareddata.h"
-#include <cstdlib>
-#include <cstdio>
-#include <cerrno>
-#include <csignal>
-#include <syslog.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/file.h>
-#include "types.h"
-#include "Protocol.h"
-#include "version.h"
-#include "ATVersion.h"
-#include "glue.h"
-
-#ifdef __sun
-#include <signal.h>
-#endif
-
-#ifdef DAEMON
-#include "daemonize.h"
-#endif //DAEMON
-
-#define LOCK_PATH IATSTATERUNDIR
-/* Change this to whatever your daemon is called */
-#define DAEMON_PID_FILE "lms.pid"
-
-#define QUICK_CONNECT_COUNT 30
-#define SLEEP_TIMEOUT 30
-#define QUICK_SLEEP_TIMEOUT 5
-
-
-bool isRunning(int running = -1)
-{
- static int _running = 0;
- if (running >= 0)
- {
- _running = running;
- }
- if (_running == 1)
- {
- return true;
- }
- else
- {
- return false;
- }
-}
-
-void log(void *param, LPCTSTR message, WORD eventType)
-{
-#ifdef DEBUGLOG
- syslog((int)eventType, "%s", message);
-#endif
-}
-
-//This needs to be global for termination action
-Protocol prot;
-int lock_pid_file_fd = -1;
-glue plugin;
-
-void exitcleanup()
-{
- prot.Deinit();
- prot.DestroySockets();
- //syslog(EVENTLOG_INFORMATION_TYPE, "Service stopped\n");
- closelog();
- if (-1 != lock_pid_file_fd) {
- close(lock_pid_file_fd);
- lock_pid_file_fd = -1;
- unlink(LOCK_PATH DAEMON_PID_FILE);
- }
-
- plugin.deinit();
-}
-
-//Action termination
-#ifdef __sun
-extern "C"
-#endif
-void terminationHandler(int signum, siginfo_t *sinfo, void *dummy)
-{
- PRINT("LMS Service received - Signal:%d Err:(%d) Code:(%d)\n", signum, sinfo->si_errno, sinfo->si_code);
- if (isRunning()) {
- syslog(EVENTLOG_WARNING_TYPE, "Received termination signal (%d)\n", signum);
-
- isRunning(0);
-
- exit(EXIT_SUCCESS);
- }
-}
-
-void setTerminationHandler()
-{
- int sigSet = 0;
- // Termination signal handler.
- struct sigaction terminateAction;
- // Set up the structure to specify the termination action.
- terminateAction.sa_sigaction = terminationHandler;
- sigemptyset(&terminateAction.sa_mask);
- terminateAction.sa_flags = SA_SIGINFO;
- sigSet &= sigaction(SIGTERM, &terminateAction, NULL);
- sigSet &= sigaction(SIGQUIT, &terminateAction, NULL);
- sigSet &= sigaction(SIGINT, &terminateAction, NULL);
- sigSet &= sigaction(SIGHUP, &terminateAction, NULL);
- sigSet &= sigaction(SIGPIPE, &terminateAction, NULL);
- sigSet &= sigaction(SIGALRM, &terminateAction, NULL);
- sigSet &= sigaction(SIGUSR1, &terminateAction, NULL);
- sigSet &= sigaction(SIGUSR2, &terminateAction, NULL);
-
- if (sigSet != 0) {
- syslog(EVENTLOG_WARNING_TYPE, "Failed to register terminate signal handler\n");
- }
-}
-
-/*
- * return: 1 if the lock is real, 0 if not real, -1 on error
- **/
-int lock_is_real(const char *lockfile)
-{
- int lfp;
- char pid_buf[32];
- ssize_t count = 0;
- int lockpid;
-
- lfp = open(lockfile, O_RDONLY);
- if (lfp < 0) {
- syslog(LOG_ERR,
- "unable to open lock file %s, code=%d (%s)",
- lockfile, errno, strerror(errno));
- return -1;
- }
-
- count = read(lfp, pid_buf, sizeof(pid_buf)-1);
- if (count < 1) {
- syslog(LOG_ERR,
- "unable to read lock file %s, code=%d (%s)",
- lockfile, errno, strerror(errno));
- close(lfp);
- return -1;
- }
- close(lfp);
- pid_buf[count] = '\0';
-
- lockpid = atoi(pid_buf);
- if (lockpid <= 1) {
- syslog(LOG_ERR, "bad pid in lock file %s", lockfile);
- return 0;
- }
-
- /* See if the process still exists */
- if (kill(lockpid, 0) == 0) {
- /* Process exists, lock is real */
- return 1;
- }
- else {
- /* Process is gone */
- return 0;
- }
-}
-
-/**
- * lock_pid_file - creates a pid file and writes current process pid into it
- *
- * lockfile - name of a file to be created
- *
- * return: 0 on success, -1 on fatal error, -2 on error
- **/
-int lock_pid_file(const char *lockfile)
-{
- int lfp = -1;
- size_t towrite = 0;
- ssize_t written = 0;
- int error = 0;
- int haserror = 0;
- char pid_buf[32];
-
- /* Create the lock file as the current user */
- if (lockfile && lockfile[0]) {
-#ifdef __sun
- lfp = open(lockfile, O_RDWR | O_CREAT | O_EXCL, 0644);
- if (lfp < 0) {
- if (errno == EEXIST) {
- if (lock_is_real(lockfile)) {
- syslog(LOG_ERR,
- "The LMS service is already running!");
- }
- else {
- unlink(lockfile);
- }
- return -2;
- }
- else {
- syslog(LOG_ERR,
- "unable to lock file %s, code=%d (%s)",
- lockfile, errno, strerror(errno));
- return -1;
- }
- }
- snprintf(pid_buf, sizeof(pid_buf), "%u", getpid());
- towrite = strnlen(pid_buf, 31);
- written = write(lfp, pid_buf, towrite);
-#else
- lfp = open(lockfile, O_RDWR | O_CREAT, 0644);
- if (lfp < 0) {
- syslog(LOG_ERR,
- "unable to create lock file %s, code=%d (%s)",
- lockfile, errno, strerror(errno));
- return -1;
- }
-
- if (-1 == flock(lfp, LOCK_EX | LOCK_NB)) {
- error = errno;
- if (EWOULDBLOCK == errno) {
- syslog(LOG_ERR, "The LMS service is already running!");
- close(lfp);
- } else {
- syslog(LOG_ERR,
- "unable to lock file %s, code=%d (%s)",
- lockfile, error, strerror(error));
- close(lfp);
- unlink(lockfile);
- return -2;
- }
- return -1;
- }
- if (-1 == ftruncate(lfp, 0)) {
- syslog(LOG_ERR,
- "unable to fruncate lock file %s, code=%d (%s)",
- lockfile, errno, strerror(errno));
- close(lfp);
- unlink(lockfile);
- return -2;
- }
- snprintf(pid_buf, sizeof(pid_buf), "%u", getpid());
- towrite = strnlen(pid_buf, 31);
- written = write(lfp, pid_buf, towrite);
- if (-1 == written) {
- error = errno;
- haserror = 1;
- } else if (towrite != (size_t)written) {
- haserror = 1;
- } else if (-1 == fsync(lfp)) {
- error = errno;
- haserror = 1;
- }
- if (1 == haserror) {
- syslog(LOG_ERR,
- "unable to write pid into lock file %s, code=%d (%s)",
- lockfile, error, strerror(error));
- close(lfp);
- unlink(lockfile);
- return -2;
- }
-#endif // __sun
- lock_pid_file_fd = lfp;
- }
- return 0;
-}
-
-
-int main(int argc, char **argv)
-{
- bool alreadyFailed = false;
- bool firstLoop = true;
- bool init = false;
- int connectCount = 0;
- int lockresult = -1;
-
- if (ATVersion::ShowVersionIfArg(argc, const_cast<const char **>(argv), VER_PRODUCTVERSION_STR)) {
- return 0;
- }
-
- umask(022);
-
- openlog("LMS", LOG_CONS, LOG_DAEMON);
-
-#ifdef DAEMON
- daemonize();
-#else
- setTerminationHandler();
-#endif
-
- lockresult = lock_pid_file(LOCK_PATH DAEMON_PID_FILE);
- if (-2 == lockresult) {
- lockresult = lock_pid_file(LOCK_PATH DAEMON_PID_FILE);
- }
- if (0 != lockresult) {
- exit(EXIT_FAILURE);
- }
-
- isRunning(1);
- //syslog(EVENTLOG_INFORMATION_TYPE, "Service started\n");
-
- atexit(exitcleanup);
-
- plugin.init();
-
- while (isRunning()) {
- if (!prot.IsInitialized()) {
- if (init) {
-#ifdef DEBUGLOG
- log(NULL, "LMS Service lost connection to AMT via HECI driver", EVENTLOG_ERROR_TYPE);
-#endif
- init = false;
- }
-
- if (!prot.Init(log, NULL)) {
- if (firstLoop) {
- syslog(EVENTLOG_ERROR_TYPE, "Cannot connect to AMT via HECI driver");
- firstLoop = false;
- }
- // Failed to connect to the HECI driver.
- // Sleep for a second and try again.
- connectCount++;
- if (connectCount >= QUICK_CONNECT_COUNT) {
- sleep(SLEEP_TIMEOUT);
- } else {
- sleep(QUICK_SLEEP_TIMEOUT);
- }
- continue;
- }
- init = true;
- firstLoop = false;
- connectCount = 0;
-#ifdef DEBUGLOG
- log(NULL, "Connected to AMT via HECI driver\n", EVENTLOG_INFORMATION_TYPE);
-#endif
- }
-
- if (!prot.SocketsCreated()) {
- if (!prot.CreateSockets()) {
- if (!alreadyFailed) {
-#ifdef DEBUGLOG
- log(NULL, "LMS Service has a problem in achieving network resources.", EVENTLOG_ERROR_TYPE);
-#endif
- alreadyFailed = true;
- }
- continue;
- } else {
- alreadyFailed = false;
- }
- }
- // Select on active sockets (IANA ports and open connections).
- prot.Select();
- }
-
- return 0;
-}
diff --git a/usr/src/cmd/lms/plugin.h b/usr/src/cmd/lms/plugin.h
deleted file mode 100644
index 7ff0b922a5..0000000000
--- a/usr/src/cmd/lms/plugin.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * 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 __LMS_PLUGIN_H__
-#define __LMS_PLUGIN_H__
-
-#define LMS_OK 0x0
-#define LMS_ERROR 0x1
-
-#define LMS_ACCEPTED 0x1
-#define LMS_DROPPED 0x2
-#define LMS_STOPPED 0x3
-
-
-#ifdef __sun
-#define LMS_PLUGIN_CONFIG_FILE "/etc/lms_plugin.conf"
-#else
-#define LMS_PLUGIN_CONFIG_FILE "@prefix@/etc/lms_plugin.conf"
-#endif
-
-#define LMS_INIT_FUNC_NAME "lms_init_func"
-#define LMS_VERSION_FUNC_NAME "lms_version_func"
-#define LMS_PRE_FUNC_NAME "lms_pre_func"
-#define LMS_RETRY_FUNC_NAME "lms_retry_func"
-#define LMS_POST_FUNC_NAME "lms_post_func"
-#define LMS_DEINIT_FUNC_NAME "lms_deinit_func"
-
-
-typedef int (*lms_init_t)(void);
-typedef void (*lms_version_t)(unsigned char version);
-typedef int (*lms_pre_t)(unsigned char *buff, int len);
-typedef int (*lms_retry_t)(unsigned char *buff, int len);
-typedef int (*lms_post_t)(unsigned char *buff, int len, int status);
-typedef void (*lms_deinit_t)(void);
-
-
-#endif
-
diff --git a/usr/src/cmd/lms/svc-lms b/usr/src/cmd/lms/svc-lms
deleted file mode 100644
index 509a6bbb1f..0000000000
--- a/usr/src/cmd/lms/svc-lms
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/sbin/sh
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-
-. /lib/svc/share/smf_include.sh
-
-[ ! -x /usr/lib/lms ] && exit $SMF_EXIT_ERR_CONFIG
-
-# Check for an lms process and exit
-# if the daemon is already running.
-
-if /usr/bin/pgrep -x -u 0 -z `smf_zonename` lms >/dev/null 2>&1; then
- echo "$0: lms is already running"
- exit 1
-fi
-
-/usr/lib/lms &
diff --git a/usr/src/cmd/lms/tools/ATNetworkTool.cpp b/usr/src/cmd/lms/tools/ATNetworkTool.cpp
deleted file mode 100644
index 8261a42268..0000000000
--- a/usr/src/cmd/lms/tools/ATNetworkTool.cpp
+++ /dev/null
@@ -1,735 +0,0 @@
-/*******************************************************************************
- * 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.
- *******************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "ATNetworkTool.h"
-#include <sstream>
-#include <algorithm>
-#include <cerrno>
-#include <net/if.h>
-#include <netdb.h>
-
-#ifdef __sun
-#include <arpa/inet.h>
-#include <sys/sockio.h>
-#include <stdio.h>
-#include <stropts.h>
-#else
-#include <ifaddrs.h>
-#endif // __sun
-
-#include <unistd.h>
-#include <fcntl.h>
-
-bool ATNetworkTool::GetHostNameDomain(const char *name, std::string &domain)
-{
- const char *domp = strchr(name, '.');
- if (domp) {
- domp++;
- if (*domp) {
-#ifdef LMS_NET_DEBUG
- printf("D: %s\n", domp);
-#endif
- domain = domp;
- return true;
- }
- }
- return false;
-}
-
-bool ATNetworkTool::GetHentDomain(struct hostent *hent, std::string &domain)
-{
- if (NULL == hent) {
- return false;
- }
- if (NULL == hent->h_name) {
- return false;
- }
-
-#ifdef LMS_NET_DEBUG
- printf("N: %s\n", hent->h_name);
-#endif
- if (ATNetworkTool::GetHostNameDomain(hent->h_name, domain)) {
- return true;
- }
-
- if (NULL != hent->h_aliases) {
- for (char **ssx = hent->h_aliases; ssx && *ssx; ssx++) {
-#ifdef LMS_NET_DEBUG
- printf("A: %s\n", *ssx);
-#endif
- if (ATNetworkTool::GetHostNameDomain(*ssx, domain)) {
- return true;
- }
- }
- }
- return false;
-}
-
-bool ATNetworkTool::GetIPDomain(const ATAddress &ip, std::string &domain, int &error)
-{
- char hbuf[NI_MAXHOST];
-
- if (0 != (error = getnameinfo(ip.addr(), ip.size(),
- hbuf, sizeof(hbuf),
- NULL, 0,
- NI_NAMEREQD))) {
- return false;
- }
-
- return ATNetworkTool::GetHostNameDomain(hbuf, domain);
-}
-
-int ATNetworkTool::GetLocalIPs(ATAddressList &addresses, int &error, int family, bool withloopback)
-{
- struct ifaddrs *ifap;
-
-#ifdef __sun
-
- char buf[1024];
- struct ifconf ifc;
- struct ifreq *ifr;
- int sock;
- int nInterfaces;
- int i;
-
- addresses.clear();
-
- sock = socket(AF_INET, SOCK_DGRAM, 0);
- if(sock < 0)
- {
- perror("socket");
- return 1;
- }
-
- /* Query available interfaces. */
- ifc.ifc_len = sizeof(buf);
- ifc.ifc_buf = buf;
- if(ioctl(sock, SIOCGIFCONF, &ifc) < 0)
- {
- perror("ioctl(SIOCGIFCONF)");
- close(sock);
- return 1;
- }
-
- /* Iterate through the list of interfaces. */
- ifr = ifc.ifc_req;
- nInterfaces = ifc.ifc_len / sizeof(struct ifreq);
- for(i = 0; i < nInterfaces; i++)
- {
- struct ifreq *item = &ifr[i];
-
- if (item->ifr_flags & IFF_LOOPBACK)
- continue;
-
- addresses.insert(&item->ifr_addr);
- }
-
- close(sock);
-
-#else // ! __sun
-
- if (0 != getifaddrs(&ifap)) {
- error = errno;
- return -1;
- }
-
- addresses.clear();
- for (struct ifaddrs *ifa = ifap; ifa; ifa = ifa->ifa_next) {
- if (NULL == ifa->ifa_addr) {
- continue;
- }
- if ((ifa->ifa_flags & IFF_UP) == 0) {
- continue;
- }
- if ((!withloopback) &&
- (((ifa->ifa_flags & IFF_LOOPBACK) != 0) ||
- ((ifa->ifa_flags & (IFF_BROADCAST | IFF_POINTOPOINT)) == 0))) {
- continue;
- }
-
- if (AF_UNSPEC != family) {
- if (ATNetworkTool::AF_XINETX == family) {
- if (!ATAddress::saIsInet(ifa->ifa_addr)) {
- continue;
- }
- } else {
- if (ifa->ifa_addr->sa_family != family) {
- continue;
- }
- }
- }
-
- addresses.insert(ifa->ifa_addr);
- }
- freeifaddrs(ifap);
-
-#endif // __sun
-
- return 0;
-}
-
-int ATNetworkTool::GetLocalNetDomains(ATDomainMap &domains, int &error, int family)
-{
- int ret;
- ATAddressList addresses;
-
- if (0 != (ret = ATNetworkTool::GetLocalIPs(addresses, error, family))) {
- return ret;
- }
-
- domains.clear();
- ATAddressList::iterator aend = addresses.end();
- for (ATAddressList::iterator ait = addresses.begin();
- ait != aend;
- ait++)
- {
- std::string domain;
- if (ATNetworkTool::GetIPDomain(*ait, domain, error)) {
- domains[*ait] = domain;
- }
- }
- return 0;
-}
-
-int ATNetworkTool::GetSockDomain(int sock, std::string &domain, int &error)
-{
- struct sockaddr_storage ss;
- socklen_t salen = sizeof(ss);
- struct sockaddr *sa;
-
- sa = (struct sockaddr *)&ss;
-
- if (getsockname(sock, sa, &salen) != 0) {
- error = errno;
- return -1;
- }
-
- if (ATNetworkTool::GetIPDomain(sa, domain, error)) {
- return 1;
- }
- return 0;
-}
-
-int ATNetworkTool::GetSockPeerIPs(int sock, ATAddressList &addresses, int &error,
- int family, bool zeroport)
-{
- struct sockaddr_storage ss;
- socklen_t salen = sizeof(ss);
- struct sockaddr *sa;
- struct addrinfo hints, *paddr, *paddrp;
-
- sa = (struct sockaddr *)&ss;
-
- if (getpeername(sock, sa, &salen) != 0) {
- error = errno;
- return -1;
- }
-
- char hbuf[NI_MAXHOST];
- char pbuf[NI_MAXSERV];
- if (0 != (error = getnameinfo(sa, salen,
- hbuf, sizeof(hbuf),
- pbuf, sizeof(pbuf),
- 0))) {
- return -1;
- }
-
- memset(&hints, 0, sizeof(hints));
- if (ATNetworkTool::AF_XINETX == family) {
- hints.ai_family = PF_UNSPEC;
- } else {
- hints.ai_family = family;
- }
- hints.ai_socktype = SOCK_STREAM;
- if (0 != (error = getaddrinfo(hbuf, pbuf, &hints, &paddrp))) {
- return -1;
- }
- addresses.clear();
- for (paddr = paddrp; paddr; paddr = paddr->ai_next) {
- if (ATNetworkTool::AF_XINETX == family) {
- if (!ATAddress::saIsInet(paddr->ai_addr)) {
- continue;
- }
- }
- if (zeroport) {
- addresses.insert(ATAddress(paddr->ai_addr, 0));
- } else {
- addresses.insert(paddr->ai_addr);
- }
- }
- freeaddrinfo(paddrp);
- return 0;
-}
-
-int ATNetworkTool::IsSockPeerLocal(int sock, int &error, int family)
-{
- ATAddressList localAddresses;
- ATAddressList targAddresses;
-
- if (0 != ATNetworkTool::GetSockPeerIPs(sock, targAddresses, error,
- family, true)) {
- return -1;
- }
- if (0 != ATNetworkTool::GetLocalIPs(localAddresses, error,
- family, true)) {
- return -1;
- }
- if (std::includes(localAddresses.begin(), localAddresses.end(),
- targAddresses.begin(), targAddresses.end())) {
- return 1;
- }
- return 0;
-}
-
-int ATNetworkTool::CloseSocket(int s)
-{
- shutdown(s, SHUT_RDWR);
- return close(s);
-}
-
-int ATNetworkTool::CreateSocket(const struct addrinfo *addr, int &error)
-{
- return ATNetworkTool::CreateSocket(addr->ai_addr, addr->ai_addrlen,
- error,
- addr->ai_family, addr->ai_socktype,
- addr->ai_protocol);
-}
-
-int ATNetworkTool::CreateSocket(const struct sockaddr *addr, socklen_t addrlen,
- int &error,
- int family, int socktype, int protocol)
-{
- int s = socket(family, socktype, protocol);
- if (s < 0) {
- error = errno;
- return -1;
- }
-
- if (socktype != SOCK_DGRAM) {
- linger l;
- l.l_onoff = 0;
- l.l_linger = 0;
- if (setsockopt(s, SOL_SOCKET, SO_LINGER,
- (char *)&l, sizeof(l)) == -1) {
- error = errno;
- close(s);
- return -1;
- }
- }
-
- if (bind(s, addr, addrlen) == -1) {
- error = errno;
- close(s);
- return -1;
- }
-
- return s;
-}
-
-int ATNetworkTool::ConnectSocket(struct addrinfo *addr,
- int &error, bool loopback)
-{
- return ATNetworkTool::ConnectSocket(addr->ai_addr, addr->ai_addrlen,
- error, loopback,
- addr->ai_family, addr->ai_socktype,
- addr->ai_protocol);
-}
-
-int ATNetworkTool::ConnectSocket(const struct sockaddr *addr, socklen_t addrlen,
- int &error, bool loopback,
- int family, int socktype, int protocol)
-{
- struct addrinfo hints, *paddr, *paddrp;
- int oks = -1;
-
- memset(&hints, 0, sizeof(hints));
- if (ATNetworkTool::AF_XINETX == family) {
- hints.ai_family = PF_UNSPEC;
- } else {
- hints.ai_family = family;
- }
- hints.ai_socktype = socktype;
- hints.ai_protocol = protocol;
-#ifdef AI_NUMERICSERV
- hints.ai_flags |= AI_NUMERICSERV;
-#endif
- if (!loopback) {
- hints.ai_flags |= AI_PASSIVE;
- }
- if ((error = getaddrinfo(NULL, "0", &hints, &paddrp)) != 0) {
- return -1;
- }
- for (paddr = paddrp; paddr; paddr = paddr->ai_next) {
- if (ATNetworkTool::AF_XINETX == family) {
- if (!ATAddress::saIsInet(paddr->ai_addr)) {
- continue;
- }
- }
-
- int s = ATNetworkTool::CreateSocket(paddr, error);
- if (s < 0) {
- continue;
- }
-
- if (connect(s, addr, addrlen) != 0) {
- error = errno;
- ATNetworkTool::CloseSocket(s);
- continue;
- }
-
- oks = s;
- break;
- }
- freeaddrinfo(paddrp);
- return oks;
-}
-
-int ATNetworkTool::CreateServerSocket(in_port_t port,
- int &error,
- bool loopback, bool nonblocking,
- int family, int socktype, int protocol,
- int backlog)
-{
- std::stringstream ssport;
-
- ssport << port;
- return ATNetworkTool::CreateServerSocket(ssport.str().c_str(),
- error,
- loopback, nonblocking,
- family, socktype, protocol,
- backlog);
-}
-
-int ATNetworkTool::CreateServerSocket(const char *port,
- int &error,
- bool loopback, bool nonblocking,
- int family, int socktype, int protocol,
- int backlog)
-{
- ATSocketList sockets;
- int s = -1;
-
- int num = ATNetworkTool::CreateServerSockets(sockets, port,
- error,
- loopback, nonblocking,
- family, socktype, protocol,
- backlog, true);
- if ((num > 0) && (sockets.size() > 0)) {
- s = sockets[0];
- }
- sockets.clear();
- return s;
-}
-
-
-int ATNetworkTool::CreateServerSockets(ATSocketList &sockets, in_port_t port,
- int &error,
- bool loopback, bool nonblocking,
- int family, int socktype, int protocol,
- int backlog, bool one)
-{
- std::stringstream ssport;
-
- ssport << port;
- return ATNetworkTool::CreateServerSockets(sockets, ssport.str().c_str(),
- error,
- loopback, nonblocking,
- family, socktype, protocol,
- backlog, one);
-}
-
-int ATNetworkTool::CreateServerSockets(ATSocketList &sockets, const char *port,
- int &error,
- bool loopback, bool nonblocking,
- int family, int socktype, int protocol,
- int backlog, bool one)
-{
- struct addrinfo hints, *paddr, *paddrp;
- int num = 0;
-
- memset(&hints, 0, sizeof(hints));
- if (ATNetworkTool::AF_XINETX == family) {
- hints.ai_family = PF_UNSPEC;
- } else {
- hints.ai_family = family;
- }
- hints.ai_socktype = socktype;
- hints.ai_protocol = protocol;
-#ifdef AI_NUMERICSERV
- hints.ai_flags |= AI_NUMERICSERV;
-#endif
- if (!loopback) {
- hints.ai_flags |= AI_PASSIVE;
- }
- if ((error = getaddrinfo(NULL, port, &hints, &paddrp)) != 0) {
- return -1;
- }
- for (paddr = paddrp; paddr; paddr = paddr->ai_next) {
- if (ATNetworkTool::AF_XINETX == family) {
- if (!ATAddress::saIsInet(paddr->ai_addr)) {
- continue;
- }
- }
-
- int s = ATNetworkTool::CreateServerSocket(paddr, error,
- nonblocking,
- backlog);
- if (s < 0) {
- continue;
- }
- sockets.push_back(s);
- num++;
- if (one) {
- break;
- }
- }
- freeaddrinfo(paddrp);
- return num;
-}
-
-int ATNetworkTool::CreateServerSocket(const struct addrinfo *addr, int &error,
- bool nonblocking, int backlog)
-{
- int s = ATNetworkTool::CreateSocket(addr, error);
- if (s < 0) {
- return -1;
- }
-
- if (nonblocking) {
- ATNetworkTool::SetNonBlocking(s);
- }
-
- if (listen(s, backlog) == -1) {
- error = errno;
- ATNetworkTool::CloseSocket(s);
- return -1;
- }
-
- return s;
-}
-
-int ATNetworkTool::SetNonBlocking(int s, bool block)
-{
- if (block) {
- return fcntl(s, F_SETFL, fcntl(s, F_GETFL) | O_NONBLOCK);
- } else {
- return fcntl(s, F_SETFL, fcntl(s, F_GETFL) & ~O_NONBLOCK);
- }
-}
-
-int ATNetworkTool::ConnectToSocket(int sock, int &error, bool loopback,
- int socktype, int protocol)
-{
- struct sockaddr_storage ss;
- socklen_t addrLen = sizeof(ss);
- struct sockaddr *sa = (struct sockaddr *)&ss;
-
- if (getsockname(sock, sa, &addrLen) != 0) {
- error = errno;
- return -1;
- }
- int s = ATNetworkTool::ConnectSocket(sa, addrLen,
- error, loopback,
- sa->sa_family,
- socktype, protocol);
- if (s < 0) {
- return -1;
- }
- return s;
-}
-
-int ATNetworkTool::Connect(const char *host, in_port_t port,
- int &error,
- int family, int socktype, int protocol)
-{
- std::stringstream ssport;
-
- ssport << port;
-
- return ATNetworkTool::Connect(host, ssport.str().c_str(), error,
- family, socktype, protocol);
-}
-
-int ATNetworkTool::Connect(const char *host, const char *port,
- int &error,
- int family, int socktype, int protocol)
-{
- struct addrinfo hints, *paddr, *paddrp;
- int oks = -1;
-
- if (socktype != SOCK_DGRAM) {
- socktype = SOCK_STREAM;
- }
-
- memset(&hints, 0, sizeof(hints));
- if (ATNetworkTool::AF_XINETX == family) {
- hints.ai_family = PF_UNSPEC;
- } else {
- hints.ai_family = family;
- }
- hints.ai_socktype = socktype;
- hints.ai_protocol = protocol;
- hints.ai_flags = AI_NUMERICHOST;
-#ifdef AI_NUMERICSERV
- hints.ai_flags |= AI_NUMERICSERV;
-#endif
- if ((error = getaddrinfo(host, port, &hints, &paddrp)) != 0) {
- memset(&hints, 0, sizeof(hints));
- if (ATNetworkTool::AF_XINETX == family) {
- hints.ai_family = PF_UNSPEC;
- } else {
- hints.ai_family = family;
- }
- hints.ai_socktype = socktype;
- hints.ai_protocol = protocol;
-#ifdef AI_NUMERICSERV
- hints.ai_flags |= AI_NUMERICSERV;
-#endif
- if ((error = getaddrinfo(host, port, &hints, &paddrp)) != 0) {
- return -1;
- }
- }
- for (paddr = paddrp; paddr; paddr = paddr->ai_next) {
- if (ATNetworkTool::AF_XINETX == family) {
- if (!ATAddress::saIsInet(paddr->ai_addr)) {
- continue;
- }
- }
-
- int s = ATNetworkTool::ConnectSocket(paddr, error);
- if (s < 0) {
- continue;
- }
- oks = s;
- break;
- }
- freeaddrinfo(paddrp);
- return oks;
-}
-
-int ATNetworkTool::ConnectLoopback(in_port_t port,
- int &error,
- int family, int socktype, int protocol)
-{
- std::stringstream ssport;
-
- ssport << port;
-
- return ATNetworkTool::ConnectLoopback(ssport.str().c_str(), error,
- family, socktype, protocol);
-}
-
-int ATNetworkTool::ConnectLoopback(const char *port,
- int &error,
- int family, int socktype, int protocol)
-{
- struct addrinfo hints, *paddr, *paddrp;
- int oks = -1;
-
- if (socktype != SOCK_DGRAM) {
- socktype = SOCK_STREAM;
- }
-
- memset(&hints, 0, sizeof(hints));
- if (ATNetworkTool::AF_XINETX == family) {
- hints.ai_family = PF_UNSPEC;
- } else {
- hints.ai_family = family;
- }
- hints.ai_socktype = socktype;
- hints.ai_protocol = protocol;
-#ifdef AI_NUMERICSERV
- hints.ai_flags |= AI_NUMERICSERV;
-#endif
- if ((error = getaddrinfo(NULL, port, &hints, &paddrp)) != 0) {
- return -1;
- }
- for (paddr = paddrp; paddr; paddr = paddr->ai_next) {
- if (ATNetworkTool::AF_XINETX == family) {
- if (!ATAddress::saIsInet(paddr->ai_addr)) {
- continue;
- }
- }
-
- int s = ATNetworkTool::ConnectSocket(paddr, error, true);
- if (s < 0) {
- continue;
- }
- oks = s;
- break;
- }
- freeaddrinfo(paddrp);
- return oks;
-}
-
-unsigned int ATNetworkTool::GetLocalPort(int sock)
-{
- struct sockaddr_storage ss;
- socklen_t addrLen = sizeof(ss);
- struct sockaddr *sa = (struct sockaddr *)&ss;
-
- if (getsockname(sock, sa, &addrLen) != 0) {
- return 0;
- }
- switch (sa->sa_family) {
- case AF_INET6:
- return ntohs(((struct sockaddr_in6 *)sa)->sin6_port);
- break;
- case AF_INET:
- return ntohs(((struct sockaddr_in *)sa)->sin_port);
- break;
- }
- return 0;
-}
-
-int ATNetworkTool::Accept(int s, ATAddress &address,
- int &error, bool nonblocking)
-{
- struct sockaddr_storage saddr;
- socklen_t addrLen = sizeof(saddr);
- struct sockaddr *addr = (struct sockaddr *)&saddr;
-
- int s_new = accept(s, addr, &addrLen);
- if (s_new == -1) {
- error = errno;
- return -1;
- }
-
- address = addr;
-
- ATNetworkTool::SetNonBlocking(s_new, nonblocking);
-
- return s_new;
-}
-
diff --git a/usr/src/cmd/lms/tools/ATNetworkTool.h b/usr/src/cmd/lms/tools/ATNetworkTool.h
deleted file mode 100644
index 00cda38d08..0000000000
--- a/usr/src/cmd/lms/tools/ATNetworkTool.h
+++ /dev/null
@@ -1,553 +0,0 @@
-/*******************************************************************************
- * 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 _AT_NETWORK_TOOL_H_
-#define _AT_NETWORK_TOOL_H_
-
-#include <string>
-#include <set>
-#include <vector>
-#include <map>
-#include <cstring>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-
-class ATAddress
-{
-private:
- struct sockaddr_storage ip;
-
-public:
-
- ATAddress()
- {
- memset(&(this->ip), 0, sizeof(struct sockaddr_storage));
- };
-
- ATAddress(const ATAddress &y)
- {
- memcpy(&(this->ip), y.addr(), sizeof(struct sockaddr_storage));
- };
-
- ATAddress(const struct sockaddr *yip)
- {
- memset(&(this->ip), 0, sizeof(struct sockaddr_storage));
- memcpy(&(this->ip), yip, saSize(yip));
- };
-
- ATAddress(const ATAddress &y, in_port_t yport)
- {
- memcpy(&(this->ip), y.addr(), sizeof(struct sockaddr_storage));
- ATAddress::saSetPort((const struct sockaddr *)&(this->ip), yport);
- };
-
- ATAddress(const struct sockaddr *yip, in_port_t yport)
- {
- memset(&(this->ip), 0, sizeof(struct sockaddr_storage));
- memcpy(&(this->ip), yip, saSize(yip));
- ATAddress::saSetPort((const struct sockaddr *)&(this->ip), yport);
- };
-
- static void saSetPort(const struct sockaddr *ip, in_port_t yport)
- {
- switch (ip->sa_family) {
- case AF_INET6:
- ((struct sockaddr_in6 *)ip)->sin6_port = htons(yport);
- break;
-
- case AF_INET:
- ((struct sockaddr_in *)ip)->sin_port = htons(yport);
- break;
- }
- }
-
- static bool saIsInet(const struct sockaddr *ip)
- {
- return ((ip->sa_family == AF_INET) || (ip->sa_family == AF_INET6));
- };
-
- static unsigned int saSize(const struct sockaddr *ip)
- {
- switch (ip->sa_family) {
- case AF_INET6:
- return sizeof(struct sockaddr_in6);
- break;
-
- case AF_INET:
- return sizeof(struct sockaddr_in);
- break;
-
- default:
- return 0;
- }
- };
-
- static in_port_t saInPort(const struct sockaddr *ip)
- {
- switch (ip->sa_family) {
- case AF_INET6:
- return ntohs(((struct sockaddr_in6 *)ip)->sin6_port);
- break;
-
- case AF_INET:
- return ntohs(((struct sockaddr_in *)ip)->sin_port);
- break;
-
- default:
- return 0;
- }
- };
-
- static const void *saInAddr(const struct sockaddr *ip, size_t &asize)
- {
- switch (ip->sa_family) {
- case AF_INET6:
- asize = sizeof(in6_addr);
- return (const void *)&(((struct sockaddr_in6 *)ip)->sin6_addr);
- break;
-
- case AF_INET:
- asize = sizeof(in_addr);
- return (const void *)&(((struct sockaddr_in *)ip)->sin_addr);
- break;
-
- default:
- asize = 0;
- return NULL;
- }
- };
-
- static const char *saInNtoP(const struct sockaddr *ip, char *buf, size_t buflen)
- {
- if (!ATAddress::saIsInet(ip)) {
- return NULL;
- }
-
- size_t asize;
- const void *src = ATAddress::saInAddr(ip, asize);
- if (NULL == src) {
- return NULL;
- }
- return inet_ntop(ip->sa_family, src, buf, buflen);
- };
-
- sa_family_t family() const { return ip.ss_family; };
-
- bool isInet() const { return ((ip.ss_family == AF_INET) || (ip.ss_family == AF_INET6)); };
-
- unsigned int size() const
- {
- return ATAddress::saSize((const struct sockaddr *)&(this->ip));
- };
-
- const struct sockaddr *addr() const
- {
- return (const struct sockaddr *)&ip;
- };
-
- in_port_t inPort() const
- {
- return ATAddress::saInPort((const struct sockaddr *)&(this->ip));
- };
-
- const void *inAddr(size_t &asize) const
- {
- return ATAddress::saInAddr((const struct sockaddr *)&(this->ip), asize);
- };
-
- const char *inNtoP(char *buf, size_t buflen)
- {
- return ATAddress::saInNtoP((const struct sockaddr *)&(this->ip), buf, buflen);
- };
-
- ATAddress &operator=(const ATAddress &y)
- {
- if (this != &y) {
- memcpy(&(this->ip), y.addr(), sizeof(struct sockaddr_storage));
- }
- return *this;
- };
-
- ATAddress &operator=(const struct sockaddr &yip)
- {
- memset(&(this->ip), 0, sizeof(struct sockaddr_storage));
- memcpy(&(this->ip), &yip, saSize(&yip));
- return *this;
- };
-
- int compare(const ATAddress &y) const
- {
- if (this->family() != y.family()) {
- return (this->family() - y.family());
- }
-
- size_t asize = 0;
- const void *a = this->inAddr(asize);
- const void *b = y.inAddr(asize);
- if ((0 != asize) && (NULL != a) && (NULL != b)) {
- int adiff = memcmp(a, b, asize);
- if (adiff != 0) {
- return adiff;
- }
- }
-
- in_port_t ap = this->inPort();
- in_port_t bp = y.inPort();
- if ((ap == 0) || (bp == 0)) {
- return 0;
- }
- if (ap != bp) {
- return (ap - bp);
- }
-
- return memcmp(&(this->ip), y.addr(), this->size());
- };
-
- bool operator<(const ATAddress &y) const
- {
- if (this == &y) {
- return false;
- }
- return (this->compare(y) < 0);
- };
-
- bool operator>(const ATAddress &y) const
- {
- if (this == &y) {
- return false;
- }
- return (this->compare(y) > 0);
- };
-
- bool operator==(const ATAddress &y) const
- {
- if (this == &y) {
- return true;
- }
- if (this->family() != y.family()) {
- return false;
- }
- return (memcmp(&(this->ip), y.addr(), this->size()) == 0);
- };
-
- bool operator!=(const ATAddress &y) const
- {
- if (this == &y) {
- return false;
- }
- if (this->family() != y.family()) {
- return true;
- }
- return (memcmp(&(this->ip), y.addr(), this->size()) != 0);
- };
-
- static bool IsAddressIP(const char *address, int family = AF_INET)
- {
- struct sockaddr_storage inaddr;
-
- if (address == NULL) {
- return false;
- }
- return (0 < inet_pton(family, address, &inaddr));
- };
-};
-
-
-typedef std::set<ATAddress> ATAddressList;
-typedef std::map<ATAddress, std::string> ATDomainMap;
-typedef std::vector<int> ATSocketList;
-
-class ATNetworkTool
-{
-public:
- static const int DefaultBacklog = 5;
- static const int DefaultFamily = AF_INET;
- static const int AF_XINETX = AF_MAX + 10;
-
- /* Gets Domain name from Hostname
- * @param name hostname
- * @param domain [out] domain name
- * @return bool true if success, false if domain unknown
- */
- static bool GetHostNameDomain(const char *name, std::string &domain);
-
- /* Gets Domain name from IP
- * @param ip address
- * @param domain [out] domain name
- * @param error [out] error code
- * @return bool true if success, false if domain unknown
- */
- static bool GetIPDomain(const ATAddress &ip, std::string &domain, int &error);
-
- /* Gets Domain name from host entry
- * @param hent pointer to host entry structure
- * @param domain [out] domain name
- * @return bool true if success, false if domain unknown
- */
- static bool GetHentDomain(struct hostent *hent, std::string &domain);
-
- /* Gets Domain name from socket
- * @param sock checked socket
- * @param domain [out] domain name
- * @param error [out] error code
- * @return int ==1 if success, <0 on error, ==0 if no domain
- */
- static int GetSockDomain(int sock, std::string &domain, int &error);
-
- /* Gets all local (IPv4/6) from local running network interfaces
- * @param addresses [out] set of local IP addresses
- * @param error [out] error code
- * @param family filtered address family
- * @param withloopback true if get loopback addresses too
- * @return int ==0 if success, !=0 on error
- */
- static int GetLocalIPs(ATAddressList &addresses, int &error,
- int family = ATNetworkTool::AF_XINETX,
- bool withloopback = false);
-
- /* Gets all local domains from local running network interfaces
- * @param domains [out] map of <local IP address> => <domain name>
- * @param error [out] error code
- * @param family filtered address family
- * @return int ==0 if success, !=0 on error
- */
- static int GetLocalNetDomains(ATDomainMap &domains, int &error,
- int family = ATNetworkTool::AF_XINETX);
-
- /* Gets all (IPv4/6) network interfaces of socket peer
- * @param addresses [out] set of peer IP addresses
- * @param error [out] error code
- * @param family filtered address family
- * @param zeroport set port to 0 in result list
- * @return int ==0 if success, !=0 on error
- */
- static int GetSockPeerIPs(int sock, ATAddressList &addresses,
- int &error,
- int family = ATNetworkTool::AF_XINETX,
- bool zeroport = false);
-
- /* Checks if socket peer is (IPv4/6) local address
- * @param sock checked socket
- * @param error [out] error code
- * @param family filtered address family
- * @return int ==1 if peer is local, ==0 if remote, <0 on error
- */
- static int IsSockPeerLocal(int sock, int &error,
- int family = ATNetworkTool::AF_XINETX);
-
- /* Closes socket
- * @param s socket to close
- * @return int ==0 if success, !=0 on error
- */
- static int CloseSocket(int s);
-
- /* Sets/removes O_NONBLOCKING flag to socket
- * @param s socket
- * @param block - true to set flag, false to remove flag
- * @return int ==0 if success, !=0 on error
- */
- static int SetNonBlocking(int s, bool block = true);
-
- /* Creates socket
- * @param addr socket parameters
- * @param error [out] error code
- * @return int !=-1 socket, ==-1 on error
- */
- static int CreateSocket(const struct addrinfo *addr, int &error);
-
- /* Creates socket
- * @param addr socket address
- * @param addrlen socket address length
- * @param error [out] error code
- * @param family socket expected family
- * @param socktype socket type
- * @param protocol socket protocol
- * @return int !=-1 socket, ==-1 on error
- */
- static int CreateSocket(const struct sockaddr *addr, socklen_t addrlen,
- int &error,
- int family = ATNetworkTool::DefaultFamily,
- int socktype = SOCK_STREAM, int protocol = 0);
-
- /* Creates server listening socket
- * @param addr socket parameters
- * @param error [out] error code
- * @param nonblocking true for nonblocking socket
- * @param backlog listening backlog
- * @return int !=-1 socket, ==-1 on error
- */
- static int CreateServerSocket(const struct addrinfo *addr,
- int &error, bool nonblocking = true,
- int backlog = ATNetworkTool::DefaultBacklog);
-
- /* Creates server listening sockets
- * @param sockets [out] list of created server listening sockets
- * @param port listening port
- * @param error [out] error code
- * @param loopback true to listen only on loopback
- * @param nonblocking true for nonblocking sockets
- * @param family sockets expected family
- * @param socktype sockets type
- * @param protocol sockets protocol
- * @param backlog listening backlog
- * @param one true if want create only one socket
- * @return int >=0 number of created server sockets, ==-1 on error
- */
- static int CreateServerSockets(ATSocketList &sockets, in_port_t port,
- int &error,
- bool loopback = false, bool nonblocking = true,
- int family = ATNetworkTool::AF_XINETX,
- int socktype = SOCK_STREAM, int protocol = 0,
- int backlog = ATNetworkTool::DefaultBacklog,
- bool one = false);
- static int CreateServerSockets(ATSocketList &sockets, const char *port,
- int &error,
- bool loopback = false, bool nonblocking = true,
- int family = ATNetworkTool::AF_XINETX,
- int socktype = SOCK_STREAM, int protocol = 0,
- int backlog = ATNetworkTool::DefaultBacklog,
- bool one = false);
-
- /* Creates one server listening socket
- * @param port listening port
- * @param error [out] error code
- * @param loopback true to listen only on loopback
- * @param nonblocking true for nonblocking sockets
- * @param family sockets expected family
- * @param socktype sockets type
- * @param protocol sockets protocol
- * @param backlog listening backlog
- * @return int !=-1 socket, ==-1 on error
- */
- static int CreateServerSocket(in_port_t port,
- int &error,
- bool loopback = false, bool nonblocking = true,
- int family = ATNetworkTool::AF_XINETX,
- int socktype = SOCK_STREAM, int protocol = 0,
- int backlog = ATNetworkTool::DefaultBacklog);
- static int CreateServerSocket(const char *port,
- int &error,
- bool loopback = false, bool nonblocking = true,
- int family = ATNetworkTool::AF_XINETX,
- int socktype = SOCK_STREAM, int protocol = 0,
- int backlog = ATNetworkTool::DefaultBacklog);
-
- /* Connects to local socket
- * @param sock socket to connect to
- * @param error [out] error code
- * @param loopback true to use loopback, false to use any local address
- * @param socktype sockets type
- * @param protocol sockets protocol
- * @return int !=-1 socket, ==-1 on error
- */
- static int ConnectToSocket(int sock,
- int &error, bool loopback = true,
- int socktype = SOCK_STREAM, int protocol = 0);
-
- /* Connects to address
- * @param addr destination address parameters
- * @param error [out] error code
- * @param loopback true to use loopback, false to use any local address
- * @return int !=-1 socket, ==-1 on error
- */
- static int ConnectSocket(struct addrinfo *addr,
- int &error, bool loopback = false);
-
- /* Connects to address
- * @param addr destination address
- * @param addrlen socket address length
- * @param error [out] error code
- * @param loopback true to use loopback, false to use any local address
- * @param family sockets expected family
- * @param socktype sockets type
- * @param protocol sockets protocol
- * @return int !=-1 socket, ==-1 on error
- */
- static int ConnectSocket(const struct sockaddr *addr, socklen_t addrlen,
- int &error, bool loopback = false,
- int family = ATNetworkTool::AF_XINETX,
- int socktype = SOCK_STREAM, int protocol = 0);
-
- /* Connects to address
- * @param hostname name of destination host
- * @param port destination port
- * @param error [out] error code
- * @param family sockets expected family
- * @param socktype sockets type
- * @param protocol sockets protocol
- * @return int !=-1 socket, ==-1 on error
- */
- static int Connect(const char *host, in_port_t port,
- int &error,
- int family = ATNetworkTool::AF_XINETX,
- int socktype = SOCK_STREAM, int protocol = 0);
- static int Connect(const char *host, const char *port,
- int &error,
- int family = ATNetworkTool::AF_XINETX,
- int socktype = SOCK_STREAM, int protocol = 0);
-
- /* Connects to loopback port
- * @param port destination port
- * @param error [out] error code
- * @param family sockets expected family
- * @param socktype sockets type
- * @param protocol sockets protocol
- * @return int !=-1 socket, ==-1 on error
- */
- static int ConnectLoopback(in_port_t port,
- int &error,
- int family = ATNetworkTool::AF_XINETX,
- int socktype = SOCK_STREAM, int protocol = 0);
- static int ConnectLoopback(const char *port,
- int &error,
- int family = ATNetworkTool::AF_XINETX,
- int socktype = SOCK_STREAM, int protocol = 0);
-
- /* Returns local port associated with socket
- * @param sock socket
- * @return unsigned int port number, or 0 - on error
- */
- static unsigned int GetLocalPort(int sock);
-
- /* Accepts connection on sockets - returns address or error
- * @param s socket accepting connection
- * @param address [out] peer address of accepted connection
- * @param error [out] error code
- * @param nonblocking true for nonblocking sockets
- * @return int !=-1 socket, ==-1 on error
- */
- static int Accept(int s, ATAddress &address,
- int &error, bool nonblocking = true);
-};
-
-#endif //_AT_NETWORK_TOOL_H_
-
diff --git a/usr/src/cmd/lms/tools/ATVersion.cpp b/usr/src/cmd/lms/tools/ATVersion.cpp
deleted file mode 100644
index 1cfdd48d6d..0000000000
--- a/usr/src/cmd/lms/tools/ATVersion.cpp
+++ /dev/null
@@ -1,204 +0,0 @@
-/*******************************************************************************
- * 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.
- *******************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include "iatshareddata.h"
-#include "ATVersion.h"
-#include <cstring>
-#include <cstdlib>
-#include <cstdio>
-#include <climits>
-#include <cerrno>
-#include <fstream>
-#include <dirent.h>
-
-#define AT_VERSION_ARGUMENT "--version"
-#define AT_VERSION_MAXSIZE 40
-#define AT_APPNAME_MAXSIZE 15
-#define ATstr(s) ATname(s)
-#define ATname(s) #s
-#define AT_VERSION_OUT_FORMAT "Version: %." ATstr(AT_VERSION_MAXSIZE) "s\n"
-#define AT_VERSION_SCAN_FORMAT "Version: %" ATstr(AT_VERSION_MAXSIZE) "s"
-#define AT_PIDFILE_NAME_FORMAT IATSTATERUNDIR "/%." ATstr(AT_APPNAME_MAXSIZE) "s.pid"
-#define AT_DEF_PIDFILE_NAME_FORMAT "/var/run/%." ATstr(AT_APPNAME_MAXSIZE) "s.pid"
-#define AT_PROCSTAT_NAME_FORMAT "Name:\t%" ATstr(AT_APPNAME_MAXSIZE) "s\n"
-
-const std::string ATVersion::appSearchPath =
- "PATH='/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin' && ";
-
-bool ATVersion::ShowVersionIfArg(int argc, const char **argv, const char *versionStr)
-{
- if (1 < argc) {
- for (int i = 1; i < argc; i++) {
- if (0 == strncmp(argv[i], AT_VERSION_ARGUMENT, strlen(AT_VERSION_ARGUMENT))) {
- fprintf(stdout, AT_VERSION_OUT_FORMAT, versionStr);
- return true;
- }
- }
- }
- return false;
-}
-
-bool ATVersion::GetAppVersion(const char *appName, std::string &version)
-{
- std::list<unsigned long> pids;
-
- version = "";
- if (IsAppRunning(appName, pids)) {
- for (std::list<unsigned long>::iterator iter = pids.begin(); iter != pids.end(); iter++) {
- std::string path = GetAppPathByPid(*iter);
- if (!path.empty()) {
- version = GetProcessVersion(path);
- return true;
- }
- }
- }
- version = GetProcessVersion(ATVersion::appSearchPath + appName);
- if (version.empty()) {
- version = GetProcessVersion(appName);
- }
- return false;
-}
-
-std::string ATVersion::GetProcessVersion(std::string cmd)
-{
- if (cmd.empty()) {
- return "";
- }
-
- FILE *fp = popen((cmd + " " AT_VERSION_ARGUMENT " 2>/dev/null").c_str(), "r");
- if (fp) {
- char buf[AT_VERSION_MAXSIZE + 1];
- int res = fscanf(fp, AT_VERSION_SCAN_FORMAT, buf);
- buf[AT_VERSION_MAXSIZE] = '\0';
- pclose(fp);
- if (1 == res) {
- return buf;
- }
- }
- return "";
-}
-
-bool ATVersion::IsAppRunning(const char *appName, std::list<unsigned long> &pids)
-{
- struct dirent **namelist;
- FILE *stat;
- char name_str[AT_APPNAME_MAXSIZE + 1];
- int num_entries;
- char status_path[256];
- unsigned long pid;
- unsigned long selfpid = 0;
- bool res = false;
- int ret;
-
- pids.clear();
-
- memset(status_path, '\0', sizeof(status_path));
- snprintf(status_path, sizeof(status_path), AT_PIDFILE_NAME_FORMAT, appName);
- std::ifstream pidf(status_path);
- if (pidf.is_open()) {
- pidf >> pid;
- pidf.close();
- if (!(GetAppPathByPid(pid).empty())) {
- pids.push_back(pid);
- return true;
- }
- }
-
- memset(status_path, '\0', sizeof(status_path));
- snprintf(status_path, sizeof(status_path), AT_DEF_PIDFILE_NAME_FORMAT, appName);
- pidf.open(status_path);
- if (pidf.is_open()) {
- pidf >> pid;
- pidf.close();
- if (!(GetAppPathByPid(pid).empty())) {
- pids.push_back(pid);
- return true;
- }
- }
-
- num_entries = scandir("/proc", &namelist, 0, alphasort);
- if (num_entries < 0) {
- return false;
- }
-
- memset(status_path, '\0', sizeof(status_path));
- if (-1 != readlink("/proc/self", status_path, sizeof(status_path))) {
- selfpid = std::atol(status_path);
- }
-
- while (num_entries--) {
- char *pidstr = namelist[num_entries]->d_name;
- if ((pidstr) && (pidstr[0] > '0') && (pidstr[0] <= '9')) {
- pid = std::atol(pidstr);
- if (pid != selfpid) {
- /* for process name we check the 'status' entry */
- memset(status_path, '\0', sizeof(status_path));
- snprintf(status_path, sizeof(status_path), "/proc/%lu/status", pid);
- if (NULL != (stat = fopen(status_path, "r"))) {
- memset(name_str, '\0', sizeof(name_str));
- ret = fscanf(stat, AT_PROCSTAT_NAME_FORMAT, name_str);
- fclose(stat);
- if ((1 == ret) && (strncmp(name_str, appName, 15) == 0)) {
- pids.push_back(pid);
- res = true;
- }
- }
- }
- }
- free(namelist[num_entries]);
- }
- free(namelist);
-
- return res;
-}
-
-
-std::string ATVersion::GetAppPathByPid(unsigned long pid)
-{
- char path[256];
- char exe_buf[PATH_MAX];
-
- memset(path, '\0', sizeof(path));
- snprintf(path, sizeof(path), "/proc/%lu/exe", pid);
- memset(exe_buf, '\0', PATH_MAX);
- if (-1 == readlink(path, exe_buf, PATH_MAX)) {
- return "";
- }
-
- if (NULL != strstr(exe_buf, " (deleted)")) {
- return "";
- }
-
- return exe_buf;
-}
-
diff --git a/usr/src/cmd/lms/tools/ATVersion.h b/usr/src/cmd/lms/tools/ATVersion.h
deleted file mode 100644
index d312c9e45f..0000000000
--- a/usr/src/cmd/lms/tools/ATVersion.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * 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 _AT_VERSION_TOOL_H_
-#define _AT_VERSION_TOOL_H_
-
-#include <string>
-#include <list>
-
-class ATVersion
-{
-public:
- /**
- function check if user requested version information to be displayed on std output
- and show version number
- @param argc Argument count
- @param argv Argument array
- @param versionStr Version string to be displayed
- @return bool true if version user requested version to be displayed
- false if version information was not displayed
- */
- static bool ShowVersionIfArg(int argc, const char **argv, const char *versionStr);
-
- /**
- function gets application version - if target application uses this class to show version
- @param appName application name
- @param version string returning version or empty string if version not determined
- @return true - if application is running, false - if not.
- */
- static bool GetAppVersion(const char *appName, std::string &version);
-
- /**
- function gets process version - if target application uses this class to show version
- @param cmd path to application
- @return string version or empty string if version not determined
- */
- static std::string GetProcessVersion(std::string cmd);
-
- /**
- Checks if an application is running in the system.
- @param app_name Application binary name (not including path).
- @param pids returned list of pids of searched application
- @return true - if application is running, false - if not.
- */
- static bool IsAppRunning(const char *app_name, std::list<unsigned long> &pids);
-
- /**
- Returns path associated with application with given PID. Note that to access this information for all processes
- the function must be called with elevated privileges.
- @param pid PID of application of interest.
- @return Application path if possible.
- Empty string if access is not possbile.
- NULL if the application isn't runnig.
- */
- static std::string GetAppPathByPid(unsigned long pid);
-
- static const std::string appSearchPath;
-};
-
-#endif /* _AT_VERSION_TOOL_H_ */
diff --git a/usr/src/cmd/lms/tools/daemonize.cpp b/usr/src/cmd/lms/tools/daemonize.cpp
deleted file mode 100644
index 39a37bf2de..0000000000
--- a/usr/src/cmd/lms/tools/daemonize.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-/*******************************************************************************
- * 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.
- *******************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#ifdef DAEMON
-
-#include <cstdio>
-#include <cstdlib>
-#include <cstring>
-#include <cerrno>
-#include <csignal>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <syslog.h>
-#include <pwd.h>
-
-#include "daemonize.h"
-
-static RETSIGTYPE child_handler(int signum)
-{
- switch (signum) {
- case SIGALRM:
- exit(EXIT_FAILURE);
- break;
- case SIGUSR1:
- exit(EXIT_SUCCESS);
- break;
- case SIGCHLD:
- exit(EXIT_FAILURE);
- break;
- }
-}
-
-void daemonize()
-{
- pid_t pid, sid, parent;
-
- /* Drop user if there is one, and we were run as root */
- if (getuid() == 0 || geteuid() == 0) {
- struct passwd *pw = getpwnam(RUN_AS_USER);
- if (pw) {
- //syslog(LOG_NOTICE, "setting user to " RUN_AS_USER);
- setuid(pw->pw_uid);
- }
- }
-
- /* Trap signals that we expect to recieve */
- signal(SIGCHLD, child_handler);
- signal(SIGUSR1, child_handler);
- signal(SIGALRM, child_handler);
-
- /* Fork off the parent process */
- pid = fork();
- if (pid < 0) {
- syslog(LOG_ERR, "unable to fork daemon, code=%d (%s)",
- errno, strerror(errno));
- exit(EXIT_FAILURE);
- }
- /* If we got a good PID, then we can exit the parent process. */
- if (pid > 0) {
-
- /* Wait for confirmation from the child via SIGTERM or SIGCHLD, or
- for two seconds to elapse (SIGALRM). pause() should not return. */
- alarm(2);
- pause();
-
- exit(EXIT_FAILURE);
- }
-
- /* At this point we are executing as the child process */
- parent = getppid();
-
- signal(SIGCHLD, SIG_DFL);
- signal(SIGUSR1, SIG_DFL);
- signal(SIGALRM, SIG_DFL);
- setTerminationHandler();
-
- /* Create a new SID for the child process */
- sid = setsid();
- if (sid < 0) {
- syslog(LOG_ERR,
- "unable to create a new session, code %d (%s)",
- errno, strerror(errno));
- exit(EXIT_FAILURE);
- }
-
- /* Change the current working directory. This prevents the current
- directory from being locked; hence not being able to remove it. */
- if ((chdir("/")) < 0) {
- syslog(LOG_ERR,
- "unable to change directory to %s, code %d (%s)",
- "/", errno, strerror(errno));
- exit(EXIT_FAILURE);
- }
-
- /* Redirect standard files to /dev/null */
- freopen("/dev/null", "r", stdin);
- freopen("/dev/null", "w", stdout);
- freopen("/dev/null", "w", stderr);
-
- /* Tell the parent process that we are A-okay */
- kill(parent, SIGUSR1);
-}
-
-#endif //DAEMON
-
diff --git a/usr/src/cmd/lms/tools/daemonize.h b/usr/src/cmd/lms/tools/daemonize.h
deleted file mode 100644
index eaa2179baf..0000000000
--- a/usr/src/cmd/lms/tools/daemonize.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * 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 __DAEMONIZE_H__
-#define __DAEMONIZE_H__
-
-/* Change this to the user under which to run */
-#define RUN_AS_USER "root"
-
-void setTerminationHandler();
-void daemonize();
-
-#endif
diff --git a/usr/src/cmd/lms/types.h b/usr/src/cmd/lms/types.h
deleted file mode 100644
index 36b9fd462b..0000000000
--- a/usr/src/cmd/lms/types.h
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * 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.
- *******************************************************************************/
-
-/**********************************************************************
-* *
-* Module Name: *
-* types.h *
-* *
-* Abstract: *
-* types for each OS are declared here. *
-* *
-**********************************************************************/
-
-#ifndef _TYPES_H_
-#define _TYPES_H_
-
-typedef char CHAR;
-typedef signed char INT8, *PINT8;
-typedef signed short INT16, *PINT16;
-typedef signed int INT32, *PINT32;
-typedef unsigned char UINT8, *PUINT8, UCHAR;
-typedef unsigned short UINT16, *PUINT16;
-typedef unsigned int UINT32, *PUINT32;
-
-#ifndef CONST
-#define CONST const
-#endif
-
-typedef unsigned long DWORD;
-typedef int BOOL;
-typedef unsigned char BYTE;
-typedef unsigned short WORD;
-typedef float FLOAT;
-typedef FLOAT *PFLOAT;
-typedef BOOL *PBOOL;
-typedef BOOL *LPBOOL;
-typedef BYTE *PBYTE;
-typedef BYTE *LPBYTE;
-typedef int *PINT;
-typedef int *LPINT;
-typedef WORD *PWORD;
-typedef WORD *LPWORD;
-typedef long *LPLONG;
-typedef DWORD *PDWORD;
-typedef DWORD *LPDWORD;
-typedef void *LPVOID;
-typedef CONST void *LPCVOID;
-
-typedef int INT;
-typedef unsigned int UINT;
-typedef unsigned int *PUINT;
-
-//
-// UNICODE (Wide Character) types
-//
-
-typedef unsigned short WCHAR;
-
-typedef WCHAR *PWCHAR, *LPWCH, *PWCH;
-typedef CONST WCHAR *LPCWCH, *PCWCH;
-typedef WCHAR *NWPSTR, *LPWSTR, *PWSTR;
-typedef PWSTR *PZPWSTR;
-typedef CONST PWSTR *PCZPWSTR;
-typedef WCHAR *LPUWSTR, *PUWSTR;
-typedef CONST WCHAR *LPCWSTR, *PCWSTR;
-typedef PCWSTR *PZPCWSTR;
-typedef CONST WCHAR *LPCUWSTR, *PCUWSTR;
-
-//
-// ANSI (Multi-byte Character) types
-//
-typedef CHAR *PCHAR, *LPCH, *PCH;
-typedef CONST CHAR *LPCCH, *PCCH;
-
-typedef CHAR *NPSTR, *LPSTR, *PSTR;
-typedef PSTR *PZPSTR;
-typedef CONST PSTR *PCZPSTR;
-typedef CONST CHAR *LPCSTR, *PCSTR;
-typedef PCSTR *PZPCSTR;
-
-//
-// Neutral ANSI/UNICODE types and macros
-//
-#ifdef UNICODE
-
-#ifndef _TCHAR_DEFINED
-typedef WCHAR TCHAR, *PTCHAR;
-typedef WCHAR TBYTE, *PTBYTE;
-#define _TCHAR_DEFINED
-#endif /* !_TCHAR_DEFINED */
-
-typedef LPWSTR LPTCH, PTCH;
-typedef LPWSTR PTSTR, LPTSTR;
-typedef LPCWSTR PCTSTR, LPCTSTR;
-typedef LPUWSTR PUTSTR, LPUTSTR;
-typedef LPCUWSTR PCUTSTR, LPCUTSTR;
-typedef LPWSTR LP;
-#define __TEXT(quote) L##quote
-
-#else /* UNICODE */
-
-#ifndef _TCHAR_DEFINED
-typedef char TCHAR, *PTCHAR;
-typedef unsigned char TBYTE , *PTBYTE ;
-#define _TCHAR_DEFINED
-#endif /* !_TCHAR_DEFINED */
-
-typedef LPSTR LPTCH, PTCH;
-typedef LPSTR PTSTR, LPTSTR, PUTSTR, LPUTSTR;
-typedef LPCSTR PCTSTR, LPCTSTR, PCUTSTR, LPCUTSTR;
-#define __TEXT(quote) quote
-
-#endif /* UNICODE */
-
-#define TEXT(quote) __TEXT(quote)
-
-#if defined(__sun) || defined(_LINUX)
-#define EVENTLOG_ERROR_TYPE LOG_ERR
-#define EVENTLOG_WARNING_TYPE LOG_WARNING
-#define EVENTLOG_INFORMATION_TYPE LOG_INFO
-
-#ifdef DEBUGLOG
-#if defined(__sun)
-#define PRINT(...) printf(__VA_ARGS__)
-#define ERROR(...) fprintf(stderr, __VA_ARGS__)
-#else // _LINUX
-#define PRINT(format, arg...) printf(format, ##arg)
-#define ERROR(format, arg...) fprintf(stderr, format, ##arg)
-#endif // __sun
-#else
-#if defined(__sun)
-#define PRINT(...)
-#define ERROR(...)
-#else // _LINUX
-#define PRINT(format, arg...)
-#define ERROR(format, arg...)
-#endif // __sun
-#endif //DEBUGLOG
-#endif // __sun || _LINUX
-
-#endif /* _TYPES_H_ */
diff --git a/usr/src/cmd/lms/version.h b/usr/src/cmd/lms/version.h
deleted file mode 100644
index 8c434e5abd..0000000000
--- a/usr/src/cmd/lms/version.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * 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 __VERSION_H__
-#define __VERSION_H__
-
-#define MAJOR_VERSION 5
-#define MINOR_VERSION 0
-#define QUICK_FIX_NUMBER 0
-#define VER_BUILD 30
-
-#define _MAKE_VER_STRING(maj, min, submin, bld) #maj "." #min "." #submin "." #bld
-#define MAKE_VER_STRING(maj, min, submin, bld) _MAKE_VER_STRING(maj, min, submin, bld)
-
-#define VER_PRODUCTVERSION MAJOR_VERSION, MINOR_VERSION, QUICK_FIX_NUMBER, VER_BUILD
-#define VER_PRODUCTVERSION_STR MAKE_VER_STRING(MAJOR_VERSION, MINOR_VERSION, QUICK_FIX_NUMBER, VER_BUILD)
-
-#endif