gobi: duplicate upstream GobiAPI so we can change it
This commit is contained in:
parent
5f0ca4eb56
commit
254f647f1b
|
@ -0,0 +1,555 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
BitPacker.cpp
|
||||
|
||||
DESCRIPTION:
|
||||
Implementation of cBitPacker class
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
cBitPacker
|
||||
This class packs bits into a buffer
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "BitPacker.h"
|
||||
|
||||
#include <list>
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
/*=========================================================================*/
|
||||
// Free Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
SetUnsignedVal (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Set an unsigned value in the bit source (writing least significant
|
||||
bits first)
|
||||
|
||||
PARAMETERS:
|
||||
pData [ O ] - Data buffer to write to
|
||||
currentOffset [I/O] - Current bit offset into above buffer
|
||||
maxOffset [ I ] - Maximum bit offset into above buffer
|
||||
numBits [ I ] - Number of bits to write
|
||||
dataIn [ I ] - Input value to write
|
||||
bLSB [ I ] - Pack LSB -> MSB?
|
||||
|
||||
RETURN VALUE:
|
||||
DWORD
|
||||
===========================================================================*/
|
||||
template <class T>
|
||||
DWORD SetUnsignedVal(
|
||||
BYTE * pData,
|
||||
ULONG & currentOffset,
|
||||
ULONG maxOffset,
|
||||
ULONG numBits,
|
||||
T dataIn,
|
||||
bool bLSB = true )
|
||||
{
|
||||
ASSERT( pData != 0 );
|
||||
|
||||
// Number of bits in the passed in type
|
||||
const ULONG TYPE_BIT_COUNT = (ULONG)(sizeof( T ) * BITS_PER_BYTE);
|
||||
ASSERT( numBits > 0 && numBits <= TYPE_BIT_COUNT);
|
||||
|
||||
// Requesting too much?
|
||||
if (currentOffset < maxOffset)
|
||||
{
|
||||
ULONG bitsToGo = maxOffset - currentOffset;
|
||||
if (bitsToGo < numBits)
|
||||
{
|
||||
return ERROR_NOT_ENOUGH_MEMORY;
|
||||
}
|
||||
}
|
||||
else if (currentOffset == maxOffset)
|
||||
{
|
||||
// Silly rabbit, don't bother to call us if you don't want any bits!
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ERROR_NOT_ENOUGH_MEMORY;
|
||||
}
|
||||
|
||||
// Advance to first valid byte
|
||||
pData += (currentOffset / BITS_PER_BYTE);
|
||||
|
||||
// Since we don't really care about performance for bit packing
|
||||
// (we do not anticipate this being called as frequently as bit
|
||||
// parsing) we always use the generic approach
|
||||
|
||||
// Reduce input to a bit array
|
||||
BYTE bits[MAX_TYPE_BITS];
|
||||
|
||||
ULONG bitsExtracted = 0;
|
||||
while (bitsExtracted < numBits)
|
||||
{
|
||||
if (bLSB == true)
|
||||
{
|
||||
BYTE bit = (BYTE)(dataIn & (T)1);
|
||||
bits[bitsExtracted++] = bit;
|
||||
}
|
||||
else
|
||||
{
|
||||
BYTE bit = (BYTE)(dataIn & (T)1);
|
||||
bits[numBits - ++bitsExtracted] = bit;
|
||||
}
|
||||
|
||||
dataIn >>= 1;
|
||||
}
|
||||
|
||||
|
||||
// Store current offset
|
||||
ULONG offset = currentOffset;
|
||||
|
||||
// Add in each bit - one at a time
|
||||
bitsExtracted = 0;
|
||||
while (bitsExtracted != numBits)
|
||||
{
|
||||
// How many bits are left in the current byte?
|
||||
ULONG bitsLeft = BITS_PER_BYTE - (offset % BITS_PER_BYTE);
|
||||
|
||||
// Shift input bit over to desired destination
|
||||
BYTE tmp = bits[bitsExtracted++];
|
||||
|
||||
if (bLSB == true)
|
||||
{
|
||||
tmp <<= (BITS_PER_BYTE - bitsLeft);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp <<= bitsLeft - 1;
|
||||
}
|
||||
|
||||
*pData |= tmp;
|
||||
|
||||
// Advance to next byte in buffer?
|
||||
offset++;
|
||||
if (offset % BITS_PER_BYTE == 0)
|
||||
{
|
||||
pData++;
|
||||
}
|
||||
}
|
||||
|
||||
currentOffset += numBits;
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
/*=========================================================================*/
|
||||
// cBitPacker Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
cBitPacker (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Constructor (default)
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cBitPacker::cBitPacker()
|
||||
: mpData( 0 ),
|
||||
mOffset( 0 ),
|
||||
mMaxAttainedOffset( 0 ),
|
||||
mMaxOffset( 0 ),
|
||||
mbLSB( true )
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
cBitPacker (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Constructor (from a buffer)
|
||||
|
||||
PARAMETERS:
|
||||
pData [ I ] - Data buffer
|
||||
dataBitSize [ I ] - Size of above data buffer (in bits)
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cBitPacker::cBitPacker(
|
||||
BYTE * pData,
|
||||
ULONG dataBitSize )
|
||||
: mpData( 0 ),
|
||||
mOffset( 0 ),
|
||||
mMaxAttainedOffset( 0 ),
|
||||
mMaxOffset( 0 ),
|
||||
mbLSB( true )
|
||||
{
|
||||
SetData( pData, dataBitSize );
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
~cBitPacker (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Destructor
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cBitPacker::~cBitPacker()
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
Set (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Write 'numBits' from a CHAR (advances offset)
|
||||
|
||||
PARAMETERS:
|
||||
numBits [ I ] - Number of bits to write
|
||||
dataIn [ I ] - Value to write
|
||||
|
||||
RETURN VALUE:
|
||||
DWORD
|
||||
===========================================================================*/
|
||||
DWORD cBitPacker::Set(
|
||||
ULONG numBits,
|
||||
CHAR dataIn )
|
||||
{
|
||||
DWORD rc = SetUnsignedVal( mpData,
|
||||
mOffset,
|
||||
mMaxOffset,
|
||||
numBits,
|
||||
dataIn,
|
||||
mbLSB );
|
||||
|
||||
if (rc == NO_ERROR && mOffset > mMaxAttainedOffset)
|
||||
{
|
||||
mMaxAttainedOffset = mOffset;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
Set (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Write 'numBits' from a SHORT (advances offset)
|
||||
|
||||
PARAMETERS:
|
||||
numBits [ I ] - Number of bits to write
|
||||
dataIn [ I ] - Value to write
|
||||
|
||||
RETURN VALUE:
|
||||
DWORD
|
||||
===========================================================================*/
|
||||
DWORD cBitPacker::Set(
|
||||
ULONG numBits,
|
||||
SHORT dataIn )
|
||||
{
|
||||
DWORD rc = SetUnsignedVal( mpData,
|
||||
mOffset,
|
||||
mMaxOffset,
|
||||
numBits,
|
||||
dataIn,
|
||||
mbLSB );
|
||||
|
||||
if (rc == NO_ERROR && mOffset > mMaxAttainedOffset)
|
||||
{
|
||||
mMaxAttainedOffset = mOffset;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
Set (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Write 'numBits' from a LONG (advances offset)
|
||||
|
||||
PARAMETERS:
|
||||
numBits [ I ] - Number of bits to write
|
||||
dataIn [ I ] - Value to write
|
||||
|
||||
RETURN VALUE:
|
||||
DWORD
|
||||
===========================================================================*/
|
||||
DWORD cBitPacker::Set(
|
||||
ULONG numBits,
|
||||
LONG dataIn )
|
||||
{
|
||||
DWORD rc = SetUnsignedVal( mpData,
|
||||
mOffset,
|
||||
mMaxOffset,
|
||||
numBits,
|
||||
dataIn,
|
||||
mbLSB );
|
||||
|
||||
if (rc == NO_ERROR && mOffset > mMaxAttainedOffset)
|
||||
{
|
||||
mMaxAttainedOffset = mOffset;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
Set (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Write 'numBits' from a LONGLONG (advances offset)
|
||||
|
||||
PARAMETERS:
|
||||
numBits [ I ] - Number of bits to write
|
||||
dataIn [ I ] - Value to write
|
||||
|
||||
RETURN VALUE:
|
||||
DWORD
|
||||
===========================================================================*/
|
||||
DWORD cBitPacker::Set(
|
||||
ULONG numBits,
|
||||
LONGLONG dataIn )
|
||||
{
|
||||
DWORD rc = SetUnsignedVal( mpData,
|
||||
mOffset,
|
||||
mMaxOffset,
|
||||
numBits,
|
||||
dataIn,
|
||||
mbLSB );
|
||||
|
||||
if (rc == NO_ERROR && mOffset > mMaxAttainedOffset)
|
||||
{
|
||||
mMaxAttainedOffset = mOffset;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
Set (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Write 'numBits' from a UCHAR (advances offset)
|
||||
|
||||
PARAMETERS:
|
||||
numBits [ I ] - Number of bits to write
|
||||
dataIn [ I ] - Value to write
|
||||
|
||||
RETURN VALUE:
|
||||
DWORD
|
||||
===========================================================================*/
|
||||
DWORD cBitPacker::Set(
|
||||
ULONG numBits,
|
||||
UCHAR dataIn )
|
||||
{
|
||||
DWORD rc = SetUnsignedVal( mpData,
|
||||
mOffset,
|
||||
mMaxOffset,
|
||||
numBits,
|
||||
dataIn,
|
||||
mbLSB );
|
||||
|
||||
if (rc == NO_ERROR && mOffset > mMaxAttainedOffset)
|
||||
{
|
||||
mMaxAttainedOffset = mOffset;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
Set (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Write 'numBits' from a USHORT (advances offset)
|
||||
|
||||
PARAMETERS:
|
||||
numBits [ I ] - Number of bits to write
|
||||
dataIn [ I ] - Value to write
|
||||
|
||||
RETURN VALUE:
|
||||
DWORD
|
||||
===========================================================================*/
|
||||
DWORD cBitPacker::Set(
|
||||
ULONG numBits,
|
||||
USHORT dataIn )
|
||||
{
|
||||
DWORD rc = SetUnsignedVal( mpData,
|
||||
mOffset,
|
||||
mMaxOffset,
|
||||
numBits,
|
||||
dataIn,
|
||||
mbLSB );
|
||||
|
||||
if (rc == NO_ERROR && mOffset > mMaxAttainedOffset)
|
||||
{
|
||||
mMaxAttainedOffset = mOffset;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
Set (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Write 'numBits' from a ULONG (advances offset)
|
||||
|
||||
PARAMETERS:
|
||||
numBits [ I ] - Number of bits to write
|
||||
dataIn [ I ] - Value to write
|
||||
|
||||
RETURN VALUE:
|
||||
DWORD
|
||||
===========================================================================*/
|
||||
DWORD cBitPacker::Set(
|
||||
ULONG numBits,
|
||||
ULONG dataIn )
|
||||
{
|
||||
DWORD rc = SetUnsignedVal( mpData,
|
||||
mOffset,
|
||||
mMaxOffset,
|
||||
numBits,
|
||||
dataIn,
|
||||
mbLSB );
|
||||
|
||||
if (rc == NO_ERROR && mOffset > mMaxAttainedOffset)
|
||||
{
|
||||
mMaxAttainedOffset = mOffset;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
Set (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Write 'numBits' from a ULONGLONG (advances offset)
|
||||
|
||||
PARAMETERS:
|
||||
numBits [ I ] - Number of bits to write
|
||||
dataIn [ I ] - Value to write
|
||||
|
||||
RETURN VALUE:
|
||||
DWORD
|
||||
===========================================================================*/
|
||||
DWORD cBitPacker::Set(
|
||||
ULONG numBits,
|
||||
ULONGLONG dataIn )
|
||||
{
|
||||
DWORD rc = SetUnsignedVal( mpData,
|
||||
mOffset,
|
||||
mMaxOffset,
|
||||
numBits,
|
||||
dataIn,
|
||||
mbLSB );
|
||||
|
||||
if (rc == NO_ERROR && mOffset > mMaxAttainedOffset)
|
||||
{
|
||||
mMaxAttainedOffset = mOffset;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
ReleaseData (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Release the data being parsed
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
void cBitPacker::ReleaseData()
|
||||
{
|
||||
// Clear out current buffer
|
||||
mpData = 0;
|
||||
mOffset = 0;
|
||||
mMaxAttainedOffset = 0;
|
||||
mMaxOffset = 0;
|
||||
};
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
SetData (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Set the data being parsed
|
||||
|
||||
PARAMETERS:
|
||||
pData [ I ] - Data buffer
|
||||
dataBitSize [ I ] - Size of above data buffer (in bits)
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
void cBitPacker::SetData(
|
||||
BYTE * pData,
|
||||
ULONG dataBitSize )
|
||||
{
|
||||
// Release current buffer
|
||||
ReleaseData();
|
||||
|
||||
// Anything to parse?
|
||||
if (pData != 0)
|
||||
{
|
||||
// Yes
|
||||
mpData = pData;
|
||||
mMaxOffset = dataBitSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
// No
|
||||
ASSERT( mpData != 0 );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,183 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
BitPacker.h
|
||||
|
||||
DESCRIPTION:
|
||||
Declaration of cBitPacker class
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
cBitPacker
|
||||
This class packs bits into a buffer
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
#include "BitParser.h"
|
||||
|
||||
|
||||
/*=========================================================================*/
|
||||
// Class cBitPacker
|
||||
//
|
||||
// Class to assist in parsing a buffer into bit/byte specified fields
|
||||
/*=========================================================================*/
|
||||
class cBitPacker
|
||||
{
|
||||
public:
|
||||
// Constructor (default)
|
||||
cBitPacker();
|
||||
|
||||
// Constructor (from a buffer)
|
||||
cBitPacker(
|
||||
BYTE * pData,
|
||||
ULONG dataBitSize );
|
||||
|
||||
// Destructor
|
||||
~cBitPacker();
|
||||
|
||||
// (Inline) Returns the number of bits left in the buffer (from the
|
||||
// current working bit offset)
|
||||
ULONG GetNumBitsLeft() const
|
||||
{
|
||||
return (mMaxOffset - mOffset);
|
||||
};
|
||||
|
||||
// (Inline) Returns the number of bits in the buffer that have been
|
||||
// written (essentially the current working bit offset)
|
||||
ULONG GetNumBitsWritten() const
|
||||
{
|
||||
return (mOffset);
|
||||
};
|
||||
|
||||
// (Inline) Returns the number of bits in the buffer that have been
|
||||
// written (essentially the maximum value the working bit offset
|
||||
// attained up to now)
|
||||
ULONG GetTotalBitsWritten() const
|
||||
{
|
||||
return mMaxAttainedOffset;
|
||||
};
|
||||
|
||||
// (Inline) Set current working bit offset
|
||||
void SetOffset( ULONG offset )
|
||||
{
|
||||
mOffset = offset;
|
||||
if (mOffset > mMaxOffset)
|
||||
{
|
||||
mOffset = mMaxOffset;
|
||||
}
|
||||
|
||||
if (mOffset > mMaxAttainedOffset)
|
||||
{
|
||||
mMaxAttainedOffset = mOffset;
|
||||
}
|
||||
};
|
||||
|
||||
// (Inline) Are we parsing LSB -> MSB (the default)?
|
||||
bool GetLSBMode()
|
||||
{
|
||||
return mbLSB;
|
||||
};
|
||||
|
||||
// (Inline) Parse LSB -> MSB (if true) or MSB -> LSB
|
||||
void SetLSBMode( bool bLSB )
|
||||
{
|
||||
mbLSB = bLSB;
|
||||
};
|
||||
|
||||
// Write 'numBits' from a CHAR (advances offset)
|
||||
DWORD Set(
|
||||
ULONG numBits,
|
||||
CHAR dataIn );
|
||||
|
||||
// Write 'numBits' from a SHORT (advances offset)
|
||||
DWORD Set(
|
||||
ULONG numBits,
|
||||
SHORT dataIn );
|
||||
|
||||
// Write 'numBits' from a LONG (advances offset)
|
||||
DWORD Set(
|
||||
ULONG numBits,
|
||||
LONG dataIn );
|
||||
|
||||
// Write 'numBits' from a LONGLONG (advances offset)
|
||||
DWORD Set(
|
||||
ULONG numBits,
|
||||
LONGLONG dataIn );
|
||||
|
||||
// Write 'numBits' from a UCHAR (advances offset)
|
||||
DWORD Set(
|
||||
ULONG numBits,
|
||||
UCHAR dataIn );
|
||||
|
||||
// Write 'numBits' from a USHORT (advances offset)
|
||||
DWORD Set(
|
||||
ULONG numBits,
|
||||
USHORT dataIn );
|
||||
|
||||
// Write 'numBits' from a ULONG (advances offset)
|
||||
DWORD Set(
|
||||
ULONG numBits,
|
||||
ULONG dataIn );
|
||||
|
||||
// Write 'numBits' from a ULONGLONG (advances offset)
|
||||
DWORD Set(
|
||||
ULONG numBits,
|
||||
ULONGLONG dataIn );
|
||||
|
||||
// Release the data being parsed
|
||||
void ReleaseData();
|
||||
|
||||
// Set the data being parsed
|
||||
void SetData(
|
||||
BYTE * pData,
|
||||
ULONG dataBitSize );
|
||||
|
||||
protected:
|
||||
/* Data buffer */
|
||||
BYTE * mpData;
|
||||
|
||||
/* Current bit-specified offset */
|
||||
ULONG mOffset;
|
||||
|
||||
/* Maximum value the above bit offset attained */
|
||||
ULONG mMaxAttainedOffset;
|
||||
|
||||
/* Maximum bit-specified offset */
|
||||
ULONG mMaxOffset;
|
||||
|
||||
/* Are we parsing LSB -> MSB (the default)? */
|
||||
bool mbLSB;
|
||||
|
||||
};
|
|
@ -0,0 +1,578 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
BitParser.cpp
|
||||
|
||||
DESCRIPTION:
|
||||
Implementation of cBitParser class
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
cBitParser
|
||||
This class extracts bits from a buffer
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "BitParser.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static BYTE MASK[BITS_PER_BYTE + 1] =
|
||||
{
|
||||
0x00,
|
||||
0x01,
|
||||
0x03,
|
||||
0x07,
|
||||
0x0F,
|
||||
0x1F,
|
||||
0x3F,
|
||||
0x7F,
|
||||
0xFF
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Free Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetUnsignedVal (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Get an unsigned value from the bit source (reading least significant
|
||||
bits first)
|
||||
|
||||
PARAMETERS:
|
||||
pData [ I ] - Data buffer
|
||||
currentOffset [I/O] - Current bit offset into above buffer
|
||||
maxOffset [ I ] - Maximum bit offset into above buffer
|
||||
numBits [ I ] - Number of bits to process
|
||||
dataOut [ O ] - Processed value
|
||||
bLSB [ I ] - Parse LSB -> MSB?
|
||||
|
||||
RETURN VALUE:
|
||||
DWORD
|
||||
===========================================================================*/
|
||||
template <class T>
|
||||
DWORD GetUnsignedVal(
|
||||
const BYTE * pData,
|
||||
ULONG & currentOffset,
|
||||
ULONG maxOffset,
|
||||
ULONG numBits,
|
||||
T & dataOut,
|
||||
bool bLSB = true )
|
||||
{
|
||||
ASSERT( pData != 0 );
|
||||
|
||||
// Number of bits in the passed in type
|
||||
const ULONG TYPE_BIT_COUNT = (ULONG)(sizeof( T ) * BITS_PER_BYTE);
|
||||
|
||||
// Bad parameters?
|
||||
if (numBits == 0 || numBits > TYPE_BIT_COUNT || numBits > MAX_TYPE_BITS)
|
||||
{
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
// Requesting too much?
|
||||
if (currentOffset < maxOffset)
|
||||
{
|
||||
ULONG bitsToGo = maxOffset - currentOffset;
|
||||
if (bitsToGo < numBits)
|
||||
{
|
||||
return ERROR_NOT_ENOUGH_MEMORY;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// No bits left!
|
||||
return ERROR_NOT_ENOUGH_MEMORY;
|
||||
}
|
||||
|
||||
// Advance to first valid bit
|
||||
pData += (currentOffset / BITS_PER_BYTE);
|
||||
|
||||
// Number of bits left in current byte
|
||||
ULONG bitsLeft = BITS_PER_BYTE - (currentOffset % BITS_PER_BYTE);
|
||||
|
||||
if (bLSB == true)
|
||||
{
|
||||
// Extracting native types on byte boundaries?
|
||||
if (numBits == TYPE_BIT_COUNT && bitsLeft == BITS_PER_BYTE)
|
||||
{
|
||||
// Yes, a simple cast will suffice
|
||||
dataOut = *((T *)pData);
|
||||
|
||||
currentOffset += numBits;
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
// Extracting some small number of bits?
|
||||
if (numBits <= bitsLeft)
|
||||
{
|
||||
// Yes, simply shift back to origin and AND with correct mask
|
||||
BYTE tmp = *pData;
|
||||
tmp >>= (BITS_PER_BYTE - bitsLeft);
|
||||
tmp &= MASK[numBits];
|
||||
|
||||
dataOut = (T)tmp;
|
||||
|
||||
currentOffset += numBits;
|
||||
return NO_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// Not either of the simple cases - extract the relevant bits
|
||||
// and then build the output
|
||||
|
||||
// Extract bits
|
||||
BYTE bits[MAX_TYPE_BITS];
|
||||
ULONG bitsExtracted = 0;
|
||||
|
||||
while (bitsExtracted < numBits)
|
||||
{
|
||||
BYTE bit = *pData;
|
||||
|
||||
if (bLSB == true)
|
||||
{
|
||||
bit <<= (bitsLeft - 1);
|
||||
bit >>= (BITS_PER_BYTE - 1);
|
||||
bits[bitsExtracted++] = bit;
|
||||
}
|
||||
else
|
||||
{
|
||||
bit >>= (bitsLeft - 1);
|
||||
bit &= 0x01;
|
||||
bits[numBits - ++bitsExtracted] = bit;
|
||||
}
|
||||
|
||||
bitsLeft--;
|
||||
if (bitsLeft == 0)
|
||||
{
|
||||
pData++;
|
||||
bitsLeft = BITS_PER_BYTE;
|
||||
}
|
||||
}
|
||||
|
||||
// Reassemble to form output value
|
||||
dataOut = 0;
|
||||
T tmp = 0;
|
||||
|
||||
for (ULONG b = 0; b < numBits; b++)
|
||||
{
|
||||
tmp = bits[b];
|
||||
tmp <<= b;
|
||||
|
||||
dataOut |= tmp;
|
||||
}
|
||||
|
||||
currentOffset += numBits;
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetSignedVal (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Get an signed value from the bit source (reading least significant
|
||||
bits first), just gets the equivalent unsigned representation and
|
||||
then sign-extends as necessary
|
||||
|
||||
PARAMETERS:
|
||||
pData [ I ] - Data buffer
|
||||
currentOffset [I/O] - Current bit offset into above buffer
|
||||
maxOffset [ I ] - Maximum bit offset into above buffer
|
||||
numBits [ I ] - Number of bits to process
|
||||
dataOut [ O ] - Processed value
|
||||
bLSB [ I ] - Parse LSB -> MSB?
|
||||
|
||||
RETURN VALUE:
|
||||
DWORD
|
||||
===========================================================================*/
|
||||
template <class T>
|
||||
DWORD GetSignedVal(
|
||||
const BYTE * pData,
|
||||
ULONG & currentOffset,
|
||||
ULONG maxOffset,
|
||||
ULONG numBits,
|
||||
T & dataOut,
|
||||
bool bLSB = true )
|
||||
{
|
||||
DWORD rc = GetUnsignedVal( pData,
|
||||
currentOffset,
|
||||
maxOffset,
|
||||
numBits,
|
||||
dataOut,
|
||||
bLSB );
|
||||
|
||||
if (rc == NO_ERROR)
|
||||
{
|
||||
// If the highest-order bit is one, we must sign-extend
|
||||
bool bSignExtend = (numBits < (sizeof( T ) * BITS_PER_BYTE))
|
||||
&& ((dataOut >> (numBits - 1)) & 1) == 1;
|
||||
|
||||
if (bSignExtend == true)
|
||||
{
|
||||
T mask = (T)((~0) << numBits);
|
||||
dataOut |= mask;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*=========================================================================*/
|
||||
// cBitParser Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
cBitParser (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Constructor (default)
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cBitParser::cBitParser()
|
||||
: mpData( 0 ),
|
||||
mOffset( 0 ),
|
||||
mMaxOffset( 0 ),
|
||||
mbLSB( true )
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
cBitParser (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Constructor (from a buffer)
|
||||
|
||||
PARAMETERS:
|
||||
pData [ I ] - Data buffer
|
||||
dataBitSize [ I ] - Size of above data buffer (in bits)
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cBitParser::cBitParser(
|
||||
const BYTE * pData,
|
||||
ULONG dataBitSize )
|
||||
: mpData( 0 ),
|
||||
mOffset( 0 ),
|
||||
mMaxOffset( 0 ),
|
||||
mbLSB( true )
|
||||
{
|
||||
SetData( pData, dataBitSize );
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
cBitParser (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Destructor
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cBitParser::~cBitParser()
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
Get (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Return 'numBits' as a CHAR (advances offset)
|
||||
|
||||
PARAMETERS:
|
||||
numBits [ I ] - Number of bits to process
|
||||
dataOut [ O ] - Processed value
|
||||
|
||||
RETURN VALUE:
|
||||
DWORD
|
||||
===========================================================================*/
|
||||
DWORD cBitParser::Get(
|
||||
ULONG numBits,
|
||||
CHAR & dataOut )
|
||||
{
|
||||
return GetSignedVal( mpData,
|
||||
mOffset,
|
||||
mMaxOffset,
|
||||
numBits,
|
||||
dataOut,
|
||||
mbLSB );
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
Get (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Return 'numBits' as a SHORT (advances offset)
|
||||
|
||||
PARAMETERS:
|
||||
numBits [ I ] - Number of bits to process
|
||||
dataOut [ O ] - Processed value
|
||||
|
||||
RETURN VALUE:
|
||||
DWORD
|
||||
===========================================================================*/
|
||||
DWORD cBitParser::Get(
|
||||
ULONG numBits,
|
||||
SHORT & dataOut )
|
||||
{
|
||||
return GetSignedVal( mpData,
|
||||
mOffset,
|
||||
mMaxOffset,
|
||||
numBits,
|
||||
dataOut,
|
||||
mbLSB );
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
Get (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Return 'numBits' as a LONG (advances offset)
|
||||
|
||||
PARAMETERS:
|
||||
numBits [ I ] - Number of bits to process
|
||||
dataOut [ O ] - Processed value
|
||||
|
||||
RETURN VALUE:
|
||||
DWORD
|
||||
===========================================================================*/
|
||||
DWORD cBitParser::Get(
|
||||
ULONG numBits,
|
||||
LONG & dataOut )
|
||||
{
|
||||
return GetSignedVal( mpData,
|
||||
mOffset,
|
||||
mMaxOffset,
|
||||
numBits,
|
||||
dataOut,
|
||||
mbLSB );
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
Get (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Return 'numBits' as a LONGLONG (advances offset)
|
||||
|
||||
PARAMETERS:
|
||||
numBits [ I ] - Number of bits to process
|
||||
dataOut [ O ] - Processed value
|
||||
|
||||
RETURN VALUE:
|
||||
DWORD
|
||||
===========================================================================*/
|
||||
DWORD cBitParser::Get(
|
||||
ULONG numBits,
|
||||
LONGLONG & dataOut )
|
||||
{
|
||||
return GetSignedVal( mpData,
|
||||
mOffset,
|
||||
mMaxOffset,
|
||||
numBits,
|
||||
dataOut,
|
||||
mbLSB );
|
||||
}
|
||||
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
Get (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Return 'numBits' as a UCHAR (advances offset)
|
||||
|
||||
PARAMETERS:
|
||||
numBits [ I ] - Number of bits to process
|
||||
dataOut [ O ] - Processed value
|
||||
|
||||
RETURN VALUE:
|
||||
DWORD
|
||||
===========================================================================*/
|
||||
DWORD cBitParser::Get(
|
||||
ULONG numBits,
|
||||
UCHAR & dataOut )
|
||||
{
|
||||
return GetUnsignedVal( mpData,
|
||||
mOffset,
|
||||
mMaxOffset,
|
||||
numBits,
|
||||
dataOut,
|
||||
mbLSB );
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
Get (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Return 'numBits' as a USHORT (advances offset)
|
||||
|
||||
PARAMETERS:
|
||||
numBits [ I ] - Number of bits to process
|
||||
dataOut [ O ] - Processed value
|
||||
|
||||
RETURN VALUE:
|
||||
DWORD
|
||||
===========================================================================*/
|
||||
DWORD cBitParser::Get(
|
||||
ULONG numBits,
|
||||
USHORT & dataOut )
|
||||
{
|
||||
return GetUnsignedVal( mpData,
|
||||
mOffset,
|
||||
mMaxOffset,
|
||||
numBits,
|
||||
dataOut,
|
||||
mbLSB );
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
Get (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Return 'numBits' as a ULONG (advances offset)
|
||||
|
||||
PARAMETERS:
|
||||
numBits [ I ] - Number of bits to process
|
||||
dataOut [ O ] - Processed value
|
||||
|
||||
RETURN VALUE:
|
||||
DWORD
|
||||
===========================================================================*/
|
||||
DWORD cBitParser::Get(
|
||||
ULONG numBits,
|
||||
ULONG & dataOut )
|
||||
{
|
||||
return GetUnsignedVal( mpData,
|
||||
mOffset,
|
||||
mMaxOffset,
|
||||
numBits,
|
||||
dataOut,
|
||||
mbLSB );
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
Get (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Return 'numBits' as a ULONGLONG (advances offset)
|
||||
|
||||
PARAMETERS:
|
||||
numBits [ I ] - Number of bits to process
|
||||
dataOut [ O ] - Processed value
|
||||
|
||||
RETURN VALUE:
|
||||
DWORD
|
||||
===========================================================================*/
|
||||
DWORD cBitParser::Get(
|
||||
ULONG numBits,
|
||||
ULONGLONG & dataOut )
|
||||
{
|
||||
return GetUnsignedVal( mpData,
|
||||
mOffset,
|
||||
mMaxOffset,
|
||||
numBits,
|
||||
dataOut,
|
||||
mbLSB );
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
ReleaseData (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Release the data being parsed
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
void cBitParser::ReleaseData()
|
||||
{
|
||||
// Clear out current buffer
|
||||
mpData = 0;
|
||||
mOffset = 0;
|
||||
mMaxOffset = 0;
|
||||
};
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
SetData (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Set the data being parsed
|
||||
|
||||
PARAMETERS:
|
||||
pData [ I ] - Data buffer
|
||||
dataBitSize [ I ] - Size of above data buffer (in bits)
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
void cBitParser::SetData(
|
||||
const BYTE * pData,
|
||||
ULONG dataBitSize )
|
||||
{
|
||||
// Release current buffer
|
||||
ReleaseData();
|
||||
|
||||
// Anything to parse?
|
||||
if (pData != 0)
|
||||
{
|
||||
// Yes
|
||||
mpData = pData;
|
||||
mMaxOffset = dataBitSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
// No
|
||||
ASSERT( mpData != 0 );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,198 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
BitParser.h
|
||||
|
||||
DESCRIPTION:
|
||||
Declaration of cBitParser class
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
cBitParser
|
||||
This class extracts bits from a buffer
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// Number of bits in a byte
|
||||
const ULONG BITS_PER_BYTE = 8;
|
||||
|
||||
// Maximum number of bits we will parse for any supported type
|
||||
const ULONG MAX_TYPE_BITS = (ULONG)sizeof(ULONGLONG) * BITS_PER_BYTE;
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
ByteSwap (Inline Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Changes little-endian values to big-endian, and vice versa
|
||||
|
||||
PARAMETERS:
|
||||
data [ I ] - Data being byte-swapped
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
template <class T>
|
||||
void ByteSwap( T & data )
|
||||
{
|
||||
// Just reverse the order of the bytes
|
||||
PBYTE pL;
|
||||
PBYTE pR;
|
||||
|
||||
for (pL = (PBYTE)&data, pR = pL + sizeof( T ) - 1; pL < pR; ++pL, --pR)
|
||||
{
|
||||
*pL = *pL ^ *pR;
|
||||
*pR = *pL ^ *pR;
|
||||
*pL = *pL ^ *pR;
|
||||
}
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Class cBitParser
|
||||
//
|
||||
// Class to assist in parsing a buffer into bit/byte specified fields
|
||||
/*=========================================================================*/
|
||||
class cBitParser
|
||||
{
|
||||
public:
|
||||
// Constructor (default)
|
||||
cBitParser();
|
||||
|
||||
// Constructor (from a buffer)
|
||||
cBitParser(
|
||||
const BYTE * pData,
|
||||
ULONG dataBitSize );
|
||||
|
||||
// Destructor
|
||||
~cBitParser();
|
||||
|
||||
// (Inline) Returns the number of bits left in the buffer (from the
|
||||
// current working bit offset)
|
||||
ULONG GetNumBitsLeft() const
|
||||
{
|
||||
return (mMaxOffset - mOffset);
|
||||
};
|
||||
|
||||
// (Inline) Returns the number of bits in the buffer that have been
|
||||
// processed (essentially the current working bit offset)
|
||||
ULONG GetNumBitsParsed() const
|
||||
{
|
||||
return (mOffset);
|
||||
};
|
||||
|
||||
// (Inline) Set current working bit offset
|
||||
void SetOffset( ULONG offset )
|
||||
{
|
||||
mOffset = offset;
|
||||
if (mOffset > mMaxOffset)
|
||||
{
|
||||
mOffset = mMaxOffset;
|
||||
}
|
||||
};
|
||||
|
||||
// (Inline) Are we parsing LSB -> MSB (the default)?
|
||||
bool GetLSBMode()
|
||||
{
|
||||
return mbLSB;
|
||||
};
|
||||
|
||||
// (Inline) Parse LSB -> MSB (if true) or MSB -> LSB
|
||||
void SetLSBMode( bool bLSB )
|
||||
{
|
||||
mbLSB = bLSB;
|
||||
};
|
||||
|
||||
// Return 'numBits' as a CHAR (advances offset)
|
||||
DWORD Get(
|
||||
ULONG numBits,
|
||||
CHAR & dataOut );
|
||||
|
||||
// Return 'numBits' as a SHORT (advances offset)
|
||||
DWORD Get(
|
||||
ULONG numBits,
|
||||
SHORT & dataOut );
|
||||
|
||||
// Return 'numBits' as a LONG (advances offset)
|
||||
DWORD Get(
|
||||
ULONG numBits,
|
||||
LONG & dataOut );
|
||||
|
||||
// Return 'numBits' as a LONGLONG (advances offset)
|
||||
DWORD Get(
|
||||
ULONG numBits,
|
||||
LONGLONG & dataOut );
|
||||
|
||||
// Return 'numBits' as a UCHAR (advances offset)
|
||||
DWORD Get(
|
||||
ULONG numBits,
|
||||
UCHAR & dataOut );
|
||||
|
||||
// Return 'numBits' as a USHORT (advances offset)
|
||||
DWORD Get(
|
||||
ULONG numBits,
|
||||
USHORT & dataOut );
|
||||
|
||||
// Return 'numBits' as a ULONG (advances offset)
|
||||
DWORD Get(
|
||||
ULONG numBits,
|
||||
ULONG & dataOut );
|
||||
|
||||
// Return 'numBits' as a ULONGLONG (advances offset)
|
||||
DWORD Get(
|
||||
ULONG numBits,
|
||||
ULONGLONG & dataOut );
|
||||
|
||||
// Release the data being parsed
|
||||
void ReleaseData();
|
||||
|
||||
// Set the data being parsed
|
||||
void SetData(
|
||||
const BYTE * pData,
|
||||
ULONG dataBitSize );
|
||||
|
||||
protected:
|
||||
/* Data buffer */
|
||||
const BYTE * mpData;
|
||||
|
||||
/* Current bit-specified offset */
|
||||
ULONG mOffset;
|
||||
|
||||
/* Maximum bit-specified offset */
|
||||
ULONG mMaxOffset;
|
||||
|
||||
/* Are we parsing LSB -> MSB (the default)? */
|
||||
bool mbLSB;
|
||||
};
|
|
@ -0,0 +1,180 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
CRC.cpp
|
||||
|
||||
DESCRIPTION:
|
||||
16-bit LSB CRC computation/verification
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
SetCRC()
|
||||
CheckCRC()
|
||||
CalculateCRC()
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "StdAfx.h"
|
||||
#include "CRC.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// CRC intermediates
|
||||
static USHORT CRCTable[CRC_TABLE_SIZE] =
|
||||
{
|
||||
0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
|
||||
0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
|
||||
0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
|
||||
0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
|
||||
0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
|
||||
0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
|
||||
0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
|
||||
0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
|
||||
0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
|
||||
0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
|
||||
0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
|
||||
0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
|
||||
0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
|
||||
0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
|
||||
0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
|
||||
0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
|
||||
0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
|
||||
0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
|
||||
0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
|
||||
0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
|
||||
0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
|
||||
0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
|
||||
0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
|
||||
0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
|
||||
0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
|
||||
0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
|
||||
0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
|
||||
0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
|
||||
0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
|
||||
0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
|
||||
0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
|
||||
0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Free Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
SetCRC (Free Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Calculate and append a 16-bit CRC to given data
|
||||
|
||||
PARAMETERS:
|
||||
pData [ I ] - The data buffer
|
||||
dataLen [ I ] - The length of the above buffer
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
void SetCRC(
|
||||
PBYTE pData,
|
||||
ULONG dataLen )
|
||||
{
|
||||
// Calculate CRC
|
||||
USHORT CRC = CalculateCRC( pData, dataLen * 8 );
|
||||
|
||||
// Add CRC to data
|
||||
pData[dataLen] = (BYTE)(CRC & 0x00ff);
|
||||
pData[dataLen + 1] = (BYTE)(CRC >> 8);
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
CheckCRC (Free Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Check the CRC validity of the given data
|
||||
|
||||
PARAMETERS:
|
||||
pData [ I ] - The data buffer
|
||||
dataLen [ I ] - The length of the above buffer
|
||||
|
||||
RETURN VALUE:
|
||||
bool:
|
||||
true - CRC checks out OK
|
||||
false - CRC doesn't cut the mustard
|
||||
===========================================================================*/
|
||||
bool CheckCRC(
|
||||
const BYTE * pData,
|
||||
ULONG dataLen )
|
||||
{
|
||||
// There must be data
|
||||
ASSERT( pData != 0 );
|
||||
ASSERT( dataLen > 0 );
|
||||
|
||||
// Calculate CRC
|
||||
USHORT CRC = CalculateCRC( pData, dataLen * 8 );
|
||||
|
||||
return (CRC == CRC_16_L_OK ? true : false);
|
||||
}
|
||||
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
CalculateCRC (Free Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Calculate a 16-bit CRC value
|
||||
|
||||
PARAMETERS:
|
||||
pBuf [ I ] - The data buffer
|
||||
bitLen [ I ] - The length of the above buffer (in bits)
|
||||
|
||||
RETURN VALUE:
|
||||
USHORT: The 16-bit calculated CRC
|
||||
===========================================================================*/
|
||||
USHORT CalculateCRC(
|
||||
const BYTE * pBuf,
|
||||
ULONG bitLen )
|
||||
{
|
||||
// Remainders are not allowed
|
||||
ASSERT( bitLen % 8 == 0 );
|
||||
|
||||
// There must be a buffer
|
||||
ASSERT( pBuf != 0 );
|
||||
|
||||
USHORT CRC;
|
||||
for (CRC = CRC_16_L_SEED; bitLen >= 8; bitLen -= 8, pBuf++)
|
||||
{
|
||||
CRC = CRCTable[(CRC ^ *pBuf) & 0x00ff] ^ (CRC >> 8);
|
||||
}
|
||||
|
||||
return ~CRC;
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
CRC.h
|
||||
|
||||
DESCRIPTION:
|
||||
16-bit LSB CRC computation/verification
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
SetCRC()
|
||||
CheckCRC()
|
||||
CalculateCRC()
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
const USHORT CRC_16_L_POLYNOMIAL = 0x8408;
|
||||
const USHORT CRC_16_L_SEED = 0xFFFF;
|
||||
const USHORT CRC_16_L_OK = 0x0F47;
|
||||
const USHORT CRC_TABLE_SIZE = 256;
|
||||
const USHORT CRC_SIZE = 2;
|
||||
|
||||
/*=========================================================================*/
|
||||
// Prototypes
|
||||
/*=========================================================================*/
|
||||
|
||||
// Calculate and append a 16-bit CRC to given data, the calculated CRC
|
||||
// value stored at pData[dataLen] & pData[dataLen + 1]
|
||||
void SetCRC(
|
||||
PBYTE pData,
|
||||
ULONG dataLen );
|
||||
|
||||
// Check a CRC value for the given data, dataLen includes the 2 byte CRC
|
||||
// value at the end of the buffer
|
||||
bool CheckCRC(
|
||||
const BYTE * pData,
|
||||
ULONG dataLen );
|
||||
|
||||
// Calculate a CRC value for the given data
|
||||
USHORT CalculateCRC(
|
||||
const BYTE * pBuf,
|
||||
ULONG bitLen );
|
||||
|
|
@ -0,0 +1,551 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
Comm.cpp
|
||||
|
||||
DESCRIPTION:
|
||||
Implementation of cComm class
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
cComm
|
||||
This class wraps low level port communications
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "StdAfx.h"
|
||||
#include "Comm.h"
|
||||
#include "ProtocolServer.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
/*=========================================================================*/
|
||||
// Free Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
RxCompletionRoutine (Free Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Completion routine for receive operation, exercises current receive
|
||||
callback object
|
||||
|
||||
PARAMETERS:
|
||||
returnSignal [ I/O ] Asynchronus signal event
|
||||
(contains pointer to cCOMM object)
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
VOID RxCompletionRoutine( sigval returnSignal )
|
||||
{
|
||||
cComm * pComm = (cComm *)returnSignal.sival_ptr;
|
||||
|
||||
if (pComm == NULL || pComm->IsValid() == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cIOCallback * pCallback = pComm->mpRxCallback;
|
||||
if (pCallback == 0)
|
||||
{
|
||||
// aio_cancel is broken if file pointer is bad
|
||||
// Notify cComm::CancelIO() manually
|
||||
TRACE( "%s manual notification %d\n", __func__, pComm->mPort );
|
||||
pComm->mReadCanceled.Set( 1 );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
pComm->mpRxCallback = 0;
|
||||
if (pCallback != (cIOCallback *)1)
|
||||
{
|
||||
int nEC = aio_error( &pComm->mReadIO );
|
||||
int nBytesTransfered = aio_return( &pComm->mReadIO );
|
||||
|
||||
pCallback->IOComplete( nEC, nBytesTransfered );
|
||||
}
|
||||
}
|
||||
|
||||
/*=========================================================================*/
|
||||
// cComm Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
cComm (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Constructor
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cComm::cComm()
|
||||
: mPortName( "" ),
|
||||
mPort( INVALID_HANDLE_VALUE ),
|
||||
mpRxCallback( 0 ),
|
||||
mbCancelWrite( false ),
|
||||
mReadCanceled()
|
||||
{
|
||||
memset( &mReadIO, 0, sizeof( aiocb) );
|
||||
|
||||
mReadIO.aio_sigevent.sigev_value.sival_ptr = this;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
~cComm (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Destructor
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cComm::~cComm()
|
||||
{
|
||||
// Disconnect from current port
|
||||
Disconnect();
|
||||
|
||||
mReadIO.aio_sigevent.sigev_value.sival_ptr = NULL;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
IsValid (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Is this object valid?
|
||||
|
||||
RETURN VALUE:
|
||||
Bool
|
||||
===========================================================================*/
|
||||
bool cComm::IsValid()
|
||||
{
|
||||
return (mReadIO.aio_sigevent.sigev_value.sival_ptr == this);
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
Connect (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Connect to the specified port
|
||||
|
||||
PARAMETERS:
|
||||
pPort [ I ] - Name of port to open (IE: /dev/qcqmi0)
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cComm::Connect( LPCSTR pPort )
|
||||
{
|
||||
if (IsValid() == false || pPort == 0 || pPort[0] == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mPort != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
Disconnect();
|
||||
}
|
||||
|
||||
// Opening the com port
|
||||
mPort = open( pPort, O_RDWR );
|
||||
if (mPort == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Clear any contents
|
||||
tcdrain( mPort );
|
||||
|
||||
mReadCanceled.Clear();
|
||||
|
||||
// Save port name
|
||||
mPortName = pPort;
|
||||
|
||||
// Success!
|
||||
return true;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
RunIOCTL (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Run an IOCTL on the open file handle
|
||||
|
||||
PARAMETERS:
|
||||
ioctlReq [ I ] - ioctl request value
|
||||
pData [I/O] - input or output specific to ioctl request value
|
||||
|
||||
RETURN VALUE:
|
||||
int - ioctl return value (0 for success)
|
||||
===========================================================================*/
|
||||
int cComm::RunIOCTL(
|
||||
UINT ioctlReq,
|
||||
void * pData )
|
||||
{
|
||||
if (mPort == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
TRACE( "Invalid file handle\n" );
|
||||
return -EBADFD;
|
||||
}
|
||||
|
||||
return ioctl( mPort, ioctlReq, pData );
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
Disconnect (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Disconnect from the current port
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cComm::Disconnect()
|
||||
{
|
||||
// Assume success
|
||||
bool bRC = true;
|
||||
|
||||
if (mPort != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
int nClose = close( mPort );
|
||||
if (nClose == -1)
|
||||
{
|
||||
bRC = false;
|
||||
}
|
||||
|
||||
mPort = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
mPortName.clear();
|
||||
return bRC;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
ConfigureSettings (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Configure the port with the passed in parameters
|
||||
|
||||
PARAMETERS:
|
||||
pSettings [ I ] - Desired port settings
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cComm::ConfigureSettings( termios * pSettings )
|
||||
{
|
||||
if (mPort == INVALID_HANDLE_VALUE || pSettings == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
tcflush( mPort, TCIOFLUSH );
|
||||
int nRC = tcsetattr( mPort, TCSANOW, pSettings );
|
||||
if (nRC == -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Success!
|
||||
return true;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetSettings (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Return the current port settings
|
||||
|
||||
PARAMETERS:
|
||||
pSettings [ I ] - Current port settings
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cComm::GetSettings( termios * pSettings )
|
||||
{
|
||||
if (mPort == INVALID_HANDLE_VALUE || pSettings == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the COM port settings
|
||||
int nRC = tcgetattr( mPort, pSettings );
|
||||
if (nRC == -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Success!
|
||||
return true;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
CancelIO (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Cancel any in-progress I/O
|
||||
|
||||
PARAMETERS:
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cComm::CancelIO()
|
||||
{
|
||||
if (mPort == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bRxCancel = CancelRx();
|
||||
bool bTxCancel = CancelTx();
|
||||
|
||||
return (bRxCancel && bTxCancel);
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
CancelRx (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Cancel any in-progress receive operation
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cComm::CancelRx()
|
||||
{
|
||||
if (mPort == INVALID_HANDLE_VALUE || mpRxCallback == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int nReadRC = aio_cancel( mPort, &mReadIO );
|
||||
mpRxCallback = 0;
|
||||
|
||||
if (nReadRC == -1 && errno == EBADF)
|
||||
{
|
||||
// aio_cancel is broken if file pointer is bad
|
||||
// wait for completion
|
||||
TRACE( "cComm::CancelRx manual wait %d\n", mPort );
|
||||
|
||||
DWORD nTemp;
|
||||
if (mReadCanceled.Wait( INFINITE, nTemp ) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Timeout or some other failure
|
||||
return false;
|
||||
}
|
||||
|
||||
return (nReadRC == AIO_CANCELED);
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
CancelTx (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Cancel any in-progress transmit operation
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cComm::CancelTx()
|
||||
{
|
||||
if (mPort == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
mbCancelWrite = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
RxData (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Receive data
|
||||
|
||||
PARAMETERS:
|
||||
pBuf [ I ] - Buffer to contain received data
|
||||
bufSz [ I ] - Amount of data to be received
|
||||
pCallback [ I ] - Callback object to be exercised when the
|
||||
operation completes
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cComm::RxData(
|
||||
BYTE * pBuf,
|
||||
ULONG bufSz,
|
||||
cIOCallback * pCallback )
|
||||
{
|
||||
if (IsValid() == false || mpRxCallback != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pCallback == 0)
|
||||
{
|
||||
// Not interested in being notified, but we still need a value
|
||||
// for this so that only one outstanding I/O operation is active
|
||||
// at any given point in time
|
||||
mpRxCallback = (cIOCallback * )1;
|
||||
}
|
||||
else
|
||||
{
|
||||
mpRxCallback = pCallback;
|
||||
}
|
||||
|
||||
mReadIO.aio_fildes = mPort;
|
||||
mReadIO.aio_buf = pBuf;
|
||||
mReadIO.aio_nbytes = bufSz;
|
||||
mReadIO.aio_sigevent.sigev_notify = SIGEV_THREAD;
|
||||
mReadIO.aio_sigevent.sigev_notify_function = RxCompletionRoutine;
|
||||
mReadIO.aio_sigevent.sigev_value.sival_ptr = this;
|
||||
mReadIO.aio_offset = 0;
|
||||
|
||||
int nRet = aio_read( &mReadIO );
|
||||
if (nRet != 0)
|
||||
{
|
||||
TRACE( "cComm::RxData() = %d, %s\n", nRet, strerror( errno ) );
|
||||
errno = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
TxData (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Transmit data
|
||||
|
||||
PARAMETERS:
|
||||
pBuf [ I ] - Data to be transmitted
|
||||
bufSz [ I ] - Amount of data to be transmitted
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cComm::TxData(
|
||||
const BYTE * pBuf,
|
||||
ULONG bufSz )
|
||||
{
|
||||
if (IsValid() == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
ULONGLONG nStart = GetTickCount();
|
||||
#endif
|
||||
|
||||
// Allow ourselves to be interupted
|
||||
mbCancelWrite = false;
|
||||
|
||||
// This seems a bit pointless, but we're still going verify
|
||||
// the device is ready for writing, and give it up to
|
||||
// (1000 + num bytes) MS to be ready (in 100 MS chunks)
|
||||
|
||||
struct timeval TimeOut;
|
||||
fd_set set;
|
||||
|
||||
int nReady = 0;
|
||||
int nCount = 0;
|
||||
|
||||
while ( nReady == 0 )
|
||||
{
|
||||
if (mbCancelWrite == true)
|
||||
{
|
||||
TRACE( "cComm::TxData() write canceled before device was ready\n" );
|
||||
return false;
|
||||
}
|
||||
|
||||
if (nCount >= (1000 + bufSz) / 100)
|
||||
{
|
||||
// Timeout is expired
|
||||
break;
|
||||
}
|
||||
|
||||
FD_ZERO( &set );
|
||||
FD_SET( mPort, &set );
|
||||
TimeOut.tv_sec = 0;
|
||||
TimeOut.tv_usec = 100000;
|
||||
nReady = select( mPort + 1, NULL, &set, NULL, &TimeOut );
|
||||
|
||||
nCount++;
|
||||
}
|
||||
|
||||
if (nReady <= 0)
|
||||
{
|
||||
TRACE( "cComm::TxData() Unable to get device ready for"
|
||||
" Write, error %d: %s\n",
|
||||
nReady,
|
||||
strerror( nReady) );
|
||||
return false;
|
||||
}
|
||||
|
||||
int nRet = write( mPort, pBuf, bufSz );
|
||||
if (nRet != bufSz)
|
||||
{
|
||||
TRACE( "cComm::TxData() write returned %d instead of %lu\n",
|
||||
nRet,
|
||||
bufSz );
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
TRACE( "Write of %lu bytes took %llu miliseconds\n", bufSz, GetTickCount() - nStart );
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
|
@ -0,0 +1,153 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
Comm.h
|
||||
|
||||
DESCRIPTION:
|
||||
Declaration of cComm class
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
cComm
|
||||
This class wraps low level port communications
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "Event.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
/*=========================================================================*/
|
||||
// Class cIOCallback
|
||||
/*=========================================================================*/
|
||||
class cIOCallback
|
||||
{
|
||||
public:
|
||||
// (Inline) Constructor
|
||||
cIOCallback() { };
|
||||
|
||||
// (Inline) Destructor
|
||||
virtual ~cIOCallback() { };
|
||||
|
||||
// The I/O has been completed, process the results
|
||||
virtual void IOComplete(
|
||||
DWORD status,
|
||||
DWORD bytesTransferred ) = 0;
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Class cComm
|
||||
/*=========================================================================*/
|
||||
class cComm
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
cComm();
|
||||
|
||||
// Destructor
|
||||
virtual ~cComm();
|
||||
|
||||
// Is this object valid?
|
||||
virtual bool IsValid();
|
||||
|
||||
// Connect to the specified port
|
||||
virtual bool Connect( LPCSTR pPort );
|
||||
|
||||
// Run an IOCTL on the open file handle
|
||||
int RunIOCTL(
|
||||
UINT ioctlReq,
|
||||
void * pData );
|
||||
|
||||
// Disconnect from the current port
|
||||
virtual bool Disconnect();
|
||||
|
||||
// Configure the port with the passed in parameters
|
||||
bool ConfigureSettings( termios * pSettings );
|
||||
|
||||
// Return the current port settings
|
||||
bool GetSettings( termios * pSettings );
|
||||
|
||||
// Cancel any in-progress I/O
|
||||
bool CancelIO();
|
||||
|
||||
// Cancel any in-progress receive operation
|
||||
bool CancelRx();
|
||||
|
||||
// Cancel any in-progress transmit operation
|
||||
bool CancelTx();
|
||||
|
||||
// Receive data
|
||||
virtual bool RxData(
|
||||
BYTE * pBuf,
|
||||
ULONG bufSz,
|
||||
cIOCallback * pCallback );
|
||||
|
||||
// Transmit data
|
||||
virtual bool TxData(
|
||||
const BYTE * pBuf,
|
||||
ULONG bufSz );
|
||||
|
||||
// (Inline) Return current port name
|
||||
virtual std::string GetPortName() const
|
||||
{
|
||||
return mPortName;
|
||||
};
|
||||
|
||||
// Are we currently connected to a port?
|
||||
bool IsConnected()
|
||||
{
|
||||
return (mPort != INVALID_HANDLE_VALUE);
|
||||
};
|
||||
|
||||
protected:
|
||||
/* Name of current port */
|
||||
std::string mPortName;
|
||||
|
||||
/* Handle to COM port */
|
||||
int mPort;
|
||||
|
||||
// Read IO settings
|
||||
aiocb mReadIO;
|
||||
|
||||
/* Read callbacks */
|
||||
cIOCallback * mpRxCallback;
|
||||
|
||||
// Cancel the write request?
|
||||
bool mbCancelWrite;
|
||||
|
||||
// Read callback cancelation notification
|
||||
cEvent mReadCanceled;
|
||||
|
||||
// Rx completion routine is allowed complete access
|
||||
friend VOID RxCompletionRoutine( sigval returnSignal );
|
||||
};
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,649 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
CoreUtilities.h
|
||||
|
||||
DESCRIPTION:
|
||||
Collection of various utility methods
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
StringToLONG
|
||||
StringToULONG
|
||||
StringToLONGLONG
|
||||
StringToULONGLONG
|
||||
|
||||
ParseCommandLine()
|
||||
ParseTokens()
|
||||
ParseFormatSpecifier()
|
||||
|
||||
FromString( CHAR )
|
||||
FromString( UCHAR )
|
||||
FromString( SHORT )
|
||||
FromString( USHORT )
|
||||
FromString( int )
|
||||
FromString( UINT )
|
||||
FromString( LONG )
|
||||
FromString( ULONG )
|
||||
FromString( LONGLONG )
|
||||
FromString( ULONGLONG )
|
||||
|
||||
ToString( CHAR )
|
||||
ToString( UCHAR )
|
||||
ToString( SHORT )
|
||||
ToString( USHORT )
|
||||
ToString( int )
|
||||
ToString( UINT )
|
||||
ToString( LONG )
|
||||
ToString( ULONG )
|
||||
ToString( LONGLONG )
|
||||
ToString( ULONGLONG )
|
||||
|
||||
GetProgramPath()
|
||||
EnumerateFolders()
|
||||
|
||||
ContainerToCSVString()
|
||||
CSVStringToContainer()
|
||||
CSVStringToValidatedContainer()
|
||||
|
||||
SetDiff()
|
||||
SetIntersection()
|
||||
SetUnion()
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include <vector>
|
||||
#include <set>
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// Suggested size of an argument buffer to ToString() for any key, each
|
||||
// ToString() should not write more than this size to the passed in buffer
|
||||
const ULONG SUGGESTED_BUFFER_LEN = 64;
|
||||
|
||||
/*=========================================================================*/
|
||||
// Prototypes
|
||||
/*=========================================================================*/
|
||||
|
||||
// Replacement/front end for _tcstol
|
||||
bool StringToLONG(
|
||||
LPCSTR pStr,
|
||||
int base,
|
||||
LONG & val );
|
||||
|
||||
// Replacement/front end for _tcstoul
|
||||
bool StringToULONG(
|
||||
LPCSTR pStr,
|
||||
int base,
|
||||
ULONG & val );
|
||||
|
||||
// Replacement/front end for _tcstoi64
|
||||
bool StringToLONGLONG(
|
||||
LPCSTR pStr,
|
||||
int base,
|
||||
LONGLONG & val );
|
||||
|
||||
// Replacement/front end for _tcstoui64
|
||||
bool StringToULONGLONG(
|
||||
LPCSTR pStr,
|
||||
int base,
|
||||
ULONGLONG & val );
|
||||
|
||||
// Parse a command line to tokens (a command line is a string of
|
||||
// space delimited values where a value that contains space is
|
||||
// enclosed in text)
|
||||
void ParseCommandLine(
|
||||
std::string commandLine,
|
||||
std::vector <std::string> & tokens );
|
||||
|
||||
// Parse a line into individual tokens
|
||||
void ParseTokens(
|
||||
LPCSTR pSeparator,
|
||||
LPSTR pLine,
|
||||
std::vector <LPSTR> & tokens );
|
||||
|
||||
// Parse a format specifier into individual format type tokens
|
||||
bool ParseFormatSpecifier(
|
||||
LPCSTR pFmt,
|
||||
ULONG fmtLen,
|
||||
std::vector <CHAR> & fmtTypes );
|
||||
|
||||
// Convert a string to a value
|
||||
bool FromString(
|
||||
LPCSTR pStr,
|
||||
CHAR & theType );
|
||||
|
||||
// Convert a string to a value
|
||||
bool FromString(
|
||||
LPCSTR pStr,
|
||||
UCHAR & theType );
|
||||
|
||||
// Convert a string to a value
|
||||
bool FromString(
|
||||
LPCSTR pStr,
|
||||
SHORT & theType );
|
||||
|
||||
// Convert a string to a value
|
||||
bool FromString(
|
||||
LPCSTR pStr,
|
||||
USHORT & theType );
|
||||
|
||||
// Convert a string to a value
|
||||
bool FromString(
|
||||
LPCSTR pStr,
|
||||
int & theType );
|
||||
|
||||
// Convert a string to a value
|
||||
bool FromString(
|
||||
LPCSTR pStr,
|
||||
UINT & theType );
|
||||
|
||||
// Convert a string to a value
|
||||
bool FromString(
|
||||
LPCSTR pStr,
|
||||
LONG & theType );
|
||||
|
||||
// Convert a string to a value
|
||||
bool FromString(
|
||||
LPCSTR pStr,
|
||||
ULONG & theType );
|
||||
|
||||
// Convert a string to a value
|
||||
bool FromString(
|
||||
LPCSTR pStr,
|
||||
LONGLONG & theType );
|
||||
|
||||
// Convert a string to a value
|
||||
bool FromString(
|
||||
LPCSTR pStr,
|
||||
ULONGLONG & theType );
|
||||
|
||||
|
||||
// Convert a value to a string
|
||||
bool ToString(
|
||||
CHAR val,
|
||||
LPSTR pStr );
|
||||
|
||||
// Convert a value to a string
|
||||
bool ToString(
|
||||
UCHAR val,
|
||||
LPSTR pStr );
|
||||
|
||||
// Convert a value to a string
|
||||
bool ToString(
|
||||
SHORT val,
|
||||
LPSTR pStr );
|
||||
|
||||
// Convert a value to a string
|
||||
bool ToString(
|
||||
USHORT val,
|
||||
LPSTR pStr );
|
||||
|
||||
// Convert a value to a string
|
||||
bool ToString(
|
||||
int val,
|
||||
LPSTR pStr );
|
||||
|
||||
// Convert a value to a string
|
||||
bool ToString(
|
||||
UINT val,
|
||||
LPSTR pStr );
|
||||
|
||||
// Convert a value to a string
|
||||
bool ToString(
|
||||
LONG val,
|
||||
LPSTR pStr );
|
||||
|
||||
// Convert a value to a string
|
||||
bool ToString(
|
||||
ULONG val,
|
||||
LPSTR pStr );
|
||||
|
||||
// Convert a value to a string
|
||||
bool ToString(
|
||||
LONGLONG val,
|
||||
LPSTR pStr );
|
||||
|
||||
// Convert a value to a string
|
||||
bool ToString(
|
||||
ULONGLONG val,
|
||||
LPSTR pStr );
|
||||
|
||||
// Return the special folder used for storing program files
|
||||
std::string GetProgramPath();
|
||||
|
||||
// Enumerate the subfolders of the given folder (recursive)
|
||||
void EnumerateFolders(
|
||||
const std::string & baseFolder,
|
||||
std::vector <std::string> & foundFolders );
|
||||
|
||||
/*=========================================================================*/
|
||||
// Free Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
ContainerToCSVString (Free Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Convert the contents of a container to a CSV string
|
||||
|
||||
NOTE: ToString() must be defined for the container value type
|
||||
|
||||
PARAMETERS:
|
||||
cont [ I ] - The container
|
||||
sep [ I ] - The character separating tokens
|
||||
csv [ O ] - The resulting comma separated string
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
template <class Container>
|
||||
void ContainerToCSVString(
|
||||
const Container & cont,
|
||||
CHAR sep,
|
||||
std::string & csv )
|
||||
{
|
||||
csv = "";
|
||||
if ((ULONG)cont.size() > (ULONG)0)
|
||||
{
|
||||
CHAR keyBuf[SUGGESTED_BUFFER_LEN];
|
||||
|
||||
typename Container::const_iterator pIter = cont.begin();
|
||||
while (pIter != cont.end())
|
||||
{
|
||||
const typename Container::value_type & theKey = *pIter;
|
||||
bool bOK = ToString( theKey, &keyBuf[0] );
|
||||
|
||||
if (bOK == true && keyBuf[0] != 0)
|
||||
{
|
||||
if (pIter != cont.begin())
|
||||
{
|
||||
csv += sep;
|
||||
}
|
||||
|
||||
csv += (LPCSTR)&keyBuf[0];
|
||||
}
|
||||
|
||||
pIter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
CSVStringToContainer (Free Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Populate a container from a parsed CSV string
|
||||
|
||||
NOTE: FromString() must be defined for the container value type
|
||||
NOTE: The container is emptied before this operation is attempted
|
||||
|
||||
PARAMETERS:
|
||||
pSeparator [ I ] - The characters separating tokens
|
||||
pCSV [ I ] - The comma separated string (will be modified)
|
||||
cont [ O ] - The resulting container
|
||||
bClear [ I ] - Clear the container first? NOTE: if the container
|
||||
is not cleared first then insertions may fail for
|
||||
duplicate keys
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
template <class Container>
|
||||
void CSVStringToContainer(
|
||||
LPCSTR pSeparator,
|
||||
LPSTR pCSV,
|
||||
Container & cont,
|
||||
bool bClear = true )
|
||||
{
|
||||
if (pCSV != 0 && *pCSV != 0)
|
||||
{
|
||||
// Remove a leading quote?
|
||||
if (*pCSV == '\"')
|
||||
{
|
||||
pCSV++;
|
||||
}
|
||||
|
||||
// Remove a trailing quote?
|
||||
ULONG len = (ULONG)strlen( pCSV );
|
||||
if (len > 0)
|
||||
{
|
||||
if (pCSV[len - 1] == '\"')
|
||||
{
|
||||
pCSV[len - 1] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Clear the container first?
|
||||
if (bClear == true)
|
||||
{
|
||||
cont.clear();
|
||||
}
|
||||
|
||||
std::vector <LPSTR> tokens;
|
||||
ParseTokens( pSeparator, pCSV, tokens );
|
||||
|
||||
std::vector <LPSTR>::const_iterator pIter = tokens.begin();
|
||||
while (pIter != tokens.end())
|
||||
{
|
||||
LPCSTR pTok = *pIter;
|
||||
|
||||
typename Container::value_type theKey;
|
||||
bool bOK = ::FromString( pTok, theKey );
|
||||
|
||||
if (bOK == true)
|
||||
{
|
||||
std::insert_iterator <Container> is( cont, cont.end() );
|
||||
*is = theKey;
|
||||
}
|
||||
|
||||
pIter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
CSVStringToValidatedContainer (Free Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Populate a container from a parsed CSV string
|
||||
|
||||
NOTE: FromString() and IsValid() must be defined for the container
|
||||
value type (the later need not do anything but return true)
|
||||
|
||||
NOTE: The container is emptied before this operation is attempted
|
||||
|
||||
PARAMETERS:
|
||||
pSeparator [ I ] - The characters separating tokens
|
||||
pCSV [ I ] - The comma separated string (will be modified)
|
||||
cont [ O ] - The resulting container
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
template <class Container>
|
||||
void CSVStringToValidatedContainer(
|
||||
LPCSTR pSeparator,
|
||||
LPSTR pCSV,
|
||||
Container & cont )
|
||||
{
|
||||
cont.clear();
|
||||
if (pCSV != 0 && *pCSV != 0)
|
||||
{
|
||||
// Remove a leading quote?
|
||||
if (*pCSV == '\"')
|
||||
{
|
||||
pCSV++;
|
||||
}
|
||||
|
||||
// Remove a trailing quote?
|
||||
ULONG len = (ULONG)strlen( pCSV );
|
||||
if (len > 0)
|
||||
{
|
||||
if (pCSV[len - 1] == '\"')
|
||||
{
|
||||
pCSV[len - 1] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
cont.clear();
|
||||
|
||||
std::vector <LPSTR> tokens;
|
||||
ParseTokens( pSeparator, pCSV, tokens );
|
||||
|
||||
std::vector <LPSTR>::const_iterator pIter = tokens.begin();
|
||||
while (pIter != tokens.end())
|
||||
{
|
||||
LPCSTR pTok = *pIter;
|
||||
|
||||
typename Container::value_type theKey;
|
||||
bool bOK = ::FromString( pTok, theKey );
|
||||
|
||||
if (bOK == true)
|
||||
{
|
||||
bool bValid = IsValid( theKey );
|
||||
if (bValid == true)
|
||||
{
|
||||
std::insert_iterator <Container> is( cont, cont.end() );
|
||||
*is = theKey;
|
||||
}
|
||||
}
|
||||
|
||||
pIter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
SetDiff (Free Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Given two sets return a third that contains everything in the first
|
||||
set but not the second set
|
||||
|
||||
PARAMETERS:
|
||||
setA [ I ] - The first set
|
||||
setB [ I ] - The second set
|
||||
|
||||
RETURN VALUE:
|
||||
std::set <T> - the difference
|
||||
===========================================================================*/
|
||||
template <class T>
|
||||
std::set <T> SetDiff(
|
||||
const std::set <T> & setA,
|
||||
const std::set <T> & setB )
|
||||
{
|
||||
std::set <T> retSet;
|
||||
|
||||
if (setB.size() == 0)
|
||||
{
|
||||
// Everything that is in the first set but not the second
|
||||
// (empty) set is ... the first set!
|
||||
retSet = setA;
|
||||
}
|
||||
else if (setA.size() == 0)
|
||||
{
|
||||
// The first set is empty, hence the return set is empty
|
||||
}
|
||||
else
|
||||
{
|
||||
// Both sets have elements, therefore the iterators will
|
||||
// be valid and we can use the standard approach
|
||||
typename std::set <T>::const_iterator pIterA = setA.begin();
|
||||
typename std::set <T>::const_iterator pIterB = setB.begin();
|
||||
|
||||
for ( ; pIterA != setA.end() && pIterB != setB.end(); )
|
||||
{
|
||||
if (*pIterA < *pIterB)
|
||||
{
|
||||
retSet.insert( *pIterA );
|
||||
pIterA++;
|
||||
}
|
||||
else if (*pIterB < *pIterA)
|
||||
{
|
||||
pIterB++;
|
||||
}
|
||||
else
|
||||
{
|
||||
pIterA++;
|
||||
pIterB++;
|
||||
}
|
||||
}
|
||||
|
||||
while (pIterA != setA.end())
|
||||
{
|
||||
retSet.insert( *pIterA );
|
||||
pIterA++;
|
||||
}
|
||||
}
|
||||
|
||||
return retSet;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
SetIntersection (Free Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Given two sets return a third that contains everything that is in both
|
||||
sets
|
||||
|
||||
PARAMETERS:
|
||||
setA [ I ] - The first set
|
||||
setB [ I ] - The second set
|
||||
|
||||
RETURN VALUE:
|
||||
std::set <T> - the union
|
||||
===========================================================================*/
|
||||
template <class T>
|
||||
std::set <T> SetIntersection(
|
||||
const std::set <T> & setA,
|
||||
const std::set <T> & setB )
|
||||
{
|
||||
std::set <T> retSet;
|
||||
|
||||
// Neither set can be empty
|
||||
if (setA.size() != 0 && setA.size() != 0)
|
||||
{
|
||||
// Both sets have elements, therefore the iterators will
|
||||
// be valid and we can use the standard approach
|
||||
typename std::set <T>::const_iterator pIterA = setA.begin();
|
||||
typename std::set <T>::const_iterator pIterB = setB.begin();
|
||||
|
||||
for ( ; pIterA != setA.end() && pIterB != setB.end(); )
|
||||
{
|
||||
if (*pIterA < *pIterB)
|
||||
{
|
||||
pIterA++;
|
||||
}
|
||||
else if (*pIterB < *pIterA)
|
||||
{
|
||||
pIterB++;
|
||||
}
|
||||
else
|
||||
{
|
||||
retSet.insert( *pIterA );
|
||||
pIterA++;
|
||||
pIterB++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return retSet;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
SetUnion (Free Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Given two sets return a third that contains everything that is either
|
||||
in the first set or in the second set
|
||||
|
||||
PARAMETERS:
|
||||
setA [ I ] - The first set
|
||||
setB [ I ] - The second set
|
||||
|
||||
RETURN VALUE:
|
||||
std::set <T> - the union
|
||||
===========================================================================*/
|
||||
template <class T>
|
||||
std::set <T> SetUnion(
|
||||
const std::set <T> & setA,
|
||||
const std::set <T> & setB )
|
||||
{
|
||||
std::set <T> retSet;
|
||||
|
||||
if (setB.size() == 0)
|
||||
{
|
||||
// Everything that is in the first (possibly empty) set or in
|
||||
// the second (empty) set is ... the first set!
|
||||
retSet = setA;
|
||||
}
|
||||
else if (setA.size() == 0)
|
||||
{
|
||||
// Everything that is in the first (empty) set or in the
|
||||
// second (possibly empty) set is ... the second set!
|
||||
retSet = setB;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Both sets have elements, therefore the iterators will
|
||||
// be valid and we can use the standard approach
|
||||
typename std::set <T>::const_iterator pIterA = setA.begin();
|
||||
typename std::set <T>::const_iterator pIterB = setB.begin();
|
||||
|
||||
for ( ; pIterA != setA.end() && pIterB != setB.end(); )
|
||||
{
|
||||
if (*pIterA < *pIterB)
|
||||
{
|
||||
retSet.insert( *pIterA );
|
||||
pIterA++;
|
||||
}
|
||||
else if (*pIterB < *pIterA)
|
||||
{
|
||||
retSet.insert( *pIterB );
|
||||
pIterB++;
|
||||
}
|
||||
else
|
||||
{
|
||||
retSet.insert( *pIterA );
|
||||
pIterA++;
|
||||
pIterB++;
|
||||
}
|
||||
}
|
||||
|
||||
while (pIterA != setA.end())
|
||||
{
|
||||
retSet.insert( *pIterA );
|
||||
pIterA++;
|
||||
}
|
||||
|
||||
while (pIterB != setB.end())
|
||||
{
|
||||
retSet.insert( *pIterB );
|
||||
pIterB++;
|
||||
}
|
||||
}
|
||||
|
||||
return retSet;
|
||||
}
|
||||
|
|
@ -0,0 +1,434 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
ProtocolEntityNavTree.cpp
|
||||
|
||||
DESCRIPTION:
|
||||
Implementation of cDB2NavTree
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
sDB2NavFragment
|
||||
cDB2NavTree
|
||||
This class distills the database description of a protocol
|
||||
entity into a simple tree structure more suited to
|
||||
efficient navigation for parsing/packing
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "StdAfx.h"
|
||||
#include "DB2NavTree.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
/*=========================================================================*/
|
||||
// sDB2NavFragment Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
sDB2NavFragment (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Constructor
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
sDB2NavFragment::sDB2NavFragment()
|
||||
: mpField( 0 ),
|
||||
mpFragment( 0 ),
|
||||
mpNextFragment( 0 ),
|
||||
mpLinkFragment( 0 )
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
/*=========================================================================*/
|
||||
// cDB2NavTree Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
cDB2NavTree (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Constructor
|
||||
|
||||
PARAMETERS:
|
||||
db [ I ] - Database to use
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cDB2NavTree::cDB2NavTree( const cCoreDatabase & db )
|
||||
: mDB( db )
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
~cDB2NavTree (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Destructor
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cDB2NavTree::~cDB2NavTree()
|
||||
{
|
||||
// Clean-up our fragment allocations
|
||||
std::list <sDB2NavFragment *>::iterator pIter;
|
||||
for (pIter = mFragments.begin(); pIter != mFragments.end(); pIter++)
|
||||
{
|
||||
sDB2NavFragment * pFrag = *pIter;
|
||||
if (pFrag != 0)
|
||||
{
|
||||
delete pFrag;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
BuildTree (Internal Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Build nav tree for the entity described by the given key/name
|
||||
|
||||
PARAMETERS:
|
||||
key [ I ] - Key into the protocol entity table
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cDB2NavTree::BuildTree( const std::vector <ULONG> & key )
|
||||
{
|
||||
// Assume failure
|
||||
bool bRC = false;
|
||||
|
||||
// Look up entity definition
|
||||
bool bFound = mDB.FindEntity( key, mEntity );
|
||||
|
||||
// Did we find it?
|
||||
if (bFound == false)
|
||||
{
|
||||
// No definition in database
|
||||
return bRC;
|
||||
}
|
||||
|
||||
// A structure to navigate?
|
||||
if (mEntity.mStructID == -1)
|
||||
{
|
||||
bRC = true;
|
||||
return bRC;
|
||||
}
|
||||
|
||||
const tDB2FragmentMap & structTable = mDB.GetProtocolStructs();
|
||||
|
||||
// Grab first fragment of structure
|
||||
std::pair <ULONG, ULONG> id( mEntity.mStructID, 0 );
|
||||
tDB2FragmentMap::const_iterator pFrag = structTable.find( id );
|
||||
|
||||
// Nothing to navigate?
|
||||
if (pFrag == structTable.end())
|
||||
{
|
||||
ASSERT( 0 );
|
||||
return bRC;
|
||||
}
|
||||
|
||||
// No name?
|
||||
if (mEntity.mpName == 0 || mEntity.mpName[0] == 0)
|
||||
{
|
||||
ASSERT( 0 );
|
||||
return bRC;
|
||||
}
|
||||
|
||||
// Process the initial structure
|
||||
bRC = ProcessStruct( &pFrag->second, 0 );
|
||||
return bRC;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
ProcessStruct (Internal Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Process a structure described by the given initial fragment
|
||||
|
||||
PARAMETERS:
|
||||
frag [ I ] - Entry point for structure
|
||||
pOwner [ I ] - Owning fragment
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cDB2NavTree::ProcessStruct(
|
||||
const sDB2Fragment * pFrag,
|
||||
sDB2NavFragment * pOwner )
|
||||
{
|
||||
// Assume success
|
||||
bool bRC = true;
|
||||
|
||||
// Grab struct ID/fragment ID from fragment
|
||||
std::pair <ULONG, ULONG> key = pFrag->GetKey();
|
||||
ULONG structID = key.first;
|
||||
|
||||
const tDB2FragmentMap & structTable = mDB.GetProtocolStructs();
|
||||
const tDB2FieldMap & fieldTable = mDB.GetProtocolFields();
|
||||
|
||||
// Sync iterator to fragment
|
||||
tDB2FragmentMap::const_iterator pFragIter = structTable.find( key );
|
||||
if (pFragIter == structTable.end())
|
||||
{
|
||||
// This should not happen
|
||||
ASSERT( 0 );
|
||||
|
||||
bRC = false;
|
||||
return bRC;
|
||||
}
|
||||
|
||||
// Fragments we allocate along the way
|
||||
sDB2NavFragment * pOld = 0;
|
||||
sDB2NavFragment * pNew = 0;
|
||||
|
||||
// Process each fragment in the structure
|
||||
while ( (pFragIter != structTable.end())
|
||||
&& (pFragIter->second.mStructID == structID) )
|
||||
{
|
||||
pFrag = &pFragIter->second;
|
||||
|
||||
// Allocate our new fragment
|
||||
pNew = new sDB2NavFragment;
|
||||
if (pNew == 0)
|
||||
{
|
||||
bRC = false;
|
||||
break;
|
||||
}
|
||||
|
||||
// Store DB fragemnt
|
||||
pNew->mpFragment = pFrag;
|
||||
mFragments.push_back( pNew );
|
||||
|
||||
// Hook previous up to us
|
||||
if (pOld != 0 && pOld->mpNextFragment == 0)
|
||||
{
|
||||
pOld->mpNextFragment = pNew;
|
||||
}
|
||||
|
||||
// Hook owner up to us
|
||||
if (pOwner != 0 && pOwner->mpLinkFragment == 0)
|
||||
{
|
||||
pOwner->mpLinkFragment = pNew;
|
||||
}
|
||||
|
||||
// Modified?
|
||||
switch (pFrag->mModifierType)
|
||||
{
|
||||
case eDB2_MOD_VARIABLE_ARRAY:
|
||||
case eDB2_MOD_VARIABLE_STRING1:
|
||||
case eDB2_MOD_VARIABLE_STRING2:
|
||||
case eDB2_MOD_VARIABLE_STRING3:
|
||||
{
|
||||
const tDB2Array1ModMap & arrays1 = mDB.GetArray1Mods();
|
||||
|
||||
tDB2Array1ModMap::const_iterator pTmp;
|
||||
pTmp = arrays1.find( pFrag->mpModifierValue );
|
||||
|
||||
if (pTmp != arrays1.end())
|
||||
{
|
||||
// We need to track the value of the given field
|
||||
std::pair <bool, LONGLONG> entry( false, 0 );
|
||||
mTrackedFields[pTmp->second] = entry;
|
||||
}
|
||||
else
|
||||
{
|
||||
bRC = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case eDB2_MOD_VARIABLE_ARRAY2:
|
||||
{
|
||||
const tDB2Array2ModMap & arrays2 = mDB.GetArray2Mods();
|
||||
|
||||
tDB2Array2ModMap::const_iterator pTmp;
|
||||
pTmp = arrays2.find( pFrag->mpModifierValue );
|
||||
|
||||
if (pTmp != arrays2.end())
|
||||
{
|
||||
// We need to track the value of the given fields
|
||||
std::pair <bool, LONGLONG> entry( false, 0 );
|
||||
mTrackedFields[pTmp->second.first] = entry;
|
||||
mTrackedFields[pTmp->second.second] = entry;
|
||||
}
|
||||
else
|
||||
{
|
||||
bRC = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case eDB2_MOD_OPTIONAL:
|
||||
{
|
||||
const tDB2OptionalModMap & conditions = mDB.GetOptionalMods();
|
||||
|
||||
tDB2OptionalModMap::const_iterator pTmp;
|
||||
pTmp = conditions.find( pFrag->mpModifierValue );
|
||||
|
||||
if (pTmp != conditions.end())
|
||||
{
|
||||
const sDB2SimpleCondition & con = pTmp->second;
|
||||
|
||||
// We need to track the value of the given field
|
||||
std::pair <bool, LONGLONG> entry( false, 0 );
|
||||
mTrackedFields[con.mID] = entry;
|
||||
|
||||
if (con.mbF2F == true)
|
||||
{
|
||||
// We need to track the value of the given field
|
||||
std::pair <bool, LONGLONG> entry( false, 0 );
|
||||
mTrackedFields[(ULONG)con.mValue] = entry;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bRC = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case eDB2_MOD_VARIABLE_ARRAY3:
|
||||
{
|
||||
const tDB2ExpressionModMap & exprs = mDB.GetExpressionMods();
|
||||
|
||||
tDB2ExpressionModMap::const_iterator pTmp;
|
||||
pTmp = exprs.find( pFrag->mpModifierValue );
|
||||
|
||||
if (pTmp != exprs.end())
|
||||
{
|
||||
const sDB2SimpleExpression & expr = pTmp->second;
|
||||
|
||||
// We need to track the value of the given field
|
||||
std::pair <bool, LONGLONG> entry( false, 0 );
|
||||
mTrackedFields[expr.mID] = entry;
|
||||
|
||||
if (expr.mbF2F == true)
|
||||
{
|
||||
// We need to track the value of the given field
|
||||
std::pair <bool, LONGLONG> entry( false, 0 );
|
||||
mTrackedFields[(ULONG)expr.mValue] = entry;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bRC = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
};
|
||||
|
||||
// What type of fragment is this?
|
||||
switch (pFrag->mFragmentType)
|
||||
{
|
||||
case eDB2_FRAGMENT_FIELD:
|
||||
{
|
||||
// Grab field ID
|
||||
ULONG fieldID = pFrag->mFragmentValue;
|
||||
|
||||
// Find field representation in database
|
||||
tDB2FieldMap::const_iterator pField = fieldTable.find( fieldID );
|
||||
if (pField != fieldTable.end())
|
||||
{
|
||||
pNew->mpField = &pField->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
bRC = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case eDB2_FRAGMENT_STRUCT:
|
||||
{
|
||||
// Grab structure ID
|
||||
ULONG structID = pFrag->mFragmentValue;
|
||||
|
||||
// Grab first fragment of structure
|
||||
std::pair <ULONG, ULONG> id( structID, 0 );
|
||||
tDB2FragmentMap::const_iterator pFragIterTmp;
|
||||
pFragIterTmp = structTable.find( id );
|
||||
if (pFragIterTmp != structTable.end())
|
||||
{
|
||||
pFrag = &pFragIterTmp->second;
|
||||
bRC = ProcessStruct( pFrag, pNew );
|
||||
}
|
||||
else
|
||||
{
|
||||
bRC = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case eDB2_FRAGMENT_VARIABLE_PAD_BITS:
|
||||
case eDB2_FRAGMENT_VARIABLE_PAD_BYTES:
|
||||
{
|
||||
// We need to track the value of the given field
|
||||
std::pair <bool, LONGLONG> entry( false, 0 );
|
||||
mTrackedFields[pFrag->mFragmentValue] = entry;
|
||||
|
||||
bRC = true;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
bRC = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (bRC == true)
|
||||
{
|
||||
pFragIter++;
|
||||
|
||||
pOld = pNew;
|
||||
pNew = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return bRC;
|
||||
}
|
|
@ -0,0 +1,136 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
ProtocolEntityNavTree.h
|
||||
|
||||
DESCRIPTION:
|
||||
Declaration of cProtocolEntityNavTree
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
sDB2NavFragment
|
||||
cDB2NavTree
|
||||
This class distills the database description of a protocol
|
||||
entity into a simple tree structure more suited to
|
||||
efficient navigation for parsing/packing
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "CoreDatabase.h"
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sDB2NavFragment
|
||||
// Protocol entity navigation fragment
|
||||
/*=========================================================================*/
|
||||
struct sDB2NavFragment
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
sDB2NavFragment();
|
||||
|
||||
/* Associated DB fragment (never empty) */
|
||||
const sDB2Fragment * mpFragment;
|
||||
|
||||
/* Associated DB field (may be empty) */
|
||||
const sDB2Field * mpField;
|
||||
|
||||
/* Next fragment in this structure */
|
||||
const sDB2NavFragment * mpNextFragment;
|
||||
|
||||
/* Fragment linked to this structure */
|
||||
const sDB2NavFragment * mpLinkFragment;
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Class cDB2NavTree
|
||||
// Class to describe a protocol entity suited to efficient navigation
|
||||
/*=========================================================================*/
|
||||
class cDB2NavTree
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
cDB2NavTree( const cCoreDatabase & db );
|
||||
|
||||
// Destructor
|
||||
virtual ~cDB2NavTree();
|
||||
|
||||
// Build nav tree for the protocol entity described by the given key
|
||||
bool BuildTree( const std::vector <ULONG> & key );
|
||||
|
||||
// (Inline) Return protocol entity
|
||||
const sDB2ProtocolEntity & GetEntity() const
|
||||
{
|
||||
return mEntity;
|
||||
};
|
||||
|
||||
// (Inline) Return fragments
|
||||
const std::list <sDB2NavFragment *> & GetFragments() const
|
||||
{
|
||||
return mFragments;
|
||||
};
|
||||
|
||||
// Return a map of all tracked fields
|
||||
std::map <ULONG, std::pair <bool, LONGLONG> > GetTrackedFields() const
|
||||
{
|
||||
return mTrackedFields;
|
||||
};
|
||||
|
||||
protected:
|
||||
// Process a structure described by the given initial fragment
|
||||
bool ProcessStruct(
|
||||
const sDB2Fragment * pFrag,
|
||||
sDB2NavFragment * pOwner );
|
||||
|
||||
/* Protocol entity being navigated */
|
||||
sDB2ProtocolEntity mEntity;
|
||||
|
||||
/* Database reference */
|
||||
const cCoreDatabase & mDB;
|
||||
|
||||
/* List of all allocated fragments */
|
||||
std::list <sDB2NavFragment *> mFragments;
|
||||
|
||||
/* Map of all 'tracked' fields */
|
||||
std::map <ULONG, std::pair <bool, LONGLONG> > mTrackedFields;
|
||||
};
|
||||
|
||||
|
|
@ -0,0 +1,253 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
DB2TextFile.h
|
||||
|
||||
DESCRIPTION:
|
||||
Implementation of cDB2TextFile class
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
cDB2TextFile
|
||||
The cDB2TextFile class provides the simple ability to read in an
|
||||
ANSI/UNICODE file and copy it to a dynamically allocated buffer
|
||||
|
||||
The sole difference between this and CStdioFile is that the issues
|
||||
stemming from supporting both ANSI and UNICODE files are handled
|
||||
in a simpler fashion at the expense of a bit of performance
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "StdAfx.h"
|
||||
#include "DB2TextFile.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Maximum size of a file this interface will try to open (8 MB)
|
||||
const DWORD MAX_FILE_SZ = 1024 * 1024 * 8;
|
||||
|
||||
// Maximum number of characters to run UNICODE check over
|
||||
const INT MAX_UNICODE_CHECK_LEN = 128;
|
||||
|
||||
/*=========================================================================*/
|
||||
// cDB2TextFile Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
cDB2TextFile (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Construct object/load file into memory
|
||||
|
||||
PARAMETERS
|
||||
pFileName [ I ] - File name
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cDB2TextFile::cDB2TextFile( LPCSTR pFileName )
|
||||
: mText( "" ),
|
||||
mStatus( ERROR_FILE_NOT_FOUND ),
|
||||
mCurrentPos( 0 )
|
||||
{
|
||||
if (pFileName == 0 || pFileName[0] == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Open the file
|
||||
std::ifstream tempFStream;
|
||||
tempFStream.open( pFileName, std::ios::in | std::ios::binary );
|
||||
if (tempFStream.fail() == true)
|
||||
{
|
||||
mStatus = ERROR_FILE_NOT_FOUND;
|
||||
return;
|
||||
}
|
||||
|
||||
// Get size
|
||||
LONG nFileSize = tempFStream.rdbuf()->in_avail();
|
||||
if (nFileSize == -1 || nFileSize > MAX_FILE_SZ)
|
||||
{
|
||||
tempFStream.close();
|
||||
mStatus = ERROR_GEN_FAILURE;
|
||||
return;
|
||||
}
|
||||
|
||||
// Read file into pTempBuffer
|
||||
CHAR * pTempBuffer = new char[ nFileSize ];
|
||||
if (pTempBuffer == NULL)
|
||||
{
|
||||
tempFStream.close();
|
||||
mStatus = ERROR_GEN_FAILURE;
|
||||
return;
|
||||
}
|
||||
|
||||
tempFStream.read( pTempBuffer, nFileSize );
|
||||
if (tempFStream.fail() == true)
|
||||
{
|
||||
tempFStream.close();
|
||||
delete [] pTempBuffer;
|
||||
mStatus = ERROR_GEN_FAILURE;
|
||||
return;
|
||||
}
|
||||
|
||||
tempFStream.close();
|
||||
|
||||
// Convert to string
|
||||
mText = std::string( pTempBuffer, nFileSize );
|
||||
|
||||
delete [] pTempBuffer;
|
||||
|
||||
// Final check
|
||||
if (mText.size() != nFileSize)
|
||||
{
|
||||
mStatus = ERROR_GEN_FAILURE;
|
||||
return;
|
||||
}
|
||||
|
||||
// Success!
|
||||
mStatus = NO_ERROR;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
cDB2TextFile (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Construct object/copy from buffer into memory
|
||||
|
||||
PARAMETERS
|
||||
pBuffer [ I ] - Buffer to copy from
|
||||
bufferLen [ I ] - Size of above buffer
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cDB2TextFile::cDB2TextFile(
|
||||
LPCSTR pBuffer,
|
||||
ULONG bufferLen )
|
||||
: mText( "" ),
|
||||
mStatus( ERROR_FILE_NOT_FOUND ),
|
||||
mCurrentPos( 0 )
|
||||
{
|
||||
// Convert to string
|
||||
mText = std::string( pBuffer, bufferLen );
|
||||
|
||||
// Final check
|
||||
if (mText.size() != bufferLen)
|
||||
{
|
||||
mStatus = ERROR_GEN_FAILURE;
|
||||
return;
|
||||
}
|
||||
|
||||
// Success!
|
||||
mStatus = NO_ERROR;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
~cDB2TextFile (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Destructor
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cDB2TextFile::~cDB2TextFile()
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
ReadLine (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Read the next available line
|
||||
|
||||
PARAMETERS
|
||||
line [ O ] - Line (minus CR/LF)
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
bool cDB2TextFile::ReadLine( std::string & line )
|
||||
{
|
||||
if (IsValid() == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int len = mText.size();
|
||||
if (mCurrentPos >= len)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int newIdx = mText.find( '\n', mCurrentPos );
|
||||
if (newIdx == -1)
|
||||
{
|
||||
// Possibly the end of the file
|
||||
newIdx = len;
|
||||
}
|
||||
|
||||
if (newIdx < mCurrentPos)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (newIdx == mCurrentPos)
|
||||
{
|
||||
// Return an empty line
|
||||
mCurrentPos++;
|
||||
line = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Grab line
|
||||
line = mText.substr( mCurrentPos, (newIdx - mCurrentPos) );
|
||||
|
||||
// Check for CR
|
||||
int nCR = line.find( '\r' );
|
||||
if (nCR != -1)
|
||||
{
|
||||
line.erase( nCR, 1 );
|
||||
}
|
||||
|
||||
mCurrentPos = newIdx + 1;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
DB2TextFile.h
|
||||
|
||||
DESCRIPTION:
|
||||
Declaration of cDB2TextFile class
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
cDB2TextFile
|
||||
The cDB2TextFile class provides the simple ability to read in an
|
||||
ANSI/UNICODE file and copy it to a dynamically allocated buffer
|
||||
|
||||
The sole difference between this and CStdioFile is that the issues
|
||||
stemming from supporting both ANSI and UNICODE files are handled
|
||||
in a simpler fashion at the expense of a bit of performance
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
#include "StdAfx.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
/*=========================================================================*/
|
||||
// Class cDB2TextFile
|
||||
/*=========================================================================*/
|
||||
class cDB2TextFile
|
||||
{
|
||||
public:
|
||||
// Constructor (loads file)
|
||||
cDB2TextFile( LPCSTR pMemFile );
|
||||
|
||||
// Constructor (loads file from resource table)
|
||||
cDB2TextFile(
|
||||
HMODULE hModule,
|
||||
LPCSTR pRscTable,
|
||||
DWORD rscID );
|
||||
|
||||
// Constructor (loads file from buffer)
|
||||
cDB2TextFile(
|
||||
LPCSTR pBuffer,
|
||||
ULONG bufferLen );
|
||||
|
||||
// Destructor
|
||||
~cDB2TextFile();
|
||||
|
||||
// (Inline) Get error status
|
||||
DWORD GetStatus()
|
||||
{
|
||||
return mStatus;
|
||||
};
|
||||
|
||||
// (Inline) Get the file contents
|
||||
bool GetText( std::string & copy )
|
||||
{
|
||||
bool bOK = IsValid();
|
||||
if (bOK == true)
|
||||
{
|
||||
copy = mText;
|
||||
}
|
||||
|
||||
return bOK;
|
||||
};
|
||||
|
||||
// (Inline) Get file validity
|
||||
virtual bool IsValid()
|
||||
{
|
||||
return (mStatus == NO_ERROR);
|
||||
};
|
||||
|
||||
// Read the next available line
|
||||
bool ReadLine( std::string & line );
|
||||
|
||||
protected:
|
||||
/* File contents */
|
||||
std::string mText;
|
||||
|
||||
/* Current position (in above contents) */
|
||||
int mCurrentPos;
|
||||
|
||||
/* Error status */
|
||||
DWORD mStatus;
|
||||
};
|
|
@ -0,0 +1,889 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
DB2Utilities.cpp
|
||||
|
||||
DESCRIPTION:
|
||||
Utility functions for packing/parsing protocol entities using the
|
||||
database
|
||||
|
||||
PUBLIC ENUMERATIONS AND METHODS:
|
||||
sProtocolEntityKey
|
||||
sDB2PackingInput
|
||||
sDB2NavInput
|
||||
|
||||
MapQMIEntityTypeToProtocolType
|
||||
MapQMIEntityTypeToQMIServiceType
|
||||
MapQMIProtocolTypeToEntityType
|
||||
DB2GetMaxBufferSize
|
||||
DB2BuildQMIBuffer
|
||||
DB2PackQMIBuffer
|
||||
DB2ReduceQMIBuffer
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "StdAfx.h"
|
||||
#include "DB2Utilities.h"
|
||||
|
||||
#include "QMIBuffers.h"
|
||||
|
||||
#include "DataPacker.h"
|
||||
#include "ProtocolEntityFieldEnumerator.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Free Methods
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
MapQMIEntityTypeToQMIServiceType (Public Free Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Map a DB protocol entity type (for QMI) to a QMI service type
|
||||
|
||||
PARAMETERS:
|
||||
et [ I ] - Protocol entity type
|
||||
|
||||
RETURN VALUE:
|
||||
eQMIService
|
||||
===========================================================================*/
|
||||
eQMIService MapQMIEntityTypeToQMIServiceType( eDB2EntityType et )
|
||||
{
|
||||
eQMIService st = eQMI_SVC_ENUM_BEGIN;
|
||||
switch (et)
|
||||
{
|
||||
case eDB2_ET_QMI_CTL_REQ:
|
||||
case eDB2_ET_QMI_CTL_RSP:
|
||||
case eDB2_ET_QMI_CTL_IND:
|
||||
st = eQMI_SVC_CONTROL;
|
||||
break;
|
||||
|
||||
case eDB2_ET_QMI_WDS_REQ:
|
||||
case eDB2_ET_QMI_WDS_RSP:
|
||||
case eDB2_ET_QMI_WDS_IND:
|
||||
st = eQMI_SVC_WDS;
|
||||
break;
|
||||
|
||||
case eDB2_ET_QMI_DMS_REQ:
|
||||
case eDB2_ET_QMI_DMS_RSP:
|
||||
case eDB2_ET_QMI_DMS_IND:
|
||||
st = eQMI_SVC_DMS;
|
||||
break;
|
||||
|
||||
case eDB2_ET_QMI_NAS_REQ:
|
||||
case eDB2_ET_QMI_NAS_RSP:
|
||||
case eDB2_ET_QMI_NAS_IND:
|
||||
st = eQMI_SVC_NAS;
|
||||
break;
|
||||
|
||||
case eDB2_ET_QMI_QOS_REQ:
|
||||
case eDB2_ET_QMI_QOS_RSP:
|
||||
case eDB2_ET_QMI_QOS_IND:
|
||||
st = eQMI_SVC_QOS;
|
||||
break;
|
||||
|
||||
case eDB2_ET_QMI_WMS_REQ:
|
||||
case eDB2_ET_QMI_WMS_RSP:
|
||||
case eDB2_ET_QMI_WMS_IND:
|
||||
st = eQMI_SVC_WMS;
|
||||
break;
|
||||
|
||||
case eDB2_ET_QMI_PDS_REQ:
|
||||
case eDB2_ET_QMI_PDS_RSP:
|
||||
case eDB2_ET_QMI_PDS_IND:
|
||||
st = eQMI_SVC_PDS;
|
||||
break;
|
||||
|
||||
case eDB2_ET_QMI_AUTH_REQ:
|
||||
case eDB2_ET_QMI_AUTH_RSP:
|
||||
case eDB2_ET_QMI_AUTH_IND:
|
||||
st = eQMI_SVC_AUTH;
|
||||
break;
|
||||
|
||||
case eDB2_ET_QMI_VOICE_REQ:
|
||||
case eDB2_ET_QMI_VOICE_RSP:
|
||||
case eDB2_ET_QMI_VOICE_IND:
|
||||
st = eQMI_SVC_VOICE;
|
||||
break;
|
||||
|
||||
case eDB2_ET_QMI_CAT_REQ:
|
||||
case eDB2_ET_QMI_CAT_RSP:
|
||||
case eDB2_ET_QMI_CAT_IND:
|
||||
st = eQMI_SVC_CAT;
|
||||
break;
|
||||
|
||||
case eDB2_ET_QMI_RMS_REQ:
|
||||
case eDB2_ET_QMI_RMS_RSP:
|
||||
case eDB2_ET_QMI_RMS_IND:
|
||||
st = eQMI_SVC_RMS;
|
||||
break;
|
||||
|
||||
case eDB2_ET_QMI_OMA_REQ:
|
||||
case eDB2_ET_QMI_OMA_RSP:
|
||||
case eDB2_ET_QMI_OMA_IND:
|
||||
st = eQMI_SVC_OMA;
|
||||
break;
|
||||
}
|
||||
|
||||
return st;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
MapQMIEntityTypeToProtocolType (Public Free Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Map a DB protocol entity type (for QMI) to a buffer protocol type
|
||||
|
||||
PARAMETERS:
|
||||
et [ I ] - Protocol entity type
|
||||
|
||||
RETURN VALUE:
|
||||
eProtocolType
|
||||
===========================================================================*/
|
||||
eProtocolType MapQMIEntityTypeToProtocolType( eDB2EntityType et )
|
||||
{
|
||||
eProtocolType pt = ePROTOCOL_ENUM_BEGIN;
|
||||
switch (et)
|
||||
{
|
||||
case eDB2_ET_QMI_WDS_REQ:
|
||||
pt = ePROTOCOL_QMI_WDS_TX;
|
||||
break;
|
||||
|
||||
case eDB2_ET_QMI_WDS_RSP:
|
||||
case eDB2_ET_QMI_WDS_IND:
|
||||
pt = ePROTOCOL_QMI_WDS_RX;
|
||||
break;
|
||||
|
||||
case eDB2_ET_QMI_DMS_REQ:
|
||||
pt = ePROTOCOL_QMI_DMS_TX;
|
||||
break;
|
||||
|
||||
case eDB2_ET_QMI_DMS_RSP:
|
||||
case eDB2_ET_QMI_DMS_IND:
|
||||
pt = ePROTOCOL_QMI_DMS_RX;
|
||||
break;
|
||||
|
||||
case eDB2_ET_QMI_NAS_REQ:
|
||||
pt = ePROTOCOL_QMI_NAS_TX;
|
||||
break;
|
||||
|
||||
case eDB2_ET_QMI_NAS_RSP:
|
||||
case eDB2_ET_QMI_NAS_IND:
|
||||
pt = ePROTOCOL_QMI_NAS_RX;
|
||||
break;
|
||||
|
||||
case eDB2_ET_QMI_QOS_REQ:
|
||||
pt = ePROTOCOL_QMI_QOS_TX;
|
||||
break;
|
||||
|
||||
case eDB2_ET_QMI_QOS_RSP:
|
||||
case eDB2_ET_QMI_QOS_IND:
|
||||
pt = ePROTOCOL_QMI_QOS_RX;
|
||||
break;
|
||||
|
||||
case eDB2_ET_QMI_WMS_REQ:
|
||||
pt = ePROTOCOL_QMI_WMS_TX;
|
||||
break;
|
||||
|
||||
case eDB2_ET_QMI_WMS_RSP:
|
||||
case eDB2_ET_QMI_WMS_IND:
|
||||
pt = ePROTOCOL_QMI_WMS_RX;
|
||||
break;
|
||||
|
||||
case eDB2_ET_QMI_PDS_REQ:
|
||||
pt = ePROTOCOL_QMI_PDS_TX;
|
||||
break;
|
||||
|
||||
case eDB2_ET_QMI_PDS_RSP:
|
||||
case eDB2_ET_QMI_PDS_IND:
|
||||
pt = ePROTOCOL_QMI_PDS_RX;
|
||||
break;
|
||||
|
||||
case eDB2_ET_QMI_AUTH_REQ:
|
||||
pt = ePROTOCOL_QMI_AUTH_TX;
|
||||
break;
|
||||
|
||||
case eDB2_ET_QMI_AUTH_RSP:
|
||||
case eDB2_ET_QMI_AUTH_IND:
|
||||
pt = ePROTOCOL_QMI_AUTH_RX;
|
||||
break;
|
||||
|
||||
case eDB2_ET_QMI_VOICE_REQ:
|
||||
pt = ePROTOCOL_QMI_VOICE_TX;
|
||||
break;
|
||||
|
||||
case eDB2_ET_QMI_VOICE_RSP:
|
||||
case eDB2_ET_QMI_VOICE_IND:
|
||||
pt = ePROTOCOL_QMI_VOICE_RX;
|
||||
break;
|
||||
|
||||
case eDB2_ET_QMI_CAT_REQ:
|
||||
pt = ePROTOCOL_QMI_CAT_TX;
|
||||
break;
|
||||
|
||||
case eDB2_ET_QMI_CAT_RSP:
|
||||
case eDB2_ET_QMI_CAT_IND:
|
||||
pt = ePROTOCOL_QMI_CAT_RX;
|
||||
break;
|
||||
|
||||
case eDB2_ET_QMI_RMS_REQ:
|
||||
pt = ePROTOCOL_QMI_RMS_TX;
|
||||
break;
|
||||
|
||||
case eDB2_ET_QMI_RMS_RSP:
|
||||
case eDB2_ET_QMI_RMS_IND:
|
||||
pt = ePROTOCOL_QMI_RMS_RX;
|
||||
break;
|
||||
|
||||
case eDB2_ET_QMI_OMA_REQ:
|
||||
pt = ePROTOCOL_QMI_OMA_TX;
|
||||
break;
|
||||
|
||||
case eDB2_ET_QMI_OMA_RSP:
|
||||
case eDB2_ET_QMI_OMA_IND:
|
||||
pt = ePROTOCOL_QMI_OMA_RX;
|
||||
break;
|
||||
|
||||
case eDB2_ET_QMI_CTL_REQ:
|
||||
pt = ePROTOCOL_QMI_CTL_TX;
|
||||
break;
|
||||
|
||||
case eDB2_ET_QMI_CTL_RSP:
|
||||
case eDB2_ET_QMI_CTL_IND:
|
||||
pt = ePROTOCOL_QMI_CTL_RX;
|
||||
break;
|
||||
}
|
||||
|
||||
return pt;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
MapQMIProtocolTypeToEntityType (Public Free Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Map a buffer protocol type to a DB protocol entity type
|
||||
|
||||
PARAMETERS:
|
||||
pt [ I ] - Protocol type
|
||||
bIndication [ I ] - Is this for an indication?
|
||||
|
||||
RETURN VALUE:
|
||||
eDB2EntityType
|
||||
===========================================================================*/
|
||||
eDB2EntityType MapQMIProtocolTypeToEntityType(
|
||||
eProtocolType pt,
|
||||
bool bIndication )
|
||||
{
|
||||
eDB2EntityType et = eDB2_ET_ENUM_BEGIN;
|
||||
switch (pt)
|
||||
{
|
||||
case ePROTOCOL_QMI_WDS_RX:
|
||||
if (bIndication == true)
|
||||
{
|
||||
et = eDB2_ET_QMI_WDS_IND;
|
||||
}
|
||||
else
|
||||
{
|
||||
et = eDB2_ET_QMI_WDS_RSP;
|
||||
}
|
||||
break;
|
||||
|
||||
case ePROTOCOL_QMI_WDS_TX:
|
||||
et = eDB2_ET_QMI_WDS_REQ;
|
||||
break;
|
||||
|
||||
case ePROTOCOL_QMI_DMS_RX:
|
||||
if (bIndication == true)
|
||||
{
|
||||
et = eDB2_ET_QMI_DMS_IND;
|
||||
}
|
||||
else
|
||||
{
|
||||
et = eDB2_ET_QMI_DMS_RSP;
|
||||
}
|
||||
break;
|
||||
|
||||
case ePROTOCOL_QMI_DMS_TX:
|
||||
et = eDB2_ET_QMI_DMS_REQ;
|
||||
break;
|
||||
|
||||
case ePROTOCOL_QMI_NAS_RX:
|
||||
if (bIndication == true)
|
||||
{
|
||||
et = eDB2_ET_QMI_NAS_IND;
|
||||
}
|
||||
else
|
||||
{
|
||||
et = eDB2_ET_QMI_NAS_RSP;
|
||||
}
|
||||
break;
|
||||
|
||||
case ePROTOCOL_QMI_NAS_TX:
|
||||
et = eDB2_ET_QMI_NAS_REQ;
|
||||
break;
|
||||
|
||||
case ePROTOCOL_QMI_QOS_RX:
|
||||
if (bIndication == true)
|
||||
{
|
||||
et = eDB2_ET_QMI_QOS_IND;
|
||||
}
|
||||
else
|
||||
{
|
||||
et = eDB2_ET_QMI_QOS_RSP;
|
||||
}
|
||||
break;
|
||||
|
||||
case ePROTOCOL_QMI_QOS_TX:
|
||||
et = eDB2_ET_QMI_QOS_REQ;
|
||||
break;
|
||||
|
||||
case ePROTOCOL_QMI_WMS_RX:
|
||||
if (bIndication == true)
|
||||
{
|
||||
et = eDB2_ET_QMI_WMS_IND;
|
||||
}
|
||||
else
|
||||
{
|
||||
et = eDB2_ET_QMI_WMS_RSP;
|
||||
}
|
||||
break;
|
||||
|
||||
case ePROTOCOL_QMI_WMS_TX:
|
||||
et = eDB2_ET_QMI_WMS_REQ;
|
||||
break;
|
||||
|
||||
case ePROTOCOL_QMI_PDS_RX:
|
||||
if (bIndication == true)
|
||||
{
|
||||
et = eDB2_ET_QMI_PDS_IND;
|
||||
}
|
||||
else
|
||||
{
|
||||
et = eDB2_ET_QMI_PDS_RSP;
|
||||
}
|
||||
break;
|
||||
|
||||
case ePROTOCOL_QMI_PDS_TX:
|
||||
et = eDB2_ET_QMI_PDS_REQ;
|
||||
break;
|
||||
|
||||
case ePROTOCOL_QMI_AUTH_RX:
|
||||
if (bIndication == true)
|
||||
{
|
||||
et = eDB2_ET_QMI_AUTH_IND;
|
||||
}
|
||||
else
|
||||
{
|
||||
et = eDB2_ET_QMI_AUTH_RSP;
|
||||
}
|
||||
break;
|
||||
|
||||
case ePROTOCOL_QMI_AUTH_TX:
|
||||
et = eDB2_ET_QMI_AUTH_REQ;
|
||||
break;
|
||||
|
||||
case ePROTOCOL_QMI_VOICE_RX:
|
||||
if (bIndication == true)
|
||||
{
|
||||
et = eDB2_ET_QMI_VOICE_IND;
|
||||
}
|
||||
else
|
||||
{
|
||||
et = eDB2_ET_QMI_VOICE_RSP;
|
||||
}
|
||||
break;
|
||||
|
||||
case ePROTOCOL_QMI_VOICE_TX:
|
||||
et = eDB2_ET_QMI_VOICE_REQ;
|
||||
break;
|
||||
|
||||
case ePROTOCOL_QMI_CAT_RX:
|
||||
if (bIndication == true)
|
||||
{
|
||||
et = eDB2_ET_QMI_CAT_IND;
|
||||
}
|
||||
else
|
||||
{
|
||||
et = eDB2_ET_QMI_CAT_RSP;
|
||||
}
|
||||
break;
|
||||
|
||||
case ePROTOCOL_QMI_CAT_TX:
|
||||
et = eDB2_ET_QMI_CAT_REQ;
|
||||
break;
|
||||
|
||||
case ePROTOCOL_QMI_RMS_RX:
|
||||
if (bIndication == true)
|
||||
{
|
||||
et = eDB2_ET_QMI_RMS_IND;
|
||||
}
|
||||
else
|
||||
{
|
||||
et = eDB2_ET_QMI_RMS_RSP;
|
||||
}
|
||||
break;
|
||||
|
||||
case ePROTOCOL_QMI_RMS_TX:
|
||||
et = eDB2_ET_QMI_RMS_REQ;
|
||||
break;
|
||||
|
||||
case ePROTOCOL_QMI_OMA_RX:
|
||||
if (bIndication == true)
|
||||
{
|
||||
et = eDB2_ET_QMI_OMA_IND;
|
||||
}
|
||||
else
|
||||
{
|
||||
et = eDB2_ET_QMI_OMA_RSP;
|
||||
}
|
||||
break;
|
||||
|
||||
case ePROTOCOL_QMI_OMA_TX:
|
||||
et = eDB2_ET_QMI_OMA_REQ;
|
||||
break;
|
||||
|
||||
case ePROTOCOL_QMI_CTL_RX:
|
||||
if (bIndication == true)
|
||||
{
|
||||
et = eDB2_ET_QMI_CTL_IND;
|
||||
}
|
||||
else
|
||||
{
|
||||
et = eDB2_ET_QMI_CTL_RSP;
|
||||
}
|
||||
break;
|
||||
|
||||
case ePROTOCOL_QMI_CTL_TX:
|
||||
et = eDB2_ET_QMI_CTL_REQ;
|
||||
break;
|
||||
}
|
||||
|
||||
return et;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
DB2GetMaxBufferSize (Public Free Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Return the maximum size of a payload buffer for given type of
|
||||
protocol entity
|
||||
|
||||
PARAMETERS:
|
||||
et [ I ] - Protocol entity type
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Maximum
|
||||
===========================================================================*/
|
||||
ULONG DB2GetMaxBufferSize( eDB2EntityType et )
|
||||
{
|
||||
ULONG maxSzInBytes = MAX_SHARED_BUFFER_SIZE;
|
||||
|
||||
if (IsQMIEntityType( et ) == true)
|
||||
{
|
||||
// QMI items are further constrained in size
|
||||
maxSzInBytes = QMI_MAX_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
return maxSzInBytes;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
DB2BuildQMIBuffer (Internal Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Build and return an allocated shared buffer for the QMI protocol using
|
||||
the specified DB keys and payloads (one per TLV content)
|
||||
|
||||
PARAMETERS:
|
||||
input [ I ] - Protocol entity key and payload
|
||||
|
||||
RETURN VALUE:
|
||||
sSharedBuffer * (0 upon failure)
|
||||
===========================================================================*/
|
||||
sSharedBuffer * DB2BuildQMIBuffer(
|
||||
const std::vector <sDB2NavInput> & input )
|
||||
{
|
||||
// Assume failure
|
||||
sSharedBuffer * pRef = 0;
|
||||
|
||||
const ULONG szTransHdr = (ULONG)sizeof(sQMIServiceRawTransactionHeader);
|
||||
const ULONG szMsgHdr = (ULONG)sizeof(sQMIRawMessageHeader);
|
||||
const ULONG szTLVHdr = (ULONG)sizeof(sQMIRawContentHeader);
|
||||
|
||||
// Need something to build
|
||||
ULONG tlvs = (ULONG)input.size();
|
||||
if (tlvs == 0)
|
||||
{
|
||||
return pRef;
|
||||
}
|
||||
|
||||
// The protocol entity keys need to be consistent
|
||||
const sDB2NavInput & tlvInput = input[0];
|
||||
if (tlvInput.IsValid() == false || tlvInput.mKey.size() < 3)
|
||||
{
|
||||
return pRef;
|
||||
}
|
||||
|
||||
eDB2EntityType et = (eDB2EntityType)tlvInput.mKey[0];
|
||||
if (IsQMIEntityType( et ) == false)
|
||||
{
|
||||
return pRef;
|
||||
}
|
||||
|
||||
ULONG szReq = szTransHdr + szMsgHdr + (tlvs * szTLVHdr);
|
||||
szReq += tlvInput.mPayloadLen;
|
||||
|
||||
ULONG t = 0;
|
||||
for (t = 1; t < tlvs; t++)
|
||||
{
|
||||
const sDB2NavInput & tlv2Input = input[t];
|
||||
if (tlv2Input.IsValid() == false || tlv2Input.mKey.size() < 3)
|
||||
{
|
||||
return pRef;
|
||||
}
|
||||
|
||||
if ( (tlvInput.mKey[0] != tlv2Input.mKey[0])
|
||||
|| (tlvInput.mKey[1] != tlv2Input.mKey[1]) )
|
||||
{
|
||||
return pRef;
|
||||
}
|
||||
|
||||
szReq += tlv2Input.mPayloadLen;
|
||||
}
|
||||
|
||||
// What we are building cannot be too large
|
||||
if (szReq > QMI_MAX_BUFFER_SIZE)
|
||||
{
|
||||
return pRef;
|
||||
}
|
||||
|
||||
BYTE buf[QMI_MAX_BUFFER_SIZE];
|
||||
|
||||
sQMIRawContentHeader * pTLV = 0;
|
||||
pTLV = (sQMIRawContentHeader *)&buf[0];
|
||||
|
||||
for (t = 0; t < tlvs; t++)
|
||||
{
|
||||
const sDB2NavInput & tlv2Input = input[t];
|
||||
|
||||
pTLV->mTypeID = (BYTE)tlv2Input.mKey[2];
|
||||
pTLV->mLength = (WORD)tlv2Input.mPayloadLen;
|
||||
pTLV++;
|
||||
|
||||
const BYTE * pPayload = (const BYTE *)pTLV;
|
||||
memcpy( (LPVOID)pPayload,
|
||||
(LPCVOID)tlv2Input.mpPayload,
|
||||
(SIZE_T)tlv2Input.mPayloadLen );
|
||||
|
||||
pPayload += tlv2Input.mPayloadLen;
|
||||
pTLV = (sQMIRawContentHeader *)pPayload;
|
||||
}
|
||||
|
||||
ULONG contentLen = szReq - szTransHdr - szMsgHdr;
|
||||
eQMIService st = MapQMIEntityTypeToQMIServiceType( et );
|
||||
|
||||
pRef = sQMIServiceBuffer::BuildBuffer( st,
|
||||
(WORD)tlvInput.mKey[1],
|
||||
IsQMIEntityResponseType( et ),
|
||||
IsQMIEntityIndicationType( et ),
|
||||
&buf[0],
|
||||
contentLen );
|
||||
|
||||
return pRef;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
DB2PackQMIBuffer (Internal Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Build an allocated shared buffer for the QMI protocol
|
||||
|
||||
PARAMETERS:
|
||||
db [ I ] - Database to use for packing
|
||||
input [ I ] - Protocol entity key and field values
|
||||
|
||||
RETURN VALUE:
|
||||
sSharedBuffer * (0 upon failure)
|
||||
===========================================================================*/
|
||||
sSharedBuffer * DB2PackQMIBuffer(
|
||||
const cCoreDatabase & db,
|
||||
const std::vector <sDB2PackingInput> & input )
|
||||
{
|
||||
// Assume failure
|
||||
sSharedBuffer * pRef = 0;
|
||||
|
||||
// Need something to build
|
||||
ULONG tlvs = (ULONG)input.size();
|
||||
if (tlvs == 0)
|
||||
{
|
||||
return pRef;
|
||||
}
|
||||
|
||||
// The protocol entity keys need to be consistent
|
||||
const sDB2PackingInput & tlvInput = input[0];
|
||||
if (tlvInput.IsValid() == false || tlvInput.mKey.size() < 3)
|
||||
{
|
||||
return pRef;
|
||||
}
|
||||
|
||||
eDB2EntityType et = (eDB2EntityType)tlvInput.mKey[0];
|
||||
if (IsQMIEntityType( et ) == false)
|
||||
{
|
||||
return pRef;
|
||||
}
|
||||
|
||||
ULONG t = 0;
|
||||
for (t = 1; t < tlvs; t++)
|
||||
{
|
||||
const sDB2PackingInput & tlv2Input = input[t];
|
||||
if (tlv2Input.IsValid() == false || tlv2Input.mKey.size() < 3)
|
||||
{
|
||||
return pRef;
|
||||
}
|
||||
|
||||
if ( (tlvInput.mKey[0] != tlv2Input.mKey[0])
|
||||
|| (tlvInput.mKey[1] != tlv2Input.mKey[1]) )
|
||||
{
|
||||
return pRef;
|
||||
}
|
||||
}
|
||||
|
||||
BYTE buf[QMI_MAX_BUFFER_SIZE];
|
||||
ULONG bufLen = 0;
|
||||
|
||||
sQMIRawContentHeader * pTLV = 0;
|
||||
pTLV = (sQMIRawContentHeader *)&buf[0];
|
||||
|
||||
bool bOK = true;
|
||||
for (t = 0; t < tlvs; t++)
|
||||
{
|
||||
ULONG packedLen = 0;
|
||||
const BYTE * pPackedData = 0;
|
||||
|
||||
const sDB2PackingInput & tlv2Input = input[t];
|
||||
|
||||
if (tlv2Input.mbString == true)
|
||||
{
|
||||
if (tlv2Input.mValues.empty() == false)
|
||||
{
|
||||
// Convert field string to input fields
|
||||
std::list <sUnpackedField> fields
|
||||
= cDataPacker::LoadValues( tlv2Input.mValues );
|
||||
|
||||
// Now pack
|
||||
cDataPacker dp( db, tlv2Input.mKey, fields );
|
||||
bOK = dp.Pack();
|
||||
if (bOK == false)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
pPackedData = dp.GetBuffer( packedLen );
|
||||
if (pPackedData == 0)
|
||||
{
|
||||
bOK = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
packedLen = tlv2Input.mDataLen;
|
||||
pPackedData = tlv2Input.mpData;
|
||||
}
|
||||
|
||||
// Check if we need to adjust buffer
|
||||
cProtocolEntityFieldEnumerator pefe( db, tlv2Input.mKey );
|
||||
bool bEnum = pefe.Enumerate();
|
||||
if (bEnum == true)
|
||||
{
|
||||
const std::vector <ULONG> & fieldIDs = pefe.GetFields();
|
||||
ULONG fieldCount = (ULONG)fieldIDs.size();
|
||||
if (fieldCount == 1)
|
||||
{
|
||||
const tDB2FieldMap & dbFields = db.GetProtocolFields();
|
||||
|
||||
tDB2FieldMap::const_iterator pField = dbFields.find( fieldIDs[0] );
|
||||
if (pField != dbFields.end())
|
||||
{
|
||||
const sDB2Field & theField = pField->second;
|
||||
if ( (theField.mType == eDB2_FIELD_STD)
|
||||
&& (theField.mTypeVal == (ULONG)eDB2_FIELD_STDTYPE_STRING_ANT) )
|
||||
{
|
||||
// For QMI we need to strip out the trailing NULL
|
||||
// string terminator when the TLV consists solely
|
||||
// of a string since the length contained in the
|
||||
// TLV structure itself renders the trailing NULL
|
||||
// redundant
|
||||
if (packedLen > 2)
|
||||
{
|
||||
packedLen--;
|
||||
}
|
||||
else
|
||||
{
|
||||
// This is the only way to specify an empty string in QMI
|
||||
// when the TLV consists solely of a string
|
||||
if (packedLen == 1)
|
||||
{
|
||||
packedLen--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bufLen += (ULONG)sizeof(sQMIRawContentHeader);
|
||||
bufLen += packedLen;
|
||||
|
||||
// What we are building cannot be too large
|
||||
if (bufLen > QMI_MAX_BUFFER_SIZE)
|
||||
{
|
||||
bOK = false;
|
||||
break;
|
||||
}
|
||||
|
||||
pTLV->mTypeID = (BYTE)tlv2Input.mKey[2];
|
||||
pTLV->mLength = (WORD)packedLen;
|
||||
pTLV++;
|
||||
|
||||
const BYTE * pPayload = (const BYTE *)pTLV;
|
||||
memcpy( (LPVOID)pPayload,
|
||||
(LPCVOID)pPackedData,
|
||||
(SIZE_T)packedLen );
|
||||
|
||||
pPayload += packedLen;
|
||||
pTLV = (sQMIRawContentHeader *)pPayload;
|
||||
}
|
||||
|
||||
if (bOK == false)
|
||||
{
|
||||
return pRef;
|
||||
}
|
||||
|
||||
eQMIService st = MapQMIEntityTypeToQMIServiceType( et );
|
||||
pRef = sQMIServiceBuffer::BuildBuffer( st,
|
||||
(WORD)tlvInput.mKey[1],
|
||||
IsQMIEntityResponseType( et ),
|
||||
IsQMIEntityIndicationType( et ),
|
||||
&buf[0],
|
||||
bufLen );
|
||||
|
||||
return pRef;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
DB2ReduceQMIBuffer (Public Free Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Reduce a DIAG buffer to a DB key and payload
|
||||
|
||||
PARAMETERS:
|
||||
buf [ I ] - Protocol buffer being reduced
|
||||
|
||||
RETURN VALUE:
|
||||
sDB2NavInput (invalid upon failure)
|
||||
===========================================================================*/
|
||||
std::vector <sDB2NavInput> DB2ReduceQMIBuffer( const sProtocolBuffer & buf )
|
||||
{
|
||||
std::vector <sDB2NavInput> retInput;
|
||||
|
||||
// We must have a valid protocol buffer
|
||||
if (buf.IsValid() == false)
|
||||
{
|
||||
return retInput;
|
||||
}
|
||||
|
||||
eProtocolType pt = (eProtocolType)buf.GetType();
|
||||
if (IsQMIProtocol( pt ) != true)
|
||||
{
|
||||
return retInput;
|
||||
}
|
||||
|
||||
sQMIServiceBuffer qmiBuf( buf.GetSharedBuffer() );
|
||||
std::map <ULONG, const sQMIRawContentHeader *> tlvs = qmiBuf.GetContents();
|
||||
|
||||
bool bErr = false;
|
||||
std::map <ULONG, const sQMIRawContentHeader *>::const_iterator pIter;
|
||||
for (pIter = tlvs.begin(); pIter != tlvs.end(); pIter++)
|
||||
{
|
||||
const sQMIRawContentHeader * pHdr = pIter->second;
|
||||
if (pHdr == 0)
|
||||
{
|
||||
bErr = true;
|
||||
break;
|
||||
}
|
||||
|
||||
bool bIndication = qmiBuf.IsIndication();
|
||||
eProtocolType pt = (eProtocolType)qmiBuf.GetType();
|
||||
eDB2EntityType et = MapQMIProtocolTypeToEntityType( pt, bIndication );
|
||||
|
||||
sDB2NavInput tmp;
|
||||
tmp.mKey.push_back( (ULONG)et );
|
||||
tmp.mKey.push_back( qmiBuf.GetMessageID() );
|
||||
tmp.mKey.push_back( (ULONG)pHdr->mTypeID );
|
||||
|
||||
tmp.mPayloadLen = pHdr->mLength;
|
||||
pHdr++;
|
||||
|
||||
tmp.mpPayload = (const BYTE *)pHdr;
|
||||
if (tmp.IsValid() == true)
|
||||
{
|
||||
retInput.push_back( tmp );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ignore empty TLVs
|
||||
if (tmp.mPayloadLen != 0)
|
||||
{
|
||||
bErr = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bErr == true)
|
||||
{
|
||||
retInput.clear();
|
||||
}
|
||||
|
||||
return retInput;
|
||||
}
|
|
@ -0,0 +1,268 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
DB2Utilities.h
|
||||
|
||||
DESCRIPTION:
|
||||
Utility functions for packing/parsing protocol entities using the
|
||||
database
|
||||
|
||||
PUBLIC ENUMERATIONS AND METHODS:
|
||||
sProtocolEntityKey
|
||||
sDB2PackingInput
|
||||
sDB2NavInput
|
||||
|
||||
MapQMIEntityTypeToProtocolType
|
||||
MapQMIEntityTypeToQMIServiceType
|
||||
MapQMIProtocolTypeToEntityType
|
||||
DB2GetMaxBufferSize
|
||||
DB2BuildQMIBuffer
|
||||
DB2PackQMIBuffer
|
||||
DB2ReduceQMIBuffer
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "CoreDatabase.h"
|
||||
#include "SharedBuffer.h"
|
||||
#include "ProtocolBuffer.h"
|
||||
#include "QMIEnum.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sProtocolEntityKey
|
||||
// Simple structure to initializing protocol entity keys easier
|
||||
/*=========================================================================*/
|
||||
struct sProtocolEntityKey
|
||||
{
|
||||
public:
|
||||
// (Inline) Constructor - default
|
||||
sProtocolEntityKey()
|
||||
{ };
|
||||
|
||||
// (Inline) Constructor - single value keys
|
||||
sProtocolEntityKey( ULONG val1 )
|
||||
{
|
||||
mKey.push_back( val1 );
|
||||
};
|
||||
|
||||
// (Inline) Constructor - two value keys
|
||||
sProtocolEntityKey(
|
||||
ULONG val1,
|
||||
ULONG val2 )
|
||||
{
|
||||
mKey.push_back( val1 );
|
||||
mKey.push_back( val2 );
|
||||
};
|
||||
|
||||
// (Inline) Constructor - three value keys
|
||||
sProtocolEntityKey(
|
||||
ULONG val1,
|
||||
ULONG val2,
|
||||
ULONG val3 )
|
||||
{
|
||||
mKey.push_back( val1 );
|
||||
mKey.push_back( val2 );
|
||||
mKey.push_back( val3 );
|
||||
};
|
||||
|
||||
// (Inline) Constructor - psuedo-copy constructor
|
||||
sProtocolEntityKey( const std::vector <ULONG> & key )
|
||||
: mKey( key )
|
||||
{ };
|
||||
|
||||
// (Inline) Constructor - copy constructor
|
||||
sProtocolEntityKey( const sProtocolEntityKey & key )
|
||||
: mKey( key.mKey )
|
||||
{ };
|
||||
|
||||
// (Inline) Assignment operator
|
||||
sProtocolEntityKey & operator = ( const sProtocolEntityKey & key )
|
||||
{
|
||||
mKey = key.mKey;
|
||||
return *this;
|
||||
};
|
||||
|
||||
// Cast operator to a protocol entity key
|
||||
operator std::vector <ULONG>() const
|
||||
{
|
||||
return mKey;
|
||||
};
|
||||
|
||||
/* Underlying key */
|
||||
std::vector <ULONG> mKey;
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sDB2PackingInput
|
||||
// Simple structure to make dealing packing easier
|
||||
/*=========================================================================*/
|
||||
struct sDB2PackingInput
|
||||
{
|
||||
public:
|
||||
// (Inline) Constructor - default
|
||||
sDB2PackingInput()
|
||||
: mpData( 0 ),
|
||||
mDataLen( 0 ),
|
||||
mbString( true )
|
||||
{ };
|
||||
|
||||
// (Inline) Constructor - parameterized (string payload)
|
||||
sDB2PackingInput(
|
||||
const sProtocolEntityKey & key,
|
||||
LPCSTR pValue )
|
||||
: mKey( key ),
|
||||
mpData( 0 ),
|
||||
mDataLen( 0 ),
|
||||
mbString( true )
|
||||
{
|
||||
if (pValue != 0 && pValue[0] != 0)
|
||||
{
|
||||
mValues = pValue;
|
||||
}
|
||||
};
|
||||
|
||||
// (Inline) Constructor - parameterized (buffer payload)
|
||||
sDB2PackingInput(
|
||||
const sProtocolEntityKey & key,
|
||||
const BYTE * pData,
|
||||
ULONG dataLen )
|
||||
: mKey( key ),
|
||||
mpData( pData ),
|
||||
mDataLen( dataLen ),
|
||||
mbString( false )
|
||||
{
|
||||
// Nothing to do
|
||||
};
|
||||
|
||||
// (Inline) Is this object in a valid state?
|
||||
bool IsValid() const
|
||||
{
|
||||
// We need a key
|
||||
if (mKey.size() <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
/* Underlying key */
|
||||
std::vector <ULONG> mKey;
|
||||
|
||||
/* Are the values specified by a string? */
|
||||
bool mbString;
|
||||
|
||||
/* String of space delimited field values */
|
||||
std::string mValues;
|
||||
|
||||
/* Buffer containing pre-formatted fields */
|
||||
const BYTE * mpData;
|
||||
|
||||
/* Length of above buffer */
|
||||
ULONG mDataLen;
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sDB2NavInput
|
||||
// Simple structure to make dealing with key/payload easier
|
||||
/*=========================================================================*/
|
||||
struct sDB2NavInput
|
||||
{
|
||||
public:
|
||||
// (Inline) Constructor - default
|
||||
sDB2NavInput()
|
||||
: mpPayload( 0 ),
|
||||
mPayloadLen( 0 )
|
||||
{ };
|
||||
|
||||
// (Inline) Constructor - parameterized
|
||||
sDB2NavInput(
|
||||
const std::vector <ULONG> & key,
|
||||
const BYTE * pData,
|
||||
ULONG dataLen )
|
||||
: mKey( key ),
|
||||
mpPayload( pData ),
|
||||
mPayloadLen( dataLen )
|
||||
{ };
|
||||
|
||||
// (Inline) Is this object in a valid state?
|
||||
bool IsValid() const
|
||||
{
|
||||
return (mKey.size() > 0 && mpPayload != 0 && mPayloadLen > 0);
|
||||
};
|
||||
|
||||
/* Database key for payload entity */
|
||||
std::vector <ULONG> mKey;
|
||||
|
||||
/* Payload */
|
||||
const BYTE * mpPayload;
|
||||
|
||||
/* Size of above payload */
|
||||
ULONG mPayloadLen;
|
||||
};
|
||||
|
||||
// Map a DB protocol entity type to a buffer protocol type
|
||||
eProtocolType MapQMIEntityTypeToProtocolType( eDB2EntityType et );
|
||||
|
||||
// Map a DB protocol entity type to a QMI service type
|
||||
eQMIService MapQMIEntityTypeToQMIServiceType( eDB2EntityType et );
|
||||
|
||||
// Map a buffer protocol type to a DB protocol entity type
|
||||
eDB2EntityType MapQMIProtocolTypeToEntityType(
|
||||
eProtocolType pt,
|
||||
bool bIndication = false );
|
||||
|
||||
// Return the maximum size of a payload buffer for given type of
|
||||
// protocol entity
|
||||
ULONG DB2GetMaxBufferSize( eDB2EntityType et );
|
||||
|
||||
// Build an allocated shared buffer for the QMI protocol
|
||||
sSharedBuffer * DB2BuildQMIBuffer(
|
||||
const std::vector <sDB2NavInput> & input );
|
||||
|
||||
// Build an allocated shared buffer for the QMI protocol
|
||||
sSharedBuffer * DB2PackQMIBuffer(
|
||||
const cCoreDatabase & db,
|
||||
const std::vector <sDB2PackingInput> & input );
|
||||
|
||||
// Reduce a QMI buffer to DB keys and payload
|
||||
std::vector <sDB2NavInput> DB2ReduceQMIBuffer( const sProtocolBuffer & buf );
|
||||
|
|
@ -0,0 +1,831 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
DataPacker.cpp
|
||||
|
||||
DESCRIPTION:
|
||||
Implementation of sUnpackedField and cDataPacker
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
sUnpackedField
|
||||
Structure to represent a single unpacked (input) field - i.e. the
|
||||
field value as a string and an optional field name (either fully
|
||||
qualified) or partial
|
||||
|
||||
cDataPacker
|
||||
Class to pack bit/byte specified fields into a buffer accordinging
|
||||
to a database description, uses cProtocolEntityNav to navigate the DB
|
||||
definition
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "StdAfx.h"
|
||||
#include "DataPacker.h"
|
||||
|
||||
#include "CoreDatabase.h"
|
||||
#include "DB2Utilities.h"
|
||||
|
||||
#include <climits>
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
/*=========================================================================*/
|
||||
// cDataPacker Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
cDataPacker (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Constructor
|
||||
|
||||
PARAMETERS:
|
||||
db [ I ] - Database to use
|
||||
key [ I ] - Key into protocol entity table
|
||||
fields [ I ] - Fields to pack into buffer
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cDataPacker::cDataPacker(
|
||||
const cCoreDatabase & db,
|
||||
const std::vector <ULONG> & key,
|
||||
const std::list <sUnpackedField> & fields )
|
||||
: cProtocolEntityNav( db ),
|
||||
mKey( key ),
|
||||
mbValuesOnly( true ),
|
||||
mProcessedFields( 0 ),
|
||||
mbPacked( false )
|
||||
{
|
||||
// Initialize internal buffer
|
||||
memset( &mBuffer[0], 0, (SIZE_T)MAX_SHARED_BUFFER_SIZE );
|
||||
|
||||
// Compute bits left in buffer
|
||||
ULONG bits = MAX_SHARED_BUFFER_SIZE * BITS_PER_BYTE;
|
||||
if (mKey.size() > 0)
|
||||
{
|
||||
eDB2EntityType et = (eDB2EntityType)mKey[0];
|
||||
bits = DB2GetMaxBufferSize( et ) * BITS_PER_BYTE;
|
||||
}
|
||||
|
||||
// Setup the bit packer
|
||||
mBitsy.SetData( mBuffer, bits );
|
||||
|
||||
// Copy fields/set value only flag
|
||||
std::list <sUnpackedField>::const_iterator pIter = fields.begin();
|
||||
while (pIter != fields.end())
|
||||
{
|
||||
if (pIter->mName.size() > 0)
|
||||
{
|
||||
mbValuesOnly = false;
|
||||
}
|
||||
|
||||
mFields.push_back( *pIter );
|
||||
pIter++;
|
||||
}
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
~cDataPacker (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Destructor
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cDataPacker::~cDataPacker()
|
||||
{
|
||||
// Ask bit packer to release data
|
||||
mBitsy.ReleaseData();
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
Pack (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Pack the buffer
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cDataPacker::Pack()
|
||||
{
|
||||
// Process (pack) the protocol entity
|
||||
if (mbPacked == false)
|
||||
{
|
||||
mbPacked = ProcessEntity( mKey );
|
||||
if (mbPacked == false)
|
||||
{
|
||||
// Failed due to no structure ID?
|
||||
if (mEntity.IsValid() == true && mEntity.mStructID == -1)
|
||||
{
|
||||
// Yes, for us that means instant success (no payload to pack)
|
||||
mbPacked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mbPacked;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetBuffer (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Get packed buffer contents
|
||||
|
||||
PARAMETERS:
|
||||
bufferLen [ O ] - Length of packed buffer (in bytes)
|
||||
|
||||
RETURN VALUE:
|
||||
const BYTE * - Packed buffer (0 upon error)
|
||||
===========================================================================*/
|
||||
const BYTE * cDataPacker::GetBuffer( ULONG & bufferLen )
|
||||
{
|
||||
if (mbPacked == false)
|
||||
{
|
||||
bufferLen = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Payload size in bytes
|
||||
bufferLen = mBitsy.GetTotalBitsWritten() + BITS_PER_BYTE - 1;
|
||||
bufferLen /= BITS_PER_BYTE;
|
||||
|
||||
// Payload is our buffer
|
||||
const BYTE * pBuffer = 0;
|
||||
if (bufferLen > 0)
|
||||
{
|
||||
pBuffer = (const BYTE *)&mBuffer[0];
|
||||
}
|
||||
|
||||
return pBuffer;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
LoadValues (Static Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Load values by parsing a 'summary' string of values, an example of
|
||||
which would be:
|
||||
|
||||
0 1 100 "Foo Foo Foo" 15 -1
|
||||
|
||||
PARAMETERS:
|
||||
vals [ I ] - Value string
|
||||
|
||||
RETURN VALUE:
|
||||
std::list <sUnpackedField>
|
||||
===========================================================================*/
|
||||
std::list <sUnpackedField> cDataPacker::LoadValues( const std::string & vals )
|
||||
{
|
||||
std::list <sUnpackedField> retList;
|
||||
if (vals.size() <= 0)
|
||||
{
|
||||
return retList;
|
||||
}
|
||||
|
||||
std::vector <std::string> tokens;
|
||||
ParseCommandLine( vals, tokens );
|
||||
|
||||
std::string name = "";
|
||||
std::string val = "";
|
||||
|
||||
std::vector <std::string>::const_iterator pIter = tokens.begin();
|
||||
while (pIter != tokens.end())
|
||||
{
|
||||
val = *pIter++;
|
||||
|
||||
sUnpackedField entry( name, val );
|
||||
retList.push_back( entry );
|
||||
}
|
||||
|
||||
return retList;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
LoadValues (Static Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Load values by parsing a vector of string values, an example of
|
||||
which would be:
|
||||
|
||||
[0] 0
|
||||
[1] 1
|
||||
[2] 100
|
||||
[3] "Foo Foo Foo"
|
||||
[4] 15
|
||||
[5] -1
|
||||
|
||||
PARAMETERS:
|
||||
vals [ I ] - Vector of values
|
||||
startIndex [ I ] - Where in above vector values start
|
||||
|
||||
RETURN VALUE:
|
||||
std::list <sUnpackedField>
|
||||
===========================================================================*/
|
||||
std::list <sUnpackedField> cDataPacker::LoadValues(
|
||||
std::vector <std::string> & vals,
|
||||
ULONG startIndex )
|
||||
{
|
||||
std::list <sUnpackedField> retList;
|
||||
|
||||
ULONG sz = (ULONG)vals.size();
|
||||
if (startIndex >= sz)
|
||||
{
|
||||
return retList;
|
||||
}
|
||||
|
||||
std::string name = "";
|
||||
std::string val = "";
|
||||
|
||||
for (ULONG v = startIndex; v < sz; v++)
|
||||
{
|
||||
val = vals[v];
|
||||
|
||||
sUnpackedField entry( name, val );
|
||||
retList.push_back( entry );
|
||||
}
|
||||
|
||||
return retList;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetLastValue (Internal Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Working from the back of the current value list find and return the
|
||||
value for the specified field ID as a LONGLONG (field type must have
|
||||
been able to fit in a LONGLONG for a value to be stored in value list
|
||||
and thus returned)
|
||||
|
||||
PARAMETERS:
|
||||
fieldID [ I ] - Field ID we are looking for
|
||||
val [ O ] - The value
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cDataPacker::GetLastValue(
|
||||
ULONG fieldID,
|
||||
LONGLONG & val )
|
||||
{
|
||||
// Assume failure
|
||||
bool bRC = false;
|
||||
|
||||
std::list < std::pair <ULONG, LONGLONG> >::reverse_iterator pValues;
|
||||
pValues = mValues.rbegin();
|
||||
while (pValues != mValues.rend())
|
||||
{
|
||||
std::pair <ULONG, LONGLONG> & entry = *pValues;
|
||||
if (entry.first == fieldID)
|
||||
{
|
||||
val = entry.second;
|
||||
|
||||
// Success!
|
||||
bRC = true;
|
||||
break;
|
||||
}
|
||||
|
||||
pValues++;
|
||||
}
|
||||
|
||||
return bRC;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetValueString (Internal Method)
|
||||
|
||||
DESCRIPTION:
|
||||
For the given field return the (input) value string
|
||||
|
||||
PARAMETERS:
|
||||
field [ I ] - The field being processed
|
||||
fieldName [ I ] - Partial (or fully qualified) field name
|
||||
pValueString [ O ] - Value string
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cDataPacker::GetValueString(
|
||||
const sDB2Field & field,
|
||||
const std::string & fieldName,
|
||||
LPCSTR & pValueString )
|
||||
{
|
||||
// Assume failure
|
||||
pValueString = 0;
|
||||
|
||||
// Create fully qualified field name
|
||||
std::string fullName = GetFullFieldName( fieldName );
|
||||
|
||||
std::vector <sUnpackedField>::const_iterator pVals = mFields.begin();
|
||||
while (pVals != mFields.end())
|
||||
{
|
||||
const std::string & inName = pVals->mName;
|
||||
if (fieldName == inName || fullName == inName)
|
||||
{
|
||||
pValueString = (LPCSTR)pVals->mValueString.c_str();
|
||||
break;
|
||||
}
|
||||
|
||||
pVals++;
|
||||
}
|
||||
|
||||
// Value provided?
|
||||
if (pValueString == 0)
|
||||
{
|
||||
// No, are we in value only mode?
|
||||
if (mbValuesOnly == true)
|
||||
{
|
||||
if (mProcessedFields < (ULONG)mFields.size())
|
||||
{
|
||||
sUnpackedField & upf = mFields[mProcessedFields++];
|
||||
|
||||
// Set field name (partial)
|
||||
upf.mName = fieldName;
|
||||
|
||||
// Grab field value
|
||||
pValueString = (LPCSTR)upf.mValueString.c_str();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Value provided?
|
||||
if (pValueString == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Meaningful value provided?
|
||||
if (pValueString[0] == 0)
|
||||
{
|
||||
// No value provided for field? Is it a string?
|
||||
if (field.mType == eDB2_FIELD_STD)
|
||||
{
|
||||
if ( (field.mTypeVal != eDB2_FIELD_STDTYPE_STRING_A)
|
||||
&& (field.mTypeVal != eDB2_FIELD_STDTYPE_STRING_U)
|
||||
&& (field.mTypeVal != eDB2_FIELD_STDTYPE_STRING_U8)
|
||||
&& (field.mTypeVal != eDB2_FIELD_STDTYPE_STRING_ANT)
|
||||
&& (field.mTypeVal != eDB2_FIELD_STDTYPE_STRING_UNT)
|
||||
&& (field.mTypeVal != eDB2_FIELD_STDTYPE_STRING_U8NT) )
|
||||
{
|
||||
// No, unable to proceed
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
PackString (Internal Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Pack the string (described by the given arguments) into the buffer
|
||||
|
||||
PARAMETERS:
|
||||
numChars [ I ] - Number of characters to pack (0 = NULL terminated)
|
||||
pStr [ I ] - String to pack
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cDataPacker::PackString(
|
||||
ULONG numChars,
|
||||
LPCSTR pStr )
|
||||
{
|
||||
// Sanity check string pointer
|
||||
if (pStr == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Assume success
|
||||
bool bOK = true;
|
||||
|
||||
// Convert native string type to desired output type
|
||||
const BYTE * pTmp = (const BYTE *)pStr;
|
||||
|
||||
// Have we reached the practical end of a fixed length string?
|
||||
ULONG numBytes = 0;
|
||||
|
||||
numBytes = (ULONG)strlen( (LPCSTR)pTmp );
|
||||
if (numChars == 0)
|
||||
{
|
||||
// We pack the string plus the NULL character
|
||||
numChars = (ULONG)strlen( (LPCSTR)pTmp ) + 1;
|
||||
}
|
||||
|
||||
// String size too long?
|
||||
if (numBytes > numChars)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Pack the string one byte at a time
|
||||
for (ULONG c = 0; c < numChars; c++)
|
||||
{
|
||||
BYTE val = 0;
|
||||
if (c < numBytes)
|
||||
{
|
||||
val = pTmp[c];
|
||||
}
|
||||
|
||||
DWORD rc = mBitsy.Set( BITS_PER_BYTE, val );
|
||||
if (rc != NO_ERROR)
|
||||
{
|
||||
bOK = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return bOK;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
ProcessField (Internal Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Process the given field (described by the given arguments) by packing
|
||||
the value into the buffer
|
||||
|
||||
PARAMETERS:
|
||||
pField [ I ] - The field being processed
|
||||
fieldName [ I ] - Field name (partial)
|
||||
arrayIndex [ I ] - Not used
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cDataPacker::ProcessField(
|
||||
const sDB2Field * pField,
|
||||
const std::string & fieldName,
|
||||
LONGLONG /* arrayIndex */ )
|
||||
{
|
||||
// Assume failure
|
||||
bool bOK = false;
|
||||
if (pField == 0)
|
||||
{
|
||||
return bOK;
|
||||
}
|
||||
|
||||
// Find given value for field
|
||||
LPCSTR pVal = 0;
|
||||
bool bVal = GetValueString( *pField, fieldName, pVal );
|
||||
if (bVal == false)
|
||||
{
|
||||
return bOK;
|
||||
}
|
||||
|
||||
// Grab field ID
|
||||
ULONG id = pField->mID;
|
||||
|
||||
// What type is this field?
|
||||
switch (pField->mType)
|
||||
{
|
||||
case eDB2_FIELD_STD:
|
||||
{
|
||||
// Standard field, what kind?
|
||||
eDB2StdFieldType ft = (eDB2StdFieldType)pField->mTypeVal;
|
||||
switch (ft)
|
||||
{
|
||||
// Field is a boolean (0/1, false/true)/8-bit unsigned integer
|
||||
case eDB2_FIELD_STDTYPE_BOOL:
|
||||
case eDB2_FIELD_STDTYPE_UINT8:
|
||||
{
|
||||
// We pack as a UCHAR
|
||||
UCHAR val = 0;
|
||||
bool bVal = ::FromString( pVal, val );
|
||||
if (bVal == true)
|
||||
{
|
||||
if (ft == eDB2_FIELD_STDTYPE_BOOL && val > 1)
|
||||
{
|
||||
val = 1;
|
||||
}
|
||||
|
||||
DWORD rc = mBitsy.Set( pField->mSize, val );
|
||||
if (rc == NO_ERROR)
|
||||
{
|
||||
// Success!
|
||||
std::pair <ULONG, LONGLONG> entry( id, (LONGLONG)val );
|
||||
mValues.push_back( entry );
|
||||
bOK = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// Field is 8-bit signed integer
|
||||
case eDB2_FIELD_STDTYPE_INT8:
|
||||
{
|
||||
// We pack as a CHAR
|
||||
CHAR val = 0;
|
||||
bool bVal = ::FromString( pVal, val );
|
||||
if (bVal == true)
|
||||
{
|
||||
DWORD rc = mBitsy.Set( pField->mSize, val );
|
||||
if (rc == NO_ERROR)
|
||||
{
|
||||
// Success!
|
||||
std::pair <ULONG, LONGLONG> entry( id, (LONGLONG)val );
|
||||
mValues.push_back( entry );
|
||||
bOK = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// Field is 16-bit signed integer
|
||||
case eDB2_FIELD_STDTYPE_INT16:
|
||||
{
|
||||
// We pack as a SHORT
|
||||
SHORT val = 0;
|
||||
bool bVal = ::FromString( pVal, val );
|
||||
if (bVal == true)
|
||||
{
|
||||
DWORD rc = mBitsy.Set( pField->mSize, val );
|
||||
if (rc == NO_ERROR)
|
||||
{
|
||||
// Success!
|
||||
std::pair <ULONG, LONGLONG> entry( id, (LONGLONG)val );
|
||||
mValues.push_back( entry );
|
||||
bOK = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// Field is 16-bit unsigned integer
|
||||
case eDB2_FIELD_STDTYPE_UINT16:
|
||||
{
|
||||
// We pack as a USHORT
|
||||
USHORT val = 0;
|
||||
bool bVal = ::FromString( pVal, val );
|
||||
if (bVal == true)
|
||||
{
|
||||
DWORD rc = mBitsy.Set( pField->mSize, val );
|
||||
if (rc == NO_ERROR)
|
||||
{
|
||||
// Success!
|
||||
std::pair <ULONG, LONGLONG> entry( id, (LONGLONG)val );
|
||||
mValues.push_back( entry );
|
||||
bOK = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// Field is 32-bit signed integer
|
||||
case eDB2_FIELD_STDTYPE_INT32:
|
||||
{
|
||||
// We pack as a LONG
|
||||
LONG val = 0;
|
||||
bool bVal = ::FromString( pVal, val );
|
||||
if (bVal == true)
|
||||
{
|
||||
DWORD rc = mBitsy.Set( pField->mSize, val );
|
||||
if (rc == NO_ERROR)
|
||||
{
|
||||
// Success!
|
||||
std::pair <ULONG, LONGLONG> entry( id, (LONGLONG)val );
|
||||
mValues.push_back( entry );
|
||||
bOK = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// Field is 32-bit unsigned integer
|
||||
case eDB2_FIELD_STDTYPE_UINT32:
|
||||
{
|
||||
// We pack as a ULONG
|
||||
ULONG val = 0;
|
||||
bool bVal = ::FromString( pVal, val );
|
||||
if (bVal == true)
|
||||
{
|
||||
DWORD rc = mBitsy.Set( pField->mSize, val );
|
||||
if (rc == NO_ERROR)
|
||||
{
|
||||
// Success!
|
||||
std::pair <ULONG, LONGLONG> entry( id, (LONGLONG)val );
|
||||
mValues.push_back( entry );
|
||||
bOK = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// Field is 64-bit signed integer
|
||||
case eDB2_FIELD_STDTYPE_INT64:
|
||||
{
|
||||
// We pack as a LONGLONG
|
||||
LONGLONG val = 0;
|
||||
bool bVal = ::FromString( pVal, val );
|
||||
if (bVal == true)
|
||||
{
|
||||
DWORD rc = mBitsy.Set( pField->mSize, val );
|
||||
if (rc == NO_ERROR)
|
||||
{
|
||||
// Success!
|
||||
std::pair <ULONG, LONGLONG> entry( id, val );
|
||||
mValues.push_back( entry );
|
||||
bOK = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// Field is 64-bit unsigned integer
|
||||
case eDB2_FIELD_STDTYPE_UINT64:
|
||||
{
|
||||
// We pack as a ULONGLONG
|
||||
ULONGLONG val = 0;
|
||||
bool bVal = ::FromString( pVal, val );
|
||||
if (bVal == true)
|
||||
{
|
||||
DWORD rc = mBitsy.Set( pField->mSize, val );
|
||||
if (rc == NO_ERROR)
|
||||
{
|
||||
// Success!
|
||||
if (val <= LLONG_MAX)
|
||||
{
|
||||
std::pair <ULONG, LONGLONG> entry( id, (LONGLONG)val );
|
||||
mValues.push_back( entry );
|
||||
}
|
||||
|
||||
bOK = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// ANSI/UNICODE strings
|
||||
case eDB2_FIELD_STDTYPE_STRING_A:
|
||||
case eDB2_FIELD_STDTYPE_STRING_U:
|
||||
case eDB2_FIELD_STDTYPE_STRING_ANT:
|
||||
case eDB2_FIELD_STDTYPE_STRING_UNT:
|
||||
{
|
||||
// Set the character size
|
||||
ULONG charSz = sizeof(CHAR);
|
||||
if ( (ft == eDB2_FIELD_STDTYPE_STRING_U)
|
||||
|| (ft == eDB2_FIELD_STDTYPE_STRING_UNT) )
|
||||
{
|
||||
charSz = sizeof(USHORT);
|
||||
}
|
||||
|
||||
// Compute the number of characters?
|
||||
ULONG numChars = 0;
|
||||
if ( (ft == eDB2_FIELD_STDTYPE_STRING_A)
|
||||
|| (ft == eDB2_FIELD_STDTYPE_STRING_U) )
|
||||
{
|
||||
numChars = (pField->mSize / BITS_PER_BYTE) / charSz;
|
||||
}
|
||||
|
||||
// Pack the string
|
||||
bOK = PackString( numChars, pVal );
|
||||
}
|
||||
break;
|
||||
|
||||
// UTF-8 strings
|
||||
case eDB2_FIELD_STDTYPE_STRING_U8:
|
||||
case eDB2_FIELD_STDTYPE_STRING_U8NT:
|
||||
{
|
||||
// Unsupported in the Linux adaptation
|
||||
bOK = false;
|
||||
}
|
||||
break;
|
||||
|
||||
// Field is 32-bit floating point value
|
||||
case eDB2_FIELD_STDTYPE_FLOAT32:
|
||||
{
|
||||
// We pack as a ULONG
|
||||
FLOAT val = (float)atof( (LPCSTR)pVal );
|
||||
ULONG * pTmp = (ULONG *)&val;
|
||||
|
||||
DWORD rc = mBitsy.Set( pField->mSize, *pTmp );
|
||||
if (rc == NO_ERROR)
|
||||
{
|
||||
// Success!
|
||||
bOK = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// Field is 64-bit floating point value
|
||||
case eDB2_FIELD_STDTYPE_FLOAT64:
|
||||
{
|
||||
// We pack as a ULONGLONG
|
||||
double val = atof( (LPCSTR)pVal );
|
||||
ULONGLONG * pTmp = (ULONGLONG *)&val;
|
||||
|
||||
DWORD rc = mBitsy.Set( pField->mSize, *pTmp );
|
||||
if (rc == NO_ERROR)
|
||||
{
|
||||
// Success!
|
||||
bOK = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
bOK = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case eDB2_FIELD_ENUM_UNSIGNED:
|
||||
{
|
||||
// We pack as a ULONG
|
||||
ULONG val = 0;
|
||||
bool bVal = ::FromString( pVal, val );
|
||||
if (bVal == true)
|
||||
{
|
||||
DWORD rc = mBitsy.Set( pField->mSize, val );
|
||||
if (rc == NO_ERROR)
|
||||
{
|
||||
// Success!
|
||||
std::pair <ULONG, LONGLONG> entry( id, (LONGLONG)val );
|
||||
mValues.push_back( entry );
|
||||
bOK = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case eDB2_FIELD_ENUM_SIGNED:
|
||||
{
|
||||
// We pack as a LONG
|
||||
LONG val = 0;
|
||||
bool bVal = ::FromString( pVal, val );
|
||||
if (bVal == true)
|
||||
{
|
||||
DWORD rc = mBitsy.Set( pField->mSize, val );
|
||||
if (rc == NO_ERROR)
|
||||
{
|
||||
// Success!
|
||||
std::pair <ULONG, LONGLONG> entry( id, (LONGLONG)val );
|
||||
mValues.push_back( entry );
|
||||
bOK = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
bOK = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return bOK;
|
||||
}
|
|
@ -0,0 +1,216 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
DataPacker.h
|
||||
|
||||
DESCRIPTION:
|
||||
Declaration of sUnpackedField and cDataPacker
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
sUnpackedField
|
||||
Structure to represent a single unpacked (input) field - i.e. the
|
||||
field value as a string and an optional field name (either fully
|
||||
qualified) or partial
|
||||
|
||||
cDataPacker
|
||||
Class to pack bit/byte specified fields into a buffer accordinging
|
||||
to a database description, uses cProtocolEntityNav to navigate the DB
|
||||
definition
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "CoreDatabase.h"
|
||||
#include "CoreUtilities.h"
|
||||
#include "BitPacker.h"
|
||||
#include "SharedBuffer.h"
|
||||
#include "ProtocolEntityNav.h"
|
||||
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sUnpackedField
|
||||
//
|
||||
// Structure to represent an unpacked (input) field
|
||||
/*=========================================================================*/
|
||||
struct sUnpackedField
|
||||
{
|
||||
public:
|
||||
// (Inline) Constructor - default
|
||||
sUnpackedField()
|
||||
: mName( "" ),
|
||||
mValueString( "" )
|
||||
{ };
|
||||
|
||||
// (Inline) Constructor - parameterized
|
||||
sUnpackedField(
|
||||
const std::string & name,
|
||||
const std::string & valueStr )
|
||||
: mName( name ),
|
||||
mValueString( valueStr )
|
||||
{ };
|
||||
|
||||
/* Field value as a string */
|
||||
std::string mValueString;
|
||||
|
||||
/* Name of field */
|
||||
std::string mName;
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Class cDataPacker
|
||||
// Class to pack bit/byte specified fields into a buffer
|
||||
/*=========================================================================*/
|
||||
class cDataPacker : public cProtocolEntityNav
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
cDataPacker(
|
||||
const cCoreDatabase & db,
|
||||
const std::vector <ULONG> & key,
|
||||
const std::list <sUnpackedField> & fields );
|
||||
|
||||
// Destructor
|
||||
virtual ~cDataPacker();
|
||||
|
||||
// Pack the buffer
|
||||
virtual bool Pack();
|
||||
|
||||
// Get packed buffer contents
|
||||
const BYTE * GetBuffer( ULONG & bufferLen );
|
||||
|
||||
// Return the results of packing as an allocated shared buffer
|
||||
sSharedBuffer * GetDiagBuffer( bool bNVRead );
|
||||
|
||||
// Load values by parsing a 'summary' string of values
|
||||
static std::list <sUnpackedField> LoadValues( const std::string & vals );
|
||||
|
||||
// Load values by parsing a vector of string values
|
||||
static std::list <sUnpackedField> LoadValues(
|
||||
std::vector <std::string> & vals,
|
||||
ULONG startIndex );
|
||||
|
||||
protected:
|
||||
// Working from the back of the current value list find
|
||||
// and return the value for the specified field ID as a
|
||||
// LONGLONG (field type must be able to fit)
|
||||
virtual bool GetLastValue(
|
||||
ULONG fieldID,
|
||||
LONGLONG & val );
|
||||
|
||||
// For the given field return the (input) value string
|
||||
virtual bool GetValueString(
|
||||
const sDB2Field & field,
|
||||
const std::string & fieldName,
|
||||
LPCSTR & pValueString );
|
||||
|
||||
// Pack the string (described by the given arguments) into the buffer
|
||||
virtual bool PackString(
|
||||
ULONG numChars,
|
||||
LPCSTR pStr );
|
||||
|
||||
// Process the given field
|
||||
virtual bool ProcessField(
|
||||
const sDB2Field * pField,
|
||||
const std::string & fieldName,
|
||||
LONGLONG arrayIndex = -1 );
|
||||
|
||||
// (Inline) Get current working offset
|
||||
virtual ULONG GetOffset()
|
||||
{
|
||||
return mBitsy.GetNumBitsWritten();
|
||||
};
|
||||
|
||||
// (Inline) Set current working offset
|
||||
virtual bool SetOffset( ULONG offset )
|
||||
{
|
||||
mBitsy.SetOffset( offset );
|
||||
return true;
|
||||
};
|
||||
|
||||
// (Inline) Get current navigation order
|
||||
virtual bool GetLSBMode()
|
||||
{
|
||||
return mBitsy.GetLSBMode();
|
||||
};
|
||||
|
||||
// (Inline) Set current navigation order
|
||||
virtual bool SetLSBMode( bool bLSB )
|
||||
{
|
||||
// Assume success
|
||||
bool bOK = true;
|
||||
if (bLSB != GetLSBMode())
|
||||
{
|
||||
if ((GetOffset() % BITS_PER_BYTE) != 0)
|
||||
{
|
||||
// We need to be on a byte boundary
|
||||
bOK = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
mBitsy.SetLSBMode( bLSB );
|
||||
}
|
||||
}
|
||||
|
||||
return bOK;
|
||||
};
|
||||
|
||||
/* Entity key */
|
||||
std::vector <ULONG> mKey;
|
||||
|
||||
/* The underlying bit packer */
|
||||
cBitPacker mBitsy;
|
||||
|
||||
/* The vector of fields */
|
||||
std::vector <sUnpackedField> mFields;
|
||||
|
||||
/* Are we operating in value only mode, i.e. no field names given? */
|
||||
bool mbValuesOnly;
|
||||
ULONG mProcessedFields;
|
||||
|
||||
/* Raw field values associated with field ID */
|
||||
std::list < std::pair <ULONG, LONGLONG> > mValues;
|
||||
|
||||
/* Internal working buffer */
|
||||
BYTE mBuffer[MAX_SHARED_BUFFER_SIZE];
|
||||
|
||||
/* Did we successfully pack the buffer? */
|
||||
bool mbPacked;
|
||||
};
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,399 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
DataParser.h
|
||||
|
||||
DESCRIPTION:
|
||||
Declaration of sParsedField and cDataParser
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
sParsedField
|
||||
Structure to represent a single parsed field (field ID, offset,
|
||||
size, value, name, etc.)
|
||||
|
||||
cDataParser
|
||||
Class to parse a buffer into bit/byte specified fields accordinging
|
||||
to a database description, uses cProtocolEntityNav to navigate the DB
|
||||
definition
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "CoreDatabase.h"
|
||||
#include "BitParser.h"
|
||||
#include "ProtocolEntityNav.h"
|
||||
#include "ProtocolBuffer.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
class cColorItem;
|
||||
|
||||
/*=========================================================================*/
|
||||
// Union uFields
|
||||
//
|
||||
// Union to represent the data of a parsed field
|
||||
/*=========================================================================*/
|
||||
union uFields
|
||||
{
|
||||
CHAR mS8;
|
||||
UCHAR mU8;
|
||||
SHORT mS16;
|
||||
USHORT mU16;
|
||||
LONG mS32;
|
||||
ULONG mU32;
|
||||
FLOAT mFP32;
|
||||
LONGLONG mS64;
|
||||
ULONGLONG mU64;
|
||||
double mFP64;
|
||||
LPCSTR mpAStr;
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sParsedField
|
||||
//
|
||||
// Structure to represent a parsed field
|
||||
/*=========================================================================*/
|
||||
struct sParsedField
|
||||
{
|
||||
// Give data parser full access
|
||||
friend class cDataParser;
|
||||
|
||||
public:
|
||||
// (Inline) Constructor - default
|
||||
sParsedField()
|
||||
: mField(),
|
||||
mOffset( 0 ),
|
||||
mValueString( "" ),
|
||||
mName( "" ),
|
||||
mbValid( false )
|
||||
{
|
||||
memset( (PVOID)&mValue, 0, sizeof( mValue ) );
|
||||
};
|
||||
|
||||
// Constructor - parameterized
|
||||
sParsedField(
|
||||
const cCoreDatabase & db,
|
||||
const sDB2Field * pField,
|
||||
const std::string & name,
|
||||
cBitParser & bp,
|
||||
bool bGenStrings = true );
|
||||
|
||||
// (Inline) Get the raw value string (i.e. unmapped enums)
|
||||
std::string GetRawValueString() const
|
||||
{
|
||||
std::string retStr = "";
|
||||
std::ostringstream tmp;
|
||||
|
||||
if (IsValid() == true)
|
||||
{
|
||||
if (mField.mType == eDB2_FIELD_ENUM_UNSIGNED)
|
||||
{
|
||||
if (mField.mbHex == false)
|
||||
{
|
||||
tmp << mValue.mU32;
|
||||
retStr = tmp.str();
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp << std::ios_base::hex << std::ios_base::uppercase
|
||||
<< std::ios_base::showbase << mValue.mU32;
|
||||
retStr = tmp.str();
|
||||
}
|
||||
}
|
||||
else if (mField.mType == eDB2_FIELD_ENUM_SIGNED)
|
||||
{
|
||||
if (mField.mbHex == false)
|
||||
{
|
||||
tmp << mValue.mS32;
|
||||
retStr = tmp.str();
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp << std::ios_base::hex << std::ios_base::uppercase
|
||||
<< std::ios_base::showbase << mValue.mU32;
|
||||
retStr = tmp.str();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
retStr = mValueString;
|
||||
}
|
||||
}
|
||||
|
||||
return retStr;
|
||||
};
|
||||
|
||||
// (Inline) Get field size in bits
|
||||
ULONG GetSize() const
|
||||
{
|
||||
ULONG sz = 0;
|
||||
if (mField.IsValid() == true)
|
||||
{
|
||||
sz = mField.mSize;
|
||||
}
|
||||
|
||||
return sz;
|
||||
};
|
||||
|
||||
// (Inline) Is this field a string type?
|
||||
bool IsString() const
|
||||
{
|
||||
bool bStr = false;
|
||||
if (IsValid() == false)
|
||||
{
|
||||
return bStr;
|
||||
}
|
||||
|
||||
if (mField.mType == eDB2_FIELD_STD)
|
||||
{
|
||||
switch ((eDB2StdFieldType)mField.mTypeVal)
|
||||
{
|
||||
case eDB2_FIELD_STDTYPE_STRING_A:
|
||||
case eDB2_FIELD_STDTYPE_STRING_U:
|
||||
case eDB2_FIELD_STDTYPE_STRING_U8:
|
||||
case eDB2_FIELD_STDTYPE_STRING_ANT:
|
||||
case eDB2_FIELD_STDTYPE_STRING_UNT:
|
||||
case eDB2_FIELD_STDTYPE_STRING_U8NT:
|
||||
bStr = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return bStr;
|
||||
};
|
||||
|
||||
// (Inline) Is this object valid?
|
||||
bool IsValid() const
|
||||
{
|
||||
return mbValid;
|
||||
};
|
||||
|
||||
/* Field definition */
|
||||
sDB2Field mField;
|
||||
|
||||
/* Bit offset (from start of payload) */
|
||||
ULONG mOffset;
|
||||
|
||||
/* Field value */
|
||||
uFields mValue;
|
||||
|
||||
/* Field value as a string */
|
||||
std::string mValueString;
|
||||
|
||||
/* Partially qualified name of field */
|
||||
std::string mName;
|
||||
|
||||
protected:
|
||||
// Parse a string
|
||||
bool ParseString(
|
||||
ULONG numChars,
|
||||
cBitParser & bp );
|
||||
|
||||
/* Is this object valid? */
|
||||
bool mbValid;
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Class cParsedFieldNavigator
|
||||
//
|
||||
// Class to navigate/search parsed fields produced by the above
|
||||
/*=========================================================================*/
|
||||
class cParsedFieldNavigator
|
||||
{
|
||||
public:
|
||||
// (Inline) Constructor
|
||||
cParsedFieldNavigator( const std::vector <sParsedField> & pf )
|
||||
: mFields( pf ),
|
||||
mLastIDIndex( ULONG_MAX )
|
||||
{ };
|
||||
|
||||
// Get index of the (first) field that matches the field ID,
|
||||
// the search starts from the last success index returned by
|
||||
// a previous call to this method
|
||||
ULONG GetFieldIndex(
|
||||
ULONG fieldID,
|
||||
bool bLoop = false ) const;
|
||||
|
||||
// (Inline) Get index of the (first) field that matches the
|
||||
// given ID, the search starts from the provided index
|
||||
ULONG GetFieldIndexFrom(
|
||||
ULONG fieldID,
|
||||
ULONG startIndex,
|
||||
bool bLoop = false ) const
|
||||
{
|
||||
mLastIDIndex = startIndex;
|
||||
return GetFieldIndex( fieldID, bLoop );
|
||||
};
|
||||
|
||||
protected:
|
||||
/* The list of parsed fields */
|
||||
const std::vector <sParsedField> & mFields;
|
||||
|
||||
/* Index of last field we matched */
|
||||
mutable ULONG mLastIDIndex;
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Class cDataParser
|
||||
// Class to parse a buffer into bit/byte specified fields
|
||||
/*=========================================================================*/
|
||||
class cDataParser : public cProtocolEntityNav
|
||||
{
|
||||
public:
|
||||
// Constructor (protocol buffer)
|
||||
cDataParser(
|
||||
const cCoreDatabase & db,
|
||||
const sProtocolBuffer & buffer );
|
||||
|
||||
// Constructor (protocol buffer, entity key, and payload)
|
||||
cDataParser(
|
||||
const cCoreDatabase & db,
|
||||
const sProtocolBuffer & buffer,
|
||||
const std::vector <ULONG> & key,
|
||||
const BYTE * pData,
|
||||
ULONG dataLen );
|
||||
|
||||
// Destructor
|
||||
virtual ~cDataParser();
|
||||
|
||||
// Parse the data to a list of fields/summary text
|
||||
virtual bool Parse(
|
||||
bool bFieldStrings = true,
|
||||
bool bFieldNames = true );
|
||||
|
||||
// (Inline) Get the protocol entity name
|
||||
std::string GetEntityName() const
|
||||
{
|
||||
std::string retName = "?";
|
||||
if (mEntity.mpName != 0 && mEntity.mpName[0] != 0)
|
||||
{
|
||||
retName = mEntity.mpName;
|
||||
}
|
||||
|
||||
return retName;
|
||||
};
|
||||
|
||||
// (Inline) Get the parsed fields
|
||||
typedef std::vector <sParsedField> tParsedFields;
|
||||
const tParsedFields & GetFields() const
|
||||
{
|
||||
return mFields;
|
||||
};
|
||||
|
||||
protected:
|
||||
// Working from the back of the current field list find
|
||||
// and return the value for the specified field ID as a
|
||||
// LONGLONG (field type must be able to fit)
|
||||
virtual bool GetLastValue(
|
||||
ULONG fieldID,
|
||||
LONGLONG & val );
|
||||
|
||||
// Contiue navigation now that entity has been set?
|
||||
virtual bool ContinueNavigation();
|
||||
|
||||
// Process the given field
|
||||
virtual bool ProcessField(
|
||||
const sDB2Field * pField,
|
||||
const std::string & fieldName,
|
||||
LONGLONG arrayIndex = -1 );
|
||||
|
||||
// (Inline) Get current working offset
|
||||
virtual ULONG GetOffset()
|
||||
{
|
||||
return mBitsy.GetNumBitsParsed();
|
||||
};
|
||||
|
||||
// (Inline) Set current working offset
|
||||
virtual bool SetOffset( ULONG offset )
|
||||
{
|
||||
mBitsy.SetOffset( offset );
|
||||
return true;
|
||||
};
|
||||
|
||||
// (Inline) Get current navigation order
|
||||
virtual bool GetLSBMode()
|
||||
{
|
||||
return mBitsy.GetLSBMode();
|
||||
};
|
||||
|
||||
// (Inline) Set current navigation order
|
||||
virtual bool SetLSBMode( bool bLSB )
|
||||
{
|
||||
// Assume success
|
||||
bool bOK = true;
|
||||
if (bLSB != GetLSBMode())
|
||||
{
|
||||
if ((GetOffset() % BITS_PER_BYTE) != 0)
|
||||
{
|
||||
// We need to be on a byte boundary
|
||||
bOK = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
mBitsy.SetLSBMode( bLSB );
|
||||
}
|
||||
}
|
||||
|
||||
return bOK;
|
||||
};
|
||||
|
||||
// Handle special case processing for summary text generation
|
||||
virtual void HandleSpecialCases(
|
||||
std::string & args,
|
||||
std::string & fs );
|
||||
|
||||
/* Color item containing the data we are parsing */
|
||||
sProtocolBuffer mBuffer;
|
||||
|
||||
/* Entity key */
|
||||
std::vector <ULONG> mKey;
|
||||
|
||||
/* The underlying bit parser */
|
||||
cBitParser mBitsy;
|
||||
|
||||
/* The list of parsed fields */
|
||||
tParsedFields mFields;
|
||||
|
||||
/* Generate field value strings? */
|
||||
bool mbFieldStrings;
|
||||
|
||||
/* Did we successfully parse the buffer? */
|
||||
bool mbParsed;
|
||||
|
||||
/* Parsed field vector index of last instance of each field (by ID) */
|
||||
std::map <ULONG, ULONG> mFieldIndices;
|
||||
};
|
||||
|
|
@ -0,0 +1,443 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
Event.cpp
|
||||
|
||||
DESCRIPTION:
|
||||
Implementation of cEvent class
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
WaitOnMultipleEvents
|
||||
cEvent
|
||||
Functionality to mimic Windows events using UNIX pipes (enhanced
|
||||
somewhat to allow one to specify a DWORD value to pass through
|
||||
when signalling the event)
|
||||
|
||||
WARNING:
|
||||
This class is not designed to be thread safe
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "StdAfx.h"
|
||||
#include "Event.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
const DWORD READING = 0;
|
||||
const DWORD WRITING = 1;
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
WaitOnMultipleEvents (Free Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Wait for any of the events to be set and return the value
|
||||
|
||||
Note: If multiple events are set, only the event specified by
|
||||
eventIndex will be read from. Run this function again
|
||||
to get the next event.
|
||||
|
||||
PARAMETERS:
|
||||
events [ I ] - Vector of events which may be signaled
|
||||
timeoutMS [ I ] - Relative timeout length (in milliseconds)
|
||||
val [ O ] - Associated value upon success
|
||||
eventIndex [ O ] - Index of event which was signaled
|
||||
|
||||
RETURN VALUE:
|
||||
Return code
|
||||
positive for number of events set
|
||||
-ETIME on timeout
|
||||
negative errno value on failure
|
||||
===========================================================================*/
|
||||
int WaitOnMultipleEvents(
|
||||
std::vector <cEvent *> events,
|
||||
DWORD timeoutMS,
|
||||
DWORD & val,
|
||||
DWORD & eventIndex )
|
||||
{
|
||||
// Check internal pipes' status
|
||||
for (int index = 0; index < events.size(); index++)
|
||||
{
|
||||
int error = events[index]->mError;
|
||||
if (error != 0)
|
||||
{
|
||||
TRACE( "cEvent %d has error %d\n", index, error );
|
||||
return -error;
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize the FD set
|
||||
fd_set fds;
|
||||
FD_ZERO( &fds );
|
||||
|
||||
// Add each item to the FD set, keeping track of the largest,
|
||||
// which is used for select()
|
||||
int largestFD = 0;
|
||||
for (int index = 0; index < events.size(); index++)
|
||||
{
|
||||
int pipe = events[index]->mPipes[READING];
|
||||
FD_SET( pipe, &fds );
|
||||
|
||||
largestFD = std::max( pipe, largestFD );
|
||||
}
|
||||
|
||||
struct timeval timeOut;
|
||||
|
||||
// Add avoiding an overflow on (long)usec
|
||||
timeOut.tv_sec = timeoutMS / 1000l;
|
||||
timeOut.tv_usec = ( timeoutMS % 1000l ) * 1000l;
|
||||
|
||||
// Wait for activity on the pipes for the specified amount of time
|
||||
int rc = select( largestFD + 1, &fds, 0, 0, &timeOut );
|
||||
if (rc == -1)
|
||||
{
|
||||
TRACE( "WaitOnMultipleEvents error %d\n", errno );
|
||||
return -errno;
|
||||
}
|
||||
else if (rc == 0)
|
||||
{
|
||||
// No activity on the pipes
|
||||
return -ETIME;
|
||||
}
|
||||
|
||||
int numSignaled = rc;
|
||||
|
||||
// Only read from first pipe which was signaled
|
||||
int signaled = -1;
|
||||
for (int index = 0; index < events.size(); index++)
|
||||
{
|
||||
int pipe = events[index]->mPipes[READING];
|
||||
if (FD_ISSET( pipe, &fds ) != 0)
|
||||
{
|
||||
signaled = index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (signaled == -1)
|
||||
{
|
||||
// Odd, no one was signaled
|
||||
return -ENODATA;
|
||||
}
|
||||
|
||||
DWORD tempVal = 0;
|
||||
rc = events[signaled]->Read( tempVal );
|
||||
if (rc == 0)
|
||||
{
|
||||
// Success
|
||||
val = tempVal;
|
||||
eventIndex = signaled;
|
||||
return numSignaled;
|
||||
}
|
||||
else
|
||||
{
|
||||
// failure
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
/*=========================================================================*/
|
||||
// cEvent Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
cEvent (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Constructor
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cEvent::cEvent()
|
||||
: mError( 0 )
|
||||
{
|
||||
int rc = pipe( mPipes );
|
||||
if (rc != 0)
|
||||
{
|
||||
mError = errno;
|
||||
TRACE( "cEvent - Error %d creating pipe, %s\n",
|
||||
mError,
|
||||
strerror( mError ) );
|
||||
}
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
~cEvent (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Destructor
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cEvent::~cEvent()
|
||||
{
|
||||
// Check internal pipe status
|
||||
if (mError == 0)
|
||||
{
|
||||
Close();
|
||||
mError = EBADF;
|
||||
}
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
Close (Internal Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Close pipe
|
||||
|
||||
RETURN VALUE:
|
||||
Return code
|
||||
0 on success
|
||||
errno value on failure
|
||||
===========================================================================*/
|
||||
int cEvent::Close()
|
||||
{
|
||||
int retCode = 0;
|
||||
|
||||
int rc = close( mPipes[READING] );
|
||||
mPipes[READING] = -1;
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
retCode = errno;
|
||||
TRACE( "cEvent - Error %d deleting pipe[READING], %s\n",
|
||||
retCode,
|
||||
strerror( retCode ) );
|
||||
}
|
||||
|
||||
rc = close( mPipes[WRITING] );
|
||||
mPipes[WRITING] = -1;
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
retCode = errno;
|
||||
TRACE( "cEvent - Error %d deleting pipe[WRITING], %s\n",
|
||||
retCode,
|
||||
strerror( retCode ) );
|
||||
}
|
||||
|
||||
return retCode;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
Set (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Set/signal the event with the specified value
|
||||
|
||||
PARAMETERS:
|
||||
val [ I ] - Value to pass through with signal
|
||||
|
||||
RETURN VALUE:
|
||||
Return code
|
||||
0 on success
|
||||
errno value on failure
|
||||
===========================================================================*/
|
||||
int cEvent::Set( DWORD val )
|
||||
{
|
||||
// Check internal pipe status
|
||||
if (mError != 0)
|
||||
{
|
||||
return mError;
|
||||
}
|
||||
|
||||
PBYTE pWrite = (PBYTE)&val;
|
||||
|
||||
int writeSize = sizeof( DWORD );
|
||||
while (writeSize > 0)
|
||||
{
|
||||
int bytesWritten = write( mPipes[WRITING], pWrite, writeSize );
|
||||
if (bytesWritten == -1)
|
||||
{
|
||||
// Store error from write
|
||||
int writeErr = errno;
|
||||
|
||||
// First error?
|
||||
if (mError == 0)
|
||||
{
|
||||
// Yes, save the error
|
||||
mError = writeErr;
|
||||
}
|
||||
|
||||
// We cannot recover from this error
|
||||
Close();
|
||||
return writeErr;
|
||||
}
|
||||
|
||||
pWrite += bytesWritten;
|
||||
writeSize -= bytesWritten;
|
||||
}
|
||||
|
||||
// Success
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
Wait (Free Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Wait for the event to be signalled and return the read in value
|
||||
|
||||
PARAMETERS:
|
||||
timeoutMS [ I ] - Relative timeout length (in milliseconds)
|
||||
val [ O ] - Associated value upon success
|
||||
|
||||
RETURN VALUE:
|
||||
Return code
|
||||
0 on success
|
||||
ETIME on timeout
|
||||
errno value on failure
|
||||
===========================================================================*/
|
||||
int cEvent::Wait(
|
||||
DWORD timeoutMS,
|
||||
DWORD & val )
|
||||
{
|
||||
// Check internal pipe status
|
||||
if (mError != 0)
|
||||
{
|
||||
return mError;
|
||||
}
|
||||
|
||||
fd_set fds;
|
||||
FD_ZERO( &fds );
|
||||
FD_SET( mPipes[READING], &fds );
|
||||
|
||||
struct timeval timeOut;
|
||||
|
||||
// Add avoiding an overflow on (long)usec
|
||||
timeOut.tv_sec = timeoutMS / 1000l;
|
||||
timeOut.tv_usec = ( timeoutMS % 1000l ) * 1000l;
|
||||
|
||||
// Wait for activity on the pipe for the specified amount of time
|
||||
int rc = select( mPipes[READING] + 1, &fds, 0, 0, &timeOut );
|
||||
if (rc == -1)
|
||||
{
|
||||
// Store error from select
|
||||
int selectErr = errno;
|
||||
|
||||
// First error?
|
||||
if (mError == 0)
|
||||
{
|
||||
// Yes, save the error
|
||||
mError = selectErr;
|
||||
}
|
||||
|
||||
// We cannot recover from this error
|
||||
Close();
|
||||
return selectErr;
|
||||
}
|
||||
else if (rc == 0)
|
||||
{
|
||||
// No activity on the pipe
|
||||
return ETIME;
|
||||
}
|
||||
|
||||
return Read( val );
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
Clear (Free Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Read and discard all values currently in the pipe
|
||||
===========================================================================*/
|
||||
void cEvent::Clear()
|
||||
{
|
||||
DWORD unusedVal;
|
||||
int rc = 0;
|
||||
while (rc == 0)
|
||||
{
|
||||
rc = Wait( (DWORD)0, unusedVal );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
Read (Internal Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Read a DWORD from the pipe
|
||||
|
||||
RETURN VALUE:
|
||||
Return code
|
||||
0 on success
|
||||
errno value on failure
|
||||
===========================================================================*/
|
||||
int cEvent::Read( DWORD & val )
|
||||
{
|
||||
DWORD tempVal;
|
||||
PBYTE pRead = (PBYTE)&tempVal;
|
||||
|
||||
int readSize = sizeof( DWORD );
|
||||
while (readSize > 0)
|
||||
{
|
||||
int bytesRead = read( mPipes[READING], pRead, readSize );
|
||||
if (bytesRead <= 0)
|
||||
{
|
||||
// Store error from read
|
||||
int readErr = errno;
|
||||
if (readErr == 0)
|
||||
{
|
||||
// Hard error! This should NEVER happen for a pipe
|
||||
ASSERT( 0 );
|
||||
readErr = EBADF;
|
||||
}
|
||||
|
||||
// First error?
|
||||
if (mError == 0)
|
||||
{
|
||||
// Yes, store the error
|
||||
mError = readErr;
|
||||
}
|
||||
|
||||
// We cannot recover from this error
|
||||
Close();
|
||||
return readErr;
|
||||
}
|
||||
|
||||
pRead += bytesRead;
|
||||
readSize -= bytesRead;
|
||||
}
|
||||
|
||||
val = tempVal;
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
Event.h
|
||||
|
||||
DESCRIPTION:
|
||||
Declaration of cEvent class
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
WaitOnMultipleEvents
|
||||
cEvent
|
||||
Functionality to mimic Windows events using UNIX pipes (enhanced
|
||||
somewhat to allow one to specify a DWORD value to pass through
|
||||
when signalling the event)
|
||||
|
||||
WARNING:
|
||||
This class is not designed to be thread safe
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "StdAfx.h"
|
||||
#include <vector>
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Prototype
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class cEvent;
|
||||
|
||||
/*=========================================================================*/
|
||||
// Free methods
|
||||
/*=========================================================================*/
|
||||
|
||||
// Wait for any of the events to be set and return the value
|
||||
int WaitOnMultipleEvents(
|
||||
std::vector <cEvent *> events,
|
||||
DWORD timeoutMS,
|
||||
DWORD & val,
|
||||
DWORD & eventIndex );
|
||||
|
||||
/*=========================================================================*/
|
||||
// Class cEvent
|
||||
/*=========================================================================*/
|
||||
class cEvent
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
cEvent();
|
||||
|
||||
// Destructor
|
||||
~cEvent();
|
||||
|
||||
// Set/signal the event with the specified value
|
||||
int Set( DWORD val );
|
||||
|
||||
// Wait for the event to be signalled and return the read in value
|
||||
int Wait(
|
||||
DWORD timeoutMS,
|
||||
DWORD & val );
|
||||
|
||||
// Read and discard all values currently in the pipe
|
||||
void Clear();
|
||||
|
||||
protected:
|
||||
// Close pipe (used in errors or normal exit)
|
||||
int Close();
|
||||
|
||||
// Read from the pipe
|
||||
int Read( DWORD & val );
|
||||
|
||||
/* Internal error status */
|
||||
int mError;
|
||||
|
||||
/* Internal pipes */
|
||||
int mPipes[2];
|
||||
|
||||
// WaitOnMultipleEvents gets full access
|
||||
friend int WaitOnMultipleEvents(
|
||||
std::vector <cEvent *> events,
|
||||
DWORD timeoutMS,
|
||||
DWORD & val,
|
||||
DWORD & eventIndex );
|
||||
};
|
||||
|
|
@ -0,0 +1,304 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
HDLC.cpp
|
||||
|
||||
DESCRIPTION:
|
||||
Encode and decode asynchronous HDLC protocol packets as described
|
||||
by both the QUALCOMM download & SDIC (diagnostic) protocol documents
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
HDLCDecode()
|
||||
HDLCEncode()
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "StdAfx.h"
|
||||
#include "HDLC.h"
|
||||
#include "CRC.h"
|
||||
#include "SharedBuffer.h"
|
||||
#include "ProtocolServer.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
/* Async HDLC defines */
|
||||
const BYTE AHDLC_FLAG = 0x7e;
|
||||
const BYTE AHDLC_ESCAPE = 0x7d;
|
||||
const BYTE AHDLC_ESC_M = 0x20;
|
||||
|
||||
/*=========================================================================*/
|
||||
// Free Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
HDLCDecode (Free Method)
|
||||
|
||||
DESCRIPTION:
|
||||
HDLC decode the given buffer returning the results in an allocated buffer
|
||||
|
||||
PARAMETERS:
|
||||
pBuf [ I ] - The data buffer to decode
|
||||
|
||||
RETURN VALUE:
|
||||
sSharedBuffer * : The decoded buffer (allocated), 0 on error
|
||||
===========================================================================*/
|
||||
sSharedBuffer * HDLCDecode( sSharedBuffer * pBuf )
|
||||
{
|
||||
// The return buffer
|
||||
sSharedBuffer * pRet = 0;
|
||||
|
||||
// The has to be something to decode
|
||||
if (pBuf == 0 || pBuf->IsValid() == false)
|
||||
{
|
||||
return pRet;
|
||||
}
|
||||
|
||||
// Grab raw data from shared buffer
|
||||
const BYTE * pData = pBuf->GetBuffer();
|
||||
UINT sz = pBuf->GetSize();
|
||||
|
||||
// Is the first character a leading flag?
|
||||
if (pData[0] == AHDLC_FLAG)
|
||||
{
|
||||
pData++;
|
||||
sz--;
|
||||
}
|
||||
|
||||
// There must be at least four bytes (data, CRC, trailing flag)
|
||||
if (sz < 4)
|
||||
{
|
||||
return pRet;
|
||||
}
|
||||
|
||||
// The last character must be the trailing flag
|
||||
if (pData[sz - 1] == AHDLC_FLAG)
|
||||
{
|
||||
sz--;
|
||||
}
|
||||
else
|
||||
{
|
||||
return pRet;
|
||||
}
|
||||
|
||||
// Allocate the decode buffer
|
||||
PBYTE pDecoded = new BYTE[sz];
|
||||
if (pDecoded == 0)
|
||||
{
|
||||
return pRet;
|
||||
}
|
||||
|
||||
// Handle escaped characters and copy into decode buffer
|
||||
UINT encodeIndex = 0;
|
||||
UINT decodeIndex = 0;
|
||||
while (encodeIndex < sz)
|
||||
{
|
||||
BYTE b = pData[encodeIndex++];
|
||||
if (b == AHDLC_ESCAPE && encodeIndex < sz)
|
||||
{
|
||||
b = pData[encodeIndex++];
|
||||
b ^= AHDLC_ESC_M;
|
||||
}
|
||||
|
||||
pDecoded[decodeIndex++] = b;
|
||||
}
|
||||
|
||||
// Check CRC value
|
||||
if (CheckCRC( pDecoded, decodeIndex ) == false)
|
||||
{
|
||||
delete [] pDecoded;
|
||||
return pRet;
|
||||
}
|
||||
|
||||
// Adjust decode length down for CRC
|
||||
decodeIndex -= 2;
|
||||
|
||||
// ... and wrap up in a shared buffer
|
||||
pRet = new sSharedBuffer( decodeIndex, pDecoded, pBuf->GetType() );
|
||||
return pRet;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
HDLCEncode (Free Method)
|
||||
|
||||
DESCRIPTION:
|
||||
HDLC encode the given buffer returning the results in an allocated buffer
|
||||
|
||||
PARAMETERS:
|
||||
pBuf [ I ] - The data buffer to decode
|
||||
|
||||
RETURN VALUE:
|
||||
sSharedBuffer * : The decoded buffer (allocated), 0 on error
|
||||
===========================================================================*/
|
||||
sSharedBuffer * HDLCEncode( sSharedBuffer * pBuf )
|
||||
{
|
||||
// The return buffer
|
||||
sSharedBuffer * pRet = 0;
|
||||
|
||||
// The has to be something to decode
|
||||
if (pBuf == 0 || pBuf->IsValid() == false)
|
||||
{
|
||||
return pRet;
|
||||
}
|
||||
|
||||
// Grab raw data from shared buffer
|
||||
const BYTE * pData = pBuf->GetBuffer();
|
||||
UINT sz = pBuf->GetSize();
|
||||
|
||||
// Compute CRC
|
||||
USHORT CRC = CalculateCRC( pData, sz * 8 );
|
||||
|
||||
// Allocate the encode buffer
|
||||
PBYTE pEncoded = new BYTE[sz * 2 + 4];
|
||||
if (pEncoded == 0)
|
||||
{
|
||||
return pRet;
|
||||
}
|
||||
|
||||
// Add leading flag
|
||||
UINT encodeIndex = 0;
|
||||
pEncoded[encodeIndex++] = AHDLC_FLAG;
|
||||
|
||||
// Add data, escaping when necessary
|
||||
UINT decodeIndex = 0;
|
||||
while (decodeIndex < sz)
|
||||
{
|
||||
BYTE value = pData[decodeIndex++];
|
||||
if (value == AHDLC_FLAG || value == AHDLC_ESCAPE)
|
||||
{
|
||||
value ^= AHDLC_ESC_M;
|
||||
pEncoded[encodeIndex++] = AHDLC_ESCAPE;
|
||||
}
|
||||
|
||||
pEncoded[encodeIndex++] = value;
|
||||
}
|
||||
|
||||
// Byte order CRC
|
||||
BYTE byteOrderedCRC[2];
|
||||
byteOrderedCRC[0] = (BYTE)(CRC & 0x00ff);
|
||||
byteOrderedCRC[1] = (BYTE)(CRC >> 8);
|
||||
|
||||
// Add CRC
|
||||
UINT c = 0;
|
||||
while (c < 2)
|
||||
{
|
||||
BYTE value = byteOrderedCRC[c++];
|
||||
if (value == AHDLC_FLAG || value == AHDLC_ESCAPE)
|
||||
{
|
||||
value ^= AHDLC_ESC_M;
|
||||
pEncoded[encodeIndex++] = AHDLC_ESCAPE;
|
||||
}
|
||||
|
||||
pEncoded[encodeIndex++] = value;
|
||||
}
|
||||
|
||||
// Add trailing flag
|
||||
pEncoded[encodeIndex++] = AHDLC_FLAG;
|
||||
|
||||
// Wrap up in a shared buffer
|
||||
pRet = new sSharedBuffer( encodeIndex, pEncoded, pBuf->GetType() );
|
||||
return pRet;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
HDLCUnitTest (Free Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Simple in = out testing of HDLCEncode/HDLCDecode
|
||||
|
||||
RETURN VALUE:
|
||||
bool:
|
||||
true - Test succeeded
|
||||
false - Test failed
|
||||
===========================================================================*/
|
||||
#ifdef DEBUG
|
||||
#include <cstdlib>
|
||||
|
||||
bool HDLCUnitTest()
|
||||
{
|
||||
// Assume failure
|
||||
bool bRC = false;
|
||||
|
||||
const UINT MAX_LEN = 2048;
|
||||
BYTE testBuf[MAX_LEN];
|
||||
|
||||
srand( GetTickCount() );
|
||||
|
||||
UINT len = (((UINT)rand()) % MAX_LEN) + 1;
|
||||
for (UINT i = 0; i < len; i++)
|
||||
{
|
||||
testBuf[i] = (BYTE)((UINT)rand() % 256);
|
||||
}
|
||||
|
||||
sSharedBuffer * pOrig = new sSharedBuffer( testBuf, len, 0 );
|
||||
if (pOrig != 0)
|
||||
{
|
||||
// Encode buffer
|
||||
sSharedBuffer * pEnc = HDLCEncode( pOrig );
|
||||
if (pEnc != 0)
|
||||
{
|
||||
// Now decode buffer encoded above
|
||||
sSharedBuffer * pDec = HDLCDecode( pEnc );
|
||||
if (pDec != 0)
|
||||
{
|
||||
if (pOrig->IsValid() == true && pDec->IsValid() == true)
|
||||
{
|
||||
// Compare decoded to original
|
||||
const BYTE * pOrigData = pOrig->GetBuffer();
|
||||
const BYTE * pDecData = pDec->GetBuffer();
|
||||
|
||||
if (len == pDec->GetSize())
|
||||
{
|
||||
int cmp = memcmp( (const void *)pOrigData,
|
||||
(const void *)pDecData,
|
||||
(size_t)len );
|
||||
|
||||
bRC = (cmp == 0);
|
||||
}
|
||||
}
|
||||
|
||||
delete [] pDec;
|
||||
}
|
||||
|
||||
delete [] pEnc;
|
||||
}
|
||||
|
||||
delete [] pOrig;
|
||||
}
|
||||
|
||||
return bRC;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,70 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
HDLC.h
|
||||
|
||||
DESCRIPTION:
|
||||
Encode and decode asynchronous HDLC protocol packets as described
|
||||
by both the QUALCOMM download & SDIC (diagnostic) protocol documents
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
HDLCDecode()
|
||||
HDLCEncode()
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
extern const BYTE AHDLC_FLAG;
|
||||
extern const BYTE AHDLC_ESCAPE;
|
||||
extern const BYTE AHDLC_ESC_M;
|
||||
|
||||
struct sSharedBuffer;
|
||||
|
||||
/*=========================================================================*/
|
||||
// Prototypes
|
||||
/*=========================================================================*/
|
||||
|
||||
// HDLC encode the given buffer returning the results in an allocated buffer
|
||||
sSharedBuffer * HDLCEncode( sSharedBuffer * pBuf );
|
||||
|
||||
// HDLC decode the given buffer returning the results in an allocated buffer
|
||||
sSharedBuffer * HDLCDecode( sSharedBuffer * pBuf );
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
// Simple in = out testing of HDLCEncode/HDLCDecode
|
||||
bool HDLCUnitTest();
|
||||
|
||||
#endif
|
|
@ -0,0 +1,323 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
HDLCProtocolServer.cpp
|
||||
|
||||
DESCRIPTION:
|
||||
Generic HDLC framed protocol packet server
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
cHDLCProtocolServer
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "StdAfx.h"
|
||||
#include "HDLCProtocolServer.h"
|
||||
#include "HDLC.h"
|
||||
#include "CRC.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
/*=========================================================================*/
|
||||
// cHDLCProtocolServer Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
cHDLCProtocolServer (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Constructor
|
||||
|
||||
PARAMETERS:
|
||||
rxType [ I ] - Protocol type to assign to incoming data
|
||||
txType [ I ] - Protocol type to verify for outgoing data
|
||||
bufferSzRx [ I ] - Size of data buffer for incoming data
|
||||
logSz [ I ] - Size of log (number of buffers)
|
||||
|
||||
SEQUENCING:
|
||||
None (constructs sequencing objects)
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cHDLCProtocolServer::cHDLCProtocolServer(
|
||||
eProtocolType rxType,
|
||||
eProtocolType txType,
|
||||
ULONG bufferSzRx,
|
||||
ULONG logSz )
|
||||
: cProtocolServer( rxType, txType, bufferSzRx, logSz ),
|
||||
mRxType( rxType ),
|
||||
mpEncodedBuffer( 0 ),
|
||||
mpRxDecodeBuffer( 0 ),
|
||||
mRxDecodeOffset( 0 ),
|
||||
mbInEscape( false )
|
||||
{
|
||||
// Allocate decode buffer?
|
||||
if (mRxBufferSize > 0)
|
||||
{
|
||||
mpRxDecodeBuffer = new BYTE[mRxBufferSize * 4];
|
||||
}
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
~cHDLCProtocolServer (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Destructor
|
||||
|
||||
SEQUENCING:
|
||||
None (constructs sequencing objects)
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cHDLCProtocolServer::~cHDLCProtocolServer()
|
||||
{
|
||||
// Free encoded buffer?
|
||||
if (mpEncodedBuffer != 0)
|
||||
{
|
||||
delete mpEncodedBuffer;
|
||||
mpEncodedBuffer = 0;
|
||||
}
|
||||
|
||||
// Free decode buffer?
|
||||
if (mpRxDecodeBuffer != 0)
|
||||
{
|
||||
delete [] mpRxDecodeBuffer;
|
||||
mpRxDecodeBuffer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
InitializeComm (Internal Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Perform protocol specific communications port initialization
|
||||
|
||||
NOTE: This sends the commands to the driver which sends the IOCTL, but
|
||||
that isn't successful
|
||||
|
||||
SEQUENCING:
|
||||
None (must be called from protocol server thread)
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cHDLCProtocolServer::InitializeComm()
|
||||
{
|
||||
// Default configuration setting
|
||||
struct termios settings;
|
||||
|
||||
if (mComm.GetSettings( &settings ) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
cfmakeraw( &settings );
|
||||
settings.c_cflag |= CREAD|CLOCAL;
|
||||
|
||||
return mComm.ConfigureSettings( &settings );
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
CleanupComm (Internal Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Perform protocol specific communications port cleanup
|
||||
|
||||
SEQUENCING:
|
||||
None (must be called from protocol server thread)
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cHDLCProtocolServer::CleanupComm()
|
||||
{
|
||||
// Nothing to actually do here
|
||||
return true;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
EncodeTxData (Internal Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Encode data for transmission
|
||||
|
||||
PARAMETERS:
|
||||
pBuffer [ I ] - Data to be encoded
|
||||
bEncoded [ O ] - Do we even encoded data?
|
||||
|
||||
SEQUENCING:
|
||||
None (must be called from protocol server thread)
|
||||
|
||||
RETURN VALUE:
|
||||
sSharedBuffer * - Encoded data (0 upon error when encoding is indicated)
|
||||
===========================================================================*/
|
||||
sSharedBuffer * cHDLCProtocolServer::EncodeTxData(
|
||||
sSharedBuffer * pBuffer,
|
||||
bool & bEncoded )
|
||||
{
|
||||
// We encoded data
|
||||
bEncoded = true;
|
||||
|
||||
// Last encoded buffer around?
|
||||
if (mpEncodedBuffer != 0)
|
||||
{
|
||||
// Yes free it. Note that this assumes that the last transmission has
|
||||
// concluded since the buffer must exist during transmission. Since we
|
||||
// support one and only one outstanding request this is valid
|
||||
delete mpEncodedBuffer;
|
||||
mpEncodedBuffer = 0;
|
||||
}
|
||||
|
||||
mpEncodedBuffer = HDLCEncode( pBuffer );
|
||||
return mpEncodedBuffer;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
DecodeRxData (Internal Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Decode incoming data into packets returning the last response
|
||||
|
||||
PARAMETERS:
|
||||
bytesReceived [ I ] - Number of bytes to decoded
|
||||
rspIdx [ O ] - Log index of last valid response
|
||||
bAbortTx [ O ] - Response aborts current transmission?
|
||||
|
||||
SEQUENCING:
|
||||
None (must be called from protocol server thread)
|
||||
|
||||
RETURN VALUE:
|
||||
bool - Was a response received?
|
||||
===========================================================================*/
|
||||
bool cHDLCProtocolServer::DecodeRxData(
|
||||
ULONG bytesReceived,
|
||||
ULONG & rspIdx,
|
||||
bool & bAbortTx )
|
||||
{
|
||||
// Assume failure
|
||||
bool bRC = false;
|
||||
rspIdx = INVALID_LOG_INDEX;
|
||||
|
||||
// Something to decode from/to?
|
||||
if (bytesReceived == 0 || mpRxDecodeBuffer == 0)
|
||||
{
|
||||
return bRC;
|
||||
}
|
||||
|
||||
BYTE val;
|
||||
ULONG idx = 0;
|
||||
ULONG maxSz = mRxBufferSize * 4;
|
||||
|
||||
while (idx < bytesReceived)
|
||||
{
|
||||
val = mpRxBuffer[idx++];
|
||||
|
||||
// Check for target spewing nonsense
|
||||
if (mRxDecodeOffset >= maxSz)
|
||||
{
|
||||
// Reset to beginning
|
||||
mRxDecodeOffset = 0;
|
||||
}
|
||||
|
||||
// Was the previous byte an escape byte?
|
||||
if (mbInEscape == true)
|
||||
{
|
||||
// Yes, handle it
|
||||
mbInEscape = false;
|
||||
|
||||
val ^= AHDLC_ESC_M;
|
||||
mpRxDecodeBuffer[mRxDecodeOffset++] = val;
|
||||
}
|
||||
else if (val == AHDLC_ESCAPE)
|
||||
{
|
||||
// No, but this one is
|
||||
mbInEscape = true;
|
||||
}
|
||||
else if (val == AHDLC_FLAG)
|
||||
{
|
||||
// Is this a valid frame?
|
||||
if ( (mRxDecodeOffset > 0)
|
||||
&& (CheckCRC( mpRxDecodeBuffer, mRxDecodeOffset ) == true) )
|
||||
{
|
||||
// Yes, extract it (minus CRC) to a shared buffer
|
||||
sSharedBuffer * pTmp = 0;
|
||||
pTmp = new sSharedBuffer( mpRxDecodeBuffer,
|
||||
mRxDecodeOffset - 2,
|
||||
(ULONG)mRxType );
|
||||
|
||||
if (pTmp != 0)
|
||||
{
|
||||
sProtocolBuffer tmpPB( pTmp );
|
||||
ULONG tmpIdx = mLog.AddBuffer( tmpPB );
|
||||
|
||||
// Abort?
|
||||
bool bTmpAbortTx = IsTxAbortResponse( tmpPB );
|
||||
if (bTmpAbortTx == true)
|
||||
{
|
||||
bAbortTx = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Is this the response we are looking for?
|
||||
bool bRsp = IsResponse( tmpPB );
|
||||
if (bRsp == true)
|
||||
{
|
||||
rspIdx = tmpIdx;
|
||||
bRC = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Reset for next frame
|
||||
mRxDecodeOffset = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// No, just a regular value
|
||||
mpRxDecodeBuffer[mRxDecodeOffset++] = val;
|
||||
}
|
||||
}
|
||||
|
||||
return bRC;
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
HDLCProtocolServer.h
|
||||
|
||||
DESCRIPTION:
|
||||
Generic HDLC framed protocol packet server
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
cHDLCProtocolServer
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "ProtocolServer.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
/*=========================================================================*/
|
||||
// Class cHDLCProtocolServer
|
||||
/*=========================================================================*/
|
||||
class cHDLCProtocolServer : public cProtocolServer
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
cHDLCProtocolServer(
|
||||
eProtocolType rxType,
|
||||
eProtocolType txType,
|
||||
ULONG bufferSzRx,
|
||||
ULONG logSz );
|
||||
|
||||
// Destructor
|
||||
virtual ~cHDLCProtocolServer();
|
||||
|
||||
protected:
|
||||
// Perform protocol specific communications port initialization
|
||||
virtual bool InitializeComm();
|
||||
|
||||
// Perform protocol specific communications port cleanup
|
||||
virtual bool CleanupComm();
|
||||
|
||||
// Encode data for transmission
|
||||
virtual sSharedBuffer * EncodeTxData(
|
||||
sSharedBuffer * pBuffer,
|
||||
bool & bEncoded );
|
||||
|
||||
// Decode incoming data into packets returning the last response
|
||||
virtual bool DecodeRxData(
|
||||
ULONG bytesReceived,
|
||||
ULONG & rspIdx,
|
||||
bool & bAbortTx );
|
||||
|
||||
// Is the passed in data a response to the current request?
|
||||
virtual bool IsResponse( const sProtocolBuffer & /* rsp */ ) = 0;
|
||||
|
||||
// Is the passed in data a response that aborts the current request?
|
||||
virtual bool IsTxAbortResponse( const sProtocolBuffer & rsp ) = 0;
|
||||
|
||||
/* Protocol type for incoming data*/
|
||||
eProtocolType mRxType;
|
||||
|
||||
/* Encoded data being transmitted */
|
||||
sSharedBuffer * mpEncodedBuffer;
|
||||
|
||||
/* Decode buffer for incoming data */
|
||||
BYTE * mpRxDecodeBuffer;
|
||||
|
||||
/* Current index into above buffer */
|
||||
ULONG mRxDecodeOffset;
|
||||
|
||||
/* Are we currently escaping a character? */
|
||||
bool mbInEscape;
|
||||
};
|
|
@ -0,0 +1,58 @@
|
|||
noinst_LTLIBRARIES = libCore.la
|
||||
|
||||
libCore_la_CXXFLAGS = -Wunused-variable
|
||||
|
||||
libCore_la_SOURCES = \
|
||||
BitPacker.cpp \
|
||||
BitPacker.h \
|
||||
BitParser.cpp \
|
||||
BitParser.h \
|
||||
Comm.cpp \
|
||||
Comm.h \
|
||||
CoreDatabase.cpp \
|
||||
CoreDatabase.h \
|
||||
CoreUtilities.cpp \
|
||||
CoreUtilities.h \
|
||||
CRC.cpp \
|
||||
CRC.h \
|
||||
DataPacker.cpp \
|
||||
DataPacker.h \
|
||||
DataParser.cpp \
|
||||
DataParser.h \
|
||||
DB2NavTree.cpp \
|
||||
DB2NavTree.h \
|
||||
DB2TextFile.cpp \
|
||||
DB2TextFile.h \
|
||||
DB2Utilities.cpp \
|
||||
DB2Utilities.h \
|
||||
Event.cpp \
|
||||
Event.h \
|
||||
HDLC.cpp \
|
||||
HDLC.h \
|
||||
HDLCProtocolServer.cpp \
|
||||
HDLCProtocolServer.h \
|
||||
MemoryMappedFile.cpp \
|
||||
MemoryMappedFile.h \
|
||||
ProtocolBuffer.cpp \
|
||||
ProtocolBuffer.h \
|
||||
ProtocolEntityNav.cpp \
|
||||
ProtocolEntityNav.h \
|
||||
ProtocolLog.cpp \
|
||||
ProtocolLog.h \
|
||||
ProtocolNotification.cpp \
|
||||
ProtocolNotification.h \
|
||||
ProtocolRequest.cpp \
|
||||
ProtocolRequest.h \
|
||||
ProtocolServer.cpp \
|
||||
ProtocolServer.h \
|
||||
QDLBuffers.cpp \
|
||||
QDLBuffers.h \
|
||||
QDLProtocolServer.cpp \
|
||||
QDLProtocolServer.h \
|
||||
QMIBuffers.cpp \
|
||||
QMIBuffers.h \
|
||||
QMIProtocolServer.cpp \
|
||||
QMIProtocolServer.h \
|
||||
SharedBuffer.cpp \
|
||||
SharedBuffer.h
|
||||
|
|
@ -0,0 +1,183 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
MemoryMappedFile.cpp
|
||||
|
||||
DESCRIPTION:
|
||||
Implementation of cMemoryMappedFile class
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
cMemoryMappedFile
|
||||
The cMemoryMappedFile class provides the ability to read in a file
|
||||
via Linux memory maps
|
||||
|
||||
Note: cMemoryMappedFiles are read only
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "StdAfx.h"
|
||||
#include "MemoryMappedFile.h"
|
||||
|
||||
#include <sys/mman.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Maximum size of a file this interface will try to open (64 MB)
|
||||
const DWORD MAX_FILE_SZ = 1024 * 1024 * 64;
|
||||
|
||||
/*=========================================================================*/
|
||||
// cMemoryMappedFile Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
cMemoryMappedFile (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Construct object/load file into memory
|
||||
|
||||
PARAMETERS
|
||||
pFile [ I ] - File name
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cMemoryMappedFile::cMemoryMappedFile( LPCSTR pFile )
|
||||
: mbResourceBased( false ),
|
||||
mpBuffer( 0 ),
|
||||
mFileSize( 0 ),
|
||||
mStatus( ERROR_FILE_NOT_FOUND )
|
||||
{
|
||||
if (pFile == 0 || pFile[0] == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Open the file
|
||||
mFile = open( pFile, O_RDONLY );
|
||||
if (mFile == -1)
|
||||
{
|
||||
TRACE( "Unable to Map %s to memory. Error %d: %s\n",
|
||||
pFile,
|
||||
errno,
|
||||
strerror( errno ) );
|
||||
return;
|
||||
}
|
||||
|
||||
// Grab the file size
|
||||
struct stat fileInfo;
|
||||
if (fstat( mFile, &fileInfo ) != 0)
|
||||
{
|
||||
TRACE( "Unable to get info for %s. Error %d: %s\n",
|
||||
pFile,
|
||||
errno,
|
||||
strerror( errno ) );
|
||||
return;
|
||||
}
|
||||
DWORD fileSize = fileInfo.st_size;
|
||||
|
||||
// Map to mpBuffer
|
||||
mpBuffer = mmap( 0,
|
||||
fileSize,
|
||||
PROT_READ,
|
||||
MAP_SHARED | MAP_POPULATE,
|
||||
mFile,
|
||||
0 );
|
||||
if (mpBuffer == 0 || mpBuffer == MAP_FAILED )
|
||||
{
|
||||
TRACE( "Memory map failed error %d:, %s\n",
|
||||
errno,
|
||||
strerror( errno ) );
|
||||
return;
|
||||
}
|
||||
|
||||
// Success!
|
||||
mFileSize = fileSize;
|
||||
mStatus = NO_ERROR;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
cMemoryMappedFile (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Construct object/load resource based file into memory
|
||||
|
||||
PARAMETERS
|
||||
pStart [ I ] - Start location of object
|
||||
nSize [ I ] - Size of object
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cMemoryMappedFile::cMemoryMappedFile(
|
||||
const char * pStart,
|
||||
const int nSize )
|
||||
: mbResourceBased( true ),
|
||||
mpBuffer( 0 ),
|
||||
mFileSize( 0 ),
|
||||
mStatus( INVALID_HANDLE_VALUE )
|
||||
{
|
||||
// Set size
|
||||
mFileSize = nSize;
|
||||
|
||||
// Set memory pointer
|
||||
mpBuffer = (void * )pStart;
|
||||
|
||||
// Success!
|
||||
mStatus = NO_ERROR;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
~cMemoryMappedFile (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Destructor
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cMemoryMappedFile::~cMemoryMappedFile()
|
||||
{
|
||||
if (mbResourceBased == false)
|
||||
{
|
||||
if (munmap( mpBuffer, mFileSize ) == -1)
|
||||
{
|
||||
TRACE( "Memory unmapping error %d: %s\n",
|
||||
errno,
|
||||
strerror( errno ) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,120 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
MemoryMappedFile.h
|
||||
|
||||
DESCRIPTION:
|
||||
Declaration of cMemoryMappedFile class
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
cMemoryMappedFile
|
||||
The cMemoryMappedFile class provides the ability to read in a file
|
||||
via Linux memory maps
|
||||
|
||||
Note: cMemoryMappedFiles are read only
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
/*=========================================================================*/
|
||||
// Class cMemoryMappedFile
|
||||
/*=========================================================================*/
|
||||
class cMemoryMappedFile
|
||||
{
|
||||
public:
|
||||
// Constructor (loads file)
|
||||
cMemoryMappedFile( LPCSTR pFile );
|
||||
|
||||
// Constructor (loads file from resource)
|
||||
cMemoryMappedFile(
|
||||
const char * pStart,
|
||||
const int nSize );
|
||||
|
||||
// Destructor
|
||||
virtual ~cMemoryMappedFile();
|
||||
|
||||
// (Inline) Get error status
|
||||
DWORD GetStatus()
|
||||
{
|
||||
DWORD stat = mStatus;
|
||||
if (mStatus == NO_ERROR)
|
||||
{
|
||||
if (mpBuffer == 0 || mFileSize == 0)
|
||||
{
|
||||
// We failed but GetLastError() return NO_ERROR
|
||||
stat = ERROR_NO_MORE_ITEMS;
|
||||
}
|
||||
}
|
||||
|
||||
return stat;
|
||||
};
|
||||
|
||||
// (Inline) Return the size of the file (contents)
|
||||
ULONG GetSize()
|
||||
{
|
||||
ULONG sz = 0;
|
||||
if (GetStatus() == NO_ERROR)
|
||||
{
|
||||
sz = mFileSize;
|
||||
}
|
||||
|
||||
return sz;
|
||||
};
|
||||
|
||||
// (Inline) Return the file contents
|
||||
LPVOID GetContents()
|
||||
{
|
||||
LPVOID pContents = 0;
|
||||
if (GetStatus() == NO_ERROR)
|
||||
{
|
||||
pContents = mpBuffer;
|
||||
}
|
||||
|
||||
return pContents;
|
||||
};
|
||||
|
||||
protected:
|
||||
/* Resource based file? */
|
||||
bool mbResourceBased;
|
||||
|
||||
/* File handle */
|
||||
int mFile;
|
||||
|
||||
/* File contents*/
|
||||
LPVOID mpBuffer;
|
||||
|
||||
/* File size */
|
||||
ULONG mFileSize;
|
||||
|
||||
/* Error status */
|
||||
DWORD mStatus;
|
||||
};
|
|
@ -0,0 +1,222 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
ProtocolBuffer.cpp
|
||||
|
||||
DESCRIPTION:
|
||||
Generic protocol structures and affliated methods
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
sProtocolBuffer
|
||||
Simple struct to represent a protocol buffer using a reference counted
|
||||
(shared) buffer, this allows us to use in in several places without
|
||||
copying it once in each place. A few base services are provided
|
||||
but the main purpose is to provide a class to inherit off of for
|
||||
specific protocols
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "StdAfx.h"
|
||||
#include "ProtocolBuffer.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
/*=========================================================================*/
|
||||
// sProtocolBuffer Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
sProtocolBuffer (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Constructor (default)
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
sProtocolBuffer::sProtocolBuffer()
|
||||
: mpData( 0 ),
|
||||
mbValid( false )
|
||||
{
|
||||
// Object is currently invalid
|
||||
mTimestamp = EMPTY_TIME;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
sProtocolBuffer (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Constructor (parameterized)
|
||||
|
||||
PARAMETERS:
|
||||
pBuffer [ I ] - Shareable buffer that contains the DIAG data
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
sProtocolBuffer::sProtocolBuffer( sSharedBuffer * pBuffer )
|
||||
: mpData( 0 ),
|
||||
mbValid( false )
|
||||
{
|
||||
mTimestamp = EMPTY_TIME;
|
||||
|
||||
time_t rawtime;
|
||||
time( &rawtime );
|
||||
tm * timestamp = localtime( &rawtime );
|
||||
if (timestamp != 0)
|
||||
{
|
||||
mTimestamp = *timestamp;
|
||||
}
|
||||
|
||||
if (mpData != 0 && mpData->IsValid() == true)
|
||||
{
|
||||
mpData->Release();
|
||||
mpData = 0;
|
||||
}
|
||||
|
||||
mpData = pBuffer;
|
||||
if (mpData != 0 && mpData->IsValid() == true)
|
||||
{
|
||||
mpData->AddRef();
|
||||
}
|
||||
else
|
||||
{
|
||||
mpData = 0;
|
||||
}
|
||||
|
||||
// NOTE: Derived classes need to call their own validation method
|
||||
// in their constructors since the override might try to access
|
||||
// data that is not yet in place
|
||||
sProtocolBuffer::Validate();
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
sProtocolBuffer (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Copy constructor
|
||||
|
||||
PARAMETERS:
|
||||
copyThis [ I ] - sProtocolBuffer to base the new one on
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
sProtocolBuffer::sProtocolBuffer( const sProtocolBuffer & copyThis )
|
||||
: mpData( copyThis.mpData ),
|
||||
mTimestamp( copyThis.mTimestamp ),
|
||||
mbValid( copyThis.mbValid )
|
||||
{
|
||||
// Bump reference count for shared buffer
|
||||
if (mpData != 0 && mpData->IsValid() == true)
|
||||
{
|
||||
mpData->AddRef();
|
||||
}
|
||||
else
|
||||
{
|
||||
mpData = 0;
|
||||
mbValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
operator = (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Assignment operator
|
||||
|
||||
PARAMETERS:
|
||||
copyThis [ I ] - sProtocolBuffer to base the new one on
|
||||
|
||||
RETURN VALUE:
|
||||
sProtocolBuffer &
|
||||
===========================================================================*/
|
||||
sProtocolBuffer & sProtocolBuffer::operator = ( const sProtocolBuffer & copyThis )
|
||||
{
|
||||
// Do we already have data?
|
||||
if (mpData != 0)
|
||||
{
|
||||
// Is it different than what we are duplicating?
|
||||
if (mpData != copyThis.mpData)
|
||||
{
|
||||
// Yes, release our current buffer
|
||||
mpData->Release();
|
||||
}
|
||||
}
|
||||
|
||||
mpData = copyThis.mpData;
|
||||
mTimestamp = copyThis.mTimestamp;
|
||||
mbValid = copyThis.mbValid;
|
||||
|
||||
// Bump reference count for shared buffer
|
||||
if (mpData != 0 && mpData->IsValid() == true)
|
||||
{
|
||||
mpData->AddRef();
|
||||
}
|
||||
else
|
||||
{
|
||||
mpData = 0;
|
||||
mbValid = false;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
~sProtocolBuffer (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Destructor
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
sProtocolBuffer::~sProtocolBuffer()
|
||||
{
|
||||
if (mpData != 0 && mpData->IsValid() == true)
|
||||
{
|
||||
mpData->Release();
|
||||
mpData = 0;
|
||||
}
|
||||
else if (mpData != 0)
|
||||
{
|
||||
ASSERT( 0 );
|
||||
}
|
||||
|
||||
mbValid = false;
|
||||
}
|
|
@ -0,0 +1,162 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
ProtocolBuffer.h
|
||||
|
||||
DESCRIPTION:
|
||||
Generic protocol structures and affliated methods
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
sProtocolBuffer
|
||||
Simple struct to represent a protocol buffer using a reference counted
|
||||
(shared) buffer, this allows us to use in in several places without
|
||||
copying it once in each place. A few base services are provided
|
||||
but the main purpose is to provide a class to inherit off of for
|
||||
specific protocols
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "SharedBuffer.h"
|
||||
#include "ProtocolEnum.h"
|
||||
|
||||
static const tm EMPTY_TIME = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sProtocolBuffer
|
||||
/*=========================================================================*/
|
||||
struct sProtocolBuffer
|
||||
{
|
||||
public:
|
||||
// Constructor (default)
|
||||
sProtocolBuffer();
|
||||
|
||||
// Constructor (parameterized)
|
||||
sProtocolBuffer( sSharedBuffer * pBuffer );
|
||||
|
||||
// Copy constructor
|
||||
sProtocolBuffer( const sProtocolBuffer & copyThis );
|
||||
|
||||
// Assignment operator
|
||||
sProtocolBuffer & operator = ( const sProtocolBuffer & copyThis );
|
||||
|
||||
// Destructor
|
||||
virtual ~sProtocolBuffer();
|
||||
|
||||
// (Inline) Get buffer
|
||||
const BYTE * GetBuffer() const
|
||||
{
|
||||
BYTE * pRet = 0;
|
||||
if (IsValid() == true)
|
||||
{
|
||||
pRet = (BYTE *)mpData->GetBuffer();
|
||||
}
|
||||
|
||||
return (const BYTE *)pRet;
|
||||
};
|
||||
|
||||
// (Inline) Get buffer size
|
||||
ULONG GetSize() const
|
||||
{
|
||||
ULONG size = 0;
|
||||
if (IsValid() == true)
|
||||
{
|
||||
size = mpData->GetSize();
|
||||
}
|
||||
|
||||
return size;
|
||||
};
|
||||
|
||||
// (Inline) Return the protocol type
|
||||
eProtocolType GetType() const
|
||||
{
|
||||
eProtocolType pt = ePROTOCOL_ENUM_BEGIN;
|
||||
if (IsValid() == true)
|
||||
{
|
||||
pt = (eProtocolType)mpData->GetType();
|
||||
}
|
||||
|
||||
return pt;
|
||||
};
|
||||
|
||||
// (Inline) Return the shared buffer
|
||||
sSharedBuffer * GetSharedBuffer() const
|
||||
{
|
||||
sSharedBuffer * pRet = 0;
|
||||
if (IsValid() == true)
|
||||
{
|
||||
pRet = mpData;
|
||||
}
|
||||
|
||||
return pRet;
|
||||
};
|
||||
|
||||
// (Inline) Return the timestamp
|
||||
tm GetTimestamp() const
|
||||
{
|
||||
tm ft = EMPTY_TIME;
|
||||
|
||||
if (IsValid() == true)
|
||||
{
|
||||
ft = mTimestamp;
|
||||
}
|
||||
|
||||
return ft;
|
||||
};
|
||||
|
||||
// (Inline) Is this buffer valid?
|
||||
virtual bool IsValid() const
|
||||
{
|
||||
return mbValid;
|
||||
};
|
||||
|
||||
protected:
|
||||
// (Inline) Validate buffer
|
||||
virtual bool Validate()
|
||||
{
|
||||
// Do we have a shared buffer and is it valid?
|
||||
mbValid = (mpData != 0 && mpData->IsValid());
|
||||
return mbValid;
|
||||
};
|
||||
|
||||
/* Our data buffer */
|
||||
sSharedBuffer * mpData;
|
||||
|
||||
/* Time buffer was created */
|
||||
tm mTimestamp;
|
||||
|
||||
/* Has this buffer been validated? (NOTE: *NOT* set in base) */
|
||||
bool mbValid;
|
||||
};
|
|
@ -0,0 +1,139 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
ProtocolEntityFieldEnumerator.h
|
||||
|
||||
DESCRIPTION:
|
||||
Declaration of cProtocolEntityFieldEnumerator
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
cProtocolEntityFieldEnumerator
|
||||
Class to navigate a protoocl entity, generating a vector of
|
||||
field IDs, i.e. every field referenced by this protocol entity
|
||||
in the exact order it would regularly be found
|
||||
|
||||
NOTE: This only functions for fixed structures such as NV items
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "ProtocolEntityNav.h"
|
||||
#include "DB2NavTree.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
/*=========================================================================*/
|
||||
// Class cProtocolEntityFieldEnumerator
|
||||
/*=========================================================================*/
|
||||
class cProtocolEntityFieldEnumerator : public cProtocolEntityNav
|
||||
{
|
||||
public:
|
||||
// (Inline) Constructor
|
||||
cProtocolEntityFieldEnumerator(
|
||||
const cCoreDatabase & db,
|
||||
const std::vector <ULONG> & key )
|
||||
: cProtocolEntityNav( db ),
|
||||
mKey( key )
|
||||
{
|
||||
// Nothing to do
|
||||
};
|
||||
|
||||
// (Inline) Destructor
|
||||
virtual ~cProtocolEntityFieldEnumerator()
|
||||
{
|
||||
// Nothing to do
|
||||
};
|
||||
|
||||
// (Inline) Enumerate the fields
|
||||
virtual bool Enumerate()
|
||||
{
|
||||
bool bRC = ProcessEntity( mKey );
|
||||
return bRC;
|
||||
};
|
||||
|
||||
// (Inline) Return fields
|
||||
const std::vector <ULONG> & GetFields() const
|
||||
{
|
||||
return mFields;
|
||||
};
|
||||
|
||||
protected:
|
||||
// (Inline) Evaluate the given condition
|
||||
virtual bool EvaluateCondition(
|
||||
LPCSTR /* pCondition */,
|
||||
bool & bResult )
|
||||
{
|
||||
// All conditions pass
|
||||
bResult = true;
|
||||
return bResult;
|
||||
};
|
||||
|
||||
// Return the value for the specified field ID as a
|
||||
// LONGLONG (field type must be able to fit)
|
||||
virtual bool GetLastValue(
|
||||
ULONG /* fieldID */,
|
||||
LONGLONG & val )
|
||||
{
|
||||
// This should only be called for figuring out array
|
||||
// boundaries (including strings)
|
||||
val = 1;
|
||||
return true;
|
||||
};
|
||||
|
||||
// Process the given field
|
||||
virtual bool ProcessField(
|
||||
const sDB2Field * pField,
|
||||
const std::string & /* fieldName */,
|
||||
LONGLONG /* arrayIndex = -1 */ )
|
||||
{
|
||||
if (pField != 0)
|
||||
{
|
||||
mFields.push_back( pField->mID );
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
/* Protocol entity being navigated */
|
||||
std::vector <ULONG> mKey;
|
||||
|
||||
/* Fields (by ID) */
|
||||
std::vector <ULONG> mFields;
|
||||
};
|
|
@ -0,0 +1,997 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
ProtocolEntityNav.cpp
|
||||
|
||||
DESCRIPTION:
|
||||
Implementation of cProtocolEntityNav
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
cProtocolEntityNav
|
||||
This calss serves as a base for all class that need to
|
||||
'navigate' a protocol entity database description. It is
|
||||
necessary in order to seperate the structural aspects
|
||||
from parsing/packing details
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "StdAfx.h"
|
||||
#include "ProtocolEntityNav.h"
|
||||
#include "BitParser.h"
|
||||
#include "CoreUtilities.h"
|
||||
#include "DB2NavTree.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// Field seperator string
|
||||
LPCSTR PE_NAV_FIELD_SEP = ".";
|
||||
|
||||
/*=========================================================================*/
|
||||
// cProtocolEntityNav Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
cProtocolEntityNav (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Constructor
|
||||
|
||||
PARAMETERS:
|
||||
db [ I ] - Database to use
|
||||
bSummaryOnly [ I ] - Only navigate if a format specifier exists?
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cProtocolEntityNav::cProtocolEntityNav( const cCoreDatabase & db )
|
||||
: mDB( db ),
|
||||
mbFieldNames( true ),
|
||||
mConditions( db.GetOptionalMods() ),
|
||||
mExpressions( db.GetExpressionMods() ),
|
||||
mArrays1( db.GetArray1Mods() ),
|
||||
mArrays2( db.GetArray2Mods() )
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
~cProtocolEntityNav (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Destructor
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cProtocolEntityNav::~cProtocolEntityNav()
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
EvaluateCondition (Internal Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Evaluate the given condition
|
||||
|
||||
PARAMETERS:
|
||||
pCondition [ I ] - Condition to evaluate
|
||||
bResult [ O ] - Result of evaluating the condition (true/false)
|
||||
|
||||
RETURN VALUE:
|
||||
bool :
|
||||
true - We were able to evaluate the condition
|
||||
false - Unable to evaluate condition
|
||||
===========================================================================*/
|
||||
bool cProtocolEntityNav::EvaluateCondition(
|
||||
LPCSTR pCondition,
|
||||
bool & bResult )
|
||||
{
|
||||
// Assume error
|
||||
bool bRC = false;
|
||||
|
||||
tDB2OptionalModMap::const_iterator pIter;
|
||||
pIter = mConditions.find( pCondition );
|
||||
|
||||
if (pIter != mConditions.end())
|
||||
{
|
||||
const sDB2SimpleCondition & con = pIter->second;
|
||||
|
||||
// Grab the value for the given field ID
|
||||
LONGLONG valA = 0;
|
||||
bRC = GetLastValue( con.mID, valA );
|
||||
|
||||
// Field to field?
|
||||
LONGLONG valB = con.mValue;
|
||||
if (con.mbF2F == true)
|
||||
{
|
||||
// Yes, grab value of the second field
|
||||
bRC &= GetLastValue( (ULONG)con.mValue, valB );
|
||||
}
|
||||
|
||||
if (bRC == true)
|
||||
{
|
||||
bResult = sDB2Fragment::EvaluateCondition( valA,
|
||||
con.mOperator,
|
||||
valB );
|
||||
}
|
||||
else
|
||||
{
|
||||
// We could not find the field used in the condition, this
|
||||
// can either be because of a bad entity (which is ruled
|
||||
// out prior to reaching this point) or the existence of
|
||||
// the field itself is based on another condition. The
|
||||
// former should not happen and the later is not an error
|
||||
bResult = false;
|
||||
bRC = true;
|
||||
}
|
||||
}
|
||||
|
||||
return bRC;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetArrayBounds (Internal Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Get the array bounds described by the fragment descriptor
|
||||
|
||||
PARAMETERS:
|
||||
frag [ I ] - Fragment descriptor
|
||||
arraySz [ O ] - Size of array
|
||||
arrayAdj [ O ] - Adjust for array indices
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cProtocolEntityNav::GetArrayBounds(
|
||||
const sDB2Fragment & frag,
|
||||
LONGLONG & arraySz,
|
||||
LONGLONG & arrayAdj )
|
||||
{
|
||||
// Assume failure
|
||||
bool bRC = false;
|
||||
|
||||
// Figure out the array size/adjust
|
||||
arraySz = 0;
|
||||
arrayAdj = 0;
|
||||
|
||||
switch (frag.mModifierType)
|
||||
{
|
||||
case eDB2_MOD_CONSTANT_ARRAY:
|
||||
{
|
||||
tDB2Array1ModMap::const_iterator pIter;
|
||||
pIter = mArrays1.find( frag.mpModifierValue );
|
||||
|
||||
if (pIter != mArrays1.end())
|
||||
{
|
||||
arraySz = (LONGLONG)pIter->second;
|
||||
bRC = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case eDB2_MOD_VARIABLE_ARRAY:
|
||||
{
|
||||
tDB2Array1ModMap::const_iterator pIter;
|
||||
pIter = mArrays1.find( frag.mpModifierValue );
|
||||
|
||||
if (pIter != mArrays1.end())
|
||||
{
|
||||
ULONG id = pIter->second;
|
||||
|
||||
// Now find last occurence of this field ID and grab the value
|
||||
bRC = GetLastValue( id, arraySz );
|
||||
if (bRC == true)
|
||||
{
|
||||
// It makes no sense to have a negative sized array
|
||||
if (arraySz < 0)
|
||||
{
|
||||
bRC = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case eDB2_MOD_VARIABLE_ARRAY2:
|
||||
{
|
||||
tDB2Array2ModMap::const_iterator pIter;
|
||||
pIter = mArrays2.find( frag.mpModifierValue );
|
||||
|
||||
if (pIter != mArrays2.end())
|
||||
{
|
||||
ULONG sID = pIter->second.first;
|
||||
ULONG eID = pIter->second.second;
|
||||
|
||||
LONGLONG s;
|
||||
LONGLONG e;
|
||||
|
||||
// Now find last occurence of these field IDs and
|
||||
// grab the values
|
||||
bRC = GetLastValue( sID, s );
|
||||
bRC &= GetLastValue( eID, e );
|
||||
if (bRC == true)
|
||||
{
|
||||
// It makes no sense to have an negative sized array
|
||||
if (e < s)
|
||||
{
|
||||
bRC = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
arrayAdj = s;
|
||||
arraySz = (e - s) + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case eDB2_MOD_VARIABLE_ARRAY3:
|
||||
{
|
||||
tDB2ExpressionModMap::const_iterator pIter;
|
||||
pIter = mExpressions.find( frag.mpModifierValue );
|
||||
|
||||
if (pIter != mExpressions.end())
|
||||
{
|
||||
const sDB2SimpleExpression & expr = pIter->second;
|
||||
|
||||
// Grab the value for the given field ID
|
||||
LONGLONG valA = 0;
|
||||
bRC = GetLastValue( expr.mID, valA );
|
||||
|
||||
// Field to field?
|
||||
LONGLONG valB = expr.mValue;
|
||||
if (expr.mbF2F == true)
|
||||
{
|
||||
// Yes, grab value of the second field
|
||||
bRC &= GetLastValue( (ULONG)expr.mValue, valB );
|
||||
}
|
||||
|
||||
if (bRC == true)
|
||||
{
|
||||
bRC = sDB2Fragment::EvaluateExpression( valA,
|
||||
expr.mOperator,
|
||||
valB,
|
||||
arraySz );
|
||||
|
||||
// It makes no sense to have a negative sized array
|
||||
if (bRC == true && arraySz < 0)
|
||||
{
|
||||
bRC = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return bRC;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
ModifyStringLength (Internal Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Modify string length based on existing field value, at the end
|
||||
of this function the field size will be the string length in bits
|
||||
|
||||
PARAMETERS:
|
||||
frag [ I ] - Fragment descriptor
|
||||
field [ O ] - Field to modify
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cProtocolEntityNav::ModifyStringLength(
|
||||
const sDB2Fragment & frag,
|
||||
sDB2Field & field )
|
||||
{
|
||||
// Assume failure
|
||||
bool bRC = false;
|
||||
|
||||
if (field.mType != eDB2_FIELD_STD)
|
||||
{
|
||||
// Why are we here?
|
||||
ASSERT( 0 );
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( (field.mTypeVal != (ULONG)eDB2_FIELD_STDTYPE_STRING_A)
|
||||
&& (field.mTypeVal != (ULONG)eDB2_FIELD_STDTYPE_STRING_U)
|
||||
&& (field.mTypeVal != (ULONG)eDB2_FIELD_STDTYPE_STRING_U8) )
|
||||
{
|
||||
// Why are we here?
|
||||
ASSERT( 0 );
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( (frag.mModifierType == eDB2_MOD_VARIABLE_STRING3)
|
||||
&& (field.mTypeVal == (ULONG)eDB2_FIELD_STDTYPE_STRING_U8) )
|
||||
{
|
||||
// We can't have the size specified in characters when the
|
||||
// size of the character itself is variable length
|
||||
ASSERT( 0 );
|
||||
return false;
|
||||
}
|
||||
|
||||
tDB2Array1ModMap::const_iterator pIter;
|
||||
pIter = mArrays1.find( frag.mpModifierValue );
|
||||
if (pIter == mArrays1.end())
|
||||
{
|
||||
// Unable to obtain string length
|
||||
return bRC;
|
||||
}
|
||||
|
||||
ULONG id = pIter->second;
|
||||
|
||||
// Now find last occurence of this field ID and grab the value
|
||||
LONGLONG strSz;
|
||||
bRC = GetLastValue( id, strSz );
|
||||
if (bRC == false || strSz < 0)
|
||||
{
|
||||
// Unable to obtain size or invalid size
|
||||
bRC = false;
|
||||
return bRC;
|
||||
}
|
||||
|
||||
// Compute character size
|
||||
ULONG charSz = BITS_PER_BYTE;
|
||||
if (field.mTypeVal == (ULONG)eDB2_FIELD_STDTYPE_STRING_U)
|
||||
{
|
||||
charSz *= 2;
|
||||
}
|
||||
|
||||
if (frag.mModifierType == eDB2_MOD_VARIABLE_STRING2)
|
||||
{
|
||||
strSz *= BITS_PER_BYTE;
|
||||
}
|
||||
else if (frag.mModifierType == eDB2_MOD_VARIABLE_STRING3)
|
||||
{
|
||||
strSz *= charSz;
|
||||
}
|
||||
|
||||
if (strSz > ULONG_MAX)
|
||||
{
|
||||
// String length far too large
|
||||
bRC = false;
|
||||
return bRC;
|
||||
}
|
||||
|
||||
if (strSz != 0)
|
||||
{
|
||||
if (strSz < charSz || (strSz % charSz) != 0)
|
||||
{
|
||||
// String length not a proper multiple of character size
|
||||
bRC = false;
|
||||
return bRC;
|
||||
}
|
||||
}
|
||||
|
||||
field.mSize = (ULONG)strSz;
|
||||
return bRC;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
ProcessEntity (Internal Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Process a protocol entity
|
||||
|
||||
PARAMETERS:
|
||||
key [ I ] - Key into the protocol entity table
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cProtocolEntityNav::ProcessEntity( const std::vector <ULONG> & key )
|
||||
{
|
||||
// Assume failure
|
||||
bool bRC = false;
|
||||
|
||||
// Look up entity definition
|
||||
const cDB2NavTree * pNavTree = mDB.GetEntityNavTree( key );
|
||||
|
||||
// Did we find it?
|
||||
if (pNavTree == 0)
|
||||
{
|
||||
return bRC;
|
||||
}
|
||||
|
||||
// Is it valid?
|
||||
mEntity = pNavTree->GetEntity();
|
||||
if (mEntity.IsValid() == false)
|
||||
{
|
||||
// No definition in database
|
||||
return bRC;
|
||||
}
|
||||
|
||||
// Check if we should continue
|
||||
if (ContinueNavigation() == false)
|
||||
{
|
||||
// Success!
|
||||
bRC = true;
|
||||
return bRC;
|
||||
}
|
||||
|
||||
// A structure to navigate?
|
||||
if (mEntity.mStructID == -1)
|
||||
{
|
||||
// Success!
|
||||
bRC = true;
|
||||
return bRC;
|
||||
}
|
||||
|
||||
// Grab navigation fragments
|
||||
const std::list <sDB2NavFragment *> & frags = pNavTree->GetFragments();
|
||||
|
||||
// Nothing to navigate?
|
||||
if (frags.size() == 0)
|
||||
{
|
||||
ASSERT( 0 );
|
||||
return bRC;
|
||||
}
|
||||
|
||||
// No name?
|
||||
if (mEntity.mpName == 0 || mEntity.mpName[0] == 0)
|
||||
{
|
||||
ASSERT( 0 );
|
||||
return bRC;
|
||||
}
|
||||
|
||||
// Grab tracked fields
|
||||
mTrackedFields = pNavTree->GetTrackedFields();
|
||||
|
||||
std::string preamble = "";
|
||||
|
||||
// Process the initial structure
|
||||
EnterStruct( mEntity.mpName, -1 );
|
||||
bRC = ProcessStruct( frags.front(), preamble, -1 );
|
||||
ExitStruct( mEntity.mpName, -1 );
|
||||
|
||||
return bRC;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
ProcessStruct (Internal Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Process a structure described by the given initial fragment
|
||||
|
||||
PARAMETERS:
|
||||
pFrag [ I ] - First fragment in structure
|
||||
preamable [ I ] - String to prepend to any field/struct names
|
||||
arrayIndex [ I ] - Array index (-1 = not part of an array)
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cProtocolEntityNav::ProcessStruct(
|
||||
const sDB2NavFragment * pFrag,
|
||||
const std::string & preamble,
|
||||
LONGLONG /* arrayIndex */ )
|
||||
{
|
||||
// Assume success
|
||||
bool bRC = true;
|
||||
|
||||
ULONG structSz = 0;
|
||||
ULONG structOffset = GetOffset();
|
||||
|
||||
// Grab current navigation order
|
||||
bool bOldLSB = GetLSBMode();
|
||||
bool bNewLSB = bOldLSB;
|
||||
|
||||
// Check for directives
|
||||
if (pFrag != 0)
|
||||
{
|
||||
bool bDirective = false;
|
||||
|
||||
const sDB2Fragment & frag = *pFrag->mpFragment;
|
||||
if (frag.mFragmentType == eDB2_FRAGMENT_MSB_2_LSB)
|
||||
{
|
||||
bDirective = true;
|
||||
if (bOldLSB == true)
|
||||
{
|
||||
bNewLSB = false;
|
||||
bRC = SetLSBMode( bNewLSB );
|
||||
}
|
||||
}
|
||||
|
||||
if (frag.mFragmentType == eDB2_FRAGMENT_LSB_2_MSB)
|
||||
{
|
||||
bDirective = true;
|
||||
if (bOldLSB == false)
|
||||
{
|
||||
bNewLSB = true;
|
||||
bRC = SetLSBMode( bNewLSB );
|
||||
}
|
||||
}
|
||||
|
||||
if (bDirective == true)
|
||||
{
|
||||
// We process directives here so move on to the next fragment
|
||||
// upon success
|
||||
if (bRC == true)
|
||||
{
|
||||
pFrag = pFrag->mpNextFragment;
|
||||
}
|
||||
else
|
||||
{
|
||||
pFrag = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Process each fragment in the structure
|
||||
while (pFrag != 0)
|
||||
{
|
||||
bRC = ProcessFragment( pFrag, structOffset, structSz, preamble );
|
||||
if (bRC == true)
|
||||
{
|
||||
pFrag = pFrag->mpNextFragment;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Restore navigation order
|
||||
if (bRC == true && bOldLSB != bNewLSB)
|
||||
{
|
||||
bRC = SetLSBMode( bOldLSB );
|
||||
}
|
||||
|
||||
return bRC;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
ProcessFragment (Internal Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Process the given fragment
|
||||
|
||||
PARAMETERS:
|
||||
pFrag [ I ] - Fragment to be processed
|
||||
structOffset [ I ] - Offset (from start of payload) of enclosing struct
|
||||
structSize [ I ] - Current size of enclosing struct
|
||||
preamble [ I ] - String to prepend to any field/struct names
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cProtocolEntityNav::ProcessFragment(
|
||||
const sDB2NavFragment * pFrag,
|
||||
ULONG structOffset,
|
||||
ULONG & structSize,
|
||||
const std::string & preamble )
|
||||
{
|
||||
// Assume failure
|
||||
bool bRC = false;
|
||||
if (pFrag == 0 || pFrag->mpFragment == 0)
|
||||
{
|
||||
return bRC;
|
||||
}
|
||||
|
||||
// Grab database fragment
|
||||
const sDB2Fragment & frag = *pFrag->mpFragment;
|
||||
|
||||
// Is this fragment optional?
|
||||
if (frag.mModifierType == eDB2_MOD_OPTIONAL)
|
||||
{
|
||||
bool bParse = false;
|
||||
bool bOK = EvaluateCondition( frag.mpModifierValue, bParse );
|
||||
if (bOK == false)
|
||||
{
|
||||
// Error evaluating the condition
|
||||
bRC = false;
|
||||
return bRC;
|
||||
}
|
||||
|
||||
if (bParse == false)
|
||||
{
|
||||
// Condition not satisfied, nothing to parse
|
||||
bRC = true;
|
||||
return bRC;
|
||||
}
|
||||
}
|
||||
|
||||
// Is this an array?
|
||||
LONGLONG arraySz = -1;
|
||||
LONGLONG arrayAdj = 0;
|
||||
bool bArray = ModifiedToArray( frag.mModifierType );
|
||||
if (bArray == true)
|
||||
{
|
||||
bool bOK = GetArrayBounds( frag, arraySz, arrayAdj );
|
||||
if (bOK == false)
|
||||
{
|
||||
// Error obtaining array dimensions
|
||||
bRC = false;
|
||||
return bRC;
|
||||
}
|
||||
else if (arraySz == 0)
|
||||
{
|
||||
// No array to process
|
||||
bRC = true;
|
||||
return bRC;
|
||||
}
|
||||
}
|
||||
|
||||
// Set base name
|
||||
std::string baseName = "";
|
||||
if (mbFieldNames == true)
|
||||
{
|
||||
baseName = preamble;
|
||||
|
||||
// Add in fragment name?
|
||||
if (frag.mpName != EMPTY_STRING)
|
||||
{
|
||||
if (baseName.size() > 0)
|
||||
{
|
||||
baseName += PE_NAV_FIELD_SEP;
|
||||
}
|
||||
|
||||
// Yes, add to the preamble
|
||||
baseName += frag.mpName;
|
||||
}
|
||||
}
|
||||
|
||||
// Is this fragment offset?
|
||||
if (frag.mFragmentOffset != -1)
|
||||
{
|
||||
// Yes, add in offset to structure offset and save
|
||||
ULONG newOffset = frag.mFragmentOffset + structOffset;
|
||||
SetOffset( newOffset );
|
||||
}
|
||||
|
||||
// What type of fragment is this?
|
||||
switch (frag.mFragmentType)
|
||||
{
|
||||
case eDB2_FRAGMENT_FIELD:
|
||||
{
|
||||
const sDB2Field * pField = pFrag->mpField;
|
||||
if (pField != 0)
|
||||
{
|
||||
if (mbFieldNames == true)
|
||||
{
|
||||
if (baseName.size() > 0)
|
||||
{
|
||||
baseName += PE_NAV_FIELD_SEP;
|
||||
}
|
||||
|
||||
// Add in field name
|
||||
baseName += pField->mpName;
|
||||
}
|
||||
|
||||
// Variable string?
|
||||
sDB2Field modField;
|
||||
if ( (frag.mModifierType == eDB2_MOD_VARIABLE_STRING1)
|
||||
|| (frag.mModifierType == eDB2_MOD_VARIABLE_STRING2)
|
||||
|| (frag.mModifierType == eDB2_MOD_VARIABLE_STRING3) )
|
||||
{
|
||||
modField = *pField;
|
||||
bRC = ModifyStringLength( frag, modField );
|
||||
if (bRC == false)
|
||||
{
|
||||
// Unable to obtain string length
|
||||
return bRC;
|
||||
}
|
||||
|
||||
if (modField.mSize == 0)
|
||||
{
|
||||
// String has no length - treat like an optional fragment
|
||||
bRC = true;
|
||||
return bRC;
|
||||
}
|
||||
|
||||
pField = &modField;
|
||||
}
|
||||
|
||||
// Handle an array?
|
||||
if (bArray == true)
|
||||
{
|
||||
EnterArray( frag, arraySz );
|
||||
|
||||
if (mbFieldNames == true)
|
||||
{
|
||||
ULONG baseLen = baseName.size();
|
||||
|
||||
std::string fieldName;
|
||||
fieldName.reserve( baseLen + 16 );
|
||||
fieldName = baseName;
|
||||
|
||||
CHAR arraySpec[32];
|
||||
|
||||
for (LONGLONG i = 0; i < arraySz; i++)
|
||||
{
|
||||
snprintf( arraySpec, 31, "[%lld]", i + arrayAdj );
|
||||
fieldName += arraySpec;
|
||||
|
||||
bRC = ProcessField( pField, fieldName, i );
|
||||
if (bRC == false)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// Remove the array specifier for the next pass
|
||||
fieldName.resize( baseLen );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (LONGLONG i = 0; i < arraySz; i++)
|
||||
{
|
||||
bRC = ProcessField( pField, baseName, i );
|
||||
if (bRC == false)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ExitArray( frag, arraySz );
|
||||
}
|
||||
else
|
||||
{
|
||||
bRC = ProcessField( pField, baseName );
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case eDB2_FRAGMENT_STRUCT:
|
||||
{
|
||||
if (pFrag->mpLinkFragment != 0)
|
||||
{
|
||||
// Handle an array?
|
||||
if (bArray == true)
|
||||
{
|
||||
EnterArray( frag, arraySz );
|
||||
|
||||
if (mbFieldNames == true)
|
||||
{
|
||||
ULONG baseLen = baseName.size();
|
||||
|
||||
std::string structName;
|
||||
structName.reserve( baseLen + 16 );
|
||||
structName = baseName;
|
||||
|
||||
CHAR arraySpec[32];
|
||||
|
||||
for (LONGLONG i = 0; i < arraySz; i++)
|
||||
{
|
||||
snprintf( arraySpec, 31, "[%lld]", i + arrayAdj );
|
||||
structName += arraySpec;
|
||||
|
||||
EnterStruct( frag.mpName, i );
|
||||
|
||||
bRC = ProcessStruct( pFrag->mpLinkFragment,
|
||||
structName,
|
||||
i );
|
||||
|
||||
ExitStruct( frag.mpName, i );
|
||||
|
||||
if (bRC == false)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// Remove the array specifier for the next pass
|
||||
structName.resize( baseLen );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
for (LONGLONG i = 0; i < arraySz; i++)
|
||||
{
|
||||
EnterStruct( frag.mpName, i );
|
||||
|
||||
bRC = ProcessStruct( pFrag->mpLinkFragment,
|
||||
baseName,
|
||||
i );
|
||||
|
||||
ExitStruct( frag.mpName, i );
|
||||
|
||||
if (bRC == false)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ExitArray( frag, arraySz );
|
||||
}
|
||||
else
|
||||
{
|
||||
EnterStruct( frag.mpName, -1 );
|
||||
bRC = ProcessStruct( pFrag->mpLinkFragment, baseName );
|
||||
ExitStruct( frag.mpName, -1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case eDB2_FRAGMENT_CONSTANT_PAD:
|
||||
{
|
||||
// Is the structure is smaller than the specified
|
||||
// value that we are to pad out to?
|
||||
ULONG totalSz = frag.mFragmentValue;
|
||||
if (totalSz >= structSize)
|
||||
{
|
||||
ULONG newOffset = structOffset + totalSz;
|
||||
SetOffset( newOffset );
|
||||
}
|
||||
|
||||
// Succcess!
|
||||
bRC = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case eDB2_FRAGMENT_VARIABLE_PAD_BITS:
|
||||
case eDB2_FRAGMENT_VARIABLE_PAD_BYTES:
|
||||
{
|
||||
// Find last occurence of this field ID and grab the value
|
||||
LONGLONG totalSz = 0;
|
||||
bRC = GetLastValue( frag.mFragmentValue, totalSz );
|
||||
if (bRC == true)
|
||||
{
|
||||
// Convert to bits?
|
||||
if (frag.mFragmentType == eDB2_FRAGMENT_VARIABLE_PAD_BYTES)
|
||||
{
|
||||
totalSz *= BITS_PER_BYTE;
|
||||
}
|
||||
|
||||
// Is the structure is smaller than the specified
|
||||
// value that we are to pad out to?
|
||||
if ((ULONG)totalSz >= structSize)
|
||||
{
|
||||
ULONG newOffset = structOffset + (ULONG)totalSz;
|
||||
SetOffset( newOffset );
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case eDB2_FRAGMENT_FULL_BYTE_PAD:
|
||||
{
|
||||
ULONG totalSz = structSize;
|
||||
while ((totalSz % BITS_PER_BYTE) != 0)
|
||||
{
|
||||
totalSz++;
|
||||
}
|
||||
|
||||
if (totalSz > structSize)
|
||||
{
|
||||
ULONG newOffset = structOffset + totalSz;
|
||||
SetOffset( newOffset );
|
||||
}
|
||||
|
||||
// Succcess!
|
||||
bRC = true;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
bRC = false;
|
||||
break;
|
||||
}
|
||||
|
||||
// Adjust struct size?
|
||||
if (bRC == true)
|
||||
{
|
||||
ULONG newOffset = GetOffset();
|
||||
if (newOffset > structOffset)
|
||||
{
|
||||
ULONG newSz = newOffset - structOffset;
|
||||
if (newSz > structSize)
|
||||
{
|
||||
structSize = newSz;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bRC;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetPartialFieldName (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Return the fully qualified field name given the partial name
|
||||
|
||||
PARAMETERS:
|
||||
partialName [ I ] - Partial field name
|
||||
|
||||
RETURN VALUE:
|
||||
std::string
|
||||
===========================================================================*/
|
||||
std::string cProtocolEntityNav::GetFullFieldName(
|
||||
const std::string & partialName ) const
|
||||
{
|
||||
std::string retStr = EMPTY_STRING;
|
||||
|
||||
if (mEntity.mpName != 0 && mEntity.mpName != EMPTY_STRING)
|
||||
{
|
||||
retStr = mEntity.mpName;
|
||||
retStr += PE_NAV_FIELD_SEP;
|
||||
retStr += partialName;
|
||||
}
|
||||
|
||||
return retStr;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetPartialFieldName (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Return the partial field name given the fully qualified name
|
||||
|
||||
PARAMETERS:
|
||||
fieldNameFQ [ I ] - Fully qualified name
|
||||
|
||||
RETURN VALUE:
|
||||
std::string
|
||||
===========================================================================*/
|
||||
std::string cProtocolEntityNav::GetPartialFieldName(
|
||||
const std::string & fieldNameFQ ) const
|
||||
{
|
||||
std::string retStr = EMPTY_STRING;
|
||||
|
||||
if (mEntity.mpName != 0 && mEntity.mpName != EMPTY_STRING)
|
||||
{
|
||||
int idx = fieldNameFQ.find( mEntity.mpName, 0 );
|
||||
if (idx == 0)
|
||||
{
|
||||
idx = fieldNameFQ.find( PE_NAV_FIELD_SEP );
|
||||
if (idx != -1)
|
||||
{
|
||||
retStr = fieldNameFQ.substr( idx - 1 );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return retStr;
|
||||
}
|
|
@ -0,0 +1,246 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
ProtocolEntityNav.h
|
||||
|
||||
DESCRIPTION:
|
||||
Declaration of cProtocolEntityNav
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
cProtocolEntityNav
|
||||
This class serves as a base for all class that need to
|
||||
'navigate' a protocol entity database description. It is
|
||||
necessary in order to seperate the structural aspects
|
||||
from parsing/packing details
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "CoreDatabase.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
struct sSharedBuffer;
|
||||
struct sDB2NavFragment;
|
||||
|
||||
// Field seperator string
|
||||
extern LPCSTR PE_NAV_FIELD_SEP;
|
||||
|
||||
// Types of protocol entity field attributes
|
||||
enum ePENavFieldAttr
|
||||
{
|
||||
ePENAV_FIELD_BEGIN = -1,
|
||||
|
||||
ePENAV_FIELD_NAME, // Name of field
|
||||
ePENAV_FIELD_NAME_FULL, // Fully qualified name of field
|
||||
ePENAV_FIELD_NAME_PARTIAL, // Partially qualified name of field
|
||||
ePENAV_FIELD_VALUE, // Translated value of field
|
||||
ePENAV_FIELD_VALUE_RAW, // Raw value of field
|
||||
ePENAV_FIELD_TYPE, // Type of field
|
||||
ePENAV_FIELD_SIZE, // Size of field
|
||||
ePENAV_FIELD_OFFSET, // Offset of field
|
||||
ePENAV_FIELD_INDEX, // Index of field
|
||||
ePENAV_FIELD_ID, // ID of field
|
||||
|
||||
ePENAV_FIELD_END // Number of field attributes
|
||||
};
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
IsValid (Inline Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Is this a valid ePENavFieldAttr?
|
||||
|
||||
PARAMETERS:
|
||||
contentType [ I ] - The enum value being validated
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
inline bool IsValid( ePENavFieldAttr attr )
|
||||
{
|
||||
bool bRC = false;
|
||||
if (attr > ePENAV_FIELD_BEGIN && attr < ePENAV_FIELD_END)
|
||||
{
|
||||
bRC = true;
|
||||
}
|
||||
|
||||
return bRC;
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Class cProtocolEntityNav
|
||||
// Class to navigate a protocol entity
|
||||
/*=========================================================================*/
|
||||
class cProtocolEntityNav
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
cProtocolEntityNav( const cCoreDatabase & db );
|
||||
|
||||
// Destructor
|
||||
virtual ~cProtocolEntityNav();
|
||||
|
||||
// Return the fully qualified field name given the partial name
|
||||
virtual std::string GetFullFieldName( const std::string & partialName ) const;
|
||||
|
||||
// Return the partial field name given the fully qualified name
|
||||
virtual std::string GetPartialFieldName(
|
||||
const std::string & fieldNameFQ ) const;
|
||||
|
||||
protected:
|
||||
// Evaluate the given condition
|
||||
virtual bool EvaluateCondition(
|
||||
LPCSTR pCondition,
|
||||
bool & bResult );
|
||||
|
||||
// Get the array bounds described by the fragment descriptor
|
||||
virtual bool GetArrayBounds(
|
||||
const sDB2Fragment & frag,
|
||||
LONGLONG & arraySz,
|
||||
LONGLONG & arrayAdj );
|
||||
|
||||
// Return the value for the specified field ID as a
|
||||
// LONGLONG (field type must be able to fit)
|
||||
virtual bool GetLastValue(
|
||||
ULONG fieldID,
|
||||
LONGLONG & val ) = 0;
|
||||
|
||||
// Modify string length based on existing field value
|
||||
virtual bool ModifyStringLength(
|
||||
const sDB2Fragment & frag,
|
||||
sDB2Field & field );
|
||||
|
||||
// Process the protocol entity described by the given key/name
|
||||
virtual bool ProcessEntity( const std::vector <ULONG> & key );
|
||||
|
||||
// (Inline) Contiue navigation now that entity has been set?
|
||||
virtual bool ContinueNavigation()
|
||||
{
|
||||
// Override to implement
|
||||
return true;
|
||||
};
|
||||
|
||||
// Process a structure described by the given initial fragment
|
||||
virtual bool ProcessStruct(
|
||||
const sDB2NavFragment * pFrag,
|
||||
const std::string & preamble,
|
||||
LONGLONG arrayIndex = -1 );
|
||||
|
||||
// Process the given fragment
|
||||
virtual bool ProcessFragment(
|
||||
const sDB2NavFragment * pFrag,
|
||||
ULONG structOffset,
|
||||
ULONG & structSize,
|
||||
const std::string & preamble );
|
||||
|
||||
// Process the given field
|
||||
virtual bool ProcessField(
|
||||
const sDB2Field * pField,
|
||||
const std::string & fieldName,
|
||||
LONGLONG arrayIndex = -1 ) = 0;
|
||||
|
||||
// (Inline) Handle an array being entered
|
||||
virtual void EnterArray(
|
||||
const sDB2Fragment & /* frag */,
|
||||
LONGLONG /* arraySz */ )
|
||||
{ };
|
||||
|
||||
// (Inline) Handle an array being exited
|
||||
virtual void ExitArray(
|
||||
const sDB2Fragment & /* frag */,
|
||||
LONGLONG /* arraySz */ )
|
||||
{ };
|
||||
|
||||
// (Inline) Handle a structure being entered
|
||||
virtual void EnterStruct(
|
||||
LPCSTR /* pName */,
|
||||
LONGLONG /* arrayIndex */ )
|
||||
{ };
|
||||
|
||||
// (Inline) Handle a structure being exited
|
||||
virtual void ExitStruct(
|
||||
LPCSTR /* pName */,
|
||||
LONGLONG /* arrayIndex */ )
|
||||
{ };
|
||||
|
||||
// (Inline) Get current working offset
|
||||
virtual ULONG GetOffset()
|
||||
{
|
||||
// Override to implement
|
||||
return 0;
|
||||
};
|
||||
|
||||
// (Inline) Set current working offset
|
||||
virtual bool SetOffset( ULONG /* offset */ )
|
||||
{
|
||||
// Override to implement
|
||||
return true;
|
||||
};
|
||||
|
||||
// (Inline) Get current navigation order
|
||||
virtual bool GetLSBMode()
|
||||
{
|
||||
// Override to implement
|
||||
return true;
|
||||
};
|
||||
|
||||
// (Inline) Set current navigation order
|
||||
virtual bool SetLSBMode( bool /* bLSB */ )
|
||||
{
|
||||
// Override to implement
|
||||
return true;
|
||||
};
|
||||
|
||||
/* Generate field name strings? */
|
||||
bool mbFieldNames;
|
||||
|
||||
/* Protocol entity being navigated */
|
||||
sDB2ProtocolEntity mEntity;
|
||||
|
||||
/* Database reference */
|
||||
const cCoreDatabase & mDB;
|
||||
|
||||
/* References to DB tables we need */
|
||||
const tDB2OptionalModMap & mConditions;
|
||||
const tDB2ExpressionModMap & mExpressions;
|
||||
const tDB2Array1ModMap & mArrays1;
|
||||
const tDB2Array2ModMap & mArrays2;
|
||||
|
||||
/* Map of all 'tracked' fields */
|
||||
std::map <ULONG, std::pair <bool, LONGLONG> > mTrackedFields;
|
||||
};
|
|
@ -0,0 +1,214 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
ProtocolEnum.h
|
||||
|
||||
DESCRIPTION:
|
||||
Generic protocol enumerations and related methods
|
||||
|
||||
PUBLIC ENUMERATIONS AND METHODS:
|
||||
eProtocolType
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
/*=========================================================================*/
|
||||
// eProtocolType Enumeration
|
||||
/*=========================================================================*/
|
||||
enum eProtocolType
|
||||
{
|
||||
ePROTOCOL_ENUM_BEGIN = -1,
|
||||
|
||||
ePROTOCOL_COMMAND, // 00 Protocol server command
|
||||
ePROTOCOL_AT, // 01 AT command protocol
|
||||
ePROTOCOL_NMEA, // 02 NMEA (GPS) protocol
|
||||
ePROTOCOL_DIAG_RX, // 03 DIAG protocol (incoming)
|
||||
ePROTOCOL_DIAG_TX, // 04 DIAG protocol (outgoing)
|
||||
ePROTOCOL_DOWNLOAD_RX, // 05 Download protocol (incoming)
|
||||
ePROTOCOL_DOWNLOAD_TX, // 06 Download protocol (outgoing)
|
||||
ePROTOCOL_SDOWNLOAD_RX, // 07 Streaming download protocol (incoming)
|
||||
ePROTOCOL_SDOWNLOAD_TX, // 08 Streaming download protocol (outgoing)
|
||||
ePROTOCOL_QDL_RX, // 09 QDL variant of streaming protocol (incoming)
|
||||
ePROTOCOL_QDL_TX, // 10 QDL variant of streaming protocol (outgoing)
|
||||
ePROTOCOL_QMI_CTL_RX, // 11 QMI CTL protocol (incoming)
|
||||
ePROTOCOL_QMI_CTL_TX, // 12 QMI CTL protocol (outgoing)
|
||||
ePROTOCOL_QMI_WDS_RX, // 13 QMI WDS protocol (incoming)
|
||||
ePROTOCOL_QMI_WDS_TX, // 14 QMI WDS protocol (outgoing)
|
||||
ePROTOCOL_QMI_DMS_RX, // 15 QMI DMS protocol (incoming)
|
||||
ePROTOCOL_QMI_DMS_TX, // 16 QMI DMS protocol (outgoing)
|
||||
ePROTOCOL_QMI_NAS_RX, // 17 QMI NAS protocol (incoming)
|
||||
ePROTOCOL_QMI_NAS_TX, // 18 QMI NAS protocol (outgoing)
|
||||
ePROTOCOL_QMI_QOS_RX, // 19 QMI QOS protocol (incoming)
|
||||
ePROTOCOL_QMI_QOS_TX, // 20 QMI QOS protocol (outgoing)
|
||||
ePROTOCOL_QMI_WMS_RX, // 21 QMI WMS protocol (incoming)
|
||||
ePROTOCOL_QMI_WMS_TX, // 22 QMI WMS protocol (outgoing)
|
||||
ePROTOCOL_QMI_PDS_RX, // 23 QMI PDS protocol (incoming)
|
||||
ePROTOCOL_QMI_PDS_TX, // 24 QMI PDS protocol (outgoing)
|
||||
ePROTOCOL_QMI_AUTH_RX, // 25 QMI AUTH protocol (incoming)
|
||||
ePROTOCOL_QMI_AUTH_TX, // 26 QMI AUTH protocol (outgoing)
|
||||
ePROTOCOL_QMI_CAT_RX, // 27 QMI CAT protocol (incoming)
|
||||
ePROTOCOL_QMI_CAT_TX, // 28 QMI CAT protocol (outgoing)
|
||||
ePROTOCOL_QMI_RMS_RX, // 29 QMI RMS protocol (incoming)
|
||||
ePROTOCOL_QMI_RMS_TX, // 30 QMI RMS protocol (outgoing)
|
||||
ePROTOCOL_QMI_OMA_RX, // 31 QMI OMA protocol (incoming)
|
||||
ePROTOCOL_QMI_OMA_TX, // 32 QMI OMA protocol (outgoing)
|
||||
ePROTOCOL_QMI_VOICE_RX, // 33 QMI Voice protocol (incoming)
|
||||
ePROTOCOL_QMI_VOICE_TX, // 34 QMI Voice protocol (outgoing)
|
||||
|
||||
ePROTOCOL_ENUM_END
|
||||
};
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
IsValid (Inline Method)
|
||||
|
||||
DESCRIPTION:
|
||||
eProtocolType validity check
|
||||
|
||||
PARAMETERS:
|
||||
pt [ I ] - Enum value being verified
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
inline bool IsValid( eProtocolType pt )
|
||||
{
|
||||
bool retVal = false;
|
||||
if (pt > ePROTOCOL_ENUM_BEGIN && pt < ePROTOCOL_ENUM_END)
|
||||
{
|
||||
retVal = true;
|
||||
}
|
||||
|
||||
return retVal;
|
||||
};
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
IsQMIProtocol (Inline Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Does the passed in value represent a QMI protocol?
|
||||
|
||||
PARAMETERS:
|
||||
pt [ I ] - Enum value being checked
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
inline bool IsQMIProtocol( eProtocolType pt )
|
||||
{
|
||||
bool retVal = false;
|
||||
if (pt >= ePROTOCOL_QMI_CTL_RX && pt <= ePROTOCOL_QMI_VOICE_TX)
|
||||
{
|
||||
retVal = true;
|
||||
}
|
||||
|
||||
return retVal;
|
||||
};
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
IsQMIProtocolRX (Inline Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Does the passed in value represent a QMI protocol and if so in the
|
||||
incoming direction?
|
||||
|
||||
PARAMETERS:
|
||||
pt [ I ] - Enum value being checked
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
inline bool IsQMIProtocolRX( eProtocolType pt )
|
||||
{
|
||||
bool retVal = false;
|
||||
|
||||
switch (pt)
|
||||
{
|
||||
case ePROTOCOL_QMI_CTL_RX:
|
||||
case ePROTOCOL_QMI_WDS_RX:
|
||||
case ePROTOCOL_QMI_DMS_RX:
|
||||
case ePROTOCOL_QMI_NAS_RX:
|
||||
case ePROTOCOL_QMI_QOS_RX:
|
||||
case ePROTOCOL_QMI_WMS_RX:
|
||||
case ePROTOCOL_QMI_PDS_RX:
|
||||
case ePROTOCOL_QMI_AUTH_RX:
|
||||
case ePROTOCOL_QMI_CAT_RX:
|
||||
case ePROTOCOL_QMI_RMS_RX:
|
||||
case ePROTOCOL_QMI_OMA_RX:
|
||||
case ePROTOCOL_QMI_VOICE_RX:
|
||||
retVal = true;
|
||||
break;
|
||||
}
|
||||
|
||||
return retVal;
|
||||
};
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
IsQMIProtocolTX (Inline Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Does the passed in value represent a QMI protocol and if so in the
|
||||
outgoing direction?
|
||||
|
||||
PARAMETERS:
|
||||
pt [ I ] - Enum value being checked
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
inline bool IsQMIProtocolTX( eProtocolType pt )
|
||||
{
|
||||
bool retVal = false;
|
||||
|
||||
switch (pt)
|
||||
{
|
||||
case ePROTOCOL_QMI_CTL_TX:
|
||||
case ePROTOCOL_QMI_WDS_TX:
|
||||
case ePROTOCOL_QMI_DMS_TX:
|
||||
case ePROTOCOL_QMI_NAS_TX:
|
||||
case ePROTOCOL_QMI_QOS_TX:
|
||||
case ePROTOCOL_QMI_WMS_TX:
|
||||
case ePROTOCOL_QMI_PDS_TX:
|
||||
case ePROTOCOL_QMI_AUTH_TX:
|
||||
case ePROTOCOL_QMI_CAT_TX:
|
||||
case ePROTOCOL_QMI_RMS_TX:
|
||||
case ePROTOCOL_QMI_OMA_TX:
|
||||
case ePROTOCOL_QMI_VOICE_TX:
|
||||
retVal = true;
|
||||
break;
|
||||
}
|
||||
|
||||
return retVal;
|
||||
};
|
|
@ -0,0 +1,190 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
ProtocolLog.h
|
||||
|
||||
DESCRIPTION:
|
||||
Simple protocol 'log' class definition
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
cProtocolLog
|
||||
This class stores protocol buffers in to a flat array (actually a
|
||||
double-ended queue) so that they can be accessed by other objects
|
||||
during the flow of normal processing. Note that the storage is
|
||||
in-memory and therefore finite
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "StdAfx.h"
|
||||
#include "ProtocolLog.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// The maximum number of in-memory buffers we allow
|
||||
const ULONG MAX_PROTOCOL_BUFFERS = 1024 * 16;
|
||||
|
||||
/*=========================================================================*/
|
||||
// cProtocolLog Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
cProtocolLog (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Constructor
|
||||
|
||||
PARAMETERS:
|
||||
maxBuffers [ I ] - Maximum number of buffers to store in the log
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cProtocolLog::cProtocolLog( ULONG maxBuffers )
|
||||
: mLog( maxBuffers > MAX_PROTOCOL_BUFFERS ? MAX_PROTOCOL_BUFFERS : maxBuffers,
|
||||
true )
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
~cProtocolLog (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Destructor
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cProtocolLog::~cProtocolLog()
|
||||
{
|
||||
// Empty out the log
|
||||
Clear();
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
AddBuffer (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Add an protocol buffer to the end of the log
|
||||
|
||||
PARAMETERS:
|
||||
buff [ I ] - Protocol buffer to add
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Index of newly added buffer (INVALID_LOG_INDEX upon failure)
|
||||
===========================================================================*/
|
||||
ULONG cProtocolLog::AddBuffer( sProtocolBuffer & buf )
|
||||
{
|
||||
ULONG idx = INVALID_LOG_INDEX;
|
||||
if (buf.IsValid() == false)
|
||||
{
|
||||
return idx;
|
||||
}
|
||||
|
||||
bool bRC = mLog.AddElement( buf, idx );
|
||||
if (bRC == false)
|
||||
{
|
||||
idx = INVALID_LOG_INDEX;
|
||||
}
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetBuffer (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Return the protocol buffer at the given index from the log
|
||||
|
||||
PARAMETERS:
|
||||
idx [ I ] - Index of protocol buffer to obtain
|
||||
|
||||
RETURN VALUE:
|
||||
sProtocolBuffer - Protocol buffer
|
||||
===========================================================================*/
|
||||
sProtocolBuffer cProtocolLog::GetBuffer( ULONG idx ) const
|
||||
{
|
||||
sProtocolBuffer buf;
|
||||
mLog.GetElement( idx, buf );
|
||||
return buf;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetSignalEvent (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Return the underlying signal event, which will be set when
|
||||
the log is updated.
|
||||
|
||||
RETURN VALUE:
|
||||
cEvent - Signal event
|
||||
===========================================================================*/
|
||||
cEvent & cProtocolLog::GetSignalEvent() const
|
||||
{
|
||||
return mLog.GetSignalEvent();
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetCount (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Return the total number of buffers added to the log
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG
|
||||
===========================================================================*/
|
||||
ULONG cProtocolLog::GetCount() const
|
||||
{
|
||||
return mLog.GetTotalCount();
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
Clear (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Clear the log
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
void cProtocolLog::Clear()
|
||||
{
|
||||
mLog.EmptyQueue();
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
ProtocolLog.h
|
||||
|
||||
DESCRIPTION:
|
||||
Simple protocol 'log' class declaration
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
cProtocolLog
|
||||
This class stores protocol buffers in to a flat array (actually a
|
||||
double-ended queue) so that they can be accessed by other objects
|
||||
during the flow of normal processing. Note that the storage is
|
||||
in-memory and therefore finite
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "ProtocolBuffer.h"
|
||||
#include "SyncQueue.h"
|
||||
|
||||
#include <climits>
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
const ULONG INVALID_LOG_INDEX = ULONG_MAX;
|
||||
|
||||
/*=========================================================================*/
|
||||
// Class cProtocolLog
|
||||
/*=========================================================================*/
|
||||
class cProtocolLog
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
cProtocolLog( ULONG maxBuffers );
|
||||
|
||||
// Destructor
|
||||
virtual ~cProtocolLog();
|
||||
|
||||
// Add an protocol buffer to the end of the log
|
||||
virtual ULONG AddBuffer( sProtocolBuffer & buf );
|
||||
|
||||
// Return the protocol buffer at the given index from the log
|
||||
virtual sProtocolBuffer GetBuffer( ULONG idx ) const;
|
||||
|
||||
// Return the underlying signal event
|
||||
virtual cEvent & GetSignalEvent() const;
|
||||
|
||||
// Return the total number of buffers added to the log
|
||||
virtual ULONG GetCount() const;
|
||||
|
||||
// Clear the log
|
||||
virtual void Clear();
|
||||
|
||||
protected:
|
||||
/* The underlying 'log' */
|
||||
cSyncQueue <sProtocolBuffer> mLog;
|
||||
};
|
|
@ -0,0 +1,171 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
ProtocolNotification.cpp
|
||||
|
||||
DESCRIPTION:
|
||||
Implementation of cProtocolNotification base class and derivations
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
sProtocolNotificationEvent
|
||||
Generic protocol event notification structure
|
||||
|
||||
cProtocolNotification
|
||||
This abstract base class provides notification of protocol server
|
||||
events sent from the protocol server to protocol server clients
|
||||
|
||||
cProtocolQueueNotification
|
||||
This class provides notification via a cSyncQueue object
|
||||
populated with sProtocolNotificationEvent objects
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "StdAfx.h"
|
||||
#include "ProtocolNotification.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
/*=========================================================================*/
|
||||
// cProtocolQueueNotification Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
cProtocolQueueNotification (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Constructor
|
||||
|
||||
PARAMETERS:
|
||||
pSQ [ I ] - Sync queue to utilize
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cProtocolQueueNotification::cProtocolQueueNotification(
|
||||
cSyncQueue <sProtocolNotificationEvent> * pSQ )
|
||||
: mpSQ( pSQ )
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
cProtocolQueueNotification (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Copy constructor
|
||||
|
||||
PARAMETERS:
|
||||
notifier [ I ] - Notifier to base the new one on
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cProtocolQueueNotification::cProtocolQueueNotification(
|
||||
const cProtocolQueueNotification & notifier )
|
||||
: mpSQ( notifier.mpSQ )
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
~cProtocolQueueNotification (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Destructor
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cProtocolQueueNotification::~cProtocolQueueNotification()
|
||||
{
|
||||
mpSQ = 0;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
Clone (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Return an allocated copy of this object downcasted to our base class
|
||||
|
||||
RETURN VALUE:
|
||||
cProtocolNotification * : Cloned object (0 on error)
|
||||
===========================================================================*/
|
||||
cProtocolNotification * cProtocolQueueNotification::Clone() const
|
||||
{
|
||||
cProtocolQueueNotification * pCopy = 0;
|
||||
|
||||
try
|
||||
{
|
||||
pCopy = new cProtocolQueueNotification( *this );
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// Simply return 0
|
||||
}
|
||||
|
||||
return ((cProtocolNotification *)pCopy);
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
Notify (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Notify view of a protocol event by adding notification structure to
|
||||
the underlying sync queue (which will provide the notification
|
||||
by signalling an event)
|
||||
|
||||
PARAMETERS:
|
||||
eventType [ I ] - Protocol event type
|
||||
param1 [ I ] - Event type specific argument (see header description)
|
||||
param2 [ I ] - Event type specific argument (see header description)
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
void cProtocolQueueNotification::Notify(
|
||||
eProtocolEventType eventType,
|
||||
DWORD param1,
|
||||
DWORD param2 ) const
|
||||
{
|
||||
sProtocolNotificationEvent evt( eventType, param1, param2 );
|
||||
if (evt.IsValid() == true && mpSQ != 0 && mpSQ->IsValid() == true)
|
||||
{
|
||||
sProtocolNotificationEvent elem( eventType, param1, param2 );
|
||||
mpSQ->AddElement( elem );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,237 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
ProtocolNotification.h
|
||||
|
||||
DESCRIPTION:
|
||||
Declaration of cProtocolNotification base class and derivations
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
sProtocolNotificationEvent
|
||||
Generic protocol event notification structure
|
||||
|
||||
cProtocolNotification
|
||||
This abstract base class provides notification of protocol server
|
||||
events sent from the protocol server to protocol server clients
|
||||
|
||||
cProtocolQueueNotification
|
||||
This class provides notification via a cSyncQueue object
|
||||
populated with sProtocolNotificationEvent objects
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "SyncQueue.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
enum eProtocolEventType
|
||||
{
|
||||
ePROTOCOL_EVT_BEGIN = -1,
|
||||
|
||||
ePROTOCOL_EVT_REQ_ERR, // There was an error sending the request
|
||||
ePROTOCOL_EVT_REQ_SENT, // The request has been sent
|
||||
|
||||
ePROTOCOL_EVT_RSP_ERR, // There was an error receiving the response
|
||||
ePROTOCOL_EVT_RSP_RECV, // The response has been received
|
||||
|
||||
ePROTOCOL_EVT_AUX_TU_SENT, // Auxiliary data transmission unit sent
|
||||
|
||||
ePROTOCOL_EVT_END
|
||||
};
|
||||
|
||||
// NOTE: The arguments for each event are currently as follows:
|
||||
//
|
||||
// ePROTOCOL_EVT_REQ_ERR
|
||||
// param1: Request ID
|
||||
// param2: Error code
|
||||
//
|
||||
// ePROTOCOL_EVT_REQ_SENT
|
||||
// param1: Request ID
|
||||
// param2: Index of request buffer in associated protocol log
|
||||
|
||||
// ePROTOCOL_EVT_RSP_ERR
|
||||
// param1: Request ID
|
||||
// param2: Error code
|
||||
//
|
||||
// ePROTOCOL_EVT_RSP_RECV
|
||||
// param1: Request ID
|
||||
// param2: Index of response buffer in associated protocol log
|
||||
//
|
||||
// ePROTOCOL_EVT_AUX_TU_SENT
|
||||
// param1: Request ID
|
||||
// param2: Size of transmission unit
|
||||
|
||||
// NOTE: To handle protoocl events using the Windows notifier add the following
|
||||
// prototype to your Window class header file:
|
||||
//
|
||||
// afx_msg LRESULT OnProtocolEvent(
|
||||
// WPARAM wParam,
|
||||
// LPARAM lParam );
|
||||
//
|
||||
// Then add an entry to the message map in your Window class source file:
|
||||
//
|
||||
// BEGIN_MESSAGE_MAP( CView, CChildView )
|
||||
// ON_MESSAGE( PROTOCOL_WM_BASE + (ULONG)ePROTOCOL_EVT_XXX, OnProtocolEvent )
|
||||
// END_MESSAGE_MAP()
|
||||
//
|
||||
// Finally write the handler itself:
|
||||
//
|
||||
// LRESULT CView::OnProtocolEvent(
|
||||
// WPARAM wParam,
|
||||
// LPARAM lParam )
|
||||
// {
|
||||
// Do something
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
IsValid (Inline Method)
|
||||
|
||||
DESCRIPTION:
|
||||
eProtocolEventType validity check
|
||||
|
||||
PARAMETERS:
|
||||
evtType [ I ] - Enum value being verified
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
inline bool IsValid( eProtocolEventType evtType )
|
||||
{
|
||||
bool bRC = false;
|
||||
if (evtType > ePROTOCOL_EVT_BEGIN && evtType < ePROTOCOL_EVT_END)
|
||||
{
|
||||
bRC = true;
|
||||
}
|
||||
|
||||
return bRC;
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sProtocolNotificationEvent
|
||||
/*=========================================================================*/
|
||||
struct sProtocolNotificationEvent
|
||||
{
|
||||
public:
|
||||
// (Inline) Default constructor (results in invalid object)
|
||||
sProtocolNotificationEvent()
|
||||
: mEventType( ePROTOCOL_EVT_BEGIN ),
|
||||
mParam1( 0 ),
|
||||
mParam2( 0 )
|
||||
{
|
||||
// Nothing to do
|
||||
};
|
||||
|
||||
// (Inline) Parameter constructor
|
||||
sProtocolNotificationEvent(
|
||||
eProtocolEventType eventType,
|
||||
DWORD param1,
|
||||
DWORD param2 )
|
||||
: mEventType( eventType ),
|
||||
mParam1( param1 ),
|
||||
mParam2( param2 )
|
||||
{
|
||||
// Nothing to do
|
||||
};
|
||||
|
||||
// (Inline) Is this object valid?
|
||||
bool IsValid()
|
||||
{
|
||||
return ::IsValid( mEventType );
|
||||
}
|
||||
|
||||
/* Event type */
|
||||
eProtocolEventType mEventType;
|
||||
|
||||
/* First parameter (see above) */
|
||||
DWORD mParam1;
|
||||
|
||||
/* Second parameter (see above) */
|
||||
DWORD mParam2;
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Class cProtocolNotification
|
||||
//
|
||||
// This abstract base class provides notification of protocol server
|
||||
// events sent from the protocol server to protocol server clients
|
||||
/*=========================================================================*/
|
||||
class cProtocolNotification
|
||||
{
|
||||
public:
|
||||
// Return an allocated copy of this object
|
||||
virtual cProtocolNotification * Clone() const = 0;
|
||||
|
||||
// Notify view of a protocol event
|
||||
virtual void Notify(
|
||||
eProtocolEventType eventType,
|
||||
DWORD param1,
|
||||
DWORD param2 ) const = 0;
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Class cProtocolQueueNotification
|
||||
//
|
||||
// This class provides notification via a cSyncQueue object
|
||||
// populated with sProtocolNotificationEvent objects
|
||||
/*=========================================================================*/
|
||||
class cProtocolQueueNotification : public cProtocolNotification
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
cProtocolQueueNotification( cSyncQueue <sProtocolNotificationEvent> * pSQ );
|
||||
|
||||
// Copy constructor
|
||||
cProtocolQueueNotification( const cProtocolQueueNotification & notifier );
|
||||
|
||||
// Destructor
|
||||
virtual ~cProtocolQueueNotification();
|
||||
|
||||
// Return a copy of this object
|
||||
virtual cProtocolNotification * Clone() const;
|
||||
|
||||
// Notify view of a MIS event
|
||||
virtual void Notify(
|
||||
eProtocolEventType eventType,
|
||||
DWORD param1,
|
||||
DWORD param2 ) const;
|
||||
|
||||
protected:
|
||||
/* Event notification queue */
|
||||
mutable cSyncQueue <sProtocolNotificationEvent> * mpSQ;
|
||||
};
|
|
@ -0,0 +1,254 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
ProtocolRequest.cpp
|
||||
|
||||
DESCRIPTION:
|
||||
Generic protocol request/command related structures and
|
||||
affliated methods, these structures are used by clients of
|
||||
the protocol server to specify outgoing requests
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
sProtocolRequest
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "ProtocolRequest.h"
|
||||
#include "ProtocolNotification.h"
|
||||
#include "ProtocolServer.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// Default protocol request timeout
|
||||
const ULONG DEFAULT_REQ_TIMEOUT = 1000;
|
||||
|
||||
// Minimum and maximum allowable timeout values (in milliseconds)
|
||||
const ULONG MIN_REQ_TIMEOUT = 100;
|
||||
const ULONG MAX_REQ_TIMEOUT = 300000;
|
||||
|
||||
// Minimum number of attempts a request can be scheduled for
|
||||
const ULONG MIN_REQ_ATTEMPTS = 1;
|
||||
|
||||
// Value to indicate that a request is to be sent out indefinately
|
||||
const ULONG INFINITE_REQS = 0xFFFFFFFF;
|
||||
|
||||
// Minimum/default amount of time between repeated requests (in milliseconds)
|
||||
const ULONG MIN_REQ_FREQUENCY = 10;
|
||||
const ULONG DEFAULT_REQ_FREQUENCY = 100;
|
||||
|
||||
/*=========================================================================*/
|
||||
// sProtocolRequest Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
sProtocolRequest
|
||||
|
||||
DESCRIPTION:
|
||||
Parameterized constructor
|
||||
|
||||
PARAMETERS:
|
||||
pBuffer [ I ] - Shareable buffer representing the request (must be
|
||||
valid)
|
||||
|
||||
schedule [ I ] - When (from now, in milliseconds) to send the first
|
||||
request, this isn't a hard value as the request is
|
||||
only guaranteed to go out after this time elapses
|
||||
|
||||
timeout [ I ] - Milliseconds to wait for a response to an individual
|
||||
request before declaring a timeout. Regardless of
|
||||
what is passed in the timeout value used will be
|
||||
between MIN/MAX_REQ_TIMEOUT
|
||||
|
||||
requests [ I ] - Number of request attempts to make, this isn't a
|
||||
retry count rather this value is used to specify
|
||||
repeating requests. Regardless of what is passed in
|
||||
the requests value used will be at least
|
||||
MIN_REQ_ATTEMPTS
|
||||
|
||||
frequency [ I ] - If the 'requests' value is greater than the
|
||||
MIN_REQ_ATTEMPTS than this represents the amount of
|
||||
time to wait between requests (from the completion of
|
||||
the last request attempt, in milliseconds), again this
|
||||
isn't a hard value. Regardless of what is passed in
|
||||
the frequency value used will be at least
|
||||
MIN_REQ_FREQUENCY
|
||||
|
||||
pNotifier [ I ] - Status notification mechanism (may be 0)
|
||||
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
sProtocolRequest::sProtocolRequest(
|
||||
sSharedBuffer * pBuffer,
|
||||
ULONG schedule,
|
||||
ULONG timeout,
|
||||
ULONG requests,
|
||||
ULONG frequency,
|
||||
cProtocolNotification * pNotifier )
|
||||
: sProtocolBuffer( pBuffer ),
|
||||
mSchedule( schedule ),
|
||||
mTimeout( DEFAULT_REQ_TIMEOUT ),
|
||||
mRequests( MIN_REQ_ATTEMPTS ),
|
||||
mFrequency( DEFAULT_REQ_FREQUENCY ),
|
||||
mpNotifier( 0 ),
|
||||
mpAuxData( 0 ),
|
||||
mAuxDataSize( 0 ),
|
||||
mbTXOnly( false )
|
||||
{
|
||||
// Constrain requested timeout to allowable range
|
||||
if (timeout < MIN_REQ_TIMEOUT)
|
||||
{
|
||||
timeout = MIN_REQ_TIMEOUT;
|
||||
}
|
||||
|
||||
if (timeout > MAX_REQ_TIMEOUT)
|
||||
{
|
||||
timeout = MAX_REQ_TIMEOUT;
|
||||
}
|
||||
|
||||
mTimeout = timeout;
|
||||
|
||||
// Constrain request attempts
|
||||
if (requests >= MIN_REQ_ATTEMPTS)
|
||||
{
|
||||
mRequests = requests;
|
||||
}
|
||||
|
||||
// Constrain frequency
|
||||
if (frequency >= MIN_REQ_FREQUENCY)
|
||||
{
|
||||
mFrequency = frequency;
|
||||
}
|
||||
|
||||
// Clone notifier?
|
||||
if (pNotifier != 0)
|
||||
{
|
||||
mpNotifier = pNotifier->Clone();
|
||||
}
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
sProtocolRequest
|
||||
|
||||
DESCRIPTION:
|
||||
Parameterized constructor (notification with defaults)
|
||||
|
||||
PARAMETERS:
|
||||
pBuffer [ I ] - Shareable buffer representing the request (must be
|
||||
valid)
|
||||
|
||||
pNotifier [ I ] - Status notification mechanism (may be 0)
|
||||
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
sProtocolRequest::sProtocolRequest(
|
||||
sSharedBuffer * pBuffer,
|
||||
cProtocolNotification * pNotifier )
|
||||
: sProtocolBuffer( pBuffer ),
|
||||
mSchedule( 0 ),
|
||||
mTimeout( DEFAULT_REQ_TIMEOUT ),
|
||||
mRequests( MIN_REQ_ATTEMPTS ),
|
||||
mFrequency( DEFAULT_REQ_FREQUENCY ),
|
||||
mpNotifier( pNotifier ),
|
||||
mpAuxData( 0 ),
|
||||
mAuxDataSize( 0 ),
|
||||
mbTXOnly( false )
|
||||
{
|
||||
// Clone notifier?
|
||||
if (pNotifier != 0)
|
||||
{
|
||||
mpNotifier = pNotifier->Clone();
|
||||
}
|
||||
|
||||
Validate();
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
sProtocolRequest
|
||||
|
||||
DESCRIPTION:
|
||||
Copy constructor
|
||||
|
||||
PARAMETERS:
|
||||
req [ I ] - Request to copy
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
sProtocolRequest::sProtocolRequest( const sProtocolRequest & req )
|
||||
: sProtocolBuffer( req ),
|
||||
mSchedule( req.mSchedule ),
|
||||
mTimeout( req.mTimeout ),
|
||||
mRequests( req.mRequests ),
|
||||
mFrequency( req.mFrequency ),
|
||||
mpNotifier( 0 ),
|
||||
mpAuxData( req.mpAuxData ),
|
||||
mAuxDataSize( req.mAuxDataSize ),
|
||||
mbTXOnly( req.mbTXOnly )
|
||||
{
|
||||
// Clone notifier?
|
||||
if (req.mpNotifier != 0)
|
||||
{
|
||||
mpNotifier = req.mpNotifier->Clone();
|
||||
}
|
||||
|
||||
Validate();
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
~sProtocolRequest
|
||||
|
||||
DESCRIPTION:
|
||||
Destructor
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
sProtocolRequest::~sProtocolRequest()
|
||||
{
|
||||
// Delete cloned notifier?
|
||||
if (mpNotifier != 0)
|
||||
{
|
||||
delete mpNotifier;
|
||||
mpNotifier = 0;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,193 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
ProtocolRequest.h
|
||||
|
||||
DESCRIPTION:
|
||||
Generic protocol request/command related structures and
|
||||
affliated methods, these structures are used by clients of
|
||||
the protocol server to specify outgoing protocol requests
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
sProtocolRequest
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "ProtocolBuffer.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Forward Declarations
|
||||
//---------------------------------------------------------------------------
|
||||
class cProtocolNotification;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// Default protocol request timeout
|
||||
extern const ULONG DEFAULT_REQ_TIMEOUT;
|
||||
|
||||
// Minimum and maximum allowable timeout values (in milliseconds)
|
||||
extern const ULONG MIN_REQ_TIMEOUT;
|
||||
extern const ULONG MAX_REQ_TIMEOUT;
|
||||
|
||||
// Minimum number of attempts a request can be scheduled for
|
||||
extern const ULONG MIN_REQ_ATTEMPTS;
|
||||
|
||||
// Value to indicate that a request is to be sent out indefinately
|
||||
extern const ULONG INFINITE_REQS;
|
||||
|
||||
// Minimum/default amount of time between repeated requests (in milliseconds)
|
||||
extern const ULONG MIN_REQ_FREQUENCY;
|
||||
extern const ULONG DEFAULT_REQ_FREQUENCY;
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sProtocolRequest
|
||||
//
|
||||
// Structure to represent a generic request packet, including all the
|
||||
// information needed to schedule the request, send the request, and
|
||||
// (optionally) reschedule the request for another TX/RX attempt
|
||||
//
|
||||
// The default parameters schedule an immediate request (indicated by
|
||||
// passing in '0' for the schedule parameter) to be sent once with
|
||||
// the default timeout value
|
||||
/*=========================================================================*/
|
||||
struct sProtocolRequest : public sProtocolBuffer
|
||||
{
|
||||
public:
|
||||
// Parameterized constructor
|
||||
sProtocolRequest(
|
||||
sSharedBuffer * pBuffer,
|
||||
ULONG schedule = 0,
|
||||
ULONG timeout = DEFAULT_REQ_TIMEOUT,
|
||||
ULONG requests = MIN_REQ_ATTEMPTS,
|
||||
ULONG frequency = DEFAULT_REQ_FREQUENCY,
|
||||
cProtocolNotification * pNotifier = 0 );
|
||||
|
||||
// Parameterized constructor (notification with defaults)
|
||||
sProtocolRequest(
|
||||
sSharedBuffer * pBuffer,
|
||||
cProtocolNotification * pNotifier );
|
||||
|
||||
// Copy constructor
|
||||
sProtocolRequest( const sProtocolRequest & req );
|
||||
|
||||
// Destructor
|
||||
virtual ~sProtocolRequest();
|
||||
|
||||
// (Inline) Get schedule value (value is in milliseconds)
|
||||
ULONG GetSchedule() const
|
||||
{
|
||||
return mSchedule;
|
||||
};
|
||||
|
||||
// (Inline) Get timeout value
|
||||
ULONG GetTimeout() const
|
||||
{
|
||||
return mTimeout;
|
||||
};
|
||||
|
||||
// (Inline) Get requests value
|
||||
ULONG GetRequests() const
|
||||
{
|
||||
return mRequests;
|
||||
};
|
||||
|
||||
// (Inline) Get frequency value (value is in milliseconds)
|
||||
ULONG GetFrequency() const
|
||||
{
|
||||
return mFrequency;
|
||||
};
|
||||
|
||||
const cProtocolNotification * GetNotifier() const
|
||||
{
|
||||
return mpNotifier;
|
||||
};
|
||||
|
||||
// (Inline) Set auxiliary data
|
||||
void SetAuxiliaryData(
|
||||
const BYTE * pData,
|
||||
ULONG dataSz )
|
||||
{
|
||||
mpAuxData = pData;
|
||||
mAuxDataSize = dataSz;
|
||||
};
|
||||
|
||||
// (Inline) Get auxiliary data
|
||||
const BYTE * GetAuxiliaryData( ULONG & dataSz ) const
|
||||
{
|
||||
dataSz = mAuxDataSize;
|
||||
return mpAuxData;
|
||||
};
|
||||
|
||||
// (Inline) Set TX only flag
|
||||
void SetTXOnly()
|
||||
{
|
||||
mbTXOnly = true;
|
||||
};
|
||||
|
||||
// (Inline) Get TX only flag
|
||||
bool IsTXOnly() const
|
||||
{
|
||||
return mbTXOnly;
|
||||
};
|
||||
|
||||
protected:
|
||||
/* Schedule (approximately when to send the initial request) */
|
||||
ULONG mSchedule;
|
||||
|
||||
/* Timeout value for receiving a response */
|
||||
ULONG mTimeout;
|
||||
|
||||
/* Number of requests to schedule (must be at least one) */
|
||||
ULONG mRequests;
|
||||
|
||||
/* Frequency (approximately how long to wait before next request) */
|
||||
ULONG mFrequency;
|
||||
|
||||
/* Notification object */
|
||||
cProtocolNotification * mpNotifier;
|
||||
|
||||
/* Auxiliary data */
|
||||
const BYTE * mpAuxData;
|
||||
|
||||
/* Auxilary data size */
|
||||
ULONG mAuxDataSize;
|
||||
|
||||
/* TX only (i.e. do not wait for a response) ? */
|
||||
bool mbTXOnly;
|
||||
};
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,351 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
ProtocolServer.h
|
||||
|
||||
DESCRIPTION:
|
||||
Generic protocol packet server
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
cProtocolServer
|
||||
Abstract base class for protocol servers
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "Comm.h"
|
||||
#include "ProtocolRequest.h"
|
||||
#include "ProtocolLog.h"
|
||||
#include "Event.h"
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Forward Declarations
|
||||
//---------------------------------------------------------------------------
|
||||
class cProtocolServer;
|
||||
struct sServerControl;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// Invalid request ID
|
||||
extern const ULONG INVALID_REQUEST_ID;
|
||||
|
||||
// Fill timespec with the time it will be in specified milliseconds
|
||||
// Relative time to Absolute time
|
||||
timespec TimeIn( ULONG millis );
|
||||
|
||||
// Find the milliseconds from current time this timespec will occur
|
||||
// Absolute time to Relative time
|
||||
ULONG TimeFromNow( timespec time );
|
||||
|
||||
// Provide a number for sequencing reference, similar to the windows function
|
||||
ULONGLONG GetTickCount();
|
||||
|
||||
// timespec < comparison method
|
||||
inline bool operator< (const timespec & first, const timespec & second)
|
||||
{
|
||||
return ( (first.tv_sec < second.tv_sec)
|
||||
||( (first.tv_sec == second.tv_sec)
|
||||
&&(first.tv_nsec < second.tv_nsec) ) );
|
||||
}
|
||||
|
||||
// timespec <= comparison method
|
||||
inline bool operator<= (const timespec & first, const timespec & second)
|
||||
{
|
||||
return ( (first.tv_sec < second.tv_sec)
|
||||
||( (first.tv_sec == second.tv_sec)
|
||||
&&(first.tv_nsec <= second.tv_nsec) ) );
|
||||
}
|
||||
|
||||
/*=========================================================================*/
|
||||
// Class cProtocolServerRxCallback
|
||||
/*=========================================================================*/
|
||||
class cProtocolServerRxCallback
|
||||
{
|
||||
public:
|
||||
// (Inline) Constructor
|
||||
cProtocolServerRxCallback()
|
||||
: mpServer( 0 )
|
||||
{ };
|
||||
|
||||
// (Inline) Destructor
|
||||
virtual ~cProtocolServerRxCallback() { };
|
||||
|
||||
// (Inline) Set server object to pass results to
|
||||
void SetServer( cProtocolServer * pServer )
|
||||
{
|
||||
mpServer = pServer;
|
||||
};
|
||||
|
||||
// The I/O has been completed, process the results
|
||||
virtual void IOComplete(
|
||||
DWORD status,
|
||||
DWORD bytesReceived );
|
||||
|
||||
protected:
|
||||
/* Protocol server to interact with */
|
||||
cProtocolServer * mpServer;
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Class cProtocolServer
|
||||
/*=========================================================================*/
|
||||
class cProtocolServer
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
cProtocolServer(
|
||||
eProtocolType rxType,
|
||||
eProtocolType txType,
|
||||
ULONG bufferSzRx,
|
||||
ULONG logSz );
|
||||
|
||||
// Destructor
|
||||
virtual ~cProtocolServer();
|
||||
|
||||
// Initialize the protocol server
|
||||
bool Initialize();
|
||||
|
||||
// Exit the protocol server
|
||||
bool Exit();
|
||||
|
||||
// Connect to the given communications port
|
||||
bool Connect( LPCSTR pPort );
|
||||
|
||||
// Disconnect from target
|
||||
bool Disconnect();
|
||||
|
||||
// Are we currently connected to a port?
|
||||
bool IsConnected();
|
||||
|
||||
// Add an outgoing protocol request to the protocol server request queue
|
||||
ULONG AddRequest( const sProtocolRequest & req );
|
||||
|
||||
// Remove a previously added protocol request
|
||||
bool RemoveRequest( ULONG reqID );
|
||||
|
||||
// (Inline) Return the protocol log
|
||||
const cProtocolLog & GetLog()
|
||||
{
|
||||
return mLog;
|
||||
};
|
||||
|
||||
protected:
|
||||
// Internal protocol server request/response structure, used to track
|
||||
// info related to sending out a request
|
||||
struct sProtocolReqRsp
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
sProtocolReqRsp(
|
||||
const sProtocolRequest & requestInfo,
|
||||
ULONG requestID,
|
||||
ULONG auxDataMTU );
|
||||
|
||||
// Copy constructor
|
||||
sProtocolReqRsp( const sProtocolReqRsp & reqRsp );
|
||||
|
||||
// (Inline) Reset for next transmission attempt
|
||||
void Reset()
|
||||
{
|
||||
mEncodedSize = mRequest.GetSize();
|
||||
|
||||
mCurrentAuxTx = 0;
|
||||
mbWaitingForResponse = 0;
|
||||
};
|
||||
|
||||
/* Request ID */
|
||||
ULONG mID;
|
||||
|
||||
/* Number of times this request has been attempted */
|
||||
ULONG mAttempts;
|
||||
|
||||
/* Size of encoded data being transmitted */
|
||||
ULONG mEncodedSize;
|
||||
|
||||
/* Number of required auxiliary data transmissions */
|
||||
ULONG mRequiredAuxTxs;
|
||||
|
||||
/* Current auxiliary data transmission */
|
||||
ULONG mCurrentAuxTx;
|
||||
|
||||
/* Are we currently waiting for a response? */
|
||||
bool mbWaitingForResponse;
|
||||
|
||||
/* Underlying protocol request */
|
||||
sProtocolRequest mRequest;
|
||||
};
|
||||
|
||||
// Handle the remove request
|
||||
bool HandleRemoveRequest( ULONG reqID );
|
||||
|
||||
// Schedule a request for transmission
|
||||
bool ScheduleRequest(
|
||||
ULONG reqID,
|
||||
ULONG schedule );
|
||||
|
||||
// (Inline) Get next request's time from mRequestSchedule
|
||||
timespec GetNextRequestTime()
|
||||
{
|
||||
timespec outTime;
|
||||
|
||||
std::set <tSchedule>::iterator pScheduleIter;
|
||||
pScheduleIter = mRequestSchedule.begin();
|
||||
tSchedule entry = *pScheduleIter;
|
||||
|
||||
outTime = entry.first;
|
||||
return outTime;
|
||||
}
|
||||
|
||||
// (Inline) Validate a request that is about to be scheduled
|
||||
virtual bool ValidateRequest( const sProtocolRequest & req )
|
||||
{
|
||||
return req.IsValid();
|
||||
};
|
||||
|
||||
// Reschedule (or cleanup) the active request
|
||||
void RescheduleActiveRequest();
|
||||
|
||||
// Process a single outgoing protocol request
|
||||
void ProcessRequest();
|
||||
|
||||
// Check that system time hasn't moved backwards
|
||||
bool CheckSystemTime();
|
||||
|
||||
// Perform protocol specific communications port initialization
|
||||
virtual bool InitializeComm() = 0;
|
||||
|
||||
// Perform protocol specific communications port cleanup
|
||||
virtual bool CleanupComm() = 0;
|
||||
|
||||
// Encode data for transmission
|
||||
virtual sSharedBuffer * EncodeTxData(
|
||||
sSharedBuffer * pBuffer,
|
||||
bool & bEncoded ) = 0;
|
||||
|
||||
// Decode incoming data into packets returning the last response
|
||||
virtual bool DecodeRxData(
|
||||
ULONG bytesReceived,
|
||||
ULONG & rspIdx,
|
||||
bool & bAbortTx ) = 0;
|
||||
|
||||
// Handle completion of receive data operation
|
||||
void RxComplete(
|
||||
DWORD status,
|
||||
DWORD bytesReceived );
|
||||
|
||||
// Handle the response timer expiring
|
||||
void RxTimeout();
|
||||
|
||||
// Handle completion of transmit data operation
|
||||
virtual void TxComplete();
|
||||
|
||||
// Handle a transmission error
|
||||
void TxError();
|
||||
|
||||
/* Underlying communications object */
|
||||
cComm mComm;
|
||||
|
||||
/* Rx callback */
|
||||
cProtocolServerRxCallback mRxCallback;
|
||||
|
||||
/* ID of Schedule thread */
|
||||
pthread_t mScheduleThreadID;
|
||||
|
||||
// ScheduleThread signal event
|
||||
cEvent mThreadScheduleEvent;
|
||||
|
||||
// Schedule mutex
|
||||
// Ensures exclusive access to mRequestSchedule
|
||||
pthread_mutex_t mScheduleMutex;
|
||||
|
||||
// Is the thread in the process of exiting?
|
||||
// (no new commands will be accepted)
|
||||
bool mbExiting;
|
||||
|
||||
/* Client/server thread control object */
|
||||
sSharedBuffer * mpServerControl;
|
||||
|
||||
/* Protocol request schedule (scheduled time/request ID) */
|
||||
typedef std::pair <timespec, ULONG> tSchedule;
|
||||
std::set < tSchedule, std::less <tSchedule> > mRequestSchedule;
|
||||
|
||||
/* Last system time value (used to check for time changes) */
|
||||
timespec mLastTime;
|
||||
|
||||
/* Protocol request map (request ID mapped to internal req/rsp struct) */
|
||||
std::map <ULONG, sProtocolReqRsp *> mRequestMap;
|
||||
|
||||
/* Last assigned request ID */
|
||||
ULONG mLastRequestID;
|
||||
|
||||
/* Current request being processed */
|
||||
sProtocolReqRsp * mpActiveRequest;
|
||||
|
||||
/* Absolute timeout for mpActiveRequest
|
||||
based on when write was completed */
|
||||
timespec mActiveRequestTimeout;
|
||||
|
||||
/* Data buffer for incoming data */
|
||||
BYTE * mpRxBuffer;
|
||||
|
||||
/* Size of above buffer (i.e. how much data to read in at once) */
|
||||
ULONG mRxBufferSize;
|
||||
|
||||
/* Protocol type for incoming/outgoing data*/
|
||||
eProtocolType mRxType;
|
||||
eProtocolType mTxType;
|
||||
|
||||
/* Protocol log */
|
||||
cProtocolLog mLog;
|
||||
|
||||
// Get a lock on ScheduleMutex
|
||||
bool GetScheduleMutex();
|
||||
|
||||
// Release lock on ScheduleMutex
|
||||
// Signal ScheduleThread if desired
|
||||
bool ReleaseScheduleMutex( bool bSignalThread = true );
|
||||
|
||||
// Schedule Thread gets full access
|
||||
friend void * ScheduleThread( PVOID pArg );
|
||||
|
||||
// Callback objects get full access
|
||||
friend class cProtocolServerRxCallback;
|
||||
};
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,716 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
QDLBuffers.h
|
||||
|
||||
DESCRIPTION:
|
||||
QDL protocol related structures and affliated methods
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
sQDLRawHelloReq
|
||||
sQDLRawHelloRsp
|
||||
sQDLRawErrorRsp
|
||||
sQDLRawOpenUnframedReq
|
||||
sQDLRawOpenUnframedRsp
|
||||
sQDLRawWriteUnframedReq
|
||||
sQDLRawWriteUnframedRsp
|
||||
sQDLRawDoneRsp
|
||||
sQDLRawGetImagePrefRsp
|
||||
sQDLRawImageID
|
||||
|
||||
sQDLHello
|
||||
sQDLError
|
||||
sQDLOpenUnframed
|
||||
sQDLWriteUnframed
|
||||
sQDLDone
|
||||
sQDLGetImagePref
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "ProtocolBuffer.h"
|
||||
#include "QDLEnum.h"
|
||||
|
||||
#include <list>
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas (pack structs)
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma pack( push, 1 )
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sQDLRawHelloReq
|
||||
// Struct to represent a QDL hello request (raw)
|
||||
/*=========================================================================*/
|
||||
struct sQDLRawHelloReq
|
||||
{
|
||||
public:
|
||||
BYTE mCommandCode;
|
||||
BYTE mMagicNumber[32];
|
||||
BYTE mMaxVersion;
|
||||
BYTE mMinVersion;
|
||||
BYTE mFeatures;
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sQDLRawHelloRsp
|
||||
// Struct to represent a QDL hello response (raw)
|
||||
/*=========================================================================*/
|
||||
struct sQDLRawHelloRsp
|
||||
{
|
||||
public:
|
||||
BYTE mCommandCode;
|
||||
BYTE mMagicNumber[24];
|
||||
DWORD mReserved1;
|
||||
WORD mBootMajorVersion;
|
||||
WORD mBootMinorVersion;
|
||||
BYTE mMaxVersion;
|
||||
BYTE mMinVersion;
|
||||
DWORD mReserved2;
|
||||
DWORD mReserved3;
|
||||
BYTE mReserved4;
|
||||
WORD mReserved5;
|
||||
WORD mReserved6;
|
||||
BYTE mFeatures;
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sQDLRawErrorRsp
|
||||
// Struct to represent a QDL error response (raw)
|
||||
/*=========================================================================*/
|
||||
struct sQDLRawErrorRsp
|
||||
{
|
||||
public:
|
||||
BYTE mCommandCode;
|
||||
DWORD mErrorCode;
|
||||
BYTE mErrorText;
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sQDLRawOpenUnframedReq
|
||||
// Struct to represent a QDL open unframed image write request (raw)
|
||||
/*=========================================================================*/
|
||||
struct sQDLRawOpenUnframedReq
|
||||
{
|
||||
public:
|
||||
BYTE mCommandCode;
|
||||
BYTE mImageType;
|
||||
DWORD mImageLength;
|
||||
BYTE mWindowSize;
|
||||
DWORD mUnframedChunkSize;
|
||||
WORD mReserved1;
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sQDLRawOpenUnframedRsp
|
||||
// Struct to represent a QDL open unframed image write response (raw)
|
||||
/*=========================================================================*/
|
||||
struct sQDLRawOpenUnframedRsp
|
||||
{
|
||||
public:
|
||||
BYTE mCommandCode;
|
||||
WORD mStatus;
|
||||
BYTE mWindowSize;
|
||||
DWORD mUnframedChunkSize;
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sQDLRawWriteUnframedReq
|
||||
// Struct to represent a QDL unframed image write request (raw)
|
||||
/*=========================================================================*/
|
||||
struct sQDLRawWriteUnframedReq
|
||||
{
|
||||
public:
|
||||
BYTE mCommandCode;
|
||||
WORD mSequenceNumber;
|
||||
DWORD mReserved;
|
||||
DWORD mUnframedChunkSize;
|
||||
WORD mCRC;
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sQDLRawWriteUnframedRsp
|
||||
// Struct to represent a QDL unframed image write response (raw)
|
||||
/*=========================================================================*/
|
||||
struct sQDLRawWriteUnframedRsp
|
||||
{
|
||||
public:
|
||||
BYTE mCommandCode;
|
||||
WORD mSequenceNumber;
|
||||
DWORD mReserved;
|
||||
WORD mStatus;
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sQDLRawDoneRsp
|
||||
// Struct to represent a QDL session done response (raw)
|
||||
/*=========================================================================*/
|
||||
struct sQDLRawDoneRsp
|
||||
{
|
||||
public:
|
||||
BYTE mCommandCode;
|
||||
WORD mStatus;
|
||||
BYTE mImageType;
|
||||
BYTE mErrorText;
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sQDLRawGetImagePrefRsp
|
||||
// Struct to represent a QDL get image preference response (raw)
|
||||
/*=========================================================================*/
|
||||
struct sQDLRawGetImagePrefRsp
|
||||
{
|
||||
public:
|
||||
BYTE mCommandCode;
|
||||
BYTE mEntries;
|
||||
|
||||
// Array of sQDLRawImageID follows (sized by mEntries)
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sQDLRawImageID
|
||||
// Struct to represent a QDL image ID (raw)
|
||||
/*=========================================================================*/
|
||||
struct sQDLRawImageID
|
||||
{
|
||||
public:
|
||||
BYTE mImageType;
|
||||
BYTE mImageID[16];
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma pack( pop )
|
||||
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sQDLHello
|
||||
// Struct to represent a QDL hello request/response (shared buffer)
|
||||
/*=========================================================================*/
|
||||
struct sQDLHello : public sProtocolBuffer
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
sQDLHello( sSharedBuffer * pBuffer );
|
||||
|
||||
// Destructor
|
||||
virtual ~sQDLHello();
|
||||
|
||||
// (Inline) Is this a request?
|
||||
bool IsRequest() const
|
||||
{
|
||||
bool bRequest = false;
|
||||
if (IsValid() == true)
|
||||
{
|
||||
const BYTE * pBuf = GetBuffer();
|
||||
bRequest = (pBuf[0] == (BYTE)eQDL_CMD_HELLO_REQ);
|
||||
}
|
||||
|
||||
return bRequest;
|
||||
};
|
||||
|
||||
// (Inline) Is this a response?
|
||||
bool IsResponse() const
|
||||
{
|
||||
bool bResponse = false;
|
||||
if (IsValid() == true)
|
||||
{
|
||||
const BYTE * pBuf = GetBuffer();
|
||||
bResponse = (pBuf[0] == (BYTE)eQDL_CMD_HELLO_RSP);
|
||||
}
|
||||
|
||||
return bResponse;
|
||||
};
|
||||
|
||||
// (Inline) Return raw request
|
||||
const sQDLRawHelloReq * GetRequest() const
|
||||
{
|
||||
const sQDLRawHelloReq * pReq = 0;
|
||||
if (IsRequest() == true)
|
||||
{
|
||||
pReq = (const sQDLRawHelloReq *)GetBuffer();
|
||||
}
|
||||
|
||||
return pReq;
|
||||
};
|
||||
|
||||
// (Inline) Return raw response
|
||||
const sQDLRawHelloRsp * GetResponse() const
|
||||
{
|
||||
const sQDLRawHelloRsp * pRsp = 0;
|
||||
if (IsResponse() == true)
|
||||
{
|
||||
pRsp = (const sQDLRawHelloRsp *)GetBuffer();
|
||||
}
|
||||
|
||||
return pRsp;
|
||||
};
|
||||
|
||||
// Extract boot downloader version info from the response
|
||||
bool GetBootVersionInfo(
|
||||
ULONG & major,
|
||||
ULONG & minor ) const;
|
||||
|
||||
// Build a hello request
|
||||
static sSharedBuffer * BuildHelloReq( bool bBARMode = false );
|
||||
|
||||
protected:
|
||||
// Is this hello request/response packet valid?
|
||||
virtual bool Validate();
|
||||
|
||||
private:
|
||||
// Prevent 'upcopying'
|
||||
sQDLHello( const sProtocolBuffer & );
|
||||
sQDLHello & operator = ( const sProtocolBuffer & );
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sQDLError
|
||||
// Struct to represent a QDL error response (shared buffer)
|
||||
/*=========================================================================*/
|
||||
struct sQDLError : public sProtocolBuffer
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
sQDLError( sSharedBuffer * pBuffer );
|
||||
|
||||
// Destructor
|
||||
virtual ~sQDLError();
|
||||
|
||||
// (Inline) Return raw response
|
||||
const sQDLRawErrorRsp * GetResponse() const
|
||||
{
|
||||
const sQDLRawErrorRsp * pRsp = 0;
|
||||
if (IsValid() == true)
|
||||
{
|
||||
pRsp = (const sQDLRawErrorRsp *)GetBuffer();
|
||||
}
|
||||
|
||||
return pRsp;
|
||||
};
|
||||
|
||||
// (Inline) Return the (validated) error code
|
||||
eQDLError GetErrorCode() const
|
||||
{
|
||||
eQDLError err = eQDL_ERROR_ENUM_BEGIN;
|
||||
|
||||
const sQDLRawErrorRsp * pRsp = GetResponse();
|
||||
if (pRsp != 0)
|
||||
{
|
||||
err = (eQDLError)pRsp->mErrorCode;
|
||||
}
|
||||
|
||||
return err;
|
||||
};
|
||||
|
||||
// (Inline) Return the error text string
|
||||
LPCSTR GetError() const
|
||||
{
|
||||
LPCSTR pErr = 0;
|
||||
|
||||
const sQDLRawErrorRsp * pRsp = GetResponse();
|
||||
if (pRsp != 0)
|
||||
{
|
||||
pErr = (LPCSTR)&pRsp->mErrorText;
|
||||
}
|
||||
|
||||
return pErr;
|
||||
};
|
||||
|
||||
protected:
|
||||
// Is this session done request/response packet valid?
|
||||
virtual bool Validate();
|
||||
|
||||
private:
|
||||
// Prevent 'upcopying'
|
||||
sQDLError( const sProtocolBuffer & );
|
||||
sQDLError & operator = ( const sProtocolBuffer & );
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sQDLOpenUnframed
|
||||
// Struct to represent a QDL open image for unframed write
|
||||
// request/response (shared buffer)
|
||||
/*=========================================================================*/
|
||||
struct sQDLOpenUnframed : public sProtocolBuffer
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
sQDLOpenUnframed( sSharedBuffer * pBuffer );
|
||||
|
||||
// Destructor
|
||||
virtual ~sQDLOpenUnframed();
|
||||
|
||||
// (Inline) Is this a request?
|
||||
bool IsRequest() const
|
||||
{
|
||||
bool bRequest = false;
|
||||
if (IsValid() == true)
|
||||
{
|
||||
const BYTE * pBuf = GetBuffer();
|
||||
bRequest = (pBuf[0] == (BYTE)eQDL_CMD_OPEN_UNFRAMED_REQ);
|
||||
}
|
||||
|
||||
return bRequest;
|
||||
};
|
||||
|
||||
// (Inline) Is this a response?
|
||||
bool IsResponse() const
|
||||
{
|
||||
bool bResponse = false;
|
||||
if (IsValid() == true)
|
||||
{
|
||||
const BYTE * pBuf = GetBuffer();
|
||||
bResponse = (pBuf[0] == (BYTE)eQDL_CMD_OPEN_UNFRAMED_RSP);
|
||||
}
|
||||
|
||||
return bResponse;
|
||||
};
|
||||
|
||||
// (Inline) Return raw request
|
||||
const sQDLRawOpenUnframedReq * GetRequest() const
|
||||
{
|
||||
const sQDLRawOpenUnframedReq * pReq = 0;
|
||||
if (IsRequest() == true)
|
||||
{
|
||||
pReq = (const sQDLRawOpenUnframedReq *)GetBuffer();
|
||||
}
|
||||
|
||||
return pReq;
|
||||
};
|
||||
|
||||
// (Inline) Return raw response
|
||||
const sQDLRawOpenUnframedRsp * GetResponse() const
|
||||
{
|
||||
const sQDLRawOpenUnframedRsp * pRsp = 0;
|
||||
if (IsResponse() == true)
|
||||
{
|
||||
pRsp = (const sQDLRawOpenUnframedRsp *)GetBuffer();
|
||||
}
|
||||
|
||||
return pRsp;
|
||||
};
|
||||
|
||||
// (Inline) Does the response indicate success?
|
||||
bool IsSuccess() const
|
||||
{
|
||||
bool bSuccess = false;
|
||||
|
||||
const sQDLRawOpenUnframedRsp * pRsp = GetResponse();
|
||||
if (pRsp != 0)
|
||||
{
|
||||
bSuccess = (pRsp->mStatus == eQDL_OPEN_STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
return bSuccess;
|
||||
};
|
||||
|
||||
// Extract supported chunk size from the response
|
||||
bool GetChunkSize( ULONG & chunkSize ) const;
|
||||
|
||||
// Build an open image for unframed write request
|
||||
static sSharedBuffer * BuildOpenUnframedReq(
|
||||
eQDLImageType imageType,
|
||||
ULONG imageSize,
|
||||
ULONG chunkSize );
|
||||
|
||||
protected:
|
||||
// Is this open unframed request/response packet valid?
|
||||
virtual bool Validate();
|
||||
|
||||
private:
|
||||
// Prevent 'upcopying'
|
||||
sQDLOpenUnframed( const sProtocolBuffer & );
|
||||
sQDLOpenUnframed & operator = ( const sProtocolBuffer & );
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sQDLWriteUnframed
|
||||
// Struct to represent a QDL unframed write of an image
|
||||
// request/response (shared buffer)
|
||||
/*=========================================================================*/
|
||||
struct sQDLWriteUnframed : public sProtocolBuffer
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
sQDLWriteUnframed( sSharedBuffer * pBuffer );
|
||||
|
||||
// Destructor
|
||||
virtual ~sQDLWriteUnframed();
|
||||
|
||||
// (Inline) Is this a request?
|
||||
bool IsRequest() const
|
||||
{
|
||||
bool bRequest = false;
|
||||
if (IsValid() == true)
|
||||
{
|
||||
const BYTE * pBuf = GetBuffer();
|
||||
bRequest = (pBuf[0] == (BYTE)eQDL_CMD_WRITE_UNFRAMED_REQ);
|
||||
}
|
||||
|
||||
return bRequest;
|
||||
};
|
||||
|
||||
// (Inline) Is this a response?
|
||||
bool IsResponse() const
|
||||
{
|
||||
bool bResponse = false;
|
||||
if (IsValid() == true)
|
||||
{
|
||||
const BYTE * pBuf = GetBuffer();
|
||||
bResponse = (pBuf[0] == (BYTE)eQDL_CMD_WRITE_UNFRAMED_RSP);
|
||||
}
|
||||
|
||||
return bResponse;
|
||||
};
|
||||
|
||||
// (Inline) Return raw request
|
||||
const sQDLRawWriteUnframedReq * GetRequest() const
|
||||
{
|
||||
const sQDLRawWriteUnframedReq * pReq = 0;
|
||||
if (IsRequest() == true)
|
||||
{
|
||||
pReq = (const sQDLRawWriteUnframedReq *)GetBuffer();
|
||||
}
|
||||
|
||||
return pReq;
|
||||
};
|
||||
|
||||
// (Inline) Return raw response
|
||||
const sQDLRawWriteUnframedRsp * GetResponse() const
|
||||
{
|
||||
const sQDLRawWriteUnframedRsp * pRsp = 0;
|
||||
if (IsResponse() == true)
|
||||
{
|
||||
pRsp = (const sQDLRawWriteUnframedRsp *)GetBuffer();
|
||||
}
|
||||
|
||||
return pRsp;
|
||||
};
|
||||
|
||||
// (Inline) Does the response indicate success?
|
||||
bool IsSuccess() const
|
||||
{
|
||||
bool bSuccess = false;
|
||||
|
||||
const sQDLRawWriteUnframedRsp * pRsp = GetResponse();
|
||||
if (pRsp != 0)
|
||||
{
|
||||
bSuccess = (pRsp->mStatus == eQDL_WRITE_STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
return bSuccess;
|
||||
};
|
||||
|
||||
// Extract sequence number from the response
|
||||
bool GetSequenceNumber( ULONG & sequenceNumber ) const;
|
||||
|
||||
// Build an unframed write request
|
||||
static sSharedBuffer * BuildWriteUnframedReq(
|
||||
USHORT sequenceNumber,
|
||||
ULONG chunkSize );
|
||||
|
||||
// Build unframed write requests for the specified parameters
|
||||
static std::list <sSharedBuffer *> BuildWriteUnframedReqs(
|
||||
ULONG chunkSize,
|
||||
ULONG totalSize );
|
||||
|
||||
protected:
|
||||
// Is this open unframed request/response packet valid?
|
||||
virtual bool Validate();
|
||||
|
||||
private:
|
||||
// Prevent 'upcopying'
|
||||
sQDLWriteUnframed( const sProtocolBuffer & );
|
||||
sQDLWriteUnframed & operator = ( const sProtocolBuffer & );
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sQDLDone
|
||||
// Struct to represent a QDL session done request/response (shared buffer)
|
||||
/*=========================================================================*/
|
||||
struct sQDLDone : public sProtocolBuffer
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
sQDLDone( sSharedBuffer * pBuffer );
|
||||
|
||||
// Destructor
|
||||
virtual ~sQDLDone();
|
||||
|
||||
// (Inline) Is this a request?
|
||||
bool IsRequest() const
|
||||
{
|
||||
bool bRequest = false;
|
||||
if (IsValid() == true)
|
||||
{
|
||||
const BYTE * pBuf = GetBuffer();
|
||||
bRequest = (pBuf[0] == (BYTE)eQDL_CMD_SESSION_DONE_REQ);
|
||||
}
|
||||
|
||||
return bRequest;
|
||||
};
|
||||
|
||||
// (Inline) Is this a response?
|
||||
bool IsResponse() const
|
||||
{
|
||||
bool bResponse = false;
|
||||
if (IsValid() == true)
|
||||
{
|
||||
const BYTE * pBuf = GetBuffer();
|
||||
bResponse = (pBuf[0] == (BYTE)eQDL_CMD_SESSION_DONE_RSP);
|
||||
}
|
||||
|
||||
return bResponse;
|
||||
};
|
||||
|
||||
// (Inline) Return raw response
|
||||
const sQDLRawDoneRsp * GetResponse() const
|
||||
{
|
||||
const sQDLRawDoneRsp * pRsp = 0;
|
||||
if (IsResponse() == true)
|
||||
{
|
||||
pRsp = (const sQDLRawDoneRsp *)GetBuffer();
|
||||
}
|
||||
|
||||
return pRsp;
|
||||
};
|
||||
|
||||
// (Inline) Does the response indicate success?
|
||||
bool IsSuccess() const
|
||||
{
|
||||
bool bSuccess = false;
|
||||
|
||||
const sQDLRawDoneRsp * pRsp = GetResponse();
|
||||
if (pRsp != 0)
|
||||
{
|
||||
bSuccess = (pRsp->mStatus == eQDL_DONE_STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
return bSuccess;
|
||||
};
|
||||
|
||||
// (Inline) Return the error text string
|
||||
LPCSTR GetError() const
|
||||
{
|
||||
LPCSTR pErr = 0;
|
||||
|
||||
const sQDLRawDoneRsp * pRsp = GetResponse();
|
||||
if (pRsp != 0)
|
||||
{
|
||||
if (pRsp->mStatus != eQDL_DONE_STATUS_SUCCESS)
|
||||
{
|
||||
pErr = (LPCSTR)&pRsp->mErrorText;
|
||||
}
|
||||
}
|
||||
|
||||
return pErr;
|
||||
};
|
||||
|
||||
protected:
|
||||
// Is this session done request/response packet valid?
|
||||
virtual bool Validate();
|
||||
|
||||
private:
|
||||
// Prevent 'upcopying'
|
||||
sQDLDone( const sProtocolBuffer & );
|
||||
sQDLDone & operator = ( const sProtocolBuffer & );
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sQDLGetImagePref
|
||||
// Struct to represent a QDL get image preference
|
||||
// request/response (shared buffer)
|
||||
/*=========================================================================*/
|
||||
struct sQDLGetImagePref : public sProtocolBuffer
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
sQDLGetImagePref( sSharedBuffer * pBuffer );
|
||||
|
||||
// Destructor
|
||||
virtual ~sQDLGetImagePref();
|
||||
|
||||
// (Inline) Is this a request?
|
||||
bool IsRequest() const
|
||||
{
|
||||
bool bRequest = false;
|
||||
if (IsValid() == true)
|
||||
{
|
||||
const BYTE * pBuf = GetBuffer();
|
||||
bRequest = (pBuf[0] == (BYTE)eQDL_CMD_GET_IMAGE_PREF_REQ);
|
||||
}
|
||||
|
||||
return bRequest;
|
||||
};
|
||||
|
||||
// (Inline) Is this a response?
|
||||
bool IsResponse() const
|
||||
{
|
||||
bool bResponse = false;
|
||||
if (IsValid() == true)
|
||||
{
|
||||
const BYTE * pBuf = GetBuffer();
|
||||
bResponse = (pBuf[0] == (BYTE)eQDL_CMD_GET_IMAGE_PREF_RSP);
|
||||
}
|
||||
|
||||
return bResponse;
|
||||
};
|
||||
|
||||
// (Inline) Return raw response
|
||||
const sQDLRawGetImagePrefRsp * GetResponse() const
|
||||
{
|
||||
const sQDLRawGetImagePrefRsp * pRsp = 0;
|
||||
if (IsResponse() == true)
|
||||
{
|
||||
pRsp = (const sQDLRawGetImagePrefRsp *)GetBuffer();
|
||||
}
|
||||
|
||||
return pRsp;
|
||||
};
|
||||
|
||||
// Return image IDs
|
||||
std::list <sQDLRawImageID> GetImageIDs() const;
|
||||
|
||||
protected:
|
||||
// Is this get image preference request/response packet valid?
|
||||
virtual bool Validate();
|
||||
|
||||
private:
|
||||
// Prevent 'upcopying'
|
||||
sQDLGetImagePref( const sProtocolBuffer & );
|
||||
sQDLGetImagePref & operator = ( const sProtocolBuffer & );
|
||||
};
|
|
@ -0,0 +1,428 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
QDLEnum.h
|
||||
|
||||
DESCRIPTION:
|
||||
QDL protocol enumerations and related methods
|
||||
|
||||
PUBLIC ENUMERATIONS AND METHODS:
|
||||
eQDLCommand
|
||||
eQDLError
|
||||
eQDLImageType
|
||||
eQDLOpenStatus
|
||||
eQDLWriteStatus
|
||||
eQDLDoneStatus
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// QDL feature bits
|
||||
const BYTE QDL_FEATURE_GENERIC_UNFRAMED = 0x10;
|
||||
const BYTE QDL_FEATURE_QDL_UNFRAMED = 0x20;
|
||||
const BYTE QDL_FEATURE_BAR_MODE = 0x40;
|
||||
|
||||
// QDL protocol version
|
||||
const BYTE QDL_MIN_VERSION = 6;
|
||||
const BYTE QDL_MAX_VERSION = 6;
|
||||
|
||||
const BYTE QDL_HELLO_MAGIC_REQ[32] =
|
||||
{
|
||||
'Q',
|
||||
'C',
|
||||
'O',
|
||||
'M',
|
||||
' ',
|
||||
'h',
|
||||
'i',
|
||||
'g',
|
||||
'h',
|
||||
' ',
|
||||
's',
|
||||
'p',
|
||||
'e',
|
||||
'e',
|
||||
'd',
|
||||
' ',
|
||||
'p',
|
||||
'r',
|
||||
'o',
|
||||
't',
|
||||
'o',
|
||||
'c',
|
||||
'o',
|
||||
'l',
|
||||
' ',
|
||||
'h',
|
||||
's',
|
||||
't',
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
const BYTE QDL_HELLO_MAGIC_RSP[24] =
|
||||
{
|
||||
'Q',
|
||||
'C',
|
||||
'O',
|
||||
'M',
|
||||
' ',
|
||||
'h',
|
||||
'i',
|
||||
'g',
|
||||
'h',
|
||||
' ',
|
||||
's',
|
||||
'p',
|
||||
'e',
|
||||
'e',
|
||||
'd',
|
||||
' ',
|
||||
'p',
|
||||
'r',
|
||||
'o',
|
||||
't',
|
||||
'o',
|
||||
'c',
|
||||
'o',
|
||||
'l'
|
||||
};
|
||||
|
||||
// QDL maximum chunk size we support
|
||||
const ULONG QDL_MAX_CHUNK_SIZE = 1024 * 1024 * 64;
|
||||
|
||||
/*=========================================================================*/
|
||||
// eQDLCommand Enumeration
|
||||
// QDL Command Code Enumeration
|
||||
/*=========================================================================*/
|
||||
enum eQDLCommand
|
||||
{
|
||||
eQDL_CMD_ENUM_BEGIN = -1,
|
||||
|
||||
eQDL_CMD_HELLO_REQ = 1, // 001 Hello request
|
||||
eQDL_CMD_HELLO_RSP, // 002 Hello response
|
||||
|
||||
eQDL_CMD_ERROR = 13, // 013 Error report
|
||||
|
||||
eQDL_CMD_OPEN_UNFRAMED_REQ = 37, // 037 Open unframed image write request
|
||||
eQDL_CMD_OPEN_UNFRAMED_RSP, // 038 Open unframed image write response
|
||||
eQDL_CMD_WRITE_UNFRAMED_REQ, // 039 Unframed image write request
|
||||
eQDL_CMD_WRITE_UNFRAMED_RSP, // 040 Unframed image write response
|
||||
eQDL_CMD_SESSION_DONE_REQ, // 041 Unframed session done request
|
||||
eQDL_CMD_SESSION_DONE_RSP, // 042 Unframed session done response
|
||||
eQDL_CMD_DOWNLOAD_REQ, // 043 Switch to download protocol request
|
||||
|
||||
eQDL_CMD_SESSION_CLOSE_REQ = 45, // 045 Close unframed session request
|
||||
eQDL_CMD_GET_IMAGE_PREF_REQ, // 046 Get image preference request
|
||||
eQDL_CMD_GET_IMAGE_PREF_RSP, // 047 Get image preference response
|
||||
|
||||
eQDL_CMD_ENUM_END
|
||||
};
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
IsValid (Inline Method)
|
||||
|
||||
DESCRIPTION:
|
||||
eQDLCommand validity check
|
||||
|
||||
PARAMETERS:
|
||||
cmd [ I ] - Enum value being verified
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
inline bool IsValid( eQDLCommand cmd )
|
||||
{
|
||||
bool retVal = false;
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case eQDL_CMD_HELLO_REQ:
|
||||
case eQDL_CMD_HELLO_RSP:
|
||||
case eQDL_CMD_ERROR:
|
||||
case eQDL_CMD_OPEN_UNFRAMED_REQ:
|
||||
case eQDL_CMD_OPEN_UNFRAMED_RSP:
|
||||
case eQDL_CMD_WRITE_UNFRAMED_REQ:
|
||||
case eQDL_CMD_WRITE_UNFRAMED_RSP:
|
||||
case eQDL_CMD_SESSION_DONE_REQ:
|
||||
case eQDL_CMD_SESSION_DONE_RSP:
|
||||
case eQDL_CMD_DOWNLOAD_REQ:
|
||||
case eQDL_CMD_SESSION_CLOSE_REQ:
|
||||
case eQDL_CMD_GET_IMAGE_PREF_REQ:
|
||||
case eQDL_CMD_GET_IMAGE_PREF_RSP:
|
||||
retVal = true;
|
||||
break;
|
||||
}
|
||||
|
||||
return retVal;
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// eQDLError Enumeration
|
||||
// QDL Error Enumeration
|
||||
/*=========================================================================*/
|
||||
enum eQDLError
|
||||
{
|
||||
eQDL_ERROR_ENUM_BEGIN = 0,
|
||||
|
||||
eQDL_ERROR_01, // 01 Reserved
|
||||
eQDL_ERROR_BAD_ADDR, // 02 Invalid destination address
|
||||
eQDL_ERROR_BAD_LEN, // 03 Invalid length
|
||||
eQDL_ERROR_BAD_PACKET, // 04 Unexpected end of packet
|
||||
eQDL_ERROR_BAD_CMD, // 05 Invalid command
|
||||
eQDL_ERROR_06, // 06 Reserved
|
||||
eQDL_ERROR_OP_FAILED, // 07 Operation failed
|
||||
eQDL_ERROR_BAD_FLASH_ID, // 08 Invalid flash intelligent ID
|
||||
eQDL_ERROR_BAD_VOLTAGE, // 09 Invalid programming voltage
|
||||
eQDL_ERROR_WRITE_FAILED, // 10 Write verify failed
|
||||
eQDL_ERROR_11, // 11 Reserved
|
||||
eQDL_ERROR_BAD_SPC, // 12 Invalid security code
|
||||
eQDL_ERROR_POWERDOWN, // 13 Power-down failed
|
||||
eQDL_ERROR_UNSUPPORTED, // 14 NAND flash programming not supported
|
||||
eQDL_ERROR_CMD_SEQ, // 15 Command out of sequence
|
||||
eQDL_ERROR_CLOSE, // 16 Close failed
|
||||
eQDL_ERROR_BAD_FEATURES, // 17 Invalid feature bits
|
||||
eQDL_ERROR_SPACE, // 18 Out of space
|
||||
eQDL_ERROR_BAD_SECURITY, // 19 Invalid security mode
|
||||
eQDL_ERROR_MULTI_UNSUPPORTED, // 20 Multi-image NAND not supported
|
||||
eQDL_ERROR_POWEROFF, // 21 Power-off command not supported
|
||||
eQDL_ERROR_CMD_UNSUPPORTED, // 22 Command not supported
|
||||
eQDL_ERROR_BAD_CRC, // 23 Invalid CRC
|
||||
eQDL_ERROR_STATE, // 24 Command received in invalid state
|
||||
eQDL_ERROR_TIMEOUT, // 25 Receive timeout
|
||||
eQDL_ERROR_IMAGE_AUTH, // 26 Image authentication error
|
||||
|
||||
eQDL_ERROR_ENUM_END
|
||||
};
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
IsValid (Inline Method)
|
||||
|
||||
DESCRIPTION:
|
||||
eQDLError validity check
|
||||
|
||||
PARAMETERS:
|
||||
err [ I ] - Enum value being verified
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
inline bool IsValid( eQDLError err )
|
||||
{
|
||||
bool retVal = false;
|
||||
if (err > eQDL_ERROR_ENUM_BEGIN && err < eQDL_ERROR_ENUM_END)
|
||||
{
|
||||
retVal = true;
|
||||
}
|
||||
|
||||
return retVal;
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// eQDLImageType Enumeration
|
||||
// QDL Download Image Type Enumeration
|
||||
/*=========================================================================*/
|
||||
enum eQDLImageType
|
||||
{
|
||||
eQDL_IMAGE_ENUM_BEGIN = -1,
|
||||
|
||||
eQDL_IMAGE_AMSS_MODEM = 5, // 05 AMSS modem image
|
||||
eQDL_IMAGE_AMSS_APPLICATION, // 06 AMSS application image
|
||||
|
||||
eQDL_IMAGE_AMSS_UQCN = 13, // 13 Provisioning information
|
||||
|
||||
eQDL_IMAGE_DBL = 15, // 15 DBL image
|
||||
eQDL_IMAGE_OSBL, // 16 OSBL image
|
||||
|
||||
eQDL_IMAGE_ENUM_END
|
||||
};
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
IsValid (Inline Method)
|
||||
|
||||
DESCRIPTION:
|
||||
eQDLImageType validity check
|
||||
|
||||
PARAMETERS:
|
||||
it [ I ] - Enum value being verified
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
inline bool IsValid( eQDLImageType it )
|
||||
{
|
||||
bool retVal = false;
|
||||
|
||||
switch (it)
|
||||
{
|
||||
case eQDL_IMAGE_AMSS_MODEM:
|
||||
case eQDL_IMAGE_AMSS_APPLICATION:
|
||||
case eQDL_IMAGE_AMSS_UQCN:
|
||||
case eQDL_IMAGE_DBL:
|
||||
case eQDL_IMAGE_OSBL:
|
||||
retVal = true;
|
||||
break;
|
||||
}
|
||||
|
||||
return retVal;
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// eQDLOpenStatus Enumeration
|
||||
// QDL Unframed Open Status Enumeration
|
||||
/*=========================================================================*/
|
||||
enum eQDLOpenStatus
|
||||
{
|
||||
eQDL_OPEN_STATUS_ENUM_BEGIN = -1,
|
||||
|
||||
eQDL_OPEN_STATUS_SUCCESS, // 00 Success
|
||||
eQDL_OPEN_STATUS_SIZE, // 01 Reported image size error
|
||||
eQDL_OPEN_STATUS_BAD_TYPE, // 02 Invalid image type for downloader
|
||||
eQDL_OPEN_STATUS_HDR_SIZE, // 03 Reported image header size error
|
||||
eQDL_OPEN_STATUS_HDR1, // 04 Image header incorrectly present
|
||||
eQDL_OPEN_STATUS_HDR2, // 05 Image header required
|
||||
eQDL_OPEN_STATUS_PROTECTION, // 06 Memory block protection error
|
||||
eQDL_OPEN_STATUS_NOT_NEEDED, // 07 Image type not required
|
||||
|
||||
eQDL_OPEN_STATUS_ENUM_END
|
||||
};
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
IsValid (Inline Method)
|
||||
|
||||
DESCRIPTION:
|
||||
eQDLOpenStatus validity check
|
||||
|
||||
PARAMETERS:
|
||||
os [ I ] - Enum value being verified
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
inline bool IsValid( eQDLOpenStatus os )
|
||||
{
|
||||
bool retVal = false;
|
||||
if (os > eQDL_OPEN_STATUS_ENUM_BEGIN && os < eQDL_OPEN_STATUS_ENUM_END)
|
||||
{
|
||||
retVal = true;
|
||||
}
|
||||
|
||||
return retVal;
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// eQDLWriteStatus Enumeration
|
||||
// QDL Unframed Write Status Enumeration
|
||||
/*=========================================================================*/
|
||||
enum eQDLWriteStatus
|
||||
{
|
||||
eQDL_WRITE_STATUS_ENUM_BEGIN = -1,
|
||||
|
||||
eQDL_WRITE_STATUS_SUCCESS, // 00 Success
|
||||
eQDL_WRITE_STATUS_CRC, // 01 Error with CRC
|
||||
eQDL_WRITE_STATUS_CONTENT, // 02 Error with chunk content
|
||||
|
||||
eQDL_WRITE_STATUS_ENUM_END
|
||||
};
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
IsValid (Inline Method)
|
||||
|
||||
DESCRIPTION:
|
||||
eQDLWriteStatus validity check
|
||||
|
||||
PARAMETERS:
|
||||
ws [ I ] - Enum value being verified
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
inline bool IsValid( eQDLWriteStatus ws )
|
||||
{
|
||||
bool retVal = false;
|
||||
if (ws > eQDL_WRITE_STATUS_ENUM_BEGIN && ws < eQDL_WRITE_STATUS_ENUM_END)
|
||||
{
|
||||
retVal = true;
|
||||
}
|
||||
|
||||
return retVal;
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// eQDLDoneStatus Enumeration
|
||||
// QDL Done Status Enumeration
|
||||
/*=========================================================================*/
|
||||
enum eQDLDoneStatus
|
||||
{
|
||||
eQDL_DONE_STATUS_ENUM_BEGIN = -1,
|
||||
|
||||
eQDL_DONE_STATUS_SUCCESS, // 00 Success
|
||||
eQDL_DONE_STATUS_AUTH, // 01 Authentication failure
|
||||
eQDL_DONE_STATUS_WRITE, // 02 Write failure
|
||||
|
||||
eQDL_DONE_STATUS_ENUM_END
|
||||
};
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
IsValid (Inline Method)
|
||||
|
||||
DESCRIPTION:
|
||||
eQDLDoneStatus validity check
|
||||
|
||||
PARAMETERS:
|
||||
ds [ I ] - Enum value being verified
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
inline bool IsValid( eQDLDoneStatus ds )
|
||||
{
|
||||
bool retVal = false;
|
||||
if (ds > eQDL_DONE_STATUS_ENUM_BEGIN && ds < eQDL_DONE_STATUS_ENUM_END)
|
||||
{
|
||||
retVal = true;
|
||||
}
|
||||
|
||||
return retVal;
|
||||
};
|
|
@ -0,0 +1,269 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
QDLProtocolServer.cpp
|
||||
|
||||
DESCRIPTION:
|
||||
QDL protocol packet server
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
cQDLProtocolServer
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "StdAfx.h"
|
||||
#include "QDLProtocolServer.h"
|
||||
#include "QDLEnum.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
/*=========================================================================*/
|
||||
// cQDLProtocolServer Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
cQDLProtocolServer (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Constructor
|
||||
|
||||
PARAMETERS:
|
||||
bufferSzRx [ I ] - Size of data buffer for incoming data
|
||||
|
||||
SEQUENCING:
|
||||
None (constructs sequencing objects)
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cQDLProtocolServer::cQDLProtocolServer(
|
||||
ULONG bufferSzRx,
|
||||
ULONG logSz )
|
||||
: cHDLCProtocolServer( ePROTOCOL_QDL_RX,
|
||||
ePROTOCOL_QDL_TX,
|
||||
bufferSzRx,
|
||||
logSz )
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
~cQDLProtocolServer (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Destructor
|
||||
|
||||
SEQUENCING:
|
||||
None (destroys sequencing objects)
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cQDLProtocolServer::~cQDLProtocolServer()
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
EncodeTxData (Internal Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Encode data for transmission
|
||||
|
||||
PARAMETERS:
|
||||
pBuffer [ I ] - Data to be encoded
|
||||
bEncoded [ O ] - Do we even encoded data?
|
||||
|
||||
SEQUENCING:
|
||||
None (must be called from protocol server thread)
|
||||
|
||||
RETURN VALUE:
|
||||
sSharedBuffer * - Encoded data (0 upon error when encoding is indicated)
|
||||
===========================================================================*/
|
||||
sSharedBuffer * cQDLProtocolServer::EncodeTxData(
|
||||
sSharedBuffer * pBuffer,
|
||||
bool & bEncoded )
|
||||
{
|
||||
// We encoded data
|
||||
bEncoded = true;
|
||||
if (pBuffer != 0 && pBuffer->IsValid() == true)
|
||||
{
|
||||
const BYTE * pReqBuf = mpActiveRequest->mRequest.GetBuffer();
|
||||
|
||||
eQDLCommand reqCmd = (eQDLCommand)pReqBuf[0];
|
||||
if (reqCmd == eQDL_CMD_WRITE_UNFRAMED_REQ)
|
||||
{
|
||||
// The write request is not HDLC encoded
|
||||
bEncoded = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (bEncoded == true)
|
||||
{
|
||||
// Base class can handle HDLC encoding
|
||||
return cHDLCProtocolServer::EncodeTxData( pBuffer, bEncoded );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
IsResponse (Internal Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Is the passed in data a response to the current request?
|
||||
|
||||
PARAMETERS:
|
||||
rsp [ I ] - Candidate response
|
||||
|
||||
SEQUENCING:
|
||||
None (must be called from protocol server thread)
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cQDLProtocolServer::IsResponse( const sProtocolBuffer & rsp )
|
||||
{
|
||||
// Assume not
|
||||
bool bRC = false;
|
||||
if ( (mpActiveRequest == 0)
|
||||
|| (mpActiveRequest->mRequest.IsValid() == false)
|
||||
|| (mpActiveRequest->mbWaitingForResponse == false)
|
||||
|| (rsp.IsValid() == false) )
|
||||
{
|
||||
return bRC;
|
||||
}
|
||||
|
||||
const BYTE * pReqBuf = mpActiveRequest->mRequest.GetBuffer();
|
||||
const BYTE * pRspBuf = rsp.GetBuffer();
|
||||
|
||||
eQDLCommand reqCmd = (eQDLCommand)pReqBuf[0];
|
||||
eQDLCommand rspCmd = (eQDLCommand)pRspBuf[0];
|
||||
|
||||
switch (reqCmd)
|
||||
{
|
||||
case eQDL_CMD_HELLO_REQ:
|
||||
if ( (rspCmd == eQDL_CMD_HELLO_RSP)
|
||||
|| (rspCmd == eQDL_CMD_ERROR) )
|
||||
{
|
||||
bRC = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case eQDL_CMD_OPEN_UNFRAMED_REQ:
|
||||
if ( (rspCmd == eQDL_CMD_OPEN_UNFRAMED_RSP)
|
||||
|| (rspCmd == eQDL_CMD_ERROR) )
|
||||
{
|
||||
bRC = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case eQDL_CMD_WRITE_UNFRAMED_REQ:
|
||||
if ( (rspCmd == eQDL_CMD_WRITE_UNFRAMED_RSP)
|
||||
|| (rspCmd == eQDL_CMD_ERROR) )
|
||||
{
|
||||
bRC = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case eQDL_CMD_SESSION_DONE_REQ:
|
||||
if ( (rspCmd == eQDL_CMD_SESSION_DONE_RSP)
|
||||
|| (rspCmd == eQDL_CMD_ERROR) )
|
||||
{
|
||||
bRC = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case eQDL_CMD_DOWNLOAD_REQ:
|
||||
case eQDL_CMD_SESSION_CLOSE_REQ:
|
||||
if (rspCmd == eQDL_CMD_ERROR)
|
||||
{
|
||||
bRC = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case eQDL_CMD_GET_IMAGE_PREF_REQ:
|
||||
if ( (rspCmd == eQDL_CMD_GET_IMAGE_PREF_RSP)
|
||||
|| (rspCmd == eQDL_CMD_ERROR) )
|
||||
{
|
||||
bRC = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return bRC;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
IsTxAbortResponse (Internal Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Is the passed in data a response that aborts the current request?
|
||||
|
||||
PARAMETERS:
|
||||
rsp [ I ] - Candidate response
|
||||
|
||||
SEQUENCING:
|
||||
None (must be called from protocol server thread)
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cQDLProtocolServer::IsTxAbortResponse( const sProtocolBuffer & rsp )
|
||||
{
|
||||
// Assume not
|
||||
bool bRC = false;
|
||||
if ( (mpActiveRequest == 0)
|
||||
|| (mpActiveRequest->mRequest.IsValid() == false)
|
||||
|| (mpActiveRequest->mbWaitingForResponse == true)
|
||||
|| (rsp.IsValid() == false) )
|
||||
{
|
||||
return bRC;
|
||||
}
|
||||
|
||||
// If we are in the middle of a transmission an we receive an error
|
||||
// packet then we abort
|
||||
const BYTE * pRspBuf = rsp.GetBuffer();
|
||||
eQDLCommand rspCmd = (eQDLCommand)pRspBuf[0];
|
||||
if (rspCmd == eQDL_CMD_ERROR)
|
||||
{
|
||||
bRC = true;
|
||||
}
|
||||
|
||||
return bRC;
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
QDLProtocolServer.h
|
||||
|
||||
DESCRIPTION:
|
||||
QDL protocol packet server
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
cQDLProtocolServer
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "HDLCProtocolServer.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
/*=========================================================================*/
|
||||
// Class cQDLProtocolServer
|
||||
/*=========================================================================*/
|
||||
class cQDLProtocolServer : public cHDLCProtocolServer
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
cQDLProtocolServer(
|
||||
ULONG bufferSzRx,
|
||||
ULONG logSz );
|
||||
|
||||
// Destructor
|
||||
virtual ~cQDLProtocolServer();
|
||||
|
||||
// Encode data for transmission
|
||||
virtual sSharedBuffer * EncodeTxData(
|
||||
sSharedBuffer * pBuffer,
|
||||
bool & bEncoded );
|
||||
|
||||
// Is the passed in data a response to the current request?
|
||||
virtual bool IsResponse( const sProtocolBuffer & rsp );
|
||||
|
||||
// Is the passed in data a response that aborts the current request?
|
||||
virtual bool IsTxAbortResponse( const sProtocolBuffer & rsp );
|
||||
};
|
|
@ -0,0 +1,366 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
QMIBuffers.cpp
|
||||
|
||||
DESCRIPTION:
|
||||
QMI service protocol related structures and affliated methods
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
sQMIControlRawTransactionHeader
|
||||
sQMIServiceRawTransactionHeader
|
||||
sQMIRawMessageHeader
|
||||
sQMIRawContentHeader
|
||||
|
||||
sQMIServiceBuffer
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "StdAfx.h"
|
||||
#include "QMIBuffers.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
/*=========================================================================*/
|
||||
// sQMIServiceBuffer Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
sQMIServiceBuffer (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Constructor
|
||||
|
||||
PARAMETERS:
|
||||
pBuffer [ I ] - Shareable buffer that contains the DIAG data
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
sQMIServiceBuffer::sQMIServiceBuffer( sSharedBuffer * pBuffer )
|
||||
: sProtocolBuffer( pBuffer )
|
||||
{
|
||||
sQMIServiceBuffer::Validate();
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
~sQMIServiceBuffer (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Destructor
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
sQMIServiceBuffer::~sQMIServiceBuffer()
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetResult (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Return contents of mandatory result content
|
||||
|
||||
PARAMETERS:
|
||||
returnCode [ I ] - The return code (should be eQMIResultCode)
|
||||
errorCode [ I ] - The error code (should be eQMIErrorCode)
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool sQMIServiceBuffer::GetResult(
|
||||
ULONG & returnCode,
|
||||
ULONG & errorCode )
|
||||
{
|
||||
if (IsResponse() == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
std::map <ULONG, const sQMIRawContentHeader *>::const_iterator pIter;
|
||||
pIter = mContents.find( QMI_TLV_ID_RESULT );
|
||||
if (pIter == mContents.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const sQMIRawContentHeader * pContent = pIter->second;
|
||||
if (pContent == 0)
|
||||
{
|
||||
ASSERT( 0 );
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pContent->mLength != 4)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const WORD * pData = (const WORD *)(++pContent);
|
||||
|
||||
returnCode = (ULONG)*pData++;
|
||||
errorCode = (ULONG)*pData;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
BuildBuffer (Static Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Build a QMI request
|
||||
|
||||
PARAMETERS:
|
||||
serviceType [ I ] - QMI service type
|
||||
msgID [ I ] - The QMI message request ID
|
||||
bResponse [ I ] - Build a response?
|
||||
bIndication [ I ] - Build an indication?
|
||||
pPayload [ I ] - Payload
|
||||
payloadLen [ I ] - Size of above payload
|
||||
|
||||
RETURN VALUE:
|
||||
sSharedBuffer * : The request in an allocated buffer (0 on error)
|
||||
===========================================================================*/
|
||||
sSharedBuffer * sQMIServiceBuffer::BuildBuffer(
|
||||
eQMIService serviceType,
|
||||
WORD msgID,
|
||||
bool bResponse,
|
||||
bool bIndication,
|
||||
const BYTE * pPayload,
|
||||
ULONG payloadLen )
|
||||
{
|
||||
const ULONG szTransHdr = (ULONG)sizeof(sQMIServiceRawTransactionHeader);
|
||||
const ULONG szMsgHdr = (ULONG)sizeof(sQMIRawMessageHeader);
|
||||
const ULONG totalHdrSz = szTransHdr + szMsgHdr;
|
||||
|
||||
// Truncate payload?
|
||||
if (payloadLen > (QMI_MAX_BUFFER_SIZE - totalHdrSz))
|
||||
{
|
||||
payloadLen = QMI_MAX_BUFFER_SIZE - totalHdrSz;
|
||||
}
|
||||
|
||||
// Make sure length agrees with pointer
|
||||
if (pPayload == 0)
|
||||
{
|
||||
payloadLen = 0;
|
||||
}
|
||||
|
||||
// Allocate buffer
|
||||
PBYTE pBuffer = new BYTE[payloadLen + totalHdrSz];
|
||||
if (pBuffer == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Format header
|
||||
sQMIServiceRawTransactionHeader * pHdr = 0;
|
||||
pHdr = (sQMIServiceRawTransactionHeader *)&pBuffer[0];
|
||||
pHdr->mCompound = 0;
|
||||
pHdr->mResponse = 0;
|
||||
pHdr->mIndication = 0;
|
||||
pHdr->mReserved = 0;
|
||||
pHdr->mTransactionID = 1;
|
||||
|
||||
bool bTX = true;
|
||||
if (bResponse == true)
|
||||
{
|
||||
pHdr->mResponse = 1;
|
||||
bTX = false;
|
||||
}
|
||||
else if (bIndication == true)
|
||||
{
|
||||
pHdr->mIndication = 1;
|
||||
bTX = false;
|
||||
}
|
||||
|
||||
pHdr++;
|
||||
|
||||
// Format message header
|
||||
sQMIRawMessageHeader * pMsg = 0;
|
||||
pMsg = (sQMIRawMessageHeader *)pHdr;
|
||||
pMsg->mMessageID = msgID;
|
||||
pMsg->mLength = (WORD)payloadLen;
|
||||
|
||||
// Copy in payload?
|
||||
if (payloadLen > 0 && pPayload != 0)
|
||||
{
|
||||
memcpy( (LPVOID)&pBuffer[totalHdrSz],
|
||||
(LPCVOID)&pPayload[0],
|
||||
(SIZE_T)payloadLen );
|
||||
}
|
||||
|
||||
// Compute total size
|
||||
ULONG sz = payloadLen + totalHdrSz;
|
||||
|
||||
// Build and return the shared buffer
|
||||
eProtocolType pt = MapQMIServiceToProtocol( serviceType, bTX );
|
||||
sSharedBuffer * pBuf = new sSharedBuffer( sz, pBuffer, pt );
|
||||
return pBuf;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
Validate (Internal Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Is this open unframed request/response packet valid?
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool sQMIServiceBuffer::Validate()
|
||||
{
|
||||
// Assume failure
|
||||
bool bRC = false;
|
||||
|
||||
// Sanity check protocol type
|
||||
eProtocolType pt = GetType();
|
||||
if (IsQMIProtocol( pt ) == false)
|
||||
{
|
||||
mbValid = bRC;
|
||||
return bRC;
|
||||
}
|
||||
|
||||
const ULONG szTransHdr = (ULONG)sizeof(sQMIServiceRawTransactionHeader);
|
||||
const ULONG szMsgHdr = (ULONG)sizeof(sQMIRawMessageHeader);
|
||||
const ULONG szContentHdr = (ULONG)sizeof(sQMIRawContentHeader);
|
||||
|
||||
// Must be enough space for both headers
|
||||
ULONG sz = GetSize();
|
||||
if (sz < szTransHdr + szMsgHdr)
|
||||
{
|
||||
mbValid = bRC;
|
||||
return bRC;
|
||||
}
|
||||
|
||||
const BYTE * pBuffer = GetBuffer();
|
||||
|
||||
// Obtain transaction header
|
||||
const sQMIServiceRawTransactionHeader * pTransHdr = 0;
|
||||
pTransHdr = (const sQMIServiceRawTransactionHeader *)pBuffer;
|
||||
pBuffer += szTransHdr;
|
||||
|
||||
// This is required to be 0
|
||||
if (pTransHdr->mCompound != 0)
|
||||
{
|
||||
mbValid = bRC;
|
||||
return bRC;
|
||||
}
|
||||
|
||||
// These are mutually exclusive
|
||||
if (pTransHdr->mIndication == 1 && pTransHdr->mResponse == 1)
|
||||
{
|
||||
mbValid = bRC;
|
||||
return bRC;
|
||||
}
|
||||
|
||||
// Requests/responses required valid transaction IDs
|
||||
if ( (pTransHdr->mIndication == 0)
|
||||
&& (pTransHdr->mTransactionID == (WORD)INVALID_QMI_TRANSACTION_ID) )
|
||||
{
|
||||
mbValid = bRC;
|
||||
return bRC;
|
||||
}
|
||||
|
||||
if ( (pTransHdr->mResponse == 1 || pTransHdr->mIndication == 1)
|
||||
&& (IsQMIProtocolRX( pt ) == false) )
|
||||
{
|
||||
mbValid = bRC;
|
||||
return bRC;
|
||||
}
|
||||
|
||||
if ( (pTransHdr->mResponse == 0 && pTransHdr->mIndication == 0)
|
||||
&& (IsQMIProtocolTX( pt ) == false) )
|
||||
{
|
||||
mbValid = bRC;
|
||||
return bRC;
|
||||
}
|
||||
|
||||
// Obtain message header
|
||||
const sQMIRawMessageHeader * pMsgHdr = 0;
|
||||
pMsgHdr = (const sQMIRawMessageHeader *)pBuffer;
|
||||
pBuffer += szMsgHdr;
|
||||
|
||||
// Validate reported length
|
||||
if (sz != ((ULONG)pMsgHdr->mLength + szTransHdr + szMsgHdr))
|
||||
{
|
||||
mbValid = bRC;
|
||||
return bRC;
|
||||
}
|
||||
|
||||
// Extract content TLV structures
|
||||
ULONG contentProcessed = 0;
|
||||
ULONG contentSz = (ULONG)pMsgHdr->mLength;
|
||||
while (contentProcessed < contentSz)
|
||||
{
|
||||
const sQMIRawContentHeader * pContent = 0;
|
||||
pContent = (const sQMIRawContentHeader *)pBuffer;
|
||||
|
||||
ULONG tlvLen = szContentHdr + pContent->mLength;
|
||||
|
||||
contentProcessed += tlvLen;
|
||||
if (contentProcessed <= contentSz)
|
||||
{
|
||||
mContents[(ULONG)pContent->mTypeID] = pContent;
|
||||
}
|
||||
else
|
||||
{
|
||||
mContents.clear();
|
||||
|
||||
mbValid = bRC;
|
||||
return bRC;
|
||||
}
|
||||
|
||||
pBuffer += tlvLen;
|
||||
}
|
||||
|
||||
// Validate TLV reported lengths
|
||||
if (contentProcessed != contentSz)
|
||||
{
|
||||
mbValid = bRC;
|
||||
return bRC;
|
||||
}
|
||||
|
||||
// Success!
|
||||
bRC = true;
|
||||
|
||||
mbValid = bRC;
|
||||
return mbValid;
|
||||
}
|
||||
|
|
@ -0,0 +1,379 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
QMIBuffers.h
|
||||
|
||||
DESCRIPTION:
|
||||
QMI service protocol related structures and affliated methods
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
sQMUXHeader
|
||||
sQMIControlRawTransactionHeader
|
||||
sQMIServiceRawTransactionHeader
|
||||
sQMIRawMessageHeader
|
||||
sQMIRawContentHeader
|
||||
|
||||
sQMIServiceBuffer
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "ProtocolBuffer.h"
|
||||
#include "QMIEnum.h"
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// QMI maximum buffer size (cannot be larger than MAX_SHARED_BUFFER_SIZE)
|
||||
const ULONG QMI_MAX_BUFFER_SIZE = MAX_SHARED_BUFFER_SIZE;
|
||||
|
||||
// Content ID for mandatory result TLV
|
||||
const ULONG QMI_TLV_ID_RESULT = 2;
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
MapQMIServiceToProtocol (Inline Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Map QMI service type (eQMIService) and direction to a protocol type
|
||||
(eProtocolType)
|
||||
|
||||
PARAMETERS:
|
||||
serviceType [ I ] - Enum value being mapped
|
||||
bTransmission [ I ] - IS this a transmission (TX vs. RX)?
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
inline eProtocolType MapQMIServiceToProtocol(
|
||||
eQMIService serviceType,
|
||||
bool bTransmission = true )
|
||||
{
|
||||
eProtocolType pt = ePROTOCOL_ENUM_BEGIN;
|
||||
switch (serviceType)
|
||||
{
|
||||
case eQMI_SVC_WDS:
|
||||
pt = ePROTOCOL_QMI_WDS_RX;
|
||||
break;
|
||||
|
||||
case eQMI_SVC_DMS:
|
||||
pt = ePROTOCOL_QMI_DMS_RX;
|
||||
break;
|
||||
|
||||
case eQMI_SVC_NAS:
|
||||
pt = ePROTOCOL_QMI_NAS_RX;
|
||||
break;
|
||||
|
||||
case eQMI_SVC_QOS:
|
||||
pt = ePROTOCOL_QMI_QOS_RX;
|
||||
break;
|
||||
|
||||
case eQMI_SVC_WMS:
|
||||
pt = ePROTOCOL_QMI_WMS_RX;
|
||||
break;
|
||||
|
||||
case eQMI_SVC_PDS:
|
||||
pt = ePROTOCOL_QMI_PDS_RX;
|
||||
break;
|
||||
|
||||
case eQMI_SVC_AUTH:
|
||||
pt = ePROTOCOL_QMI_AUTH_RX;
|
||||
break;
|
||||
|
||||
case eQMI_SVC_VOICE:
|
||||
pt = ePROTOCOL_QMI_VOICE_RX;
|
||||
break;
|
||||
|
||||
case eQMI_SVC_CAT:
|
||||
pt = ePROTOCOL_QMI_CAT_RX;
|
||||
break;
|
||||
|
||||
case eQMI_SVC_RMS:
|
||||
pt = ePROTOCOL_QMI_RMS_RX;
|
||||
break;
|
||||
|
||||
case eQMI_SVC_OMA:
|
||||
pt = ePROTOCOL_QMI_OMA_RX;
|
||||
break;
|
||||
|
||||
case eQMI_SVC_CONTROL:
|
||||
pt = ePROTOCOL_QMI_CTL_RX;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (pt != ePROTOCOL_ENUM_BEGIN && bTransmission == true)
|
||||
{
|
||||
// This relies on the fact the the TX variant is always the next
|
||||
// enumerated value after the RX variant (so don't do something
|
||||
// to change that)
|
||||
pt = (eProtocolType)((ULONG)pt + 1);
|
||||
}
|
||||
|
||||
return pt;
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas (pack structs)
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma pack( push, 1 )
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sQMUXHeader
|
||||
// Struct to represent a QMUX transaction header (raw)
|
||||
/*=========================================================================*/
|
||||
struct sQMUXHeader
|
||||
{
|
||||
public:
|
||||
WORD mLength;
|
||||
BYTE mFlags;
|
||||
BYTE mServiceType;
|
||||
BYTE mClientID;
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sQMIControlRawTransactionHeader
|
||||
// Struct to represent a QMI control transaction header (raw)
|
||||
/*=========================================================================*/
|
||||
struct sQMIControlRawTransactionHeader
|
||||
{
|
||||
public:
|
||||
BYTE mResponse : 1; // Is this a response transaction?
|
||||
BYTE mIndication : 1; // Is this an indication transaction?
|
||||
BYTE mReserved : 6;
|
||||
|
||||
BYTE mTransactionID; // Transaction ID
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sQMIServiceRawTransactionHeader
|
||||
// Struct to represent a QMI service transaction header (raw)
|
||||
/*=========================================================================*/
|
||||
struct sQMIServiceRawTransactionHeader
|
||||
{
|
||||
public:
|
||||
BYTE mCompound : 1; // Is this a compound transaction?
|
||||
BYTE mResponse : 1; // Is this a response transaction?
|
||||
BYTE mIndication : 1; // Is this an indication transaction?
|
||||
BYTE mReserved : 5;
|
||||
|
||||
WORD mTransactionID; // Transaction ID
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sQMIRawMessageHeader
|
||||
// Struct to represent a QMI (control/service) message header (raw)
|
||||
/*=========================================================================*/
|
||||
struct sQMIRawMessageHeader
|
||||
{
|
||||
public:
|
||||
WORD mMessageID; // Message ID
|
||||
WORD mLength; // Length of message (not including this header)
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sQMIRawContentHeader
|
||||
// Struct to represent a QMI (control/service) content
|
||||
// (i.e Type/Length/Value, TLV) header (raw)
|
||||
/*=========================================================================*/
|
||||
struct sQMIRawContentHeader
|
||||
{
|
||||
public:
|
||||
BYTE mTypeID; // Content type ID
|
||||
WORD mLength; // Content length (not including this header)
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma pack( pop )
|
||||
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sQMIServiceBuffer
|
||||
// Struct to represent a QMI service channel request/response/indication
|
||||
// (shared buffer)
|
||||
/*=========================================================================*/
|
||||
struct sQMIServiceBuffer : public sProtocolBuffer
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
sQMIServiceBuffer( sSharedBuffer * pBuffer );
|
||||
|
||||
// Destructor
|
||||
virtual ~sQMIServiceBuffer();
|
||||
|
||||
// (Inline) Is this a request?
|
||||
bool IsRequest() const
|
||||
{
|
||||
bool bRequest = false;
|
||||
|
||||
const sQMIServiceRawTransactionHeader * pHdr = GetHeader();
|
||||
if (pHdr != 0)
|
||||
{
|
||||
bRequest = (pHdr->mResponse == 0 && pHdr->mIndication == 0);
|
||||
}
|
||||
|
||||
return bRequest;
|
||||
};
|
||||
|
||||
// (Inline) Is this a response?
|
||||
bool IsResponse() const
|
||||
{
|
||||
bool bResponse = false;
|
||||
|
||||
const sQMIServiceRawTransactionHeader * pHdr = GetHeader();
|
||||
if (pHdr != 0)
|
||||
{
|
||||
bResponse = (pHdr->mResponse == 1);
|
||||
}
|
||||
|
||||
return bResponse;
|
||||
};
|
||||
|
||||
// (Inline) Is this an indication?
|
||||
bool IsIndication() const
|
||||
{
|
||||
bool bInd = false;
|
||||
|
||||
const sQMIServiceRawTransactionHeader * pHdr = GetHeader();
|
||||
if (pHdr != 0)
|
||||
{
|
||||
bInd = (pHdr->mIndication == 1);
|
||||
}
|
||||
|
||||
return bInd;
|
||||
};
|
||||
|
||||
// (Inline) Return raw header
|
||||
const sQMIServiceRawTransactionHeader * GetHeader() const
|
||||
{
|
||||
const sQMIServiceRawTransactionHeader * pHdr = 0;
|
||||
if (IsValid() == true)
|
||||
{
|
||||
pHdr = (const sQMIServiceRawTransactionHeader *)GetBuffer();
|
||||
}
|
||||
|
||||
return pHdr;
|
||||
};
|
||||
|
||||
// (Inline) Return the message ID
|
||||
ULONG GetMessageID() const
|
||||
{
|
||||
ULONG id = (ULONG)ULONG_MAX;
|
||||
|
||||
const sQMIServiceRawTransactionHeader * pHdr = GetHeader();
|
||||
if (pHdr != 0)
|
||||
{
|
||||
pHdr++;
|
||||
const sQMIRawMessageHeader * pMsgHdr = 0;
|
||||
pMsgHdr = (sQMIRawMessageHeader *)pHdr;
|
||||
|
||||
id = pMsgHdr->mMessageID;
|
||||
}
|
||||
|
||||
return id;
|
||||
};
|
||||
|
||||
// (Inline) Return the transaction ID
|
||||
WORD GetTransactionID() const
|
||||
{
|
||||
WORD id = (WORD)INVALID_QMI_TRANSACTION_ID;
|
||||
|
||||
const sQMIServiceRawTransactionHeader * pHdr = GetHeader();
|
||||
if (pHdr != 0)
|
||||
{
|
||||
id = pHdr->mTransactionID;
|
||||
}
|
||||
|
||||
return id;
|
||||
};
|
||||
|
||||
// (Inline) Return content structures
|
||||
std::map <ULONG, const sQMIRawContentHeader *> GetContents() const
|
||||
{
|
||||
return mContents;
|
||||
};
|
||||
|
||||
// Return contents of mandatory result content
|
||||
bool GetResult(
|
||||
ULONG & returnCode,
|
||||
ULONG & errorCode );
|
||||
|
||||
// Build a QMI request/response/indication
|
||||
static sSharedBuffer * BuildBuffer(
|
||||
eQMIService serviceType,
|
||||
WORD msgID,
|
||||
bool bResponse = false,
|
||||
bool bIndication = false,
|
||||
const BYTE * pData = 0,
|
||||
ULONG dataLen = 0 );
|
||||
|
||||
protected:
|
||||
// QMI protocol server has to be able to set the transaction ID
|
||||
friend class cQMIProtocolServer;
|
||||
|
||||
// Set the transaction ID
|
||||
void SetTransactionID( WORD tid ) const
|
||||
{
|
||||
if (tid == (WORD)INVALID_QMI_TRANSACTION_ID || IsValid() == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
sQMIServiceRawTransactionHeader * pHdr = 0;
|
||||
pHdr = (sQMIServiceRawTransactionHeader *)GetHeader();
|
||||
if (pHdr != 0)
|
||||
{
|
||||
pHdr->mTransactionID = tid;
|
||||
}
|
||||
};
|
||||
|
||||
// Is this QMI request/response/indication packet valid?
|
||||
virtual bool Validate();
|
||||
|
||||
/* Content TLV structures (indexed by type ID) */
|
||||
std::map <ULONG, const sQMIRawContentHeader *> mContents;
|
||||
|
||||
private:
|
||||
// Prevent 'upcopying'
|
||||
sQMIServiceBuffer( const sProtocolBuffer & );
|
||||
sQMIServiceBuffer & operator = ( const sProtocolBuffer & );
|
||||
};
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,424 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
QMIProtocolServer.h
|
||||
|
||||
DESCRIPTION:
|
||||
QMI protocol server
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
cQMIProtocolServer
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "StdAfx.h"
|
||||
#include "QMIProtocolServer.h"
|
||||
#include "QMIBuffers.h"
|
||||
|
||||
/*=========================================================================*/
|
||||
// cQMIProtocolServer Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
cQMIProtocolServer (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Constructor
|
||||
|
||||
PARAMETERS:
|
||||
serviceType [ I ] - QMI service type requested
|
||||
bufferSzRx [ I ] - Size of data buffer for incoming data
|
||||
logSz [ I ] - Size of log (number of buffers)
|
||||
|
||||
SEQUENCING:
|
||||
None (constructs sequencing objects)
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cQMIProtocolServer::cQMIProtocolServer(
|
||||
eQMIService serviceType,
|
||||
ULONG bufferSzRx,
|
||||
ULONG logSz )
|
||||
: cProtocolServer( MapQMIServiceToProtocol( serviceType, false ),
|
||||
MapQMIServiceToProtocol( serviceType, true ),
|
||||
bufferSzRx,
|
||||
logSz ),
|
||||
mLastTID( (WORD)INVALID_QMI_TRANSACTION_ID ),
|
||||
mService( serviceType ),
|
||||
mMEID( "" )
|
||||
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
~cQMIProtocolServer (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Destructor
|
||||
|
||||
SEQUENCING:
|
||||
None (constructs sequencing objects)
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cQMIProtocolServer::~cQMIProtocolServer()
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
Connect (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Connect to the configured QMI service using the given QMI
|
||||
control file
|
||||
|
||||
PARAMETERS:
|
||||
pControlFile [ I ] - QMI control file
|
||||
|
||||
SEQUENCING:
|
||||
This method is sequenced according to the command event, i.e. any
|
||||
other thread that needs to send a command to the protocol server
|
||||
thread will block until this method completes
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cQMIProtocolServer::Connect( LPCSTR pControlFile )
|
||||
{
|
||||
// Assume failure
|
||||
bool bRC = false;
|
||||
if (IsValid( mService ) == false || mService == eQMI_SVC_CONTROL)
|
||||
{
|
||||
return bRC;
|
||||
}
|
||||
|
||||
// Store the MEID
|
||||
mMEID = GetDeviceMEID( pControlFile );
|
||||
|
||||
// Pass service file to base class for actual connection
|
||||
bRC = cProtocolServer::Connect( pControlFile );
|
||||
|
||||
if (bRC == false)
|
||||
{
|
||||
TRACE( "QMI connect %d failed\n", mService );
|
||||
}
|
||||
|
||||
return bRC;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetDeviceMEID (Internal Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Get device MEID by interfacing to the given QMI control file
|
||||
|
||||
PARAMETERS:
|
||||
deviceNode [ I ] - QMI device node
|
||||
|
||||
SEQUENCING:
|
||||
None (must be called from protocol server thread)
|
||||
|
||||
RETURN VALUE:
|
||||
std::string (empty upon failure)
|
||||
===========================================================================*/
|
||||
std::string cQMIProtocolServer::GetDeviceMEID( std::string deviceNode )
|
||||
{
|
||||
std::string retStr = "";
|
||||
|
||||
int devHandle = open( deviceNode.c_str(), 0 );
|
||||
if (devHandle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
return retStr;
|
||||
}
|
||||
|
||||
char devMEID[15];
|
||||
memset( &devMEID[0], 0, 15 );
|
||||
|
||||
if (ioctl( devHandle, QMI_GET_MEID_IOCTL, &devMEID[0] ) != 0)
|
||||
{
|
||||
close( devHandle );
|
||||
return retStr;
|
||||
}
|
||||
|
||||
// Enforce null
|
||||
devMEID[14] = 0;
|
||||
|
||||
retStr = &devMEID[0];
|
||||
|
||||
close( devHandle );
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
ValidateRequest (Internal Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Validate a request that is about to be scheduled
|
||||
|
||||
SEQUENCING:
|
||||
This method is sequenced according to the command event, i.e. any
|
||||
other thread that needs to send a command to the protocol server
|
||||
thread will block until this method completes
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cQMIProtocolServer::ValidateRequest( const sProtocolRequest & req )
|
||||
{
|
||||
if (cProtocolServer::ValidateRequest( req ) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
sQMIServiceBuffer qmiReq( req.GetSharedBuffer() );
|
||||
return qmiReq.IsValid();
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
InitializeComm (Internal Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Perform protocol specific communications port initialization
|
||||
|
||||
SEQUENCING:
|
||||
None (must be called from protocol server thread)
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cQMIProtocolServer::InitializeComm()
|
||||
{
|
||||
// Setup the QMI Service type
|
||||
int result = mComm.RunIOCTL( QMI_GET_SERVICE_FILE_IOCTL,
|
||||
(void*)(unsigned long)mService );
|
||||
|
||||
if (result == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
CleanupComm (Internal Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Perform protocol specific communications port cleanup
|
||||
|
||||
SEQUENCING:
|
||||
None (must be called from protocol server thread)
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cQMIProtocolServer::CleanupComm()
|
||||
{
|
||||
// Nothing to actually do here
|
||||
return true;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
DecodeRxData (Internal Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Decode incoming data into QMI indications/responses
|
||||
|
||||
PARAMETERS:
|
||||
bytesReceived [ I ] - Number of bytes to decoded
|
||||
rspIdx [ O ] - Log index of last valid response (not used)
|
||||
bAbortTx [ O ] - Response aborts current transmission? (not used)
|
||||
|
||||
SEQUENCING:
|
||||
None (must be called from protocol server thread)
|
||||
|
||||
RETURN VALUE:
|
||||
bool - Was a response received?
|
||||
===========================================================================*/
|
||||
bool cQMIProtocolServer::DecodeRxData(
|
||||
ULONG bytesReceived,
|
||||
ULONG & rspIdx,
|
||||
bool & bAbortTx )
|
||||
{
|
||||
// Assume failure
|
||||
bool bRC = false;
|
||||
|
||||
rspIdx = INVALID_LOG_INDEX;
|
||||
bAbortTx = false;
|
||||
|
||||
// Something to decode from?
|
||||
if (bytesReceived == 0)
|
||||
{
|
||||
return bRC;
|
||||
}
|
||||
|
||||
// Set protocol type (we have to be dealing with a valid QMI service)
|
||||
eProtocolType pt = MapQMIServiceToProtocol( mService, false );
|
||||
if (pt == ePROTOCOL_ENUM_BEGIN)
|
||||
{
|
||||
return bRC;
|
||||
}
|
||||
|
||||
sSharedBuffer * pTmp = 0;
|
||||
pTmp = new sSharedBuffer( mpRxBuffer, bytesReceived, pt );
|
||||
if (pTmp != 0)
|
||||
{
|
||||
sQMIServiceBuffer tmpBuf( pTmp );
|
||||
if (tmpBuf.IsValid() == true)
|
||||
{
|
||||
rspIdx = mLog.AddBuffer( tmpBuf );
|
||||
if (IsResponse( tmpBuf ) == true)
|
||||
{
|
||||
bRC = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
rspIdx = INVALID_LOG_INDEX;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bRC;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
EncodeTxData (Internal Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Encode data for transmission
|
||||
|
||||
PARAMETERS:
|
||||
pBuffer [ I ] - Data to be encoded
|
||||
bEncoded [ O ] - Do we even encode data?
|
||||
|
||||
SEQUENCING:
|
||||
None (must be called from protocol server thread)
|
||||
|
||||
RETURN VALUE:
|
||||
sSharedBuffer * - Encoded data (0 upon error when encoding is indicated)
|
||||
===========================================================================*/
|
||||
sSharedBuffer * cQMIProtocolServer::EncodeTxData(
|
||||
sSharedBuffer * pBuffer,
|
||||
bool & bEncoded )
|
||||
{
|
||||
WORD tid = ++mLastTID;
|
||||
if (tid == (WORD)INVALID_QMI_TRANSACTION_ID)
|
||||
{
|
||||
tid++;
|
||||
}
|
||||
|
||||
sQMIServiceBuffer tmpBuf( pBuffer );
|
||||
tmpBuf.SetTransactionID( tid );
|
||||
|
||||
// No actual encoding required as we alter the original request
|
||||
bEncoded = false;
|
||||
return 0;
|
||||
};
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
IsResponse (Internal Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Is the passed in data a response to the current request?
|
||||
|
||||
PARAMETERS:
|
||||
rsp [ I ] - Candidate response
|
||||
|
||||
SEQUENCING:
|
||||
None (must be called from protocol server thread)
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cQMIProtocolServer::IsResponse( const sProtocolBuffer & rsp )
|
||||
{
|
||||
// Assume not
|
||||
bool bRC = false;
|
||||
if ( (mpActiveRequest == 0)
|
||||
|| (mpActiveRequest->mRequest.IsValid() == false)
|
||||
|| (mpActiveRequest->mbWaitingForResponse == false)
|
||||
|| (rsp.IsValid() == false) )
|
||||
{
|
||||
return bRC;
|
||||
}
|
||||
|
||||
sQMIServiceBuffer qmiReq( mpActiveRequest->mRequest.GetSharedBuffer() );
|
||||
sQMIServiceBuffer qmiRsp( rsp.GetSharedBuffer() );
|
||||
|
||||
if (qmiReq.IsValid() == false || qmiRsp.IsValid() == false)
|
||||
{
|
||||
return bRC;
|
||||
}
|
||||
|
||||
if (qmiRsp.IsResponse() == false)
|
||||
{
|
||||
return bRC;
|
||||
}
|
||||
|
||||
WORD reqID = qmiReq.GetTransactionID();
|
||||
WORD rspID = qmiRsp.GetTransactionID();
|
||||
|
||||
if ( (reqID == (WORD)INVALID_QMI_TRANSACTION_ID)
|
||||
|| (rspID == (WORD)INVALID_QMI_TRANSACTION_ID)
|
||||
|| (reqID != rspID) )
|
||||
{
|
||||
return bRC;
|
||||
}
|
||||
|
||||
// Sadly there are documentated cases of firmware returning responses
|
||||
// with a matching transaction ID but a mismatching message ID. There
|
||||
// is no reason for this to be considered valid behavior as of yet
|
||||
ULONG reqMsgID = qmiReq.GetMessageID();
|
||||
ULONG rspMsgID = qmiRsp.GetMessageID();
|
||||
|
||||
if (reqMsgID != rspMsgID)
|
||||
{
|
||||
return bRC;
|
||||
}
|
||||
|
||||
bRC = true;
|
||||
return bRC;
|
||||
}
|
|
@ -0,0 +1,128 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
QMIProtocolServer.h
|
||||
|
||||
DESCRIPTION:
|
||||
QMI protocol server
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
cQMIProtocolServer
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "ProtocolServer.h"
|
||||
#include "QMIEnum.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
/*=========================================================================*/
|
||||
// Class cQMIProtocolServer
|
||||
/*=========================================================================*/
|
||||
class cQMIProtocolServer : public cProtocolServer
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
cQMIProtocolServer(
|
||||
eQMIService serviceType,
|
||||
ULONG bufferSzRx,
|
||||
ULONG logSz );
|
||||
|
||||
// Destructor
|
||||
virtual ~cQMIProtocolServer();
|
||||
|
||||
// Connect to the given QMI service using the configured QMI
|
||||
// control file
|
||||
bool Connect( LPCSTR pControlFile );
|
||||
|
||||
// (Inline) Return the device MEID
|
||||
std::string GetMEID()
|
||||
{
|
||||
return mMEID;
|
||||
};
|
||||
|
||||
// (Inline) Return the QMI service type
|
||||
eQMIService GetServiceType()
|
||||
{
|
||||
return mService;
|
||||
};
|
||||
|
||||
// Get device MEID by interfacing to the given device node
|
||||
static std::string GetDeviceMEID( std::string deviceNode );
|
||||
|
||||
protected:
|
||||
// Validate a request that is about to be scheduled
|
||||
virtual bool ValidateRequest( const sProtocolRequest & req );
|
||||
|
||||
// Perform protocol specific communications port initialization
|
||||
virtual bool InitializeComm();
|
||||
|
||||
// Perform protocol specific communications port cleanup
|
||||
virtual bool CleanupComm();
|
||||
|
||||
// Decode incoming data into packets returning the last response
|
||||
virtual bool DecodeRxData(
|
||||
ULONG bytesReceived,
|
||||
ULONG & rspIdx,
|
||||
bool & bAbortTx );
|
||||
|
||||
// Encode data for transmission
|
||||
virtual sSharedBuffer * EncodeTxData(
|
||||
sSharedBuffer * pBuffer,
|
||||
bool & bEncoded );
|
||||
|
||||
// Is the passed in data a response to the current request?
|
||||
virtual bool IsResponse( const sProtocolBuffer & rsp );
|
||||
|
||||
// (Inline) Is the passed in data a response that aborts the
|
||||
// current request?
|
||||
virtual bool IsTxAbortResponse( const sProtocolBuffer & /* rsp */ )
|
||||
{
|
||||
// QMI doesn't necessarily require this
|
||||
return false;
|
||||
};
|
||||
|
||||
/* Current transaction ID */
|
||||
SHORT mLastTID;
|
||||
|
||||
/* Type of QMI service we are serving */
|
||||
eQMIService mService;
|
||||
|
||||
/* Device MEID */
|
||||
std::string mMEID;
|
||||
};
|
|
@ -0,0 +1,382 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
SharedBuffer.cpp
|
||||
|
||||
DESCRIPTION:
|
||||
Shareable protocol structures and affliated methods
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
|
||||
sSharedBuffer
|
||||
Simple struct to represent a reference counted shareable (no copy)
|
||||
buffer, as the basis for all buffer related classes
|
||||
|
||||
sDiagBuffer
|
||||
Simple struct to represent a DIAG buffer using a reference counted
|
||||
(shared) buffer, this allows us to use in in several places without
|
||||
copying it once in each place. A few base services are provided
|
||||
but the main purpose is to provide a class to inherit off of for
|
||||
DIAG command code specific DIAG buffers
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "StdAfx.h"
|
||||
#include "SharedBuffer.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// Synchronization object
|
||||
struct sSharedBufferSync
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
sSharedBufferSync()
|
||||
: mbInitialized( false )
|
||||
{
|
||||
int nRet = pthread_mutex_init( &mSyncSection, NULL );
|
||||
if (nRet != 0)
|
||||
{
|
||||
TRACE( "SharedBuffer: Unable to init sync mutex."
|
||||
" Error %d: %s\n",
|
||||
nRet,
|
||||
strerror( nRet ) );
|
||||
return;
|
||||
}
|
||||
|
||||
mbInitialized = true;
|
||||
};
|
||||
|
||||
// Destructor
|
||||
~sSharedBufferSync()
|
||||
{
|
||||
mbInitialized = false;
|
||||
int nRet = pthread_mutex_destroy( &mSyncSection );
|
||||
if (nRet != 0)
|
||||
{
|
||||
TRACE( "SharedBuffer: Unable to destroy sync mutex."
|
||||
" Error %d: %s\n",
|
||||
nRet,
|
||||
strerror( nRet ) );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Lock sync object
|
||||
void Lock()
|
||||
{
|
||||
if (mbInitialized == true)
|
||||
{
|
||||
int nRet = pthread_mutex_lock( &mSyncSection );
|
||||
if (nRet != 0)
|
||||
{
|
||||
TRACE( "SharedBuffer: Unable to lock sync mutex."
|
||||
" Error %d: %s\n",
|
||||
nRet,
|
||||
strerror( nRet ) );
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
// Unlock sync object
|
||||
void Unlock()
|
||||
{
|
||||
if (mbInitialized == true)
|
||||
{
|
||||
int nRet = pthread_mutex_unlock( &mSyncSection );
|
||||
if (nRet != 0)
|
||||
{
|
||||
TRACE( "SharedBuffer: Unable to unlock sync mutex."
|
||||
" Error %d: %s\n",
|
||||
nRet,
|
||||
strerror( nRet ) );
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
protected:
|
||||
/* DIAG buffer critical section */
|
||||
pthread_mutex_t mSyncSection;
|
||||
|
||||
/* Has this object been initialized? */
|
||||
bool mbInitialized;
|
||||
};
|
||||
|
||||
// Global (across all shared buffers) reference count guard
|
||||
sSharedBufferSync gRefCount;
|
||||
|
||||
/*=========================================================================*/
|
||||
// sSharedBuffer Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
sSharedBuffer (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Constructor (copy passed in buffer)
|
||||
|
||||
PARAMETERS:
|
||||
pDataToCopy [ I ] - The data buffer to copy (should be non-zero)
|
||||
dataLen [ I ] - The length of the above buffer (should be > 1)
|
||||
dataType [ I ] - Type of data (not used internal to class)
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
sSharedBuffer::sSharedBuffer(
|
||||
const BYTE * pDataToCopy,
|
||||
ULONG dataLen,
|
||||
ULONG dataType )
|
||||
: mpData( 0 ),
|
||||
mSize( 0 ),
|
||||
mType( dataType ),
|
||||
mRefCount( 0 )
|
||||
{
|
||||
// Length not too small/not too big?
|
||||
if (IsValidSize( dataLen ) == true)
|
||||
{
|
||||
// Yes, data actually exists?
|
||||
if (pDataToCopy != 0)
|
||||
{
|
||||
// Yes, try to allocate memory
|
||||
mpData = new BYTE[dataLen];
|
||||
if (mpData != 0)
|
||||
{
|
||||
// Now copy into our allocation
|
||||
memcpy( (PVOID)mpData,
|
||||
(LPCVOID)pDataToCopy,
|
||||
(SIZE_T)dataLen );
|
||||
|
||||
// Now set the size, we do this last so that our double
|
||||
// deletion logic is only applied if we had an allocation
|
||||
// in the first place
|
||||
mSize = dataLen;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
sSharedBuffer (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Constructor (assume ownership of passed in buffer)
|
||||
|
||||
PARAMETERS:
|
||||
dataLen [ I ] - The length of the above buffer (should be > 1)
|
||||
pDataToOwn [ I ] - The data buffer to assume ownership of (should
|
||||
be non-zero)
|
||||
|
||||
dataType [ I ] - Type of data (not used internal to class)
|
||||
|
||||
NOTE: The order is intentionally reversed from the previous constructor
|
||||
to avoid any cases of mistaken identity (copy versus assume ownership)
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
sSharedBuffer::sSharedBuffer(
|
||||
ULONG dataLen,
|
||||
PBYTE pDataToOwn,
|
||||
ULONG dataType )
|
||||
: mpData( 0 ),
|
||||
mSize( 0 ),
|
||||
mType( dataType ),
|
||||
mRefCount( 0 )
|
||||
{
|
||||
// Data actually exists?
|
||||
if (pDataToOwn != 0)
|
||||
{
|
||||
// Yes, length not too small/not too big?
|
||||
if (IsValidSize( dataLen ) == true)
|
||||
{
|
||||
// Yes, assume ownership of the passed in buffer
|
||||
mpData = pDataToOwn;
|
||||
mSize = dataLen;
|
||||
}
|
||||
else
|
||||
{
|
||||
// This data buffer is not acceptable to us, but we have assumed
|
||||
// ownership of the memory which we will now free
|
||||
delete [] pDataToOwn;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
~sSharedBuffer (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Destructor
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
sSharedBuffer::~sSharedBuffer()
|
||||
{
|
||||
ASSERT( mRefCount == 0 );
|
||||
|
||||
// Buffer data to free?
|
||||
if (mpData != 0)
|
||||
{
|
||||
// Yes, zero first byte for caution and then delete it
|
||||
mpData[0] = 0;
|
||||
delete [] mpData;
|
||||
|
||||
// Even more caution, zero out pointer
|
||||
mpData = 0;
|
||||
}
|
||||
else if (mSize != 0)
|
||||
{
|
||||
ASSERT( (PVOID)("Double deletion detected in ~sSharedBuffer") == 0 );
|
||||
}
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
operator == (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Equality operator
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool sSharedBuffer::operator == ( const sSharedBuffer & refBuf ) const
|
||||
{
|
||||
// Assume they are not equal
|
||||
bool bEq = false;
|
||||
|
||||
// The buffers must be the same
|
||||
if (mpData == refBuf.mpData)
|
||||
{
|
||||
if (mSize == refBuf.mSize)
|
||||
{
|
||||
if (mRefCount == refBuf.mRefCount)
|
||||
{
|
||||
if (mType == refBuf.mType)
|
||||
{
|
||||
// The shared buffers are the same
|
||||
bEq = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Very odd - the buffers are the same, but not the ref count?!?
|
||||
ASSERT( 0 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Very odd - the buffers are the same, but not the size?!?
|
||||
ASSERT( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
return bEq;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
operator != (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Inequality operator
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool sSharedBuffer::operator != ( const sSharedBuffer & refBuf ) const
|
||||
{
|
||||
if (*this == refBuf)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
AddRef (Internal Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Increment reference count
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
void sSharedBuffer::AddRef()
|
||||
{
|
||||
gRefCount.Lock();
|
||||
mRefCount++;
|
||||
gRefCount.Unlock();
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
Release (Internal Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Release reference, delete if reference count zero
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
void sSharedBuffer::Release()
|
||||
{
|
||||
gRefCount.Lock();
|
||||
|
||||
ASSERT( mRefCount != 0 );
|
||||
|
||||
// Decrement reference count
|
||||
if (mRefCount > 0)
|
||||
{
|
||||
mRefCount--;
|
||||
}
|
||||
|
||||
// ... and delete if reference count now 0
|
||||
if (mRefCount == 0)
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
|
||||
gRefCount.Unlock();
|
||||
}
|
|
@ -0,0 +1,166 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
SharedBuffer.h
|
||||
|
||||
DESCRIPTION:
|
||||
Shareable buffer structures and affliated methods
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
sSharedBuffer
|
||||
Simple struct to represent a reference counted shareable (no copy)
|
||||
buffer, as the basis for all buffer related classes
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Forward Declarations
|
||||
//---------------------------------------------------------------------------
|
||||
struct sProtocolBuffer;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// Maximum size of a shared buffer
|
||||
const ULONG MAX_SHARED_BUFFER_SIZE = 1024 * 16 + 256;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas (pack structs)
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma pack( push, 1 )
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sSharedBuffer
|
||||
//
|
||||
// Simple struct to represent a reference counted shareable (no copy)
|
||||
// buffer, as the basis for all buffer related classes
|
||||
//
|
||||
// NOTE: Do *NOT* create instances of this structure on the stack, it
|
||||
// must be dynamically allocated in order to function correctly
|
||||
/*=========================================================================*/
|
||||
struct sSharedBuffer
|
||||
{
|
||||
public:
|
||||
// Constructor (copy passed in buffer)
|
||||
sSharedBuffer(
|
||||
const BYTE * pDataToCopy,
|
||||
ULONG dataLen,
|
||||
ULONG dataType );
|
||||
|
||||
// Constructor (assume ownership of passed in buffer)
|
||||
sSharedBuffer(
|
||||
ULONG dataLen,
|
||||
PBYTE pDataToOwn,
|
||||
ULONG dataType );
|
||||
|
||||
// Destructor
|
||||
virtual ~sSharedBuffer();
|
||||
|
||||
// Equality operator
|
||||
bool operator == ( const sSharedBuffer & ) const;
|
||||
|
||||
// Inequality operator
|
||||
bool operator != ( const sSharedBuffer & ) const;
|
||||
|
||||
// (Inline) Get buffer
|
||||
const BYTE * GetBuffer() const
|
||||
{
|
||||
return mpData;
|
||||
};
|
||||
|
||||
// (Inline) Get buffer size
|
||||
ULONG GetSize() const
|
||||
{
|
||||
return mSize;
|
||||
};
|
||||
|
||||
// (Inline) Get buffer type
|
||||
ULONG GetType() const
|
||||
{
|
||||
return mType;
|
||||
};
|
||||
|
||||
// (Inline) Is this buffer valid?
|
||||
bool IsValid() const
|
||||
{
|
||||
return (mpData != 0 && IsValidSize( mSize ));
|
||||
};
|
||||
|
||||
// (Inline) Get reference count
|
||||
ULONG GetRefCount() const
|
||||
{
|
||||
return mRefCount;
|
||||
};
|
||||
|
||||
// (Static Inline) Is the passed in size within the allowable range
|
||||
// a shared buffer?
|
||||
static bool IsValidSize( ULONG sz )
|
||||
{
|
||||
return (sz > 0 && sz <= MAX_SHARED_BUFFER_SIZE);
|
||||
};
|
||||
|
||||
protected:
|
||||
// Add reference
|
||||
void AddRef();
|
||||
|
||||
// Release reference, delete if reference count zero
|
||||
void Release();
|
||||
|
||||
/* Data */
|
||||
PBYTE mpData;
|
||||
|
||||
/* Size of data */
|
||||
ULONG mSize;
|
||||
|
||||
/* Type of data */
|
||||
ULONG mType;
|
||||
|
||||
/* Reference count */
|
||||
ULONG mRefCount;
|
||||
|
||||
private:
|
||||
// Leave copy constructor and assignment operator unimplemented
|
||||
// to prevent unintentional and unauthorized copying of the object
|
||||
// (which would lead to bad reference counting)
|
||||
sSharedBuffer( const sSharedBuffer & );
|
||||
sSharedBuffer & operator = ( const sSharedBuffer & );
|
||||
|
||||
friend struct sProtocolBuffer;
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma pack( pop )
|
||||
|
|
@ -0,0 +1,172 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
StdAfx.h
|
||||
|
||||
DESCRIPTION:
|
||||
Application Framework eXtenstions for Linux
|
||||
|
||||
PUBLIC CLASSES AND FUNCTIONS:
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma once
|
||||
//---------------------------------------------------------------------------
|
||||
// Includes
|
||||
//---------------------------------------------------------------------------
|
||||
#include <aio.h>
|
||||
#include <fstream>
|
||||
#include <assert.h>
|
||||
#include <termios.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <algorithm>
|
||||
#include <limits.h>
|
||||
#include <dirent.h>
|
||||
#include <sstream>
|
||||
#include <stdarg.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Macro defination
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#define ASSERT( x ) assert( x )
|
||||
|
||||
#ifdef DEBUG
|
||||
#define TRACE printf
|
||||
#else
|
||||
#define TRACE(...)
|
||||
#endif
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// data type defination
|
||||
//---------------------------------------------------------------------------
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#ifndef CONST
|
||||
#define CONST const
|
||||
#endif
|
||||
|
||||
typedef void VOID;
|
||||
typedef unsigned long DWORD;
|
||||
typedef int BOOL;
|
||||
typedef unsigned char BYTE;
|
||||
typedef unsigned short WORD;
|
||||
typedef float FLOAT;
|
||||
typedef long long LONGLONG;
|
||||
typedef unsigned long long ULONGLONG;
|
||||
typedef signed char INT8;
|
||||
typedef double DOUBLE;
|
||||
|
||||
typedef int INT;
|
||||
typedef unsigned int UINT;
|
||||
typedef unsigned int * PUINT;
|
||||
typedef INT HANDLE;
|
||||
typedef HANDLE HMODULE;
|
||||
|
||||
typedef char CHAR;
|
||||
typedef short SHORT;
|
||||
typedef long LONG;
|
||||
|
||||
typedef unsigned long ULONG;
|
||||
typedef ULONG * PULONG;
|
||||
typedef unsigned short USHORT;
|
||||
typedef USHORT * PUSHORT;
|
||||
typedef unsigned char UCHAR;
|
||||
typedef UCHAR * PUCHAR;
|
||||
typedef char * PSZ;
|
||||
|
||||
|
||||
typedef CONST CHAR * LPCSTR;
|
||||
typedef CHAR * LPSTR;
|
||||
|
||||
typedef BYTE * PBYTE;
|
||||
typedef BOOL * PBOOL;
|
||||
typedef INT * PINT;
|
||||
typedef UINT * LPINT;
|
||||
typedef WORD * PWORD;
|
||||
typedef PWORD LPWORD;
|
||||
typedef LONG * LPLONG;
|
||||
typedef DWORD * PDWORD;
|
||||
typedef VOID * PVOID;
|
||||
typedef PVOID LPVOID;
|
||||
typedef const void * LPCVOID;
|
||||
|
||||
typedef size_t SIZE_T;
|
||||
typedef double DATE;
|
||||
|
||||
// Error code
|
||||
#define NO_ERROR 0L
|
||||
#define ERROR_SUCCESS 0L
|
||||
#define ERROR_NO_MORE_ITEMS 259L
|
||||
#define ERROR_CRC 23L
|
||||
#define ERROR_OUTOFMEMORY 14L
|
||||
#define ERROR_CAN_NOT_COMPLETE 1003L
|
||||
#define ERROR_REVISION_MISMATCH 1306L
|
||||
#define ERROR_BAD_ARGUMENTS 160L
|
||||
#define INVALID_SET_FILE_POINTER -1
|
||||
#define VALID_HANDLE_VALUE 0
|
||||
#define INVALID_HANDLE_VALUE -1
|
||||
#define INVALID_FILE_SZ -1
|
||||
|
||||
#define ERROR_GEN_FAILURE 31L
|
||||
#define ERROR_FILE_NOT_FOUND 2L
|
||||
#define ERROR_NOT_ENOUGH_MEMORY 8L
|
||||
#define ERROR_INVALID_PARAMETER 87L
|
||||
#define ERROR_BAD_FORMAT 11L
|
||||
|
||||
|
||||
// Other Constant definitions
|
||||
#define MAX_PATH 512
|
||||
#define INFINITE 0xffffffff
|
||||
|
||||
|
||||
// SIOCIWFIRSTPRIV = 0x8BE0
|
||||
|
||||
// Device I/O control code for setting QMI service
|
||||
#define QMI_GET_SERVICE_FILE_IOCTL 0x8BE0 + 1
|
||||
|
||||
// Device I/O control code for obtaining device VIDPID
|
||||
#define QMI_GET_VIDPID_IOCTL 0x8BE0 + 2
|
||||
|
||||
// Device I/O control code for obtaining device MEID
|
||||
#define QMI_GET_MEID_IOCTL 0x8BE0 + 3
|
||||
|
|
@ -0,0 +1,419 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
SyncQueue.h
|
||||
|
||||
DESCRIPTION:
|
||||
Declaration/Implementation of cSyncQueue class
|
||||
|
||||
PUBLIC CLASSES AND METHODS:
|
||||
cSyncQueue
|
||||
Synchronized shareable (across multiple threads) queue of
|
||||
structures with event notifications
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
===========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include <deque>
|
||||
#include "Event.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
/*=========================================================================*/
|
||||
// Class cSyncQueue
|
||||
/*=========================================================================*/
|
||||
template <class tElementType> class cSyncQueue
|
||||
{
|
||||
public:
|
||||
// (Inline) Constructor
|
||||
cSyncQueue(
|
||||
ULONG maxElements,
|
||||
bool bSignalEvent = false )
|
||||
: mSignature( (ULONG)eSYNC_QUEUE_SIG ),
|
||||
mSignalEvent(),
|
||||
mbSignalEvent( bSignalEvent ),
|
||||
mMaxElements( maxElements ),
|
||||
mTotalElements( 0 )
|
||||
{
|
||||
// Create sync CS
|
||||
int nRet = pthread_mutex_init( &mSyncSection, NULL );
|
||||
if (nRet != 0)
|
||||
{
|
||||
TRACE( "SyncQueue: Unable to init sync mutex. Error %d: %s\n",
|
||||
nRet,
|
||||
strerror( nRet ) );
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
// (Inline) Destructor
|
||||
~cSyncQueue()
|
||||
{
|
||||
if (IsValid() == false)
|
||||
{
|
||||
ASSERT( (PVOID)"Double deletion detected in ~cSyncQueue" == 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
EmptyQueue();
|
||||
|
||||
mSignature = 0;
|
||||
int nRet = pthread_mutex_destroy( &mSyncSection );
|
||||
if (nRet != 0)
|
||||
{
|
||||
TRACE( "SyncQueue: Unable to destroy sync mutex."
|
||||
" Error %d: %s\n",
|
||||
nRet,
|
||||
strerror( nRet ) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// (Inline) Add an element to the queue
|
||||
bool AddElement( const tElementType & elem )
|
||||
{
|
||||
// Assume failure
|
||||
bool bRC = false;
|
||||
if (IsValid() == false)
|
||||
{
|
||||
ASSERT( (PVOID)"Bad cSyncQueue object detected" == 0 );
|
||||
return bRC;
|
||||
}
|
||||
|
||||
int nRet = pthread_mutex_lock( &mSyncSection );
|
||||
if (nRet != 0)
|
||||
{
|
||||
TRACE( "SyncQueue: Unable to lock sync mutex. Error %d: %s\n",
|
||||
nRet,
|
||||
strerror( nRet ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
// Are we out of space?
|
||||
if ((ULONG)mElementDeque.size() >= mMaxElements)
|
||||
{
|
||||
// Yes, drop oldest element
|
||||
mElementDeque.pop_front();
|
||||
}
|
||||
|
||||
// Add new item to the queue
|
||||
mElementDeque.push_back( elem );
|
||||
mTotalElements++;
|
||||
|
||||
// Set event?
|
||||
if (mbSignalEvent == true)
|
||||
{
|
||||
// Signal index of event
|
||||
nRet = mSignalEvent.Set( mTotalElements - 1 );
|
||||
if (nRet != 0)
|
||||
{
|
||||
TRACE( "SyncQueue: Unable to signal. Error %d: %s\n",
|
||||
nRet,
|
||||
strerror( nRet ) );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Success!
|
||||
bRC = true;
|
||||
|
||||
nRet = pthread_mutex_unlock( &mSyncSection );
|
||||
if (nRet != 0)
|
||||
{
|
||||
TRACE( "SyncQueue: Unable to unlock sync mutex. Error %d: %s\n",
|
||||
nRet,
|
||||
strerror( nRet ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
return bRC;
|
||||
};
|
||||
|
||||
// (Inline) Add an element to the queue returning the index of
|
||||
// the element
|
||||
bool AddElement(
|
||||
const tElementType & elem,
|
||||
ULONG & idx )
|
||||
{
|
||||
// Assume failure
|
||||
bool bRC = false;
|
||||
if (IsValid() == false)
|
||||
{
|
||||
ASSERT( (PVOID)"Bad cSyncQueue object detected" == 0 );
|
||||
return bRC;
|
||||
}
|
||||
|
||||
int nRet = pthread_mutex_lock( &mSyncSection );
|
||||
if (nRet != 0)
|
||||
{
|
||||
TRACE( "SyncQueue: Unable to lock sync mutex. Error %d: %s\n",
|
||||
nRet,
|
||||
strerror( nRet ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
// Are we out of space?
|
||||
if ((ULONG)mElementDeque.size() >= mMaxElements)
|
||||
{
|
||||
mElementDeque.pop_front();
|
||||
}
|
||||
|
||||
// Add new item to the queue
|
||||
mElementDeque.push_back( elem );
|
||||
idx = mTotalElements++;
|
||||
|
||||
// Set event?
|
||||
if (mbSignalEvent == true)
|
||||
{
|
||||
// Signal index of event
|
||||
nRet = mSignalEvent.Set( mTotalElements - 1 );
|
||||
if (nRet != 0)
|
||||
{
|
||||
TRACE( "SyncQueue: Unable to signal. Error %d: %s\n",
|
||||
nRet,
|
||||
strerror( nRet ) );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Success!
|
||||
bRC = true;
|
||||
|
||||
nRet = pthread_mutex_unlock( &mSyncSection );
|
||||
if (nRet != 0)
|
||||
{
|
||||
TRACE( "SyncQueue: Unable to unlock sync mutex. Error %d: %s\n",
|
||||
nRet,
|
||||
strerror( nRet ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
return bRC;
|
||||
};
|
||||
|
||||
// (Inline) Return given element in the queue
|
||||
bool GetElement(
|
||||
ULONG idx,
|
||||
tElementType & elem ) const
|
||||
{
|
||||
// Assume failure
|
||||
bool bRC = false;
|
||||
if (IsValid() == false)
|
||||
{
|
||||
ASSERT( (PVOID)"Bad cSyncQueue object detected" == 0 );
|
||||
return bRC;
|
||||
}
|
||||
|
||||
int nRet = pthread_mutex_lock( &mSyncSection );
|
||||
if (nRet != 0)
|
||||
{
|
||||
TRACE( "SyncQueue: Unable to lock sync mutex. Error %d: %s\n",
|
||||
nRet,
|
||||
strerror( nRet ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
// Is this a current element index?
|
||||
ULONG expiredIndices = mTotalElements - (ULONG)mElementDeque.size();
|
||||
if (idx >= expiredIndices)
|
||||
{
|
||||
// Yes, grab it from the deque
|
||||
idx -= expiredIndices;
|
||||
if (idx < (ULONG)mElementDeque.size())
|
||||
{
|
||||
elem = mElementDeque[idx];
|
||||
bRC = true;
|
||||
}
|
||||
}
|
||||
|
||||
nRet = pthread_mutex_unlock( &mSyncSection );
|
||||
if (nRet != 0)
|
||||
{
|
||||
TRACE( "SyncQueue: Unable to unlock sync mutex. Error %d: %s\n",
|
||||
nRet,
|
||||
strerror( nRet ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
return bRC;
|
||||
};
|
||||
|
||||
// (Inline) Empty element queue
|
||||
bool EmptyQueue()
|
||||
{
|
||||
// Assume failure
|
||||
bool bRC = false;
|
||||
if (IsValid() == false)
|
||||
{
|
||||
ASSERT( (PVOID)"Bad cSyncQueue object detected" == 0 );
|
||||
return bRC;
|
||||
}
|
||||
|
||||
int nRet = pthread_mutex_lock( &mSyncSection );
|
||||
if (nRet != 0)
|
||||
{
|
||||
TRACE( "SyncQueue: Unable to lock sync mutex. Error %d: %s\n",
|
||||
nRet,
|
||||
strerror( nRet ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
mElementDeque.clear();
|
||||
mTotalElements = 0;
|
||||
|
||||
nRet = pthread_mutex_unlock( &mSyncSection );
|
||||
if (nRet != 0)
|
||||
{
|
||||
TRACE( "SyncQueue: Unable to unlock sync mutex. Error %d: %s\n",
|
||||
nRet,
|
||||
strerror( nRet ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
bRC = true;
|
||||
return bRC;
|
||||
};
|
||||
|
||||
// (Inline) Return the number of queued elements
|
||||
ULONG GetQueueCount() const
|
||||
{
|
||||
ULONG elems = 0;
|
||||
if (IsValid() == false)
|
||||
{
|
||||
ASSERT( (PVOID)"Bad cSyncQueue object detected" == 0 );
|
||||
return elems;
|
||||
}
|
||||
|
||||
int nRet = pthread_mutex_lock( &mSyncSection );
|
||||
if (nRet != 0)
|
||||
{
|
||||
TRACE( "SyncQueue: Unable to lock sync mutex. Error %d: %s\n",
|
||||
nRet,
|
||||
strerror( nRet ) );
|
||||
return 0;
|
||||
}
|
||||
|
||||
elems = (ULONG)mElementDeque.size();
|
||||
|
||||
nRet = pthread_mutex_unlock( &mSyncSection );
|
||||
if (nRet != 0)
|
||||
{
|
||||
TRACE( "SyncQueue: Unable to unlock sync mutex. Error %d: %s\n",
|
||||
nRet,
|
||||
strerror( nRet ) );
|
||||
return 0;
|
||||
}
|
||||
|
||||
return elems;
|
||||
};
|
||||
|
||||
// (Inline) Return the total number of elements added to queue
|
||||
ULONG GetTotalCount() const
|
||||
{
|
||||
ULONG elems = 0;
|
||||
if (IsValid() == false)
|
||||
{
|
||||
ASSERT( (PVOID)"Bad cSyncQueue object detected" == 0 );
|
||||
return elems;
|
||||
}
|
||||
|
||||
int nRet = pthread_mutex_lock( &mSyncSection );
|
||||
if (nRet != 0)
|
||||
{
|
||||
TRACE( "SyncQueue: Unable to lock sync mutex. Error %d: %s\n",
|
||||
nRet,
|
||||
strerror( nRet ) );
|
||||
return 0;
|
||||
}
|
||||
|
||||
elems = mTotalElements;
|
||||
|
||||
nRet = pthread_mutex_unlock( &mSyncSection );
|
||||
if (nRet != 0)
|
||||
{
|
||||
TRACE( "SyncQueue: Unable to unlock sync mutex. Error %d: %s\n",
|
||||
nRet,
|
||||
strerror( nRet ) );
|
||||
return 0;
|
||||
}
|
||||
|
||||
return elems;
|
||||
};
|
||||
|
||||
// (Inline) Return the signal event
|
||||
cEvent & GetSignalEvent() const
|
||||
{
|
||||
return mSignalEvent;
|
||||
};
|
||||
|
||||
// (Inline) Is this sync queue valid?
|
||||
bool IsValid() const
|
||||
{
|
||||
return (mSignature == (ULONG)eSYNC_QUEUE_SIG);
|
||||
};
|
||||
|
||||
protected:
|
||||
// Object signature
|
||||
enum eClassConstants
|
||||
{
|
||||
eSYNC_QUEUE_SIG = 0x1799A2BC
|
||||
};
|
||||
|
||||
/* Object signature */
|
||||
ULONG mSignature;
|
||||
|
||||
/* Multithreaded mutex type */
|
||||
mutable pthread_mutex_t mSyncSection;
|
||||
|
||||
/* Signal event, set everytime an element is added (if configured) */
|
||||
mutable cEvent mSignalEvent;
|
||||
|
||||
/* Use above signal event? */
|
||||
bool mbSignalEvent;
|
||||
|
||||
/* Maximum number of elements to add to the deque */
|
||||
ULONG mMaxElements;
|
||||
|
||||
/* Total number of elements added to the deque */
|
||||
ULONG mTotalElements;
|
||||
|
||||
/* Element queue */
|
||||
std::deque <tElementType> mElementDeque;
|
||||
};
|
|
@ -0,0 +1,2 @@
|
|||
SUBDIRS=QMI
|
||||
|
|
@ -0,0 +1,964 @@
|
|||
30^"32,1"^"CTL/Set Instance ID Request/Instance"^50900^-1^0
|
||||
30^"34,1"^"CTL/Get Client ID Request/Type"^50905^-1^0
|
||||
30^"35,1"^"CTL/Release Client ID Request/ID"^50906^-1^0
|
||||
30^"38,1"^"CTL/Set Data Format Request/Format"^50907^-1^0
|
||||
30^"38,16"^"CTL/Set Data Format Request/Protocol"^50908^-1^0
|
||||
30^"40,1"^"CTL/Set Event Report Request/Report"^50909^-1^0
|
||||
30^"41,1"^"CTL/Set Power Save Config Request/Descriptor"^50911^-1^0
|
||||
30^"41,17"^"CTL/Set Power Save Config Request/Permitted Set"^50912^-1^0
|
||||
30^"42,1"^"CTL/Set Power Save Mode Request/Mode"^50913^-1^0
|
||||
31^"32,1"^"CTL/Set Instance ID Response/Link"^50901^-1^0
|
||||
31^"32,2"^"CTL/Set Instance ID Response/Result Code"^50000^-1^0
|
||||
31^"33,1"^"CTL/Get Version Info Response/List"^50902^-1^0
|
||||
31^"33,2"^"CTL/Get Version Info Response/Result Code"^50000^-1^0
|
||||
31^"33,16"^"CTL/Get Version Info Response/Addendum"^50904^-1^0
|
||||
31^"34,1"^"CTL/Get Client ID Response/ID"^50906^-1^0
|
||||
31^"34,2"^"CTL/Get Client ID Response/Result Code"^50000^-1^0
|
||||
31^"35,1"^"CTL/Release Client ID Response/ID"^50906^-1^0
|
||||
31^"35,2"^"CTL/Release Client ID Response/Result Code"^50000^-1^0
|
||||
31^"38,2"^"CTL/Set Data Format Response/Result Code"^50000^-1^0
|
||||
31^"38,16"^"CTL/Set Data Format Response/Protocol"^50908^-1^0
|
||||
31^"40,2"^"CTL/Set Event Report Response/Result Code"^50000^-1^0
|
||||
31^"41,2"^"CTL/Set Power Save Config Response/Result Code"^50000^-1^0
|
||||
31^"42,2"^"CTL/Set Power Save Mode Response/Result Code"^50000^-1^0
|
||||
31^"43,1"^"CTL/Get Power Save Mode Response/Mode"^50913^-1^0
|
||||
31^"43,2"^"CTL/Get Power Save Mode Response/Result Code"^50000^-1^0
|
||||
32^"36,1"^"CTL/Release Client ID Indication/ID"^50906^-1^0
|
||||
32^"37,1"^"CTL/Invalid Client ID Indication/ID"^50906^-1^0
|
||||
32^"40,1"^"CTL/Event Report Indication/Report"^50910^-1^0
|
||||
33^"1,16"^"WDS/Set Event Report Request/Channel Rate Indicator"^50010^-1
|
||||
33^"1,17"^"WDS/Set Event Report Request/Transfer Statistics Indicator"^50011^-1
|
||||
33^"1,18"^"WDS/Set Event Report Request/Data Bearer Technology Indicator"^50012^-1
|
||||
33^"1,19"^"WDS/Set Event Report Request/Dormancy Status Indicator"^50041^-1
|
||||
33^"1,20"^"WDS/Set Event Report Request/MIP Status Indicator"^50087^-1
|
||||
33^"1,21"^"WDS/Set Event Report Request/Current Data Bearer Technology Indicator"^50012^-1
|
||||
33^"2,1"^"WDS/Abort Request/Transaction ID"^50001^-1
|
||||
33^"32,16"^"WDS/Start Network Interface Request/Primary DNS"^50021^-1
|
||||
33^"32,17"^"WDS/Start Network Interface Request/Secondary DNS"^50021^-1
|
||||
33^"32,18"^"WDS/Start Network Interface Request/Primary NBNS"^50021^-1
|
||||
33^"32,19"^"WDS/Start Network Interface Request/Secondary NBNS"^50021^-1
|
||||
33^"32,20"^"WDS/Start Network Interface Request/Context APN Name"^50022^-1
|
||||
33^"32,21"^"WDS/Start Network Interface Request/IP Address"^50021^-1
|
||||
33^"32,22"^"WDS/Start Network Interface Request/Authentication"^50023^-1
|
||||
33^"32,23"^"WDS/Start Network Interface Request/Username"^50024^-1
|
||||
33^"32,24"^"WDS/Start Network Interface Request/Password"^50025^-1
|
||||
33^"32,25"^"WDS/Start Network Interface Request/IP Family"^50097^-1
|
||||
33^"32,48"^"WDS/Start Network Interface Request/Technology Preference"^50026^-1
|
||||
33^"32,49"^"WDS/Start Network Interface Request/3GPP Profile Identifier"^50027^-1
|
||||
33^"32,50"^"WDS/Start Network Interface Request/3GPP2 Profile Identifier"^50027^-1
|
||||
33^"32,51"^"WDS/Start Network Interface Request/Autoconnect"^50045^-1
|
||||
33^"32,52"^"WDS/Start Network Interface Request/Extended Technology Preference"^50095^-1
|
||||
33^"32,53"^"WDS/Start Network Interface Request/Call Type"^50096^-1
|
||||
33^"33,1"^"WDS/Stop Network Interface Request/Packet Data Handle"^50028^-1
|
||||
33^"33,16"^"WDS/Stop Network Interface Request/Autoconnect"^50046^-1
|
||||
33^"36,1"^"WDS/Get Packet Statistics Request/Packet Stats Mask"^50032^-1
|
||||
33^"39,1"^"WDS/Create Profile Request/Profile Type"^50033^-1
|
||||
33^"39,16"^"WDS/Create Profile Request/Profile Name"^50034^-1
|
||||
33^"39,17"^"WDS/Create Profile Request/PDP Type"^50035^-1
|
||||
33^"39,20"^"WDS/Create Profile Request/APN Name"^50022^-1
|
||||
33^"39,21"^"WDS/Create Profile Request/Primary DNS"^50021^-1
|
||||
33^"39,22"^"WDS/Create Profile Request/Secondary DNS"^50021^-1
|
||||
33^"39,23"^"WDS/Create Profile Request/UMTS Requested QoS"^50036^-1
|
||||
33^"39,24"^"WDS/Create Profile Request/UMTS Minimum QoS"^50036^-1
|
||||
33^"39,25"^"WDS/Create Profile Request/GPRS Requested QoS"^50037^-1
|
||||
33^"39,26"^"WDS/Create Profile Request/GPRS Minimum QoS"^50037^-1
|
||||
33^"39,27"^"WDS/Create Profile Request/Username"^50024^-1
|
||||
33^"39,28"^"WDS/Create Profile Request/Password"^50025^-1
|
||||
33^"39,29"^"WDS/Create Profile Request/Authentication"^50023^-1
|
||||
33^"39,30"^"WDS/Create Profile Request/IP Address"^50021^-1
|
||||
33^"39,31"^"WDS/Create Profile Request/P-CSCF"^50099^-1
|
||||
33^"40,1"^"WDS/Modify Profile Request/Profile Identifier"^50038^-1
|
||||
33^"40,16"^"WDS/Modify Profile Request/Profile Name"^50034^-1
|
||||
33^"40,17"^"WDS/Modify Profile Request/PDP Type"^50035^-1
|
||||
33^"40,20"^"WDS/Modify Profile Request/APN Name"^50022^-1
|
||||
33^"40,21"^"WDS/Modify Profile Request/Primary DNS"^50021^-1
|
||||
33^"40,22"^"WDS/Modify Profile Request/Secondary DNS"^50021^-1
|
||||
33^"40,23"^"WDS/Modify Profile Request/UMTS Requested QoS"^50036^-1
|
||||
33^"40,24"^"WDS/Modify Profile Request/UMTS Minimum QoS"^50036^-1
|
||||
33^"40,25"^"WDS/Modify Profile Request/GPRS Requested QoS"^50037^-1
|
||||
33^"40,26"^"WDS/Modify Profile Request/GPRS Minimum QoS"^50037^-1
|
||||
33^"40,27"^"WDS/Modify Profile Request/Username"^50024^-1
|
||||
33^"40,28"^"WDS/Modify Profile Request/Password"^50025^-1
|
||||
33^"40,29"^"WDS/Modify Profile Request/Authentication"^50023^-1
|
||||
33^"40,30"^"WDS/Modify Profile Request/IP Address"^50021^-1
|
||||
33^"40,31"^"WDS/Modify Profile Request/P-CSCF"^50099^-1
|
||||
33^"40,32"^"WDS/Modify Profile Request/PDP Access Control Flag"^60086^-1
|
||||
33^"40,33"^"WDS/Modify Profile Request/P-CSCF Address Using DHCP"^60087^-1
|
||||
33^"40,34"^"WDS/Modify Profile Request/IM CN Flag"^60088^-1
|
||||
33^"40,35"^"WDS/Modify Profile Request/Traffic Flow Template ID1 Parameters"^60018^-1
|
||||
33^"40,36"^"WDS/Modify Profile Request/Traffic Flow Template ID2 Parameters"^60018^-1
|
||||
33^"40,37"^"WDS/Modify Profile Request/PDP Context Number"^60020^-1
|
||||
33^"40,38"^"WDS/Modify Profile Request/PDP Context Secondary Flag"^60021^-1
|
||||
33^"40,39"^"WDS/Modify Profile Request/PDP Context Primary ID"^60022^-1
|
||||
33^"40,40"^"WDS/Modify Profile Request/IPv6 Address"^60023^-1
|
||||
33^"40,41"^"WDS/Modify Profile Request/Requested QoS"^60024^-1
|
||||
33^"40,42"^"WDS/Modify Profile Request/Minimum QoS"^60024^-1
|
||||
33^"40,43"^"WDS/Modify Profile Request/Primary IPv6"^60090^-1
|
||||
33^"40,44"^"WDS/Modify Profile Request/Secondary IPv6"^60090^-1
|
||||
33^"40,45"^"WDS/Modify Profile Request/Address Allocation Preference"^60028^-1
|
||||
33^"40,46"^"WDS/Modify Profile Request/LTE QoS Parameters"^60029^-1
|
||||
33^"40,144"^"WDS/Modify Profile Request/Negotiate DNS Server Prefrence"^60059^-1
|
||||
33^"40,145"^"WDS/Modify Profile Request/PPP Session Close Timer DO"^60060^-1
|
||||
33^"40,146"^"WDS/Modify Profile Request/PPP Session Close Timer 1X"^60061^-1
|
||||
33^"40,147"^"WDS/Modify Profile Request/Allow Linger"^60062^-1
|
||||
33^"40,148"^"WDS/Modify Profile Request/LCP ACK Timeout"^60063^-1
|
||||
33^"40,149"^"WDS/Modify Profile Request/IPCP ACK Timeout"^60064^-1
|
||||
33^"40,150"^"WDS/Modify Profile Request/Authentication Timeout"^60065^-1
|
||||
33^"40,154"^"WDS/Modify Profile Request/Authentication Protocol"^60069^-1
|
||||
33^"40,155"^"WDS/Modify Profile Request/User ID"^60070^-1
|
||||
33^"40,156"^"WDS/Modify Profile Request/Authentication Password"^60071^-1
|
||||
33^"40,157"^"WDS/Modify Profile Request/Data Rate"^60072^-1
|
||||
33^"40,158"^"WDS/Modify Profile Request/Application Type"^60073^-1
|
||||
33^"40,159"^"WDS/Modify Profile Request/Data Mode"^60074^-1
|
||||
33^"40,160"^"WDS/Modify Profile Request/Application Priority"^60075^-1
|
||||
33^"40,161"^"WDS/Modify Profile Request/APN String"^60076^-1
|
||||
33^"40,162"^"WDS/Modify Profile Request/PDN Type"^60077^-1
|
||||
33^"40,163"^"WDS/Modify Profile Request/P-CSCF Address Needed"^60078^-1
|
||||
33^"40,164"^"WDS/Modify Profile Request/Primary IPv4 Address"^60079^-1
|
||||
33^"40,165"^"WDS/Modify Profile Request/Secondary IPv4 Address"^60080^-1
|
||||
33^"40,166"^"WDS/Modify Profile Request/Primary IPv6 Address"^60081^-1
|
||||
33^"40,167"^"WDS/Modify Profile Request/Secondary IPv6 Address"^60082^-1
|
||||
33^"41,1"^"WDS/Delete Profile Request/Profile Identifier"^50038^-1
|
||||
33^"43,1"^"WDS/Get Profile Settings Request/Profile Identifier"^50038^-1
|
||||
33^"44,1"^"WDS/Get Default Settings Request/Profile Type"^50033^-1
|
||||
33^"45,16"^"WDS/Get Current Settings Request/Requested Settings"^50084^-1
|
||||
33^"46,1"^"WDS/Set MIP Mode Request/Mobile IP Mode"^50044^-1
|
||||
33^"56,1"^"WDS/Get Modem Info Request/Requested Status"^50051^-1
|
||||
33^"56,16"^"WDS/Get Modem Info Request/Connection Status Indicator"^50052^-1
|
||||
33^"56,17"^"WDS/Get Modem Info Request/Transfer Statistics Indicator"^50053^-1
|
||||
33^"56,18"^"WDS/Get Modem Info Request/Dormancy Status Indicator"^50041^-1
|
||||
33^"56,19"^"WDS/Get Modem Info Request/Data Bearer Technology Indicator"^50012^-1
|
||||
33^"56,20"^"WDS/Get Modem Info Request/Channel Rate Indicator"^50010^-1
|
||||
33^"61,1"^"WDS/Set Active MIP Profile Request/Index"^50056^-1
|
||||
33^"62,1"^"WDS/Get MIP Profile Request/Index"^50027^-1
|
||||
33^"63,1"^"WDS/Set MIP Profile Request/Index"^50056^-1
|
||||
33^"63,16"^"WDS/Set MIP Profile Request/State"^50057^-1
|
||||
33^"63,17"^"WDS/Set MIP Profile Request/Home Address"^50021^-1
|
||||
33^"63,18"^"WDS/Set MIP Profile Request/Primary Home Agent Address"^50021^-1
|
||||
33^"63,19"^"WDS/Set MIP Profile Request/Secondary Home Agent Address"^50021^-1
|
||||
33^"63,20"^"WDS/Set MIP Profile Request/Reverse Tunneling"^50058^-1
|
||||
33^"63,21"^"WDS/Set MIP Profile Request/NAI"^50059^-1
|
||||
33^"63,22"^"WDS/Set MIP Profile Request/HA SPI"^50060^-1
|
||||
33^"63,23"^"WDS/Set MIP Profile Requeste/AAA SPI"^50061^-1
|
||||
33^"63,24"^"WDS/Set MIP Profile Request/MN-HA"^50062^-1
|
||||
33^"63,25"^"WDS/Set MIP Profile Request/MN-AAA"^50063^-1
|
||||
33^"65,1"^"WDS/Set MIP Parameters Request/SPC"^50070^-1
|
||||
33^"65,16"^"WDS/Set MIP Parameters Request/Mobile IP Mode"^50044^-1
|
||||
33^"65,17"^"WDS/Set MIP Parameters Request/Retry Attempt Limit"^50064^-1
|
||||
33^"65,18"^"WDS/Set MIP Parameters Request/Retry Attempt Interval"^50065^-1
|
||||
33^"65,19"^"WDS/Set MIP Parameters Request/Re-Registration Period"^50066^-1
|
||||
33^"65,20"^"WDS/Set MIP Parameters Request/Re-Registration Only With Traffic"^50067^-1
|
||||
33^"65,21"^"WDS/Set MIP Parameters Request/MN-HA Authenticator Calculator"^50068^-1
|
||||
33^"65,22"^"WDS/Set MIP Parameters Request/MN-HA RFC 2002 BIS Authentication"^50069^-1
|
||||
33^"69,16"^"WDS/Get Call List Request/List Type"^50073^-1
|
||||
33^"70,1"^"WDS/Get Call Record Request/Record ID"^50077^-1
|
||||
33^"81,1"^"WDS/Set Autoconnect Setting Request/Autoconnect"^50045^-1
|
||||
33^"81,16"^"WDS/Set Autoconnect Setting Request/Roam"^60008^-1
|
||||
33^"83,16"^"WDS/Set DNS Setting Request/Primary"^60009^-1
|
||||
33^"83,17"^"WDS/Set DNS Setting Request/Secondary"^60009^-1
|
||||
33^"83,18"^"WDS/Set DNS Setting Request/Primary IPv6 Address"^60084^-1
|
||||
33^"83,19"^"WDS/Set DNS Setting Request/Secondary IPv6 Address"^60085^-1
|
||||
34^"0,2"^"WDS/Reset Response/Result Code"^50000^-1
|
||||
34^"1,2"^"WDS/Set Event Report Response/Result Code"^50000^-1
|
||||
34^"2,2"^"WDS/Abort Response/Result Code"^50000^-1
|
||||
34^"32,1"^"WDS/Start Network Interface Response/Packet Data Handle"^50028^-1
|
||||
34^"32,2"^"WDS/Start Network Interface Response/Result Code"^50000^-1
|
||||
34^"32,16"^"WDS/Start Network Interface Response/Call End Reason"^50043^-1
|
||||
34^"32,17"^"WDS/Start Network Interface Response/Verbose Call End Reason"^50098^-1
|
||||
34^"33,2"^"WDS/Stop Network Interface Response/Result Code"^50000^-1
|
||||
34^"34,1"^"WDS/Get Packet Service Status Response/Status"^50029^-1
|
||||
34^"34,2"^"WDS/Get Packet Service Status Response/Result Code"^50000^-1
|
||||
34^"35,1"^"WDS/Get Channel Rates Response/Channel Rates"^50031^-1
|
||||
34^"35,2"^"WDS/Get Channel Rates Response/Result Code"^50000^-1
|
||||
34^"36,2"^"WDS/Get Packet Statistics Response/Result Code"^50000^-1
|
||||
34^"36,16"^"WDS/Get Packet Statistics Response/TX Packet Successes"^50013^-1
|
||||
34^"36,17"^"WDS/Get Packet Statistics Response/RX Packet Successes"^50014^-1
|
||||
34^"36,18"^"WDS/Get Packet Statistics Response/TX Packet Errors"^50015^-1
|
||||
34^"36,19"^"WDS/Get Packet Statistics Response/RX Packet Errors"^50016^-1
|
||||
34^"36,20"^"WDS/Get Packet Statistics Response/TX Overflows"^50017^-1
|
||||
34^"36,21"^"WDS/Get Packet Statistics Response/RX Overflows"^50018^-1
|
||||
34^"36,25"^"WDS/Get Packet Statistics Response/TX Bytes"^50054^-1
|
||||
34^"36,26"^"WDS/Get Packet Statistics Response/RX Bytes"^50055^-1
|
||||
34^"36,27"^"WDS/Get Packet Statistics Response/Previous TX Bytes"^50079^-1
|
||||
34^"36,28"^"WDS/Get Packet Statistics Response/Previous RX Bytes"^50080^-1
|
||||
34^"37,2"^"WDS/Go Dormant Response/Result Code"^50000^-1
|
||||
34^"38,2"^"WDS/Go Active Response/Result Code"^50000^-1
|
||||
34^"39,1"^"WDS/Create Profile Response/Profile Identifier"^50038^-1
|
||||
34^"39,2"^"WDS/Create Profile Response/Result Code"^50000^-1
|
||||
34^"40,2"^"WDS/Modify Profile Response/Result Code"^50000^-1
|
||||
34^"40,151"^"WDS/Modify Profile Request/LCP Config Retry Count"^60066^-1
|
||||
34^"40,152"^"WDS/Modify Profile Request/IPCP Config Retry Count"^60067^-1
|
||||
34^"40,153"^"WDS/Modify Profile Request/Authentication Retry"^60068^-1
|
||||
34^"40,224"^"WDS/Modify Profile Request/Extended Error Code"^60083^-1
|
||||
34^"41,2"^"WDS/Delete Profile Response/Result Code"^50000^-1
|
||||
34^"42,1"^"WDS/Get Profile List Response/Profile List"^50039^-1
|
||||
34^"42,2"^"WDS/Get Profile List Response/Result Code"^50000^-1
|
||||
34^"43,2"^"WDS/Get Profile Settings Response/Result Code"^50000^-1
|
||||
34^"43,16"^"WDS/Get Profile Settings Response/Profile Name"^50034^-1
|
||||
34^"43,17"^"WDS/Get Profile Settings Response/PDP Type"^50035^-1
|
||||
34^"43,20"^"WDS/Get Profile Settings Response/APN Name"^50022^-1
|
||||
34^"43,21"^"WDS/Get Profile Settings Response/Primary DNS"^50021^-1
|
||||
34^"43,22"^"WDS/Get Profile Settings Response/Secondary DNS"^50021^-1
|
||||
34^"43,23"^"WDS/Get Profile Settings Response/UMTS Requested QoS"^50036^-1
|
||||
34^"43,24"^"WDS/Get Profile Settings Response/UMTS Minimum QoS"^50036^-1
|
||||
34^"43,25"^"WDS/Get Profile Settings Response/GPRS Requested QoS"^50037^-1
|
||||
34^"43,26"^"WDS/Get Profile Settings Response/GPRS Minimum QoS"^50037^-1
|
||||
34^"43,27"^"WDS/Get Profile Settings Response/Username"^50024^-1
|
||||
34^"43,29"^"WDS/Get Profile Settings Response/Authentication"^50023^-1
|
||||
34^"43,30"^"WDS/Get Profile Settings Response/IP Address"^50021^-1
|
||||
34^"43,31"^"WDS/Get Profile Settings Response/P-CSCF"^50099^-1
|
||||
34^"44,2"^"WDS/Get Default Settings Response/Result Code"^50000^-1
|
||||
34^"44,16"^"WDS/Get Default Settings Response/Profile Name"^50034^-1
|
||||
34^"44,17"^"WDS/Get Default Settings Response/PDP Type"^50035^-1
|
||||
34^"44,20"^"WDS/Get Default Settings Response/APN Name"^50022^-1
|
||||
34^"44,21"^"WDS/Get Default Settings Response/Primary DNS"^50021^-1
|
||||
34^"44,22"^"WDS/Get Default Settings Response/Secondary DNS"^50021^-1
|
||||
34^"44,23"^"WDS/Get Default Settings Response/UMTS Requested QoS"^50036^-1
|
||||
34^"44,24"^"WDS/Get Default Settings Response/UMTS Minimum QoS"^50036^-1
|
||||
34^"44,25"^"WDS/Get Default Settings Response/GPRS Requested QoS"^50037^-1
|
||||
34^"44,26"^"WDS/Get Default Settings Response/GPRS Minimum QoS"^50037^-1
|
||||
34^"44,27"^"WDS/Get Default Settings Response/Username"^50024^-1
|
||||
34^"44,28"^"WDS/Get Default Settings Response/Password"^50025^-1
|
||||
34^"44,29"^"WDS/Get Default Settings Response/Authentication"^50023^-1
|
||||
34^"44,30"^"WDS/Get Default Settings Response/IP Address"^50021^-1
|
||||
34^"44,31"^"WDS/Get Default Settings Response/P-CSCF"^50099^-1
|
||||
34^"44,32"^"WDS/Get Default Settings Response/PDP Access Control Flag"^60015^-1
|
||||
34^"44,33"^"WDS/Get Default Settings Response/P-CSCF Address Using DHCP"^60016^-1
|
||||
34^"44,34"^"WDS/Get Default Settings Response/IM CN Flag"^60017^-1
|
||||
34^"44,35"^"WDS/Get Default Settings Response/Traffic Flow Template ID1 Parameters"^60018^-1
|
||||
34^"44,36"^"WDS/Get Default Settings Response/Traffic Flow Template ID2 Parameters"^60019^-1
|
||||
34^"44,37"^"WDS/Get Default Settings Response/PDP Context Number"^60020^-1
|
||||
34^"44,38"^"WDS/Get Default Settings Response/PDP Context Secondary Flag"^60021^-1
|
||||
34^"44,39"^"WDS/Get Default Settings Response/PDP Context Primary ID"^60022^-1
|
||||
34^"44,40"^"WDS/Get Default Settings Response/IPv6 Address"^60023^-1
|
||||
34^"44,41"^"WDS/Get Default Settings Response/Requested QoS"^60024^-1
|
||||
34^"44,42"^"WDS/Get Default Settings Response/Minimum QoS"^60025^-1
|
||||
34^"44,43"^"WDS/Get Default Settings Response/Primary DNS IPv6 Address"^60026^-1
|
||||
34^"44,44"^"WDS/Get Default Settings Response/Secondary DNS IPv6 Address"^60027^-1
|
||||
34^"44,45"^"WDS/Get Default Settings Response/DHCP NAS Preference"^60028^-1
|
||||
34^"44,46"^"WDS/Get Default Settings Response/LTE QoS Parameters"^60029^-1
|
||||
34^"44,144"^"WDS/Get Default Settings Response/Negotiate DSN Server Preferences"^60030^-1
|
||||
34^"44,145"^"WDS/Get Default Settings Response/PPP Session CLose Timer DO"^60031^-1
|
||||
34^"44,146"^"WDS/Get Default Settings Response/PPP Session Close Timer 1X"^60032^-1
|
||||
34^"44,147"^"WDS/Get Default Settings Response/Allow Lingering Interface"^60033^-1
|
||||
34^"44,148"^"WDS/Get Default Settings Response/LCP ACK Timeout"^60034^-1
|
||||
34^"44,149"^"WDS/Get Default Settings Response/IPCP ACK Timeout"^60035^-1
|
||||
34^"44,150"^"WDS/Get Default Settings Response/Authentication Timeout"^60036^-1
|
||||
34^"44,151"^"WDS/Get Default Settings Response/LCP Config Retry Count"^60037^-1
|
||||
34^"44,152"^"WDS/Get Default Settings Response/IPCP Config Retry Count"^60038^-1
|
||||
34^"44,153"^"WDS/Get Default Settings Response/Authentication Retry"^60039^-1
|
||||
34^"44,154"^"WDS/Get Default Settings Response/Authentication Protocol"^60040^-1
|
||||
34^"44,155"^"WDS/Get Default Settings Response/User ID"^60041^-1^0^-1^0^0
|
||||
34^"44,156"^"WDS/Get Default Settings Response/Authentication Password"^60042^-1
|
||||
34^"44,157"^"WDS/Get Default Settings Response/Data Rate"^60043^-1
|
||||
34^"44,158"^"WDS/Get Default Settings Response/Application Type"^60044^-1
|
||||
34^"44,159"^"WDS/Get Default Settings Response/Data Mode"^60045^-1
|
||||
34^"44,160"^"WDS/Get Default Settings Response/Application Priority"^60046^-1
|
||||
34^"44,161"^"WDS/Get Default Settings Response/APN String"^60047^-1
|
||||
34^"44,162"^"WDS/Get Default Settings Response/PDN Type"^60048^-1
|
||||
34^"44,163"^"WDS/Get Default Settings Response/P-CSCF Address Needed"^60049^-1
|
||||
34^"44,164"^"WDS/Get Default Settings Response/Primary DNS Address"^60050^-1
|
||||
34^"44,165"^"WDS/Get Default Settings Response/Secondary DNS Address"^60051^-1
|
||||
34^"44,166"^"WDS/Get Default Settings Response/Primary IPv6 Address"^60052^-1
|
||||
34^"44,167"^"WDS/Get Default Settings Response/Secondary IPv6 Address"^60053^-1
|
||||
34^"44,224"^"WDS/Get Default Settings Response/Extended Error Code"^60054^-1
|
||||
34^"45,2"^"WDS/Get Current Settings Response/Result Code"^50000^-1
|
||||
34^"45,16"^"WDS/Get Current Settings Response/Profile Name"^50034^-1
|
||||
34^"45,17"^"WDS/Get Current Settings Response/PDP Type"^50035^-1
|
||||
34^"45,20"^"WDS/Get Current Settings Response/APN Name"^50022^-1
|
||||
34^"45,21"^"WDS/Get Current Settings Response/Primary DNS"^50021^-1
|
||||
34^"45,22"^"WDS/Get Current Settings Response/Secondary DNS"^50021^-1
|
||||
34^"45,23"^"WDS/Get Current Settings Response/UMTS Granted QoS"^50036^-1
|
||||
34^"45,25"^"WDS/Get Current Settings Response/GPRS Granted QoS"^50037^-1
|
||||
34^"45,27"^"WDS/Get Current Settings Response/Username"^50024^-1
|
||||
34^"45,29"^"WDS/Get Current Settings Response/Authentication"^50023^-1
|
||||
34^"45,30"^"WDS/Get Current Settings Response/IP Address"^50021^-1
|
||||
34^"45,31"^"WDS/Get Current Settings Response/Profile ID"^50038^-1
|
||||
34^"45,32"^"WDS/Get Current Settings Response/Gateway Address"^50021^-1
|
||||
34^"45,33"^"WDS/Get Current Settings Response/Gateway Subnet Mask"^50085^-1
|
||||
34^"45,34"^"WDS/Get Current Settings Response/P-CSCF"^50099^-1
|
||||
34^"45,35"^"WDS/Get Current Settings Response/P-CSCF Server Address List"^60000^-1
|
||||
34^"45,36"^"WDS/Get Current Settings Response/P-CSCF Domain Name List"^60001^-1
|
||||
34^"45,37"^"WDS/Get Current Settings Response/IPv6 Address"^60010^-1
|
||||
34^"45,38"^"WDS/Get Current Settings Response/IPv6 Gateway Address"^60011^-1
|
||||
34^"45,39"^"WDS/Get Current Settings Response/Primary IPv6 DNS"^60003^-1
|
||||
34^"45,40"^"WDS/Get Current Settings Response/Secondary IPv6 DNS"^60003^-1
|
||||
34^"45,41"^"WDS/Get Current Settings Response/MTU"^60004^-1
|
||||
34^"45,42"^"WDS/Get Current Settings Response/Domain Name List"^60005^-1
|
||||
34^"45,43"^"WDS/Get Current Settings Response/IP Family"^50097^-1
|
||||
34^"45,44"^"WDS/Get Current Settings Response/IM CN Flag"^60007^-1
|
||||
34^"45,45"^"WDS/Get Current Settings Response/Extended Technology"^50095^-1
|
||||
34^"45,46"^"WDS/Get Current Settings Response/P-CSCF IPv6 Address List"^60057^-1
|
||||
34^"46,2"^"WDS/Set MIP Mode Response/Result Code"^50000^-1
|
||||
34^"47,1"^"WDS/Get MIP Mode Response/Mobile IP Mode"^50044^-1
|
||||
34^"47,2"^"WDS/Get MIP Mode Response/Result Code"^50000^-1
|
||||
34^"48,1"^"WDS/Get Dormancy Response/Dormancy Status"^50042^-1
|
||||
34^"48,2"^"WDS/Get Dormancy Response/Result Code"^50000^-1
|
||||
34^"52,1"^"WDS/Get Autoconnect Setting Response/Autoconnect"^50045^-1
|
||||
34^"52,2"^"WDS/Get Autoconnect Setting Response/Result Code"^50000^-1
|
||||
34^"52,16"^"WDS/Get Autoconnect Setting Response/Roam"^60008^-1
|
||||
34^"53,1"^"WDS/Get Data Session Duration Response/Duration"^50047^-1
|
||||
34^"53,2"^"WDS/Get Data Session Duration Response/Result Code"^50000^-1
|
||||
34^"53,16"^"WDS/Get Data Session Duration Response/Previous Duration"^50081^-1
|
||||
34^"53,17"^"WDS/Get Data Session Duration Response/Active Duration"^50082^-1
|
||||
34^"53,18"^"WDS/Get Data Session Duration Response/Previous Active Duration"^50083^-1
|
||||
34^"54,1"^"WDS/Get Modem Status Response/Status"^50048^-1
|
||||
34^"54,2"^"WDS/Get Modem Status Response/Result Code"^50000^-1
|
||||
34^"54,16"^"WDS/Get Modem Status Response/Call End Reason"^50049^-1
|
||||
34^"55,1"^"WDS/Get Data Bearer Technology Response/Technology"^50020^-1
|
||||
34^"55,2"^"WDS/Get Data Bearer Technology Response/Result Code"^50000^-1
|
||||
34^"55,16"^"WDS/Get Data Bearer Technology Response/Last Call Technology"^50020^-1
|
||||
34^"56,2"^"WDS/Get Modem Info Response/Result Code"^50000^-1
|
||||
34^"56,16"^"WDS/Get Modem Info Response/Status"^50048^-1
|
||||
34^"56,17"^"WDS/Get Modem Info Response/Call End Reason"^50049^-1
|
||||
34^"56,18"^"WDS/Get Modem Info Response/TX Bytes"^50054^-1
|
||||
34^"56,19"^"WDS/Get Modem Info Response/RX Bytes"^50055^-1
|
||||
34^"56,20"^"WDS/Get Modem Info Response/Dormancy Status"^50042^-1
|
||||
34^"56,21"^"WDS/Get Modem Info Response/Technology"^50020^-1
|
||||
34^"56,22"^"WDS/Get Modem Info Response/Rates"^50031^-1
|
||||
34^"56,23"^"WDS/Get Modem Info Response/Previous TX Bytes"^50079^-1
|
||||
34^"56,24"^"WDS/Get Modem Info Response/Previous RX Bytes"^50080^-1
|
||||
34^"56,25"^"WDS/Get Modem Info Duration Response/Active Duration"^50082^-1
|
||||
34^"60,1"^"WDS/Get Active MIP Profile Response/Index"^50027^-1
|
||||
34^"60,2"^"WDS/Get Active MIP Profile Response/Result Code"^50000^-1
|
||||
34^"61,2"^"WDS/Set Active MIP Profile Response/Result Code"^50000^-1
|
||||
34^"62,2"^"WDS/Get MIP Profile Response/Result Code"^50000^-1
|
||||
34^"62,16"^"WDS/Get MIP Profile Response/State"^50057^-1
|
||||
34^"62,17"^"WDS/Get MIP Profile Response/Home Address"^50021^-1
|
||||
34^"62,18"^"WDS/Get MIP Profile Response/Primary Home Agent Address"^50021^-1
|
||||
34^"62,19"^"WDS/Get MIP Profile Response/Secondary Home Agent Address"^50021^-1
|
||||
34^"62,20"^"WDS/Get MIP Profile Response/Reverse Tunneling"^50058^-1
|
||||
34^"62,21"^"WDS/Get MIP Profile Response/NAI"^50059^-1
|
||||
34^"62,22"^"WDS/Get MIP Profile Response/HA SPI"^50060^-1
|
||||
34^"62,23"^"WDS/Get MIP Profile Response/AAA SPI"^50061^-1
|
||||
34^"62,26"^"WDS/Get MIP Profile Response/HA State"^50086^-1
|
||||
34^"62,27"^"WDS/Get MIP Profile Response/AAA State"^50086^-1
|
||||
34^"63,2"^"WDS/Set MIP Profile Response/Result Code"^50000^-1
|
||||
34^"64,2"^"WDS/Get MIP Parameters Response/Result Code"^50000^-1
|
||||
34^"64,16"^"WDS/Get MIP Parameters Response/Mobile IP Mode"^50044^-1
|
||||
34^"64,17"^"WDS/Get MIP Parameters Response/Retry Attempt Limit"^50064^-1
|
||||
34^"64,18"^"WDS/Get MIP Parameters Response/Retry Attempt Interval"^50065^-1
|
||||
34^"64,19"^"WDS/Get MIP Parameters Response/Re-Registration Period"^50066^-1
|
||||
34^"64,20"^"WDS/Get MIP Parameters Response/Re-Registration Only With Traffic"^50067^-1
|
||||
34^"64,21"^"WDS/Get MIP Parameters Response/MN-HA Authenticator Calculator"^50068^-1
|
||||
34^"64,22"^"WDS/Get MIP Parameters Response/MN-HA RFC 2002 BIS Authentication"^50069^-1
|
||||
34^"65,2"^"WDS/Set MIP Parameters Response/Result Code"^50000^-1
|
||||
34^"66,1"^"WDS/Get Last MIP Status Response/Status"^50071^-1
|
||||
34^"66,2"^"WDS/Get Last MIP Status Response/Result Code"^50000^-1
|
||||
34^"67,1"^"WDS/Get AN-AAA Authentication Status Response/Status"^50072^-1
|
||||
34^"67,2"^"WDS/Get AN-AAA Authentication Status Response/Result Code"^50000^-1
|
||||
34^"68,1"^"WDS/Get Current Data Bearer Technology Response/Technology"^50090^-1
|
||||
34^"68,2"^"WDS/Get Current Data Bearer Technology Response/Result Code"^50000^-1
|
||||
34^"69,2"^"WDS/Get Call List Response/Result Code"^50000^-1
|
||||
34^"69,16"^"WDS/Get Call List Response/Full List"^50074^-1
|
||||
34^"69,17"^"WDS/Get Call List Response/ID List"^50076^-1
|
||||
34^"70,1"^"WDS/Get Call Record Response/Record"^50075^-1
|
||||
34^"70,2"^"WDS/Get Call Record Response/Result Code"^50000^-1
|
||||
34^"71,2"^"WDS/Clear Call List Response/Result Code"^50000^-1
|
||||
34^"72,1"^"WDS/Get Call List Max Size Response/Maximum"^50078^-1
|
||||
34^"72,2"^"WDS/Get Call List Max Size Response/Result Code"^50000^-1
|
||||
34^"81,2"^"WDS/Set Autoconnect Setting Response/Result Code"^50000^-1
|
||||
34^"82,2"^"WDS/Get DNS Setting Response/Result Code"^50000^-1
|
||||
34^"82,16"^"WDS/Get DNS Setting Response/Primary"^60009^-1
|
||||
34^"82,17"^"WDS/Get DNS Setting Response/Secondary"^60009^-1
|
||||
34^"82,18"^"WDS/Get DNS Setting Response/Primary IPv6"^60055^-1
|
||||
34^"82,19"^"WDS/Get DNS Setting Response/Secondary IPv6"^60056^-1
|
||||
34^"83,2"^"WDS/Set DNS Setting Response/Result Code"^50000^-1
|
||||
35^"1,16"^"WDS/Event Report/TX Packet Successes"^50013^-1
|
||||
35^"1,17"^"WDS/Event Report/RX Packet Successes"^50014^-1
|
||||
35^"1,18"^"WDS/Event Report/TX Packet Errors"^50015^-1
|
||||
35^"1,19"^"WDS/Event Report/RX Packet Errors"^50016^-1
|
||||
35^"1,20"^"WDS/Event Report/TX Overflows"^50017^-1
|
||||
35^"1,21"^"WDS/Event Report/RX Overflows"^50018^-1
|
||||
35^"1,22"^"WDS/Event Report/Channel Rates"^50019^-1
|
||||
35^"1,23"^"WDS/Event Report/Data Bearer Technology"^50020^-1
|
||||
35^"1,24"^"WDS/Event Report/Dormancy Status"^50042^-1
|
||||
35^"1,25"^"WDS/Event Report/TX Bytes"^50054^-1
|
||||
35^"1,26"^"WDS/Event Report/RX Bytes"^50055^-1
|
||||
35^"1,27"^"WDS/Event Report/MIP Status"^50088^-1
|
||||
35^"1,29"^"WDS/Event Report/Current Data Bearer Technology"^50090^-1
|
||||
35^"34,1"^"WDS/Packet Service Status Report/Status"^50030^-1
|
||||
35^"34,16"^"WDS/Packet Service Status Report/Call End Reason"^50043^-1
|
||||
35^"34,17"^"WDS/Packet Service Status Report/Verbose Call End Reason"^50098^-1
|
||||
35^"54,1"^"WDS/Modem Status Report/Status"^50050^-1
|
||||
35^"54,16"^"WDS/Modem Status Report/Call End Reason"^50049^-1
|
||||
35^"56,16"^"WDS/Modem Info Report/Status"^50050^-1
|
||||
35^"56,17"^"WDS/Modem Info Report/Call End Reason"^50049^-1
|
||||
35^"56,18"^"WDS/Modem Info Report/TX Bytes"^50054^-1
|
||||
35^"56,19"^"WDS/Modem Info Report/RX Bytes"^50055^-1
|
||||
35^"56,20"^"WDS/Modem Info Report/Dormancy Status"^50042^-1
|
||||
35^"56,21"^"WDS/Modem Info Report/Technology"^50020^-1
|
||||
35^"56,22"^"WDS/Modem Info Report/Rates"^50019^-1
|
||||
36^"1,16"^"DMS/Set Event Report Request/Power State"^50100^-1
|
||||
36^"1,17"^"DMS/Set Event Report Request/Battery Level"^50101^-1
|
||||
36^"1,18"^"DMS/Set Event Report Request/PIN Status"^50133^-1
|
||||
36^"1,19"^"DMS/Set Event Report Request/Activation State"^50111^-1
|
||||
36^"1,20"^"DMS/Set Event Report Request/Operating Mode"^50144^-1
|
||||
36^"1,21"^"DMS/Set Event Report Request/UIM State"^50151^-1
|
||||
36^"1,22"^"DMS/Set Event Report Request/Wireless Disable State"^50166^-1
|
||||
36^"39,1"^"DMS/UIM Set PIN Protection Request/Info"^50127^-1
|
||||
36^"40,1"^"DMS/UIM Verify PIN Request/Info"^50129^-1
|
||||
36^"41,1"^"DMS/UIM Unblock PIN Request/Info"^50130^-1
|
||||
36^"42,1"^"DMS/UIM Change PIN Request/Info"^50131^-1
|
||||
36^"46,1"^"DMS/Set Operating Mode Request/Operating Mode"^50115^-1
|
||||
36^"50,1"^"DMS/Activate Automatic Request/Activation Code"^50118^-1
|
||||
36^"51,1"^"DMS/Activate Manual Request/Activation Data"^50119^-1
|
||||
36^"51,16"^"DMS/Activate Manual Request/PRL (Obsolete)"^50120^-1
|
||||
36^"51,17"^"DMS/Activate Manual Request/MN-HA Key"^50121^-1
|
||||
36^"51,18"^"DMS/Activate Manual Request/MN-AAA Key"^50122^-1
|
||||
36^"51,19"^"DMS/Activate Manual Request/PRL"^50135^-1
|
||||
36^"53,1"^"DMS/Set Lock State Request/Lock State"^50124^-1
|
||||
36^"54,1"^"DMS/Set Lock Code Request/Lock Code"^50125^-1
|
||||
36^"56,1"^"DMS/Write User Data Request/User Data"^50126^-1
|
||||
36^"58,1"^"DMS/Reset Factory Defaults Request/SPC"^50134^-1
|
||||
36^"59,1"^"DMS/Validate SPC Request/SPC"^50070^-1
|
||||
36^"62,1"^"DMS/UIM Set Firmware ID Request/ID"^50141^-1
|
||||
36^"64,1"^"DMS/UIM Get Control Key Status Request/Facility"^50145^-1
|
||||
36^"65,1"^"DMS/UIM Set Control Key Protection Request/Facility"^50147^-1
|
||||
36^"66,1"^"DMS/UIM Unblock Control Key Request/Facility"^50149^-1
|
||||
36^"72,1"^"DMS/Set Firmware Preference Request/Image List"^50155^-1
|
||||
36^"72,16"^"DMS/Set Firmware Preference Request/Override"^50157^-1
|
||||
36^"72,17"^"DMS/Set Firmware Preference Request/Index"^50158^-1
|
||||
36^"74,1"^"DMS/Delete Stored Firmware Request/Image"^50156^-1
|
||||
36^"75,1"^"DMS/Set Device Time Request/Time"^50170^-1
|
||||
36^"75,16"^"DMS/Set Device Time Request/Type"^50171^-1
|
||||
36^"76,1"^"DMS/Get Stored Firmware Info Request/Image"^50156^-1
|
||||
36^"78,1"^"DMS/Set Alternate Net Config Request/Config"^50169^-1
|
||||
36^"80,1"^"DMS/Set Image Download Mode Request/Mode"^50175^-1
|
||||
37^"0,2"^"DMS/Reset Response/Result Code"^50000^-1
|
||||
37^"1,2"^"DMS/Set Event Report Response/Result Code"^50000^-1
|
||||
37^"32,1"^"DMS/Get Device Capabilities Response/Capabilities"^50103^-1
|
||||
37^"32,2"^"DMS/Get Device Capabilities Response/Result Code"^50000^-1
|
||||
37^"33,1"^"DMS/Get Device Manfacturer Response/Manfacturer"^50104^-1
|
||||
37^"33,2"^"DMS/Get Device Manfacturer Response/Result Code"^50000^-1
|
||||
37^"34,1"^"DMS/Get Device Model Response/Model"^50105^-1
|
||||
37^"34,2"^"DMS/Get Device Model Response/Result Code"^50000^-1
|
||||
37^"35,1"^"DMS/Get Device Revision Response/Revision"^50106^-1
|
||||
37^"35,2"^"DMS/Get Device Revision Response/Result Code"^50000^-1
|
||||
37^"35,16"^"DMS/Get Device Revision Response/Boot Code Revision"^50136^-1
|
||||
37^"35,17"^"DMS/Get Device Revision Response/UQCN Revision"^50136^-1
|
||||
37^"36,1"^"DMS/Get Device Voice Number Response/Voice Number"^50107^-1
|
||||
37^"36,2"^"DMS/Get Device Voice Number Response/Result Code"^50000^-1
|
||||
37^"36,16"^"DMS/Get Device Voice Number Response/Mobile ID Number"^50113^-1
|
||||
37^"36,17"^"DMS/Get Device Voice Number Response/IMSI"^50138^-1
|
||||
37^"37,2"^"DMS/Get Device Serial Numbers Response/Result Code"^50000^-1
|
||||
37^"37,16"^"DMS/Get Device Serial Numbers Response/ESN"^50108^-1
|
||||
37^"37,17"^"DMS/Get Device Serial Numbers Response/IMEI"^50109^-1
|
||||
37^"37,18"^"DMS/Get Device Serial Numbers Response/MEID"^50110^-1
|
||||
37^"38,1"^"DMS/Get Power State Response/Power State"^50102^-1
|
||||
37^"38,2"^"DMS/Get Power State Response/Result Code"^50000^-1
|
||||
37^"39,2"^"DMS/UIM Set PIN Protection Response/Result Code"^50000^-1
|
||||
37^"39,16"^"DMS/UIM Set PIN Protection Response/Retry Info"^50128^-1
|
||||
37^"40,2"^"DMS/UIM Verify PIN Response/Result Code"^50000^-1
|
||||
37^"40,16"^"DMS/UIM Verify PIN Response/Retry Info"^50128^-1
|
||||
37^"41,2"^"DMS/UIM Unblock PIN Response/Result Code"^50000^-1
|
||||
37^"41,16"^"DMS/UIM Unblock PIN Response/Retry Info"^50128^-1
|
||||
37^"42,2"^"DMS/UIM Change PIN Response/Result Code"^50000^-1
|
||||
37^"42,16"^"DMS/UIM Change PIN Response/Retry Info"^50128^-1
|
||||
37^"43,2"^"DMS/UIM Get PIN Status Response/Result Code"^50000^-1
|
||||
37^"43,17"^"DMS/UIM Get PIN Status Response/PIN1 Status"^50132^-1
|
||||
37^"43,18"^"DMS/UIM Get PIN Status Response/PIN2 Status"^50132^-1
|
||||
37^"44,1"^"DMS/Get Hardware Revision Response/Hardware Revision"^50114^-1
|
||||
37^"44,2"^"DMS/Get Hardware Revision Response/Result Code"^50000^-1
|
||||
37^"45,1"^"DMS/Get Operating Mode Response/Operating Mode"^50115^-1
|
||||
37^"45,2"^"DMS/Get Operating Mode Response/Result Code"^50000^-1
|
||||
37^"45,16"^"DMS/Get Operating Mode Response/Offline Reason"^50139^-1
|
||||
37^"45,17"^"DMS/Get Operating Mode Response/Platform Restricted"^50143^-1
|
||||
37^"46,2"^"DMS/Set Operating Mode Response/Result Code"^50000^-1
|
||||
37^"47,1"^"DMS/Get Timestamp Response/Timestamp"^50116^-1
|
||||
37^"47,2"^"DMS/Get Timestamp Response/Result Code"^50000^-1
|
||||
37^"48,1"^"DMS/Get PRL Version Response/PRL Version"^50117^-1
|
||||
37^"48,2"^"DMS/Get PRL Version Response/Result Code"^50000^-1
|
||||
37^"49,1"^"DMS/Get Activation State Response/Activation State"^50112^-1
|
||||
37^"49,2"^"DMS/Get Activation State Response/Result Code"^50000^-1
|
||||
37^"50,2"^"DMS/Activate Automatic Response/Result Code"^50000^-1
|
||||
37^"51,2"^"DMS/Activate Manual Response/Result Code"^50000^-1
|
||||
37^"52,1"^"DMS/Get Lock State Response/Lock State"^50123^-1
|
||||
37^"52,2"^"DMS/Get Lock State Response/Result Code"^50000^-1
|
||||
37^"53,2"^"DMS/Set Lock State Response/Result Code"^50000^-1
|
||||
37^"54,2"^"DMS/Set Lock Code Response/Result Code"^50000^-1
|
||||
37^"55,1"^"DMS/Read User Data Response/User Data"^50126^-1
|
||||
37^"55,2"^"DMS/Read User Data Response/Result Code"^50000^-1
|
||||
37^"56,2"^"DMS/Write User Data Response/Result Code"^50000^-1
|
||||
37^"57,1"^"DMS/Read ERI Data Response/User Data"^50126^-1
|
||||
37^"57,2"^"DMS/Read ERI Data Response/Result Code"^50000^-1
|
||||
37^"58,2"^"DMS/Reset Factory Defaults Response/Result Code"^50000^-1
|
||||
37^"59,2"^"DMS/Validate SPC Response/Result Code"^50000^-1
|
||||
37^"60,1"^"DMS/UIM Get ICCID Response/ICCID"^50140^-1
|
||||
37^"60,2"^"DMS/UIM Get ICCID Response/Result Code"^50000^-1
|
||||
37^"61,1"^"DMS/UIM Get Firmware ID Response/ID"^50141^-1
|
||||
37^"61,2"^"DMS/UIM Get Firmware ID Response/Result Code"^50000^-1
|
||||
37^"62,2"^"DMS/UIM Set Firmware ID Response/Result Code"^50000^-1
|
||||
37^"63,1"^"DMS/UIM Get Host Lock ID Response/ID"^50142^-1
|
||||
37^"63,2"^"DMS/UIM Get Host Lock ID Response/Result Code"^50000^-1
|
||||
37^"64,1"^"DMS/UIM Get Control Key Status Response/Status"^50146^-1
|
||||
37^"64,2"^"DMS/UIM Get Control Key Status Response/Result Code"^50000^-1
|
||||
37^"64,16"^"DMS/UIM Get Control Key Status Response/Blocking"^50153^-1
|
||||
37^"65,2"^"DMS/UIM Set Control Key Protection Response/Result Code"^50000^-1
|
||||
37^"65,16"^"DMS/UIM Set Control Key Protection Response/Status"^50148^-1
|
||||
37^"66,2"^"DMS/UIM Unblock Control Key Response/Result Code"^50000^-1
|
||||
37^"66,16"^"DMS/UIM Unblock Control Key Response/Status"^50150^-1
|
||||
37^"67,1"^"DMS/Get IMSI Response/IMSI"^50138^-1
|
||||
37^"67,2"^"DMS/Get IMSI Response/Result Code"^50000^-1
|
||||
37^"68,1"^"DMS/Get UIM State Response/State"^50152^-1
|
||||
37^"68,2"^"DMS/Get UIM State Response/Result Code"^50000^-1
|
||||
37^"69,1"^"DMS/Get Band Capabilities Response/Bands"^50165^-1
|
||||
37^"69,2"^"DMS/Get Band Capabilities Response/Result Code"^50000^-1
|
||||
37^"70,1"^"DMS/Get Factory Serial Number Response/ID"^50168^-1^0
|
||||
37^"70,2"^"DMS/Get Factory Serial Number Response/Result Code"^50000^-1^0
|
||||
37^"71,1"^"DMS/Get Firmware Preference Response/Image List"^50155^-1
|
||||
37^"71,2"^"DMS/Get Firmware Preference Response/Result Code"^50000^-1
|
||||
37^"72,1"^"DMS/Set Firmware Preference Response/Image List"^50159^-1
|
||||
37^"72,2"^"DMS/Set Firmware Preference Response/Result Code"^50000^-1
|
||||
37^"72,16"^"DMS/Set Firmware Preference Response/Maximum"^50160^-1
|
||||
37^"73,1"^"DMS/List Stored Firmware Response/Image List"^50161^-1
|
||||
37^"73,2"^"DMS/List Stored Firmware Response/Result Code"^50000^-1
|
||||
37^"74,2"^"DMS/Delete Stored Firmware Response/Result Code"^50000^-1
|
||||
37^"75,2"^"DMS/Set Device Time Response/Result Code"^50000^-1
|
||||
37^"76,2"^"DMS/Get Stored Firmware Info Response/Result Code"^50000^-1
|
||||
37^"76,16"^"DMS/Get Stored Firmware Info Response/Boot Version"^50172^-1
|
||||
37^"76,17"^"DMS/Get Stored Firmware Info Response/PRI Version"^50173^-1
|
||||
37^"76,18"^"DMS/Get Stored Firmware Info Response/OEM Lock ID"^50174^-1
|
||||
37^"77,1"^"DMS/Get Alternate Net Config Response/Config"^50169^-1
|
||||
37^"77,2"^"DMS/Get Alternate Net Config Response/Result Code"^50000^-1
|
||||
37^"78,2"^"DMS/Set Alternate Net Config Response/Result Code"^50000^-1
|
||||
37^"79,2"^"DMS/Get Image Download Mode Response/Result Code"^50000^-1
|
||||
37^"79,16"^"DMS/Get Image Download Mode Response/Mode"^50175^-1
|
||||
37^"80,2"^"DMS/Set Image Download Mode Response/Result Code"^50000^-1
|
||||
38^"1,16"^"DMS/Event Report/Power State"^50102^-1
|
||||
38^"1,17"^"DMS/Event Report/PIN1 State"^50132^-1
|
||||
38^"1,18"^"DMS/Event Report/PIN2 State"^50132^-1
|
||||
38^"1,19"^"DMS/Event Report/Activation State"^50112^-1
|
||||
38^"1,20"^"DMS/Event Report/Operating Mode"^50115^-1
|
||||
38^"1,21"^"DMS/Event Report/UIM State"^50152^-1
|
||||
38^"1,22"^"DMS/Event Report/Wireless Disable State"^50167^-1
|
||||
39^"1,1"^"NAS/Abort Request/Transaction ID"^50001^-1
|
||||
39^"2,16"^"NAS/Set Event Report Request/Signal Indicator"^50200^-1
|
||||
39^"2,17"^"NAS/Set Event Report Request/RF Indicator"^50233^-1
|
||||
39^"2,18"^"NAS/Set Event Report Request/Registration Reject Indicator"^50234^-1
|
||||
39^"2,19"^"NAS/Set Event Report Request/RSSI Indicator"^50240^-1
|
||||
39^"2,20"^"NAS/Set Event Report Request/ECIO Indicator"^50241^-1
|
||||
39^"2,21"^"NAS/Set Event Report Request/IO Indicator"^50242^-1
|
||||
39^"2,22"^"NAS/Set Event Report Request/SINR Indicator"^50243^-1
|
||||
39^"2,23"^"NAS/Set Event Report Request/Error Rate Indicator"^50244^-1
|
||||
39^"2,24"^"NAS/Set Event Report Request/RSRQ Indicator"^50277^-1
|
||||
39^"3,16"^"NAS/Set Registration Event Report Request/System Select Indicator"^50250^-1
|
||||
39^"3,18"^"NAS/Set Registration Event Report Request/DDTM Indicator"^50251^-1
|
||||
39^"3,19"^"NAS/Set Registration Event Report Request/Serving System Indicator"^50252^-1
|
||||
39^"32,16"^"NAS/Get Signal Strength Request/Request Mask"^50253^-1
|
||||
39^"34,1"^"NAS/Initiate Network Register Request/Action"^50204^-1
|
||||
39^"34,16"^"NAS/Initiate Network Register Request/Manual Info"^50205^-1
|
||||
39^"34,17"^"NAS/Initiate Network Register Request/Change Duration"^50276^-1
|
||||
39^"35,16"^"NAS/Initiate Attach Request/Action"^50206^-1
|
||||
39^"39,16"^"NAS/Set Preferred Networks Request/Networks"^50210^-1
|
||||
39^"41,16"^"NAS/Set Forbidden Networks Request/Networks"^50213^-1
|
||||
39^"42,1"^"NAS/Set Technology Preference Request/Preference"^50216^-1
|
||||
39^"45,1"^"NAS/Set ACCOLC Request/ACCOLC"^50219^-1
|
||||
39^"48,16"^"NAS/Set Network Parameters Request/SPC"^50230^-1
|
||||
39^"48,20"^"NAS/Set Network Parameters Request/CDMA 1xEV-DO Revision"^50228^-1
|
||||
39^"48,21"^"NAS/Set Network Parameters Request/CDMA 1xEV-DO SCP Custom"^50229^-1
|
||||
39^"48,22"^"NAS/Set Network Parameters Request/Roaming"^50231^-1
|
||||
39^"51,16"^"NAS/Set System Selection Pref Request/Emergency Mode"^50263^-1
|
||||
39^"51,17"^"NAS/Set System Selection Pref Request/Mode"^50264^-1
|
||||
39^"51,18"^"NAS/Set System Selection Pref Request/Band"^50265^-1
|
||||
39^"51,19"^"NAS/Set System Selection Pref Request/PRL"^50266^-1
|
||||
39^"51,20"^"NAS/Set System Selection Pref Request/Roaming"^50267^-1
|
||||
39^"55,1"^"NAS/Set DDTM Preference Request/DDTM"^50268^-1
|
||||
39^"68,1"^"NAS/Get PLMN Name Request/PLMN"^50214^-1
|
||||
40^"0,2"^"NAS/Reset Response/Result Code"^50000^-1
|
||||
40^"1,2"^"NAS/Abort Response/Result Code"^50000^-1
|
||||
40^"2,2"^"NAS/Set Event Report Response/Result Code"^50000^-1
|
||||
40^"3,2"^"NAS/Set Registration Event Report Response/Result Code"^50000^-1
|
||||
40^"32,1"^"NAS/Get Signal Strength Response/Signal Strength"^50201^-1
|
||||
40^"32,2"^"NAS/Get Signal Strength Response/Result Code"^50000^-1
|
||||
40^"32,16"^"NAS/Get Signal Strength Response/Signal Strength List"^50220^-1
|
||||
40^"32,17"^"NAS/Get Signal Strength Response/RSSI List"^50254^-1
|
||||
40^"32,18"^"NAS/Get Signal Strength Response/ECIO List"^50255^-1
|
||||
40^"32,19"^"NAS/Get Signal Strength Response/IO"^50247^-1
|
||||
40^"32,20"^"NAS/Get Signal Strength Response/SINR"^50248^-1
|
||||
40^"32,21"^"NAS/Get Signal Strength Response/Error Rate List"^50256^-1
|
||||
40^"33,2"^"NAS/Perform Network Scan Response/Result Code"^50000^-1
|
||||
40^"33,16"^"NAS/Perform Network Scan Response/Network Info"^50202^-1
|
||||
40^"33,17"^"NAS/Perform Network Scan Response/Network RAT"^50270^-1
|
||||
40^"34,2"^"NAS/Initiate Network Register Response/Result Code"^50000^-1
|
||||
40^"35,2"^"NAS/Initiate Attach Response/Result Code"^50000^-1
|
||||
40^"36,1"^"NAS/Get Serving System Response/Serving System"^50207^-1
|
||||
40^"36,2"^"NAS/Get Serving System Response/Result Code"^50000^-1
|
||||
40^"36,16"^"NAS/Get Serving System Response/Roaming Indicator"^50208^-1
|
||||
40^"36,17"^"NAS/Get Serving System Response/Data Services"^50223^-1
|
||||
40^"36,18"^"NAS/Get Serving System Response/Current PLMN"^50209^-1
|
||||
40^"36,19"^"NAS/Get Serving System Response/System ID"^50215^-1
|
||||
40^"36,20"^"NAS/Get Serving System Response/Base Station"^50257^-1
|
||||
40^"36,21"^"NAS/Get Serving System Response/Roaming List"^50258^-1
|
||||
40^"36,22"^"NAS/Get Serving System Response/Default Roaming"^50260^-1
|
||||
40^"36,23"^"NAS/Get Serving System Response/Time Zone"^50261^-1
|
||||
40^"36,24"^"NAS/Get Serving System Response/Protocol Revision"^50262^-1
|
||||
40^"37,1"^"NAS/Get Home Network Response/Home Network"^50209^-1
|
||||
40^"37,2"^"NAS/Get Home Network Response/Result Code"^50000^-1
|
||||
40^"37,16"^"NAS/Get Home Network Response/Home IDs"^50215^-1
|
||||
40^"37,17"^"NAS/Get Home Network Response/Extended Home Network"^50269^-1
|
||||
40^"38,2"^"NAS/Get Preferred Networks Response/Result Code"^50000^-1
|
||||
40^"38,16"^"NAS/Get Preferred Networks Response/Networks"^50210^-1
|
||||
40^"38,17"^"NAS/Get Preferred Networks Response/Static Networks"^50210^-1
|
||||
40^"39,2"^"NAS/Set Preferred Networks Response/Result Code"^50000^-1
|
||||
40^"40,2"^"NAS/Get Forbidden Networks Response/Result Code"^50000^-1
|
||||
40^"40,16"^"NAS/Get Forbidden Networks Response/Networks"^50213^-1
|
||||
40^"41,2"^"NAS/Set Forbidden Networks Response/Result Code"^50000^-1
|
||||
40^"42,2"^"NAS/Set Technology Preference Response/Result Code"^50000^-1
|
||||
40^"43,1"^"NAS/Get Technology Preference Response/Active Preference"^50216^-1
|
||||
40^"43,2"^"NAS/Get Technology Preference Response/Result Code"^50000^-1
|
||||
40^"43,16"^"NAS/Get Technology Preference Response/Persistent Preference"^50217^-1
|
||||
40^"44,1"^"NAS/Get ACCOLC Response/ACCOLC"^50218^-1
|
||||
40^"44,2"^"NAS/Get ACCOLC Response/Result Code"^50000^-1
|
||||
40^"45,2"^"NAS/Set ACCOLC Response/Result Code"^50000^-1
|
||||
40^"46,1"^"NAS/Get System Preference/Pref"^50224^-1
|
||||
40^"46,2"^"NAS/Get System Preference/Result Code"^50000^-1
|
||||
40^"47,2"^"NAS/Get Network Parameters Response/Result Code"^50000^-1
|
||||
40^"47,17"^"NAS/Get Network Parameters Response/SCI"^50225^-1
|
||||
40^"47,18"^"NAS/Get Network Parameters Response/SCM"^50226^-1
|
||||
40^"47,19"^"NAS/Get Network Parameters Response/Registration"^50227^-1
|
||||
40^"47,20"^"NAS/Get Network Parameters Response/CDMA 1xEV-DO Revision"^50228^-1
|
||||
40^"47,21"^"NAS/Get Network Parameters Response/CDMA 1xEV-DO SCP Custom"^50229^-1
|
||||
40^"47,22"^"NAS/Get Network Parameters Response/Roaming"^50231^-1
|
||||
40^"48,2"^"NAS/Set Network Parameters Response/Result Code"^50000^-1
|
||||
40^"49,1"^"NAS/Get RF Info Response/RF Info"^50235^-1
|
||||
40^"49,2"^"NAS/Get RF Info Response/Result Code"^50000^-1
|
||||
40^"50,1"^"NAS/Get AN-AAA Authentication Status Response/Status"^50237^-1
|
||||
40^"50,2"^"NAS/Get AN-AAA Authentication Status Response/Result Code"^50000^-1
|
||||
40^"51,2"^"NAS/Set System Selection Pref Response/Result Code"^50000^-1
|
||||
40^"52,2"^"NAS/Get System Selection Pref Response/Result Code"^50000^-1
|
||||
40^"52,16"^"NAS/Get System Selection Pref Response/Emergency Mode"^50263^-1
|
||||
40^"52,17"^"NAS/Get System Selection Pref Response/Mode"^50264^-1
|
||||
40^"52,18"^"NAS/Get System Selection Pref Response/Band"^50265^-1
|
||||
40^"52,19"^"NAS/Get System Selection Pref Response/PRL"^50266^-1
|
||||
40^"52,20"^"NAS/Get System Selection Pref Response/Roaming"^50267^-1
|
||||
40^"55,2"^"NAS/Set DDTM Preference Response/Result Code"^50000^-1
|
||||
40^"56,1"^"NAS/Get DDTM Preference Response/DDTM"^50268^-1
|
||||
40^"56,2"^"NAS/Get DDTM Preference Response/Result Code"^50000^-1
|
||||
40^"59,2"^"NAS/Get CSP PLMN Mode Response/Result Code"^50000^-1
|
||||
40^"59,16"^"NAS/Get CSP PLMN Mode Response/Mode"^50273^-1
|
||||
40^"68,2"^"NAS/Get PLMN Name Response/Result Code"^50000^-1
|
||||
40^"68,16"^"NAS/Get PLMN Name Response/Name"^50274^-1
|
||||
41^"2,16"^"NAS/Event Report/Signal Strength"^50201^-1
|
||||
41^"2,17"^"NAS/Event Report/RF Info"^50235^-1
|
||||
41^"2,18"^"NAS/Event Report/Registration Reject"^50236^-1
|
||||
41^"2,19"^"NAS/Event Report/RSSI"^50245^-1
|
||||
41^"2,20"^"NAS/Event Report/ECIO"^50246^-1
|
||||
41^"2,21"^"NAS/Event Report/IO"^50247^-1
|
||||
41^"2,22"^"NAS/Event Report/SINR"^50248^-1
|
||||
41^"2,23"^"NAS/Event Report/Error Rate"^50249^-1
|
||||
41^"2,24"^"NAS/Event Report/RSRQ"^50275^-1
|
||||
41^"36,1"^"NAS/Serving System Indication/Serving System"^50207^-1
|
||||
41^"36,16"^"NAS/Serving System Indication/Roaming Indicator"^50208^-1
|
||||
41^"36,17"^"NAS/Serving System Indication/Data Services"^50223^-1
|
||||
41^"36,18"^"NAS/Serving System Indication/Current PLMN"^50209^-1
|
||||
41^"36,19"^"NAS/Serving System Indication/System ID"^50215^-1
|
||||
41^"36,20"^"NAS/Serving System Indication/Base Station"^50257^-1
|
||||
41^"36,21"^"NAS/Serving System Indication/Roaming List"^50258^-1
|
||||
41^"36,22"^"NAS/Serving System Indication/Default Roaming"^50260^-1
|
||||
41^"36,23"^"NAS/Serving System Indication/Time Zone"^50261^-1
|
||||
41^"36,24"^"NAS/Serving System Indication/Protocol Revision"^50262^-1
|
||||
41^"36,25"^"NAS/Serving System Indication/PLMN Change"^50272^-1
|
||||
41^"52,16"^"NAS/System Selection Pref Indication/Emergency Mode"^50263^-1
|
||||
41^"52,17"^"NAS/System Selection Pref Indication/Mode"^50264^-1
|
||||
41^"52,18"^"NAS/System Selection Pref Indication/Band"^50265^-1
|
||||
41^"52,19"^"NAS/System Selection Pref Indication/PRL"^50266^-1
|
||||
41^"52,20"^"NAS/System Selection Pref Indication/Roaming"^50267^-1
|
||||
41^"56,1"^"NAS/DDTM Preference Indication/DDTM"^50268^-1
|
||||
41^"60,16"^"NAS/CSP PLMN Mode Indication/Mode"^50273^-1
|
||||
45^"1,16"^"WMS/Set Event Report Request/New MT Message Indicator"^50300^-1
|
||||
45^"32,1"^"WMS/Raw Send Request/Message Data"^50302^-1
|
||||
45^"32,16"^"WMS/Raw Send Request/Force On DC"^50321^-1
|
||||
45^"32,17"^"WMS/Raw Send Request/Follow On DC"^50322^-1
|
||||
45^"32,18"^"WMS/Raw Send Request/Link Control"^50323^-1
|
||||
45^"33,1"^"WMS/Raw Write Request/Message Data"^50304^-1
|
||||
45^"34,1"^"WMS/Raw Read Request/Message Index"^50301^-1
|
||||
45^"34,16"^"WMS/Raw Read Request/Message Mode"^50310^-1
|
||||
45^"35,1"^"WMS/Modify Tag Request/Message Tag"^50307^-1
|
||||
45^"35,16"^"WMS/Modify Tag Request/Message Mode"^50310^-1
|
||||
45^"36,1"^"WMS/Delete Request/Memory Storage"^50308^-1
|
||||
45^"36,16"^"WMS/Delete Request/Message Index"^50305^-1
|
||||
45^"36,17"^"WMS/Delete Request/Message Tag"^50309^-1
|
||||
45^"36,18"^"WMS/Delete Request/Message Mode"^50310^-1
|
||||
45^"49,1"^"WMS/List Messages Request/Memory Storage"^50308^-1
|
||||
45^"49,16"^"WMS/List Messages Request/Message Tag"^50309^-1
|
||||
45^"49,17"^"WMS/List Messages Request/Message Mode"^50310^-1
|
||||
45^"50,1"^"WMS/Set Routes Request/Route List"^50313^-1
|
||||
45^"50,16"^"WMS/Set Routes Request/Transfer Status Report"^50326^-1
|
||||
45^"53,1"^"WMS/Set SMSC Address Request/Address"^50319^-1
|
||||
45^"53,16"^"WMS/Set SMSC Address Request/Address Type"^50318^-1
|
||||
45^"54,1"^"WMS/Get Storage Max Size Request/Memory Storage"^50308^-1
|
||||
45^"54,16"^"WMS/Get Storage Max Size Request/Message Mode"^50310^-1
|
||||
45^"55,1"^"WMS/Send ACK Request/ACK"^50329^-1
|
||||
45^"55,16"^"WMS/Send ACK Request/3GPP2 Failure Info"^50330^-1
|
||||
45^"55,17"^"WMS/Send ACK Request/3GPP Failure Info"^50331^-1
|
||||
45^"56,1"^"WMS/Set Retry Period Request/Period"^50332^-1
|
||||
45^"57,1"^"WMS/Set Retry Interval Request/Interval"^50333^-1
|
||||
45^"58,1"^"WMS/Set DC Disconnect Timer Request/Timer"^50334^-1
|
||||
45^"59,1"^"WMS/Set Memory Status Request/Status"^50335^-1
|
||||
45^"60,1"^"WMS/Set Broadcast Activation Request/BC Info"^50336^-1
|
||||
45^"61,1"^"WMS/Set Broadcast Config Request/Mode"^50310^-1
|
||||
45^"61,16"^"WMS/Set Broadcast Config Request/3GPP Info"^50337^-1
|
||||
45^"61,17"^"WMS/Set Broadcast Config Request/3GPP2 Info"^50339^-1
|
||||
45^"62,1"^"WMS/Get Broadcast Config Request/Mode"^50310^-1
|
||||
45^"65,1"^"WMS/Set Domain Preference Request/Pref"^50344^-1
|
||||
45^"66,1"^"WMS/Send From Memory Store Request/Info"^50345^-1
|
||||
46^"0,2"^"WMS/Reset Response/Result Code"^50000^-1
|
||||
46^"1,2"^"WMS/Set Event Report Response/Result Code"^50000^-1
|
||||
46^"32,2"^"WMS/Raw Send Response/Result Code"^50000^-1
|
||||
46^"32,16"^"WMS/Raw Send Response/Cause Code"^50303^-1
|
||||
46^"32,17"^"WMS/Raw Send Response/Error Class"^50324^-1
|
||||
46^"32,18"^"WMS/Raw Send Response/Cause Info"^50325^-1
|
||||
46^"33,1"^"WMS/Raw Write Response/Message Index"^50305^-1
|
||||
46^"33,2"^"WMS/Raw Write Response/Result Code"^50000^-1
|
||||
46^"34,1"^"WMS/Raw Read Response/Message Data"^50306^-1
|
||||
46^"34,2"^"WMS/Raw Read Response/Result Code"^50000^-1
|
||||
46^"35,2"^"WMS/Modify Tag Response/Result Code"^50000^-1
|
||||
46^"36,2"^"WMS/Delete Response/Result Code"^50000^-1
|
||||
46^"48,1"^"WMS/Get Message Protocol Response/Message Protocol"^50310^-1
|
||||
46^"48,2"^"WMS/Get Message Protocol Response/Result Code"^50000^-1
|
||||
46^"49,1"^"WMS/List Messages Response/Message List"^50311^-1
|
||||
46^"49,2"^"WMS/List Messages Response/Result Code"^50000^-1
|
||||
46^"50,2"^"WMS/Set Routes Response/Result Code"^50000^-1
|
||||
46^"51,1"^"WMS/Get Routes Response/Route List"^50315^-1
|
||||
46^"51,16"^"WMS/Get Routes Response/Transfer Status Report"^50326^-1
|
||||
46^"51,2"^"WMS/Get Routes Response/Result Code"^50000^-1
|
||||
46^"52,1"^"WMS/Get SMSC Address Response/Address"^50317^-1
|
||||
46^"52,2"^"WMS/Get SMSC Address Response/Result Code"^50000^-1
|
||||
46^"54,1"^"WMS/Get Storage Max Size Response/Max Size"^50327^-1
|
||||
46^"54,2"^"WMS/Get Storage Max Size Response/Result Code"^50000^-1
|
||||
46^"54,16"^"WMS/Get Storage Max Size Response/Available Size"^50328^-1
|
||||
46^"55,2"^"WMS/Send ACK Response/Result Code"^50000^-1
|
||||
46^"56,2"^"WMS/Set Retry Period Response/Result Code"^50000^-1
|
||||
46^"57,2"^"WMS/Set Retry Interval Response/Result Code"^50000^-1
|
||||
46^"58,2"^"WMS/Set DC Disconnect Timer Response/Result Code"^50000^-1
|
||||
46^"59,2"^"WMS/Set Memory Status Response/Result Code"^50000^-1
|
||||
46^"60,2"^"WMS/Set Broadcast Activation Response/Result Code"^50000^-1
|
||||
46^"61,2"^"WMS/Set Broadcast Config Response/Result Code"^50000^-1
|
||||
46^"62,2"^"WMS/Get Broadcast Config Response/Result Code"^50000^-1
|
||||
46^"62,16"^"WMS/Get Broadcast Config Response/3GPP Info"^50341^-1
|
||||
46^"62,17"^"WMS/Get Broadcast Config Response/3GPP2 Info"^50342^-1
|
||||
46^"64,1"^"WMS/Get Domain Preference Response/Pref"^50344^-1
|
||||
46^"64,2"^"WMS/Get Domain Preference Response/Result Code"^50000^-1
|
||||
46^"65,2"^"WMS/Set Domain Preference Response/Result Code"^50000^-1
|
||||
46^"66,2"^"WMS/Send From Memory Store Response/Result Code"^50000^-1
|
||||
46^"66,16"^"WMS/Send From Memory Store Response/Message ID"^50346^-1
|
||||
46^"66,17"^"WMS/Send From Memory Store Response/Cause Code"^50303^-1
|
||||
46^"66,18"^"WMS/Send From Memory Store Response/Error Class"^50324^-1
|
||||
46^"66,19"^"WMS/Send From Memory Store Response/Cause Info"^50325^-1
|
||||
47^"1,16"^"WMS/Event Report/Received MT Message"^50301^-1
|
||||
47^"1,17"^"WMS/Event Report/Transfer Route MT Message"^50320^-1
|
||||
47^"1,18"^"WMS/Event Report/Message Mode"^50310^-1
|
||||
47^"63,1"^"WMS/Memory Full Indication/Info"^50343^-1
|
||||
47^"70,1"^"WMS/SMSC Address Indication/Address"^50317^-1
|
||||
48^"1,16"^"PDS/Set Event Report Request/NMEA Indicator"^50400^-1
|
||||
48^"1,17"^"PDS/Set Event Report Request/Mode Indicator"^50416^-1
|
||||
48^"1,18"^"PDS/Set Event Report Request/Raw Indicator"^50420^-1
|
||||
48^"1,19"^"PDS/Set Event Report Request/XTRA Request Indicator"^50421^-1
|
||||
48^"1,20"^"PDS/Set Event Report Request/Time Injection Indicator"^50422^-1
|
||||
48^"1,21"^"PDS/Set Event Report Request/Wi-Fi Indicator"^50423^-1
|
||||
48^"1,22"^"PDS/Set Event Report Request/Satellite Indicator"^50424^-1
|
||||
48^"1,23"^"PDS/Set Event Report Request/VX Network Indicator"^50425^-1
|
||||
48^"1,24"^"PDS/Set Event Report Request/SUPL Network Indicator"^50426^-1
|
||||
48^"1,25"^"PDS/Set Event Report Request/UMTS CP Network Indicator"^50427^-1
|
||||
48^"1,26"^"PDS/Set Event Report Request/PDS Comm Indicator"^50428^-1
|
||||
48^"33,1"^"PDS/Set Service State Request/State"^50403^-1
|
||||
48^"34,1"^"PDS/Start Tracking Session Request/Session"^50404^-1
|
||||
48^"39,1"^"PDS/Set NMEA Config Request/Config"^50405^-1
|
||||
48^"40,1"^"PDS/Inject Time Reference Request/Time"^50406^-1
|
||||
48^"42,1"^"PDS/Set Defaults Request/Defaults"^50407^-1
|
||||
48^"44,16"^"PDS/Set XTRA Parameters Request/Automatic"^50408^-1
|
||||
48^"44,17"^"PDS/Set XTRA Parameters Request/Medium"^50409^-1
|
||||
48^"44,18"^"PDS/Set XTRA Parameters Request/Network"^50410^-1
|
||||
48^"44,20"^"PDS/Set XTRA Parameters Request/Embedded"^50441^-1
|
||||
48^"46,18"^"PDS/Get AGPS Config Request/Network Mode"^50471^-1
|
||||
48^"47,16"^"PDS/Set AGPS Config Request/Server"^50412^-1
|
||||
48^"47,17"^"PDS/Set AGPS Config Request/Server URL"^50432^-1
|
||||
48^"47,18"^"PDS/Set AGPS Config Request/Network Mode"^50471^-1
|
||||
48^"49,1"^"PDS/Set Service Auto-Tracking State Request/State"^50413^-1
|
||||
48^"51,1"^"PDS/Set COM Port Auto-Tracking Config Request/Config"^50413^-1
|
||||
48^"52,16"^"PDS/Reset PDS Data Request/GPS Data"^50414^-1
|
||||
48^"52,17"^"PDS/Reset PDS Data Request/Cell Data"^50415^-1
|
||||
48^"53,16"^"PDS/Single Position Fix Request/Mode"^50442^-1
|
||||
48^"53,17"^"PDS/Single Position Fix Request/Timeout"^50443^-1
|
||||
48^"53,18"^"PDS/Single Position Fix Request/Accuracy"^50444^-1
|
||||
48^"55,1"^"PDS/Inject XTRA Data Request/Data"^50446^-1
|
||||
48^"56,16"^"PDS/Inject Position Data Request/Timestamp"^50447^-1
|
||||
48^"56,17"^"PDS/Inject Position Data Request/Latitude"^50448^-1
|
||||
48^"56,18"^"PDS/Inject Position Data Request/Longitude"^50449^-1
|
||||
48^"56,19"^"PDS/Inject Position Data Request/Altitude Ellipsoid"^50450^-1
|
||||
48^"56,20"^"PDS/Inject Position Data Request/Altitude Sea Level"^50451^-1
|
||||
48^"56,21"^"PDS/Inject Position Data Request/Horizontal Uncertainty"^50452^-1
|
||||
48^"56,22"^"PDS/Inject Position Data Request/Vertical Uncertainty"^50453^-1
|
||||
48^"56,23"^"PDS/Inject Position Data Request/Horizontal Confidence"^50454^-1
|
||||
48^"56,24"^"PDS/Inject Position Data Request/Vertical Confidence"^50455^-1
|
||||
48^"56,25"^"PDS/Inject Position Data Request/Source"^50456^-1
|
||||
48^"57,16"^"PDS/Inject Wi-Fi Position Data Request/Time"^50457^-1
|
||||
48^"57,17"^"PDS/Inject Wi-Fi Position Data Request/Position"^50458^-1
|
||||
48^"57,18"^"PDS/Inject Wi-Fi Position Data Request/AP Info"^50459^-1
|
||||
48^"59,16"^"PDS/Set SBAS Config Request/Config"^50462^-1
|
||||
48^"60,1"^"PDS/Send Network Initiated Response Request/Action"^50463^-1
|
||||
48^"60,16"^"PDS/Send Network Initiated Response Request/VX"^50437^-1
|
||||
48^"60,17"^"PDS/Send Network Initiated Response Request/SUPL"^50438^-1
|
||||
48^"60,18"^"PDS/Send Network Initiated Response Request/UMTS CP"^50439^-1
|
||||
48^"61,1"^"PDS/Inject Absolute Time Request/Time"^50464^-1
|
||||
48^"62,1"^"PDS/Inject EFS Data Request/Date File"^50465^-1
|
||||
48^"64,1"^"PDS/Set DPO Config Request/Config"^50467^-1
|
||||
48^"66,16"^"PDS/Set ODP Config Request/Config"^50468^-1
|
||||
48^"81,16"^"PDS/Set Position Methods State Request/XTRA Time"^50470^-1
|
||||
48^"81,17"^"PDS/Set Position Methods State Request/XTRA Data"^50470^-1
|
||||
48^"81,18"^"PDS/Set Position Methods State Request/Wi-Fi"^50470^-1
|
||||
49^"0,2"^"PDS/Reset Response/Result Code"^50000^-1
|
||||
49^"1,2"^"PDS/Set Event Report Response/Result Code"^50000^-1
|
||||
49^"32,1"^"PDS/Get Service State Response/State"^50402^-1
|
||||
49^"32,2"^"PDS/Get Service State Response/Result Code"^50000^-1
|
||||
49^"33,2"^"PDS/Set Service State Response/Result Code"^50000^-1
|
||||
49^"34,2"^"PDS/Start Tracking Session Response/Result Code"^50000^-1
|
||||
49^"35,1"^"PDS/Get Tracking Session Info Response/Info"^50404^-1
|
||||
49^"35,2"^"PDS/Get Tracking Session Info Response/Result Code"^50000^-1
|
||||
49^"36,2"^"PDS/Fix Position Response/Result Code"^50000^-1
|
||||
49^"37,2"^"PDS/End Tracking Session Response/Result Code"^50000^-1
|
||||
49^"38,1"^"PDS/Get NMEA Config Response/Config"^50405^-1
|
||||
49^"38,2"^"PDS/Get NMEA Config Response/Result Code"^50000^-1
|
||||
49^"39,2"^"PDS/Set NMEA Config Response/Result Code"^50000^-1
|
||||
49^"40,2"^"PDS/Inject Time Reference Response/Result Code"^50000^-1
|
||||
49^"41,1"^"PDS/Get Defaults Response/Defaults"^50407^-1
|
||||
49^"41,2"^"PDS/Get Defaults Response/Result Code"^50000^-1
|
||||
49^"42,2"^"PDS/Set Defaults Response/Result Code"^50000^-1
|
||||
49^"43,2"^"PDS/Get XTRA Parameters Response/Result Code"^50000^-1
|
||||
49^"43,16"^"PDS/Get XTRA Parameters Response/Automatic"^50408^-1
|
||||
49^"43,17"^"PDS/Get XTRA Parameters Response/Medium"^50409^-1
|
||||
49^"43,18"^"PDS/Get XTRA Parameters Response/Network"^50410^-1
|
||||
49^"43,19"^"PDS/Get XTRA Parameters Response/Validity"^50411^-1
|
||||
49^"43,20"^"PDS/Get XTRA Parameters Response/Embedded"^50441^-1
|
||||
49^"44,2"^"PDS/Set XTRA Parameters Response/Result Code"^50000^-1
|
||||
49^"45,2"^"PDS/Force XTRA Download Response/Result Code"^50000^-1
|
||||
49^"46,2"^"PDS/Get AGPS Config Response/Result Code"^50000^-1
|
||||
49^"46,16"^"PDS/Get AGPS Config Response/Server"^50412^-1
|
||||
49^"46,17"^"PDS/Get AGPS Config Response/Server URL"^50432^-1
|
||||
49^"47,2"^"PDS/Set AGPS Config Response/Result Code"^50000^-1
|
||||
49^"48,1"^"PDS/Get Service Auto-Tracking State Response/State"^50413^-1
|
||||
49^"48,2"^"PDS/Get Service Auto-Tracking State Response/Result Code"^50000^-1
|
||||
49^"49,2"^"PDS/Set Service Auto-Tracking State Response/Result Code"^50000^-1
|
||||
49^"50,1"^"PDS/Get COM Port Auto-Tracking Config Response/Config"^50413^-1
|
||||
49^"50,2"^"PDS/Get COM Port Auto-Tracking Config Response/Result Code"^50000^-1
|
||||
49^"51,2"^"PDS/Set COM Port Auto-Tracking Config Response/Result Code"^50000^-1
|
||||
49^"52,2"^"PDS/Reset PDS Data Response/Result Code"^50000^-1
|
||||
49^"53,2"^"PDS/Single Position Fix Response/Result Code"^50000^-1
|
||||
49^"54,1"^"PDS/Get Service Version Response/Version"^50445^-1
|
||||
49^"54,2"^"PDS/Get Service Version Response/Result Code"^50000^-1
|
||||
49^"55,2"^"PDS/Inject XTRA Data Response/Result Code"^50000^-1
|
||||
49^"56,2"^"PDS/Inject Position Data Response/Result Code"^50000^-1
|
||||
49^"57,2"^"PDS/Inject Wi-Fi Position Data Response/Result Code"^50000^-1
|
||||
49^"58,2"^"PDS/Get SBAS Config Response/Result Code"^50000^-1
|
||||
49^"58,16"^"PDS/Get SBAS Config Response/Config"^50461^-1
|
||||
49^"59,2"^"PDS/Set SBAS Config Response/Result Code"^50000^-1
|
||||
49^"60,2"^"PDS/Send Network Initiated Response Response/Result Code"^50000^-1
|
||||
49^"61,2"^"PDS/Inject Absolute Time Response/Result Code"^50000^-1
|
||||
49^"62,2"^"PDS/Inject EFS Data Response/Result Code"^50000^-1
|
||||
49^"63,2"^"PDS/Get DPO Config Response/Result Code"^50000^-1
|
||||
49^"63,16"^"PDS/Get DPO Config Response/Config"^50466^-1
|
||||
49^"64,2"^"PDS/Set DPO Config Response/Result Code"^50000^-1
|
||||
49^"65,2"^"PDS/Get ODP Config Response/Result Code"^50000^-1
|
||||
49^"65,16"^"PDS/Get ODP Config Response/Config"^50468^-1
|
||||
49^"66,2"^"PDS/Set ODP Config Response/Result Code"^50000^-1
|
||||
49^"67,2"^"PDS/Cancel Single Position Fix Response/Result Code"^50000^-1
|
||||
49^"68,2"^"PDS/Get GPS State Response/Result Code"^50000^-1
|
||||
49^"68,16"^"PDS/Get GPS State Response/State"^50469^-1
|
||||
49^"80,2"^"PDS/Get Position Methods State Response/Result Code"^50000^-1
|
||||
49^"80,16"^"PDS/Get Position Methods State Response/XTRA Time"^50470^-1
|
||||
49^"80,17"^"PDS/Get Position Methods State Response/XTRA Data"^50470^-1
|
||||
49^"80,18"^"PDS/Get Position Methods State Response/Wi-Fi"^50470^-1
|
||||
49^"81,2"^"PDS/Set Position Methods State Response/Result Code"^50000^-1
|
||||
50^"1,16"^"PDS/Event Report/NMEA Sentence"^50401^-1
|
||||
50^"1,17"^"PDS/Event Report/NMEA Sentence Plus Mode"^50417^-1
|
||||
50^"1,18"^"PDS/Event Report/Position Session Status"^50429^-1
|
||||
50^"1,19"^"PDS/Event Report/Parsed Position Data"^50430^-1
|
||||
50^"1,20"^"PDS/Event Report/External XTRA Request"^50431^-1
|
||||
50^"1,21"^"PDS/Event Report/External Time Injection Request"^50433^-1
|
||||
50^"1,22"^"PDS/Event Report/External Wi-Fi Position Request"^50434^-1
|
||||
50^"1,23"^"PDS/Event Report/Satellite Info"^50435^-1
|
||||
50^"1,24"^"PDS/Event Report/VX Network Initiated Prompt"^50437^-1
|
||||
50^"1,25"^"PDS/Event Report/SUPL Network Initiated Prompt"^50438^-1
|
||||
50^"1,26"^"PDS/Event Report/UMTS CP Network Initiated Prompt"^50439^-1
|
||||
50^"1,27"^"PDS/Event Report/Comm Events"^50440^-1
|
||||
50^"32,1"^"PDS/Service State Indication/State"^50402^-1
|
||||
51^"32,16"^"AUTH/Start EAP Session Request/Method Mask"^50700^-1^0
|
||||
51^"33,1"^"AUTH/Send EAP Packet Request/Request Packet"^50701^-1^0
|
||||
52^"32,2"^"AUTH/Start EAP Session Response/Result Code"^50000^-1^0
|
||||
52^"33,1"^"AUTH/Send EAP Packet Response/Response Packet"^50703^-1^0
|
||||
52^"33,2"^"AUTH/Send EAP Packet Response/Result Code"^50000^-1^0
|
||||
52^"35,1"^"AUTH/Get EAP Session Keys Response/Session Keys"^50705^-1^0
|
||||
52^"35,2"^"AUTH/Get EAP Session Keys Response/Result Code"^50000^-1^0
|
||||
52^"36,2"^"AUTH/End EAP Session Response/Result Code"^50000^-1^0
|
||||
52^"34,1"^"AUTH/EAP Session Result/Result"^50704^-1^0
|
||||
54^"1,16"^"CAT/Set Event Report Request/Report Mask"^50600^-1^0
|
||||
54^"33,1"^"CAT/Send Terminal Response Request/Terminal Response Type"^50612^-1^0
|
||||
54^"34,1"^"CAT/Envelope Command Request/Envelope Command"^50613^-1^0
|
||||
55^"0,2"^"CAT/Reset Response/Result Code"^50000^-1^0
|
||||
55^"1,2"^"CAT/Set Event Report Response/Result Code"^50000^-1^0
|
||||
55^"1,16"^"CAT/Set Event Report Response/Reg Status Mask"^50600^-1^0
|
||||
55^"32,1"^"CAT/Get Service State Response/CAT Service State"^50615^-1^0
|
||||
55^"32,2"^"CAT/Get Service State Response/Result Code"^50000^-1^0
|
||||
55^"33,2"^"CAT/Send Terminal Response Response/Result Code"^50000^-1^0
|
||||
55^"34,2"^"CAT/Envelope Command Response/Result Code"^50000^-1^0
|
||||
56^"1,16"^"CAT/Event Report/Display Text Event"^50601^-1^0
|
||||
56^"1,17"^"CAT/Event Report/Get Inkey Event"^50602^-1^0
|
||||
56^"1,18"^"CAT/Event Report/Get Input Event"^50603^-1^0
|
||||
56^"1,19"^"CAT/Event Report/Setup Menu Event"^50604^-1^0
|
||||
56^"1,20"^"CAT/Event Report/Select Item Event"^50605^-1^0
|
||||
56^"1,21"^"CAT/Event Report/Alpha ID Available"^50606^-1^0
|
||||
56^"1,22"^"CAT/Event Report/Setup Event List"^50607^-1^0
|
||||
56^"1,23"^"CAT/Event Report/Setup Idle Mode Text Event"^50608^-1^0
|
||||
56^"1,24"^"CAT/Event Report/Language Notification Event"^50609^-1^0
|
||||
56^"1,25"^"CAT/Event Report/Refresh Event"^50610^-1^0
|
||||
56^"1,26"^"CAT/Event Report/End Proactive Session"^50611^-1^0
|
||||
57^"33,16"^"RMS/Set SMS Wake Request/State"^50500^-1^0
|
||||
57^"33,17"^"RMS/Set SMS Wake Request/Mask"^50501^-1^0
|
||||
58^"0,2"^"RMS/Reset Response/Result Code"^50000^-1^0
|
||||
58^"32,2"^"RMS/Get SMS Wake Response/Result Code"^50000^-1^0
|
||||
58^"32,16"^"RMS/Get SMS Wake Response/State"^50500^-1^0
|
||||
58^"32,17"^"RMS/Get SMS Wake Request/Mask"^50501^-1^0
|
||||
58^"33,2"^"RMS/Set SMS Wake Response/Result Code"^50000^-1^0
|
||||
60^"1,16"^"OMA/Set Event Report Request/NIA"^50800^-1^0
|
||||
60^"1,17"^"OMA/Set Event Report Request/Status"^50801^-1^0
|
||||
60^"32,16"^"OMA/Start Session Request/Type"^50805^-1^0
|
||||
60^"35,16"^"OMA/Send Selection Request/Type"^50808^-1^0
|
||||
60^"37,16"^"OMA/Set Features Response/Provisioning"^50809^-1^0
|
||||
60^"37,17"^"OMA/Set Features Response/PRL Update"^50810^-1^0
|
||||
60^"37,18"^"OMA/Set Features Response/HFA Feature"^50811^-1^0
|
||||
61^"0,2"^"OMA/Reset Response/Result Code"^50000^-1^0
|
||||
61^"1,2"^"OMA/Set Event Report Response/Result Code"^50000^-1^0
|
||||
61^"32,2"^"OMA/Start Session Response/Result Code"^50000^-1^0
|
||||
61^"33,2"^"OMA/Cancel Session Response/Result Code"^50000^-1^0
|
||||
61^"34,2"^"OMA/Get Session Info Response/Result Code"^50000^-1^0
|
||||
61^"34,16"^"OMA/Get Session Info Response/Info"^50806^-1^0
|
||||
61^"34,17"^"OMA/Get Session Info Response/Failure"^50804^-1^0
|
||||
61^"34,18"^"OMA/Get Session Info Response/Retry"^50807^-1^0
|
||||
61^"34,19"^"OMA/Get Session Info Response/NIA"^50802^-1^0
|
||||
61^"35,2"^"OMA/Send Selection Response/Result Code"^50000^-1^0
|
||||
61^"36,2"^"OMA/Get Features Response/Result Code"^50000^-1^0
|
||||
61^"36,16"^"OMA/Get Features Response/Provisioning"^50809^-1^0
|
||||
61^"36,17"^"OMA/Get Features Response/PRL Update"^50810^-1^0
|
||||
61^"36,18"^"OMA/Get Features Response/HFA Feature"^50811^-1^0
|
||||
61^"36,19"^"OMA/Get Features Response/HFA Done State"^50812^-1^0
|
||||
61^"37,2"^"OMA/Set Features Response/Result Code"^50000^-1^0
|
||||
62^"1,16"^"OMA/Event Report/NIA"^50802^-1^0
|
||||
62^"1,17"^"OMA/Event Report/Status"^50803^-1^0
|
||||
62^"1,18"^"OMA/Event Report/Failure"^50804^-1^0
|
||||
63^"58,1"^"Voice/Initiate USSD Request/Info"^70000^-1^0
|
||||
63^"59,1"^"Voice/Answer USSD Request/Info"^70000^-1^0
|
||||
63^"67,1"^"Voice/Async Initiate USSD Request/Info"^70000^-1^0
|
||||
64^"58,2"^"Voice/Initiate USSD Response/Result Code"^50000^-1^0
|
||||
64^"58,16"^"Voice/Initiate USSD Response/Fail Cause"^70001^-1^0
|
||||
64^"58,17"^"Voice/Initiate USSD Response/Alpha ID"^70002^-1^0
|
||||
64^"58,18"^"Voice/Initiate USSD Response/Data"^70000^-1^0
|
||||
64^"59,2"^"Voice/Answer USSD Response/Result Code"^50000^-1^0
|
||||
64^"60,2"^"Voice/Cancel USSD Response/Result Code"^50000^-1^0
|
||||
64^"67,2"^"Voice/Async Initiate USSD Response/Result Code"^50000^-1^0
|
||||
65^"62,1"^"Voice/USSD Indication/Type"^70003^-1^0
|
||||
65^"62,16"^"Voice/USSD Indication/Data"^70000^-1
|
||||
65^"67,16"^"Voice/USSD Async Indication/Error"^70004^-1^0
|
||||
65^"67,17"^"Voice/USSD Async Indication/Fail Cause"^70001^-1^0
|
||||
65^"67,18"^"Voice/USSD Async Indication/Info"^70000^-1^0
|
||||
65^"67,19"^"Voice/USSD Async Indication/Alpha ID"^70002^-1^0
|
|
@ -0,0 +1,147 @@
|
|||
50000^"QMI Results"^-1^0
|
||||
50001^"QMI Errors"^-1^0
|
||||
50002^"QMI Data Bearer Technologies"^-1^0
|
||||
50003^"QMI Connection Status"^-1^0
|
||||
50004^"QMI Profile Types"^-1^0
|
||||
50005^"QMI PDP Types"^-1^0
|
||||
50006^"QMI Traffic Classes"^-1^0
|
||||
50007^"QMI QoS Delivery Orders"^-1^0
|
||||
50008^"QMI SDU Error Ratios"^-1^0
|
||||
50009^"QMI SDU Residual Bit Error Ratios"^-1^0
|
||||
50010^"QMI Erroneous SDU Deliveries"^-1^0
|
||||
50011^"QMI Dormancy Status"^-1^0
|
||||
50012^"QMI Call End Reasons"^-1^0
|
||||
50013^"QMI Mobile IP Modes"^-1^0
|
||||
50014^"QMI Call History Types"^-1^0
|
||||
50015^"QMI Call Types"^-1^0
|
||||
50016^"QMI HA/AAA Key States"^-1^0
|
||||
50017^"QMI WDS Network Types"^-1^0
|
||||
50018^"QMI WDS Extended Tech Prefs"^-1^0
|
||||
50019^"QMI WDS Call Types"^-1^0
|
||||
50020^"QMI WDS IP Families"^-1^0
|
||||
50021^"QMI WDS Mobile IP Call End Reasons"^-1^0
|
||||
50022^"QMI WDS Internal Call End Reasons"^-1^0
|
||||
50023^"QMI WDS Call Manager Call End Reasons"^-1^0
|
||||
50024^"QMI WDS 3GPP Call End Reasons"^-1^0
|
||||
50025^"QMI WDS Call End Reason Types"^-1^0
|
||||
50026^"QMI WDS Autoconnect Settings"^-1^0
|
||||
50027^"QMI WDS Autoconnect Roam Settings"^-1^0
|
||||
50028^"QMI PDP Access Control Flag"^-1^0
|
||||
50029^"QMI IP Version"^-1^0
|
||||
50030^"QMI Address Allocation Preference"^-1^0
|
||||
50031^"QMI QoS Class Identifier"^-1^0
|
||||
50032^"QMI Authentication Protocol"^-1^0
|
||||
50033^"QMI Data Rate"^-1^0
|
||||
50034^"QMI Application Type"^-1^0
|
||||
50035^"QMI Data Mode"^-1^0
|
||||
50036^"QMI PDN Type"^-1^0
|
||||
50037^"QMI Extended Error Code"^-1^0
|
||||
50100^"QMI Power Sources"^-1^0
|
||||
50101^"QMI Data Service Capabilities 1"^-1^0
|
||||
50102^"QMI DMS Radio Interfaces"^-1^0
|
||||
50103^"QMI DMS Activation States"^-1^0
|
||||
50104^"QMI DMS Operating Modes"^-1^0
|
||||
50105^"QMI DMS Timestamp Sources"^-1^0
|
||||
50106^"QMI DMS Activation Types"^-1^0
|
||||
50107^"QMI DMS Lock States"^-1^0
|
||||
50108^"QMI DMS PIN Status"^-1^0
|
||||
50109^"QMI DMS UIM Facility"^-1^0
|
||||
50110^"QMI DMS UIM Facility States"^-1^0
|
||||
50111^"QMI DMS UIM States"^-1^0
|
||||
50112^"QMI DMS Image Types"^-1^0
|
||||
50113^"QMI DMS Time References"^-1^0
|
||||
50200^"QMI NAS Radio Interfaces"^-1^0
|
||||
50201^"QMI In Use States"^-1^0
|
||||
50202^"QMI Roaming States"^-1^0
|
||||
50203^"QMI Forbidden States"^-1^0
|
||||
50204^"QMI Preferred States"^-1^0
|
||||
50205^"QMI Register Actions"^-1^0
|
||||
50206^"QMI Radio Access Technologies"^-1^0
|
||||
50207^"QMI PS Attach Actions"^-1^0
|
||||
50208^"QMI Registration States"^-1^0
|
||||
50209^"QMI CS/PS Attach States"^-1^0
|
||||
50210^"QMI Registered Networks"^-1^0
|
||||
50211^"QMI Roaming Indicators"^-1^0
|
||||
50212^"QMI Tech Pref Durations"^-1^0
|
||||
50213^"QMI Tech Prefs"^-1^0
|
||||
50214^"QMI Data Service Capabilities 2"^-1^0
|
||||
50215^"QMI NAS System Preferences"^-1^0
|
||||
50216^"QMI NAS Roaming Preferences"^-1^0
|
||||
50217^"QMI NAS Band Classes"^-1^0
|
||||
50218^"QMI NAS Service Domains"^-1^0
|
||||
50219^"QMI NAS AN-AAA Authentication Status"^-1^0
|
||||
50220^"QMI NAS SINR Levels"^-1^0
|
||||
50221^"QMI NAS PRL Preferences"^-1^0
|
||||
50222^"QMI NAS Roaming Preferences 2"^-1^0
|
||||
50223^"QMI NAS DDTM Preferences"^-1^0
|
||||
50224^"QMI NAS Service Option Actions"^-1^0
|
||||
50225^"QMI NAS Network Description Displays"^-1^0
|
||||
50226^"QMI NAS Network Description Encodings"^-1^0
|
||||
50227^"QMI NAS PLMN Name Encoding Schemes"^-1^0
|
||||
50228^"QMI NAS PLMN Name Country Initials"^-1^0
|
||||
50229^"QMI NAS PLMN Name Spare Bits"^-1^0
|
||||
50230^"QMI Change Duration"^-1^0
|
||||
50300^"QMI WMS Storage Types"^-1^0
|
||||
50301^"QMI WMS Message Formats"^-1^0
|
||||
50302^"QMI WMS Message Tags"^-1^0
|
||||
50303^"QMI WMS Message Protocols"^-1^0
|
||||
50304^"QMI WMS Message Types"^-1^0
|
||||
50305^"QMI WMS Message Classes"^-1^0
|
||||
50306^"QMI WMS Receipt Actions"^-1^0
|
||||
50307^"QMI WMS Route Values"^-1^0
|
||||
50308^"QMI WMS CDMA Service Options"^-1^0
|
||||
50309^"QMI WMS Error Classes"^-1^0
|
||||
50310^"QMI WMS Error Classes 2"^-1^0
|
||||
50311^"QMI WMS GSM/WCDMA Domains"^-1^0
|
||||
50400^"QMI PDS Tracking Session States"^-1^0
|
||||
50401^"QMI PDS Session Control Types"^-1^0
|
||||
50402^"QMI PDS Session Types"^-1^0
|
||||
50403^"QMI PDS Operation Types"^-1^0
|
||||
50404^"QMI PDS Server Options"^-1^0
|
||||
50405^"QMI PDS Output Devices"^-1^0
|
||||
50406^"QMI PDS NMEA Reporting Options"^-1^0
|
||||
50407^"QMI PDS Mediums"^-1^0
|
||||
50408^"QMI PDS WWAN Network Preferences"^-1^0
|
||||
50409^"QMI PDS NMEA Sentence Operating Modes"^-1^0
|
||||
50410^"QMI PDS Session Status"^-1^0
|
||||
50411^"QMI PDS Calendar Months"^-1^0
|
||||
50412^"QMI PDS Calendar Days"^-1^0
|
||||
50413^"QMI PDS Wi-Fi Request Types"^-1^0
|
||||
50414^"QMI PDS SV Systems"^-1^0
|
||||
50415^"QMI PDS SV Health Status"^-1^0
|
||||
50416^"QMI PDS SV Processing Status"^-1^0
|
||||
50417^"QMI PDS SV Ephemeris Status"^-1^0
|
||||
50418^"QMI PDS SV Almanac Status"^-1^0
|
||||
50419^"QMI PDS Privacy Modes"^-1^0
|
||||
50420^"QMI PDS VX Modes"^-1^0
|
||||
50421^"QMI PDS VX Data Coding Schemes"^-1^0
|
||||
50422^"QMI PDS SUPL Modes"^-1^0
|
||||
50423^"QMI PDS SUPL Data Coding Schemes"^-1^0
|
||||
50424^"QMI PDS SUPL ID/Name Data Coding Schemes"^-1^0
|
||||
50425^"QMI PDS UMTS CP Data Coding Schemes"^-1^0
|
||||
50426^"QMI PDS UMTS CP Location Types"^-1^0
|
||||
50427^"QMI PDS Comm Event Types"^-1^0
|
||||
50428^"QMI PDS Comm Event Protocols"^-1^0
|
||||
50429^"QMI PDS Injected Position Sources"^-1^0
|
||||
50430^"QMI PDS SBAS States"^-1^0
|
||||
50431^"QMI PDS Time Bases"^-1^0
|
||||
50432^"QMI PDS EFS File Operations"^-1^0
|
||||
50433^"QMI PDS ODP States"^-1^0
|
||||
50434^"QMI PDS Method States"^-1^0
|
||||
50435^"QMI Network Mode"^-1^0
|
||||
50600^"QMI CAT Alpha ID Command Type"^-1^0
|
||||
50601^"QMI CAT Refresh Stage"^-1^0
|
||||
50602^"QMI CAT Proactive Session End Type"^-1^0
|
||||
50603^"QMI CAT Envelope Command Type"^-1^0
|
||||
50700^"QMI AUTH EAP Result"^-1^0
|
||||
50800^"QMI OMA Session Types"^-1^0
|
||||
50801^"QMI OMA Session States"^-1^0
|
||||
50802^"QMI OMA Session Failure Reasons"^-1^0
|
||||
50803^"QMI OMA Selections"^-1^0
|
||||
50804^"QMI OMA HFA Done States"^-1^0
|
||||
50900^"QMI Service Types"^-1^0
|
||||
50901^"QMI Driver Data Formats"^-1^0
|
||||
50902^"QMI Power Save States "^-1^0
|
||||
70000^"USSD Data Coding Schemes"^-1^0
|
||||
70001^"USSD Alpha Coding Schemes"^-1^0
|
||||
70002^"USSD Notifcation Types"^-1^0
|
|
@ -0,0 +1,916 @@
|
|||
50000^0^"Success"
|
||||
50000^1^"Failure"
|
||||
50001^0^"None"
|
||||
50001^1^"Malformed Message"
|
||||
50001^2^"No Memory"
|
||||
50001^3^"Internal"
|
||||
50001^4^"Aborted"
|
||||
50001^5^"Client IDs Exhausted"
|
||||
50001^6^"Unabortable Transaction"
|
||||
50001^7^"Invalid Client ID"
|
||||
50001^8^"No Thresholds Provided"
|
||||
50001^9^"Invalid Handle"
|
||||
50001^10^"Invalid Profile"
|
||||
50001^11^"Invalid PIN ID"
|
||||
50001^12^"Incorrect PIN"
|
||||
50001^13^"No Network Found"
|
||||
50001^14^"Call Failed"
|
||||
50001^15^"Out Of Call"
|
||||
50001^16^"Not Provisioned"
|
||||
50001^17^"Missing Argument"
|
||||
50001^19^"Argument Too Long"
|
||||
50001^22^"Invalid Transaction ID"
|
||||
50001^23^"Device In Use"
|
||||
50001^24^"Network Unsupported"
|
||||
50001^25^"Device Unsupported"
|
||||
50001^26^"No Effect"
|
||||
50001^27^"No Free Profile"
|
||||
50001^28^"Invalid PDP Type"
|
||||
50001^29^"Invalid Technology Preference"
|
||||
50001^30^"Invalid Profile Type"
|
||||
50001^31^"Invalid Service Type"
|
||||
50001^32^"Invalid Register Action"
|
||||
50001^33^"Invalid PS Attach Action"
|
||||
50001^34^"Authentication Failed"
|
||||
50001^35^"PIN Blocked"
|
||||
50001^36^"PIN Always Blocked"
|
||||
50001^37^"UIM Uninitialized"
|
||||
50001^38^"Maximum QoS Requests In Use"
|
||||
50001^39^"Incorrect Flow Filter"
|
||||
50001^40^"Network QoS Unaware"
|
||||
50001^41^"Invalid QoS ID"
|
||||
50001^42^"QoS Unavailable"
|
||||
50001^43^"Flow Suspended"
|
||||
50001^46^"General Error"
|
||||
50001^47^"Unknown Error"
|
||||
50001^48^"Invalid Argument"
|
||||
50001^49^"Invalid Index"
|
||||
50001^50^"No Entry"
|
||||
50001^51^"Device Storage Full"
|
||||
50001^52^"Device Not Ready"
|
||||
50001^53^"Network Not Ready"
|
||||
50001^54^"WMS Cause Code"
|
||||
50001^55^"WMS Message Not Sent"
|
||||
50001^56^"WMS Message Delivery Failure"
|
||||
50001^57^"WMS Invalid Message ID"
|
||||
50001^58^"WMS Encoding"
|
||||
50001^59^"Authentication Lock"
|
||||
50001^60^"Invalid Transition"
|
||||
50001^65^"Session Inactive"
|
||||
50001^66^"Session Invalid"
|
||||
50001^67^"Session Ownership"
|
||||
50001^68^"Insufficient Resources"
|
||||
50001^69^"Disabled"
|
||||
50001^70^"Invalid Operation"
|
||||
50001^71^"Invalid QMI Command"
|
||||
50001^72^"WMS TPDU Type"
|
||||
50001^73^"WMS SMSC Address"
|
||||
50001^74^"Information Unavailable"
|
||||
50001^75^"Segment Too Long"
|
||||
50001^76^"Segment Order"
|
||||
50001^77^"Bundling Not Supported"
|
||||
50001^80^"SIM File Not Found"
|
||||
50001^82^"Access Denied"
|
||||
50001^83^"Hardware Restricted"
|
||||
50001^61441^"CAT Event Registration Failed"
|
||||
50001^61442^"CAT Invalid Terminal Response"
|
||||
50001^61443^"CAT Invalid Envelope Command"
|
||||
50001^61444^"CAT Envelope Command Busy"
|
||||
50001^61445^"CAT Envelope Command Failed"
|
||||
50002^1^"CDMA2000 1x"
|
||||
50002^2^"CDMA2000 1x Ev-DO Rev. 0"
|
||||
50002^3^"GPRS"
|
||||
50002^4^"WCDMA"
|
||||
50002^5^"CDMA2000 1x Ev-DO Rev. A"
|
||||
50002^6^"EGPRS"
|
||||
50002^7^"HSDPA/WCDMA"
|
||||
50002^8^"WCDMA/HSUPA"
|
||||
50002^9^"HSDPA/HSUPA"
|
||||
50002^10^"LTE"
|
||||
50002^11^"CDMA2000 EHRPD"
|
||||
50003^1^"Disconnected"
|
||||
50003^2^"Connected"
|
||||
50003^3^"Suspended"
|
||||
50003^4^"Authenticating"
|
||||
50004^0^"3GPP"
|
||||
50004^1^"3GPP2"
|
||||
50005^0^"PDP-IP (V4)"
|
||||
50006^0^"Subscribed"
|
||||
50006^1^"Conversational"
|
||||
50006^2^"Streaming"
|
||||
50006^3^"Interactive"
|
||||
50006^4^"Background"
|
||||
50007^0^"Subscribe"
|
||||
50007^1^"Delivery Order On"
|
||||
50007^2^"Delivery Order Off"
|
||||
50008^0^"Subscribe"
|
||||
50008^1^"1 x 10-2"
|
||||
50008^2^"7 x 10-3"
|
||||
50008^3^"1 x 10-3"
|
||||
50008^4^"1 x 10-4"
|
||||
50008^5^"1 x 10-5"
|
||||
50008^6^"1 x 10-6"
|
||||
50008^7^"1 x 10-1"
|
||||
50009^0^"Subscribe"
|
||||
50009^1^"5 x 10-2"
|
||||
50009^2^"1 x 10-2"
|
||||
50009^3^"5 x 10-3"
|
||||
50009^4^"4 x 10-3"
|
||||
50009^5^"1 x 10-3"
|
||||
50009^6^"1 x 10-4"
|
||||
50009^7^"1 x 10-5"
|
||||
50009^8^"1 x 10-6"
|
||||
50009^9^"6 x 10-8"
|
||||
50010^0^"Subscribe"
|
||||
50010^1^"No Detection"
|
||||
50010^2^"Erroneous SDU Is Delivered"
|
||||
50010^3^"Erroneous SDU Is Not Delivered"
|
||||
50011^1^"Traffic Channel Dormant"
|
||||
50011^2^"Traffic Channel Active"
|
||||
50012^1^"Unspecified"
|
||||
50012^2^"Client End"
|
||||
50012^3^"No Service"
|
||||
50012^4^"Fade"
|
||||
50012^5^"Release Normal"
|
||||
50012^6^"Acc In Progress"
|
||||
50012^7^"Acc Failed"
|
||||
50012^8^"Redirect Or Handoff"
|
||||
50012^9^"Close In Progress"
|
||||
50012^10^"Authentication Failed"
|
||||
50012^11^"Internal Error"
|
||||
50012^500^"CDMA Lock"
|
||||
50012^501^"Intercept"
|
||||
50012^502^"Reorder"
|
||||
50012^503^"Release Service Option Rejected"
|
||||
50012^504^"Incoming Call"
|
||||
50012^505^"Alert Stop"
|
||||
50012^506^"Activation"
|
||||
50012^507^"Max Access Probe"
|
||||
50012^508^"CCS Not Supported By BS"
|
||||
50012^509^"No Response From BS"
|
||||
50012^510^"Rejected By BS"
|
||||
50012^511^"Incompatible"
|
||||
50012^512^"Already In TC"
|
||||
50012^513^"User Call Orig During GPS"
|
||||
50012^514^"User Call Orig During SMS"
|
||||
50012^515^"No CDMA Service"
|
||||
50012^1000^"Conf Failed"
|
||||
50012^1001^"Incoming Rejected"
|
||||
50012^1002^"No GW Service"
|
||||
50012^1003^"Network End"
|
||||
50012^1004^"LLC Or SNDCP Failure"
|
||||
50012^1005^"Insufficient Resources"
|
||||
50012^1006^"Service Option Out Of order"
|
||||
50012^1007^"NSAPI Already Used"
|
||||
50012^1008^"Regular PDP Context Deactivation"
|
||||
50012^1009^"Network Failure"
|
||||
50012^1010^"Reactivation Requested"
|
||||
50012^1011^"Protocol Error"
|
||||
50012^1012^"Operator Determined Barring"
|
||||
50012^1013^"Unknown Or Missing APN"
|
||||
50012^1014^"Unknown PDP Address Or PDP Type"
|
||||
50012^1015^"Activation Rejected By GGSN"
|
||||
50012^1016^"Activation Rejected, Unspecified"
|
||||
50012^1017^"Service Option Not Supported"
|
||||
50012^1018^"Requested Service Option Not Subscribed"
|
||||
50012^1019^"QoS Not Accepted"
|
||||
50012^1020^"Semantic Error In The TFT Operation"
|
||||
50012^1021^"Syntactical Error In The TFT Operation"
|
||||
50012^1022^"Unknown PDP Context"
|
||||
50012^1023^"Semantic Errors In Packet Filter(s)"
|
||||
50012^1024^"Syntactical Errors In Packet Filter(s)"
|
||||
50012^1025^"PDP Context Without TFT Already Activated"
|
||||
50012^1026^"Invalid Transaction Identifier Value"
|
||||
50012^1027^"Semantically Incorrect Message"
|
||||
50012^1028^"Invalid Mandatory Information"
|
||||
50012^1029^"Message Type Non-Existent"
|
||||
50012^1030^"Message Not Compatible With State"
|
||||
50012^1031^"Information Element Nonexistent "
|
||||
50012^1032^"Conditional Information Element Error"
|
||||
50012^1033^"Message Not Compatible With Protocol State"
|
||||
50012^1034^"APN Restriction Value Incompatible With Active PDP Context"
|
||||
50012^1035^"No GPRS Context Present"
|
||||
50012^1036^"Requested Feature Not Supported"
|
||||
50012^1500^"CD Gen Or Busy"
|
||||
50012^1501^"CD Bill Or Auth"
|
||||
50012^1502^"Change HDR"
|
||||
50012^1503^"Exit HDR"
|
||||
50012^1504^"HDR No Session"
|
||||
50012^1505^"HDR Orig During GPS Fix"
|
||||
50012^1506^"HDR CS Timeout"
|
||||
50012^1507^"HDR Released By CM"
|
||||
50013^0^"MIP Off (Simple IP Only)"
|
||||
50013^1^"MIP Preferred"
|
||||
50013^2^"MIP Only"
|
||||
50014^0^"Full"
|
||||
50014^1^"IDs Only"
|
||||
50015^0^"NDIS"
|
||||
50015^1^"DUN"
|
||||
50016^0^"Unset"
|
||||
50016^1^"Set, Default"
|
||||
50016^2^"Set, Modified"
|
||||
50017^0^"Unknown"
|
||||
50017^1^"CDMA"
|
||||
50017^2^"UMTS"
|
||||
50018^0x8001^"CDMA"
|
||||
50018^0x8004^"UMTS"
|
||||
50019^0^"Laptop"
|
||||
50019^1^"Embedded"
|
||||
50020^4^"IPv4"
|
||||
50020^6^"IPv6"
|
||||
50020^8^"Unspecified"
|
||||
50021^64^"FA Unspecified"
|
||||
50021^65^"FA Administratively Prohibited"
|
||||
50021^66^"FA Insufficient Resources"
|
||||
50021^67^"FA Mobile Node Authentication Failure"
|
||||
50021^68^"FA HA Authentication Failure"
|
||||
50021^69^"FA Requested Lifetime Too Long"
|
||||
50021^70^"FA Malformed Request"
|
||||
50021^71^"FA Malformed Reply"
|
||||
50021^72^"FA Encapsulation Unavailable"
|
||||
50021^73^"FA VJHC Unavailable"
|
||||
50021^74^"FA Reverse Tunnel Unavailable"
|
||||
50021^75^"FA Reverse Tunnel Is Mandatory And T Bit Is Not Set"
|
||||
50021^79^"FA Delivery Style Not Supported"
|
||||
50021^97^"FA Missing NAI"
|
||||
50021^98^"FA Missing HA"
|
||||
50021^99^"FA Missing Home Address"
|
||||
50021^104^"FA Unknown Challenge"
|
||||
50021^105^"FA Missing Challenge"
|
||||
50021^106^"FA Stale Challenge"
|
||||
50021^128^"HA Reason Unspecified"
|
||||
50021^129^"HA Administratively Prohibited"
|
||||
50021^130^"HA Insufficient Resources"
|
||||
50021^131^"HA Mobile Node Authentication Failure"
|
||||
50021^132^"HA FA Authentication Failure"
|
||||
50021^133^"HA Registration ID Mismatch"
|
||||
50021^134^"HA Malformed Request"
|
||||
50021^136^"HA Unknown HA Address"
|
||||
50021^137^"HA Reverse Tunnel Unavailable"
|
||||
50021^138^"HA Reverse Tunnel Is Mandatory And T Bit Is Not Set"
|
||||
50021^139^"HA Encapsulation Unavailable"
|
||||
50021^65535^"Unknown"
|
||||
50022^201^"Internal"
|
||||
50022^202^"Call Ended"
|
||||
50022^203^"Internal Unknown Cause Code"
|
||||
50022^204^"Unknown Cause Code"
|
||||
50022^205^"Close In Progress"
|
||||
50022^206^"NW Initiated Termination"
|
||||
50022^207^"App Preempted"
|
||||
50023^500^"CDMA Lock"
|
||||
50023^501^"Intercept"
|
||||
50023^502^"Reorder"
|
||||
50023^503^"Release Service Option Reject"
|
||||
50023^504^"Incoming Call"
|
||||
50023^505^"Alert Stop"
|
||||
50023^506^"Activation"
|
||||
50023^507^"Max Access Probe"
|
||||
50023^508^"CCS Not Supported By BS"
|
||||
50023^509^"No Response From BS"
|
||||
50023^510^"Rejected By BS"
|
||||
50023^511^"Incompatible"
|
||||
50023^512^"Already In TC"
|
||||
50023^513^"User Call Orig During GPS"
|
||||
50023^514^"User Call Orig During SMS"
|
||||
50023^515^"No CDMA Service"
|
||||
50023^1000^"Conf Failed"
|
||||
50023^1001^"Incoming Rejected"
|
||||
50023^1002^"No GW Service"
|
||||
50023^1003^"No GPRS Context"
|
||||
50023^1004^"Illegal MS"
|
||||
50023^1005^"Illegal ME"
|
||||
50023^1006^"GPRS Services And Non-GPRS Service Not Allowed"
|
||||
50023^1007^"GPRS Services Not Allowed"
|
||||
50023^1008^"MS Identity Cannot Be Derived By The Network"
|
||||
50023^1009^"Implicitly Detached"
|
||||
50023^1010^"PLMN Not Allowed"
|
||||
50023^1011^"LA Not Allowed"
|
||||
50023^1012^"GPRS Services Not Allowed In This PLMN"
|
||||
50023^1013^"PDP Duplicate"
|
||||
50023^1014^"UE RAT Change"
|
||||
50023^1015^"Congestion"
|
||||
50023^1016^"No PDP Context Activated"
|
||||
50023^1017^"Access Class DSAC Rejection"
|
||||
50023^1500^"CD Gen Or Busy"
|
||||
50023^1501^"CD Bill Or Auth"
|
||||
50023^1502^"Change HDR"
|
||||
50023^1503^"Exit HDR"
|
||||
50023^1504^"HDR No Session"
|
||||
50023^1505^"HDR Orig During GPS Fix"
|
||||
50023^1506^"HDR CS Timeout"
|
||||
50023^1507^"HDR Released By CM"
|
||||
50023^2000^"Client End"
|
||||
50023^2001^"No Service"
|
||||
50023^2002^"Fade"
|
||||
50023^2003^"Normal Release"
|
||||
50023^2004^"Access In Progress"
|
||||
50023^2005^"Access Fail"
|
||||
50023^2006^"Redirect Or Handoff"
|
||||
50024^8^"Operator Determined Barring"
|
||||
50024^25^"LLC SNDCP Failure"
|
||||
50024^26^"Insufficient Resources"
|
||||
50024^27^"Unknown APN"
|
||||
50024^28^"Unknown PDP"
|
||||
50024^29^"Authentication FAiled"
|
||||
50024^30^"GGSN Reject"
|
||||
50024^31^"Activation Reject"
|
||||
50024^32^"Option Not Supported"
|
||||
50024^33^"Option Unsubscribed"
|
||||
50024^34^"Option Temporarily OOO"
|
||||
50024^35^"NSAPI Already Used"
|
||||
50024^36^"Regular Deactivation"
|
||||
50024^37^"QoS Not Accepted"
|
||||
50024^38^"Network Failure"
|
||||
50024^39^"UMTS Reactivation Request"
|
||||
50024^40^"Feature Not Supported"
|
||||
50024^41^"TFT Semantic Error"
|
||||
50024^42^"TFT Syntax Error"
|
||||
50024^43^"Unknown PDP Context"
|
||||
50024^44^"Filter Semantic Error"
|
||||
50024^45^"Filter Syntax Error"
|
||||
50024^46^"PDP Without Active TFT"
|
||||
50024^81^"Invalid Transaction ID"
|
||||
50024^95^"Message Incorrect Semantic"
|
||||
50024^96^"Invalid Mandatory ID"
|
||||
50024^97^"Message Type Unsupported"
|
||||
50024^98^"Message Type Noncompatible State"
|
||||
50024^99^"Unknown Info Element"
|
||||
50024^100^"Conditional Info Element Error"
|
||||
50024^101^"Message And Protocol State Uncompatible"
|
||||
50024^111^"Protocol Error"
|
||||
50024^112^"APN Type Conflict"
|
||||
50025^1^"Mobile IP"
|
||||
50025^2^"Internal"
|
||||
50025^3^"Call Manager Defined"
|
||||
50025^6^"3GPP Specification Defined"
|
||||
50026^0^"Disabled"
|
||||
50026^1^"Enabled"
|
||||
50026^2^"Paused"
|
||||
50027^0^"Always"
|
||||
50027^1^"Home Only"
|
||||
50028^0^"PDP Access Control None"
|
||||
50028^1^"PDP Access Control Reject"
|
||||
50028^2^"PDP Access Control Permission"
|
||||
50029^4^"IPv4"
|
||||
50029^6^"IPv6"
|
||||
50030^0^"NAS signaling"
|
||||
50030^1^"DHCP"
|
||||
50031^0^"Network Assign QCI"
|
||||
50031^1^"Guaranteed Bitrate"
|
||||
50031^2^"Guaranteed Bitrate"
|
||||
50031^3^"Guaranteed Bitrate"
|
||||
50031^4^"Guaranteed Bitrate"
|
||||
50031^5^"Non Guaranteed Bitrate"
|
||||
50031^6^"Non Guaranteed Bitrate"
|
||||
50031^7^"Non Guaranteed Bitrate"
|
||||
50031^8^"Non Guaranteed Bitrate"
|
||||
50032^1^"PAP"
|
||||
50032^2^"CHAP"
|
||||
50032^3^"PAP or CHAP"
|
||||
50033^0^"Low (SO15 Only)"
|
||||
50033^1^"Medium (SO33 + low R-SCH)"
|
||||
50033^2^"High (SO33 + high R-SCH)"
|
||||
50034^0^"Default Application Type"
|
||||
50034^32^"LBS Application Type"
|
||||
50034^64^"Tethered Application Type"
|
||||
50035^0^"CDMA or HDR"
|
||||
50035^1^"CDMA Only"
|
||||
50035^2^"HDR Only"
|
||||
50036^0^"IPv4 PDN Type"
|
||||
50036^1^"IPv6 PDN Type"
|
||||
50036^2^"IPv4 or IPv6 PDN Type"
|
||||
50036^3^"Unspecified PDN Type"
|
||||
50037^1^"Failure"
|
||||
50037^2^"Invalid handle"
|
||||
50037^3^"Invalid Operation"
|
||||
50037^4^"Invalid Profile Type"
|
||||
50037^5^"Invalid Profile Number"
|
||||
50037^6^"Invalid Identifier"
|
||||
50037^7^"Invalid Argument"
|
||||
50037^8^"Not Initialized"
|
||||
50037^9^"Invalid Length"
|
||||
50037^10^"List End"
|
||||
50037^11^"Invalid Subscription ID"
|
||||
50037^12^"Invalid Profile Family"
|
||||
50037^1001^"3GPP Invalid Profile Family"
|
||||
50037^1002^"3GPP Access Error"
|
||||
50037^1003^"3GPP Context Not Defined"
|
||||
50037^1004^"3GPP Valid Flag Not Set"
|
||||
50037^1005^"3GPP Read Only Flag Set"
|
||||
50037^1006^"3GPP Error Max Profile Number"
|
||||
50037^1101^"3GPP2 Error Invalid Identifier For Profile"
|
||||
50100^0^"Battery"
|
||||
50100^1^"External"
|
||||
50101^0^"No Data Services Supported"
|
||||
50101^1^"Only Circuit Switched"
|
||||
50101^2^"Only Packet Switched"
|
||||
50101^3^"Simultaneous Circuit/Packet Switched"
|
||||
50101^4^"Nonsimultaneous Circuit/Packet Switched"
|
||||
50102^1^"CDMA2000 1x"
|
||||
50102^2^"CDMA2000 HRPD"
|
||||
50102^4^"GSM"
|
||||
50102^5^"UMTS"
|
||||
50102^8^"LTE"
|
||||
50103^0^"Service Not Activated"
|
||||
50103^1^"Serivce Activated"
|
||||
50103^2^"Activation Connecting"
|
||||
50103^3^"Activation In Progress"
|
||||
50103^4^"OTASP Security Authenticated"
|
||||
50103^5^"OTASP NAM Downloaded"
|
||||
50103^6^"OTASP MDN Downloaded"
|
||||
50103^7^"OTASP IMSI Downloaded"
|
||||
50103^8^"OTASP PRL Downloaded"
|
||||
50103^9^"OTASP SPC Downloaded"
|
||||
50103^10^"OTASP Settings Committed"
|
||||
50104^0^"Online"
|
||||
50104^1^"Low Power"
|
||||
50104^2^"Factory Test Mode"
|
||||
50104^3^"Offline"
|
||||
50104^4^"Reset"
|
||||
50104^5^"Shutdown"
|
||||
50104^6^"Persistent Low Power"
|
||||
50104^7^"Mode-Only Low Power"
|
||||
50105^0^"Device"
|
||||
50105^1^"CDMA Network"
|
||||
50105^2^"CDMA 1xEV-DO Network"
|
||||
50105^3^"GSM Network"
|
||||
50105^4^"WCDMA Network"
|
||||
50105^5^"GPS Network"
|
||||
50105^6^"MFLO Network"
|
||||
50106^0^"OTASP"
|
||||
50107^0^"Lock Disabled"
|
||||
50107^1^"Lock Enabled"
|
||||
50108^0^"PIN Uninitialized"
|
||||
50108^1^"PIN Enabled, Unverified"
|
||||
50108^2^"PIN Enabled, Verified"
|
||||
50108^3^"PIN Disabled"
|
||||
50108^4^"PIN Blocked"
|
||||
50108^5^"PIN Blocked Permanently"
|
||||
50108^6^"PIN Unblocked"
|
||||
50108^7^"PIN Changed"
|
||||
50109^0^"PN - Network Personalization"
|
||||
50109^1^"PU - Network Subset Personalization"
|
||||
50109^2^"PP - Service Provider Personalization"
|
||||
50109^3^"PC - Corporate Personalization"
|
||||
50109^4^"PF - UIM Personalization"
|
||||
50110^0^"Deactivated"
|
||||
50110^1^"Activated"
|
||||
50110^2^"Block"
|
||||
50111^0^"Initialization Completed"
|
||||
50111^1^"Initialization Failed"
|
||||
50111^2^"Not Present"
|
||||
50111^255^"State Unavailable"
|
||||
50112^0^"Modem"
|
||||
50112^1^"PRI"
|
||||
50113^0^"User"
|
||||
50200^0^"None (No Service)"
|
||||
50200^1^"CDMA2000 1x"
|
||||
50200^2^"CDMA2000 HRPD"
|
||||
50200^3^"AMPS"
|
||||
50200^4^"GSM"
|
||||
50200^5^"UMTS"
|
||||
50200^8^"LTE"
|
||||
50201^0^"Unknown"
|
||||
50201^1^"Current Serving"
|
||||
50201^2^"Available"
|
||||
50202^0^"Unknown"
|
||||
50202^1^"Home"
|
||||
50202^2^"Roam"
|
||||
50203^0^"Unknown"
|
||||
50203^1^"Forbidden"
|
||||
50203^2^"Not Forbidden"
|
||||
50204^0^"Unknown"
|
||||
50204^1^"Preferred"
|
||||
50204^2^"Not Preferred"
|
||||
50205^1^"Automatic"
|
||||
50205^2^"Manual"
|
||||
50206^4^"GSM"
|
||||
50206^5^"UMTS"
|
||||
50206^8^"LTE"
|
||||
50207^1^"Attach"
|
||||
50207^2^"Detach"
|
||||
50208^0^"NAS Not Registered"
|
||||
50208^1^"NAS Registered"
|
||||
50208^2^"NAS Not Registered (Searching)"
|
||||
50208^3^"NAS Registration Denied"
|
||||
50208^4^"Registration State Unknown"
|
||||
50209^0^"Unknown/Not Applicable"
|
||||
50209^1^"Attached"
|
||||
50209^2^"Detached"
|
||||
50210^0^"Unknown"
|
||||
50210^1^"3GPP2"
|
||||
50210^2^"3GPP"
|
||||
50211^0^"Roaming"
|
||||
50211^1^"Home"
|
||||
50211^2^"Roaming (Partner)"
|
||||
50212^0^"Permanent"
|
||||
50212^1^"Power Cycle"
|
||||
50213^0^"Automatic"
|
||||
50213^1^"3GPP2"
|
||||
50213^2^"3GPP"
|
||||
50213^3^"Invalid"
|
||||
50214^1^"GPRS"
|
||||
50214^2^"EGPRS"
|
||||
50214^3^"HSDPA"
|
||||
50214^4^"HSUPA"
|
||||
50214^5^"WCDMA"
|
||||
50214^6^"CDMA"
|
||||
50214^7^"CDMA 1xEV-DO Rev. 0"
|
||||
50214^8^"CDMA 1xEV-DO Rev. A"
|
||||
50214^9^"GSM"
|
||||
50214^10^"CDMA 1xEV-DO Rev. B"
|
||||
50214^11^"LTE"
|
||||
50214^12^"HSDPA+"
|
||||
50214^13^"DC-HSDPA+"
|
||||
50215^0^"Automatic"
|
||||
50215^1^"Automatic A"
|
||||
50215^2^"Automatic B"
|
||||
50216^0^"Automatic"
|
||||
50216^1^"Home Only"
|
||||
50216^2^"Roaming Only"
|
||||
50216^3^"Home/Roaming"
|
||||
50217^0^"CDMA Band Class 0"
|
||||
50217^1^"CDMA Band Class 1"
|
||||
50217^3^"CDMA Band Class 3"
|
||||
50217^4^"CDMA Band Class 4"
|
||||
50217^5^"CDMA Band Class 5"
|
||||
50217^6^"CDMA Band Class 6"
|
||||
50217^7^"CDMA Band Class 7"
|
||||
50217^8^"CDMA Band Class 8"
|
||||
50217^9^"CDMA Band Class 9"
|
||||
50217^10^"CDMA Band Class 10"
|
||||
50217^11^"CDMA Band Class 11"
|
||||
50217^12^"CDMA Band Class 12"
|
||||
50217^13^"CDMA Band Class 13"
|
||||
50217^14^"CDMA Band Class 14"
|
||||
50217^15^"CDMA Band Class 15"
|
||||
50217^16^"CDMA Band Class 16"
|
||||
50217^40^"GSM 450"
|
||||
50217^41^"GSM 480"
|
||||
50217^42^"GSM 750"
|
||||
50217^43^"GSM 850"
|
||||
50217^44^"GSM 900 (Extended)"
|
||||
50217^45^"GSM 900 (Primary)"
|
||||
50217^46^"GSM 900 (Railways)"
|
||||
50217^47^"GSM 1800"
|
||||
50217^48^"GSM 1900"
|
||||
50217^80^"WCDMA 2100"
|
||||
50217^81^"WCDMA PCS 1900"
|
||||
50217^82^"WCDMA DCS 1800"
|
||||
50217^83^"WCDMA 1700 (US)"
|
||||
50217^84^"WCDMA 850"
|
||||
50217^85^"WCDMA 800"
|
||||
50217^86^"WCDMA 2600"
|
||||
50217^87^"WCDMA 900"
|
||||
50217^88^"WCDMA 1700 (Japan)"
|
||||
50217^120^"E-UTRA Band 1"
|
||||
50217^121^"E-UTRA Band 2"
|
||||
50217^122^"E-UTRA Band 3"
|
||||
50217^123^"E-UTRA Band 4"
|
||||
50217^124^"E-UTRA Band 5"
|
||||
50217^125^"E-UTRA Band 6"
|
||||
50217^126^"E-UTRA Band 7"
|
||||
50217^127^"E-UTRA Band 8"
|
||||
50217^128^"E-UTRA Band 9"
|
||||
50217^129^"E-UTRA Band 10"
|
||||
50217^130^"E-UTRA Band 11"
|
||||
50217^131^"E-UTRA Band 12"
|
||||
50217^132^"E-UTRA Band 13"
|
||||
50217^133^"E-UTRA Band 14"
|
||||
50217^134^"E-UTRA Band 17"
|
||||
50217^135^"E-UTRA Band 33"
|
||||
50217^136^"E-UTRA Band 34"
|
||||
50217^137^"E-UTRA Band 35"
|
||||
50217^138^"E-UTRA Band 36"
|
||||
50217^139^"E-UTRA Band 37"
|
||||
50217^140^"E-UTRA Band 38"
|
||||
50217^141^"E-UTRA Band 39"
|
||||
50217^142^"E-UTRA Band 40"
|
||||
50218^1^"Circuit Switched"
|
||||
50219^0^"Authentication Failed"
|
||||
50219^1^"Authentication Success"
|
||||
50219^2^"No Authentication Requested"
|
||||
50220^0^"-9 dB"
|
||||
50220^1^"-6 dB"
|
||||
50220^2^"-4.5 dB"
|
||||
50220^3^"-3 dB"
|
||||
50220^4^"-2 dB"
|
||||
50220^5^"1 dB"
|
||||
50220^6^"3 dB"
|
||||
50220^7^"6 dB"
|
||||
50220^8^"9 dB"
|
||||
50221^1^"Acquire A Side Only"
|
||||
50221^2^"Acquire B Side Only"
|
||||
50221^16383^"Acquire Any"
|
||||
50222^1^"Acquire When Roaming Indicator Off"
|
||||
50222^2^"Acquire When Roaming Indicator Not Off"
|
||||
50222^3^"Acquire When Roaming Indicator Not Flashing"
|
||||
50222^255^"Acquire Any"
|
||||
50223^0^"Off"
|
||||
50223^1^"On"
|
||||
50223^2^"No Change"
|
||||
50224^0^"Add"
|
||||
50224^1^"Replace"
|
||||
50224^2^"Delete"
|
||||
50224^3^"No Change"
|
||||
50225^0^"Do Not Display"
|
||||
50225^1^"Display"
|
||||
50225^255^"Unknown"
|
||||
50226^0^"Unspecified Octet"
|
||||
50226^1^"Extended Protocol Message"
|
||||
50226^2^"7-Bit ASCII"
|
||||
50226^3^"IA5"
|
||||
50226^4^"UNICODE"
|
||||
50226^5^"Shift-JIS"
|
||||
50226^6^"Korean"
|
||||
50226^7^"Latin/Hebrew"
|
||||
50226^8^"Latin"
|
||||
50226^9^"GSM 7-Bit"
|
||||
50226^10^"GSM DCS"
|
||||
50227^0^"ASCII"
|
||||
50227^1^"UCS2-LE"
|
||||
50228^0^"Do Not Add Country Initials"
|
||||
50228^1^"Add Country Initials"
|
||||
50228^255^"Unspecified"
|
||||
50229^0^"Unknown"
|
||||
50229^1^"Bit 8"
|
||||
50229^2^"Bits 7/8"
|
||||
50229^3^"Bits 6 - 8"
|
||||
50229^4^"Bits 5 - 8"
|
||||
50229^5^"Bits 4 - 8"
|
||||
50229^6^"Bits 3 - 8"
|
||||
50229^7^"Bits 2 - 8"
|
||||
50230^0^"Power Cycle"
|
||||
50230^1^"Permanent"
|
||||
50300^0^"UIM"
|
||||
50300^1^"NV"
|
||||
50300^2^"Unknown"
|
||||
50301^0^"CDMA"
|
||||
50301^1^"Analog CLI (Unsupported)"
|
||||
50301^2^"Analog Voice Mail (Unsupported)"
|
||||
50301^3^"Analog WMS (Unsupported)"
|
||||
50301^4^"Analog AWI/WMS (Unsupported)"
|
||||
50301^5^"MWI (Unsupported)"
|
||||
50301^6^"GSM/WCDMA PP"
|
||||
50301^7^"GSM/WCDMA BC"
|
||||
50301^8^"MWI"
|
||||
50302^0^"MT Read"
|
||||
50302^1^"MT Not Read"
|
||||
50302^2^"MO Send"
|
||||
50302^3^"MO Not Sent"
|
||||
50303^0^"CDMA"
|
||||
50303^1^"GSM/WCDMA (Unsupported)"
|
||||
50304^0^"Point-To-Point"
|
||||
50304^1^"Broadcast"
|
||||
50305^0^"Class 0"
|
||||
50305^1^"Class 1"
|
||||
50305^2^"Class 2"
|
||||
50305^3^"Class 3"
|
||||
50305^4^"Class None"
|
||||
50305^5^"Class CDMA"
|
||||
50306^0^"Discard"
|
||||
50306^1^"Store And Notify"
|
||||
50307^0^"Discard"
|
||||
50307^1^"Store And Notify"
|
||||
50307^2^"Unknown"
|
||||
50308^0^"Automatic"
|
||||
50308^6^"SO 6"
|
||||
50308^14^"SO 14"
|
||||
50309^0^"Temporary"
|
||||
50309^1^"Permanent"
|
||||
50310^2^"Temporary"
|
||||
50310^3^"Permanent"
|
||||
50311^0^"CS Preferred"
|
||||
50311^1^"PS Preferred"
|
||||
50311^2^"CS Only"
|
||||
50311^3^"PS Only"
|
||||
50400^0^"Unknown"
|
||||
50400^1^"Inactive"
|
||||
50400^2^"Active"
|
||||
50401^0^"Manual"
|
||||
50402^0^"New"
|
||||
50403^0^"Standalone"
|
||||
50403^1^"MS Based"
|
||||
50403^2^"MS Assisted"
|
||||
50404^0^"Default"
|
||||
50405^0^"None (Disabled)"
|
||||
50405^1^"USB"
|
||||
50405^2^"UART1"
|
||||
50405^3^"UART2"
|
||||
50405^4^"Shared Memory"
|
||||
50406^0^"1 Hz From Time Requested Until Final Position Determination"
|
||||
50406^1^"Final Position Determination Only"
|
||||
50407^0^"WWAN"
|
||||
50408^0^"Any Available"
|
||||
50408^1^"Home Only"
|
||||
50408^2^"Roam Only"
|
||||
50409^0^"Standalone"
|
||||
50409^1^"MS Based"
|
||||
50409^2^"MS Assisted"
|
||||
50409^255^"Unknown"
|
||||
50410^0^"Success"
|
||||
50410^1^"In Progress"
|
||||
50410^2^"General Failure"
|
||||
50410^3^"Timeout"
|
||||
50410^4^"User Ended"
|
||||
50410^5^"Bad Parameter"
|
||||
50410^6^"Phone Offline"
|
||||
50410^7^"Engine Locked"
|
||||
50410^8^"E911 Session In Progress"
|
||||
50411^0^"January"
|
||||
50411^1^"February"
|
||||
50411^2^"March"
|
||||
50411^3^"April"
|
||||
50411^4^"May"
|
||||
50411^5^"June"
|
||||
50411^6^"July"
|
||||
50411^7^"August"
|
||||
50411^8^"September"
|
||||
50411^9^"October"
|
||||
50411^10^"November"
|
||||
50411^11^"December"
|
||||
50412^0^"Sunday"
|
||||
50412^1^"Monday"
|
||||
50412^2^"Tuesday"
|
||||
50412^3^"Wednesday"
|
||||
50412^4^"Thursday"
|
||||
50412^5^"Friday"
|
||||
50412^6^"Saturday"
|
||||
50413^0^"Start Periodic Fixes - High Frequency"
|
||||
50413^1^"Start Periodic Fixes - Keep Warm"
|
||||
50413^2^"Stop Periodic Fixes"
|
||||
50413^4^"Suspend"
|
||||
50414^1^"GPS"
|
||||
50414^2^"Galileo"
|
||||
50414^3^"SBAS"
|
||||
50414^4^"Compass"
|
||||
50414^5^"Glonass"
|
||||
50415^0^"Unhealthy"
|
||||
50415^1^"Healthy"
|
||||
50416^1^"Idle"
|
||||
50416^2^"Search"
|
||||
50416^3^"Search Verify"
|
||||
50416^4^"Bit Edge"
|
||||
50416^5^"Track"
|
||||
50417^0^"Unavailable"
|
||||
50417^1^"Available"
|
||||
50418^0^"Unavailable"
|
||||
50418^1^"Available"
|
||||
50419^0^"No Notify/Verify"
|
||||
50419^1^"Notify"
|
||||
50419^2^"Notify/Verify - Allow No Response"
|
||||
50419^3^"Notify/Verify - Require Response"
|
||||
50419^4^"Privacy Override"
|
||||
50420^0^"MS Assisted"
|
||||
50420^1^"MS Based"
|
||||
50420^2^"MS Assisted Preferred"
|
||||
50420^3^"MS Based Preferred"
|
||||
50421^0^"Octet"
|
||||
50421^1^"EXN Protocol Message"
|
||||
50421^2^"ASCII"
|
||||
50421^3^"IA5"
|
||||
50421^4^"Unicode"
|
||||
50421^5^"Shift JIS"
|
||||
50421^6^"Korean"
|
||||
50421^7^"Latin Hebrew"
|
||||
50421^8^"Latin"
|
||||
50421^9^"GSM"
|
||||
50422^0^"MS Assisted"
|
||||
50422^1^"MS Based"
|
||||
50422^2^"MS Assisted Preferred"
|
||||
50422^3^"MS Based Preferred"
|
||||
50422^4^"Standalone"
|
||||
50422^5^"AFLT"
|
||||
50422^6^"ECID"
|
||||
50422^7^"EOTD"
|
||||
50422^8^"OTDOA"
|
||||
50422^9^"No Position"
|
||||
50423^0^"UTF8"
|
||||
50423^1^"UCS2"
|
||||
50423^2^"GSM"
|
||||
50423^255^"Unknown"
|
||||
50424^0^"Logical Name"
|
||||
50424^1^"Email Address"
|
||||
50424^2^"MSISDN"
|
||||
50424^3^"URL"
|
||||
50424^4^"SIP URL"
|
||||
50424^5^"MIN"
|
||||
50424^6^"MDN"
|
||||
50424^255^"Unknown"
|
||||
50425^0^"German"
|
||||
50425^1^"English"
|
||||
50425^2^"Italian"
|
||||
50425^3^"French"
|
||||
50425^4^"Spanish"
|
||||
50425^5^"Dutch"
|
||||
50425^6^"Swedish"
|
||||
50425^7^"Danish"
|
||||
50425^8^"Portuguese"
|
||||
50425^9^"Finnish"
|
||||
50425^10^"Norwegian"
|
||||
50425^11^"Greek"
|
||||
50425^12^"Turkish"
|
||||
50425^13^"Hungarian"
|
||||
50425^14^"Polish"
|
||||
50425^255^"Unknown"
|
||||
50426^0^"Current"
|
||||
50426^1^"Current Or Last Known"
|
||||
50426^2^"Initial"
|
||||
50427^0^"Begin"
|
||||
50427^1^"Connected"
|
||||
50427^2^"Failure"
|
||||
50427^3^"Done"
|
||||
50427^4^"Other Failure"
|
||||
50428^0^"UMTS User Plane SUPL"
|
||||
50428^1^"1X"
|
||||
50428^2^"UMTS Control Plane WCDMA"
|
||||
50428^3^"UMTS Control Plane GSM"
|
||||
50428^4^"V1/V2"
|
||||
50428^5^"KDDI"
|
||||
50428^6^"XTRA Data Download"
|
||||
50428^7^"SNTP Time Download"
|
||||
50429^0^"Unknown"
|
||||
50429^1^"GPS"
|
||||
50429^2^"Cell ID"
|
||||
50429^3^"Enhanced Cell ID"
|
||||
50429^4^"Wi-Fi"
|
||||
50429^5^"Terrestial"
|
||||
50429^6^"Terrestial Hybrid"
|
||||
50429^7^"Other"
|
||||
50430^0^"Disabled"
|
||||
50430^1^"Enabled"
|
||||
50430^255^"Unknown"
|
||||
50431^0^"GPS"
|
||||
50431^1^"UTC"
|
||||
50432^0^"Write"
|
||||
50433^0^"Disables"
|
||||
50433^1^"Enabled - Low Power Mode"
|
||||
50433^2^"Enabled - Ready Mode"
|
||||
50434^0^"Disabled"
|
||||
50434^1^"Enabled"
|
||||
50434^255^"Not Supported"
|
||||
50435^0^"UMTS"
|
||||
50435^1^"CDMA"
|
||||
50600^1^"Send SMS Proactive Command"^-1
|
||||
50601^1^"Refresh Start"^-1
|
||||
50601^2^"Refresh Success"^-1
|
||||
50601^3^"Refresh Failed"^-1
|
||||
50602^1^"End Proactive Session Command Received from the card"^-1
|
||||
50602^2^"End Proactive Session Internal to ME"^-1
|
||||
50603^1^"Menu Selection"^-1
|
||||
50603^2^"Event Download User Activity"^-1
|
||||
50603^3^"Event Download Idle Screen Available"^-1
|
||||
50603^4^"Event Download Language Selection"^-1
|
||||
50700^0^"Success"^-1
|
||||
50700^1^"Failure"^-1
|
||||
50800^0^"Client Initiated Device Configure"^-1
|
||||
50800^1^"Client Initiated PRL Update"^-1
|
||||
50800^2^"Client Initiated Hands Free Activation"^-1
|
||||
50800^3^"Device Initiated Hands Free Activation"^-1
|
||||
50800^4^"Network Initiated PRL Update"^-1
|
||||
50800^5^"Network Initiated Device Configure"^-1
|
||||
50801^0^"Complete, Info Updated"^-1
|
||||
50801^1^"Complete, Info Unavailable"^-1
|
||||
50801^2^"Failed"^-1
|
||||
50801^3^"Retrying"^-1
|
||||
50801^4^"Connecting"^-1
|
||||
50801^5^"Connected"^-1
|
||||
50801^6^"Authenticated"^-1
|
||||
50801^7^"MDN Downloaded"^-1
|
||||
50801^8^"MSID Downloaded"^-1
|
||||
50801^9^"PRL Downloaded"^-1
|
||||
50801^10^"MIP Profile Downloaded"^-1
|
||||
50802^0^"Unknown"^-1
|
||||
50802^1^"Network Unavailable"^-1
|
||||
50802^2^"Server Unavailable"^-1
|
||||
50802^3^"Authentication Failed"^-1
|
||||
50802^4^"Max Retry Exceeded"^-1
|
||||
50802^5^"Session Cancelled"^-1
|
||||
50803^0^"Reject"^-1
|
||||
50803^1^"Accept"^-1
|
||||
50804^0^"None"^-1
|
||||
50804^1^"Succeeded"^-1
|
||||
50804^2^"Failed"^-1
|
||||
50900^0^"Control"^-1
|
||||
50900^1^"WDS"^-1
|
||||
50900^2^"DMS"^-1
|
||||
50900^3^"NAS"^-1
|
||||
50900^4^"QOS"^-1
|
||||
50900^5^"WMS"^-1
|
||||
50900^6^"PDS"^-1
|
||||
50900^7^"AUTH"^-1
|
||||
50900^224^"CAT"^-1
|
||||
50900^225^"RMS"^-1
|
||||
50900^226^"OMA"^-1
|
||||
50901^0^"QoS Flow Header Absent"^-1
|
||||
50901^1^"QoS Flow Header Present"^-1
|
||||
50902^0^"Normal"^-1
|
||||
50902^1^"Suspend"^-1
|
||||
50902^2^"Powerdown"^-1
|
||||
70000^1^"ASCII"^-1
|
||||
70000^2^"8-Bit"^-1
|
||||
70000^3^"UCS2"^-1
|
||||
70001^1^"GSM"^-1
|
||||
70001^2^"UCS2"^-1
|
||||
70002^1^"No Action Required"^-1
|
||||
70002^2^"Action Is Required"^-1
|
|
@ -0,0 +1,967 @@
|
|||
50000^"QMI Result"^16^1^50000^0
|
||||
50001^"QMI Error"^16^1^50001^0
|
||||
50002^"Transaction ID"^16^0^4^0
|
||||
50100^"Report Channel Rate"^8^0^0^0
|
||||
50101^"Transfer Statistics Interval (Seconds)"^8^0^2^0
|
||||
50102^"Report TX Packet Successes"^1^0^0^0
|
||||
50103^"Report RX Packet Successes"^1^0^0^0
|
||||
50104^"Report TX Packet Errors"^1^0^0^0
|
||||
50105^"Report RX Packet Errors"^1^0^0^0
|
||||
50106^"Report TX Overflows"^1^0^0^0
|
||||
50107^"Report RX Overflows"^1^0^0^0
|
||||
50108^"Report Data Bearer Technology"^8^0^0^0
|
||||
50109^"TX Packet Successes"^32^0^6^0
|
||||
50110^"RX Packet Successes"^32^0^6^0
|
||||
50111^"TX Packet Errors"^32^0^6^0
|
||||
50112^"RX Packet Errors"^32^0^6^0
|
||||
50113^"TX Overflows"^32^0^6^0
|
||||
50114^"RX Overflows"^32^0^6^0
|
||||
50115^"Channel TX Rate (bps)"^32^0^6^0
|
||||
50116^"Channel RX Rate (bps)"^32^0^6^0
|
||||
50117^"Data Bearer Technology"^8^1^50002^0
|
||||
50118^"IP V4 Address"^8^0^2^0
|
||||
50119^"APN Name"^0^0^11^0
|
||||
50120^"Enable PAP"^1^0^0^0
|
||||
50121^"Enable CHAP"^1^0^0^0
|
||||
50122^"Username"^0^0^11^0
|
||||
50123^"Password"^0^0^11^0
|
||||
50124^"Enable 3GPP"^1^0^0^0
|
||||
50125^"Enable 3GPP2"^1^0^0^0
|
||||
50126^"Profile Index"^8^0^2^0
|
||||
50127^"Packet Data Handle"^32^0^6^1
|
||||
50128^"Connection Status"^8^1^50003^0
|
||||
50129^"Reconfigure Required"^8^0^0^0
|
||||
50130^"Max Channel TX Rate (bps)"^32^0^6^0
|
||||
50131^"Max Channel RX Rate (bps)"^32^0^6^0
|
||||
50132^"Profile Type"^8^1^50004^0
|
||||
50133^"Profile Name"^0^0^11^0
|
||||
50134^"PDP Type"^8^1^50005^0
|
||||
50135^"Traffic Class"^8^1^50006^0
|
||||
50136^"Max Uplink Bitrate"^32^0^6^0
|
||||
50137^"Max Downlink Bitrate"^32^0^6^0
|
||||
50138^"Guaranteed Uplink Bitrate"^32^0^6^0
|
||||
50139^"Guaranteed Downlink Bitrate"^32^0^6^0
|
||||
50140^"QoS Delivery Order"^8^1^50007^0
|
||||
50141^"Max SDU Size"^32^0^6^0
|
||||
50142^"SDU Error Ratio"^8^1^50008^0
|
||||
50143^"SDU Residual Bit Error Ratio"^8^1^50009^0
|
||||
50144^"Erroneous SDU Delivery"^8^1^50010^0
|
||||
50145^"Transfer Delay"^32^0^6^0
|
||||
50146^"Traffic Handling Priority"^32^0^6^0
|
||||
50147^"Precedence Class"^32^0^6^0
|
||||
50148^"Delay Class"^32^0^6^0
|
||||
50149^"Reliability Class"^32^0^6^0
|
||||
50150^"Peak Throughput Class"^32^0^6^0
|
||||
50151^"Mean Throughput Class"^32^0^6^0
|
||||
50152^"Number Of Profiles"^8^0^2^0
|
||||
50153^"Profile Name Length"^8^0^2^0
|
||||
50154^"Profile Name"^8^0^9^0
|
||||
50155^"Report Dormancy Status"^8^0^0^0
|
||||
50156^"Dormancy Status"^8^1^50011^0
|
||||
50157^"Call End"^16^1^50012^0
|
||||
50158^"MIP Mode"^8^1^50013^0
|
||||
50159^"Autoconnect Setting"^8^1^50026^0
|
||||
50160^"Autoconnect Off"^8^0^0^0
|
||||
50161^"Data Session Duration"^64^0^8^0
|
||||
50162^"Connection Status"^1^0^0^0
|
||||
50163^"Last Call End Reason"^1^0^0^0
|
||||
50164^"RX/TX Byte Totals"^1^0^0^0
|
||||
50165^"Dormancy Status"^1^0^0^0
|
||||
50166^"Data Bearer Technology"^1^0^0^0
|
||||
50167^"Channel Rates"^1^0^0^0
|
||||
50168^"Report Connection Status"^8^0^0^0
|
||||
50169^"TX Byte Total"^1^0^0^0
|
||||
50170^"RX Byte Total"^1^0^0^0
|
||||
50171^"TX Byte Total"^64^0^8^0
|
||||
50172^"RX Byte Total"^64^0^8^0
|
||||
50173^"SPC"^48^0^9^0
|
||||
50174^"Enabled"^8^0^0^0
|
||||
50175^"Reverse Tunneling"^8^0^0^0
|
||||
50176^"NAI"^0^0^11^0
|
||||
50177^"HA SPI"^32^0^6^0
|
||||
50178^"AAA SPI"^32^0^6^0
|
||||
50179^"MN-HA Key"^0^0^11^0
|
||||
50180^"MN-AAA Key"^0^0^11^0
|
||||
50181^"Retry Attempt Limit"^8^0^2^0
|
||||
50182^"Retry Attempt Interval"^8^0^2^0
|
||||
50183^"Re-Registration Period"^8^0^2^0
|
||||
50184^"Re-Registration Only With Traffic"^8^0^0^0
|
||||
50185^"MN-HA Authenticator Calculator"^8^0^0^0
|
||||
50186^"MN-HA RFC 2002 BIS Authentication"^8^0^0^0
|
||||
50187^"Last MIP Status"^8^0^2^0
|
||||
50188^"AN-AAA Authenticated"^8^0^0^0
|
||||
50189^"Call List Type"^8^1^50014^0
|
||||
50190^"Call Records"^16^0^4^0
|
||||
50191^"ID"^16^0^4^0
|
||||
50192^"Type"^8^1^50015^0
|
||||
50193^"Data Bearer"^8^1^50002^0
|
||||
50194^"Timestamp"^64^0^8^1
|
||||
50196^"Total Duration"^64^0^8^0
|
||||
50197^"Active Duration"^64^0^8^0
|
||||
50198^"RX Byte Total"^64^0^8^0
|
||||
50199^"TX Byte Total"^64^0^8^0
|
||||
50201^"Phone Number Length"^8^0^2^0
|
||||
50202^"Phone Number"^8^0^9^0
|
||||
50203^"Call List Max Size"^16^0^4^0
|
||||
50204^"Previous Call TX Byte Total"^64^0^8^0
|
||||
50205^"Previous Call RX Byte Total"^64^0^8^0
|
||||
50206^"Previous Data Session Duration"^64^0^8^0
|
||||
50207^"Data Session Active Duration"^64^0^8^0
|
||||
50208^"Previous Data Session Active Duration"^64^0^8^0
|
||||
50209^"Duration"^1^0^0^0
|
||||
50210^"Profile ID"^1^0^0^0
|
||||
50211^"Profile Name"^1^0^0^0
|
||||
50212^"PDP Type"^1^0^0^0
|
||||
50213^"APN Name"^1^0^0^0
|
||||
50214^"DNS Address"^1^0^0^0
|
||||
50215^"Granted QoS"^1^0^0^0
|
||||
50216^"Username"^1^0^0^0
|
||||
50217^"Authentication Protocol"^1^0^0^0
|
||||
50218^"IP Address"^1^0^0^0
|
||||
50219^"Gateway Info"^1^0^0^0
|
||||
50220^"IPv4 Subnet Mask"^32^0^6^1
|
||||
50221^"Key State"^8^1^50016^0
|
||||
50222^"Report MIP Status"^8^0^0^0
|
||||
50223^"MIP Status"^8^0^2^0
|
||||
50230^"Network Type"^8^1^50017^0
|
||||
50231^"CDMA 1x"^1^0^0^0
|
||||
50232^"CDMA 1x Ev-DO Rev. 0"^1^0^0^0
|
||||
50233^"CDMA 1x Ev-DO Rev. A"^1^0^0^0
|
||||
50234^"WCDMA"^1^0^0^0
|
||||
50235^"GPRS"^1^0^0^0
|
||||
50236^"HSDPA"^1^0^0^0
|
||||
50237^"HSUPA"^1^0^0^0
|
||||
50238^"EDGE"^1^0^0^0
|
||||
50239^"CDMA 1x IS95"^1^0^0^0
|
||||
50240^"CDMA 1x IS2000"^1^0^0^0
|
||||
50241^"CDMA 1x IS2000 Rel. A"^1^0^0^0
|
||||
50242^"CDMA 1x Ev-DO Rev. A DPA"^1^0^0^0
|
||||
50243^"CDMA 1x Ev-DO Rev. A MFPA"^1^0^0^0
|
||||
50244^"CDMA 1x Ev-DO Rev. A EMPA"^1^0^0^0
|
||||
50245^"Extended Technology Preference"^16^1^50018^0
|
||||
50246^"Call Type"^8^1^50019^0
|
||||
50247^"IP Family"^8^1^50020^0
|
||||
50248^"Call End Reason Type"^16^1^50025^0
|
||||
50249^"Call End Reason Value"^16^0^4^0
|
||||
50250^"Call End Reason"^16^1^50021^0
|
||||
50251^"Call End Reason"^16^1^50022^0
|
||||
50252^"Call End Reason"^16^1^50023^0
|
||||
50253^"Call End Reason"^16^1^50024^0
|
||||
50254^"P-CSCF Address Using PCO"^8^0^0^0
|
||||
50255^"P-CSCF Address"^1^0^0^0
|
||||
50256^"P-CSCF Server Address List"^1^0^0^0
|
||||
50257^"P-CSCF Domain Name List"^1^0^0^0
|
||||
50258^"MTU"^1^0^0^0
|
||||
50259^"Domain Name List"^1^0^0^0
|
||||
50260^"IP Family"^1^0^0^0
|
||||
50261^"IM CN Flag"^1^0^0^0
|
||||
50262^"Extended Technology"^1^0^0^0
|
||||
50263^"Number Of Instances"^8^0^2^0
|
||||
50264^"FQDN Length"^16^0^4^0
|
||||
50265^"FQDN"^8^0^9^0
|
||||
50266^"MTU"^32^0^6^0
|
||||
50267^"Domain Name Length"^16^0^4^0
|
||||
50268^"Domain Name"^8^0^9^0
|
||||
50269^"IM CN"^8^0^0^0
|
||||
50270^"Autoconnect Roam Setting"^8^1^50027^0
|
||||
50271^"DNS Address"^8^0^2^0
|
||||
50272^"IP Prefix Length"^8^0^2^0
|
||||
50273^"LTE"^1^0^0^0
|
||||
50274^"CDMA 1x Ev-DO Rev. A EMPA EHRPD"^1^0^0^0
|
||||
50275^"IPv6 Address"^16^0^4^1
|
||||
50276^"PDP Access Control Flag"^8^1^50028^0
|
||||
50277^"P-CSCF Address Using DHCP"^8^0^0^0
|
||||
50278^"Filter ID"^8^0^2^0
|
||||
50279^"Evaluation ID"^8^0^2^0
|
||||
50280^"IP Version"^8^1^50029^0
|
||||
50281^"IP Source"^8^0^2^0
|
||||
50282^"Source IP Mask"^8^0^2^0
|
||||
50283^"Next Header"^8^0^2^0
|
||||
50284^"Destination Port Range Start"^16^0^4^0
|
||||
50285^"Destination Port Range End"^16^0^4^0
|
||||
50286^"Source Port Range Start"^16^0^4^0
|
||||
50287^"Source Port Range End"^16^0^4^0
|
||||
50288^"IPSEC Security Parameter Index"^32^0^6^0
|
||||
50289^"TOS Mask"^16^0^4^0
|
||||
50290^"Flow Label"^32^0^6^0
|
||||
50291^"PDP Context Number"^8^0^2^0
|
||||
50292^"PDP Context Secondary Flag"^8^0^0^0
|
||||
50293^"PDP Primary ID"^8^0^2^0
|
||||
50294^"Signaling Indication"^8^0^0^0
|
||||
50295^"Address Allocation Preference"^8^1^50030^0
|
||||
50296^"QoS Class Identifier"^8^1^50031^0
|
||||
50297^"Negotiate DNS Server Preference"^8^0^0^0
|
||||
50298^"PPP Session Close Timer DO"^32^0^6^0
|
||||
50299^"PPP Session Close Timer 1X"^32^0^6^0
|
||||
50300^"Allow Linger"^8^0^0^0
|
||||
50301^"Timeout"^16^0^4^0
|
||||
50302^"Retry Count"^8^0^2^0
|
||||
50303^"Authentication Protocol"^8^1^50032^0
|
||||
50304^"Data Rate"^8^1^50033^0
|
||||
50305^"Application Type"^32^1^50034^0
|
||||
50306^"Data Mode"^8^1^50035^0
|
||||
50307^"Application Priority"^8^0^2^0
|
||||
50308^"PDN Type"^8^1^50036^0
|
||||
50309^"P-CSCF Address Needed"^8^0^0^0
|
||||
50310^"Extended Error Code"^16^1^50037^0
|
||||
50311^"Number Of Addresses"^8^0^2^0
|
||||
51000^"Report Power State"^8^0^0^0
|
||||
51001^"Battery Level Lower Limit (%)"^8^0^2^0
|
||||
51002^"Battery Level Upper Limit (%)"^8^0^2^0
|
||||
51003^"Power Source"^1^1^50100^0
|
||||
51004^"Battery Connected"^1^0^0^0
|
||||
51005^"Battery Charging"^1^0^0^0
|
||||
51006^"Power Fault"^1^0^0^0
|
||||
51007^"Battery Level (%)"^8^0^2^0
|
||||
51008^"Max TX Rate (bps)"^32^0^6^0
|
||||
51009^"Max RX Rate (bps)"^32^0^6^0
|
||||
51010^"Data Service Capability"^8^1^50101^0
|
||||
51011^"SIM Supported"^8^0^0^0
|
||||
51012^"Radio Interface Count"^8^0^2^0
|
||||
51013^"Radio Interface"^8^1^50102^0
|
||||
51014^"Device Manfacturer"^0^0^11^0
|
||||
51015^"Device Model ID"^0^0^11^0
|
||||
51016^"Device Revision ID"^0^0^11^0
|
||||
51017^"Device Voice Number"^0^0^11^0
|
||||
51018^"ESN"^0^0^11^0
|
||||
51019^"IMEI"^0^0^11^0
|
||||
51020^"MEID"^0^0^11^0
|
||||
51021^"Report Activation State"^8^0^0^0
|
||||
51022^"Activation State"^16^1^50103^0
|
||||
51023^"Device Mobile ID Number"^0^0^11^0
|
||||
51024^"Device Hardware Revision"^0^0^11^0
|
||||
51025^"Operating Mode"^8^1^50104^0
|
||||
51026^"Timestamp"^48^0^8^1
|
||||
51027^"Source"^16^1^50105^0
|
||||
51028^"PRL Version"^16^0^4^0
|
||||
51030^"SPC"^48^0^9^0
|
||||
51031^"SID"^16^0^4^0
|
||||
51032^"MDN Length"^8^0^2^0
|
||||
51033^"MDN"^8^0^9^0
|
||||
51034^"MIN Length"^8^0^2^0
|
||||
51035^"MIN"^8^0^9^0
|
||||
51036^"PRL Length"^16^0^4^0
|
||||
51037^"PRL"^8^0^2^1
|
||||
51038^"MN-HA Length"^8^0^2^0
|
||||
51039^"MN-HA"^8^0^9^0
|
||||
51040^"MN-AAA Length"^8^0^2^0
|
||||
51041^"MN-AAA"^8^0^9^0
|
||||
51042^"Lock State"^8^1^50107^0
|
||||
51043^"Lock Code"^32^0^9^0
|
||||
51044^"Current Lock Code"^32^0^9^0
|
||||
51045^"New Lock Code"^32^0^9^0
|
||||
51046^"Data Length"^16^0^4^0
|
||||
51047^"Data"^8^0^2^1
|
||||
51048^"Code Length"^8^0^2^0
|
||||
51049^"Code"^8^0^9^0
|
||||
51050^"PIN ID"^8^0^2^0
|
||||
51051^"PIN Enabled"^8^0^2^0
|
||||
51052^"PIN Length"^8^0^2^0
|
||||
51053^"PIN Value"^8^0^9^0
|
||||
51054^"Remaining Verify Retries"^8^0^2^0
|
||||
51055^"Remaining Unblock Retries"^8^0^2^0
|
||||
51056^"PUK Length"^8^0^2^0
|
||||
51057^"PUK Value"^8^0^9^0
|
||||
51058^"Old PIN Length"^8^0^2^0
|
||||
51059^"Old PIN Value"^8^0^9^0
|
||||
51060^"New PIN Length"^8^0^2^0
|
||||
51061^"New PIN Value"^8^0^9^0
|
||||
51062^"PIN Status"^8^1^50108^0
|
||||
51063^"Report PIN Status"^8^0^0^0
|
||||
51064^"PRL Total Length"^16^0^4^0
|
||||
51065^"PRL Segment Length"^16^0^4^0
|
||||
51066^"PRL Segment ID"^8^0^2^0
|
||||
51067^"Boot Code Revision ID"^0^0^11^0
|
||||
51068^"UQCN Revision ID"^0^0^11^0
|
||||
51069^"IMSI"^0^0^11^0
|
||||
51070^"Host Image Mismatch"^1^0^2^0
|
||||
51071^"UQCN Image Mismatch"^1^0^2^0
|
||||
51072^"Incompatible UQCN"^1^0^2^0
|
||||
51073^"ICCID"^0^0^11^0
|
||||
51074^"Firmware ID"^32^0^6^0
|
||||
51075^"Host Lock Code"^32^0^6^0
|
||||
51076^"Platform Restricted"^8^0^0^0
|
||||
51077^"Report Operating Mode"^8^0^0^0
|
||||
51078^"Facility"^8^1^50109^0
|
||||
51079^"Facility State"^8^1^50110^0
|
||||
51080^"Control Key Length"^8^0^2^0
|
||||
51081^"Control Key"^8^0^9^0
|
||||
51082^"UQCN Copy Issue"^1^0^2^0
|
||||
51083^"Report UIM State"^8^0^0^0
|
||||
51084^"UIM State"^8^1^50111^0
|
||||
51085^"Operation Blocking"^8^0^0^0
|
||||
51090^"Number Of Images"^8^0^2^0
|
||||
51091^"Image Type"^8^1^50112^0
|
||||
51092^"Image ID"^8^0^2^1
|
||||
51093^"Build ID Length"^8^0^2^0
|
||||
51094^"Build ID"^8^0^9^0
|
||||
51095^"Force Download"^8^0^0^0
|
||||
51096^"Storage Index"^8^0^2^0
|
||||
51097^"Maximum Build ID Length"^8^0^2^0
|
||||
51098^"Number Of Image Types"^8^0^2^0
|
||||
51099^"Maximum Number Of Images"^8^0^2^0
|
||||
51100^"Index Of Executing Image"^8^0^2^0
|
||||
51101^"Failure Count"^8^0^2^0
|
||||
51110^"Band Class 0 - A System"^1^0^0^0
|
||||
51111^"Band Class 0 - B System"^1^0^0^0
|
||||
51112^"Band Class 1"^1^0^0^0
|
||||
51113^"Band Class 2"^1^0^0^0
|
||||
51114^"Band Class 3 - A System"^1^0^0^0
|
||||
51115^"Band Class 4"^1^0^0^0
|
||||
51116^"Band Class 5"^1^0^0^0
|
||||
51117^"GSM DCS"^1^0^0^0
|
||||
51118^"GSM Primary"^1^0^0^0
|
||||
51119^"GSM Extended"^1^0^0^0
|
||||
51120^"Band Class 6"^1^0^0^0
|
||||
51121^"Band Class 7"^1^0^0^0
|
||||
51122^"Band Class 8"^1^0^0^0
|
||||
51123^"Band Class 9"^1^0^0^0
|
||||
51124^"Band Class 10"^1^0^0^0
|
||||
51125^"Band Class 11"^1^0^0^0
|
||||
51126^"GSM 450"^1^0^0^0
|
||||
51127^"GSM 480"^1^0^0^0
|
||||
51128^"GSM 750"^1^0^0^0
|
||||
51129^"GSM 850"^1^0^0^0
|
||||
51130^"GSM Railways"^1^0^0^0
|
||||
51131^"GSM PCS"^1^0^0^0
|
||||
51132^"WCDMA 2100I"^1^0^0^0
|
||||
51133^"WCDMA PCS 1900"^1^0^0^0
|
||||
51134^"WCDMA DCS 1800"^1^0^0^0
|
||||
51135^"WCDMA 1700 (US)"^1^0^0^0
|
||||
51136^"WCDMA 850"^1^0^0^0
|
||||
51137^"WCDMA 800"^1^0^0^0
|
||||
51138^"Band Class 12"^1^0^0^0
|
||||
51139^"Band Class 14"^1^0^0^0
|
||||
51140^"Band Class 15"^1^0^0^0
|
||||
51141^"WCDMA 2600"^1^0^0^0
|
||||
51142^"WCDMA 900"^1^0^0^0
|
||||
51143^"WCDMA 1700 (Japan)"^1^0^0^0
|
||||
51144^"Band Class 16"^1^0^0^0
|
||||
51145^"Band Class 17"^1^0^0^0
|
||||
51146^"Band Class 18"^1^0^0^0
|
||||
51147^"Band Class 19"^1^0^0^0
|
||||
51148^"Report Wireless Disable State"^8^0^0^0
|
||||
51149^"Wireless Disable On"^8^0^0^0
|
||||
51150^"Factory Serial Number"^0^0^11^0
|
||||
51151^"Alternate Enabled"^8^0^0^0
|
||||
51152^"Time In Milliseconds"^64^0^8^0
|
||||
51153^"Time Reference"^32^1^50113^0
|
||||
51154^"Boot Major Version"^16^0^4^0
|
||||
51155^"Boot Minor Version"^16^0^4^0
|
||||
51156^"PRI Version"^32^0^6^1
|
||||
51157^"PRI Info"^256^0^9^0
|
||||
51158^"OEM Lock ID"^32^0^6^1
|
||||
51159^"BAR Mode"^8^0^0^0
|
||||
52000^"Report Signal Strength"^8^0^0^0
|
||||
52001^"Number Of Thresholds"^8^0^2^0
|
||||
52002^"Signal Strength Threshold (dBm)"^8^0^1^0
|
||||
52003^"Signal Strength (dBm)"^8^0^1^0
|
||||
52004^"Radio Interface"^8^1^50200^0
|
||||
52005^"Number Of Info Instances"^16^0^4^0
|
||||
52006^"Mobile Country Code"^16^0^4^0
|
||||
52007^"Mobile Network Code"^16^0^4^0
|
||||
52008^"In Use Status"^2^1^50201^0
|
||||
52009^"Roaming Status"^2^1^50202^0
|
||||
52010^"Forbidden Status"^2^1^50203^0
|
||||
52011^"Preferred Status"^2^1^50204^0
|
||||
52012^"Description Length"^8^0^2^0
|
||||
52013^"Description"^8^0^9^0
|
||||
52014^"Register Action"^8^1^50205^0
|
||||
52015^"Radio Access Technology"^8^1^50206^0
|
||||
52016^"PS Attach Action"^8^1^50207^0
|
||||
52017^"Registration State"^8^1^50208^0
|
||||
52018^"CS Attach State"^8^1^50209^0
|
||||
52019^"PS Attach State"^8^1^50209^0
|
||||
52020^"Registered Network"^8^1^50210^0
|
||||
52021^"Number Of Radio Interfaces In Use"^8^0^2^0
|
||||
52022^"Roaming Indicator"^8^1^50211^0
|
||||
52023^"Number Of Preferred Networks"^16^0^4^0
|
||||
52024^"GSM Compact"^1^0^0^0
|
||||
52025^"GSM"^1^0^0^0
|
||||
52026^"UMTS"^1^0^0^0
|
||||
52027^"Number Of Forbidden Networks"^16^0^4^0
|
||||
52028^"System ID"^16^0^4^0
|
||||
52029^"Network ID"^16^0^4^0
|
||||
52032^"Duration"^8^1^50212^0
|
||||
52033^"ACCOLC"^8^0^2^0
|
||||
52034^"SPC"^48^0^9^0
|
||||
52035^"Technology"^2^1^50213^0
|
||||
52036^"Analog"^1^0^2^0
|
||||
52037^"Digital"^1^0^2^0
|
||||
52038^"EV-DO"^1^0^2^0
|
||||
52039^"GSM"^1^0^2^0
|
||||
52040^"WCDMA"^1^0^2^0
|
||||
52041^"Number Of Data Capabilities"^8^0^2^0
|
||||
52042^"Data Capability"^8^1^50214^0
|
||||
52043^"System Preference"^8^1^50215^0
|
||||
52044^"Slot Cycle Index"^8^0^2^0
|
||||
52045^"Station Class Mark"^8^0^2^0
|
||||
52046^"Register On Home System"^8^0^0^0
|
||||
52047^"Register On Foreign System"^8^0^0^0
|
||||
52048^"Register On Foreign Network"^8^0^0^0
|
||||
52049^"Force CDMA 1xEV-DO Rev. 0"^8^0^0^0
|
||||
52050^"CDMA 1xEV-DO SCP Custom Config"^8^0^0^0
|
||||
52051^"Subtype 2 Physical Layer"^1^0^0^0
|
||||
52052^"Enhanced CC MAC"^1^0^0^0
|
||||
52053^"Enhanced AC MAC"^1^0^0^0
|
||||
52054^"Enhanced FTC MAC"^1^0^0^0
|
||||
52055^"Subtype 3 RTC MAC"^1^0^0^0
|
||||
52056^"Subtype 1 RTC MAC"^1^0^0^0
|
||||
52057^"Enhanced Idle"^1^0^0^0
|
||||
52058^"Generic Multimode Capable Disc Port"^1^0^0^0
|
||||
52059^"Generic Broadcast"^1^0^0^0
|
||||
52060^"SN Multiflow Packet Application"^1^0^0^0
|
||||
52061^"SN Enhanced Multiflow Packet Application"^1^0^0^0
|
||||
52062^"Roam Preference"^8^1^50216^0
|
||||
52063^"Active Band Class"^16^1^50217^0
|
||||
52064^"Active Channel"^16^0^4^0
|
||||
52065^"Report RF Info"^8^0^0^0
|
||||
52066^"Report LU Reject"^8^0^0^0
|
||||
52067^"Number Of Instances"^8^0^2^0
|
||||
52068^"Service Domain"^8^1^50218^0
|
||||
52069^"Reject Cause"^16^0^4^0
|
||||
52070^"AN-AAA Authentication Status"^8^1^50219^0
|
||||
52080^"Report RSSI"^8^0^0^0
|
||||
52081^"RSSI Delta"^8^0^2^0
|
||||
52082^"Report ECIO"^8^0^0^0
|
||||
52083^"ECIO Delta"^8^0^2^0
|
||||
52084^"Report IO"^8^0^0^0
|
||||
52085^"IO Delta"^8^0^2^0
|
||||
52086^"Report SINR"^8^0^0^0
|
||||
52087^"SINR Delta"^8^0^2^0
|
||||
52088^"Report Error Rate"^8^0^0^0
|
||||
52089^"RSSI"^8^0^2^0
|
||||
52090^"ECIO"^8^0^2^0
|
||||
52091^"IO"^32^0^6^0
|
||||
52092^"SINR"^8^1^50220^0
|
||||
52093^"Error Rate"^16^0^4^0
|
||||
52094^"Report System Select"^8^0^0^0
|
||||
52095^"Report DDTM"^8^0^0^0
|
||||
52096^"Report Serving System"^8^0^0^0
|
||||
52097^"Number Of Measurements"^16^0^4^0
|
||||
52098^"Base Station ID"^16^0^4^0
|
||||
52099^"Latitude"^32^0^5^0
|
||||
52100^"Longitude"^32^0^5^0
|
||||
52101^"Leap Seconds"^8^0^2^0
|
||||
52102^"Local Time Offset"^8^0^1^0
|
||||
52103^"Daylight Savings In Effect"^8^0^0^0
|
||||
52104^"Protocol Revision"^8^0^2^0
|
||||
52105^"Emergency Mode On"^8^0^0^0
|
||||
52106^"CDMA 1x"^1^0^0^0
|
||||
52107^"CDMA 1xEV-DO"^1^0^0^0
|
||||
52108^"GSM"^1^0^0^0
|
||||
52109^"UMTS"^1^0^0^0
|
||||
52110^"Band Class 0 - A System"^1^0^0^0
|
||||
52111^"Band Class 0 - B System"^1^0^0^0
|
||||
52112^"Band Class 1"^1^0^0^0
|
||||
52113^"Band Class 2"^1^0^0^0
|
||||
52114^"Band Class 3 - A System"^1^0^0^0
|
||||
52115^"Band Class 4"^1^0^0^0
|
||||
52116^"Band Class 5"^1^0^0^0
|
||||
52117^"GSM DCS"^1^0^0^0
|
||||
52118^"GSM Primary"^1^0^0^0
|
||||
52119^"GSM Extended"^1^0^0^0
|
||||
52120^"Band Class 6"^1^0^0^0
|
||||
52121^"Band Class 7"^1^0^0^0
|
||||
52122^"Band Class 8"^1^0^0^0
|
||||
52123^"Band Class 9"^1^0^0^0
|
||||
52124^"Band Class 10"^1^0^0^0
|
||||
52125^"Band Class 11"^1^0^0^0
|
||||
52126^"GSM 450"^1^0^0^0
|
||||
52127^"GSM 480"^1^0^0^0
|
||||
52128^"GSM 750"^1^0^0^0
|
||||
52129^"GSM 850"^1^0^0^0
|
||||
52130^"GSM Railways"^1^0^0^0
|
||||
52131^"GSM PCS"^1^0^0^0
|
||||
52132^"WCDMA 2100I"^1^0^0^0
|
||||
52133^"WCDMA PCS 1900"^1^0^0^0
|
||||
52134^"WCDMA DCS 1800"^1^0^0^0
|
||||
52135^"WCDMA 1700 (US)"^1^0^0^0
|
||||
52136^"WCDMA 850"^1^0^0^0
|
||||
52137^"WCDMA 800"^1^0^0^0
|
||||
52138^"Band Class 12"^1^0^0^0
|
||||
52139^"Band Class 14"^1^0^0^0
|
||||
52140^"Band Class 15"^1^0^0^0
|
||||
52141^"WCDMA 2600"^1^0^0^0
|
||||
52142^"WCDMA 900"^1^0^0^0
|
||||
52143^"WCDMA 1700 (Japan)"^1^0^0^0
|
||||
52144^"Band Class 16"^1^0^0^0
|
||||
52145^"Band Class 17"^1^0^0^0
|
||||
52146^"Band Class 18"^1^0^0^0
|
||||
52147^"Band Class 19"^1^0^0^0
|
||||
52148^"PRL Preference"^16^1^50221^0
|
||||
52149^"Roaming Preference"^16^1^50222^0
|
||||
52150^"DDTM Preference"^8^1^50223^0
|
||||
52151^"Suppress L2 ACK"^1^0^0^0
|
||||
52152^"Suppress 1x Registrations"^1^0^0^0
|
||||
52153^"Ignore Service Option Pages"^1^0^0^0
|
||||
52154^"Block Mobile Originated SMS And DBM"^1^0^0^0
|
||||
52155^"Service Option Action"^8^1^50224^0
|
||||
52156^"Service Option"^16^0^4^0
|
||||
52157^"Query RSSI"^1^0^0^0
|
||||
52158^"Query ECIO"^1^0^0^0
|
||||
52159^"Query IO"^1^0^0^0
|
||||
52160^"Query SINR"^1^0^0^0
|
||||
52161^"Query Error Rate"^1^0^0^0
|
||||
52162^"Display Network Description"^8^1^50225^0
|
||||
52163^"Network Description Encoding"^8^1^50226^0
|
||||
52164^"Network Description Length"^8^0^2^0
|
||||
52165^"Network Description"^8^0^2^1
|
||||
52166^"PLMN Changed"^8^0^0^0
|
||||
52167^"Restrict Manual PLMN Selection"^8^0^0^0
|
||||
52168^"SPN Encoding"^8^1^50227^0
|
||||
52169^"SPN Length"^8^0^2^0
|
||||
52170^"SPN"^8^0^2^1
|
||||
52171^"PLMN Short Encoding"^8^1^50227^0
|
||||
52172^"PLMN Short Country Initials"^8^1^50228^0
|
||||
52173^"PLMN Spare Bits"^8^1^50229^0
|
||||
52174^"PLMN Short Length"^8^0^2^0
|
||||
52175^"PLMN Short"^8^0^2^1
|
||||
52176^"PLMN Long Encoding"^8^1^50227^0
|
||||
52177^"PLMN Long Country Initials"^8^1^50228^0
|
||||
52178^"PLMN Long Bits"^8^1^50229^0
|
||||
52179^"PLMN Long Length"^8^0^2^0
|
||||
52180^"PLMN Long"^8^0^2^1
|
||||
52181^"RSRQ"^8^0^1^0
|
||||
52182^"Change Duration"^8^1^50230^0
|
||||
52183^"Report RSRQ"^8^0^0^0
|
||||
52184^"RSRQ Delta"^8^0^2^0
|
||||
53000^"Report New MT Messages"^8^0^0^0
|
||||
53001^"Storage Type"^8^1^50300^0
|
||||
53002^"Storage Index"^32^0^6^0
|
||||
53003^"Message Format"^8^1^50301^0
|
||||
53004^"Raw Message Length"^16^0^4^0
|
||||
53005^"Raw Message"^8^0^2^1
|
||||
53006^"Cause Code"^16^0^4^0
|
||||
53007^"Message Tag"^8^1^50302^0
|
||||
53008^"Mode"^8^1^50303^0
|
||||
53009^"Number Of Messages"^32^0^6^0
|
||||
53010^"Number Of Routes"^16^0^4^0
|
||||
53011^"Message Type"^8^1^50304^0
|
||||
53012^"Message Class"^8^1^50305^0
|
||||
53013^"Receipt Action"^8^1^50306^0
|
||||
53014^"Route Value"^8^1^50307^0
|
||||
53015^"SMSC Address Type"^24^0^9^0
|
||||
53016^"SMSC Address Length"^8^0^2^0
|
||||
53017^"SMSC Address"^8^0^9^0
|
||||
53018^"SMSC Address Type"^8^0^11^0
|
||||
53019^"SMSC Address"^8^0^11^0
|
||||
53020^"ACK Required"^8^0^0^0
|
||||
53021^"Transaction ID"^32^0^6^0
|
||||
53022^"Force Send On DC"^8^0^0^0
|
||||
53023^"Service Option"^8^1^50308^0
|
||||
53024^"Do Not Disconnect DC"^8^0^0^0
|
||||
53025^"Link Timer In Seconds"^8^0^2^0
|
||||
53026^"Error Class"^8^1^50309^0
|
||||
53027^"GSM/WCDMA RP Cause"^16^0^4^0
|
||||
53028^"GSM/WCDMA TP Cause"^8^0^2^0
|
||||
53029^"Transfer Status Reports"^8^0^0^0
|
||||
53030^"Max Storage Size In Messages"^32^0^6^0
|
||||
53031^"Free Storage Size In Messages"^32^0^6^0
|
||||
53032^"Processed Successfully"^8^0^0^0
|
||||
53033^"Error Class"^8^1^50310^0
|
||||
53034^"Transport Layer Status"^8^0^2^0
|
||||
53035^"GSM/WCDMA RP Cause"^8^0^2^0
|
||||
53036^"Retry Period In Seconds"^32^0^6^0
|
||||
53037^"Retry Interval In Seconds"^32^0^6^0
|
||||
53038^"DC Disconnect Timer In Seconds"^32^0^6^0
|
||||
53039^"Memory Is Available"^8^0^0^0
|
||||
53040^"Activate Broadcast"^8^0^0^0
|
||||
53041^"Number Of Instances"^16^0^4^0
|
||||
53042^"Message ID Start"^16^0^4^0
|
||||
53043^"Message ID End"^16^0^4^0
|
||||
53044^"Selected"^8^0^0^0
|
||||
53045^"Service Category"^16^0^4^0
|
||||
53046^"Language"^16^0^4^0
|
||||
53047^"Activated"^8^0^0^0
|
||||
53048^"Domain Preference"^8^1^50311^0
|
||||
53049^"Message ID"^16^0^4^0
|
||||
54000^"Report NMEA Sentences"^8^0^0^0
|
||||
54001^"NMEA Sentence"^0^0^11^0
|
||||
54002^"Service Enabled"^8^0^0^0
|
||||
54003^"Tracking Session State"^8^1^50400^0
|
||||
54004^"Session Control"^8^1^50401^0
|
||||
54005^"Session Type"^8^1^50402^0
|
||||
54006^"Session Operation"^8^1^50403^0
|
||||
54007^"Server Option"^8^1^50404^0
|
||||
54008^"Timeout In Seconds"^8^0^2^0
|
||||
54009^"Session Fix Requests"^32^0^6^0
|
||||
54010^"Fix Request Interval In Seconds"^32^0^6^0
|
||||
54011^"Desired Accuracy In Meters"^32^0^6^0
|
||||
54012^"GGA NMEA Sentences"^1^0^0^0
|
||||
54013^"RMC NMEA Sentences"^1^0^0^0
|
||||
54014^"GSV NMEA Sentences"^1^0^0^0
|
||||
54015^"GSA NMEA Sentences"^1^0^0^0
|
||||
54016^"VTG NMEA Sentences"^1^0^0^0
|
||||
54017^"Output Device"^8^1^50405^0
|
||||
54018^"NMEA Reporting"^8^1^50406^0
|
||||
54019^"System Time"^64^0^8^0
|
||||
54020^"System Discontinuties"^16^0^4^0
|
||||
54021^"Automatic Download Enabled"^8^0^0^0
|
||||
54022^"Download Interval In Hours"^16^0^4^0
|
||||
54023^"Medium Preferences"^8^0^2^0
|
||||
54024^"Medium Preference"^8^1^50407^0
|
||||
54025^"WWAN Network Preference"^8^1^50408^0
|
||||
54026^"Valid Period - GPS Start Week"^16^0^4^0
|
||||
54027^"Valid Period - GPS Start Week Offset In Minutes"^16^0^4^0
|
||||
54028^"Valid Period - Duration In Hours"^16^0^4^0
|
||||
54029^"Server Address"^8^0^2^0
|
||||
54030^"Server Port"^32^0^6^0
|
||||
54031^"Auto-Tracking Enabled"^8^0^0^0
|
||||
54032^"Reset EPH"^1^0^0^0
|
||||
54033^"Reset ALM"^1^0^0^0
|
||||
54034^"Reset POS"^1^0^0^0
|
||||
54035^"Reset TIME"^1^0^0^0
|
||||
54036^"Reset IONO"^1^0^0^0
|
||||
54037^"Reset UTC"^1^0^0^0
|
||||
54038^"Reset HEALTH"^1^0^0^0
|
||||
54039^"Reset SVDIR"^1^0^0^0
|
||||
54040^"Reset SVSTEER"^1^0^0^0
|
||||
54041^"Reset SADATA"^1^0^0^0
|
||||
54042^"Reset RTI"^1^0^0^0
|
||||
54043^"Reset ALM CORR"^1^0^0^0
|
||||
54044^"Reset FREQ BIAS EST"^1^0^0^0
|
||||
54045^"Reset POS"^1^0^0^0
|
||||
54046^"Reset LATEST GPS POS"^1^0^0^0
|
||||
54047^"Reset OTA POS"^1^0^0^0
|
||||
54048^"Reset EXT REF POS"^1^0^0^0
|
||||
54049^"Reset TIMETAG"^1^0^0^0
|
||||
54050^"Reset CELLID"^1^0^0^0
|
||||
54051^"Reset CACHED CELLID"^1^0^0^0
|
||||
54052^"Reset LAST SRV CELL"^1^0^0^0
|
||||
54053^"Reset CUR SRV CELL"^1^0^0^0
|
||||
54054^"Reset NEIGHBOR INFO"^1^0^0^0
|
||||
54055^"Report NMEA Sentences Plus Mode"^8^0^0^0
|
||||
54056^"NMEA Sentence Operating Mode"^8^1^50409^0
|
||||
54057^"NMEA Sentence Length"^16^0^4^0
|
||||
54058^"NMEA Sentence"^8^0^9^0
|
||||
54100^"Report Raw Position Data"^8^0^0^0
|
||||
54101^"Report External XTRA Data Requests"^8^0^0^0
|
||||
54102^"Report External Time Injections"^8^0^0^0
|
||||
54103^"Report External Wi-Fi Requests"^8^0^0^0
|
||||
54104^"Report Satellite Info"^8^0^0^0
|
||||
54105^"Report VX Network Initiated Prompts"^8^0^0^0
|
||||
54106^"Report SUPL Network Initiated Prompts"^8^0^0^0
|
||||
54107^"Report UMTS CP Network Initiated Prompts"^8^0^0^0
|
||||
54108^"Report PDS Comm Events"^8^0^0^0
|
||||
54109^"Session Status"^8^1^50410^0
|
||||
54110^"Timestamp Calendar Valid"^1^0^0^0
|
||||
54111^"Timestamp UTC Valid"^1^0^0^0
|
||||
54112^"Leap Seconds Valid"^1^0^0^0
|
||||
54113^"Time Uncertainty Valid"^1^0^0^0
|
||||
54114^"Latitude Valid"^1^0^0^0
|
||||
54115^"Longitude Valid"^1^0^0^0
|
||||
54116^"Ellipsoid Altitude Valid"^1^0^0^0
|
||||
54117^"Mean Sea Level Altitude Valid"^1^0^0^0
|
||||
54118^"Horizontal Speed Valid"^1^0^0^0
|
||||
54119^"Vertical Speed Valid"^1^0^0^0
|
||||
54120^"Heading Valid"^1^0^0^0
|
||||
54121^"Horizontal Uncertainty Circular Valid"^1^0^0^0
|
||||
54122^"Horizontal Uncertainty Ellipse Semi-Major Valid"^1^0^0^0
|
||||
54123^"Horizontal Uncertainty Ellipse Semi-Minor Valid"^1^0^0^0
|
||||
54124^"Horizontal Uncertainty Ellipse Orient Azimuth Valid"^1^0^0^0
|
||||
54125^"Vertical Uncertainty Valid"^1^0^0^0
|
||||
54126^"Horizontal Velocity Uncertainty Valid"^1^0^0^0
|
||||
54127^"Vertical Velocity Uncertainty Valid"^1^0^0^0
|
||||
54128^"Horizontal Confidence Valid"^1^0^0^0
|
||||
54129^"Position DOP Valid"^1^0^0^0
|
||||
54130^"Horizontal DOP Valid"^1^0^0^0
|
||||
54131^"Vertical DOP Valid"^1^0^0^0
|
||||
54132^"Operating Mode Used Valid"^1^0^0^0
|
||||
54133^"Calendar Year"^16^0^4^0
|
||||
54134^"Calendar Month"^8^1^50411^0
|
||||
54135^"Calendar Day"^8^1^50412^0
|
||||
54136^"Calendar Day Of Month"^8^0^2^0
|
||||
54137^"Calendar Hour"^8^0^2^0
|
||||
54138^"Calendar Minute"^8^0^2^0
|
||||
54139^"Calendar Second"^8^0^2^0
|
||||
54140^"Calendar Millisecond"^16^0^4^0
|
||||
54141^"Calendar Leap Seconds"^8^0^2^0
|
||||
54142^"UTC Timestamp"^64^0^8^1
|
||||
54143^"UTC Timestamp Uncertainty"^32^0^6^0
|
||||
54144^"Latitude"^64^0^14^0
|
||||
54145^"Longitude"^64^0^14^0
|
||||
54146^"Ellipsoid Altitude"^32^0^13^0
|
||||
54147^"Mean Sea Level Altitude"^32^0^13^0
|
||||
54148^"Horizontal Speed"^32^0^13^0
|
||||
54149^"Vertical Speed"^32^0^13^0
|
||||
54150^"Heading"^32^0^13^0
|
||||
54151^"Horizontal Uncertainty Circular"^32^0^13^0
|
||||
54152^"Horizontal Uncertainty Ellipse Semi-Major"^32^0^13^0
|
||||
54153^"Horizontal Uncertainty Ellipse Semi-Minor"^32^0^13^0
|
||||
54154^"Horizontal Uncertainty Ellipse Orient Azimuth"^32^0^13^0
|
||||
54155^"Vertical Uncertainty"^32^0^13^0
|
||||
54156^"Horizontal Velocity Uncertainty"^32^0^13^0
|
||||
54157^"Vertical Velocity Uncertainty"^32^0^13^0
|
||||
54158^"Horizontal Confidence"^8^0^2^0
|
||||
54159^"Position DOP "^32^0^13^0
|
||||
54160^"Horizontal DOP"^32^0^13^0
|
||||
54161^"Vertical DOP"^32^0^13^0
|
||||
54162^"Operating Mode"^8^1^50409^0
|
||||
54163^"Maximum File Size"^16^0^4^0
|
||||
54164^"URL Record Count"^8^0^2^0
|
||||
54165^"URL Length"^8^0^2^0
|
||||
54166^"URL"^8^0^9^0
|
||||
54167^"Delay Threshold"^32^0^6^0
|
||||
54168^"Wi-Fi Request Type"^8^1^50413^0
|
||||
54169^"Wi-Fi Request Time Between Fixes"^16^0^4^0
|
||||
54170^"Iono Valid"^1^0^0^0
|
||||
54171^"Satellite Count Valid"^1^0^0^0
|
||||
54172^"Satellite List Valid"^1^0^0^0
|
||||
54173^"Ionospheric Corrections"^8^0^0^0
|
||||
54174^"SV Record Count"^8^0^2^0
|
||||
54175^"System Valid"^1^0^0^0
|
||||
54176^"PRN Valid"^1^0^0^0
|
||||
54177^"Health Status Valid"^1^0^0^0
|
||||
54178^"Process Status Valid"^1^0^0^0
|
||||
54179^"Ephemeris State Valid"^1^0^0^0
|
||||
54180^"Almanac State Valid"^1^0^0^0
|
||||
54181^"Elevation Valid"^1^0^0^0
|
||||
54182^"Azimuth Valid"^1^0^0^0
|
||||
54183^"CN0 Valid"^1^0^0^0
|
||||
54184^"System"^8^1^50414^0
|
||||
54185^"PRN"^8^0^2^0
|
||||
54186^"Health Level"^8^1^50415^0
|
||||
54187^"Processing Status"^8^1^50416^0
|
||||
54188^"Ephemeris State"^8^1^50417^0
|
||||
54189^"Almanac State"^8^1^50418^0
|
||||
54190^"Azimuth"^16^0^4^0
|
||||
54191^"CN0"^16^0^4^0
|
||||
54192^"Privacy Valid"^1^0^0^0
|
||||
54193^"QoS Valid"^1^0^0^0
|
||||
54194^"Count Valid"^1^0^0^0
|
||||
54195^"Interval Valid"^1^0^0^0
|
||||
54196^"Mode Valid"^1^0^0^0
|
||||
54197^"Requestor ID Valid"^1^0^0^0
|
||||
54198^"Privacy"^8^1^50419^0
|
||||
54199^"QoS"^8^0^2^0
|
||||
54200^"Position Count"^32^0^6^0
|
||||
54201^"Interval Between Fixes"^32^0^6^0
|
||||
54202^"Mode"^8^1^50420^0
|
||||
54203^"Requestor ID DCS"^8^1^50421^0
|
||||
54204^"Requestor ID Length"^8^0^2^0
|
||||
54205^"Requestor ID"^8^0^2^1
|
||||
54206^"Privacy Valid"^1^0^0^0
|
||||
54207^"INIT Hash Valid"^1^0^0^0
|
||||
54208^"Mode Valid"^1^0^0^0
|
||||
54209^"SLP Session ID Valid"^1^0^0^0
|
||||
54210^"SLP Server IPv4 Address Valid"^1^0^0^0
|
||||
54211^"SLP Server IPv6 Address Valid"^1^0^0^0
|
||||
54212^"SLP Server URL Address Valid"^1^0^0^0
|
||||
54213^"DCS Valid"^1^0^0^0
|
||||
54214^"Requestor ID Valid"^1^0^0^0
|
||||
54215^"Client Name Valid"^1^0^0^0
|
||||
54216^"QoP Horizontal Accuracy Valid"^1^0^0^0
|
||||
54217^"QoP Vertical Accuracy Valid"^1^0^0^0
|
||||
54218^"QoP Max Location Age Valid"^1^0^0^0
|
||||
54219^"QoP Delay Valid"^1^0^0^0
|
||||
54220^"Privacy"^8^1^50419^0
|
||||
54221^"INIT Hash"^64^0^8^1
|
||||
54222^"Mode"^8^1^50422^0
|
||||
54223^"SLP Session ID"^32^0^6^0
|
||||
54224^"SLP Server IPv4 Port"^32^0^6^0
|
||||
54225^"SLP Server IPv4 Address"^8^0^2^0
|
||||
54226^"SLP Server IPv6 Address"^8^0^2^0
|
||||
54227^"SLP Server URL Length"^8^0^2^0
|
||||
54228^"SLP Server URL Address"^8^0^9^0
|
||||
54229^"Request DCS"^8^1^50423^0
|
||||
54230^"Requestor ID DCS"^8^1^50424^0
|
||||
54231^"Requestor ID Length"^8^0^2^0
|
||||
54232^"Requestor ID"^8^0^2^1
|
||||
54233^"Client Name DCS"^8^1^50424^0
|
||||
54234^"Client Name Length"^8^0^2^0
|
||||
54235^"Client Name"^8^0^2^1
|
||||
54236^"QoP Horizontal Accuracy"^8^0^2^0
|
||||
54237^"QoP Vertical Accuracy"^8^0^2^0
|
||||
54238^"QoP Max Location Age"^8^0^2^0
|
||||
54239^"QoP Delay"^8^0^2^0
|
||||
54250^"Privacy Valid"^1^0^0^0
|
||||
54251^"Invoke ID Valid"^1^0^0^0
|
||||
54252^"Notification Text Valid"^1^0^0^0
|
||||
54253^"Client Address Valid"^1^0^0^0
|
||||
54254^"Location Type Valid"^1^0^0^0
|
||||
54255^"Requestor ID Valid"^1^0^0^0
|
||||
54256^"Codeword String Valid"^1^0^0^0
|
||||
54257^"Service Type ID Valid"^1^0^0^0
|
||||
54258^"Privacy"^8^1^50419^0
|
||||
54259^"Invoke ID"^8^0^2^0
|
||||
54260^"Notification Text DCS"^8^1^50425^0
|
||||
54261^"Notification Text Length"^8^0^2^0
|
||||
54262^"Notification Text"^8^0^2^1
|
||||
54263^"Client Address Length"^8^0^2^0
|
||||
54264^"Client Address"^8^0^9^0
|
||||
54265^"Location Type"^8^1^50426^0
|
||||
54266^"Requestor ID DCS"^8^1^50425^0
|
||||
54267^"Requestor ID Length"^8^0^2^0
|
||||
54268^"Requestor ID"^8^0^2^1
|
||||
54269^"Codeword DCS"^8^1^50425^0
|
||||
54270^"Codeword Length"^8^0^2^0
|
||||
54271^"Codeword"^8^0^2^1
|
||||
54272^"Service Type ID"^8^0^2^0
|
||||
54273^"Type"^8^1^50427^0
|
||||
54274^"Protocol/Data Type"^8^1^50428^0
|
||||
54275^"Embedded XTRA Data Client Enabled"^8^0^0^0
|
||||
54276^"Embedded XTRA Time Client Enabled"^8^0^0^0
|
||||
54277^"Service Major Version"^8^0^2^0
|
||||
54278^"Service Minor Version"^8^0^2^0
|
||||
54279^"Sequence Number"^8^0^2^0
|
||||
54280^"Total Length"^16^0^4^0
|
||||
54281^"Sequence Length"^16^0^4^0
|
||||
54282^"Data"^8^0^2^1
|
||||
54283^"Vertical Confidence"^8^0^2^0
|
||||
54284^"Source"^8^1^50429^0
|
||||
54285^"Wi-Fi Time Counter"^32^0^6^0
|
||||
54286^"Wi-Fi Latitude"^32^0^5^0
|
||||
54287^"Wi-Fi Longitude"^32^0^5^0
|
||||
54288^"HEPE In Meters"^16^0^4^0
|
||||
54289^"AP Count"^8^0^2^0
|
||||
54290^"Error Code"^8^0^2^0
|
||||
54291^"MAC Address"^8^0^2^1
|
||||
54292^"RSSI"^32^0^6^0
|
||||
54293^"Beacon Channel"^16^0^4^0
|
||||
54294^"State"^8^1^50430^0
|
||||
54295^"Enable SBAS"^8^0^0^0
|
||||
54296^"Allow Request"^8^0^0^0
|
||||
54297^"Timestamp"^64^0^8^0
|
||||
54298^"Time Uncertainty"^32^0^6^0
|
||||
54299^"Time Base"^8^1^50431^0
|
||||
54300^"Force Acceptance"^8^0^0^0
|
||||
54301^"Filename Length"^8^0^2^0
|
||||
54302^"Filename"^8^0^9^0
|
||||
54303^"File Operation"^8^1^50432^0
|
||||
54304^"Data Length"^32^0^6^0
|
||||
54305^"Part Number"^8^0^2^0
|
||||
54306^"Total Parts"^8^0^2^0
|
||||
54307^"Data"^8^0^2^1
|
||||
54308^"Data Power Optimization Enabled"^8^0^0^0
|
||||
54309^"Enable Data Power Optimization"^8^0^0^0
|
||||
54310^"On Demand Positioning"^8^1^50433^0
|
||||
54311^"Position Valid"^1^0^0^0
|
||||
54312^"Altitude/Vertical Uncertainty Valid"^1^0^0^0
|
||||
54313^"Time Milliseconds Valid"^1^0^0^0
|
||||
54314^"Time Week Number Valid"^1^0^0^0
|
||||
54315^"Time Uncertainty Valid"^1^0^0^0
|
||||
54316^"Iono Valid"^1^0^0^0
|
||||
54317^"GPS Ephemeris Valid"^1^0^0^0
|
||||
54318^"GPS Almanac Valid"^1^0^0^0
|
||||
54319^"GPS Health Valid"^1^0^0^0
|
||||
54320^"GPS Visible SVs Valid"^1^0^0^0
|
||||
54321^"Glonass Ephemeris Valid"^1^0^0^0
|
||||
54322^"Glonass Almanac Valid"^1^0^0^0
|
||||
54323^"Glonass Health Valid"^1^0^0^0
|
||||
54324^"Glonass Visible SVs Valid"^1^0^0^0
|
||||
54325^"SBAS Ephemeris Valid"^1^0^0^0
|
||||
54326^"SBAS Almanac Valid"^1^0^0^0
|
||||
54327^"SBAS Health Valid"^1^0^0^0
|
||||
54328^"SBAS Visible SVs Valid"^1^0^0^0
|
||||
54329^"XTRA Information Valid"^1^0^0^0
|
||||
54330^"Timestamp In TOW Milliseconds"^32^0^6^0
|
||||
54331^"GPS Week Number"^16^0^4^0
|
||||
54332^"Iono Is Valid"^8^0^0^0
|
||||
54333^"GPS Ephemeris SV Mask"^32^0^6^1
|
||||
54334^"GPS Almanac SV Mask"^32^0^6^1
|
||||
54335^"GPS Health SV Mask"^32^0^6^1
|
||||
54336^"GPS Visible SV Mask"^32^0^6^1
|
||||
54337^"Glonass Ephemeris SV Mask"^32^0^6^1
|
||||
54338^"Glonass Almanac SV Mask"^32^0^6^1
|
||||
54339^"Glonass Health SV Mask"^32^0^6^1
|
||||
54340^"Glonass Visible SV Mask"^32^0^6^1
|
||||
54341^"SBAS Ephemeris SV Mask"^32^0^6^1
|
||||
54342^"SBAS Almanac SV Mask"^32^0^6^1
|
||||
54343^"SBAS Health SV Mask"^32^0^6^1
|
||||
54344^"SBAS Visible SV Mask"^32^0^6^1
|
||||
54345^"XTRA GPS Start Week"^16^0^4^0
|
||||
54346^"XTRA GPS Start Minutes"^16^0^4^0
|
||||
54347^"XTRA GPS Valid Hours"^16^0^4^0
|
||||
54348^"Elevation"^32^0^13^0
|
||||
54349^"SLP Server IPv6 Port"^32^0^6^0
|
||||
54350^"Used For Position"^1^0^0^0
|
||||
54351^"Hidden SSID"^1^0^0^0
|
||||
54352^"Encryption On"^1^0^0^0
|
||||
54353^"Infrastructure Mode"^1^0^0^0
|
||||
54354^"Engine Enabled"^8^0^0^0
|
||||
54355^"Method State"^8^1^50434^0
|
||||
54356^"Network Mode"^8^1^50435^0
|
||||
55000^"SMS Wake Enabled"^8^0^0^0^-1^0
|
||||
55001^"Mask"^32^0^6^1^-1^0
|
||||
56000^"Display Text"^1^0^0^0^-1^0
|
||||
56001^"Get Inkey"^1^0^0^0^-1^0
|
||||
56002^"Get Input"^1^0^0^0^-1^0
|
||||
56003^"Setup Menu"^1^0^0^0^-1^0
|
||||
56004^"Select Item"^1^0^0^0^-1^0
|
||||
56005^"Send SMS Alpha Identifier"^1^0^0^0^-1^0
|
||||
56006^"Setup Event User Activity"^1^0^0^0^-1^0
|
||||
56007^"Setup Event Idle Screen Notify"^1^0^0^0^-1^0
|
||||
56008^"Setup Event Language Sel Notify"^1^0^0^0^-1^0
|
||||
56009^"Setup Idle Mode Text"^1^0^0^0^-1^0
|
||||
56010^"Language Notification"^1^0^0^0^-1^0
|
||||
56011^"Refresh"^1^0^0^0^-1^0
|
||||
56012^"End Proactive Session"^1^0^0^0^-1^0
|
||||
56013^"Reference ID"^32^0^6^1^-1^0
|
||||
56014^"Command Length"^16^0^4^0^-1^0
|
||||
56015^"Display Text Command"^8^0^2^1^-1^0
|
||||
56016^"Get Inkey Command"^8^0^2^1^-1^0
|
||||
56017^"Get Input Command"^8^0^2^1^-1^0
|
||||
56018^"Setup Menu Command"^8^0^2^1^-1^0
|
||||
56019^"Select Item Command"^8^0^2^1^-1^0
|
||||
56020^"Alpha ID Command Type"^8^1^50600^1^-1^0
|
||||
56021^"Alpha ID Length"^16^0^4^0^-1^0
|
||||
56022^"Alpha ID"^8^0^2^1^-1^0
|
||||
56023^"User Activity Notify"^1^0^0^0^-1^0
|
||||
56024^"Idle Screen Available"^1^0^0^0^-1^0
|
||||
56025^"Language Selection Notify"^1^0^0^0^-1^0
|
||||
56026^"Setup Idle Mode Text Command"^8^0^2^1^-1^0
|
||||
56027^"Language Notification Command"^8^0^2^1^-1^0
|
||||
56028^"Refresh Mode"^16^0^4^1^-1^0
|
||||
56029^"Refresh Stage"^16^1^50601^1^-1^0
|
||||
56030^"Proactive Session End Type"^8^1^50602^1^-1^0
|
||||
56031^"Terminal Response Length"^16^0^4^0^-1^0
|
||||
56032^"Terminal Response"^8^0^2^1^-1^0
|
||||
56033^"Envelope Command Type"^16^1^50005^0^-1^0
|
||||
56034^"Envelope Length"^16^0^4^0^-1^0
|
||||
56035^"Envelope Data"^8^0^2^1^-1^0
|
||||
56036^"Envelope Command Type"^16^1^50603^0^-1^0
|
||||
57000^"EAP-SIM"^1^0^0^0^-1^0
|
||||
57001^"EAP-AKA"^1^0^0^0^-1^0
|
||||
57002^"EAP Request Packet"^8^0^2^1^-1^0
|
||||
57003^"Response Packet"^8^0^2^1^-1^0
|
||||
57005^"Session Keys"^8^0^2^1^-1^0
|
||||
57006^"Result"^8^1^50700^0^-1^0
|
||||
58000^"Report Network Initiated Alerts"^8^0^0^0^-1^0
|
||||
58001^"Report Session Status"^8^0^0^0^-1^0
|
||||
58002^"Session Type"^8^1^50800^0^-1^0
|
||||
58003^"Session ID"^16^0^4^0^-1^0
|
||||
58004^"Session State"^8^1^50801^0^-1^0
|
||||
58005^"Session Failure"^8^1^50802^0^-1^0
|
||||
58006^"Retry Count"^8^0^2^0^-1^0
|
||||
58007^"Retry Pause Timer"^16^0^4^0^-1^0
|
||||
58008^"Remaining Time"^16^0^4^0^-1^0
|
||||
58009^"Selection"^8^1^50803^0^-1^0
|
||||
58010^"Device Provisioning Service Update Enabled"^8^0^0^0^-1^0
|
||||
58011^"PRL Service Update Enabled"^8^0^0^0^-1^0
|
||||
58012^"HFA Feature Enabled"^8^0^0^0^-1^0
|
||||
58013^"HFA Feature Done State"^8^1^50804^0^-1^0
|
||||
59000^"Instance ID"^8^0^2^0^-1^0
|
||||
59001^"Link ID"^16^0^4^0^-1^0
|
||||
59002^"Service Count"^8^0^2^0^-1^0
|
||||
59003^"Service Type"^8^1^50900^0^-1^0
|
||||
59004^"Major Version"^16^0^4^0^-1^0
|
||||
59005^"Minor Version"^16^0^4^0^-1^0
|
||||
59006^"Addendum Label Length"^8^0^2^0^-1^0
|
||||
59007^"Addendum Label"^8^0^9^0^-1^0
|
||||
59008^"Client ID"^8^0^2^0^-1^0
|
||||
59009^"Data Format"^8^1^50901^0^-1^0
|
||||
59010^"Link Protocol - 802.3"^1^0^0^0^-1^0
|
||||
59011^"Link Protocol - IP"^1^0^0^0^-1^0
|
||||
59012^"Report Power State Changes"^8^0^0^0^-1^0
|
||||
59013^"Current Power Save State"^32^1^50902^0^-1^0
|
||||
59014^"Previous Power Save State"^32^1^50902^0^-1^0
|
||||
59015^"Message ID"^16^0^4^0^-1^0
|
||||
70000^"USS DCS"^8^1^70000^0^-1^0
|
||||
70001^"USS Length"^8^0^2^0^-1^0
|
||||
70002^"USS Data"^8^0^2^1^-1^0
|
||||
70003^"Failure Cause"^16^0^4^1^-1^0
|
||||
70004^"Alpha DCS"^8^1^70001^0^-1^0
|
||||
70005^"Alpha Length"^8^0^2^0^-1^0
|
||||
70006^"Alpha Data"^8^0^2^1^-1^0
|
||||
70007^"Notification Type"^8^1^70002^0^-1^0
|
|
@ -0,0 +1,17 @@
|
|||
noinst_LTLIBRARIES = libQMIDB.la
|
||||
|
||||
DBFILES = \
|
||||
Entity.txt \
|
||||
EnumEntry.txt \
|
||||
Enum.txt \
|
||||
Field.txt \
|
||||
Struct.txt
|
||||
|
||||
QMIDB.o: $(DBFILES)
|
||||
$(LD) -r -b binary -o QMIDB.o $(DBFILES)
|
||||
|
||||
libQMIDB_la_SOURCES = foo.c
|
||||
|
||||
libQMIDB_la_LIBADD = QMIDB.o
|
||||
|
||||
CLEANFILES = QMIDB.o
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,31 @@
|
|||
INCLUDES = \
|
||||
-I$(top_srcdir)/Core \
|
||||
-I$(top_srcdir)/Shared
|
||||
|
||||
lib_LTLIBRARIES = libGobiConnectionMgmt.la
|
||||
|
||||
libGobiConnectionMgmt_la_CPPFLAGS = \
|
||||
-D WDS_SUPPORT \
|
||||
-D DMS_SUPPORT \
|
||||
-D NAS_SUPPORT \
|
||||
-D PDS_SUPPORT \
|
||||
-D CAT_SUPPORT \
|
||||
-D RMS_SUPPORT \
|
||||
-D OMA_SUPPORT \
|
||||
-D UIM_SUPPORT \
|
||||
-D WMS_SUPPORT \
|
||||
-D IMG2K_SUPPORT \
|
||||
-D IMG_SUPPORT \
|
||||
-D VOICE_SUPPORT
|
||||
|
||||
libGobiConnectionMgmt_la_SOURCES = \
|
||||
GobiConnectionMgmtAPI.h \
|
||||
GobiConnectionMgmt.cpp \
|
||||
GobiConnectionMgmt.h \
|
||||
GobiConnectionMgmtExports.cpp
|
||||
|
||||
libGobiConnectionMgmt_la_LIBADD = \
|
||||
$(top_builddir)/Database/QMI/libQMIDB.la \
|
||||
$(top_builddir)/Shared/libShared.la \
|
||||
$(top_builddir)/Core/libCore.la
|
||||
|
|
@ -0,0 +1,315 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
GobiQMIImageMgmt.cpp
|
||||
|
||||
DESCRIPTION:
|
||||
QUALCOMM Image Management API for Gobi 3000
|
||||
|
||||
PUBLIC CLASSES AND FUNCTIONS:
|
||||
cGobiImageMgmtDLL
|
||||
cGobiImageMgmt
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
==========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "StdAfx.h"
|
||||
#include "GobiImageMgmt.h"
|
||||
|
||||
#include "QMIBuffers.h"
|
||||
#include "QDLBuffers.h"
|
||||
|
||||
|
||||
// Global object
|
||||
cGobiImageMgmtDLL gImageDLL;
|
||||
|
||||
/*=========================================================================*/
|
||||
// cGobiImageMgmtDLL Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
cGobiImageMgmtDLL (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Constructor
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cGobiImageMgmtDLL::cGobiImageMgmtDLL()
|
||||
: mpAPI( 0 ),
|
||||
mbAllocated( false )
|
||||
{
|
||||
// Create sync CS
|
||||
pthread_mutex_init( &mSyncSection, NULL );
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
~cGobiImageMgmtDLL (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Destructor
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cGobiImageMgmtDLL::~cGobiImageMgmtDLL()
|
||||
{
|
||||
// Just in case
|
||||
if (mpAPI != 0)
|
||||
{
|
||||
mpAPI->Cleanup();
|
||||
delete mpAPI;
|
||||
mpAPI = 0;
|
||||
}
|
||||
|
||||
pthread_mutex_destroy( &mSyncSection );
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetAPI (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Return the cGobiImageMgmt object
|
||||
|
||||
RETURN VALUE:
|
||||
cGobiImageMgmt *
|
||||
===========================================================================*/
|
||||
cGobiImageMgmt * cGobiImageMgmtDLL::GetAPI()
|
||||
{
|
||||
pthread_mutex_lock( &mSyncSection );
|
||||
|
||||
bool bAlloc = mbAllocated;
|
||||
|
||||
pthread_mutex_unlock( &mSyncSection );
|
||||
|
||||
if (bAlloc == true)
|
||||
{
|
||||
return mpAPI;
|
||||
}
|
||||
|
||||
pthread_mutex_lock( &mSyncSection );
|
||||
|
||||
mpAPI = new cGobiImageMgmt;
|
||||
if (mpAPI != 0)
|
||||
{
|
||||
bool bAPI = mpAPI->Initialize();
|
||||
if (bAPI == false)
|
||||
{
|
||||
delete mpAPI;
|
||||
mpAPI = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// We have tried to allocate/initialize the object
|
||||
mbAllocated = true;
|
||||
|
||||
pthread_mutex_unlock( &mSyncSection );
|
||||
return mpAPI;
|
||||
}
|
||||
|
||||
/*=========================================================================*/
|
||||
// cGobiImageMgmt Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
cGobiImageMgmt (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Constructor
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cGobiImageMgmt::cGobiImageMgmt()
|
||||
: cGobiQMICore(),
|
||||
mTargetDeviceNode( "" ),
|
||||
mTargetDeviceKey( "" ),
|
||||
mQDL()
|
||||
{
|
||||
// We require a DMS server
|
||||
tServerConfig dmsSvr( eQMI_SVC_DMS, true );
|
||||
mServerConfig.insert( dmsSvr );
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
~cGobiImageMgmt (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Destructor
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cGobiImageMgmt::~cGobiImageMgmt()
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
Initialize (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Initialize the object
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cGobiImageMgmt::Initialize()
|
||||
{
|
||||
bool bRC = cGobiQMICore::Initialize();
|
||||
if (bRC == false)
|
||||
{
|
||||
return bRC;
|
||||
}
|
||||
|
||||
bRC = mQDL.Initialize();
|
||||
return bRC;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
Cleanup (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Cleanup the object
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cGobiImageMgmt::Cleanup()
|
||||
{
|
||||
mQDL.Cleanup();
|
||||
return cGobiQMICore::Cleanup();
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetDeviceID (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Set the ID of the device to target
|
||||
|
||||
PARAMETERS:
|
||||
deviceID [ I ] - The device ID as reported by Windows
|
||||
deviceKey [ I ] - The device key (unique, stored on-device)
|
||||
|
||||
RETURN VALUE:
|
||||
void
|
||||
===========================================================================*/
|
||||
void cGobiImageMgmt::GetDeviceID(
|
||||
std::string & deviceID,
|
||||
std::string & deviceKey )
|
||||
{
|
||||
deviceID = mTargetDeviceNode;
|
||||
deviceKey = mTargetDeviceKey;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
SetDeviceID (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Set the ID of the device to target
|
||||
|
||||
PARAMETERS:
|
||||
pDeviceID [ I ] - The device ID as reported by Windows
|
||||
pDeviceKey [ I ] - The device key (unique, stored on-device)
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cGobiImageMgmt::SetDeviceID(
|
||||
LPCSTR pDeviceID,
|
||||
LPCSTR pDeviceKey )
|
||||
{
|
||||
// Clear last error recorded
|
||||
ClearLastError();
|
||||
|
||||
// If you specify a device key then you have to specify a device ID
|
||||
if (pDeviceID == 0 && pDeviceKey != 0)
|
||||
{
|
||||
mLastError = eGOBI_ERR_INVALID_ARG;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pDeviceID == 0 || pDeviceID[0] == 0)
|
||||
{
|
||||
mTargetDeviceNode.clear();
|
||||
mTargetDeviceKey.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
mTargetDeviceNode = pDeviceID;
|
||||
if (pDeviceKey == 0 || pDeviceKey[0] == 0)
|
||||
{
|
||||
mTargetDeviceKey.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
mTargetDeviceKey = pDeviceKey;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
ResetDevice (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function resets the device
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiImageMgmt::ResetDevice()
|
||||
{
|
||||
WORD msgID = (WORD)eQMI_DMS_SET_OPERATING_MODE;
|
||||
std::vector <sDB2PackingInput> piv;
|
||||
|
||||
sProtocolEntityKey pek( eDB2_ET_QMI_DMS_REQ, msgID, 1 );
|
||||
sDB2PackingInput pi( pek, "5" );
|
||||
piv.push_back( pi );
|
||||
|
||||
// Pack up the QMI request
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
sSharedBuffer * pRequest = DB2PackQMIBuffer( db, piv );
|
||||
|
||||
// Send the QMI request, check result, and return
|
||||
return SendAndCheckReturn( eQMI_SVC_DMS, pRequest );
|
||||
}
|
|
@ -0,0 +1,186 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
GobiImageMgmt.h
|
||||
|
||||
DESCRIPTION:
|
||||
QUALCOMM Image Management API for Gobi 3000
|
||||
|
||||
PUBLIC CLASSES AND FUNCTIONS:
|
||||
cGobiImageMgmtDLL
|
||||
cGobiImageMgmt
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
==========================================================================*/
|
||||
|
||||
/*=========================================================================*/
|
||||
// Pragmas
|
||||
/*=========================================================================*/
|
||||
#pragma once
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "GobiQMICore.h"
|
||||
#include "GobiQDLCore.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
/*=========================================================================*/
|
||||
// Class cGobiImageMgmt
|
||||
/*=========================================================================*/
|
||||
class cGobiImageMgmt : public cGobiQMICore
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
cGobiImageMgmt();
|
||||
|
||||
// Destructor
|
||||
virtual ~cGobiImageMgmt();
|
||||
|
||||
// Initialize the object
|
||||
virtual bool Initialize();
|
||||
|
||||
// Cleanup the object
|
||||
virtual bool Cleanup();
|
||||
|
||||
// Get the ID of the device to target
|
||||
void GetDeviceID(
|
||||
std::string & deviceID,
|
||||
std::string & deviceKey );
|
||||
|
||||
// Set the ID of the device to target
|
||||
bool SetDeviceID(
|
||||
LPCSTR pDeviceID = 0,
|
||||
LPCSTR pDeviceKey = 0 );
|
||||
|
||||
// This function resets the device
|
||||
eGobiError ResetDevice();
|
||||
|
||||
// (Inline) Return the set of available Gobi QDL ports
|
||||
std::vector <std::string> GetAvailableQDLPorts()
|
||||
{
|
||||
return mQDL.GetAvailableQDLPorts();
|
||||
};
|
||||
|
||||
// (Inline) Set the timeout for QDL transactions
|
||||
eGobiError SetQDLTimeout( ULONG to )
|
||||
{
|
||||
return mQDL.SetQDLTimeout( to );
|
||||
};
|
||||
|
||||
// (Inline) Open the specified QDL port of the device
|
||||
eGobiError OpenQDLPort(
|
||||
std::string & portID,
|
||||
ULONG bBARMode,
|
||||
ULONG * pMajorVersion,
|
||||
ULONG * pMinorVersion )
|
||||
{
|
||||
return mQDL.OpenQDLPort( portID,
|
||||
bBARMode,
|
||||
pMajorVersion,
|
||||
pMinorVersion );
|
||||
};
|
||||
|
||||
// (Inline) Close the specified QDL port of the device
|
||||
eGobiError CloseQDLPort( bool bInformDevice )
|
||||
{
|
||||
return mQDL.CloseQDLPort( bInformDevice );
|
||||
};
|
||||
|
||||
// (Inline) Get the images preference as from the device boot downloader
|
||||
eGobiError GetQDLImagesPreference(
|
||||
ULONG * pImageListSize,
|
||||
BYTE * pImageList )
|
||||
{
|
||||
return mQDL.GetQDLImagesPreference( pImageListSize, pImageList );
|
||||
};
|
||||
|
||||
// (Inline) Prepare the device boot downloader for an image write
|
||||
eGobiError PrepareQDLImageWrite(
|
||||
BYTE imageType,
|
||||
ULONG imageSize,
|
||||
ULONG * pBlockSize )
|
||||
{
|
||||
return mQDL.PrepareQDLImageWrite( imageType, imageSize, pBlockSize );
|
||||
};
|
||||
|
||||
// (Inline) Write the specified image block to the device
|
||||
eGobiError WriteQDLImageBlock(
|
||||
USHORT sequenceNumber,
|
||||
ULONG chunkSize,
|
||||
BYTE * pImageBlock )
|
||||
{
|
||||
return mQDL.WriteQDLImageBlock( sequenceNumber,
|
||||
chunkSize,
|
||||
pImageBlock );
|
||||
};
|
||||
|
||||
// (Inline) Request the device validate the written images
|
||||
eGobiError ValidateQDLImages( BYTE * pImageType )
|
||||
{
|
||||
return mQDL.ValidateQDLImages( pImageType );
|
||||
};
|
||||
|
||||
protected:
|
||||
/* Device node/key of the device to target */
|
||||
std::string mTargetDeviceNode;
|
||||
std::string mTargetDeviceKey;
|
||||
|
||||
/* QDL protocol server */
|
||||
cGobiQDLCore mQDL;
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Class cGobiImageMgmtDLL
|
||||
/*=========================================================================*/
|
||||
class cGobiImageMgmtDLL
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
cGobiImageMgmtDLL();
|
||||
|
||||
// Destructor
|
||||
virtual ~cGobiImageMgmtDLL();
|
||||
|
||||
// Return the GobiImageMgmt object
|
||||
cGobiImageMgmt * GetAPI();
|
||||
|
||||
protected:
|
||||
/* API interface object */
|
||||
cGobiImageMgmt * mpAPI;
|
||||
|
||||
/* Above object allocation attempted? */
|
||||
bool mbAllocated;
|
||||
|
||||
/* Synchronization object */
|
||||
mutable pthread_mutex_t mSyncSection;
|
||||
};
|
||||
|
||||
extern cGobiImageMgmtDLL gImageDLL;
|
|
@ -0,0 +1,416 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
GobiImageMgmtAPI.h
|
||||
|
||||
DESCRIPTION:
|
||||
QUALCOMM Image Management API for Gobi 3000
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
==========================================================================*/
|
||||
|
||||
#ifndef GOBI_TYPEDEFS
|
||||
#define GOBI_TYPEDEFS
|
||||
|
||||
// Type Definitions
|
||||
typedef unsigned long ULONG;
|
||||
typedef unsigned long long ULONGLONG;
|
||||
typedef signed char INT8;
|
||||
typedef unsigned char BYTE;
|
||||
typedef char CHAR;
|
||||
typedef unsigned short WORD;
|
||||
typedef unsigned short USHORT;
|
||||
typedef const char * LPCSTR;
|
||||
|
||||
#endif
|
||||
|
||||
/*=========================================================================*/
|
||||
// Pragmas
|
||||
/*=========================================================================*/
|
||||
#pragma once
|
||||
|
||||
/*=========================================================================*/
|
||||
// Definitions
|
||||
/*=========================================================================*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*=========================================================================*/
|
||||
// Prototypes
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GobiEnumerateDevices
|
||||
|
||||
DESCRIPTION:
|
||||
This function enumerates the Gobi devices currently attached to the
|
||||
system
|
||||
|
||||
PARAMETERS:
|
||||
pDevicesSize [I/O] - Upon input the maximum number of elements that the
|
||||
device array can contain. Upon successful output
|
||||
the actual number of elements in the device array
|
||||
pDevices [ O ] - The device array
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG GobiEnumerateDevices(
|
||||
BYTE * pDevicesSize,
|
||||
BYTE * pDevices );
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
SetDeviceID
|
||||
|
||||
DESCRIPTION:
|
||||
This function sets the ID of the device to target
|
||||
|
||||
PARAMETERS:
|
||||
pDeviceID [ I ] - The device ID as reported by Windows
|
||||
pDeviceKey [ I ] - The device key (unique, stored on-device)
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG SetDeviceID(
|
||||
CHAR * pDeviceID,
|
||||
CHAR * pDeviceKey );
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetImagesPreference
|
||||
|
||||
DESCRIPTION:
|
||||
This function gets the current images preference
|
||||
|
||||
PARAMETERS:
|
||||
pImageListSize [I/O] - Upon input the size in BYTEs of the image list
|
||||
array. Upon success the actual number of BYTEs
|
||||
copied to the image list array
|
||||
pImageList [ O ] - The image info list array
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG GetImagesPreference(
|
||||
ULONG * pImageListSize,
|
||||
BYTE * pImageList );
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
SetImagesPreference
|
||||
|
||||
DESCRIPTION:
|
||||
This function sets the current images preference
|
||||
|
||||
PARAMETERS:
|
||||
imageListSize [ I ] - The size in BYTEs of the image list array
|
||||
pImageList [ I ] - The image list array
|
||||
bForceDownload [ I ] - Force device to download images from host?
|
||||
modemIndex [ I ] - Desired storage index for downloaded modem image
|
||||
pImageTypesSize [I/O] - Upon input the maximum number of elements that
|
||||
the download image types array can contain.
|
||||
Upon successful output the actual number of
|
||||
elements in the download image types array
|
||||
pImageTypes [ O ] - The download image types array
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG SetImagesPreference(
|
||||
ULONG imageListSize,
|
||||
BYTE * pImageList,
|
||||
ULONG bForceDownload,
|
||||
BYTE modemIndex,
|
||||
ULONG * pImageTypesSize,
|
||||
BYTE * pImageTypes );
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetBARMode
|
||||
|
||||
DESCRIPTION:
|
||||
This function returns the boot and recovery image download mode
|
||||
|
||||
PARAMETERS:
|
||||
pBARMode [ O ] - Boot and recovery image download mode
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG GetBARMode( ULONG * pBARMode );
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
SetBARMode
|
||||
|
||||
DESCRIPTION:
|
||||
This function requests the device enter boot and recovery image download
|
||||
mode after the next reset
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG SetBARMode();
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetStoredImages
|
||||
|
||||
DESCRIPTION:
|
||||
This function gets the list of images stored on the device
|
||||
|
||||
PARAMETERS:
|
||||
pImageListSize [I/O] - Upon input the size in BYTEs of the image list
|
||||
array. Upon success the actual number of BYTEs
|
||||
copied to the image list array
|
||||
pImageList [ O ] - The image info list array
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG GetStoredImages(
|
||||
ULONG * pImageListSize,
|
||||
BYTE * pImageList );
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetStoredImageInfo
|
||||
|
||||
DESCRIPTION:
|
||||
This function returns info about the specified image from the device
|
||||
|
||||
PARAMETERS:
|
||||
imageInfoSize [ I ] - The size in BYTEs of the image info array
|
||||
pImageInfo [ I ] - The image info array
|
||||
pMajorVersion [ O ] - Major version of compatible boot downloader
|
||||
pMinorVersion [ O ] - Minor version of compatible boot downloader
|
||||
pVersionID [ O ] - Image version ID
|
||||
pInfo [ O ] - Image info string
|
||||
pLockID [ O ] - Image OEM lock ID
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG GetStoredImageInfo(
|
||||
ULONG imageInfoSize,
|
||||
BYTE * pImageInfo,
|
||||
ULONG * pMajorVersion,
|
||||
ULONG * pMinorVersion,
|
||||
ULONG * pVersionID,
|
||||
CHAR * pInfo,
|
||||
ULONG * pLockID );
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
DeleteStoredImage
|
||||
|
||||
DESCRIPTION:
|
||||
This function deletes the specified image from the device
|
||||
|
||||
PARAMETERS:
|
||||
imageInfoSize [ I ] - The size in BYTEs of the image info array
|
||||
pImageInfo [ I ] - The image info array
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG DeleteStoredImage(
|
||||
ULONG imageInfoSize,
|
||||
BYTE * pImageInfo );
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
ResetDevice
|
||||
|
||||
DESCRIPTION:
|
||||
This function resets the device
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG ResetDevice();
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GobiEnumerateQDLPorts
|
||||
|
||||
DESCRIPTION:
|
||||
This function enumerates the Gobi QDL port IDs currently attached to the
|
||||
system
|
||||
|
||||
PARAMETERS:
|
||||
pPortSize [I/O] - Upon input the maximum number of elements that the
|
||||
port ID array can contain. Upon successful output
|
||||
the actual number of elements in the port ID array
|
||||
pPorts [ O ] - Port ID array
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG GobiEnumerateQDLPorts(
|
||||
BYTE * pPortSize,
|
||||
BYTE * pPorts );
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
SetQDLTimeout
|
||||
|
||||
DESCRIPTION:
|
||||
This function sets the timeout for all subsequent QDL transactions
|
||||
|
||||
PARAMETERS:
|
||||
to [ O ] - Timeout (in milliseconds) for subsequent transactions
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG SetQDLTimeout( ULONG to );
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
OpenQDLPort
|
||||
|
||||
DESCRIPTION:
|
||||
This function opens the specified QDL port of the device
|
||||
|
||||
PARAMETERS:
|
||||
pPortID [ I ] - ID of QDL port to connect to
|
||||
bBARMode [ I ] - Request boot and recovery mode feature
|
||||
pMajorVersion [ O ] - Major version of the device boot downloader
|
||||
pMinorVersion [ O ] - Minor version of the device boot downloader
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG OpenQDLPort(
|
||||
CHAR * pPortID,
|
||||
ULONG bBARMode,
|
||||
ULONG * pMajorVersion,
|
||||
ULONG * pMinorVersion );
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
CloseQDLPort
|
||||
|
||||
DESCRIPTION:
|
||||
This function closes the currently open QDL port of the device
|
||||
|
||||
PARAMETERS:
|
||||
bInformDevice [ I ] - Inform device that QDL port is being closed?
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG CloseQDLPort( ULONG bInformDevice );
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetQDLImagesPreference
|
||||
|
||||
DESCRIPTION:
|
||||
This function gets the current images preference as reported by the
|
||||
device boot downloader
|
||||
|
||||
PARAMETERS:
|
||||
pImageListSize [I/O] - Upon input the maximum number of elements that the
|
||||
image info list can contain. Upon successful output
|
||||
the actual number of elements in the image info list
|
||||
pImageList [ O ] - The image info list
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG GetQDLImagesPreference(
|
||||
ULONG * pImageListSize,
|
||||
BYTE * pImageList );
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
PrepareQDLImageWrite
|
||||
|
||||
DESCRIPTION:
|
||||
This function prepares the device boot downloader for an image write
|
||||
|
||||
PARAMETERS:
|
||||
imageType [ I ] - Type of image being written
|
||||
imageSize [ I ] - Size of image being written
|
||||
pBlockSize [I/O] - Upon input the maximum size of image block supported
|
||||
by host, upon successful output the maximum size of
|
||||
image block supported by device
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG PrepareQDLImageWrite(
|
||||
BYTE imageType,
|
||||
ULONG imageSize,
|
||||
ULONG * pBlockSize );
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
WriteQDLImageBlock
|
||||
|
||||
DESCRIPTION:
|
||||
This function writes the specified image block to the device
|
||||
|
||||
PARAMETERS:
|
||||
sequenceNumber [ I ] - Sequence number for image write
|
||||
blockSize [ I ] - Size of image block
|
||||
pImageBlock [ I ] - Image block
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG WriteQDLImageBlock(
|
||||
USHORT sequenceNumber,
|
||||
ULONG blockSize,
|
||||
BYTE * pImageBlock );
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
ValidateQDLImages
|
||||
|
||||
DESCRIPTION:
|
||||
This function requests the device validate the written images
|
||||
|
||||
PARAMETERS:
|
||||
pImageType [ O ] - Upon failure this may contain the type of the image
|
||||
that failed validation
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG ValidateQDLImages( BYTE * pImageType );
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
|
@ -0,0 +1,923 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
GobiImageMgmtExports.cpp
|
||||
|
||||
DESCRIPTION:
|
||||
QUALCOMM Image Management API for Gobi 3000 exports
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
==========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "GobiImageMgmt.h"
|
||||
#include "GobiImageMgmtAPI.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// Maximum length for adapter device path
|
||||
const ULONG MAX_DI_DEVICE_PATH = 256;
|
||||
|
||||
// Maximum length for adapter key
|
||||
const ULONG MAX_DI_KEY = 16;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas (pack structs)
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma pack( push, 1 )
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sDeviceInfo
|
||||
// Struct to represent Gobi device info
|
||||
/*=========================================================================*/
|
||||
struct sDeviceInfoElement
|
||||
{
|
||||
public:
|
||||
CHAR mPath[MAX_DI_DEVICE_PATH];
|
||||
CHAR mKey[MAX_DI_KEY];
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sPortInfo
|
||||
// Struct to represent Gobi QDL port info
|
||||
/*=========================================================================*/
|
||||
struct sPortInfoElement
|
||||
{
|
||||
public:
|
||||
CHAR mPath[MAX_DI_DEVICE_PATH];
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma pack( pop )
|
||||
|
||||
/*=========================================================================*/
|
||||
// Exported Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GobiEnumerateDevices
|
||||
|
||||
DESCRIPTION:
|
||||
This function enumerates the Gobi devices currently attached to the
|
||||
system
|
||||
|
||||
PARAMETERS:
|
||||
pDevicesSize [I/O] - Upon input the maximum number of elements that the
|
||||
device array can contain. Upon successful output
|
||||
the actual number of elements in the device array
|
||||
pDevices [ O ] - The device array
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG GobiEnumerateDevices(
|
||||
BYTE * pDevicesSize,
|
||||
BYTE * pDevices )
|
||||
{
|
||||
cGobiImageMgmt * pAPI = gImageDLL.GetAPI();
|
||||
if (pAPI == 0)
|
||||
{
|
||||
return (ULONG)eGOBI_ERR_INTERNAL;
|
||||
}
|
||||
|
||||
// Validate arguments
|
||||
if (pDevicesSize == 0 || pDevices == 0)
|
||||
{
|
||||
return (ULONG)eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
// Assume failure
|
||||
BYTE maxInstances = *pDevicesSize;
|
||||
*pDevicesSize = 0;
|
||||
|
||||
// Obtain adapter info
|
||||
std::vector <cGobiQMICore::tDeviceID> adapters;
|
||||
adapters = pAPI->GetAvailableDevices();
|
||||
|
||||
ULONG sz = (ULONG)adapters.size();
|
||||
if (sz > (ULONG)maxInstances)
|
||||
{
|
||||
sz = (ULONG)maxInstances;
|
||||
}
|
||||
|
||||
sDeviceInfoElement * pOutput = (sDeviceInfoElement *)pDevices;
|
||||
for (ULONG a = 0; a < sz; a++)
|
||||
{
|
||||
const cGobiQMICore::tDeviceID & id = adapters[a];
|
||||
|
||||
memset( &pOutput->mPath[0], 0, (SIZE_T)MAX_DI_DEVICE_PATH );
|
||||
memset( &pOutput->mKey[0], 0, (SIZE_T)MAX_DI_KEY );
|
||||
|
||||
ULONG len = id.first.size();
|
||||
if (len > 0)
|
||||
{
|
||||
if (len >= MAX_DI_DEVICE_PATH)
|
||||
{
|
||||
len = MAX_DI_DEVICE_PATH - 1;
|
||||
}
|
||||
|
||||
LPCSTR pStr = (LPCSTR)id.first.c_str();
|
||||
memcpy( (LPVOID)&pOutput->mPath[0],
|
||||
(LPCVOID)pStr,
|
||||
(SIZE_T)len );
|
||||
}
|
||||
|
||||
len = id.second.size();
|
||||
if (len > 0)
|
||||
{
|
||||
if (len >= MAX_DI_KEY)
|
||||
{
|
||||
len = MAX_DI_KEY - 1;
|
||||
}
|
||||
|
||||
LPCSTR pStr = (LPCSTR)id.second.c_str();
|
||||
memcpy( (LPVOID)&pOutput->mKey[0],
|
||||
(LPCVOID)pStr,
|
||||
(SIZE_T)len );
|
||||
}
|
||||
|
||||
pOutput++;
|
||||
}
|
||||
|
||||
*pDevicesSize = (BYTE)sz;
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
SetDeviceID
|
||||
|
||||
DESCRIPTION:
|
||||
This function sets the ID of the device to target
|
||||
|
||||
PARAMETERS:
|
||||
pDeviceID [ I ] - The device ID as reported by Windows
|
||||
pDeviceKey [ I ] - The device key (unique, stored on-device)
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG SetDeviceID(
|
||||
CHAR * pDeviceID,
|
||||
CHAR * pDeviceKey )
|
||||
{
|
||||
cGobiImageMgmt * pAPI = gImageDLL.GetAPI();
|
||||
if (pAPI == 0)
|
||||
{
|
||||
return (ULONG)eGOBI_ERR_INTERNAL;
|
||||
}
|
||||
|
||||
bool bOK = pAPI->SetDeviceID( pDeviceID, pDeviceKey );
|
||||
if (bOK == false)
|
||||
{
|
||||
return (ULONG)pAPI->GetCorrectedLastError();
|
||||
}
|
||||
|
||||
return (ULONG)eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetImagesPreference
|
||||
|
||||
DESCRIPTION:
|
||||
This function gets the current images preference
|
||||
|
||||
PARAMETERS:
|
||||
pImageListSize [I/O] - Upon input the size in BYTEs of the image list
|
||||
array. Upon success the actual number of BYTEs
|
||||
copied to the image list array
|
||||
pImageList [ O ] - The image info list array
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG GetImagesPreference(
|
||||
ULONG * pImageListSize,
|
||||
BYTE * pImageList )
|
||||
{
|
||||
cGobiImageMgmt * pAPI = gImageDLL.GetAPI();
|
||||
if (pAPI == 0)
|
||||
{
|
||||
return (ULONG)eGOBI_ERR_INTERNAL;
|
||||
}
|
||||
|
||||
std::string devID;
|
||||
std::string devKey;
|
||||
pAPI->GetDeviceID( devID, devKey );
|
||||
|
||||
LPCSTR pID = 0;
|
||||
if (devID.size() > 0)
|
||||
{
|
||||
pID = (LPCSTR)devID.c_str();
|
||||
}
|
||||
|
||||
LPCSTR pKey = 0;
|
||||
if (devKey.size() > 0)
|
||||
{
|
||||
pKey = (LPCSTR)devKey.c_str();
|
||||
}
|
||||
|
||||
bool bConnect = pAPI->Connect( pID, pKey );
|
||||
if (bConnect == false)
|
||||
{
|
||||
return (ULONG)pAPI->GetCorrectedLastError();
|
||||
}
|
||||
|
||||
ULONG rc = (ULONG)pAPI->GetImagesPreference( pImageListSize,
|
||||
pImageList );
|
||||
|
||||
pAPI->Disconnect();
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
SetImagesPreference
|
||||
|
||||
DESCRIPTION:
|
||||
This function sets the current images preference
|
||||
|
||||
PARAMETERS:
|
||||
imageListSize [ I ] - The size in BYTEs of the image list array
|
||||
pImageList [ I ] - The image list array
|
||||
bForceDownload [ I ] - Force device to download images from host?
|
||||
modemIndex [ I ] - Desired storage index for downloaded modem image
|
||||
pImageTypesSize [I/O] - Upon input the maximum number of elements that
|
||||
the download image types array can contain.
|
||||
Upon successful output the actual number of
|
||||
elements in the download image types array
|
||||
pImageTypes [ O ] - The download image types array
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG SetImagesPreference(
|
||||
ULONG imageListSize,
|
||||
BYTE * pImageList,
|
||||
ULONG bForceDownload,
|
||||
BYTE modemIndex,
|
||||
ULONG * pImageTypesSize,
|
||||
BYTE * pImageTypes )
|
||||
{
|
||||
cGobiImageMgmt * pAPI = gImageDLL.GetAPI();
|
||||
if (pAPI == 0)
|
||||
{
|
||||
return (ULONG)eGOBI_ERR_INTERNAL;
|
||||
}
|
||||
|
||||
std::string devID;
|
||||
std::string devKey;
|
||||
pAPI->GetDeviceID( devID, devKey );
|
||||
|
||||
LPCSTR pID = 0;
|
||||
if (devID.size() > 0)
|
||||
{
|
||||
pID = (LPCSTR)devID.c_str();
|
||||
}
|
||||
|
||||
LPCSTR pKey = 0;
|
||||
if (devKey.size() > 0)
|
||||
{
|
||||
pKey = (LPCSTR)devKey.c_str();
|
||||
}
|
||||
|
||||
bool bConnect = pAPI->Connect( pID, pKey );
|
||||
if (bConnect == false)
|
||||
{
|
||||
return (ULONG)pAPI->GetCorrectedLastError();
|
||||
}
|
||||
|
||||
ULONG rc = (ULONG)pAPI->SetImagesPreference( imageListSize,
|
||||
pImageList,
|
||||
bForceDownload,
|
||||
modemIndex,
|
||||
pImageTypesSize,
|
||||
pImageTypes );
|
||||
|
||||
pAPI->Disconnect();
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetBARMode
|
||||
|
||||
DESCRIPTION:
|
||||
This function returns the boot and recovery image download mode
|
||||
|
||||
PARAMETERS:
|
||||
pBARMode [ O ] - Boot and recovery image download mode
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG GetBARMode( ULONG * pBARMode )
|
||||
{
|
||||
cGobiImageMgmt * pAPI = gImageDLL.GetAPI();
|
||||
if (pAPI == 0)
|
||||
{
|
||||
return (ULONG)eGOBI_ERR_INTERNAL;
|
||||
}
|
||||
|
||||
std::string devID;
|
||||
std::string devKey;
|
||||
pAPI->GetDeviceID( devID, devKey );
|
||||
|
||||
LPCSTR pID = 0;
|
||||
if (devID.size() > 0)
|
||||
{
|
||||
pID = devID.c_str();
|
||||
}
|
||||
|
||||
LPCSTR pKey = 0;
|
||||
if (devKey.size() > 0)
|
||||
{
|
||||
pKey = devKey.c_str();
|
||||
}
|
||||
|
||||
bool bConnect = pAPI->Connect( pID, pKey );
|
||||
if (bConnect == false)
|
||||
{
|
||||
return (ULONG)pAPI->GetCorrectedLastError();
|
||||
}
|
||||
|
||||
ULONG rc = (ULONG)pAPI->GetBARMode( pBARMode );
|
||||
|
||||
pAPI->Disconnect();
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
SetBARMode
|
||||
|
||||
DESCRIPTION:
|
||||
This function requests the device enter boot and recovery image download
|
||||
mode after the next reset
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG SetBARMode()
|
||||
{
|
||||
cGobiImageMgmt * pAPI = gImageDLL.GetAPI();
|
||||
if (pAPI == 0)
|
||||
{
|
||||
return (ULONG)eGOBI_ERR_INTERNAL;
|
||||
}
|
||||
|
||||
std::string devID;
|
||||
std::string devKey;
|
||||
pAPI->GetDeviceID( devID, devKey );
|
||||
|
||||
LPCSTR pID = 0;
|
||||
if (devID.size() > 0)
|
||||
{
|
||||
pID = devID.c_str();
|
||||
}
|
||||
|
||||
LPCSTR pKey = 0;
|
||||
if (devKey.size() > 0)
|
||||
{
|
||||
pKey = devKey.c_str();
|
||||
}
|
||||
|
||||
bool bConnect = pAPI->Connect( pID, pKey );
|
||||
if (bConnect == false)
|
||||
{
|
||||
return (ULONG)pAPI->GetCorrectedLastError();
|
||||
}
|
||||
|
||||
ULONG rc = (ULONG)pAPI->SetBARMode();
|
||||
|
||||
pAPI->Disconnect();
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetStoredImages
|
||||
|
||||
DESCRIPTION:
|
||||
This function gets the list of images stored on the device
|
||||
|
||||
PARAMETERS:
|
||||
pImageListSize [I/O] - Upon input the size in BYTEs of the image list
|
||||
array. Upon success the actual number of BYTEs
|
||||
copied to the image list array
|
||||
pImageList [ O ] - The image info list array
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG GetStoredImages(
|
||||
ULONG * pImageListSize,
|
||||
BYTE * pImageList )
|
||||
{
|
||||
cGobiImageMgmt * pAPI = gImageDLL.GetAPI();
|
||||
if (pAPI == 0)
|
||||
{
|
||||
return (ULONG)eGOBI_ERR_INTERNAL;
|
||||
}
|
||||
|
||||
std::string devID;
|
||||
std::string devKey;
|
||||
pAPI->GetDeviceID( devID, devKey );
|
||||
|
||||
LPCSTR pID = 0;
|
||||
if (devID.size() > 0)
|
||||
{
|
||||
pID = (LPCSTR)devID.c_str();
|
||||
}
|
||||
|
||||
LPCSTR pKey = 0;
|
||||
if (devKey.size() > 0)
|
||||
{
|
||||
pKey = (LPCSTR)devKey.c_str();
|
||||
}
|
||||
|
||||
bool bConnect = pAPI->Connect( pID, pKey );
|
||||
if (bConnect == false)
|
||||
{
|
||||
return (ULONG)pAPI->GetCorrectedLastError();
|
||||
}
|
||||
|
||||
ULONG rc = (ULONG)pAPI->GetStoredImages( pImageListSize,
|
||||
pImageList );
|
||||
|
||||
pAPI->Disconnect();
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetStoredImageInfo
|
||||
|
||||
DESCRIPTION:
|
||||
This function returns info about the specified image from the device
|
||||
|
||||
PARAMETERS:
|
||||
imageInfoSize [ I ] - The size in BYTEs of the image info array
|
||||
pImageInfo [ I ] - The image info array
|
||||
pMajorVersion [ O ] - Major version of compatible boot downloader
|
||||
pMinorVersion [ O ] - Minor version of compatible boot downloader
|
||||
pVersionID [ O ] - Image version ID
|
||||
pInfo [ O ] - Image info string
|
||||
pLockID [ O ] - Image OEM lock ID
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG GetStoredImageInfo(
|
||||
ULONG imageInfoSize,
|
||||
BYTE * pImageInfo,
|
||||
ULONG * pMajorVersion,
|
||||
ULONG * pMinorVersion,
|
||||
ULONG * pVersionID,
|
||||
CHAR * pInfo,
|
||||
ULONG * pLockID )
|
||||
{
|
||||
cGobiImageMgmt * pAPI = gImageDLL.GetAPI();
|
||||
if (pAPI == 0)
|
||||
{
|
||||
return (ULONG)eGOBI_ERR_INTERNAL;
|
||||
}
|
||||
|
||||
std::string devID;
|
||||
std::string devKey;
|
||||
pAPI->GetDeviceID( devID, devKey );
|
||||
|
||||
LPCSTR pID = 0;
|
||||
if (devID.size() > 0)
|
||||
{
|
||||
pID = (LPCSTR)devID.c_str();
|
||||
}
|
||||
|
||||
LPCSTR pKey = 0;
|
||||
if (devKey.size() > 0)
|
||||
{
|
||||
pKey = (LPCSTR)devKey.c_str();
|
||||
}
|
||||
|
||||
bool bConnect = pAPI->Connect( pID, pKey );
|
||||
if (bConnect == false)
|
||||
{
|
||||
return (ULONG)pAPI->GetCorrectedLastError();
|
||||
}
|
||||
|
||||
ULONG rc = (ULONG)pAPI->GetStoredImageInfo( imageInfoSize,
|
||||
pImageInfo,
|
||||
pMajorVersion,
|
||||
pMinorVersion,
|
||||
pVersionID,
|
||||
pInfo,
|
||||
pLockID );
|
||||
|
||||
pAPI->Disconnect();
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
DeleteStoredImage
|
||||
|
||||
DESCRIPTION:
|
||||
This function deletes the specified image from the device
|
||||
|
||||
PARAMETERS:
|
||||
imageInfoSize [ I ] - The size in BYTEs of the image info array
|
||||
pImageInfo [ I ] - The image info array
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG DeleteStoredImage(
|
||||
ULONG imageInfoSize,
|
||||
BYTE * pImageInfo )
|
||||
{
|
||||
cGobiImageMgmt * pAPI = gImageDLL.GetAPI();
|
||||
if (pAPI == 0)
|
||||
{
|
||||
return (ULONG)eGOBI_ERR_INTERNAL;
|
||||
}
|
||||
|
||||
std::string devID;
|
||||
std::string devKey;
|
||||
pAPI->GetDeviceID( devID, devKey );
|
||||
|
||||
LPCSTR pID = 0;
|
||||
if (devID.size() > 0)
|
||||
{
|
||||
pID = (LPCSTR)devID.c_str();
|
||||
}
|
||||
|
||||
LPCSTR pKey = 0;
|
||||
if (devKey.size() > 0)
|
||||
{
|
||||
pKey = (LPCSTR)devKey.c_str();
|
||||
}
|
||||
|
||||
bool bConnect = pAPI->Connect( pID, pKey );
|
||||
if (bConnect == false)
|
||||
{
|
||||
return (ULONG)pAPI->GetCorrectedLastError();
|
||||
}
|
||||
|
||||
ULONG rc = (ULONG)pAPI->DeleteStoredImage( imageInfoSize,
|
||||
pImageInfo );
|
||||
|
||||
pAPI->Disconnect();
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
ResetDevice
|
||||
|
||||
DESCRIPTION:
|
||||
This function resets the device
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG ResetDevice()
|
||||
{
|
||||
cGobiImageMgmt * pAPI = gImageDLL.GetAPI();
|
||||
if (pAPI == 0)
|
||||
{
|
||||
return (ULONG)eGOBI_ERR_INTERNAL;
|
||||
}
|
||||
|
||||
std::string devID;
|
||||
std::string devKey;
|
||||
pAPI->GetDeviceID( devID, devKey );
|
||||
|
||||
LPCSTR pID = 0;
|
||||
if (devID.size() > 0)
|
||||
{
|
||||
pID = (LPCSTR)devID.c_str();
|
||||
}
|
||||
|
||||
LPCSTR pKey = 0;
|
||||
if (devKey.size() > 0)
|
||||
{
|
||||
pKey = (LPCSTR)devKey.c_str();
|
||||
}
|
||||
|
||||
bool bConnect = pAPI->Connect( pID, pKey );
|
||||
if (bConnect == false)
|
||||
{
|
||||
return (ULONG)pAPI->GetCorrectedLastError();
|
||||
}
|
||||
|
||||
ULONG rc = (ULONG)pAPI->ResetDevice();
|
||||
|
||||
pAPI->Disconnect();
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GobiEnumerateQDLPorts
|
||||
|
||||
DESCRIPTION:
|
||||
This function enumerates the Gobi QDL port IDs currently attached to the
|
||||
system
|
||||
|
||||
PARAMETERS:
|
||||
pPortSize [I/O] - Upon input the maximum number of elements that the
|
||||
port ID array can contain. Upon successful output
|
||||
the actual number of elements in the port ID array
|
||||
pPorts [ O ] - Port ID array
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG GobiEnumerateQDLPorts(
|
||||
BYTE * pPortSize,
|
||||
BYTE * pPorts )
|
||||
{
|
||||
cGobiImageMgmt * pAPI = gImageDLL.GetAPI();
|
||||
if (pAPI == 0)
|
||||
{
|
||||
return (ULONG)eGOBI_ERR_INTERNAL;
|
||||
}
|
||||
|
||||
// Validate arguments
|
||||
if (pPortSize == 0 || *pPortSize == 0 || pPorts == 0)
|
||||
{
|
||||
return (ULONG)eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
BYTE maxPorts = *pPortSize;
|
||||
*pPortSize = 0;
|
||||
|
||||
std::vector <std::string> ports = pAPI->GetAvailableQDLPorts();
|
||||
ULONG portCount = (ULONG)ports.size();
|
||||
if (portCount > maxPorts)
|
||||
{
|
||||
portCount = (ULONG)maxPorts;
|
||||
}
|
||||
|
||||
sPortInfoElement * pOutput = (sPortInfoElement *)pPorts;
|
||||
for (ULONG a = 0; a < portCount; a++)
|
||||
{
|
||||
memset( &pOutput->mPath[0], 0, (SIZE_T)MAX_DI_DEVICE_PATH );
|
||||
|
||||
ULONG len = ports[a].size();
|
||||
if (len > 0)
|
||||
{
|
||||
if (len >= MAX_DI_DEVICE_PATH)
|
||||
{
|
||||
len = MAX_DI_DEVICE_PATH - 1;
|
||||
}
|
||||
|
||||
LPCSTR pStr = ports[a].c_str();
|
||||
memcpy( (LPVOID)&pOutput->mPath[0],
|
||||
(LPCVOID)pStr,
|
||||
(SIZE_T)len );
|
||||
}
|
||||
|
||||
pOutput++;
|
||||
}
|
||||
|
||||
*pPortSize = (BYTE)portCount;
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
SetQDLTimeout
|
||||
|
||||
DESCRIPTION:
|
||||
This function sets the timeout for all subsequent QDL transactions
|
||||
|
||||
PARAMETERS:
|
||||
to [ O ] - Timeout (in milliseconds) for subsequent transactions
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG SetQDLTimeout( ULONG to )
|
||||
{
|
||||
cGobiImageMgmt * pAPI = gImageDLL.GetAPI();
|
||||
if (pAPI == 0)
|
||||
{
|
||||
return (ULONG)eGOBI_ERR_INTERNAL;
|
||||
}
|
||||
|
||||
return (ULONG)pAPI->SetQDLTimeout( to );
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
OpenQDLPort
|
||||
|
||||
DESCRIPTION:
|
||||
This function opens the specified QDL port of the device
|
||||
|
||||
PARAMETERS:
|
||||
pPortID [ I ] - ID of QDL port to connect to
|
||||
bBARMode [ I ] - Request boot and recovery mode feature
|
||||
pMajorVersion [ O ] - Major version of the device boot downloader
|
||||
pMinorVersion [ O ] - Minor version of the device boot downloader
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG OpenQDLPort(
|
||||
CHAR * pPortID,
|
||||
ULONG bBARMode,
|
||||
ULONG * pMajorVersion,
|
||||
ULONG * pMinorVersion )
|
||||
{
|
||||
cGobiImageMgmt * pAPI = gImageDLL.GetAPI();
|
||||
if (pAPI == 0)
|
||||
{
|
||||
return (ULONG)eGOBI_ERR_INTERNAL;
|
||||
}
|
||||
|
||||
std::string strPortID( (const char *)pPortID );
|
||||
|
||||
return (ULONG)pAPI->OpenQDLPort( strPortID,
|
||||
bBARMode,
|
||||
pMajorVersion,
|
||||
pMinorVersion );
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
CloseQDLPort
|
||||
|
||||
DESCRIPTION:
|
||||
This function closes the currently open QDL port of the device
|
||||
|
||||
PARAMETERS:
|
||||
bInformDevice [ I ] - Inform device that QDL port is being closed?
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG CloseQDLPort( ULONG bInformDevice )
|
||||
{
|
||||
cGobiImageMgmt * pAPI = gImageDLL.GetAPI();
|
||||
if (pAPI == 0)
|
||||
{
|
||||
return (ULONG)eGOBI_ERR_INTERNAL;
|
||||
}
|
||||
|
||||
bool bTmp = (bInformDevice != 0);
|
||||
return (ULONG)pAPI->CloseQDLPort( bTmp );
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetQDLImagesPreference
|
||||
|
||||
DESCRIPTION:
|
||||
This function gets the current images preference as reported by the
|
||||
device boot downloader
|
||||
|
||||
PARAMETERS:
|
||||
pImageListSize [I/O] - Upon input the maximum number of elements that the
|
||||
image info list can contain. Upon successful output
|
||||
the actual number of elements in the image info list
|
||||
pImageList [ O ] - The image info list
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG GetQDLImagesPreference(
|
||||
ULONG * pImageListSize,
|
||||
BYTE * pImageList )
|
||||
{
|
||||
cGobiImageMgmt * pAPI = gImageDLL.GetAPI();
|
||||
if (pAPI == 0)
|
||||
{
|
||||
return (ULONG)eGOBI_ERR_INTERNAL;
|
||||
}
|
||||
|
||||
return (ULONG)pAPI->GetQDLImagesPreference( pImageListSize,
|
||||
pImageList );
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
PrepareQDLImageWrite
|
||||
|
||||
DESCRIPTION:
|
||||
This function prepares the device boot downloader for an image write
|
||||
|
||||
PARAMETERS:
|
||||
imageType [ I ] - Type of image being written
|
||||
imageSize [ I ] - Size of image being written
|
||||
pBlockSize [I/O] - Upon input the maximum size of image block supported
|
||||
by host, upon successful output the maximum size of
|
||||
image block supported by device
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG PrepareQDLImageWrite(
|
||||
BYTE imageType,
|
||||
ULONG imageSize,
|
||||
ULONG * pBlockSize )
|
||||
{
|
||||
cGobiImageMgmt * pAPI = gImageDLL.GetAPI();
|
||||
if (pAPI == 0)
|
||||
{
|
||||
return (ULONG)eGOBI_ERR_INTERNAL;
|
||||
}
|
||||
|
||||
return (ULONG)pAPI->PrepareQDLImageWrite( imageType,
|
||||
imageSize,
|
||||
pBlockSize );
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
WriteQDLImageBlock
|
||||
|
||||
DESCRIPTION:
|
||||
This function writes the specified image block to the device
|
||||
|
||||
PARAMETERS:
|
||||
sequenceNumber [ I ] - Sequence number for image write
|
||||
blockSize [ I ] - Size of image block
|
||||
pImageBlock [ I ] - Image block
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG WriteQDLImageBlock(
|
||||
USHORT sequenceNumber,
|
||||
ULONG blockSize,
|
||||
BYTE * pImageBlock )
|
||||
{
|
||||
cGobiImageMgmt * pAPI = gImageDLL.GetAPI();
|
||||
if (pAPI == 0)
|
||||
{
|
||||
return (ULONG)eGOBI_ERR_INTERNAL;
|
||||
}
|
||||
|
||||
return (ULONG)pAPI->WriteQDLImageBlock( sequenceNumber,
|
||||
blockSize,
|
||||
pImageBlock );
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
ValidateQDLImages
|
||||
|
||||
DESCRIPTION:
|
||||
This function requests the device validate the written images
|
||||
|
||||
PARAMETERS:
|
||||
pImageType [ O ] - Upon failure this may contain the type of the image
|
||||
that failed validation
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
ULONG ValidateQDLImages( BYTE * pImageType )
|
||||
{
|
||||
cGobiImageMgmt * pAPI = gImageDLL.GetAPI();
|
||||
if (pAPI == 0)
|
||||
{
|
||||
return (ULONG)eGOBI_ERR_INTERNAL;
|
||||
}
|
||||
|
||||
return (ULONG)pAPI->ValidateQDLImages( pImageType );
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
INCLUDES = \
|
||||
-I$(top_srcdir)/Core \
|
||||
-I$(top_srcdir)/Shared
|
||||
|
||||
lib_LTLIBRARIES = libGobiImageMgmt.la
|
||||
|
||||
libGobiImageMgmt_la_CPPFLAGS = \
|
||||
-D WDS_SUPPORT \
|
||||
-D DMS_SUPPORT \
|
||||
-D NAS_SUPPORT \
|
||||
-D PDS_SUPPORT \
|
||||
-D CAT_SUPPORT \
|
||||
-D RMS_SUPPORT \
|
||||
-D OMA_SUPPORT \
|
||||
-D UIM_SUPPORT \
|
||||
-D WMS_SUPPORT \
|
||||
-D IMG2K_SUPPORT \
|
||||
-D IMG_SUPPORT \
|
||||
-D VOICE_SUPPORT
|
||||
|
||||
libGobiImageMgmt_la_SOURCES = \
|
||||
GobiImageMgmtAPI.h \
|
||||
GobiImageMgmt.h \
|
||||
GobiImageMgmt.cpp \
|
||||
GobiImageMgmtExports.cpp
|
||||
|
||||
libGobiImageMgmt_la_LIBADD = \
|
||||
$(top_builddir)/Database/QMI/libQMIDB.la \
|
||||
$(top_builddir)/Shared/libShared.la \
|
||||
$(top_builddir)/Core/libCore.la
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
SUBDIRS= \
|
||||
Database \
|
||||
Shared \
|
||||
Core \
|
||||
GobiConnectionMgmt \
|
||||
GobiImageMgmt \
|
||||
GobiQDLService
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
|
@ -0,0 +1,147 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
GobiError.h
|
||||
|
||||
DESCRIPTION:
|
||||
QUALCOMM Gobi Errors
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
==========================================================================*/
|
||||
|
||||
/*=========================================================================*/
|
||||
// Pragmas
|
||||
/*=========================================================================*/
|
||||
#pragma once
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "QMIEnum.h"
|
||||
#include "QDLEnum.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
/*=========================================================================*/
|
||||
// eGobiError Enumeration
|
||||
// Gobi API Error Enumeration
|
||||
/*=========================================================================*/
|
||||
enum eGobiError
|
||||
{
|
||||
eGOBI_ERR_ENUM_BEGIN = -1,
|
||||
|
||||
eGOBI_ERR_NONE, // 00 Success
|
||||
eGOBI_ERR_GENERAL, // 01 General error
|
||||
eGOBI_ERR_INTERNAL, // 02 Internal error
|
||||
eGOBI_ERR_MEMORY, // 03 Memory error
|
||||
eGOBI_ERR_INVALID_ARG, // 04 Invalid argument
|
||||
eGOBI_ERR_BUFFER_SZ, // 05 Buffer too small
|
||||
eGOBI_ERR_NO_DEVICE, // 06 Unable to detect device
|
||||
eGOBI_ERR_INVALID_DEVID, // 07 Invalid device ID
|
||||
eGOBI_ERR_NO_CONNECTION, // 08 No connection to device
|
||||
eGOBI_ERR_IFACE, // 09 Unable to obtain required interace
|
||||
eGOBI_ERR_CONNECT, // 10 Unable to connect to interface
|
||||
eGOBI_ERR_REQ_SCHEDULE, // 11 Unable to schedule request
|
||||
eGOBI_ERR_REQUEST, // 12 Error sending request
|
||||
eGOBI_ERR_RESPONSE, // 13 Error receiving response
|
||||
eGOBI_ERR_REQUEST_TO, // 14 Timeout while sending request
|
||||
eGOBI_ERR_RESPONSE_TO, // 15 Timeout while receiving response
|
||||
eGOBI_ERR_MALFORMED_RSP, // 16 Malformed response received
|
||||
eGOBI_ERR_INVALID_RSP, // 17 Invalid/error response received
|
||||
eGOBI_ERR_INVALID_FILE, // 18 Invalid file path
|
||||
eGOBI_ERR_FILE_OPEN, // 19 Unable to open file
|
||||
eGOBI_ERR_FILE_COPY, // 20 Unable to copy file
|
||||
eGOBI_ERR_QDL_SCM, // 21 Unable to open service control mgr
|
||||
eGOBI_ERR_NO_QDL_SVC, // 22 Unable to detect QDL service
|
||||
eGOBI_ERR_NO_QDL_SVC_INFO, // 23 Unable to obtain QDL service info
|
||||
eGOBI_ERR_NO_QDL_SVC_PATH, // 24 Unable to locate QSL service
|
||||
eGOBI_ERR_QDL_SVC_CFG, // 25 Unable to reconfigure QDL service
|
||||
eGOBI_ERR_QDL_SVC_IFACE, // 26 Unable to interface to QDL service
|
||||
eGOBI_ERR_OFFLINE, // 27 Unable to set device offline
|
||||
eGOBI_ERR_RESET, // 28 Unable to reset device
|
||||
eGOBI_ERR_NO_SIGNAL, // 29 No available signal
|
||||
eGOBI_ERR_MULTIPLE_DEVICES, // 30 Multiple devices detected
|
||||
eGOBI_ERR_DRIVER, // 31 Error interfacing to driver
|
||||
eGOBI_ERR_NO_CANCELABLE_OP, // 32 No cancelable operation is pending
|
||||
eGOBI_ERR_CANCEL_OP, // 33 Error canceling outstanding operation
|
||||
eGOBI_ERR_QDL_CRC, // 34 QDL image data CRC error
|
||||
eGOBI_ERR_QDL_PARSING, // 35 QDL image data parsing error
|
||||
eGOBI_ERR_QDL_AUTH, // 36 QDL image authentication error
|
||||
eGOBI_ERR_QDL_WRITE, // 37 QDL image write error
|
||||
eGOBI_ERR_QDL_OPEN_SIZE, // 38 QDL image size error
|
||||
eGOBI_ERR_QDL_OPEN_TYPE, // 39 QDL image type error
|
||||
eGOBI_ERR_QDL_OPEN_PROT, // 40 QDL memory protection error
|
||||
eGOBI_ERR_QDL_OPEN_SKIP, // 41 QDL image not required
|
||||
eGOBI_ERR_QDL_ERR_GENERAL, // 42 QDL general error
|
||||
eGOBI_ERR_QDL_BAR_MODE, // 43 QDL BAR mode error
|
||||
|
||||
eGOBI_ERR_ENUM_END,
|
||||
|
||||
// Offset from which mapped QMI error codes start from (see eQMIErrorCode)
|
||||
eGOBI_ERR_QMI_OFFSET = 1000,
|
||||
|
||||
// Offset from which mapped QDL errors start from (see eQDLError)
|
||||
eGOBI_ERR_QDL_OFFSET = 100000
|
||||
};
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
IsValid (Inline Method)
|
||||
|
||||
DESCRIPTION:
|
||||
eGobiError validity check
|
||||
|
||||
PARAMETERS:
|
||||
ec [ I ] - Enum value being verified
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
inline bool IsValid( eGobiError ec )
|
||||
{
|
||||
bool retVal = false;
|
||||
if (ec > eGOBI_ERR_ENUM_BEGIN && ec < eGOBI_ERR_ENUM_END)
|
||||
{
|
||||
retVal = true;
|
||||
}
|
||||
|
||||
if (ec >= eGOBI_ERR_QMI_OFFSET && ec < eGOBI_ERR_QDL_OFFSET)
|
||||
{
|
||||
ULONG tmp = (ULONG)ec - (ULONG)eGOBI_ERR_QMI_OFFSET;
|
||||
retVal = ::IsValid( (eQMIErrorCode)tmp );
|
||||
}
|
||||
|
||||
if (ec >= eGOBI_ERR_QDL_OFFSET)
|
||||
{
|
||||
ULONG tmp = (ULONG)ec - (ULONG)eGOBI_ERR_QDL_OFFSET;
|
||||
retVal = ::IsValid( (eQDLError)tmp );
|
||||
}
|
||||
|
||||
return retVal;
|
||||
};
|
|
@ -0,0 +1,176 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
GobiImageDefinitions.h
|
||||
|
||||
DESCRIPTION:
|
||||
QUALCOMM Gobi Image related definitions
|
||||
|
||||
PUBLIC CLASSES AND FUNCTIONS:
|
||||
eGobiDeviceType
|
||||
eGobiMBNType
|
||||
eGobiImageTech
|
||||
eGobiImageCarrier
|
||||
eGobiImageRegion
|
||||
eGobiImageGPS
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
==========================================================================*/
|
||||
|
||||
/*=========================================================================*/
|
||||
// Pragmas
|
||||
/*=========================================================================*/
|
||||
#pragma once
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
/*=========================================================================*/
|
||||
// eGobiDeviceType Enumeration
|
||||
// Gobi Device Interface Enumeration
|
||||
/*=========================================================================*/
|
||||
enum eGobiDeviceType
|
||||
{
|
||||
eGOBI_DEV_ENUM_BEGIN = -1,
|
||||
|
||||
eGOBI_DEV_NET, // 0 - Network adapter
|
||||
eGOBI_DEV_NMEA, // 1 - NMEA COM port
|
||||
eGOBI_DEV_DIAG, // 2 - DIAG port
|
||||
eGOBI_DEV_MODEM, // 3 - Modem
|
||||
eGOBI_DEV_AT, // 4 - AT port
|
||||
eGOBI_DEV_NET2, // 5 - Auxiliary network adapter
|
||||
eGOBI_DEV_QDL, // 6 - QDL port (should always be last)
|
||||
|
||||
eGOBI_DEV_ENUM_END
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// eGobiMBNType Enumeration
|
||||
// Gobi MBN File Type Enumeration
|
||||
/*=========================================================================*/
|
||||
enum eGobiMBNType
|
||||
{
|
||||
eGOBI_MBN_TYPE_ENUM_BEGIN = -1,
|
||||
|
||||
eGOBI_MBN_TYPE_MODEM, // 0 - Modem/AMSS
|
||||
eGOBI_MBN_TYPE_PRI, // 1 - PRI/UQCN
|
||||
|
||||
eGOBI_MBN_TYPE_ENUM_END,
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// eGobiImageTech Enumeration
|
||||
// Gobi Image Technology Enumeration
|
||||
/*=========================================================================*/
|
||||
enum eGobiImageTech
|
||||
{
|
||||
eGOBI_IMG_TECH_CDMA = 0, // 0 - CDMA
|
||||
eGOBI_IMG_TECH_UMTS // 1 - UMTS
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// eGobiImageCarrier Enumeration
|
||||
// Gobi Image Carrier Enumeration
|
||||
/*=========================================================================*/
|
||||
enum eGobiImageCarrier
|
||||
{
|
||||
eGOBI_IMG_CAR_GENERIC = 1, // 001
|
||||
eGOBI_IMG_CAR_FACTORY, // 002
|
||||
eGOBI_IMG_CAR_NORF, // 003
|
||||
|
||||
eGOBI_IMG_CAR_VERIZON = 101, // 101
|
||||
eGOBI_IMG_CAR_SPRINT, // 102
|
||||
eGOBI_IMG_CAR_ALLTEL, // 103
|
||||
eGOBI_IMG_CAR_BELL, // 104
|
||||
eGOBI_IMG_CAR_TELUS, // 105
|
||||
eGOBI_IMG_CAR_US, // 106
|
||||
eGOBI_IMG_CAR_TELSTRA1, // 107
|
||||
eGOBI_IMG_CAR_CHINA_UNICOM, // 108
|
||||
eGOBI_IMG_CAR_TELCOM_NZ, // 109
|
||||
eGOBI_IMG_CAR_SK_TELCOM1, // 110
|
||||
eGOBI_IMG_CAR_RELIANCE1, // 111
|
||||
eGOBI_IMG_CAR_TATA, // 112
|
||||
eGOBI_IMG_CAR_METROPCS, // 113
|
||||
eGOBI_IMG_CAR_LEAP, // 114
|
||||
eGOBI_IMG_CAR_KDDI, // 115
|
||||
eGOBI_IMG_CAR_IUSACELL, // 116
|
||||
eGOBI_IMG_CAR_CHINA_TELECOM, // 117
|
||||
eGOBI_IMG_CAR_OMH, // 118
|
||||
|
||||
eGOBI_IMG_CAR_ATT = 201, // 201
|
||||
eGOBI_IMG_CAR_VODAFONE, // 202
|
||||
eGOBI_IMG_CAR_TMOBILE, // 203
|
||||
eGOBI_IMG_CAR_ORANGE, // 204
|
||||
eGOBI_IMG_CAR_TELEFONICA, // 205
|
||||
eGOBI_IMG_CAR_TELCOM_ITALIA, // 206
|
||||
eGOBI_IMG_CAR_3, // 207
|
||||
eGOBI_IMG_CAR_O2, // 208
|
||||
eGOBI_IMG_CAR_SFR, // 209
|
||||
eGOBI_IMG_CAR_SWISSCOM, // 210
|
||||
eGOBI_IMG_CAR_CHINA_MOBILE, // 211
|
||||
eGOBI_IMG_CAR_TELSTRA2, // 212
|
||||
eGOBI_IMG_CAR_SINGTEL_OPTUS, // 213
|
||||
eGOBI_IMG_CAR_RELIANCE2, // 214
|
||||
eGOBI_IMG_CAR_BHARTI, // 215
|
||||
eGOBI_IMG_CAR_NTT_DOCOMO, // 216
|
||||
eGOBI_IMG_CAR_EMOBILE, // 217
|
||||
eGOBI_IMG_CAR_SOFTBANK, // 218
|
||||
eGOBI_IMG_CAR_KT_FREETEL, // 219
|
||||
eGOBI_IMG_CAR_SK_TELCOM2, // 220
|
||||
eGOBI_IMG_CAR_TELENOR, // 221
|
||||
eGOBI_IMG_CAR_NETCOM, // 222
|
||||
eGOBI_IMG_CAR_TELIASONERA, // 223
|
||||
eGOBI_IMG_CAR_AMX_TELCEL, // 224
|
||||
eGOBI_IMG_CAR_BRASIL_VIVO // 225
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// eGobiImageRegion Enumeration
|
||||
// Gobi Image Region Enumeration
|
||||
/*=========================================================================*/
|
||||
enum eGobiImageRegion
|
||||
{
|
||||
eGOBI_IMG_REG_NA = 0, // 0 - North America
|
||||
eGOBI_IMG_REG_LA, // 1 - Latin America
|
||||
eGOBI_IMG_REG_EU, // 2 - Europe
|
||||
eGOBI_IMG_REG_ASIA, // 3 - Asia
|
||||
eGOBI_IMG_REG_AUS, // 4 - Australia
|
||||
eGOBI_IMG_REG_GLOBAL // 5 - Global
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// eGobiImageGPS Enumeration
|
||||
// Gobi Image GPS Enumeration
|
||||
/*=========================================================================*/
|
||||
enum eGobiImageGPS
|
||||
{
|
||||
eGOBI_IMG_GPS_NONE = 0, // 0 - None
|
||||
eGOBI_IMG_GPS_STAND_ALONE, // 1 - Stand-alone
|
||||
eGOBI_IMG_GPS_ASSISTED, // 2 - Stand-alone + AGPS + XTRA
|
||||
eGOBI_IMG_GPS_NO_XTRA // 3 - Stand-alone + AGPS
|
||||
};
|
|
@ -0,0 +1,959 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
GobiMBNMgmt.cpp
|
||||
|
||||
DESCRIPTION:
|
||||
QUALCOMM Gobi MBN management functions for Gobi 3000
|
||||
|
||||
PUBLIC CLASSES AND FUNCTIONS:
|
||||
GetImageStore
|
||||
GetImageInfo
|
||||
GetImagesInfo
|
||||
GetImageBootCompatibility
|
||||
MapVersionInfo
|
||||
GetImageByUniqueID
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
==========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "StdAfx.h"
|
||||
#include "GobiMBNMgmt.h"
|
||||
#include "GobiError.h"
|
||||
|
||||
#include "CoreUtilities.h"
|
||||
#include "MemoryMappedFile.h"
|
||||
|
||||
#include <glob.h>
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// Magic values for MBN (AMSS/UQCN) images
|
||||
const ULONG MBN_LOCK_MAGIC = 0x809b1d80;
|
||||
const ULONG MBN_BOOT_MAGIC = 0xFEDC1234;
|
||||
const ULONG MBN_BUILD_MAGIC = 0xFEDC1235;
|
||||
const ULONG UQCN_INFO_MAGIC = 0xFEDC1236;
|
||||
const ULONG MBN_HASH_MAGIC = 0xFEDC1237;
|
||||
const ULONG MBN_LOCK_AUTH_MAGIC = 0xFEDC1238;
|
||||
|
||||
// Maximum length for an UQCN build info string (including NULL)
|
||||
const ULONG MBN_BUILD_ID_LEN = 32;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas (pack structs)
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma pack( push, 1 )
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sMBNBootRecord
|
||||
// Struct to represent the MBN boot flash record
|
||||
/*=========================================================================*/
|
||||
struct sMBNBootRecord
|
||||
{
|
||||
public:
|
||||
ULONG mMagic; // MBN_BOOT_MAGIC
|
||||
WORD mMajorID; // Boot flash major version
|
||||
WORD mMinorID; // Boot flash minor version
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sMBNBuildRecord
|
||||
// Struct to represent the build ID record
|
||||
/*=========================================================================*/
|
||||
struct sMBNBuildIDRecord
|
||||
{
|
||||
public:
|
||||
ULONG mMagic; // MBN_BUILD_MAGIC
|
||||
CHAR mBuildID[MBN_BUILD_ID_LEN]; // Build ID string
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sUQCNVersionID
|
||||
// Struct to represent the UQCN version ID
|
||||
/*=========================================================================*/
|
||||
struct sUQCNVersionID
|
||||
{
|
||||
public:
|
||||
ULONG mMinorID : 7;
|
||||
ULONG mXTRADisabled : 1;
|
||||
ULONG mGPSDisabled : 1;
|
||||
ULONG mReserved : 7;
|
||||
ULONG mMajorID : 8;
|
||||
ULONG mSystem : 2;
|
||||
ULONG mCompatibility : 6;
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sUQCNInfoRecord
|
||||
// Struct to represent the UQCN information record
|
||||
/*=========================================================================*/
|
||||
struct sUQCNInfoRecord
|
||||
{
|
||||
public:
|
||||
ULONG mMagic; // UQCN_INFO_MAGIC
|
||||
sUQCNVersionID mVersionID; // Version ID
|
||||
CHAR mInfo[MBN_BUILD_ID_LEN]; // Build info string
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sMBNHashRecord
|
||||
// Struct to represent the signature hash record
|
||||
/*=========================================================================*/
|
||||
struct sMBNHashRecord
|
||||
{
|
||||
public:
|
||||
ULONG mMagic; // MBN_HASH_MAGIC
|
||||
BYTE mUniqueID[MBN_UNIQUE_ID_LEN]; // Build ID string
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma pack( pop )
|
||||
|
||||
/*=========================================================================*/
|
||||
// Free Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
ReverseBinaryDataSearch (Free Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Search a data buffer for the first occurence of a specified
|
||||
sequence of data (starting from the end of the buffer)
|
||||
|
||||
PARAMETERS:
|
||||
pBuffer [ I ] - Buffer being search
|
||||
bufferLen [ I ] - Length of above buffer
|
||||
pData [ I ] - Data to search for
|
||||
dataLen [ I ] - Length of above buffer
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
const BYTE * ReverseBinaryDataSearch(
|
||||
const BYTE * pBuffer,
|
||||
ULONG bufferLen,
|
||||
const BYTE * pData,
|
||||
ULONG dataLen )
|
||||
{
|
||||
// Handle empty cases
|
||||
if (pBuffer == 0 || bufferLen == 0 || pData ==0 || dataLen == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Handle impossible case
|
||||
if (dataLen > bufferLen)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
const BYTE * pTmp = pBuffer + (bufferLen - dataLen);
|
||||
while (pTmp > pBuffer)
|
||||
{
|
||||
int res = ::memcmp( (const void *)pTmp,
|
||||
(const void *)pData,
|
||||
(size_t)dataLen );
|
||||
|
||||
if (res == 0)
|
||||
{
|
||||
return pTmp;
|
||||
}
|
||||
|
||||
pTmp--;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
ParseUQCNVersion (Free Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Parse UQCN version ID to image information
|
||||
|
||||
PARAMETERS:
|
||||
uqcnID [ I ] - UQCN ID
|
||||
pTechnology [ O ] - Technology (0xFFFFFFFF if unknown)
|
||||
pCarrier [ O ] - Carrier (0xFFFFFFFF if unknown)
|
||||
pRegion [ O ] - Region (0xFFFFFFFF if unknown)
|
||||
pGPSCapability [ O ] - GPS capability (0xFFFFFFFF if unknown)
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool ParseUQCNVersion(
|
||||
ULONG uqcnID,
|
||||
ULONG * pTechnology,
|
||||
ULONG * pCarrier,
|
||||
ULONG * pRegion,
|
||||
ULONG * pGPSCapability )
|
||||
{
|
||||
// Assume failure
|
||||
bool bRC = false;
|
||||
*pTechnology = ULONG_MAX;
|
||||
*pCarrier = ULONG_MAX;
|
||||
*pRegion = ULONG_MAX;
|
||||
*pGPSCapability = ULONG_MAX;
|
||||
|
||||
sUQCNVersionID * pID = (sUQCNVersionID *)&uqcnID;
|
||||
if (pID->mSystem == 2)
|
||||
{
|
||||
// Successs is returned when the technology is valid
|
||||
*pTechnology = (ULONG)eGOBI_IMG_TECH_UMTS;
|
||||
bRC = true;
|
||||
}
|
||||
else if (pID->mSystem == 1)
|
||||
{
|
||||
// Successs is returned when the technology is valid
|
||||
*pTechnology = (ULONG)eGOBI_IMG_TECH_CDMA;
|
||||
bRC = true;
|
||||
}
|
||||
|
||||
// Valid technology?
|
||||
if (bRC == false)
|
||||
{
|
||||
return bRC;
|
||||
}
|
||||
|
||||
switch (pID->mMajorID)
|
||||
{
|
||||
case 0x00:
|
||||
*pCarrier = (ULONG)eGOBI_IMG_CAR_FACTORY;
|
||||
*pRegion = (ULONG)eGOBI_IMG_REG_NA;
|
||||
break;
|
||||
|
||||
case 0x01:
|
||||
*pCarrier = (ULONG)eGOBI_IMG_CAR_VERIZON;
|
||||
*pRegion = (ULONG)eGOBI_IMG_REG_NA;
|
||||
break;
|
||||
|
||||
case 0x02:
|
||||
*pCarrier = (ULONG)eGOBI_IMG_CAR_SPRINT;
|
||||
*pRegion = (ULONG)eGOBI_IMG_REG_NA;
|
||||
break;
|
||||
|
||||
case 0x03:
|
||||
*pCarrier = (ULONG)eGOBI_IMG_CAR_ATT;
|
||||
*pRegion = (ULONG)eGOBI_IMG_REG_NA;
|
||||
break;
|
||||
|
||||
case 0x04:
|
||||
*pCarrier = (ULONG)eGOBI_IMG_CAR_VODAFONE;
|
||||
*pRegion = (ULONG)eGOBI_IMG_REG_EU;
|
||||
break;
|
||||
|
||||
case 0x05:
|
||||
*pCarrier = (ULONG)eGOBI_IMG_CAR_TMOBILE;
|
||||
*pRegion = (ULONG)eGOBI_IMG_REG_EU;
|
||||
break;
|
||||
|
||||
case 0x09:
|
||||
*pCarrier = (ULONG)eGOBI_IMG_CAR_GENERIC;
|
||||
*pRegion = (ULONG)eGOBI_IMG_REG_GLOBAL;
|
||||
break;
|
||||
|
||||
case 0x0B:
|
||||
*pCarrier = (ULONG)eGOBI_IMG_CAR_ORANGE;
|
||||
*pRegion = (ULONG)eGOBI_IMG_REG_EU;
|
||||
break;
|
||||
|
||||
case 0x0C:
|
||||
*pCarrier = (ULONG)eGOBI_IMG_CAR_TELEFONICA;
|
||||
*pRegion = (ULONG)eGOBI_IMG_REG_EU;
|
||||
break;
|
||||
|
||||
case 0x0D:
|
||||
*pCarrier = (ULONG)eGOBI_IMG_CAR_NTT_DOCOMO;
|
||||
*pRegion = (ULONG)eGOBI_IMG_REG_ASIA;
|
||||
break;
|
||||
|
||||
case 0x0E:
|
||||
*pCarrier = (ULONG)eGOBI_IMG_CAR_TELCOM_ITALIA;
|
||||
*pRegion = (ULONG)eGOBI_IMG_REG_EU;
|
||||
break;
|
||||
|
||||
case 0x12:
|
||||
*pCarrier = (ULONG)eGOBI_IMG_CAR_TELCOM_NZ;
|
||||
*pRegion = (ULONG)eGOBI_IMG_REG_AUS;
|
||||
break;
|
||||
|
||||
case 0x13:
|
||||
*pCarrier = (ULONG)eGOBI_IMG_CAR_CHINA_TELECOM;
|
||||
*pRegion = (ULONG)eGOBI_IMG_REG_ASIA;
|
||||
break;
|
||||
|
||||
case 0x14:
|
||||
*pCarrier = (ULONG)eGOBI_IMG_CAR_OMH;
|
||||
*pRegion = (ULONG)eGOBI_IMG_REG_GLOBAL;
|
||||
break;
|
||||
|
||||
case 0x16:
|
||||
*pCarrier = (ULONG)eGOBI_IMG_CAR_AMX_TELCEL;
|
||||
*pRegion = (ULONG)eGOBI_IMG_REG_LA;
|
||||
break;
|
||||
|
||||
case 0x17:
|
||||
*pCarrier = (ULONG)eGOBI_IMG_CAR_NORF;
|
||||
*pRegion = (ULONG)eGOBI_IMG_REG_GLOBAL;
|
||||
break;
|
||||
|
||||
case 0x18:
|
||||
*pCarrier = (ULONG)eGOBI_IMG_CAR_FACTORY;
|
||||
*pRegion = (ULONG)eGOBI_IMG_REG_GLOBAL;
|
||||
break;
|
||||
|
||||
case 0x19:
|
||||
*pCarrier = (ULONG)eGOBI_IMG_CAR_BRASIL_VIVO;
|
||||
*pRegion = (ULONG)eGOBI_IMG_REG_LA;
|
||||
break;
|
||||
}
|
||||
|
||||
// Set GPS capability
|
||||
if (pID->mGPSDisabled == 1)
|
||||
{
|
||||
*pGPSCapability = (ULONG)eGOBI_IMG_GPS_NONE;
|
||||
}
|
||||
else if (*pCarrier == (ULONG)eGOBI_IMG_CAR_NORF)
|
||||
{
|
||||
// No RF with GPS results in stand-alone GPS support only
|
||||
*pGPSCapability = (ULONG)eGOBI_IMG_GPS_STAND_ALONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pID->mXTRADisabled == 1)
|
||||
{
|
||||
*pGPSCapability = (ULONG)eGOBI_IMG_GPS_NO_XTRA;
|
||||
}
|
||||
else
|
||||
{
|
||||
*pGPSCapability = (ULONG)eGOBI_IMG_GPS_ASSISTED;
|
||||
}
|
||||
}
|
||||
|
||||
return bRC;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
ParseAMSSVersion (Free Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Parse UQCN version ID to image information
|
||||
|
||||
PARAMETERS:
|
||||
pVersion [ I ] - Version string
|
||||
pTechnology [ O ] - Technology (0xFFFFFFFF if unknown)
|
||||
pCarrier [ O ] - Carrier (0xFFFFFFFF if unknown)
|
||||
pRegion [ O ] - Region (0xFFFFFFFF if unknown)
|
||||
pGPSCapability [ O ] - GPS capability (0xFFFFFFFF if unknown)
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool ParseAMSSVersion(
|
||||
LPCSTR pVersion,
|
||||
ULONG * pTechnology,
|
||||
ULONG * pCarrier,
|
||||
ULONG * pRegion,
|
||||
ULONG * pGPSCapability )
|
||||
{
|
||||
// Assume failure
|
||||
bool bRC = false;
|
||||
*pTechnology = ULONG_MAX;
|
||||
*pCarrier = ULONG_MAX;
|
||||
*pRegion = ULONG_MAX;
|
||||
*pGPSCapability = ULONG_MAX;
|
||||
|
||||
// Validate arguments
|
||||
if (pVersion == 0 || pVersion[0] == 0)
|
||||
{
|
||||
return bRC;
|
||||
}
|
||||
|
||||
std::string tmpVer = pVersion;
|
||||
|
||||
// std::string version of MakeUpper()
|
||||
transform( tmpVer.begin(), tmpVer.end(), tmpVer.begin(), toupper );
|
||||
|
||||
if ( (tmpVer.find( "STAUFH" ) != std::string::npos)
|
||||
|| (tmpVer.find( "STSUFH" ) != std::string::npos) )
|
||||
{
|
||||
*pTechnology = (ULONG)eGOBI_IMG_TECH_CDMA;
|
||||
*pCarrier = (ULONG)eGOBI_IMG_CAR_FACTORY;
|
||||
*pRegion = (ULONG)eGOBI_IMG_REG_GLOBAL;
|
||||
|
||||
bRC = true;
|
||||
return bRC;
|
||||
}
|
||||
else if ( (tmpVer.find( "STAUVH" ) != std::string::npos)
|
||||
|| (tmpVer.find( "STSUVH" ) != std::string::npos) )
|
||||
{
|
||||
*pTechnology = (ULONG)eGOBI_IMG_TECH_CDMA;
|
||||
*pCarrier = (ULONG)eGOBI_IMG_CAR_VERIZON;
|
||||
*pRegion = (ULONG)eGOBI_IMG_REG_NA;
|
||||
|
||||
bRC = true;
|
||||
return bRC;
|
||||
}
|
||||
else if ( (tmpVer.find( "STAUSH" ) != std::string::npos)
|
||||
|| (tmpVer.find( "STSUSH" ) != std::string::npos) )
|
||||
{
|
||||
*pTechnology = (ULONG)eGOBI_IMG_TECH_CDMA;
|
||||
*pCarrier = (ULONG)eGOBI_IMG_CAR_SPRINT;
|
||||
*pRegion = (ULONG)eGOBI_IMG_REG_NA;
|
||||
|
||||
bRC = true;
|
||||
return bRC;
|
||||
}
|
||||
else if (tmpVer.find( "STSUCH" ) != std::string::npos)
|
||||
{
|
||||
*pTechnology = (ULONG)eGOBI_IMG_TECH_CDMA;
|
||||
*pCarrier = (ULONG)eGOBI_IMG_CAR_CHINA_TELECOM;
|
||||
*pRegion = (ULONG)eGOBI_IMG_REG_ASIA;
|
||||
|
||||
bRC = true;
|
||||
return bRC;
|
||||
}
|
||||
else if (tmpVer.find( "STSUOH" ) != std::string::npos)
|
||||
{
|
||||
*pTechnology = (ULONG)eGOBI_IMG_TECH_CDMA;
|
||||
*pCarrier = (ULONG)eGOBI_IMG_CAR_OMH;
|
||||
*pRegion = (ULONG)eGOBI_IMG_REG_GLOBAL;
|
||||
|
||||
bRC = true;
|
||||
return bRC;
|
||||
}
|
||||
else if ( (tmpVer.find( "STAUXN" ) != std::string::npos)
|
||||
|| (tmpVer.find( "STSUXN" ) != std::string::npos) )
|
||||
{
|
||||
*pTechnology = (ULONG)eGOBI_IMG_TECH_UMTS;
|
||||
*pCarrier = (ULONG)eGOBI_IMG_CAR_NORF;
|
||||
*pRegion = (ULONG)eGOBI_IMG_REG_GLOBAL;
|
||||
|
||||
bRC = true;
|
||||
return bRC;
|
||||
}
|
||||
else if ( (tmpVer.find( "STAUFN" ) != std::string::npos)
|
||||
|| (tmpVer.find( "STSUFN" ) != std::string::npos) )
|
||||
{
|
||||
*pTechnology = (ULONG)eGOBI_IMG_TECH_UMTS;
|
||||
*pCarrier = (ULONG)eGOBI_IMG_CAR_FACTORY;
|
||||
*pRegion = (ULONG)eGOBI_IMG_REG_GLOBAL;
|
||||
|
||||
bRC = true;
|
||||
return bRC;
|
||||
}
|
||||
else if ( (tmpVer.find( "STAUGN" ) != std::string::npos)
|
||||
|| (tmpVer.find( "STSUGN" ) != std::string::npos) )
|
||||
{
|
||||
*pTechnology = (ULONG)eGOBI_IMG_TECH_UMTS;
|
||||
*pCarrier = (ULONG)eGOBI_IMG_CAR_GENERIC;
|
||||
*pRegion = (ULONG)eGOBI_IMG_REG_GLOBAL;
|
||||
|
||||
bRC = true;
|
||||
return bRC;
|
||||
}
|
||||
|
||||
return bRC;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetImageStore (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Get the image store folder, i.e., the folder containing one or more
|
||||
carrier-specific image subfolders
|
||||
|
||||
RETURN VALUE:
|
||||
std::string - Image Store
|
||||
===========================================================================*/
|
||||
std::string GetImageStore()
|
||||
{
|
||||
std::string imageStore = GetProgramPath();
|
||||
imageStore += "Images/3000/Generic";
|
||||
|
||||
return imageStore;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetImageInfo (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Get the image information for the image specified by the given fully
|
||||
qualified path
|
||||
|
||||
PARAMETERS:
|
||||
pFilePath [ I ] - Fully qualified path to image file
|
||||
pImageType [ O ] - Image type
|
||||
pImageID [ O ] - Unique image ID
|
||||
pVersionID [ O ] - Version ID
|
||||
versionSize [ I ] - The maximum number of characters including the NULL
|
||||
terminator that can be copied to the version array
|
||||
pVersion [ O ] - NULL-terminated string representing the version
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError GetImageInfo(
|
||||
LPCSTR pFilePath,
|
||||
BYTE * pImageType,
|
||||
BYTE * pImageID,
|
||||
ULONG * pVersionID,
|
||||
USHORT versionSize,
|
||||
CHAR * pVersion )
|
||||
{
|
||||
// Validate arguments
|
||||
if ( (pFilePath == 0)
|
||||
|| (pFilePath[0] == 0)
|
||||
|| (pImageType == 0)
|
||||
|| (pImageID == 0)
|
||||
|| (pVersionID == 0)
|
||||
|| (versionSize == 0)
|
||||
|| (pVersion == 0) )
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
// Open up MBN file
|
||||
cMemoryMappedFile mbnFile( pFilePath );
|
||||
const BYTE * pMBNData = (const BYTE *)mbnFile.GetContents();
|
||||
ULONG dataSz = mbnFile.GetSize();
|
||||
|
||||
// MBN file (sort of) valid?
|
||||
if (pMBNData == 0)
|
||||
{
|
||||
return eGOBI_ERR_FILE_OPEN;
|
||||
}
|
||||
|
||||
if (dataSz <= 256)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_FILE;
|
||||
}
|
||||
|
||||
// Skip to the end
|
||||
pMBNData += (dataSz - 256);
|
||||
|
||||
// Search for the UQCN specific info
|
||||
const BYTE * pTmp = 0;
|
||||
pTmp = ReverseBinaryDataSearch( pMBNData,
|
||||
256,
|
||||
(const BYTE *)&UQCN_INFO_MAGIC,
|
||||
(ULONG)sizeof( UQCN_INFO_MAGIC ) );
|
||||
|
||||
if (pTmp != 0)
|
||||
{
|
||||
const sUQCNInfoRecord * pRec = (const sUQCNInfoRecord *)pTmp;
|
||||
*pVersionID = *(ULONG *)&pRec->mVersionID;
|
||||
*pImageType = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Since we did not find UQCN info, presume this is an AMSS file
|
||||
pTmp = ReverseBinaryDataSearch( pMBNData,
|
||||
256,
|
||||
(const BYTE *)&MBN_BOOT_MAGIC,
|
||||
(ULONG)sizeof( MBN_BOOT_MAGIC ) );
|
||||
|
||||
if (pTmp == 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_FILE;
|
||||
}
|
||||
|
||||
const sMBNBootRecord * pRec = (const sMBNBootRecord *)pTmp;
|
||||
*pVersionID = pRec->mMinorID;
|
||||
*pImageType = 0;
|
||||
}
|
||||
|
||||
// Search for the unique ID
|
||||
pTmp = ReverseBinaryDataSearch( pMBNData,
|
||||
256,
|
||||
(const BYTE *)&MBN_HASH_MAGIC,
|
||||
(ULONG)sizeof( MBN_HASH_MAGIC ) );
|
||||
|
||||
if (pTmp == 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_FILE;
|
||||
}
|
||||
|
||||
// Copy the unique ID
|
||||
const sMBNHashRecord * pHash = (const sMBNHashRecord *)pTmp;
|
||||
memcpy( (LPVOID)pImageID,
|
||||
(LPCVOID)&pHash->mUniqueID[0],
|
||||
(SIZE_T)MBN_UNIQUE_ID_LEN );
|
||||
|
||||
|
||||
// Search for the build ID
|
||||
pTmp = ReverseBinaryDataSearch( pMBNData,
|
||||
256,
|
||||
(const BYTE *)&MBN_BUILD_MAGIC,
|
||||
(ULONG)sizeof( MBN_BUILD_MAGIC ) );
|
||||
|
||||
if (pTmp == 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_FILE;
|
||||
}
|
||||
|
||||
memset( (PVOID)&pVersion[0], 0, (SIZE_T)versionSize );
|
||||
|
||||
// Copy the MBN_BUILD_MAGIC ID
|
||||
const sMBNBuildIDRecord * pRec = (const sMBNBuildIDRecord *)pTmp;
|
||||
for (ULONG t = 0; t < MBN_BUILD_ID_LEN; t++)
|
||||
{
|
||||
if (t >= versionSize)
|
||||
{
|
||||
return eGOBI_ERR_BUFFER_SZ;
|
||||
}
|
||||
|
||||
pVersion[t] = pRec->mBuildID[t];
|
||||
if (pRec->mBuildID[t] == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetImagesInfo (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Return the info for the images located at the given path
|
||||
|
||||
PARAMETERS:
|
||||
path [ I ] - Fully qualified path
|
||||
|
||||
RETURN VALUE:
|
||||
std:vector <sImageInfo> - Vector of image information
|
||||
===========================================================================*/
|
||||
std::vector <sImageInfo> GetImagesInfo( const std::string & path )
|
||||
{
|
||||
// Validate arguments
|
||||
std::vector <sImageInfo> retVec;
|
||||
if (path.size() <= 0)
|
||||
{
|
||||
return retVec;
|
||||
}
|
||||
|
||||
// Search all MBN files in the specified folder
|
||||
std::string folderSearch = path;
|
||||
|
||||
int folderLen = folderSearch.size();
|
||||
if (folderSearch[folderLen - 1] != '/')
|
||||
{
|
||||
folderSearch += '/';
|
||||
}
|
||||
|
||||
folderSearch += "*.mbn";
|
||||
|
||||
glob_t files;
|
||||
int ret = glob( folderSearch.c_str(),
|
||||
0,
|
||||
NULL,
|
||||
&files );
|
||||
if (ret != 0)
|
||||
{
|
||||
// Glob error
|
||||
return retVec;
|
||||
}
|
||||
|
||||
for (int i = 0; i < files.gl_pathc; i++)
|
||||
{
|
||||
std::string mbnName = files.gl_pathv[i];
|
||||
|
||||
BYTE imageType = UCHAR_MAX;
|
||||
BYTE imageID[16] = { 0 };
|
||||
ULONG versionID = ULONG_MAX;
|
||||
USHORT versionSz = MAX_PATH * 2 + 1;
|
||||
CHAR versionStr[MAX_PATH * 2 + 1] = { 0 };
|
||||
eGobiError rc = ::GetImageInfo( mbnName.c_str(),
|
||||
&imageType,
|
||||
&imageID[0],
|
||||
&versionID,
|
||||
versionSz,
|
||||
&versionStr[0] );
|
||||
|
||||
if (rc == eGOBI_ERR_NONE)
|
||||
{
|
||||
sImageInfo ii;
|
||||
ii.mImageType = (eGobiMBNType)imageType;
|
||||
ii.mVersionID = versionID;
|
||||
ii.mVersion = (LPCSTR)&versionStr[0];
|
||||
memcpy( (LPVOID)&ii.mImageID[0], (LPCVOID)&imageID[0], 16 );
|
||||
|
||||
retVec.push_back( ii );
|
||||
}
|
||||
}
|
||||
globfree( &files );
|
||||
|
||||
return retVec;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetImageBootCompatibility (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Get the image boot compatibility for the image specified by the given
|
||||
fully qualified path
|
||||
|
||||
PARAMETERS:
|
||||
pFilePath [ I ] - Fully qualified path to image file
|
||||
pMajorVersion [ O ] - Major version of compatible boot downloader
|
||||
pMinorVersion [ O ] - Minor version of compatible boot downloader
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError GetImageBootCompatibility(
|
||||
LPCSTR pFilePath,
|
||||
ULONG * pMajorVersion,
|
||||
ULONG * pMinorVersion )
|
||||
{
|
||||
// Validate arguments
|
||||
if ( (pFilePath == 0)
|
||||
|| (pFilePath[0] == 0)
|
||||
|| (pMajorVersion == 0)
|
||||
|| (pMinorVersion == 0) )
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
// Open up MBN file
|
||||
cMemoryMappedFile mbnFile( pFilePath );
|
||||
const BYTE * pMBNData = (const BYTE *)mbnFile.GetContents();
|
||||
ULONG dataSz = mbnFile.GetSize();
|
||||
|
||||
// MBN file (sort of) valid?
|
||||
if (pMBNData == 0)
|
||||
{
|
||||
return eGOBI_ERR_FILE_OPEN;
|
||||
}
|
||||
|
||||
if (dataSz <= 256)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_FILE;
|
||||
}
|
||||
|
||||
// Skip to the end
|
||||
pMBNData += (dataSz - 256);
|
||||
|
||||
const BYTE * pTmp = 0;
|
||||
pTmp = ReverseBinaryDataSearch( pMBNData,
|
||||
256,
|
||||
(const BYTE *)&MBN_BOOT_MAGIC,
|
||||
(ULONG)sizeof( MBN_BOOT_MAGIC ) );
|
||||
|
||||
if (pTmp == 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_FILE;
|
||||
}
|
||||
|
||||
const sMBNBootRecord * pRec = (const sMBNBootRecord *)pTmp;
|
||||
*pMajorVersion = pRec->mMajorID;
|
||||
*pMinorVersion = pRec->mMinorID;
|
||||
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
MapVersionInfo (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Map the specified version string to image capabilities
|
||||
|
||||
PARAMETERS:
|
||||
versionID [ I ] - Version ID
|
||||
imageType [ I ] - Image type
|
||||
pVersion [ I ] - Version string for image
|
||||
pTechnology [ O ] - Technology type
|
||||
pCarrier [ O ] - Carrier type
|
||||
pRegion [ O ] - Region type
|
||||
pGPSCapability [ O ] - GPS capability
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError MapVersionInfo(
|
||||
ULONG versionID,
|
||||
BYTE imageType,
|
||||
LPCSTR pVersion,
|
||||
ULONG * pTechnology,
|
||||
ULONG * pCarrier,
|
||||
ULONG * pRegion,
|
||||
ULONG * pGPSCapability )
|
||||
{
|
||||
if ((eGobiMBNType)imageType == eGOBI_MBN_TYPE_MODEM)
|
||||
{
|
||||
// AMSS (modem)
|
||||
bool bOK = ParseAMSSVersion( pVersion,
|
||||
pTechnology,
|
||||
pCarrier,
|
||||
pRegion,
|
||||
pGPSCapability );
|
||||
|
||||
if (bOK == false)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
}
|
||||
else if ((eGobiMBNType)imageType == eGOBI_MBN_TYPE_PRI)
|
||||
{
|
||||
// UQCN (PRI)
|
||||
bool bOK = ParseUQCNVersion( versionID,
|
||||
pTechnology,
|
||||
pCarrier,
|
||||
pRegion,
|
||||
pGPSCapability );
|
||||
|
||||
if (bOK == false)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
}
|
||||
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetImageByUniqueID (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Return the fully qualified path to an image specified by unique ID
|
||||
|
||||
PARAMETERS:
|
||||
pImageID [ I ] - Unique image ID
|
||||
|
||||
RETURN VALUE:
|
||||
std::string - Fully qualified path to matching image
|
||||
===========================================================================*/
|
||||
std::string GetImageByUniqueID( BYTE * pImageID )
|
||||
{
|
||||
// Validate arguments
|
||||
std::string retStr = "";
|
||||
if (pImageID == 0)
|
||||
{
|
||||
return retStr;
|
||||
}
|
||||
|
||||
// Enumerate all folders of the image store
|
||||
std::vector <std::string> folders;
|
||||
std::string imageStore = ::GetImageStore();
|
||||
EnumerateFolders( imageStore, folders );
|
||||
|
||||
// Did we find any folders?
|
||||
ULONG foldersSz = (ULONG)folders.size();
|
||||
if (foldersSz == 0)
|
||||
{
|
||||
return retStr;
|
||||
}
|
||||
|
||||
// Go through each folder searching for a match
|
||||
for (ULONG f = 0; f < foldersSz; f++)
|
||||
{
|
||||
// Search all MBN files in the specified folder
|
||||
std::string folderSearch = folders[f];
|
||||
|
||||
int folderLen = folderSearch.size();
|
||||
if (folderSearch[folderLen - 1] != '/')
|
||||
{
|
||||
folderSearch += '/';
|
||||
}
|
||||
|
||||
folderSearch += "*.mbn";
|
||||
|
||||
glob_t files;
|
||||
int ret = glob( folderSearch.c_str(),
|
||||
0,
|
||||
NULL,
|
||||
&files );
|
||||
if (ret != 0)
|
||||
{
|
||||
// Glob error, often GLOB_NOMATCH
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int i = 0; i < files.gl_pathc; i++)
|
||||
{
|
||||
std::string mbnName = files.gl_pathv[i];
|
||||
|
||||
BYTE imageType = UCHAR_MAX;
|
||||
BYTE imageID[16] = { 0 };
|
||||
ULONG versionID = ULONG_MAX;
|
||||
USHORT versionSz = MAX_PATH * 2 + 1;
|
||||
CHAR versionStr[MAX_PATH * 2 + 1] = { 0 };
|
||||
eGobiError rc = ::GetImageInfo( mbnName.c_str(),
|
||||
&imageType,
|
||||
&imageID[0],
|
||||
&versionID,
|
||||
versionSz,
|
||||
&versionStr[0] );
|
||||
|
||||
if (rc == eGOBI_ERR_NONE)
|
||||
{
|
||||
bool bMatch = true;
|
||||
for (ULONG i = 0; i < 16; i++)
|
||||
{
|
||||
if (imageID[i] != pImageID[i])
|
||||
{
|
||||
bMatch = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bMatch == true)
|
||||
{
|
||||
retStr = mbnName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
globfree( &files );
|
||||
|
||||
if (retStr.size() > 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return retStr;
|
||||
}
|
||||
|
|
@ -0,0 +1,226 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
GobiMBNMgmt.h
|
||||
|
||||
DESCRIPTION:
|
||||
QUALCOMM Gobi MBN management functions for Gobi 3000
|
||||
|
||||
PUBLIC CLASSES AND FUNCTIONS:
|
||||
sImageInfo
|
||||
GetImageStore
|
||||
GetImageInfo
|
||||
GetImagesInfo
|
||||
GetImageBootCompatibility
|
||||
MapVersionInfo
|
||||
GetImageByUniqueID
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
==========================================================================*/
|
||||
|
||||
/*=========================================================================*/
|
||||
// Pragmas
|
||||
/*=========================================================================*/
|
||||
#pragma once
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "GobiImageDefinitions.h"
|
||||
#include "GobiError.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// Maximum length for unique image ID
|
||||
const ULONG MBN_UNIQUE_ID_LEN = 16;
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sImageInfo
|
||||
// Storage structure for Image information
|
||||
/*=========================================================================*/
|
||||
struct sImageInfo
|
||||
{
|
||||
public:
|
||||
// Default constructor
|
||||
sImageInfo()
|
||||
: mImageType( eGOBI_MBN_TYPE_ENUM_BEGIN ),
|
||||
mVersionID( ULONG_MAX ),
|
||||
mVersion( "" )
|
||||
{
|
||||
memset( (LPVOID)&mImageID[0], 0, MBN_UNIQUE_ID_LEN );
|
||||
};
|
||||
|
||||
// Is this object valid?
|
||||
bool IsValid() const
|
||||
{
|
||||
return ( (mImageType != eGOBI_MBN_TYPE_ENUM_BEGIN)
|
||||
&& (mVersionID != ULONG_MAX)
|
||||
&& (mVersion.size() > 0) );
|
||||
};
|
||||
|
||||
/* Image type */
|
||||
eGobiMBNType mImageType;
|
||||
|
||||
/* Unique image ID */
|
||||
BYTE mImageID[MBN_UNIQUE_ID_LEN];
|
||||
|
||||
/* Version ID */
|
||||
ULONG mVersionID;
|
||||
|
||||
/* Version string */
|
||||
std::string mVersion;
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Public Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetImageStore (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Return the image store folder, i.e., the folder containing one or more
|
||||
carrier-specific image subfolders
|
||||
|
||||
RETURN VALUE:
|
||||
std::string - Image Store
|
||||
===========================================================================*/
|
||||
std::string GetImageStore();
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetImageInfo (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Get the image information for the image specified by the given fully
|
||||
qualified path
|
||||
|
||||
PARAMETERS:
|
||||
pFilePath [ I ] - Fully qualified path to image file
|
||||
pImageType [ O ] - Image type
|
||||
pImageID [ O ] - Unique image ID
|
||||
pVersionID [ O ] - Version ID
|
||||
versionSize [ I ] - The maximum number of characters including the NULL
|
||||
terminator that can be copied to the version array
|
||||
pVersion [ O ] - NULL-terminated string representing the version
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError GetImageInfo(
|
||||
LPCSTR pFilePath,
|
||||
BYTE * pImageType,
|
||||
BYTE * pImageID,
|
||||
ULONG * pVersionID,
|
||||
USHORT versionSize,
|
||||
CHAR * pVersion );
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetImagesInfo (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Return the info for the images located at the given path
|
||||
|
||||
PARAMETERS:
|
||||
path [ I ] - Fully qualified path
|
||||
|
||||
RETURN VALUE:
|
||||
std:vector <sImageInfo> - Vector of image information
|
||||
===========================================================================*/
|
||||
std::vector <sImageInfo> GetImagesInfo( const std::string & path );
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetImageBootCompatibility (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Get the image boot compatibility for the image specified by the given
|
||||
fully qualified path
|
||||
|
||||
PARAMETERS:
|
||||
pFilePath [ I ] - Fully qualified path to image file
|
||||
pMajorVersion [ O ] - Major version of compatible boot downloader
|
||||
pMinorVersion [ O ] - Minor version of compatible boot downloader
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError GetImageBootCompatibility(
|
||||
LPCSTR pFilePath,
|
||||
ULONG * pMajorVersion,
|
||||
ULONG * pMinorVersion );
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
MapVersionInfo (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Map the specified version string to image capabilities
|
||||
|
||||
PARAMETERS:
|
||||
versionID [ I ] - Version ID
|
||||
imageType [ I ] - Image type
|
||||
pVersion [ I ] - Version string for image
|
||||
pTechnology [ O ] - Technology type
|
||||
pCarrier [ O ] - Carrier type
|
||||
pRegion [ O ] - Region type
|
||||
pGPSCapability [ O ] - GPS capability
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError MapVersionInfo(
|
||||
ULONG versionID,
|
||||
BYTE imageType,
|
||||
LPCSTR pVersion,
|
||||
ULONG * pTechnology,
|
||||
ULONG * pCarrier,
|
||||
ULONG * pRegion,
|
||||
ULONG * pGPSCapability );
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetImageByUniqueID (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Return the fully qualified path to an image specified by unique ID
|
||||
|
||||
PARAMETERS:
|
||||
pImageID [ I ] - Unique image ID
|
||||
|
||||
RETURN VALUE:
|
||||
std::string - Fully qualified path to matching image
|
||||
===========================================================================*/
|
||||
std::string GetImageByUniqueID( BYTE * pImageID );
|
||||
|
||||
|
|
@ -0,0 +1,949 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
GobiQDLCore.cpp
|
||||
|
||||
DESCRIPTION:
|
||||
QUALCOMM Gobi QDL Based API Core
|
||||
|
||||
PUBLIC CLASSES AND FUNCTIONS:
|
||||
cGobiQDLCore
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
==========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "StdAfx.h"
|
||||
#include "GobiQDLCore.h"
|
||||
|
||||
#include "QDLBuffers.h"
|
||||
#include "ProtocolNotification.h"
|
||||
|
||||
#include <glob.h>
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// Default/minimum timeout for QCWWAN QMI requests
|
||||
const ULONG DEFAULT_GOBI_QDL_TIMEOUT = 4000;
|
||||
const ULONG MINIMUM_GOBI_QDL_TIMEOUT = 2000;
|
||||
|
||||
/*=========================================================================*/
|
||||
// cGobiQDLCore Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
cGobiQDLCore (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Constructor
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cGobiQDLCore::cGobiQDLCore()
|
||||
: mQDL( 512, 512 ),
|
||||
mQDLPortNode( "" ),
|
||||
mQDLTimeout( DEFAULT_GOBI_QDL_TIMEOUT )
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
~cGobiQDLCore (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Destructor
|
||||
|
||||
RETURN VALUE:
|
||||
None
|
||||
===========================================================================*/
|
||||
cGobiQDLCore::~cGobiQDLCore()
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
Initialize (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Initialize the object
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cGobiQDLCore::Initialize()
|
||||
{
|
||||
// Nothing to do
|
||||
return true;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
Cleanup (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Cleanup the object
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cGobiQDLCore::Cleanup()
|
||||
{
|
||||
// Just in case
|
||||
CloseQDLPort( false );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetAvailableQDLPorts (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Return the set of available Gobi QDL ports
|
||||
|
||||
RETURN VALUE:
|
||||
std::vector <sDeviceID>
|
||||
===========================================================================*/
|
||||
std::vector <std::string> cGobiQDLCore::GetAvailableQDLPorts()
|
||||
{
|
||||
std::vector <std::string> devices;
|
||||
|
||||
std::string path = "/sys/bus/usb/devices/";
|
||||
|
||||
glob_t files;
|
||||
int ret = glob( (path + "*/*/ttyUSB*").c_str(),
|
||||
0,
|
||||
NULL,
|
||||
&files );
|
||||
if (ret != 0)
|
||||
{
|
||||
// Glob failure
|
||||
return devices;
|
||||
}
|
||||
|
||||
for (int i = 0; i < files.gl_pathc; i++)
|
||||
{
|
||||
// Example "/sys/bus/usb/devices/8-1/8-1:1.1/ttyUSB0"
|
||||
std::string nodePath = files.gl_pathv[i];
|
||||
|
||||
int lastSlash = nodePath.find_last_of( "/" );
|
||||
|
||||
// This is what we want to return if everything else matches
|
||||
std::string deviceNode = nodePath.substr( lastSlash + 1 );
|
||||
|
||||
// Move down one directory to the interface level
|
||||
std::string curPath = nodePath.substr( 0, lastSlash );
|
||||
|
||||
// Read bInterfaceNumber
|
||||
int handle = open( (curPath + "/bInterfaceNumber").c_str(),
|
||||
O_RDONLY );
|
||||
if (handle == -1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
char buff[4];
|
||||
memset( buff, 0, 4 );
|
||||
|
||||
bool bFound = false;
|
||||
ret = read( handle, buff, 2 );
|
||||
if (ret == 2)
|
||||
{
|
||||
// Interface 1 or 0
|
||||
ret = strncmp( buff, "01", 2 );
|
||||
if (ret == 0)
|
||||
{
|
||||
bFound = true;
|
||||
}
|
||||
ret = strncmp( buff, "00", 2 );
|
||||
if (ret == 0)
|
||||
{
|
||||
bFound = true;
|
||||
}
|
||||
|
||||
}
|
||||
close( handle );
|
||||
|
||||
if (bFound == false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Move down one directory to the device level
|
||||
curPath = curPath.substr( 0, curPath.find_last_of( "/" ) );
|
||||
|
||||
// Read idVendor
|
||||
handle = open( (curPath + "/idVendor").c_str(), O_RDONLY );
|
||||
if (handle == -1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
bFound = false;
|
||||
ret = read( handle, buff, 4 );
|
||||
if (ret == 4)
|
||||
{
|
||||
ret = strncmp( buff, "05c6", 4 );
|
||||
if (ret == 0)
|
||||
{
|
||||
bFound = true;
|
||||
}
|
||||
}
|
||||
close( handle );
|
||||
|
||||
if (bFound == false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Read idProduct
|
||||
handle = open( (curPath + "/idProduct").c_str(), O_RDONLY );
|
||||
if (handle == -1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
bFound = false;
|
||||
ret = read( handle, buff, 4 );
|
||||
if (ret == 4)
|
||||
{
|
||||
ret = strncmp( buff, "920c", 4 );
|
||||
if (ret == 0)
|
||||
{
|
||||
bFound = true;
|
||||
}
|
||||
}
|
||||
close( handle );
|
||||
|
||||
if (bFound == false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Success!
|
||||
devices.push_back( deviceNode );
|
||||
}
|
||||
globfree( &files );
|
||||
|
||||
return devices;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
SetQDLTimeout (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Set the timeout for all subsequent QDL transactions
|
||||
|
||||
PARAMETERS:
|
||||
to [ I ] - Timeout value (in milliseconds)
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQDLCore::SetQDLTimeout( ULONG to )
|
||||
{
|
||||
if (to < MINIMUM_GOBI_QDL_TIMEOUT)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
mQDLTimeout = to;
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
OpenQDLPort (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function opens the specified QDL port of the device
|
||||
|
||||
PARAMETERS:
|
||||
portID [ I ] - ID of QDL port to connect to
|
||||
bBARMode [ I ] - Request boot and recovery mode feature
|
||||
pMajorVersion [ O ] - Major version of the device boot downloader
|
||||
pMinorVersion [ O ] - Minor version of the device boot downloader
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQDLCore::OpenQDLPort(
|
||||
std::string & portID,
|
||||
ULONG bBARMode,
|
||||
ULONG * pMajorVersion,
|
||||
ULONG * pMinorVersion )
|
||||
{
|
||||
if (portID.empty() == true || pMajorVersion == 0 || pMinorVersion == 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
// First disconnect from current port (if any)
|
||||
CloseQDLPort( false );
|
||||
|
||||
// Validate port ID
|
||||
std::string foundDevice;
|
||||
std::vector <std::string> availPorts = GetAvailableQDLPorts();
|
||||
for (int index = 0; index < availPorts.size(); index++)
|
||||
{
|
||||
if (availPorts[index] == portID)
|
||||
{
|
||||
foundDevice = availPorts[index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (foundDevice.empty() == true)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_DEVID;
|
||||
}
|
||||
|
||||
// Initialize server (we don't care about the return code
|
||||
// since the following Connect() call will fail if we are
|
||||
// unable to initialize the server)
|
||||
mQDL.Initialize();
|
||||
|
||||
// Connect to the port
|
||||
std::string deviceStr = "/dev/" + foundDevice;
|
||||
bool bOK = mQDL.Connect( deviceStr.c_str() );
|
||||
if (bOK == false)
|
||||
{
|
||||
return eGOBI_ERR_CONNECT;
|
||||
}
|
||||
|
||||
// Store port ID (we are connected)
|
||||
mQDLPortNode = foundDevice;
|
||||
|
||||
// Build the hello request
|
||||
bool bBARFeature = bBARMode != 0;
|
||||
sSharedBuffer * pHelloBuf = sQDLHello::BuildHelloReq( bBARFeature );
|
||||
if (pHelloBuf == 0)
|
||||
{
|
||||
return eGOBI_ERR_MEMORY;
|
||||
}
|
||||
|
||||
// Send the hello request and wait for the response
|
||||
sProtocolBuffer rsp;
|
||||
rsp = SendQDL( pHelloBuf );
|
||||
if (rsp.IsValid() == false)
|
||||
{
|
||||
return GetCorrectedLastError();
|
||||
}
|
||||
|
||||
// Extract major and minor boot downloader versions
|
||||
ULONG majVer;
|
||||
ULONG minVer;
|
||||
sQDLHello helloRsp( rsp.GetSharedBuffer() );
|
||||
if (helloRsp.GetBootVersionInfo( majVer, minVer ) == false)
|
||||
{
|
||||
sQDLError errRsp( rsp.GetSharedBuffer() );
|
||||
if (errRsp.IsValid() == true)
|
||||
{
|
||||
eQDLError qdlErr = errRsp.GetErrorCode();
|
||||
return GetCorrectedQDLError( qdlErr );
|
||||
}
|
||||
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
|
||||
// NOTE: in the current firmware implimentation, this cannot happen.
|
||||
// No hello response will be received in case of feature mismatch.
|
||||
if (bBARFeature == true)
|
||||
{
|
||||
const sQDLRawHelloRsp * pTmpRsp = helloRsp.GetResponse();
|
||||
if (pTmpRsp == 0)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
|
||||
if ( (pTmpRsp->mFeatures & QDL_FEATURE_BAR_MODE) == 0)
|
||||
{
|
||||
return eGOBI_ERR_QDL_BAR_MODE;
|
||||
}
|
||||
}
|
||||
|
||||
*pMajorVersion = majVer;
|
||||
*pMinorVersion = minVer;
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
CloseQDLPort (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function closes the currently open QDL port of the device
|
||||
|
||||
PARAMETERS:
|
||||
bInformDevice [ I ] - Inform device that QDL port is being closed?
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQDLCore::CloseQDLPort( bool bInformDevice )
|
||||
{
|
||||
// Assume success
|
||||
eGobiError rc = eGOBI_ERR_NONE;
|
||||
if (mQDLPortNode.empty() == true)
|
||||
{
|
||||
rc = eGOBI_ERR_NO_CONNECTION;
|
||||
}
|
||||
else if (bInformDevice == true)
|
||||
{
|
||||
BYTE cmd = (BYTE)eQDL_CMD_SESSION_CLOSE_REQ;
|
||||
eProtocolType pt = ePROTOCOL_QDL_TX;
|
||||
|
||||
sSharedBuffer * pReq = 0;
|
||||
pReq = new sSharedBuffer( (const BYTE *)&cmd, 1, pt );
|
||||
if (pReq == 0)
|
||||
{
|
||||
rc = eGOBI_ERR_MEMORY;
|
||||
}
|
||||
else
|
||||
{
|
||||
sProtocolBuffer rsp = SendQDL( pReq, 0, 0, false );
|
||||
rc = GetLastError();
|
||||
}
|
||||
}
|
||||
|
||||
mQDL.Disconnect();
|
||||
mQDL.Exit();
|
||||
|
||||
mQDLPortNode.clear();
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetQDLImagesPreference (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function gets the current images preference as reported by the
|
||||
device boot downloader
|
||||
|
||||
PARAMETERS:
|
||||
pImageListSize [I/O] - Upon input the maximum number of elements that the
|
||||
image info list can contain. Upon successful output
|
||||
the actual number of elements in the image info list
|
||||
pImageList [ O ] - The image info list
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQDLCore::GetQDLImagesPreference(
|
||||
ULONG * pImageListSize,
|
||||
BYTE * pImageList )
|
||||
{
|
||||
if (pImageListSize == 0 || *pImageListSize == 0 || pImageList == 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
BYTE cmd = (BYTE)eQDL_CMD_GET_IMAGE_PREF_REQ;
|
||||
eProtocolType pt = ePROTOCOL_QDL_TX;
|
||||
|
||||
sSharedBuffer * pReq = 0;
|
||||
pReq = new sSharedBuffer( (const BYTE *)&cmd, 1, pt );
|
||||
if (pReq == 0)
|
||||
{
|
||||
return eGOBI_ERR_MEMORY;
|
||||
}
|
||||
|
||||
ULONG maxImages = (ULONG)*pImageListSize;
|
||||
*pImageListSize = 0;
|
||||
|
||||
sProtocolBuffer rsp = SendQDL( pReq );
|
||||
if (rsp.IsValid() == false)
|
||||
{
|
||||
return GetCorrectedLastError();
|
||||
}
|
||||
|
||||
sQDLGetImagePref prefRsp( rsp.GetSharedBuffer() );
|
||||
if (prefRsp.IsValid() == false)
|
||||
{
|
||||
sQDLError errRsp( rsp.GetSharedBuffer() );
|
||||
if (errRsp.IsValid() == true)
|
||||
{
|
||||
eQDLError qdlErr = errRsp.GetErrorCode();
|
||||
return GetCorrectedQDLError( qdlErr );
|
||||
}
|
||||
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
|
||||
std::list <sQDLRawImageID> imageIDs = prefRsp.GetImageIDs();
|
||||
ULONG imageCount = (ULONG)imageIDs.size();
|
||||
if (imageCount > maxImages)
|
||||
{
|
||||
imageCount = maxImages;
|
||||
}
|
||||
|
||||
sQDLRawImageID * pOutList = (sQDLRawImageID *)pImageList;
|
||||
std::list <sQDLRawImageID>::const_iterator pIter = imageIDs.begin();
|
||||
for (ULONG i = 0; i < imageCount; i++)
|
||||
{
|
||||
*pOutList++ = *pIter++;
|
||||
}
|
||||
|
||||
*pImageListSize = imageCount;
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
PrepareQDLImageWrite (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function prepares the device boot downloader for an image write
|
||||
|
||||
PARAMETERS:
|
||||
imageType [ I ] - Type of image being written
|
||||
imageSize [ I ] - Size of image being written
|
||||
pBlockSize [I/O] - Upon input the maximum size of image block supported
|
||||
by host, upon successful output the maximum size of
|
||||
image block supported by device
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQDLCore::PrepareQDLImageWrite(
|
||||
BYTE imageType,
|
||||
ULONG imageSize,
|
||||
ULONG * pBlockSize )
|
||||
{
|
||||
eQDLImageType it = (eQDLImageType)imageType;
|
||||
if (::IsValid( it ) == false)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (pBlockSize == 0 || *pBlockSize == 0 || *pBlockSize > QDL_MAX_CHUNK_SIZE)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
sSharedBuffer * pReq = 0;
|
||||
pReq = sQDLOpenUnframed::BuildOpenUnframedReq( it, imageSize, *pBlockSize );
|
||||
if (pReq == 0)
|
||||
{
|
||||
return eGOBI_ERR_MEMORY;
|
||||
}
|
||||
|
||||
sProtocolBuffer rsp = SendQDL( pReq );
|
||||
if (rsp.IsValid() == false)
|
||||
{
|
||||
return GetCorrectedLastError();
|
||||
}
|
||||
|
||||
ULONG tmp;
|
||||
sQDLOpenUnframed openRsp( rsp.GetSharedBuffer() );
|
||||
const sQDLRawOpenUnframedRsp * pTmp = openRsp.GetResponse();
|
||||
if (pTmp == 0 || openRsp.GetChunkSize( tmp ) == false)
|
||||
{
|
||||
sQDLError errRsp( rsp.GetSharedBuffer() );
|
||||
if (errRsp.IsValid() == true)
|
||||
{
|
||||
eQDLError qdlErr = errRsp.GetErrorCode();
|
||||
return GetCorrectedQDLError( qdlErr );
|
||||
}
|
||||
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
|
||||
if (openRsp.IsSuccess() == false)
|
||||
{
|
||||
switch ((eQDLOpenStatus)pTmp->mStatus)
|
||||
{
|
||||
case eQDL_OPEN_STATUS_SIZE:
|
||||
return eGOBI_ERR_QDL_OPEN_SIZE;
|
||||
|
||||
case eQDL_OPEN_STATUS_BAD_TYPE:
|
||||
return eGOBI_ERR_QDL_OPEN_TYPE;
|
||||
|
||||
case eQDL_OPEN_STATUS_PROTECTION:
|
||||
return eGOBI_ERR_QDL_OPEN_PROT;
|
||||
|
||||
case eQDL_OPEN_STATUS_NOT_NEEDED:
|
||||
return eGOBI_ERR_QDL_OPEN_SKIP;
|
||||
}
|
||||
|
||||
return eGOBI_ERR_QDL_ERR_GENERAL;
|
||||
}
|
||||
|
||||
*pBlockSize = tmp;
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
WriteQDLImageBlock (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function writes the specified image block to the device
|
||||
|
||||
PARAMETERS:
|
||||
sequenceNumber [ I ] - Sequence number for image write
|
||||
blockSize [ I ] - Size of image block
|
||||
pImageBlock [ I ] - Image block
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQDLCore::WriteQDLImageBlock(
|
||||
USHORT sequenceNumber,
|
||||
ULONG blockSize,
|
||||
BYTE * pImageBlock )
|
||||
{
|
||||
if (blockSize > QDL_MAX_CHUNK_SIZE || pImageBlock == 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
sSharedBuffer * pReq = 0;
|
||||
pReq = sQDLWriteUnframed::BuildWriteUnframedReq( sequenceNumber,
|
||||
blockSize );
|
||||
|
||||
if (pReq == 0)
|
||||
{
|
||||
return eGOBI_ERR_MEMORY;
|
||||
}
|
||||
|
||||
sProtocolBuffer rsp = SendQDL( pReq, pImageBlock, blockSize );
|
||||
if (rsp.IsValid() == false)
|
||||
{
|
||||
return GetCorrectedLastError();
|
||||
}
|
||||
|
||||
sQDLWriteUnframed writeRsp( rsp.GetSharedBuffer() );
|
||||
const sQDLRawWriteUnframedRsp * pTmp = writeRsp.GetResponse();
|
||||
if (pTmp == 0)
|
||||
{
|
||||
sQDLError errRsp( rsp.GetSharedBuffer() );
|
||||
if (errRsp.IsValid() == true)
|
||||
{
|
||||
eQDLError qdlErr = errRsp.GetErrorCode();
|
||||
return GetCorrectedQDLError( qdlErr );
|
||||
}
|
||||
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
|
||||
if (writeRsp.IsSuccess() == false)
|
||||
{
|
||||
switch ((eQDLWriteStatus)pTmp->mStatus)
|
||||
{
|
||||
case eQDL_WRITE_STATUS_CRC:
|
||||
return eGOBI_ERR_QDL_CRC;
|
||||
|
||||
case eQDL_WRITE_STATUS_CONTENT:
|
||||
return eGOBI_ERR_QDL_PARSING;
|
||||
}
|
||||
|
||||
return eGOBI_ERR_QDL_ERR_GENERAL;
|
||||
}
|
||||
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
ValidateQDLImages (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function requests the device validate the written images
|
||||
|
||||
PARAMETERS:
|
||||
pImageType [ O ] - Upon failure this may contain the type of the image
|
||||
that failed validation
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQDLCore::ValidateQDLImages( BYTE * pImageType )
|
||||
{
|
||||
if (pImageType == 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
*pImageType = UCHAR_MAX;
|
||||
|
||||
BYTE cmd = (BYTE)eQDL_CMD_SESSION_DONE_REQ;
|
||||
eProtocolType pt = ePROTOCOL_QDL_TX;
|
||||
|
||||
sSharedBuffer * pReq = 0;
|
||||
pReq = new sSharedBuffer( (const BYTE *)&cmd, 1, pt );
|
||||
if (pReq == 0)
|
||||
{
|
||||
return eGOBI_ERR_MEMORY;
|
||||
}
|
||||
|
||||
sProtocolBuffer rsp = SendQDL( pReq );
|
||||
if (rsp.IsValid() == false)
|
||||
{
|
||||
return GetCorrectedLastError();
|
||||
}
|
||||
|
||||
sQDLDone doneRsp( rsp.GetSharedBuffer() );
|
||||
const sQDLRawDoneRsp * pTmp = doneRsp.GetResponse();
|
||||
if (pTmp == 0)
|
||||
{
|
||||
sQDLError errRsp( rsp.GetSharedBuffer() );
|
||||
if (errRsp.IsValid() == true)
|
||||
{
|
||||
eQDLError qdlErr = errRsp.GetErrorCode();
|
||||
return GetCorrectedQDLError( qdlErr );
|
||||
}
|
||||
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
|
||||
if (doneRsp.IsSuccess() == false)
|
||||
{
|
||||
*pImageType = pTmp->mImageType;
|
||||
switch ((eQDLDoneStatus)pTmp->mStatus)
|
||||
{
|
||||
case eQDL_DONE_STATUS_AUTH:
|
||||
return eGOBI_ERR_QDL_AUTH;
|
||||
|
||||
case eQDL_DONE_STATUS_WRITE:
|
||||
return eGOBI_ERR_QDL_WRITE;
|
||||
}
|
||||
|
||||
return eGOBI_ERR_QDL_ERR_GENERAL;
|
||||
}
|
||||
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
SendQDL (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Send a QDL request and wait for and return response (if needed)
|
||||
|
||||
PARAMETERS:
|
||||
pRequest [ I ] - Request to schedule
|
||||
pAuxData [ I ] - Auxiliary data for request
|
||||
auxDataSz [ I ] - Size of auxiliary data
|
||||
bWaitForResponse [ I ] - Wait for a response?
|
||||
|
||||
RETURN VALUE:
|
||||
sProtocolBuffer - The response (invalid when no response was received)
|
||||
===========================================================================*/
|
||||
sProtocolBuffer cGobiQDLCore::SendQDL(
|
||||
sSharedBuffer * pRequest,
|
||||
const BYTE * pAuxData,
|
||||
ULONG auxDataSz,
|
||||
bool bWaitForResponse )
|
||||
{
|
||||
// Clear last error recorded
|
||||
ClearLastError();
|
||||
|
||||
// Returned response
|
||||
sProtocolBuffer rsp;
|
||||
|
||||
// Validate the arguments
|
||||
if (pRequest == 0)
|
||||
{
|
||||
mLastError = eGOBI_ERR_MEMORY;
|
||||
return rsp;
|
||||
}
|
||||
|
||||
// We use the event based notification approach
|
||||
cSyncQueue <sProtocolNotificationEvent> evts( 12, true );
|
||||
cProtocolQueueNotification pn( &evts );
|
||||
|
||||
// Process up to the indicated timeout
|
||||
cEvent & sigEvt = evts.GetSignalEvent();
|
||||
|
||||
// Build the request object
|
||||
sProtocolRequest req( pRequest, 0, mQDLTimeout, 1, 1, &pn );
|
||||
req.SetAuxiliaryData( pAuxData, auxDataSz );
|
||||
if (bWaitForResponse == false)
|
||||
{
|
||||
req.SetTXOnly();
|
||||
}
|
||||
|
||||
// Are we connected?
|
||||
if ( (mQDLPortNode.empty() == true)
|
||||
|| (mQDL.IsConnected() == false) )
|
||||
{
|
||||
mLastError = eGOBI_ERR_NO_CONNECTION;
|
||||
return rsp;
|
||||
}
|
||||
|
||||
// Grab the log from the server
|
||||
const cProtocolLog & protocolLog = mQDL.GetLog();
|
||||
|
||||
// Schedule the request
|
||||
ULONG reqID = mQDL.AddRequest( req );
|
||||
if (reqID == INVALID_REQUEST_ID)
|
||||
{
|
||||
mLastError = eGOBI_ERR_REQ_SCHEDULE;
|
||||
return rsp;
|
||||
}
|
||||
|
||||
bool bReq = false;
|
||||
bool bExit = false;
|
||||
DWORD idx;
|
||||
|
||||
// Process up to the indicated timeout
|
||||
while (bExit == false)
|
||||
{
|
||||
int wc = sigEvt.Wait( mQDLTimeout, idx );
|
||||
if (wc == ETIME)
|
||||
{
|
||||
if (bReq == true)
|
||||
{
|
||||
mLastError = eGOBI_ERR_RESPONSE_TO;
|
||||
}
|
||||
else
|
||||
{
|
||||
mLastError = eGOBI_ERR_REQUEST_TO;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if (wc != 0)
|
||||
{
|
||||
mLastError = eGOBI_ERR_INTERNAL;
|
||||
break;
|
||||
}
|
||||
|
||||
sProtocolNotificationEvent evt;
|
||||
bool bEvt = evts.GetElement( idx, evt );
|
||||
if (bEvt == false)
|
||||
{
|
||||
mLastError = eGOBI_ERR_INTERNAL;
|
||||
bExit = true;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (evt.mEventType)
|
||||
{
|
||||
case ePROTOCOL_EVT_REQ_ERR:
|
||||
mLastError = eGOBI_ERR_REQUEST;
|
||||
bExit = true;
|
||||
break;
|
||||
|
||||
case ePROTOCOL_EVT_RSP_ERR:
|
||||
mLastError = eGOBI_ERR_RESPONSE;
|
||||
bExit = true;
|
||||
break;
|
||||
|
||||
case ePROTOCOL_EVT_REQ_SENT:
|
||||
{
|
||||
bReq = true;
|
||||
if (bWaitForResponse == false)
|
||||
{
|
||||
// Success!
|
||||
bExit = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ePROTOCOL_EVT_RSP_RECV:
|
||||
// Success!
|
||||
rsp = protocolLog.GetBuffer( evt.mParam2 );
|
||||
bExit = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( (mLastError == eGOBI_ERR_INTERNAL)
|
||||
|| (mLastError == eGOBI_ERR_REQUEST_TO)
|
||||
|| (mLastError == eGOBI_ERR_RESPONSE_TO) )
|
||||
{
|
||||
// Remove the request as our protocol notification object is
|
||||
// about to go out of scope and hence be destroyed
|
||||
mQDL.RemoveRequest( reqID );
|
||||
}
|
||||
|
||||
return rsp;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetConnectedPortID (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Get the device node of the currently connected Gobi device
|
||||
|
||||
PARAMETERS:
|
||||
devNode [ O ] - Device node (IE: ttyUSB0)
|
||||
|
||||
RETURN VALUE:
|
||||
bool
|
||||
===========================================================================*/
|
||||
bool cGobiQDLCore::GetConnectedPortID( std::string & devNode )
|
||||
{
|
||||
// Assume failure
|
||||
bool bFound = false;
|
||||
|
||||
devNode.clear();
|
||||
|
||||
// Were we once connected?
|
||||
if (mQDLPortNode.size() > 0)
|
||||
{
|
||||
// Yes, but is our device still present?
|
||||
// NOTE: This does not garantee the device did not leave and come back
|
||||
std::vector <std::string> devices = GetAvailableQDLPorts();
|
||||
ULONG deviceCount = (ULONG)devices.size();
|
||||
|
||||
for (ULONG a = 0; a < deviceCount; a++)
|
||||
{
|
||||
if (devices[a] == mQDLPortNode)
|
||||
{
|
||||
devNode = devices[a];
|
||||
|
||||
bFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bFound == false)
|
||||
{
|
||||
mLastError = eGOBI_ERR_NO_DEVICE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// We are not connected
|
||||
mLastError = eGOBI_ERR_NO_CONNECTION;
|
||||
}
|
||||
|
||||
return bFound;
|
||||
}
|
|
@ -0,0 +1,168 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
GobiQDLCore.h
|
||||
|
||||
DESCRIPTION:
|
||||
QUALCOMM Gobi QDL Based API Core
|
||||
|
||||
PUBLIC CLASSES AND FUNCTIONS:
|
||||
cGobiQDLCore
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
==========================================================================*/
|
||||
|
||||
/*=========================================================================*/
|
||||
// Pragmas
|
||||
/*=========================================================================*/
|
||||
#pragma once
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "ProtocolBuffer.h"
|
||||
#include "QDLProtocolServer.h"
|
||||
#include "GobiError.h"
|
||||
#include "GobiMBNMgmt.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
/*=========================================================================*/
|
||||
// Class cGobiQDLCore
|
||||
/*=========================================================================*/
|
||||
class cGobiQDLCore
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
cGobiQDLCore();
|
||||
|
||||
// Destructor
|
||||
virtual ~cGobiQDLCore();
|
||||
|
||||
// Initialize the object
|
||||
virtual bool Initialize();
|
||||
|
||||
// Cleanup the object
|
||||
virtual bool Cleanup();
|
||||
|
||||
// Return the set of available Gobi QDL ports
|
||||
std::vector <std::string> GetAvailableQDLPorts();
|
||||
|
||||
// Set the timeout for QDL transactions
|
||||
eGobiError SetQDLTimeout( ULONG to );
|
||||
|
||||
// Open the specified QDL port of the device
|
||||
eGobiError OpenQDLPort(
|
||||
std::string & portID,
|
||||
ULONG bBARMode,
|
||||
ULONG * pMajorVersion,
|
||||
ULONG * pMinorVersion );
|
||||
|
||||
// Close the specified QDL port of the device
|
||||
eGobiError CloseQDLPort( bool bInformDevice );
|
||||
|
||||
// Get the images preference as from the device boot downloader
|
||||
eGobiError GetQDLImagesPreference(
|
||||
ULONG * pImageListSize,
|
||||
BYTE * pImageList );
|
||||
|
||||
// Prepare the device boot downloader for an image write
|
||||
eGobiError PrepareQDLImageWrite(
|
||||
BYTE imageType,
|
||||
ULONG imageSize,
|
||||
ULONG * pBlockSize );
|
||||
|
||||
// Write the specified image block to the device
|
||||
eGobiError WriteQDLImageBlock(
|
||||
USHORT sequenceNumber,
|
||||
ULONG chunkSize,
|
||||
BYTE * pImageBlock );
|
||||
|
||||
// Request the device validate the written images
|
||||
eGobiError ValidateQDLImages( BYTE * pImageType );
|
||||
|
||||
// Send a QDL request and wait for and return response
|
||||
sProtocolBuffer SendQDL(
|
||||
sSharedBuffer * pRequest,
|
||||
const BYTE * pAuxData = 0,
|
||||
ULONG auxDataSz = 0,
|
||||
bool bWAitForResponse = true );
|
||||
|
||||
// Get currently connected port ID
|
||||
bool GetConnectedPortID( std::string & portNode );
|
||||
|
||||
// (Inline) Clear last error recorded
|
||||
void ClearLastError()
|
||||
{
|
||||
mLastError = eGOBI_ERR_NONE;
|
||||
};
|
||||
|
||||
// (Inline) Get last error recorded
|
||||
eGobiError GetLastError()
|
||||
{
|
||||
return mLastError;
|
||||
};
|
||||
|
||||
// (Inline) Return the last recorded error (if this happens to indicate
|
||||
// that no error occurred then return eGOBI_ERR_INTERNAL)
|
||||
eGobiError GetCorrectedLastError()
|
||||
{
|
||||
eGobiError ec = GetLastError();
|
||||
if (ec == eGOBI_ERR_NONE)
|
||||
{
|
||||
ec = eGOBI_ERR_INTERNAL;
|
||||
}
|
||||
|
||||
return ec;
|
||||
};
|
||||
|
||||
// (Inline) Return the correct QDL error
|
||||
eGobiError GetCorrectedQDLError( ULONG qdlError )
|
||||
{
|
||||
ULONG ec = qdlError + (ULONG)eGOBI_ERR_QDL_OFFSET;
|
||||
return (eGobiError)ec;
|
||||
};
|
||||
|
||||
|
||||
protected:
|
||||
/* QDL protocol server */
|
||||
cQDLProtocolServer mQDL;
|
||||
|
||||
/* ID of QDL port device node is connected to */
|
||||
std::string mQDLPortNode;
|
||||
|
||||
/* Timeout for QDL transactions (in milliseconds) */
|
||||
ULONG mQDLTimeout;
|
||||
|
||||
/* Last error recorded */
|
||||
eGobiError mLastError;
|
||||
};
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,219 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
GobiQMICoreCAT.cpp
|
||||
|
||||
DESCRIPTION:
|
||||
QUALCOMM Gobi QMI Based API Core (CAT Service)
|
||||
|
||||
PUBLIC CLASSES AND FUNCTIONS:
|
||||
cGobiQMICore
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
==========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "StdAfx.h"
|
||||
#include "GobiQMICore.h"
|
||||
|
||||
#include "QMIBuffers.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas (pack structs)
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma pack( push, 1 )
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sCATTerminalResponseHdr
|
||||
// Struct to represent a CAT terminal response header
|
||||
/*=========================================================================*/
|
||||
struct sCATTerminalResponseHdr
|
||||
{
|
||||
public:
|
||||
ULONG mReferenceID;
|
||||
USHORT mLength;
|
||||
|
||||
// Terminal response data of 'mLength' follows
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sCATEnvelopeCommandHdr
|
||||
// Struct to represent a CAT envelope command header
|
||||
/*=========================================================================*/
|
||||
struct sCATEnvelopeCommandHdr
|
||||
{
|
||||
public:
|
||||
USHORT mCommandID;
|
||||
USHORT mLength;
|
||||
|
||||
// Envelope command data of 'mLength' follows
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma pack( pop )
|
||||
|
||||
/*=========================================================================*/
|
||||
// cGobiQMICore Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
CATSendTerminalResponse (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function sends the terminal response to the device
|
||||
|
||||
PARAMETERS:
|
||||
refID [ I ] - UIM reference ID (from CAT event)
|
||||
dataLen [ I ] - Terminal response data length
|
||||
pData [ I ] - Terminal response data
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::CATSendTerminalResponse(
|
||||
ULONG refID,
|
||||
ULONG dataLen,
|
||||
BYTE * pData )
|
||||
{
|
||||
const ULONG szTransHdr = (ULONG)sizeof( sQMIServiceRawTransactionHeader );
|
||||
const ULONG szMsgHdr = (ULONG)sizeof( sQMIRawMessageHeader );
|
||||
const ULONG szTLVHdr = (ULONG)sizeof( sQMIRawContentHeader );
|
||||
const ULONG szCATHdr = (ULONG)sizeof( sCATTerminalResponseHdr );
|
||||
|
||||
// Validate arguments
|
||||
if (pData == 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
BYTE buf[QMI_MAX_BUFFER_SIZE];
|
||||
|
||||
ULONG totalLen = szTransHdr + szMsgHdr+ szTLVHdr + szCATHdr + dataLen;
|
||||
if (QMI_MAX_BUFFER_SIZE < totalLen)
|
||||
{
|
||||
return eGOBI_ERR_BUFFER_SZ;
|
||||
}
|
||||
|
||||
sQMIRawContentHeader * pTLV = (sQMIRawContentHeader *)&buf[0];
|
||||
pTLV->mTypeID = 1;
|
||||
pTLV->mLength = (WORD)(szCATHdr + dataLen);
|
||||
|
||||
sCATTerminalResponseHdr * pCAT = (sCATTerminalResponseHdr *)&buf[szTLVHdr];
|
||||
pCAT->mReferenceID = refID;
|
||||
pCAT->mLength = (USHORT)dataLen;
|
||||
|
||||
pCAT++;
|
||||
if (dataLen > 0)
|
||||
{
|
||||
memcpy( (LPVOID)pCAT, (LPCVOID)pData, (SIZE_T)dataLen );
|
||||
}
|
||||
|
||||
sSharedBuffer * pReq = 0;
|
||||
pReq = sQMIServiceBuffer::BuildBuffer( eQMI_SVC_CAT,
|
||||
(WORD)eQMI_CAT_SEND_TERMINAL,
|
||||
false,
|
||||
false,
|
||||
&buf[0],
|
||||
szTLVHdr + szCATHdr + dataLen );
|
||||
|
||||
// Send the QMI request, check result, and return
|
||||
return SendAndCheckReturn( eQMI_SVC_CAT, pReq );
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
CATSendEnvelopeCommand (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function sends the envelope command to the device
|
||||
|
||||
PARAMETERS:
|
||||
cmdID [ I ] - Envelope command ID
|
||||
dataLen [ I ] - Envelope command data length
|
||||
pData [ I ] - Envelope command data
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::CATSendEnvelopeCommand(
|
||||
ULONG cmdID,
|
||||
ULONG dataLen,
|
||||
BYTE * pData )
|
||||
{
|
||||
const ULONG szTransHdr = (ULONG)sizeof( sQMIServiceRawTransactionHeader );
|
||||
const ULONG szMsgHdr = (ULONG)sizeof( sQMIRawMessageHeader );
|
||||
const ULONG szTLVHdr = (ULONG)sizeof( sQMIRawContentHeader );
|
||||
const ULONG szCATHdr = (ULONG)sizeof( sCATEnvelopeCommandHdr );
|
||||
|
||||
// Validate arguments
|
||||
if (pData == 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
BYTE buf[QMI_MAX_BUFFER_SIZE];
|
||||
|
||||
ULONG totalLen = szTransHdr + szMsgHdr+ szTLVHdr + szCATHdr + dataLen;
|
||||
if (QMI_MAX_BUFFER_SIZE < totalLen)
|
||||
{
|
||||
return eGOBI_ERR_BUFFER_SZ;
|
||||
}
|
||||
|
||||
sQMIRawContentHeader * pTLV = (sQMIRawContentHeader *)&buf[0];
|
||||
pTLV->mTypeID = 1;
|
||||
pTLV->mLength = (WORD)(szCATHdr + dataLen);
|
||||
|
||||
sCATEnvelopeCommandHdr * pCAT = (sCATEnvelopeCommandHdr *)&buf[szTLVHdr];
|
||||
pCAT->mCommandID = (USHORT)cmdID;
|
||||
pCAT->mLength = (USHORT)dataLen;
|
||||
|
||||
pCAT++;
|
||||
if (dataLen > 0)
|
||||
{
|
||||
memcpy( (LPVOID)pCAT, (LPCVOID)pData, (SIZE_T)dataLen );
|
||||
}
|
||||
|
||||
sSharedBuffer * pReq = 0;
|
||||
pReq = sQMIServiceBuffer::BuildBuffer( eQMI_SVC_CAT,
|
||||
(WORD)eQMI_CAT_SEND_ENVELOPE,
|
||||
false,
|
||||
false,
|
||||
&buf[0],
|
||||
szTLVHdr + szCATHdr + dataLen );
|
||||
|
||||
// Send the QMI request, check result, and return
|
||||
return SendAndCheckReturn( eQMI_SVC_CAT, pReq );
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,656 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
GobiQMICoreImg.cpp
|
||||
|
||||
DESCRIPTION:
|
||||
QUALCOMM Gobi QMI Based API Core (Image Management)
|
||||
|
||||
PUBLIC CLASSES AND FUNCTIONS:
|
||||
cGobiQMICore
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
==========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "StdAfx.h"
|
||||
#include "GobiQMICore.h"
|
||||
|
||||
#include "QMIBuffers.h"
|
||||
|
||||
/*=========================================================================*/
|
||||
// cGobiQMICore Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetImagesPreference (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function gets the current images preference
|
||||
|
||||
PARAMETERS:
|
||||
pImageListSize [I/O] - Upon input the size in BYTEs of the image list
|
||||
array. Upon success the actual number of BYTEs
|
||||
copied to the image list array
|
||||
pImageList [ O ] - The image info list array
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::GetImagesPreference(
|
||||
ULONG * pImageListSize,
|
||||
BYTE * pImageList )
|
||||
{
|
||||
// Validate arguments
|
||||
if ( (pImageListSize == 0)
|
||||
|| (*pImageListSize == 0)
|
||||
|| (pImageList == 0) )
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ULONG maxSz = *pImageListSize;
|
||||
*pImageListSize = 0;
|
||||
|
||||
// Generate and send the QMI request
|
||||
WORD msgID = (WORD)eQMI_DMS_GET_FIRMWARE_PREF;
|
||||
sProtocolBuffer rsp = SendSimple( eQMI_SVC_DMS, msgID );
|
||||
if (rsp.IsValid() == false)
|
||||
{
|
||||
return GetCorrectedLastError();
|
||||
}
|
||||
|
||||
// Did we receive a valid QMI response?
|
||||
sQMIServiceBuffer qmiRsp( rsp.GetSharedBuffer() );
|
||||
if (qmiRsp.IsValid() == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
|
||||
// Check the mandatory QMI result TLV for success
|
||||
ULONG rc = 0;
|
||||
ULONG ec = 0;
|
||||
bool bResult = qmiRsp.GetResult( rc, ec );
|
||||
if (bResult == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
else if (rc != 0)
|
||||
{
|
||||
return GetCorrectedQMIError( ec );
|
||||
}
|
||||
|
||||
// Try to find TLV ID 1
|
||||
std::map <ULONG, const sQMIRawContentHeader *> tlvs;
|
||||
tlvs = qmiRsp.GetContents();
|
||||
|
||||
std::map <ULONG, const sQMIRawContentHeader *>::const_iterator pIter;
|
||||
pIter = tlvs.find( 1 );
|
||||
if (pIter == tlvs.end())
|
||||
{
|
||||
return eGOBI_ERR_INVALID_RSP;
|
||||
}
|
||||
|
||||
// Enough space to copy result?
|
||||
const sQMIRawContentHeader * pHdr = pIter->second;
|
||||
ULONG needSz = (ULONG)pHdr->mLength;
|
||||
if (needSz == 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_RSP;
|
||||
}
|
||||
|
||||
*pImageListSize = needSz;
|
||||
if (needSz > maxSz)
|
||||
{
|
||||
return eGOBI_ERR_BUFFER_SZ;
|
||||
}
|
||||
|
||||
pHdr++;
|
||||
const BYTE * pData = (const BYTE *)pHdr;
|
||||
|
||||
memcpy( (LPVOID)pImageList,
|
||||
(LPCVOID)pData,
|
||||
(SIZE_T)needSz );
|
||||
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
SetImagesPreference (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function sets the current images preference
|
||||
|
||||
PARAMETERS:
|
||||
imageListSize [ I ] - The size in BYTEs of the image list array
|
||||
pImageList [ I ] - The image list array
|
||||
bForceDownload [ I ] - Force device to download images from host?
|
||||
modemIndex [ I ] - Desired storage index for downloaded modem image
|
||||
pImageTypesSize [I/O] - Upon input the maximum number of elements that
|
||||
the download image types array can contain.
|
||||
Upon successful output the actual number of
|
||||
elements in the download image types array
|
||||
pImageTypes [ O ] - The download image types array
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::SetImagesPreference(
|
||||
ULONG imageListSize,
|
||||
BYTE * pImageList,
|
||||
ULONG bForceDownload,
|
||||
BYTE modemIndex,
|
||||
ULONG * pImageTypesSize,
|
||||
BYTE * pImageTypes )
|
||||
{
|
||||
// Validate arguments
|
||||
if ( (imageListSize == 0)
|
||||
|| (pImageList == 0)
|
||||
|| (pImageTypesSize == 0)
|
||||
|| (*pImageTypesSize == 0)
|
||||
|| (pImageTypes == 0) )
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ULONG maxSz = *pImageTypesSize;
|
||||
*pImageTypesSize = 0;
|
||||
|
||||
WORD msgID = (WORD)eQMI_DMS_SET_FIRMWARE_PREF;
|
||||
std::vector <sDB2PackingInput> piv;
|
||||
|
||||
sProtocolEntityKey pek1( eDB2_ET_QMI_DMS_REQ, msgID, 1 );
|
||||
sDB2PackingInput pi1( pek1, pImageList, imageListSize );
|
||||
piv.push_back( pi1 );
|
||||
|
||||
BYTE bOverride = 0;
|
||||
if (bForceDownload != 0)
|
||||
{
|
||||
bOverride = 1;
|
||||
sProtocolEntityKey pek2( eDB2_ET_QMI_DMS_REQ, msgID, 16 );
|
||||
sDB2PackingInput pi2( pek2, &bOverride, 1 );
|
||||
piv.push_back( pi2 );
|
||||
}
|
||||
|
||||
if (modemIndex != UCHAR_MAX)
|
||||
{
|
||||
sProtocolEntityKey pek3( eDB2_ET_QMI_DMS_REQ, msgID, 17 );
|
||||
sDB2PackingInput pi3( pek3, &modemIndex, 1 );
|
||||
piv.push_back( pi3 );
|
||||
}
|
||||
|
||||
// Pack up the QMI request
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
sSharedBuffer * pRequest = DB2PackQMIBuffer( db, piv );
|
||||
if (pRequest == 0)
|
||||
{
|
||||
return eGOBI_ERR_MEMORY;
|
||||
}
|
||||
|
||||
sProtocolBuffer rsp = Send( eQMI_SVC_DMS, pRequest );
|
||||
if (rsp.IsValid() == false)
|
||||
{
|
||||
return GetCorrectedLastError();
|
||||
}
|
||||
|
||||
// Did we receive a valid QMI response?
|
||||
sQMIServiceBuffer qmiRsp( rsp.GetSharedBuffer() );
|
||||
if (qmiRsp.IsValid() == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
|
||||
// Check the mandatory QMI result TLV for success
|
||||
ULONG rc = 0;
|
||||
ULONG ec = 0;
|
||||
bool bResult = qmiRsp.GetResult( rc, ec );
|
||||
if (bResult == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
else if (rc != 0)
|
||||
{
|
||||
return GetCorrectedQMIError( ec );
|
||||
}
|
||||
|
||||
// Try to find TLV ID 1
|
||||
std::map <ULONG, const sQMIRawContentHeader *> tlvs;
|
||||
tlvs = qmiRsp.GetContents();
|
||||
|
||||
std::map <ULONG, const sQMIRawContentHeader *>::const_iterator pIter;
|
||||
pIter = tlvs.find( 1 );
|
||||
if (pIter == tlvs.end())
|
||||
{
|
||||
return eGOBI_ERR_INVALID_RSP;
|
||||
}
|
||||
|
||||
// Enough space to copy result?
|
||||
const sQMIRawContentHeader * pHdr = pIter->second;
|
||||
ULONG dataLen = (ULONG)pHdr->mLength;
|
||||
if (dataLen == 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_RSP;
|
||||
}
|
||||
|
||||
pHdr++;
|
||||
const BYTE * pData = (const BYTE *)pHdr;
|
||||
BYTE typeCount = *pData++;
|
||||
if (typeCount != 0)
|
||||
{
|
||||
if (dataLen != (ULONG)typeCount + 1)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_RSP;
|
||||
}
|
||||
|
||||
*pImageTypesSize = typeCount;
|
||||
if (typeCount > maxSz)
|
||||
{
|
||||
return eGOBI_ERR_BUFFER_SZ;
|
||||
}
|
||||
|
||||
memcpy( (LPVOID)pImageTypes,
|
||||
(LPCVOID)pData,
|
||||
(SIZE_T)typeCount );
|
||||
}
|
||||
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetBARMode (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function returns the boot and recovery image download mode
|
||||
|
||||
PARAMETERS:
|
||||
pBARMode [ O ] - Boot and recovery image download mode
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::GetBARMode( ULONG * pBARMode )
|
||||
{
|
||||
// Validate arguments
|
||||
if (pBARMode == 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
// Generate and send the QMI request
|
||||
WORD msgID = (WORD)eQMI_DMS_GET_IMG_DLOAD_MODE;
|
||||
sProtocolBuffer rsp = SendSimple( eQMI_SVC_DMS, msgID );
|
||||
if (rsp.IsValid() == false)
|
||||
{
|
||||
return GetCorrectedLastError();
|
||||
}
|
||||
|
||||
// Did we receive a valid QMI response?
|
||||
sQMIServiceBuffer qmiRsp( rsp.GetSharedBuffer() );
|
||||
if (qmiRsp.IsValid() == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
|
||||
// Check the mandatory QMI result TLV for success
|
||||
ULONG rc = 0;
|
||||
ULONG ec = 0;
|
||||
bool bResult = qmiRsp.GetResult( rc, ec );
|
||||
if (bResult == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
else if (rc != 0)
|
||||
{
|
||||
return GetCorrectedQMIError( ec );
|
||||
}
|
||||
|
||||
// Prepare TLVs for parsing
|
||||
std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiRsp );
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
|
||||
// Parse the TLV we want (by DB key)
|
||||
sProtocolEntityKey tlvKey( eDB2_ET_QMI_DMS_RSP, msgID, 16 );
|
||||
cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
|
||||
if (pf.size() < 1)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_RSP;
|
||||
}
|
||||
|
||||
// Populate the state
|
||||
*pBARMode = pf[0].mValue.mU32;
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
SetBARMode (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function requests the device enter boot and recovery image download
|
||||
mode after the next reset
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::SetBARMode()
|
||||
{
|
||||
WORD msgID = (WORD)eQMI_DMS_SET_IMG_DLOAD_MODE;
|
||||
std::vector <sDB2PackingInput> piv;
|
||||
|
||||
sProtocolEntityKey pek( eDB2_ET_QMI_DMS_REQ, msgID, 1 );
|
||||
sDB2PackingInput pi( pek, "1" );
|
||||
piv.push_back( pi );
|
||||
|
||||
// Pack up the QMI request
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
sSharedBuffer * pRequest = DB2PackQMIBuffer( db, piv );
|
||||
if (pRequest == 0)
|
||||
{
|
||||
return eGOBI_ERR_MEMORY;
|
||||
}
|
||||
|
||||
// Send the QMI request, check result, and return
|
||||
return SendAndCheckReturn( eQMI_SVC_DMS, pRequest );
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetStoredImages (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function gets the list of images stored on the device
|
||||
|
||||
PARAMETERS:
|
||||
pImageListSize [I/O] - Upon input the size in BYTEs of the image list
|
||||
array. Upon success the actual number of BYTEs
|
||||
copied to the image list array
|
||||
pImageList [ O ] - The image info list array
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::GetStoredImages(
|
||||
ULONG * pImageListSize,
|
||||
BYTE * pImageList )
|
||||
{
|
||||
// Validate arguments
|
||||
if ( (pImageListSize == 0)
|
||||
|| (*pImageListSize == 0)
|
||||
|| (pImageList == 0) )
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ULONG maxSz = *pImageListSize;
|
||||
|
||||
// Assume failure
|
||||
*pImageListSize = 0;
|
||||
|
||||
// Generate and send the QMI request
|
||||
WORD msgID = (WORD)eQMI_DMS_LIST_FIRMWARE;
|
||||
sProtocolBuffer rsp = SendSimple( eQMI_SVC_DMS, msgID );
|
||||
if (rsp.IsValid() == false)
|
||||
{
|
||||
return GetCorrectedLastError();
|
||||
}
|
||||
|
||||
// Did we receive a valid QMI response?
|
||||
sQMIServiceBuffer qmiRsp( rsp.GetSharedBuffer() );
|
||||
if (qmiRsp.IsValid() == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
|
||||
// Check the mandatory QMI result TLV for success
|
||||
ULONG rc = 0;
|
||||
ULONG ec = 0;
|
||||
bool bResult = qmiRsp.GetResult( rc, ec );
|
||||
if (bResult == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
else if (rc != 0)
|
||||
{
|
||||
return GetCorrectedQMIError( ec );
|
||||
}
|
||||
|
||||
// Try to find TLV ID 1
|
||||
std::map <ULONG, const sQMIRawContentHeader *> tlvs;
|
||||
tlvs = qmiRsp.GetContents();
|
||||
|
||||
std::map <ULONG, const sQMIRawContentHeader *>::const_iterator pIter;
|
||||
pIter = tlvs.find( 1 );
|
||||
if (pIter == tlvs.end())
|
||||
{
|
||||
return eGOBI_ERR_INVALID_RSP;
|
||||
}
|
||||
|
||||
// Enough space to copy result?
|
||||
const sQMIRawContentHeader * pHdr = pIter->second;
|
||||
ULONG needSz = (ULONG)pHdr->mLength;
|
||||
|
||||
*pImageListSize = needSz;
|
||||
if (needSz > maxSz)
|
||||
{
|
||||
return eGOBI_ERR_BUFFER_SZ;
|
||||
}
|
||||
|
||||
pHdr++;
|
||||
const BYTE * pData = (const BYTE *)pHdr;
|
||||
|
||||
memcpy( (LPVOID)pImageList,
|
||||
(LPCVOID)pData,
|
||||
(SIZE_T)needSz );
|
||||
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetStoredImageInfo (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function returns info about the specified image from the device
|
||||
|
||||
PARAMETERS:
|
||||
imageInfoSize [ I ] - The size in BYTEs of the image info array
|
||||
pImageInfo [ I ] - The image info array
|
||||
pMajorVersion [ O ] - Major version of compatible boot downloader
|
||||
pMinorVersion [ O ] - Minor version of compatible boot downloader
|
||||
pVersionID [ O ] - Image version ID
|
||||
pInfo [ O ] - Image info string
|
||||
pLockID [ O ] - Image OEM lock ID
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::GetStoredImageInfo(
|
||||
ULONG imageInfoSize,
|
||||
BYTE * pImageInfo,
|
||||
ULONG * pMajorVersion,
|
||||
ULONG * pMinorVersion,
|
||||
ULONG * pVersionID,
|
||||
CHAR * pInfo,
|
||||
ULONG * pLockID )
|
||||
{
|
||||
// Validate arguments
|
||||
if ( (imageInfoSize == 0)
|
||||
|| (pImageInfo == 0)
|
||||
|| (pMajorVersion == 0)
|
||||
|| (pMinorVersion == 0)
|
||||
|| (pVersionID == 0)
|
||||
|| (pInfo == 0)
|
||||
|| (pLockID == 0) )
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
*pMajorVersion = ULONG_MAX;
|
||||
*pMinorVersion = ULONG_MAX;
|
||||
*pVersionID = ULONG_MAX;
|
||||
*pLockID = ULONG_MAX;
|
||||
pInfo[0] = 0;
|
||||
|
||||
|
||||
WORD msgID = (WORD)eQMI_DMS_GET_FIRMWARE_INFO;
|
||||
std::vector <sDB2PackingInput> piv;
|
||||
|
||||
sProtocolEntityKey pek( eDB2_ET_QMI_DMS_REQ, msgID, 1 );
|
||||
sDB2PackingInput pi( pek, pImageInfo, imageInfoSize );
|
||||
piv.push_back( pi );
|
||||
|
||||
// Pack up the QMI request
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
sSharedBuffer * pRequest = DB2PackQMIBuffer( db, piv );
|
||||
if (pRequest == 0)
|
||||
{
|
||||
return eGOBI_ERR_MEMORY;
|
||||
}
|
||||
|
||||
// Send the QMI request
|
||||
sProtocolBuffer rsp = Send( eQMI_SVC_DMS, pRequest );
|
||||
if (rsp.IsValid() == false)
|
||||
{
|
||||
return GetCorrectedLastError();
|
||||
}
|
||||
|
||||
// Did we receive a valid QMI response?
|
||||
sQMIServiceBuffer qmiRsp( rsp.GetSharedBuffer() );
|
||||
if (qmiRsp.IsValid() == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
|
||||
// Check the mandatory QMI result TLV for success
|
||||
ULONG rc = 0;
|
||||
ULONG ec = 0;
|
||||
bool bResult = qmiRsp.GetResult( rc, ec );
|
||||
if (bResult == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
else if (rc != 0)
|
||||
{
|
||||
return GetCorrectedQMIError( ec );
|
||||
}
|
||||
|
||||
// Keep track of the number of TLVs we actually processed
|
||||
ULONG tlvCount = 0;
|
||||
|
||||
// Parse the TLV we want (by DB key)
|
||||
std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiRsp );
|
||||
sProtocolEntityKey tlvKey( eDB2_ET_QMI_DMS_RSP, msgID, 16 );
|
||||
cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
|
||||
if (pf.size() >= 2)
|
||||
{
|
||||
tlvCount++;
|
||||
*pMajorVersion = (ULONG)pf[0].mValue.mU16;
|
||||
*pMinorVersion = (ULONG)pf[1].mValue.mU16;
|
||||
}
|
||||
|
||||
tlvKey = sProtocolEntityKey( eDB2_ET_QMI_DMS_RSP, msgID, 17 );
|
||||
pf = ParseTLV( db, rsp, tlvs, tlvKey );
|
||||
if (pf.size() >= 2)
|
||||
{
|
||||
tlvCount++;
|
||||
*pVersionID = pf[0].mValue.mU32;
|
||||
|
||||
LONG strLen = pf[1].mValueString.size();
|
||||
if (strLen > 0 && strLen <= 32)
|
||||
{
|
||||
memcpy( pInfo, pf[1].mValueString.c_str(), strLen );
|
||||
|
||||
if (strLen < 32)
|
||||
{
|
||||
pInfo[strLen] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tlvKey = sProtocolEntityKey( eDB2_ET_QMI_DMS_RSP, msgID, 18 );
|
||||
pf = ParseTLV( db, rsp, tlvs, tlvKey );
|
||||
if (pf.size() >= 1)
|
||||
{
|
||||
tlvCount++;
|
||||
*pLockID = pf[0].mValue.mU32;
|
||||
}
|
||||
|
||||
if (tlvCount == 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_RSP;
|
||||
}
|
||||
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
DeleteStoredImage (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function deletes the specified image from the device
|
||||
|
||||
PARAMETERS:
|
||||
imageInfoSize [ I ] - The size in BYTEs of the image info array
|
||||
pImageInfo [ I ] - The image info array
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::DeleteStoredImage(
|
||||
ULONG imageInfoSize,
|
||||
BYTE * pImageInfo )
|
||||
{
|
||||
// Validate arguments
|
||||
if (imageInfoSize == 0 || pImageInfo == 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
WORD msgID = (WORD)eQMI_DMS_DELETE_FIRMWARE;
|
||||
std::vector <sDB2PackingInput> piv;
|
||||
|
||||
sProtocolEntityKey pek( eDB2_ET_QMI_DMS_REQ, msgID, 1 );
|
||||
sDB2PackingInput pi( pek, pImageInfo, imageInfoSize );
|
||||
piv.push_back( pi );
|
||||
|
||||
// Pack up the QMI request
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
sSharedBuffer * pRequest = DB2PackQMIBuffer( db, piv );
|
||||
if (pRequest == 0)
|
||||
{
|
||||
return eGOBI_ERR_MEMORY;
|
||||
}
|
||||
|
||||
// Send the QMI request, check result, and return
|
||||
return SendAndCheckReturn( eQMI_SVC_DMS, pRequest );
|
||||
}
|
|
@ -0,0 +1,571 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
GobiQMICoreImg2k.cpp
|
||||
|
||||
DESCRIPTION:
|
||||
QUALCOMM Gobi QMI Based API Core (Image Management, G2k API)
|
||||
|
||||
PUBLIC CLASSES AND FUNCTIONS:
|
||||
cGobiQMICore
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
==========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "StdAfx.h"
|
||||
#include "GobiMBNMgmt.h"
|
||||
#include "GobiQMICore.h"
|
||||
|
||||
#include "QMIBuffers.h"
|
||||
|
||||
#include <glob.h>
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
/*=========================================================================*/
|
||||
// Free Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetGenericImage (Free Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Return a compatible AMSS generic image
|
||||
|
||||
PARAMETERS:
|
||||
uqcnInfo [ I ] - UQCN image needing a compatible AMSS generic image
|
||||
|
||||
RETURN VALUE:
|
||||
sImageInfo - Generic image information
|
||||
===========================================================================*/
|
||||
sImageInfo GetGenericImage( const sImageInfo & uqcnInfo )
|
||||
{
|
||||
// Validate arguments
|
||||
sImageInfo amssInfo;
|
||||
|
||||
// Obtain the technology/carrier of the UQCN
|
||||
ULONG uqcnTech;
|
||||
ULONG uqcnCarrier;
|
||||
ULONG dummy;
|
||||
eGobiError rc = ::MapVersionInfo( uqcnInfo.mVersionID,
|
||||
(BYTE)uqcnInfo.mImageType,
|
||||
uqcnInfo.mVersion.c_str(),
|
||||
&uqcnTech,
|
||||
&uqcnCarrier,
|
||||
&dummy,
|
||||
&dummy );
|
||||
|
||||
if (rc != eGOBI_ERR_NONE)
|
||||
{
|
||||
return amssInfo;
|
||||
}
|
||||
|
||||
// Recursively enumerate all folders of the image store
|
||||
std::vector <std::string> folders;
|
||||
std::string imageStore = ::GetImageStore();
|
||||
EnumerateFolders( imageStore, folders );
|
||||
|
||||
// Did we find any folders?
|
||||
ULONG foldersSz = (ULONG)folders.size();
|
||||
if (foldersSz == 0)
|
||||
{
|
||||
return amssInfo;
|
||||
}
|
||||
|
||||
// Go through each folder searching for a compatible generic AMSS image
|
||||
for (ULONG f = 0; f < foldersSz; f++)
|
||||
{
|
||||
// Search all MBN files in the specified folder
|
||||
std::string folderSearch = folders[f];
|
||||
|
||||
int folderLen = folderSearch.size();
|
||||
if (folderSearch[folderLen - 1] != '/')
|
||||
{
|
||||
folderSearch += '/';
|
||||
}
|
||||
|
||||
folderSearch += "*.mbn";
|
||||
|
||||
glob_t files;
|
||||
int ret = glob( folderSearch.c_str(),
|
||||
0,
|
||||
NULL,
|
||||
&files );
|
||||
if (ret != 0)
|
||||
{
|
||||
// Glob error
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int i = 0; i < files.gl_pathc; i++)
|
||||
{
|
||||
std::string mbnName = files.gl_pathv[i];
|
||||
|
||||
BYTE imageType = UCHAR_MAX;
|
||||
BYTE imageID[16] = { 0 };
|
||||
ULONG versionID = ULONG_MAX;
|
||||
USHORT versionSz = MAX_PATH * 2 + 1;
|
||||
CHAR versionStr[MAX_PATH * 2 + 1] = { 0 };
|
||||
rc = ::GetImageInfo( mbnName.c_str(),
|
||||
&imageType,
|
||||
&imageID[0],
|
||||
&versionID,
|
||||
versionSz,
|
||||
&versionStr[0] );
|
||||
|
||||
if (rc == eGOBI_ERR_NONE)
|
||||
{
|
||||
if ((eGobiMBNType)imageType == eGOBI_MBN_TYPE_MODEM)
|
||||
{
|
||||
ULONG amssTech;
|
||||
ULONG amssCarrier;
|
||||
rc = ::MapVersionInfo( versionID,
|
||||
imageType,
|
||||
(LPCSTR)&versionStr[0],
|
||||
&amssTech,
|
||||
&amssCarrier,
|
||||
&dummy,
|
||||
&dummy );
|
||||
|
||||
if (rc == eGOBI_ERR_NONE)
|
||||
{
|
||||
if ( (amssTech == uqcnTech)
|
||||
&& (amssCarrier == (ULONG)eGOBI_IMG_CAR_GENERIC) )
|
||||
{
|
||||
amssInfo.mImageType = (eGobiMBNType)imageType;
|
||||
amssInfo.mVersionID = versionID;
|
||||
amssInfo.mVersion = (LPCSTR)&versionStr[0];
|
||||
memcpy( (LPVOID)&amssInfo.mImageID[0],
|
||||
(LPCVOID)&imageID[0],
|
||||
MBN_UNIQUE_ID_LEN );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
globfree( &files );
|
||||
}
|
||||
|
||||
// Success
|
||||
return amssInfo;
|
||||
}
|
||||
|
||||
/*=========================================================================*/
|
||||
// cGobiQMICore Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetFirmwareInfo (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Returns image information obtained from the current device firmware
|
||||
|
||||
PARAMETERS:
|
||||
pFirmwareID [ O ] - Firmware ID obtained from the firmware image
|
||||
pTechnology [ O ] - Technology (0xFFFFFFFF if unknown)
|
||||
pCarrier [ O ] - Carrier (0xFFFFFFFF if unknown)
|
||||
pRegion [ O ] - Region (0xFFFFFFFF if unknown)
|
||||
pGPSCapability [ O ] - GPS capability (0xFFFFFFFF if unknown)
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::GetFirmwareInfo(
|
||||
ULONG * pFirmwareID,
|
||||
ULONG * pTechnology,
|
||||
ULONG * pCarrier,
|
||||
ULONG * pRegion,
|
||||
ULONG * pGPSCapability )
|
||||
{
|
||||
// Validate arguments
|
||||
if ( (pFirmwareID == 0)
|
||||
|| (pTechnology == 0)
|
||||
|| (pCarrier == 0)
|
||||
|| (pRegion == 0)
|
||||
|| (pGPSCapability == 0) )
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
// Do we have a device node?
|
||||
if (mDeviceNode.empty() == true)
|
||||
{
|
||||
return eGOBI_ERR_NO_CONNECTION;
|
||||
}
|
||||
|
||||
// Generate and send the QMI request
|
||||
WORD msgID = (WORD)eQMI_DMS_GET_REV_ID;
|
||||
sProtocolBuffer rsp = SendSimple( eQMI_SVC_DMS, msgID );
|
||||
if (rsp.IsValid() == false)
|
||||
{
|
||||
return GetCorrectedLastError();
|
||||
}
|
||||
|
||||
// Did we receive a valid QMI response?
|
||||
sQMIServiceBuffer qmiRsp( rsp.GetSharedBuffer() );
|
||||
if (qmiRsp.IsValid() == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
|
||||
// Check the mandatory QMI result TLV for success
|
||||
ULONG rc = 0;
|
||||
ULONG ec = 0;
|
||||
bool bResult = qmiRsp.GetResult( rc, ec );
|
||||
if (bResult == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
else if (rc != 0)
|
||||
{
|
||||
return GetCorrectedQMIError( ec );
|
||||
}
|
||||
|
||||
// Prepare TLVs for parsing
|
||||
std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiRsp );
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
|
||||
// Parse the TLV we want (by DB key)
|
||||
sProtocolEntityKey tlvKey( eDB2_ET_QMI_DMS_RSP, msgID, 17 );
|
||||
cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
|
||||
if (pf.size() < 1)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_RSP;
|
||||
}
|
||||
|
||||
std::string uqcnIDString = pf[0].mValueString;
|
||||
LONG strLen = uqcnIDString.size();
|
||||
if (strLen != 8)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_RSP;
|
||||
}
|
||||
|
||||
std::string idString1 = uqcnIDString.substr( 0, 2 );
|
||||
std::string idString2 = uqcnIDString.substr( 2, 2 );
|
||||
std::string idString3 = uqcnIDString.substr( 4, 2 );
|
||||
std::string idString4 = uqcnIDString.substr( 6, 2 );
|
||||
|
||||
ULONG id1 = 0;
|
||||
ULONG id2 = 0;
|
||||
ULONG id3 = 0;
|
||||
ULONG id4 = 0;
|
||||
bool bID1 = StringToULONG( idString1.c_str(), 16, id1 );
|
||||
bool bID2 = StringToULONG( idString2.c_str(), 16, id2 );
|
||||
bool bID3 = StringToULONG( idString3.c_str(), 16, id3 );
|
||||
bool bID4 = StringToULONG( idString4.c_str(), 16, id4 );
|
||||
|
||||
if (bID1 == false || bID2 == false || bID3 == false || bID4 == false)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_RSP;
|
||||
}
|
||||
|
||||
ULONG uqcnID = (id1 << 24) | (id2 << 16) | (id3 << 8) | id4;
|
||||
|
||||
// Parse the TLV we want (AMSS revision)
|
||||
tlvKey = sProtocolEntityKey( eDB2_ET_QMI_DMS_RSP, msgID, 1 );
|
||||
pf = ParseTLV( db, rsp, tlvs, tlvKey );
|
||||
if (pf.size() < 1 || pf[0].mValueString.size() <= 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_RSP;
|
||||
}
|
||||
|
||||
*pFirmwareID = uqcnID;
|
||||
eGobiError err = ::MapVersionInfo( uqcnID,
|
||||
(BYTE)eGOBI_MBN_TYPE_PRI,
|
||||
pf[0].mValueString.c_str(),
|
||||
pTechnology,
|
||||
pCarrier,
|
||||
pRegion,
|
||||
pGPSCapability );
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
UpgradeFirmware (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function performs the following set of steps:
|
||||
a) Verifies arguments
|
||||
b) Updates firmware ID on device
|
||||
c) Resets the device
|
||||
|
||||
NOTE: Upon successful completion the above steps will have been completed,
|
||||
however the actual upgrade of the firmware will necessarily then
|
||||
follow.
|
||||
|
||||
PARAMETERS:
|
||||
pDestinationPath [ I ] - The fully qualified path to the destination folder
|
||||
that the firmware download service will use
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::UpgradeFirmware( CHAR * pDestinationPath )
|
||||
{
|
||||
// Validate arguments
|
||||
if (pDestinationPath == 0 || pDestinationPath[0] == 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
// Do we have a device ID?
|
||||
if (mDeviceNode.empty() == true)
|
||||
{
|
||||
return eGOBI_ERR_NO_CONNECTION;
|
||||
}
|
||||
|
||||
// Use that to validate the image store for this device
|
||||
std::string tmpPath( pDestinationPath );
|
||||
int tmpPathlen = tmpPath.size();
|
||||
if (tmpPath[tmpPathlen - 1] != '/')
|
||||
{
|
||||
tmpPath += '/';
|
||||
}
|
||||
|
||||
std::string imageStore = ::GetImageStore();
|
||||
if (tmpPath.find( imageStore ) == std::string::npos)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_FILE;
|
||||
}
|
||||
|
||||
sImageInfo amssInfo;
|
||||
sImageInfo uqcnInfo;
|
||||
std::vector <sImageInfo> images;
|
||||
images = ::GetImagesInfo( tmpPath );
|
||||
|
||||
ULONG imageCount = (ULONG)images.size();
|
||||
for (ULONG i = 0; i < imageCount; i++)
|
||||
{
|
||||
const sImageInfo & ii = images[i];
|
||||
if (ii.mImageType == eGOBI_MBN_TYPE_MODEM)
|
||||
{
|
||||
amssInfo = ii;
|
||||
}
|
||||
else if (ii.mImageType == eGOBI_MBN_TYPE_PRI)
|
||||
{
|
||||
uqcnInfo = ii;
|
||||
}
|
||||
}
|
||||
|
||||
if (uqcnInfo.IsValid() == false)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_FILE;
|
||||
}
|
||||
|
||||
if (amssInfo.IsValid() == false)
|
||||
{
|
||||
amssInfo = GetGenericImage( uqcnInfo );
|
||||
|
||||
// Still bad?
|
||||
if (amssInfo.IsValid() == false)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_FILE;
|
||||
}
|
||||
}
|
||||
|
||||
WORD msgID = (WORD)eQMI_DMS_SET_FIRMWARE_PREF;
|
||||
std::vector <sDB2PackingInput> piv;
|
||||
|
||||
std::ostringstream amssIDStr;
|
||||
std::ostringstream uqcnIDStr;
|
||||
for (ULONG v = 0; v < 16; v++)
|
||||
{
|
||||
amssIDStr << " " << (ULONG)amssInfo.mImageID[v];
|
||||
uqcnIDStr << " " << (ULONG)uqcnInfo.mImageID[v];
|
||||
}
|
||||
|
||||
// "2 0%s %d \"%s\" 1%s %d \"%s\""
|
||||
std::ostringstream tmp;
|
||||
tmp << "2 0" << amssIDStr.str() << " " << amssInfo.mVersion.size()
|
||||
<< " \"" << amssInfo.mVersion << "\" 1" << uqcnIDStr.str()
|
||||
<< " " << uqcnInfo.mVersion.size() << " \""
|
||||
<< uqcnInfo.mVersion << "\"";
|
||||
|
||||
sProtocolEntityKey pek( eDB2_ET_QMI_DMS_REQ, msgID, 1 );
|
||||
sDB2PackingInput pi( pek, tmp.str().c_str() );
|
||||
piv.push_back( pi );
|
||||
|
||||
|
||||
// Pack up the QMI request
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
sSharedBuffer * pRequest = DB2PackQMIBuffer( db, piv );
|
||||
|
||||
// Send the QMI request, check result, and return
|
||||
eGobiError rc = SendAndCheckReturn( eQMI_SVC_DMS, pRequest );
|
||||
if (rc != eGOBI_ERR_NONE)
|
||||
{
|
||||
return rc;
|
||||
}
|
||||
|
||||
// Ask device to power down
|
||||
rc = SetPower( 5 );
|
||||
if (rc != eGOBI_ERR_NONE)
|
||||
{
|
||||
return eGOBI_ERR_RESET;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetImageInfo (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Returns image information obtained from the firmware image located at the
|
||||
provided path
|
||||
|
||||
PARAMETERS:
|
||||
pPath [ I ] - Location of the firmware image
|
||||
pFirmwareID [ O ] - Firmware ID obtained from the firmware image
|
||||
pTechnology [ O ] - Technology (0xFFFFFFFF if unknown)
|
||||
pCarrier [ O ] - Carrier (0xFFFFFFFF if unknown)
|
||||
pRegion [ O ] - Region (0xFFFFFFFF if unknown)
|
||||
pGPSCapability [ O ] - GPS capability (0xFFFFFFFF if unknown)
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::GetImageInfo(
|
||||
CHAR * pPath,
|
||||
ULONG * pFirmwareID,
|
||||
ULONG * pTechnology,
|
||||
ULONG * pCarrier,
|
||||
ULONG * pRegion,
|
||||
ULONG * pGPSCapability )
|
||||
{
|
||||
// Validate arguments
|
||||
if ( (pPath == 0)
|
||||
|| (pPath[0] == 0)
|
||||
|| (pFirmwareID == 0)
|
||||
|| (pTechnology == 0)
|
||||
|| (pCarrier == 0)
|
||||
|| (pRegion == 0)
|
||||
|| (pGPSCapability == 0) )
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
// Do we have a device ID?
|
||||
if (mDeviceNode.empty() == true)
|
||||
{
|
||||
return eGOBI_ERR_NO_CONNECTION;
|
||||
}
|
||||
|
||||
// Use that to validate the image store for this device
|
||||
std::string tmpPath( pPath );
|
||||
int tmpPathlen = tmpPath.size();
|
||||
if (tmpPath[tmpPathlen - 1] != '/')
|
||||
{
|
||||
tmpPath += '/';
|
||||
}
|
||||
|
||||
std::string imageStore = ::GetImageStore();
|
||||
if (tmpPath.find( imageStore ) < 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_FILE;
|
||||
}
|
||||
|
||||
std::vector <sImageInfo> images;
|
||||
images = ::GetImagesInfo( tmpPath );
|
||||
|
||||
ULONG imageCount = (ULONG)images.size();
|
||||
for (ULONG i = 0; i < imageCount; i++)
|
||||
{
|
||||
const sImageInfo & ii = images[i];
|
||||
if (ii.mImageType == eGOBI_MBN_TYPE_PRI)
|
||||
{
|
||||
*pFirmwareID = ii.mVersionID;
|
||||
return ::MapVersionInfo( ii.mVersionID,
|
||||
(BYTE)ii.mImageType,
|
||||
ii.mVersion.c_str(),
|
||||
pTechnology,
|
||||
pCarrier,
|
||||
pRegion,
|
||||
pGPSCapability );
|
||||
}
|
||||
}
|
||||
|
||||
return eGOBI_ERR_INVALID_FILE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetImageStore (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Returns the image store folder, i.e. the folder co-located with the
|
||||
QDL Service executable which (by default) contains one or more carrier
|
||||
specific image subfolders
|
||||
|
||||
PARAMETERS:
|
||||
pathSize [ I ] - Maximum number of characters (including NULL
|
||||
terminator) that can be copied to the image
|
||||
store path array
|
||||
pImageStorePath [ O ] - The path to the image store
|
||||
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::GetImageStore(
|
||||
WORD pathSize,
|
||||
CHAR * pImageStorePath )
|
||||
{
|
||||
// Do we have a device ID?
|
||||
if (mDeviceNode.size() == true)
|
||||
{
|
||||
return eGOBI_ERR_NO_CONNECTION;
|
||||
}
|
||||
|
||||
std::string imageStore = ::GetImageStore();
|
||||
|
||||
// Copy over image store
|
||||
LONG strLen = imageStore.size();
|
||||
if (pathSize < (ULONG)strLen + 1)
|
||||
{
|
||||
pImageStorePath[0] = 0;
|
||||
return eGOBI_ERR_BUFFER_SZ;
|
||||
}
|
||||
|
||||
memcpy( (LPVOID)pImageStorePath,
|
||||
(LPCVOID)imageStore.c_str(),
|
||||
(SIZE_T)strLen );
|
||||
|
||||
pImageStorePath[strLen] = 0;
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,535 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
GobiQMICoreOMA.cpp
|
||||
|
||||
DESCRIPTION:
|
||||
QUALCOMM Gobi QMI Based API Core (OMA-DM Service)
|
||||
|
||||
PUBLIC CLASSES AND FUNCTIONS:
|
||||
cGobiQMICore
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
==========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "StdAfx.h"
|
||||
#include "GobiQMICore.h"
|
||||
|
||||
#include "QMIBuffers.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
/*=========================================================================*/
|
||||
// cGobiQMICore Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
OMADMStartSession (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function starts an OMA-DM session
|
||||
|
||||
PARAMETERS:
|
||||
sessionType [ I ] - Type of session to initiate
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::OMADMStartSession( ULONG sessionType )
|
||||
{
|
||||
WORD msgID = (WORD)eQMI_OMA_START_SESSION;
|
||||
std::vector <sDB2PackingInput> piv;
|
||||
|
||||
std::ostringstream tmp;
|
||||
tmp << sessionType;
|
||||
|
||||
sProtocolEntityKey pek( eDB2_ET_QMI_OMA_REQ, msgID, 16 );
|
||||
sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
|
||||
piv.push_back( pi );
|
||||
|
||||
// Pack up the QMI request
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
sSharedBuffer * pRequest = DB2PackQMIBuffer( db, piv );
|
||||
if (pRequest == 0)
|
||||
{
|
||||
return eGOBI_ERR_MEMORY;
|
||||
}
|
||||
|
||||
// Send the QMI request, check result, and return
|
||||
return SendAndCheckReturn( eQMI_SVC_OMA, pRequest );
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
OMADMCancelSession (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function cancels an ongoing OMA-DM session
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::OMADMCancelSession()
|
||||
{
|
||||
// Generate and send the QMI request
|
||||
WORD msgID = (WORD)eQMI_OMA_CANCEL_SESSION;
|
||||
sProtocolBuffer rsp = SendSimple( eQMI_SVC_OMA, msgID );
|
||||
if (rsp.IsValid() == false)
|
||||
{
|
||||
return GetCorrectedLastError();
|
||||
}
|
||||
|
||||
// Did we receive a valid QMI response?
|
||||
sQMIServiceBuffer qmiRsp( rsp.GetSharedBuffer() );
|
||||
if (qmiRsp.IsValid() == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
|
||||
// Check the mandatory QMI result TLV for success
|
||||
ULONG rc = 0;
|
||||
ULONG ec = 0;
|
||||
bool bResult = qmiRsp.GetResult( rc, ec );
|
||||
if (bResult == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
else if (rc != 0)
|
||||
{
|
||||
return GetCorrectedQMIError( ec );
|
||||
}
|
||||
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
OMADMGetSessionInfo (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function returns information related to the current (or previous
|
||||
if no session is active) OMA-DM session
|
||||
|
||||
PARAMETERS:
|
||||
pSessionState [ O ] - State of session
|
||||
pSessionType [ O ] - Type of session
|
||||
pFailureReason [ O ] - Session failure reason (when state indicates failure)
|
||||
pRetryCount [ O ] - Session retry count (when state indicates retrying)
|
||||
pSessionPause [ O ] - Session pause timer (when state indicates retrying)
|
||||
pTimeRemaining [ O ] - Pause time remaining (when state indicates retrying)
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::OMADMGetSessionInfo(
|
||||
ULONG * pSessionState,
|
||||
ULONG * pSessionType,
|
||||
ULONG * pFailureReason,
|
||||
BYTE * pRetryCount,
|
||||
WORD * pSessionPause,
|
||||
WORD * pTimeRemaining )
|
||||
{
|
||||
// Validate arguments
|
||||
if ( (pSessionState == 0)
|
||||
|| (pSessionType == 0)
|
||||
|| (pFailureReason == 0)
|
||||
|| (pRetryCount == 0)
|
||||
|| (pSessionPause == 0)
|
||||
|| (pTimeRemaining == 0) )
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
*pSessionState = ULONG_MAX;
|
||||
*pSessionType = ULONG_MAX;
|
||||
*pFailureReason = ULONG_MAX;
|
||||
*pRetryCount = UCHAR_MAX;
|
||||
*pSessionPause = USHRT_MAX;
|
||||
*pTimeRemaining = USHRT_MAX;
|
||||
|
||||
// Generate and send the QMI request
|
||||
WORD msgID = (WORD)eQMI_OMA_GET_SESSION_INFO;
|
||||
sProtocolBuffer rsp = SendSimple( eQMI_SVC_OMA, msgID );
|
||||
if (rsp.IsValid() == false)
|
||||
{
|
||||
return GetCorrectedLastError();
|
||||
}
|
||||
|
||||
// Did we receive a valid QMI response?
|
||||
sQMIServiceBuffer qmiRsp( rsp.GetSharedBuffer() );
|
||||
if (qmiRsp.IsValid() == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
|
||||
// Check the mandatory QMI result TLV for success
|
||||
ULONG rc = 0;
|
||||
ULONG ec = 0;
|
||||
bool bResult = qmiRsp.GetResult( rc, ec );
|
||||
if (bResult == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
else if (rc != 0)
|
||||
{
|
||||
return GetCorrectedQMIError( ec );
|
||||
}
|
||||
|
||||
// How many parameters did we populate?
|
||||
ULONG params = 0;
|
||||
|
||||
// Prepare TLVs for parsing
|
||||
std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiRsp );
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
|
||||
// Parse the TLVs we want (by DB key)
|
||||
sProtocolEntityKey tlvKey( eDB2_ET_QMI_OMA_RSP, msgID, 16 );
|
||||
cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
|
||||
if (pf.size() >= 2)
|
||||
{
|
||||
*pSessionState = pf[0].mValue.mU32;
|
||||
*pSessionType = pf[1].mValue.mU32;
|
||||
params += 2;
|
||||
}
|
||||
|
||||
tlvKey = sProtocolEntityKey( eDB2_ET_QMI_OMA_RSP, msgID, 17 );
|
||||
pf = ParseTLV( db, rsp, tlvs, tlvKey );
|
||||
if (pf.size() >= 1)
|
||||
{
|
||||
*pFailureReason = pf[0].mValue.mU32;
|
||||
params++;
|
||||
}
|
||||
|
||||
tlvKey = sProtocolEntityKey( eDB2_ET_QMI_OMA_RSP, msgID, 18 );
|
||||
pf = ParseTLV( db, rsp, tlvs, tlvKey );
|
||||
if (pf.size() >= 3)
|
||||
{
|
||||
*pRetryCount = pf[0].mValue.mU8;
|
||||
*pSessionPause = pf[1].mValue.mU16;
|
||||
*pTimeRemaining = pf[2].mValue.mU16;
|
||||
params += 3;
|
||||
}
|
||||
|
||||
if (params == 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_RSP;
|
||||
}
|
||||
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
OMADMGetPendingNIA (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function returns information about the pending network initiated
|
||||
alert
|
||||
|
||||
PARAMETERS:
|
||||
pSessionType [ O ] - Type of session
|
||||
pSessionID [ O ] - Unique session ID
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::OMADMGetPendingNIA(
|
||||
ULONG * pSessionType,
|
||||
USHORT * pSessionID )
|
||||
{
|
||||
// Validate arguments
|
||||
if (pSessionType == 0 || pSessionID == 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
*pSessionType = ULONG_MAX;
|
||||
*pSessionID = USHRT_MAX;
|
||||
|
||||
// Generate and send the QMI request
|
||||
WORD msgID = (WORD)eQMI_OMA_GET_SESSION_INFO;
|
||||
sProtocolBuffer rsp = SendSimple( eQMI_SVC_OMA, msgID );
|
||||
if (rsp.IsValid() == false)
|
||||
{
|
||||
return GetCorrectedLastError();
|
||||
}
|
||||
|
||||
// Did we receive a valid QMI response?
|
||||
sQMIServiceBuffer qmiRsp( rsp.GetSharedBuffer() );
|
||||
if (qmiRsp.IsValid() == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
|
||||
// Check the mandatory QMI result TLV for success
|
||||
ULONG rc = 0;
|
||||
ULONG ec = 0;
|
||||
bool bResult = qmiRsp.GetResult( rc, ec );
|
||||
if (bResult == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
else if (rc != 0)
|
||||
{
|
||||
return GetCorrectedQMIError( ec );
|
||||
}
|
||||
|
||||
// How many parameters did we populate?
|
||||
ULONG params = 0;
|
||||
|
||||
// Prepare TLVs for parsing
|
||||
std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiRsp );
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
|
||||
// Parse the TLVs we want (by DB key)
|
||||
sProtocolEntityKey tlvKey( eDB2_ET_QMI_OMA_RSP, msgID, 19 );
|
||||
cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
|
||||
if (pf.size() >= 2)
|
||||
{
|
||||
*pSessionType = pf[0].mValue.mU32;
|
||||
*pSessionID = pf[1].mValue.mU16;
|
||||
params += 2;
|
||||
}
|
||||
|
||||
if (params == 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_RSP;
|
||||
}
|
||||
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
OMADMSendSelection (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function sends the specified OMA-DM selection for the current
|
||||
network initiated session
|
||||
|
||||
PARAMETERS:
|
||||
selection [ I ] - Selection
|
||||
sessionID [ I ] - Unique session ID
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::OMADMSendSelection(
|
||||
ULONG selection,
|
||||
USHORT sessionID )
|
||||
{
|
||||
WORD msgID = (WORD)eQMI_OMA_SEND_SELECTION;
|
||||
std::vector <sDB2PackingInput> piv;
|
||||
|
||||
std::ostringstream tmp;
|
||||
tmp << selection << " " << sessionID;
|
||||
|
||||
sProtocolEntityKey pek( eDB2_ET_QMI_OMA_REQ, msgID, 16 );
|
||||
sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
|
||||
piv.push_back( pi );
|
||||
|
||||
// Pack up the QMI request
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
sSharedBuffer * pRequest = DB2PackQMIBuffer( db, piv );
|
||||
if (pRequest == 0)
|
||||
{
|
||||
return eGOBI_ERR_MEMORY;
|
||||
}
|
||||
|
||||
// Send the QMI request, check result, and return
|
||||
return SendAndCheckReturn( eQMI_SVC_OMA, pRequest );
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
OMADMGetFeatureSettings (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function returns the OMA-DM feature settings
|
||||
|
||||
PARAMETERS:
|
||||
pbProvisioning [ O ] - Device provisioning service update enabled
|
||||
pbPRLUpdate [ O ] - PRL service update enabled
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::OMADMGetFeatureSettings(
|
||||
ULONG * pbProvisioning,
|
||||
ULONG * pbPRLUpdate )
|
||||
{
|
||||
// Validate arguments
|
||||
if (pbProvisioning == 0 || pbPRLUpdate == 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
*pbProvisioning = ULONG_MAX;
|
||||
*pbPRLUpdate = ULONG_MAX;
|
||||
|
||||
// Generate and send the QMI request
|
||||
WORD msgID = (WORD)eQMI_OMA_GET_FEATURES;
|
||||
sProtocolBuffer rsp = SendSimple( eQMI_SVC_OMA, msgID );
|
||||
if (rsp.IsValid() == false)
|
||||
{
|
||||
return GetCorrectedLastError();
|
||||
}
|
||||
|
||||
// Did we receive a valid QMI response?
|
||||
sQMIServiceBuffer qmiRsp( rsp.GetSharedBuffer() );
|
||||
if (qmiRsp.IsValid() == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
|
||||
// Check the mandatory QMI result TLV for success
|
||||
ULONG rc = 0;
|
||||
ULONG ec = 0;
|
||||
bool bResult = qmiRsp.GetResult( rc, ec );
|
||||
if (bResult == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
else if (rc != 0)
|
||||
{
|
||||
return GetCorrectedQMIError( ec );
|
||||
}
|
||||
|
||||
// How many parameters did we populate?
|
||||
ULONG params = 0;
|
||||
|
||||
// Prepare TLVs for parsing
|
||||
std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiRsp );
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
|
||||
// Parse the TLVs we want (by DB key)
|
||||
sProtocolEntityKey tlvKey( eDB2_ET_QMI_OMA_RSP, msgID, 16 );
|
||||
cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
|
||||
if (pf.size() >= 1)
|
||||
{
|
||||
*pbProvisioning = pf[0].mValue.mU32;
|
||||
params++;
|
||||
}
|
||||
|
||||
tlvKey = sProtocolEntityKey( eDB2_ET_QMI_OMA_RSP, msgID, 17 );
|
||||
pf = ParseTLV( db, rsp, tlvs, tlvKey );
|
||||
if (pf.size() >= 1)
|
||||
{
|
||||
*pbPRLUpdate = pf[0].mValue.mU32;
|
||||
params++;
|
||||
}
|
||||
|
||||
if (params == 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_RSP;
|
||||
}
|
||||
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
OMADMSetProvisioningFeature (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function sets the OMA-DM device provisioning service
|
||||
update feature setting
|
||||
|
||||
PARAMETERS:
|
||||
bProvisioning [ I ] - Device provisioning service update enabled
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::OMADMSetProvisioningFeature(
|
||||
ULONG bProvisioning )
|
||||
{
|
||||
WORD msgID = (WORD)eQMI_OMA_SET_FEATURES;
|
||||
std::vector <sDB2PackingInput> piv;
|
||||
|
||||
std::ostringstream tmp;
|
||||
tmp << (ULONG)(bProvisioning != 0);
|
||||
|
||||
sProtocolEntityKey pek( eDB2_ET_QMI_OMA_REQ, msgID, 16 );
|
||||
sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
|
||||
piv.push_back( pi );
|
||||
|
||||
// Pack up the QMI request
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
sSharedBuffer * pRequest = DB2PackQMIBuffer( db, piv );
|
||||
if (pRequest == 0)
|
||||
{
|
||||
return eGOBI_ERR_MEMORY;
|
||||
}
|
||||
|
||||
// Send the QMI request, check result, and return
|
||||
return SendAndCheckReturn( eQMI_SVC_OMA, pRequest );
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
OMADMSetPRLUpdateFeature (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function sets the OMA-DM PRL service update feature setting
|
||||
|
||||
PARAMETERS:
|
||||
bPRLUpdate [ I ] - PRL service update enabled
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::OMADMSetPRLUpdateFeature(
|
||||
ULONG bPRLUpdate )
|
||||
{
|
||||
WORD msgID = (WORD)eQMI_OMA_SET_FEATURES;
|
||||
std::vector <sDB2PackingInput> piv;
|
||||
|
||||
std::ostringstream tmp;
|
||||
tmp << (ULONG)(bPRLUpdate != 0);
|
||||
|
||||
sProtocolEntityKey pek( eDB2_ET_QMI_OMA_REQ, msgID, 17 );
|
||||
sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
|
||||
piv.push_back( pi );
|
||||
|
||||
// Pack up the QMI request
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
sSharedBuffer * pRequest = DB2PackQMIBuffer( db, piv );
|
||||
if (pRequest == 0)
|
||||
{
|
||||
return eGOBI_ERR_MEMORY;
|
||||
}
|
||||
|
||||
// Send the QMI request, check result, and return
|
||||
return SendAndCheckReturn( eQMI_SVC_OMA, pRequest );
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,187 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
GobiQMICoreRMS.cpp
|
||||
|
||||
DESCRIPTION:
|
||||
QUALCOMM Gobi QMI Based API Core (RMS Service)
|
||||
|
||||
PUBLIC CLASSES AND FUNCTIONS:
|
||||
cGobiQMICore
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
==========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "StdAfx.h"
|
||||
#include "GobiQMICore.h"
|
||||
|
||||
#include "QMIBuffers.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
/*=========================================================================*/
|
||||
// cGobiQMICore Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetSMSWake
|
||||
|
||||
DESCRIPTION:
|
||||
This function queries the state of the SMS wake functionality
|
||||
|
||||
PARAMETERS:
|
||||
pbEnabled [ O ] - SMS wake functionality enabled?
|
||||
pWakeMask [ O ] - SMS wake mask (only relevant when enabled)
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::GetSMSWake(
|
||||
ULONG * pbEnabled,
|
||||
ULONG * pWakeMask )
|
||||
{
|
||||
// Validate arguments
|
||||
if (pbEnabled == 0 || pWakeMask == 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
*pbEnabled = ULONG_MAX;
|
||||
*pWakeMask = ULONG_MAX;
|
||||
|
||||
// Generate and send the QMI request
|
||||
WORD msgID = (WORD)eQMI_RMS_GET_SMS_WAKE;
|
||||
sProtocolBuffer rsp = SendSimple( eQMI_SVC_RMS, msgID );
|
||||
if (rsp.IsValid() == false)
|
||||
{
|
||||
return GetCorrectedLastError();
|
||||
}
|
||||
|
||||
// Did we receive a valid QMI response?
|
||||
sQMIServiceBuffer qmiRsp( rsp.GetSharedBuffer() );
|
||||
if (qmiRsp.IsValid() == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
|
||||
// Check the mandatory QMI result TLV for success
|
||||
ULONG rc = 0;
|
||||
ULONG ec = 0;
|
||||
bool bResult = qmiRsp.GetResult( rc, ec );
|
||||
if (bResult == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
else if (rc != 0)
|
||||
{
|
||||
return GetCorrectedQMIError( ec );
|
||||
}
|
||||
|
||||
// Try to find TLVs ID 16/17
|
||||
std::map <ULONG, const sQMIRawContentHeader *> tlvs;
|
||||
tlvs = qmiRsp.GetContents();
|
||||
|
||||
std::map <ULONG, const sQMIRawContentHeader *>::const_iterator pIter;
|
||||
pIter = tlvs.find( 16 );
|
||||
if (pIter != tlvs.end())
|
||||
{
|
||||
const sQMIRawContentHeader * pHdr = pIter->second;
|
||||
if (pHdr->mLength < (WORD)1)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
|
||||
const BYTE * pData = (const BYTE *)++pHdr;
|
||||
*pbEnabled = (ULONG)*pData;
|
||||
}
|
||||
|
||||
pIter = tlvs.find( 17 );
|
||||
if (pIter != tlvs.end())
|
||||
{
|
||||
const sQMIRawContentHeader * pHdr = pIter->second;
|
||||
if (pHdr->mLength < (WORD)4)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
|
||||
const ULONG * pData = (const ULONG *)++pHdr;
|
||||
*pWakeMask = *pData;
|
||||
}
|
||||
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
SetSMSWake
|
||||
|
||||
DESCRIPTION:
|
||||
This function enables/disables the SMS wake functionality
|
||||
|
||||
PARAMETERS:
|
||||
bEnable [ I ] - Enable SMS wake functionality?
|
||||
wakeMask [ I ] - SMS wake mask (only relevant when enabling)
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::SetSMSWake(
|
||||
ULONG bEnable,
|
||||
ULONG wakeMask )
|
||||
{
|
||||
WORD msgID = (WORD)eQMI_RMS_SET_SMS_WAKE;
|
||||
std::vector <sDB2PackingInput> piv;
|
||||
|
||||
BYTE enableTmp = (BYTE)(bEnable == 0 ? 0 : 1 );
|
||||
sProtocolEntityKey pek1( eDB2_ET_QMI_RMS_REQ, msgID, 16 );
|
||||
sDB2PackingInput pi1( pek1, &enableTmp, 1 );
|
||||
piv.push_back( pi1 );
|
||||
|
||||
if (bEnable != 0)
|
||||
{
|
||||
sProtocolEntityKey pek2( eDB2_ET_QMI_RMS_REQ, msgID, 17 );
|
||||
sDB2PackingInput pi2( pek2, (const BYTE *)&wakeMask, 4 );
|
||||
piv.push_back( pi2 );
|
||||
}
|
||||
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
sSharedBuffer * pRequest = DB2PackQMIBuffer( db, piv );
|
||||
if (pRequest == 0)
|
||||
{
|
||||
return eGOBI_ERR_MEMORY;
|
||||
}
|
||||
|
||||
// Send the QMI request, check result, and return
|
||||
return SendAndCheckReturn( eQMI_SVC_RMS, pRequest );
|
||||
}
|
||||
|
|
@ -0,0 +1,940 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
GobiQMICoreSMS.cpp
|
||||
|
||||
DESCRIPTION:
|
||||
QUALCOMM Gobi QMI Based API Core (SMS Service)
|
||||
|
||||
PUBLIC CLASSES AND FUNCTIONS:
|
||||
cGobiQMICore
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
==========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "StdAfx.h"
|
||||
#include "GobiQMICore.h"
|
||||
|
||||
#include "QMIBuffers.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
/*=========================================================================*/
|
||||
// cGobiQMICore Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
DeleteSMS (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function deletes one or more SMS messages from device memory
|
||||
|
||||
PARAMETERS:
|
||||
storageType [ I ] - SMS message storage type
|
||||
pMessageIndex [ I ] - (Optional) message index
|
||||
pMessageTag [ I ] - (Optional) message tag
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::DeleteSMS(
|
||||
ULONG storageType,
|
||||
ULONG * pMessageIndex,
|
||||
ULONG * pMessageTag )
|
||||
{
|
||||
WORD msgID = (WORD)eQMI_WMS_DELETE;
|
||||
std::vector <sDB2PackingInput> piv;
|
||||
|
||||
std::ostringstream tmp;
|
||||
tmp << (UINT)storageType;
|
||||
|
||||
sProtocolEntityKey pek( eDB2_ET_QMI_WMS_REQ, msgID, 1 );
|
||||
sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
|
||||
piv.push_back( pi );
|
||||
|
||||
if (pMessageIndex != 0)
|
||||
{
|
||||
std::ostringstream tmp2;
|
||||
tmp2 << (UINT)*pMessageIndex;
|
||||
|
||||
sProtocolEntityKey pek1( eDB2_ET_QMI_WMS_REQ, msgID, 16 );
|
||||
sDB2PackingInput pi1( pek1, (LPCSTR)tmp2.str().c_str() );
|
||||
piv.push_back( pi1 );
|
||||
}
|
||||
|
||||
if (pMessageTag != 0)
|
||||
{
|
||||
std::ostringstream tmp2;
|
||||
tmp2 << (UINT)*pMessageTag;
|
||||
|
||||
sProtocolEntityKey pek1( eDB2_ET_QMI_WMS_REQ, msgID, 17 );
|
||||
sDB2PackingInput pi1( pek1, (LPCSTR)tmp2.str().c_str() );
|
||||
piv.push_back( pi1 );
|
||||
}
|
||||
|
||||
// Pack up the QMI request
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
sSharedBuffer * pRequest = DB2PackQMIBuffer( db, piv );
|
||||
|
||||
// Send the QMI request, check result, and return
|
||||
return SendAndCheckReturn( eQMI_SVC_WMS, pRequest, 10000 );
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetSMSList (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function returns the list of SMS messages stored on the device
|
||||
|
||||
PARAMETERS:
|
||||
storageType [ I ] - SMS message storage type
|
||||
pRequestedTag [ I ] - Message index
|
||||
pMessageListSize [I/O] - Upon input the maximum number of elements that the
|
||||
message list array can contain. Upon successful
|
||||
output the actual number of elements in the message
|
||||
list array
|
||||
pMessageList [ O ] - The message list array
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::GetSMSList(
|
||||
ULONG storageType,
|
||||
ULONG * pRequestedTag,
|
||||
ULONG * pMessageListSize,
|
||||
BYTE * pMessageList )
|
||||
{
|
||||
// Validate arguments
|
||||
if (pMessageListSize == 0 || *pMessageListSize == 0 || pMessageList == 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ULONG maxMessageListSz = *pMessageListSize;
|
||||
|
||||
// Assume failure
|
||||
*pMessageListSize = 0;
|
||||
|
||||
WORD msgID = (WORD)eQMI_WMS_GET_MSG_LIST;
|
||||
std::vector <sDB2PackingInput> piv;
|
||||
|
||||
std::ostringstream tmp;
|
||||
tmp << (UINT)storageType;
|
||||
|
||||
sProtocolEntityKey pek( eDB2_ET_QMI_WMS_REQ, msgID, 1 );
|
||||
sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
|
||||
piv.push_back( pi );
|
||||
|
||||
if (pRequestedTag != 0)
|
||||
{
|
||||
std::ostringstream tmp2;
|
||||
tmp2 << (UINT)*pRequestedTag;
|
||||
|
||||
sProtocolEntityKey pek1( eDB2_ET_QMI_WMS_REQ, msgID, 16 );
|
||||
sDB2PackingInput pi1( pek1, (LPCSTR)tmp2.str().c_str() );
|
||||
piv.push_back( pi1 );
|
||||
}
|
||||
|
||||
// Pack up the QMI request
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
sSharedBuffer * pRequest = DB2PackQMIBuffer( db, piv );
|
||||
if (pRequest == 0)
|
||||
{
|
||||
return eGOBI_ERR_MEMORY;
|
||||
}
|
||||
|
||||
// Send the QMI request
|
||||
sProtocolBuffer rsp = Send( eQMI_SVC_WMS, pRequest, 5000 );
|
||||
if (rsp.IsValid() == false)
|
||||
{
|
||||
return GetCorrectedLastError();
|
||||
}
|
||||
|
||||
// Did we receive a valid QMI response?
|
||||
sQMIServiceBuffer qmiRsp( rsp.GetSharedBuffer() );
|
||||
if (qmiRsp.IsValid() == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
|
||||
// Check the mandatory QMI result TLV for success
|
||||
ULONG rc = 0;
|
||||
ULONG ec = 0;
|
||||
bool bResult = qmiRsp.GetResult( rc, ec );
|
||||
if (bResult == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
else if (rc != 0)
|
||||
{
|
||||
return GetCorrectedQMIError( ec );
|
||||
}
|
||||
|
||||
// Prepare TLVs for parsing
|
||||
std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiRsp );
|
||||
|
||||
// Parse the TLV we want (by DB key)
|
||||
sProtocolEntityKey tlvKey( eDB2_ET_QMI_WMS_RSP, msgID, 1 );
|
||||
cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
|
||||
if (pf.size() < 1)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_RSP;
|
||||
}
|
||||
|
||||
ULONG messageListSz = pf[0].mValue.mU32;
|
||||
if (messageListSz == 0)
|
||||
{
|
||||
// No stored messages, but not necessarily a failure
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
if (pf.size() < (1 + (messageListSz * 2)) )
|
||||
{
|
||||
return eGOBI_ERR_INVALID_RSP;
|
||||
}
|
||||
|
||||
if (maxMessageListSz < messageListSz)
|
||||
{
|
||||
messageListSz = maxMessageListSz;
|
||||
}
|
||||
|
||||
ULONG m = 0;
|
||||
ULONG mf = 1;
|
||||
ULONG * pData = (ULONG *)pMessageList;
|
||||
for (m = 0; m < messageListSz; m++)
|
||||
{
|
||||
*pData++ = pf[mf++].mValue.mU32;
|
||||
*pData++ = pf[mf++].mValue.mU32;
|
||||
}
|
||||
|
||||
*pMessageListSize = messageListSz;
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetSMS (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function returns an SMS message from device memory
|
||||
|
||||
PARAMETERS:
|
||||
storageType [ I ] - SMS message storage type
|
||||
messageIndex [ I ] - Message index
|
||||
pMessageTag [ O ] - Message tag
|
||||
pMessageFormat [ O ] - Message format
|
||||
pMessageSize [I/O] - Upon input the maximum number of bytes that can be
|
||||
written to the message array. Upon successful
|
||||
output the actual number of bytes written to the
|
||||
message array
|
||||
pMessage [ I ] - The message contents array
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::GetSMS(
|
||||
ULONG storageType,
|
||||
ULONG messageIndex,
|
||||
ULONG * pMessageTag,
|
||||
ULONG * pMessageFormat,
|
||||
ULONG * pMessageSize,
|
||||
BYTE * pMessage )
|
||||
{
|
||||
// Validate arguments
|
||||
if ( (pMessageTag == 0)
|
||||
|| (pMessageFormat == 0)
|
||||
|| (pMessageSize == 0)
|
||||
|| (*pMessageSize == 0)
|
||||
|| (pMessage == 0) )
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ULONG maxMessageSz = *pMessageSize;
|
||||
|
||||
// Assume failure
|
||||
*pMessageSize = 0;
|
||||
|
||||
WORD msgID = (WORD)eQMI_WMS_RAW_READ;
|
||||
std::vector <sDB2PackingInput> piv;
|
||||
|
||||
std::ostringstream tmp;
|
||||
tmp << (UINT)storageType << " " << (UINT)messageIndex;
|
||||
|
||||
sProtocolEntityKey pek( eDB2_ET_QMI_WMS_REQ, msgID, 1 );
|
||||
sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
|
||||
piv.push_back( pi );
|
||||
|
||||
// Pack up the QMI request
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
sSharedBuffer * pRequest = DB2PackQMIBuffer( db, piv );
|
||||
if (pRequest == 0)
|
||||
{
|
||||
return eGOBI_ERR_MEMORY;
|
||||
}
|
||||
|
||||
// Send the QMI request
|
||||
sProtocolBuffer rsp = Send( eQMI_SVC_WMS, pRequest, 5000 );
|
||||
if (rsp.IsValid() == false)
|
||||
{
|
||||
return GetCorrectedLastError();
|
||||
}
|
||||
|
||||
// Did we receive a valid QMI response?
|
||||
sQMIServiceBuffer qmiRsp( rsp.GetSharedBuffer() );
|
||||
if (qmiRsp.IsValid() == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
|
||||
// Check the mandatory QMI result TLV for success
|
||||
ULONG rc = 0;
|
||||
ULONG ec = 0;
|
||||
bool bResult = qmiRsp.GetResult( rc, ec );
|
||||
if (bResult == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
else if (rc != 0)
|
||||
{
|
||||
return GetCorrectedQMIError( ec );
|
||||
}
|
||||
|
||||
// Prepare TLVs for parsing
|
||||
std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiRsp );
|
||||
|
||||
// Parse the TLV we want (by DB key)
|
||||
sProtocolEntityKey tlvKey( eDB2_ET_QMI_WMS_RSP, msgID, 1 );
|
||||
cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
|
||||
if (pf.size() < 3)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_RSP;
|
||||
}
|
||||
|
||||
*pMessageTag = pf[0].mValue.mU32;
|
||||
*pMessageFormat = pf[1].mValue.mU32;
|
||||
|
||||
ULONG messageSz = (ULONG)pf[2].mValue.mU16;
|
||||
if (messageSz == 0)
|
||||
{
|
||||
// There has to be message data
|
||||
return eGOBI_ERR_INVALID_RSP;
|
||||
}
|
||||
|
||||
if (pf.size() < 3 + messageSz)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_RSP;
|
||||
}
|
||||
|
||||
if (maxMessageSz < messageSz)
|
||||
{
|
||||
// We have to be able to copy the whole message
|
||||
return eGOBI_ERR_BUFFER_SZ;
|
||||
}
|
||||
|
||||
// Copy message data
|
||||
for (ULONG b = 0; b < messageSz; b++)
|
||||
{
|
||||
pMessage[b] = pf[3 + b].mValue.mU8;
|
||||
}
|
||||
|
||||
*pMessageSize = messageSz;
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
ModifySMSStatus (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function modifies the status of an SMS message saved in storage on
|
||||
the device
|
||||
|
||||
PARAMETERS:
|
||||
storageType [ I ] - SMS message storage type
|
||||
messageIndex [ I ] - Message index
|
||||
messageTag [ I ] - Message tag
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::ModifySMSStatus(
|
||||
ULONG storageType,
|
||||
ULONG messageIndex,
|
||||
ULONG messageTag )
|
||||
{
|
||||
WORD msgID = (WORD)eQMI_WMS_MODIFY_TAG;
|
||||
std::vector <sDB2PackingInput> piv;
|
||||
|
||||
std::ostringstream tmp;
|
||||
tmp << (UINT)storageType << " " << (UINT)messageIndex << " "
|
||||
<< (UINT)messageTag;
|
||||
|
||||
sProtocolEntityKey pek( eDB2_ET_QMI_WMS_REQ, msgID, 1 );
|
||||
sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
|
||||
piv.push_back( pi );
|
||||
|
||||
// Pack up the QMI request
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
sSharedBuffer * pRequest = DB2PackQMIBuffer( db, piv );
|
||||
|
||||
// Send the QMI request, check result, and return
|
||||
return SendAndCheckReturn( eQMI_SVC_WMS, pRequest, 5000 );
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
SaveSMS (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function saves an SMS message to device memory
|
||||
|
||||
PARAMETERS:
|
||||
storageType [ I ] - SMS message storage type
|
||||
messageFormat [ I ] - Message format
|
||||
messageSize [ I ] - The length of the message contents in bytes
|
||||
pMessage [ I ] - The message contents
|
||||
pMessageIndex [ O ] - The message index assigned by the device
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::SaveSMS(
|
||||
ULONG storageType,
|
||||
ULONG messageFormat,
|
||||
ULONG messageSize,
|
||||
BYTE * pMessage,
|
||||
ULONG * pMessageIndex )
|
||||
{
|
||||
// Validate arguments
|
||||
if (messageSize == 0 || pMessage == 0 || pMessageIndex == 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
WORD msgID = (WORD)eQMI_WMS_RAW_WRITE;
|
||||
std::vector <sDB2PackingInput> piv;
|
||||
|
||||
// "%u %u %u"
|
||||
std::ostringstream tmp;
|
||||
tmp << (UINT)storageType << " " << (UINT)messageFormat
|
||||
<< " " << (UINT)messageSize;
|
||||
|
||||
for (ULONG b = 0; b < messageSize; b++)
|
||||
{
|
||||
tmp << " " << (UINT)pMessage[b];
|
||||
}
|
||||
|
||||
sProtocolEntityKey pek( eDB2_ET_QMI_WMS_REQ, msgID, 1 );
|
||||
sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
|
||||
piv.push_back( pi );
|
||||
|
||||
// Pack up the QMI request
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
sSharedBuffer * pRequest = DB2PackQMIBuffer( db, piv );
|
||||
if (pRequest == 0)
|
||||
{
|
||||
return eGOBI_ERR_MEMORY;
|
||||
}
|
||||
|
||||
// Send the QMI request
|
||||
sProtocolBuffer rsp = Send( eQMI_SVC_WMS, pRequest, 10000 );
|
||||
if (rsp.IsValid() == false)
|
||||
{
|
||||
return GetCorrectedLastError();
|
||||
}
|
||||
|
||||
// Did we receive a valid QMI response?
|
||||
sQMIServiceBuffer qmiRsp( rsp.GetSharedBuffer() );
|
||||
if (qmiRsp.IsValid() == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
|
||||
// Check the mandatory QMI result TLV for success
|
||||
ULONG rc = 0;
|
||||
ULONG ec = 0;
|
||||
bool bResult = qmiRsp.GetResult( rc, ec );
|
||||
if (bResult == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
else if (rc != 0)
|
||||
{
|
||||
return GetCorrectedQMIError( ec );
|
||||
}
|
||||
|
||||
// Prepare TLVs for parsing
|
||||
std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiRsp );
|
||||
|
||||
// Parse the TLV we want (by DB key)
|
||||
sProtocolEntityKey tlvKey( eDB2_ET_QMI_WMS_RSP, msgID, 1 );
|
||||
cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
|
||||
if (pf.size() < 1)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_RSP;
|
||||
}
|
||||
|
||||
*pMessageIndex = pf[0].mValue.mU32;
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
SendSMS (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function sends an SMS message for immediate over the air transmission
|
||||
|
||||
PARAMETERS:
|
||||
messageFormat [ I ] - Message format
|
||||
messageSize [ I ] - The length of the message contents in bytes
|
||||
pMessage [ I ] - The message contents
|
||||
pMessageFailureCode [ O ] - When the function fails due to an error sending
|
||||
the message this parameter may contain the
|
||||
message failure cause code (see 3GPP2 N.S0005
|
||||
Section 6.5.2.125). If the cause code is not
|
||||
provided then the value will be 0xFFFFFFFF
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::SendSMS(
|
||||
ULONG messageFormat,
|
||||
ULONG messageSize,
|
||||
BYTE * pMessage,
|
||||
ULONG * pMessageFailureCode )
|
||||
{
|
||||
// Validate arguments
|
||||
if (messageSize == 0 || pMessage == 0 || pMessageFailureCode == 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
// Assume we have no message failure cause code
|
||||
*pMessageFailureCode = ULONG_MAX;
|
||||
|
||||
WORD msgID = (WORD)eQMI_WMS_RAW_SEND;
|
||||
std::vector <sDB2PackingInput> piv;
|
||||
|
||||
std::ostringstream tmp;
|
||||
tmp << (UINT)messageFormat << " " << (UINT)messageSize;
|
||||
|
||||
for (ULONG b = 0; b < messageSize; b++)
|
||||
{
|
||||
tmp << " " << (UINT)pMessage[b];
|
||||
}
|
||||
|
||||
sProtocolEntityKey pek( eDB2_ET_QMI_WMS_REQ, msgID, 1 );
|
||||
sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
|
||||
piv.push_back( pi );
|
||||
|
||||
// Pack up the QMI request
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
sSharedBuffer * pRequest = DB2PackQMIBuffer( db, piv );
|
||||
if (pRequest == 0)
|
||||
{
|
||||
return eGOBI_ERR_MEMORY;
|
||||
}
|
||||
|
||||
// Send the QMI request
|
||||
sProtocolBuffer rsp = Send( eQMI_SVC_WMS, pRequest, 300000 );
|
||||
if (rsp.IsValid() == false)
|
||||
{
|
||||
return GetCorrectedLastError();
|
||||
}
|
||||
|
||||
// Did we receive a valid QMI response?
|
||||
sQMIServiceBuffer qmiRsp( rsp.GetSharedBuffer() );
|
||||
if (qmiRsp.IsValid() == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
|
||||
// Check the mandatory QMI result TLV for success
|
||||
ULONG rc = 0;
|
||||
ULONG ec = 0;
|
||||
bool bResult = qmiRsp.GetResult( rc, ec );
|
||||
if (bResult == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
else if (rc != 0)
|
||||
{
|
||||
// Prepare TLVs for parsing
|
||||
std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiRsp );
|
||||
|
||||
// Parse the optional TLV we want (by DB key)
|
||||
sProtocolEntityKey tlvKey( eDB2_ET_QMI_WMS_RSP, msgID, 1 );
|
||||
cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
|
||||
if (pf.size() >= 1)
|
||||
{
|
||||
*pMessageFailureCode = (ULONG)pf[0].mValue.mU16;
|
||||
}
|
||||
|
||||
return GetCorrectedQMIError( ec );
|
||||
}
|
||||
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetSMSCAddress (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Return the SMS center address
|
||||
|
||||
PARAMETERS:
|
||||
addressSize [ I ] - The maximum number of characters (including NULL
|
||||
terminator) that the SMS center address array
|
||||
can contain
|
||||
pSMSCAddress [ 0 ] - The SMS center address represented as a NULL
|
||||
terminated string
|
||||
typeSize [ I ] - The maximum number of characters (including NULL
|
||||
terminator) that the SMS center address type array
|
||||
can contain
|
||||
pSMSCType [ 0 ] - The SMS center address type represented as a NULL
|
||||
terminated string
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::GetSMSCAddress(
|
||||
BYTE addressSize,
|
||||
CHAR * pSMSCAddress,
|
||||
BYTE typeSize,
|
||||
CHAR * pSMSCType )
|
||||
{
|
||||
// Validate arguments
|
||||
if (addressSize == 0 || pSMSCAddress == 0 || typeSize == 0 || pSMSCType == 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
pSMSCAddress[0] = 0;
|
||||
pSMSCType[0] = 0;
|
||||
|
||||
// Generate and send the QMI request
|
||||
WORD msgID = (WORD)eQMI_WMS_GET_SMSC_ADDR;
|
||||
sProtocolBuffer rsp = SendSimple( eQMI_SVC_WMS, msgID );
|
||||
if (rsp.IsValid() == false)
|
||||
{
|
||||
return GetCorrectedLastError();
|
||||
}
|
||||
|
||||
// Did we receive a valid QMI response?
|
||||
sQMIServiceBuffer qmiRsp( rsp.GetSharedBuffer() );
|
||||
if (qmiRsp.IsValid() == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
|
||||
// Check the mandatory QMI result TLV for success
|
||||
ULONG rc = 0;
|
||||
ULONG ec = 0;
|
||||
bool bResult = qmiRsp.GetResult( rc, ec );
|
||||
if (bResult == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
else if (rc != 0)
|
||||
{
|
||||
return GetCorrectedQMIError( ec );
|
||||
}
|
||||
|
||||
// Prepare TLVs for parsing
|
||||
std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiRsp );
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
|
||||
// Parse the TLV we want (by DB key)
|
||||
sProtocolEntityKey tlvKey( eDB2_ET_QMI_WMS_RSP, msgID, 1 );
|
||||
cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
|
||||
if (pf.size() < 3)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_RSP;
|
||||
}
|
||||
|
||||
LONG strLen = pf[0].mValueString.size();
|
||||
if (strLen > 0)
|
||||
{
|
||||
// Space to perform the copy?
|
||||
if (typeSize < strLen + 1)
|
||||
{
|
||||
return eGOBI_ERR_BUFFER_SZ;
|
||||
}
|
||||
|
||||
memcpy( (LPVOID)pSMSCType, (LPCSTR)pf[0].mValueString.c_str(), strLen );
|
||||
pSMSCType[strLen] = 0;
|
||||
}
|
||||
|
||||
strLen = pf[2].mValueString.size();
|
||||
if (strLen > 0)
|
||||
{
|
||||
// Space to perform the copy?
|
||||
if (addressSize < strLen + 1)
|
||||
{
|
||||
return eGOBI_ERR_BUFFER_SZ;
|
||||
}
|
||||
|
||||
memcpy( (LPVOID)pSMSCAddress, (LPCSTR)pf[2].mValueString.c_str(), strLen );
|
||||
pSMSCAddress[strLen] = 0;
|
||||
}
|
||||
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
SetSMSCAddress (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Set the SMS center address
|
||||
|
||||
PARAMETERS:
|
||||
pSMSCAddress [ I ] - The SMS center address represented as a NULL
|
||||
terminated string (maximum of 21 characters,
|
||||
including NULL)
|
||||
pSMSCType [ I ] - The SMS center address type represented as a NULL
|
||||
terminated string (optional)
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::SetSMSCAddress(
|
||||
CHAR * pSMSCAddress,
|
||||
CHAR * pSMSCType )
|
||||
{
|
||||
// Validate arguments
|
||||
if (pSMSCAddress == 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
WORD msgID = (WORD)eQMI_WMS_SET_SMSC_ADDR;
|
||||
std::vector <sDB2PackingInput> piv;
|
||||
|
||||
std::ostringstream addr;
|
||||
if (pSMSCAddress[0] != 0)
|
||||
{
|
||||
addr << "\"" << pSMSCAddress << "\"";
|
||||
}
|
||||
|
||||
sProtocolEntityKey pek( eDB2_ET_QMI_WMS_REQ, msgID, 1 );
|
||||
sDB2PackingInput pi( pek, (LPCSTR)addr.str().c_str() );
|
||||
piv.push_back( pi );
|
||||
|
||||
if (pSMSCType != 0)
|
||||
{
|
||||
std::ostringstream addrType;
|
||||
if (pSMSCType[0] != 0)
|
||||
{
|
||||
addrType << "\"" << pSMSCType << "\"";
|
||||
}
|
||||
|
||||
pek = sProtocolEntityKey( eDB2_ET_QMI_WMS_REQ, msgID, 16 );
|
||||
pi = sDB2PackingInput( pek, (LPCSTR)addrType.str().c_str() );
|
||||
piv.push_back( pi );
|
||||
}
|
||||
|
||||
// Pack up the QMI request
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
sSharedBuffer * pRequest = DB2PackQMIBuffer( db, piv );
|
||||
|
||||
// Send the QMI request, check result, and return
|
||||
return SendAndCheckReturn( eQMI_SVC_WMS, pRequest, 5000 );
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
GetSMSRoutes (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Get the current incoming SMS routing information
|
||||
|
||||
PARAMETERS:
|
||||
pRouteSize [I/O] - Upon input the maximum number of elements that the
|
||||
SMS route array can contain. Upon succes the actual
|
||||
number of elements in the SMS route array
|
||||
pRoutes [ O ] - The SMS route array
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::GetSMSRoutes(
|
||||
BYTE * pRouteSize,
|
||||
BYTE * pRoutes )
|
||||
{
|
||||
// Validate arguments
|
||||
if (pRouteSize == 0 || *pRouteSize == 0 || pRoutes == 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
// Assume failure
|
||||
BYTE maxRoutes = *pRouteSize;
|
||||
*pRouteSize = 0;
|
||||
|
||||
// Generate and send the QMI request
|
||||
WORD msgID = (WORD)eQMI_WMS_GET_ROUTES;
|
||||
sProtocolBuffer rsp = SendSimple( eQMI_SVC_WMS, msgID, 5000 );
|
||||
if (rsp.IsValid() == false)
|
||||
{
|
||||
return GetCorrectedLastError();
|
||||
}
|
||||
|
||||
// Did we receive a valid QMI response?
|
||||
sQMIServiceBuffer qmiRsp( rsp.GetSharedBuffer() );
|
||||
if (qmiRsp.IsValid() == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
|
||||
// Check the mandatory QMI result TLV for success
|
||||
ULONG rc = 0;
|
||||
ULONG ec = 0;
|
||||
bool bResult = qmiRsp.GetResult( rc, ec );
|
||||
if (bResult == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
else if (rc != 0)
|
||||
{
|
||||
return GetCorrectedQMIError( ec );
|
||||
}
|
||||
|
||||
// Prepare TLVs for parsing
|
||||
std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiRsp );
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
|
||||
// Parse the TLV we want (by DB key)
|
||||
sProtocolEntityKey tlvKey( eDB2_ET_QMI_WMS_RSP, msgID, 1 );
|
||||
cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
|
||||
if (pf.size() < 1)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_RSP;
|
||||
}
|
||||
|
||||
ULONG fi = 0;
|
||||
ULONG routeCount = (ULONG)pf[fi++].mValue.mU16;
|
||||
if ((ULONG)pf.size() < 1 + 4 * routeCount)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_RSP;
|
||||
}
|
||||
|
||||
if (routeCount > (ULONG)maxRoutes)
|
||||
{
|
||||
routeCount = (ULONG)maxRoutes;
|
||||
}
|
||||
|
||||
ULONG * pRouteArray = (ULONG *)pRoutes;
|
||||
for (ULONG r = 0; r < routeCount; r++)
|
||||
{
|
||||
// Message type
|
||||
*pRouteArray++ = pf[fi++].mValue.mU32;
|
||||
|
||||
// Message class
|
||||
*pRouteArray++ = pf[fi++].mValue.mU32;
|
||||
|
||||
// Storage type
|
||||
*pRouteArray++ = pf[fi++].mValue.mU32;
|
||||
|
||||
// Receipt action
|
||||
*pRouteArray++ = pf[fi++].mValue.mU32;
|
||||
}
|
||||
|
||||
*pRouteSize = (BYTE)routeCount;
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
SetSMSRoutes (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
Set the desired incoming SMS routing information
|
||||
|
||||
PARAMETERS:
|
||||
pRouteSize [ I ] - The number of elements in the SMS route array
|
||||
pRoutes [ I ] - The SMS route array
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::SetSMSRoutes(
|
||||
BYTE * pRouteSize,
|
||||
BYTE * pRoutes )
|
||||
{
|
||||
// Validate arguments
|
||||
if (pRouteSize == 0 || *pRouteSize == 0 || pRoutes == 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
// Format up the request
|
||||
ULONG routeCount = (ULONG)*pRouteSize;
|
||||
|
||||
// %u
|
||||
std::ostringstream tmp;
|
||||
tmp << routeCount;
|
||||
|
||||
ULONG * pRouteArray = (ULONG *)pRoutes;
|
||||
for (ULONG r = 0; r < routeCount; r++)
|
||||
{
|
||||
// Message type, class, storage type, receipt action
|
||||
for (ULONG f = 0; f < 4; f++)
|
||||
{
|
||||
// tmp += " %u"
|
||||
tmp << " " << *pRouteArray++;
|
||||
}
|
||||
}
|
||||
|
||||
WORD msgID = (WORD)eQMI_WMS_SET_ROUTES;
|
||||
std::vector <sDB2PackingInput> piv;
|
||||
|
||||
sProtocolEntityKey pek( eDB2_ET_QMI_WMS_REQ, msgID, 1 );
|
||||
sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
|
||||
piv.push_back( pi );
|
||||
|
||||
// Pack up the QMI request
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
sSharedBuffer * pRequest = DB2PackQMIBuffer( db, piv );
|
||||
if (pRequest == 0)
|
||||
{
|
||||
return eGOBI_ERR_MEMORY;
|
||||
}
|
||||
|
||||
// Send the QMI request, check result, and return
|
||||
return SendAndCheckReturn( eQMI_SVC_WMS, pRequest, 5000 );
|
||||
}
|
|
@ -0,0 +1,965 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
GobiQMICoreUIM.cpp
|
||||
|
||||
DESCRIPTION:
|
||||
QUALCOMM Gobi QMI Based API Core (UIM Access)
|
||||
|
||||
PUBLIC CLASSES AND FUNCTIONS:
|
||||
cGobiQMICore
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
==========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "StdAfx.h"
|
||||
#include "GobiQMICore.h"
|
||||
|
||||
#include "QMIBuffers.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
/*=========================================================================*/
|
||||
// cGobiQMICore Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
UIMSetPINProtection (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function enables or disables protection of UIM contents by a
|
||||
given PIN
|
||||
|
||||
PARAMETERS:
|
||||
id [ I ] - PIN ID (1/2)
|
||||
bEnable [ I ] - Enable/disable PIN protection (0 = disable)?
|
||||
pValue [ I ] - PIN value of the PIN to be enabled/disabled
|
||||
pVerifyRetriesLeft [ O ] - Upon operational failure this will indicate
|
||||
the number of retries left, after which the
|
||||
PIN will be blocked (0xFFFFFFFF = unknown)
|
||||
pUnblockRetriesLeft [ O ] - Upon operational failure this will indicate
|
||||
the number of unblock retries left, after
|
||||
which the PIN will be permanently blocked,
|
||||
i.e. UIM is unusable (0xFFFFFFFF = unknown)
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::UIMSetPINProtection(
|
||||
ULONG id,
|
||||
ULONG bEnable,
|
||||
CHAR * pValue,
|
||||
ULONG * pVerifyRetriesLeft,
|
||||
ULONG * pUnblockRetriesLeft )
|
||||
{
|
||||
// Validate arguments
|
||||
if ( (pValue == 0)
|
||||
|| (pValue[0] == 0)
|
||||
|| (pVerifyRetriesLeft == 0)
|
||||
|| (pUnblockRetriesLeft == 0) )
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
*pVerifyRetriesLeft = ULONG_MAX;
|
||||
*pUnblockRetriesLeft = ULONG_MAX;
|
||||
|
||||
WORD msgID = (WORD)eQMI_DMS_UIM_SET_PIN_PROT;
|
||||
std::vector <sDB2PackingInput> piv;
|
||||
|
||||
std::string val( pValue );
|
||||
ULONG valSz = val.size();
|
||||
|
||||
if (bEnable != 0)
|
||||
{
|
||||
bEnable = 1;
|
||||
}
|
||||
|
||||
// "%u %u %u \"%s\""
|
||||
std::ostringstream tmp;
|
||||
tmp << (UINT)id << " " << (UINT)bEnable << " " << (UINT)valSz
|
||||
<< " \"" << val << "\"";
|
||||
|
||||
sProtocolEntityKey pek( eDB2_ET_QMI_DMS_REQ, msgID, 1 );
|
||||
sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
|
||||
piv.push_back( pi );
|
||||
|
||||
// Pack up the QMI request
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
sSharedBuffer * pRequest = DB2PackQMIBuffer( db, piv );
|
||||
if (pRequest == 0)
|
||||
{
|
||||
return eGOBI_ERR_MEMORY;
|
||||
}
|
||||
|
||||
// Send the QMI request
|
||||
sProtocolBuffer rsp = Send( eQMI_SVC_DMS, pRequest, 5000 );
|
||||
if (rsp.IsValid() == false)
|
||||
{
|
||||
return GetCorrectedLastError();
|
||||
}
|
||||
|
||||
// Did we receive a valid QMI response?
|
||||
sQMIServiceBuffer qmiRsp( rsp.GetSharedBuffer() );
|
||||
if (qmiRsp.IsValid() == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
|
||||
// Check the mandatory QMI result TLV for success
|
||||
ULONG rc = 0;
|
||||
ULONG ec = 0;
|
||||
bool bResult = qmiRsp.GetResult( rc, ec );
|
||||
if (bResult == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
else if (rc != 0)
|
||||
{
|
||||
// Prepare TLVs for parsing
|
||||
std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiRsp );
|
||||
|
||||
// Parse the optional TLV we want (by DB key)
|
||||
sProtocolEntityKey tlvKey( eDB2_ET_QMI_DMS_RSP, msgID, 16 );
|
||||
cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
|
||||
if (pf.size() >= 2)
|
||||
{
|
||||
*pVerifyRetriesLeft = (ULONG)pf[0].mValue.mU8;
|
||||
*pUnblockRetriesLeft = (ULONG)pf[1].mValue.mU8;
|
||||
}
|
||||
|
||||
return GetCorrectedQMIError( ec );
|
||||
}
|
||||
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
UIMVerifyPIN (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function verifies the PIN before accessing the UIM contents
|
||||
|
||||
PARAMETERS:
|
||||
id [ I ] - PIN ID (1/2)
|
||||
pValue [ I ] - PIN value of the PIN to verify
|
||||
pVerifyRetriesLeft [ O ] - Upon operational failure this will indicate
|
||||
the number of retries left, after which the
|
||||
PIN will be blocked (0xFFFFFFFF = unknown)
|
||||
pUnblockRetriesLeft [ O ] - Upon operational failure this will indicate
|
||||
the number of unblock retries left, after
|
||||
which the PIN will be permanently blocked,
|
||||
i.e. UIM is unusable (0xFFFFFFFF = unknown)
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::UIMVerifyPIN(
|
||||
ULONG id,
|
||||
CHAR * pValue,
|
||||
ULONG * pVerifyRetriesLeft,
|
||||
ULONG * pUnblockRetriesLeft )
|
||||
{
|
||||
// Validate arguments
|
||||
if ( (pValue == 0)
|
||||
|| (pValue[0] == 0)
|
||||
|| (pVerifyRetriesLeft == 0)
|
||||
|| (pUnblockRetriesLeft == 0) )
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
*pVerifyRetriesLeft = ULONG_MAX;
|
||||
*pUnblockRetriesLeft = ULONG_MAX;
|
||||
|
||||
WORD msgID = (WORD)eQMI_DMS_UIM_PIN_VERIFY;
|
||||
std::vector <sDB2PackingInput> piv;
|
||||
|
||||
std::string val( pValue );
|
||||
ULONG valSz = val.size();
|
||||
|
||||
// "%u %u \"%s\""
|
||||
std::ostringstream tmp;
|
||||
tmp << (UINT)id << " " << (UINT)valSz << " \"" << val << "\"";
|
||||
|
||||
sProtocolEntityKey pek( eDB2_ET_QMI_DMS_REQ, msgID, 1 );
|
||||
sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
|
||||
piv.push_back( pi );
|
||||
|
||||
// Pack up the QMI request
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
sSharedBuffer * pRequest = DB2PackQMIBuffer( db, piv );
|
||||
if (pRequest == 0)
|
||||
{
|
||||
return eGOBI_ERR_MEMORY;
|
||||
}
|
||||
|
||||
// Send the QMI request
|
||||
sProtocolBuffer rsp = Send( eQMI_SVC_DMS, pRequest, 5000 );
|
||||
if (rsp.IsValid() == false)
|
||||
{
|
||||
return GetCorrectedLastError();
|
||||
}
|
||||
|
||||
// Did we receive a valid QMI response?
|
||||
sQMIServiceBuffer qmiRsp( rsp.GetSharedBuffer() );
|
||||
if (qmiRsp.IsValid() == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
|
||||
// Check the mandatory QMI result TLV for success
|
||||
ULONG rc = 0;
|
||||
ULONG ec = 0;
|
||||
bool bResult = qmiRsp.GetResult( rc, ec );
|
||||
if (bResult == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
else if (rc != 0)
|
||||
{
|
||||
// Prepare TLVs for parsing
|
||||
std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiRsp );
|
||||
|
||||
// Parse the optional TLV we want (by DB key)
|
||||
sProtocolEntityKey tlvKey( eDB2_ET_QMI_DMS_RSP, msgID, 16 );
|
||||
cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
|
||||
if (pf.size() >= 2)
|
||||
{
|
||||
*pVerifyRetriesLeft = (ULONG)pf[0].mValue.mU8;
|
||||
*pUnblockRetriesLeft = (ULONG)pf[1].mValue.mU8;
|
||||
}
|
||||
|
||||
return GetCorrectedQMIError( ec );
|
||||
}
|
||||
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
UIMUnblockPIN (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function unblocks a blocked PIN
|
||||
|
||||
PARAMETERS:
|
||||
id [ I ] - PIN ID (1/2)
|
||||
pPUKValue [ I ] - PUK value of the PIN to unblock
|
||||
pNewValue [ I ] - New PIN value of the PIN to unblock
|
||||
pVerifyRetriesLeft [ O ] - Upon operational failure this will indicate
|
||||
the number of retries left, after which the
|
||||
PIN will be blocked (0xFFFFFFFF = unknown)
|
||||
pUnblockRetriesLeft [ O ] - Upon operational failure this will indicate
|
||||
the number of unblock retries left, after
|
||||
which the PIN will be permanently blocked,
|
||||
i.e. UIM is unusable (0xFFFFFFFF = unknown)
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::UIMUnblockPIN(
|
||||
ULONG id,
|
||||
CHAR * pPUKValue,
|
||||
CHAR * pNewValue,
|
||||
ULONG * pVerifyRetriesLeft,
|
||||
ULONG * pUnblockRetriesLeft )
|
||||
{
|
||||
// Validate arguments
|
||||
if ( (pPUKValue == 0)
|
||||
|| (pPUKValue[0] == 0)
|
||||
|| (pNewValue == 0)
|
||||
|| (pNewValue[0] == 0)
|
||||
|| (pVerifyRetriesLeft == 0)
|
||||
|| (pUnblockRetriesLeft == 0) )
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
*pVerifyRetriesLeft = ULONG_MAX;
|
||||
*pUnblockRetriesLeft = ULONG_MAX;
|
||||
|
||||
WORD msgID = (WORD)eQMI_DMS_UIM_PIN_UNBLOCK;
|
||||
std::vector <sDB2PackingInput> piv;
|
||||
|
||||
std::string val1( pPUKValue );
|
||||
ULONG val1Sz = val1.size();
|
||||
|
||||
std::string val2( pNewValue );
|
||||
ULONG val2Sz = val2.size();
|
||||
|
||||
// "%u %u \"%s\" %u \"%s\""
|
||||
std::ostringstream tmp;
|
||||
tmp << (UINT)id << " " << (UINT)val1Sz << " \"" << val1 << "\" "
|
||||
<< (UINT)val2Sz << " \"" << val2 << "\"";
|
||||
|
||||
sProtocolEntityKey pek( eDB2_ET_QMI_DMS_REQ, msgID, 1 );
|
||||
sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
|
||||
piv.push_back( pi );
|
||||
|
||||
// Pack up the QMI request
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
sSharedBuffer * pRequest = DB2PackQMIBuffer( db, piv );
|
||||
if (pRequest == 0)
|
||||
{
|
||||
return eGOBI_ERR_MEMORY;
|
||||
}
|
||||
|
||||
// Send the QMI request
|
||||
sProtocolBuffer rsp = Send( eQMI_SVC_DMS, pRequest, 5000 );
|
||||
if (rsp.IsValid() == false)
|
||||
{
|
||||
return GetCorrectedLastError();
|
||||
}
|
||||
|
||||
// Did we receive a valid QMI response?
|
||||
sQMIServiceBuffer qmiRsp( rsp.GetSharedBuffer() );
|
||||
if (qmiRsp.IsValid() == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
|
||||
// Check the mandatory QMI result TLV for success
|
||||
ULONG rc = 0;
|
||||
ULONG ec = 0;
|
||||
bool bResult = qmiRsp.GetResult( rc, ec );
|
||||
if (bResult == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
else if (rc != 0)
|
||||
{
|
||||
// Prepare TLVs for parsing
|
||||
std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiRsp );
|
||||
|
||||
// Parse the optional TLV we want (by DB key)
|
||||
sProtocolEntityKey tlvKey( eDB2_ET_QMI_DMS_RSP, msgID, 16 );
|
||||
cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
|
||||
if (pf.size() >= 2)
|
||||
{
|
||||
*pVerifyRetriesLeft = (ULONG)pf[0].mValue.mU8;
|
||||
*pUnblockRetriesLeft = (ULONG)pf[1].mValue.mU8;
|
||||
}
|
||||
|
||||
return GetCorrectedQMIError( ec );
|
||||
}
|
||||
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
UIMChangePIN (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function change the PIN value
|
||||
|
||||
PARAMETERS:
|
||||
id [ I ] - PIN ID (1/2)
|
||||
pOldValue [ I ] - Old PIN value of the PIN to change
|
||||
pNewValue [ I ] - New PIN value of the PIN to change
|
||||
pVerifyRetriesLeft [ O ] - Upon operational failure this will indicate
|
||||
the number of retries left, after which the
|
||||
PIN will be blocked (0xFFFFFFFF = unknown)
|
||||
pUnblockRetriesLeft [ O ] - Upon operational failure this will indicate
|
||||
the number of unblock retries left, after
|
||||
which the PIN will be permanently blocked,
|
||||
i.e. UIM is unusable (0xFFFFFFFF = unknown)
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::UIMChangePIN(
|
||||
ULONG id,
|
||||
CHAR * pOldValue,
|
||||
CHAR * pNewValue,
|
||||
ULONG * pVerifyRetriesLeft,
|
||||
ULONG * pUnblockRetriesLeft )
|
||||
{
|
||||
// Validate arguments
|
||||
if ( (pOldValue == 0)
|
||||
|| (pOldValue[0] == 0)
|
||||
|| (pNewValue == 0)
|
||||
|| (pNewValue[0] == 0)
|
||||
|| (pVerifyRetriesLeft == 0)
|
||||
|| (pUnblockRetriesLeft == 0) )
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
*pVerifyRetriesLeft = ULONG_MAX;
|
||||
*pUnblockRetriesLeft = ULONG_MAX;
|
||||
|
||||
WORD msgID = (WORD)eQMI_DMS_UIM_PIN_CHANGE;
|
||||
std::vector <sDB2PackingInput> piv;
|
||||
|
||||
std::string val1( pOldValue );
|
||||
ULONG val1Sz = val1.size();
|
||||
|
||||
std::string val2( pNewValue );
|
||||
ULONG val2Sz = val2.size();
|
||||
|
||||
// "%u %u \"%s\" %u \"%s\""
|
||||
std::ostringstream tmp;
|
||||
tmp << (UINT)id << " " << (UINT)val1Sz << " \"" << val1 << "\" "
|
||||
<< (UINT)val2Sz << " \"" << val2 << "\"";
|
||||
|
||||
sProtocolEntityKey pek( eDB2_ET_QMI_DMS_REQ, msgID, 1 );
|
||||
sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
|
||||
piv.push_back( pi );
|
||||
|
||||
// Pack up the QMI request
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
sSharedBuffer * pRequest = DB2PackQMIBuffer( db, piv );
|
||||
if (pRequest == 0)
|
||||
{
|
||||
return eGOBI_ERR_MEMORY;
|
||||
}
|
||||
|
||||
// Send the QMI request
|
||||
sProtocolBuffer rsp = Send( eQMI_SVC_DMS, pRequest, 5000 );
|
||||
if (rsp.IsValid() == false)
|
||||
{
|
||||
return GetCorrectedLastError();
|
||||
}
|
||||
|
||||
// Did we receive a valid QMI response?
|
||||
sQMIServiceBuffer qmiRsp( rsp.GetSharedBuffer() );
|
||||
if (qmiRsp.IsValid() == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
|
||||
// Check the mandatory QMI result TLV for success
|
||||
ULONG rc = 0;
|
||||
ULONG ec = 0;
|
||||
bool bResult = qmiRsp.GetResult( rc, ec );
|
||||
if (bResult == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
else if (rc != 0)
|
||||
{
|
||||
// Prepare TLVs for parsing
|
||||
std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiRsp );
|
||||
|
||||
// Parse the optional TLV we want (by DB key)
|
||||
sProtocolEntityKey tlvKey( eDB2_ET_QMI_DMS_RSP, msgID, 16 );
|
||||
cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
|
||||
if (pf.size() >= 2)
|
||||
{
|
||||
*pVerifyRetriesLeft = (ULONG)pf[0].mValue.mU8;
|
||||
*pUnblockRetriesLeft = (ULONG)pf[1].mValue.mU8;
|
||||
}
|
||||
|
||||
return GetCorrectedQMIError( ec );
|
||||
}
|
||||
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
UIMGetPINStatus (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function returns the status of the pin
|
||||
|
||||
PARAMETERS:
|
||||
id [ I ] - PIN ID (1/2)
|
||||
pStatus [ O ] - PIN status (0xFFFFFFFF = unknown)
|
||||
pVerifyRetriesLeft [ O ] - The number of retries left, after which the
|
||||
PIN will be blocked (0xFFFFFFFF = unknown)
|
||||
pUnblockRetriesLeft [ O ] - The number of unblock retries left, after
|
||||
which the PIN will be permanently blocked,
|
||||
i.e. UIM is unusable (0xFFFFFFFF = unknown)
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::UIMGetPINStatus(
|
||||
ULONG id,
|
||||
ULONG * pStatus,
|
||||
ULONG * pVerifyRetriesLeft,
|
||||
ULONG * pUnblockRetriesLeft )
|
||||
{
|
||||
// Validate arguments
|
||||
if (pStatus == 0 || pVerifyRetriesLeft == 0 || pUnblockRetriesLeft == 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
*pStatus = ULONG_MAX;
|
||||
*pVerifyRetriesLeft = ULONG_MAX;
|
||||
*pUnblockRetriesLeft = ULONG_MAX;
|
||||
|
||||
// Generate and send the QMI request
|
||||
WORD msgID = (WORD)eQMI_DMS_UIM_GET_PIN_STATUS;
|
||||
sProtocolBuffer rsp = SendSimple( eQMI_SVC_DMS, msgID, 5000 );
|
||||
if (rsp.IsValid() == false)
|
||||
{
|
||||
return GetCorrectedLastError();
|
||||
}
|
||||
|
||||
// Did we receive a valid QMI response?
|
||||
sQMIServiceBuffer qmiRsp( rsp.GetSharedBuffer() );
|
||||
if (qmiRsp.IsValid() == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
|
||||
// Check the mandatory QMI result TLV for success
|
||||
ULONG rc = 0;
|
||||
ULONG ec = 0;
|
||||
bool bResult = qmiRsp.GetResult( rc, ec );
|
||||
if (bResult == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
else if (rc != 0)
|
||||
{
|
||||
return GetCorrectedQMIError( ec );
|
||||
}
|
||||
|
||||
// Prepare TLVs for parsing
|
||||
std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiRsp );
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
|
||||
ULONG tlvID = 16 + id;
|
||||
|
||||
// Parse the TLV we want (by DB key)
|
||||
sProtocolEntityKey tlvKey( eDB2_ET_QMI_DMS_RSP, msgID, tlvID );
|
||||
cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
|
||||
if (pf.size() < 3)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_RSP;
|
||||
}
|
||||
|
||||
*pStatus = pf[0].mValue.mU32;
|
||||
*pVerifyRetriesLeft = (ULONG)pf[1].mValue.mU8;
|
||||
*pUnblockRetriesLeft = (ULONG)pf[2].mValue.mU8;
|
||||
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
UIMGetICCID (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function returns the UIM ICCID
|
||||
|
||||
PARAMETERS:
|
||||
stringSize [ I ] - The maximum number of characters (including NULL
|
||||
terminator) that the string array can contain
|
||||
pString [ O ] - NULL terminated string
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::UIMGetICCID(
|
||||
BYTE stringSize,
|
||||
CHAR * pString )
|
||||
{
|
||||
// Validate arguments
|
||||
if (stringSize == 0 || pString == 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
// Assume failure
|
||||
*pString = 0;
|
||||
|
||||
// Generate and send the QMI request
|
||||
WORD msgID = (WORD)eQMI_DMS_UIM_GET_ICCID;
|
||||
sProtocolBuffer rsp = SendSimple( eQMI_SVC_DMS, msgID );
|
||||
if (rsp.IsValid() == false)
|
||||
{
|
||||
return GetCorrectedLastError();
|
||||
}
|
||||
|
||||
// Did we receive a valid QMI response?
|
||||
sQMIServiceBuffer qmiRsp( rsp.GetSharedBuffer() );
|
||||
if (qmiRsp.IsValid() == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
|
||||
// Check the mandatory QMI result TLV for success
|
||||
ULONG rc = 0;
|
||||
ULONG ec = 0;
|
||||
bool bResult = qmiRsp.GetResult( rc, ec );
|
||||
if (bResult == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
else if (rc != 0)
|
||||
{
|
||||
return GetCorrectedQMIError( ec );
|
||||
}
|
||||
|
||||
// Prepare TLVs for parsing
|
||||
std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiRsp );
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
|
||||
// Parse the TLV we want (IMSI)
|
||||
sProtocolEntityKey tlvKey( eDB2_ET_QMI_DMS_RSP, msgID, 1 );
|
||||
cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
|
||||
if (pf.size() < 1 || pf[0].mValueString.size() <= 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_RSP;
|
||||
}
|
||||
|
||||
std::string tmpICCID = pf[0].mValueString;
|
||||
ULONG lenICCID = (ULONG)tmpICCID.size();
|
||||
|
||||
// Space to perform the copy?
|
||||
if (stringSize < lenICCID + 1)
|
||||
{
|
||||
return eGOBI_ERR_BUFFER_SZ;
|
||||
}
|
||||
|
||||
memcpy( (LPVOID)pString, (LPCSTR)tmpICCID.c_str(), lenICCID + 1 );
|
||||
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
UIMGetControlKeyBlockingStatus (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function returns the status of the specified facility control key
|
||||
|
||||
PARAMETERS:
|
||||
id [ I ] - Facility ID
|
||||
pStatus [ O ] - Control key status
|
||||
pVerifyRetriesLeft [ O ] - The number of retries left, after which the
|
||||
control key will be blocked
|
||||
pUnblockRetriesLeft [ O ] - The number of unblock retries left, after
|
||||
which the control key will be permanently
|
||||
blocked
|
||||
pbBlocking [ O ] - (Optional) Is the facility blocking?
|
||||
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::UIMGetControlKeyBlockingStatus(
|
||||
ULONG id,
|
||||
ULONG * pStatus,
|
||||
ULONG * pVerifyRetriesLeft,
|
||||
ULONG * pUnblockRetriesLeft,
|
||||
ULONG * pbBlocking )
|
||||
{
|
||||
// Validate arguments
|
||||
if ( (pStatus == 0)
|
||||
|| (pVerifyRetriesLeft == 0)
|
||||
|| (pUnblockRetriesLeft == 0) )
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
*pStatus = ULONG_MAX;
|
||||
*pVerifyRetriesLeft = ULONG_MAX;
|
||||
*pUnblockRetriesLeft = ULONG_MAX;
|
||||
|
||||
if (pbBlocking != 0)
|
||||
{
|
||||
*pbBlocking = 0;
|
||||
}
|
||||
|
||||
WORD msgID = (WORD)eQMI_DMS_UIM_GET_CK_STATUS;
|
||||
std::vector <sDB2PackingInput> piv;
|
||||
|
||||
std::ostringstream tmp;
|
||||
tmp << (UINT)id;
|
||||
|
||||
sProtocolEntityKey pek( eDB2_ET_QMI_DMS_REQ, msgID, 1 );
|
||||
sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
|
||||
piv.push_back( pi );
|
||||
|
||||
// Pack up the QMI request
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
sSharedBuffer * pRequest = DB2PackQMIBuffer( db, piv );
|
||||
if (pRequest == 0)
|
||||
{
|
||||
return eGOBI_ERR_MEMORY;
|
||||
}
|
||||
|
||||
// Send the QMI request
|
||||
sProtocolBuffer rsp = Send( eQMI_SVC_DMS, pRequest, 5000 );
|
||||
if (rsp.IsValid() == false)
|
||||
{
|
||||
return GetCorrectedLastError();
|
||||
}
|
||||
|
||||
// Did we receive a valid QMI response?
|
||||
sQMIServiceBuffer qmiRsp( rsp.GetSharedBuffer() );
|
||||
if (qmiRsp.IsValid() == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
|
||||
// Check the mandatory QMI result TLV for success
|
||||
ULONG rc = 0;
|
||||
ULONG ec = 0;
|
||||
bool bResult = qmiRsp.GetResult( rc, ec );
|
||||
if (bResult == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
else if (rc != 0)
|
||||
{
|
||||
return GetCorrectedQMIError( ec );
|
||||
}
|
||||
|
||||
// Prepare TLVs for parsing
|
||||
std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiRsp );
|
||||
|
||||
// Parse the required TLV we want (by DB key)
|
||||
sProtocolEntityKey tlvKey( eDB2_ET_QMI_DMS_RSP, msgID, 1 );
|
||||
cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
|
||||
if (pf.size() < 3)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_RSP;
|
||||
}
|
||||
|
||||
*pStatus = pf[0].mValue.mU32;
|
||||
*pVerifyRetriesLeft = (ULONG)pf[1].mValue.mU8;
|
||||
*pUnblockRetriesLeft = (ULONG)pf[2].mValue.mU8;
|
||||
|
||||
if (pbBlocking != 0)
|
||||
{
|
||||
tlvKey = sProtocolEntityKey( eDB2_ET_QMI_DMS_RSP, msgID, 16 );
|
||||
pf = ParseTLV( db, rsp, tlvs, tlvKey );
|
||||
if (pf.size() > 0)
|
||||
{
|
||||
*pbBlocking = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
UIMSetControlKeyProtection (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function changes the specified facility control key
|
||||
|
||||
PARAMETERS:
|
||||
id [ I ] - Facility ID
|
||||
status [ I ] - Control key status
|
||||
pValue [ I ] - Control key de-personalization string
|
||||
pVerifyRetriesLeft [ O ] - Upon operational failure this will indicate
|
||||
the number of retries left, after which the
|
||||
control key will be blocked
|
||||
(0xFFFFFFFF = unknown)
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::UIMSetControlKeyProtection(
|
||||
ULONG id,
|
||||
ULONG status,
|
||||
CHAR * pValue,
|
||||
ULONG * pVerifyRetriesLeft )
|
||||
{
|
||||
// Validate arguments
|
||||
if ( (pValue == 0)
|
||||
|| (pValue[0] == 0)
|
||||
|| (pVerifyRetriesLeft == 0) )
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
*pVerifyRetriesLeft = ULONG_MAX;
|
||||
|
||||
WORD msgID = (WORD)eQMI_DMS_UIM_SET_CK_PROT;
|
||||
std::vector <sDB2PackingInput> piv;
|
||||
|
||||
std::string val( pValue );
|
||||
ULONG valSz = val.size();
|
||||
|
||||
//"%u %u %u \"%s\""
|
||||
std::ostringstream tmp;
|
||||
tmp << (UINT)id << " " << (UINT)status << " " << (UINT)valSz
|
||||
<< " \"" << val << "\"";
|
||||
|
||||
sProtocolEntityKey pek( eDB2_ET_QMI_DMS_REQ, msgID, 1 );
|
||||
sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
|
||||
piv.push_back( pi );
|
||||
|
||||
// Pack up the QMI request
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
sSharedBuffer * pRequest = DB2PackQMIBuffer( db, piv );
|
||||
if (pRequest == 0)
|
||||
{
|
||||
return eGOBI_ERR_MEMORY;
|
||||
}
|
||||
|
||||
// Send the QMI request
|
||||
sProtocolBuffer rsp = Send( eQMI_SVC_DMS, pRequest, 5000 );
|
||||
if (rsp.IsValid() == false)
|
||||
{
|
||||
return GetCorrectedLastError();
|
||||
}
|
||||
|
||||
// Did we receive a valid QMI response?
|
||||
sQMIServiceBuffer qmiRsp( rsp.GetSharedBuffer() );
|
||||
if (qmiRsp.IsValid() == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
|
||||
// Check the mandatory QMI result TLV for success
|
||||
ULONG rc = 0;
|
||||
ULONG ec = 0;
|
||||
bool bResult = qmiRsp.GetResult( rc, ec );
|
||||
if (bResult == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
else if (rc != 0)
|
||||
{
|
||||
// Prepare TLVs for parsing
|
||||
std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiRsp );
|
||||
|
||||
// Parse the optional TLV we want (by DB key)
|
||||
sProtocolEntityKey tlvKey( eDB2_ET_QMI_DMS_RSP, msgID, 16 );
|
||||
cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
|
||||
if (pf.size() >= 1)
|
||||
{
|
||||
*pVerifyRetriesLeft = (ULONG)pf[0].mValue.mU8;
|
||||
}
|
||||
|
||||
return GetCorrectedQMIError( ec );
|
||||
}
|
||||
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
UIMUnblockControlKey (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function unblocks the specified facility control key
|
||||
|
||||
PARAMETERS:
|
||||
id [ I ] - Facility ID
|
||||
pValue [ I ] - Control key de-personalization string
|
||||
pUnblockRetriesLeft [ O ] - The number of unblock retries left, after
|
||||
which the control key will be permanently
|
||||
blocked (0xFFFFFFFF = unknown)
|
||||
RETURN VALUE:
|
||||
ULONG - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::UIMUnblockControlKey(
|
||||
ULONG id,
|
||||
CHAR * pValue,
|
||||
ULONG * pUnblockRetriesLeft )
|
||||
{
|
||||
// Validate arguments
|
||||
if ( (pValue == 0)
|
||||
|| (pValue[0] == 0)
|
||||
|| (pUnblockRetriesLeft == 0) )
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
*pUnblockRetriesLeft = ULONG_MAX;
|
||||
|
||||
WORD msgID = (WORD)eQMI_DMS_UIM_UNBLOCK_CK;
|
||||
std::vector <sDB2PackingInput> piv;
|
||||
|
||||
std::string val( pValue );
|
||||
ULONG valSz = val.size();
|
||||
|
||||
// "%u %u \"%s\""
|
||||
std::ostringstream tmp;
|
||||
tmp << (UINT)id << " " << (UINT)valSz << " \"" << val << "\"";
|
||||
|
||||
sProtocolEntityKey pek( eDB2_ET_QMI_DMS_REQ, msgID, 1 );
|
||||
sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
|
||||
piv.push_back( pi );
|
||||
|
||||
// Pack up the QMI request
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
sSharedBuffer * pRequest = DB2PackQMIBuffer( db, piv );
|
||||
if (pRequest == 0)
|
||||
{
|
||||
return eGOBI_ERR_MEMORY;
|
||||
}
|
||||
|
||||
// Send the QMI request
|
||||
sProtocolBuffer rsp = Send( eQMI_SVC_DMS, pRequest, 5000 );
|
||||
if (rsp.IsValid() == false)
|
||||
{
|
||||
return GetCorrectedLastError();
|
||||
}
|
||||
|
||||
// Did we receive a valid QMI response?
|
||||
sQMIServiceBuffer qmiRsp( rsp.GetSharedBuffer() );
|
||||
if (qmiRsp.IsValid() == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
|
||||
// Check the mandatory QMI result TLV for success
|
||||
ULONG rc = 0;
|
||||
ULONG ec = 0;
|
||||
bool bResult = qmiRsp.GetResult( rc, ec );
|
||||
if (bResult == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
else if (rc != 0)
|
||||
{
|
||||
// Prepare TLVs for parsing
|
||||
std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiRsp );
|
||||
|
||||
// Parse the optional TLV we want (by DB key)
|
||||
sProtocolEntityKey tlvKey( eDB2_ET_QMI_DMS_RSP, msgID, 16 );
|
||||
cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
|
||||
if (pf.size() >= 1)
|
||||
{
|
||||
*pUnblockRetriesLeft = (ULONG)pf[0].mValue.mU8;
|
||||
}
|
||||
|
||||
return GetCorrectedQMIError( ec );
|
||||
}
|
||||
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,205 @@
|
|||
/*===========================================================================
|
||||
FILE:
|
||||
GobiQMICoreVoice.cpp
|
||||
|
||||
DESCRIPTION:
|
||||
QUALCOMM Gobi QMI Based API Core (Voice Service)
|
||||
|
||||
PUBLIC CLASSES AND FUNCTIONS:
|
||||
cGobiQMICore
|
||||
|
||||
Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum nor
|
||||
the names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
==========================================================================*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Include Files
|
||||
//---------------------------------------------------------------------------
|
||||
#include "StdAfx.h"
|
||||
#include "GobiQMICore.h"
|
||||
|
||||
#include "QMIBuffers.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas (pack structs)
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma pack( push, 1 )
|
||||
|
||||
/*=========================================================================*/
|
||||
// Struct sUSSDInfo
|
||||
// Struct to represent USSD/Alpha information header
|
||||
/*=========================================================================*/
|
||||
struct sUSSDInfoHdr
|
||||
{
|
||||
public:
|
||||
BYTE mDCS;
|
||||
BYTE mLength;
|
||||
|
||||
// Data of 'mLength' follows
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Pragmas
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma pack( pop )
|
||||
|
||||
/*=========================================================================*/
|
||||
// cGobiQMICore Methods
|
||||
/*=========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
OriginateUSSD (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function initiates a USSD operation
|
||||
|
||||
PARAMETERS:
|
||||
pInfo [ I ] - USSD information
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::OriginateUSSD( BYTE * pInfo )
|
||||
{
|
||||
// Validate arguments
|
||||
if (pInfo == 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
const ULONG INFO_HDR_SZ = (ULONG)sizeof( sUSSDInfoHdr );
|
||||
|
||||
sUSSDInfoHdr * pInInfo = (sUSSDInfoHdr *)pInfo;
|
||||
ULONG infoLen = pInInfo->mLength + INFO_HDR_SZ;
|
||||
|
||||
WORD msgID = (WORD)eQMI_VOICE_ASYNC_ORIG_USSD;
|
||||
std::vector <sDB2PackingInput> piv;
|
||||
|
||||
sProtocolEntityKey pek( eDB2_ET_QMI_VOICE_REQ, msgID, 1 );
|
||||
sDB2PackingInput pi( pek, (const BYTE *)pInfo, infoLen );
|
||||
piv.push_back( pi );
|
||||
|
||||
// Pack up the QMI request
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
sSharedBuffer * pRequest = DB2PackQMIBuffer( db, piv );
|
||||
if (pRequest == 0)
|
||||
{
|
||||
return eGOBI_ERR_MEMORY;
|
||||
}
|
||||
|
||||
return SendAndCheckReturn( eQMI_SVC_VOICE, pRequest, 300000 );
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
AnswerUSSD (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function responds to a USSD request from the network
|
||||
|
||||
PARAMETERS:
|
||||
pInfo [ I ] - USSD information
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::AnswerUSSD( BYTE * pInfo )
|
||||
{
|
||||
// Validate arguments
|
||||
if (pInfo == 0)
|
||||
{
|
||||
return eGOBI_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
const ULONG INFO_HDR_SZ = (ULONG)sizeof( sUSSDInfoHdr );
|
||||
|
||||
sUSSDInfoHdr * pInInfo = (sUSSDInfoHdr *)pInfo;
|
||||
ULONG infoLen = pInInfo->mLength + INFO_HDR_SZ;
|
||||
|
||||
WORD msgID = (WORD)eQMI_VOICE_ANSWER_USSD;
|
||||
std::vector <sDB2PackingInput> piv;
|
||||
|
||||
sProtocolEntityKey pek( eDB2_ET_QMI_VOICE_REQ, msgID, 1 );
|
||||
sDB2PackingInput pi( pek, (const BYTE *)pInfo, infoLen );
|
||||
piv.push_back( pi );
|
||||
|
||||
// Pack up the QMI request
|
||||
const cCoreDatabase & db = GetDatabase();
|
||||
sSharedBuffer * pRequest = DB2PackQMIBuffer( db, piv );
|
||||
if (pRequest == 0)
|
||||
{
|
||||
return eGOBI_ERR_MEMORY;
|
||||
}
|
||||
|
||||
// Send the QMI request, check result, and return
|
||||
return SendAndCheckReturn( eQMI_SVC_VOICE, pRequest, 300000 );
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
METHOD:
|
||||
CancelUSSD (Public Method)
|
||||
|
||||
DESCRIPTION:
|
||||
This function cancels an in-progress USSD operation
|
||||
|
||||
RETURN VALUE:
|
||||
eGobiError - Return code
|
||||
===========================================================================*/
|
||||
eGobiError cGobiQMICore::CancelUSSD()
|
||||
{
|
||||
// Generate and send the QMI request
|
||||
WORD msgID = (WORD)eQMI_VOICE_CANCEL_USSD;
|
||||
sProtocolBuffer rsp = SendSimple( eQMI_SVC_VOICE, msgID, 30000 );
|
||||
if (rsp.IsValid() == false)
|
||||
{
|
||||
return GetCorrectedLastError();
|
||||
}
|
||||
|
||||
// Did we receive a valid QMI response?
|
||||
sQMIServiceBuffer qmiRsp( rsp.GetSharedBuffer() );
|
||||
if (qmiRsp.IsValid() == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
|
||||
// Check the mandatory QMI result TLV for success
|
||||
ULONG rc = 0;
|
||||
ULONG ec = 0;
|
||||
bool bResult = qmiRsp.GetResult( rc, ec );
|
||||
if (bResult == false)
|
||||
{
|
||||
return eGOBI_ERR_MALFORMED_RSP;
|
||||
}
|
||||
else if (rc != 0)
|
||||
{
|
||||
return GetCorrectedQMIError( ec );
|
||||
}
|
||||
|
||||
return eGOBI_ERR_NONE;
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue