/*******************************************************************************
* Copyright (C) 2004-2008 Intel Corp. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
*
* - Neither the name of Intel Corp. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <cerrno>
#include "types.h"
#include "LMEConnection.h"
#include "LMS_if.h"
#include "Lock.h"
#include "glue.h"
#endif // __sun || _LINUX
const GUID LMEConnection::_guid = {0x6733a4db, 0x0476, 0x4e7b, {0xb3, 0xaf, 0xbc, 0xfc, 0x29, 0xbe, 0xe7, 0xa7}};
_reqID(0),
{
}
{
}
{
return ((_initState == INIT_STATE_CONNECTED) ? true : false);
}
{
if (_initState == INIT_STATE_CONNECTING) {
return false;
}
} else if (_heciCompat.Init()) {
if (protocolVer > LMS_PROCOL_VERSION_COMPAT) {
return false;
}
_pHeci = &_heciCompat;
} else {
return false;
}
// launch RX thread
return true;
}
{
}
delete _rxThread;
}
delete[] _txBuffer;
}
}
{
if (!IsInitialized()) {
PRINT("State: not connected to HECI.\n");
return false;
}
PRINT("Sending disconnect to LME.\n");
}
{
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");
PRINT("Failed to allocate memory for ServiceAccept.\n");
return false;
}
++pCurrent;
pCurrent += 4;
delete [] buf;
}
{
if (!IsInitialized()) {
PRINT("State: not connected to HECI.\n");
return false;
}
PRINT("Sending user authentication success to LME.\n");
}
{
if (!IsInitialized()) {
PRINT("State: not connected to HECI.\n");
return false;
}
PRINT("Sending protocol version to LME: %d.%d\n", versionMessage.MajorVersion, versionMessage.MinorVersion);
return (res == sizeof(protVersion));
}
{
if (!IsInitialized()) {
PRINT("State: not connected to HECI.\n");
return false;
}
}
{
if (!IsInitialized()) {
PRINT("State: not connected to HECI.\n");
return false;
}
PRINT("Sending TCP forward replay failure to LME.\n");
}
{
if (!IsInitialized()) {
PRINT("State: not connected to HECI.\n");
return false;
}
PRINT("Sending TCP forward cancel replay success to LME.\n");
}
{
if (!IsInitialized()) {
PRINT("State: not connected to HECI.\n");
return false;
}
PRINT("Sending TCP forward cancel replay failure to LME.\n");
}
{
if (!IsInitialized()) {
PRINT("State: not connected to HECI.\n");
return false;
}
return false;
}
++pCurrent;
memcpy(pCurrent, APF_OPEN_CHANNEL_REQUEST_FORWARDED, APF_STR_SIZE_OF(APF_OPEN_CHANNEL_REQUEST_FORWARDED));
PRINT("Sending channel open request to LME. Address: %s, requested port: %d.\n",
}
{
if (!IsInitialized()) {
PRINT("State: not connected to HECI.\n");
return false;
}
}
{
if (!IsInitialized()) {
PRINT("State: not connected to HECI.\n");
return false;
}
PRINT("Sending channel open replay failure to LME. Recipient: %d, Reason: %d.\n", recipientChannel, reason);
}
{
if (!IsInitialized()) {
PRINT("State: not connected to HECI.\n");
return false;
}
}
{
if (!IsInitialized()) {
PRINT("State: not connected to HECI.\n");
return false;
}
return -1;
}
}
{
if (!IsInitialized()) {
PRINT("State: not connected to HECI.\n");
return false;
}
}
{
int result;
if (!IsInitialized()) {
return -1;
}
}
return result;
}
{
int result;
if (!IsInitialized()) {
return -1;
}
}
return result;
}
{
try {
connection->_doRX();
}
}
catch (...) {
PRINT("LMEConnection do RX exception\n");
}
}
{
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) +
return false;
}
break;
case APF_USERAUTH_REQUEST:
return false;
}
break;
case APF_GLOBAL_REQUEST:
return false;
}
return false;
}
break;
case APF_CHANNEL_OPEN:
if (bytesRead < sizeof(APF_GENERIC_HEADER)) {
return false;
}
if (bytesRead < (sizeof(APF_GENERIC_HEADER) +
return false;
}
break;
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) +
return false;
}
break;
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;
}
{
unsigned int bytesRead;
while (true) {
if ((int)bytesRead < 0) {
PRINT("Error receiving data from HECI\n");
Deinit();
break;
}
if (bytesRead == 0) {
// ERROR
continue;
}
PRINT("Error receiving data from HECI\n");
Deinit();
break;
}
continue;
}
switch (rxBuffer[0]) {
case APF_DISCONNECT:
{
}
break;
case APF_SERVICE_REQUEST:
{
(char *)(pMessage->ServiceName),
}
break;
case APF_USERAUTH_REQUEST:
break;
case APF_GLOBAL_REQUEST:
break;
case APF_CHANNEL_OPEN:
break;
{
}
break;
case APF_CHANNEL_OPEN_FAILURE:
{
}
break;
case APF_CHANNEL_CLOSE:
{
}
break;
case APF_CHANNEL_DATA:
{
}
break;
{
}
break;
case APF_PROTOCOLVERSION:
{
}
break;
default:
// Uknown request. Ignore
break;
}
if (IsInitialized()) {
}
}
delete[] rxBuffer;
}
}
{
}
}
}
}
}
void LMEConnection::_apfChannelOpenDirect(unsigned char *rxBuffer, unsigned int bytesRead, UINT32 *senderChannel, int *status)
{
unsigned char *pCurrent;
if (bytesRead < sizeof(APF_GENERIC_HEADER) +
PRINT("Error receiving data from HECI\n");
Deinit();
return;
}
if (senderChannel) {
}
}
{
unsigned char *pCurrent;
sizeof(UINT8);
PRINT("Error receiving data from HECI\n");
Deinit();
return;
}
PRINT("Error receiving data from HECI\n");
Deinit();
return;
}
}
sizeof(UINT8);
PRINT("Error receiving data from HECI\n");
Deinit();
return;
}
PRINT("Error receiving data from HECI\n");
Deinit();
return;
}
}
sizeof(UINT8);
PRINT("Error receiving data from HECI\n");
Deinit();
return;
}
PRINT("Error receiving data from HECI\n");
Deinit();
return;
}
PRINT("Error receiving data from HECI\n");
Deinit();
return;
}
// Skip Originator IP and Port
PRINT("Error receiving data from HECI\n");
Deinit();
return;
}
PRINT("Error receiving data from HECI\n");
Deinit();
return;
}
// Retrieve Data
PRINT("Error receiving data from HECI\n");
Deinit();
return;
}
}
}
void LMEConnection::_apfUserAuthRequest(unsigned char *rxBuffer, unsigned int bytesRead, int *status)
{
++pCurrent;
PRINT("Error receiving data from HECI\n");
Deinit();
return;
}
PRINT("Error receiving data from HECI\n");
Deinit();
return;
}
PRINT("Error receiving data from HECI\n");
Deinit();
return;
}
PRINT("Error receiving data from HECI\n");
Deinit();
return;
}
PRINT("Error receiving data from HECI\n");
Deinit();
return;
}
PRINT("Error receiving data from HECI\n");
Deinit();
return;
}
++pCurrent;
PRINT("Error receiving data from HECI\n");
Deinit();
return;
}
}
}
{
return 0;
}
return _pHeci->GetBufferSize();
}