summaryrefslogtreecommitdiff
path: root/gobi-api/GobiAPI_1.0.40
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-07-03 15:41:02 +0200
committerAleksander Morgado <aleksander@lanedo.com>2012-07-03 15:41:02 +0200
commit85b380fcb5ac42d74bede9baa9b94c31b375208e (patch)
tree8d3fff87484bb21934ed3410c4311fe468fed5d9 /gobi-api/GobiAPI_1.0.40
parent97abf15a58d06ff9170f728cc4eeefb55055e648 (diff)
core: moved Gobi API sources and utils to their own subdirectories
Diffstat (limited to 'gobi-api/GobiAPI_1.0.40')
-rw-r--r--gobi-api/GobiAPI_1.0.40/AUTHORS0
-rw-r--r--gobi-api/GobiAPI_1.0.40/COPYING27
-rw-r--r--gobi-api/GobiAPI_1.0.40/ChangeLog0
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/BitPacker.cpp555
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/BitPacker.h183
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/BitParser.cpp578
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/BitParser.h198
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/CRC.cpp180
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/CRC.h75
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/Comm.cpp643
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/Comm.h159
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/CoreDatabase.cpp3187
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/CoreDatabase.h2127
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/CoreUtilities.cpp1853
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/CoreUtilities.h657
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/DB2NavTree.cpp434
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/DB2NavTree.h136
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/DB2TextFile.cpp253
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/DB2TextFile.h110
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/DB2Utilities.cpp907
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/DB2Utilities.h268
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/DataPacker.cpp831
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/DataPacker.h216
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/DataParser.cpp1118
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/DataParser.h399
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/Event.cpp437
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/Event.h117
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/HDLC.cpp304
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/HDLC.h70
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/HDLCProtocolServer.cpp323
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/HDLCProtocolServer.h107
-rw-r--r--gobi-api/GobiAPI_1.0.40/Core/Makefile.am58
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/MemoryMappedFile.cpp183
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/MemoryMappedFile.h120
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/ProtocolBuffer.cpp222
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/ProtocolBuffer.h162
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/ProtocolEntityFieldEnumerator.h139
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/ProtocolEntityNav.cpp997
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/ProtocolEntityNav.h246
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/ProtocolEnum.h214
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/ProtocolLog.cpp190
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/ProtocolLog.h91
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/ProtocolNotification.cpp171
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/ProtocolNotification.h237
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/ProtocolRequest.cpp254
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/ProtocolRequest.h193
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/ProtocolServer.cpp1720
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/ProtocolServer.h351
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/QDLBuffers.cpp1093
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/QDLBuffers.h716
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/QDLEnum.h428
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/QDLProtocolServer.cpp269
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/QDLProtocolServer.h77
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/QMIBuffers.cpp366
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/QMIBuffers.h379
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/QMIEnum.h1149
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/QMIProtocolServer.cpp424
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/QMIProtocolServer.h128
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/SharedBuffer.cpp382
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/SharedBuffer.h166
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/StdAfx.h175
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Core/SyncQueue.h419
-rw-r--r--gobi-api/GobiAPI_1.0.40/Database/Makefile.am2
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Database/QMI/Entity.txt964
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Database/QMI/Enum.txt147
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Database/QMI/EnumEntry.txt916
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Database/QMI/Field.txt967
-rw-r--r--gobi-api/GobiAPI_1.0.40/Database/QMI/Makefile.am17
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Database/QMI/Struct.txt1317
-rw-r--r--gobi-api/GobiAPI_1.0.40/Database/QMI/foo.c0
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/GobiConnectionMgmt/GobiConnectionMgmt.cpp2882
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/GobiConnectionMgmt/GobiConnectionMgmt.h1370
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/GobiConnectionMgmt/GobiConnectionMgmtAPI.h3329
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/GobiConnectionMgmt/GobiConnectionMgmtExports.cpp5021
-rw-r--r--gobi-api/GobiAPI_1.0.40/GobiConnectionMgmt/Makefile.am31
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/GobiImageMgmt/GobiImageMgmt.cpp315
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/GobiImageMgmt/GobiImageMgmt.h186
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/GobiImageMgmt/GobiImageMgmtAPI.h416
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/GobiImageMgmt/GobiImageMgmtExports.cpp923
-rw-r--r--gobi-api/GobiAPI_1.0.40/GobiImageMgmt/Makefile.am31
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/GobiQDLService/99-GobiQDLService.rules40
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/GobiQDLService/Main.cpp205
-rw-r--r--gobi-api/GobiAPI_1.0.40/GobiQDLService/Makefile.am28
-rw-r--r--gobi-api/GobiAPI_1.0.40/INSTALL365
-rw-r--r--gobi-api/GobiAPI_1.0.40/Makefile.am9
-rw-r--r--gobi-api/GobiAPI_1.0.40/NEWS0
-rw-r--r--gobi-api/GobiAPI_1.0.40/README0
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Shared/GobiError.h147
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Shared/GobiImageDefinitions.h176
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Shared/GobiMBNMgmt.cpp943
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Shared/GobiMBNMgmt.h226
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Shared/GobiQDLCore.cpp943
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Shared/GobiQDLCore.h168
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Shared/GobiQMICore.cpp1018
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Shared/GobiQMICore.h1028
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreCAT.cpp219
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreDMS.cpp2050
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreImg.cpp656
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreImg2k.cpp562
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreNAS.cpp1986
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreOMA.cpp535
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Shared/GobiQMICorePDS.cpp1292
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreRMS.cpp187
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreSMS.cpp940
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreUIM.cpp965
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreWDS.cpp2804
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/Shared/GobiQMIVoice.cpp205
-rw-r--r--gobi-api/GobiAPI_1.0.40/Shared/Makefile.am41
-rwxr-xr-xgobi-api/GobiAPI_1.0.40/autogen.sh23
-rw-r--r--gobi-api/GobiAPI_1.0.40/configure.ac30
110 files changed, 64796 insertions, 0 deletions
diff --git a/gobi-api/GobiAPI_1.0.40/AUTHORS b/gobi-api/GobiAPI_1.0.40/AUTHORS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/AUTHORS
diff --git a/gobi-api/GobiAPI_1.0.40/COPYING b/gobi-api/GobiAPI_1.0.40/COPYING
new file mode 100644
index 0000000..1a73aa4
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/COPYING
@@ -0,0 +1,27 @@
+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.
+
diff --git a/gobi-api/GobiAPI_1.0.40/ChangeLog b/gobi-api/GobiAPI_1.0.40/ChangeLog
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/ChangeLog
diff --git a/gobi-api/GobiAPI_1.0.40/Core/BitPacker.cpp b/gobi-api/GobiAPI_1.0.40/Core/BitPacker.cpp
new file mode 100755
index 0000000..818b2e5
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/BitPacker.cpp
@@ -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 );
+ }
+}
diff --git a/gobi-api/GobiAPI_1.0.40/Core/BitPacker.h b/gobi-api/GobiAPI_1.0.40/Core/BitPacker.h
new file mode 100755
index 0000000..34363d7
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/BitPacker.h
@@ -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;
+
+};
diff --git a/gobi-api/GobiAPI_1.0.40/Core/BitParser.cpp b/gobi-api/GobiAPI_1.0.40/Core/BitParser.cpp
new file mode 100755
index 0000000..a5a638e
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/BitParser.cpp
@@ -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 );
+ }
+}
diff --git a/gobi-api/GobiAPI_1.0.40/Core/BitParser.h b/gobi-api/GobiAPI_1.0.40/Core/BitParser.h
new file mode 100755
index 0000000..8f8a686
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/BitParser.h
@@ -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;
+};
diff --git a/gobi-api/GobiAPI_1.0.40/Core/CRC.cpp b/gobi-api/GobiAPI_1.0.40/Core/CRC.cpp
new file mode 100755
index 0000000..d900ee7
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/CRC.cpp
@@ -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;
+}
diff --git a/gobi-api/GobiAPI_1.0.40/Core/CRC.h b/gobi-api/GobiAPI_1.0.40/Core/CRC.h
new file mode 100755
index 0000000..ed26e76
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/CRC.h
@@ -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 );
+
diff --git a/gobi-api/GobiAPI_1.0.40/Core/Comm.cpp b/gobi-api/GobiAPI_1.0.40/Core/Comm.cpp
new file mode 100755
index 0000000..db06db9
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/Comm.cpp
@@ -0,0 +1,643 @@
+/*===========================================================================
+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
+//---------------------------------------------------------------------------
+// Thread commands
+#define START_READ_CMD 0
+#define STOP_READ_CMD 1
+#define EXIT_CMD 2
+
+/*=========================================================================*/
+// Free Methods
+/*=========================================================================*/
+
+/*===========================================================================
+METHOD:
+ RxThread (Free Method)
+
+DESCRIPTION:
+ Thread for simulating asynchronous reads
+
+PARAMETERS:
+ pData [ I ] Asynchronous read object
+
+RETURN VALUE:
+ void * - thread exit value (always 0)
+===========================================================================*/
+void * RxThread( void * pData )
+{
+ cComm * pComm = (cComm*)pData;
+ if (pComm == NULL || pComm->IsValid() == false)
+ {
+ return 0;
+ }
+
+ fd_set inputSet, outputSet;
+ FD_ZERO( &inputSet );
+ FD_SET( pComm->mCommandPipe[READING], &inputSet );
+ int largestFD = pComm->mCommandPipe[READING];
+
+ int status = 0;
+ while (true)
+ {
+ // No FD_COPY() available
+ memcpy( &outputSet, &inputSet, sizeof( fd_set ) );
+
+ status = select( largestFD + 1, &outputSet, NULL, NULL, NULL );
+ if (status <= 0)
+ {
+ TRACE( "error %d in select, errno %d\n", status, errno );
+ break;
+ }
+
+ if (FD_ISSET( pComm->mCommandPipe[READING], &outputSet ) == true)
+ {
+ // Read from the pipe
+ BYTE cmd;
+ status = read( pComm->mCommandPipe[READING], &cmd, 1 );
+ if (status != 1)
+ {
+ TRACE( "cmd error %d\n", status );
+ break;
+ }
+
+ if (cmd == START_READ_CMD)
+ {
+ FD_SET( pComm->mPort, &inputSet );
+ largestFD = std::max( pComm->mPort,
+ pComm->mCommandPipe[READING] );
+ }
+ else if (cmd == STOP_READ_CMD)
+ {
+ FD_CLR( pComm->mPort, &inputSet );
+ largestFD = pComm->mCommandPipe[READING];
+ }
+ else
+ {
+ // EXIT_CMD or anything else
+ break;
+ }
+ }
+ else if (FD_ISSET( pComm->mPort, &outputSet ) == true)
+ {
+ // Stop watching for read data
+ FD_CLR( pComm->mPort, &inputSet );
+ largestFD = pComm->mCommandPipe[READING];
+
+ // Perform a read
+ status = read( pComm->mPort,
+ pComm->mpBuffer,
+ pComm->mBuffSz );
+
+ cIOCallback * pCallback = pComm->mpRxCallback;
+ pComm->mpRxCallback = 0;
+
+ if (pCallback == (cIOCallback *)1)
+ {
+ // We wanted to read, but not to be notified
+ }
+ else if (status >= 0)
+ {
+ pCallback->IOComplete( 0, status );
+ }
+ else
+ {
+ pCallback->IOComplete( status, 0 );
+ }
+ }
+ }
+
+ return 0;
+};
+
+/*=========================================================================*/
+// cComm Methods
+/*=========================================================================*/
+
+/*===========================================================================
+METHOD:
+ cComm (Public Method)
+
+DESCRIPTION:
+ Constructor
+
+RETURN VALUE:
+ None
+===========================================================================*/
+cComm::cComm()
+ : mPortName( "" ),
+ mPort( INVALID_HANDLE_VALUE ),
+ mpRxCallback( 0 ),
+ mbCancelWrite( false ),
+ mpBuffer( 0 ),
+ mBuffSz( 0 ),
+ mRxThreadID( 0 )
+{
+ mCommandPipe[READING] = INVALID_HANDLE_VALUE;
+ mCommandPipe[WRITING] = INVALID_HANDLE_VALUE;
+}
+
+/*===========================================================================
+METHOD:
+ ~cComm (Public Method)
+
+DESCRIPTION:
+ Destructor
+
+RETURN VALUE:
+ None
+===========================================================================*/
+cComm::~cComm()
+{
+ // Disconnect from current port
+ Disconnect();
+
+ mCommandPipe[READING] = INVALID_HANDLE_VALUE;
+ mCommandPipe[WRITING] = INVALID_HANDLE_VALUE;
+}
+
+/*===========================================================================
+METHOD:
+ IsValid (Public Method)
+
+DESCRIPTION:
+ Is this object valid?
+
+RETURN VALUE:
+ Bool
+===========================================================================*/
+bool cComm::IsValid()
+{
+ // Nothing to do, dependant on extended class functionality
+ return true;
+}
+
+/*===========================================================================
+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();
+ }
+
+ // Initialize command pipe for read thread
+ int nRet = pipe( mCommandPipe );
+ if (nRet != 0)
+ {
+ TRACE( "cComm:Connect() pipe creation failed %d\n", nRet );
+ return false;
+ }
+
+ // Start the read thread
+ nRet = pthread_create( &mRxThreadID,
+ 0,
+ RxThread,
+ this );
+ if (nRet != 0)
+ {
+ TRACE( "cComm::Connect() pthread_create = %d\n", nRet );
+
+ Disconnect();
+ return false;
+ }
+
+ // Opening the com port
+ mPort = open( pPort, O_RDWR );
+ if (mPort == INVALID_HANDLE_VALUE)
+ {
+ Disconnect();
+ return false;
+ }
+
+ // 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 (mCommandPipe[WRITING] != INVALID_HANDLE_VALUE)
+ {
+ if (mRxThreadID != 0)
+ {
+ // Notify the thread to exit
+ BYTE byte = EXIT_CMD;
+ write( mCommandPipe[WRITING], &byte, 1 );
+
+ // And wait for it
+ TRACE( "cComm::Disconnnect() joining thread\n" );
+ int nRC = pthread_join( mRxThreadID, 0 );
+ if (nRC != 0)
+ {
+ TRACE( "failed to join thread %d\n", nRC );
+ bRC = false;
+ }
+
+ mRxThreadID = 0;
+ }
+
+ close( mCommandPipe[WRITING] );
+ close( mCommandPipe[READING] );
+ mCommandPipe[READING] = INVALID_HANDLE_VALUE;
+ mCommandPipe[WRITING] = INVALID_HANDLE_VALUE;
+ }
+
+ if (mPort != INVALID_HANDLE_VALUE)
+ {
+ close( mPort );
+ 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
+ || mCommandPipe[WRITING] == INVALID_HANDLE_VALUE
+ || mpRxCallback == 0
+ || mRxThreadID == 0)
+ {
+ TRACE( "cannot cancel, thread not active\n" );
+ return false;
+ }
+
+ // Notify the thread to stop reading
+ BYTE byte = STOP_READ_CMD;
+ int nRC = write( mCommandPipe[WRITING], &byte, 1 );
+ if (nRC != 1)
+ {
+ TRACE( "error %d canceling read\n", nRC );
+ return false;
+ }
+
+ // Remove the old callback
+ mpRxCallback = 0;
+
+ return true;
+}
+
+/*===========================================================================
+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;
+ }
+
+ mpBuffer = pBuf;
+ mBuffSz = bufSz;
+
+ // Notify the thread to stop reading
+ BYTE byte = START_READ_CMD;
+ int nRC = write( mCommandPipe[WRITING], &byte, 1 );
+ if (nRC != 1)
+ {
+ TRACE( "error %d starting read\n", nRC );
+ 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;
+}
diff --git a/gobi-api/GobiAPI_1.0.40/Core/Comm.h b/gobi-api/GobiAPI_1.0.40/Core/Comm.h
new file mode 100755
index 0000000..3f56413
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/Comm.h
@@ -0,0 +1,159 @@
+/*===========================================================================
+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 callbacks */
+ cIOCallback * mpRxCallback;
+
+ // Cancel the write request?
+ bool mbCancelWrite;
+
+ /* Buffer */
+ BYTE * mpBuffer;
+
+ /* Buffer size */
+ ULONG mBuffSz;
+
+ /* Pipe for comunication with thread */
+ int mCommandPipe[2];
+
+ /* Thread ID of Rx Thread. */
+ pthread_t mRxThreadID;
+
+ // Rx thread is allowed complete access
+ friend void * RxThread( void * pData );
+};
diff --git a/gobi-api/GobiAPI_1.0.40/Core/CoreDatabase.cpp b/gobi-api/GobiAPI_1.0.40/Core/CoreDatabase.cpp
new file mode 100755
index 0000000..e9bf5e4
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/CoreDatabase.cpp
@@ -0,0 +1,3187 @@
+/*===========================================================================
+FILE:
+ CoreDatabase.cpp
+
+DESCRIPTION:
+ Implementation of cCoreDatabase class
+
+PUBLIC CLASSES AND METHODS:
+ cCoreDatabase
+ This class represents the run-time (read only) version of the
+ core library database
+
+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 "CoreDatabase.h"
+#include "DB2NavTree.h"
+
+#include "CoreUtilities.h"
+
+//---------------------------------------------------------------------------
+// Definitions
+//---------------------------------------------------------------------------
+
+// Uncomment out to enable database load/save timing through cCoreDatabase
+// #define TIME_DB 1
+
+// Database table file names
+LPCSTR DB2_FILE_PROTOCOL_FIELD = "Field.txt";
+LPCSTR DB2_FILE_PROTOCOL_STRUCT = "Struct.txt";
+LPCSTR DB2_FILE_PROTOCOL_ENTITY = "Entity.txt";
+LPCSTR DB2_FILE_ENUM_MAIN = "Enum.txt";
+LPCSTR DB2_FILE_ENUM_ENTRY = "EnumEntry.txt";
+
+// Database table file names
+LPCSTR DB2_TABLE_PROTOCOL_FIELD = "Field";
+LPCSTR DB2_TABLE_PROTOCOL_STRUCT = "Struct";
+LPCSTR DB2_TABLE_PROTOCOL_ENTITY = "Entity";
+LPCSTR DB2_TABLE_ENUM_MAIN = "Enum";
+LPCSTR DB2_TABLE_ENUM_ENTRY = "Enum Entry";
+
+// An empty (but not NULL) string
+LPCSTR EMPTY_STRING = "";
+
+// Value seperator for database text
+LPCSTR DB2_VALUE_SEP = "^";
+
+// Sub-value (i.e. within a particular value) seperator for database text
+LPCSTR DB2_SUBVAL_SEP = ",";
+
+// Maximum amount of recursion allowed in protocol entity structure processing
+const ULONG MAX_NESTING_LEVEL = 32;
+
+// The default logger (for backwards compatibility)
+cDB2TraceLog gDB2DefaultLog;
+
+/*=========================================================================*/
+// Free Methods
+/*=========================================================================*/
+
+/*===========================================================================
+METHOD:
+ CopyQuotedString (Public Method)
+
+DESCRIPTION:
+ Convert a string (in quotes) to a string (minus) quotes and copy
+ into an allocated buffer
+
+PARAMETERS:
+ pString [ I ] - The string being de-quoted/copied
+
+RETURN VALUE:
+ LPSTR: The copy (returns 0 upon error)
+===========================================================================*/
+LPCSTR CopyQuotedString( LPSTR pString )
+{
+ // Get string length
+ ULONG len = (ULONG)strlen( pString );
+
+ // Adjust to remove trailing spaces
+ while (len > 0 && pString[len - 1] == ' ')
+ {
+ pString[len - 1] = 0;
+ len--;
+ }
+
+ // Long enough (and quoted?)
+ if ( (len >= 2)
+ && (pString[0] == '\"')
+ && (pString[len - 1] == '\"') )
+ {
+ if (len == 2)
+ {
+ return EMPTY_STRING;
+ }
+ else
+ {
+ // Attempt to allocate a copy
+ LPSTR pRet = new char[len - 1];
+ if (pRet != 0)
+ {
+ ULONG bytes = (len - 2) * sizeof( char );
+ memcpy( (PVOID)pRet, (LPCVOID)&pString[1], (SIZE_T)bytes );
+ pRet[len - 2] = 0;
+
+ return pRet;
+ }
+ }
+ }
+
+ return 0;
+}
+
+/*=========================================================================*/
+// sDB2ProtocolEntity Methods
+/*=========================================================================*/
+
+/*===========================================================================
+METHOD:
+ FromString (Public Method)
+
+DESCRIPTION:
+ Populate this object from a string
+
+PARAMETERS:
+ pStr [ I ] - String to populate object from
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool sDB2ProtocolEntity::FromString( LPSTR pStr )
+{
+ bool bRC = false;
+
+ // Should be
+ // 0: Type
+ // 1: "Key"
+ // 2: "Name"
+ // 3: Struct ID
+ // 4: Format specifier ID (optional)
+ // 5: Internal only flag (optional)
+ // 6: Extended format specifier ID (optional)
+ const ULONG NUM_REQ_VALS = 4;
+
+ std::vector <LPSTR> tokens;
+ ParseTokens( DB2_VALUE_SEP, pStr, tokens );
+
+ ULONG toks = (ULONG)tokens.size();
+ if (toks >= NUM_REQ_VALS)
+ {
+ // Remove quotes from name string and copy
+ LPCSTR pCopy = CopyQuotedString( tokens[2] );
+ if (pCopy != 0)
+ {
+ mpName = pCopy;
+ mType = (eDB2EntityType)strtol( tokens[0], 0, 10 );
+
+ // Convert key/populate ID
+ mID.push_back( (ULONG)mType );
+ CSVStringToContainer( DB2_SUBVAL_SEP, tokens[1], mID, false );
+
+ mStructID = strtol( tokens[3], 0, 10 );
+
+ // Format specifier?
+ if (toks > NUM_REQ_VALS)
+ {
+ mFormatID = strtol( tokens[NUM_REQ_VALS], 0, 10 );
+ }
+
+ // Internal only flag?
+ if (toks > NUM_REQ_VALS + 1)
+ {
+ mbInternal = (strtoul( tokens[NUM_REQ_VALS + 1], 0, 10 ) != 0);
+ }
+
+ // Extended format specifier ID?
+ if (toks > NUM_REQ_VALS + 2)
+ {
+ mFormatExID = strtol( tokens[NUM_REQ_VALS + 2], 0, 10 );
+ }
+
+ bRC = IsValid();
+ }
+ }
+
+ return bRC;
+}
+
+/*===========================================================================
+METHOD:
+ IsValid (Public Method)
+
+DESCRIPTION:
+ Is this object valid?
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool sDB2ProtocolEntity::IsValid() const
+{
+ // The type has to be valid
+ if (::IsValid( mType ) == false)
+ {
+ return false;
+ }
+
+ // The ID must consists of at least two entries
+ if (mID.size() < 2)
+ {
+ return false;
+ }
+
+ // The first entry in the ID has to be the type
+ if (mID[0] != (ULONG)mType)
+ {
+ return false;
+ }
+
+ // The structure ID has to be >= -1)
+ if (mStructID < -1)
+ {
+ return false;
+ }
+
+ // The format specifier has to be >= -1)
+ if (mFormatID < -1)
+ {
+ return false;
+ }
+
+ // There has to be a non-empty name
+ if (mpName == 0 || mpName[0] == 0)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+/*=========================================================================*/
+// sDB2Fragment Methods
+/*=========================================================================*/
+
+/*===========================================================================
+METHOD:
+ FromString (Public Method)
+
+DESCRIPTION:
+ Populate this object from a string
+
+PARAMETERS:
+ pStr [ I ] - String to populate object from
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool sDB2Fragment::FromString( LPSTR pStr )
+{
+ bool bRC = false;
+
+ // Should be
+ // 0: ID
+ // 1: Order
+ // 2: Type
+ // 3: Val
+ // 4: "Name"
+ // 5: Offset
+ // 6: Mod Type
+ // 7: "Mod Value"
+ const ULONG NUM_REQ_VALS = 8;
+
+ std::vector <LPSTR> tokens;
+ ParseTokens( DB2_VALUE_SEP, pStr, tokens );
+
+ ULONG toks = (ULONG)tokens.size();
+ if (toks >= NUM_REQ_VALS)
+ {
+ // Remove quotes from modifier value and copy
+ LPCSTR pVal = CopyQuotedString( tokens[7] );
+ if (pVal != 0)
+ {
+ // Remove quotes from name string and copy
+ LPCSTR pCopy = CopyQuotedString( tokens[4] );
+ if (pCopy != 0)
+ {
+ mStructID = strtoul( tokens[0], 0, 10 );
+ mFragmentOrder = strtoul( tokens[1], 0, 10 );
+ mFragmentValue = strtoul( tokens[3], 0, 10 );
+ mFragmentOffset = strtol( tokens[5], 0, 10 );
+ mFragmentType = (eDB2FragmentType)strtol( tokens[2], 0, 10 );
+ mModifierType = (eDB2ModifierType)strtol( tokens[6], 0, 10 );;
+ mpModifierValue = pVal;
+ mpName = pCopy;
+
+ bRC = IsValid();
+ }
+ }
+ }
+
+ return bRC;
+}
+
+/*===========================================================================
+METHOD:
+ IsValid (Public Method)
+
+DESCRIPTION:
+ Is this object valid?
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool sDB2Fragment::IsValid() const
+{
+ // The fragment type has to be valid
+ if (::IsValid( mFragmentType ) == false)
+ {
+ return false;
+ }
+
+ // The modifier type has to be valid
+ if (::IsValid( mModifierType ) == false)
+ {
+ return false;
+ }
+
+ // There has to be a name (possibly empty)
+ if (mpName == 0)
+ {
+ return false;
+ }
+
+ // There has to be a modifier value (possibly empty)
+ if (mpModifierValue == 0)
+ {
+ return false;
+ }
+
+ // Directives can only be given for the first fragment
+ if ( (mFragmentType == eDB2_FRAGMENT_MSB_2_LSB)
+ || (mFragmentType == eDB2_FRAGMENT_LSB_2_MSB) )
+ {
+ if (mFragmentOrder > 0)
+ {
+ return false;
+ }
+ }
+
+ // Validate modifier
+ switch (mModifierType)
+ {
+ case eDB2_MOD_NONE:
+ if (mpModifierValue != 0 && mpModifierValue[0] != 0)
+ {
+ // Modifier string needs to be empty
+ return false;
+ }
+ break;
+
+ case eDB2_MOD_CONSTANT_ARRAY:
+ case eDB2_MOD_VARIABLE_ARRAY:
+ case eDB2_MOD_OPTIONAL:
+ case eDB2_MOD_VARIABLE_ARRAY2:
+ case eDB2_MOD_VARIABLE_ARRAY3:
+ if (mpModifierValue == 0 || mpModifierValue[0] == 0)
+ {
+ // Needs to be a modifier string
+ return false;
+ }
+ break;
+
+ case eDB2_MOD_VARIABLE_STRING1:
+ case eDB2_MOD_VARIABLE_STRING2:
+ case eDB2_MOD_VARIABLE_STRING3:
+ if (mpModifierValue == 0 || mpModifierValue[0] == 0)
+ {
+ // Needs to be a modifier string
+ return false;
+ }
+
+ if (mFragmentType != eDB2_FRAGMENT_FIELD)
+ {
+ // Only valid when modifying fields (strings)
+ return false;
+ }
+ break;
+
+ }
+
+ if (mFragmentType == eDB2_FRAGMENT_CONSTANT_PAD && mFragmentValue == 0)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+/*===========================================================================
+METHOD:
+ BuildCondition (Static Public Method)
+
+DESCRIPTION:
+ Build a simple condition string
+
+PARAMETERS:
+ id [ I ] - Field ID
+ op [ I ] - Operator
+ val [ I ] - Value (or field ID)
+ bF2F [ I ] - Field to field expression?
+
+RETURN VALUE:
+ std::string
+===========================================================================*/
+std::string sDB2Fragment::BuildCondition(
+ ULONG id,
+ eDB2Operator op,
+ LONGLONG val,
+ bool bF2F )
+{
+ std::ostringstream tmp;
+
+ if (::IsValid( op ) == true)
+ {
+ if (bF2F == false)
+ {
+ switch (op)
+ {
+ case eDB2_OP_LT:
+ tmp << (UINT)id << " " << "<" << val;
+ break;
+
+ case eDB2_OP_LTE:
+ tmp << (UINT)id << " " << "<=" << val;
+ break;
+
+ case eDB2_OP_EQ:
+ tmp << (UINT)id << " " << "=" << val;
+ break;
+
+ case eDB2_OP_NEQ:
+ tmp << (UINT)id << " " << "!=" << val;
+ break;
+
+ case eDB2_OP_GTE:
+ tmp << (UINT)id << " " << ">=" << val;
+ break;
+
+ case eDB2_OP_GT:
+ tmp << (UINT)id << " " << ">" << val;
+ break;
+
+ case eDB2_OP_DIV:
+ tmp << (UINT)id << " " << "%" << val;
+ break;
+
+ case eDB2_OP_NDIV:
+ tmp << (UINT)id << " " << "!%" << val;
+ break;
+ }
+ }
+ else
+ {
+ switch (op)
+ {
+ case eDB2_OP_LT:
+ tmp << (UINT)id << " " << "f<" << val;
+ break;
+
+ case eDB2_OP_LTE:
+ tmp << (UINT)id << " " << "f<=" << val;
+ break;
+
+ case eDB2_OP_EQ:
+ tmp << (UINT)id << " " << "f=" << val;
+ break;
+
+ case eDB2_OP_NEQ:
+ tmp << (UINT)id << " " << "f!=" << val;
+ break;
+
+ case eDB2_OP_GTE:
+ tmp << (UINT)id << " " << "f>=" << val;
+ break;
+
+ case eDB2_OP_GT:
+ tmp << (UINT)id << " " << "f>" << val;
+ break;
+
+ case eDB2_OP_DIV:
+ tmp << (UINT)id << " " << "f%" << val;
+ break;
+
+ case eDB2_OP_NDIV:
+ tmp << (UINT)id << " " << "f!%" << val;
+ break;
+ }
+ }
+ }
+
+ std::string retStr = tmp.str();
+
+ return retStr;
+}
+
+/*===========================================================================
+METHOD:
+ EvaluateCondition (Static Public Method)
+
+DESCRIPTION:
+ Evaluate a simple condition
+
+PARAMETERS:
+ valA [ I ] - Left value
+ op [ I ] - Operator
+ valB [ I ] - Right value
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool sDB2Fragment::EvaluateCondition(
+ LONGLONG valA,
+ eDB2Operator op,
+ LONGLONG valB )
+{
+ bool bOK = false;
+ if (::IsValid( op ) == true)
+ {
+ switch (op)
+ {
+ case eDB2_OP_LT:
+ bOK = (valA < valB);
+ break;
+
+ case eDB2_OP_LTE:
+ bOK = (valA <= valB);
+ break;
+
+ case eDB2_OP_EQ:
+ bOK = (valA == valB);
+ break;
+
+ case eDB2_OP_NEQ:
+ bOK = (valA != valB);
+ break;
+
+ case eDB2_OP_GTE:
+ bOK = (valA >= valB);
+ break;
+
+ case eDB2_OP_GT:
+ bOK = (valA > valB);
+ break;
+
+ case eDB2_OP_DIV:
+ bOK = ((valA % valB) == 0);
+ break;
+
+ case eDB2_OP_NDIV:
+ bOK = ((valA % valB) != 0);
+ break;
+ }
+ }
+
+ return bOK;
+}
+
+/*===========================================================================
+METHOD:
+ ParseCondition (Static Public Method)
+
+DESCRIPTION:
+ Parse a simple condition
+
+PARAMETERS:
+ pCondition [ I ] - Condition string
+ id [ O ] - Field ID
+ op [ O ] - Operator
+ val [ O ] - Value (or field ID)
+ bF2F [ O ] - Field to field expression?
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool sDB2Fragment::ParseCondition(
+ LPCSTR pCondition,
+ ULONG & id,
+ eDB2Operator & op,
+ LONGLONG & val,
+ bool & bF2F )
+{
+ // Assume error
+ bool bOK = false;
+
+ // Even a condition to start with?
+ if (pCondition == 0 || pCondition == EMPTY_STRING)
+ {
+ return bOK;
+ }
+
+ // Parse condition to tokens (field ID operator value)
+ int nSize = strlen( pCondition ) + 1;
+
+ char * pCopy = new char[ nSize ];
+ if (pCopy == NULL)
+ {
+ return false;
+ }
+
+ memcpy( pCopy, pCondition, nSize );
+
+ std::vector <LPSTR> tokens;
+ ParseTokens( " ", pCopy, tokens );
+
+ if (tokens.size() == 3)
+ {
+ // Covert first token to field ID
+ ULONG fieldID = strtoul( tokens[0], 0, 10 );
+
+ // Grab the value for the given field ID
+ LONGLONG fieldVal = 0;
+ bOK = StringToLONGLONG( tokens[2], 0, fieldVal );
+ if (bOK == true)
+ {
+ std::string opStr = tokens[1];
+
+ // std::string version of Trim()
+ int nFirst = opStr.find_first_not_of( ' ' );
+ int nLast = opStr.find_last_not_of( ' ' );
+ if (nFirst == -1 || nLast == -1)
+ {
+ // Something went horribly wrong, empty string or all spaces
+ delete [] pCopy;
+ return false;
+ }
+
+ opStr = opStr.substr( nFirst, nLast - nFirst + 1 );
+
+ // std::string version of MakeLower()
+ transform( opStr.begin(), opStr.end(), opStr.begin(), tolower );
+
+ bF2F = false;
+ if (opStr == "<")
+ {
+ op = eDB2_OP_LT;
+ }
+ else if (opStr == "<=")
+ {
+ op = eDB2_OP_LTE;
+ }
+ else if (opStr == "=")
+ {
+ op = eDB2_OP_EQ;
+ }
+ else if (opStr == "!=")
+ {
+ op = eDB2_OP_NEQ;
+ }
+ else if (opStr == ">=")
+ {
+ op = eDB2_OP_GTE;
+ }
+ else if (opStr == ">")
+ {
+ op = eDB2_OP_GT;
+ }
+ else if (opStr == "%")
+ {
+ op = eDB2_OP_DIV;
+ }
+ else if (opStr == "!%")
+ {
+ op = eDB2_OP_NDIV;
+ }
+ else if (opStr == "f<")
+ {
+ bF2F = true;
+ op = eDB2_OP_LT;
+ }
+ else if (opStr == "f<=")
+ {
+ bF2F = true;
+ op = eDB2_OP_LTE;
+ }
+ else if (opStr == "f=")
+ {
+ bF2F = true;
+ op = eDB2_OP_EQ;
+ }
+ else if (opStr == "f!=")
+ {
+ bF2F = true;
+ op = eDB2_OP_NEQ;
+ }
+ else if (opStr == "f>=")
+ {
+ bF2F = true;
+ op = eDB2_OP_GTE;
+ }
+ else if (opStr == "f>")
+ {
+ bF2F = true;
+ op = eDB2_OP_GT;
+ }
+ else if (opStr == "f%")
+ {
+ bF2F = true;
+ op = eDB2_OP_DIV;
+ }
+ else if (opStr == "f!%")
+ {
+ bF2F = true;
+ op = eDB2_OP_NDIV;
+ }
+ else
+ {
+ bOK = false;
+ }
+
+ if (bOK == true)
+ {
+ id = fieldID;
+ val = fieldVal;
+ }
+ }
+ }
+
+ delete [] pCopy;
+
+ return bOK;
+}
+
+/*===========================================================================
+METHOD:
+ BuildExpression (Static Public Method)
+
+DESCRIPTION:
+ Build a simple expression string
+
+PARAMETERS:
+ id [ I ] - Field ID
+ op [ I ] - Operator
+ val [ I ] - Value (or field ID)
+ bF2F [ I ] - Field to field expression?
+
+RETURN VALUE:
+ std::string
+===========================================================================*/
+std::string sDB2Fragment::BuildExpression(
+ ULONG id,
+ eDB2ExpOperator op,
+ LONGLONG val,
+ bool bF2F )
+{
+ std::ostringstream tmp;
+
+ if (::IsValid( op ) == true)
+ {
+ if (bF2F == false)
+ {
+ switch (op)
+ {
+ case eDB2_EXPOP_ADD:
+ tmp << (UINT)id << " " << "+" << val;
+ break;
+
+ case eDB2_EXPOP_SUB:
+ tmp << (UINT)id << " " << "-" << val;
+ break;
+
+ case eDB2_EXPOP_MUL:
+ tmp << (UINT)id << " " << "*" << val;
+ break;
+
+ case eDB2_EXPOP_DIV:
+ tmp << (UINT)id << " " << "/" << val;
+ break;
+
+ case eDB2_EXPOP_REM:
+ tmp << (UINT)id << " " << "%" << val;
+ break;
+
+ case eDB2_EXPOP_MIN:
+ tmp << (UINT)id << " " << "min" << val;
+ break;
+
+ case eDB2_EXPOP_MAX:
+ tmp << (UINT)id << " " << "max" << val;
+ break;
+ }
+ }
+ else
+ {
+ switch (op)
+ {
+ case eDB2_EXPOP_ADD:
+ tmp << (UINT)id << " " << "f+" << val;
+ break;
+
+ case eDB2_EXPOP_SUB:
+ tmp << (UINT)id << " " << "f-" << val;
+ break;
+
+ case eDB2_EXPOP_MUL:
+ tmp << (UINT)id << " " << "f*" << val;
+ break;
+
+ case eDB2_EXPOP_DIV:
+ tmp << (UINT)id << " " << "f/" << val;
+ break;
+
+ case eDB2_EXPOP_REM:
+ tmp << (UINT)id << " " << "f%" << val;
+ break;
+
+ case eDB2_EXPOP_MIN:
+ tmp << (UINT)id << " " << "fmin" << val;
+ break;
+
+ case eDB2_EXPOP_MAX:
+ tmp << (UINT)id << " " << "fmax" << val;
+ break;
+ }
+ }
+ }
+
+ std::string retStr = tmp.str();
+
+ return retStr;
+}
+
+/*===========================================================================
+METHOD:
+ EvaluateExpression (Static Public Method)
+
+DESCRIPTION:
+ Evaluate a simple expression
+
+PARAMETERS:
+ valA [ I ] - Left value
+ op [ I ] - Operator
+ valB [ I ] - Right value
+ res [ O ] - Resulting value
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool sDB2Fragment::EvaluateExpression(
+ LONGLONG valA,
+ eDB2ExpOperator op,
+ LONGLONG valB,
+ LONGLONG & res )
+{
+ bool bOK = false;
+ if (::IsValid( op ) == true)
+ {
+ bOK = true;
+ switch (op)
+ {
+ case eDB2_EXPOP_ADD:
+ res = valA + valB;
+ break;
+
+ case eDB2_EXPOP_SUB:
+ res = valA - valB;
+ break;
+
+ case eDB2_EXPOP_MUL:
+ res = valA * valB;
+ break;
+
+ case eDB2_EXPOP_DIV:
+ res = valA / valB;
+ break;
+
+ case eDB2_EXPOP_REM:
+ res = valA % valB;
+ break;
+
+ case eDB2_EXPOP_MIN:
+ res = valA;
+ if (valA > valB)
+ {
+ res = valB;
+ }
+ break;
+
+ case eDB2_EXPOP_MAX:
+ res = valA;
+ if (valA < valB)
+ {
+ res = valB;
+ }
+ break;
+
+ default:
+ bOK = false;
+ break;
+ }
+ }
+
+ return bOK;
+}
+
+/*===========================================================================
+METHOD:
+ ParseExpression (Static Public Method)
+
+DESCRIPTION:
+ Parse a simple expression
+
+PARAMETERS:
+ pExpr [ I ] - Expression string
+ id [ O ] - Field ID
+ op [ O ] - Operator
+ val [ O ] - Value (or Field ID)
+ bF2F [ O ] - Field to field expression?
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool sDB2Fragment::ParseExpression(
+ LPCSTR pExpr,
+ ULONG & id,
+ eDB2ExpOperator & op,
+ LONGLONG & val,
+ bool & bF2F )
+{
+ // Assume error
+ bool bOK = false;
+
+ // Even a condition to start with?
+ if (pExpr == 0 || pExpr == EMPTY_STRING)
+ {
+ return bOK;
+ }
+
+ // Parse condition to tokens (field ID operator value)
+ int nSize = strlen( pExpr ) + 1;
+
+ char * pCopy = new char[ nSize ];
+ if (pCopy == NULL)
+ {
+ return false;
+ }
+
+ memcpy( pCopy, pExpr, nSize );
+
+ std::vector <LPSTR> tokens;
+ ParseTokens( " ", pCopy, tokens );
+
+ if (tokens.size() == 3)
+ {
+ // Covert first token to field ID
+ ULONG fieldID = strtoul( tokens[0], 0, 10 );
+
+ // Grab the value for the given field ID
+ LONGLONG fieldVal = 0;
+ bOK = StringToLONGLONG( tokens[2], 0, fieldVal );
+ if (bOK == true)
+ {
+ std::string opStr = tokens[1];
+
+ // std::string version of Trim()
+ int nFirst = opStr.find_first_not_of( ' ' );
+ int nLast = opStr.find_last_not_of( ' ' );
+ if (nFirst == -1 || nLast == -1)
+ {
+ // Something went horribly wrong, empty string or all spaces
+ delete [] pCopy;
+ return false;
+ }
+
+ opStr = opStr.substr( nFirst, nLast - nFirst + 1 );
+
+ // std::string version of MakeLower()
+ transform( opStr.begin(), opStr.end(), opStr.begin(), tolower );
+
+ bF2F = false;
+ if (opStr == "+")
+ {
+ op = eDB2_EXPOP_ADD;
+ }
+ else if (opStr == "-")
+ {
+ op = eDB2_EXPOP_SUB;
+ }
+ else if (opStr == "*")
+ {
+ op = eDB2_EXPOP_MUL;
+ }
+ else if (opStr == "/")
+ {
+ op = eDB2_EXPOP_DIV;
+ }
+ else if (opStr == "%")
+ {
+ op = eDB2_EXPOP_REM;
+ }
+ else if (opStr == "min")
+ {
+ op = eDB2_EXPOP_MIN;
+ }
+ else if (opStr == "max")
+ {
+ op = eDB2_EXPOP_MAX;
+ }
+ else if (opStr == "f+")
+ {
+ bF2F = true;
+ op = eDB2_EXPOP_ADD;
+ }
+ else if (opStr == "f-")
+ {
+ bF2F = true;
+ op = eDB2_EXPOP_SUB;
+ }
+ else if (opStr == "f*")
+ {
+ bF2F = true;
+ op = eDB2_EXPOP_MUL;
+ }
+ else if (opStr == "f/")
+ {
+ bF2F = true;
+ op = eDB2_EXPOP_DIV;
+ }
+ else if (opStr == "f%")
+ {
+ bF2F = true;
+ op = eDB2_EXPOP_REM;
+ }
+ else if (opStr == "fmin")
+ {
+ bF2F = true;
+ op = eDB2_EXPOP_MIN;
+ }
+ else if (opStr == "fmax")
+ {
+ bF2F = true;
+ op = eDB2_EXPOP_MAX;
+ }
+ else
+ {
+ bOK = false;
+ }
+
+ if (bOK == true)
+ {
+ id = fieldID;
+ val = fieldVal;
+ }
+ }
+ }
+
+ delete [] pCopy;
+ return bOK;
+}
+
+/*=========================================================================*/
+// sDB2Field Methods
+/*=========================================================================*/
+
+/*===========================================================================
+METHOD:
+ FromString (Public Method)
+
+DESCRIPTION:
+ Populate this object from a string
+
+PARAMETERS:
+ pStr [ I ] - String to populate object from
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool sDB2Field::FromString( LPSTR pStr )
+{
+ bool bRC = false;
+
+ // Should be
+ // 0: ID
+ // 1: "Name"
+ // 2: Size
+ // 3: Field type
+ // 4: Field type value
+ // 5: Hexadecimal
+ // 6: Description ID (optional)
+ // 7: Internal only flag (optional)
+ const ULONG NUM_REQ_VALS = 6;
+
+ std::vector <LPSTR> tokens;
+ ParseTokens( DB2_VALUE_SEP, pStr, tokens );
+
+ ULONG toks = (ULONG)tokens.size();
+
+ if (toks >= NUM_REQ_VALS)
+ {
+ // Remove quotes from name string and copy
+ LPCSTR pCopy = CopyQuotedString( tokens[1] );
+ if (pCopy != 0)
+ {
+ mID = strtoul( tokens[0], 0, 10 );
+ mSize = strtoul( tokens[2], 0, 10 );
+ mpName = pCopy;
+ mType = (eDB2FieldType)strtol( tokens[3], 0, 10 );
+ mTypeVal = strtoul( tokens[4], 0, 10 );
+ mbHex = (strtoul( tokens[5], 0, 10 ) != 0);
+
+ // Description ID?
+ if (toks > NUM_REQ_VALS)
+ {
+ mDescriptionID = strtol( tokens[NUM_REQ_VALS], 0, 10 );
+ }
+
+ // Internal only flag?
+ if (toks > NUM_REQ_VALS + 1)
+ {
+ mbInternal = (strtoul( tokens[NUM_REQ_VALS + 1], 0, 10 ) != 0);
+ }
+
+ bRC = IsValid();
+ }
+ }
+
+ return bRC;
+}
+
+/*===========================================================================
+METHOD:
+ IsValid (Public Method)
+
+DESCRIPTION:
+ Is this object valid?
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool sDB2Field::IsValid() const
+{
+ // There has to be a non-empty name
+ if (mpName == 0 || mpName[0] == 0)
+ {
+ return false;
+ }
+
+ // The field type must be valid
+ if (::IsValid( mType ) == false)
+ {
+ return false;
+ }
+
+ // For validating size
+ ULONG minSz = 1;
+ ULONG maxSz = 8;
+ ULONG modVal = 0;
+
+ // What type of field is this?
+ if (mType == eDB2_FIELD_STD)
+ {
+ eDB2StdFieldType ft = (eDB2StdFieldType)mTypeVal;
+ if (::IsValid( ft ) == false)
+ {
+ return false;
+ }
+
+ switch (ft)
+ {
+ case eDB2_FIELD_STDTYPE_BOOL:
+ maxSz = 64;
+ break;
+
+ case eDB2_FIELD_STDTYPE_INT16:
+ case eDB2_FIELD_STDTYPE_UINT16:
+ maxSz = 16;
+ break;
+
+ case eDB2_FIELD_STDTYPE_INT32:
+ case eDB2_FIELD_STDTYPE_UINT32:
+ case eDB2_FIELD_STDTYPE_FLOAT32:
+ maxSz = 32;
+ break;
+
+ case eDB2_FIELD_STDTYPE_INT64:
+ case eDB2_FIELD_STDTYPE_UINT64:
+ case eDB2_FIELD_STDTYPE_FLOAT64:
+ maxSz = 64;
+ break;
+
+ case eDB2_FIELD_STDTYPE_STRING_A:
+ case eDB2_FIELD_STDTYPE_STRING_U8:
+ // One character, no maximum
+ minSz = 8;
+ maxSz = 0;
+ modVal = 8;
+ break;
+
+ case eDB2_FIELD_STDTYPE_STRING_U:
+ // One UNICODE character, no maximum
+ minSz = 16;
+ maxSz = 0;
+ modVal = 16;
+ break;
+
+ case eDB2_FIELD_STDTYPE_STRING_ANT:
+ case eDB2_FIELD_STDTYPE_STRING_UNT:
+ case eDB2_FIELD_STDTYPE_STRING_U8NT:
+ // Size needs to be specified as 0
+ minSz = maxSz = 0;
+ break;
+ }
+ }
+ else
+ {
+ // Enum must be between 1 - 32 bits in size
+ maxSz = 32;
+ }
+
+ if (mSize < minSz)
+ {
+ return false;
+ }
+
+ if (maxSz != 0 && mSize > maxSz)
+ {
+ return false;
+ }
+
+ if (modVal != 0 && (mSize % modVal) != 0)
+ {
+ return false;
+ }
+
+ if (mDescriptionID < -1)
+ {
+ return false;
+ }
+
+ // The name must be valid
+ std::string name = mpName;
+ if (name.find( DB2_VALUE_SEP ) != -1 || name.find( DB2_SUBVAL_SEP ) != -1)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+/*=========================================================================*/
+// sDB2Category Methods
+/*=========================================================================*/
+
+/*===========================================================================
+METHOD:
+ FromString (Public Method)
+
+DESCRIPTION:
+ Populate this object from a string
+
+PARAMETERS:
+ pStr [ I ] - String to populate object from
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool sDB2Category::FromString( LPSTR pStr )
+{
+ bool bRC = false;
+
+ // Should be
+ // 0: ID
+ // 1: "Name"
+ // 2: Description ID
+ // 3: Parent ID
+ const ULONG NUM_REQ_VALS = 4;
+
+ std::vector <LPSTR> tokens;
+ ParseTokens( DB2_VALUE_SEP, pStr, tokens );
+
+ ULONG toks = (ULONG)tokens.size();
+ if (toks >= NUM_REQ_VALS)
+ {
+ // Remove quotes from name string and copy
+ LPCSTR pCopy = CopyQuotedString( tokens[1] );
+ if (pCopy != 0)
+ {
+ mID = strtoul( tokens[0], 0, 10 );
+ mParentID = strtol( tokens[3], 0, 10 );
+ mpName = pCopy;
+
+ // Old format used to be a description string, so
+ // first check for quotes
+ if (tokens[2][0] != '\"')
+ {
+ mDescriptionID = strtol( tokens[2], 0, 10 );
+ }
+
+ bRC = IsValid();
+ }
+ }
+
+ return bRC;
+}
+
+/*===========================================================================
+METHOD:
+ IsValid (Public Method)
+
+DESCRIPTION:
+ Is this object valid?
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool sDB2Category::IsValid() const
+{
+ // The parent ID has to be greater than or equal to -1
+ if (mParentID < -1)
+ {
+ return false;
+ }
+
+ // There has to be a non-empty name
+ if (mpName == 0 || mpName[0] == 0)
+ {
+ return false;
+ }
+
+ if (mDescriptionID < -1)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+/*=========================================================================*/
+// sDB2NVItem Methods
+/*=========================================================================*/
+
+/*===========================================================================
+METHOD:
+ FromString (Public Method)
+
+DESCRIPTION:
+ Populate this object from a string
+
+PARAMETERS:
+ pStr [ I ] - String to populate object from
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool sDB2NVItem::FromString( LPSTR pStr )
+{
+ bool bRC = false;
+
+ // Should be
+ // 0: NV Item number
+ // 1: "Name"
+ // 2: "Categories"
+ // 3: Description ID
+ const ULONG NUM_REQ_VALS = 4;
+
+ std::vector <LPSTR> tokens;
+ ParseTokens( DB2_VALUE_SEP, pStr, tokens );
+
+ ULONG toks = (ULONG)tokens.size();
+ if (toks >= NUM_REQ_VALS)
+ {
+ // Remove quotes from name string and copy
+ LPCSTR pCopy = CopyQuotedString( tokens[1] );
+ if (pCopy != 0)
+ {
+ CSVStringToContainer( DB2_SUBVAL_SEP, tokens[2], mCategoryIDs );
+
+ mItem = strtoul( tokens[0], 0, 10 );
+ mpName = pCopy;
+
+ // Old format used to be a description string, so
+ // first check for quotes
+ if (tokens[3][0] != '\"')
+ {
+ mDescriptionID = strtol( tokens[3], 0, 10 );
+ }
+
+ bRC = IsValid();
+ }
+ }
+
+ return bRC;
+}
+
+/*===========================================================================
+METHOD:
+ IsValid (Public Method)
+
+DESCRIPTION:
+ Is this object valid?
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool sDB2NVItem::IsValid() const
+{
+ // There has to be at least one category ID
+ ULONG cats = (ULONG)mCategoryIDs.size();
+ if (cats < 1)
+ {
+ return false;
+ }
+
+ // The category IDs have to be greater than or equal to -1
+ std::set <int>::const_iterator pIter = mCategoryIDs.begin();
+ while (pIter != mCategoryIDs.end())
+ {
+ if (*pIter++ < -1)
+ {
+ return false;
+ }
+ }
+
+ // There has to be a non-empty name
+ if (mpName == 0 || mpName[0] == 0)
+ {
+ return false;
+ }
+
+ if (mDescriptionID < -1)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+/*=========================================================================*/
+// sDB2Enum Methods
+/*=========================================================================*/
+
+/*===========================================================================
+METHOD:
+ FromString (Public Method)
+
+DESCRIPTION:
+ Populate this object from a string
+
+PARAMETERS:
+ pStr [ I ] - String to populate object from
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool sDB2Enum::FromString( LPSTR pStr )
+{
+ bool bRC = false;
+
+ // Should be
+ // 0: ID
+ // 1: "Name"
+ // 2: Description ID
+ // 3: Internal?
+ const ULONG NUM_REQ_VALS = 4;
+
+ std::vector <LPSTR> tokens;
+ ParseTokens( DB2_VALUE_SEP, pStr, tokens );
+
+ ULONG toks = (ULONG)tokens.size();
+ if (toks >= NUM_REQ_VALS)
+ {
+ // Remove quotes from name string and copy
+ LPCSTR pCopy = CopyQuotedString( tokens[1] );
+ if (pCopy != 0)
+ {
+ mID = strtoul( tokens[0], 0, 10 );
+ mbInternal = (strtoul( tokens[3], 0, 10 ) != 0);
+ mpName = pCopy;
+
+ // Old format used to be a description string, so
+ // first check for quotes
+ if (tokens[2][0] != '\"')
+ {
+ mDescriptionID = strtol( tokens[2], 0, 10 );
+ }
+
+ bRC = IsValid();
+ }
+ }
+
+ return bRC;
+}
+
+/*===========================================================================
+METHOD:
+ IsValid (Public Method)
+
+DESCRIPTION:
+ Is this object valid?
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool sDB2Enum::IsValid() const
+{
+ // There has to be a non-empty name
+ if (mpName == 0 || mpName[0] == 0)
+ {
+ return false;
+ }
+
+ if (mDescriptionID < -1)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+/*=========================================================================*/
+// sDB2EnumEntry Methods
+/*=========================================================================*/
+
+/*===========================================================================
+METHOD:
+ FromString (Public Method)
+
+DESCRIPTION:
+ Populate this object from a string
+
+PARAMETERS:
+ pStr [ I ] - String to populate object from
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool sDB2EnumEntry::FromString( LPSTR pStr )
+{
+ bool bRC = false;
+
+ // Should be
+ // 0: ID
+ // 1: Value
+ // 2: "Name"
+ // 3: Description ID (optional)
+ const ULONG NUM_REQ_VALS = 3;
+
+ std::vector <LPSTR> tokens;
+ ParseTokens( DB2_VALUE_SEP, pStr, tokens );
+
+ ULONG toks = (ULONG)tokens.size();
+ if (toks >= NUM_REQ_VALS)
+ {
+ // Remove quotes from name string and copy
+ LPCSTR pCopy = CopyQuotedString( tokens[2] );
+ if (pCopy != 0)
+ {
+ mID = strtoul( tokens[0], 0, 10 );
+ mpName = pCopy;
+
+ // Enum entries are signed by definition, but can be entered
+ // in hexadecimal as they may be unsigned in practice
+ LONG val = -1;
+ StringToLONG( tokens[1], 0, val );
+ mValue = (INT)val;
+
+ // Determine hexadecimal flag by performing case-insensitve comparison
+ // of the value string's first two characters with "0x"
+ mbHex = (strncmp( tokens[1], "0x", 2 ) == 0);
+
+ // Description ID?
+ if (toks > NUM_REQ_VALS)
+ {
+ mDescriptionID = strtol( tokens[NUM_REQ_VALS], 0, 10 );
+ }
+
+ bRC = IsValid();
+ }
+ }
+
+ return bRC;
+}
+
+/*===========================================================================
+METHOD:
+ IsValid (Public Method)
+
+DESCRIPTION:
+ Is this object valid?
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool sDB2EnumEntry::IsValid() const
+{
+ // There has to be a non-empty name
+ if (mpName == 0 || mpName[0] == 0)
+ {
+ return false;
+ }
+
+ if (mDescriptionID < -1)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+/*=========================================================================*/
+// cCoreDatabase Methods
+/*=========================================================================*/
+
+/*===========================================================================
+METHOD:
+ cCoreDatabase (Public Method)
+
+DESCRIPTION:
+ Constructor
+
+RETURN VALUE:
+ None
+===========================================================================*/
+cCoreDatabase::cCoreDatabase()
+ : mpLog( &gDB2DefaultLog )
+{
+ // Nothing to do - database empty, call Initialize()
+}
+
+/*===========================================================================
+METHOD:
+ ~cCoreDatabase (Public Method)
+
+DESCRIPTION:
+ Destructor
+
+RETURN VALUE:
+ None
+===========================================================================*/
+cCoreDatabase::~cCoreDatabase()
+{
+ Exit();
+}
+
+/*===========================================================================
+METHOD:
+ Initialize (Public Method)
+
+DESCRIPTION:
+ Version to Load from file
+ Initialize the database - this must be done once (and only once)
+ prior to the database being accessed
+
+PARAMETERS
+ pBasePath [ I ] - Base path to database files
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cCoreDatabase::Initialize( LPCSTR pBasePath )
+{
+ bool bRC = true;
+
+ // Cleanup the last database (if necessary)
+ Exit();
+
+ bRC &= LoadEnumTables( pBasePath );
+ bRC &= LoadStructureTables( pBasePath );
+
+ // Build the modifier tables
+ bRC &= BuildModifierTables();
+
+ return bRC;
+}
+
+/*===========================================================================
+METHOD:
+ Initialize (Public Method)
+
+DESCRIPTION:
+ Version to Load from internal pointers
+ Initialize the database - this must be done once (and only once)
+ prior to the database being accessed
+
+PARAMETERS
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cCoreDatabase::Initialize()
+{
+ bool bRC = true;
+
+ // Cleanup the last database (if necessary)
+ Exit();
+
+ bRC &= LoadEnumTables();
+ bRC &= LoadStructureTables();
+
+ // Build the modifier tables
+ bRC &= BuildModifierTables();
+
+ return bRC;
+}
+
+/*===========================================================================
+METHOD:
+ Exit (Public Method)
+
+DESCRIPTION:
+ Exit (cleanup) the database
+
+RETURN VALUE:
+ None
+===========================================================================*/
+void cCoreDatabase::Exit()
+{
+ FreeDB2Table( mEntityFields );
+ FreeDB2Table( mEntityStructs );
+ FreeDB2Table( mProtocolEntities );
+
+ FreeDB2Table( mEnumNameMap );
+ FreeDB2Table( mEnumEntryMap );
+
+ tDB2EntityNavMap::iterator pIter = mEntityNavMap.begin();
+ while (pIter != mEntityNavMap.end())
+ {
+ cDB2NavTree * pNav = pIter->second;
+ if (pNav != 0)
+ {
+ delete pNav;
+ }
+
+ pIter++;
+ }
+
+ mEntityNavMap.clear();
+}
+
+/*===========================================================================
+METHOD:
+ GetEntityNavTree (Public Method)
+
+DESCRIPTION:
+ Get the entity navigation tree for the given protocol entity, if none
+ exists one will be built and returned
+
+PARAMETERS
+ key [ I ] - Protocol entity key
+
+RETURN VALUE:
+ const cDB2NavTree * (0 upon error)
+===========================================================================*/
+const cDB2NavTree * cCoreDatabase::GetEntityNavTree(
+ const std::vector <ULONG> & key ) const
+{
+ // Look up entity definition (to find DB string address)
+ sDB2ProtocolEntity tmpEntity;
+ bool bFound = FindEntity( key, tmpEntity );
+
+ // Did we find it?
+ if (bFound == false)
+ {
+ // No matching definition in database
+ return 0;
+ }
+
+ // Obtain the canonical key and use it to look up the nav tree
+ tDB2EntityNavMap::const_iterator pIter = mEntityNavMap.find( key );
+ if (pIter != mEntityNavMap.end())
+ {
+ return pIter->second;
+ }
+
+ // None found, go ahead and build one
+ cDB2NavTree * pNavTree = new cDB2NavTree( *this );
+ if (pNavTree != 0)
+ {
+ bool bOK = pNavTree->BuildTree( key );
+ if (bOK == true)
+ {
+ // Store it and return it to the user
+ std::pair <std::vector <ULONG>, cDB2NavTree *> e( key, pNavTree );
+ mEntityNavMap.insert( e );
+ }
+ else
+ {
+ delete pNavTree;
+ pNavTree = 0;
+ }
+ }
+
+ return pNavTree;
+}
+
+/*===========================================================================
+METHOD:
+ FindEntity (Public Method)
+
+DESCRIPTION:
+ Find the protocol entity with the specified extended ID
+
+PARAMETERS
+ key [ I ] - Protocol entity key to find
+ entity [ O ] - Protocol entity (if found)
+
+RETURN VALUE:
+ bool - Success?
+===========================================================================*/
+bool cCoreDatabase::FindEntity(
+ const std::vector <ULONG> & key,
+ sDB2ProtocolEntity & entity ) const
+{
+ // Assume failure
+ bool bFound = false;
+
+ tDB2EntityMap::const_iterator pEntity = mProtocolEntities.find( key );
+ if (pEntity != mProtocolEntities.end())
+ {
+ entity = pEntity->second;
+ bFound = true;
+ }
+
+ return bFound;
+}
+
+/*===========================================================================
+METHOD:
+ FindEntity (Public Method)
+
+DESCRIPTION:
+ Find the protocol entity with the specified name
+
+PARAMETERS
+ pEntityName [ I ] - Protocol entity name to find
+ entity [ O ] - Protocol entity (if found)
+
+RETURN VALUE:
+ bool - Success?
+===========================================================================*/
+bool cCoreDatabase::FindEntity(
+ LPCSTR pEntityName,
+ sDB2ProtocolEntity & entity ) const
+{
+ // Assume failure
+ bool bFound = false;
+ if (pEntityName != 0 && pEntityName[0] != 0)
+ {
+ tDB2EntityNameMap::const_iterator pIter = mEntityNames.find( pEntityName );
+ if (pIter != mEntityNames.end())
+ {
+ const std::vector <ULONG> & key = pIter->second;
+ bFound = FindEntity( key, entity );
+ }
+ }
+
+ return bFound;
+}
+
+/*===========================================================================
+METHOD:
+ MapEntityNameToID (Public Method)
+
+DESCRIPTION:
+ Map a protocol entity name to an ID
+
+PARAMETERS
+ pName [ I ] - Protocol entity name
+ key [ O ] - Upon success, the ID corresponding to protocol entity
+
+RETURN VALUE:
+ bool - Success?
+===========================================================================*/
+bool cCoreDatabase::MapEntityNameToID(
+ LPCSTR pName,
+ std::vector <ULONG> & key ) const
+{
+ // Assume failure
+ bool bOK = false;
+
+ if (pName != 0 && pName[0] != 0)
+ {
+ std::string tmp = pName;
+
+ // std::string version of Trim()
+ int nFirst = tmp.find_first_not_of( ' ' );
+ int nLast = tmp.find_last_not_of( ' ' );
+ if (nFirst == -1 || nLast == -1)
+ {
+ // Something went wrong, empty string or all spaces
+ return false;
+ }
+
+ tmp = tmp.substr( nFirst, nLast - nFirst + 1 );
+
+
+ tDB2EntityNameMap::const_iterator pIter = mEntityNames.find( tmp.c_str() );
+ if (pIter != mEntityNames.end())
+ {
+ key = pIter->second;
+ bOK = true;
+ }
+ }
+
+ return bOK;
+}
+
+/*===========================================================================
+METHOD:
+ MapEnumToString (Public Method)
+
+DESCRIPTION:
+ Map the given enum value (specified by enum ID, and enum value) to
+ the enum value name string
+
+PARAMETERS
+ enumID [ I ] - ID of the enumeration
+ enumVal [ I ] - Enum value to map
+ bSimpleErrFmt [ I ] - If the eunum value cannot be mapped to a string
+ what should this method return?
+
+ If 'true' then just the value as a string
+ If 'false' then the enum ID, value, and 'Unknown'
+
+ bHex [ I ] - Hexadecimal output on mapping error?
+
+RETURN VALUE:
+ std::string - The enum name (or error string if enum value is not found)
+===========================================================================*/
+std::string cCoreDatabase::MapEnumToString(
+ ULONG enumID,
+ int enumVal,
+ bool bSimpleErrFmt,
+ bool bHex ) const
+{
+ std::string retStr = "";
+
+ // Form the lookup key
+ std::pair <ULONG, int> key( enumID, enumVal );
+
+ // Look up the enum value descriptor
+ tDB2EnumEntryMap::const_iterator pVals = mEnumEntryMap.find( key );
+ if (pVals != mEnumEntryMap.end())
+ {
+ const sDB2EnumEntry & entry = pVals->second;
+ retStr = entry.mpName;
+ }
+
+ // No string?
+ if (retStr.size() <= 0)
+ {
+ std::ostringstream tmp;
+
+ if (bSimpleErrFmt == false)
+ {
+ tmp << "Unknown [" << (UINT)enumID << "/";
+ }
+
+ if (bHex == true)
+ {
+ tmp << std::ios_base::hex << std::ios_base::uppercase
+ << std::ios_base::showbase << enumVal;
+ }
+ else
+ {
+ tmp << enumVal;
+ }
+
+ retStr = tmp.str();
+ }
+
+ return retStr;
+}
+
+/*===========================================================================
+METHOD:
+ MapEnumToString (Public Method)
+
+DESCRIPTION:
+ Map the given enum value (specified by enum name, and enum value) to
+ the enum value name string
+
+PARAMETERS
+ pEnumName [ I ] - Name of the enumeration
+ enumVal [ I ] - Enum value to map
+ bSimpleErrFmt [ I ] - If the eunum value cannot be mapped to a string
+ what should this method return?
+
+ If 'true' then just the value as a string
+ If 'false' then the enum ID, value, and 'Unknown'
+
+ bHex [ I ] - Hexadecimal output on mapping error?
+
+RETURN VALUE:
+ std::string - The enum name (or error string if enum value is not found)
+===========================================================================*/
+std::string cCoreDatabase::MapEnumToString(
+ LPCSTR pEnumName,
+ int enumVal,
+ bool bSimpleErrFmt,
+ bool bHex ) const
+{
+ std::string retStr = "";
+
+ tDB2EnumMap::const_iterator pEnumMapIter = mEnumMap.find( pEnumName );
+ if (pEnumMapIter != mEnumMap.end())
+ {
+ const std::map <int, LPCSTR> & entries = pEnumMapIter->second.second;
+ std::map <int, LPCSTR>::const_iterator pEntry;
+
+ pEntry = entries.find( enumVal );
+ if (pEntry != entries.end())
+ {
+ retStr = pEntry->second;
+ }
+ }
+
+ // No string?
+ if (retStr.size() <= 0)
+ {
+ std::ostringstream tmp;
+
+ if (bSimpleErrFmt == false)
+ {
+ if (pEnumName == 0)
+ {
+ pEnumName = "?";
+ }
+
+ tmp << "Unknown [" << pEnumName << "/";
+ }
+
+ if (bHex == true)
+ {
+ tmp << std::ios_base::hex << std::ios_base::uppercase
+ << std::ios_base::showbase << enumVal;
+ }
+ else
+ {
+ tmp << enumVal;
+ }
+
+ retStr = tmp.str();
+ }
+
+ return retStr;
+}
+
+/*===========================================================================
+METHOD:
+ AssembleEnumMap (Internal Method)
+
+DESCRIPTION:
+ Assemble the internal enum map from the enum and enum entry tables
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cCoreDatabase::AssembleEnumMap()
+{
+ bool bOK = true;
+
+ // Empty it out first
+ mEnumMap.clear();
+
+ tDB2EnumEntryMap::const_iterator pEntry = mEnumEntryMap.begin();
+ if (pEntry == mEnumEntryMap.end())
+ {
+ return bOK;
+ }
+
+ // Set initial enum ID
+ ULONG currentID = pEntry->second.mID;
+
+ std::map <int, LPCSTR> entries;
+ while (pEntry != mEnumEntryMap.end())
+ {
+ const sDB2EnumEntry & entry = pEntry->second;
+ pEntry++;
+
+ if (entry.IsValid() == false)
+ {
+ continue;
+ }
+
+ if (currentID != entry.mID)
+ {
+ if (entries.size() > 0)
+ {
+ // Look up the enum name
+ tDB2EnumNameMap::const_iterator pEnum;
+ pEnum = mEnumNameMap.find( currentID );
+
+ if (pEnum != mEnumNameMap.end())
+ {
+ const sDB2Enum & dbEnum = pEnum->second;
+ if (mEnumMap.find( dbEnum.mpName ) == mEnumMap.end())
+ {
+ tDB2EnumMapPair tmp( dbEnum.mID, entries );
+ mEnumMap[dbEnum.mpName] = tmp;
+ }
+ else
+ {
+ // Hmm, duplicate enum names discovered
+ std::ostringstream tmp;
+ tmp << "DB [" << DB2_TABLE_ENUM_MAIN
+ << "] Duplicate enum (by name) detected \'"
+ << dbEnum.mpName << "\'";
+
+ mpLog->Log( tmp.str(), eDB2_STATUS_ERROR );
+
+ bOK = false;
+ }
+ }
+ else
+ {
+ // Hmm, missing enum ID discovered
+ std::ostringstream tmp;
+ tmp << "DB [" << DB2_TABLE_ENUM_MAIN
+ << "] Missing enum ID detected "
+ << currentID;
+
+ mpLog->Log( tmp.str(), eDB2_STATUS_ERROR );
+
+ bOK = false;
+ }
+
+ // Clear out enum entries for next pass and add this entry
+ entries.clear();
+ entries[entry.mValue] = entry.mpName;
+
+ // Adjust current enum ID
+ currentID = entry.mID;
+ }
+ }
+ else
+ {
+ if (entries.find( entry.mValue ) == entries.end())
+ {
+ entries[entry.mValue] = entry.mpName;
+ }
+ else
+ {
+ // Hmm, duplicate enum entry values discovered
+ std::ostringstream tmp;
+ tmp << "DB [" << DB2_TABLE_ENUM_ENTRY
+ << "] Duplicate enum entries detected \'"
+ << entry.mpName << "\', " << entry.mValue;
+
+ mpLog->Log( tmp.str(), eDB2_STATUS_ERROR );
+
+ bOK = false;
+ }
+ }
+ }
+
+ // Add in the last enum
+ if (mEnumEntryMap.size() > 0 && entries.size() > 0)
+ {
+ // Look up the enum name
+ tDB2EnumNameMap::const_iterator pEnum;
+ pEnum = mEnumNameMap.find( currentID );
+
+ if (pEnum != mEnumNameMap.end())
+ {
+ const sDB2Enum & dbEnum = pEnum->second;
+ if (mEnumMap.find( dbEnum.mpName ) == mEnumMap.end())
+ {
+ tDB2EnumMapPair tmp( dbEnum.mID, entries );
+ mEnumMap[dbEnum.mpName] = tmp;
+ }
+ else
+ {
+ // Hmm, duplicate enum names discovered
+ std::ostringstream tmp;
+ tmp << "DB [" << DB2_TABLE_ENUM_MAIN
+ << "] Duplicate enum (by name) detected \'"
+ << dbEnum.mpName << "\'";
+
+ mpLog->Log( tmp.str(), eDB2_STATUS_ERROR );
+
+ bOK = false;
+ }
+ }
+ else
+ {
+ // Hmm, missing enum ID discovered
+ std::ostringstream tmp;
+ tmp << "DB [" << DB2_TABLE_ENUM_MAIN
+ << "] Missing enum ID detected " << currentID;
+
+ mpLog->Log( tmp.str(), eDB2_STATUS_ERROR );
+
+ bOK = false;
+ }
+ }
+
+ return bOK;
+}
+
+/*===========================================================================
+METHOD:
+ AssembleEntityNameMap (Internal Method)
+
+DESCRIPTION:
+ Assemble the internal protocol entity name map
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cCoreDatabase::AssembleEntityNameMap()
+{
+ // Assume success
+ bool bOK = true;
+
+ // Empty it out first
+ mEntityNames.clear();
+
+ // Go through and build the event name table
+ tDB2EntityMap::const_iterator pIter = mProtocolEntities.begin();
+ while (pIter != mProtocolEntities.end())
+ {
+ const sDB2ProtocolEntity & obj = pIter->second;
+ pIter++;
+
+ if (obj.IsValid() == false)
+ {
+ continue;
+ }
+
+ tDB2EntityNameMap::const_iterator pNames;
+ pNames = mEntityNames.find( obj.mpName );
+ if (pNames == mEntityNames.end())
+ {
+ mEntityNames[obj.mpName] = obj.GetKey();
+ }
+ else
+ {
+ std::ostringstream tmp;
+ tmp << "DB [" << DB2_TABLE_PROTOCOL_ENTITY
+ << "] Duplicate protocol entity (by name) detected \'"
+ << obj.mpName << "\'";
+
+ mpLog->Log( tmp.str(), eDB2_STATUS_ERROR );
+
+ bOK = false;
+ }
+ }
+
+ return bOK;
+}
+
+/*===========================================================================
+METHOD:
+ BuildModifierTables (Internal Method)
+
+DESCRIPTION:
+ Build the parsed fragment modifier maps, i.e. convert the modifier
+ text string to something more useful by database clients
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cCoreDatabase::BuildModifierTables()
+{
+ // Assume success
+ bool bOK = true;
+
+ // Parse all fragment modifiers
+ tDB2FragmentMap::const_iterator pFragIter = mEntityStructs.begin();
+ while (pFragIter != mEntityStructs.end())
+ {
+ // Grab new fragment
+ const sDB2Fragment & frag = pFragIter->second;
+ pFragIter++;
+
+ // Skip invalid/unmodified fragments
+ if ( (frag.IsValid() == false)
+ || (frag.mpModifierValue == 0)
+ || (frag.mpModifierValue == EMPTY_STRING) )
+ {
+ continue;
+ }
+
+ switch (frag.mModifierType)
+ {
+ case eDB2_MOD_CONSTANT_ARRAY:
+ case eDB2_MOD_VARIABLE_ARRAY:
+ case eDB2_MOD_VARIABLE_STRING1:
+ case eDB2_MOD_VARIABLE_STRING2:
+ case eDB2_MOD_VARIABLE_STRING3:
+ {
+ ULONG val = strtoul( frag.mpModifierValue, 0, 0 );
+ mArray1ModMap[frag.mpModifierValue] = val;
+ }
+ break;
+
+ case eDB2_MOD_VARIABLE_ARRAY2:
+ {
+ // Parse modifier to tokens (start stop)
+ int nSize = strlen( frag.mpModifierValue ) + 1;
+
+ char * pCopy = new char[ nSize ];
+ if (pCopy == NULL)
+ {
+ return false;
+ }
+
+ memcpy( pCopy, frag.mpModifierValue, nSize );
+
+ std::vector <ULONG> indices;
+ CSVStringToContainer( " ", pCopy, indices );
+
+ delete [] pCopy;
+ if (indices.size() == 2)
+ {
+ std::pair <ULONG, ULONG> val;
+ val.first = indices[0];
+ val.second = indices[1];
+ mArray2ModMap[frag.mpModifierValue] = val;
+ }
+ }
+ break;
+
+ case eDB2_MOD_OPTIONAL:
+ {
+ sDB2SimpleCondition con;
+
+ // Parse condition to tokens (field ID operator value)
+ bool bRC = sDB2Fragment::ParseCondition( frag.mpModifierValue,
+ con.mID,
+ con.mOperator,
+ con.mValue,
+ con.mbF2F );
+
+ if (bRC == true)
+ {
+ mOptionalModMap[frag.mpModifierValue] = con;
+ }
+ }
+ break;
+
+ case eDB2_MOD_VARIABLE_ARRAY3:
+ {
+ sDB2SimpleExpression exp;
+
+ // Parse condition to tokens (field ID operator value)
+ bool bRC = sDB2Fragment::ParseExpression( frag.mpModifierValue,
+ exp.mID,
+ exp.mOperator,
+ exp.mValue,
+ exp.mbF2F );
+
+ if (bRC == true)
+ {
+ mExpressionModMap[frag.mpModifierValue] = exp;
+ }
+ }
+ break;
+ }
+ }
+
+ return bOK;
+}
+
+
+/*===========================================================================
+METHOD:
+ CheckAndSetBasePath (Internal Method)
+
+DESCRIPTION:
+ Check and set the passed in path to something that is useful
+
+PARAMETERS
+ pBasePath [ I ] - Base path
+
+RETURN VALUE:
+ std::string - The enum name (or error string if enum value is not found)
+===========================================================================*/
+std::string cCoreDatabase::CheckAndSetBasePath( LPCSTR pBasePath ) const
+{
+ std::string basePath = ".";
+ if (pBasePath != 0 && pBasePath[0] != 0)
+ {
+ struct stat fileInfo;
+ if (stat( pBasePath, &fileInfo ) == 0)
+ {
+ if (S_ISDIR( fileInfo.st_mode ) == true)
+ {
+ // It's a directory
+ basePath = pBasePath;
+ }
+ }
+ }
+
+ return basePath;
+}
+
+/*===========================================================================
+METHOD:
+ LoadStructureTables (Internal Method)
+
+DESCRIPTION:
+ Load all tables related to structure (entity, struct, field, format spec)
+
+PARAMETERS
+ pBasePath [ I ] - Base path to database files
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cCoreDatabase::LoadStructureTables( LPCSTR pBasePath )
+{
+ bool bRC = true;
+
+ std::string basePath = CheckAndSetBasePath( pBasePath );
+ basePath += "/";
+
+ std::string fn = basePath;
+ fn += DB2_FILE_PROTOCOL_FIELD;
+ bRC &= LoadDB2Table( (LPCSTR)fn.c_str(),
+ mEntityFields,
+ false,
+ DB2_TABLE_PROTOCOL_FIELD,
+ *mpLog );
+
+ fn = basePath;
+ fn += DB2_FILE_PROTOCOL_STRUCT;
+ bRC &= LoadDB2Table( (LPCSTR)fn.c_str(),
+ mEntityStructs,
+ false,
+ DB2_TABLE_PROTOCOL_STRUCT,
+ *mpLog );
+
+ fn = basePath;
+ fn += DB2_FILE_PROTOCOL_ENTITY;
+ bRC &= LoadDB2Table( (LPCSTR)fn.c_str(),
+ mProtocolEntities,
+ false,
+ DB2_TABLE_PROTOCOL_ENTITY,
+ *mpLog );
+
+ // Validate protocol entities
+ bRC &= ValidateStructures();
+
+ // Build internal protocol entity name map
+ bRC &= AssembleEntityNameMap();
+
+ return bRC;
+}
+
+/*===========================================================================
+METHOD:
+ LoadStructureTables (Internal Method)
+
+DESCRIPTION:
+ Load all tables related to structure (entity, struct, field)
+
+PARAMETERS
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cCoreDatabase::LoadStructureTables()
+{
+ bool bRC = true;
+
+ // Calculate sizes
+ int nFieldSize = (const char*)&_binary_QMI_Field_txt_end -
+ (const char*)&_binary_QMI_Field_txt_start;
+ int nStructSize = (const char*)&_binary_QMI_Struct_txt_end -
+ (const char*)&_binary_QMI_Struct_txt_start;
+ int nEntitySize = (const char*)&_binary_QMI_Entity_txt_end -
+ (const char*)&_binary_QMI_Entity_txt_start;
+
+ bRC &= LoadDB2Table( (const char*)&_binary_QMI_Field_txt_start,
+ nFieldSize,
+ mEntityFields,
+ false,
+ DB2_TABLE_PROTOCOL_FIELD,
+ *mpLog );
+
+ bRC &= LoadDB2Table( (const char*)&_binary_QMI_Struct_txt_start,
+ nStructSize,
+ mEntityStructs,
+ false,
+ DB2_TABLE_PROTOCOL_STRUCT,
+ *mpLog );
+
+ bRC &= LoadDB2Table( (const char*)&_binary_QMI_Entity_txt_start,
+ nEntitySize,
+ mProtocolEntities,
+ false,
+ DB2_TABLE_PROTOCOL_ENTITY,
+ *mpLog );
+
+ // Validate protocol entities
+ bRC &= ValidateStructures();
+
+ // Build internal protocol entity name map
+ bRC &= AssembleEntityNameMap();
+
+ return bRC;
+}
+
+/*===========================================================================
+METHOD:
+ LoadEnumTables (Internal Method)
+
+DESCRIPTION:
+ Load all enumeration tables
+
+PARAMETERS
+ pBasePath [ I ] - Base path to database files
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cCoreDatabase::LoadEnumTables( LPCSTR pBasePath )
+{
+ bool bRC = true;
+
+ std::string basePath = CheckAndSetBasePath( pBasePath );
+ basePath += "/";
+
+
+ std::string fn = basePath;
+ fn += DB2_FILE_ENUM_MAIN;
+ bRC &= LoadDB2Table( (LPCSTR)fn.c_str(),
+ mEnumNameMap,
+ false,
+ DB2_TABLE_ENUM_MAIN,
+ *mpLog );
+
+ fn = basePath;
+ fn += DB2_FILE_ENUM_ENTRY;
+ bRC &= LoadDB2Table( (LPCSTR)fn.c_str(),
+ mEnumEntryMap,
+ false,
+ DB2_TABLE_ENUM_ENTRY,
+ *mpLog );
+
+ // Build the enum map
+ bRC &= AssembleEnumMap();
+
+ return bRC;
+}
+
+/*===========================================================================
+METHOD:
+ LoadEnumTables (Internal Method)
+
+DESCRIPTION:
+ Load all enumeration tables
+
+PARAMETERS
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cCoreDatabase::LoadEnumTables()
+{
+ bool bRC = true;
+ // Calculate sizes
+ int nEnumSize = (const char*)&_binary_QMI_Enum_txt_end -
+ (const char*)&_binary_QMI_Enum_txt_start;
+ int nEnumEntrySize = (const char*)&_binary_QMI_EnumEntry_txt_end -
+ (const char*)&_binary_QMI_EnumEntry_txt_start;
+
+ bRC &= LoadDB2Table( (const char*)&_binary_QMI_Enum_txt_start,
+ nEnumSize,
+ mEnumNameMap,
+ false,
+ DB2_TABLE_ENUM_MAIN,
+ *mpLog );
+
+ bRC &= LoadDB2Table( (const char*)&_binary_QMI_EnumEntry_txt_start,
+ nEnumEntrySize,
+ mEnumEntryMap,
+ false,
+ DB2_TABLE_ENUM_ENTRY,
+ *mpLog );
+
+ // Build the enum map
+ bRC &= AssembleEnumMap();
+
+ return bRC;
+}
+
+/*===========================================================================
+METHOD:
+ ValidateStructures (Internal Method)
+
+DESCRIPTION:
+ Validate (and attempt repair of) structure related tables
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cCoreDatabase::ValidateStructures()
+{
+ // Assume success
+ bool bRC = true;
+
+ tDB2EntityMap::iterator pEntity = mProtocolEntities.begin();
+ while (pEntity != mProtocolEntities.end())
+ {
+ sDB2ProtocolEntity & entity = pEntity->second;
+
+ // Structure ID given?
+ if (entity.mStructID != -1)
+ {
+ // Yes, validate individual structure
+ std::set <ULONG> fields;
+ bool bValid = ValidateStructure( (ULONG)entity.mStructID, fields, 0 );
+
+ // Not valid?
+ if (bValid == false)
+ {
+ // Invalid structure, reset to none
+ std::ostringstream tmp;
+ tmp << "DB [" << DB2_TABLE_PROTOCOL_STRUCT
+ << "] Invalid struct, ID " << entity.mStructID;
+
+ mpLog->Log( tmp.str(), eDB2_STATUS_ERROR );
+
+ entity.mStructID = -1;
+
+ // We found at least one bad structure
+ bRC = false;
+ }
+ }
+
+ pEntity++;
+ }
+
+ return bRC;
+}
+
+/*===========================================================================
+METHOD:
+ ValidateStructure (Internal Method)
+
+DESCRIPTION:
+ Validate a single structure
+
+PARAMETERS:
+ structID [ I ] - ID of structure being evaluated
+ fields [I/O] - List of 'known' field IDs
+ depth [I/O] - Recursion depth
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cCoreDatabase::ValidateStructure(
+ ULONG structID,
+ std::set <ULONG> & fields,
+ ULONG depth )
+{
+ // Assume success
+ bool bRC = true;
+
+ // Reached our limit?
+ if (depth++ >= MAX_NESTING_LEVEL)
+ {
+ // Invalid structure
+ std::ostringstream tmp;
+ tmp << "DB [" << DB2_TABLE_PROTOCOL_STRUCT
+ << "] Max depth exceeded, possible loop, struct ID " << structID;
+
+ mpLog->Log( tmp.str(), eDB2_STATUS_ERROR );
+
+ return false;
+ }
+
+ // Grab first fragment of structure
+ std::pair <ULONG, ULONG> id( structID, 0 );
+ tDB2FragmentMap::const_iterator pFrag = mEntityStructs.find( id );
+
+ // Did we find the first fragment?
+ if (pFrag == mEntityStructs.end())
+ {
+ std::ostringstream tmp;
+ tmp << "DB [" << DB2_TABLE_PROTOCOL_STRUCT
+ << "] Missing initial fragment, struct ID " << structID;
+
+ mpLog->Log( tmp.str(), eDB2_STATUS_ERROR );
+
+ bRC = false;
+ }
+
+ // Iterate over each fragment in the structure
+ while (pFrag != mEntityStructs.end() && pFrag->second.mStructID == structID)
+ {
+ // Grab fragment
+ const sDB2Fragment & frag = pFrag->second;
+
+ // Variable array or optional fragment?
+ if ( (frag.mModifierType == eDB2_MOD_VARIABLE_ARRAY)
+ || (frag.mModifierType == eDB2_MOD_VARIABLE_ARRAY2) )
+ {
+ bRC = ValidateArraySpecifier( frag, fields );
+ }
+ else if (frag.mModifierType == eDB2_MOD_OPTIONAL)
+ {
+ bRC = ValidateOptionalSpecifier( frag, fields );
+ }
+ else if (frag.mModifierType == eDB2_MOD_VARIABLE_ARRAY3)
+ {
+ bRC = ValidateExpressionSpecifier( frag, fields );
+ }
+ else if ( (frag.mModifierType == eDB2_MOD_VARIABLE_STRING1)
+ || (frag.mModifierType == eDB2_MOD_VARIABLE_STRING2)
+ || (frag.mModifierType == eDB2_MOD_VARIABLE_STRING3) )
+ {
+ bRC = ValidateArraySpecifier( frag, fields );
+ if (bRC == true)
+ {
+ // The field being modified has to be a fixed length string
+ ULONG fieldID = frag.mFragmentValue;
+ tDB2FieldMap::const_iterator pIter = mEntityFields.find( fieldID );
+ if (pIter != mEntityFields.end())
+ {
+ bool bString = false;
+
+ const sDB2Field & ft = pIter->second;
+ if (ft.mType == eDB2_FIELD_STD)
+ {
+ if ( (ft.mTypeVal == (ULONG)eDB2_FIELD_STDTYPE_STRING_A)
+ || (ft.mTypeVal == (ULONG)eDB2_FIELD_STDTYPE_STRING_U)
+ || (ft.mTypeVal == (ULONG)eDB2_FIELD_STDTYPE_STRING_U8) )
+ {
+ if ( (ft.mTypeVal != (ULONG)eDB2_FIELD_STDTYPE_STRING_U8)
+ || (frag.mModifierType != eDB2_MOD_VARIABLE_STRING3) )
+ {
+ // Not the invalid combination of character length and
+ // varaible length characters
+ bString = true;
+ }
+ }
+ }
+
+ if (bString == false)
+ {
+ // Not a string so why the string modifier?
+ std::ostringstream tmp;
+ tmp << "DB [" << DB2_TABLE_PROTOCOL_STRUCT
+ << "] Invalid string modifier, struct ID " << structID
+ << ", ID " << fieldID;
+
+ mpLog->Log( tmp.str(), eDB2_STATUS_ERROR );
+
+ bRC = false;
+ }
+ }
+ }
+ }
+
+ if (bRC == true)
+ {
+ // What type of fragment is this?
+ switch (frag.mFragmentType)
+ {
+ case eDB2_FRAGMENT_FIELD:
+ {
+ ULONG fieldID = frag.mFragmentValue;
+ bRC = ValidateField( structID, fieldID, fields );
+ }
+ break;
+
+ case eDB2_FRAGMENT_VARIABLE_PAD_BITS:
+ case eDB2_FRAGMENT_VARIABLE_PAD_BYTES:
+ {
+ // Does this field exist in the entity?
+ ULONG fieldID = frag.mFragmentValue;
+ if (fields.find( fieldID ) == fields.end())
+ {
+ // No
+ std::ostringstream tmp;
+ tmp << "DB [" << DB2_TABLE_PROTOCOL_STRUCT
+ << "] Invalid pad, struct ID " << structID
+ << ", ID " << fieldID;
+
+ mpLog->Log( tmp.str(), eDB2_STATUS_ERROR );
+
+ bRC = false;
+ }
+ }
+ break;
+
+ case eDB2_FRAGMENT_STRUCT:
+ {
+ // Grab structure ID and recurse
+ ULONG structID = frag.mFragmentValue;
+ bRC = ValidateStructure( structID, fields, depth );
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ // Did an error occur?
+ if (bRC == false)
+ {
+ break;
+ }
+
+ pFrag++;
+ }
+
+ return bRC;
+}
+
+/*===========================================================================
+METHOD:
+ ValidateField (Internal Method)
+
+DESCRIPTION:
+ Validate a single field
+
+PARAMETERS:
+ structID [ I ] - ID of referencing structure
+ fieldID [ I ] - ID of field being evaluated
+ fields [I/O] - List of 'known' field IDs
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cCoreDatabase::ValidateField(
+ ULONG structID,
+ ULONG fieldID,
+ std::set <ULONG> & fields )
+{
+ // Assume success
+ bool bRC = true;
+
+ tDB2FieldMap::const_iterator pIter = mEntityFields.find( fieldID );
+ if (pIter == mEntityFields.end())
+ {
+ // No
+ std::ostringstream tmp;
+ tmp << "DB [" << DB2_TABLE_PROTOCOL_STRUCT
+ << "] Invalid field, struct ID " << structID
+ << ", ID " << fieldID;
+
+ mpLog->Log( tmp.str(), eDB2_STATUS_ERROR );
+
+ bRC = false;
+ }
+ else
+ {
+ // Mark field as part of this structure
+ fields.insert( fieldID );
+
+ // Is this field an enumeration?
+ const sDB2Field & theField = pIter->second;
+ if ( (theField.mType == eDB2_FIELD_ENUM_UNSIGNED)
+ || (theField.mType == eDB2_FIELD_ENUM_SIGNED) )
+ {
+ // Yes, check that the enum exists
+ if (mEnumNameMap.find( theField.mTypeVal ) == mEnumNameMap.end())
+ {
+ std::ostringstream tmp;
+ tmp << "DB [" << DB2_TABLE_PROTOCOL_FIELD
+ << "] Invalid enumeration ID, field ID " << fieldID
+ << ", enum ID " << theField.mTypeVal;
+
+ mpLog->Log( tmp.str(), eDB2_STATUS_WARNING );
+ }
+ }
+ }
+
+ return bRC;
+}
+
+/*===========================================================================
+METHOD:
+ ValidateArraySpecifier (Internal Method)
+
+DESCRIPTION:
+ Validate an array specifier
+
+PARAMETERS:
+ frag [ I ] - Fragment containing array specifier
+ fields [ I ] - List of 'known' field IDs
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cCoreDatabase::ValidateArraySpecifier(
+ const sDB2Fragment & frag,
+ const std::set <ULONG> & fields )
+{
+ // Assume success
+ bool bRC = true;
+
+ // Even an array specifier to start with?
+ if (frag.mpModifierValue == 0 || frag.mpModifierValue == EMPTY_STRING)
+ {
+ std::ostringstream tmp;
+ tmp << "DB [" << DB2_TABLE_PROTOCOL_STRUCT
+ << "] Missing array specifier, struct ID " << frag.mStructID;
+
+ mpLog->Log( tmp.str(), eDB2_STATUS_ERROR );
+
+ bRC = false;
+ }
+ else if ( (frag.mModifierType == eDB2_MOD_VARIABLE_ARRAY)
+ || (frag.mModifierType == eDB2_MOD_VARIABLE_STRING1)
+ || (frag.mModifierType == eDB2_MOD_VARIABLE_STRING2)
+ || (frag.mModifierType == eDB2_MOD_VARIABLE_STRING3) )
+ {
+ ULONG id = strtoul( frag.mpModifierValue, 0, 0 );
+ if (fields.find( id ) == fields.end())
+ {
+ std::ostringstream tmp;
+ tmp << "DB [" << DB2_TABLE_PROTOCOL_STRUCT
+ << "] Invalid modifier specifier, struct ID " << frag.mStructID
+ << ", ID " << id;
+
+ mpLog->Log( tmp.str(), eDB2_STATUS_ERROR );
+
+ bRC = false;
+ }
+ }
+ else if (frag.mModifierType == eDB2_MOD_VARIABLE_ARRAY2)
+ {
+ // Parse condition to tokens (start stop)
+ int nSize = strlen( frag.mpModifierValue ) + 1;
+
+ char * pCopy = new char[ nSize ];
+ if (pCopy == NULL)
+ {
+ return false;
+ }
+
+ memcpy( pCopy, frag.mpModifierValue, nSize );
+
+ std::vector <ULONG> indices;
+ CSVStringToContainer( " ", pCopy, indices );
+
+ delete [] pCopy;
+ if (indices.size() != 2)
+ {
+ std::ostringstream tmp;
+ tmp << "DB [" << DB2_TABLE_PROTOCOL_STRUCT
+ << "] Invalid array specifier, struct ID " << frag.mStructID
+ << ", " << frag.mpModifierValue;
+
+ mpLog->Log( tmp.str(), eDB2_STATUS_ERROR );
+
+ bRC = false;
+ }
+ else
+ {
+ ULONG sID = indices[0];
+ ULONG eID = indices[1];
+
+ if ( (fields.find( sID ) == fields.end())
+ || (fields.find( eID ) == fields.end()) )
+ {
+ std::ostringstream tmp;
+ tmp << "DB [" << DB2_TABLE_PROTOCOL_STRUCT
+ << "] Invalid array specifier, struct ID " << frag.mStructID
+ << ", IDs " << sID << " " << eID;
+
+ mpLog->Log( tmp.str(), eDB2_STATUS_ERROR );
+
+ bRC = false;
+ }
+ }
+ }
+ else
+ {
+ ASSERT( 0 );
+ }
+
+ return bRC;
+}
+
+/*===========================================================================
+METHOD:
+ ValidateOptionalSpecifier (Internal Method)
+
+DESCRIPTION:
+ Validate a simple optional fragment specifier
+
+PARAMETERS:
+ frag [ I ] - Fragment containing optional fragment specifier
+ fields [ I ] - List of 'known' field IDs
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cCoreDatabase::ValidateOptionalSpecifier(
+ const sDB2Fragment & frag,
+ const std::set <ULONG> & fields )
+{
+ // Assume success
+ bool bRC = true;
+
+ ASSERT( frag.mModifierType == eDB2_MOD_OPTIONAL );
+
+ // Even an optional specifier to start with?
+ if (frag.mpModifierValue == 0 || frag.mpModifierValue == EMPTY_STRING)
+ {
+ std::ostringstream tmp;
+ tmp << "DB [" << DB2_TABLE_PROTOCOL_STRUCT
+ << "] Missing optional specifier, struct ID " << frag.mStructID;
+
+ mpLog->Log( tmp.str(), eDB2_STATUS_ERROR );
+
+ return false;
+ }
+
+ ULONG conID;
+ eDB2Operator conOp;
+ LONGLONG conVal;
+ bool bF2F;
+
+ // Parse condition
+ LPCSTR pCon = frag.mpModifierValue;
+ bRC = sDB2Fragment::ParseCondition( pCon, conID, conOp, conVal, bF2F );
+ if (bRC == true)
+ {
+ // Does the given field ID exist as part of this entity?
+ if (fields.find( conID ) == fields.end())
+ {
+ std::ostringstream tmp;
+ tmp << "DB [" << DB2_TABLE_PROTOCOL_STRUCT
+ << "] Invalid optional specifier, struct ID " << frag.mStructID
+ << ", unknown field ID " << conID << "/" << frag.mpModifierValue;
+
+ mpLog->Log( tmp.str(), eDB2_STATUS_ERROR );
+
+ bRC = false;
+ }
+
+ if (bF2F == true)
+ {
+ // Does the given field ID exist as part of this entity?
+ if (fields.find( (ULONG)conVal ) == fields.end())
+ {
+ std::ostringstream tmp;
+ tmp << "DB [" << DB2_TABLE_PROTOCOL_STRUCT
+ << "] Invalid optional specifier, struct ID " << frag.mStructID
+ << ", unknown field ID " << (ULONG)conVal
+ << "/" << frag.mpModifierValue;
+
+ mpLog->Log( tmp.str(), eDB2_STATUS_ERROR );
+
+ bRC = false;
+ }
+ }
+ }
+ else
+ {
+ std::ostringstream tmp;
+ tmp << "DB [" << DB2_TABLE_PROTOCOL_STRUCT
+ << "] Invalid optional specifier, struct ID " << frag.mStructID
+ << ", " << frag.mpModifierValue;
+
+ mpLog->Log( tmp.str(), eDB2_STATUS_ERROR );
+ }
+
+ return bRC;
+}
+
+/*===========================================================================
+METHOD:
+ ValidateExpressionSpecifier (Internal Method)
+
+DESCRIPTION:
+ Validate a simple expression fragment specifier
+
+PARAMETERS:
+ frag [ I ] - Fragment containing expression fragment specifier
+ fields [ I ] - List of 'known' field IDs
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cCoreDatabase::ValidateExpressionSpecifier(
+ const sDB2Fragment & frag,
+ const std::set <ULONG> & fields )
+{
+ // Assume success
+ bool bRC = true;
+
+ ASSERT( frag.mModifierType == eDB2_MOD_VARIABLE_ARRAY3 );
+
+ // Even an expression specifier to start with?
+ if (frag.mpModifierValue == 0 || frag.mpModifierValue == EMPTY_STRING)
+ {
+ std::ostringstream tmp;
+ tmp << "DB [" << DB2_TABLE_PROTOCOL_STRUCT
+ << "] Missing array specifier, struct ID " << frag.mStructID;
+
+ mpLog->Log( tmp.str(), eDB2_STATUS_ERROR );
+
+ return false;
+ }
+
+ ULONG exprID;
+ eDB2ExpOperator exprOp;
+ LONGLONG exprVal;
+ bool bF2F;
+
+ // Parse expression
+ LPCSTR pExpr = frag.mpModifierValue;
+ bRC = sDB2Fragment::ParseExpression( pExpr, exprID, exprOp, exprVal, bF2F );
+ if (bRC == true)
+ {
+ // Does the given field ID exist as part of this entity?
+ if (fields.find( exprID ) == fields.end())
+ {
+ std::ostringstream tmp;
+ tmp << "DB [" << DB2_TABLE_PROTOCOL_STRUCT
+ << "] Invalid optional specifier, struct ID " << frag.mStructID
+ << ", unknown field ID " << exprID
+ << "/" << frag.mpModifierValue;
+
+ mpLog->Log( tmp.str(), eDB2_STATUS_ERROR );
+
+ bRC = false;
+ }
+
+ if (bF2F == true)
+ {
+ // Does the given field ID exist as part of this entity?
+ if (fields.find( (ULONG)exprVal ) == fields.end())
+ {
+ std::ostringstream tmp;
+ tmp << "DB [" << DB2_TABLE_PROTOCOL_STRUCT
+ << "] Invalid optional specifier, struct ID " << frag.mStructID
+ << ", unknown field ID " << (ULONG)exprID
+ << "/" << frag.mpModifierValue;
+
+ mpLog->Log( tmp.str(), eDB2_STATUS_ERROR );
+
+ bRC = false;
+ }
+ }
+ }
+ else
+ {
+ std::ostringstream tmp;
+ tmp << "DB [" << DB2_TABLE_PROTOCOL_STRUCT
+ << "] Invalid optional specifier, struct ID " << frag.mStructID
+ << ", " << frag.mpModifierValue;
+
+ mpLog->Log( tmp.str(), eDB2_STATUS_ERROR );
+ }
+
+ return bRC;
+}
+
diff --git a/gobi-api/GobiAPI_1.0.40/Core/CoreDatabase.h b/gobi-api/GobiAPI_1.0.40/Core/CoreDatabase.h
new file mode 100755
index 0000000..c4c47e2
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/CoreDatabase.h
@@ -0,0 +1,2127 @@
+/*===========================================================================
+FILE:
+ CoreDatabase.h
+
+DESCRIPTION:
+ Declaration of cCoreDatabase class
+
+PUBLIC CLASSES AND METHODS:
+ cCoreDatabase
+ This class represents the run-time (read only) version of the
+ core library database
+
+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 <list>
+#include <map>
+#include <set>
+#include <vector>
+
+#include "DB2TextFile.h"
+
+//---------------------------------------------------------------------------
+// Forward Declarations
+//---------------------------------------------------------------------------
+class cDB2NavTree;
+
+//---------------------------------------------------------------------------
+// Prototypes
+//---------------------------------------------------------------------------
+
+// Convert a string (in quotes) to a string (minus) quotes and copy into
+// an allocated buffer
+LPCSTR CopyQuotedString( LPSTR pString );
+
+//---------------------------------------------------------------------------
+// Definitions
+//---------------------------------------------------------------------------
+
+// An empty (but not NULL) string
+extern LPCSTR EMPTY_STRING;
+
+// Value seperator for database text
+extern LPCSTR DB2_VALUE_SEP;
+
+// Sub-value (i.e. within a particular value) seperator for database text
+extern LPCSTR DB2_SUBVAL_SEP;
+
+// Database table file names
+extern LPCSTR DB2_FILE_PROTOCOL_FIELD;
+extern LPCSTR DB2_FILE_PROTOCOL_STRUCT;
+extern LPCSTR DB2_FILE_PROTOCOL_ENTITY;
+extern LPCSTR DB2_FILE_ENUM_MAIN;
+extern LPCSTR DB2_FILE_ENUM_ENTRY;
+
+// Database start pointers
+extern const int _binary_QMI_Field_txt_start;
+extern const int _binary_QMI_Struct_txt_start;
+extern const int _binary_QMI_Entity_txt_start;
+extern const int _binary_QMI_Enum_txt_start;
+extern const int _binary_QMI_EnumEntry_txt_start;
+
+// Database end pointers
+extern const int _binary_QMI_Field_txt_end;
+extern const int _binary_QMI_Struct_txt_end;
+extern const int _binary_QMI_Entity_txt_end;
+extern const int _binary_QMI_Enum_txt_end;
+extern const int _binary_QMI_EnumEntry_txt_end;
+
+
+// Status levels for DB2 logging
+enum eDB2StatusLevel
+{
+ eDB2_STATUS_BEGIN = -1,
+
+ eDB2_STATUS_INFO, // Informational string
+ eDB2_STATUS_WARNING, // Warning string
+ eDB2_STATUS_ERROR, // Error string
+
+ eDB2_STATUS_END
+};
+
+/*===========================================================================
+METHOD:
+ IsValid (Inline Method)
+
+DESCRIPTION:
+ eDB2StatusLevel validity check
+
+PARAMETERS:
+ lvl [ I ] - Enum value being verified
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+inline bool IsValid( eDB2StatusLevel lvl )
+{
+ bool retVal = false;
+ if (lvl > eDB2_STATUS_BEGIN && lvl < eDB2_STATUS_END)
+ {
+ retVal = true;
+ }
+
+ return retVal;
+};
+
+/*=========================================================================*/
+// Class cDB2StatusLog
+//
+// Class that defines status logging interface for DB2 initialization
+// and exit related information
+/*=========================================================================*/
+class cDB2StatusLog
+{
+ public:
+ // Log an error string
+ virtual void Log(
+ LPCSTR pLog,
+ eDB2StatusLevel lvl = eDB2_STATUS_ERROR ) = 0;
+
+ // Log an error string
+ virtual void Log(
+ const std::string & log,
+ eDB2StatusLevel lvl = eDB2_STATUS_ERROR ) = 0;
+};
+
+/*=========================================================================*/
+// Class cDB2TraceLog
+// Default error logging interface for DB2 initialization and exit
+// related information - sends output to TRACE
+/*=========================================================================*/
+class cDB2TraceLog : public cDB2StatusLog
+{
+ public:
+ // (Inline) Constructor
+ cDB2TraceLog() { };
+
+ // (Inline) Destructor
+ ~cDB2TraceLog() { };
+
+
+ // (Inline) Log an error string
+ virtual void Log(
+ LPCSTR pLog,
+ eDB2StatusLevel lvl = eDB2_STATUS_ERROR )
+ {
+ if (pLog != 0 && pLog[0] != 0)
+ {
+ std::string formatString = "[0x%02X] ";
+ formatString += pLog;
+ formatString += '\n';
+
+ //Note: TRACE is just an alias for printf if DEBUG is used
+ TRACE( formatString.c_str(), lvl );
+ }
+ };
+
+ // (Inline) Log an error string
+ virtual void Log(
+ const std::string & log,
+ eDB2StatusLevel lvl = eDB2_STATUS_ERROR )
+ {
+ if (log.size() > 0)
+ {
+ Log( log.c_str(), lvl );
+ }
+ };
+
+};
+
+// The default logger (for backwards compatibility)
+extern cDB2TraceLog gDB2DefaultLog;
+
+
+/*===========================================================================
+METHOD:
+ LoadDB2Table (Free Public Method)
+
+DESCRIPTION:
+ Load a database table
+
+PARAMETERS:
+ pFile [ I ] - The file to load the table from
+ cont [I/0] - The current/resulting database table
+ bDuplicatesOK [ I ] - Duplicate keys acceptable?
+ pName [ I ] - Name (for error reporting)
+ log [I/O] - Where to log errors
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+template <class Container>
+bool LoadDB2Table(
+ LPCSTR pFile,
+ Container & cont,
+ bool bDuplicatesOK = false,
+ LPCSTR pName = 0,
+ cDB2StatusLog & log = gDB2DefaultLog )
+{
+ // Assume success
+ bool bRC = true;
+ // Sanity check error reporting name
+ if (pName == 0 || pName[0] == 0)
+ {
+ pName = "?";
+ }
+
+ // Sanity check file name
+ if (pFile == 0 || pFile[0] == 0)
+ {
+ // Bad file
+ std::ostringstream tmp;
+ tmp << "DB [" << pName << "] Invalid file name";
+
+
+ log.Log( tmp.str(), eDB2_STATUS_ERROR );
+
+ return false;
+ }
+
+ ULONG lineNum = 0;
+
+ // Attempt to open the file
+ cDB2TextFile inFile( pFile );
+ if (inFile.IsValid() == true)
+ {
+ std::string line;
+ while (inFile.ReadLine( line ) == true)
+ {
+ std::string lineCopy = line;
+
+ int nLineSize = lineCopy.size();
+ LPSTR pLine = new CHAR[ nLineSize + 1 ];
+ if (pLine == NULL)
+ {
+ return false;
+ }
+
+ memcpy( pLine, line.c_str(), nLineSize );
+
+ // Enforce null terminator
+ pLine[ nLineSize ] = 0;
+
+ typename Container::mapped_type theType;
+ bool bOK = theType.FromString( pLine );
+ if (bOK == true)
+ {
+ // Grab key
+ typename Container::key_type theKey = theType.GetKey();
+
+ // Key already exists?
+ typename Container::iterator pIter;
+ pIter = cont.find( theKey );
+
+ if (pIter != cont.end() && bDuplicatesOK == false)
+ {
+ // The key already exists which indicates a (recoverable) error
+ std::ostringstream tmp;
+ tmp << "DB [" << pName << "] Duplicate key, line "
+ << lineNum << " (" << line.c_str() << ")";
+
+ log.Log( tmp.str(), eDB2_STATUS_WARNING );
+
+ // Free the current object
+ pIter->second.FreeAllocatedStrings();
+
+ // ... and then replace it
+ pIter->second = theType;
+ }
+ else
+ {
+ typename Container::value_type entry( theKey, theType );
+ cont.insert( entry );
+ }
+ }
+ else if (lineCopy.size() > 0)
+ {
+ // Error parsing line
+ std::ostringstream tmp;
+ tmp << "DB [" << pName << "] Parsing error, line "
+ << lineNum << " (" << line.c_str() << ")";
+
+ log.Log( tmp.str(), eDB2_STATUS_ERROR );
+
+ theType.FreeAllocatedStrings();
+ bRC = false;
+ }
+ delete [] pLine;
+ lineNum++;
+ }
+ }
+ else
+ {
+#ifdef DEBUG
+ // Could not open the file
+ std::ostringstream tmp;
+ tmp << "DB [" << pName << "] Error opening file";
+
+ log.Log( tmp.str(), eDB2_STATUS_WARNING );
+#endif
+
+ bRC = false;
+ }
+
+ return bRC;
+};
+
+/*===========================================================================
+METHOD:
+ LoadDB2Table (Free Public Method)
+
+DESCRIPTION:
+ Load a database table
+
+PARAMETERS:
+ pStart [ I ] - Start location of database
+ nSize [ I ] - Size of database
+ cont [I/0] - The current/resulting database table
+ bDuplicatesOK [ I ] - Duplicate keys acceptable?
+ pName [ I ] - Name (for error reporting)
+ log [I/O] - Where to log errors
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+template <class Container>
+bool LoadDB2Table(
+ const char * pStart,
+ const int nSize,
+ Container & cont,
+ bool bDuplicatesOK = false,
+ LPCSTR pName = 0,
+ cDB2StatusLog & log = gDB2DefaultLog )
+{
+ // Assume success
+ bool bRC = true;
+
+ // Sanity check error reporting name
+ if (pName == 0 || pName[0] == 0)
+ {
+ pName = "?";
+ }
+
+ ULONG lineNum = 0;
+
+ // Attempt to open the file
+ cDB2TextFile inFile( pStart, nSize );
+ if (inFile.IsValid() == true)
+ {
+ std::string line;
+ while (inFile.ReadLine( line ) == true)
+ {
+ std::string lineCopy = line;
+
+ int nLineSize = lineCopy.size();
+ LPSTR pLine = new CHAR[ nLineSize + 1 ];
+ if (pLine == NULL)
+ {
+ return false;
+ }
+
+ memcpy( pLine, lineCopy.c_str(), nLineSize );
+
+ // Enforce null terminator
+ pLine[ nLineSize ] = 0;
+
+ typename Container::mapped_type theType;
+ bool bOK = theType.FromString( pLine );
+ if (bOK == true)
+ {
+ // Grab key
+ typename Container::key_type theKey = theType.GetKey();
+
+ // Key already exists?
+ typename Container::iterator pIter;
+ pIter = cont.find( theKey );
+
+ if (pIter != cont.end() && bDuplicatesOK == false)
+ {
+ // The key already exists which indicates a (recoverable) error
+ std::ostringstream tmp;
+ tmp << "DB [" << pName << "] Duplicate key, line "
+ << lineNum << " (" << line.c_str() << ")";
+
+ log.Log( tmp.str(), eDB2_STATUS_WARNING );
+
+ // Free the current object
+ pIter->second.FreeAllocatedStrings();
+
+ // ... and then replace it
+ pIter->second = theType;
+ }
+ else
+ {
+ typename Container::value_type entry( theKey, theType );
+ cont.insert( entry );
+ }
+ }
+ else if (lineCopy.size() > 0)
+ {
+ // Error parsing line
+ std::ostringstream tmp;
+ tmp << "DB [" << pName << "] Parsing error, line "
+ << lineNum << " (" << line.c_str() << ")";
+
+ log.Log( tmp.str(), eDB2_STATUS_ERROR );
+
+ theType.FreeAllocatedStrings();
+ bRC = false;
+ }
+
+ delete [] pLine;
+ lineNum++;
+ }
+ }
+ else
+ {
+#ifdef DEBUG
+ // Could not open the file
+ std::ostringstream tmp;
+ tmp << "DB [" << pName << "] Error opening file";
+
+ log.Log( tmp.str(), eDB2_STATUS_WARNING );
+#endif
+
+ bRC = false;
+ }
+
+ return bRC;
+};
+
+/*===========================================================================
+METHOD:
+ FreeDB2Table (Free Public Method)
+
+DESCRIPTION:
+ Free up the string allocations in a database table, emptying the
+ table in the process
+
+PARAMETERS:
+ cont [ I ] - The database table
+
+RETURN VALUE:
+ None
+===========================================================================*/
+template <class Container>
+void FreeDB2Table( Container & cont )
+{
+ typename Container::iterator pIter = cont.begin();
+ while (pIter != cont.end())
+ {
+ typename Container::mapped_type & theType = pIter->second;
+ theType.FreeAllocatedStrings();
+
+ pIter++;
+ }
+
+ cont.clear();
+};
+
+/*=========================================================================*/
+// eDB2EntityType Enumeration
+//
+// Database protocol entity header/payload type enumeration
+/*=========================================================================*/
+enum eDB2EntityType
+{
+ eDB2_ET_ENUM_BEGIN = -1,
+
+ eDB2_ET_DIAG_REQ, // 0 Synchronous request
+ eDB2_ET_DIAG_RSP, // 1 Synchronous response
+ eDB2_ET_DIAG_SUBSYS_REQ, // 2 Synchronous subsystem dispatch request
+ eDB2_ET_DIAG_SUBSYS_RSP, // 3 Synchronous subsystem dispatch response
+ eDB2_ET_DIAG_EVENT, // 4 Asynchronous event
+ eDB2_ET_DIAG_LOG, // 5 Asynchronous log
+ eDB2_ET_DIAG_NV_ITEM, // 6 NVRAM item read/write
+ eDB2_ET_RESERVED7, // 7 Reserved
+ eDB2_ET_RESERVED8, // 8 Reserved
+ eDB2_ET_DIAG_SUBSYS2_REQ, // 9 Sync subsystem V2 dispatch request
+ eDB2_ET_DIAG_SUBSYS2_RSP, // 10 Sync subsystem V2 dispatch response
+ eDB2_ET_DIAG_SUBSYS2_ASYNC, // 11 Async subsystem V2 dispatch response
+
+ eDB2_ET_QMI_BEGIN = 29, // 29 Start of QMI section
+
+ eDB2_ET_QMI_CTL_REQ, // 30 QMI CTL request
+ eDB2_ET_QMI_CTL_RSP, // 31 QMI CTL response
+ eDB2_ET_QMI_CTL_IND, // 32 QMI CTL indication
+ eDB2_ET_QMI_WDS_REQ, // 33 QMI WDS request
+ eDB2_ET_QMI_WDS_RSP, // 34 QMI WDS response
+ eDB2_ET_QMI_WDS_IND, // 35 QMI WDS indication
+ eDB2_ET_QMI_DMS_REQ, // 36 QMI DMS request
+ eDB2_ET_QMI_DMS_RSP, // 37 QMI DMS response
+ eDB2_ET_QMI_DMS_IND, // 38 QMI DMS indication
+ eDB2_ET_QMI_NAS_REQ, // 39 QMI NAS request
+ eDB2_ET_QMI_NAS_RSP, // 40 QMI NAS response
+ eDB2_ET_QMI_NAS_IND, // 41 QMI NAS indication
+ eDB2_ET_QMI_QOS_REQ, // 42 QMI QOS request
+ eDB2_ET_QMI_QOS_RSP, // 43 QMI QOS response
+ eDB2_ET_QMI_QOS_IND, // 44 QMI QOS indication
+ eDB2_ET_QMI_WMS_REQ, // 45 QMI WMS request
+ eDB2_ET_QMI_WMS_RSP, // 46 QMI WMS response
+ eDB2_ET_QMI_WMS_IND, // 47 QMI WMS indication
+ eDB2_ET_QMI_PDS_REQ, // 48 QMI PDS request
+ eDB2_ET_QMI_PDS_RSP, // 49 QMI PDS response
+ eDB2_ET_QMI_PDS_IND, // 50 QMI PDS indication
+ eDB2_ET_QMI_AUTH_REQ, // 51 QMI AUTH request
+ eDB2_ET_QMI_AUTH_RSP, // 52 QMI AUTH response
+ eDB2_ET_QMI_AUTH_IND, // 53 QMI AUTH indication
+ eDB2_ET_QMI_CAT_REQ, // 54 QMI CAT request
+ eDB2_ET_QMI_CAT_RSP, // 55 QMI CAT response
+ eDB2_ET_QMI_CAT_IND, // 56 QMI CAT indication
+ eDB2_ET_QMI_RMS_REQ, // 57 QMI RMS request
+ eDB2_ET_QMI_RMS_RSP, // 58 QMI RMS response
+ eDB2_ET_QMI_RMS_IND, // 59 QMI RMS indication
+ eDB2_ET_QMI_OMA_REQ, // 60 QMI OMA request
+ eDB2_ET_QMI_OMA_RSP, // 61 QMI OMA response
+ eDB2_ET_QMI_OMA_IND, // 62 QMI OMA indication
+ eDB2_ET_QMI_VOICE_REQ, // 63 QMI voice request
+ eDB2_ET_QMI_VOICE_RSP, // 64 QMI voice response
+ eDB2_ET_QMI_VOICE_IND, // 65 QMI voice indication
+
+ eDB2_ET_QMI_END, // 63 End of QMI section
+
+ eDB2_ET_ENUM_END
+
+};
+
+/*===========================================================================
+METHOD:
+ IsValid (Inline Method)
+
+DESCRIPTION:
+ eDB2EntityType validity check
+
+PARAMETERS:
+ et [ I ] - Enum value being verified
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+inline bool IsValid( eDB2EntityType et )
+{
+ bool retVal = false;
+ if ( (et > eDB2_ET_ENUM_BEGIN && et <= eDB2_ET_DIAG_SUBSYS2_ASYNC)
+ || (et > eDB2_ET_QMI_BEGIN && et < eDB2_ET_QMI_END) )
+
+ {
+ retVal = true;
+ }
+
+ return retVal;
+};
+
+/*===========================================================================
+METHOD:
+ IsDiagEntityType (Inline Method)
+
+DESCRIPTION:
+ Does the eDB2EntityType value represent the DIAG protocol?
+
+PARAMETERS:
+ entityType [ I ] - Enum value being verified
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+inline bool IsDiagEntityType( eDB2EntityType entityType )
+{
+ bool retVal = false;
+ if (entityType == eDB2_ET_DIAG_REQ
+ || entityType == eDB2_ET_DIAG_RSP
+ || entityType == eDB2_ET_DIAG_SUBSYS_REQ
+ || entityType == eDB2_ET_DIAG_SUBSYS_RSP
+ || entityType == eDB2_ET_DIAG_EVENT
+ || entityType == eDB2_ET_DIAG_LOG
+ || entityType == eDB2_ET_DIAG_NV_ITEM
+ || entityType == eDB2_ET_DIAG_SUBSYS2_REQ
+ || entityType == eDB2_ET_DIAG_SUBSYS2_RSP
+ || entityType == eDB2_ET_DIAG_SUBSYS2_ASYNC)
+ {
+ retVal = true;
+ }
+
+ return retVal;
+};
+
+/*===========================================================================
+METHOD:
+ IsDiagEntityRequestType (Inline Method)
+
+DESCRIPTION:
+ Does the eDB2EntityType value represent the DIAG protocol and if so
+ does it represent a request?
+
+PARAMETERS:
+ entityType [ I ] - Enum value being verified
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+inline bool IsDiagEntityRequestType( eDB2EntityType entityType )
+{
+ bool retVal = false;
+ if (entityType == eDB2_ET_DIAG_REQ
+ || entityType == eDB2_ET_DIAG_SUBSYS_REQ
+ || entityType == eDB2_ET_DIAG_SUBSYS2_REQ)
+ {
+ retVal = true;
+ }
+
+ return retVal;
+};
+
+/*===========================================================================
+METHOD:
+ IsDiagEntityResponseType (Inline Method)
+
+DESCRIPTION:
+ Does the eDB2EntityType value represent the DIAG protocol and if so
+ does it represent a response?
+
+PARAMETERS:
+ entityType [ I ] - Enum value being verified
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+inline bool IsDiagEntityResponseType( eDB2EntityType entityType )
+{
+ bool retVal = false;
+ if (entityType == eDB2_ET_DIAG_RSP
+ || entityType == eDB2_ET_DIAG_SUBSYS_RSP
+ || entityType == eDB2_ET_DIAG_SUBSYS2_RSP)
+ {
+ retVal = true;
+ }
+
+ return retVal;
+};
+
+/*===========================================================================
+METHOD:
+ IsDiagEntityAsyncType (Inline Method)
+
+DESCRIPTION:
+ Does the eDB2EntityType value represent the DIAG protocol and if so
+ does it represent asynchronous incoming data?
+
+PARAMETERS:
+ entityType [ I ] - Enum value being verified
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+inline bool IsDiagEntityAsyncType( eDB2EntityType entityType )
+{
+ bool retVal = false;
+ if (entityType == eDB2_ET_DIAG_EVENT
+ || entityType == eDB2_ET_DIAG_LOG
+ || entityType == eDB2_ET_DIAG_SUBSYS2_ASYNC)
+ {
+ retVal = true;
+ }
+
+ return retVal;
+};
+
+/*===========================================================================
+METHOD:
+ IsQMIEntityType (Inline Method)
+
+DESCRIPTION:
+ Does the eDB2EntityType value represent the QMI protocol?
+
+PARAMETERS:
+ et [ I ] - Enum value being verified
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+inline bool IsQMIEntityType( eDB2EntityType et )
+{
+ bool retVal = false;
+ if (et > eDB2_ET_QMI_BEGIN && et < eDB2_ET_QMI_END)
+ {
+ retVal = true;
+ }
+
+ return retVal;
+};
+
+/*===========================================================================
+METHOD:
+ IsQMIEntityRequestType (Inline Method)
+
+DESCRIPTION:
+ Does the eDB2EntityType value represent the QMI protocol and if so
+ does it represent a request?
+
+PARAMETERS:
+ entityType [ I ] - Enum value being verified
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+inline bool IsQMIEntityRequestType( eDB2EntityType entityType )
+{
+ bool retVal = false;
+
+ // One QMI service is always a triplet of REQ/RSP/IND
+ DWORD baseVal = (DWORD)eDB2_ET_QMI_BEGIN + 1;
+ if ((DWORD)entityType % baseVal == 0)
+ {
+ retVal = true;
+ }
+
+ return retVal;
+};
+
+/*===========================================================================
+METHOD:
+ IsQMIEntityResponseType (Inline Method)
+
+DESCRIPTION:
+ Does the eDB2EntityType value represent the QMI protocol and if so
+ does it represent a response?
+
+PARAMETERS:
+ entityType [ I ] - Enum value being verified
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+inline bool IsQMIEntityResponseType( eDB2EntityType entityType )
+{
+ bool retVal = false;
+
+ // One QMI service is always a triplet of REQ/RSP/IND
+ DWORD baseVal = (DWORD)eDB2_ET_QMI_BEGIN + 1;
+ if ((DWORD)entityType % baseVal == 1)
+ {
+ retVal = true;
+ }
+
+ return retVal;
+};
+
+/*===========================================================================
+METHOD:
+ IsQMIEntityIndicationType (Inline Method)
+
+DESCRIPTION:
+ Does the eDB2EntityType value represent the QMI protocol and if so
+ does it represent an indication?
+
+PARAMETERS:
+ entityType [ I ] - Enum value being verified
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+inline bool IsQMIEntityIndicationType( eDB2EntityType entityType )
+{
+ bool retVal = false;
+
+ // One QMI service is always a triplet of REQ/RSP/IND
+ DWORD baseVal = (DWORD)eDB2_ET_QMI_BEGIN + 1;
+ if ((DWORD)entityType % baseVal == 2)
+ {
+ retVal = true;
+ }
+
+ return retVal;
+};
+
+/*=========================================================================*/
+// eDB2FragmentType Enumeration
+//
+// Database fragment type enumeration - determines in what table
+// (or manner) the fragment is described
+/*=========================================================================*/
+enum eDB2FragmentType
+{
+ eDB2_FRAGMENT_TYPE_ENUM_BEGIN = -1,
+
+ eDB2_FRAGMENT_FIELD, // 0 Simple field fragment
+ eDB2_FRAGMENT_STRUCT, // 1 Structure fragment
+ eDB2_FRAGMENT_CONSTANT_PAD, // 2 Pad fragment, fixed length (bits)
+ eDB2_FRAGMENT_VARIABLE_PAD_BITS, // 3 Pad fragment, variable (bits)
+ eDB2_FRAGMENT_VARIABLE_PAD_BYTES, // 4 Pad fragment, variable (bytes)
+ eDB2_FRAGMENT_FULL_BYTE_PAD, // 5 Pad fragment, pad to a full byte
+ eDB2_FRAGMENT_MSB_2_LSB, // 6 Switch to MSB -> LSB order
+ eDB2_FRAGMENT_LSB_2_MSB, // 7 Switch to LSB -> MSB order
+
+ eDB2_FRAGMENT_TYPE_ENUM_END
+};
+
+/*===========================================================================
+METHOD:
+ IsValid (Inline Method)
+
+DESCRIPTION:
+ eDB2FragmentType validity check
+
+PARAMETERS:
+ fragType [ I ] - Enum value being verified
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+inline bool IsValid( eDB2FragmentType fragType )
+{
+ bool retVal = false;
+ if (fragType > eDB2_FRAGMENT_TYPE_ENUM_BEGIN
+ && fragType < eDB2_FRAGMENT_TYPE_ENUM_END)
+ {
+ retVal = true;
+ }
+
+ return retVal;
+};
+
+/*=========================================================================*/
+// eDB2ModifierType Enumeration
+//
+// Database fragment modifier type enumeration - determines how a
+// fragment is modified/used
+/*=========================================================================*/
+enum eDB2ModifierType
+{
+ eDB2_MOD_TYPE_ENUM_BEGIN = -1,
+
+ eDB2_MOD_NONE, // 0 Modifier is not used
+ eDB2_MOD_CONSTANT_ARRAY, // 1 Constant (elements) array
+ eDB2_MOD_VARIABLE_ARRAY, // 2 Variable (elements) array
+ eDB2_MOD_OBSOLETE_3, // 3 Constant (bits) array [OBS]
+ eDB2_MOD_OBSOLETE_4, // 4 Variable (bits) array [OBS]
+ eDB2_MOD_OPTIONAL, // 5 Fragment is optional
+ eDB2_MOD_VARIABLE_ARRAY2, // 6 Variable (elements) array, start/stop given
+ eDB2_MOD_VARIABLE_ARRAY3, // 7 Variable (elements) array, simple expression
+ eDB2_MOD_VARIABLE_STRING1, // 8 Variable length string (bit length)
+ eDB2_MOD_VARIABLE_STRING2, // 9 Variable length string (byte length)
+ eDB2_MOD_VARIABLE_STRING3, // 10 Variable length string (character length)
+
+ eDB2_MOD_TYPE_ENUM_END
+};
+
+/*===========================================================================
+METHOD:
+ ModifiedToArray (Inline Method)
+
+DESCRIPTION:
+ Does this modifier indicate an array?
+
+PARAMETERS:
+ modType [ I ] - Enum value being verified
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+inline bool ModifiedToArray( eDB2ModifierType modType )
+{
+ bool bRC = false;
+ if ( (modType == eDB2_MOD_CONSTANT_ARRAY)
+ || (modType == eDB2_MOD_VARIABLE_ARRAY)
+ || (modType == eDB2_MOD_VARIABLE_ARRAY2)
+ || (modType == eDB2_MOD_VARIABLE_ARRAY3) )
+ {
+ bRC = true;
+ }
+
+ return bRC;
+};
+
+/*===========================================================================
+METHOD:
+ IsValid (Inline Method)
+
+DESCRIPTION:
+ eDB2ModifierType validity check
+
+PARAMETERS:
+ modType [ I ] - Enum value being verified
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+inline bool IsValid( eDB2ModifierType modType )
+{
+ bool retVal = false;
+ if (modType > eDB2_MOD_TYPE_ENUM_BEGIN
+ && modType < eDB2_MOD_TYPE_ENUM_END)
+ {
+ retVal = true;
+ }
+
+ return retVal;
+};
+
+/*=========================================================================*/
+// eDB2FieldType Enumeration
+//
+// Database field type enumeration - determines whether the field in
+// question is a standard type or an enumeration
+/*=========================================================================*/
+enum eDB2FieldType
+{
+ eDB2_FIELD_TYPE_ENUM_BEGIN = -1,
+
+ eDB2_FIELD_STD, // 0 Field is a standard type (see below)
+ eDB2_FIELD_ENUM_UNSIGNED, // 1 Field is an unsigned enumerated type
+ eDB2_FIELD_ENUM_SIGNED, // 2 Field is a signed enumerated type
+
+ eDB2_FIELD_TYPE_ENUM_END
+};
+
+/*===========================================================================
+METHOD:
+ IsValid (Inline Method)
+
+DESCRIPTION:
+ eDB2FieldType validity check
+
+PARAMETERS:
+ fieldType [ I ] - Enum value being verified
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+inline bool IsValid( eDB2FieldType fieldType )
+{
+ bool retVal = false;
+ if (fieldType > eDB2_FIELD_TYPE_ENUM_BEGIN
+ && fieldType < eDB2_FIELD_TYPE_ENUM_END)
+ {
+ retVal = true;
+ }
+
+ return retVal;
+};
+
+/*=========================================================================*/
+// eDB2StdFieldType Enumeration
+//
+// Database standard field type enumeration
+/*=========================================================================*/
+enum eDB2StdFieldType
+{
+ eDB2_FIELD_STDTYPE_ENUM_BEGIN = -1,
+
+ eDB2_FIELD_STDTYPE_BOOL, // 0 Field is a boolean (0/1, false/true)
+ eDB2_FIELD_STDTYPE_INT8, // 1 Field is 8-bit signed integer
+ eDB2_FIELD_STDTYPE_UINT8, // 2 Field is 8-bit unsigned integer
+ eDB2_FIELD_STDTYPE_INT16, // 3 Field is 16-bit signed integer
+ eDB2_FIELD_STDTYPE_UINT16, // 4 Field is 16-bit unsigned integer
+ eDB2_FIELD_STDTYPE_INT32, // 5 Field is 32-bit signed integer
+ eDB2_FIELD_STDTYPE_UINT32, // 6 Field is 32-bit unsigned integer
+ eDB2_FIELD_STDTYPE_INT64, // 7 Field is 64-bit signed integer
+ eDB2_FIELD_STDTYPE_UINT64, // 8 Field is 64-bit unsigned integer
+ eDB2_FIELD_STDTYPE_STRING_A, // 9 ANSI fixed length string
+ eDB2_FIELD_STDTYPE_STRING_U, // 10 UNICODE fixed length string
+ eDB2_FIELD_STDTYPE_STRING_ANT, // 11 ANSI NULL terminated string
+ eDB2_FIELD_STDTYPE_STRING_UNT, // 12 UNICODE NULL terminated string
+ eDB2_FIELD_STDTYPE_FLOAT32, // 13 Field is 32-bit floating point value
+ eDB2_FIELD_STDTYPE_FLOAT64, // 14 Field is 64-bit floating point value
+ eDB2_FIELD_STDTYPE_STRING_U8, // 15 UTF-8 encoded fixed length string
+ eDB2_FIELD_STDTYPE_STRING_U8NT, // 16 UTF-8 encoded NULL terminated string
+
+ eDB2_FIELD_STDTYPE_ENUM_END
+};
+
+/*===========================================================================
+METHOD:
+ IsValid (Inline Method)
+
+DESCRIPTION:
+ eDB2StdFieldType validity check
+
+PARAMETERS:
+ fieldType [ I ] - Enum value being verified
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+inline bool IsValid( eDB2StdFieldType fieldType )
+{
+ bool retVal = false;
+ if (fieldType > eDB2_FIELD_STDTYPE_ENUM_BEGIN
+ && fieldType < eDB2_FIELD_STDTYPE_ENUM_END)
+ {
+ retVal = true;
+ }
+
+ return retVal;
+};
+
+/*=========================================================================*/
+// eDB2Operator Enumeration
+//
+// Database conditional fragment operator type enumeration
+/*=========================================================================*/
+enum eDB2Operator
+{
+ eDB2_OP_TYPE_ENUM_BEGIN = -1,
+
+ eDB2_OP_LT,
+ eDB2_OP_LTE,
+ eDB2_OP_EQ,
+ eDB2_OP_NEQ,
+ eDB2_OP_GTE,
+ eDB2_OP_GT,
+ eDB2_OP_DIV,
+ eDB2_OP_NDIV,
+
+ eDB2_OP_TYPE_ENUM_END
+};
+
+/*===========================================================================
+METHOD:
+ IsValid (Inline Method)
+
+DESCRIPTION:
+ eDB2Operator validity check
+
+PARAMETERS:
+ op [ I ] - Enum value being verified
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+inline bool IsValid( eDB2Operator op )
+{
+ bool retVal = false;
+ if (op > eDB2_OP_TYPE_ENUM_BEGIN
+ && op < eDB2_OP_TYPE_ENUM_END)
+ {
+ retVal = true;
+ }
+
+ return retVal;
+};
+
+/*=========================================================================*/
+// eDB2ExpOperator Enumeration
+//
+// Database simple expression operator type enumeration
+/*=========================================================================*/
+enum eDB2ExpOperator
+{
+ eDB2_EXPOP_TYPE_ENUM_BEGIN = -1,
+
+ eDB2_EXPOP_ADD,
+ eDB2_EXPOP_SUB,
+ eDB2_EXPOP_MUL,
+ eDB2_EXPOP_DIV,
+ eDB2_EXPOP_REM,
+ eDB2_EXPOP_MIN,
+ eDB2_EXPOP_MAX,
+
+ eDB2_EXPOP_TYPE_ENUM_END
+};
+
+/*===========================================================================
+METHOD:
+ IsValid (Inline Method)
+
+DESCRIPTION:
+ eDB2ExpOperator validity check
+
+PARAMETERS:
+ op [ I ] - Enum value being verified
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+inline bool IsValid( eDB2ExpOperator op )
+{
+ bool retVal = false;
+ if (op > eDB2_EXPOP_TYPE_ENUM_BEGIN
+ && op < eDB2_EXPOP_TYPE_ENUM_END)
+ {
+ retVal = true;
+ }
+
+ return retVal;
+};
+
+/*=========================================================================*/
+// Struct sDB2ProtocolEntity
+//
+// Structure that defines the schema for the protocol entity table
+/*=========================================================================*/
+struct sDB2ProtocolEntity
+{
+ public:
+ // (Inline) Default constructor
+ sDB2ProtocolEntity()
+ : mType( eDB2_ET_ENUM_BEGIN ),
+ mStructID( -1 ),
+ mFormatID( -1 ),
+ mbInternal( false ),
+ mFormatExID( -1 ),
+ mpName( EMPTY_STRING )
+ { };
+
+ // (Inline) Free up our allocated strings
+ void FreeAllocatedStrings()
+ {
+ if (mpName != 0 && mpName != EMPTY_STRING)
+ {
+ delete [] mpName;
+ mpName = 0;
+ }
+ };
+
+ // (Inline) Return object key
+ std::vector <ULONG> GetKey() const
+ {
+ return mID;
+ };
+
+ // Populate this object from a string
+ bool FromString( LPSTR pStr );
+
+ // Is this object valid?
+ bool IsValid() const;
+
+ /* Type of protocol entity 'header/payload' */
+ eDB2EntityType mType;
+
+ /* Multi-value ID (includes above type) */
+ std::vector <ULONG> mID;
+
+ /* Associated structure ID (-1 = no structure) */
+ int mStructID;
+
+ /* Associated format specifier (-1 = none) */
+ int mFormatID;
+
+ /* Is this protocol entity internal only? */
+ bool mbInternal;
+
+ /* Associated extended format specifier (-1 = none) */
+ int mFormatExID;
+
+ /* Name of protocol entity */
+ LPCSTR mpName;
+};
+
+/*=========================================================================*/
+// Struct sDB2Fragment
+//
+// Structure that defines the schema for the protocol structure table
+/*=========================================================================*/
+struct sDB2Fragment
+{
+ public:
+ // (Inline) Default constructor
+ sDB2Fragment()
+ : mStructID( 0 ),
+ mFragmentOrder( 0 ),
+ mFragmentOffset( 0 ),
+ mFragmentType( eDB2_FRAGMENT_TYPE_ENUM_BEGIN ),
+ mFragmentValue( 0 ),
+ mModifierType( eDB2_MOD_TYPE_ENUM_BEGIN ),
+ mpModifierValue( EMPTY_STRING ),
+ mpName( EMPTY_STRING )
+ { };
+
+ // (Inline) Free up our allocated strings
+ void FreeAllocatedStrings()
+ {
+ if (mpName != 0 && mpName != EMPTY_STRING)
+ {
+ delete [] mpName;
+ mpName = 0;
+ }
+
+ if (mpModifierValue != 0 && mpModifierValue != EMPTY_STRING)
+ {
+ delete [] mpModifierValue;
+ mpModifierValue = 0;
+ }
+ };
+
+ // (Inline) Return object key
+ std::pair <ULONG, ULONG> GetKey() const
+ {
+ std::pair <ULONG, ULONG> key( mStructID, mFragmentOrder );
+ return key;
+ };
+
+ // Populate this object from a string
+ bool FromString( LPSTR pStr );
+
+ // Is this object valid?
+ bool IsValid() const;
+
+ // Build a simple condition string
+ static std::string BuildCondition(
+ ULONG id,
+ eDB2Operator op,
+ LONGLONG val,
+ bool bF2F );
+
+ // Evaluate a simple condition
+ static bool EvaluateCondition(
+ LONGLONG valA,
+ eDB2Operator op,
+ LONGLONG valB );
+
+ // Parse a simple condition
+ static bool ParseCondition(
+ LPCSTR pCondition,
+ ULONG & id,
+ eDB2Operator & op,
+ LONGLONG & val,
+ bool & bF2F );
+
+ // Build a simple expression string
+ static std::string BuildExpression(
+ ULONG id,
+ eDB2ExpOperator op,
+ LONGLONG val,
+ bool bF2F );
+
+ // Evaluate a simple expression
+ static bool EvaluateExpression(
+ LONGLONG valA,
+ eDB2ExpOperator op,
+ LONGLONG valB,
+ LONGLONG & res );
+
+ // Parse a simple expression
+ static bool ParseExpression(
+ LPCSTR pExpr,
+ ULONG & id,
+ eDB2ExpOperator & op,
+ LONGLONG & val,
+ bool & bF2F );
+
+ /* Enclosing structure ID */
+ ULONG mStructID;
+
+ /* Order of fragment within structure */
+ ULONG mFragmentOrder;
+
+ /* Offset (in bits) of fragment from beginning of enclosing structure */
+ int mFragmentOffset;
+
+ /* Fragment type, how to interpret the following fragment value */
+ eDB2FragmentType mFragmentType;
+
+ /* Fragment Value */
+ ULONG mFragmentValue;
+
+ /* Modifier type, how to interpret the following modifier value */
+ eDB2ModifierType mModifierType;
+
+ /* Modifier value */
+ LPCSTR mpModifierValue;
+
+ /* Fragment Name */
+ LPCSTR mpName;
+};
+
+/*=========================================================================*/
+// Struct sDB2Field
+//
+// Structure that defines the schema for the protocol field table
+/*=========================================================================*/
+struct sDB2Field
+{
+ public:
+ // (Inline) Default constructor
+ sDB2Field()
+ : mID( 0 ),
+ mSize( 0 ),
+ mType( eDB2_FIELD_TYPE_ENUM_BEGIN ),
+ mTypeVal( 0 ),
+ mbHex( false ),
+ mbInternal( false ),
+ mDescriptionID( -1 ),
+ mpName( EMPTY_STRING )
+ { };
+
+ // (Inline) Free up our allocated strings
+ void FreeAllocatedStrings()
+ {
+ if ( (mpName != 0)
+ && (mpName != EMPTY_STRING) )
+ {
+ delete [] mpName;
+ mpName = 0;
+ }
+ };
+
+ // (Inline) Return object key
+ ULONG GetKey() const
+ {
+ return mID;
+ };
+
+ // Populate this object from a string
+ bool FromString( LPSTR pStr );
+
+ // Is this object valid?
+ bool IsValid() const;
+
+ /* Field ID */
+ ULONG mID;
+
+ /* Size of field (in bits, maximum is 64 bits for integral types) */
+ ULONG mSize;
+
+ /* Field type */
+ eDB2FieldType mType;
+
+ /* Actual field type (eDB2StdFieldType or enum ID) */
+ ULONG mTypeVal;
+
+ /* Display integral fields as hexadecimal? */
+ bool mbHex;
+
+ /* Is this field internal only? */
+ bool mbInternal;
+
+ /* Description of field */
+ int mDescriptionID;
+
+ /* Field name */
+ LPCSTR mpName;
+};
+
+/*=========================================================================*/
+// Struct sDB2Category
+//
+// Structure that defines the generic category table schema, gives
+// category ID, category name, category description, and parent
+// category relationship (specified as a category ID into the very
+// same table)
+/*=========================================================================*/
+struct sDB2Category
+{
+ public:
+ // (Inline) Default constructor
+ sDB2Category()
+ : mID( 0 ),
+ mParentID( -1 ),
+ mpName( EMPTY_STRING ),
+ mDescriptionID( -1 )
+ { };
+
+ // (Inline) Free up our allocated strings
+ void FreeAllocatedStrings()
+ {
+ if (mpName != 0 && mpName != EMPTY_STRING)
+ {
+ delete [] mpName;
+ mpName = 0;
+ }
+ };
+
+ // (Inline) Return object key
+ ULONG GetKey() const
+ {
+ return mID;
+ };
+
+ // Populate this object from a string
+ bool FromString( LPSTR pStr );
+
+ // Is this object valid?
+ bool IsValid() const;
+
+ /* Category ID */
+ ULONG mID;
+
+ /* Category ID of parent, -1 implies no parent/category is at root */
+ int mParentID;
+
+ /* Category display name */
+ LPCSTR mpName;
+
+ /* Description of category */
+ int mDescriptionID;
+};
+
+
+/*===========================================================================
+METHOD:
+ ValidateDB2Categories (Public Method)
+
+DESCRIPTION:
+ Validate the relationship between a pair of DB category/reference tables
+
+ NOTE: Discovered problems will be repaired, i.e. bogus/problematic
+ category IDs are reset to -1
+
+PARAMETERS:
+ catMap [ I ] - The category table
+ refMap [ I ] - The reference table
+ pName [ I ] - Table name (for error reporting)
+ log [ I ] - Error log
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+template <class Key, class NamedType>
+bool ValidateDB2Categories(
+ std::map <ULONG, sDB2Category> & catMap,
+ std::map <Key, NamedType> & refMap,
+ LPCSTR pName,
+ cDB2StatusLog & log = gDB2DefaultLog )
+{
+ // Assume success
+ bool bRC = true;
+ std::string err;
+
+ // Sanity check table name
+ if (pName == 0 || pName[0] == 0)
+ {
+ pName = "?";
+ }
+
+ // First validate/repair category map; stage 1: bad parent IDs
+ std::map <ULONG, sDB2Category>::iterator pCats = catMap.begin();
+ while (pCats != catMap.end())
+ {
+ sDB2Category & cat = pCats->second;
+ pCats++;
+
+ if (cat.IsValid() == false)
+ {
+ continue;
+ }
+
+ // The parent ID must be -1 or exist in the category map
+ if (cat.mParentID != -1)
+ {
+ if (catMap.find( cat.mParentID ) == catMap.end())
+ {
+ // Unable to locate parent category
+ std::ostringstream tmp;
+ tmp << "DB [" << pName << "] Missing ID, parent ID "
+ << cat.mParentID;
+
+ log.Log( tmp.str(), eDB2_STATUS_ERROR );
+
+ cat.mParentID = -1;
+ bRC = false;
+ }
+ }
+ }
+
+ // Validate/repair category map; stage 2: loop detection
+ pCats = catMap.begin();
+ while (pCats != catMap.end())
+ {
+ std::set <int> catsVisited;
+ sDB2Category & cat = pCats->second;
+
+ // Itererate up through parents
+ int parentID = cat.mParentID;
+ while (parentID != -1)
+ {
+ // Have we already been here?
+ if (catsVisited.find( parentID ) == catsVisited.end())
+ {
+ // Nope, add ID and go on to the next one
+ catsVisited.insert( parentID );
+
+ std::map <ULONG, sDB2Category>::iterator pParent;
+ pParent = catMap.find( parentID );
+
+ parentID = pParent->second.mParentID;
+ }
+ else
+ {
+ // Yes, we are caught in a loop
+ std::ostringstream tmp;
+ tmp << "DB [" << pName << "] Loop in category, parent ID "
+ << cat.mParentID;
+
+ log.Log( tmp.str(), eDB2_STATUS_ERROR );
+
+ cat.mParentID = -1;
+ bRC = false;
+
+ break;
+ }
+ }
+
+ pCats++;
+ }
+
+ // Validate that each reference references valid category IDs
+ typename std::map <Key, NamedType>::iterator pTypes = refMap.begin();
+ while (pTypes != refMap.end())
+ {
+ NamedType & theType = pTypes->second;
+ std::set <int> cats = theType.mCategoryIDs;
+
+ std::set <int>::iterator pRefCats = cats.begin();
+ while (pRefCats != cats.end())
+ {
+ if (*pRefCats != -1)
+ {
+ pCats = catMap.find( *pRefCats );
+ if (pCats == catMap.end())
+ {
+ // Unable to locate category
+ std::ostringstream tmp;
+ tmp << "DB [" << pName << "] Missing ID, category ID "
+ << *pRefCats << ", reference " << theType.mpName;
+
+ log.Log( tmp.str(), eDB2_STATUS_ERROR );
+
+ *pRefCats = -1;
+ bRC = false;
+ }
+ }
+
+ pRefCats++;
+ }
+
+ pTypes++;
+ }
+
+ return bRC;
+};
+
+/*=========================================================================*/
+// Struct sDB2NVItem
+//
+// NVRAM item structure for database schema
+/*=========================================================================*/
+struct sDB2NVItem
+{
+ public:
+ // (Inline) Default constructor
+ sDB2NVItem()
+ : mItem( 0 ),
+ mpName( EMPTY_STRING ),
+ mDescriptionID( -1 )
+ { };
+
+ // (Inline) Free up our allocated strings
+ void FreeAllocatedStrings()
+ {
+ if (mpName != 0 && mpName != EMPTY_STRING)
+ {
+ delete [] mpName;
+ mpName = 0;
+ }
+ };
+
+ // (Inline) Return object key
+ ULONG GetKey() const
+ {
+ return mItem;
+ };
+
+ // Populate this object from a string
+ bool FromString( LPSTR pStr );
+
+ // Is this object valid?
+ bool IsValid() const;
+
+ /* Category IDs (indices into NV items category table) */
+ std::set <int> mCategoryIDs;
+
+ /* Item number */
+ ULONG mItem;
+
+ /* NV item display name */
+ LPCSTR mpName;
+
+ /* Description of NV item */
+ int mDescriptionID;
+};
+
+/*=========================================================================*/
+// Struct sDB2Enum
+//
+// Structure that defines the schema for the enum table
+/*=========================================================================*/
+struct sDB2Enum
+{
+ public:
+ // (Inline) Default constructor
+ sDB2Enum()
+ : mID( 0 ),
+ mbInternal( false ),
+ mpName( EMPTY_STRING ),
+ mDescriptionID( -1 )
+ { };
+
+ // (Inline) Free up our allocated strings
+ void FreeAllocatedStrings()
+ {
+ if (mpName != 0 && mpName != EMPTY_STRING)
+ {
+ delete [] mpName;
+ mpName = 0;
+ }
+ };
+
+ // (Inline) Return object key
+ ULONG GetKey() const
+ {
+ return mID;
+ };
+
+ // Populate this object from a string
+ bool FromString( LPSTR pStr );
+
+ // Is this object valid?
+ bool IsValid() const;
+
+ /* Enum ID */
+ ULONG mID;
+
+ /* Is this enum used internally? */
+ bool mbInternal;
+
+ /* Description of enum */
+ int mDescriptionID;
+
+ /* Name of enum */
+ LPCSTR mpName;
+};
+
+/*=========================================================================*/
+// Struct sDB2EnumEntry
+//
+// Structure that defines the schema for the enum entry table
+/*=========================================================================*/
+struct sDB2EnumEntry
+{
+ public:
+ // (Inline) Default constructor
+ sDB2EnumEntry()
+ : mID( 0 ),
+ mValue( -1 ),
+ mbHex( false ),
+ mpName( EMPTY_STRING ),
+ mDescriptionID( -1 )
+ { };
+
+ // (Inline) Free up our allocated strings
+ void FreeAllocatedStrings()
+ {
+ if (mpName != 0 && mpName != EMPTY_STRING)
+ {
+ delete [] mpName;
+ mpName = 0;
+ }
+ };
+
+ // (Inline) Return object key
+ std::pair <ULONG, int> GetKey() const
+ {
+ std::pair <ULONG, int> key( mID, mValue );
+ return key;
+ };
+
+ // (Inline) Populate this object from a string
+ bool FromString( LPSTR pStr );
+
+ // Is this object valid?
+ bool IsValid() const;
+
+ /* Enum ID */
+ ULONG mID;
+
+ /* Enum entry value */
+ int mValue;
+
+ /* Hexadecimal flag */
+ bool mbHex;
+
+ /* Enum value name */
+ LPCSTR mpName;
+
+ /* Description of enum value */
+ int mDescriptionID;
+};
+
+/*=========================================================================*/
+// Struct sDB2SimpleCondition
+//
+// Structure that defines a (parsed) simple condition modifier
+/*=========================================================================*/
+struct sDB2SimpleCondition
+{
+ public:
+ // (Inline) Default constructor
+ sDB2SimpleCondition()
+ : mID( 0 ),
+ mOperator( eDB2_OP_TYPE_ENUM_BEGIN ),
+ mValue( 0 ),
+ mbF2F( false )
+ { };
+
+ // (Inline) Is this object valid?
+ bool IsValid() const
+ {
+ return ::IsValid( mOperator );
+ };
+
+ /* ID of field whose value is to be used */
+ ULONG mID;
+
+ /* Operator to be used */
+ eDB2Operator mOperator;
+
+ /* Value (or field ID) to compare against */
+ LONGLONG mValue;
+
+ /* Field to field expression? */
+ bool mbF2F;
+};
+
+/*=========================================================================*/
+// Struct sDB2SimpleExpression
+//
+// Structure that defines a (parsed) simple expression
+/*=========================================================================*/
+struct sDB2SimpleExpression
+{
+ public:
+ // (Inline) Default constructor
+ sDB2SimpleExpression()
+ : mID( 0 ),
+ mOperator( eDB2_EXPOP_TYPE_ENUM_BEGIN ),
+ mValue( 0 ),
+ mbF2F( false )
+ { };
+
+ // (Inline) Is this object valid?
+ bool IsValid() const
+ {
+ return (::IsValid( mOperator ) && mValue != 0);
+ };
+
+ /* ID of field whose value is to be used */
+ ULONG mID;
+
+ /* Operator to be used */
+ eDB2ExpOperator mOperator;
+
+ /* Value (or field ID) to compare against */
+ LONGLONG mValue;
+
+ /* Field to field expression? */
+ bool mbF2F;
+};
+
+/*=========================================================================*/
+// Struct sLPCSTRCmp
+//
+// Structure that defines the '<' operator for string comparison
+/*=========================================================================*/
+struct sLPCSTRCmp
+{
+ public:
+ // (Inline) Is A < B?
+ bool operator () (
+ LPCSTR pStrA,
+ LPCSTR pStrB ) const
+ {
+ bool bLess = false;
+ if (pStrA != 0 && pStrB != 0)
+ {
+ bLess = (strcmp( pStrA, pStrB ) < 0);
+ }
+
+ return bLess;
+ };
+};
+
+/*=========================================================================*/
+// Case insensitive compare function
+/*=========================================================================*/
+inline bool InsensitiveCompare( CHAR first, CHAR second )
+{
+ return tolower( first ) < tolower( second );
+}
+
+/*=========================================================================*/
+// Struct sLPCSTRCmpI
+//
+// Structure that defines the '<' operator for string comparison
+// (case insensitive version)
+/*=========================================================================*/
+struct sLPCSTRCmpI
+{
+ public:
+ // (Inline) Is A < B?
+ bool operator () (
+ LPCSTR pStrA,
+ LPCSTR pStrB ) const
+ {
+ bool bLess = false;
+ if (pStrA != 0 && pStrB != 0)
+ {
+ // Is there a simpler stl function for this?
+ bLess = std::lexicographical_compare( pStrA,
+ pStrA +
+ strlen( pStrA ),
+ pStrB,
+ pStrB +
+ strlen( pStrB ),
+ InsensitiveCompare );
+ }
+
+ return bLess;
+ };
+};
+
+//---------------------------------------------------------------------------
+// Typedefs
+//---------------------------------------------------------------------------
+
+// The protocol entity table expressed as a type
+typedef std::multimap <std::vector <ULONG>, sDB2ProtocolEntity> tDB2EntityMap;
+
+// Protocol entity entity name to ID (reverse) table
+typedef std::map <LPCSTR, std::vector <ULONG>, sLPCSTRCmpI> tDB2EntityNameMap;
+
+// The struct table expressed as a type
+typedef std::map <std::pair <ULONG, ULONG>, sDB2Fragment> tDB2FragmentMap;
+
+// The field table expressed as a type
+typedef std::map <ULONG, sDB2Field> tDB2FieldMap;
+
+// A generic category table expressed as a type
+typedef std::map <ULONG, sDB2Category> tDB2CategoryMap;
+
+// NV item table expressed as a map type
+typedef std::map <ULONG, sDB2NVItem> tDB2NVMap;
+
+// Enum table expressed as a map type
+typedef std::map <ULONG, sDB2Enum> tDB2EnumNameMap;
+
+// Enum entry table expressed as a map type
+typedef std::map <std::pair <ULONG, int>, sDB2EnumEntry> tDB2EnumEntryMap;
+
+// The built enumeration map
+typedef std::pair < ULONG, std::map <int, LPCSTR> > tDB2EnumMapPair;
+typedef std::map <LPCSTR, tDB2EnumMapPair, sLPCSTRCmp> tDB2EnumMap;
+
+// Parsed fragment modifier map - optional fragment
+typedef std::map <LPCSTR, sDB2SimpleCondition> tDB2OptionalModMap;
+
+// Parsed fragment modifier map - simple expression based sizes
+typedef std::map <LPCSTR, sDB2SimpleExpression> tDB2ExpressionModMap;
+
+// Parsed fragment modifier map - element count specified arrays
+typedef std::map <LPCSTR, ULONG> tDB2Array1ModMap;
+
+// Parsed fragment modifier map - start/stop index specified arrays
+typedef std::map <LPCSTR, std::pair <ULONG, ULONG> > tDB2Array2ModMap;
+
+// A protocol entity navigation map expressed as a type
+typedef std::map <std::vector <ULONG>, cDB2NavTree *> tDB2EntityNavMap;
+
+
+
+/*=========================================================================*/
+// Class cCoreDatabase
+/*=========================================================================*/
+class cCoreDatabase
+{
+ public:
+ // Constructor
+ cCoreDatabase();
+
+ // Destructor
+ virtual ~cCoreDatabase();
+
+ // Initialize the database - must be done once (and only once) prior
+ // to any database object access
+ virtual bool Initialize( LPCSTR pBasePath );
+ virtual bool Initialize();
+
+ // Exit (cleanup) the database
+ virtual void Exit();
+
+ // Get the entity navigation tree for the given protocol entity, if
+ // none exists one will be built and returned
+ const cDB2NavTree * GetEntityNavTree(
+ const std::vector <ULONG> & key ) const;
+
+ // Find the protocol entity with the specified key
+ bool FindEntity(
+ const std::vector <ULONG> & key,
+ sDB2ProtocolEntity & entity ) const;
+
+ // Find the protocol entity with the specified name
+ bool FindEntity(
+ LPCSTR pEntityName,
+ sDB2ProtocolEntity & entity ) const;
+
+ // Map a protocol entity name to an ID
+ bool MapEntityNameToID(
+ LPCSTR pName,
+ std::vector <ULONG> & key ) const;
+
+ // Map the given enum value (specified by enum ID, and enum value)
+ // to the enum value name string
+ std::string MapEnumToString(
+ ULONG enumID,
+ int enumVal,
+ bool bSimpleErrFmt = false,
+ bool bHex = false ) const;
+
+ // Map the given enum value (specified by enum name, and enum value)
+ // to the enum value name string
+ std::string MapEnumToString(
+ LPCSTR pEnumName,
+ int enumVal,
+ bool bSimpleErrFmt = false,
+ bool bHex = false ) const;
+
+ // (Inline) Set status log (object must exist for the duration of
+ // the DB or at least until being reset)
+ void SetLog( cDB2StatusLog * pLog )
+ {
+ if (pLog != 0)
+ {
+ mpLog = pLog;
+ }
+ };
+
+ // (Inline) Return protocol entities
+ const tDB2EntityMap & GetProtocolEntities() const
+ {
+ return mProtocolEntities;
+ };
+
+ // (Inline) Return protocol entity names
+ const tDB2EntityNameMap & GetProtocolEntityNames() const
+ {
+ return mEntityNames;
+ };
+
+ // (Inline) Return protocol structures
+ const tDB2FragmentMap & GetProtocolStructs() const
+ {
+ return mEntityStructs;
+ };
+
+ // (Inline) Return protocol fields
+ const tDB2FieldMap & GetProtocolFields() const
+ {
+ return mEntityFields;
+ };
+
+ // (Inline) Return assembled enumeration map
+ const tDB2EnumMap & GetEnums() const
+ {
+ return mEnumMap;
+ };
+
+ // (Inline) Return raw enumeration map
+ const tDB2EnumNameMap & GetRawEnums() const
+ {
+ return mEnumNameMap;
+ };
+
+ // (Inline) Return raw enumeration entry map
+ const tDB2EnumEntryMap & GetRawEnumEntries() const
+ {
+ return mEnumEntryMap;
+ };
+
+ // (Inline) Return parsed fragment modifier map - optional
+ const tDB2OptionalModMap & GetOptionalMods() const
+ {
+ return mOptionalModMap;
+ };
+
+ // (Inline) Return parsed fragment modifier map - expressions
+ const tDB2ExpressionModMap & GetExpressionMods() const
+ {
+ return mExpressionModMap;
+ };
+
+ // (Inline) Return parsed fragment modifier map - element
+ // count specified arrays
+ const tDB2Array1ModMap & GetArray1Mods() const
+ {
+ return mArray1ModMap;
+ };
+
+ // (Inline) Return parsed fragment modifier map - start/stop
+ // index specified arrays
+ const tDB2Array2ModMap & GetArray2Mods() const
+ {
+ return mArray2ModMap;
+ };
+
+ protected:
+ // Assemble the internal enum map
+ bool AssembleEnumMap();
+
+ // Assemble the internal protocol entity name map
+ bool AssembleEntityNameMap();
+
+ // Build the modifier tables
+ bool BuildModifierTables();
+
+ // Check and set the passed in path to something that is useful
+ std::string CheckAndSetBasePath( LPCSTR pBasePath ) const;
+
+ // Load all tables related to structure (entity, struct, field)
+ bool LoadStructureTables( LPCSTR pBasePath );
+ bool LoadStructureTables();
+
+ // Load all enumeration related tables
+ bool LoadEnumTables( LPCSTR pBasePath );
+ bool LoadEnumTables();
+
+ // Validate (and attempt repair of) structure related tables
+ bool ValidateStructures();
+
+ // Validate a single structure
+ bool ValidateStructure(
+ ULONG structID,
+ std::set <ULONG> & fields,
+ ULONG depth );
+
+ // Validate a single field
+ bool ValidateField(
+ ULONG structID,
+ ULONG fieldID,
+ std::set <ULONG> & fields );
+
+ // Validate an array specifier
+ bool ValidateArraySpecifier(
+ const sDB2Fragment & frag,
+ const std::set <ULONG> & fields );
+
+ // Validate a simple optional fragment specifier
+ bool ValidateOptionalSpecifier(
+ const sDB2Fragment & frag,
+ const std::set <ULONG> & fields );
+
+ // Validate a simple expression fragment specifier
+ bool ValidateExpressionSpecifier(
+ const sDB2Fragment & frag,
+ const std::set <ULONG> & fields );
+
+ /* Status log */
+ cDB2StatusLog * mpLog;
+
+ /* Protocol entity table, referenced by multi-value key */
+ tDB2EntityMap mProtocolEntities;
+
+ /* Protocol entity keys, referenced by indexed by entity name */
+ tDB2EntityNameMap mEntityNames;
+
+ /* The on-demand Protocol entity navigation map */
+ mutable tDB2EntityNavMap mEntityNavMap;
+
+ /* Protocol entity struct table, indexed by struct ID & fragment order */
+ tDB2FragmentMap mEntityStructs;
+
+ /* Protocol entity field table, indexed by field ID */
+ tDB2FieldMap mEntityFields;
+
+ /* Enum map, indexed by enum ID */
+ tDB2EnumNameMap mEnumNameMap;
+
+ /* Enum entry map, indexed by enum ID/value pair */
+ tDB2EnumEntryMap mEnumEntryMap;
+
+ /* The assembled enum map */
+ tDB2EnumMap mEnumMap;
+
+ /* Parsed fragment modifier map - optional fragments */
+ tDB2OptionalModMap mOptionalModMap;
+
+ /* Parsed fragment modifier map - expression fragments */
+ tDB2ExpressionModMap mExpressionModMap;
+
+ /* Parsed fragment modifier map - element count specified arrays */
+ tDB2Array1ModMap mArray1ModMap;
+
+ /* Parsed fragment modifier map - start/stop index specified arrays */
+ tDB2Array2ModMap mArray2ModMap;
+};
diff --git a/gobi-api/GobiAPI_1.0.40/Core/CoreUtilities.cpp b/gobi-api/GobiAPI_1.0.40/Core/CoreUtilities.cpp
new file mode 100755
index 0000000..3331bfa
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/CoreUtilities.cpp
@@ -0,0 +1,1853 @@
+/*===========================================================================
+FILE:
+ CoreUtilities.cpp
+
+DESCRIPTION:
+ Collection of various utility methods
+
+PUBLIC CLASSES AND METHODS:
+ StringToLONG
+ StringToULONG
+ StringToLONGLONG
+ StringToULONGLONG
+
+ ParseTokens()
+ ParseCommandLine()
+ 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 )
+
+ ContainerToCSVString()
+ CSVStringToContainer()
+ CSVStringToValidatedContainer()
+
+ SetDiff()
+ SetIntersection()
+ SetUnion()
+
+ GetProgramPath()
+ IsFolder()
+ EnumerateFolders()
+ IsHidden()
+ DepthSearch()
+
+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 "CoreUtilities.h"
+
+#include <climits>
+
+//---------------------------------------------------------------------------
+// Definitions
+//---------------------------------------------------------------------------
+
+// Format specifier states
+enum eFormatState
+{
+ eFMT_STATE_NORMAL, // [0] Normal state; outputting literal characters
+ eFMT_STATE_PERCENT, // [1] Just read '%'
+ eFMT_STATE_FLAG, // [2] Just read flag character
+ eFMT_STATE_WIDTH, // [3] Just read width specifier
+ eFMT_STATE_DOT, // [4] Just read '.'
+ eFMT_STATE_PRECIS, // [5] Just read precision specifier
+ eFMT_STATE_SIZE, // [6] Just read size specifier
+ eFMT_STATE_TYPE, // [7] Just read type specifier
+ eFMT_STATE_INVALID, // [8] Invalid format
+
+ eFMT_STATES // [9] Number of format states
+};
+
+// Format specifier character classes
+enum eFormatCharClass
+{
+ eFMT_CH_CLASS_OTHER, // [0] Character with no special meaning
+ eFMT_CH_CLASS_PERCENT, // [1] '%'
+ eFMT_CH_CLASS_DOT, // [2] '.'
+ eFMT_CH_CLASS_STAR, // [3] '*'
+ eFMT_CH_CLASS_ZERO, // [4] '0'
+ eFMT_CH_CLASS_DIGIT, // [5] '1'..'9'
+ eFMT_CH_CLASS_FLAG, // [6] ' ', '+', '-', '#'
+ eFMT_CH_CLASS_SIZE, // [7] 'h', 'l', 'L', 'N', 'F', 'w'
+ eFMT_CH_CLASS_TYPE // [8] Type specifying character
+};
+
+// Lookup table for determining class of a character (lower nibble)
+// and next format specifier state (upper nibble)
+const UCHAR gLookupTable[] =
+{
+ 0x06, // ' ', FLAG
+ 0x80, // '!', OTHER
+ 0x80, // '"', OTHER
+ 0x86, // '#', FLAG
+ 0x80, // '$', OTHER
+ 0x81, // '%', PERCENT
+ 0x80, // '&', OTHER
+ 0x00, // ''', OTHER
+ 0x00, // '(', OTHER
+ 0x10, // ')', OTHER
+ 0x03, // '*', STAR
+ 0x86, // '+', FLAG
+ 0x80, // ',', OTHER
+ 0x86, // '-', FLAG
+ 0x82, // '.', DOT
+ 0x80, // '/', OTHER
+ 0x14, // '0', ZERO
+ 0x05, // '1', DIGIT
+ 0x05, // '2', DIGIT
+ 0x45, // '3', DIGIT
+ 0x45, // '4', DIGIT
+ 0x45, // '5', DIGIT
+ 0x85, // '6', DIGIT
+ 0x85, // '7', DIGIT
+ 0x85, // '8', DIGIT
+ 0x05, // '9', DIGIT
+ 0x00, // :!', OTHER
+ 0x00, // ';', OTHER
+ 0x30, // '<', OTHER
+ 0x30, // '=', OTHER
+ 0x80, // '>', OTHER
+ 0x50, // '?', OTHER
+ 0x80, // '@', OTHER
+ 0x80, // 'A', OTHER
+ 0x00, // 'B', OTHER
+ 0x08, // 'C', TYPE
+ 0x00, // 'D', OTHER
+ 0x28, // 'E', TYPE
+ 0x27, // 'F', SIZE
+ 0x38, // 'G', TYPE
+ 0x50, // 'H', OTHER
+ 0x57, // 'I', SIZE
+ 0x80, // 'J', OTHER
+ 0x00, // 'K', OTHER
+ 0x07, // 'L', SIZE
+ 0x00, // 'M', OTHER
+ 0x37, // 'N', SIZE
+ 0x30, // 'O', OTHER
+ 0x30, // 'P', OTHER
+ 0x50, // 'Q', OTHER
+ 0x50, // 'R', OTHER
+ 0x88, // 'S', TYPE
+ 0x00, // 'T', OTHER
+ 0x00, // 'U', OTHER
+ 0x00, // 'V', OTHER
+ 0x20, // 'W', OTHER
+ 0x28, // 'X', TYPE
+ 0x80, // 'Y', OTHER
+ 0x88, // 'Z', TYPE
+ 0x80, // '[', OTHER
+ 0x80, // '\', OTHER
+ 0x00, // ']', OTHER
+ 0x00, // '^', OTHER
+ 0x00, // '-', OTHER
+ 0x60, // '`', OTHER
+ 0x60, // 'a', OTHER
+ 0x60, // 'b', OTHER
+ 0x68, // 'c', TYPE
+ 0x68, // 'd', TYPE
+ 0x68, // 'e', TYPE
+ 0x08, // 'f', TYPE
+ 0x08, // 'g', TYPE
+ 0x07, // 'h', SIZE
+ 0x78, // 'i', TYPE
+ 0x70, // 'j', OTHER
+ 0x70, // 'k', OTHER
+ 0x77, // 'l', SIZE
+ 0x70, // 'm', OTHER
+ 0x70, // 'n', OTHER
+ 0x08, // 'o', TYPE
+ 0x08, // 'p', TYPE
+ 0x00, // 'q', OTHER
+ 0x00, // 'r', OTHER
+ 0x08, // 's', TYPE
+ 0x00, // 't', OTHER
+ 0x08, // 'u', TYPE
+ 0x00, // 'v', OTHER
+ 0x07, // 'w', SIZE
+ 0x08 // 'x', TYPE
+};
+
+/*=========================================================================*/
+// Free Methods
+/*=========================================================================*/
+
+/*===========================================================================
+METHOD:
+ IsWhitespace (Private Free Method)
+
+DESCRIPTION:
+ Is this whitespace?
+
+PARAMETERS:
+ pStr [ I ] - The string
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+static bool IsWhitespace( LPCSTR pStr )
+{
+ bool bWS = false;
+
+ int c = (int)*pStr;
+ if (isspace( c ))
+ {
+ bWS = true;
+ }
+
+ return bWS;
+}
+
+/*===========================================================================
+METHOD:
+ IsHexadecimalString (Private Free Method)
+
+DESCRIPTION:
+ Is this a hexadecimal digits string?
+
+PARAMETERS:
+ pStr [ I ] - The string
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+static bool IsHexadecimalString( LPCSTR pStr )
+{
+ // Assume not
+ bool bHex = false;
+
+ // Skip whitespace
+ LPCSTR pTmp = pStr;
+ while (IsWhitespace( pTmp ) == true)
+ {
+ pTmp++;
+ }
+
+ // Skip leading +/-
+ CHAR ch = *pTmp;
+ if (ch == '+' || ch == '-')
+ {
+ pTmp++;
+ }
+
+ if (*pTmp == '0')
+ {
+ pTmp++;
+ if (*pTmp == 'x' || *pTmp == 'X')
+ {
+ bHex = true;
+ }
+ }
+
+ return bHex;
+}
+
+/*===========================================================================
+METHOD:
+ IsNegativeString (Private Free Method)
+
+DESCRIPTION:
+ Is this a string starting with a negative sign?
+
+PARAMETERS:
+ pStr [ I ] - The string
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+static bool IsNegativeString( LPCSTR pStr )
+{
+ // Assume not
+ bool bNeg = false;
+
+ // Skip whitespace
+ LPCSTR pTmp = pStr;
+ while (IsWhitespace( pTmp ) == true)
+ {
+ pTmp++;
+ }
+
+ CHAR ch = *pTmp;
+ if (ch == '-')
+ {
+ bNeg = true;
+ }
+
+ return bNeg;
+}
+
+/*===========================================================================
+METHOD:
+ StringToLONG (Free Method)
+
+DESCRIPTION:
+ Replacement/front end for strtol
+
+ NOTE: strtol does not correctly handle a negative integer
+ when specified in hexadecimal, so we have to check for that
+ first
+
+PARAMETERS:
+ pStr [ I ] - The string
+ base [ I ] - Base for conversion
+ val [ O ] - Resulting value
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool StringToLONG(
+ LPCSTR pStr,
+ int base,
+ LONG & val )
+{
+ // Assume failure
+ bool bOK = false;
+ if (pStr == 0 || *pStr == 0)
+ {
+ return bOK;
+ }
+
+ // Hexadecimal?
+ if (base == 16 || (base == 0 && IsHexadecimalString( pStr ) == true))
+ {
+ // No negative hexadecimal strings allowed
+ if (IsNegativeString( pStr ) == false)
+ {
+ // Reset error
+ errno = 0;
+
+ // Use the unsigned version, then cast
+ LPSTR pEnd = (LPSTR)pStr;
+ ULONG tmpVal = strtoul( pStr, &pEnd, base );
+ if (tmpVal != ULONG_MAX || errno != ERANGE)
+ {
+ // Where did we end?
+ if (pEnd != pStr && (*pEnd == 0 || IsWhitespace( pEnd ) == true))
+ {
+ // Success!
+ val = (LONG)tmpVal;
+ bOK = true;
+ }
+ }
+ }
+ }
+ else
+ {
+ // Proceed as normal
+ LPSTR pEnd = (LPSTR)pStr;
+ LONG tmpVal = strtol( pStr, &pEnd, base );
+ if ((tmpVal != LONG_MAX && tmpVal != LONG_MIN) || errno != ERANGE)
+ {
+ // Where did we end?
+ if (pEnd != pStr && (*pEnd == 0 || IsWhitespace( pEnd ) == true))
+ {
+ // Success!
+ val = tmpVal;
+ bOK = true;
+ }
+ }
+ }
+
+ return bOK;
+}
+
+/*===========================================================================
+METHOD:
+ StringToULONG (Free Method)
+
+DESCRIPTION:
+ Replacement/front end for strtoul
+
+PARAMETERS:
+ pStr [ I ] - The string
+ base [ I ] - Base for conversion
+ val [ O ] - Resulting value
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool StringToULONG(
+ LPCSTR pStr,
+ int base,
+ ULONG & val )
+{
+ // Assume failure
+ bool bOK = false;
+ if (pStr == 0 || *pStr == 0)
+ {
+ return bOK;
+ }
+
+ // No negative strings allowed
+ if (IsNegativeString( pStr ) == true)
+ {
+ return bOK;
+ }
+
+ // Reset error
+ errno = 0;
+
+ LPSTR pEnd = (LPSTR)pStr;
+ ULONG tmpVal = strtoul( pStr, &pEnd, base );
+ if (tmpVal != ULONG_MAX || errno != ERANGE)
+ {
+ if (pEnd != pStr && (*pEnd == 0 || IsWhitespace( pEnd ) == true))
+ {
+ // Success!
+ val = tmpVal;
+ bOK = true;
+ }
+ }
+
+ return bOK;
+}
+
+/*===========================================================================
+METHOD:
+ StringToLONGLONG (Free Method)
+
+DESCRIPTION:
+ Replacement/front end for strtoll
+
+ NOTE: strtoll does not correctly handle a negative integer
+ when specified in hexadecimal, so we have to check for that
+ first
+
+PARAMETERS:
+ pStr [ I ] - The string
+ base [ I ] - Base for conversion
+ val [ O ] - Resulting value
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool StringToLONGLONG(
+ LPCSTR pStr,
+ int base,
+ LONGLONG & val )
+{
+ // Assume failure
+ bool bOK = false;
+ if (pStr == 0 || *pStr == 0)
+ {
+ return bOK;
+ }
+
+ if (base == 16 || (base == 0 && IsHexadecimalString( pStr ) == true))
+ {
+ // No negative hexadecimal strings allowed
+ if (IsNegativeString( pStr ) == false)
+ {
+ // Reset error
+ errno = 0;
+
+ // Use the unsigned version, then cast
+ LPSTR pEnd = (LPSTR)pStr;
+ ULONGLONG tmpVal = strtoull( pStr, &pEnd, base );
+ if (tmpVal != ULLONG_MAX || errno != ERANGE)
+ {
+ // Where did we end?
+ if (pEnd != pStr && (*pEnd == 0 || IsWhitespace( pEnd ) == true))
+ {
+ // Success!
+ val = (LONGLONG)tmpVal;
+ bOK = true;
+ }
+ }
+ }
+ }
+ else
+ {
+ // Proceed as normal
+ LPSTR pEnd = (LPSTR)pStr;
+ LONGLONG tmpVal = strtoll( pStr, &pEnd, base );
+ if ((tmpVal != LLONG_MAX && tmpVal != LLONG_MIN) || errno != ERANGE)
+ {
+ if (pEnd != pStr && (*pEnd == 0 || IsWhitespace( pEnd ) == true))
+ {
+ // Success!
+ val = tmpVal;
+ bOK = true;
+ }
+ }
+ }
+
+ return bOK;
+}
+
+/*===========================================================================
+METHOD:
+ StringToULONGLONG (Free Method)
+
+DESCRIPTION:
+ Replacement/front end for strtouill
+
+PARAMETERS:
+ pStr [ I ] - The string
+ base [ I ] - Base for conversion
+ val [ O ] - Resulting value
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool StringToULONGLONG(
+ LPCSTR pStr,
+ int base,
+ ULONGLONG & val )
+{
+ // Assume failure
+ bool bOK = false;
+ if (pStr == 0 || *pStr == 0)
+ {
+ return bOK;
+ }
+
+ // No negative strings allowed
+ if (IsNegativeString( pStr ) == true)
+ {
+ return bOK;
+ }
+
+ // Reset error
+ errno = 0;
+
+ LPSTR pEnd = (LPSTR)pStr;
+ ULONGLONG tmpVal = strtoull( pStr, &pEnd, base );
+ if (tmpVal != ULLONG_MAX || errno != ERANGE)
+ {
+ if (pEnd != pStr && (*pEnd == 0 || IsWhitespace( pEnd ) == true))
+ {
+ // Success!
+ val = tmpVal;
+ bOK = true;
+ }
+ }
+
+ return bOK;
+}
+
+/*===========================================================================
+METHOD:
+ ParseCommandLine (Free Method)
+
+DESCRIPTION:
+ 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)
+
+PARAMETERS:
+ commandLine [ I ] - The characters separating tokens
+ tokens [ O ] - The resultant vector of tokens
+
+RETURN VALUE:
+ None
+===========================================================================*/
+void ParseCommandLine(
+ std::string commandLine,
+ std::vector <std::string> & tokens )
+{
+ ULONG count = (ULONG)commandLine.size();
+
+ for (ULONG nEndToken = 0; nEndToken < count;)
+ {
+ // Skip leading spaces
+ int nStartToken = commandLine.find_first_not_of( " ", nEndToken );
+ if (nStartToken == -1)
+ {
+ // All that is left is spaces
+ return;
+ }
+
+ int stringLength = 0;
+
+ // In Quotes? If so ignore spaces until next quote
+ if (commandLine[ nStartToken ] == '\"')
+ {
+ nStartToken++;
+ nEndToken = commandLine.find( '\"', nStartToken );
+ if (nEndToken == -1)
+ {
+ // Unable to find trailing quote, fail
+ return;
+ }
+ stringLength = nEndToken - nStartToken;
+ nEndToken++;
+ }
+ else
+ {
+ nEndToken = commandLine.find( ' ', nStartToken );
+ if (nEndToken == -1)
+ {
+ // Unable to find trailing space, use end
+ nEndToken = commandLine.size();
+ }
+
+ stringLength = nEndToken - nStartToken;
+ }
+
+ std::string newToken = commandLine.substr( nStartToken, stringLength );
+ tokens.push_back( newToken );
+ }
+}
+
+/*===========================================================================
+METHOD:
+ ParseTokens (Free Method)
+
+DESCRIPTION:
+ Parse a line into individual tokens
+
+ NOTE: No attempt is made to handle accidental separators, i.e. searching
+ for ',' on 'foo, bar, "foo, bar"' will return four tokens, not three so
+ pick something like '^' instead of ','!
+
+PARAMETERS:
+ pSeparator [ I ] - The characters separating tokens
+ pLine [ I ] - The string being parsed
+ tokens [ O ] - The resultant vector of tokens
+
+RETURN VALUE:
+ None
+===========================================================================*/
+void ParseTokens(
+ LPCSTR pSeparator,
+ LPSTR pLine,
+ std::vector <LPSTR> & tokens )
+{
+ if (pSeparator != 0 && pSeparator[0] != 0 && pLine != 0 && pLine[0] != 0)
+ {
+ LPSTR pToken = strtok( pLine, pSeparator );
+ while (pToken != 0)
+ {
+ // Store token
+ tokens.push_back( pToken );
+
+ // Get next token:
+ pToken = strtok( 0, pSeparator );
+ }
+ }
+}
+
+/*===========================================================================
+METHOD:
+ ParseFormatSpecifier (Free Method)
+
+DESCRIPTION:
+ Parse a format specifier into individual format type tokens
+
+PARAMETERS:
+ pFmt [ I ] - The format specifier (must be NULL terminated)
+ fmtLen [ I ] - Length of above format specifier
+ fmtTypes [ O ] - The individual format type tokens ('d', 'u', 'us' etc.)
+
+RETURN VALUE:
+ bool - Valid format specifier?
+===========================================================================*/
+bool ParseFormatSpecifier(
+ LPCSTR pFmt,
+ ULONG fmtLen,
+ std::vector <CHAR> & fmtTypes )
+{
+ // Assume failure
+ bool bOK = false;
+
+ // Make sure string is NULL terminated
+ CHAR ch;
+ ULONG chars = 0;
+ while (chars < fmtLen)
+ {
+ if (pFmt[chars] == '\0')
+ {
+ break;
+ }
+ else
+ {
+ chars++;
+ }
+ }
+
+ if (pFmt[chars] != '\0')
+ {
+ return bOK;
+ }
+
+ // Extract individual format type tokens
+ eFormatState state = eFMT_STATE_NORMAL;
+ eFormatCharClass cc = eFMT_CH_CLASS_OTHER;
+ while ((ch = *pFmt++) != '\0' && state != eFMT_STATE_INVALID)
+ {
+ // Find character class
+ cc = eFMT_CH_CLASS_OTHER;
+ if (ch >= ' ' && ch <= 'x')
+ {
+ cc = (eFormatCharClass)(gLookupTable[ch - ' '] & 0xF);
+ }
+
+ // Find next state
+ state = (eFormatState)(gLookupTable[cc * eFMT_STATES + (state)] >> 4);
+ switch (state)
+ {
+ case eFMT_STATE_NORMAL:
+ NORMAL_STATE:
+ break;
+
+ case eFMT_STATE_PERCENT:
+ case eFMT_STATE_FLAG:
+ case eFMT_STATE_DOT:
+ break;
+
+ case eFMT_STATE_WIDTH:
+ case eFMT_STATE_PRECIS:
+ if (ch == '*')
+ {
+ fmtTypes.push_back( ch );
+ }
+ break;
+
+ case eFMT_STATE_SIZE:
+ switch (ch)
+ {
+ case 'l':
+ if (*pFmt == 'l')
+ {
+ ++pFmt;
+ }
+ break;
+
+ case 'I':
+ if ( (*pFmt == '6') && (*(pFmt + 1) == '4') )
+ {
+ pFmt += 2;
+ }
+ else if ( (*pFmt == '3') && (*(pFmt + 1) == '2') )
+ {
+ pFmt += 2;
+ }
+ else if ( (*pFmt == 'd')
+ || (*pFmt == 'i')
+ || (*pFmt == 'o')
+ || (*pFmt == 'u')
+ || (*pFmt == 'x')
+ || (*pFmt == 'X') )
+ {
+ // Nothing further needed
+ }
+ else
+ {
+ state = eFMT_STATE_NORMAL;
+ goto NORMAL_STATE;
+ }
+ break;
+
+ case 'h':
+ case 'w':
+ break;
+ }
+ break;
+
+ case eFMT_STATE_TYPE:
+ fmtTypes.push_back( ch );
+ break;
+ }
+ }
+
+ bOK = (state == eFMT_STATE_NORMAL || state == eFMT_STATE_TYPE);
+ return bOK;
+}
+
+/*===========================================================================
+METHOD:
+ FromString (Free Method)
+
+DESCRIPTION:
+ Convert a string to a value
+
+PARAMETERS:
+ pStr [ I ] - The string
+ theType [ O ] - Resulting value
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool FromString(
+ LPCSTR pStr,
+ CHAR & theType )
+{
+ // Assume failure
+ bool bOK = false;
+
+ if (pStr != 0)
+ {
+ LONG val = LONG_MAX;
+ bOK = StringToLONG( pStr, 0, val );
+ if (bOK == true)
+ {
+ // Reset status
+ bOK = false;
+
+ // Was this provided as a hexadecimal string?
+ if (IsHexadecimalString( pStr ) == true)
+ {
+ // Yes, the return value is a LONG, so check against
+ // the maximum range for a UCHAR, before casting to
+ // a CHAR (to pick sign back up)
+ if (val <= UCHAR_MAX)
+ {
+ // Success!
+ theType = (CHAR)val;
+ bOK = true;
+ }
+ }
+ else if (val >= SCHAR_MIN && val <= SCHAR_MAX)
+ {
+ // Success!
+ theType = (CHAR)val;
+ bOK = true;
+ }
+ }
+ }
+
+ return bOK;
+}
+
+/*===========================================================================
+METHOD:
+ FromString (Free Method)
+
+DESCRIPTION:
+ Convert a string to a value
+
+PARAMETERS:
+ pStr [ I ] - The string
+ theType [ O ] - Resulting value
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool FromString(
+ LPCSTR pStr,
+ UCHAR & theType )
+{
+ // Assume failure
+ bool bOK = false;
+
+ if (pStr != 0)
+ {
+ ULONG val = ULONG_MAX;
+ bOK = StringToULONG( pStr, 0, val );
+ if (bOK == true && val <= UCHAR_MAX)
+ {
+ // Success!
+ theType = (UCHAR)val;
+ }
+ else
+ {
+ bOK = false;
+ }
+ }
+
+ return bOK;
+}
+
+/*===========================================================================
+METHOD:
+ FromString (Free Method)
+
+DESCRIPTION:
+ Convert a string to a value
+
+PARAMETERS:
+ pStr [ I ] - The string
+ theType [ O ] - Resulting value
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool FromString(
+ LPCSTR pStr,
+ SHORT & theType )
+{
+ // Assume failure
+ bool bOK = false;
+
+ if (pStr != 0)
+ {
+ LONG val = LONG_MAX;
+ bOK = StringToLONG( pStr, 0, val );
+ if (bOK == true)
+ {
+ // Reset status
+ bOK = false;
+
+ // Was this provided as a hexadecimal string?
+ if (IsHexadecimalString( pStr ) == true)
+ {
+ // Yes, the return value is a LONG, so check against
+ // the maximum range for a USHORT, before casting to
+ // a SHORT (to pick sign back up)
+ if (val <= USHRT_MAX)
+ {
+ // Success!
+ theType = (SHORT)val;
+ bOK = true;
+ }
+ }
+ else if (val >= SHRT_MIN && val <= SHRT_MAX)
+ {
+ // Success!
+ theType = (SHORT)val;
+ bOK = true;
+ }
+ }
+ }
+
+ return bOK;
+}
+
+/*===========================================================================
+METHOD:
+ FromString (Free Method)
+
+DESCRIPTION:
+ Convert a string to a value
+
+PARAMETERS:
+ pStr [ I ] - The string
+ theType [ O ] - Resulting value
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool FromString(
+ LPCSTR pStr,
+ USHORT & theType )
+{
+ // Assume failure
+ bool bOK = false;
+
+ if (pStr != 0)
+ {
+ ULONG val = ULONG_MAX;
+ bOK = StringToULONG( pStr, 0, val );
+ if (bOK == true && val <= USHRT_MAX)
+ {
+ // Success!
+ theType = (USHORT)val;
+ }
+ else
+ {
+ bOK = false;
+ }
+ }
+
+ return bOK;
+}
+
+/*===========================================================================
+METHOD:
+ FromString (Free Method)
+
+DESCRIPTION:
+ Convert a string to a value
+
+PARAMETERS:
+ pStr [ I ] - The string
+ theType [ O ] - Resulting value
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool FromString(
+ LPCSTR pStr,
+ int & theType )
+{
+ // Assume failure
+ bool bOK = false;
+
+ if (pStr != 0)
+ {
+ LONG val = LONG_MAX;
+ bOK = StringToLONG( pStr, 0, val );
+ if (bOK == true && (val >= INT_MIN && val <= INT_MAX))
+ {
+ // Success!
+ theType = (int)val;
+ }
+ else
+ {
+ bOK = false;
+ }
+ }
+
+ return bOK;
+}
+
+/*===========================================================================
+METHOD:
+ FromString (Free Method)
+
+DESCRIPTION:
+ Convert a string to a value
+
+PARAMETERS:
+ pStr [ I ] - The string
+ theType [ O ] - Resulting value
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool FromString(
+ LPCSTR pStr,
+ UINT & theType )
+{
+ // Assume failure
+ bool bOK = false;
+
+ if (pStr != 0)
+ {
+ ULONG val = ULONG_MAX;
+ bOK = StringToULONG( pStr, 0, val );
+ if (bOK == true && val <= UINT_MAX)
+ {
+ // Success!
+ theType = (UINT)val;
+ }
+ else
+ {
+ bOK = false;
+ }
+ }
+
+ return bOK;
+}
+
+/*===========================================================================
+METHOD:
+ FromString (Free Method)
+
+DESCRIPTION:
+ Convert a string to a value
+
+PARAMETERS:
+ pStr [ I ] - The string
+ theType [ O ] - Resulting value
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool FromString(
+ LPCSTR pStr,
+ LONG & theType )
+{
+ // Assume failure
+ bool bOK = false;
+
+ if (pStr != 0)
+ {
+ LONG val = LONG_MAX;
+ bOK = StringToLONG( pStr, 0, val );
+ if (bOK == true)
+ {
+ // Success!
+ theType = val;
+ }
+ else
+ {
+ bOK = false;
+ }
+ }
+
+ return bOK;
+}
+
+/*===========================================================================
+METHOD:
+ FromString (Free Method)
+
+DESCRIPTION:
+ Convert a string to a value
+
+PARAMETERS:
+ pStr [ I ] - The string
+ theType [ O ] - Resulting value
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool FromString(
+ LPCSTR pStr,
+ ULONG & theType )
+{
+ // Assume failure
+ bool bOK = false;
+
+ if (pStr != 0)
+ {
+ ULONG val = ULONG_MAX;
+ bOK = StringToULONG( pStr, 0, val );
+ if (bOK == true)
+ {
+ // Success!
+ theType = val;
+ }
+ else
+ {
+ bOK = false;
+ }
+ }
+
+ return bOK;
+}
+
+/*===========================================================================
+METHOD:
+ FromString (Free Method)
+
+DESCRIPTION:
+ Convert a string to a value
+
+PARAMETERS:
+ pStr [ I ] - The string
+ theType [ O ] - Resulting value
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool FromString(
+ LPCSTR pStr,
+ LONGLONG & theType )
+{
+ // Assume failure
+ bool bOK = false;
+
+ if (pStr != 0)
+ {
+ LONGLONG val = LLONG_MAX;
+ bOK = StringToLONGLONG( pStr, 0, val );
+ if (bOK == true)
+ {
+ // Success!
+ theType = val;
+ }
+ else
+ {
+ bOK = false;
+ }
+ }
+
+ return bOK;
+}
+
+/*===========================================================================
+METHOD:
+ FromString (Free Method)
+
+DESCRIPTION:
+ Convert a string to a value
+
+PARAMETERS:
+ pStr [ I ] - The string
+ theType [ O ] - Resulting value
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool FromString(
+ LPCSTR pStr,
+ ULONGLONG & theType )
+{
+ // Assume failure
+ bool bOK = false;
+
+ if (pStr != 0)
+ {
+ ULONGLONG val = ULLONG_MAX;
+ bOK = StringToULONGLONG( pStr, 0, val );
+ if (bOK == true)
+ {
+ // Success!
+ theType = val;
+ }
+ else
+ {
+ bOK = false;
+ }
+ }
+
+ return bOK;
+}
+
+/*===========================================================================
+METHOD:
+ ToString (Free Method)
+
+DESCRIPTION:
+ Convert a value to a string
+
+PARAMETERS:
+ val [ I ] - The value to convert
+ pStr [ O ] - The resulting string
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool ToString(
+ CHAR val,
+ LPSTR pStr )
+{
+ // Assume failure
+ bool bOK = false;
+
+ if (pStr != 0)
+ {
+ int tmp = (int)val;
+ int rc = snprintf( pStr,
+ (size_t)(SUGGESTED_BUFFER_LEN - 1),
+ "%d",
+ tmp );
+
+ if (rc < 0)
+ {
+ pStr[0] = 0;
+ }
+ else
+ {
+ // Success!
+ bOK = true;
+ }
+ }
+
+ return bOK;
+}
+
+/*===========================================================================
+METHOD:
+ ToString (Free Method)
+
+DESCRIPTION:
+ Convert a value to a string
+
+PARAMETERS:
+ val [ I ] - The value to convert
+ pStr [ O ] - The resulting string
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool ToString(
+ UCHAR val,
+ LPSTR pStr )
+{
+ // Assume failure
+ bool bOK = false;
+
+ if (pStr != 0)
+ {
+ int rc = snprintf( pStr,
+ (size_t)(SUGGESTED_BUFFER_LEN - 1),
+ "%u",
+ (UINT)val );
+
+ if (rc < 0)
+ {
+ pStr[0] = 0;
+ }
+ else
+ {
+ // Success!
+ bOK = true;
+ }
+ }
+
+ return bOK;
+}
+
+/*===========================================================================
+METHOD:
+ ToString (Free Method)
+
+DESCRIPTION:
+ Convert a value to a string
+
+PARAMETERS:
+ val [ I ] - The value to convert
+ pStr [ O ] - The resulting string
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool ToString(
+ SHORT val,
+ LPSTR pStr )
+{
+ // Assume failure
+ bool bOK = false;
+
+ if (pStr != 0)
+ {
+ int tmp = (int)val;
+ int rc = snprintf( pStr,
+ (size_t)(SUGGESTED_BUFFER_LEN - 1),
+ "%d",
+ tmp );
+
+ if (rc < 0)
+ {
+ pStr[0] = 0;
+ }
+ else
+ {
+ // Success!
+ bOK = true;
+ }
+ }
+
+ return bOK;
+}
+
+/*===========================================================================
+METHOD:
+ ToString (Free Method)
+
+DESCRIPTION:
+ Convert a value to a string
+
+PARAMETERS:
+ val [ I ] - The value to convert
+ pStr [ O ] - The resulting string
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool ToString(
+ USHORT val,
+ LPSTR pStr )
+{
+ // Assume failure
+ bool bOK = false;
+
+ if (pStr != 0)
+ {
+ int rc = snprintf( pStr,
+ (size_t)(SUGGESTED_BUFFER_LEN - 1),
+ "%u",
+ (UINT)val );
+
+ if (rc < 0)
+ {
+ pStr[0] = 0;
+ }
+ else
+ {
+ // Success!
+ bOK = true;
+ }
+ }
+
+ return bOK;
+}
+
+/*===========================================================================
+METHOD:
+ ToString (Free Method)
+
+DESCRIPTION:
+ Convert a value to a string
+
+PARAMETERS:
+ val [ I ] - The value to convert
+ pStr [ O ] - The resulting string
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool ToString(
+ int val,
+ LPSTR pStr )
+{
+ // Assume failure
+ bool bOK = false;
+
+ if (pStr != 0)
+ {
+ int rc = snprintf( pStr,
+ (size_t)(SUGGESTED_BUFFER_LEN - 1),
+ "%d",
+ val );
+
+ if (rc < 0)
+ {
+ pStr[0] = 0;
+ }
+ else
+ {
+ // Success!
+ bOK = true;
+ }
+ }
+
+ return bOK;
+}
+
+
+/*===========================================================================
+METHOD:
+ ToString (Free Method)
+
+DESCRIPTION:
+ Convert a value to a string
+
+PARAMETERS:
+ val [ I ] - The value to convert
+ pStr [ O ] - The resulting string
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool ToString(
+ UINT val,
+ LPSTR pStr )
+{
+ // Assume failure
+ bool bOK = false;
+
+ if (pStr != 0)
+ {
+ int rc = snprintf( pStr,
+ (size_t)(SUGGESTED_BUFFER_LEN - 1),
+ "%u",
+ val );
+
+ if (rc < 0)
+ {
+ pStr[0] = 0;
+ }
+ else
+ {
+ // Success!
+ bOK = true;
+ }
+ }
+
+ return bOK;
+}
+
+/*===========================================================================
+METHOD:
+ ToString (Free Method)
+
+DESCRIPTION:
+ Convert a value to a string
+
+PARAMETERS:
+ val [ I ] - The value to convert
+ pStr [ O ] - The resulting string
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool ToString(
+ LONG val,
+ LPSTR pStr )
+{
+ // Assume failure
+ bool bOK = false;
+
+ if (pStr != 0)
+ {
+ int rc = snprintf( pStr,
+ (size_t)(SUGGESTED_BUFFER_LEN - 1),
+ "%ld",
+ val );
+
+ if (rc < 0)
+ {
+ pStr[0] = 0;
+ }
+ else
+ {
+ // Success!
+ bOK = true;
+ }
+ }
+
+ return bOK;
+}
+
+
+/*===========================================================================
+METHOD:
+ ToString (Free Method)
+
+DESCRIPTION:
+ Convert a value to a string
+
+PARAMETERS:
+ val [ I ] - The value to convert
+ pStr [ O ] - The resulting string
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool ToString(
+ ULONG val,
+ LPSTR pStr )
+{
+ // Assume failure
+ bool bOK = false;
+
+ if (pStr != 0)
+ {
+ int rc = snprintf( pStr,
+ (size_t)(SUGGESTED_BUFFER_LEN - 1),
+ "%lu",
+ val );
+
+ if (rc < 0)
+ {
+ pStr[0] = 0;
+ }
+ else
+ {
+ // Success!
+ bOK = true;
+ }
+ }
+
+ return bOK;
+}
+
+/*===========================================================================
+METHOD:
+ ToString (Free Method)
+
+DESCRIPTION:
+ Convert a value to a string
+
+PARAMETERS:
+ val [ I ] - The value to convert
+ pStr [ O ] - The resulting string
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool ToString(
+ LONGLONG val,
+ LPSTR pStr )
+{
+ // Assume failure
+ bool bOK = false;
+
+ if (pStr != 0)
+ {
+ int rc = snprintf( pStr,
+ (size_t)(SUGGESTED_BUFFER_LEN - 1),
+ "%lld",
+ val );
+
+ if (rc < 0)
+ {
+ pStr[0] = 0;
+ }
+ else
+ {
+ // Success!
+ bOK = true;
+ }
+ }
+
+ return bOK;
+}
+
+/*===========================================================================
+METHOD:
+ ToString (Free Method)
+
+DESCRIPTION:
+ Convert a value to a string
+
+PARAMETERS:
+ val [ I ] - The value to convert
+ pStr [ O ] - The resulting string
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool ToString(
+ ULONGLONG val,
+ LPSTR pStr )
+{
+ // Assume failure
+ bool bOK = false;
+
+ if (pStr != 0)
+ {
+ int rc = snprintf( pStr,
+ (size_t)(SUGGESTED_BUFFER_LEN - 1),
+ "%llu",
+ val );
+
+ if (rc < 0)
+ {
+ pStr[0] = 0;
+ }
+ else
+ {
+ // Success!
+ bOK = true;
+ }
+ }
+
+ return bOK;
+}
+
+/*===========================================================================
+METHOD:
+ GetProgramPath (Public Method)
+
+DESCRIPTION:
+ Return the special folder used for storing program files
+
+RETURN VALUE:
+ std::string (Static value of "/opt/Qualcomm/Gobi/")
+===========================================================================*/
+std::string GetProgramPath()
+{
+ // If running programs's path is desired we could
+ // use readlink with /proc/getpid()/exe
+
+ // Just using static path, as we don't want them to move it
+ std::string path = "/opt/Qualcomm/Gobi/";
+
+ return path;
+
+}
+
+/*===========================================================================
+METHOD:
+ IsFolder (Free Method)
+
+DESCRIPTION:
+ Helper function for EnumerateFolders, tells if a dirent is a folder.
+ This reduces the memory usage by scandir, as compared to checking after
+ scandir returns.
+
+PARAMETERS:
+ pFile [ I ] - dirent structure describing file
+
+RETURN VALUE:
+ int: zero - Ignore this file
+ nonzero - Process this file
+===========================================================================*/
+int IsFolder( const struct dirent * pFile )
+{
+ // Ignore anything beginning with a '.'
+ if (pFile->d_name[0] == '.')
+ {
+ return 0;
+ }
+
+ return (pFile->d_type == DT_DIR ? 1 : 0);
+}
+
+/*===========================================================================
+METHOD:
+ EnumerateFolders (Public Method)
+
+DESCRIPTION:
+ Enumerate the subfolders of the given folder (recursive)
+
+PARAMETERS:
+ baseFolder [ I ] - Folder to search in
+ foundFolders [ O ] - Fully qualified paths of found folders
+
+RETURN VALUE:
+ None
+===========================================================================*/
+void EnumerateFolders(
+ const std::string & baseFolder,
+ std::vector <std::string> & foundFolders )
+{
+ if (baseFolder.size() == 0)
+ {
+ return;
+ }
+
+ std::string folderSearch = baseFolder;
+
+ // Add trailing / if not present
+ int folderLen = folderSearch.size();
+ if (folderSearch[folderLen - 1] != '/')
+ {
+ folderSearch += '/';
+ }
+
+ dirent ** ppDevFiles;
+
+ // Yes, scandir really takes a triple pointer for its second param
+ int nNumDevFiles = scandir( folderSearch.c_str(),
+ &ppDevFiles,
+ IsFolder,
+ NULL );
+ for (int nFile = 0; nFile < nNumDevFiles; nFile++)
+ {
+ std::string newFolder = folderSearch + ppDevFiles[nFile]->d_name;
+ free( ppDevFiles[nFile] );
+
+ foundFolders.push_back( newFolder );
+ EnumerateFolders( newFolder, foundFolders );
+ }
+
+ if (nNumDevFiles != -1)
+ {
+ free( ppDevFiles );
+ }
+}
+
+/*===========================================================================
+METHOD:
+ IsHidden (Free Method)
+
+DESCRIPTION:
+ Helper function for DepthSearch, tells if a dirent is a hidden file.
+ This reduces the memory usage by scandir, as compared to checking after
+ scandir returns.
+
+PARAMETERS:
+ pFile [ I ] - dirent structure describing file
+
+RETURN VALUE:
+ int: zero - Ignore this file
+ nonzero - Process this file
+===========================================================================*/
+int IsHidden( const struct dirent * pFile )
+{
+ // Ignore anything beginning with a '.'
+ if (pFile->d_name[0] == '.')
+ {
+ return 0;
+ }
+
+ return 1;
+}
+
+/*===========================================================================
+METHOD:
+ DepthSearch (Public Method)
+
+DESCRIPTION:
+ Search for all matching files at a specified depth (recursive)
+
+PARAMETERS:
+ baseFolder [ I ] - Folder to search in
+ depth [ I ] - Depth
+ name [ I ] - Partial name of file to search for
+ foundFolders [ O ] - Fully qualified paths of found files
+
+RETURN VALUE:
+ None
+===========================================================================*/
+void DepthSearch(
+ const std::string & baseFolder,
+ int depth,
+ std::string name,
+ std::vector <std::string> & foundFiles )
+{
+ if (baseFolder.size() == 0
+ || name.size() == 0
+ || depth < 0)
+ {
+ return;
+ }
+
+ std::string folderSearch = baseFolder;
+
+ // Add trailing / if not present
+ int folderLen = folderSearch.size();
+ if (folderSearch[folderLen - 1] != '/')
+ {
+ folderSearch += '/';
+ }
+
+ dirent ** ppDevFiles;
+
+ // Yes, scandir really takes a triple pointer for its second param
+ int nNumDevFiles = scandir( folderSearch.c_str(),
+ &ppDevFiles,
+ IsHidden,
+ NULL );
+ for (int nFile = 0; nFile < nNumDevFiles; nFile++)
+ {
+ std::string newFile = ppDevFiles[nFile]->d_name;
+
+ // Recurse or not?
+ if (depth == 0)
+ {
+ if (newFile.find( name ) != std::string::npos)
+ {
+ foundFiles.push_back( folderSearch + newFile );
+ }
+ }
+ else
+ {
+ DepthSearch( folderSearch + newFile,
+ depth - 1,
+ name,
+ foundFiles );
+ }
+ }
+
+ if (nNumDevFiles != -1)
+ {
+ free( ppDevFiles );
+ }
+}
+
diff --git a/gobi-api/GobiAPI_1.0.40/Core/CoreUtilities.h b/gobi-api/GobiAPI_1.0.40/Core/CoreUtilities.h
new file mode 100755
index 0000000..54e0ee0
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/CoreUtilities.h
@@ -0,0 +1,657 @@
+/*===========================================================================
+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()
+ DepthSearch()
+
+ 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 );
+
+// Search for a file at a given depth
+void DepthSearch(
+ const std::string & baseFolder,
+ int depth,
+ std::string name,
+ std::vector <std::string> & foundFiles );
+
+/*=========================================================================*/
+// 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;
+}
+
diff --git a/gobi-api/GobiAPI_1.0.40/Core/DB2NavTree.cpp b/gobi-api/GobiAPI_1.0.40/Core/DB2NavTree.cpp
new file mode 100755
index 0000000..3705dcf
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/DB2NavTree.cpp
@@ -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;
+}
diff --git a/gobi-api/GobiAPI_1.0.40/Core/DB2NavTree.h b/gobi-api/GobiAPI_1.0.40/Core/DB2NavTree.h
new file mode 100755
index 0000000..a1745ba
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/DB2NavTree.h
@@ -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;
+};
+
+
diff --git a/gobi-api/GobiAPI_1.0.40/Core/DB2TextFile.cpp b/gobi-api/GobiAPI_1.0.40/Core/DB2TextFile.cpp
new file mode 100755
index 0000000..aaebdf5
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/DB2TextFile.cpp
@@ -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;
+}
+
diff --git a/gobi-api/GobiAPI_1.0.40/Core/DB2TextFile.h b/gobi-api/GobiAPI_1.0.40/Core/DB2TextFile.h
new file mode 100755
index 0000000..8ecb1cb
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/DB2TextFile.h
@@ -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;
+};
diff --git a/gobi-api/GobiAPI_1.0.40/Core/DB2Utilities.cpp b/gobi-api/GobiAPI_1.0.40/Core/DB2Utilities.cpp
new file mode 100755
index 0000000..0e40c6d
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/DB2Utilities.cpp
@@ -0,0 +1,907 @@
+/*===========================================================================
+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 (but not too much)
+ ULONG tlvs = (ULONG)input.size();
+ if (tlvs == 0 || tlvs > (ULONG)UCHAR_MAX)
+ {
+ 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 t = 0;
+ for (t = 0; t < tlvs; t++)
+ {
+ const sDB2NavInput & tlvInput = input[t];
+ if (tlvInput.mPayloadLen > QMI_MAX_BUFFER_SIZE)
+ {
+ return pRef;
+ }
+ }
+
+ ULONG szReq = szTransHdr + szMsgHdr + (tlvs * szTLVHdr);
+ szReq += tlvInput.mPayloadLen;
+
+ 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 (but not too much)
+ ULONG tlvs = (ULONG)input.size();
+ if (tlvs == 0 || tlvs > (ULONG)UCHAR_MAX)
+ {
+ 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 = 0; t < tlvs; t++)
+ {
+ const sDB2PackingInput & tlvInput = input[t];
+ if (tlvInput.mDataLen > QMI_MAX_BUFFER_SIZE)
+ {
+ return pRef;
+ }
+ }
+
+ 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;
+}
diff --git a/gobi-api/GobiAPI_1.0.40/Core/DB2Utilities.h b/gobi-api/GobiAPI_1.0.40/Core/DB2Utilities.h
new file mode 100755
index 0000000..b3223e1
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/DB2Utilities.h
@@ -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 );
+
diff --git a/gobi-api/GobiAPI_1.0.40/Core/DataPacker.cpp b/gobi-api/GobiAPI_1.0.40/Core/DataPacker.cpp
new file mode 100755
index 0000000..16107b3
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/DataPacker.cpp
@@ -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;
+}
diff --git a/gobi-api/GobiAPI_1.0.40/Core/DataPacker.h b/gobi-api/GobiAPI_1.0.40/Core/DataPacker.h
new file mode 100755
index 0000000..13af0d7
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/DataPacker.h
@@ -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;
+};
diff --git a/gobi-api/GobiAPI_1.0.40/Core/DataParser.cpp b/gobi-api/GobiAPI_1.0.40/Core/DataParser.cpp
new file mode 100755
index 0000000..24bc2df
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/DataParser.cpp
@@ -0,0 +1,1118 @@
+/*===========================================================================
+FILE:
+ DataParser.cpp
+
+DESCRIPTION:
+ Implementation 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.
+===========================================================================*/
+
+//---------------------------------------------------------------------------
+// Include Files
+//---------------------------------------------------------------------------
+#include "StdAfx.h"
+#include "DataParser.h"
+
+#include "CoreDatabase.h"
+#include "DB2Utilities.h"
+
+#include <climits>
+
+//---------------------------------------------------------------------------
+// Definitions
+//---------------------------------------------------------------------------
+
+/*=========================================================================*/
+// sParsedField Methods
+/*=========================================================================*/
+
+/*===========================================================================
+METHOD:
+ sParsedField (Public Method)
+
+DESCRIPTION:
+ Construct a parsed field by setting the values and extracting
+ the data according to the definition
+
+PARAMETERS:
+ db [ I ] - Database to use
+ field [ I ] - Field description (from database)
+ name [ I ] - Desired field name
+ bp [I/O] - Bit parser to use
+ bGenStrings [ I ] - Generate field value strings?
+
+ NOTE: 'bGenStrings' does not apply to fields that are string types?
+
+RETURN VALUE:
+ None
+===========================================================================*/
+sParsedField::sParsedField(
+ const cCoreDatabase & db,
+ const sDB2Field * pField,
+ const std::string & name,
+ cBitParser & bp,
+ bool bGenStrings )
+ : mField(),
+ mOffset( bp.GetNumBitsParsed() ),
+ mValueString( "" ),
+ mName( name ),
+ mbValid( false )
+{
+ // Clear value
+ memset( (PVOID)&mValue, 0, (SIZE_T)sizeof( mValue ) );
+
+ // Assume failure
+ bool bOK = false;
+ if (pField == 0)
+ {
+ return;
+ }
+
+ mField = *pField;
+
+ char tempValueString[128];
+ memset( &tempValueString[0], 0, 128 );
+
+ // What type is this field?
+ switch (mField.mType)
+ {
+ case eDB2_FIELD_STD:
+ {
+ // Standard field, what kind?
+ eDB2StdFieldType ft = (eDB2StdFieldType)mField.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 store as a UCHAR
+ UCHAR val;
+ DWORD rc = bp.Get( mField.mSize, val );
+ if (rc == NO_ERROR)
+ {
+ // Constrain boolean values?
+ if (ft == eDB2_FIELD_STDTYPE_BOOL && val > 1)
+ {
+ val = 1;
+ }
+
+ // Success!
+ mValue.mU8 = val;
+ bOK = true;
+
+ if (bGenStrings == true)
+ {
+ if (mField.mbHex == true)
+ {
+ snprintf( &tempValueString[0], 0, "0x%02X", (UINT)mValue.mU8 );
+ }
+ else
+ {
+ snprintf( &tempValueString[0], 0, "%u", (UINT)mValue.mU8 );
+ }
+ mValueString = &tempValueString[0];
+ }
+ }
+ }
+ break;
+
+ // Field is 8-bit signed integer
+ case eDB2_FIELD_STDTYPE_INT8:
+ {
+ // We store as a CHAR
+ CHAR val;
+ DWORD rc = bp.Get( mField.mSize, val );
+ if (rc == NO_ERROR)
+ {
+ // Success!
+ mValue.mS8 = val;
+ bOK = true;
+
+ if (bGenStrings == true)
+ {
+ if (mField.mbHex == true)
+ {
+ snprintf( &tempValueString[0], 0, "0x%02X", (UINT)mValue.mU8 );
+ }
+ else
+ {
+ snprintf( &tempValueString[0], 0, "%d", (INT)mValue.mS8 );
+ }
+ mValueString = &tempValueString[0];
+ }
+ }
+ }
+ break;
+
+ // Field is 16-bit signed integer
+ case eDB2_FIELD_STDTYPE_INT16:
+ {
+ // We store as a SHORT
+ SHORT val;
+ DWORD rc = bp.Get( mField.mSize, val );
+ if (rc == NO_ERROR)
+ {
+ // Success!
+ mValue.mS16 = val;
+ bOK = true;
+
+ if (bGenStrings == true)
+ {
+ if (mField.mbHex == true)
+ {
+ snprintf( &tempValueString[0], 0, "0x%04hX", mValue.mU16 );
+ }
+ else
+ {
+ snprintf( &tempValueString[0], 0, "%hd", mValue.mS16 );
+ }
+ mValueString = &tempValueString[0];
+ }
+ }
+ }
+ break;
+
+ // Field is 16-bit unsigned integer
+ case eDB2_FIELD_STDTYPE_UINT16:
+ {
+ // We store as a USHORT
+ USHORT val;
+ DWORD rc = bp.Get( mField.mSize, val );
+ if (rc == NO_ERROR)
+ {
+ // Success!
+ mValue.mU16 = val;
+ bOK = true;
+
+ if (bGenStrings == true)
+ {
+ if (mField.mbHex == true)
+ {
+ snprintf( &tempValueString[0], 0, "0x%04hX", mValue.mU16 );
+ }
+ else
+ {
+ snprintf( &tempValueString[0], 0, "%hu", mValue.mU16 );
+ }
+ mValueString = &tempValueString[0];
+ }
+ }
+ }
+ break;
+
+ // Field is 32-bit signed integer
+ case eDB2_FIELD_STDTYPE_INT32:
+ {
+ // We store as a LONG
+ LONG val;
+ DWORD rc = bp.Get( mField.mSize, val );
+ if (rc == NO_ERROR)
+ {
+ // Success!
+ mValue.mS32 = val;
+ bOK = true;
+
+ if (bGenStrings == true)
+ {
+ if (mField.mbHex == true)
+ {
+ snprintf( &tempValueString[0], 0, "0x%08lX", mValue.mU32 );
+ }
+ else
+ {
+ snprintf( &tempValueString[0], 0, "%ld", mValue.mS32 );
+ }
+ mValueString = &tempValueString[0];
+ }
+ }
+ }
+ break;
+
+ // Field is 32-bit unsigned integer
+ case eDB2_FIELD_STDTYPE_UINT32:
+ {
+ // We store as a ULONG
+ ULONG val;
+ DWORD rc = bp.Get( mField.mSize, val );
+ if (rc == NO_ERROR)
+ {
+ // Success!
+ mValue.mU32 = val;
+ bOK = true;
+
+ if (bGenStrings == true)
+ {
+ if (mField.mbHex == true)
+ {
+ snprintf( &tempValueString[0], 0, "0x%08lX", mValue.mU32 );
+ }
+ else
+ {
+ snprintf( &tempValueString[0], 0, "%lu", mValue.mU32 );
+ }
+ mValueString = &tempValueString[0];
+ }
+ }
+ }
+ break;
+
+ // Field is 64-bit signed integer
+ case eDB2_FIELD_STDTYPE_INT64:
+ {
+ // We store as a LONGLONG
+ LONGLONG val;
+ DWORD rc = bp.Get( mField.mSize, val );
+ if (rc == NO_ERROR)
+ {
+ // Success!
+ mValue.mS64 = val;
+ bOK = true;
+
+ if (bGenStrings == true)
+ {
+ if (mField.mbHex == true)
+ {
+ snprintf( &tempValueString[0], 0, "0x%016llX", mValue.mU64 );
+ }
+ else
+ {
+ snprintf( &tempValueString[0], 0, "%lld", mValue.mS64 );
+ }
+ mValueString = &tempValueString[0];
+ }
+ }
+ }
+ break;
+
+ // Field is 64-bit unsigned integer
+ case eDB2_FIELD_STDTYPE_UINT64:
+ {
+ // We store as a ULONGLONG
+ ULONGLONG val;
+ DWORD rc = bp.Get( mField.mSize, val );
+ if (rc == NO_ERROR)
+ {
+ // Success!
+ mValue.mU64 = val;
+ bOK = true;
+
+ if (bGenStrings == true)
+ {
+ if (mField.mbHex == true)
+ {
+ snprintf( &tempValueString[0], 0, "0x%016llX", mValue.mU64 );
+ }
+ else
+ {
+ snprintf( &tempValueString[0], 0, "%llu", mValue.mU64 );
+ }
+ mValueString = &tempValueString[0];
+ }
+ }
+ }
+ break;
+
+ // ANSI/UNICODE fixed length string
+ case eDB2_FIELD_STDTYPE_STRING_A:
+ case eDB2_FIELD_STDTYPE_STRING_U:
+ {
+ // Compute the number of characters
+ ULONG numChars = mField.mSize / BITS_PER_BYTE;
+
+ // Parse out the string
+ bOK = ParseString( numChars, bp );
+ }
+ break;
+
+ // ANSI NULL terminated string
+ case eDB2_FIELD_STDTYPE_STRING_ANT:
+ {
+ // Figure out the length of the string
+ ULONG numChars = 0;
+
+ // Temporarily assume success
+ bOK = true;
+
+ ULONG tmpOffset = bp.GetNumBitsParsed();
+
+ CHAR val = 1;
+ while (val != 0)
+ {
+ DWORD rc = bp.Get( BITS_PER_BYTE, val );
+ if (rc == NO_ERROR)
+ {
+ numChars++;
+ }
+ else
+ {
+ val = 0;
+ }
+ }
+
+ // Now actually parse/load the string
+ if (bOK == true)
+ {
+ bp.SetOffset( tmpOffset );
+ bOK = ParseString( numChars, bp );
+ }
+ }
+ break;
+
+ // UNICODE NULL terminated string
+ case eDB2_FIELD_STDTYPE_STRING_UNT:
+ {
+ // Figure out the length of the string
+ ULONG numChars = 0;
+
+ // Temporarily assume success
+ bOK = true;
+
+ ULONG tmpOffset = bp.GetNumBitsParsed();
+
+ USHORT val = 1;
+ while (val != 0)
+ {
+ DWORD rc = bp.Get( BITS_PER_BYTE, val );
+ if (rc == NO_ERROR)
+ {
+ numChars++;
+ }
+ else
+ {
+ val = 0;
+ }
+ }
+
+ // Now actually parse/load the string
+ if (bOK == true)
+ {
+ bp.SetOffset( tmpOffset );
+ bOK = ParseString( numChars, bp );
+ }
+ }
+ break;
+
+ 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 store as a ULONG
+ ULONG val;
+ DWORD rc = bp.Get( mField.mSize, val );
+ if (rc == NO_ERROR)
+ {
+ FLOAT * pFloat = (FLOAT *)&val;
+
+ // Success!
+ mValue.mFP32 = *pFloat;
+ bOK = true;
+
+ if (bGenStrings == true)
+ {
+ if (mField.mbHex == true)
+ {
+ snprintf( &tempValueString[0], 0, "0x%04lX", mValue.mU32 );
+ }
+ else
+ {
+ snprintf( &tempValueString[0], 0, "%f", mValue.mFP32 );
+ }
+ mValueString = &tempValueString[0];
+ }
+ }
+ }
+ break;
+
+ // Field is 64-bit floating point value
+ case eDB2_FIELD_STDTYPE_FLOAT64:
+ {
+ // We store as a ULONGLONG
+ ULONGLONG val;
+ DWORD rc = bp.Get( mField.mSize, val );
+ if (rc == NO_ERROR)
+ {
+ DOUBLE * pFloat = (DOUBLE *)&val;
+
+ // Success!
+ mValue.mFP64 = *pFloat;
+ bOK = true;
+
+ if (bGenStrings == true)
+ {
+ if (mField.mbHex == true)
+ {
+ snprintf( &tempValueString[0], 0, "0x%08llX", mValue.mU64 );
+ }
+ else
+ {
+ snprintf( &tempValueString[0], 0, "%f", mValue.mFP64 );
+ }
+ mValueString = &tempValueString[0];
+ }
+ }
+ }
+ break;
+ }
+ }
+ break;
+
+ // Unsigend enum value
+ case eDB2_FIELD_ENUM_UNSIGNED:
+ {
+ // We store as a ULONG
+ ULONG val;
+ DWORD rc = bp.Get( mField.mSize, val );
+ if (rc == NO_ERROR)
+ {
+ // Success!
+ mValue.mU32 = val;
+ bOK = true;
+
+ // Grab the enum ID
+ ULONG id = pField->mTypeVal;
+
+ // Map to a string?
+ if (bGenStrings == true)
+ {
+ mValueString = db.MapEnumToString( id,
+ (int)mValue.mU32,
+ true,
+ mField.mbHex );
+ }
+ }
+ }
+ break;
+
+ // Signed enum value
+ case eDB2_FIELD_ENUM_SIGNED:
+ {
+ // We store as a LONG
+ LONG val;
+ DWORD rc = bp.Get( mField.mSize, val );
+ if (rc == NO_ERROR)
+ {
+ // Success!
+ mValue.mS32 = val;
+ bOK = true;
+
+ // Grab the enum ID
+ ULONG id = pField->mTypeVal;
+
+ // Map to a string?
+ if (bGenStrings == true)
+ {
+ mValueString = db.MapEnumToString( id,
+ (int)mValue.mS32,
+ true,
+ mField.mbHex );
+ }
+ }
+ }
+ break;
+ }
+
+ mbValid = bOK;
+}
+
+/*===========================================================================
+METHOD:
+ ParseString (Public Method)
+
+DESCRIPTION:
+ Convert the field value to a string
+
+PARAMETERS:
+ numChars [ I ] - Number of characters to parse/load
+ bp [I/O] - Bit parser to use
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool sParsedField::ParseString(
+ ULONG numChars,
+ cBitParser & bp )
+{
+ // Validate size (including null char)
+ if (MAX_SHARED_BUFFER_SIZE < numChars + 1)
+ {
+ return false;
+ }
+
+ // Assume success
+ bool bRC = true;
+
+ // Store current offset so we can update field length
+ ULONG curOffset = bp.GetNumBitsParsed();
+
+ // Load each byte of the string individually
+ BYTE buf[MAX_SHARED_BUFFER_SIZE];
+ for (ULONG c = 0; c < numChars; c++)
+ {
+ BYTE val = 0;
+ DWORD rc = bp.Get( BITS_PER_BYTE, val );
+ if (rc == NO_ERROR)
+ {
+ buf[c] = val;
+ }
+ else
+ {
+ bRC = false;
+ break;
+ }
+ }
+
+ if (bRC == true)
+ {
+ // Write zeros to the rest of the buffer
+ ULONG size = numChars;
+ ULONG end = numChars + 1;
+ for (ULONG current = size; current < end; current++)
+ {
+ buf[current] = 0;
+ }
+
+ mValueString = (LPCSTR)&buf[0];
+
+ mValue.mpAStr = (LPCSTR)mValueString.c_str();
+
+ // Update field size
+ mField.mSize = bp.GetNumBitsParsed() - curOffset;
+ }
+
+ return bRC;
+}
+
+/*=========================================================================*/
+// cParsedFieldNavigator Methods
+/*=========================================================================*/
+
+/*===========================================================================
+METHOD:
+ GetFieldIndex (Public Method)
+
+DESCRIPTION:
+ Get index of the (first) field that matches the given field ID
+
+PARAMETERS:
+ fieldID [ I ] - Field ID to look for
+ bLoop [ I ] - Loop around end of field list?
+
+RETURN VALUE:
+ ULONG - Index of the field (0xFFFFFFFF upon failure)
+===========================================================================*/
+ULONG cParsedFieldNavigator::GetFieldIndex(
+ ULONG fieldID,
+ bool bLoop ) const
+{
+ ULONG id = ULONG_MAX;
+ ULONG count = (ULONG)mFields.size();
+
+ // Start from last field ID?
+ ULONG fp = 0;
+ ULONG fi = 0;
+ if (mLastIDIndex < count)
+ {
+ fi = mLastIDIndex;
+ }
+ else if (mLastIDIndex != ULONG_MAX && bLoop == false)
+ {
+ // Beyond end of fields with no looping
+ mLastIDIndex = id;
+ return id;
+ }
+
+ for (fp = 0; fp < count; fp++)
+ {
+ if (mFields[fi].mField.mID == fieldID)
+ {
+ id = fi;
+ break;
+ }
+
+ fi++;
+ if (fi == count)
+ {
+ if (bLoop == true)
+ {
+ fi = 0;
+ }
+ else
+ {
+ break;
+ }
+ }
+ }
+
+ // Update last ID accordingly (0xFFFFFFFF upon failure), and return
+ mLastIDIndex = id;
+ if (mLastIDIndex != ULONG_MAX)
+ {
+ mLastIDIndex++;
+ if (mLastIDIndex == count)
+ {
+ mLastIDIndex = 0;
+ }
+ }
+
+ return id;
+}
+
+/*=========================================================================*/
+// cDataParser Methods
+/*=========================================================================*/
+
+/*===========================================================================
+METHOD:
+ cDataParser (Public Method)
+
+DESCRIPTION:
+ Constructor (protocol buffer, entity key, and payload)
+
+PARAMETERS:
+ db [ I ] - Database to use
+ buffer [ I ] - The protocol buffer being parsed
+ key [ I ] - Protocol entity key
+ pData [ I ] - Payload from above protocol buffer
+ dataLen [ I ] - Size of above payload
+
+RETURN VALUE:
+ None
+===========================================================================*/
+cDataParser::cDataParser(
+ const cCoreDatabase & db,
+ const sProtocolBuffer & buffer,
+ const std::vector <ULONG> & key,
+ const BYTE * pData,
+ ULONG dataLen )
+ : cProtocolEntityNav( db ),
+ mBuffer( buffer.GetSharedBuffer() ),
+ mbFieldStrings( true ),
+ mbParsed( false )
+{
+ // We must have a valid protocol buffer
+ if (mBuffer.IsValid() == false)
+ {
+ return;
+ }
+
+ // We need something to parse
+ if (pData == 0 || dataLen == 0)
+ {
+ return;
+ }
+
+ // Key has to be proper
+ if (key.size() < 1)
+ {
+ return;
+ }
+
+ // Key needs to match protocol
+ eProtocolType pt = (eProtocolType)mBuffer.GetType();
+ eDB2EntityType et = (eDB2EntityType)key[0];
+
+ if (pt == ePROTOCOL_DIAG_RX || pt == ePROTOCOL_DIAG_TX)
+ {
+ if (IsDiagEntityType( et ) == false)
+ {
+ return;
+ }
+ }
+
+ else if (IsQMIProtocol( pt ) == true)
+ {
+ if (IsQMIEntityType( et ) == false)
+ {
+ return;
+ }
+ }
+
+ // Pass data to the bit parser
+ mKey = key;
+ mBitsy.SetData( pData, dataLen * BITS_PER_BYTE );
+}
+
+/*===========================================================================
+METHOD:
+ ~cDataParser (Public Method)
+
+DESCRIPTION:
+ Destructor
+
+RETURN VALUE:
+ None
+===========================================================================*/
+cDataParser::~cDataParser()
+{
+ // Ask bit parser to release data
+ mBitsy.ReleaseData();
+
+ // Empty fields
+ mFields.clear();
+}
+
+/*===========================================================================
+METHOD:
+ Parse (Public Method)
+
+DESCRIPTION:
+ Parse the data to a list of fields/summary text
+
+PARAMETERS:
+ bFieldStrings [ I ] - Generate string representations of field values?
+ bFieldNames [ I ] - Generate (partial) field names?
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cDataParser::Parse(
+ bool bFieldStrings,
+ bool bFieldNames )
+{
+ // Store parsing options
+ mbFieldStrings = bFieldStrings;
+ mbFieldNames = bFieldNames;
+
+ if (mbParsed == false)
+ {
+ // Allocate space for 1024 fields up front in order to increase
+ // performance when parsing and accessing parsed fields
+ mFields.reserve( 1024 );
+
+ // Process (parse) the protocol entity
+ mbParsed = ProcessEntity( mKey );
+ }
+
+ return mbParsed;
+}
+
+
+/*===========================================================================
+METHOD:
+ GetLastValue (Internal Method)
+
+DESCRIPTION:
+ 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 in a LONGLONG for a value to be returned)
+
+PARAMETERS:
+ fieldID [ I ] - Field ID we are looking for
+ val [ O ] - The value
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cDataParser::GetLastValue(
+ ULONG fieldID,
+ LONGLONG & val )
+{
+ // Assume failure
+ bool bRC = false;
+
+ // Use field value tracking information
+ std::map <ULONG, std::pair <bool, LONGLONG> >::iterator pTF;
+ pTF = mTrackedFields.find( fieldID );
+ if (pTF != mTrackedFields.end() && pTF->second.first == true)
+ {
+ val = pTF->second.second;
+ bRC = true;
+ }
+
+ return bRC;
+}
+
+/*===========================================================================
+METHOD:
+ ContinueNavigation (Internal Method)
+
+DESCRIPTION:
+ Continue navigation now that entity has been set?
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cDataParser::ContinueNavigation()
+{
+ // Proceed to parse?
+ bool bParse = true;
+
+ // Is there actually something to process?
+ if (mBitsy.GetNumBitsLeft() == 0)
+ {
+ bParse = false;
+ }
+
+ return bParse;
+}
+
+/*===========================================================================
+METHOD:
+ ProcessField (Internal Method)
+
+DESCRIPTION:
+ Process the given field by parsing the value
+
+PARAMETERS:
+ pField [ I ] - The field being processed
+ fieldName [ I ] - Field name (partial)
+ arrayIndex [ I ] - Not used
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cDataParser::ProcessField(
+ const sDB2Field * pField,
+ const std::string & fieldName,
+ LONGLONG /* arrayIndex */ )
+{
+ // Assume failure
+ bool bRC = false;
+ if (pField == 0)
+ {
+ return bRC;
+ }
+
+ // We must have a name
+ sParsedField theField( mDB,
+ pField,
+ fieldName,
+ mBitsy,
+ mbFieldStrings );
+
+ // Did that result in a valid field?
+ if (theField.IsValid() == true)
+ {
+ // Add field
+ mFields.push_back( theField );
+ bRC = true;
+
+ // Are we tracking the value of this field?
+ std::map <ULONG, std::pair <bool, LONGLONG> >::iterator pTF;
+ pTF = mTrackedFields.find( pField->mID );
+ if (pTF != mTrackedFields.end())
+ {
+ std::pair <bool, LONGLONG> & entry = pTF->second;
+
+ // 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
+ case eDB2_FIELD_STDTYPE_BOOL:
+ case eDB2_FIELD_STDTYPE_UINT8:
+ {
+ // Treat as UCHAR
+ entry.second = (LONGLONG)theField.mValue.mU8;
+ entry.first = true;
+ }
+ break;
+
+ // Field is 8-bit signed integer
+ case eDB2_FIELD_STDTYPE_INT8:
+ {
+ // Treat as CHAR
+ entry.second = (LONGLONG)theField.mValue.mS8;
+ entry.first = true;
+ }
+ break;
+
+ // Field is 16-bit signed integer
+ case eDB2_FIELD_STDTYPE_INT16:
+ {
+ // Treat as SHORT
+ entry.second = (LONGLONG)theField.mValue.mS16;
+ entry.first = true;
+ }
+ break;
+
+ // Field is 16-bit unsigned integer
+ case eDB2_FIELD_STDTYPE_UINT16:
+ {
+ // Treat as USHORT
+ entry.second = (LONGLONG)theField.mValue.mU16;
+ entry.first = true;
+ }
+ break;
+
+ // Field is 32-bit signed integer
+ case eDB2_FIELD_STDTYPE_INT32:
+ {
+ // Treat as LONG
+ entry.second = (LONGLONG)theField.mValue.mS32;
+ entry.first = true;
+ }
+ break;
+
+ // Field is 32-bit unsigned integer
+ case eDB2_FIELD_STDTYPE_UINT32:
+ {
+ // Treat as ULONG
+ entry.second = (LONGLONG)theField.mValue.mU32;
+ entry.first = true;
+ }
+ break;
+
+ // Field is 64-bit signed integer
+ case eDB2_FIELD_STDTYPE_INT64:
+ {
+ // Treat as LONGLONG
+ entry.second = (LONGLONG)theField.mValue.mS64;
+ entry.first = true;
+ }
+ break;
+
+ // Field is 64-bit unsigned integer
+ case eDB2_FIELD_STDTYPE_UINT64:
+ {
+ // Treat as ULONGLONG
+ if (theField.mValue.mU64 <= LLONG_MAX)
+ {
+ entry.second = (LONGLONG)theField.mValue.mU64;
+ entry.first = true;
+ }
+ }
+ break;
+ }
+ }
+ break;
+
+ case eDB2_FIELD_ENUM_UNSIGNED:
+ {
+ // Treat as ULONG
+ entry.second = (LONGLONG)theField.mValue.mU32;
+ entry.first = true;
+ }
+ break;
+
+ case eDB2_FIELD_ENUM_SIGNED:
+ {
+ // Treat as LONG
+ entry.second = (LONGLONG)theField.mValue.mS32;
+ entry.first = true;
+ }
+ break;
+ }
+ }
+ }
+
+ return bRC;
+}
+
+/*===========================================================================
+METHOD:
+ HandleSpecialCases (Internal Method)
+
+DESCRIPTION:
+ Handle special case processing for summary text generation
+
+ NOTE: This should only be added to as a last resort
+
+PARAMETERS:
+ args [I/O] - Current argument list/updated 'special' argument list
+ fs [I/O] - Current format specifier/updated 'special' format
+ specifier
+
+RETURN VALUE:
+ None
+===========================================================================*/
+void cDataParser::HandleSpecialCases(
+ std::string & args,
+ std::string & fs )
+{
+ std::vector <ULONG> key = mEntity.GetKey();
+ if (key.size() == 2 && key[0] == (ULONG)eDB2_ET_DIAG_EVENT)
+ {
+ ULONG id = key[1];
+
+ mBitsy.SetOffset( 0 );
+ ULONG lenInBits = mBitsy.GetNumBitsLeft();
+
+ switch (id)
+ {
+ case 276:
+ if (lenInBits == 16)
+ {
+ // Old style idle handoff event, remap summary
+ args = "idle_handoff";
+ fs = "idle_handoff=%u";
+ }
+ break;
+
+ case 277:
+ if (lenInBits == 16)
+ {
+ // Old style access handoff event, remap summary
+ args = "ms_access_handoff";
+ fs = "ms_access_handoff=%u";
+ }
+ break;
+
+ case 278:
+ if (lenInBits == 16)
+ {
+ // Old style access probe handoff event, remap summary
+ args = "ms_access_probe_handoff";
+ fs = "ms_access_probe_handoff=%u";
+ }
+ break;
+
+ case 639:
+ if (lenInBits == 16)
+ {
+ // Old style access entry handoff event, remap summary
+ args = "ms_access_handoff";
+ fs = "ms_access_handoff=%u";
+ }
+ break;
+ }
+ }
+}
+
diff --git a/gobi-api/GobiAPI_1.0.40/Core/DataParser.h b/gobi-api/GobiAPI_1.0.40/Core/DataParser.h
new file mode 100755
index 0000000..5435046
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/DataParser.h
@@ -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;
+};
+
diff --git a/gobi-api/GobiAPI_1.0.40/Core/Event.cpp b/gobi-api/GobiAPI_1.0.40/Core/Event.cpp
new file mode 100755
index 0000000..2b1211e
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/Event.cpp
@@ -0,0 +1,437 @@
+/*===========================================================================
+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"
+
+/*===========================================================================
+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;
+} \ No newline at end of file
diff --git a/gobi-api/GobiAPI_1.0.40/Core/Event.h b/gobi-api/GobiAPI_1.0.40/Core/Event.h
new file mode 100755
index 0000000..43db20d
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/Event.h
@@ -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 );
+};
+
diff --git a/gobi-api/GobiAPI_1.0.40/Core/HDLC.cpp b/gobi-api/GobiAPI_1.0.40/Core/HDLC.cpp
new file mode 100755
index 0000000..10c3689
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/HDLC.cpp
@@ -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
diff --git a/gobi-api/GobiAPI_1.0.40/Core/HDLC.h b/gobi-api/GobiAPI_1.0.40/Core/HDLC.h
new file mode 100755
index 0000000..91a1a75
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/HDLC.h
@@ -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
diff --git a/gobi-api/GobiAPI_1.0.40/Core/HDLCProtocolServer.cpp b/gobi-api/GobiAPI_1.0.40/Core/HDLCProtocolServer.cpp
new file mode 100755
index 0000000..7c92a8b
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/HDLCProtocolServer.cpp
@@ -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;
+}
diff --git a/gobi-api/GobiAPI_1.0.40/Core/HDLCProtocolServer.h b/gobi-api/GobiAPI_1.0.40/Core/HDLCProtocolServer.h
new file mode 100755
index 0000000..58b3d8f
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/HDLCProtocolServer.h
@@ -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;
+};
diff --git a/gobi-api/GobiAPI_1.0.40/Core/Makefile.am b/gobi-api/GobiAPI_1.0.40/Core/Makefile.am
new file mode 100644
index 0000000..d036d62
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/Makefile.am
@@ -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
+
diff --git a/gobi-api/GobiAPI_1.0.40/Core/MemoryMappedFile.cpp b/gobi-api/GobiAPI_1.0.40/Core/MemoryMappedFile.cpp
new file mode 100755
index 0000000..ec1709e
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/MemoryMappedFile.cpp
@@ -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;
+ }
+ }
+}
diff --git a/gobi-api/GobiAPI_1.0.40/Core/MemoryMappedFile.h b/gobi-api/GobiAPI_1.0.40/Core/MemoryMappedFile.h
new file mode 100755
index 0000000..180aa88
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/MemoryMappedFile.h
@@ -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;
+};
diff --git a/gobi-api/GobiAPI_1.0.40/Core/ProtocolBuffer.cpp b/gobi-api/GobiAPI_1.0.40/Core/ProtocolBuffer.cpp
new file mode 100755
index 0000000..7171d62
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/ProtocolBuffer.cpp
@@ -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;
+}
diff --git a/gobi-api/GobiAPI_1.0.40/Core/ProtocolBuffer.h b/gobi-api/GobiAPI_1.0.40/Core/ProtocolBuffer.h
new file mode 100755
index 0000000..1c34747
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/ProtocolBuffer.h
@@ -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;
+};
diff --git a/gobi-api/GobiAPI_1.0.40/Core/ProtocolEntityFieldEnumerator.h b/gobi-api/GobiAPI_1.0.40/Core/ProtocolEntityFieldEnumerator.h
new file mode 100755
index 0000000..1a2743f
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/ProtocolEntityFieldEnumerator.h
@@ -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;
+};
diff --git a/gobi-api/GobiAPI_1.0.40/Core/ProtocolEntityNav.cpp b/gobi-api/GobiAPI_1.0.40/Core/ProtocolEntityNav.cpp
new file mode 100755
index 0000000..de2ea14
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/ProtocolEntityNav.cpp
@@ -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;
+}
diff --git a/gobi-api/GobiAPI_1.0.40/Core/ProtocolEntityNav.h b/gobi-api/GobiAPI_1.0.40/Core/ProtocolEntityNav.h
new file mode 100755
index 0000000..4ad8550
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/ProtocolEntityNav.h
@@ -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;
+};
diff --git a/gobi-api/GobiAPI_1.0.40/Core/ProtocolEnum.h b/gobi-api/GobiAPI_1.0.40/Core/ProtocolEnum.h
new file mode 100755
index 0000000..fbb50f1
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/ProtocolEnum.h
@@ -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;
+};
diff --git a/gobi-api/GobiAPI_1.0.40/Core/ProtocolLog.cpp b/gobi-api/GobiAPI_1.0.40/Core/ProtocolLog.cpp
new file mode 100755
index 0000000..7b6ad74
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/ProtocolLog.cpp
@@ -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();
+}
diff --git a/gobi-api/GobiAPI_1.0.40/Core/ProtocolLog.h b/gobi-api/GobiAPI_1.0.40/Core/ProtocolLog.h
new file mode 100755
index 0000000..c0d6163
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/ProtocolLog.h
@@ -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;
+};
diff --git a/gobi-api/GobiAPI_1.0.40/Core/ProtocolNotification.cpp b/gobi-api/GobiAPI_1.0.40/Core/ProtocolNotification.cpp
new file mode 100755
index 0000000..92bcc68
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/ProtocolNotification.cpp
@@ -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 );
+ }
+}
diff --git a/gobi-api/GobiAPI_1.0.40/Core/ProtocolNotification.h b/gobi-api/GobiAPI_1.0.40/Core/ProtocolNotification.h
new file mode 100755
index 0000000..f44d13e
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/ProtocolNotification.h
@@ -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;
+};
diff --git a/gobi-api/GobiAPI_1.0.40/Core/ProtocolRequest.cpp b/gobi-api/GobiAPI_1.0.40/Core/ProtocolRequest.cpp
new file mode 100755
index 0000000..23069ec
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/ProtocolRequest.cpp
@@ -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;
+ }
+}
diff --git a/gobi-api/GobiAPI_1.0.40/Core/ProtocolRequest.h b/gobi-api/GobiAPI_1.0.40/Core/ProtocolRequest.h
new file mode 100755
index 0000000..414e1c2
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/ProtocolRequest.h
@@ -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;
+};
+
diff --git a/gobi-api/GobiAPI_1.0.40/Core/ProtocolServer.cpp b/gobi-api/GobiAPI_1.0.40/Core/ProtocolServer.cpp
new file mode 100755
index 0000000..4e14f15
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/ProtocolServer.cpp
@@ -0,0 +1,1720 @@
+/*===========================================================================
+FILE:
+ ProtocolServer.cpp
+
+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.
+===========================================================================*/
+
+//---------------------------------------------------------------------------
+// Include Files
+//---------------------------------------------------------------------------
+#include "StdAfx.h"
+
+#include "ProtocolServer.h"
+#include "ProtocolNotification.h"
+
+#include <climits>
+
+//---------------------------------------------------------------------------
+// Definitions
+//---------------------------------------------------------------------------
+
+// Invalid request ID
+const ULONG INVALID_REQUEST_ID = 0;
+
+// Default activity timeout value
+const ULONG DEFAULT_WAIT = 100;
+
+// MTU (Maximum Transmission Unit) for auxiliary data (QC USB imposed)
+const ULONG MAX_AUX_MTU_SIZE = 1024 * 256;
+
+// USB's MaxPacketSize
+const ULONG MAX_PACKET_SIZE = 512;
+
+// Maximum amount of time to wait on external access synchronization object
+#ifdef DEBUG
+ // For the sake of debugging do not be so quick to assume failure
+ const ULONG DEADLOCK_TIME = 180000;
+#else
+ const ULONG DEADLOCK_TIME = 10000;
+#endif
+
+// Maximum amount of time to wait for the protocol server to process a command
+const ULONG COMMAND_TIME = DEADLOCK_TIME;
+
+/*=========================================================================*/
+// Free Methods
+/*=========================================================================*/
+
+/*===========================================================================
+METHOD:
+ ScheduleThread (Free Method)
+
+DESCRIPTION:
+ Watch schedule for event to process or timeout
+
+PARAMETERS:
+ pArg [ I ] - The protocol server object
+
+RETURN VALUE:
+ void * - thread exit value (always NULL)
+===========================================================================*/
+void * ScheduleThread( PVOID pArg )
+{
+ // Do we have a server?
+ cProtocolServer * pServer = (cProtocolServer *)pArg;
+ if (pServer == 0)
+ {
+ TRACE( "ScheduleThread started with empty pArg."
+ " Unable to locate cProtocolServer\n" );
+
+ ASSERT( 0 );
+ return NULL;
+ }
+
+ TRACE( "Schedule thread [%lu] started\n",
+ pthread_self() );
+
+ // Default wait event
+ timespec toTime = TimeIn( DEFAULT_WAIT );
+
+ // Return value checking
+ int nRet;
+
+ while (pServer->mbExiting == false)
+ {
+ DWORD nTemp;
+ nRet = pServer->mThreadScheduleEvent.Wait( TimeFromNow( toTime ), nTemp );
+ if (nRet != 0 && nRet != ETIME)
+ {
+ // Error condition
+ TRACE( "ScheduleThread [%lu] ScheduleThread wait error %d, %s\n",
+ pthread_self(),
+ nRet,
+ strerror( nRet ) );
+ break;
+ }
+
+ // Time to exit?
+ if (pServer->mbExiting == true)
+ {
+ break;
+ }
+
+ // Get Schedule Mutex (non-blocking)
+ nRet = pthread_mutex_trylock( &pServer->mScheduleMutex );
+ if (nRet == EBUSY)
+ {
+ // Not an error, we're just too slow
+ // Someone else got to the ScheduleMutex before us
+ // We'll wait for the signal again
+ toTime = TimeIn( DEFAULT_WAIT );
+ TRACE( "ScheduleThread [%lu] unable to lock ScheduleMutex\n",
+ pthread_self() );
+ continue;
+ }
+ else if (nRet != 0)
+ {
+ // Error condition
+ TRACE( "ScheduleThread [%lu] mScheduleMutex error %d, %s\n",
+ pthread_self(),
+ nRet,
+ strerror( nRet ) );
+ break;
+ }
+
+ // Verify time. In the rare event it does move backward
+ // it would simply place all our schedule items as due now
+ pServer->CheckSystemTime();
+
+ // Default next wait period
+ toTime = TimeIn( DEFAULT_WAIT );
+
+ timespec curTime = TimeIn( 0 );
+
+ if (pServer->mpActiveRequest != 0)
+ {
+ if (pServer->mpActiveRequest->mbWaitingForResponse == true)
+ {
+ // Waiting on a response, this takes priority over the next
+ // scheduled event
+
+ // Has timeout expired?
+ if (pServer->mActiveRequestTimeout <= curTime)
+ {
+ // Response timeout
+
+ // Note: This may clear mpActiveRequest
+ pServer->RxTimeout();
+ }
+ else
+ {
+ // Active response timer is not yet due to expire
+ // Default timeout again, or this response's timeout?
+ if (pServer->mActiveRequestTimeout <= toTime)
+ {
+ toTime = pServer->mActiveRequestTimeout;
+ }
+ }
+ }
+ else
+ {
+ // This should never happen
+
+ TRACE( "ScheduleThread() Sequencing error: "
+ "Active request %lu is not waiting for response ???\n",
+ pServer->mpActiveRequest->mID );
+
+ break;
+ }
+ }
+
+ if (pServer->mpActiveRequest == 0
+ && pServer->mRequestSchedule.size() > 0)
+ {
+ // No response timer active, ready to start the next
+ // scheduled item if due
+
+ timespec scheduledItem = pServer->GetNextRequestTime();
+
+ // Is item due to be scheduled?
+ if (scheduledItem <= curTime)
+ {
+ // Process scheduled item
+ pServer->ProcessRequest();
+ }
+ else
+ {
+ // Scheduled item is not yet due to be processed
+ // Default timeout again, or this item's start time?
+ if (scheduledItem <= toTime)
+ {
+ toTime = scheduledItem;
+ }
+ }
+ }
+
+ /*TRACE( "Updated timer at %llu waiting %lu\n",
+ GetTickCount(),
+ TimeFromNow( toTime ) ); */
+
+ // Unlock schedule mutex
+ nRet = pthread_mutex_unlock( &pServer->mScheduleMutex );
+ if (nRet != 0)
+ {
+ TRACE( "ScheduleThread Unable to unlock schedule mutex."
+ " Error %d: %s\n",
+ nRet,
+ strerror( nRet ) );
+ return false;
+ }
+ }
+
+ TRACE( "Schedule thread [%lu] exited\n",
+ pthread_self() );
+
+ return NULL;
+}
+
+/*===========================================================================
+METHOD:
+ TimeIn (Free Method)
+
+DESCRIPTION:
+ Fill timespec with the time it will be in specified milliseconds
+ Relative time to Absolute time
+
+PARAMETERS:
+ millis [ I ] - Milliseconds from current time
+
+RETURN VALUE:
+ timespec - resulting time (from epoc)
+ NOTE: tv_sec of 0 is an error
+===========================================================================*/
+timespec TimeIn( ULONG millis )
+{
+ timespec outTime;
+
+ int nRC = clock_gettime( CLOCK_REALTIME, &outTime );
+ if (nRC == 0)
+ {
+ // Add avoiding an overflow on (long)nsec
+ outTime.tv_sec += millis / 1000l;
+ outTime.tv_nsec += ( millis % 1000l ) * 1000000l;
+
+ // Check if we need to carry
+ if (outTime.tv_nsec >= 1000000000l)
+ {
+ outTime.tv_sec += outTime.tv_nsec / 1000000000l;
+ outTime.tv_nsec = outTime.tv_nsec % 1000000000l;
+ }
+ }
+ else
+ {
+ outTime.tv_sec = 0;
+ outTime.tv_nsec = 0;
+ }
+
+ return outTime;
+}
+
+/*===========================================================================
+METHOD:
+ TimeFromNow (Free Method)
+
+DESCRIPTION:
+ Find the milliseconds from current time this timespec will occur
+ Absolute time to Relative time
+
+PARAMETERS:
+ time [ I ] - Absolute time
+
+RETURN VALUE:
+ Milliseconds in which absolute time will occur
+ 0 if time has passed or error has occured
+===========================================================================*/
+ULONG TimeFromNow( timespec time )
+{
+ // Assume failure
+ ULONG nOutTime = 0;
+
+ timespec now;
+ int nRC = clock_gettime( CLOCK_REALTIME, &now );
+ if (nRC == -1)
+ {
+ TRACE( "Error %d with gettime, %s\n", errno, strerror( errno ) );
+ return nOutTime;
+ }
+
+ if (time <= now)
+ {
+ return nOutTime;
+ }
+
+ nOutTime = (time.tv_sec - now.tv_sec) * 1000l;
+ nOutTime += (time.tv_nsec - now.tv_nsec) / 1000000l;
+
+ return nOutTime;
+}
+
+/*===========================================================================
+METHOD:
+ GetTickCount (Free Method)
+
+DESCRIPTION:
+ Provide a number for sequencing reference, similar to the windows
+ ::GetTickCount().
+
+ NOTE: This number is based on the time since epoc, not
+ uptime.
+
+PARAMETERS:
+
+RETURN VALUE:
+ ULONGLONG - Number of milliseconds system has been up
+===========================================================================*/
+ULONGLONG GetTickCount()
+{
+ timespec curtime = TimeIn( 0 );
+
+ ULONGLONG outtime = curtime.tv_sec * 1000LL;
+ outtime += curtime.tv_nsec / 1000000LL;
+
+ return outtime;
+}
+
+/*=========================================================================*/
+// cProtocolServerRxCallback Methods
+/*=========================================================================*/
+
+/*===========================================================================
+METHOD:
+ IOComplete (Free Method)
+
+DESCRIPTION:
+ The I/O has been completed, process the results
+
+PARAMETERS:
+ status [ I ] - Status of operation
+ bytesReceived [ I ] - Bytes received during operation
+
+RETURN VALUE:
+ None
+===========================================================================*/
+void cProtocolServerRxCallback::IOComplete(
+ DWORD status,
+ DWORD bytesReceived )
+{
+ if (mpServer != 0)
+ {
+ mpServer->RxComplete( status, bytesReceived );
+ }
+}
+
+/*=========================================================================*/
+// cProtocolServer::sProtocolReqRsp Methods
+/*=========================================================================*/
+
+/*===========================================================================
+METHOD:
+ cProtocolServer::sProtocolReqRsp (Public Method)
+
+DESCRIPTION:
+ Constructor
+
+PARAMETERS:
+ requestInfo [ I ] - Underlying request object
+ requestID [ I ] - Request ID
+ auxDataMTU [ I ] - MTU (Maximum Transmission Unit) for auxiliary data
+
+RETURN VALUE:
+ None
+===========================================================================*/
+cProtocolServer::sProtocolReqRsp::sProtocolReqRsp(
+ const sProtocolRequest & requestInfo,
+ ULONG requestID,
+ ULONG auxDataMTU )
+ : mRequest( requestInfo ),
+ mID( requestID ),
+ mAttempts( 0 ),
+ mEncodedSize( requestInfo.GetSize() ),
+ mRequiredAuxTxs( 0 ),
+ mCurrentAuxTx( 0 ),
+ mbWaitingForResponse( false )
+{
+ ULONG auxDataSz = 0;
+ const BYTE * pAuxData = requestInfo.GetAuxiliaryData( auxDataSz );
+
+ // Compute the number of required auxiliary data transmissions?
+ if (auxDataMTU > 0 && pAuxData != 0 && auxDataSz > 0)
+ {
+ mRequiredAuxTxs = 1;
+ if (auxDataSz > auxDataMTU)
+ {
+ mRequiredAuxTxs = auxDataSz / auxDataMTU;
+ if ((auxDataSz % auxDataMTU) != 0)
+ {
+ mRequiredAuxTxs++;
+ }
+ }
+ }
+}
+
+/*===========================================================================
+METHOD:
+ cProtocolServer::sProtocolReqRsp (Public Method)
+
+DESCRIPTION:
+ Coop constructor
+
+PARAMETERS:
+ reqRsp [ I ] - Object being copied
+
+RETURN VALUE:
+ None
+===========================================================================*/
+cProtocolServer::sProtocolReqRsp::sProtocolReqRsp(
+ const sProtocolReqRsp & reqRsp )
+ : mRequest( reqRsp.mRequest ),
+ mID( reqRsp.mID ),
+ mAttempts( reqRsp.mAttempts ),
+ mEncodedSize( reqRsp.mEncodedSize ),
+ mRequiredAuxTxs( reqRsp.mRequiredAuxTxs ),
+ mCurrentAuxTx( reqRsp.mCurrentAuxTx ),
+ mbWaitingForResponse( reqRsp.mbWaitingForResponse )
+{
+ // Nothing to do
+};
+
+/*=========================================================================*/
+// cProtocolServer Methods
+/*=========================================================================*/
+
+/*===========================================================================
+METHOD:
+ cProtocolServer (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
+===========================================================================*/
+cProtocolServer::cProtocolServer(
+ eProtocolType rxType,
+ eProtocolType txType,
+ ULONG bufferSzRx,
+ ULONG logSz )
+ : mComm(),
+ mRxCallback(),
+ mScheduleThreadID( 0 ),
+ mThreadScheduleEvent(),
+ mbExiting( false ),
+ mpServerControl( 0 ),
+ mLastRequestID( 1 ),
+ mpActiveRequest( 0 ),
+ mpRxBuffer( 0 ),
+ mRxBufferSize( bufferSzRx ),
+ mRxType( rxType ),
+ mTxType( txType ),
+ mLog( logSz )
+{
+ mLastTime = TimeIn( 0 );
+
+ // Allocate receive buffer?
+ if (mRxBufferSize > 0 && mComm.IsValid() == true)
+ {
+ mpRxBuffer = new BYTE[mRxBufferSize];
+ }
+
+ // Before continuing verify receive buffer was allocated
+ if (mpRxBuffer != 0)
+ {
+ // Schedule mutex
+ int nRet = pthread_mutex_init( &mScheduleMutex, NULL );
+ if (nRet != 0)
+ {
+ TRACE( "Unable to init schedule mutex. Error %d: %s\n",
+ nRet,
+ strerror( nRet ) );
+ return;
+ }
+ }
+}
+
+/*===========================================================================
+METHOD:
+ ~cProtocolServer (Public Method)
+
+DESCRIPTION:
+ Destructor
+
+SEQUENCING:
+ None (destroys sequencing objects)
+
+RETURN VALUE:
+ None
+===========================================================================*/
+cProtocolServer::~cProtocolServer()
+{
+ // This should have already been called, but ...
+ Exit();
+
+ // Schedule mutex
+ int nRet = pthread_mutex_destroy( &mScheduleMutex );
+ if (nRet != 0)
+ {
+ TRACE( "Unable to destroy schedule mutex. Error %d: %s\n",
+ nRet,
+ strerror( nRet ) );
+ }
+
+ // Free receive buffer
+ if (mpRxBuffer != 0)
+ {
+ delete [] mpRxBuffer;
+ mpRxBuffer = 0;
+ }
+}
+
+/*===========================================================================
+METHOD:
+ HandleRemoveRequest (Public Method)
+
+DESCRIPTION:
+ Remove a previously added protocol request
+
+ Note: if a request is being processed, it cannot be inturrupted
+
+PARAMETERS:
+ reqID [ I ] - Server assigned request ID
+
+SEQUENCING:
+ Calling process must have lock on mScheduleMutex
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cProtocolServer::HandleRemoveRequest( ULONG reqID )
+{
+ // Assume failure
+ bool bRC = false;
+
+ // Find and erase request from request map
+ std::map <ULONG, sProtocolReqRsp *>::iterator pReqIter;
+ pReqIter = mRequestMap.find( reqID );
+
+ if (pReqIter != mRequestMap.end())
+ {
+ sProtocolReqRsp * pReqRsp = pReqIter->second;
+ if (pReqRsp != 0)
+ {
+ delete pReqRsp;
+ }
+
+ mRequestMap.erase( pReqIter );
+
+ // Success!
+ bRC = true;
+
+ // Find and erase request from schedule
+ bool bFound = false;
+ int entryIndex = -1;
+
+ std::set <tSchedule>::iterator pScheduleIter;
+ pScheduleIter = mRequestSchedule.begin();
+
+ while (pScheduleIter != mRequestSchedule.end())
+ {
+ entryIndex++;
+
+ tSchedule entry = *pScheduleIter;
+ if (entry.second == reqID)
+ {
+ bFound = true;
+ mRequestSchedule.erase( pScheduleIter );
+ break;
+ }
+ else
+ {
+ pScheduleIter++;
+ }
+ }
+
+ // Note: schedule will be updated when mutex is unlocked/signaled
+ }
+ else if (mpActiveRequest != 0 && mpActiveRequest->mID == reqID)
+ {
+ const sProtocolRequest & req = mpActiveRequest->mRequest;
+ const cProtocolNotification * pNotifier = req.GetNotifier();
+
+ // Cancel the response timer (when active)
+ if (mpActiveRequest->mbWaitingForResponse == true)
+ {
+ // Schedule will be updated when mutex is unlocked
+
+ // Failure to receive response, notify client
+ if (pNotifier != 0)
+ {
+ pNotifier->Notify( ePROTOCOL_EVT_RSP_ERR,
+ (DWORD)reqID,
+ ECANCELED );
+ }
+ }
+ else
+ {
+ // This is the active request, cancel the underlying transmit
+ // Note: Because ProcessRequest and RemoveRequest are both muxed
+ // with ScheduleMutex, it is impossible to for the write
+ // to actually be in progress when this code is reached.
+ mComm.CancelTx();
+
+ // Failure to send request, notify client
+ if (pNotifier != 0)
+ {
+ pNotifier->Notify( ePROTOCOL_EVT_REQ_ERR,
+ (DWORD)reqID,
+ ECANCELED );
+ }
+ }
+
+ // Now delete the request
+ delete mpActiveRequest;
+ mpActiveRequest = 0;
+
+ // Success!
+ bRC = true;
+ }
+ else
+ {
+ TRACE( "cProtocolServer::RemoveRequest( %lu ),"
+ " invalid request ID\n",
+ reqID );
+ }
+
+ return bRC;
+}
+
+/*===========================================================================
+METHOD:
+ ScheduleRequest (Internal Method)
+
+DESCRIPTION:
+ Schedule a request for transmission
+
+PARAMETERS:
+ reqID [ I ] - ID of the request being scheduled this ID must exist
+ in the internal request/schedule maps
+
+ schedule [ I ] - Value in milliseconds that indicates the approximate
+ time from now that the request is to be sent out, the
+ actual time that the request is sent will be greater
+ than or equal to this value dependant on requests
+ scheduled before the request in question and
+ standard server processing time
+
+SEQUENCING:
+ Calling process must have lock on mScheduleMutex
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cProtocolServer::ScheduleRequest(
+ ULONG reqID,
+ ULONG schedule )
+{
+ // Assume failure
+ bool bRC = false;
+
+ // Schedule adjust is in milliseconds
+ timespec schTimer = TimeIn( schedule );
+
+ // Create the schedule entry
+ tSchedule newEntry( schTimer, reqID );
+
+ // Fit this request into the schedule (ordered by scheduled time)
+ mRequestSchedule.insert( newEntry );
+
+ // Note: timer will be updated when mScheduleMutex is unlocked
+
+ return bRC;
+}
+
+/*===========================================================================
+METHOD:
+ RescheduleActiveRequest (Internal Method)
+
+DESCRIPTION:
+ Reschedule (or cleanup) the active request
+
+SEQUENCING:
+ Calling process must have lock on mScheduleMutex
+
+RETURN VALUE:
+ None
+===========================================================================*/
+void cProtocolServer::RescheduleActiveRequest()
+{
+ // Are there more attempts to be made?
+ if (mpActiveRequest->mAttempts < mpActiveRequest->mRequest.GetRequests())
+ {
+ // Yes, first reset the request
+ mpActiveRequest->Reset();
+
+ // Now add it back to the request map
+ mRequestMap[mpActiveRequest->mID] = mpActiveRequest;
+
+ TRACE( "RescheduleActiveRequest(): req %lu rescheduled\n", mpActiveRequest->mID );
+
+ // Lastly reschedule the request
+ ScheduleRequest( mpActiveRequest->mID,
+ mpActiveRequest->mRequest.GetFrequency() );
+
+ }
+ else
+ {
+ TRACE( "RescheduleActiveRequest(): req %lu removed\n", mpActiveRequest->mID );
+
+ // No, we are through with this request
+ delete mpActiveRequest;
+ }
+
+ // There is no longer an active request
+ mpActiveRequest = 0;
+
+}
+
+/*===========================================================================
+METHOD:
+ ProcessRequest (Internal Method)
+
+DESCRIPTION:
+ Process a single outgoing protocol request, this consists of removing
+ the request ID from the head of the schedule, looking up the internal
+ request object in the request map, sending out the request, and setting
+ up the response timer (if a response is required)
+
+SEQUENCING:
+ Calling process must have lock on mScheduleMutex
+
+RETURN VALUE:
+===========================================================================*/
+void cProtocolServer::ProcessRequest()
+{
+ // Is there already an active request?
+ if (mpActiveRequest != 0)
+ {
+ return;
+ }
+
+ // Grab request ID from the schedule
+ std::set <tSchedule>::iterator pScheduleIter;
+ pScheduleIter = mRequestSchedule.begin();
+
+ // Did we find the request?
+ if (pScheduleIter == mRequestSchedule.end())
+ {
+ // No
+ return;
+ }
+
+ // Yes, grab the request ID
+ ULONG reqID = pScheduleIter->second;
+
+ // Remove from schedule
+ mRequestSchedule.erase( pScheduleIter );
+
+ // Look up the internal request object
+ std::map <ULONG, sProtocolReqRsp *>::iterator pReqIter;
+ pReqIter = mRequestMap.find( reqID );
+
+ // Request not found around?
+ if (pReqIter == mRequestMap.end() || pReqIter->second == 0)
+ {
+ // No
+ return;
+ }
+
+ // Set this request as the active request
+ mpActiveRequest = pReqIter->second;
+
+ TRACE( "ProcessRequest(): req %lu started\n", mpActiveRequest->mID );
+
+ // Remove request from pending request map
+ mRequestMap.erase( pReqIter );
+
+ // Extract the underlying request
+ const sProtocolRequest & req = mpActiveRequest->mRequest;
+
+ // Increment attempt count?
+ if (req.GetRequests() != INFINITE_REQS)
+ {
+ // This request isn't an indefinite one, so keep track of each attempt
+ mpActiveRequest->mAttempts++;
+ }
+
+ bool bTxSuccess = false;
+
+ // Encode data for transmission?
+ bool bEncoded = false;
+ sSharedBuffer * pEncoded = 0;
+ pEncoded = EncodeTxData( req.GetSharedBuffer(), bEncoded );
+ if (bEncoded == false)
+ {
+ // Note: no longer asynchronus
+ // Send the request data
+ bTxSuccess = mComm.TxData( req.GetBuffer(),
+ req.GetSize() );
+ }
+ else if (bEncoded == true)
+ {
+ if (pEncoded != 0 && pEncoded->IsValid() == true)
+ {
+ // Note: no longer asynchronus
+ // Send the request data
+ mpActiveRequest->mEncodedSize = pEncoded->GetSize();
+ bTxSuccess = mComm.TxData( pEncoded->GetBuffer(),
+ pEncoded->GetSize() );
+ }
+ }
+
+ if (bTxSuccess == true)
+ {
+ TRACE( "ProcessRequest(): req %lu finished\n", mpActiveRequest->mID );
+ TxComplete();
+ }
+ else
+ {
+ TxError();
+ TRACE( "ProcessRequest(): req finished with a TxError\n" );
+ }
+
+ return;
+}
+
+/*===========================================================================
+METHOD:
+ CheckSystemTime (Internal Method)
+
+DESCRIPTION:
+ Check that system time hasn't moved backwards. Since we use the system
+ time for scheduling requests we need to periodically check that the
+ user (or system itself) hasn't reset system time backwards, if it has
+ then we reschedule everything to the current system time. This disrupts
+ the schedule but avoids stranding requests
+
+ Updates mLastTime
+
+SEQUENCING:
+ Calling process must have lock on mScheduleMutex
+
+RETURN VALUE:
+ bool: System time moved backwards?
+===========================================================================*/
+bool cProtocolServer::CheckSystemTime()
+{
+ // Assume that time is still marching forward
+ bool bAdjust = false;
+
+ timespec curTime = TimeIn( 0 );
+
+ if (curTime < mLastTime)
+ {
+ // Looks like the system clock has been adjusted to an earlier
+ // value, go through the current schedule and adjust each timer
+ // to reflect the adjustment. This isn't an exact approach but
+ // it prevents requests from being stranded which is our goal
+
+ // Note: set iterators are constant. This means we need to
+ // create a set with the new data, we can't modify this one
+
+ std::set < tSchedule, std::less <tSchedule> > tempSchedule;
+
+ std::set <tSchedule>::iterator pScheduleIter;
+ pScheduleIter = mRequestSchedule.begin();
+
+ while (pScheduleIter != mRequestSchedule.end())
+ {
+ tSchedule entry = *pScheduleIter;
+ entry.first.tv_sec = curTime.tv_sec;
+ entry.first.tv_nsec = curTime.tv_nsec;
+ tempSchedule.insert( entry );
+
+ pScheduleIter++;
+ }
+
+ mRequestSchedule = tempSchedule;
+
+ // Update mActiveRequestTimeout
+ if ( (mpActiveRequest != 0)
+ && (mpActiveRequest->mbWaitingForResponse == true) )
+ {
+ // Restart active request's timeout
+ ULONG mTimeout = mpActiveRequest->mRequest.GetTimeout();
+ mActiveRequestTimeout = TimeIn( mTimeout );
+ }
+
+ TRACE( "Time has moved backwards, schedule updated\n" );
+
+ // Indicate the change
+ bAdjust = true;
+ }
+
+ mLastTime.tv_sec = curTime.tv_sec;
+ mLastTime.tv_nsec = curTime.tv_nsec;
+
+ return bAdjust;
+}
+
+/*===========================================================================
+METHOD:
+ RxComplete (Internal Method)
+
+DESCRIPTION:
+ Handle completion of receive data operation
+
+PARAMETERS:
+ status [ I ] - Status of operation
+ bytesReceived [ I ] - Number of bytes received
+
+SEQUENCING:
+ This method is sequenced according to the schedule mutex
+ i.e. any other thread that needs to modify the schedule
+ will block until this method completes
+
+RETURN VALUE:
+ None
+===========================================================================*/
+void cProtocolServer::RxComplete(
+ DWORD status,
+ DWORD bytesReceived )
+{
+ if (status != NO_ERROR)
+ {
+ TRACE( "cProtocolServer::RxComplete() = %lu\n", status );
+ }
+
+ // Error with the read
+ if (status != NO_ERROR || bytesReceived == 0)
+ {
+ // Setup the next read
+ mComm.RxData( mpRxBuffer,
+ (ULONG)mRxBufferSize,
+ (cIOCallback *)&mRxCallback );
+
+ return;
+ }
+
+ // Get Schedule Mutex
+ if (GetScheduleMutex() == false)
+ {
+ TRACE( "RxComplete(), unable to get schedule Mutex\n" );
+ return;
+ }
+
+ TRACE( "RxComplete() - Entry at %llu\n", GetTickCount() );
+
+ // Decode data
+ bool bAbortTx = false;
+ ULONG rspIdx = INVALID_LOG_INDEX;
+ bool bRsp = DecodeRxData( bytesReceived, rspIdx, bAbortTx );
+
+ // Is there an active request that needs to be aborted
+ if (mpActiveRequest != 0 && bAbortTx == true)
+ {
+ // Yes, terminate the transmission and handle the error
+ mComm.CancelTx();
+ TxError();
+ }
+ // Is there an active request and a valid response?
+ else if (mpActiveRequest != 0 && bRsp == true)
+ {
+ const sProtocolRequest & req = mpActiveRequest->mRequest;
+ const cProtocolNotification * pNotifier = req.GetNotifier();
+
+ // Notify client that response was received
+ if (pNotifier != 0)
+ {
+ pNotifier->Notify( ePROTOCOL_EVT_RSP_RECV,
+ (DWORD)mpActiveRequest->mID,
+ (DWORD)rspIdx );
+ }
+
+ // Reschedule request as needed
+ RescheduleActiveRequest();
+ }
+
+ // Setup the next read
+ mComm.RxData( mpRxBuffer,
+ (ULONG)mRxBufferSize,
+ (cIOCallback *)&mRxCallback );
+
+ TRACE( "RxComplete() - Exit at %llu\n", GetTickCount() );
+
+ // Unlock schedule mutex
+ if (ReleaseScheduleMutex() == false)
+ {
+ // This should never happen
+ return;
+ }
+
+ return;
+}
+
+/*===========================================================================
+METHOD:
+ RxTimeout (Internal Method)
+
+DESCRIPTION:
+ Handle the response timer expiring
+
+SEQUENCING:
+ Calling process must have lock on mScheduleMutex
+
+RETURN VALUE:
+ None
+===========================================================================*/
+void cProtocolServer::RxTimeout()
+{
+ // No active request?
+ if (mpActiveRequest == 0)
+ {
+ TRACE( "RxTimeout() with no active request\n" );
+ ASSERT( 0 );
+ }
+
+ TRACE( "RxTimeout() for req %lu\n", mpActiveRequest->mID );
+
+ const sProtocolRequest & req = mpActiveRequest->mRequest;
+ const cProtocolNotification * pNotifier = req.GetNotifier();
+
+ // Failure to receive response, notify client
+ if (pNotifier != 0)
+ {
+ pNotifier->Notify( ePROTOCOL_EVT_RSP_ERR,
+ (DWORD)mpActiveRequest->mID,
+ (DWORD)0 );
+ }
+
+ // Reschedule request as needed
+ RescheduleActiveRequest();
+}
+
+/*===========================================================================
+METHOD:
+ TxComplete (Internal Method)
+
+DESCRIPTION:
+ Handle completion of transmit data operation
+
+PARAMETERS:
+
+SEQUENCING:
+ Calling process must have lock on mScheduleMutex
+
+RETURN VALUE:
+ None
+===========================================================================*/
+void cProtocolServer::TxComplete()
+{
+ // No active request?
+ if (mpActiveRequest == 0)
+ {
+ TRACE( "TxComplete() called with no active request\n" );
+ ASSERT( 0 );
+ }
+
+ TRACE( "TxComplete() req %lu started\n", mpActiveRequest->mID );
+
+ ULONG reqID = mpActiveRequest->mID;
+ const sProtocolRequest & req = mpActiveRequest->mRequest;
+ const cProtocolNotification * pNotifier = req.GetNotifier();
+
+ // Notify client of auxiliary data being sent?
+ if (mpActiveRequest->mRequiredAuxTxs && mpActiveRequest->mCurrentAuxTx)
+ {
+ pNotifier->Notify( ePROTOCOL_EVT_AUX_TU_SENT,
+ (DWORD)reqID,
+ (DWORD)mpActiveRequest->mEncodedSize );
+ }
+
+ // Check for more auxiliary data to transmit
+ if (mpActiveRequest->mCurrentAuxTx < mpActiveRequest->mRequiredAuxTxs)
+ {
+ ULONG auxDataSz = 0;
+ const BYTE * pAuxData = req.GetAuxiliaryData( auxDataSz );
+ if (auxDataSz > 0 && pAuxData != 0)
+ {
+ bool bRC = false;
+
+ // Adjust for current MTU
+ pAuxData += (mpActiveRequest->mCurrentAuxTx * MAX_AUX_MTU_SIZE);
+ mpActiveRequest->mCurrentAuxTx++;
+
+ // Last MTU?
+ if (mpActiveRequest->mCurrentAuxTx == mpActiveRequest->mRequiredAuxTxs)
+ {
+ // More than one MTU?
+ if (mpActiveRequest->mRequiredAuxTxs > 1)
+ {
+ auxDataSz = (auxDataSz % MAX_AUX_MTU_SIZE);
+ if (auxDataSz == 0)
+ {
+ auxDataSz = MAX_AUX_MTU_SIZE;
+ }
+ }
+
+ if (auxDataSz % MAX_PACKET_SIZE == 0)
+ {
+ // If last write of unframed write request is divisible
+ // by 512, break off last byte and send seperatly.
+ TRACE( "TxComplete() Special case, break off last byte\n" );
+
+ bRC = mComm.TxData( pAuxData,
+ auxDataSz - 1 );
+
+ if (bRC == true)
+ {
+ bRC = mComm.TxData( pAuxData + auxDataSz -1,
+ 1 );
+ }
+ }
+ else
+ {
+ bRC = mComm.TxData( pAuxData,
+ auxDataSz );
+ }
+ }
+ else if (mpActiveRequest->mRequiredAuxTxs > 1)
+ {
+ auxDataSz = MAX_AUX_MTU_SIZE;
+
+ bRC = mComm.TxData( pAuxData,
+ auxDataSz );
+ }
+
+ if (bRC == true)
+ {
+ mpActiveRequest->mEncodedSize = auxDataSz;
+ TxComplete();
+ }
+ else
+ {
+ TxError();
+ }
+
+ return;
+ }
+ }
+
+ // Another successful transmission, add the buffer to the log
+ ULONG reqIdx = INVALID_LOG_INDEX;
+
+ sProtocolBuffer pb( req.GetSharedBuffer() );
+ reqIdx = mLog.AddBuffer( pb );
+
+ // Notify client?
+ if (pNotifier != 0)
+ {
+ pNotifier->Notify( ePROTOCOL_EVT_REQ_SENT, (DWORD)reqID, (DWORD)reqIdx );
+ }
+
+ // Wait for a response?
+ if (mpActiveRequest->mRequest.IsTXOnly() == false)
+ {
+ // We now await the response
+ mpActiveRequest->mbWaitingForResponse = true;
+ mActiveRequestTimeout = TimeIn( mpActiveRequest->mRequest.GetTimeout() );
+ }
+ else
+ {
+ // Reschedule request as needed
+ RescheduleActiveRequest();
+ }
+}
+
+/*===========================================================================
+METHOD:
+ TxError (Internal Method)
+
+DESCRIPTION:
+ Handle transmit data operation error be either rescheduling the
+ request or cleaning it up
+
+SEQUENCING:
+ Calling process must have lock on mScheduleMutex
+
+RETURN VALUE:
+ None
+===========================================================================*/
+void cProtocolServer::TxError()
+{
+ // No active request?
+ if (mpActiveRequest == 0)
+ {
+ return;
+ }
+
+ ULONG reqID = mpActiveRequest->mID;
+ const sProtocolRequest & req = mpActiveRequest->mRequest;
+ const cProtocolNotification * pNotifier = req.GetNotifier();
+
+ // Failure to send request, notify client
+ if (pNotifier != 0)
+ {
+ pNotifier->Notify( ePROTOCOL_EVT_REQ_ERR, (DWORD)reqID, (DWORD)0 );
+ }
+
+ // Reschedule request as needed
+ RescheduleActiveRequest();
+}
+
+/*===========================================================================
+METHOD:
+ Initialize (Public Method)
+
+DESCRIPTION:
+ Initialize the protocol server by starting up the schedule thread
+
+SEQUENCING:
+ This method is sequenced according to the schedule mutex, i.e. any
+ other thread that needs to modify the schedule will block until
+ this method completes
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cProtocolServer::Initialize()
+{
+ // Assume failure
+ bool bRC = false;
+
+ mbExiting = false;
+
+ // Get mScheduleMutex
+ if (GetScheduleMutex() == true)
+ {
+ if (mScheduleThreadID == 0)
+ {
+ // Yes, start thread
+ int nRet = pthread_create( &mScheduleThreadID,
+ NULL,
+ ScheduleThread,
+ this );
+ if (nRet == 0)
+ {
+ // Success!
+ bRC = true;
+ }
+ }
+ }
+ else
+ {
+ TRACE( "cProtocolServer::Initialize(), unable to aquire ScheduleMutex\n" );
+ return false;
+ }
+
+ // Unlock schedule mutex
+ if (ReleaseScheduleMutex() == false)
+ {
+ // This should never happen
+ return false;
+ }
+
+ return bRC;
+}
+
+/*===========================================================================
+METHOD:
+ Exit (Public Method)
+
+DESCRIPTION:
+ Exit the protocol server by exiting the schedule thread (if necessary)
+
+SEQUENCING:
+ This method is sequenced according to the schedule mutex, i.e. any
+ other thread that needs to modify the schedule will block until
+ this method completes
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cProtocolServer::Exit()
+{
+ // Assume failure
+ bool bRC = false;
+
+ if (mScheduleThreadID != 0)
+ {
+ if (GetScheduleMutex() == false)
+ {
+ // This should never happen
+ return false;
+ }
+
+ // Set exit event
+ mbExiting = true;
+
+ // Signal a schedule update
+ if (mThreadScheduleEvent.Set( 1 ) != 0)
+ {
+ // This should never happen
+ return false;
+ }
+
+ TRACE( "Joining ScheduleThread\n" );
+
+ // Allow process to continue until it finishes
+ int nRet = pthread_join( mScheduleThreadID, NULL );
+ if (nRet == ESRCH)
+ {
+ TRACE( "ScheduleThread has exited already\n" );
+ }
+ else if (nRet != 0)
+ {
+ TRACE( "Unable to join ScheduleThread. Error %d: %s\n",
+ nRet,
+ strerror( nRet ) );
+ return false;
+ }
+
+ TRACE( "cProtocolServer::Exit(), completed thread %lu\n",
+ (ULONG)mScheduleThreadID );
+
+ bRC = true;
+
+ // Release "handle"
+ mScheduleThreadID = 0;
+
+ // Release mutex lock, don't signal ScheduleThread
+ if (ReleaseScheduleMutex( false ) == false)
+ {
+ // This should never happen
+ return false;
+ }
+ }
+ else
+ {
+ // No ScheduleThread
+ bRC = true;
+ }
+
+ // Free any allocated requests
+ std::map <ULONG, sProtocolReqRsp *>::iterator pReqIter;
+ pReqIter = mRequestMap.begin();
+
+ while (pReqIter != mRequestMap.end())
+ {
+ sProtocolReqRsp * pReqRsp = pReqIter->second;
+ if (pReqRsp != 0)
+ {
+ delete pReqRsp;
+ }
+
+ pReqIter++;
+ }
+
+ mRequestMap.clear();
+
+ // Free log
+ mLog.Clear();
+
+ return bRC;
+}
+
+/*===========================================================================
+METHOD:
+ Connect (Public Method)
+
+DESCRIPTION:
+ Connect to the given communications port
+
+PARAMETERS:
+ pPort [ I ] - String pointer representing the device node to
+ connect to (IE: /dev/qcqmi0)
+
+SEQUENCING:
+ None
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cProtocolServer::Connect( LPCSTR pPort )
+{
+ // Assume failure
+ bool bRC = false;
+ if (pPort == 0 || pPort[0] == 0)
+ {
+ return bRC;
+ }
+
+ // Connect to device
+
+ // Set callback
+ mRxCallback.SetServer( this );
+
+ // Override to initialize port with protocol specific options
+ bRC = mComm.Connect( pPort );
+ if (bRC == true)
+ {
+ bRC = InitializeComm();
+ if (bRC == true)
+ {
+ // Setup the initial read
+ mComm.RxData( mpRxBuffer,
+ (ULONG)mRxBufferSize,
+ (cIOCallback *)&mRxCallback );
+ }
+ }
+
+ return bRC;
+}
+
+/*===========================================================================
+METHOD:
+ Disconnect (Public Method)
+
+DESCRIPTION:
+ Disconnect from the current communications port
+
+SEQUENCING:
+ None
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cProtocolServer::Disconnect()
+{
+ // Disconnect
+
+ // Cancel any outstanding I/O
+ mComm.CancelIO();
+
+ // Empty callback
+ mRxCallback.SetServer( 0 );
+
+ // Cleanup COM port
+ CleanupComm();
+
+ // Now disconnect
+ return mComm.Disconnect();
+}
+
+/*===========================================================================
+METHOD:
+ IsConnected (Public Method)
+
+DESCRIPTION:
+ Are we currently connected to a port?
+
+SEQUENCING:
+ None
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cProtocolServer::IsConnected()
+{
+ return mComm.IsConnected();
+}
+
+/*===========================================================================
+METHOD:
+ AddRequest (Public Method)
+
+DESCRIPTION:
+ Add an outgoing protocol request to the protocol server request queue
+
+PARAMETERS:
+ req [ I ] - Request being added
+
+SEQUENCING:
+ This method is sequenced according to the schedule mutex, i.e. any
+ other thread that needs to modify the schedule will block until
+ this method completes
+
+RETURN VALUE:
+ ULONG - ID of scheduled request (INVALID_REQUEST_ID upon error)
+===========================================================================*/
+ULONG cProtocolServer::AddRequest( const sProtocolRequest & req )
+{
+ // Assume failure
+ ULONG reqID = INVALID_REQUEST_ID;
+
+ // Server not configured for sending requests?
+ if (IsValid( mTxType ) == false)
+ {
+ return reqID;
+ }
+
+ // Request type not valid for server?
+ if (req.GetType() != mTxType)
+ {
+ return reqID;
+ }
+
+ // Invalide request?
+ if (ValidateRequest( req ) == false)
+ {
+ return reqID;
+ }
+
+ // Get mScheduleMutex
+ if (GetScheduleMutex() == true)
+ {
+ TRACE( "AddRequest() - Entry at %llu\n", GetTickCount() );
+
+ // Grab next available request ID
+ if (++mLastRequestID == 0)
+ {
+ mLastRequestID++;
+ }
+
+ reqID = mLastRequestID;
+ while (mRequestMap.find( reqID ) != mRequestMap.end())
+ {
+ reqID++;
+ }
+
+ // Wrap in our internal structure
+ sProtocolReqRsp * pReqRsp = 0;
+ pReqRsp = new sProtocolReqRsp( req, reqID, MAX_AUX_MTU_SIZE );
+
+ if (pReqRsp != 0)
+ {
+ // Add to request map
+ mRequestMap[reqID] = pReqRsp;
+
+ // ... and schedule
+ ScheduleRequest( reqID, req.GetSchedule() );
+ }
+
+ TRACE( "AddRequest() - Exit at %llu\n", GetTickCount() );
+
+ // Unlock schedule mutex
+ if (ReleaseScheduleMutex() == false)
+ {
+ // This should never happen
+ return INVALID_REQUEST_ID;
+ }
+ }
+ else
+ {
+ TRACE( "cProtocolServer::AddRequest(), unable to get schedule Mutex\n" );
+ }
+
+ return reqID;
+}
+
+/*===========================================================================
+METHOD:
+ RemoveRequest (Public Method)
+
+DESCRIPTION:
+ Remove a previously added protocol request
+
+SEQUENCING:
+ This method is sequenced according to the schedule mutex, i.e. any
+ other thread that needs to modify the schedule will block until
+ this method completes
+
+ Note: If a request is being written, it cannot be inturrupted as
+ both ProcessRequest and RemoveRequest depend on the ScheduleMutex
+ and the write is synchronus. If the request has been written but
+ the read has not been triggered it can be removed.
+
+PARAMETERS:
+ reqID [ I ] - ID of request being removed
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cProtocolServer::RemoveRequest( ULONG reqID )
+{
+ // Assume failure
+ bool bRC = false;
+
+ // Get Schedule Mutex
+ if (GetScheduleMutex() == true)
+ {
+ TRACE( "RemoveRequest() - Entry at %llu\n", GetTickCount() );
+
+ bRC = HandleRemoveRequest( reqID );
+
+ TRACE( "RemoveRequest() - Exit at %llu\n", GetTickCount() );
+
+ // Unlock schedule mutex
+ if (ReleaseScheduleMutex() == false)
+ {
+ // This should never happen
+ return false;
+ }
+ }
+ else
+ {
+ TRACE( "cProtocolServer::RemoveRequest(), unable to get mScheduleMutex\n" );
+ }
+
+ return bRC;
+}
+
+/*===========================================================================
+METHOD:
+ GetScheduleMutex (Internal Method)
+
+DESCRIPTION:
+ Get the schedule mutex. Additionally a check is applied to verify the
+ DEADLOCK_TIME was not exceeded
+
+SEQUENCING:
+ This function will block until the mScheduleMutex is aquired
+
+PARAMETERS:
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cProtocolServer::GetScheduleMutex()
+{
+ ULONGLONG nStart = GetTickCount();
+
+ //TRACE( "Locking Schedule mutex\n" );
+ int nRet = pthread_mutex_lock( &mScheduleMutex );
+ if (nRet != 0)
+ {
+ TRACE( "Unable to lock schedule mutex. Error %d: %s\n",
+ nRet,
+ strerror( nRet ) );
+ return false;
+ }
+
+ ULONGLONG nEnd = GetTickCount();
+ if (nEnd - nStart > DEADLOCK_TIME)
+ {
+ TRACE( "Deadlock time exceeded: took %llu ms\n", nEnd - nStart );
+ ReleaseScheduleMutex( true );
+ return false;
+ }
+
+ //TRACE( "Locked ScheduleMutex\n" );
+ return true;
+}
+
+/*===========================================================================
+METHOD:
+ ReleaseScheduleMutex (Internal Method)
+
+DESCRIPTION:
+ Release lock on the schedule mutex
+
+SEQUENCING:
+ Calling process must have lock
+
+PARAMETERS:
+ bSignalThread [ I ] - Signal Schedule thread as well?
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cProtocolServer::ReleaseScheduleMutex( bool bSignalThread )
+{
+ if (bSignalThread == true)
+ {
+ if (mThreadScheduleEvent.Set( 1 ) != 0)
+ {
+ return false;
+ }
+ }
+
+ int nRet = pthread_mutex_unlock( &mScheduleMutex );
+ if (nRet != 0)
+ {
+ TRACE( "Unable to unlock schedule mutex. Error %d: %s\n",
+ nRet,
+ strerror( nRet ) );
+ return false;
+ }
+
+ return true;
+}
diff --git a/gobi-api/GobiAPI_1.0.40/Core/ProtocolServer.h b/gobi-api/GobiAPI_1.0.40/Core/ProtocolServer.h
new file mode 100755
index 0000000..4f8bd4c
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/ProtocolServer.h
@@ -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;
+};
+
diff --git a/gobi-api/GobiAPI_1.0.40/Core/QDLBuffers.cpp b/gobi-api/GobiAPI_1.0.40/Core/QDLBuffers.cpp
new file mode 100755
index 0000000..c6e2010
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/QDLBuffers.cpp
@@ -0,0 +1,1093 @@
+/*===========================================================================
+FILE:
+ QDLBuffers.cpp
+
+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.
+===========================================================================*/
+
+//---------------------------------------------------------------------------
+// Include Files
+//---------------------------------------------------------------------------
+#include "StdAfx.h"
+#include "QDLBuffers.h"
+#include "CRC.h"
+
+//---------------------------------------------------------------------------
+// Definitions
+//---------------------------------------------------------------------------
+
+/*=========================================================================*/
+// sQDLHello Methods
+/*=========================================================================*/
+
+/*===========================================================================
+METHOD:
+ sQDLHello (Public Method)
+
+DESCRIPTION:
+ Constructor
+
+PARAMETERS:
+ pBuffer [ I ] - Shareable buffer that contains the QDL data
+
+RETURN VALUE:
+ None
+===========================================================================*/
+sQDLHello::sQDLHello( sSharedBuffer * pBuffer )
+ : sProtocolBuffer( pBuffer )
+{
+ sQDLHello::Validate();
+}
+
+/*===========================================================================
+METHOD:
+ ~sQDLHello (Public Method)
+
+DESCRIPTION:
+ Destructor
+
+RETURN VALUE:
+ None
+===========================================================================*/
+sQDLHello::~sQDLHello()
+{
+ // Nothing to do
+}
+
+/*===========================================================================
+METHOD:
+ Validate (Internal Method)
+
+DESCRIPTION:
+ Is this hello request/response packet valid?
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool sQDLHello::Validate()
+{
+ // Assume failure
+ bool bRC = false;
+
+ // Sanity check protocol type
+ eProtocolType pt = GetType();
+ if (pt != ePROTOCOL_QDL_RX && pt != ePROTOCOL_QDL_TX)
+ {
+ mbValid = bRC;
+ return bRC;
+ }
+
+ ULONG sz = GetSize();
+ const ULONG szReq = (ULONG)sizeof(sQDLRawHelloReq);
+ const ULONG szRsp = (ULONG)sizeof(sQDLRawHelloRsp);
+
+ if (pt == ePROTOCOL_QDL_TX && sz == szReq)
+ {
+ const sQDLRawHelloReq * pReq = (const sQDLRawHelloReq *)GetBuffer();
+ if (pReq->mCommandCode != (BYTE)eQDL_CMD_HELLO_REQ)
+ {
+ return bRC;
+ }
+
+ int notEqual = memcmp( (const void *)&pReq->mMagicNumber[0],
+ (const void *)&QDL_HELLO_MAGIC_REQ[0],
+ sizeof( QDL_HELLO_MAGIC_REQ ) );
+
+ if (notEqual != 0)
+ {
+ return bRC;
+ }
+
+ bRC = true;
+ }
+ else if (pt == ePROTOCOL_QDL_RX && sz == szRsp)
+ {
+ const sQDLRawHelloRsp * pRsp = (const sQDLRawHelloRsp *)GetBuffer();
+ if (pRsp->mCommandCode != (BYTE)eQDL_CMD_HELLO_RSP)
+ {
+ return bRC;
+ }
+
+ int notEqual = memcmp( (const void *)&pRsp->mMagicNumber[0],
+ (const void *)&QDL_HELLO_MAGIC_RSP[0],
+ sizeof( QDL_HELLO_MAGIC_RSP ) );
+
+ if (notEqual != 0)
+ {
+ return bRC;
+ }
+
+ if ( (pRsp->mMaxVersion != QDL_MIN_VERSION)
+ || (pRsp->mMinVersion != QDL_MAX_VERSION) )
+ {
+ return bRC;
+ }
+
+ if ( ((pRsp->mFeatures & QDL_FEATURE_GENERIC_UNFRAMED) == 0)
+ || ((pRsp->mFeatures & QDL_FEATURE_QDL_UNFRAMED) == 0) )
+ {
+ return bRC;
+ }
+
+ bRC = true;
+ }
+
+ mbValid = bRC;
+ return mbValid;
+}
+
+/*===========================================================================
+METHOD:
+ GetBootVersionInfo (Internal Method)
+
+DESCRIPTION:
+ Extract boot downloader version info from the response
+
+PARAMETERS:
+ major [ O ] - Major version
+ minor [ O ] - Minor version
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool sQDLHello::GetBootVersionInfo(
+ ULONG & major,
+ ULONG & minor ) const
+{
+ // Assume failure
+ bool bRC = false;
+
+ major = 0;
+ minor = 0;
+
+ const sQDLRawHelloRsp * pRsp = GetResponse();
+ if (pRsp == 0)
+ {
+ return bRC;
+ }
+
+ major = (ULONG)pRsp->mBootMajorVersion;
+ minor = (ULONG)pRsp->mBootMinorVersion;
+
+ bRC = true;
+ return bRC;
+}
+
+/*===========================================================================
+METHOD:
+ BuildHelloReq (Static Public Method)
+
+DESCRIPTION:
+ Build a hello request
+
+PARAMETERS:
+ bBARMode [ O ] - Request boot and recovery mode feature
+
+RETURN VALUE:
+ sSharedBuffer * : The request in an allocated buffer (0 on error)
+===========================================================================*/
+sSharedBuffer * sQDLHello::BuildHelloReq( bool bBARMode )
+{
+ const ULONG sz = (ULONG)sizeof(sQDLRawHelloReq);
+ BYTE req[sz];
+
+ sQDLRawHelloReq * pReq = (sQDLRawHelloReq *)&req[0];
+
+ pReq->mCommandCode = (BYTE)eQDL_CMD_HELLO_REQ;
+ pReq->mMaxVersion = QDL_MIN_VERSION;
+ pReq->mMinVersion = QDL_MAX_VERSION;
+ pReq->mFeatures = QDL_FEATURE_GENERIC_UNFRAMED | QDL_FEATURE_QDL_UNFRAMED;
+
+ if (bBARMode == true)
+ {
+ pReq->mFeatures |= QDL_FEATURE_BAR_MODE;
+ }
+
+ memcpy( (PVOID)&pReq->mMagicNumber[0],
+ (const VOID *)&QDL_HELLO_MAGIC_REQ[0],
+ (SIZE_T)32 );
+
+ eProtocolType pt = ePROTOCOL_QDL_TX;
+ sSharedBuffer * pRetBuf = new sSharedBuffer( (const BYTE *)req, sz, pt );
+ return pRetBuf;
+}
+
+/*=========================================================================*/
+// sQDLError Methods
+/*=========================================================================*/
+
+/*===========================================================================
+METHOD:
+ sQDLError (Public Method)
+
+DESCRIPTION:
+ Constructor
+
+PARAMETERS:
+ pBuffer [ I ] - Shareable buffer that contains the QDL data
+
+RETURN VALUE:
+ None
+===========================================================================*/
+sQDLError::sQDLError( sSharedBuffer * pBuffer )
+ : sProtocolBuffer( pBuffer )
+{
+ sQDLError::Validate();
+}
+
+/*===========================================================================
+METHOD:
+ ~sQDLError (Public Method)
+
+DESCRIPTION:
+ Destructor
+
+RETURN VALUE:
+ None
+===========================================================================*/
+sQDLError::~sQDLError()
+{
+ // Nothing to do
+}
+
+/*===========================================================================
+METHOD:
+ Validate (Internal Method)
+
+DESCRIPTION:
+ Is this session done request/response packet valid?
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool sQDLError::Validate()
+{
+ // Assume failure
+ bool bRC = false;
+
+ // Sanity check protocol type
+ eProtocolType pt = GetType();
+ if (pt != ePROTOCOL_QDL_RX)
+ {
+ mbValid = bRC;
+ return bRC;
+ }
+
+ ULONG sz = GetSize();
+ const ULONG szRsp = (ULONG)sizeof( sQDLRawErrorRsp );
+
+ if (sz >= szRsp)
+ {
+ const sQDLRawErrorRsp * pRsp = 0;
+ pRsp = (const sQDLRawErrorRsp *)GetBuffer();
+ if (pRsp->mCommandCode != (BYTE)eQDL_CMD_ERROR)
+ {
+ return bRC;
+ }
+
+ // Error code needs to be valid
+ if (::IsValid( (eQDLError)pRsp->mErrorCode ) == false)
+ {
+ return bRC;
+ }
+
+ // Error text needs to be NULL terminated
+ const BYTE * pTmp = GetBuffer();
+ if (pTmp[sz - 1] != 0)
+ {
+ return bRC;
+ }
+
+ // What there is of the error text needs to be printable
+ pTmp = &pRsp->mErrorText;
+ while (*pTmp != 0)
+ {
+ int val = (int)*pTmp++;
+ if (isprint( (int)val ) == 0)
+ {
+ return bRC;
+ }
+ }
+
+ bRC = true;
+ }
+
+ mbValid = bRC;
+ return mbValid;
+}
+
+/*=========================================================================*/
+// sQDLOpenUnframed Methods
+/*=========================================================================*/
+
+/*===========================================================================
+METHOD:
+ sQDLOpenUnframed (Public Method)
+
+DESCRIPTION:
+ Constructor
+
+PARAMETERS:
+ pBuffer [ I ] - Shareable buffer that contains the QDL data
+
+RETURN VALUE:
+ None
+===========================================================================*/
+sQDLOpenUnframed::sQDLOpenUnframed( sSharedBuffer * pBuffer )
+ : sProtocolBuffer( pBuffer )
+{
+ sQDLOpenUnframed::Validate();
+}
+
+/*===========================================================================
+METHOD:
+ ~sQDLOpenUnframed (Public Method)
+
+DESCRIPTION:
+ Destructor
+
+RETURN VALUE:
+ None
+===========================================================================*/
+sQDLOpenUnframed::~sQDLOpenUnframed()
+{
+ // Nothing to do
+}
+
+/*===========================================================================
+METHOD:
+ Validate (Internal Method)
+
+DESCRIPTION:
+ Is this open unframed request/response packet valid?
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool sQDLOpenUnframed::Validate()
+{
+ // Assume failure
+ bool bRC = false;
+
+ // Sanity check protocol type
+ eProtocolType pt = GetType();
+ if (pt != ePROTOCOL_QDL_RX && pt != ePROTOCOL_QDL_TX)
+ {
+ mbValid = bRC;
+ return bRC;
+ }
+
+ ULONG sz = GetSize();
+ const ULONG szReq = (ULONG)sizeof(sQDLRawOpenUnframedReq);
+ const ULONG szRsp = (ULONG)sizeof(sQDLRawOpenUnframedRsp);
+
+ if (pt == ePROTOCOL_QDL_TX && sz == szReq)
+ {
+ const sQDLRawOpenUnframedReq * pReq = 0;
+ pReq = (const sQDLRawOpenUnframedReq *)GetBuffer();
+ if (pReq->mCommandCode != (BYTE)eQDL_CMD_OPEN_UNFRAMED_REQ)
+ {
+ return bRC;
+ }
+
+ if (::IsValid( (eQDLImageType)pReq->mImageType ) == false)
+ {
+ return bRC;
+ }
+
+ if (pReq->mWindowSize != 1)
+ {
+ return bRC;
+ }
+
+ bRC = true;
+ }
+ else if (pt == ePROTOCOL_QDL_RX && sz == szRsp)
+ {
+ const sQDLRawOpenUnframedRsp * pRsp = 0;
+ pRsp = (const sQDLRawOpenUnframedRsp *)GetBuffer();
+ if (pRsp->mCommandCode != (BYTE)eQDL_CMD_OPEN_UNFRAMED_RSP)
+ {
+ return bRC;
+ }
+
+ if (pRsp->mWindowSize != 1)
+ {
+ return bRC;
+ }
+
+ bRC = true;
+ }
+
+ mbValid = bRC;
+ return mbValid;
+}
+
+/*===========================================================================
+METHOD:
+ GetChunkSize (Internal Method)
+
+DESCRIPTION:
+ Extract chunk size info from the response
+
+PARAMETERS:
+ chunkSize [ O ] - Target supported chunk size
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool sQDLOpenUnframed::GetChunkSize( ULONG & chunkSize ) const
+{
+ // Assume failure
+ bool bRC = false;
+
+ chunkSize = 0;
+
+ const sQDLRawOpenUnframedRsp * pRsp = GetResponse();
+ if (pRsp == 0)
+ {
+ return bRC;
+ }
+
+ chunkSize = (ULONG)pRsp->mUnframedChunkSize;
+
+ bRC = true;
+ return bRC;
+}
+
+/*===========================================================================
+METHOD:
+ BuildOpenUnframedReq (Static Public Method)
+
+DESCRIPTION:
+ Build an open image for unframed write request
+
+PARAMETERS:
+ imageType [ I ] - Type of image about to be written
+ imageSize [ I ] - Size of image about to be written
+ chunkSize [ I ] - Desired size of chunk for each write
+
+RETURN VALUE:
+ sSharedBuffer * : The request in an allocated buffer (0 on error)
+===========================================================================*/
+sSharedBuffer * sQDLOpenUnframed::BuildOpenUnframedReq(
+ eQDLImageType imageType,
+ ULONG imageSize,
+ ULONG chunkSize )
+{
+ sSharedBuffer * pRetBuf = 0;
+ if (::IsValid( imageType ) == false)
+ {
+ return pRetBuf;
+ }
+
+ // We can not write out chunks larger than the maximum
+ if (chunkSize > QDL_MAX_CHUNK_SIZE)
+ {
+ return pRetBuf;
+ }
+
+ const ULONG sz = (ULONG)sizeof(sQDLRawOpenUnframedReq);
+ BYTE req[sz];
+
+ memset( (LPVOID)&req[0], 0, (SIZE_T)sz );
+
+ sQDLRawOpenUnframedReq * pReq = (sQDLRawOpenUnframedReq *)&req[0];
+
+ pReq->mCommandCode = (BYTE)eQDL_CMD_OPEN_UNFRAMED_REQ;
+ pReq->mImageType = (BYTE)imageType;
+ pReq->mImageLength = (DWORD)imageSize;
+ pReq->mWindowSize = 1;
+ pReq->mUnframedChunkSize = chunkSize;
+
+ eProtocolType pt = ePROTOCOL_QDL_TX;
+ pRetBuf = new sSharedBuffer( (const BYTE *)req, sz, pt );
+ return pRetBuf;
+}
+
+/*=========================================================================*/
+// sQDLWriteUnframed Methods
+/*=========================================================================*/
+
+/*===========================================================================
+METHOD:
+ sQDLWriteUnframed (Public Method)
+
+DESCRIPTION:
+ Constructor
+
+PARAMETERS:
+ pBuffer [ I ] - Shareable buffer that contains the QDL data
+
+RETURN VALUE:
+ None
+===========================================================================*/
+sQDLWriteUnframed::sQDLWriteUnframed( sSharedBuffer * pBuffer )
+ : sProtocolBuffer( pBuffer )
+{
+ sQDLWriteUnframed::Validate();
+}
+
+/*===========================================================================
+METHOD:
+ ~sQDLWriteUnframed (Public Method)
+
+DESCRIPTION:
+ Destructor
+
+RETURN VALUE:
+ None
+===========================================================================*/
+sQDLWriteUnframed::~sQDLWriteUnframed()
+{
+ // Nothing to do
+}
+
+/*===========================================================================
+METHOD:
+ Validate (Internal Method)
+
+DESCRIPTION:
+ Is this unframed write request/response packet valid?
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool sQDLWriteUnframed::Validate()
+{
+ // Assume failure
+ bool bRC = false;
+
+ // Sanity check protocol type
+ eProtocolType pt = GetType();
+ if (pt != ePROTOCOL_QDL_RX && pt != ePROTOCOL_QDL_TX)
+ {
+ mbValid = bRC;
+ return bRC;
+ }
+
+ ULONG sz = GetSize();
+ const ULONG szReq = (ULONG)sizeof( sQDLRawWriteUnframedReq );
+ const ULONG szRsp = (ULONG)sizeof( sQDLRawWriteUnframedRsp );
+
+ if (pt == ePROTOCOL_QDL_TX && sz == szReq)
+ {
+ const sQDLRawWriteUnframedReq * pReq = 0;
+ pReq = (const sQDLRawWriteUnframedReq *)GetBuffer();
+ if (pReq->mCommandCode != (BYTE)eQDL_CMD_WRITE_UNFRAMED_REQ)
+ {
+ return bRC;
+ }
+
+ bRC = CheckCRC( GetBuffer(), szReq - sizeof( USHORT ) );
+ }
+ else if (pt == ePROTOCOL_QDL_RX && sz == szRsp)
+ {
+ const sQDLRawWriteUnframedRsp * pRsp = 0;
+ pRsp = (const sQDLRawWriteUnframedRsp *)GetBuffer();
+ if (pRsp->mCommandCode != (BYTE)eQDL_CMD_WRITE_UNFRAMED_RSP)
+ {
+ return bRC;
+ }
+
+ bRC = true;
+ }
+
+ mbValid = bRC;
+ return mbValid;
+}
+
+/*===========================================================================
+METHOD:
+ GetSequenceNumber (Internal Method)
+
+DESCRIPTION:
+ Extract sequence number from the response
+
+PARAMETERS:
+ sequenceNumber [ O ] - Target reported sequence number
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool sQDLWriteUnframed::GetSequenceNumber( ULONG & sequenceNumber ) const
+{
+ // Assume failure
+ bool bRC = false;
+
+ sequenceNumber = 0;
+
+ const sQDLRawWriteUnframedRsp * pRsp = GetResponse();
+ if (pRsp == 0)
+ {
+ return bRC;
+ }
+
+ sequenceNumber = (ULONG)pRsp->mSequenceNumber;
+
+ bRC = true;
+ return bRC;
+}
+
+/*===========================================================================
+METHOD:
+ BuildWriteUnframedReq (Static Public Method)
+
+DESCRIPTION:
+ Build an unframed write request
+
+PARAMETERS:
+ sequenceNumber [ I ] - Type of image about to be written
+ chunkSize [ I ] - Size of chunk being written
+
+RETURN VALUE:
+ sSharedBuffer * : The request in an allocated buffer (0 on error)
+===========================================================================*/
+sSharedBuffer * sQDLWriteUnframed::BuildWriteUnframedReq(
+ USHORT sequenceNumber,
+ ULONG chunkSize )
+{
+ sSharedBuffer * pRetBuf = 0;
+
+ // We can not write out chunks larger than the maximum
+ if (chunkSize == 0 || chunkSize > (ULONG)QDL_MAX_CHUNK_SIZE)
+ {
+ return pRetBuf;
+ }
+
+ const ULONG sz = (ULONG)sizeof(sQDLRawWriteUnframedReq);
+ BYTE req[sz];
+
+ memset( (LPVOID)&req[0], 0, (SIZE_T)sz );
+
+ sQDLRawWriteUnframedReq * pReq = (sQDLRawWriteUnframedReq *)&req[0];
+
+ pReq->mCommandCode = (BYTE)eQDL_CMD_WRITE_UNFRAMED_REQ;
+ pReq->mSequenceNumber = (WORD)sequenceNumber;
+ pReq->mUnframedChunkSize = (DWORD)chunkSize;
+ SetCRC( req, sz - sizeof( USHORT ) );
+
+ eProtocolType pt = ePROTOCOL_QDL_TX;
+ pRetBuf = new sSharedBuffer( (const BYTE *)req, sz, pt );
+ return pRetBuf;
+}
+
+/*===========================================================================
+METHOD:
+ BuildWriteUnframedReqs (Static Public Method)
+
+DESCRIPTION:
+ Build list of unframed write requests from the given parameters
+
+PARAMETERS:
+ chunkSize [ I ] - Size to write in each request
+ dataLen [ I ] - Total number of bytes to write
+
+RETURN VALUE:
+ std::list <sSharedBuffer *> : The requests in allocated buffers (the
+ list is empty on error)
+===========================================================================*/
+std::list <sSharedBuffer *> sQDLWriteUnframed::BuildWriteUnframedReqs(
+ ULONG chunkSize,
+ ULONG totalSize )
+{
+ std::list <sSharedBuffer *> retList;
+
+ // Check length (in bytes) is acceptable
+ if (chunkSize == 0 || chunkSize > QDL_MAX_CHUNK_SIZE)
+ {
+ return retList;
+ }
+
+ ULONG writes = 1;
+ ULONG rem = totalSize;
+
+ // Will we need more than one write request?
+ if (totalSize > chunkSize)
+ {
+ writes = totalSize / chunkSize;
+ rem = totalSize % chunkSize;
+
+ // Total size is a multiple of chunk size?
+ if (rem == 0)
+ {
+ // Yes, the remainder will be the block size
+ rem = chunkSize;
+ }
+ else
+ {
+ // No, we need an extra write for the remainder
+ writes++;
+ }
+ }
+
+ ULONG blockSz = chunkSize;
+ if (writes == 1)
+ {
+ blockSz = rem;
+ }
+
+ // Generate first request
+ USHORT seqNum = 0;
+ sSharedBuffer * pReq = 0;
+ pReq = sQDLWriteUnframed::BuildWriteUnframedReq( seqNum++, blockSz );
+ if (pReq != 0)
+ {
+ retList.push_back( pReq );
+ }
+
+ // Generate remaining requests
+ for (UINT b = 1; b < writes; b++)
+ {
+ blockSz = chunkSize;
+ if (b == writes - 1)
+ {
+ blockSz = rem;
+ }
+
+ pReq = sQDLWriteUnframed::BuildWriteUnframedReq( seqNum++, blockSz );
+ if (pReq != 0)
+ {
+ retList.push_back( pReq );
+ }
+ }
+
+ // Errors?
+ if (retList.size() != writes)
+ {
+ // Free up all our hard work
+ std::list <sSharedBuffer *>::const_iterator pIter = retList.begin();
+ while (pIter != retList.end())
+ {
+ delete [] *pIter;
+ pIter++;
+ }
+
+ retList.clear();
+ }
+
+ return retList;
+}
+
+/*=========================================================================*/
+// sQDLDone Methods
+/*=========================================================================*/
+
+/*===========================================================================
+METHOD:
+ sQDLDone (Public Method)
+
+DESCRIPTION:
+ Constructor
+
+PARAMETERS:
+ pBuffer [ I ] - Shareable buffer that contains the QDL data
+
+RETURN VALUE:
+ None
+===========================================================================*/
+sQDLDone::sQDLDone( sSharedBuffer * pBuffer )
+ : sProtocolBuffer( pBuffer )
+{
+ sQDLDone::Validate();
+}
+
+/*===========================================================================
+METHOD:
+ ~sQDLDone (Public Method)
+
+DESCRIPTION:
+ Destructor
+
+RETURN VALUE:
+ None
+===========================================================================*/
+sQDLDone::~sQDLDone()
+{
+ // Nothing to do
+}
+
+/*===========================================================================
+METHOD:
+ Validate (Internal Method)
+
+DESCRIPTION:
+ Is this session done request/response packet valid?
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool sQDLDone::Validate()
+{
+ // Assume failure
+ bool bRC = false;
+
+ // Sanity check protocol type
+ eProtocolType pt = GetType();
+ if (pt != ePROTOCOL_QDL_RX && pt != ePROTOCOL_QDL_TX)
+ {
+ mbValid = bRC;
+ return bRC;
+ }
+
+ ULONG sz = GetSize();
+ const ULONG szReq = (ULONG)sizeof( BYTE );
+ const ULONG szRsp = (ULONG)sizeof( sQDLRawDoneRsp );
+
+ if (pt == ePROTOCOL_QDL_TX && sz == szReq)
+ {
+ const BYTE * pReq = GetBuffer();
+ if (*pReq != (BYTE)eQDL_CMD_SESSION_DONE_REQ)
+ {
+ return bRC;
+ }
+
+ bRC = true;
+ }
+ else if (pt == ePROTOCOL_QDL_RX && sz >= szRsp)
+ {
+ const sQDLRawDoneRsp * pRsp = 0;
+ pRsp = (const sQDLRawDoneRsp *)GetBuffer();
+ if (pRsp->mCommandCode != (BYTE)eQDL_CMD_SESSION_DONE_RSP)
+ {
+ return bRC;
+ }
+
+ // Status needs to be valid
+ if (::IsValid( (eQDLDoneStatus)pRsp->mStatus ) == false)
+ {
+ return bRC;
+ }
+
+ // For success the error text should be NULL
+ if ( (pRsp->mStatus == (WORD)eQDL_DONE_STATUS_SUCCESS)
+ && (sz != szRsp || pRsp->mErrorText != 0) )
+ {
+ return bRC;
+ }
+
+ if (pRsp->mStatus != (WORD)eQDL_DONE_STATUS_SUCCESS)
+ {
+ // Error text needs to be NULL terminated
+ const BYTE * pTmp = GetBuffer();
+ if (pTmp[sz - 1] != 0)
+ {
+ return bRC;
+ }
+
+ // What there is of the error text needs to be printable
+ pTmp = &pRsp->mErrorText;
+ while (*pTmp != 0)
+ {
+ int val = (int)*pTmp++;
+ if (isprint( (int)val ) == 0)
+ {
+ return bRC;
+ }
+ }
+ }
+
+ bRC = true;
+ }
+
+ mbValid = bRC;
+ return mbValid;
+}
+
+/*=========================================================================*/
+// sQDLGetImagePref Methods
+/*=========================================================================*/
+
+/*===========================================================================
+METHOD:
+ sQDLGetImagePref (Public Method)
+
+DESCRIPTION:
+ Constructor
+
+PARAMETERS:
+ pBuffer [ I ] - Shareable buffer that contains the QDL data
+
+RETURN VALUE:
+ None
+===========================================================================*/
+sQDLGetImagePref::sQDLGetImagePref( sSharedBuffer * pBuffer )
+ : sProtocolBuffer( pBuffer )
+{
+ sQDLGetImagePref::Validate();
+}
+
+/*===========================================================================
+METHOD:
+ ~sQDLGetImagePref (Public Method)
+
+DESCRIPTION:
+ Destructor
+
+RETURN VALUE:
+ None
+===========================================================================*/
+sQDLGetImagePref::~sQDLGetImagePref()
+{
+ // Nothing to do
+}
+
+/*===========================================================================
+METHOD:
+ Validate (Internal Method)
+
+DESCRIPTION:
+ Is this get image preference request/response packet valid?
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool sQDLGetImagePref::Validate()
+{
+ // Assume failure
+ bool bRC = false;
+
+ // Sanity check protocol type
+ eProtocolType pt = GetType();
+ if (pt != ePROTOCOL_QDL_RX && pt != ePROTOCOL_QDL_TX)
+ {
+ mbValid = bRC;
+ return bRC;
+ }
+
+ ULONG sz = GetSize();
+ const ULONG szReq = (ULONG)sizeof( BYTE );
+ const ULONG szRsp = (ULONG)sizeof( sQDLRawGetImagePrefRsp );
+
+ if (pt == ePROTOCOL_QDL_TX && sz == szReq)
+ {
+ const BYTE * pReq = GetBuffer();
+ if (*pReq != (BYTE)eQDL_CMD_GET_IMAGE_PREF_REQ)
+ {
+ return bRC;
+ }
+
+ bRC = true;
+ }
+ else if (pt == ePROTOCOL_QDL_RX && sz >= szRsp)
+ {
+ const sQDLRawGetImagePrefRsp * pRsp = 0;
+ pRsp = (const sQDLRawGetImagePrefRsp *)GetBuffer();
+ if (pRsp->mCommandCode != (BYTE)eQDL_CMD_GET_IMAGE_PREF_RSP)
+ {
+ return bRC;
+ }
+
+ BYTE entries = pRsp->mEntries;
+ ULONG needSz = szRsp + (ULONG)entries * (ULONG)sizeof( sQDLRawImageID );
+ if (sz != needSz)
+ {
+ return bRC;
+ }
+
+ // Skip response header
+ pRsp++;
+
+ // Validate image IDs
+ const sQDLRawImageID * pID = (const sQDLRawImageID *)pRsp;
+ for (BYTE e = 0; e < entries; e++)
+ {
+ sQDLRawImageID imagePref = *pID++;
+ if (::IsValid( (eQDLImageType)imagePref.mImageType) == false)
+ {
+ return bRC;
+ }
+ }
+
+ bRC = true;
+ }
+
+ mbValid = bRC;
+ return mbValid;
+}
+
+/*===========================================================================
+METHOD:
+ GetImageIDs (Public Method)
+
+DESCRIPTION:
+ Return image IDs
+
+RETURN VALUE:
+ std::list <sQDLRawImageID>
+===========================================================================*/
+std::list <sQDLRawImageID> sQDLGetImagePref::GetImageIDs() const
+{
+ // Assume failure
+ std::list <sQDLRawImageID> retIDs;
+
+ const sQDLRawGetImagePrefRsp * pRsp = GetResponse();
+ if (pRsp == 0)
+ {
+ return retIDs;
+ }
+
+ BYTE entries = pRsp->mEntries;
+ if (entries == 0)
+ {
+ return retIDs;
+ }
+
+ // Skip response header
+ pRsp++;
+
+ const sQDLRawImageID * pID = (const sQDLRawImageID *)pRsp;
+ for (BYTE e = 0; e < entries; e++)
+ {
+ retIDs.push_back( *pID++ );
+ }
+
+ return retIDs;
+}
diff --git a/gobi-api/GobiAPI_1.0.40/Core/QDLBuffers.h b/gobi-api/GobiAPI_1.0.40/Core/QDLBuffers.h
new file mode 100755
index 0000000..cf6f1af
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/QDLBuffers.h
@@ -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 & );
+};
diff --git a/gobi-api/GobiAPI_1.0.40/Core/QDLEnum.h b/gobi-api/GobiAPI_1.0.40/Core/QDLEnum.h
new file mode 100755
index 0000000..f53b19e
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/QDLEnum.h
@@ -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;
+};
diff --git a/gobi-api/GobiAPI_1.0.40/Core/QDLProtocolServer.cpp b/gobi-api/GobiAPI_1.0.40/Core/QDLProtocolServer.cpp
new file mode 100755
index 0000000..9568b1a
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/QDLProtocolServer.cpp
@@ -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;
+}
diff --git a/gobi-api/GobiAPI_1.0.40/Core/QDLProtocolServer.h b/gobi-api/GobiAPI_1.0.40/Core/QDLProtocolServer.h
new file mode 100755
index 0000000..f86c6fe
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/QDLProtocolServer.h
@@ -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 );
+};
diff --git a/gobi-api/GobiAPI_1.0.40/Core/QMIBuffers.cpp b/gobi-api/GobiAPI_1.0.40/Core/QMIBuffers.cpp
new file mode 100755
index 0000000..154617b
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/QMIBuffers.cpp
@@ -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;
+}
+
diff --git a/gobi-api/GobiAPI_1.0.40/Core/QMIBuffers.h b/gobi-api/GobiAPI_1.0.40/Core/QMIBuffers.h
new file mode 100755
index 0000000..2f4c5eb
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/QMIBuffers.h
@@ -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 & );
+};
+
diff --git a/gobi-api/GobiAPI_1.0.40/Core/QMIEnum.h b/gobi-api/GobiAPI_1.0.40/Core/QMIEnum.h
new file mode 100755
index 0000000..88a7d9d
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/QMIEnum.h
@@ -0,0 +1,1149 @@
+/*===========================================================================
+FILE:
+ QMIEnum.h
+
+DESCRIPTION:
+ QMI protocol enumerations and related methods
+
+PUBLIC ENUMERATIONS AND METHODS:
+ eQMIService
+ eQMIMessageCTL
+ eQMIMessageWDS
+ eQMIMessageDMS
+ eQMIMessageNAS
+ eQMIMessageWMS
+ eQMIMessagePDS
+ eQMIMessageAUTH
+ eQMIMessageCAT
+ eQMIMessageRMS
+ eQMIMessageOMA
+ eQMIResultCode
+ eQMIErrorCode
+ eQMICallEndReason
+
+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
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+// Definitions
+//---------------------------------------------------------------------------
+
+// Invalid QMI transaction ID
+const ULONG INVALID_QMI_TRANSACTION_ID = 0;
+
+// QMI DMS PRL size constants
+const ULONG QMI_DMS_MAX_PRL_SIZE = 16384;
+const ULONG QMI_DMS_MAX_PRL_BLOCK = 256;
+
+/*=========================================================================*/
+// eQMIService Enumeration
+// QMI Service Type Enumeration
+/*=========================================================================*/
+enum eQMIService
+{
+ eQMI_SVC_ENUM_BEGIN = -1,
+
+ eQMI_SVC_CONTROL, // 000 Control service
+ eQMI_SVC_WDS, // 001 Wireless data service
+ eQMI_SVC_DMS, // 002 Device management service
+ eQMI_SVC_NAS, // 003 Network access service
+ eQMI_SVC_QOS, // 004 Quality of service, err, service
+ eQMI_SVC_WMS, // 005 Wireless messaging service
+ eQMI_SVC_PDS, // 006 Position determination service
+ eQMI_SVC_AUTH, // 007 Authentication service
+
+ eQMI_SVC_VOICE = 9, // 009 Voice service
+
+ eQMI_SVC_CAT = 224, // 224 Card application toolkit service
+ eQMI_SVC_RMS, // 225 Remote management service
+ eQMI_SVC_OMA, // 226 Open mobile alliance dev mgmt service
+
+ eQMI_SVC_ENUM_END
+};
+
+/*===========================================================================
+METHOD:
+ IsValid (Inline Method)
+
+DESCRIPTION:
+ eQMIService validity check
+
+PARAMETERS:
+ svc [ I ] - Enum value being verified
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+inline bool IsValid( eQMIService svc )
+{
+ bool retVal = false;
+ if ( (svc > eQMI_SVC_ENUM_BEGIN && svc <= eQMI_SVC_AUTH)
+ || (svc == eQMI_SVC_VOICE)
+ || (svc >= eQMI_SVC_CAT && svc < eQMI_SVC_ENUM_END) )
+ {
+ retVal = true;
+ }
+
+ return retVal;
+};
+
+/*=========================================================================*/
+// eQMIMessageCTL Enumeration
+// QMI Control Service Type Message ID Enumeration
+/*=========================================================================*/
+enum eQMIMessageCTL
+{
+ eQMI_CTL_ENUM_BEGIN = -1,
+
+ eQMI_CTL_SET_INSTANCE_ID = 32, // 32 Set the unique link instance ID
+ eQMI_CTL_GET_VERSION_INFO, // 33 Get supported service version info
+ eQMI_CTL_GET_CLIENT_ID, // 34 Get a unique client ID
+ eQMI_CTL_RELEASE_CLIENT_ID, // 35 Release the unique client ID
+ eQMI_CTL_REVOKE_CLIENT_ID_IND, // 36 Indication of client ID revocation
+ eQMI_CTL_INVALID_CLIENT_ID, // 37 Indication of invalid client ID
+ eQMI_CTL_SET_DATA_FORMAT, // 38 Set host driver data format
+ eQMI_CTL_SYNC, // 39 Synchronize client/server
+ eQMI_CTL_SYNC_IND = 39, // 39 Synchronize indication
+ eQMI_CTL_SET_EVENT, // 40 Set event report conditions
+ eQMI_CTL_EVENT_IND = 40, // 40 Event report indication
+ eQMI_CTL_SET_POWER_SAVE_CFG, // 41 Set power save config
+ eQMI_CTL_SET_POWER_SAVE_MODE, // 42 Set power save mode
+ eQMI_CTL_GET_POWER_SAVE_MODE, // 43 Get power save mode
+
+ eQMI_CTL_ENUM_END
+};
+
+/*===========================================================================
+METHOD:
+ IsValid (Inline Method)
+
+DESCRIPTION:
+ eQMIMessageCTL validity check
+
+PARAMETERS:
+ msgID [ I ] - Enum value being verified
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+inline bool IsValid( eQMIMessageCTL msgID )
+{
+ bool retVal = false;
+ if (msgID >= eQMI_CTL_SET_INSTANCE_ID && msgID < eQMI_CTL_ENUM_END)
+ {
+ retVal = true;
+ }
+
+ return retVal;
+};
+
+/*=========================================================================*/
+// eQMIMessageWDS Enumeration
+// QMI WDS Service Type Message ID Enumeration
+/*=========================================================================*/
+enum eQMIMessageWDS
+{
+ eQMI_WDS_ENUM_BEGIN = -1,
+
+ eQMI_WDS_RESET, // 00 Reset WDS service state variables
+ eQMI_WDS_SET_EVENT, // 01 Set connection state report conditions
+ eQMI_WDS_EVENT_IND = 1, // 01 Connection state report indication
+ eQMI_WDS_ABORT, // 02 Abort previously issued WDS command
+
+ eQMI_WDS_START_NET = 32, // 32 Start WDS network interface
+ eQMI_WDS_STOP_NET, // 33 Stop WDS network interface
+ eQMI_WDS_GET_PKT_STATUS, // 34 Get packet data connection status
+ eQMI_WDS_PKT_STATUS_IND = 34, // 34 Packet data connection status indication
+ eQMI_WDS_GET_RATES, // 35 Get current bit rates of the connection
+ eQMI_WDS_GET_STATISTICS, // 36 Get the packet data transfer statistics
+ eQMI_WDS_G0_DORMANT, // 37 Go dormant
+ eQMI_WDS_G0_ACTIVE, // 38 Go active
+ eQMI_WDS_CREATE_PROFILE, // 39 Create profile with specified settings
+ eQMI_WDS_MODIFY_PROFILE, // 40 Modify profile with specified settings
+ eQMI_WDS_DELETE_PROFILE, // 41 Delete the specified profile
+ eQMI_WDS_GET_PROFILE_LIST, // 42 Get all profiles
+ eQMI_WDS_GET_PROFILE, // 43 Get the specified profile
+ eQMI_WDS_GET_DEFAULTS, // 44 Get the default data session settings
+ eQMI_WDS_GET_SETTINGS, // 45 Get the runtime data session settings
+ eQMI_WDS_SET_MIP, // 46 Get the mobile IP setting
+ eQMI_WDS_GET_MIP, // 47 Set the mobile IP setting
+ eQMI_WDS_GET_DORMANCY, // 48 Get the dormancy status
+
+ eQMI_WDS_GET_AUTOCONNECT = 52, // 52 Get the NDIS autoconnect setting
+ eQMI_WDS_GET_DURATION, // 53 Get the duration of data session
+ eQMI_WDS_GET_MODEM_STATUS, // 54 Get the modem status
+ eQMI_WDS_MODEM_IND = 54, // 54 Modem status indication
+ eQMI_WDS_GET_DATA_BEARER, // 55 Get the data bearer type
+ eQMI_WDS_GET_MODEM_INFO, // 56 Get the modem info
+ eQMI_WDS_MODEM_INFO_IND = 56, // 56 Modem info indication
+
+ eQMI_WDS_GET_ACTIVE_MIP = 60, // 60 Get the active mobile IP profile
+ eQMI_WDS_SET_ACTIVE_MIP, // 61 Set the active mobile IP profile
+ eQMI_WDS_GET_MIP_PROFILE, // 62 Get mobile IP profile settings
+ eQMI_WDS_SET_MIP_PROFILE, // 63 Set mobile IP profile settings
+ eQMI_WDS_GET_MIP_PARAMS, // 64 Get mobile IP parameters
+ eQMI_WDS_SET_MIP_PARAMS, // 65 Set mobile IP parameters
+ eQMI_WDS_GET_LAST_MIP_STATUS, // 66 Get last mobile IP status
+ eQMI_WDS_GET_AAA_AUTH_STATUS, // 67 Get AN-AAA authentication status
+ eQMI_WDS_GET_CUR_DATA_BEARER, // 68 Get current data bearer
+ eQMI_WDS_GET_CALL_LIST, // 69 Get the call history list
+ eQMI_WDS_GET_CALL_ENTRY, // 70 Get an entry from the call history list
+ eQMI_WDS_CLEAR_CALL_LIST, // 71 Clear the call history list
+ eQMI_WDS_GET_CALL_LIST_MAX, // 72 Get maximum size of call history list
+
+ eQMI_WDS_SET_IP_FAMILY = 77, // 77 Set the client IP family preference
+
+ eQMI_WDS_SET_AUTOCONNECT = 81, // 81 Set the NDIS autoconnect setting
+ eQMI_WDS_GET_DNS, // 82 Get the DNS setting
+ eQMI_WDS_SET_DNS, // 83 Set the DNS setting
+
+ eQMI_WDS_ENUM_END
+};
+
+/*===========================================================================
+METHOD:
+ IsValid (Inline Method)
+
+DESCRIPTION:
+ eQMIMessageWDS validity check
+
+PARAMETERS:
+ msgID [ I ] - Enum value being verified
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+inline bool IsValid( eQMIMessageWDS msgID )
+{
+ bool retVal = false;
+ if ( (msgID > eQMI_WDS_ENUM_BEGIN && msgID <= eQMI_WDS_ABORT)
+ || (msgID >= eQMI_WDS_START_NET && msgID <= eQMI_WDS_GET_DORMANCY)
+ || (msgID >= eQMI_WDS_GET_AUTOCONNECT && msgID <= eQMI_WDS_MODEM_INFO_IND)
+ || (msgID >= eQMI_WDS_GET_ACTIVE_MIP && msgID <= eQMI_WDS_GET_CALL_LIST_MAX)
+ || (msgID == eQMI_WDS_SET_IP_FAMILY)
+ || (msgID >= eQMI_WDS_SET_AUTOCONNECT && msgID < eQMI_WDS_ENUM_END) )
+ {
+ retVal = true;
+ }
+
+ return retVal;
+};
+
+/*=========================================================================*/
+// eQMIMessageDMS Enumeration
+// QMI DMS Service Type Message ID Enumeration
+/*=========================================================================*/
+enum eQMIMessageDMS
+{
+ eQMI_DMS_ENUM_BEGIN = -1,
+
+ eQMI_DMS_RESET, // 00 Reset DMS service state variables
+ eQMI_DMS_SET_EVENT, // 01 Set connection state report conditions
+ eQMI_DMS_EVENT_IND = 1, // 01 Connection state report indication
+
+ eQMI_DMS_GET_CAPS = 32, // 32 Get the device capabilities
+ eQMI_DMS_GET_MANUFACTURER, // 33 Get the device manfacturer
+ eQMI_DMS_GET_MODEL_ID, // 34 Get the device model ID
+ eQMI_DMS_GET_REV_ID, // 35 Get the device revision ID
+ eQMI_DMS_GET_NUMBER, // 36 Get the assigned voice number
+ eQMI_DMS_GET_IDS, // 37 Get the ESN/IMEI/MEID
+ eQMI_DMS_GET_POWER_STATE, // 38 Get the get power state
+ eQMI_DMS_UIM_SET_PIN_PROT, // 39 UIM - Set PIN protection
+ eQMI_DMS_UIM_PIN_VERIFY, // 40 UIM - Verify PIN
+ eQMI_DMS_UIM_PIN_UNBLOCK, // 41 UIM - Unblock PIN
+ eQMI_DMS_UIM_PIN_CHANGE, // 42 UIM - Change PIN
+ eQMI_DMS_UIM_GET_PIN_STATUS, // 43 UIM - Get PIN status
+ eQMI_DMS_GET_MSM_ID = 44, // 44 Get MSM ID
+ eQMI_DMS_GET_OPERTAING_MODE, // 45 Get the operating mode
+ eQMI_DMS_SET_OPERATING_MODE, // 46 Set the operating mode
+ eQMI_DMS_GET_TIME, // 47 Get timestamp from the device
+ eQMI_DMS_GET_PRL_VERSION, // 48 Get the PRL version
+ eQMI_DMS_GET_ACTIVATED_STATE, // 49 Get the activation state
+ eQMI_DMS_ACTIVATE_AUTOMATIC, // 50 Perform an automatic activation
+ eQMI_DMS_ACTIVATE_MANUAL, // 51 Perform a manual activation
+ eQMI_DMS_GET_USER_LOCK_STATE, // 52 Get the lock state
+ eQMI_DMS_SET_USER_LOCK_STATE, // 53 Set the lock state
+ eQMI_DMS_SET_USER_LOCK_CODE, // 54 Set the lock PIN
+ eQMI_DMS_READ_USER_DATA, // 55 Read user data
+ eQMI_DMS_WRITE_USER_DATA, // 56 Write user data
+ eQMI_DMS_READ_ERI_FILE, // 57 Read the enhanced roaming indicator file
+ eQMI_DMS_FACTORY_DEFAULTS, // 58 Reset to factory defaults
+ eQMI_DMS_VALIDATE_SPC, // 59 Validate service programming code
+ eQMI_DMS_UIM_GET_ICCID, // 60 Get UIM ICCID
+ eQMI_DMS_GET_FIRWARE_ID, // 61 Get firmware ID
+ eQMI_DMS_SET_FIRMWARE_ID, // 62 Set firmware ID
+ eQMI_DMS_GET_HOST_LOCK_ID, // 63 Get host lock ID
+ eQMI_DMS_UIM_GET_CK_STATUS, // 64 UIM - Get control key status
+ eQMI_DMS_UIM_SET_CK_PROT, // 65 UIM - Set control key protection
+ eQMI_DMS_UIM_UNBLOCK_CK, // 66 UIM - Unblock facility control key
+ eQMI_DMS_GET_IMSI, // 67 Get the IMSI
+ eQMI_DMS_UIM_GET_STATE, // 68 UIM - Get the UIM state
+ eQMI_DMS_GET_BAND_CAPS, // 69 Get the device band capabilities
+ eQMI_DMS_GET_FACTORY_ID, // 70 Get the device factory ID
+ eQMI_DMS_GET_FIRMWARE_PREF, // 71 Get firmware preference
+ eQMI_DMS_SET_FIRMWARE_PREF, // 72 Set firmware preference
+ eQMI_DMS_LIST_FIRMWARE, // 73 List all stored firmware
+ eQMI_DMS_DELETE_FIRMWARE, // 74 Delete specified stored firmware
+ eQMI_DMS_SET_TIME, // 75 Set device time
+ eQMI_DMS_GET_FIRMWARE_INFO, // 76 Get stored firmware info
+ eQMI_DMS_GET_ALT_NET_CFG, // 77 Get alternate network config
+ eQMI_DMS_SET_ALT_NET_CFG, // 78 Set alternate network config
+ eQMI_DMS_GET_IMG_DLOAD_MODE, // 79 Get next image download mode
+ eQMI_DMS_SET_IMG_DLOAD_MODE, // 80 Set next image download mod
+
+ eQMI_DMS_ENUM_END
+};
+
+/*===========================================================================
+METHOD:
+ IsValid (Inline Method)
+
+DESCRIPTION:
+ eQMIMessageDMS validity check
+
+PARAMETERS:
+ msgID [ I ] - Enum value being verified
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+inline bool IsValid( eQMIMessageDMS msgID )
+{
+ bool retVal = false;
+ if ( (msgID > eQMI_DMS_ENUM_BEGIN && msgID <= eQMI_DMS_EVENT_IND)
+ || (msgID >= eQMI_DMS_GET_CAPS && msgID < eQMI_DMS_ENUM_END) )
+ {
+ retVal = true;
+ }
+
+ return retVal;
+};
+
+/*=========================================================================*/
+// eQMIMessageNAS Enumeration
+// QMI NAS Service Type Message ID Enumeration
+/*=========================================================================*/
+enum eQMIMessageNAS
+{
+ eQMI_NAS_ENUM_BEGIN = -1,
+
+ eQMI_NAS_RESET, // 00 Reset NAS service state variables
+ eQMI_NAS_ABORT, // 01 Abort previously issued NAS command
+ eQMI_NAS_SET_EVENT, // 02 Set NAS state report conditions
+ eQMI_NAS_EVENT_IND = 2, // 02 Connection state report indication
+ eQMI_NAS_SET_REG_EVENT, // 03 Set NAS registration report conditions
+
+ eQMI_NAS_GET_RSSI = 32, // 32 Get the signal strength
+ eQMI_NAS_SCAN_NETS, // 33 Scan for visible network
+ eQMI_NAS_REGISTER_NET, // 34 Initiate a network registration
+ eQMI_NAS_ATTACH_DETACH, // 35 Initiate an attach or detach action
+ eQMI_NAS_GET_SS_INFO, // 36 Get info about current serving system
+ eQMI_NAS_SS_INFO_IND = 36, // 36 Current serving system info indication
+ eQMI_NAS_GET_HOME_INFO, // 37 Get info about home network
+ eQMI_NAS_GET_NET_PREF_LIST, // 38 Get the list of preferred networks
+ eQMI_NAS_SET_NET_PREF_LIST, // 39 Set the list of preferred networks
+ eQMI_NAS_GET_NET_BAN_LIST, // 40 Get the list of forbidden networks
+ eQMI_NAS_SET_NET_BAN_LIST, // 41 Set the list of forbidden networks
+ eQMI_NAS_SET_TECH_PREF, // 42 Set the technology preference
+ eQMI_NAS_GET_TECH_PREF, // 43 Get the technology preference
+ eQMI_NAS_GET_ACCOLC, // 44 Get the Access Overload Class
+ eQMI_NAS_SET_ACCOLC, // 45 Set the Access Overload Class
+ eQMI_NAS_GET_SYSPREF, // 46 Get the CDMA system preference
+ eQMI_NAS_GET_NET_PARAMS, // 47 Get various network parameters
+ eQMI_NAS_SET_NET_PARAMS, // 48 Set various network parameters
+ eQMI_NAS_GET_RF_INFO, // 49 Get the SS radio/band channel info
+ eQMI_NAS_GET_AAA_AUTH_STATUS, // 50 Get AN-AAA authentication status
+ eQMI_NAS_SET_SYS_SELECT_PREF, // 51 Set system selection preference
+ eQMI_NAS_GET_SYS_SELECT_PREF, // 52 Get system selection preference
+ eQMI_NAS_SYS_SELECT_IND = 52, // 52 System selection pref indication
+
+ eQMI_NAS_SET_DDTM_PREF = 55, // 55 Set DDTM preference
+ eQMI_NAS_GET_DDTM_PREF, // 56 Get DDTM preference
+ eQMI_NAS_DDTM_IND = 56, // 56 DDTM preference indication
+
+ eQMI_NAS_GET_PLMN_MODE = 59, // 59 Get PLMN mode bit from CSP
+ eQMI_NAS_PLMN_MODE_IND, // 60 CSP PLMN mode bit indication
+
+ eQMI_NAS_GET_PLMN_NAME = 68, // 68 Get operator name for specified network
+
+ eQMI_NAS_ENUM_END
+};
+
+/*===========================================================================
+METHOD:
+ IsValid (Inline Method)
+
+DESCRIPTION:
+ eQMIMessageNAS validity check
+
+PARAMETERS:
+ msgID [ I ] - Enum value being verified
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+inline bool IsValid( eQMIMessageNAS msgID )
+{
+ bool retVal = false;
+ if ( (msgID > eQMI_NAS_ENUM_BEGIN && msgID <= eQMI_NAS_SET_REG_EVENT)
+ || (msgID >= eQMI_NAS_GET_RSSI && msgID <= eQMI_NAS_SYS_SELECT_IND)
+ || (msgID >= eQMI_NAS_SET_DDTM_PREF && msgID <= eQMI_NAS_DDTM_IND)
+ || (msgID >= eQMI_NAS_GET_PLMN_MODE && msgID <= eQMI_NAS_PLMN_MODE_IND)
+ || (msgID >= eQMI_NAS_GET_PLMN_NAME && msgID < eQMI_NAS_ENUM_END) )
+ {
+ retVal = true;
+ }
+ return retVal;
+};
+
+/*=========================================================================*/
+// eQMIMessageWMS Enumeration
+// QMI WMS Service Type Message ID Enumeration
+/*=========================================================================*/
+enum eQMIMessageWMS
+{
+ eQMI_WMS_ENUM_BEGIN = -1,
+
+ eQMI_WMS_RESET, // 00 Reset WMS service state variables
+ eQMI_WMS_SET_EVENT, // 01 Set new message report conditions
+ eQMI_WMS_EVENT_IND = 1, // 01 New message report indication
+
+ eQMI_WMS_RAW_SEND = 32, // 32 Send a raw message
+ eQMI_WMS_RAW_WRITE, // 33 Write a raw message to the device
+ eQMI_WMS_RAW_READ, // 34 Read a raw message from the device
+ eQMI_WMS_MODIFY_TAG, // 35 Modify message tag on the device
+ eQMI_WMS_DELETE, // 36 Delete message by index/tag/memory
+
+ eQMI_WMS_GET_MSG_PROTOCOL = 48, // 48 Get the current message protocol
+ eQMI_WMS_GET_MSG_LIST, // 49 Get list of messages from the device
+ eQMI_WMS_SET_ROUTES, // 50 Set routes for message memory storage
+ eQMI_WMS_GET_ROUTES, // 51 Get routes for message memory storage
+ eQMI_WMS_GET_SMSC_ADDR, // 52 Get SMSC address
+ eQMI_WMS_SET_SMSC_ADDR, // 53 Set SMSC address
+ eQMI_WMS_GET_MSG_LIST_MAX, // 54 Get maximum size of SMS storage
+ eQMI_WMS_SEND_ACK, // 55 Send ACK
+ eQMI_WMS_SET_RETRY_PERIOD, // 56 Set retry period
+ eQMI_WMS_SET_RETRY_INTERVAL, // 57 Set retry interval
+ eQMI_WMS_SET_DC_DISCO_TIMER, // 58 Set DC auto-disconnect timer
+ eQMI_WMS_SET_MEMORY_STATUS, // 59 Set memory storage status
+ eQMI_WMS_SET_BC_ACTIVATION, // 60 Set broadcast activation
+ eQMI_WMS_SET_BC_CONFIG, // 61 Set broadcast config
+ eQMI_WMS_GET_BC_CONFIG, // 62 Get broadcast config
+ eQMI_WMS_MEMORY_FULL_IND, // 63 Memory full indication
+ eQMI_WMS_GET_DOMAIN_PREF, // 64 Get domain preference
+ eQMI_WMS_SET_DOMAIN_PREF, // 65 Set domain preference
+ eQMI_WMS_MEMORY_SEND, // 66 Send message from memory store
+ eQMI_WMS_GET_MSG_WAITING, // 67 Get message waiting info
+ eQMI_WMS_MSG_WAITING_IND, // 68 Message waiting indication
+ eQMI_WMS_SET_PRIMARY_CLIENT, // 69 Set client as primary client
+ eQMI_WMS_SMSC_ADDR_IND, // 70 SMSC address indication
+
+ eQMI_WMS_ENUM_END
+};
+
+/*===========================================================================
+METHOD:
+ IsValid (Inline Method)
+
+DESCRIPTION:
+ eQMIMessageWMS validity check
+
+PARAMETERS:
+ msgID [ I ] - Enum value being verified
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+inline bool IsValid( eQMIMessageWMS msgID )
+{
+ bool retVal = false;
+ if ( (msgID > eQMI_WMS_ENUM_BEGIN && msgID <= eQMI_WMS_EVENT_IND)
+ || (msgID >= eQMI_WMS_RAW_SEND && msgID <= eQMI_WMS_DELETE)
+ || (msgID >= eQMI_WMS_GET_MSG_PROTOCOL && msgID < eQMI_WMS_ENUM_END) )
+ {
+ retVal = true;
+ }
+
+ return retVal;
+};
+
+/*=========================================================================*/
+// eQMIMessagePDS Enumeration
+// QMI PDS Service Type Message ID Enumeration
+/*=========================================================================*/
+enum eQMIMessagePDS
+{
+ eQMI_PDS_ENUM_BEGIN = -1,
+
+ eQMI_PDS_RESET, // 00 Reset PDS service state variables
+ eQMI_PDS_SET_EVENT, // 01 Set PDS report conditions
+ eQMI_PDS_EVENT_IND = 1, // 01 PDS report indication
+
+ eQMI_PDS_GET_STATE = 32, // 32 Return PDS service state
+ eQMI_PDS_STATE_IND = 32, // 32 PDS service state indication
+ eQMI_PDS_SET_STATE, // 33 Set PDS service state
+ eQMI_PDS_START_SESSION, // 34 Start a PDS tracking session
+ eQMI_PDS_GET_SESSION_INFO, // 35 Get PDS tracking session info
+ eQMI_PDS_FIX_POSITION, // 36 Manual tracking session position
+ eQMI_PDS_END_SESSION, // 37 End a PDS tracking session
+ eQMI_PDS_GET_NMEA_CFG, // 38 Get NMEA sentence config
+ eQMI_PDS_SET_NMEA_CFG, // 39 Set NMEA sentence config
+ eQMI_PDS_INJECT_TIME, // 40 Inject a time reference
+ eQMI_PDS_GET_DEFAULTS, // 41 Get default tracking session config
+ eQMI_PDS_SET_DEFAULTS, // 42 Set default tracking session config
+ eQMI_PDS_GET_XTRA_PARAMS, // 43 Get the GPS XTRA parameters
+ eQMI_PDS_SET_XTRA_PARAMS, // 44 Set the GPS XTRA parameters
+ eQMI_PDS_FORCE_XTRA_DL, // 45 Force a GPS XTRA database download
+ eQMI_PDS_GET_AGPS_CONFIG, // 46 Get the AGPS mode configuration
+ eQMI_PDS_SET_AGPS_CONFIG, // 47 Set the AGPS mode configuration
+
+ eQMI_PDS_GET_SVC_AUTOTRACK, // 48 Get the service auto-tracking state
+ eQMI_PDS_SET_SVC_AUTOTRACK, // 49 Set the service auto-tracking state
+ eQMI_PDS_GET_COM_AUTOTRACK, // 50 Get COM port auto-tracking config
+ eQMI_PDS_SET_COM_AUTOTRACK, // 51 Set COM port auto-tracking config
+ eQMI_PDS_RESET_DATA, // 52 Reset PDS service data
+ eQMI_PDS_SINGLE_FIX, // 53 Request single position fix
+ eQMI_PDS_GET_VERSION, // 54 Get PDS service version
+ eQMI_PDS_INJECT_XTRA, // 55 Inject XTRA data
+ eQMI_PDS_INJECT_POSITION, // 56 Inject position data
+ eQMI_PDS_INJECT_WIFI, // 57 Inject Wi-Fi obtained data
+ eQMI_PDS_GET_SBAS_CONFIG, // 58 Get SBAS config
+ eQMI_PDS_SET_SBAS_CONFIG, // 59 Set SBAS config
+ eQMI_PDS_SEND_NI_RESPONSE, // 60 Send network initiated response
+ eQMI_PDS_INJECT_ABS_TIME, // 61 Inject absolute time
+ eQMI_PDS_INJECT_EFS, // 62 Inject EFS data
+ eQMI_PDS_GET_DPO_CONFIG, // 63 Get DPO config
+ eQMI_PDS_SET_DPO_CONFIG, // 64 Set DPO config
+ eQMI_PDS_GET_ODP_CONFIG, // 65 Get ODP config
+ eQMI_PDS_SET_ODP_CONFIG, // 66 Set ODP config
+ eQMI_PDS_CANCEL_SINGLE_FIX, // 67 Cancel single position fix
+ eQMI_PDS_GET_GPS_STATE, // 68 Get GPS state
+
+ eQMI_PDS_GET_METHODS = 80, // 80 Get GPS position methods state
+ eQMI_PDS_SET_METHODS, // 81 Set GPS position methods state
+
+ eQMI_PDS_ENUM_END
+};
+
+/*===========================================================================
+METHOD:
+ IsValid (Inline Method)
+
+DESCRIPTION:
+ eQMIMessagePDS validity check
+
+PARAMETERS:
+ msgID [ I ] - Enum value being verified
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+inline bool IsValid( eQMIMessagePDS msgID )
+{
+ bool retVal = false;
+ if ( (msgID > eQMI_PDS_ENUM_BEGIN && msgID <= eQMI_PDS_EVENT_IND)
+ || (msgID >= eQMI_PDS_GET_STATE && msgID <= eQMI_PDS_GET_GPS_STATE)
+ || (msgID >= eQMI_PDS_GET_METHODS && msgID < eQMI_PDS_ENUM_END) )
+ {
+ retVal = true;
+ }
+
+ return retVal;
+};
+
+/*=========================================================================*/
+// eQMIMessageAUTH Enumeration
+// QMI Authentication Service Type Message ID Enumeration
+/*=========================================================================*/
+enum eQMIMessageAUTH
+{
+ eQMI_AUTH_ENUM_BEGIN = -1,
+
+ eQMI_AUTH_START_EAP = 32, // 32 Start the EAP session
+ eQMI_AUTH_SEND_EAP, // 33 Send and receive EAP packets
+ eQMI_AUTH_EAP_RESULT_IND, // 34 EAP session result indication
+ eQMI_AUTH_GET_EAP_KEYS, // 35 Get the EAP session keys
+ eQMI_AUTH_END_EAP, // 36 End the EAP session
+
+ eQMI_AUTH_ENUM_END
+};
+
+/*=========================================================================*/
+// eQMIMessageVoice Enumeration
+// QMI Voice Service Type Message ID Enumeration
+/*=========================================================================*/
+enum eQMIMessageVoice
+{
+ eQMI_VOICE_ENUM_BEGIN = -1,
+
+ eQMI_VOICE_INDICATION_REG = 3, // 03 Set indication registration state
+
+ eQMI_VOICE_CALL_ORIGINATE = 32, // 32 Originate a voice call
+ eQMI_VOICE_CALL_END, // 33 End a voice call
+ eQMI_VOICE_CALL_ANSWER, // 34 Answer incoming voice call
+
+ eQMI_VOICE_GET_CALL_INFO = 36, // 36 Get call information
+ eQMI_VOICE_OTASP_STATUS_IND, // 37 OTASP/OTAPA event indication
+ eQMI_VOICE_INFO_REC_IND, // 38 New info record indication
+ eQMI_VOICE_SEND_FLASH, // 39 Send a simple flash
+ eQMI_VOICE_BURST_DTMF, // 40 Send a burst DTMF
+ eQMI_VOICE_START_CONT_DTMF, // 41 Starts a continuous DTMF
+ eQMI_VOICE_STOP_CONT_DTMF, // 42 Stops a continuous DTMF
+ eQMI_VOICE_DTMF_IND, // 43 DTMF event indication
+ eQMI_VOICE_SET_PRIVACY_PREF, // 44 Set privacy preference
+ eQMI_VOICE_PRIVACY_IND, // 45 Privacy change indication
+ eQMI_VOICE_ALL_STATUS_IND, // 46 Voice all call status indication
+ eQMI_VOICE_GET_ALL_STATUS, // 47 Get voice all call status
+
+ eQMI_VOICE_MANAGE_CALLS = 49, // 49 Manage calls
+ eQMI_VOICE_SUPS_NOTIFICATION_IND, // 50 Supplementary service notifications
+ eQMI_VOICE_SET_SUPS_SERVICE, // 51 Manage supplementary service
+ eQMI_VOICE_GET_CALL_WAITING, // 52 Query sup service call waiting
+ eQMI_VOICE_GET_CALL_BARRING, // 53 Query sup service call barring
+ eQMI_VOICE_GET_CLIP, // 54 Query sup service CLIP
+ eQMI_VOICE_GET_CLIR, // 55 Query sup service CLIR
+ eQMI_VOICE_GET_CALL_FWDING, // 56 Query sup service call forwarding
+ eQMI_VOICE_SET_CALL_BARRING_PWD, // 57 Set call barring password
+ eQMI_VOICE_ORIG_USSD, // 58 Initiate USSD operation
+ eQMI_VOICE_ANSWER_USSD, // 59 Answer USSD request
+ eQMI_VOICE_CANCEL_USSD, // 60 Cancel USSD operation
+ eQMI_VOICE_USSD_RELEASE_IND, // 61 USSD release indication
+ eQMI_VOICE_USSD_IND, // 62 USSD request/notification indication
+ eQMI_VOICE_UUS_IND, // 63 UUS information indication
+ eQMI_VOICE_SET_CONFIG, // 64 Set config
+ eQMI_VOICE_GET_CONFIG, // 65 Get config
+ eQMI_VOICE_SUPS_IND, // 66 Sup service request indication
+ eQMI_VOICE_ASYNC_ORIG_USSD, // 67 Initiate USSD operation
+ eQMI_VOICE_ASYNC_USSD_IND = 67, // 67 USSD request/notification indication
+
+ eQMI_VOICE_ENUM_END
+};
+
+/*===========================================================================
+METHOD:
+ IsValid (Inline Method)
+
+DESCRIPTION:
+ eQMIMessageVoice validity check
+
+PARAMETERS:
+ msgID [ I ] - Enum value being verified
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+inline bool IsValid( eQMIMessageVoice msgID )
+{
+ bool retVal = false;
+ if ( (msgID == eQMI_VOICE_INDICATION_REG)
+ || (msgID >= eQMI_VOICE_CALL_ORIGINATE && msgID <= eQMI_VOICE_CALL_ANSWER)
+ || (msgID >= eQMI_VOICE_GET_CALL_INFO && msgID <= eQMI_VOICE_GET_ALL_STATUS)
+ || (msgID >= eQMI_VOICE_MANAGE_CALLS && msgID < eQMI_VOICE_ENUM_END) )
+ {
+ retVal = true;
+ }
+
+ return retVal;
+};
+
+/*===========================================================================
+METHOD:
+ IsValid (Inline Method)
+
+DESCRIPTION:
+ eQMIMessageAUTH validity check
+
+PARAMETERS:
+ msgID [ I ] - Enum value being verified
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+inline bool IsValid( eQMIMessageAUTH msgID )
+{
+ bool retVal = false;
+ if (msgID >= eQMI_AUTH_START_EAP && msgID < eQMI_AUTH_ENUM_END)
+ {
+ retVal = true;
+ }
+
+ return retVal;
+};
+
+/*=========================================================================*/
+// eQMIMessageCAT Enumeration
+// QMI CAT Service Type Message ID Enumeration
+/*=========================================================================*/
+enum eQMIMessageCAT
+{
+ eQMI_CAT_ENUM_BEGIN = -1,
+
+ eQMI_CAT_RESET, // 00 Reset CAT service state variables
+ eQMI_CAT_SET_EVENT, // 01 Set new message report conditions
+ eQMI_CAT_EVENT_IND = 1, // 01 New message report indication
+
+ eQMI_CAT_GET_STATE = 32, // 32 Get service state information
+ eQMI_CAT_SEND_TERMINAL, // 33 Send a terminal response
+ eQMI_CAT_SEND_ENVELOPE, // 34 Send an envelope command
+
+ eQMI_CAT_ENUM_END
+};
+
+/*===========================================================================
+METHOD:
+ IsValid (Inline Method)
+
+DESCRIPTION:
+ eQMIMessageCAT validity check
+
+PARAMETERS:
+ msgID [ I ] - Enum value being verified
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+inline bool IsValid( eQMIMessageCAT msgID )
+{
+ bool retVal = false;
+ if ( (msgID > eQMI_CAT_ENUM_BEGIN && msgID <= eQMI_CAT_EVENT_IND)
+ || (msgID >= eQMI_CAT_GET_STATE && msgID < eQMI_CAT_ENUM_END) )
+ {
+ retVal = true;
+ }
+
+ return retVal;
+};
+
+/*=========================================================================*/
+// eQMIMessageRMS Enumeration
+// QMI RMS Service Type Message ID Enumeration
+/*=========================================================================*/
+enum eQMIMessageRMS
+{
+ eQMI_RMS_ENUM_BEGIN = -1,
+
+ eQMI_RMS_RESET, // 00 Reset RMS service state variables
+
+ eQMI_RMS_GET_SMS_WAKE = 32, // 32 Get SMS wake settings
+ eQMI_RMS_SET_SMS_WAKE, // 33 Set SMS wake settings
+
+ eQMI_RMS_ENUM_END
+};
+
+/*===========================================================================
+METHOD:
+ IsValid (Inline Method)
+
+DESCRIPTION:
+ eQMIMessageRMS validity check
+
+PARAMETERS:
+ msgID [ I ] - Enum value being verified
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+inline bool IsValid( eQMIMessageRMS msgID )
+{
+ bool retVal = false;
+ if ( (msgID == eQMI_RMS_RESET)
+ || (msgID >= eQMI_RMS_GET_SMS_WAKE && msgID < eQMI_RMS_ENUM_END) )
+ {
+ retVal = true;
+ }
+
+ return retVal;
+};
+
+/*=========================================================================*/
+// eQMIMessageOMA Enumeration
+// QMI OMA-DM Service Type Message ID Enumeration
+/*=========================================================================*/
+enum eQMIMessageOMA
+{
+ eQMI_OMA_ENUM_BEGIN = -1,
+
+ eQMI_OMA_RESET, // 00 Reset OMA service state variables
+ eQMI_OMA_SET_EVENT, // 01 Set OMA report conditions
+ eQMI_OMA_EVENT_IND = 1, // 01 OMA report indication
+
+ eQMI_OMA_START_SESSION = 32, // 32 Start client inititated session
+ eQMI_OMA_CANCEL_SESSION, // 33 Cancel session
+ eQMI_OMA_GET_SESSION_INFO, // 34 Get session information
+ eQMI_OMA_SEND_SELECTION, // 35 Send selection for net inititated msg
+ eQMI_OMA_GET_FEATURES, // 36 Get feature settings
+ eQMI_OMA_SET_FEATURES, // 37 Set feature settings
+
+ eQMI_OMA_ENUM_END
+};
+
+/*===========================================================================
+METHOD:
+ IsValid (Inline Method)
+
+DESCRIPTION:
+ eQMIMessageOMA validity check
+
+PARAMETERS:
+ msgID [ I ] - Enum value being verified
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+inline bool IsValid( eQMIMessageOMA msgID )
+{
+ bool retVal = false;
+ if ( (msgID > eQMI_OMA_ENUM_BEGIN && msgID <= eQMI_OMA_EVENT_IND)
+ || (msgID >= eQMI_OMA_START_SESSION && msgID < eQMI_OMA_ENUM_END) )
+ {
+ retVal = true;
+ }
+
+ return retVal;
+};
+
+/*=========================================================================*/
+// eQMIResultCode Enumeration
+// QMI Result Code Enumeration
+/*=========================================================================*/
+enum eQMIResultCode
+{
+ eQMI_RC_ENUM_BEGIN = -1,
+
+ eQMI_RC_SUCCESS, // 00 Success
+ eQMI_RC_ERROR, // 01 Error
+
+ eQMI_RC_ENUM_END
+};
+
+/*===========================================================================
+METHOD:
+ IsValid (Inline Method)
+
+DESCRIPTION:
+ eQMIResultCode validity check
+
+PARAMETERS:
+ rc [ I ] - Enum value being verified
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+inline bool IsValid( eQMIResultCode rc )
+{
+ bool retVal = false;
+ if (rc > eQMI_RC_ENUM_BEGIN && rc < eQMI_RC_ENUM_END)
+ {
+ retVal = true;
+ }
+
+ return retVal;
+};
+
+/*=========================================================================*/
+// eQMIErrorCode Enumeration
+// QMI Error Code Enumeration
+/*=========================================================================*/
+enum eQMIErrorCode
+{
+ eQMI_ERR_ENUM_BEGIN = -1,
+
+ eQMI_ERR_NONE, // 00
+ eQMI_ERR_MALFORMED_MSG, // 01
+ eQMI_ERR_NO_MEMORY, // 02
+ eQMI_ERR_INTERNAL, // 03
+ eQMI_ERR_ABORTED, // 04
+ eQMI_ERR_CLIENT_IDS_EXHAUSTED, // 05
+ eQMI_ERR_UNABORTABLE_TRANSACTION, // 06
+ eQMI_ERR_INVALID_CLIENT_ID, // 07
+ eQMI_ERR_NO_THRESHOLDS, // 08
+ eQMI_ERR_INVALID_HANDLE, // 09
+ eQMI_ERR_INVALID_PROFILE, // 10
+ eQMI_ERR_INVALID_PIN_ID, // 11
+ eQMI_ERR_INCORRECT_PIN, // 12
+ eQMI_ERR_NO_NETWORK_FOUND, // 13
+ eQMI_ERR_CALL_FAILED, // 14
+ eQMI_ERR_OUT_OF_CALL, // 15
+ eQMI_ERR_NOT_PROVISIONED, // 16
+ eQMI_ERR_MISSING_ARG, // 17
+ eQMI_ERR_18, // 18
+ eQMI_ERR_ARG_TOO_LONG, // 19
+ eQMI_ERR_20, // 20
+ eQMI_ERR_21, // 21
+ eQMI_ERR_INVALID_TX_ID, // 22
+ eQMI_ERR_DEVICE_IN_USE, // 23
+ eQMI_ERR_OP_NETWORK_UNSUPPORTED, // 24
+ eQMI_ERR_OP_DEVICE_UNSUPPORTED, // 25
+ eQMI_ERR_NO_EFFECT, // 26
+ eQMI_ERR_NO_FREE_PROFILE, // 27
+ eQMI_ERR_INVALID_PDP_TYPE, // 28
+ eQMI_ERR_INVALID_TECH_PREF, // 29
+ eQMI_ERR_INVALID_PROFILE_TYPE, // 30
+ eQMI_ERR_INVALID_SERVICE_TYPE, // 31
+ eQMI_ERR_INVALID_REGISTER_ACTION, // 32
+ eQMI_ERR_INVALID_PS_ATTACH_ACTION, // 33
+ eQMI_ERR_AUTHENTICATION_FAILED, // 34
+ eQMI_ERR_PIN_BLOCKED, // 35
+ eQMI_ERR_PIN_ALWAYS_BLOCKED, // 36
+ eQMI_ERR_UIM_UNINITIALIZED, // 37
+ eQMI_ERR_MAX_QOS_REQUESTS_IN_USE, // 38
+ eQMI_ERR_INCORRECT_FLOW_FILTER, // 39
+ eQMI_ERR_NETWORK_QOS_UNAWARE, // 40
+ eQMI_ERR_INVALID_QOS_ID, // 41
+ eQMI_ERR_REQUESTED_NUM_UNSUPPORTED, // 42
+ eQMI_ERR_INTERFACE_NOT_FOUND, // 43
+ eQMI_ERR_FLOW_SUSPENDED, // 44
+ eQMI_ERR_INVALID_DATA_FORMAT, // 45
+ eQMI_ERR_GENERAL, // 46
+ eQMI_ERR_UNKNOWN, // 47
+ eQMI_ERR_INVALID_ARG, // 48
+ eQMI_ERR_INVALID_INDEX, // 49
+ eQMI_ERR_NO_ENTRY, // 50
+ eQMI_ERR_DEVICE_STORAGE_FULL, // 51
+ eQMI_ERR_DEVICE_NOT_READY, // 52
+ eQMI_ERR_NETWORK_NOT_READY, // 53
+ eQMI_ERR_WMS_CAUSE_CODE, // 54
+ eQMI_ERR_WMS_MESSAGE_NOT_SENT, // 55
+ eQMI_ERR_WMS_MESSAGE_DELIVERY_FAILURE, // 56
+ eQMI_ERR_WMS_INVALID_MESSAGE_ID, // 57
+ eQMI_ERR_WMS_ENCODING, // 58
+ eQMI_ERR_AUTHENTICATION_LOCK, // 59
+ eQMI_ERR_INVALID_TRANSITION, // 60
+ eQMI_ERR_61, // 61
+ eQMI_ERR_62, // 62
+ eQMI_ERR_63, // 63
+ eQMI_ERR_64, // 64
+ eQMI_ERR_SESSION_INACTIVE, // 65
+ eQMI_ERR_SESSION_INVALID, // 66
+ eQMI_ERR_SESSION_OWNERSHIP, // 67
+ eQMI_ERR_INSUFFICIENT_RESOURCES, // 68
+ eQMI_ERR_DISABLED, // 69
+ eQMI_ERR_INVALID_OPERATION, // 70
+ eQMI_ERR_INVALID_QMI_CMD, // 71
+ eQMI_ERR_WMS_TPDU_TYPE, // 72
+ eQMI_ERR_WMS_SMSC_ADDR, // 73
+ eQMI_ERR_INFO_UNAVAILABLE, // 74
+ eQMI_ERR_SEGMENT_TOO_LONG, // 75
+ eQMI_ERR_SEGMENT_ORDER, // 76
+ eQMI_ERR_BUNDLING_NOT_SUPPORTED, // 77
+ eQMI_ERR_78, // 78
+ eQMI_ERR_POLICY_MISMATCH, // 79
+ eQMI_ERR_SIM_FILE_NOT_FOUND, // 80
+ eQMI_ERR_EXTENDED_EXTERNAL, // 81
+ eQMI_ERR_ACCESS_DENIED, // 82
+ eQMI_ERR_HARDWARE_RESTRICTED, // 83
+ eQMI_ERR_ACK_NOT_SENT, // 84
+
+ eQMI_ERR_INCOMPATIBLE_STATE = 90, // 90
+ eQMI_ERR_FDN_RESTRICT, // 91
+ eQMI_ERR_SUPS_FAILURE_CAUSE, // 92
+ eQMI_ERR_NO_RADIO, // 93
+ eQMI_ERR_NOT_SUPPORTED, // 94
+
+ eQMI_ERR_CARD_CALL_CONTROL_FAILED = 96, // 96
+ eQMI_ERR_NETWORK_ABORTED, // 97
+
+ eQMI_ERR_CAT_EVT_REG_FAILED, // 61441
+ eQMI_ERR_CAT_INVALID_TR, // 61442
+ eQMI_ERR_CAT_INVALID_ENV_CMD, // 61443
+ eQMI_ERR_CAT_ENV_CMD_BUSY, // 61444
+ eQMI_ERR_CAT_ENV_CMD_FAIL, // 61445
+
+ eQMI_ERR_ENUM_END
+};
+
+/*===========================================================================
+METHOD:
+ IsValid (Inline Method)
+
+DESCRIPTION:
+ eQMIErrorCode validity check
+
+PARAMETERS:
+ ec [ I ] - Enum value being verified
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+inline bool IsValid( eQMIErrorCode ec )
+{
+ bool retVal = false;
+ if ( (ec > eQMI_ERR_ENUM_BEGIN && ec <= eQMI_ERR_ACK_NOT_SENT)
+ || (ec >= eQMI_ERR_INCOMPATIBLE_STATE && ec <= eQMI_ERR_NOT_SUPPORTED)
+ || (ec == eQMI_ERR_CARD_CALL_CONTROL_FAILED)
+ || (ec == eQMI_ERR_NETWORK_ABORTED)
+ || (ec >= eQMI_ERR_CAT_EVT_REG_FAILED && ec < eQMI_ERR_ENUM_END) )
+ {
+ retVal = true;
+ }
+
+ return retVal;
+};
+
+/*=========================================================================*/
+// eQMICallEndReason Enumeration
+// QMI Call End Reason Enumeration
+/*=========================================================================*/
+enum eQMICallEndReason
+{
+ eQMI_CALL_END_REASON_BEGIN = -1,
+
+ // General
+ eQMI_CALL_END_REASON_UNSPECIFIED = 1, // 1
+ eQMI_CALL_END_REASON_CLIENT_END, // 2
+ eQMI_CALL_END_REASON_NO_SRV, // 3
+ eQMI_CALL_END_REASON_FADE, // 4
+ eQMI_CALL_END_REASON_REL_NORMAL, // 5
+ eQMI_CALL_END_REASON_ACC_IN_PROG, // 6
+ eQMI_CALL_END_REASON_ACC_FAIL, // 7
+ eQMI_CALL_END_REASON_REDIR_OR_HANDOFF, // 8
+ eQMI_CALL_END_REASON_CLOSE_IN_PROGRESS, // 9
+ eQMI_CALL_END_REASON_AUTH_FAILED, // 10
+ eQMI_CALL_END_REASON_INTERNAL, // 11
+
+ // CDMA
+ eQMI_CALL_END_REASON_CDMA_LOCK = 500, // 500
+ eQMI_CALL_END_REASON_INTERCEPT, // 501
+ eQMI_CALL_END_REASON_REORDER, // 502
+ eQMI_CALL_END_REASON_REL_SO_REJ, // 503
+ eQMI_CALL_END_REASON_INCOM_CALL, // 504
+ eQMI_CALL_END_REASON_ALERT_STOP, // 505
+ eQMI_CALL_END_REASON_ACTIVATION, // 506
+ eQMI_CALL_END_REASON_MAX_ACCESS_PROBE, // 507
+ eQMI_CALL_END_REASON_CCS_NOT_SUPPORTED_BY_BS, // 508
+ eQMI_CALL_END_REASON_NO_RESPONSE_FROM_BS, // 509
+ eQMI_CALL_END_REASON_REJECTED_BY_BS, // 510
+ eQMI_CALL_END_REASON_INCOMPATIBLE, // 511
+ eQMI_CALL_END_REASON_ALREADY_IN_TC, // 512
+ eQMI_CALL_END_REASON_USER_CALL_ORIG_DURING_GPS, // 513
+ eQMI_CALL_END_REASON_USER_CALL_ORIG_DURING_SMS, // 514
+ eQMI_CALL_END_REASON_NO_CDMA_SRV, // 515
+
+ // GSM/WCDMA
+ eQMI_CALL_END_REASON_CONF_FAILED = 1000, // 1000
+ eQMI_CALL_END_REASON_INCOM_REJ, // 1001
+ eQMI_CALL_END_REASON_NO_GW_SRV, // 1002
+ eQMI_CALL_END_REASON_NETWORK_END, // 1003
+
+ eQMI_CALL_END_REASON_LLC_SNDCP_FAILURE, // 1004
+ eQMI_CALL_END_REASON_INSUFFICIENT_RESOURCES, // 1005
+ eQMI_CALL_END_REASON_OPTION_TEMP_OOO, // 1006
+ eQMI_CALL_END_REASON_NSAPI_ALREADY_USED, // 1007
+ eQMI_CALL_END_REASON_REGULAR_DEACTIVATION, // 1008
+ eQMI_CALL_END_REASON_NETWORK_FAILURE, // 1009
+ eQMI_CALL_END_REASON_UMTS_REATTACH_REQ, // 1010
+ eQMI_CALL_END_REASON_UMTS_PROTOCOL_ERROR, // 1011
+ eQMI_CALL_END_REASON_OPERATOR_BARRING, // 1012
+ eQMI_CALL_END_REASON_UNKNOWN_APN, // 1013
+ eQMI_CALL_END_REASON_UNKNOWN_PDP, // 1014
+ eQMI_CALL_END_REASON_GGSN_REJECT, // 1015
+ eQMI_CALL_END_REASON_ACTIVATION_REJECT, // 1016
+ eQMI_CALL_END_REASON_OPTION_NOT_SUPPORTED, // 1017
+ eQMI_CALL_END_REASON_OPTION_UNSUBSCRIBED, // 1018
+ eQMI_CALL_END_REASON_QOS_NOT_ACCEPTED, // 1019
+ eQMI_CALL_END_REASON_TFT_SEMANTIC_ERROR, // 1020
+ eQMI_CALL_END_REASON_TFT_SYNTAX_ERROR, // 1021
+ eQMI_CALL_END_REASON_UNKNOWN_PDP_CONTEXT, // 1022
+ eQMI_CALL_END_REASON_FILTER_SEMANTIC_ERROR, // 1023
+ eQMI_CALL_END_REASON_FILTER_SYNTAX_ERROR, // 1024
+ eQMI_CALL_END_REASON_PDP_WITHOUT_ACTIVE_TFT, // 1025
+ eQMI_CALL_END_REASON_INVALID_TRANSACTION_ID, // 1026
+ eQMI_CALL_END_REASON_MESSAGE_SEMANTIC_ERROR, // 1027
+ eQMI_CALL_END_REASON_INVALID_MANDATORY_INFO, // 1028
+ eQMI_CALL_END_REASON_TYPE_UNSUPPORTED, // 1029
+ eQMI_CALL_END_REASON_MSG_TYPE_WRONG_FOR_STATE, // 1030
+ eQMI_CALL_END_REASON_UNKNOWN_INFO_ELEMENT, // 1031
+ eQMI_CALL_END_REASON_CONDITIONAL_IE_ERROR, // 1032
+ eQMI_CALL_END_REASON_MSG_WRONG_FOR_PROTOCOL, // 1033
+ eQMI_CALL_END_REASON_APN_TYPE_CONFLICT, // 1034
+ eQMI_CALL_END_REASON_NO_GPRS_CONTEXT, // 1035
+ eQMI_CALL_END_REASON_FEATURE_NOT_SUPPORTED, // 1036
+
+ // CDMA 1xEV-DO (HDR)
+ eQMI_CALL_END_REASON_CD_GEN_OR_BUSY = 1500, // 1500
+ eQMI_CALL_END_REASON_CD_BILL_OR_AUTH, // 1501
+ eQMI_CALL_END_REASON_CHG_HDR, // 1502
+ eQMI_CALL_END_REASON_EXIT_HDR, // 1503
+ eQMI_CALL_END_REASON_HDR_NO_SESSION , // 1504
+ eQMI_CALL_END_REASON_HDR_ORIG_DURING_GPS_FIX, // 1505
+ eQMI_CALL_END_REASON_HDR_CS_TIMEOUT , // 1506
+ eQMI_CALL_END_REASON_HDR_RELEASED_BY_CM, // 1507
+
+ eQMI_CALL_END_REASON_END
+};
+
+/*===========================================================================
+METHOD:
+ IsValid (Inline Method)
+
+DESCRIPTION:
+ eQMICallEndReason validity check
+
+PARAMETERS:
+ err [ I ] - Enum value being verified
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+inline bool IsValid( eQMICallEndReason err )
+{
+ if ( (err >= eQMI_CALL_END_REASON_UNSPECIFIED)
+ && (err <= eQMI_CALL_END_REASON_INTERNAL) )
+ {
+ return true;
+ }
+
+ if ( (err >= eQMI_CALL_END_REASON_CDMA_LOCK)
+ && (err <= eQMI_CALL_END_REASON_NO_CDMA_SRV) )
+ {
+ return true;
+ }
+
+ if ( (err >= eQMI_CALL_END_REASON_CONF_FAILED)
+ && (err <= eQMI_CALL_END_REASON_FEATURE_NOT_SUPPORTED) )
+ {
+ return true;
+ }
+
+ if ( (err >= eQMI_CALL_END_REASON_CD_GEN_OR_BUSY)
+ && (err <= eQMI_CALL_END_REASON_HDR_RELEASED_BY_CM) )
+ {
+ return true;
+ }
+
+ return false;
+};
diff --git a/gobi-api/GobiAPI_1.0.40/Core/QMIProtocolServer.cpp b/gobi-api/GobiAPI_1.0.40/Core/QMIProtocolServer.cpp
new file mode 100755
index 0000000..9a15f21
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/QMIProtocolServer.cpp
@@ -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;
+}
diff --git a/gobi-api/GobiAPI_1.0.40/Core/QMIProtocolServer.h b/gobi-api/GobiAPI_1.0.40/Core/QMIProtocolServer.h
new file mode 100755
index 0000000..1276de9
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/QMIProtocolServer.h
@@ -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;
+};
diff --git a/gobi-api/GobiAPI_1.0.40/Core/SharedBuffer.cpp b/gobi-api/GobiAPI_1.0.40/Core/SharedBuffer.cpp
new file mode 100755
index 0000000..74334e8
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/SharedBuffer.cpp
@@ -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();
+}
diff --git a/gobi-api/GobiAPI_1.0.40/Core/SharedBuffer.h b/gobi-api/GobiAPI_1.0.40/Core/SharedBuffer.h
new file mode 100755
index 0000000..c2d4bc7
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/SharedBuffer.h
@@ -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 )
+
diff --git a/gobi-api/GobiAPI_1.0.40/Core/StdAfx.h b/gobi-api/GobiAPI_1.0.40/Core/StdAfx.h
new file mode 100755
index 0000000..8063e7b
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/StdAfx.h
@@ -0,0 +1,175 @@
+/*===========================================================================
+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 <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>
+#include <fcntl.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
+
+// Define the directions for pipes
+#define READING 0
+#define WRITING 1
diff --git a/gobi-api/GobiAPI_1.0.40/Core/SyncQueue.h b/gobi-api/GobiAPI_1.0.40/Core/SyncQueue.h
new file mode 100755
index 0000000..7c62e3f
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Core/SyncQueue.h
@@ -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;
+};
diff --git a/gobi-api/GobiAPI_1.0.40/Database/Makefile.am b/gobi-api/GobiAPI_1.0.40/Database/Makefile.am
new file mode 100644
index 0000000..720a3fb
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Database/Makefile.am
@@ -0,0 +1,2 @@
+SUBDIRS=QMI
+
diff --git a/gobi-api/GobiAPI_1.0.40/Database/QMI/Entity.txt b/gobi-api/GobiAPI_1.0.40/Database/QMI/Entity.txt
new file mode 100755
index 0000000..593b6e2
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Database/QMI/Entity.txt
@@ -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 \ No newline at end of file
diff --git a/gobi-api/GobiAPI_1.0.40/Database/QMI/Enum.txt b/gobi-api/GobiAPI_1.0.40/Database/QMI/Enum.txt
new file mode 100755
index 0000000..a772f9a
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Database/QMI/Enum.txt
@@ -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 \ No newline at end of file
diff --git a/gobi-api/GobiAPI_1.0.40/Database/QMI/EnumEntry.txt b/gobi-api/GobiAPI_1.0.40/Database/QMI/EnumEntry.txt
new file mode 100755
index 0000000..75837cc
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Database/QMI/EnumEntry.txt
@@ -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 \ No newline at end of file
diff --git a/gobi-api/GobiAPI_1.0.40/Database/QMI/Field.txt b/gobi-api/GobiAPI_1.0.40/Database/QMI/Field.txt
new file mode 100755
index 0000000..c50db38
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Database/QMI/Field.txt
@@ -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 \ No newline at end of file
diff --git a/gobi-api/GobiAPI_1.0.40/Database/QMI/Makefile.am b/gobi-api/GobiAPI_1.0.40/Database/QMI/Makefile.am
new file mode 100644
index 0000000..5c7cb31
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Database/QMI/Makefile.am
@@ -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
diff --git a/gobi-api/GobiAPI_1.0.40/Database/QMI/Struct.txt b/gobi-api/GobiAPI_1.0.40/Database/QMI/Struct.txt
new file mode 100755
index 0000000..0ab7590
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Database/QMI/Struct.txt
@@ -0,0 +1,1317 @@
+50000^0^0^50000^""^-1^0^""
+50000^1^0^50001^""^-1^0^""
+50001^0^0^50002^""^-1^0^""
+50010^0^0^50100^""^-1^0^""
+50011^0^0^50101^""^-1^0^""
+50011^1^0^50102^""^-1^0^""
+50011^2^0^50103^""^-1^0^""
+50011^3^0^50104^""^-1^0^""
+50011^4^0^50105^""^-1^0^""
+50011^5^0^50106^""^-1^0^""
+50011^6^0^50107^""^-1^0^""
+50011^7^0^50169^""^-1^0^""
+50011^8^0^50170^""^-1^0^""
+50011^9^2^40^""^-1^0^""
+50012^0^0^50108^""^-1^0^""
+50013^0^0^50109^""^-1^0^""
+50014^0^0^50110^""^-1^0^""
+50015^0^0^50111^""^-1^0^""
+50016^0^0^50112^""^-1^0^""
+50017^0^0^50113^""^-1^0^""
+50018^0^0^50114^""^-1^0^""
+50019^0^0^50115^""^-1^0^""
+50019^1^0^50116^""^-1^0^""
+50020^0^0^50117^""^-1^0^""
+50021^0^0^50118^""^-1^1^"4"
+50022^0^0^50119^""^-1^0^""
+50023^0^0^50120^""^-1^0^""
+50023^1^0^50121^""^-1^0^""
+50023^2^2^8^""^-1^0^""
+50024^0^0^50122^""^-1^0^""
+50025^0^0^50123^""^-1^0^""
+50026^0^0^50124^""^-1^0^""
+50026^1^0^50125^""^-1^0^""
+50026^2^2^8^""^-1^0^""
+50027^0^0^50126^""^-1^0^""
+50028^0^0^50127^""^-1^0^""
+50029^0^0^50128^""^-1^0^""
+50030^0^0^50128^""^-1^0^""
+50030^1^0^50129^""^-1^0^""
+50031^0^0^50115^""^-1^0^""
+50031^1^0^50116^""^-1^0^""
+50031^2^0^50130^""^-1^0^""
+50031^3^0^50131^""^-1^0^""
+50032^0^0^50102^""^-1^0^""
+50032^1^0^50103^""^-1^0^""
+50032^2^0^50104^""^-1^0^""
+50032^3^0^50105^""^-1^0^""
+50032^4^0^50106^""^-1^0^""
+50032^5^0^50107^""^-1^0^""
+50032^6^0^50169^""^-1^0^""
+50032^7^0^50170^""^-1^0^""
+50032^8^2^32^""^-1^0^""
+50033^0^0^50132^""^-1^0^""
+50034^0^0^50133^""^-1^0^""
+50035^0^0^50134^""^-1^0^""
+50036^0^0^50135^""^-1^0^""
+50036^1^0^50136^""^-1^0^""
+50036^2^0^50137^""^-1^0^""
+50036^3^0^50138^""^-1^0^""
+50036^4^0^50139^""^-1^0^""
+50036^5^0^50140^""^-1^0^""
+50036^6^0^50141^""^-1^0^""
+50036^7^0^50142^""^-1^0^""
+50036^8^0^50143^""^-1^0^""
+50036^9^0^50144^""^-1^0^""
+50036^10^0^50145^""^-1^0^""
+50036^11^0^50146^""^-1^0^""
+50037^0^0^50147^""^-1^0^""
+50037^1^0^50148^""^-1^0^""
+50037^2^0^50149^""^-1^0^""
+50037^3^0^50150^""^-1^0^""
+50037^4^0^50151^""^-1^0^""
+50038^0^0^50132^""^-1^0^""
+50038^1^0^50126^""^-1^0^""
+50039^0^0^50152^""^-1^0^""
+50039^1^1^50040^"Profile"^-1^2^"50152"
+50040^0^0^50132^""^-1^0^""
+50040^1^0^50126^""^-1^0^""
+50040^2^0^50153^""^-1^0^""
+50040^3^0^50154^""^-1^10^"50153"
+50041^0^0^50155^""^-1^0^""
+50042^0^0^50156^""^-1^0^""
+50043^0^0^50157^""^-1^0^""
+50044^0^0^50158^""^-1^0^""
+50045^0^0^50159^""^-1^0^""
+50046^0^0^50160^""^-1^0^""
+50047^0^0^50161^""^-1^0^""
+50048^0^0^50128^""^-1^0^""
+50048^1^0^50161^""^-1^0^""
+50049^0^0^50157^""^-1^0^""
+50050^0^0^50128^""^-1^0^""
+50051^0^0^50162^""^-1^0^""
+50051^1^0^50163^""^-1^0^""
+50051^2^0^50164^""^-1^0^""
+50051^3^0^50165^""^-1^0^""
+50051^4^0^50166^""^-1^0^""
+50051^5^0^50167^""^-1^0^""
+50051^6^0^50209^""^-1^0^""
+50051^7^2^32^""^-1^0^""
+50052^0^0^50168^""^-1^0^""
+50053^0^0^50101^""^-1^0^""
+50053^1^0^50169^""^14^0^""
+50053^2^0^50170^""^-1^0^""
+50053^7^2^40^""^-1^0^""
+50054^0^0^50171^""^-1^0^""
+50055^0^0^50172^""^-1^0^""
+50056^0^0^50173^""^-1^0^""
+50056^1^0^50126^""^-1^0^""
+50057^0^0^50174^""^-1^0^""
+50058^0^0^50175^""^-1^0^""
+50059^0^0^50176^""^-1^0^""
+50060^0^0^50177^""^-1^0^""
+50061^0^0^50178^""^-1^0^""
+50062^0^0^50179^""^-1^0^""
+50063^0^0^50180^""^-1^0^""
+50064^0^0^50181^""^-1^0^""
+50065^0^0^50182^""^-1^0^""
+50066^0^0^50183^""^-1^0^""
+50067^0^0^50184^""^-1^0^""
+50068^0^0^50185^""^-1^0^""
+50069^0^0^50186^""^-1^0^""
+50070^0^0^50173^""^-1^0^""
+50071^0^0^50187^""^-1^0^""
+50072^0^0^50188^""^-1^0^""
+50073^0^0^50189^""^-1^0^""
+50074^0^0^50190^""^-1^0^""
+50074^1^1^50075^"Record"^-1^2^"50190"
+50075^0^0^50191^""^-1^0^""
+50075^1^0^50192^""^-1^0^""
+50075^2^0^50193^""^-1^0^""
+50075^3^0^50194^""^-1^0^""
+50075^4^0^50118^""^-1^1^"4"
+50075^5^0^50196^""^-1^0^""
+50075^6^0^50197^""^-1^0^""
+50075^7^0^50198^""^-1^0^""
+50075^8^0^50199^""^-1^0^""
+50075^9^0^50157^""^-1^0^""
+50075^10^0^50201^""^-1^0^""
+50075^11^0^50202^""^-1^10^"50201"
+50076^0^0^50190^""^-1^0^""
+50076^1^1^50077^"Record"^-1^2^"50190"
+50077^0^0^50191^""^-1^0^""
+50078^0^0^50203^""^-1^0^""
+50079^0^0^50204^""^-1^0^""
+50080^0^0^50205^""^-1^0^""
+50081^0^0^50206^""^-1^0^""
+50082^0^0^50207^""^-1^0^""
+50083^0^0^50208^""^-1^0^""
+50084^0^0^50210^""^-1^0^""
+50084^1^0^50211^""^-1^0^""
+50084^2^0^50212^""^-1^0^""
+50084^3^0^50213^""^-1^0^""
+50084^4^0^50214^""^-1^0^""
+50084^5^0^50215^""^-1^0^""
+50084^6^0^50216^""^-1^0^""
+50084^7^0^50217^""^-1^0^""
+50084^8^0^50218^""^-1^0^""
+50084^9^0^50219^""^-1^0^""
+50084^10^0^50255^""^-1^0^""
+50084^11^0^50256^""^-1^0^""
+50084^12^0^50257^""^-1^0^""
+50084^13^0^50258^""^-1^0^""
+50084^14^0^50259^""^-1^0^""
+50084^15^0^50260^""^-1^0^""
+50084^16^0^50261^""^-1^0^""
+50084^17^0^50262^""^-1^0^""
+50084^18^2^32^""^-1^0^""
+50085^0^0^50220^""^-1^0^""
+50086^0^0^50221^""^-1^0^""
+50087^0^0^50222^""^-1^0^""
+50088^0^0^50223^""^-1^0^""
+50090^0^0^50230^""^-1^0^""
+50090^1^1^50091^""^-1^5^"50230 = 1"
+50090^2^1^50092^""^-1^5^"50230 = 2"
+50090^3^2^72^""^-1^0^""
+50091^0^0^50231^""^-1^0^""
+50091^1^0^50232^""^-1^0^""
+50091^2^0^50233^""^-1^0^""
+50091^3^2^32^""^-1^0^""
+50091^4^1^50093^""^-1^5^"50231 = 1"
+50091^5^1^50094^""^-1^5^"50233 = 1"
+50091^6^2^64^""^-1^0^""
+50092^0^0^50234^""^-1^0^""
+50092^1^0^50235^""^-1^0^""
+50092^2^0^50236^""^-1^0^""
+50092^3^0^50237^""^-1^0^""
+50092^4^0^50238^""^-1^0^""
+50092^5^0^50273^""^-1^0^""
+50092^6^2^32^""^-1^0^""
+50093^0^0^50239^""^-1^0^""
+50093^1^0^50240^""^-1^0^""
+50093^2^0^50241^""^-1^0^""
+50093^3^2^32^""^-1^0^""
+50094^0^0^50242^""^-1^0^""
+50094^1^0^50243^""^-1^0^""
+50094^2^0^50244^""^-1^0^""
+50094^3^0^50274^""^-1^0^""
+50094^4^2^32^""^-1^0^""
+50095^0^0^50245^""^-1^0^""
+50096^0^0^50246^""^-1^0^""
+50097^0^0^50247^""^-1^0^""
+50098^0^0^50248^""^-1^0^""
+50098^1^0^50249^""^-1^0^""
+50098^2^0^50250^""^16^5^"50248 = 1"
+50098^3^0^50251^""^16^5^"50248 = 2"
+50098^4^0^50252^""^16^5^"50248 = 3"
+50098^5^0^50253^""^16^5^"50248 = 6"
+50099^0^0^50254^""^-1^0^""
+50100^0^0^51000^""^-1^0^""
+50101^0^0^51001^""^-1^0^""
+50101^1^0^51002^""^-1^0^""
+50102^0^0^51003^""^-1^0^""
+50102^1^0^51004^""^-1^0^""
+50102^2^0^51005^""^-1^0^""
+50102^3^0^51006^""^-1^0^""
+50102^4^0^51007^""^8^0^""
+50103^0^0^51008^""^-1^0^""
+50103^1^0^51009^""^-1^0^""
+50103^2^0^51010^""^-1^0^""
+50103^3^0^51011^""^-1^0^""
+50103^4^0^51012^""^-1^0^""
+50103^5^0^51013^""^-1^2^"51012"
+50104^0^0^51014^""^-1^0^""
+50105^0^0^51015^""^-1^0^""
+50106^0^0^51016^""^-1^0^""
+50107^0^0^51017^""^-1^0^""
+50108^0^0^51018^""^-1^0^""
+50109^0^0^51019^""^-1^0^""
+50110^0^0^51020^""^-1^0^""
+50111^0^0^51021^""^-1^0^""
+50112^0^0^51022^""^-1^0^""
+50113^0^0^51023^""^-1^0^""
+50114^0^0^51024^""^-1^0^""
+50115^0^0^51025^""^-1^0^""
+50116^0^0^51026^""^-1^0^""
+50116^1^0^51027^""^-1^0^""
+50117^0^0^51028^""^-1^0^""
+50118^0^0^51048^""^-1^0^""
+50118^1^0^51049^""^-1^9^"51048"
+50119^0^0^51030^""^-1^0^""
+50119^1^0^51031^""^-1^0^""
+50119^2^0^51032^""^-1^0^""
+50119^3^0^51033^""^-1^9^"51032"
+50119^4^0^51034^""^-1^0^""
+50119^5^0^51035^""^-1^9^"51034"
+50120^0^0^51036^""^-1^0^""
+50120^1^0^51037^""^-1^2^"51036"
+50121^0^0^51038^""^-1^0^""
+50121^1^0^51039^""^-1^9^"51038"
+50122^0^0^51040^""^-1^0^""
+50122^1^0^51041^""^-1^9^"51040"
+50123^0^0^51042^""^-1^0^""
+50124^0^0^51042^""^-1^0^""
+50124^1^0^51043^""^-1^0^""
+50125^0^0^51044^""^-1^0^""
+50125^1^0^51045^""^-1^0^""
+50126^0^0^51046^""^-1^0^""
+50126^1^0^51047^""^-1^2^"51046"
+50127^0^0^51050^""^-1^0^""
+50127^1^0^51051^""^-1^0^""
+50127^2^0^51052^""^-1^0^""
+50127^3^0^51053^""^-1^9^"51052"
+50128^0^0^51054^""^-1^0^""
+50128^1^0^51055^""^-1^0^""
+50129^0^0^51050^""^-1^0^""
+50129^1^0^51052^""^-1^0^""
+50129^2^0^51053^""^-1^9^"51052"
+50130^0^0^51050^""^-1^0^""
+50130^1^0^51056^""^-1^0^""
+50130^2^0^51057^""^-1^9^"51056"
+50130^3^0^51060^""^-1^0^""
+50130^4^0^51061^""^-1^9^"51060"
+50131^0^0^51050^""^-1^0^""
+50131^1^0^51058^""^-1^0^""
+50131^2^0^51059^""^-1^9^"51058"
+50131^3^0^51060^""^-1^0^""
+50131^4^0^51061^""^-1^9^"51060"
+50132^0^0^51062^""^-1^0^""
+50132^1^0^51054^""^-1^0^""
+50132^2^0^51055^""^-1^0^""
+50133^0^0^51063^""^-1^0^""
+50134^0^0^51030^""^-1^0^""
+50135^0^0^51064^""^-1^0^""
+50135^1^0^51065^""^-1^0^""
+50135^2^0^51066^""^-1^0^""
+50135^3^0^51037^""^-1^2^"51065"
+50136^0^0^51067^""^-1^0^""
+50137^0^0^51068^""^-1^0^""
+50138^0^0^51069^""^-1^0^""
+50139^0^0^51070^""^-1^0^""
+50139^1^0^51071^""^-1^0^""
+50139^2^0^51072^""^-1^0^""
+50139^3^0^51082^""^-1^0^""
+50140^0^0^51073^""^-1^0^""
+50141^0^0^51074^""^-1^0^""
+50142^0^0^51075^""^-1^0^""
+50143^0^0^51076^""^-1^0^""
+50144^0^0^51077^""^-1^0^""
+50145^0^0^51078^""^-1^0^""
+50146^0^0^51079^""^-1^0^""
+50146^1^0^51054^""^-1^0^""
+50146^2^0^51055^""^-1^0^""
+50147^0^0^51078^""^-1^0^""
+50147^1^0^51079^""^-1^0^""
+50147^2^0^51080^""^-1^0^""
+50147^3^0^51081^""^-1^9^"51080"
+50148^0^0^51054^""^-1^0^""
+50149^0^0^51078^""^-1^0^""
+50149^1^0^51080^""^-1^0^""
+50149^2^0^51081^""^-1^9^"51080"
+50150^0^0^51055^""^-1^0^""
+50151^0^0^51083^""^-1^0^""
+50152^0^0^51084^""^-1^0^""
+50153^0^0^51085^""^-1^0^""
+50155^0^0^51090^""^-1^0^""
+50155^1^1^50156^"Image"^-1^2^"51090"
+50156^0^0^51091^""^-1^0^""
+50156^1^0^51092^""^-1^1^"16"
+50156^2^0^51093^""^-1^0^""
+50156^3^0^51094^""^-1^10^"51093"
+50157^0^0^51095^""^-1^0^""
+50158^0^0^51096^""^-1^0^""
+50159^0^0^51090^""^-1^0^""
+50159^1^0^51091^""^-1^2^"51090"
+50160^0^0^51097^""^-1^0^""
+50161^0^0^51098^""^-1^0^""
+50161^1^1^50162^"Type"^-1^2^"51098"
+50162^0^0^51091^""^-1^0^""
+50162^1^0^51099^""^-1^0^""
+50162^2^0^51100^""^-1^0^""
+50162^3^0^51090^""^-1^0^""
+50162^4^1^50163^"Image"^-1^2^"51090"
+50163^0^0^51096^""^-1^0^""
+50163^1^0^51101^""^-1^0^""
+50163^2^0^51092^""^-1^1^"16"
+50163^3^0^51093^""^-1^0^""
+50163^4^0^51094^""^-1^10^"51093"
+50165^0^0^51110^""^-1^0^""
+50165^1^0^51111^""^-1^0^""
+50165^2^0^51112^""^-1^0^""
+50165^3^0^51113^""^-1^0^""
+50165^4^0^51114^""^-1^0^""
+50165^5^0^51115^""^-1^0^""
+50165^6^0^51116^""^-1^0^""
+50165^7^0^51117^""^-1^0^""
+50165^8^0^51118^""^-1^0^""
+50165^9^0^51119^""^-1^0^""
+50165^10^0^51120^""^-1^0^""
+50165^11^0^51121^""^-1^0^""
+50165^12^0^51122^""^-1^0^""
+50165^13^0^51123^""^-1^0^""
+50165^14^0^51124^""^-1^0^""
+50165^15^0^51125^""^-1^0^""
+50165^16^0^51126^""^-1^0^""
+50165^17^0^51127^""^-1^0^""
+50165^18^0^51128^""^-1^0^""
+50165^19^0^51129^""^-1^0^""
+50165^20^0^51130^""^-1^0^""
+50165^21^0^51131^""^-1^0^""
+50165^22^0^51132^""^-1^0^""
+50165^23^0^51133^""^-1^0^""
+50165^24^0^51134^""^-1^0^""
+50165^25^0^51135^""^-1^0^""
+50165^26^0^51136^""^-1^0^""
+50165^27^0^51137^""^-1^0^""
+50165^28^0^51138^""^-1^0^""
+50165^29^0^51139^""^-1^0^""
+50165^30^0^51140^""^31^0^""
+50165^31^0^51141^""^48^0^""
+50165^32^0^51142^""^-1^0^""
+50165^33^0^51143^""^-1^0^""
+50165^34^0^51144^""^56^0^""
+50165^35^0^51145^""^-1^0^""
+50165^36^0^51146^""^-1^0^""
+50165^37^0^51147^""^-1^0^""
+50165^38^2^64^""^-1^0^""
+50166^0^0^51148^""^-1^0^""
+50167^0^0^51149^""^-1^0^""
+50168^0^0^51150^""^-1^0^""
+50169^0^0^51151^""^-1^0^""
+50170^0^0^51152^""^-1^0^""
+50171^0^0^51153^""^-1^0^""
+50172^0^0^51154^""^-1^0^""
+50172^1^0^51155^""^-1^0^""
+50173^0^0^51156^""^-1^0^""
+50173^1^0^51157^""^-1^0^""
+50174^0^0^51158^""^-1^0^""
+50175^0^0^51159^""^-1^0^""
+50200^0^0^52000^""^-1^0^""
+50200^1^0^52001^""^-1^0^""
+50200^2^0^52002^""^-1^2^"52001"
+50201^0^0^52003^""^-1^0^""
+50201^1^0^52004^""^-1^0^""
+50202^0^0^52005^""^-1^0^""
+50202^1^1^50203^"Network Info"^-1^2^"52005"
+50203^0^0^52006^""^-1^0^""
+50203^1^0^52007^""^-1^0^""
+50203^2^0^52008^""^-1^0^""
+50203^3^0^52009^""^-1^0^""
+50203^4^0^52010^""^-1^0^""
+50203^5^0^52011^""^-1^0^""
+50203^6^0^52012^""^-1^0^""
+50203^7^0^52013^""^-1^10^"52012"
+50204^0^0^52014^""^-1^0^""
+50205^0^0^52006^""^-1^0^""
+50205^1^0^52007^""^-1^0^""
+50205^2^0^52015^""^-1^0^""
+50206^0^0^52016^""^-1^0^""
+50207^0^0^52017^""^-1^0^""
+50207^1^0^52018^""^-1^0^""
+50207^2^0^52019^""^-1^0^""
+50207^3^0^52020^""^-1^0^""
+50207^4^0^52021^""^-1^0^""
+50207^5^0^52004^""^-1^2^"52021"
+50208^0^0^52022^""^-1^0^""
+50209^0^0^52006^""^-1^0^""
+50209^1^0^52007^""^-1^0^""
+50209^2^0^52012^""^-1^0^""
+50209^3^0^52013^""^-1^10^"52012"
+50210^0^0^52023^""^-1^0^""
+50210^1^1^50211^"Network"^-1^2^"52023"
+50211^0^0^52006^""^-1^0^""
+50211^1^0^52007^""^-1^0^""
+50211^2^1^50212^""^-1^0^""
+50212^0^0^52024^""^6^0^""
+50212^1^0^52025^""^-1^0^""
+50212^2^0^52026^""^15^0^""
+50213^0^0^52027^""^-1^0^""
+50213^1^1^50214^"Network"^-1^2^"52027"
+50214^0^0^52006^""^-1^0^""
+50214^1^0^52007^""^-1^0^""
+50215^0^0^52028^""^-1^0^""
+50215^1^0^52029^""^-1^0^""
+50216^0^1^50217^""^-1^0^""
+50216^1^0^52032^""^-1^0^""
+50217^0^0^52035^""^-1^0^""
+50217^1^1^50221^""^-1^5^"52035 = 1"
+50217^2^1^50222^""^-1^5^"52035 = 2"
+50217^3^2^16^""^-1^0^""
+50218^0^0^52033^""^-1^0^""
+50219^0^0^52034^""^-1^0^""
+50219^1^0^52033^""^-1^0^""
+50220^0^0^52005^""^-1^0^""
+50220^1^1^50201^"Info"^-1^2^"52005"
+50221^0^0^52036^""^-1^0^""
+50221^1^0^52037^""^-1^0^""
+50221^2^0^52038^""^-1^0^""
+50222^0^0^52039^""^-1^0^""
+50222^1^0^52040^""^-1^0^""
+50223^0^0^52041^""^-1^0^""
+50223^1^0^52042^""^-1^2^"52041"
+50224^0^0^52043^""^-1^0^""
+50225^0^0^52044^""^-1^0^""
+50226^0^0^52045^""^-1^0^""
+50227^0^0^52046^""^-1^0^""
+50227^1^0^52047^""^-1^0^""
+50227^2^0^52048^""^-1^0^""
+50228^0^0^52049^""^-1^0^""
+50229^0^0^52050^""^-1^0^""
+50229^1^0^52051^""^-1^0^""
+50229^2^0^52052^""^-1^0^""
+50229^3^0^52053^""^-1^0^""
+50229^4^0^52054^""^-1^0^""
+50229^5^0^52055^""^-1^0^""
+50229^6^0^52056^""^-1^0^""
+50229^7^0^52057^""^-1^0^""
+50229^8^0^52058^""^-1^0^""
+50229^9^0^52059^""^40^0^""
+50229^10^0^52060^""^72^0^""
+50229^11^0^52061^""^-1^0^""
+50229^12^2^104^""^-1^0^""
+50230^0^0^52034^""^-1^0^""
+50231^0^0^52062^""^-1^0^""
+50232^0^0^52004^""^-1^0^""
+50232^1^0^52063^""^-1^0^""
+50232^2^0^52064^""^-1^0^""
+50233^0^0^52065^""^-1^0^""
+50234^0^0^52066^""^-1^0^""
+50235^0^0^52067^""^-1^0^""
+50235^1^1^50232^"Instance"^-1^2^"52067"
+50236^0^0^52068^""^-1^0^""
+50236^1^0^52069^""^-1^0^""
+50237^0^0^52070^""^-1^0^""
+50240^0^0^52080^""^-1^0^""
+50240^1^0^52081^""^-1^0^""
+50241^0^0^52082^""^-1^0^""
+50241^1^0^52083^""^-1^0^""
+50242^0^0^52084^""^-1^0^""
+50242^1^0^52085^""^-1^0^""
+50243^0^0^52086^""^-1^0^""
+50243^1^0^52087^""^-1^0^""
+50244^0^0^52088^""^-1^0^""
+50245^0^0^52089^""^-1^0^""
+50245^1^0^52004^""^-1^0^""
+50246^0^0^52090^""^-1^0^""
+50246^1^0^52004^""^-1^0^""
+50247^0^0^52091^""^-1^0^""
+50248^0^0^52092^""^-1^0^""
+50249^0^0^52093^""^-1^0^""
+50249^1^0^52004^""^-1^0^""
+50250^0^0^52094^""^-1^0^""
+50251^0^0^52095^""^-1^0^""
+50252^0^0^52096^""^-1^0^""
+50253^0^0^52157^""^-1^0^""
+50253^1^0^52158^""^-1^0^""
+50253^2^0^52159^""^-1^0^""
+50253^3^0^52160^""^-1^0^""
+50253^4^0^52161^""^-1^0^""
+50253^5^2^16^""^-1^0^""
+50254^0^0^52097^""^-1^0^""
+50254^1^1^50245^"Measurement"^-1^2^"52097"
+50255^0^0^52097^""^-1^0^""
+50255^1^1^50246^"Measurement"^-1^2^"52097"
+50256^0^0^52097^""^-1^0^""
+50256^1^1^50249^"Measurement"^-1^2^"52097"
+50257^0^0^52098^""^-1^0^""
+50257^1^0^52099^""^-1^0^""
+50257^2^0^52100^""^-1^0^""
+50258^0^0^52067^""^-1^0^""
+50258^1^1^50259^"Instance"^-1^2^"52067"
+50259^0^0^52004^""^-1^0^""
+50259^1^0^52022^""^-1^0^""
+50260^0^0^52022^""^-1^0^""
+50261^0^0^52101^""^-1^0^""
+50261^1^0^52102^""^-1^0^""
+50261^2^0^52103^""^-1^0^""
+50262^0^0^52104^""^-1^0^""
+50263^0^0^52105^""^-1^0^""
+50264^0^0^52106^""^-1^0^""
+50264^1^0^52107^""^-1^0^""
+50264^2^0^52108^""^-1^0^""
+50264^3^0^52109^""^-1^0^""
+50264^4^2^16^""^-1^0^""
+50265^0^0^52110^""^-1^0^""
+50265^1^0^52111^""^-1^0^""
+50265^2^0^52112^""^-1^0^""
+50265^3^0^52113^""^-1^0^""
+50265^4^0^52114^""^-1^0^""
+50265^5^0^52115^""^-1^0^""
+50265^6^0^52116^""^-1^0^""
+50265^7^0^52117^""^-1^0^""
+50265^8^0^52118^""^-1^0^""
+50265^9^0^52119^""^-1^0^""
+50265^10^0^52120^""^-1^0^""
+50265^11^0^52121^""^-1^0^""
+50265^12^0^52122^""^-1^0^""
+50265^13^0^52123^""^-1^0^""
+50265^14^0^52124^""^-1^0^""
+50265^15^0^52125^""^-1^0^""
+50265^16^0^52126^""^-1^0^""
+50265^17^0^52127^""^-1^0^""
+50265^18^0^52128^""^-1^0^""
+50265^19^0^52129^""^-1^0^""
+50265^20^0^52130^""^-1^0^""
+50265^21^0^52131^""^-1^0^""
+50265^22^0^52132^""^-1^0^""
+50265^23^0^52133^""^-1^0^""
+50265^24^0^52134^""^-1^0^""
+50265^25^0^52135^""^-1^0^""
+50265^26^0^52136^""^-1^0^""
+50265^27^0^52137^""^-1^0^""
+50265^28^0^52138^""^-1^0^""
+50265^29^0^52139^""^-1^0^""
+50265^30^0^52140^""^31^0^""
+50265^31^0^52141^""^48^0^""
+50265^32^0^52142^""^-1^0^""
+50265^33^0^52143^""^-1^0^""
+50265^34^0^52144^""^56^0^""
+50265^35^0^52145^""^-1^0^""
+50265^36^0^52146^""^-1^0^""
+50265^37^0^52147^""^-1^0^""
+50265^38^2^64^""^-1^0^""
+50266^0^0^52148^""^-1^0^""
+50267^0^0^52149^""^-1^0^""
+50268^0^0^52150^""^-1^0^""
+50268^1^0^52151^""^-1^0^""
+50268^2^0^52152^""^-1^0^""
+50268^3^0^52153^""^-1^0^""
+50268^4^0^52154^""^-1^0^""
+50268^6^0^52155^""^24^0^""
+50268^7^0^52067^""^-1^0^""
+50268^8^0^52156^""^-1^2^"52067"
+50269^0^0^52006^""^-1^0^""
+50269^1^0^52007^""^-1^0^""
+50269^2^0^52162^""^-1^0^""
+50269^3^0^52163^""^-1^0^""
+50269^4^0^52164^""^-1^0^""
+50269^5^0^52165^""^-1^2^"52164"
+50270^0^0^52005^""^-1^0^""
+50270^1^1^50271^"Info"^-1^2^"52005"
+50271^0^0^52006^""^-1^0^""
+50271^1^0^52007^""^-1^0^""
+50271^2^0^52015^""^-1^0^""
+50272^0^0^52166^""^-1^0^""
+50273^0^0^52167^""^-1^0^""
+50274^0^0^52168^""^-1^0^""
+50274^1^0^52169^""^-1^0^""
+50274^2^0^52170^""^-1^2^"52169"
+50274^3^0^52171^""^-1^0^""
+50274^4^0^52172^""^-1^0^""
+50274^5^0^52173^""^-1^0^""
+50274^6^0^52174^""^-1^0^""
+50274^7^0^52175^""^-1^2^"52174"
+50274^8^0^52176^""^-1^0^""
+50274^9^0^52177^""^-1^0^""
+50274^10^0^52178^""^-1^0^""
+50274^11^0^52179^""^-1^0^""
+50274^12^0^52180^""^-1^2^"52179"
+50275^0^0^52181^""^-1^0^""
+50275^1^0^52004^""^-1^0^""
+50276^0^0^52182^""^-1^0^""
+50277^0^0^52183^""^-1^0^""
+50277^1^0^52184^""^-1^0^""
+50300^0^0^53000^""^-1^0^""
+50301^0^0^53001^""^-1^0^""
+50301^1^0^53002^""^-1^0^""
+50302^0^0^53003^""^-1^0^""
+50302^1^0^53004^""^-1^0^""
+50302^2^0^53005^""^-1^2^"53004"
+50303^0^0^53006^""^-1^0^""
+50304^0^0^53001^""^-1^0^""
+50304^1^0^53003^""^-1^0^""
+50304^2^0^53004^""^-1^0^""
+50304^3^0^53005^""^-1^2^"53004"
+50305^0^0^53002^""^-1^0^""
+50306^0^0^53007^""^-1^0^""
+50306^1^0^53003^""^-1^0^""
+50306^2^0^53004^""^-1^0^""
+50306^3^0^53005^""^-1^2^"53004"
+50307^0^0^53001^""^-1^0^""
+50307^1^0^53002^""^-1^0^""
+50307^2^0^53007^""^-1^0^""
+50308^0^0^53001^""^-1^0^""
+50309^0^0^53007^""^-1^0^""
+50310^0^0^53008^""^-1^0^""
+50311^0^0^53009^""^-1^0^""
+50311^1^1^50312^"Message"^-1^2^"53009"
+50312^0^0^53002^""^-1^0^""
+50312^1^0^53007^""^-1^0^""
+50313^0^0^53010^""^-1^0^""
+50313^1^1^50314^"Route"^-1^2^"53010"
+50314^0^0^53011^""^-1^0^""
+50314^1^0^53012^""^-1^0^""
+50314^2^0^53001^""^-1^0^""
+50314^3^0^53013^""^-1^0^""
+50315^0^0^53010^""^-1^0^""
+50315^1^1^50316^"Route"^-1^2^"53010"
+50316^0^0^53011^""^-1^0^""
+50316^1^0^53012^""^-1^0^""
+50316^2^0^53001^""^-1^0^""
+50316^3^0^53014^""^-1^0^""
+50317^0^0^53015^""^-1^0^""
+50317^1^0^53016^""^-1^0^""
+50317^2^0^53017^""^-1^9^"53016"
+50318^0^0^53018^""^-1^0^""
+50319^0^0^53019^""^-1^0^""
+50320^0^0^53020^""^-1^0^""
+50320^1^0^53021^""^-1^0^""
+50320^2^0^53003^""^-1^0^""
+50320^3^0^53004^""^-1^0^""
+50320^4^0^53005^""^-1^2^"53004"
+50321^0^0^53022^""^-1^0^""
+50321^1^0^53023^""^-1^0^""
+50322^0^0^53024^""^-1^0^""
+50323^0^0^53025^""^-1^0^""
+50324^0^0^53026^""^-1^0^""
+50325^0^0^53027^""^-1^0^""
+50325^1^0^53028^""^-1^0^""
+50326^0^0^53029^""^-1^0^""
+50327^0^0^53030^""^-1^0^""
+50328^0^0^53031^""^-1^0^""
+50329^0^0^53021^""^-1^0^""
+50329^1^0^53008^""^-1^0^""
+50329^2^0^53032^""^-1^0^""
+50330^0^0^53033^""^-1^0^""
+50330^1^0^53034^""^-1^0^""
+50331^0^0^53035^""^-1^0^""
+50331^1^0^53028^""^-1^0^""
+50332^0^0^53036^""^-1^0^""
+50333^0^0^53037^""^-1^0^""
+50334^0^0^53038^""^-1^0^""
+50335^0^0^53039^""^-1^0^""
+50336^0^0^53008^""^-1^0^""
+50336^1^0^53040^""^-1^0^""
+50337^0^0^53041^""^-1^0^""
+50337^1^1^50338^"Instance"^-1^2^"53041"
+50338^0^0^53042^""^-1^0^""
+50338^1^0^53043^""^-1^0^""
+50338^2^0^53044^""^-1^0^""
+50339^0^0^53041^""^-1^0^""
+50339^1^1^50340^"Instance"^-1^2^"53041"
+50340^0^0^53045^""^-1^0^""
+50340^1^0^53046^""^-1^0^""
+50340^2^0^53044^""^-1^0^""
+50341^0^0^53047^""^-1^0^""
+50341^1^0^53041^""^-1^0^""
+50341^2^1^50338^"Instance"^-1^2^"53041"
+50342^0^0^53047^""^-1^0^""
+50342^1^0^53041^""^-1^0^""
+50342^2^1^50340^"Instance"^-1^2^"53041"
+50343^0^0^53001^""^-1^0^""
+50343^1^0^53008^""^-1^0^""
+50344^0^0^53048^""^-1^0^""
+50345^0^0^53001^""^-1^0^""
+50345^1^0^53002^""^-1^0^""
+50345^2^0^53008^""^-1^0^""
+50346^0^0^53049^""^-1^0^""
+50400^0^0^54000^""^-1^0^""
+50401^0^0^54001^""^-1^0^""
+50402^0^0^54002^""^-1^0^""
+50402^1^0^54003^""^-1^0^""
+50403^0^0^54002^""^-1^0^""
+50404^0^0^54004^""^-1^0^""
+50404^1^0^54005^""^-1^0^""
+50404^2^0^54006^""^-1^0^""
+50404^3^0^54007^""^-1^0^""
+50404^4^0^54008^""^-1^0^""
+50404^5^0^54009^""^-1^0^""
+50404^6^0^54010^""^-1^0^""
+50404^7^0^54011^""^-1^0^""
+50405^0^0^54012^""^-1^0^""
+50405^1^0^54013^""^-1^0^""
+50405^2^0^54014^""^-1^0^""
+50405^3^0^54015^""^-1^0^""
+50405^4^0^54016^""^-1^0^""
+50405^5^0^54017^""^8^0^""
+50405^6^0^54018^""^-1^0^""
+50406^0^0^54019^""^-1^0^""
+50406^1^0^54020^""^-1^0^""
+50407^0^0^54006^""^-1^0^""
+50407^1^0^54008^""^-1^0^""
+50407^2^0^54010^""^-1^0^""
+50407^3^0^54011^""^-1^0^""
+50408^0^0^54021^""^-1^0^""
+50408^1^0^54022^""^-1^0^""
+50409^0^0^54023^""^-1^0^""
+50409^1^0^54024^""^-1^2^"54023"
+50410^0^0^54025^""^-1^0^""
+50411^0^0^54026^""^-1^0^""
+50411^1^0^54027^""^-1^0^""
+50411^2^0^54028^""^-1^0^""
+50412^0^0^54029^""^-1^1^"4"
+50412^1^0^54030^""^-1^0^""
+50413^0^0^54031^""^-1^0^""
+50414^0^0^54032^""^-1^0^""
+50414^1^0^54033^""^-1^0^""
+50414^2^0^54034^""^-1^0^""
+50414^3^0^54035^""^-1^0^""
+50414^4^0^54036^""^-1^0^""
+50414^5^0^54037^""^-1^0^""
+50414^6^0^54038^""^-1^0^""
+50414^7^0^54039^""^-1^0^""
+50414^8^0^54040^""^-1^0^""
+50414^9^0^54041^""^-1^0^""
+50414^10^0^54042^""^-1^0^""
+50414^11^0^54043^""^-1^0^""
+50414^12^0^54044^""^-1^0^""
+50414^13^2^32^""^-1^0^""
+50415^0^0^54045^""^-1^0^""
+50415^1^0^54046^""^-1^0^""
+50415^2^0^54047^""^-1^0^""
+50415^3^0^54048^""^-1^0^""
+50415^4^0^54049^""^-1^0^""
+50415^5^0^54050^""^-1^0^""
+50415^6^0^54051^""^-1^0^""
+50415^7^0^54052^""^-1^0^""
+50415^8^0^54053^""^-1^0^""
+50415^9^0^54054^""^-1^0^""
+50415^10^2^32^""^-1^0^""
+50416^0^0^54055^""^-1^0^""
+50417^0^0^54056^""^-1^0^""
+50417^1^0^54057^""^-1^0^""
+50417^2^0^54058^""^-1^10^"54057"
+50420^0^0^54100^""^-1^0^""
+50421^0^0^54101^""^-1^0^""
+50422^0^0^54102^""^-1^0^""
+50423^0^0^54103^""^-1^0^""
+50424^0^0^54104^""^-1^0^""
+50425^0^0^54105^""^-1^0^""
+50426^0^0^54106^""^-1^0^""
+50427^0^0^54107^""^-1^0^""
+50428^0^0^54108^""^-1^0^""
+50429^0^0^54109^""^-1^0^""
+50430^0^0^54110^""^-1^0^""
+50430^1^0^54111^""^-1^0^""
+50430^2^0^54112^""^-1^0^""
+50430^3^0^54113^""^-1^0^""
+50430^4^0^54114^""^-1^0^""
+50430^5^0^54115^""^-1^0^""
+50430^6^0^54116^""^-1^0^""
+50430^7^0^54117^""^-1^0^""
+50430^8^0^54118^""^-1^0^""
+50430^9^0^54119^""^-1^0^""
+50430^10^0^54120^""^-1^0^""
+50430^11^0^54121^""^-1^0^""
+50430^12^0^54122^""^-1^0^""
+50430^13^0^54123^""^-1^0^""
+50430^14^0^54124^""^-1^0^""
+50430^15^0^54125^""^-1^0^""
+50430^16^0^54126^""^-1^0^""
+50430^17^0^54127^""^-1^0^""
+50430^18^0^54128^""^-1^0^""
+50430^19^0^54129^""^-1^0^""
+50430^20^0^54130^""^-1^0^""
+50430^21^0^54131^""^-1^0^""
+50430^22^0^54132^""^-1^0^""
+50430^23^0^54132^""^-1^0^""
+50430^24^2^32^""^-1^0^""
+50430^25^0^54133^""^-1^0^""
+50430^26^0^54134^""^-1^0^""
+50430^27^0^54135^""^-1^0^""
+50430^28^0^54136^""^-1^0^""
+50430^29^0^54137^""^-1^0^""
+50430^30^0^54138^""^-1^0^""
+50430^31^0^54139^""^-1^0^""
+50430^32^0^54140^""^-1^0^""
+50430^33^0^54141^""^-1^0^""
+50430^34^0^54142^""^-1^0^""
+50430^35^0^54143^""^-1^0^""
+50430^36^0^54144^""^-1^0^""
+50430^37^0^54145^""^-1^0^""
+50430^38^0^54146^""^-1^0^""
+50430^39^0^54147^""^-1^0^""
+50430^40^0^54148^""^-1^0^""
+50430^41^0^54149^""^-1^0^""
+50430^42^0^54150^""^-1^0^""
+50430^43^0^54151^""^-1^0^""
+50430^44^0^54152^""^-1^0^""
+50430^45^0^54153^""^-1^0^""
+50430^46^0^54154^""^-1^0^""
+50430^47^0^54155^""^-1^0^""
+50430^48^0^54156^""^-1^0^""
+50430^49^0^54157^""^-1^0^""
+50430^50^0^54158^""^-1^0^""
+50430^51^0^54159^""^-1^0^""
+50430^52^0^54160^""^-1^0^""
+50430^53^0^54161^""^-1^0^""
+50430^54^0^54162^""^-1^0^""
+50431^0^0^54163^""^-1^0^""
+50431^1^0^54164^""^-1^0^""
+50431^2^1^50432^"URL"^-1^2^"54164"
+50432^0^0^54165^""^-1^0^""
+50432^1^0^54166^""^-1^10^"54165"
+50433^0^0^54167^""^-1^0^""
+50433^1^0^54164^""^-1^0^""
+50433^2^1^50432^"URL"^-1^2^"54164"
+50434^0^0^54168^""^-1^0^""
+50434^1^0^54169^""^-1^0^""
+50435^0^0^54170^""^-1^0^""
+50435^1^0^54171^""^-1^0^""
+50435^2^0^54172^""^-1^0^""
+50435^3^2^32^""^-1^0^""
+50435^4^0^54173^""^-1^0^""
+50435^5^0^54174^""^-1^0^""
+50435^6^1^50436^"SV"^-1^2^"54174"
+50436^0^0^54175^""^-1^0^""
+50436^1^0^54176^""^-1^0^""
+50436^2^0^54177^""^-1^0^""
+50436^3^0^54178^""^-1^0^""
+50436^4^0^54179^""^-1^0^""
+50436^5^0^54180^""^-1^0^""
+50436^6^0^54181^""^-1^0^""
+50436^7^0^54182^""^-1^0^""
+50436^8^0^54183^""^-1^0^""
+50436^9^2^32^""^-1^0^""
+50436^10^0^54184^""^-1^0^""
+50436^11^0^54185^""^-1^0^""
+50436^12^0^54186^""^-1^0^""
+50436^13^0^54187^""^-1^0^""
+50436^14^0^54188^""^-1^0^""
+50436^15^0^54189^""^-1^0^""
+50436^16^0^54347^""^-1^0^""
+50436^17^0^54190^""^-1^0^""
+50436^18^0^54191^""^-1^0^""
+50437^0^0^54192^""^-1^0^""
+50437^1^0^54193^""^-1^0^""
+50437^2^0^54194^""^-1^0^""
+50437^3^0^54195^""^-1^0^""
+50437^4^0^54196^""^-1^0^""
+50437^5^0^54197^""^-1^0^""
+50437^6^2^32^""^-1^0^""
+50437^7^0^54198^""^-1^0^""
+50437^8^0^54199^""^-1^0^""
+50437^9^0^54200^""^-1^0^""
+50437^10^0^54201^""^-1^0^""
+50437^11^0^54202^""^-1^0^""
+50437^12^0^54203^""^-1^0^""
+50437^13^0^54204^""^-1^0^""
+50437^14^0^54205^""^-1^2^"54204"
+50438^0^0^54206^""^-1^0^""
+50438^1^0^54207^""^-1^0^""
+50438^2^0^54208^""^-1^0^""
+50438^3^0^54209^""^-1^0^""
+50438^4^0^54210^""^-1^0^""
+50438^5^0^54211^""^-1^0^""
+50438^6^0^54212^""^-1^0^""
+50438^7^0^54213^""^-1^0^""
+50438^8^0^54214^""^-1^0^""
+50438^9^0^54215^""^-1^0^""
+50438^10^0^54216^""^-1^0^""
+50438^11^0^54217^""^-1^0^""
+50438^12^0^54218^""^-1^0^""
+50438^13^0^54219^""^-1^0^""
+50438^14^2^32^""^-1^0^""
+50438^15^0^54220^""^-1^0^""
+50438^16^0^54221^""^-1^0^""
+50438^17^0^54222^""^-1^0^""
+50438^18^0^54223^""^-1^0^""
+50438^19^0^54224^""^-1^0^""
+50438^20^0^54225^""^-1^1^"4"
+50438^21^0^54348^""^-1^0^""
+50438^22^0^54226^""^-1^1^"16"
+50438^23^0^54227^""^-1^0^""
+50438^24^0^54228^""^-1^10^"54227"
+50438^25^0^54229^""^-1^0^""
+50438^26^0^54230^""^-1^0^""
+50438^27^0^54231^""^-1^0^""
+50438^28^0^54232^""^-1^2^"54231"
+50438^29^0^54233^""^-1^0^""
+50438^30^0^54234^""^-1^0^""
+50438^31^0^54235^""^-1^2^"54234"
+50438^32^0^54236^""^-1^0^""
+50438^33^0^54237^""^-1^0^""
+50438^34^0^54238^""^-1^0^""
+50438^35^0^54239^""^-1^0^""
+50439^0^0^54250^""^-1^0^""
+50439^1^0^54251^""^-1^0^""
+50439^2^0^54252^""^-1^0^""
+50439^3^0^54253^""^-1^0^""
+50439^4^0^54254^""^-1^0^""
+50439^5^0^54255^""^-1^0^""
+50439^6^0^54256^""^-1^0^""
+50439^7^0^54257^""^-1^0^""
+50439^8^2^32^""^-1^0^""
+50439^9^0^54258^""^-1^0^""
+50439^10^0^54259^""^-1^0^""
+50439^11^0^54260^""^-1^0^""
+50439^12^0^54261^""^-1^0^""
+50439^13^0^54262^""^-1^2^"54261"
+50439^14^0^54263^""^-1^0^""
+50439^15^0^54264^""^-1^10^"54263"
+50439^16^0^54265^""^-1^0^""
+50439^17^0^54266^""^-1^0^""
+50439^18^0^54267^""^-1^0^""
+50439^19^0^54268^""^-1^2^"54267"
+50439^20^0^54269^""^-1^0^""
+50439^21^0^54270^""^-1^0^""
+50439^22^0^54271^""^-1^2^"54270"
+50439^23^0^54272^""^-1^0^""
+50440^0^0^54273^""^-1^0^""
+50440^1^0^54274^""^-1^0^""
+50441^0^0^54275^""^-1^0^""
+50441^1^0^54276^""^-1^0^""
+50442^0^0^54006^""^-1^0^""
+50443^0^0^54008^""^-1^0^""
+50444^0^0^54011^""^-1^0^""
+50445^0^0^54277^""^-1^0^""
+50445^1^0^54278^""^-1^0^""
+50446^0^0^54279^""^-1^0^""
+50446^1^0^54280^""^-1^0^""
+50446^2^0^54281^""^-1^0^""
+50446^3^0^54282^""^-1^2^"54281"
+50447^0^0^54142^""^-1^0^""
+50448^0^0^54144^""^-1^0^""
+50449^0^0^54145^""^-1^0^""
+50450^0^0^54146^""^-1^0^""
+50451^0^0^54147^""^-1^0^""
+50452^0^0^54151^""^-1^0^""
+50453^0^0^54155^""^-1^0^""
+50454^0^0^54158^""^-1^0^""
+50455^0^0^54283^""^-1^0^""
+50456^0^0^54284^""^-1^0^""
+50457^0^0^54285^""^-1^0^""
+50458^0^0^54286^""^-1^0^""
+50458^1^0^54287^""^-1^0^""
+50458^2^0^54288^""^-1^0^""
+50458^3^0^54289^""^-1^0^""
+50458^4^0^54290^""^-1^0^""
+50459^0^0^54289^""^-1^0^""
+50459^1^1^50460^"AP"^-1^2^"54289"
+50460^0^0^54291^""^-1^1^"6"
+50460^1^0^54292^""^-1^0^""
+50460^2^0^54293^""^-1^0^""
+50460^3^0^54350^""^-1^0^""
+50460^4^0^54351^""^-1^0^""
+50460^5^0^54352^""^-1^0^""
+50460^6^0^54353^""^-1^0^""
+50460^7^2^8^""^-1^0^""
+50461^0^0^54294^""^-1^0^""
+50462^0^0^54295^""^-1^0^""
+50463^0^0^54296^""^-1^0^""
+50464^0^0^54297^""^-1^0^""
+50464^1^0^54298^""^-1^0^""
+50464^2^0^54299^""^-1^0^""
+50464^3^0^54300^""^-1^0^""
+50465^0^0^54301^""^-1^0^""
+50465^1^0^54302^""^-1^10^"54301"
+50465^2^0^54303^""^-1^0^""
+50465^3^0^54304^""^-1^0^""
+50465^4^0^54305^""^-1^0^""
+50465^5^0^54306^""^-1^0^""
+50465^6^0^54306^""^-1^2^"54304"
+50466^0^0^54308^""^-1^0^""
+50467^0^0^54309^""^-1^0^""
+50468^0^0^54310^""^-1^0^""
+50469^0^0^54354^""^-1^0^""
+50469^1^0^54311^""^-1^0^""
+50469^2^0^54312^""^-1^0^""
+50469^3^0^54313^""^-1^0^""
+50469^4^0^54314^""^-1^0^""
+50469^5^0^54315^""^-1^0^""
+50469^6^0^54316^""^-1^0^""
+50469^7^0^54317^""^-1^0^""
+50469^8^0^54318^""^-1^0^""
+50469^9^0^54319^""^-1^0^""
+50469^10^0^54320^""^-1^0^""
+50469^11^0^54321^""^-1^0^""
+50469^12^0^54322^""^-1^0^""
+50469^13^0^54323^""^-1^0^""
+50469^14^0^54324^""^-1^0^""
+50469^15^0^54325^""^-1^0^""
+50469^16^0^54326^""^-1^0^""
+50469^17^0^54327^""^-1^0^""
+50469^18^0^54328^""^-1^0^""
+50469^19^0^54329^""^-1^0^""
+50469^20^2^32^""^-1^0^""
+50469^21^0^54144^""^-1^0^""
+50469^22^0^54145^""^-1^0^""
+50469^23^0^54151^""^-1^0^""
+50469^24^0^54146^""^-1^0^""
+50469^25^0^54155^""^-1^0^""
+50469^26^0^54330^""^-1^0^""
+50469^27^0^54331^""^-1^0^""
+50469^28^0^54298^""^-1^0^""
+50469^29^0^54332^""^-1^0^""
+50469^30^0^54333^""^-1^0^""
+50469^31^0^54334^""^-1^0^""
+50469^32^0^54335^""^-1^0^""
+50469^33^0^54336^""^-1^0^""
+50469^34^0^54337^""^-1^0^""
+50469^35^0^54338^""^-1^0^""
+50469^36^0^54339^""^-1^0^""
+50469^37^0^54340^""^-1^0^""
+50469^38^0^54341^""^-1^0^""
+50469^39^0^54342^""^-1^0^""
+50469^40^0^54343^""^-1^0^""
+50469^41^0^54344^""^-1^0^""
+50469^42^0^54345^""^-1^0^""
+50469^43^0^54346^""^-1^0^""
+50469^44^0^54347^""^-1^0^""
+50470^0^0^54355^""^-1^0^""
+50471^0^0^54356^""^-1^0^""
+50500^0^0^55000^""^-1^0^""
+50501^0^0^55001^""^-1^0^""
+50600^0^0^56000^""^-1^0^""
+50600^1^0^56001^""^-1^0^""
+50600^2^0^56002^""^-1^0^""
+50600^3^0^56003^""^-1^0^""
+50600^4^0^56004^""^-1^0^""
+50600^5^0^56005^""^-1^0^""
+50600^6^0^56006^""^-1^0^""
+50600^7^0^56007^""^-1^0^""
+50600^8^0^56008^""^-1^0^""
+50600^9^0^56009^""^-1^0^""
+50600^10^0^56010^""^-1^0^""
+50600^11^0^56011^""^-1^0^""
+50600^12^0^56012^""^-1^0^""
+50600^13^2^32^""^-1^0^""
+50601^0^0^56013^""^-1^0^""
+50601^1^0^56014^""^-1^0^""
+50601^2^0^56015^""^-1^2^"56014"
+50602^0^0^56013^""^-1^0^""
+50602^1^0^56014^""^-1^0^""
+50602^2^0^56016^""^-1^2^"56014"
+50603^0^0^56013^""^-1^0^""
+50603^1^0^56014^""^-1^0^""
+50603^2^0^56017^""^-1^2^"56014"
+50604^0^0^56013^""^-1^0^""
+50604^1^0^56014^""^-1^0^""
+50604^2^0^56018^""^-1^2^"56014"
+50605^0^0^56013^""^-1^0^""
+50605^1^0^56014^""^-1^0^""
+50605^2^0^56019^""^-1^2^"56014"
+50606^0^0^56020^""^-1^0^""
+50606^1^0^56021^""^-1^0^""
+50606^2^0^56022^""^-1^2^"56021"
+50607^0^0^56023^""^-1^0^""
+50607^1^0^56024^""^-1^0^""
+50607^2^0^56025^""^-1^0^""
+50607^3^2^32^""^-1^0^""
+50608^0^0^56013^""^-1^0^""
+50608^1^0^56014^""^-1^0^""
+50608^2^0^56026^""^-1^2^"56014"
+50609^0^0^56013^""^-1^0^""
+50609^1^0^56014^""^-1^0^""
+50609^2^0^56027^""^-1^2^"56014"
+50610^0^0^56028^""^-1^0^""
+50610^1^0^56029^""^-1^0^""
+50611^0^0^56030^""^-1^0^""
+50612^0^0^56013^""^-1^0^""
+50612^1^0^56031^""^-1^0^""
+50612^2^0^56032^""^-1^2^"56031"
+50613^0^0^56036^""^-1^0^""
+50613^1^0^56034^""^-1^0^""
+50613^2^0^56035^""^-1^2^"56034"
+50615^0^1^50600^"Common"^-1^0^""
+50615^1^1^50600^"Control"^-1^0^""
+50700^0^0^57000^""^-1^0^""
+50700^1^0^57001^""^-1^0^""
+50700^2^2^32^""^-1^0^""
+50701^0^0^57002^""^-1^1^"4096"
+50703^0^0^57003^""^-1^1^"4096"
+50704^0^0^57006^""^-1^0^""
+50705^0^0^57005^""^-1^1^"4096"
+50800^0^0^58000^""^-1^0^""
+50801^0^0^58001^""^-1^0^""
+50802^0^0^58002^""^-1^0^""
+50802^1^0^58003^""^-1^0^""
+50803^0^0^58004^""^-1^0^""
+50804^0^0^58005^""^-1^0^""
+50805^0^0^58002^""^-1^0^""
+50806^0^0^58004^""^-1^0^""
+50806^1^0^58002^""^-1^0^""
+50807^0^0^58006^""^-1^0^""
+50807^1^0^58007^""^-1^0^""
+50807^2^0^58008^""^-1^0^""
+50808^0^0^58009^""^-1^0^""
+50808^1^0^58003^""^-1^0^""
+50809^0^0^58010^""^-1^0^""
+50810^0^0^58011^""^-1^0^""
+50811^0^0^58012^""^-1^0^""
+50812^0^0^58013^""^-1^0^""
+50900^0^0^59000^""^-1^0^""
+50901^0^0^59001^""^-1^0^""
+50902^0^0^59002^""^-1^0^""
+50902^1^1^50903^"Services"^-1^2^"59002"
+50903^0^0^59003^""^-1^0^""
+50903^1^0^59004^""^-1^0^""
+50903^2^0^59005^""^-1^0^""
+50904^0^0^59006^""^-1^0^""
+50904^1^0^59007^""^-1^9^"59006"
+50904^2^0^59002^""^-1^0^""
+50904^3^1^50903^"Services"^-1^2^"59002"
+50905^0^0^59003^""^-1^0^""
+50906^0^0^59003^""^-1^0^""
+50906^1^0^59008^""^-1^0^""
+50907^0^0^59009^""^-1^0^""
+50908^0^0^59010^""^-1^0^""
+50908^1^0^59011^""^-1^0^""
+50908^2^2^16^""^-1^0^""
+50909^0^0^59012^""^-1^0^""
+50910^0^0^59013^""^-1^0^""
+50910^1^0^59014^""^-1^0^""
+50911^0^0^59013^""^-1^0^""
+50911^1^0^59003^""^-1^0^""
+50912^0^0^59015^""^-1^1^"255"
+50913^0^0^59013^""^-1^0^""
+60000^0^0^50263^""^-1^0^""
+60000^1^1^50021^"Instance"^-1^2^"50263"
+60001^0^0^50263^""^-1^0^""
+60001^1^1^60002^"Instance"^-1^2^"50263"
+60002^0^0^50264^""^-1^0^""
+60002^1^0^50265^""^-1^10^"50264"
+60003^0^1^60013^""^-1^0^""
+60004^0^0^50266^""^-1^0^""
+60005^0^0^50263^""^-1^0^""
+60005^1^1^60006^"Instance"^-1^2^"50263"
+60006^0^0^50267^""^-1^0^""
+60006^1^0^50268^""^-1^10^"50267"
+60007^0^0^50269^""^-1^0^""
+60008^0^0^50270^""^-1^0^""
+60009^0^0^50271^""^-1^1^"4"
+60010^0^1^60012^""^-1^0^""
+60011^0^1^60012^""^-1^0^""
+60012^0^1^60013^""^-1^0^""
+60012^1^1^60014^""^-1^0^""
+60013^0^6^0^""^-1^0^""
+60013^1^0^50275^""^-1^1^"8"
+60014^0^0^50272^""^-1^0^""
+60015^0^0^50276^""^-1^0^""
+60016^0^0^50277^""^-1^0^""
+60017^0^0^50269^""^-1^0^""
+60018^0^0^50278^""^-1^0^""
+60018^1^0^50279^""^-1^0^""
+60018^2^0^50280^""^-1^0^""
+60018^3^0^50281^""^-1^1^"16"
+60018^4^0^50282^""^-1^0^""
+60018^5^0^50283^""^-1^0^""
+60018^6^0^50284^""^-1^0^""
+60018^7^0^50285^""^-1^0^""
+60018^8^0^50286^""^-1^0^""
+60018^9^0^50287^""^-1^0^""
+60018^10^0^50288^""^-1^0^""
+60018^11^0^50289^""^-1^0^""
+60018^12^0^50290^""^-1^0^""
+60019^0^0^50278^""^-1^0^""
+60019^1^0^50279^""^-1^0^""
+60019^2^0^50280^""^-1^0^""
+60019^3^0^50281^""^-1^0^""
+60019^4^0^50282^""^-1^0^""
+60019^5^0^50283^""^-1^0^""
+60019^6^0^50284^""^-1^0^""
+60019^7^0^50285^""^-1^0^""
+60019^8^0^50286^""^-1^0^""
+60019^9^0^50287^""^-1^0^""
+60019^10^0^50288^""^-1^0^""
+60019^11^0^50289^""^-1^0^""
+60019^12^0^50290^""^-1^0^""
+60020^0^0^50291^""^-1^0^""
+60021^0^0^50292^""^-1^0^""
+60022^0^0^50293^""^-1^0^""
+60023^0^1^60058^""^-1^0^""
+60024^0^0^50135^""^-1^0^""
+60024^1^0^50136^""^-1^0^""
+60024^2^0^50137^""^-1^0^""
+60024^3^0^50138^""^-1^0^""
+60024^4^0^50139^""^-1^0^""
+60024^5^0^50140^""^-1^0^""
+60024^6^0^50141^""^-1^0^""
+60024^7^0^50142^""^-1^0^""
+60024^8^0^50143^""^-1^0^""
+60024^9^0^50144^""^-1^0^""
+60024^10^0^50145^""^-1^0^""
+60024^11^0^50146^""^-1^0^""
+60024^12^0^50294^""^-1^0^""
+60025^0^0^50135^""^-1^0^""
+60025^1^0^50136^""^-1^0^""
+60025^2^0^50137^""^-1^0^""
+60025^3^0^50138^""^-1^0^""
+60025^4^0^50139^""^-1^0^""
+60025^5^0^50140^""^-1^0^""
+60025^6^0^50141^""^-1^0^""
+60025^7^0^50142^""^-1^0^""
+60025^8^0^50143^""^-1^0^""
+60025^9^0^50144^""^-1^0^""
+60025^10^0^50145^""^-1^0^""
+60025^11^0^50146^""^-1^0^""
+60025^12^0^50294^""^-1^0^""
+60026^0^1^60058^""^-1^0^""
+60027^0^1^60058^""^-1^0^""
+60028^0^0^50295^""^-1^0^""
+60029^0^0^50296^""^-1^0^""
+60029^1^0^50139^""^-1^0^""
+60029^2^0^50137^""^-1^0^""
+60029^3^0^50138^""^-1^0^""
+60029^4^0^50136^""^-1^0^""
+60030^0^0^50297^""^-1^0^""
+60031^0^0^50298^""^-1^0^""
+60032^0^0^50299^""^-1^0^""
+60033^0^0^50300^""^-1^0^""
+60034^0^0^50301^""^-1^0^""
+60035^0^0^50301^""^-1^0^""
+60036^0^0^50301^""^-1^0^""
+60037^0^0^50302^""^-1^0^""
+60038^0^0^50302^""^-1^0^""
+60039^0^0^50302^""^-1^0^""
+60040^0^0^50303^""^-1^0^""
+60041^0^0^50122^""^-1^0^""
+60042^0^0^50123^""^-1^0^""
+60043^0^0^50304^""^-1^0^""
+60044^0^0^50305^""^-1^0^""
+60045^0^0^50306^""^-1^0^""
+60046^0^0^50307^""^-1^0^""
+60047^0^0^50119^""^-1^0^""
+60048^0^0^50308^""^-1^0^""
+60049^0^0^50309^""^-1^0^""
+60050^0^0^50271^""^-1^0^""
+60051^0^0^50271^""^-1^0^""
+60052^0^1^60058^""^-1^0^""
+60053^0^1^60058^""^-1^0^""
+60054^0^0^50310^""^-1^0^""
+60055^0^1^60058^""^-1^0^""
+60056^0^1^60058^""^-1^0^""
+60057^0^0^50311^""^-1^0^""
+60057^1^1^60058^""^-1^2^"50311"
+60058^0^1^60013^""^-1^0^""
+60059^0^0^50297^""^-1^0^""
+60060^0^0^50298^""^-1^0^""
+60061^0^0^50299^""^-1^0^""
+60062^0^0^50300^""^-1^0^""
+60063^0^0^50301^""^-1^0^""
+60064^0^0^50301^""^-1^0^""
+60065^0^0^50301^""^-1^0^""
+60066^0^0^50302^""^-1^0^""
+60067^0^0^50302^""^-1^0^""
+60068^0^0^50302^""^-1^0^""
+60069^0^0^50303^""^-1^0^""
+60070^0^0^50122^""^-1^0^""
+60071^0^0^50123^""^-1^0^""
+60072^0^0^50304^""^-1^0^""
+60073^0^0^50305^""^-1^0^""
+60074^0^0^50306^""^-1^0^""
+60075^0^0^50307^""^-1^0^""
+60076^0^0^50119^""^-1^0^""
+60077^0^0^50308^""^-1^0^""
+60078^0^0^50309^""^-1^0^""
+60079^0^0^50271^""^-1^0^""
+60080^0^0^50271^""^-1^0^""
+60081^0^1^60058^""^-1^0^""
+60082^0^1^60058^""^-1^0^""
+60083^0^0^50310^""^-1^0^""
+60084^0^1^60058^""^-1^0^""
+60085^0^1^60058^""^-1^0^""
+60086^0^0^50276^""^-1^0^""
+60087^0^0^50277^""^-1^0^""
+60088^0^0^50269^""^-1^0^""
+60090^0^1^60058^""^-1^0^""
+
+70000^0^0^70000^""^-1^0^""
+70000^1^0^70001^""^-1^0^""
+70000^2^0^70002^""^-1^2^"70001"
+70001^0^0^70003^""^-1^0^""
+70002^0^0^70004^""^-1^0^""
+70002^1^0^70005^""^-1^0^""
+70002^2^0^70006^""^-1^2^"70005"
+70003^0^0^70007^""^-1^0^""
+70004^0^0^50001^""^-1^0^"" \ No newline at end of file
diff --git a/gobi-api/GobiAPI_1.0.40/Database/QMI/foo.c b/gobi-api/GobiAPI_1.0.40/Database/QMI/foo.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Database/QMI/foo.c
diff --git a/gobi-api/GobiAPI_1.0.40/GobiConnectionMgmt/GobiConnectionMgmt.cpp b/gobi-api/GobiAPI_1.0.40/GobiConnectionMgmt/GobiConnectionMgmt.cpp
new file mode 100755
index 0000000..fa89daf
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/GobiConnectionMgmt/GobiConnectionMgmt.cpp
@@ -0,0 +1,2882 @@
+/*===========================================================================
+FILE:
+ GobiConnectionMgmt.cpp
+
+DESCRIPTION:
+ QUALCOMM Connection Management API for Gobi 3000
+
+PUBLIC CLASSES AND FUNCTIONS:
+ cGobiConnectionMgmtDLL
+ cGobiConnectionMgmt
+
+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 "GobiConnectionMgmt.h"
+#include "QMIBuffers.h"
+
+//---------------------------------------------------------------------------
+// Definitions
+//---------------------------------------------------------------------------
+
+// Global object
+cGobiConnectionMgmtDLL gConnectionDLL;
+
+// Interval between traffic processing loop iterations (milliseconds)
+const ULONG TRAFFIC_INTERVAL_MS = 300000;
+
+/*=========================================================================*/
+// Free Methods
+/*=========================================================================*/
+
+/*===========================================================================
+METHOD:
+ TrafficProcessThread (Free Method)
+
+DESCRIPTION:
+ QMI traffic process thread - processes all traffic in order to fire
+ off QMI traffic related callbacks
+
+PARAMETERS:
+ pArg [ I ] - Object to interface to
+
+RETURN VALUE:
+ VOID * - always NULL
+===========================================================================*/
+VOID * TrafficProcessThread( PVOID pArg )
+{
+ // Keep running?
+ bool bRun = false;
+
+ TRACE( "GobiConnectionMgmt traffic thread [%u] started\n",
+ (UINT)pthread_self() );
+
+ // Create a vector of the objects to wait on
+ std::vector <cEvent *> events;
+
+ // Store the index to service type for use later
+ std::map <DWORD, eQMIService> services;
+
+ cGobiConnectionMgmt * pAPI = (cGobiConnectionMgmt *)pArg;
+ if (pAPI != 0)
+ {
+ // Time to go to work
+ bRun = true;
+
+ // Add the thread exit event
+ events.push_back( &pAPI->mExitEvent );
+
+ // For each Protocol server, grab the signal event
+ std::set <cGobiConnectionMgmt::tServerConfig>::const_iterator pIter;
+ pIter = pAPI->mServerConfig.begin();
+ while (pIter != pAPI->mServerConfig.end())
+ {
+ eQMIService svc = pIter->first;
+ cQMIProtocolServer * pServer = pAPI->GetServer( svc );
+ if (pServer != 0)
+ {
+ // Grab the log from the server
+ const cProtocolLog & log = pServer->GetLog();
+
+ // Grab the Signal event, if it exists
+ cEvent & sigEvent = log.GetSignalEvent();
+
+ services[events.size()] = svc;
+ events.push_back( &sigEvent );
+ }
+
+ pIter++;
+ }
+ }
+
+ // Loop waiting for exit event
+ while (bRun == true)
+ {
+ // Wait for activity
+ DWORD ignoredVal, index;
+ int nRet = WaitOnMultipleEvents( events,
+ TRAFFIC_INTERVAL_MS,
+ ignoredVal,
+ index );
+ // Timeout
+ if (nRet == -ETIME)
+ {
+ // Do nothing
+ }
+ // Error?
+ else if (nRet <= 0)
+ {
+ TRACE( "GobiConnectionMgmt traffic thread wait error %d\n", nRet );
+ bRun = false;
+ }
+ // Exit event?
+ else if (index == 0)
+ {
+ bRun = false;
+ }
+ else if (index < events.size())
+ {
+ // Run ProcessTraffic() for this service type
+ if (services.find( index ) != services.end())
+ {
+ pAPI->ProcessTraffic( services[index] );
+ }
+ }
+ else
+ {
+ // Fatal error
+ bRun = false;
+ }
+ }
+
+ TRACE( "GobiConnectionMgmt traffic thread [%u] exited\n",
+ (UINT)pthread_self() );
+
+ return NULL;
+}
+
+/*===========================================================================
+METHOD:
+ CallbackThread (Free Method)
+
+DESCRIPTION:
+ Thread to execute a callback asynchronously
+
+PARAMETERS:
+ pArg [ I ] - The cAsyncFunction object
+
+RETURN VALUE:
+ void * - thread exit value (always 0)
+===========================================================================*/
+void * CallbackThread( PVOID pArg )
+{
+ cGobiCMCallback * pCB = (cGobiCMCallback *)pArg;
+ if (pCB == 0)
+ {
+ ASSERT( 0 );
+ return 0;
+ }
+
+ pCB->Call();
+
+ delete pCB;
+ pCB = 0;
+
+ return 0;
+}
+
+/*=========================================================================*/
+// cGobiConnectionMgmtDLL Methods
+/*=========================================================================*/
+
+/*===========================================================================
+METHOD:
+ cGobiConnectionMgmtDLL (Public Method)
+
+DESCRIPTION:
+ Constructor
+
+RETURN VALUE:
+ None
+===========================================================================*/
+cGobiConnectionMgmtDLL::cGobiConnectionMgmtDLL()
+ : mpAPI( 0 ),
+ mbAllocated( false )
+{
+ // Create sync CS
+ pthread_mutex_init( &mSyncSection, NULL );
+}
+
+/*===========================================================================
+METHOD:
+ ~cGobiConnectionMgmtDLL (Public Method)
+
+DESCRIPTION:
+ Destructor
+
+RETURN VALUE:
+ None
+===========================================================================*/
+cGobiConnectionMgmtDLL::~cGobiConnectionMgmtDLL()
+{
+ // Just in case
+ if (mpAPI != 0)
+ {
+ mpAPI->Cleanup();
+ delete mpAPI;
+ mpAPI = 0;
+ }
+
+ pthread_mutex_destroy( &mSyncSection );
+}
+
+/*===========================================================================
+METHOD:
+ GetAPI (Public Method)
+
+DESCRIPTION:
+ Return the cGobiConnectionMgmt object
+
+RETURN VALUE:
+ cGobiConnectionMgmt *
+===========================================================================*/
+cGobiConnectionMgmt * cGobiConnectionMgmtDLL::GetAPI()
+{
+ pthread_mutex_lock( &mSyncSection );
+
+ bool bAlloc = mbAllocated;
+
+ pthread_mutex_unlock( &mSyncSection );
+
+ if (bAlloc == true)
+ {
+ return mpAPI;
+ }
+
+ pthread_mutex_lock( &mSyncSection );
+
+ mpAPI = new cGobiConnectionMgmt();
+ if (mpAPI != 0)
+ {
+ mpAPI->Initialize();
+ }
+
+ // We have tried to allocate the object
+ mbAllocated = true;
+
+ pthread_mutex_unlock( &mSyncSection );
+ return mpAPI;
+}
+
+/*=========================================================================*/
+// cGobiConnectionMgmt Methods
+/*=========================================================================*/
+
+/*===========================================================================
+METHOD:
+ cGobiConnectionMgmt (Public Method)
+
+DESCRIPTION:
+ Constructor
+
+RETURN VALUE:
+ None
+===========================================================================*/
+cGobiConnectionMgmt::cGobiConnectionMgmt()
+ : cGobiQMICore(),
+ mbThreadStarted( false ),
+ mThreadID( 0 ),
+ mWDSItemsProcessed( 0 ),
+ mDMSItemsProcessed( 0 ),
+ mNASItemsProcessed( 0 ),
+ mWMSItemsProcessed( 0 ),
+ mPDSItemsProcessed( 0 ),
+ mCATItemsProcessed( 0 ),
+ mOMAItemsProcessed( 0 ),
+ mVoiceItemsProcessed( 0 ),
+ mpFNSessionState( 0 ),
+ mpFNByteTotals( 0 ),
+ mpFNDataCapabilities( 0 ),
+ mpFNDataBearer( 0 ),
+ mpFNDormancyStatus( 0 ),
+ mpFNMobileIPStatus( 0 ),
+ mpFNActivationStatus( 0 ),
+ mpFNPower( 0 ),
+ mpFNWirelessDisable( 0 ),
+ mpFNRoamingIndicator( 0 ),
+ mpFNSignalStrength( 0 ),
+ mpFNRFInfo( 0 ),
+ mpFNLUReject( 0 ),
+ mpPLMNMode( 0 ),
+ mpFNNewSMS( 0 ),
+ mpFNNewNMEA( 0 ),
+ mpFNPDSState( 0 ),
+ mpFNCATEvent( 0 ),
+ mpFNOMADMAlert( 0 ),
+ mpFNOMADMState( 0 ),
+ mpFNUSSDRelease( 0 ),
+ mpFNUSSDNotification( 0 ),
+ mpFNUSSDOrigination( 0 )
+{
+ tServerConfig wdsSvr( eQMI_SVC_WDS, true );
+ tServerConfig dmsSvr( eQMI_SVC_DMS, true );
+ tServerConfig nasSvr( eQMI_SVC_NAS, true );
+ tServerConfig wmsSvr( eQMI_SVC_WMS, true );
+ tServerConfig pdsSvr( eQMI_SVC_PDS, true );
+ tServerConfig catSvr( eQMI_SVC_CAT, false );
+ tServerConfig rmsSvr( eQMI_SVC_RMS, false );
+ tServerConfig omaSvr( eQMI_SVC_OMA, false );
+ tServerConfig voiceSvr( eQMI_SVC_VOICE, false );
+ mServerConfig.insert( wdsSvr );
+ mServerConfig.insert( dmsSvr );
+ mServerConfig.insert( nasSvr );
+ mServerConfig.insert( wmsSvr );
+ mServerConfig.insert( pdsSvr );
+ mServerConfig.insert( catSvr );
+ mServerConfig.insert( rmsSvr );
+ mServerConfig.insert( omaSvr );
+ mServerConfig.insert( voiceSvr );
+}
+
+/*===========================================================================
+METHOD:
+ ~cGobiConnectionMgmt (Public Method)
+
+DESCRIPTION:
+ Destructor
+
+RETURN VALUE:
+ None
+===========================================================================*/
+cGobiConnectionMgmt::~cGobiConnectionMgmt()
+{
+ Disconnect();
+}
+
+/*===========================================================================
+METHOD:
+ ProcessTraffic (Internal Method)
+
+DESCRIPTION:
+ Process traffic in a QMI server protocol log, this is done to
+ exercise QMI indication related callbacks
+
+PARAMETERS:
+ svc [ I ] - QMI Service type
+
+RETURN VALUE:
+ None
+===========================================================================*/
+void cGobiConnectionMgmt::ProcessTraffic( eQMIService svc )
+{
+ ULONG count = 0;
+
+ switch (svc)
+ {
+ case eQMI_SVC_WDS:
+ {
+ cQMIProtocolServer * pWDS = GetServer( eQMI_SVC_WDS );
+ if (pWDS != 0)
+ {
+ // Grab the WDS log from the server
+ const cProtocolLog & logWDS = pWDS->GetLog();
+
+ // New WDS items to process?
+ count = logWDS.GetCount();
+ if (count != INVALID_LOG_INDEX && count > mWDSItemsProcessed)
+ {
+ for (ULONG i = mWDSItemsProcessed; i < count; i++)
+ {
+ sProtocolBuffer buf = logWDS.GetBuffer( i );
+ if ( (buf.IsValid() == true)
+ && (buf.GetType() == (ULONG)ePROTOCOL_QMI_WDS_RX) )
+ {
+ ProcessWDSBuffer( buf );
+ }
+ }
+
+ mWDSItemsProcessed = count;
+ }
+ }
+
+ break;
+ }
+
+ case eQMI_SVC_DMS:
+ {
+ cQMIProtocolServer * pDMS = GetServer( eQMI_SVC_DMS );
+ if (pDMS != 0)
+ {
+ // Grab the DMS log from the server
+ const cProtocolLog & logDMS = pDMS->GetLog();
+
+ // New DMS items to process?
+ count = logDMS.GetCount();
+ if (count != INVALID_LOG_INDEX && count > mDMSItemsProcessed)
+ {
+ for (ULONG i = mDMSItemsProcessed; i < count; i++)
+ {
+ sProtocolBuffer buf = logDMS.GetBuffer( i );
+ if ( (buf.IsValid() == true)
+ && (buf.GetType() == (ULONG)ePROTOCOL_QMI_DMS_RX) )
+ {
+ ProcessDMSBuffer( buf );
+ }
+ }
+
+ mDMSItemsProcessed = count;
+ }
+ }
+
+ break;
+ }
+
+ case eQMI_SVC_NAS:
+ {
+ cQMIProtocolServer * pNAS = GetServer( eQMI_SVC_NAS );
+ if (pNAS != 0)
+ {
+ // Grab the NAS log from the server
+ const cProtocolLog & logNAS = pNAS->GetLog();
+
+ // New NAS items to process?
+ count = logNAS.GetCount();
+ if (count != INVALID_LOG_INDEX && count > mNASItemsProcessed)
+ {
+ for (ULONG i = mNASItemsProcessed; i < count; i++)
+ {
+ sProtocolBuffer buf = logNAS.GetBuffer( i );
+ if ( (buf.IsValid() == true)
+ && (buf.GetType() == (ULONG)ePROTOCOL_QMI_NAS_RX) )
+ {
+ ProcessNASBuffer( buf );
+ }
+ }
+
+ mNASItemsProcessed = count;
+ }
+ }
+
+ break;
+ }
+
+ case eQMI_SVC_WMS:
+ {
+ cQMIProtocolServer * pWMS = GetServer( eQMI_SVC_WMS );
+ if (pWMS != 0)
+ {
+ // Grab the WMS log from the server
+ const cProtocolLog & logWMS = pWMS->GetLog();
+
+ // New WMS items to process?
+ count = logWMS.GetCount();
+ if (count != INVALID_LOG_INDEX && count > mWMSItemsProcessed)
+ {
+ for (ULONG i = mWMSItemsProcessed; i < count; i++)
+ {
+ sProtocolBuffer buf = logWMS.GetBuffer( i );
+ if ( (buf.IsValid() == true)
+ && (buf.GetType() == (ULONG)ePROTOCOL_QMI_WMS_RX) )
+ {
+ ProcessWMSBuffer( buf );
+ }
+ }
+
+ mWMSItemsProcessed = count;
+ }
+ }
+
+ break;
+ }
+
+ case eQMI_SVC_PDS:
+ {
+ cQMIProtocolServer * pPDS = GetServer( eQMI_SVC_PDS );
+ if (pPDS != 0)
+ {
+ // Grab the PDS log from the server
+ const cProtocolLog & logPDS = pPDS->GetLog();
+
+ // New PDS items to process?
+ count = logPDS.GetCount();
+ if (count != INVALID_LOG_INDEX && count > mPDSItemsProcessed)
+ {
+ for (ULONG i = mPDSItemsProcessed; i < count; i++)
+ {
+ sProtocolBuffer buf = logPDS.GetBuffer( i );
+ if ( (buf.IsValid() == true)
+ && (buf.GetType() == (ULONG)ePROTOCOL_QMI_PDS_RX) )
+ {
+ ProcessPDSBuffer( buf );
+ }
+ }
+
+ mPDSItemsProcessed = count;
+ }
+ }
+
+ break;
+ }
+
+ case eQMI_SVC_CAT:
+ {
+ cQMIProtocolServer * pCAT = GetServer( eQMI_SVC_CAT );
+ if (pCAT != 0)
+ {
+ // Grab the CAT log from the server
+ const cProtocolLog & logCAT = pCAT->GetLog();
+
+ // New CAT items to process?
+ count = logCAT.GetCount();
+ if (count != INVALID_LOG_INDEX && count > mCATItemsProcessed)
+ {
+ for (ULONG i = mCATItemsProcessed; i < count; i++)
+ {
+ sProtocolBuffer buf = logCAT.GetBuffer( i );
+ if ( (buf.IsValid() == true)
+ && (buf.GetType() == (ULONG)ePROTOCOL_QMI_CAT_RX) )
+ {
+ ProcessCATBuffer( buf );
+ }
+ }
+
+ mCATItemsProcessed = count;
+ }
+ }
+
+ break;
+ }
+
+ case eQMI_SVC_OMA:
+ {
+ cQMIProtocolServer * pOMA = GetServer( eQMI_SVC_OMA );
+ if (pOMA != 0)
+ {
+ // Grab the OMA log from the server
+ const cProtocolLog & logOMA = pOMA->GetLog();
+
+ // New OMA items to process?
+ count = logOMA.GetCount();
+ if (count != INVALID_LOG_INDEX && count > mOMAItemsProcessed)
+ {
+ for (ULONG i = mOMAItemsProcessed; i < count; i++)
+ {
+ sProtocolBuffer buf = logOMA.GetBuffer( i );
+ if ( (buf.IsValid() == true)
+ && (buf.GetType() == (ULONG)ePROTOCOL_QMI_OMA_RX) )
+ {
+ ProcessOMABuffer( buf );
+ }
+ }
+
+ mOMAItemsProcessed = count;
+ }
+ }
+
+ break;
+ }
+
+ case eQMI_SVC_VOICE:
+ {
+ cQMIProtocolServer * pVoice = GetServer( eQMI_SVC_VOICE );
+ if (pVoice != 0)
+ {
+ // Grab the voice log from the server
+ const cProtocolLog & logVoice = pVoice->GetLog();
+
+ // New voice items to process?
+ count = logVoice.GetCount();
+ if (count != INVALID_LOG_INDEX && count > mVoiceItemsProcessed)
+ {
+ for (ULONG i = mVoiceItemsProcessed; i < count; i++)
+ {
+ sProtocolBuffer buf = logVoice.GetBuffer( i );
+ if ( (buf.IsValid() == true)
+ && (buf.GetType() == (ULONG)ePROTOCOL_QMI_VOICE_RX) )
+ {
+ ProcessVoiceBuffer( buf );
+ }
+ }
+
+ mVoiceItemsProcessed = count;
+ }
+ }
+
+ break;
+ }
+
+ default:
+ break;
+ }
+}
+
+/*===========================================================================
+METHOD:
+ ProcessWDSBuffer (Internal Method)
+
+DESCRIPTION:
+ Process a WDS buffer
+
+PARAMETERS:
+ buf [ I ] - QMI buffer to process
+
+RETURN VALUE:
+ None
+===========================================================================*/
+void cGobiConnectionMgmt::ProcessWDSBuffer( const sProtocolBuffer & buf )
+{
+ sQMIServiceBuffer qmiBuf( buf.GetSharedBuffer() );
+ if (qmiBuf.IsValid() == false)
+ {
+ return;
+ }
+
+ // Indication?
+ if (qmiBuf.IsIndication() == false)
+ {
+ return;
+ }
+
+ // Do we even care?
+ ULONG msgID = qmiBuf.GetMessageID();
+ if (msgID == eQMI_WDS_EVENT_IND)
+ {
+ // Prepare TLVs for parsing
+ std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiBuf );
+
+ // Parse out data bearer technology
+ sProtocolEntityKey tlvKey( eDB2_ET_QMI_WDS_IND, msgID, 23 );
+ cDataParser::tParsedFields pf = ParseTLV( mDB, buf, tlvs, tlvKey );
+ if (pf.size() >= 1)
+ {
+ if (mpFNDataBearer != 0)
+ {
+ cDataBearerCallback * pCB = 0;
+ pCB = new cDataBearerCallback( mpFNDataBearer, pf[0].mValue.mU32 );
+ if (pCB != 0)
+ {
+ if (pCB->Initialize() == false)
+ {
+ delete pCB;
+ }
+ }
+ }
+ }
+
+ // Parse out dormancy status
+ tlvKey = sProtocolEntityKey( eDB2_ET_QMI_WDS_IND, msgID, 24 );
+ pf = ParseTLV( mDB, buf, tlvs, tlvKey );
+ if (pf.size() >= 1)
+ {
+ if (mpFNDormancyStatus != 0)
+ {
+ cDormancyStatusCallback * pCB = 0;
+ pCB = new cDormancyStatusCallback( mpFNDormancyStatus,
+ pf[0].mValue.mU32 );
+
+ if (pCB != 0)
+ {
+ if (pCB->Initialize() == false)
+ {
+ delete pCB;
+ }
+ }
+ }
+ }
+
+ // Parse out byte totals
+ tlvKey = sProtocolEntityKey( eDB2_ET_QMI_WDS_IND, msgID, 25 );
+ pf = ParseTLV( mDB, buf, tlvs, tlvKey );
+ if (pf.size() >= 1)
+ {
+ ULONGLONG tx = pf[0].mValue.mU64;
+ ULONGLONG rx = ULLONG_MAX;
+
+ tlvKey = sProtocolEntityKey( eDB2_ET_QMI_WDS_IND, msgID, 26 );
+ pf = ParseTLV( mDB, buf, tlvs, tlvKey );
+ if (pf.size() >= 1)
+ {
+ rx = pf[0].mValue.mU64;
+ }
+
+ if (mpFNByteTotals != 0)
+ {
+ cByteTotalsCallback * pCB = 0;
+ pCB = new cByteTotalsCallback( mpFNByteTotals, tx, rx );
+ if (pCB != 0)
+ {
+ if (pCB->Initialize() == false)
+ {
+ delete pCB;
+ }
+ }
+ }
+ }
+ // Parse out mobile IP status
+ tlvKey = sProtocolEntityKey( eDB2_ET_QMI_WDS_IND, msgID, 27 );
+ pf = ParseTLV( mDB, buf, tlvs, tlvKey );
+ if (pf.size() >= 1)
+ {
+ if (mpFNMobileIPStatus != 0)
+ {
+ cMobileIPStatusCallback * pCB = 0;
+ pCB = new cMobileIPStatusCallback( mpFNMobileIPStatus,
+ pf[0].mValue.mU32 );
+
+ if (pCB != 0)
+ {
+ if (pCB->Initialize() == false)
+ {
+ delete pCB;
+ }
+ }
+ }
+ }
+ }
+ else if (msgID == eQMI_WDS_PKT_STATUS_IND)
+ {
+ // Prepare TLVs for parsing
+ std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiBuf );
+
+ // Parse out session status
+ sProtocolEntityKey tlvKey( eDB2_ET_QMI_WDS_IND, msgID, 1 );
+ cDataParser::tParsedFields pf = ParseTLV( mDB, buf, tlvs, tlvKey );
+ if (pf.size() >= 1)
+ {
+ ULONG ss = pf[0].mValue.mU32;
+ ULONG cer = ULONG_MAX;
+
+ // Parse out call end reason (if present)
+ tlvKey = sProtocolEntityKey( eDB2_ET_QMI_WDS_IND, msgID, 16 );
+ pf = ParseTLV( mDB, buf, tlvs, tlvKey );
+ if (pf.size() >= 1)
+ {
+ cer = pf[0].mValue.mU32;
+ }
+
+ if (mpFNSessionState != 0)
+ {
+ cSessionStateCallback * pCB = 0;
+ pCB = new cSessionStateCallback( mpFNSessionState, ss, cer );
+ if (pCB != 0)
+ {
+ if (pCB->Initialize() == false)
+ {
+ delete pCB;
+ }
+ }
+ }
+ }
+ }
+}
+
+/*===========================================================================
+METHOD:
+ ProcessDMSBuffer (Internal Method)
+
+DESCRIPTION:
+ Process a DMS buffer
+
+PARAMETERS:
+ buf [ I ] - QMI buffer to process
+
+RETURN VALUE:
+ None
+===========================================================================*/
+void cGobiConnectionMgmt::ProcessDMSBuffer( const sProtocolBuffer & buf )
+{
+ sQMIServiceBuffer qmiBuf( buf.GetSharedBuffer() );
+ if (qmiBuf.IsValid() == false)
+ {
+ return;
+ }
+
+ // Indication?
+ if (qmiBuf.IsIndication() == false)
+ {
+ return;
+ }
+
+ // Do we even care?
+ ULONG msgID = qmiBuf.GetMessageID();
+ if (msgID == eQMI_DMS_EVENT_IND)
+ {
+ // Prepare TLVs for parsing
+ std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiBuf );
+
+ // Parse out activation status
+ sProtocolEntityKey tlvKey( eDB2_ET_QMI_DMS_IND, msgID, 19 );
+ cDataParser::tParsedFields pf = ParseTLV( mDB, buf, tlvs, tlvKey );
+ if (pf.size() >= 1 && mpFNActivationStatus != 0)
+ {
+ cActivationStatusCallback * pCB = 0;
+ pCB = new cActivationStatusCallback( mpFNActivationStatus,
+ pf[0].mValue.mU32 );
+
+ if (pCB != 0)
+ {
+ if (pCB->Initialize() == false)
+ {
+ delete pCB;
+ }
+ }
+ }
+
+ // Parse out operating mode
+ tlvKey = sProtocolEntityKey( eDB2_ET_QMI_DMS_IND, msgID, 20 );
+ pf = ParseTLV( mDB, buf, tlvs, tlvKey );
+ if (pf.size() >= 1 && mpFNPower != 0)
+ {
+ cPowerCallback * pCB = 0;
+ pCB = new cPowerCallback( mpFNPower, pf[0].mValue.mU32 );
+ if (pCB != 0)
+ {
+ if (pCB->Initialize() == false)
+ {
+ delete pCB;
+ }
+ }
+ }
+
+ // Parse out wireless disable state
+ tlvKey = sProtocolEntityKey( eDB2_ET_QMI_DMS_IND, msgID, 22 );
+ pf = ParseTLV( mDB, buf, tlvs, tlvKey );
+ if (pf.size() >= 1 && mpFNWirelessDisable != 0)
+ {
+ cWirelessDisableCallback * pCB = 0;
+ pCB = new cWirelessDisableCallback( mpFNWirelessDisable,
+ pf[0].mValue.mU32 );
+ if (pCB != 0)
+ {
+ if (pCB->Initialize() == false)
+ {
+ delete pCB;
+ }
+ }
+ }
+ }
+}
+
+/*===========================================================================
+METHOD:
+ ProcessNASBuffer (Internal Method)
+
+DESCRIPTION:
+ Process a NAS buffer
+
+PARAMETERS:
+ buf [ I ] - QMI buffer to process
+
+RETURN VALUE:
+ None
+===========================================================================*/
+void cGobiConnectionMgmt::ProcessNASBuffer( const sProtocolBuffer & buf )
+{
+ sQMIServiceBuffer qmiBuf( buf.GetSharedBuffer() );
+ if (qmiBuf.IsValid() == false)
+ {
+ return;
+ }
+
+ // Indication?
+ if (qmiBuf.IsIndication() == false)
+ {
+ return;
+ }
+
+ // Do we even care?
+ ULONG msgID = qmiBuf.GetMessageID();
+ if (msgID == (ULONG)eQMI_NAS_EVENT_IND)
+ {
+ // Prepare TLVs for parsing
+ std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiBuf );
+
+ // Parse signal strength
+ sProtocolEntityKey tlvKey( eDB2_ET_QMI_NAS_IND, msgID, 16 );
+ cDataParser::tParsedFields pf = ParseTLV( mDB, buf, tlvs, tlvKey );
+ if (pf.size() >= 2)
+ {
+ INT8 sigVal = pf[0].mValue.mS8;
+ ULONG radioVal = pf[1].mValue.mU32;
+ bool bValidSig = (sigVal <= -30 && sigVal > -125 && radioVal != 0);
+
+ if (bValidSig == true && mpFNSignalStrength != 0)
+ {
+ cSignalStrengthCallback * pCB = 0;
+ pCB = new cSignalStrengthCallback( mpFNSignalStrength,
+ pf[0].mValue.mS8,
+ pf[1].mValue.mU32 );
+
+ if (pCB != 0)
+ {
+ if (pCB->Initialize() == false)
+ {
+ delete pCB;
+ }
+ }
+ }
+ }
+
+ // Parse out RF info
+ sProtocolEntityKey tlvKey2( eDB2_ET_QMI_NAS_IND, msgID, 17 );
+ cDataParser::tParsedFields pf2 = ParseTLV( mDB, buf, tlvs, tlvKey2 );
+
+ ULONG fieldCount = (ULONG)pf2.size();
+ if (fieldCount >= 1 && mpFNRFInfo != 0)
+ {
+ BYTE ifaceCount = pf2[0].mValue.mU8;
+ if (fieldCount >= 1 + ((ULONG)ifaceCount * 3))
+ {
+ for (BYTE i = 0; i < ifaceCount; i++)
+ {
+ ULONG offset = 3 * (ULONG)i;
+
+ cRFInfoCallback * pCB = 0;
+ pCB = new cRFInfoCallback( mpFNRFInfo,
+ pf2[offset + 1].mValue.mU32,
+ pf2[offset + 2].mValue.mU32,
+ (ULONG)pf2[offset + 3].mValue.mU16 );
+
+ if (pCB != 0)
+ {
+ if (pCB->Initialize() == false)
+ {
+ delete pCB;
+ }
+ }
+ }
+ }
+ }
+
+ // Parse out LU reject
+ sProtocolEntityKey tlvKey3( eDB2_ET_QMI_NAS_IND, msgID, 18 );
+ cDataParser::tParsedFields pf3 = ParseTLV( mDB, buf, tlvs, tlvKey3 );
+ if (pf3.size() >= 2 && mpFNLUReject != 0)
+ {
+ cLURejectCallback * pCB = 0;
+ pCB = new cLURejectCallback( mpFNLUReject,
+ pf3[0].mValue.mU32,
+ (ULONG)pf3[1].mValue.mU16 );
+
+ if (pCB != 0)
+ {
+ if (pCB->Initialize() == false)
+ {
+ delete pCB;
+ }
+ }
+ }
+
+ }
+ else if (msgID == (ULONG)eQMI_NAS_SS_INFO_IND)
+ {
+ // Prepare TLVs for parsing
+ std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiBuf );
+
+ // Parse out roaming indicator
+ sProtocolEntityKey tlvKey1( eDB2_ET_QMI_NAS_IND, msgID, 16 );
+ cDataParser::tParsedFields pf1 = ParseTLV( mDB, buf, tlvs, tlvKey1 );
+ if (pf1.size() >= 1)
+ {
+ if (mpFNRoamingIndicator != 0)
+ {
+ cRoamingIndicatorCallback * pCB = 0;
+ pCB = new cRoamingIndicatorCallback( mpFNRoamingIndicator,
+ pf1[0].mValue.mU32 );
+
+ if (pCB != 0)
+ {
+ if (pCB->Initialize() == false)
+ {
+ delete pCB;
+ }
+ }
+ }
+ }
+
+ // Parse out data capabilities
+ sProtocolEntityKey tlvKey2( eDB2_ET_QMI_NAS_IND, msgID, 17 );
+ cDataParser::tParsedFields pf2 = ParseTLV( mDB, buf, tlvs, tlvKey2 );
+ if (pf2.size() >= 1)
+ {
+ BYTE activeDataCaps = pf2[0].mValue.mU8;
+ if (pf2.size() >= 1 + (ULONG)activeDataCaps)
+ {
+ ULONG caps[12] = { 0 };
+ if (activeDataCaps > 12)
+ {
+ activeDataCaps = 12;
+ }
+
+ for (ULONG d = 0; d < activeDataCaps; d++)
+ {
+ caps[d] = pf2[1 + d].mValue.mU32;
+ }
+
+ if (mpFNDataCapabilities != 0)
+ {
+ cDataCapabilitiesCallback * pCB = 0;
+ pCB = new cDataCapabilitiesCallback( mpFNDataCapabilities,
+ activeDataCaps,
+ &caps[0] );
+
+ if (pCB != 0)
+ {
+ if (pCB->Initialize() == false)
+ {
+ delete pCB;
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (msgID == (ULONG)eQMI_NAS_PLMN_MODE_IND)
+ {
+ // Prepare TLVs for parsing
+ std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiBuf );
+
+ // Parse PLMN mode
+ sProtocolEntityKey tlvKey( eDB2_ET_QMI_NAS_IND, msgID, 16 );
+ cDataParser::tParsedFields pf = ParseTLV( mDB, buf, tlvs, tlvKey );
+ if (pf.size() >= 1)
+ {
+ cPLMNModeCallback * pCB = 0;
+ pCB = new cPLMNModeCallback( mpPLMNMode,
+ (ULONG)pf[0].mValue.mU8 );
+
+ if (pCB != 0)
+ {
+ if (pCB->Initialize() == false)
+ {
+ delete pCB;
+ }
+ }
+ }
+ }
+}
+
+/*===========================================================================
+METHOD:
+ ProcessWMSBuffer (Internal Method)
+
+DESCRIPTION:
+ Process a WDS buffer
+
+PARAMETERS:
+ buf [ I ] - QMI buffer to process
+
+RETURN VALUE:
+ None
+===========================================================================*/
+void cGobiConnectionMgmt::ProcessWMSBuffer( const sProtocolBuffer & buf )
+{
+ sQMIServiceBuffer qmiBuf( buf.GetSharedBuffer() );
+ if (qmiBuf.IsValid() == false)
+ {
+ return;
+ }
+
+ // Indication?
+ if (qmiBuf.IsIndication() == false)
+ {
+ return;
+ }
+
+ // Do we even care?
+ ULONG msgID = qmiBuf.GetMessageID();
+ if (msgID == (ULONG)eQMI_WMS_EVENT_IND)
+ {
+ // Prepare TLVs for parsing
+ std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiBuf );
+
+ // Parse out message details
+ sProtocolEntityKey tlvKey( eDB2_ET_QMI_WMS_IND, msgID, 16 );
+ cDataParser::tParsedFields pf = ParseTLV( mDB, buf, tlvs, tlvKey );
+ if (pf.size() >= 2)
+ {
+ if (mpFNNewSMS != 0)
+ {
+ cNewSMSCallback * pCB = 0;
+ pCB = new cNewSMSCallback( mpFNNewSMS,
+ pf[0].mValue.mU32,
+ pf[1].mValue.mU32 );
+
+ if (pCB != 0)
+ {
+ if (pCB->Initialize() == false)
+ {
+ delete pCB;
+ }
+ }
+ }
+ }
+ }
+}
+
+/*===========================================================================
+METHOD:
+ ProcessPDSBuffer (Internal Method)
+
+DESCRIPTION:
+ Process a PDS buffer
+
+PARAMETERS:
+ buf [ I ] - QMI buffer to process
+
+RETURN VALUE:
+ None
+===========================================================================*/
+void cGobiConnectionMgmt::ProcessPDSBuffer( const sProtocolBuffer & buf )
+{
+ sQMIServiceBuffer qmiBuf( buf.GetSharedBuffer() );
+ if (qmiBuf.IsValid() == false)
+ {
+ return;
+ }
+
+ // Indication?
+ if (qmiBuf.IsIndication() == false)
+ {
+ return;
+ }
+
+ // Do we even care?
+ ULONG msgID = qmiBuf.GetMessageID();
+ if (msgID == (ULONG)eQMI_PDS_EVENT_IND)
+ {
+ // Prepare TLVs for extraction
+ std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiBuf );
+
+ sProtocolEntityKey tlvKey( eDB2_ET_QMI_PDS_IND, msgID, 16 );
+ cDataParser::tParsedFields pf = ParseTLV( mDB, buf, tlvs, tlvKey );
+ if (pf.size() >= 1 && mpFNNewNMEA != 0)
+ {
+ cNewNMEACallback * pCB = 0;
+ pCB = new cNewNMEACallback( mpFNNewNMEA, pf[0].mValueString );
+ if (pCB != 0)
+ {
+ if (pCB->Initialize() == false)
+ {
+ delete pCB;
+ }
+ }
+ }
+ }
+ else if (msgID == (ULONG)eQMI_PDS_STATE_IND)
+ {
+ // Prepare TLVs for extraction
+ std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiBuf );
+
+ // Parse out message details
+ sProtocolEntityKey tlvKey( eDB2_ET_QMI_PDS_IND, msgID, 1 );
+ cDataParser::tParsedFields pf = ParseTLV( mDB, buf, tlvs, tlvKey );
+ if (pf.size() >= 2 && mpFNPDSState != 0)
+ {
+ cPDSStateCallback * pCB = 0;
+ pCB = new cPDSStateCallback( mpFNPDSState,
+ pf[0].mValue.mU32,
+ pf[1].mValue.mU32 );
+
+ if (pCB != 0)
+ {
+ if (pCB->Initialize() == false)
+ {
+ delete pCB;
+ }
+ }
+ }
+ }
+}
+
+/*===========================================================================
+METHOD:
+ ProcessCATBuffer (Internal Method)
+
+DESCRIPTION:
+ Process a CAT buffer
+
+PARAMETERS:
+ buf [ I ] - QMI buffer to process
+
+RETURN VALUE:
+ None
+===========================================================================*/
+void cGobiConnectionMgmt::ProcessCATBuffer( const sProtocolBuffer & buf )
+{
+ sQMIServiceBuffer qmiBuf( buf.GetSharedBuffer() );
+ if (qmiBuf.IsValid() == false)
+ {
+ return;
+ }
+
+ // Indication?
+ if (qmiBuf.IsIndication() == false)
+ {
+ return;
+ }
+
+ // Do we even care?
+ ULONG msgID = qmiBuf.GetMessageID();
+ if (msgID == (ULONG)eQMI_CAT_EVENT_IND && mpFNCATEvent != 0)
+ {
+ // Prepare TLVs for extraction
+ std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiBuf );
+
+ ULONG tlvCount = (ULONG)tlvs.size();
+ for (ULONG t = 0; t < tlvCount; t++)
+ {
+ const sDB2NavInput tlv = tlvs[t];
+ if (tlv.mKey.size() == 3)
+ {
+ cCATEventCallback * pCB = 0;
+ pCB = new cCATEventCallback( mpFNCATEvent,
+ tlv.mKey[2],
+ tlv.mPayloadLen,
+ tlv.mpPayload );
+
+ if (pCB != 0)
+ {
+ if (pCB->Initialize() == false)
+ {
+ delete pCB;
+ }
+ }
+ }
+ }
+ }
+}
+
+/*===========================================================================
+METHOD:
+ ProcessOMABuffer (Internal Method)
+
+DESCRIPTION:
+ Process an OMA buffer
+
+PARAMETERS:
+ buf [ I ] - QMI buffer to process
+
+RETURN VALUE:
+ None
+===========================================================================*/
+void cGobiConnectionMgmt::ProcessOMABuffer( const sProtocolBuffer & buf )
+{
+ sQMIServiceBuffer qmiBuf( buf.GetSharedBuffer() );
+ if (qmiBuf.IsValid() == false)
+ {
+ return;
+ }
+
+ // Indication?
+ if (qmiBuf.IsIndication() == false)
+ {
+ return;
+ }
+
+ // Do we even care?
+ ULONG msgID = qmiBuf.GetMessageID();
+ if (msgID == (ULONG)eQMI_OMA_EVENT_IND)
+ {
+ // Prepare TLVs for parsing
+ std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiBuf );
+
+ // Parse out NIA
+ sProtocolEntityKey tlvKey( eDB2_ET_QMI_OMA_IND, msgID, 16 );
+ cDataParser::tParsedFields pf = ParseTLV( mDB, buf, tlvs, tlvKey );
+ if (pf.size() >= 2)
+ {
+ if (mpFNOMADMAlert != 0)
+ {
+ cOMADMAlertCallback * pCB = 0;
+ pCB = new cOMADMAlertCallback( mpFNOMADMAlert,
+ pf[0].mValue.mU32,
+ pf[1].mValue.mU16 );
+
+ if (pCB != 0)
+ {
+ if (pCB->Initialize() == false)
+ {
+ delete pCB;
+ }
+ }
+ }
+ }
+
+ // Parse out failure reason (may not be present)
+ ULONG failureReason = ULONG_MAX;
+ tlvKey = sProtocolEntityKey( eDB2_ET_QMI_OMA_IND, msgID, 18 );
+ pf = ParseTLV( mDB, buf, tlvs, tlvKey );
+ if (pf.size() >= 1)
+ {
+ failureReason = pf[0].mValue.mU32;
+ }
+
+ // Parse out state
+ tlvKey = sProtocolEntityKey( eDB2_ET_QMI_OMA_IND, msgID, 17 );
+ pf = ParseTLV( mDB, buf, tlvs, tlvKey );
+ if (pf.size() >= 1)
+ {
+ if (mpFNOMADMState != 0)
+ {
+ cOMADMStateCallback * pCB = 0;
+ pCB = new cOMADMStateCallback( mpFNOMADMState,
+ pf[0].mValue.mU32,
+ failureReason );
+
+ if (pCB != 0)
+ {
+ if (pCB->Initialize() == false)
+ {
+ delete pCB;
+ }
+ }
+ }
+ }
+ }
+}
+
+/*===========================================================================
+METHOD:
+ ProcessVoiceBuffer (Internal Method)
+
+DESCRIPTION:
+ Process a voice buffer
+
+PARAMETERS:
+ buf [ I ] - QMI buffer to process
+
+RETURN VALUE:
+ None
+===========================================================================*/
+void cGobiConnectionMgmt::ProcessVoiceBuffer( const sProtocolBuffer & buf )
+{
+ sQMIServiceBuffer qmiBuf( buf.GetSharedBuffer() );
+ if (qmiBuf.IsValid() == false)
+ {
+ return;
+ }
+
+ // Indication?
+ if (qmiBuf.IsIndication() == false)
+ {
+ return;
+ }
+
+ // Do we even care?
+ ULONG msgID = qmiBuf.GetMessageID();
+ if (msgID == (ULONG)eQMI_VOICE_USSD_RELEASE_IND && mpFNUSSDRelease != 0)
+ {
+ cUSSDReleaseCallback * pCB = 0;
+ pCB = new cUSSDReleaseCallback( mpFNUSSDRelease );
+ if (pCB != 0)
+ {
+ if (pCB->Initialize() == false)
+ {
+ delete pCB;
+ }
+ }
+
+ }
+ else if (msgID == (ULONG)eQMI_VOICE_USSD_IND && mpFNUSSDNotification != 0)
+ {
+ // Prepare TLVs for extraction
+ std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiBuf );
+ std::map <ULONG, const sQMIRawContentHeader *> tlvMap;
+ tlvMap = qmiBuf.GetContents();
+
+ // Parse out message details
+ sProtocolEntityKey tlvKey( eDB2_ET_QMI_VOICE_IND, msgID, 1 );
+ cDataParser::tParsedFields pf = ParseTLV( mDB, buf, tlvs, tlvKey );
+ if (pf.size() >= 1)
+ {
+ const BYTE * pUSSData = 0;
+
+ std::map <ULONG, const sQMIRawContentHeader *>::const_iterator pIter;
+ pIter = tlvMap.find( 16 );
+ if (pIter != tlvMap.end())
+ {
+ const sQMIRawContentHeader * pHdr = pIter->second;
+ ULONG len = (ULONG)pHdr->mLength;
+ if (len >= (ULONG)2)
+ {
+ const BYTE * pData = (const BYTE *)++pHdr;
+ if (len >= (ULONG)pData[1] + (ULONG)2)
+ {
+ pUSSData = pData;
+ }
+ }
+ }
+
+ cUSSDNotificationCallback * pCB = 0;
+ pCB = new cUSSDNotificationCallback( mpFNUSSDNotification,
+ pf[0].mValue.mU32,
+ pUSSData );
+
+ if (pCB != 0)
+ {
+ if (pCB->Initialize() == false)
+ {
+ delete pCB;
+ }
+ }
+ }
+ }
+ else if ( (msgID == (ULONG)eQMI_VOICE_ASYNC_USSD_IND)
+ && (mpFNUSSDOrigination != 0) )
+ {
+ // Prepare TLVs for extraction
+ std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiBuf );
+ std::map <ULONG, const sQMIRawContentHeader *> tlvMap;
+ tlvMap = qmiBuf.GetContents();
+
+ ULONG ec = ULONG_MAX;
+ ULONG fc = ULONG_MAX;
+
+ // Parse out message details
+ sProtocolEntityKey tlvKey( eDB2_ET_QMI_VOICE_IND, msgID, 16 );
+ cDataParser::tParsedFields pf = ParseTLV( mDB, buf, tlvs, tlvKey );
+ if (pf.size() >= 1)
+ {
+ ec = pf[0].mValue.mU32;
+ }
+
+ tlvKey = sProtocolEntityKey( eDB2_ET_QMI_VOICE_IND, msgID, 17 );
+ pf = ParseTLV( mDB, buf, tlvs, tlvKey );
+ if (pf.size() >= 1)
+ {
+ fc = pf[0].mValue.mU32;
+ }
+
+ const BYTE * pNetworkInfo = 0;
+
+ std::map <ULONG, const sQMIRawContentHeader *>::const_iterator pIter;
+ pIter = tlvMap.find( 18 );
+ if (pIter != tlvMap.end())
+ {
+ const sQMIRawContentHeader * pHdr = pIter->second;
+ ULONG len = (ULONG)pHdr->mLength;
+ if (len >= (ULONG)2)
+ {
+ const BYTE * pData = (const BYTE *)++pHdr;
+ if (len >= (ULONG)pData[1] + (ULONG)2)
+ {
+ pNetworkInfo = pData;
+ }
+ }
+ }
+
+ const BYTE * pAlpha = 0;
+
+ pIter = tlvMap.find( 19 );
+ if (pIter != tlvMap.end())
+ {
+ const sQMIRawContentHeader * pHdr = pIter->second;
+ ULONG len = (ULONG)pHdr->mLength;
+ if (len >= (ULONG)2)
+ {
+ const BYTE * pData = (const BYTE *)++pHdr;
+ if (len >= (ULONG)pData[1] + (ULONG)2)
+ {
+ pAlpha = pData;
+ }
+ }
+ }
+
+
+ cUSSDOriginationCallback * pCB = 0;
+ pCB = new cUSSDOriginationCallback( mpFNUSSDOrigination,
+ ec,
+ fc,
+ pNetworkInfo,
+ pAlpha );
+
+ if (pCB != 0)
+ {
+ if (pCB->Initialize() == false)
+ {
+ delete pCB;
+ }
+ }
+ }
+}
+
+/*===========================================================================
+METHOD:
+ Connect (Public Method)
+
+DESCRIPTION:
+ Connect to the specified (or first detected) Gobi device
+
+PARAMETERS:
+ pDeviceNode [ I ] - The device node
+ pDeviceKey [ I ] - The device key (unique, stored on-device)
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cGobiConnectionMgmt::Connect(
+ LPCSTR pDeviceNode,
+ LPCSTR pDeviceKey )
+{
+ // Assume failure
+ bool bRC = cGobiQMICore::Connect( pDeviceNode, pDeviceKey );
+ if (bRC == true)
+ {
+ // Clear mExitEvent;
+ mExitEvent.Clear();
+
+ pthread_create( &mThreadID,
+ NULL,
+ TrafficProcessThread,
+ this );
+
+ mbThreadStarted = true;
+ }
+
+ return bRC;
+}
+
+/*===========================================================================
+METHOD:
+ Disconnect (Public Method)
+
+DESCRIPTION:
+ Disconnect from the currently connected Gobi device
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cGobiConnectionMgmt::Disconnect()
+{
+ // Clear all callback function pointers (no need to turn them off at
+ // the device as we are about to tear-down each QMI service client)
+ mpFNSessionState = 0;
+ mpFNByteTotals = 0;
+ mpFNDataCapabilities = 0;
+ mpFNDataBearer = 0;
+ mpFNDormancyStatus = 0;
+ mpFNMobileIPStatus = 0;
+ mpFNActivationStatus = 0;
+ mpFNPower = 0;
+ mpFNWirelessDisable = 0;
+ mpFNRoamingIndicator = 0;
+ mpFNSignalStrength = 0;
+ mpFNRFInfo = 0;
+ mpFNLUReject = 0;
+ mpPLMNMode = 0;
+ mpFNNewSMS = 0;
+ mpFNNewNMEA = 0;
+ mpFNPDSState = 0;
+ mpFNCATEvent = 0;
+ mpFNOMADMAlert = 0;
+ mpFNOMADMState = 0;
+ mpFNUSSDRelease = 0;
+ mpFNUSSDNotification = 0;
+ mpFNUSSDOrigination = 0;
+
+ // Exit traffic processing thread
+ if (mbThreadStarted == true)
+ {
+ // Signal thread to exit
+ mExitEvent.Set( 0 );
+
+ // If we are not being called from the thread itself then wait for
+ // it to exit, if not then it will have to exit automatically
+ if (pthread_self() != mThreadID)
+ {
+ if (mThreadID != 0)
+ {
+ pthread_join( mThreadID, NULL );
+ }
+ }
+ }
+
+ // Clear out thread handle/ID
+ mbThreadStarted = false;
+ mThreadID = 0;
+
+ bool bRC = cGobiQMICore::Disconnect();
+
+ // Servers reset server logs so we need to reset our counters
+ mWDSItemsProcessed = 0;
+ mDMSItemsProcessed = 0;
+ mNASItemsProcessed = 0;
+ mWMSItemsProcessed = 0;
+ mPDSItemsProcessed = 0;
+ mCATItemsProcessed = 0;
+ mOMAItemsProcessed = 0;
+ mVoiceItemsProcessed = 0;
+
+ return bRC;
+}
+
+/*===========================================================================
+METHOD:
+ SetSessionStateCallback (Public Method)
+
+DESCRIPTION:
+ Enable/disable session state callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiConnectionMgmt::SetSessionStateCallback(
+ tFNSessionState pCallback )
+{
+ // We don't have to register for anything so a simple assignment works
+ mpFNSessionState = pCallback;
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ SetByteTotalsCallback
+
+DESCRIPTION:
+ This function enables/disables the RX/TX byte counts callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+ interval [ I ] - Interval in seconds (ignored when disabling)
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiConnectionMgmt::SetByteTotalsCallback(
+ tFNByteTotals pCallback,
+ BYTE interval )
+{
+ // Assume failure
+ eGobiError rc = eGOBI_ERR_GENERAL;
+
+ // Something changing?
+ bool bOn = (pCallback != 0 && mpFNByteTotals == 0);
+ bool bOff = (pCallback == 0 && mpFNByteTotals != 0);
+ bool bReplace = (pCallback != 0 && mpFNByteTotals != 0);
+ if (bOn == true || bOff == true)
+ {
+ // Turning on/off
+ eQMIService svc = eQMI_SVC_WDS;
+ WORD msgID = (WORD)eQMI_WDS_SET_EVENT;
+ sSharedBuffer * pReq = 0;
+
+ std::vector <sDB2PackingInput> piv;
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 17 );
+
+ if (bOn == true)
+ {
+ std::ostringstream tmp;
+ tmp << (ULONG)interval << " 0 0 0 0 0 0 1 1";
+ sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
+ piv.push_back( pi );
+ }
+ else
+ {
+ sDB2PackingInput pi( pek, "0 0 0 0 0 0 0 0 0" );
+ piv.push_back( pi );
+ }
+
+ pReq = DB2PackQMIBuffer( mDB, piv );
+
+ rc = SendAndCheckReturn( svc, pReq );
+ if (rc == eGOBI_ERR_NONE || bOff == true)
+ {
+ mpFNByteTotals = pCallback;
+ }
+ }
+ else if (bReplace == true)
+ {
+ // We don't have to register for anything so a simple assignment works
+ mpFNByteTotals = pCallback;
+ rc = eGOBI_ERR_NONE;
+ }
+ else
+ {
+ // Turning it off redundantly
+ rc = eGOBI_ERR_NONE;
+ }
+
+ return rc;
+}
+
+/*===========================================================================
+METHOD:
+ SetDataCapabilitiesCallback (Public Method)
+
+DESCRIPTION:
+ Enables/disables the serving system data capabilities callback
+
+PARAMETERS:
+ pCallback [ I ] - Callback function
+
+RETURN VALUE:
+ eGobiError - Corrected error code
+===========================================================================*/
+eGobiError cGobiConnectionMgmt::SetDataCapabilitiesCallback(
+ tFNDataCapabilities pCallback )
+{
+ // We don't have to register for anything so a simple assignment works
+ mpFNDataCapabilities = pCallback;
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ SetDataBearerCallback (Public Method)
+
+DESCRIPTION:
+ Enable/disable data bearer callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function
+
+RETURN VALUE:
+ eGobiError - Return cod
+===========================================================================*/
+eGobiError cGobiConnectionMgmt::SetDataBearerCallback(
+ tFNDataBearer pCallback )
+{
+ // Assume failure
+ eGobiError rc = eGOBI_ERR_GENERAL;
+
+ // Something changing?
+ bool bOn = (pCallback != 0 && mpFNDataBearer == 0);
+ bool bOff = (pCallback == 0 && mpFNDataBearer != 0);
+ bool bReplace = (pCallback != 0 && mpFNDataBearer != 0);
+ if (bOn == true || bOff == true)
+ {
+ // Turning on/off
+ eQMIService svc = eQMI_SVC_WDS;
+ WORD msgID = (WORD)eQMI_WDS_SET_EVENT;
+ sSharedBuffer * pReq = 0;
+
+ std::vector <sDB2PackingInput> piv;
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 18 );
+
+ if (bOn == true)
+ {
+ sDB2PackingInput pi( pek, "1" );
+ piv.push_back( pi );
+ }
+ else
+ {
+ sDB2PackingInput pi( pek, "0" );
+ piv.push_back( pi );
+ }
+
+ pReq = DB2PackQMIBuffer( mDB, piv );
+
+ rc = SendAndCheckReturn( svc, pReq );
+ if (rc == eGOBI_ERR_NONE || bOff == true)
+ {
+ mpFNDataBearer = pCallback;
+ }
+ }
+ else if (bReplace == true)
+ {
+ // We don't have to register for anything so a simple assignment works
+ mpFNDataBearer = pCallback;
+ rc = eGOBI_ERR_NONE;
+ }
+ else
+ {
+ // Turning it off redundantly
+ rc = eGOBI_ERR_NONE;
+ }
+
+ return rc;
+}
+
+/*===========================================================================
+METHOD:
+ SetDormancyStatusCallback (Public Method)
+
+DESCRIPTION:
+ Enable/disable dormancy status callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiConnectionMgmt::SetDormancyStatusCallback(
+ tFNDormancyStatus pCallback )
+{
+ // Assume failure
+ eGobiError rc = eGOBI_ERR_GENERAL;
+
+ // Something changing?
+ bool bOn = (pCallback != 0 && mpFNDormancyStatus == 0);
+ bool bOff = (pCallback == 0 && mpFNDormancyStatus != 0);
+ bool bReplace = (pCallback != 0 && mpFNDormancyStatus != 0);
+ if (bOn == true || bOff == true)
+ {
+ // Turning on/off
+ eQMIService svc = eQMI_SVC_WDS;
+ WORD msgID = (WORD)eQMI_WDS_SET_EVENT;
+ sSharedBuffer * pReq = 0;
+
+ std::vector <sDB2PackingInput> piv;
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 19 );
+
+ if (bOn == true)
+ {
+ sDB2PackingInput pi( pek, "1" );
+ piv.push_back( pi );
+ }
+ else
+ {
+ sDB2PackingInput pi( pek, "0" );
+ piv.push_back( pi );
+ }
+
+ pReq = DB2PackQMIBuffer( mDB, piv );
+
+ rc = SendAndCheckReturn( svc, pReq );
+ if (rc == eGOBI_ERR_NONE || bOff == true)
+ {
+ mpFNDormancyStatus = pCallback;
+ }
+ }
+ else if (bReplace == true)
+ {
+ // We don't have to register for anything so a simple assignment works
+ mpFNDormancyStatus = pCallback;
+ rc = eGOBI_ERR_NONE;
+ }
+ else
+ {
+ // Turning it off redundantly
+ rc = eGOBI_ERR_NONE;
+ }
+
+ return rc;
+}
+
+/*===========================================================================
+METHOD:
+ SetMobileIPStatusCallback (Public Method)
+
+DESCRIPTION:
+ Enable/disable mobile IP status callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiConnectionMgmt::SetMobileIPStatusCallback(
+ tFNMobileIPStatus pCallback )
+{
+ // Assume failure
+ eGobiError rc = eGOBI_ERR_GENERAL;
+
+ // Something changing?
+ bool bOn = (pCallback != 0 && mpFNMobileIPStatus == 0);
+ bool bOff = (pCallback == 0 && mpFNMobileIPStatus != 0);
+ bool bReplace = (pCallback != 0 && mpFNMobileIPStatus != 0);
+ if (bOn == true || bOff == true)
+ {
+ // Turning on/off
+ eQMIService svc = eQMI_SVC_WDS;
+ WORD msgID = (WORD)eQMI_WDS_SET_EVENT;
+ sSharedBuffer * pReq = 0;
+
+ std::vector <sDB2PackingInput> piv;
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 20 );
+
+ if (bOn == true)
+ {
+ sDB2PackingInput pi( pek, "1" );
+ piv.push_back( pi );
+ }
+ else
+ {
+ sDB2PackingInput pi( pek, "0" );
+ piv.push_back( pi );
+ }
+
+ pReq = DB2PackQMIBuffer( mDB, piv );
+
+ rc = SendAndCheckReturn( svc, pReq );
+ if (rc == eGOBI_ERR_NONE || bOff == true)
+ {
+ mpFNMobileIPStatus = pCallback;
+ }
+ }
+ else if (bReplace == true)
+ {
+ // We don't have to register for anything so a simple assignment works
+ mpFNMobileIPStatus = pCallback;
+ rc = eGOBI_ERR_NONE;
+ }
+ else
+ {
+ // Turning it off redundantly
+ rc = eGOBI_ERR_NONE;
+ }
+
+ return rc;
+}
+
+/*===========================================================================
+METHOD:
+ SetActivationStatusCallback (Public Method)
+
+DESCRIPTION:
+ Enable/disable activation status callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiConnectionMgmt::SetActivationStatusCallback(
+ tFNActivationStatus pCallback )
+{
+ // Assume failure
+ eGobiError rc = eGOBI_ERR_GENERAL;
+
+ // Something changing?
+ bool bOn = (pCallback != 0 && mpFNActivationStatus == 0);
+ bool bOff = (pCallback == 0 && mpFNActivationStatus != 0);
+ bool bReplace = (pCallback != 0 && mpFNActivationStatus != 0);
+ if (bOn == true || bOff == true)
+ {
+ // Turning on/off
+ eQMIService svc = eQMI_SVC_DMS;
+ WORD msgID = (WORD)eQMI_DMS_SET_EVENT;
+ sSharedBuffer * pReq = 0;
+
+ std::vector <sDB2PackingInput> piv;
+ sProtocolEntityKey pek( eDB2_ET_QMI_DMS_REQ, msgID, 19 );
+
+ if (bOn == true)
+ {
+ sDB2PackingInput pi( pek, "1" );
+ piv.push_back( pi );
+ }
+ else
+ {
+ sDB2PackingInput pi( pek, "0" );
+ piv.push_back( pi );
+ }
+
+ pReq = DB2PackQMIBuffer( mDB, piv );
+
+ rc = SendAndCheckReturn( svc, pReq );
+ if (rc == eGOBI_ERR_NONE || bOff == true)
+ {
+ mpFNActivationStatus = pCallback;
+ }
+ }
+ else if (bReplace == true)
+ {
+ // We don't have to register for anything so a simple assignment works
+ mpFNActivationStatus = pCallback;
+ rc = eGOBI_ERR_NONE;
+ }
+ else
+ {
+ // Turning it off redundantly
+ rc = eGOBI_ERR_NONE;
+ }
+
+ return rc;
+}
+
+/*===========================================================================
+METHOD:
+ SetPowerCallback (Public Method)
+
+DESCRIPTION:
+ Enable/disable power operating mode callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiConnectionMgmt::SetPowerCallback(
+ tFNPower pCallback )
+{
+ // Assume failure
+ eGobiError rc = eGOBI_ERR_GENERAL;
+
+ // Something changing?
+ bool bOn = (pCallback != 0 && mpFNPower == 0);
+ bool bOff = (pCallback == 0 && mpFNPower != 0);
+ bool bReplace = (pCallback != 0 && mpFNPower != 0);
+ if (bOn == true || bOff == true)
+ {
+ // Turning on/off
+ eQMIService svc = eQMI_SVC_DMS;
+ WORD msgID = (WORD)eQMI_DMS_SET_EVENT;
+ sSharedBuffer * pReq = 0;
+
+ std::vector <sDB2PackingInput> piv;
+ sProtocolEntityKey pek( eDB2_ET_QMI_DMS_REQ, msgID, 20 );
+
+ if (bOn == true)
+ {
+ sDB2PackingInput pi( pek, "1" );
+ piv.push_back( pi );
+ }
+ else
+ {
+ sDB2PackingInput pi( pek, "0" );
+ piv.push_back( pi );
+ }
+
+ pReq = DB2PackQMIBuffer( mDB, piv );
+
+ rc = SendAndCheckReturn( svc, pReq );
+ if (rc == eGOBI_ERR_NONE || bOff == true)
+ {
+ mpFNPower = pCallback;
+ }
+ }
+ else if (bReplace == true)
+ {
+ // We don't have to register for anything so a simple assignment works
+ mpFNPower = pCallback;
+ rc = eGOBI_ERR_NONE;
+ }
+ else
+ {
+ // Turning it off redundantly
+ rc = eGOBI_ERR_NONE;
+ }
+
+ return rc;
+}
+
+/*===========================================================================
+METHOD:
+ SetWirelessDisableCallback (Public Method)
+
+DESCRIPTION:
+ Enable/disable wireless disable state callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiConnectionMgmt::SetWirelessDisableCallback(
+ tFNWirelessDisable pCallback )
+{
+ // Assume failure
+ eGobiError rc = eGOBI_ERR_GENERAL;
+
+ // Something changing?
+ bool bOn = (pCallback != 0 && mpFNWirelessDisable == 0);
+ bool bOff = (pCallback == 0 && mpFNWirelessDisable != 0);
+ bool bReplace = (pCallback != 0 && mpFNWirelessDisable != 0);
+ if (bOn == true || bOff == true)
+ {
+ // Turning on/off
+ eQMIService svc = eQMI_SVC_DMS;
+ WORD msgID = (WORD)eQMI_DMS_SET_EVENT;
+ sSharedBuffer * pReq = 0;
+
+ std::vector <sDB2PackingInput> piv;
+ sProtocolEntityKey pek( eDB2_ET_QMI_DMS_REQ, msgID, 22 );
+
+ if (bOn == true)
+ {
+ sDB2PackingInput pi( pek, "1" );
+ piv.push_back( pi );
+ }
+ else
+ {
+ sDB2PackingInput pi( pek, "0" );
+ piv.push_back( pi );
+ }
+
+ pReq = DB2PackQMIBuffer( mDB, piv );
+
+ rc = SendAndCheckReturn( svc, pReq );
+ if (rc == eGOBI_ERR_NONE || bOff == true)
+ {
+ mpFNWirelessDisable = pCallback;
+ }
+ }
+ else if (bReplace == true)
+ {
+ // We don't have to register for anything so a simple assignment works
+ mpFNWirelessDisable = pCallback;
+ rc = eGOBI_ERR_NONE;
+ }
+ else
+ {
+ // Turning it off redundantly
+ rc = eGOBI_ERR_NONE;
+ }
+
+ return rc;
+}
+
+/*===========================================================================
+METHOD:
+ SetRoamingIndicatorCallback (Public Method)
+
+DESCRIPTION:
+ Enable/disable roaming indicator callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function
+
+RETURN VALUE:
+ eGobiError - Corrected error code
+===========================================================================*/
+eGobiError cGobiConnectionMgmt::SetRoamingIndicatorCallback(
+ tFNRoamingIndicator pCallback )
+{
+ // We don't have to register for anything so a simple assignment works
+ mpFNRoamingIndicator = pCallback;
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ SetSignalStrengthCallback (Public Method)
+
+DESCRIPTION:
+ Enable/disable signal strength callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function
+ thresholds [ I ] - Desired threholds (only valid when enabling)
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiConnectionMgmt::SetSignalStrengthCallback(
+ tFNSignalStrength pCallback,
+ std::list <INT8> thresholds )
+{
+ // Assume failure
+ eGobiError rc = eGOBI_ERR_GENERAL;
+
+ // Grab number of thresholds
+ ULONG thresholdCount = (ULONG)thresholds.size();
+
+ // Validate arguments versus what is changing
+ bool bOn = (pCallback != 0 && mpFNSignalStrength == 0);
+ if (bOn == true && thresholdCount == 0)
+ {
+ rc = eGOBI_ERR_INVALID_ARG;
+ return rc;
+ }
+
+ bool bOff = (pCallback == 0 && mpFNSignalStrength != 0);
+ if (bOff == true && thresholdCount != 0)
+ {
+ rc = eGOBI_ERR_INVALID_ARG;
+ return rc;
+ }
+
+ bool bReplace = (pCallback != 0 && mpFNSignalStrength != 0);
+ if (bReplace == true && thresholdCount == 0)
+ {
+ rc = eGOBI_ERR_INVALID_ARG;
+ return rc;
+ }
+
+ eQMIService svc = eQMI_SVC_NAS;
+ WORD msgID = (WORD)eQMI_NAS_SET_EVENT;
+ sSharedBuffer * pReq = 0;
+
+ std::vector <sDB2PackingInput> piv;
+ sProtocolEntityKey pek( eDB2_ET_QMI_NAS_REQ, msgID, 16 );
+
+ if (bOn == true || bOff == true || bReplace == true)
+ {
+ if (bOn == true || bReplace == true)
+ {
+ std::ostringstream args;
+ args << "1 " << (UINT)thresholdCount;
+
+ std::list <INT8>::const_iterator pThreshold = thresholds.begin();
+ while (pThreshold != thresholds.end())
+ {
+ INT8 t = *pThreshold++;
+
+ args << " " << (INT)t;
+ }
+
+ sDB2PackingInput pi( pek, (LPCSTR)args.str().c_str() );
+ piv.push_back( pi );
+ }
+ else
+ {
+ sDB2PackingInput pi( pek, "0 0" );
+ piv.push_back( pi );
+ }
+
+ pReq = DB2PackQMIBuffer( mDB, piv );
+
+ rc = SendAndCheckReturn( svc, pReq );
+ if (rc == eGOBI_ERR_NONE || bOff == true || bReplace == true)
+ {
+ mpFNSignalStrength = pCallback;
+ }
+ }
+ else
+ {
+ // Turning it off redundantly
+ if (thresholdCount != 0)
+ {
+ rc = eGOBI_ERR_INVALID_ARG;
+ }
+ else
+ {
+ rc = eGOBI_ERR_NONE;
+ }
+ }
+
+ return rc;
+}
+
+/*===========================================================================
+METHOD:
+ SetRFInfoCallback (Public Method)
+
+DESCRIPTION:
+ Enable/disable RF information callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiConnectionMgmt::SetRFInfoCallback( tFNRFInfo pCallback )
+{
+ // Assume failure
+ eGobiError rc = eGOBI_ERR_GENERAL;
+
+ // Validate arguments versus what is changing
+ bool bOn = (pCallback != 0 && mpFNRFInfo == 0);
+ bool bOff = (pCallback == 0 && mpFNRFInfo != 0);
+ bool bReplace = (pCallback != 0 && mpFNRFInfo != 0);
+ if (bOn == true || bOff == true)
+ {
+ // Turning on/off
+ eQMIService svc = eQMI_SVC_NAS;
+ WORD msgID = (WORD)eQMI_NAS_SET_EVENT;
+ sSharedBuffer * pReq = 0;
+
+ std::vector <sDB2PackingInput> piv;
+ sProtocolEntityKey pek( eDB2_ET_QMI_NAS_REQ, msgID, 17 );
+
+ if (bOn == true)
+ {
+ sDB2PackingInput pi( pek, "1" );
+ piv.push_back( pi );
+ }
+ else
+ {
+ sDB2PackingInput pi( pek, "0" );
+ piv.push_back( pi );
+ }
+
+ pReq = DB2PackQMIBuffer( mDB, piv );
+
+ rc = SendAndCheckReturn( svc, pReq );
+ if (rc == eGOBI_ERR_NONE || bOff == true)
+ {
+ mpFNRFInfo = pCallback;
+ }
+ }
+ else if (bReplace == true)
+ {
+ // We don't have to register for anything so a simple assignment works
+ mpFNRFInfo = pCallback;
+ rc = eGOBI_ERR_NONE;
+ }
+ else
+ {
+ // Turning it off redundantly
+ rc = eGOBI_ERR_NONE;
+ }
+
+ return rc;
+}
+
+/*===========================================================================
+METHOD:
+ SetLURejectCallback (Public Method)
+
+DESCRIPTION:
+ Enable/disable LU reject callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiConnectionMgmt::SetLURejectCallback( tFNLUReject pCallback )
+{
+ // Assume failure
+ eGobiError rc = eGOBI_ERR_GENERAL;
+
+ // Validate arguments versus what is changing
+ bool bOn = (pCallback != 0 && mpFNLUReject == 0);
+ bool bOff = (pCallback == 0 && mpFNLUReject != 0);
+ bool bReplace = (pCallback != 0 && mpFNLUReject != 0);
+ if (bOn == true || bOff == true)
+ {
+ // Turning on/off
+ eQMIService svc = eQMI_SVC_NAS;
+ WORD msgID = (WORD)eQMI_NAS_SET_EVENT;
+ sSharedBuffer * pReq = 0;
+
+ std::vector <sDB2PackingInput> piv;
+ sProtocolEntityKey pek( eDB2_ET_QMI_NAS_REQ, msgID, 18 );
+
+ if (bOn == true)
+ {
+ sDB2PackingInput pi( pek, "1" );
+ piv.push_back( pi );
+ }
+ else
+ {
+ sDB2PackingInput pi( pek, "0" );
+ piv.push_back( pi );
+ }
+
+ pReq = DB2PackQMIBuffer( mDB, piv );
+
+ rc = SendAndCheckReturn( svc, pReq );
+ if (rc == eGOBI_ERR_NONE || bOff == true)
+ {
+ mpFNLUReject = pCallback;
+ }
+ }
+ else if (bReplace == true)
+ {
+ // We don't have to register for anything so a simple assignment works
+ mpFNLUReject = pCallback;
+ rc = eGOBI_ERR_NONE;
+ }
+ else
+ {
+ // Turning it off redundantly
+ rc = eGOBI_ERR_NONE;
+ }
+
+ return rc;
+}
+
+/*===========================================================================
+METHOD:
+ SetPLMNModeCallback (Public Method)
+
+DESCRIPTION:
+ Enable/disable PLMN mode callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiConnectionMgmt::SetPLMNModeCallback( tFNPLMNMode pCallback )
+{
+ // We don't have to register for anything so a simple assignment works
+ mpPLMNMode = pCallback;
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ SetNewSMSCallback (Public Method)
+
+DESCRIPTION:
+ Enable/disable new SMS callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiConnectionMgmt::SetNewSMSCallback( tFNNewSMS pCallback )
+{
+ // Assume failure
+ eGobiError rc = eGOBI_ERR_GENERAL;
+
+ // Something changing?
+ bool bOn = (pCallback != 0 && mpFNNewSMS == 0);
+ bool bOff = (pCallback == 0 && mpFNNewSMS != 0);
+ bool bReplace = (pCallback != 0 && mpFNNewSMS != 0);
+ if (bOn == true || bOff == true)
+ {
+ // Turning on/off
+ eQMIService svc = eQMI_SVC_WMS;
+ WORD msgID = (WORD)eQMI_WMS_SET_EVENT;
+ sSharedBuffer * pReq = 0;
+
+ std::vector <sDB2PackingInput> piv;
+ sProtocolEntityKey pek( eDB2_ET_QMI_WMS_REQ, msgID, 16 );
+
+ if (bOn == true)
+ {
+ sDB2PackingInput pi( pek, "1" );
+ piv.push_back( pi );
+ }
+ else
+ {
+ sDB2PackingInput pi( pek, "0" );
+ piv.push_back( pi );
+ }
+
+ pReq = DB2PackQMIBuffer( mDB, piv );
+
+ rc = SendAndCheckReturn( svc, pReq );
+ if (rc == eGOBI_ERR_NONE || bOff == true)
+ {
+ mpFNNewSMS = pCallback;
+ }
+ }
+ else if (bReplace == true)
+ {
+ // We don't have to register for anything so a simple assignment works
+ mpFNNewSMS = pCallback;
+ rc = eGOBI_ERR_NONE;
+ }
+ else
+ {
+ // Turning it off redundantly
+ rc = eGOBI_ERR_NONE;
+ }
+
+ return rc;
+}
+
+/*===========================================================================
+METHOD:
+ SetNMEACallback (Public Method)
+
+DESCRIPTION:
+ Enable/disable new NMEA sentence function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiConnectionMgmt::SetNMEACallback( tFNNewNMEA pCallback )
+{
+ // Assume failure
+ eGobiError rc = eGOBI_ERR_GENERAL;
+
+ // Something changing?
+ bool bOn = (pCallback != 0 && mpFNNewNMEA == 0);
+ bool bOff = (pCallback == 0 && mpFNNewNMEA != 0);
+ bool bReplace = (pCallback != 0 && mpFNNewNMEA != 0);
+ if (bOn == true || bOff == true)
+ {
+ // Turning on/off
+ eQMIService svc = eQMI_SVC_PDS;
+ WORD msgID = (WORD)eQMI_PDS_SET_EVENT;
+ sSharedBuffer * pReq = 0;
+
+ std::vector <sDB2PackingInput> piv;
+ sProtocolEntityKey pek( eDB2_ET_QMI_PDS_REQ, msgID, 16 );
+
+ if (bOn == true)
+ {
+ sDB2PackingInput pi( pek, "1" );
+ piv.push_back( pi );
+ }
+ else
+ {
+ sDB2PackingInput pi( pek, "0" );
+ piv.push_back( pi );
+ }
+
+ pReq = DB2PackQMIBuffer( mDB, piv );
+
+ rc = SendAndCheckReturn( svc, pReq );
+ if (rc == eGOBI_ERR_NONE || bOff == true)
+ {
+ mpFNNewNMEA = pCallback;
+ }
+ }
+ else if (bReplace == true)
+ {
+ // We don't have to register for anything so a simple assignment works
+ mpFNNewNMEA = pCallback;
+ rc = eGOBI_ERR_NONE;
+ }
+ else
+ {
+ // Turning it off redundantly
+ rc = eGOBI_ERR_NONE;
+ }
+
+ return rc;
+}
+
+/*===========================================================================
+METHOD:
+ SetPDSStateCallback (Public Method)
+
+DESCRIPTION:
+ Enable/disable PDS service state callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiConnectionMgmt::SetPDSStateCallback( tFNPDSState pCallback )
+{
+ // We don't have to register for anything so a simple assignment works
+ mpFNPDSState = pCallback;
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ SetCATEventCallback (Public Method)
+
+DESCRIPTION:
+ This function enables/disables the CAT event callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+ eventMask [ I ] - Bitmask of CAT events to register for
+ pErrorMask [ O ] - Error bitmask
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiConnectionMgmt::SetCATEventCallback(
+ tFNCATEvent pCallback,
+ ULONG eventMask,
+ ULONG * pErrorMask )
+{
+ // Assume failure
+ eGobiError retCode = eGOBI_ERR_GENERAL;
+ *pErrorMask = ULONG_MAX;
+
+ // Validate arguments versus what is changing
+ bool bOn = (pCallback != 0 && mpFNCATEvent == 0);
+ bool bOff = (pCallback == 0 && mpFNCATEvent != 0);
+ bool bReplace = (pCallback != 0 && mpFNCATEvent != 0);
+ if (bOn == true || bOff == true || bReplace == true)
+ {
+ const ULONG szTLVHdr = (ULONG)sizeof( sQMIRawContentHeader );
+ const ULONG szData = (ULONG)sizeof( ULONG );
+ BYTE buf[szTLVHdr + szData];
+
+ sQMIRawContentHeader * pTLV = (sQMIRawContentHeader *)&buf[0];
+ pTLV->mTypeID = 16;
+ pTLV->mLength = (WORD)szData;
+
+ ULONG * pData = (ULONG *)&buf[szTLVHdr];
+
+ *pData = eventMask;
+
+ if (bOff == true)
+ {
+ // Ignore event mask argument when disabling the callback
+ *pData = 0;
+
+ // We also always clear the callback regardless of the response
+ mpFNCATEvent = pCallback;
+ }
+
+ sSharedBuffer * pReq = 0;
+ pReq = sQMIServiceBuffer::BuildBuffer( eQMI_SVC_CAT,
+ (WORD)eQMI_CAT_SET_EVENT,
+ false,
+ false,
+ &buf[0],
+ szTLVHdr + szData );
+
+ sProtocolBuffer rsp = Send( eQMI_SVC_CAT, pReq );
+ if (rsp.IsValid() == false)
+ {
+ retCode = GetCorrectedLastError();
+ return retCode;
+ }
+
+ // Did we receive a valid QMI response?
+ sQMIServiceBuffer qmiRsp( rsp.GetSharedBuffer() );
+ if (qmiRsp.IsValid() == false)
+ {
+ retCode = eGOBI_ERR_MALFORMED_RSP;
+ return retCode;
+ }
+
+ // Check the mandatory QMI result TLV for success
+ ULONG rc = 0;
+ ULONG ec = 0;
+ bool bResult = qmiRsp.GetResult( rc, ec );
+ if (bResult == false)
+ {
+ retCode = eGOBI_ERR_MALFORMED_RSP;
+ return retCode;
+ }
+ else if (rc != 0)
+ {
+ // Parse out the error mask?
+ if (qmiRsp.GetMessageID() == (ULONG)eQMI_CAT_SET_EVENT)
+ {
+ 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 > 4)
+
+ {
+ pData = (ULONG *)++pHdr;
+ *pErrorMask = *pData;
+ }
+ }
+ }
+
+ retCode = GetCorrectedQMIError( ec );
+ return retCode;
+ }
+
+ // Success!
+ mpFNCATEvent = pCallback;
+ retCode = eGOBI_ERR_NONE;
+ }
+ else
+ {
+ // Turning it off redundantly
+ retCode = eGOBI_ERR_NONE;
+ }
+
+ return retCode;
+}
+
+/*===========================================================================
+METHOD:
+ SetOMADMAlertCallback (Public Method)
+
+DESCRIPTION:
+ This function enables/disables the OMA-DM network initiated alert
+ callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiConnectionMgmt::SetOMADMAlertCallback(
+ tFNOMADMAlert pCallback )
+{
+ // Assume failure
+ eGobiError rc = eGOBI_ERR_GENERAL;
+
+ // Something changing?
+ bool bOn = (pCallback != 0 && mpFNOMADMAlert == 0);
+ bool bOff = (pCallback == 0 && mpFNOMADMAlert != 0);
+ bool bReplace = (pCallback != 0 && mpFNOMADMAlert != 0);
+ if (bOn == true || bOff == true)
+ {
+ // Turning on/off
+ eQMIService svc = eQMI_SVC_OMA;
+ WORD msgID = (WORD)eQMI_OMA_SET_EVENT;
+ sSharedBuffer * pReq = 0;
+
+ std::vector <sDB2PackingInput> piv;
+ sProtocolEntityKey pek( eDB2_ET_QMI_OMA_REQ, msgID, 16 );
+
+ if (bOn == true)
+ {
+ sDB2PackingInput pi( pek, "1" );
+ piv.push_back( pi );
+ }
+ else
+ {
+ sDB2PackingInput pi( pek, "0" );
+ piv.push_back( pi );
+ }
+
+ pReq = DB2PackQMIBuffer( mDB, piv );
+
+ rc = SendAndCheckReturn( svc, pReq );
+ if (rc == eGOBI_ERR_NONE || bOff == true)
+ {
+ mpFNOMADMAlert = pCallback;
+ }
+ }
+ else if (bReplace == true)
+ {
+ // We don't have to register for anything so a simple assignment works
+ mpFNOMADMAlert = pCallback;
+ rc = eGOBI_ERR_NONE;
+ }
+ else
+ {
+ // Turning it off redundantly
+ rc = eGOBI_ERR_NONE;
+ }
+
+ return rc;
+}
+
+/*===========================================================================
+METHOD:
+ SetOMADMStateCallback (Public Method)
+
+DESCRIPTION:
+ This function enables/disables the OMA-DM state callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiConnectionMgmt::SetOMADMStateCallback( tFNOMADMState pCallback )
+{
+ // Assume failure
+ eGobiError rc = eGOBI_ERR_GENERAL;
+
+ // Something changing?
+ bool bOn = (pCallback != 0 && mpFNOMADMState == 0);
+ bool bOff = (pCallback == 0 && mpFNOMADMState != 0);
+ bool bReplace = (pCallback != 0 && mpFNOMADMState != 0);
+ if (bOn == true || bOff == true)
+ {
+ // Turning on/off
+ eQMIService svc = eQMI_SVC_OMA;
+ WORD msgID = (WORD)eQMI_OMA_SET_EVENT;
+ sSharedBuffer * pReq = 0;
+
+ std::vector <sDB2PackingInput> piv;
+ sProtocolEntityKey pek( eDB2_ET_QMI_OMA_REQ, msgID, 17 );
+
+ if (bOn == true)
+ {
+ sDB2PackingInput pi( pek, "1" );
+ piv.push_back( pi );
+ }
+ else
+ {
+ sDB2PackingInput pi( pek, "0" );
+ piv.push_back( pi );
+ }
+
+ pReq = DB2PackQMIBuffer( mDB, piv );
+
+ rc = SendAndCheckReturn( svc, pReq );
+ if (rc == eGOBI_ERR_NONE || bOff == true)
+ {
+ mpFNOMADMState = pCallback;
+ }
+ }
+ else if (bReplace == true)
+ {
+ // We don't have to register for anything so a simple assignment works
+ mpFNOMADMState = pCallback;
+ rc = eGOBI_ERR_NONE;
+ }
+ else
+ {
+ // Turning it off redundantly
+ rc = eGOBI_ERR_NONE;
+ }
+
+ return rc;
+}
+
+/*===========================================================================
+METHOD:
+ SetUSSDReleaseCallback (Public Method)
+
+DESCRIPTION:
+ Enable/disable USSD release callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiConnectionMgmt::SetUSSDReleaseCallback(
+ tFNUSSDRelease pCallback )
+{
+ // We don't have to register for anything so a simple assignment works
+ mpFNUSSDRelease = pCallback;
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ SetUSSDNotificationCallback (Public Method)
+
+DESCRIPTION:
+ Enable/disable USSD notification callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiConnectionMgmt::SetUSSDNotificationCallback(
+ tFNUSSDNotification pCallback )
+{
+ // We don't have to register for anything so a simple assignment works
+ mpFNUSSDNotification = pCallback;
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ SetUSSDOriginationCallback (Public Method)
+
+DESCRIPTION:
+ Enable/disable USSD origination callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiConnectionMgmt::SetUSSDOriginationCallback(
+ tFNUSSDOrigination pCallback )
+{
+ // We don't have to register for anything so a simple assignment works
+ mpFNUSSDOrigination = pCallback;
+ return eGOBI_ERR_NONE;
+}
+
diff --git a/gobi-api/GobiAPI_1.0.40/GobiConnectionMgmt/GobiConnectionMgmt.h b/gobi-api/GobiAPI_1.0.40/GobiConnectionMgmt/GobiConnectionMgmt.h
new file mode 100755
index 0000000..e92cbcf
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/GobiConnectionMgmt/GobiConnectionMgmt.h
@@ -0,0 +1,1370 @@
+/*===========================================================================
+FILE:
+ GobiConnectionMgmt.h
+
+DESCRIPTION:
+ QUALCOMM Connection Management API for Gobi 3000
+
+PUBLIC CLASSES AND FUNCTIONS:
+ cGobiConnectionMgmtDLL
+ cGobiConnectionMgmt
+
+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"
+
+//---------------------------------------------------------------------------
+// Definitions
+//---------------------------------------------------------------------------
+extern "C"
+{
+
+// Session state callback function
+typedef void (* tFNSessionState)(
+ULONG state,
+ULONG sessionEndReason );
+
+// RX/TX byte counts callback function
+typedef void (* tFNByteTotals)(
+ULONGLONG totalBytesTX,
+ULONGLONG totalBytesRX );
+
+// Dormancy status callback function
+typedef void (* tFNDormancyStatus)( ULONG dormancyStatus );
+
+// Mobile IP status callback function
+typedef void (* tFNMobileIPStatus)( ULONG mipStatus );
+
+// Activation status callback function
+typedef void (* tFNActivationStatus)( ULONG activationStatus );
+
+// Power operating mode callback function
+typedef void (* tFNPower)( ULONG operatingMode );
+
+// Wireless disable callback function
+typedef void (* tFNWirelessDisable)( ULONG bState );
+
+// Serving system data capabilities callback function
+typedef void (* tFNDataCapabilities)(
+BYTE dataCapsSize,
+BYTE * pDataCaps );
+
+// Data bearer technology callback function
+typedef void (* tFNDataBearer)( ULONG dataBearer );
+
+// Roaming indicator callback function
+typedef void (* tFNRoamingIndicator)( ULONG roaming );
+
+// Signal strength callback function
+typedef void (* tFNSignalStrength)(
+INT8 signalStrength,
+ULONG radioInterface );
+
+// RF information callback function
+typedef void (* tFNRFInfo)(
+ULONG radioInterface,
+ULONG activeBandClass,
+ULONG activeChannel );
+
+// LU reject callback function
+typedef void (* tFNLUReject)(
+ULONG serviceDomain,
+ULONG rejectCause );
+
+// PLMN mode callback function
+typedef void (* tFNPLMNMode)( ULONG mode );
+
+// New SMS message callback function
+typedef void (* tFNNewSMS)(
+ULONG storageType,
+ULONG messageIndex );
+
+// New NMEA sentence callback function
+typedef void (* tFNNewNMEA)( LPCSTR pNMEA );
+
+// PDS session state callback function
+typedef void (* tFNPDSState)(
+ULONG enabledStatus,
+ULONG trackingStatus );
+
+// CAT event callback function
+typedef void (* tFNCATEvent)(
+ULONG eventID,
+ULONG eventLen,
+BYTE * pEventData );
+
+// OMA-DM network initiated alert callback function
+typedef void (* tFNOMADMAlert)(
+ ULONG sessionType,
+ USHORT sessionID );
+
+// OMA-DM state callback function
+typedef void (* tFNOMADMState)(
+ ULONG sessionState,
+ ULONG failureReason );
+
+// USSD release callback function
+typedef void (* tFNUSSDRelease)();
+
+// USSD notification callback function
+typedef void (* tFNUSSDNotification)(
+ ULONG type,
+ BYTE * pNetworkInfo );
+
+// USSD origination callback function
+typedef void (* tFNUSSDOrigination)(
+ ULONG errorCode,
+ ULONG failureCause,
+ BYTE * pNetworkInfo,
+ BYTE * pAlpha );
+
+};
+
+// CallbackThread prototype
+// Thread to execute a callback asynchronously
+void * CallbackThread( PVOID pArg );
+
+/*=========================================================================*/
+// Class cGobiCMCallback
+/*=========================================================================*/
+class cGobiCMCallback
+{
+ public:
+ // (Inline) Constructor
+ cGobiCMCallback()
+ { };
+
+ // (Inline) Destructor
+ virtual ~cGobiCMCallback()
+ { };
+
+ // (Inline) Initialize the callback object by starting the thread
+ bool Initialize()
+ {
+ // Start the thread
+ pthread_t threadID;
+ pthread_attr_t attributes;
+ pthread_attr_init( &attributes );
+ pthread_attr_setdetachstate( &attributes, PTHREAD_CREATE_DETACHED );
+
+ int nRC = pthread_create( &threadID,
+ &attributes,
+ CallbackThread,
+ this );
+
+ if (nRC == 0)
+ {
+ // Success!
+ return true;
+ }
+
+ return false;
+ };
+
+ protected:
+ // Call the function
+ virtual void Call() = 0;
+
+ // Function thread gets full access
+ friend void * CallbackThread( PVOID pArg );
+};
+
+/*=========================================================================*/
+// Class cSessionStateCallback
+/*=========================================================================*/
+class cSessionStateCallback : public cGobiCMCallback
+{
+ public:
+ // (Inline) Constructor
+ cSessionStateCallback(
+ tFNSessionState pCallback,
+ ULONG state,
+ ULONG sessionEndReason )
+ : mpCallback( pCallback ),
+ mState( state ),
+ mSessionEndReason( sessionEndReason )
+ { };
+
+ // (Inline) Destructor
+ virtual ~cSessionStateCallback()
+ {
+ mpCallback = 0;
+ };
+
+ protected:
+ // (Inline) Call the function
+ virtual void Call()
+ {
+ if (mpCallback != 0)
+ {
+ mpCallback( mState, mSessionEndReason );
+ }
+ };
+
+ /* Callback function */
+ tFNSessionState mpCallback;
+
+ /* Callback arguments */
+ ULONG mState;
+ ULONG mSessionEndReason;
+};
+
+/*=========================================================================*/
+// Class cByteTotalsCallback
+/*=========================================================================*/
+class cByteTotalsCallback : public cGobiCMCallback
+{
+ public:
+ // (Inline) Constructor
+ cByteTotalsCallback(
+ tFNByteTotals pCallback,
+ ULONGLONG totalBytesTX,
+ ULONGLONG totalBytesRX )
+ : mpCallback( pCallback ),
+ mTotalBytesTX( totalBytesTX ),
+ mTotalBytesRX( totalBytesRX )
+ { };
+
+ // (Inline) Destructor
+ virtual ~cByteTotalsCallback()
+ {
+ mpCallback = 0;
+ };
+
+ protected:
+ // (Inline) Call the function
+ virtual void Call()
+ {
+ if (mpCallback != 0)
+ {
+ mpCallback( mTotalBytesTX, mTotalBytesRX );
+ }
+ };
+
+ /* Callback function */
+ tFNByteTotals mpCallback;
+
+ /* Callback arguments */
+ ULONGLONG mTotalBytesTX;
+ ULONGLONG mTotalBytesRX;
+};
+
+/*=========================================================================*/
+// Class cDormancyStatusCallback
+/*=========================================================================*/
+class cDormancyStatusCallback : public cGobiCMCallback
+{
+ public:
+ // (Inline) Constructor
+ cDormancyStatusCallback(
+ tFNDormancyStatus pCallback,
+ ULONG dormancyStatus )
+ : mpCallback( pCallback ),
+ mDormancyStatus( dormancyStatus )
+ { };
+
+ // (Inline) Destructor
+ virtual ~cDormancyStatusCallback()
+ {
+ mpCallback = 0;
+ };
+
+ protected:
+ // (Inline) Call the function
+ virtual void Call()
+ {
+ if (mpCallback != 0)
+ {
+ mpCallback( mDormancyStatus );
+ }
+ };
+
+ /* Callback function */
+ tFNDormancyStatus mpCallback;
+
+ /* Callback arguments */
+ ULONG mDormancyStatus;
+};
+
+/*=========================================================================*/
+// Class cMobileIPStatusCallback
+/*=========================================================================*/
+class cMobileIPStatusCallback : public cGobiCMCallback
+{
+ public:
+ // (Inline) Constructor
+ cMobileIPStatusCallback(
+ tFNMobileIPStatus pCallback,
+ ULONG mobileIPStatus )
+ : mpCallback( pCallback ),
+ mMobileIPStatus( mobileIPStatus )
+ { };
+
+ // (Inline) Destructor
+ virtual ~cMobileIPStatusCallback()
+ {
+ mpCallback = 0;
+ };
+
+ protected:
+ // (Inline) Call the function
+ virtual void Call()
+ {
+ if (mpCallback != 0)
+ {
+ mpCallback( mMobileIPStatus );
+ }
+ };
+
+ /* Callback function */
+ tFNMobileIPStatus mpCallback;
+
+ /* Callback arguments */
+ ULONG mMobileIPStatus;
+};
+
+/*=========================================================================*/
+// Class cActivationStatusCallback
+/*=========================================================================*/
+class cActivationStatusCallback : public cGobiCMCallback
+{
+ public:
+ // (Inline) Constructor
+ cActivationStatusCallback(
+ tFNActivationStatus pCallback,
+ ULONG activationStatus )
+ : mpCallback( pCallback ),
+ mActivationStatus( activationStatus )
+ { };
+
+ // (Inline) Destructor
+ virtual ~cActivationStatusCallback()
+ {
+ mpCallback = 0;
+ };
+
+ protected:
+ // (Inline) Call the function
+ virtual void Call()
+ {
+ if (mpCallback != 0)
+ {
+ mpCallback( mActivationStatus );
+ }
+ };
+
+ /* Callback function */
+ tFNActivationStatus mpCallback;
+
+ /* Callback arguments */
+ ULONG mActivationStatus;
+};
+
+/*=========================================================================*/
+// Class cPowerCallback
+/*=========================================================================*/
+class cPowerCallback : public cGobiCMCallback
+{
+ public:
+ // (Inline) Constructor
+ cPowerCallback(
+ tFNPower pCallback,
+ ULONG operatingMode )
+ : mpCallback( pCallback ),
+ mOperatingMode( operatingMode )
+ { };
+
+ // (Inline) Destructor
+ virtual ~cPowerCallback()
+ {
+ mpCallback = 0;
+ };
+
+ protected:
+ // (Inline) Call the function
+ virtual void Call()
+ {
+ if (mpCallback != 0)
+ {
+ mpCallback( mOperatingMode );
+ }
+ };
+
+ /* Callback function */
+ tFNPower mpCallback;
+
+ /* Callback arguments */
+ ULONG mOperatingMode;
+};
+
+/*=========================================================================*/
+// Class cWirelessDisableCallback
+/*=========================================================================*/
+class cWirelessDisableCallback : public cGobiCMCallback
+{
+ public:
+ // (Inline) Constructor
+ cWirelessDisableCallback(
+ tFNWirelessDisable pCallback,
+ ULONG bState )
+ : mpCallback( pCallback ),
+ mbState( bState )
+ { };
+
+ // (Inline) Destructor
+ virtual ~cWirelessDisableCallback()
+ {
+ mpCallback = 0;
+ };
+
+ protected:
+ // (Inline) Call the function
+ virtual void Call()
+ {
+ if (mpCallback != 0)
+ {
+ mpCallback( mbState );
+ }
+ };
+
+ /* Callback function */
+ tFNWirelessDisable mpCallback;
+
+ /* Callback arguments */
+ ULONG mbState;
+};
+
+/*=========================================================================*/
+// Class cDataCapabilitiesCallback
+/*=========================================================================*/
+class cDataCapabilitiesCallback : public cGobiCMCallback
+{
+ public:
+ // (Inline) Constructor
+ cDataCapabilitiesCallback(
+ tFNDataCapabilities pCallback,
+ BYTE dataCapsSize,
+ ULONG * pDataCaps )
+ : mpCallback( pCallback ),
+ mDataCapsSize( dataCapsSize )
+ {
+ memset( (LPVOID)&mDataCaps[0], 0, 12 * sizeof( ULONG ) );
+
+ if (mDataCapsSize > 12)
+ {
+ mDataCapsSize = 12;
+ }
+
+ for (ULONG d = 0; d < mDataCapsSize; d++)
+ {
+ mDataCaps[d] = pDataCaps[d];
+ }
+ };
+
+ // (Inline) Destructor
+ virtual ~cDataCapabilitiesCallback()
+ {
+ mpCallback = 0;
+ };
+
+ protected:
+ // (Inline) Call the function
+ virtual void Call()
+ {
+ if (mpCallback != 0)
+ {
+ mpCallback( mDataCapsSize, (BYTE *)&mDataCaps[0] );
+ }
+ };
+
+ /* Callback function */
+ tFNDataCapabilities mpCallback;
+
+ /* Callback arguments */
+ BYTE mDataCapsSize;
+ ULONG mDataCaps[12];
+};
+
+/*=========================================================================*/
+// Class cDataBearerCallback
+/*=========================================================================*/
+class cDataBearerCallback : public cGobiCMCallback
+{
+ public:
+ // (Inline) Constructor
+ cDataBearerCallback(
+ tFNDataBearer pCallback,
+ ULONG dataBearer )
+ : mpCallback( pCallback ),
+ mDataBearer( dataBearer )
+ { };
+
+ // (Inline) Destructor
+ virtual ~cDataBearerCallback()
+ {
+ mpCallback = 0;
+ };
+
+ protected:
+ // (Inline) Call the function
+ virtual void Call()
+ {
+ if (mpCallback != 0)
+ {
+ mpCallback( mDataBearer );
+ }
+ };
+
+ /* Callback function */
+ tFNDataBearer mpCallback;
+
+ /* Callback arguments */
+ ULONG mDataBearer;
+};
+
+/*=========================================================================*/
+// Class cRoamingIndicatorCallback
+/*=========================================================================*/
+class cRoamingIndicatorCallback : public cGobiCMCallback
+{
+ public:
+ // (Inline) Constructor
+ cRoamingIndicatorCallback(
+ tFNRoamingIndicator pCallback,
+ ULONG roaming )
+ : mpCallback( pCallback ),
+ mRoaming( roaming )
+ { };
+
+ // (Inline) Destructor
+ virtual ~cRoamingIndicatorCallback()
+ {
+ mpCallback = 0;
+ };
+
+ protected:
+ // (Inline) Call the function
+ virtual void Call()
+ {
+ if (mpCallback != 0)
+ {
+ mpCallback( mRoaming );
+ }
+ };
+
+ /* Callback function */
+ tFNRoamingIndicator mpCallback;
+
+ /* Callback arguments */
+ ULONG mRoaming;
+};
+
+/*=========================================================================*/
+// Class cSignalStrengthCallback
+/*=========================================================================*/
+class cSignalStrengthCallback : public cGobiCMCallback
+{
+ public:
+ // (Inline) Constructor
+ cSignalStrengthCallback(
+ tFNSignalStrength pCallback,
+ INT8 signalStrength,
+ ULONG radioInterface )
+ : mpCallback( pCallback ),
+ mSignalStrength( signalStrength ),
+ mRadioInterface( radioInterface )
+ { };
+
+ // (Inline) Destructor
+ virtual ~cSignalStrengthCallback()
+ {
+ mpCallback = 0;
+ };
+
+ protected:
+ // (Inline) Call the function
+ virtual void Call()
+ {
+ if (mpCallback != 0)
+ {
+ mpCallback( mSignalStrength, mRadioInterface );
+ }
+ };
+
+ /* Callback function */
+ tFNSignalStrength mpCallback;
+
+ /* Callback arguments */
+ INT8 mSignalStrength;
+ ULONG mRadioInterface;
+};
+
+/*=========================================================================*/
+// Class cRFInfoCallback
+/*=========================================================================*/
+class cRFInfoCallback : public cGobiCMCallback
+{
+ public:
+ // (Inline) Constructor
+ cRFInfoCallback(
+ tFNRFInfo pCallback,
+ ULONG radioInterface,
+ ULONG activeBandClass,
+ ULONG activeChannel )
+ : mpCallback( pCallback ),
+ mRadioInterface( radioInterface ),
+ mActiveBandClass( activeBandClass ),
+ mActiveChannel( activeChannel )
+ { };
+
+ // (Inline) Destructor
+ virtual ~cRFInfoCallback()
+ {
+ mpCallback = 0;
+ };
+
+ protected:
+ // (Inline) Call the function
+ virtual void Call()
+ {
+ if (mpCallback != 0)
+ {
+ mpCallback( mRadioInterface, mActiveBandClass, mActiveChannel );
+ }
+ };
+
+ /* Callback function */
+ tFNRFInfo mpCallback;
+
+ /* Callback arguments */
+ ULONG mRadioInterface;
+ ULONG mActiveBandClass;
+ ULONG mActiveChannel;
+};
+
+/*=========================================================================*/
+// Class cLURejectCallback
+/*=========================================================================*/
+class cLURejectCallback : public cGobiCMCallback
+{
+ public:
+ // (Inline) Constructor
+ cLURejectCallback(
+ tFNLUReject pCallback,
+ ULONG serviceDomain,
+ ULONG rejectCause )
+ : mpCallback( pCallback ),
+ mServiceDomain( serviceDomain ),
+ mRejectCause( rejectCause )
+ { };
+
+ // (Inline) Destructor
+ virtual ~cLURejectCallback()
+ {
+ mpCallback = 0;
+ };
+
+ protected:
+ // (Inline) Call the function
+ virtual void Call()
+ {
+ if (mpCallback != 0)
+ {
+ mpCallback( mServiceDomain, mRejectCause );
+ }
+ };
+
+ /* Callback function */
+ tFNLUReject mpCallback;
+
+ /* Callback arguments */
+ ULONG mServiceDomain;
+ ULONG mRejectCause;
+};
+
+/*=========================================================================*/
+// Class cPLMNModeCallback
+/*=========================================================================*/
+class cPLMNModeCallback : public cGobiCMCallback
+{
+ public:
+ // (Inline) Constructor
+ cPLMNModeCallback(
+ tFNPLMNMode pCallback,
+ ULONG mode )
+ : mpCallback( pCallback ),
+ mMode( mode )
+ { };
+
+ // (Inline) Destructor
+ virtual ~cPLMNModeCallback()
+ {
+ mpCallback = 0;
+ };
+
+ protected:
+ // (Inline) Call the function
+ virtual void Call()
+ {
+ if (mpCallback != 0)
+ {
+ mpCallback( mMode );
+ }
+ };
+
+ /* Callback function */
+ tFNPLMNMode mpCallback;
+
+ /* Callback arguments */
+ ULONG mMode;
+};
+
+/*=========================================================================*/
+// Class cNewSMSCallback
+/*=========================================================================*/
+class cNewSMSCallback : public cGobiCMCallback
+{
+ public:
+ // (Inline) Constructor
+ cNewSMSCallback(
+ tFNNewSMS pCallback,
+ ULONG storageType,
+ ULONG messageIndex )
+ : mpCallback( pCallback ),
+ mStorageType( storageType ),
+ mMessageIndex( messageIndex )
+ { };
+
+ // (Inline) Destructor
+ virtual ~cNewSMSCallback()
+ {
+ mpCallback = 0;
+ };
+
+ protected:
+ // (Inline) Call the function
+ virtual void Call()
+ {
+ if (mpCallback != 0)
+ {
+ mpCallback( mStorageType, mMessageIndex );
+ }
+ };
+
+ /* Callback function */
+ tFNNewSMS mpCallback;
+
+ /* Callback arguments */
+ ULONG mStorageType;
+ ULONG mMessageIndex;
+};
+
+/*=========================================================================*/
+// Class cNewNMEACallback
+/*=========================================================================*/
+class cNewNMEACallback : public cGobiCMCallback
+{
+ public:
+ // (Inline) Constructor
+ cNewNMEACallback(
+ tFNNewNMEA pCallback,
+ std::string & nmea )
+ : mpCallback( pCallback )
+ {
+ memset( (LPVOID)&mNMEA[0], 0, 512 );
+
+ ULONG len = nmea.size();
+ if (len > 0 && len < 512)
+ {
+ memcpy( (LPVOID)&mNMEA[0],
+ (LPCVOID)nmea.c_str(),
+ (SIZE_T)len );
+ }
+ };
+
+ // (Inline) Destructor
+ virtual ~cNewNMEACallback()
+ {
+ mpCallback = 0;
+ };
+
+ protected:
+ // (Inline) Call the function
+ virtual void Call()
+ {
+ if (mpCallback != 0 && mNMEA[0] != 0)
+ {
+ mpCallback( &mNMEA[0] );
+ }
+ };
+
+ /* Callback function */
+ tFNNewNMEA mpCallback;
+
+ /* Callback arguments */
+ CHAR mNMEA[512];
+};
+
+/*=========================================================================*/
+// Class cPDSStateCallback
+/*=========================================================================*/
+class cPDSStateCallback : public cGobiCMCallback
+{
+ public:
+ // (Inline) Constructor
+ cPDSStateCallback(
+ tFNPDSState pCallback,
+ ULONG enabledState,
+ ULONG trackingState )
+ : mpCallback( pCallback ),
+ mEnabledState( enabledState ),
+ mTrackingState( trackingState )
+ { };
+
+ // (Inline) Destructor
+ virtual ~cPDSStateCallback()
+ {
+ mpCallback = 0;
+ };
+
+ protected:
+ // (Inline) Call the function
+ virtual void Call()
+ {
+ if (mpCallback != 0)
+ {
+ mpCallback( mEnabledState, mTrackingState );
+ }
+ };
+
+ /* Callback function */
+ tFNPDSState mpCallback;
+
+ /* Callback arguments */
+ ULONG mTrackingState;
+ ULONG mEnabledState;
+};
+
+/*=========================================================================*/
+// Class cCATEventCallback
+/*=========================================================================*/
+class cCATEventCallback : public cGobiCMCallback
+{
+ public:
+ // (Inline) Constructor
+ cCATEventCallback(
+ tFNCATEvent pCallback,
+ ULONG eventID,
+ ULONG eventLen,
+ const BYTE * pEventData )
+ : mpCallback( pCallback ),
+ mEventID( eventID ),
+ mEventLen( 0 )
+ {
+ memset( (LPVOID)&mData[0], 0, 2048 );
+
+ if (pEventData != 0 && eventLen > 0 && eventLen < 2048)
+ {
+ mEventLen = eventLen;
+ memcpy( (LPVOID)&mData[0],
+ (LPCVOID)pEventData,
+ (SIZE_T)eventLen );
+ }
+ };
+
+ // (Inline) Destructor
+ virtual ~cCATEventCallback()
+ {
+ mpCallback = 0;
+ };
+
+ protected:
+ // (Inline) Call the function
+ virtual void Call()
+ {
+ if (mpCallback != 0)
+ {
+ mpCallback( mEventID, mEventLen, &mData[0] );
+ }
+ };
+
+ /* Callback function */
+ tFNCATEvent mpCallback;
+
+ /* Callback arguments */
+ ULONG mEventID;
+ ULONG mEventLen;
+ BYTE mData[2048];
+};
+
+/*=========================================================================*/
+// Class cOMADMAlertCallback
+/*=========================================================================*/
+class cOMADMAlertCallback : public cGobiCMCallback
+{
+ public:
+ // (Inline) Constructor
+ cOMADMAlertCallback(
+ tFNOMADMAlert pCallback,
+ ULONG sessionType,
+ USHORT sessionID )
+ : mpCallback( pCallback ),
+ mSessionType( sessionType ),
+ mSessionID( sessionID )
+ { };
+
+ // (Inline) Destructor
+ virtual ~cOMADMAlertCallback()
+ {
+ mpCallback = 0;
+ };
+
+ protected:
+ // (Inline) Call the function
+ virtual void Call()
+ {
+ if (mpCallback != 0)
+ {
+ mpCallback( mSessionType, mSessionID );
+ }
+ };
+
+ /* Callback function */
+ tFNOMADMAlert mpCallback;
+
+ /* Callback arguments */
+ ULONG mSessionType;
+ USHORT mSessionID;
+};
+
+/*=========================================================================*/
+// Class cOMADMStateCallback
+/*=========================================================================*/
+class cOMADMStateCallback : public cGobiCMCallback
+{
+ public:
+ // (Inline) Constructor
+ cOMADMStateCallback(
+ tFNOMADMState pCallback,
+ ULONG sessionState,
+ ULONG failureReason )
+ : mpCallback( pCallback ),
+ mSessionState( sessionState ),
+ mFailureReason( failureReason )
+ { };
+
+ // (Inline) Destructor
+ virtual ~cOMADMStateCallback()
+ {
+ mpCallback = 0;
+ };
+
+ protected:
+ // (Inline) Call the function
+ virtual void Call()
+ {
+ if (mpCallback != 0)
+ {
+ mpCallback( mSessionState, mFailureReason );
+ }
+ };
+
+ /* Callback function */
+ tFNOMADMState mpCallback;
+
+ /* Callback arguments */
+ ULONG mSessionState;
+ ULONG mFailureReason;
+};
+
+/*=========================================================================*/
+// Class cUSSDReleaseCallback
+/*=========================================================================*/
+class cUSSDReleaseCallback : public cGobiCMCallback
+{
+ public:
+ // (Inline) Constructor
+ cUSSDReleaseCallback( tFNUSSDRelease pCallback )
+ : mpCallback( pCallback )
+ { };
+
+ // (Inline) Destructor
+ virtual ~cUSSDReleaseCallback()
+ {
+ mpCallback = 0;
+ };
+
+ protected:
+ // (Inline) Call the function
+ virtual void Call()
+ {
+ if (mpCallback != 0)
+ {
+ mpCallback();
+ }
+ };
+
+ /* Callback function */
+ tFNUSSDRelease mpCallback;
+};
+
+/*=========================================================================*/
+// Class cUSSDNotificationCallback
+/*=========================================================================*/
+class cUSSDNotificationCallback : public cGobiCMCallback
+{
+ public:
+ // (Inline) Constructor
+ cUSSDNotificationCallback(
+ tFNUSSDNotification pCallback,
+ ULONG type,
+ const BYTE * pData )
+ : mpCallback( pCallback ),
+ mType( type ),
+ mbData( false )
+ {
+ memset( (LPVOID)&mData[0], 0, 512 );
+
+ // Data to copy?
+ if (pData != 0)
+ {
+ ULONG len = (ULONG)pData[1] + (ULONG)2;
+ memcpy( (LPVOID)&mData[0], (LPCVOID)pData, (SIZE_T)len );
+
+ mbData = true;
+ }
+ };
+
+ // (Inline) Destructor
+ virtual ~cUSSDNotificationCallback()
+ {
+ mpCallback = 0;
+ };
+
+ protected:
+ // (Inline) Call the function
+ virtual void Call()
+ {
+ if (mpCallback != 0)
+ {
+ if (mbData == true)
+ {
+ mpCallback( mType, &mData[0] );
+ }
+ else
+ {
+ mpCallback( mType, 0 );
+ }
+ }
+ };
+
+ /* Callback function */
+ tFNUSSDNotification mpCallback;
+
+ /* Callback arguments */
+ ULONG mType;
+ BYTE mData[512];
+
+ /* Did we get data? */
+ bool mbData;
+};
+
+/*=========================================================================*/
+// Class cUSSDOriginationCallback
+/*=========================================================================*/
+class cUSSDOriginationCallback : public cGobiCMCallback
+{
+ public:
+ // (Inline) Constructor
+ cUSSDOriginationCallback(
+ tFNUSSDOrigination pCallback,
+ ULONG errorCode,
+ ULONG failureCause,
+ const BYTE * pNetworkInfo,
+ const BYTE * pAlpha )
+ : mpCallback( pCallback ),
+ mErrorCode( errorCode ),
+ mFailureCause( failureCause ),
+ mbNetwork( false ),
+ mbAlpha( 0 )
+ {
+ memset( &mNetworkInfo[0], 0, 512 );
+ memset( &mAlpha[0], 0, 512 );
+
+ // Data to copy?
+ if (pNetworkInfo != 0)
+ {
+ ULONG len = (ULONG)pNetworkInfo[1] + (ULONG)2;
+ memcpy( &mNetworkInfo[0],
+ pNetworkInfo,
+ len );
+
+ mbNetwork = true;
+ }
+
+ if (pAlpha != 0)
+ {
+ ULONG len = (ULONG)pAlpha[1] + (ULONG)2;
+ memcpy( &mAlpha[0],
+ pAlpha,
+ len );
+
+ mbAlpha = true;
+ }
+ };
+
+ // (Inline) Destructor
+ virtual ~cUSSDOriginationCallback()
+ {
+ mpCallback = 0;
+ };
+
+ protected:
+ // (Inline) Call the function
+ virtual void Call()
+ {
+ if (mpCallback != 0)
+ {
+ BYTE * pNetworkInfo = (mbNetwork == true ? &mNetworkInfo[0] : 0);
+ BYTE * pAlpha = (mbAlpha == true ? &mAlpha[0] : 0);
+
+ mpCallback( mErrorCode, mFailureCause, pNetworkInfo, pAlpha );
+ }
+ };
+
+ /* Callback function */
+ tFNUSSDOrigination mpCallback;
+
+ /* Callback arguments */
+ ULONG mErrorCode;
+ ULONG mFailureCause;
+ BYTE mNetworkInfo[512];
+ BYTE mAlpha[512];
+
+ /* Did we get data? */
+ bool mbNetwork;
+ bool mbAlpha;
+};
+
+/*=========================================================================*/
+// Class cGobiConnectionMgmt
+/*=========================================================================*/
+class cGobiConnectionMgmt : public cGobiQMICore
+{
+ public:
+ // Constructor
+ cGobiConnectionMgmt();
+
+ // Destructor
+ virtual ~cGobiConnectionMgmt();
+
+ // Connect to the specified Gobi device
+ virtual bool Connect(
+ LPCSTR pDeviceNode = 0,
+ LPCSTR pDeviceKey = 0 );
+
+ // Disconnect from the currently connected Gobi device
+ virtual bool Disconnect();
+
+ // Enable/disable session state callback function
+ eGobiError SetSessionStateCallback( tFNSessionState pCallback );
+
+ // Enables/disables the RX/TX byte counts callback function
+ eGobiError SetByteTotalsCallback(
+ tFNByteTotals pCallback,
+ BYTE interval );
+
+ // Enables/disables the serving system data capabilities callback
+ eGobiError SetDataCapabilitiesCallback( tFNDataCapabilities pCallback );
+
+ // Enable/disable data bearer callback function
+ eGobiError SetDataBearerCallback( tFNDataBearer pCallback );
+
+ // Enable/disable dormancy status callback function
+ eGobiError SetDormancyStatusCallback( tFNDormancyStatus pCallback );
+
+ // Enable/disable mobile IP status callback function
+ eGobiError SetMobileIPStatusCallback( tFNDormancyStatus pCallback );
+
+ // Enable/disable activation status callback function
+ eGobiError SetActivationStatusCallback( tFNActivationStatus pCallback );
+
+ // Enable/disable power operating mode callback function
+ eGobiError SetPowerCallback( tFNPower pCallback );
+
+ // Enable/disable wireless disable state callback function
+ eGobiError SetWirelessDisableCallback( tFNWirelessDisable pCallback );
+
+ // Enable/disable roaming indicator callback function
+ eGobiError SetRoamingIndicatorCallback( tFNRoamingIndicator pCallback );
+
+ // Enable/disable signal strength callback function
+ eGobiError SetSignalStrengthCallback(
+ tFNSignalStrength pCallback,
+ std::list <INT8> thresholds );
+
+ // Enable/disable RF information callback function
+ eGobiError SetRFInfoCallback( tFNRFInfo pCallback );
+
+ // Enable/disable LU reject callback function
+ eGobiError SetLURejectCallback( tFNLUReject pCallback );
+
+ // Enable/disable PLMN mode callback function
+ eGobiError SetPLMNModeCallback( tFNPLMNMode pCallback );
+
+ // Enable/disable new SMS callback function
+ eGobiError SetNewSMSCallback( tFNNewSMS pCallback );
+
+ // Enable/disable NMEA sentence callback function
+ eGobiError SetNMEACallback( tFNNewNMEA pCallback );
+
+ // Enable/disable PDS service state callback function
+ eGobiError SetPDSStateCallback( tFNPDSState pCallback );
+
+ // Enable/disable CAT event callback function
+ eGobiError SetCATEventCallback(
+ tFNCATEvent pCallback,
+ ULONG eventMask,
+ ULONG * pErrorMask );
+
+ // Enable/disable OMA-DM NIA callback function
+ eGobiError SetOMADMAlertCallback( tFNOMADMAlert pCallback );
+
+ // Enable/disable OMA-DM state callback function
+ eGobiError SetOMADMStateCallback( tFNOMADMState pCallback );
+
+ // Enable/disable USSD release callback function
+ eGobiError SetUSSDReleaseCallback( tFNUSSDRelease pCallback );
+
+ // Enable/disable USSD notification callback function
+ eGobiError SetUSSDNotificationCallback( tFNUSSDNotification pCallback );
+
+ // Enable/disable USSD origination callback function
+ eGobiError SetUSSDOriginationCallback( tFNUSSDOrigination pCallback );
+
+ protected:
+ // Process new traffic
+ void ProcessTraffic( eQMIService svc );
+
+ // Process QMI traffic
+ void ProcessWDSBuffer( const sProtocolBuffer & buf );
+ void ProcessDMSBuffer( const sProtocolBuffer & buf );
+ void ProcessNASBuffer( const sProtocolBuffer & buf );
+ void ProcessWMSBuffer( const sProtocolBuffer & buf );
+ void ProcessPDSBuffer( const sProtocolBuffer & buf );
+ void ProcessCATBuffer( const sProtocolBuffer & buf );
+ void ProcessOMABuffer( const sProtocolBuffer & buf );
+ void ProcessVoiceBuffer( const sProtocolBuffer & buf );
+
+ /* Is there an active thread? */
+ bool mbThreadStarted;
+
+ /* ID of traffic processing thread */
+ pthread_t mThreadID;
+
+ /* Traffic processing thread exit event */
+ cEvent mExitEvent;
+
+ /* Has the protocol server thread finished cleanup? */
+ bool mThreadCleanupFinished;
+
+ /* Number of buffers processed by ProcessTraffic() (per server) */
+ ULONG mWDSItemsProcessed;
+ ULONG mDMSItemsProcessed;
+ ULONG mNASItemsProcessed;
+ ULONG mWMSItemsProcessed;
+ ULONG mPDSItemsProcessed;
+ ULONG mCATItemsProcessed;
+ ULONG mOMAItemsProcessed;
+ ULONG mVoiceItemsProcessed;
+
+ /* Callback functions */
+ tFNSessionState mpFNSessionState;
+ tFNByteTotals mpFNByteTotals;
+ tFNDataCapabilities mpFNDataCapabilities;
+ tFNDataBearer mpFNDataBearer;
+ tFNDormancyStatus mpFNDormancyStatus;
+ tFNMobileIPStatus mpFNMobileIPStatus;
+ tFNActivationStatus mpFNActivationStatus;
+ tFNPower mpFNPower;
+ tFNWirelessDisable mpFNWirelessDisable;
+ tFNRoamingIndicator mpFNRoamingIndicator;
+ tFNSignalStrength mpFNSignalStrength;
+ tFNRFInfo mpFNRFInfo;
+ tFNLUReject mpFNLUReject;
+ tFNPLMNMode mpPLMNMode;
+ tFNNewSMS mpFNNewSMS;
+ tFNNewNMEA mpFNNewNMEA;
+ tFNPDSState mpFNPDSState;
+ tFNCATEvent mpFNCATEvent;
+ tFNOMADMAlert mpFNOMADMAlert;
+ tFNOMADMState mpFNOMADMState;
+ tFNUSSDRelease mpFNUSSDRelease;
+ tFNUSSDNotification mpFNUSSDNotification;
+ tFNUSSDOrigination mpFNUSSDOrigination;
+
+ // Traffic process thread gets full access
+ friend VOID * TrafficProcessThread( PVOID pArg );
+};
+
+/*=========================================================================*/
+// Class cGobiConnectionMgmtDLL
+/*=========================================================================*/
+class cGobiConnectionMgmtDLL
+{
+ public:
+ // Constructor
+ cGobiConnectionMgmtDLL();
+
+ // Destructor
+ virtual ~cGobiConnectionMgmtDLL();
+
+ // Return the GobiConnectionMgmt object
+ cGobiConnectionMgmt * GetAPI();
+
+ protected:
+ /* API interface object */
+ cGobiConnectionMgmt * mpAPI;
+
+ /* Above object allocation attempted? */
+ bool mbAllocated;
+
+ /* Synchronization object */
+ mutable pthread_mutex_t mSyncSection;
+};
+
+extern cGobiConnectionMgmtDLL gConnectionDLL;
diff --git a/gobi-api/GobiAPI_1.0.40/GobiConnectionMgmt/GobiConnectionMgmtAPI.h b/gobi-api/GobiAPI_1.0.40/GobiConnectionMgmt/GobiConnectionMgmtAPI.h
new file mode 100755
index 0000000..955f391
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/GobiConnectionMgmt/GobiConnectionMgmtAPI.h
@@ -0,0 +1,3329 @@
+/*===========================================================================
+FILE:
+ GobiConnectionMgmtAPI.h
+
+DESCRIPTION:
+ QUALCOMM Connection 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
+
+/*=========================================================================*/
+// Definitions
+/*=========================================================================*/
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// Session state callback function
+typedef void (* tFNSessionState)(
+ ULONG state,
+ ULONG sessionEndReason );
+
+// RX/TX byte counts callback function
+typedef void (* tFNByteTotals)(
+ ULONGLONG totalBytesTX,
+ ULONGLONG totalBytesRX );
+
+// Dormancy status callback function
+typedef void (* tFNDormancyStatus)( ULONG dormancyStatus );
+
+// Mobile IP status callback function
+typedef void (* tFNMobileIPStatus)( ULONG mipStatus );
+
+// Activation status callback function
+typedef void (* tFNActivationStatus)( ULONG activationStatus );
+
+// Power operating mode callback function
+typedef void (* tFNPower)( ULONG operatingMode );
+
+// Wireless disable callback function
+typedef void (* tFNWirelessDisable)( ULONG bState );
+
+// Serving system data capabilities callback function
+typedef void (* tFNDataCapabilities)(
+ BYTE dataCapsSize,
+ BYTE * pDataCaps );
+
+// Data bearer technology callback function
+typedef void (* tFNDataBearer)( ULONG dataBearer );
+
+// Roaming indicator callback function
+typedef void (* tFNRoamingIndicator)( ULONG roaming );
+
+// Signal strength callback function
+typedef void (* tFNSignalStrength)(
+ INT8 signalStrength,
+ ULONG radioInterface );
+
+// RF information callback function
+typedef void (* tFNRFInfo)(
+ ULONG radioInterface,
+ ULONG activeBandClass,
+ ULONG activeChannel );
+
+// LU reject callback function
+typedef void (* tFNLUReject)(
+ ULONG serviceDomain,
+ ULONG rejectCause );
+
+// PLMN mode callback function
+typedef void (* tFNPLMNMode)( ULONG mode );
+
+// New SMS message callback function
+typedef void (* tFNNewSMS)(
+ ULONG storageType,
+ ULONG messageIndex );
+
+// New NMEA sentence callback function
+typedef void (* tFNNewNMEA)( LPCSTR pNMEA );
+
+// PDS session state callback function
+typedef void (* tFNPDSState)(
+ ULONG enabledStatus,
+ ULONG trackingStatus );
+
+// CAT event callback function
+typedef void (* tFNCATEvent)(
+ ULONG eventID,
+ ULONG eventLen,
+ BYTE * pEventData );
+
+// OMA-DM network initiated alert callback function
+typedef void (* tFNOMADMAlert)(
+ ULONG sessionType,
+ USHORT sessionID );
+
+// OMA-DM state callback function
+typedef void (* tFNOMADMState)(
+ ULONG sessionState,
+ ULONG failureReason );
+
+// USSD release callback function
+typedef void (* tFNUSSDRelease)();
+
+// USSD notification callback function
+typedef void (* tFNUSSDNotification)(
+ ULONG type,
+ BYTE * pNetworkInfo );
+
+// USSD origination callback function
+typedef void (* tFNUSSDOrigination)(
+ ULONG errorCode,
+ ULONG failureCause,
+ BYTE * pNetworkInfo,
+ BYTE * pAlpha );
+
+/*=========================================================================*/
+// Prototypes
+/*=========================================================================*/
+
+/*===========================================================================
+METHOD:
+ QCWWANEnumerateDevices
+
+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 QCWWANEnumerateDevices(
+ BYTE * pDevicesSize,
+ BYTE * pDevices );
+
+/*===========================================================================
+METHOD:
+ QCWWANConnect
+
+DESCRIPTION:
+ This function connects the CM API library to the specified Gobi
+ device
+
+ Both device node and key are case sensitive
+
+PARAMETERS:
+ pDeviceNode [ I ] - The device node
+ pDeviceKey [ I ] - The device key (unique, stored on-device)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG QCWWANConnect(
+ CHAR * pDeviceNode,
+ CHAR * pDeviceKey );
+
+/*===========================================================================
+METHOD:
+ QCWWANCancel
+
+DESCRIPTION:
+ This function cancels the most recent outstanding request
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG QCWWANCancel();
+
+/*===========================================================================
+METHOD:
+ QCWWANDisconnect
+
+DESCRIPTION:
+ This function disconnects the CM API library from the currently
+ connected Gobi device
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG QCWWANDisconnect();
+
+/*===========================================================================
+METHOD:
+ QCWWANGetConnectedDeviceID
+
+DESCRIPTION:
+ This function returns the Node/key of the device the Gobi CM API library
+ is currently connected to
+
+PARAMETERS:
+ deviceNodeSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the device Node array can contain
+ pDeviceNode [ O ] - Device Node (NULL terminated string)
+ deviceKeySize [ I ] - The maximum number of characters (including NULL
+ terminator) that the device key array can contain
+ pDeviceKey [ O ] - Device key (NULL terminated string)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG QCWWANGetConnectedDeviceID(
+ ULONG deviceNodeSize,
+ CHAR * pDeviceNode,
+ ULONG deviceKeySize,
+ CHAR * pDeviceKey );
+
+/*===========================================================================
+METHOD:
+ GetSessionState
+
+DESCRIPTION:
+ This function returns the state of the current packet data session
+
+PARAMETERS:
+ pState [ O ] - State of the current packet session
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetSessionState( ULONG * pState );
+
+/*===========================================================================
+METHOD:
+ GetSessionDuration
+
+DESCRIPTION:
+ This function returns the duration of the current packet data session
+
+PARAMETERS:
+ pDuration [ O ] - Duration of the current packet session
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetSessionDuration( ULONGLONG * pDuration );
+
+/*===========================================================================
+METHOD:
+ GetDormancyState
+
+DESCRIPTION:
+ This function returns the dormancy state of the current packet
+ data session (when connected)
+
+PARAMETERS:
+ pState [ O ] - Dormancy state of the current packet session
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetDormancyState( ULONG * pState );
+
+/*===========================================================================
+METHOD:
+ GetAutoconnect (Deprecated)
+
+DESCRIPTION:
+ This function returns the current autoconnect data session setting
+
+PARAMETERS:
+ pSetting [ O ] - NDIS autoconnect setting
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetAutoconnect( ULONG * pSetting );
+
+/*===========================================================================
+METHOD:
+ SetAutoconnect (Deprecated)
+
+DESCRIPTION:
+ This function sets the autoconnect data session setting
+
+PARAMETERS:
+ setting [ I ] - NDIS autoconnect disabled (0) or enabled (non-zero)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetAutoconnect( ULONG setting );
+
+/*===========================================================================
+METHOD:
+ GetEnhancedAutoconnect
+
+DESCRIPTION:
+ This function returns the current autoconnect data session setting
+
+PARAMETERS:
+ pSetting [ O ] - NDIS autoconnect setting
+ pRoamSetting [ O ] - NDIS autoconnect roam setting
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetEnhancedAutoconnect(
+ ULONG * pSetting,
+ ULONG * pRoamSetting );
+
+/*===========================================================================
+METHOD:
+ SetEnhancedAutoconnect
+
+DESCRIPTION:
+ This function sets the autoconnect data session setting
+
+PARAMETERS:
+ setting [ I ] - NDIS autoconnect setting
+ pRoamSetting [ I ] - (Optional) NDIS autoconnect roam setting
+
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetEnhancedAutoconnect(
+ ULONG setting,
+ ULONG * pRoamSetting );
+
+/*===========================================================================
+METHOD:
+ SetDefaultProfile
+
+DESCRIPTION:
+ This function writes the default profile settings to the device, the
+ default profile is used during autoconnect
+
+PARAMETERS:
+ profileType [ I ] - Profile type being written
+ pPDPType [ I ] - (Optional) PDP type
+ pIPAddress [ I ] - (Optional) Preferred assigned IPv4 address
+ pPrimaryDNS [ I ] - (Optional) Primary DNS IPv4 address
+ pSecondaryDNS [ I ] - (Optional) Secondary DNS IPv4 address
+ pAuthentication [ I ] - (Optional) Authentication algorithm bitmap
+ pName [ I ] - (Optional) The profile name or description
+ pAPNName [ I ] - (Optional) Access point name
+ pUsername [ I ] - (Optional) Username used during authentication
+ pPassword [ I ] - (Optional) Password used during authentication
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetDefaultProfile(
+ ULONG profileType,
+ ULONG * pPDPType,
+ ULONG * pIPAddress,
+ ULONG * pPrimaryDNS,
+ ULONG * pSecondaryDNS,
+ ULONG * pAuthentication,
+ CHAR * pName,
+ CHAR * pAPNName,
+ CHAR * pUsername,
+ CHAR * pPassword );
+
+/*===========================================================================
+METHOD:
+ GetDefaultProfile
+
+DESCRIPTION:
+ This function reads the default profile settings from the device, the
+ default profile is used during autoconnect
+
+PARAMETERS:
+ profileType [ I ] - Profile type being read
+ pPDPType [ O ] - PDP type
+ pIPAddress [ O ] - Preferred assigned IPv4 address
+ pPrimaryDNS [ O ] - Primary DNS IPv4 address
+ pSecondaryDNS [ O ] - Secondary DNS IPv4 address
+ pAuthentication [ O ] - Authentication algorithm bitmap
+ nameSize [ I ] - The maximum number of characters (including
+ NULL terminator) that the profile name array
+ can contain
+ pName [ O ] - The profile name or description
+ apnSize [ I ] - The maximum number of characters (including
+ NULL terminator) that the APN name array
+ can contain
+ pAPNName [ O ] - Access point name represented as a NULL
+ terminated string (empty string returned when
+ unknown)
+ userSize [ I ] - The maximum number of characters (including
+ NULL terminator) that the username array
+ can contain
+ pUsername [ O ] - Username used during authentication
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetDefaultProfile(
+ ULONG profileType,
+ ULONG * pPDPType,
+ ULONG * pIPAddress,
+ ULONG * pPrimaryDNS,
+ ULONG * pSecondaryDNS,
+ ULONG * pAuthentication,
+ BYTE nameSize,
+ CHAR * pName,
+ BYTE apnSize,
+ CHAR * pAPNName,
+ BYTE userSize,
+ CHAR * pUsername );
+
+/*===========================================================================
+METHOD:
+ StartDataSession
+
+DESCRIPTION:
+ These functions activate a packet data session
+
+PARAMETERS:
+ pTechnology [ I ] - (Optional) Technology bitmap
+ pPrimaryDNS [ I ] - (Optional) Primary DNS IPv4 address
+ pSecondaryDNS [ I ] - (Optional) Secondary DNS IPv4 address
+ pPrimaryNBNS [ I ] - (Optional) Primary NetBIOS NS IPv4 address
+ pSecondaryNBNS [ I ] - (Optional) Secondary NetBIOS NS IPv4 address
+ pAPNName [ I ] - (Optional) Access point name
+ pIPAddress [ I ] - (Optional) Preferred assigned IPv4 address
+ pAuthentication [ I ] - (Optional) Authentication algorithm bitmap
+ pUsername [ I ] - (Optional) Username used during authentication
+ pPassword [ I ] - (Optional) Password used during authentication
+ pSessionId [ O ] - The assigned session ID
+ pFailureReason [ O ] - Upon call failure the failure reason provided
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG StartDataSession(
+ ULONG * pTechnology,
+ ULONG * pPrimaryDNS,
+ ULONG * pSecondaryDNS,
+ ULONG * pPrimaryNBNS,
+ ULONG * pSecondaryNBNS,
+ CHAR * pAPNName,
+ ULONG * pIPAddress,
+ ULONG * pAuthentication,
+ CHAR * pUsername,
+ CHAR * pPassword,
+ ULONG * pSessionId,
+ ULONG * pFailureReason );
+
+/*===========================================================================
+METHOD:
+ CancelDataSession
+
+DESCRIPTION:
+ This function cancels an in-progress packet data session activation
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG CancelDataSession();
+
+/*===========================================================================
+METHOD:
+ StopDataSession
+
+DESCRIPTION:
+ This function stops the current data session
+
+PARAMETERS:
+ sessionId [ I ] - The ID of the session to terminate
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG StopDataSession( ULONG sessionId );
+
+/*===========================================================================
+METHOD:
+ GetIPAddress
+
+DESCRIPTION:
+ This function returns the current packet data session IP address
+
+PARAMETERS:
+ pIPAddress [ O ] - Assigned IPv4 address
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetIPAddress( ULONG * pIPAddress );
+
+/*===========================================================================
+METHOD:
+ GetConnectionRate
+
+DESCRIPTION:
+ This function returns connection rate information for the packet data
+ connection
+
+PARAMETERS:
+ pCurrentChannelTXRate [ O ] - Current channel TX rate (bps)
+ pCurrentChannelRXRate [ O ] - Current channel RX rate (bps)
+ pMaxChannelTXRate [ O ] - Maximum channel TX rate (bps)
+ pMaxChannelRXRate [ O ] - Maximum channel RX rate (bps)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetConnectionRate(
+ ULONG * pCurrentChannelTXRate,
+ ULONG * pCurrentChannelRXRate,
+ ULONG * pMaxChannelTXRate,
+ ULONG * pMaxChannelRXRate );
+
+/*===========================================================================
+METHOD:
+ GetPacketStatus
+
+DESCRIPTION:
+ This function returns the packet data transfer statistics since the start
+ of the current packet data session
+
+PARAMETERS:
+ pTXPacketSuccesses [ O ] - Packets transmitted without error
+ pRXPacketSuccesses [ O ] - Packets received without error
+ pTXPacketErrors [ O ] - Outgoing packets with framing errors
+ pRXPacketErrors [ O ] - Incoming packets with framing errors
+ pTXPacketOverflows [ O ] - Packets dropped because TX buffer overflowed
+ pRXPacketOverflows [ O ] - Packets dropped because RX buffer overflowed
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetPacketStatus(
+ ULONG * pTXPacketSuccesses,
+ ULONG * pRXPacketSuccesses,
+ ULONG * pTXPacketErrors,
+ ULONG * pRXPacketErrors,
+ ULONG * pTXPacketOverflows,
+ ULONG * pRXPacketOverflows );
+
+/*===========================================================================
+METHOD:
+ GetByteTotals
+
+DESCRIPTION:
+ This function returns the RX/TX byte counts since the start of the
+ current packet data session
+
+PARAMETERS:
+ pTXTotalBytes [ O ] - Bytes transmitted without error
+ pRXTotalBytes [ O ] - Bytes received without error
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetByteTotals(
+ ULONGLONG * pTXTotalBytes,
+ ULONGLONG * pRXTotalBytes );
+
+/*===========================================================================
+METHOD:
+ SetMobileIP
+
+DESCRIPTION:
+ This function sets the current mobile IP setting
+
+PARAMETERS:
+ mode [ I ] - Desired mobile IP setting
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetMobileIP( ULONG mode );
+
+/*===========================================================================
+METHOD:
+ GetMobileIP
+
+DESCRIPTION:
+ This function gets the current mobile IP setting
+
+PARAMETERS:
+ pMode [ O ] - Current mobile IP setting
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetMobileIP( ULONG * pMode );
+
+/*===========================================================================
+METHOD:
+ SetActiveMobileIPProfile
+
+DESCRIPTION:
+ This function sets the active mobile IP profile index
+
+PARAMETERS:
+ pSPC [ I ] - Six digit service programming code
+ index [ I ] - Desired mobile IP profile index
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetActiveMobileIPProfile(
+ CHAR * pSPC,
+ BYTE index );
+
+/*===========================================================================
+METHOD:
+ GetActiveMobileIPProfile
+
+DESCRIPTION:
+ This function gets the the active mobile IP profile index
+
+PARAMETERS:
+ pIndex [ O ] - Active mobile IP profile index
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetActiveMobileIPProfile( BYTE * pIndex );
+
+/*===========================================================================
+METHOD:
+ SetMobileIPProfile
+
+DESCRIPTION:
+ This function sets the specified mobile IP profile settings
+
+PARAMETERS:
+ pSPC [ I ] - Six digit service programming code
+ index [ I ] - Mobile IP profile ID
+ pEnabled [ I ] - (Optional) Enable MIP profile?
+ pAddress [ I ] - (Optional) Home IPv4 address
+ pPrimaryHA [ I ] - (Optional) Primary home agent IPv4 address
+ pSecondaryHA [ I ] - (Optional) Secondary home agent IPv4 address
+ pRevTunneling [ I ] - (Optional) Enable reverse tunneling?
+ pNAI [ I ] - (Optional) Network access identifier string
+ pHASPI [ I ] - (Optional) HA security parameter index
+ pAAASPI [ I ] - (Optional) AAA security parameter index
+ pMNHA [ I ] - (Optional) MN-HA string
+ pMNAAA [ I ] - (Optional) MN-AAA string
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetMobileIPProfile(
+ CHAR * pSPC,
+ BYTE index,
+ BYTE * pEnabled,
+ ULONG * pAddress,
+ ULONG * pPrimaryHA,
+ ULONG * pSecondaryHA,
+ BYTE * pRevTunneling,
+ CHAR * pNAI,
+ ULONG * pHASPI,
+ ULONG * pAAASPI,
+ CHAR * pMNHA,
+ CHAR * pMNAAA );
+
+/*===========================================================================
+METHOD:
+ GetMobileIPProfile
+
+DESCRIPTION:
+ This function gets the specified mobile IP profile settings
+
+PARAMETERS:
+ index [ I ] - Mobile IP profile ID
+ pEnabled [ O ] - Mobile IP profile enabled?
+ pAddress [ O ] - Home IPv4 address
+ pPrimaryHA [ O ] - Primary home agent IPv4 address
+ pSecondaryHA [ O ] - Secondary home agent IPv4 address
+ pRevTunneling [ O ] - Reverse tunneling enabled?
+ naiSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the NAI array can contain
+ pNAI [ O ] - Network access identifier string
+ pHASPI [ O ] - HA security parameter index
+ pAAASPI [ O ] - AAA security parameter index
+ pHAState [ O ] - HA key state
+ pAAAState [ O ] - AAA key state
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetMobileIPProfile(
+ BYTE index,
+ BYTE * pEnabled,
+ ULONG * pAddress,
+ ULONG * pPrimaryHA,
+ ULONG * pSecondaryHA,
+ BYTE * pRevTunneling,
+ BYTE naiSize,
+ CHAR * pNAI,
+ ULONG * pHASPI,
+ ULONG * pAAASPI,
+ ULONG * pHAState,
+ ULONG * pAAAState );
+
+/*===========================================================================
+METHOD:
+ SetMobileIPParameters
+
+DESCRIPTION:
+ This function sets the specified mobile IP parameters
+
+PARAMETERS:
+ pSPC [ I ] - Six digit service programming code
+ pMode [ I ] - (Optional) Desired mobile IP setting
+ pRetryLimit [ I ] - (Optional) Retry attempt limit
+ pRetryInterval [ I ] - (Optional) Retry attempt interval
+ pReRegPeriod [ I ] - (Optional) Re-registration period
+ pReRegTraffic [ I ] - (Optional) Re-registration only with traffic?
+ pHAAuthenticator [ I ] - (Optional) MH-HA authenticator calculator?
+ pHA2002bis [ I ] - (Optional) MH-HA RFC 2002bis authentication?
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetMobileIPParameters(
+ CHAR * pSPC,
+ ULONG * pMode,
+ BYTE * pRetryLimit,
+ BYTE * pRetryInterval,
+ BYTE * pReRegPeriod,
+ BYTE * pReRegTraffic,
+ BYTE * pHAAuthenticator,
+ BYTE * pHA2002bis );
+
+/*===========================================================================
+METHOD:
+ GetMobileIPParameters
+
+DESCRIPTION:
+ This function gets the mobile IP parameters
+
+PARAMETERS:
+ pMode [ O ] - Current mobile IP setting
+ pRetryLimit [ O ] - Retry attempt limit
+ pRetryInterval [ O ] - Retry attempt interval
+ pReRegPeriod [ O ] - Re-registration period
+ pReRegTraffic [ O ] - Re-registration only with traffic?
+ pHAAuthenticator [ O ] - MH-HA authenticator calculator?
+ pHA2002bis [ O ] - MH-HA RFC 2002bis authentication?
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetMobileIPParameters(
+ ULONG * pMode,
+ BYTE * pRetryLimit,
+ BYTE * pRetryInterval,
+ BYTE * pReRegPeriod,
+ BYTE * pReRegTraffic,
+ BYTE * pHAAuthenticator,
+ BYTE * pHA2002bis );
+
+/*===========================================================================
+METHOD:
+ GetLastMobileIPError
+
+DESCRIPTION:
+ This function gets the last mobile IP error
+
+PARAMETERS:
+ pError [ O ] - Last mobile IP error
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetLastMobileIPError( ULONG * pError );
+
+/*===========================================================================
+METHOD:
+ SetDNSSettings
+
+DESCRIPTION:
+ This function sets the DNS settings for the device
+
+PARAMETERS:
+ pPrimaryDNS [ I ] - (Optional) Primary DNS IPv4 address
+ pSecondaryDNS [ I ] - (Optional) Secondary DNS IPv4 address
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetDNSSettings(
+ ULONG * pPrimaryDNS,
+ ULONG * pSecondaryDNS );
+
+/*===========================================================================
+METHOD:
+ GetDNSSettings
+
+DESCRIPTION:
+ This function gets the DNS settings for the device
+
+PARAMETERS:
+ pPrimaryDNS [ O ] - Primary DNS IPv4 address
+ pSecondaryDNS [ O ] - Secondary DNS IPv4 address
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetDNSSettings(
+ ULONG * pPrimaryDNS,
+ ULONG * pSecondaryDNS );
+
+/*===========================================================================
+METHOD:
+ GetANAAAAuthenticationStatus
+
+DESCRIPTION:
+ This function gets the AN-AAA authentication status
+
+PARAMETERS:
+ pStatus [ O ] - AN-AAA authentication status
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetANAAAAuthenticationStatus( ULONG * pStatus );
+
+/*===========================================================================
+METHOD:
+ GetSignalStrengths
+
+DESCRIPTION:
+ This function gets the current available signal strengths (in dBm)
+ as measured by the device
+
+PARAMETERS:
+ pArraySizes [I/O] - Upon input the maximum number of elements
+ that each array can contain can contain.
+ Upon successful output the actual number
+ of elements in each array
+ pSignalStrengths [ O ] - Received signal strength array (dBm)
+ pRadioInterfaces [ O ] - Radio interface technology array
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetSignalStrengths(
+ ULONG * pArraySizes,
+ INT8 * pSignalStrengths,
+ ULONG * pRadioInterfaces );
+
+/*===========================================================================
+METHOD:
+ GetRFInfo (Public Method)
+
+DESCRIPTION:
+ This function gets the current RF information
+
+PARAMETERS:
+ pInstanceSize [I/O] - Upon input the maximum number of elements that the
+ RF info instance array can contain. Upon success
+ the actual number of elements in the RF info
+ instance array
+ pInstances [ O ] - The RF info instance array
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetRFInfo(
+ BYTE * pInstanceSize,
+ BYTE * pInstances );
+
+/*===========================================================================
+METHOD:
+ PerformNetworkScan
+
+DESCRIPTION:
+ This function performs a scan for available networks
+
+PARAMETERS:
+ pInstanceSize [I/O] - Upon input the maximum number of elements that the
+ network info instance array can contain. Upon
+ success the actual number of elements in the
+ network info instance array
+ pInstances [ O ] - The network info instance array
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG PerformNetworkScan(
+ BYTE * pInstanceSize,
+ BYTE * pInstances );
+
+/*===========================================================================
+METHOD:
+ PerformNetworkRATScan
+
+DESCRIPTION:
+ This function performs a scan for available networks (includes RAT)
+
+PARAMETERS:
+ pInstanceSize [I/O] - Upon input the maximum number of elements that the
+ network info instance array can contain. Upon
+ success the actual number of elements in the
+ network info instance array
+ pInstances [ O ] - The network info instance array
+ pRATSize [I/O] - Upon input the maximum number of elements that the
+ RAT info instance array can contain. Upon success
+ the actual number of elements in the RAT info
+ instance array
+ pRATInstances [ O ] - The RAT info instance array
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG PerformNetworkRATScan(
+ BYTE * pInstanceSize,
+ BYTE * pInstances,
+ BYTE * pRATSize,
+ BYTE * pRATInstances );
+
+/*===========================================================================
+METHOD:
+ InitiateNetworkRegistration
+
+DESCRIPTION:
+ This function initiates a network registration
+
+PARAMETERS:
+ regType [ I ] - Registration type
+ mcc [ I ] - Mobile country code (ignored for auto registration)
+ mnc [ I ] - Mobile network code (ignored for auto registration)
+ rat [ I ] - Radio access type (ignored for auto registration)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG InitiateNetworkRegistration(
+ ULONG regType,
+ WORD mcc,
+ WORD mnc,
+ ULONG rat );
+
+/*===========================================================================
+METHOD:
+ InitiateDomainAttach
+
+DESCRIPTION:
+ This function initiates a domain attach (or detach)
+
+PARAMETERS:
+ action [ I ] - PS attach action (attach or detach)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG InitiateDomainAttach( ULONG action );
+
+/*===========================================================================
+METHOD:
+ GetServingNetwork
+
+DESCRIPTION:
+ Gets information regarding the system that currently provides service
+ to the device
+
+PARAMETERS:
+ pRegistrationState [ O ] - Registration state
+ pCSDomain [ O ] - Circuit switch domain status
+ pPSDomain [ O ] - Packet switch domain status
+ pRAN [ O ] - Radio access network
+ pRadioIfacesSize [I/O] - Upon input the maximum number of elements
+ that the radio interfaces can contain. Upon
+ successful output the actual number of elements
+ in the radio interface array
+ pRadioIfaces [ O ] - The radio interface array
+ pRoaming [ O ] - Roaming indicator (0xFFFFFFFF - Unknown)
+ pMCC [ O ] - Mobile country code (0xFFFF - Unknown)
+ pMNC [ O ] - Mobile network code (0xFFFF - Unknown)
+ nameSize [ I ] - The maximum number of characters (including
+ NULL terminator) that the network name array
+ can contain
+ pName [ O ] - The network name or description represented
+ as a NULL terminated string (empty string
+ returned when unknown)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetServingNetwork(
+ ULONG * pRegistrationState,
+ ULONG * pCSDomain,
+ ULONG * pPSDomain,
+ ULONG * pRAN,
+ BYTE * pRadioIfacesSize,
+ BYTE * pRadioIfaces,
+ ULONG * pRoaming,
+ WORD * pMCC,
+ WORD * pMNC,
+ BYTE nameSize,
+ CHAR * pName );
+
+/*===========================================================================
+METHOD:
+ GetServingNetworkCapabilities
+
+DESCRIPTION:
+ Gets information regarding the data capabilities of the system that
+ currently provides service to the device
+
+PARAMETERS:
+ pDataCapsSize [I/O] - Upon input the maximum number of elements that the
+ data capabilities array can contain. Upon success
+ the actual number of elements in the data
+ capabilities array
+ pDataCaps [ O ] - The data capabilities array
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetServingNetworkCapabilities(
+ BYTE * pDataCapsSize,
+ BYTE * pDataCaps );
+
+/*===========================================================================
+METHOD:
+ GetDataBearerTechnology
+
+DESCRIPTION:
+ This function retrieves the current data bearer technology (only
+ valid when connected)
+
+PARAMETERS:
+ pDataCaps [ O ] - The data bearer technology
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetDataBearerTechnology( ULONG * pDataBearer );
+
+/*===========================================================================
+METHOD:
+ GetHomeNetwork
+
+DESCRIPTION:
+ This function retrieves information about the home network of the device
+
+PARAMETERS:
+ pMCC [ O ] - Mobile country code
+ pMNC [ O ] - Mobile network code
+ nameSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the network name array can contain
+ pName [ O ] - The network name or description represented as a NULL
+ terminated string (empty string returned when unknown)
+ pSID [ O ] - Home network system ID (0xFFFF - Unknown)
+ pNID [ O ] - Home network ID (0xFFFF - Unknown)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetHomeNetwork(
+ WORD * pMCC,
+ WORD * pMNC,
+ BYTE nameSize,
+ CHAR * pName,
+ WORD * pSID,
+ WORD * pNID );
+
+/*===========================================================================
+METHOD:
+ SetNetworkPreference
+
+DESCRIPTION:
+ This function sets the network registration preference
+
+PARAMETERS:
+ technologyPref [ I ] - Technology preference bitmap
+ duration [ I ] - Duration of active preference
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetNetworkPreference(
+ ULONG technologyPref,
+ ULONG duration );
+
+/*===========================================================================
+METHOD:
+ GetNetworkPreference
+
+DESCRIPTION:
+ This function returns the network registration preference
+
+PARAMETERS:
+ pTechnologyPref [ O ] - Technology preference bitmap
+ pDuration [ O ] - Duration of active preference
+ pPersistentTechnologyPref [ O ] - Persistent technology preference bitmap
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetNetworkPreference(
+ ULONG * pTechnologyPref,
+ ULONG * pDuration,
+ ULONG * pPersistentTechnologyPref );
+
+/*===========================================================================
+METHOD:
+ SetCDMANetworkParameters
+
+DESCRIPTION:
+ This function sets the desired CDMA network parameters
+
+PARAMETERS:
+ pSPC [ I ] - Six digit service programming code
+ pForceRev0 [ I ] - (Optional) Force CDMA 1x-EV-DO Rev. 0 mode?
+ pCustomSCP [ I ] - (Optional) Use a custom config for CDMA 1x-EV-DO SCP?
+ pProtocol [ I ] - (Optional) Protocol mask for custom SCP config
+ pBroadcast [ I ] - (Optional) Broadcast mask for custom SCP config
+ pApplication [ I ] - (Optional) Application mask for custom SCP config
+ pRoaming [ I ] - (Optional) Roaming preference
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetCDMANetworkParameters(
+ CHAR * pSPC,
+ BYTE * pForceRev0,
+ BYTE * pCustomSCP,
+ ULONG * pProtocol,
+ ULONG * pBroadcast,
+ ULONG * pApplication,
+ ULONG * pRoaming );
+
+/*===========================================================================
+METHOD:
+ GetCDMANetworkParameters
+
+DESCRIPTION:
+ This function gets the current CDMA network parameters
+
+PARAMETERS:
+ pSCI [ O ] - Slot cycle index
+ pSCM [ O ] - Station class mark
+ pRegHomeSID [ O ] - Register on home SID?
+ pRegForeignSID [ O ] - Register on foreign SID?
+ pRegForeignNID [ O ] - Register on foreign NID?
+ pForceRev0 [ O ] - Force CDMA 1x-EV-DO Rev. 0 mode?
+ pCustomSCP [ O ] - Use a custom config for CDMA 1x-EV-DO SCP?
+ pProtocol [ O ] - Protocol mask for custom SCP config
+ pBroadcast [ O ] - Broadcast mask for custom SCP config
+ pApplication [ O ] - Application mask for custom SCP config
+ pRoaming [ O ] - Roaming preference
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetCDMANetworkParameters(
+ BYTE * pSCI,
+ BYTE * pSCM,
+ BYTE * pRegHomeSID,
+ BYTE * pRegForeignSID,
+ BYTE * pRegForeignNID,
+ BYTE * pForceRev0,
+ BYTE * pCustomSCP,
+ ULONG * pProtocol,
+ ULONG * pBroadcast,
+ ULONG * pApplication,
+ ULONG * pRoaming );
+
+/*===========================================================================
+METHOD:
+ GetACCOLC
+
+DESCRIPTION:
+ This function returns the Access Overload Class (ACCOLC) of the device
+
+PARAMETERS:
+ pACCOLC [ O ] - The ACCOLC
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetACCOLC( BYTE * pACCOLC );
+
+/*===========================================================================
+METHOD:
+ SetACCOLC
+
+DESCRIPTION:
+ This function sets the Access Overload Class (ACCOLC) of the device
+
+PARAMETERS:
+ pSPC [ I ] - NULL terminated string representing the six digit
+ service programming code
+ accolc [ I ] - The ACCOLC
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetACCOLC(
+ CHAR * pSPC,
+ BYTE accolc );
+
+/*===========================================================================
+METHOD:
+ GetPLMNMode
+
+DESCRIPTION:
+ This function returns the PLMN mode from the CSP
+
+PARAMETERS:
+ pMode [ O ] - PLMN mode
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetPLMNMode( ULONG * pMode );
+
+/*===========================================================================
+METHOD:
+ GetPLMNName
+
+DESCRIPTION:
+ This function returns PLMN name information for the given MCC/MNC
+
+PARAMETERS:
+ mcc [ I ] - Mobile country code
+ mnc [ I ] - Mobile network code
+ pNamesSize [I/O] - Upon input the size in BYTEs of the name structure
+ array. Upon success the actual number of BYTEs
+ copied to the name structure array
+ pNames [ O ] - The name structure array
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetPLMNName(
+ USHORT mcc,
+ USHORT mnc,
+ ULONG * pNamesSize,
+ BYTE * pNames );
+
+/*===========================================================================
+METHOD:
+ GetDeviceCapabilities
+
+DESCRIPTION:
+ This function gets device capabilities
+
+PARAMETERS:
+ pMaxTxChannelRate [ O ] - Maximum transmission rate (bps)
+ pMaxRxChannelRate [ O ] - Maximum reception rate (bps)
+ pDataServiceCapability [ O ] - CS/PS data service capability
+ pSimCapability [ O ] - Device SIM support
+ pRadioIfacesSize [I/O] - Upon input the maximum number of elements
+ that the radio interfaces can contain.
+ Upon successful output the actual number
+ of elements in the radio interface array
+ pRadioIfaces [ O ] - The radio interface array
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetDeviceCapabilities(
+ ULONG * pMaxTXChannelRate,
+ ULONG * pMaxRXChannelRate,
+ ULONG * pDataServiceCapability,
+ ULONG * pSimCapability,
+ ULONG * pRadioIfacesSize,
+ BYTE * pRadioIfaces );
+
+/*===========================================================================
+METHOD:
+ GetManufacturer
+
+DESCRIPTION:
+ This function returns the device manufacturer name
+
+PARAMETERS:
+ stringSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the string array can contain
+ pString [ O ] - NULL terminated string
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetManufacturer(
+ BYTE stringSize,
+ CHAR * pString );
+
+/*===========================================================================
+METHOD:
+ GetModelID
+
+DESCRIPTION:
+ This function returns the device model ID
+
+PARAMETERS:
+ stringSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the string array can contain
+ pString [ O ] - NULL terminated string
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetModelID(
+ BYTE stringSize,
+ CHAR * pString );
+
+/*===========================================================================
+METHOD:
+ GetFirmwareRevision
+
+DESCRIPTION:
+ This function returns the device firmware revision
+
+PARAMETERS:
+ stringSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the string array can contain
+ pString [ O ] - NULL terminated string
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetFirmwareRevision(
+ BYTE stringSize,
+ CHAR * pString );
+
+/*===========================================================================
+METHOD:
+ GetFirmwareRevisions
+
+DESCRIPTION:
+ This function returns the device firmware (AMSS, boot, and PRI)
+ revisions
+
+PARAMETERS:
+ amssSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the AMSS string array can contain
+ pAMSSString [ O ] - NULL terminated AMSS revision string
+ bootSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the boot string array can contain
+ pBootString [ O ] - NULL terminated boot code revision string
+ priSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the PRI string array can contain
+ pPRIString [ O ] - NULL terminated PRI revision string
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetFirmwareRevisions(
+ BYTE amssSize,
+ CHAR * pAMSSString,
+ BYTE bootSize,
+ CHAR * pBootString,
+ BYTE priSize,
+ CHAR * pPRIString );
+
+/*===========================================================================
+METHOD:
+ GetFirmwareInfo
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetFirmwareInfo(
+ ULONG * pFirmwareID,
+ ULONG * pTechnology,
+ ULONG * pCarrier,
+ ULONG * pRegion,
+ ULONG * pGPSCapability );
+
+/*===========================================================================
+METHOD:
+ GetVoiceNumber
+
+DESCRIPTION:
+ This function returns the voice number in use by the device
+
+PARAMETERS:
+ voiceNumberSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the voice number array can
+ contain
+ pVoiceNumber [ O ] - Voice number (MDN or ISDN) string
+ minSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the MIN array can contain
+ pMIN [ O ] - MIN string (empty string returned when MIN is
+ not supported/programmed)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetVoiceNumber(
+ BYTE voiceNumberSize,
+ CHAR * pVoiceNumber,
+ BYTE minSize,
+ CHAR * pMIN );
+
+/*===========================================================================
+METHOD:
+ GetIMSI
+
+DESCRIPTION:
+ This function returns the device IMSI
+
+PARAMETERS:
+ stringSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the string array can contain
+ pString [ O ] - NULL terminated string
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetIMSI(
+ BYTE stringSize,
+ CHAR * pString );
+
+/*===========================================================================
+METHOD:
+ GetSerialNumbers
+
+DESCRIPTION:
+ This command returns all serial numbers assigned to the device
+
+PARAMETERS:
+ esnSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the ESN array can contain
+ pESNString [ O ] - ESN string (empty string returned when ESN is
+ not supported/programmed)
+ imeiSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the IMEI array can contain
+ pIMEIString [ O ] - IMEI string (empty string returned when IMEI is
+ not supported/programmed)
+ meidSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the MEID array can contain
+ pMEIDString [ O ] - MEID string (empty string returned when MEID is
+ not supported/programmed)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetSerialNumbers(
+ BYTE esnSize,
+ CHAR * pESNString,
+ BYTE imeiSize,
+ CHAR * pIMEIString,
+ BYTE meidSize,
+ CHAR * pMEIDString );
+
+/*===========================================================================
+METHOD:
+ SetLock
+
+DESCRIPTION:
+ This function sets the user lock state maintained by the device
+
+PARAMETERS:
+ state [ I ] - Desired lock state
+ pCurrentPIN [ I ] - Current four digit PIN string
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetLock(
+ ULONG state,
+ CHAR * pCurrentPIN );
+
+/*===========================================================================
+METHOD:
+ QueryLock
+
+DESCRIPTION:
+ This function sets the user lock state maintained by the device
+
+PARAMETERS:
+ pState [ O ] - Current lock state
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG QueryLock( ULONG * pState );
+
+/*===========================================================================
+METHOD:
+ ChangeLockPIN
+
+DESCRIPTION:
+ This command sets the user lock code maintained by the device
+
+PARAMETERS:
+ pCurrentPIN [ O ] - Current four digit PIN string
+ pDesiredPIN [ O ] - New four digit PIN string
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG ChangeLockPIN(
+ CHAR * pCurrentPIN,
+ CHAR * pDesiredPIN );
+
+/*===========================================================================
+METHOD:
+ GetHardwareRevision
+
+DESCRIPTION:
+ This function returns the device hardware revision
+
+PARAMETERS:
+ stringSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the string array can contain
+ pString [ O ] - NULL terminated string
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetHardwareRevision(
+ BYTE stringSize,
+ CHAR * pString );
+
+/*===========================================================================
+METHOD:
+ GetPRLVersion
+
+DESCRIPTION:
+ This function returns the version of the active Preferred Roaming List
+ (PRL) in use by the device
+
+PARAMETERS:
+ pPRLVersion [ O ] - The PRL version number
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetPRLVersion( WORD * pPRLVersion );
+
+/*===========================================================================
+METHOD:
+ GetERIFile
+
+DESCRIPTION:
+ This command returns the ERI file that is stored in EFS on the device
+
+PARAMETERS:
+ pFileSize [I/O] - Upon input the maximum number of bytes that the file
+ contents array can contain. Upon successful output
+ the actual number of bytes written to the file contents
+ array
+ pFile [ O ] - The file contents
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetERIFile(
+ ULONG * pFileSize,
+ BYTE * pFile );
+
+/*===========================================================================
+METHOD:
+ ActivateAutomatic
+
+DESCRIPTION:
+ This function requests the device to perform automatic service activation
+
+PARAMETERS:
+ pActivationCode [ I ] - Activation code (maximum string length of 12)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG ActivateAutomatic( CHAR * pActivationCode );
+
+/*===========================================================================
+METHOD:
+ ActivateManual
+
+DESCRIPTION:
+ This function requests the device perform manual service activation,
+ after a successful request the device is then asked to reset
+
+PARAMETERS:
+ pSPC [ I ] - NULL terminated string representing the six digit
+ service programming code
+ sid [ I ] - System identification number
+ pMDN [ I ] - Mobile Directory Number string
+ pMIN [ I ] - Mobile Identification Number string
+ prlSize [ I ] - (Optional) Size of PRL file array
+ pPRL [ I ] - (Optional) The PRL file contents
+ pMNHA [ I ] - (Optional) MN-HA string
+ pMNAAA [ I ] - (Optional) MN-AAA string
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG ActivateManual(
+ CHAR * pSPC,
+ WORD sid,
+ CHAR * pMDN,
+ CHAR * pMIN,
+ ULONG prlSize,
+ BYTE * pPRL,
+ CHAR * pMNHA,
+ CHAR * pMNAAA );
+
+/*===========================================================================
+METHOD:
+ ResetToFactoryDefaults
+
+DESCRIPTION:
+ This function requests the device reset configuration to factory defaults,
+ after a successful request the device is then asked to reset
+
+PARAMETERS:
+ pSPC [ I ] - NULL terminated string representing the six digit
+ service programming code
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG ResetToFactoryDefaults( CHAR * pSPC );
+
+/*===========================================================================
+METHOD:
+ GetActivationState
+
+DESCRIPTION:
+ This function returns the device activation state
+
+PARAMETERS:
+ pActivationState [ O ] - Service activation state
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetActivationState( ULONG * pActivationState );
+
+/*===========================================================================
+METHOD:
+ SetPower
+
+DESCRIPTION:
+ This function sets the operating mode of the device
+
+PARAMETERS:
+ powerMode [ I ] - Selected operating mode
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetPower( ULONG powerMode );
+
+/*===========================================================================
+METHOD:
+ GetPower
+
+DESCRIPTION:
+ This function returns the operating mode of the device
+
+PARAMETERS:
+ pPowerMode [ O ] - Current operating mode
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetPower( ULONG * pPowerMode );
+
+/*===========================================================================
+METHOD:
+ GetOfflineReason
+
+DESCRIPTION:
+ This function returns the reason why the operating mode of the device
+ is currently offline
+
+PARAMETERS:
+ pReasonMask [ O ] - Bitmask of offline reasons
+ pbPlatform [ O ] - Offline due to being platform retricted?
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetOfflineReason(
+ ULONG * pReasonMask,
+ ULONG * pbPlatform );
+
+/*===========================================================================
+METHOD:
+ GetNetworkTime
+
+DESCRIPTION:
+ This function returns the current time of the device
+
+PARAMETERS:
+ pTimeStamp [ O ] - Count of 1.25ms that have elapsed from the start
+ of GPS time (Jan 6, 1980)
+ pTimeSource [ O ] - Source of the timestamp
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetNetworkTime(
+ ULONGLONG * pTimeCount,
+ ULONG * pTimeSource );
+
+/*===========================================================================
+METHOD:
+ ValidateSPC
+
+DESCRIPTION:
+ This function validates the service programming code
+
+PARAMETERS:
+ pSPC [ I ] - Six digit service programming code
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG ValidateSPC( CHAR * pSPC );
+
+/*===========================================================================
+METHOD:
+ DeleteSMS
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG DeleteSMS(
+ ULONG storageType,
+ ULONG * pMessageIndex,
+ ULONG * pMessageTag );
+
+/*===========================================================================
+METHOD:
+ GetSMSList
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetSMSList(
+ ULONG storageType,
+ ULONG * pRequestedTag,
+ ULONG * pMessageListSize,
+ BYTE * pMessageList );
+
+/*===========================================================================
+METHOD:
+ GetSMS
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetSMS(
+ ULONG storageType,
+ ULONG messageIndex,
+ ULONG * pMessageTag,
+ ULONG * pMessageFormat,
+ ULONG * pMessageSize,
+ BYTE * pMessage );
+
+/*===========================================================================
+METHOD:
+ ModifySMSStatus
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG ModifySMSStatus(
+ ULONG storageType,
+ ULONG messageIndex,
+ ULONG messageTag );
+
+/*===========================================================================
+METHOD:
+ SaveSMS
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG SaveSMS(
+ ULONG storageType,
+ ULONG messageFormat,
+ ULONG messageSize,
+ BYTE * pMessage,
+ ULONG * pMessageIndex );
+
+/*===========================================================================
+METHOD:
+ SendSMS
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG SendSMS(
+ ULONG messageFormat,
+ ULONG messageSize,
+ BYTE * pMessage,
+ ULONG * pMessageFailureCode );
+
+/*===========================================================================
+METHOD:
+ GetSMSCAddress
+
+DESCRIPTION:
+ This function returns 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:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetSMSCAddress(
+ BYTE addressSize,
+ CHAR * pSMSCAddress,
+ BYTE typeSize,
+ CHAR * pSMSCType );
+
+/*===========================================================================
+METHOD:
+ SetSMSCAddress
+
+DESCRIPTION:
+ This function sets the SMS center address
+
+PARAMETERS:
+ pSMSCAddress [ I ] - The SMS center address represented as a NULL
+ terminated string
+ pSMSCType [ I ] - The SMS center address type represented as a NULL
+ terminated string (optional)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetSMSCAddress(
+ CHAR * pSMSCAddress,
+ CHAR * pSMSCType );
+
+/*===========================================================================
+METHOD:
+ GetSMSRoutes
+
+DESCRIPTION:
+ This function gets 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
+===========================================================================*/
+ULONG GetSMSRoutes(
+ BYTE * pRouteSize,
+ BYTE * pRoutes );
+
+/*===========================================================================
+METHOD:
+ SetSMSRoutes
+
+DESCRIPTION:
+ This function sets 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
+===========================================================================*/
+ULONG SetSMSRoutes(
+ BYTE * pRouteSize,
+ BYTE * pRoutes );
+
+/*===========================================================================
+METHOD:
+ UIMSetPINProtection
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG UIMSetPINProtection(
+ ULONG id,
+ ULONG bEnable,
+ CHAR * pValue,
+ ULONG * pVerifyRetriesLeft,
+ ULONG * pUnblockRetriesLeft );
+
+/*===========================================================================
+METHOD:
+ UIMVerifyPIN
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG UIMVerifyPIN(
+ ULONG id,
+ CHAR * pValue,
+ ULONG * pVerifyRetriesLeft,
+ ULONG * pUnblockRetriesLeft );
+
+/*===========================================================================
+METHOD:
+ UIMUnblockPIN
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG UIMUnblockPIN(
+ ULONG id,
+ CHAR * pPUKValue,
+ CHAR * pNewValue,
+ ULONG * pVerifyRetriesLeft,
+ ULONG * pUnblockRetriesLeft );
+
+/*===========================================================================
+METHOD:
+ UIMChangePIN
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG UIMChangePIN(
+ ULONG id,
+ CHAR * pOldValue,
+ CHAR * pNewValue,
+ ULONG * pVerifyRetriesLeft,
+ ULONG * pUnblockRetriesLeft );
+
+/*===========================================================================
+METHOD:
+ UIMGetPINStatus
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG UIMGetPINStatus(
+ ULONG id,
+ ULONG * pStatus,
+ ULONG * pVerifyRetriesLeft,
+ ULONG * pUnblockRetriesLeft );
+
+/*===========================================================================
+METHOD:
+ UIMGetICCID
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG UIMGetICCID(
+ BYTE stringSize,
+ CHAR * pString );
+/*===========================================================================
+METHOD:
+ UIMGetControlKeyStatus
+
+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
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG UIMGetControlKeyStatus(
+ ULONG id,
+ ULONG * pStatus,
+ ULONG * pVerifyRetriesLeft,
+ ULONG * pUnblockRetriesLeft );
+
+/*===========================================================================
+METHOD:
+ UIMGetControlKeyBlockingStatus
+
+DESCRIPTION:
+ This function returns the blocking 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
+===========================================================================*/
+ULONG UIMGetControlKeyBlockingStatus(
+ ULONG id,
+ ULONG * pStatus,
+ ULONG * pVerifyRetriesLeft,
+ ULONG * pUnblockRetriesLeft,
+ ULONG * pbBlocking );
+
+/*===========================================================================
+METHOD:
+ UIMSetControlKeyProtection
+
+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
+===========================================================================*/
+ULONG UIMSetControlKeyProtection(
+ ULONG id,
+ ULONG status,
+ CHAR * pValue,
+ ULONG * pVerifyRetriesLeft );
+
+/*===========================================================================
+METHOD:
+ UIMUnblockControlKey
+
+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
+===========================================================================*/
+ULONG UIMUnblockControlKey(
+ ULONG id,
+ CHAR * pValue,
+ ULONG * pUnblockRetriesLeft );
+
+/*===========================================================================
+METHOD:
+ GetPDSState
+
+DESCRIPTION:
+ This function returns the current PDS state
+
+PARAMETERS:
+ pEnabled [ O ] - Current PDS state (0 = disabled)
+ pTracking [ O ] - Current PDS tracking session state
+
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetPDSState(
+ ULONG * pEnabled,
+ ULONG * pTracking );
+
+/*===========================================================================
+METHOD:
+ SetPDSState
+
+DESCRIPTION:
+ This function sets the PDS state
+
+PARAMETERS:
+ enable [ I ] - Desired PDS state (0 = disable)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetPDSState( ULONG enable );
+
+/*===========================================================================
+METHOD:
+ PDSInjectTimeReference
+
+DESCRIPTION:
+ This function injects a system time into the PDS engine
+
+PARAMETERS:
+ sysTime [ I ] - System time
+ sysDiscontinuities [ I ] - Number of system time discontinuities
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG PDSInjectTimeReference(
+ ULONGLONG systemTime,
+ USHORT systemDiscontinuities );
+
+/*===========================================================================
+METHOD:
+ GetPDSDefaults
+
+DESCRIPTION:
+ This function returns the default tracking session configuration
+
+PARAMETERS:
+ pOperation [ O ] - Current session operating mode
+ pTimeout [ O ] - Maximum amount of time (seconds) to work on each fix
+ pInterval [ O ] - Interval (milliseconds) between fix requests
+ pAccuracy [ O ] - Current accuracy threshold (meters)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetPDSDefaults(
+ ULONG * pOperation,
+ BYTE * pTimeout,
+ ULONG * pInterval,
+ ULONG * pAccuracy );
+
+/*===========================================================================
+METHOD:
+ SetPDSDefaults
+
+DESCRIPTION:
+ This function sets the default tracking session configuration
+
+PARAMETERS:
+ operation [ I ] - Desired session operating mode
+ timeout [ I ] - Maximum amount of time (seconds) to work on each fix
+ interval [ I ] - Interval (milliseconds) between fix requests
+ accuracy [ I ] - Desired accuracy threshold (meters)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetPDSDefaults(
+ ULONG operation,
+ BYTE timeout,
+ ULONG interval,
+ ULONG accuracy );
+
+/*===========================================================================
+METHOD:
+ GetXTRAAutomaticDownload
+
+DESCRIPTION:
+ This function returns the XTRA automatic download configuration
+
+PARAMETERS:
+ pbEnabled [ O ] - Automatic download enabled?
+ pInterval [ O ] - Interval (hours) between XTRA downloads
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetXTRAAutomaticDownload(
+ ULONG * pbEnabled,
+ USHORT * pInterval );
+
+/*===========================================================================
+METHOD:
+ SetXTRAAutomaticDownload
+
+DESCRIPTION:
+ This function sets the XTRA automatic download configuration
+
+PARAMETERS:
+ bEnabled [ I ] - Automatic download enabled?
+ interval [ I ] - Interval (hours) between XTRA downloads
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetXTRAAutomaticDownload(
+ ULONG bEnabled,
+ USHORT interval );
+
+/*===========================================================================
+METHOD:
+ GetXTRANetwork
+
+DESCRIPTION:
+ This function returns the XTRA WWAN network preference
+
+PARAMETERS:
+ pPreference [ O ] - XTRA WWAN network preference
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetXTRANetwork( ULONG * pPreference );
+
+/*===========================================================================
+METHOD:
+ SetXTRANetwork
+
+DESCRIPTION:
+ This function sets the XTRA WWAN network preference
+
+PARAMETERS:
+ preference [ I ] - XTRA WWAN network preference
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetXTRANetwork( ULONG preference );
+
+/*===========================================================================
+METHOD:
+ GetXTRAValidity
+
+DESCRIPTION:
+ This function returns the XTRA database validity period
+
+PARAMETERS:
+ pGPSWeek [ O ] - Starting GPS week of validity period
+ pGPSWeekOffset [ O ] - Starting GPS week offset (minutes) of validity period
+ pDuration [ O ] - Length of validity period (hours)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetXTRAValidity(
+ USHORT * pGPSWeek,
+ USHORT * pGPSWeekOffset,
+ USHORT * pDuration );
+
+/*===========================================================================
+METHOD:
+ ForceXTRADownload
+
+DESCRIPTION:
+ This function forces the XTRA database to be downloaded to the device
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG ForceXTRADownload();
+
+/*===========================================================================
+METHOD:
+ GetXTRADataState
+
+DESCRIPTION:
+ This function returns the XTRA data positioning state
+
+PARAMETERS:
+ pState [ O ] - XTRA data positioning state
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetXTRADataState( ULONG * pState );
+
+/*===========================================================================
+METHOD:
+ SetXTRADataState
+
+DESCRIPTION:
+ This function sets the XTRA data positioning state
+
+PARAMETERS:
+ state [ I ] - XTRA data positioning state
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetXTRADataState( ULONG state );
+
+/*===========================================================================
+METHOD:
+ GetXTRATimeState
+
+DESCRIPTION:
+ This function returns the XTRA time positioning state
+
+PARAMETERS:
+ pState [ O ] - XTRA time positioning state
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetXTRATimeState( ULONG * pState );
+
+/*===========================================================================
+METHOD:
+ SetXTRATimeState
+
+DESCRIPTION:
+ This function sets the XTRA time positioning state
+
+PARAMETERS:
+ state [ I ] - XTRA time positioning state
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetXTRATimeState( ULONG state );
+
+/*===========================================================================
+METHOD:
+ GetAGPSConfig
+
+DESCRIPTION:
+ This function returns the PDS AGPS configuration
+
+PARAMETERS:
+ pServerAddress [ O ] - IPv4 address of AGPS server
+ pServerPort [ O ] - Port number of AGPS server
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetAGPSConfig(
+ ULONG * pServerAddress,
+ ULONG * pServerPort );
+
+/*===========================================================================
+METHOD:
+ SetAGPSConfig
+
+DESCRIPTION:
+ This function sets the PDS AGPS configuration
+
+PARAMETERS:
+ serverAddress [ I ] - IPv4 address of AGPS server
+ serverPort [ I ] - Port number of AGPS server
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetAGPSConfig(
+ ULONG serverAddress,
+ ULONG serverPort );
+
+/*===========================================================================
+METHOD:
+ GetServiceAutomaticTracking
+
+DESCRIPTION:
+ This function returns the automatic tracking state for the service
+
+PARAMETERS:
+ pbAuto [ O ] - Automatic tracking session started for service?
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetServiceAutomaticTracking( ULONG * pbAuto );
+
+/*===========================================================================
+METHOD:
+ SetServiceAutomaticTracking
+
+DESCRIPTION:
+ This function sets the automatic tracking state for the service
+
+PARAMETERS:
+ pbAuto [ I ] - Start automatic tracking session for service?
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetServiceAutomaticTracking( ULONG bAuto );
+
+/*===========================================================================
+METHOD:
+ GetPortAutomaticTracking
+
+DESCRIPTION:
+ This function returns the automatic tracking configuration for the NMEA
+ COM port
+
+PARAMETERS:
+ pbAuto [ O ] - Automatic tracking enabled for NMEA COM port?
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetPortAutomaticTracking( ULONG * pbAuto );
+
+/*===========================================================================
+METHOD:
+ SetPortAutomaticTracking
+
+DESCRIPTION:
+ This function sets the automatic tracking configuration for the NMEA
+ COM port
+
+PARAMETERS:
+ pbAuto [ I ] - Enable automatic tracking for NMEA COM port?
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetPortAutomaticTracking( ULONG bAuto );
+
+/*===========================================================================
+METHOD:
+ ResetPDSData
+
+DESCRIPTION:
+ This function resets the specified PDS data
+
+PARAMETERS:
+ pGPSDataMask [ I ] - Bitmask of GPS data to clear (optional)
+ pCellDataMask [ I ] - Bitmask of cell data to clear (optional)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG ResetPDSData(
+ ULONG * pGPSDataMask,
+ ULONG * pCellDataMask );
+
+/*===========================================================================
+METHOD:
+ CATSendTerminalResponse
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG CATSendTerminalResponse(
+ ULONG refID,
+ ULONG dataLen,
+ BYTE * pData );
+
+/*===========================================================================
+METHOD:
+ CATSendEnvelopeCommand
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG CATSendEnvelopeCommand(
+ ULONG cmdID,
+ ULONG dataLen,
+ BYTE * pData );
+
+/*===========================================================================
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetSMSWake(
+ ULONG * pbEnabled,
+ ULONG * pWakeMask );
+
+/*===========================================================================
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetSMSWake(
+ ULONG bEnable,
+ ULONG wakeMask );
+
+/*===========================================================================
+METHOD:
+ OMADMStartSession
+
+DESCRIPTION:
+ This function starts an OMA-DM session
+
+PARAMETERS:
+ sessionType [ I ] - Type of session to initiate
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG OMADMStartSession( ULONG sessionType );
+
+/*===========================================================================
+METHOD:
+ OMADMCancelSession
+
+DESCRIPTION:
+ This function cancels an ongoing OMA-DM session
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG OMADMCancelSession();
+
+/*===========================================================================
+METHOD:
+ OMADMGetSessionInfo
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG OMADMGetSessionInfo(
+ ULONG * pSessionState,
+ ULONG * pSessionType,
+ ULONG * pFailureReason,
+ BYTE * pRetryCount,
+ WORD * pSessionPause,
+ WORD * pTimeRemaining );
+
+/*===========================================================================
+METHOD:
+ OMADMGetPendingNIA
+
+DESCRIPTION:
+ This function returns information about the pending network initiated
+ alert
+
+PARAMETERS:
+ pSessionType [ O ] - Type of session
+ pSessionID [ O ] - Unique session ID
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG OMADMGetPendingNIA(
+ ULONG * pSessionType,
+ USHORT * pSessionID );
+
+/*===========================================================================
+METHOD:
+ OMADMSendSelection
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG OMADMSendSelection(
+ ULONG selection,
+ USHORT sessionID );
+
+/*===========================================================================
+METHOD:
+ OMADMGetFeatureSettings
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG OMADMGetFeatureSettings(
+ ULONG * pbProvisioning,
+ ULONG * pbPRLUpdate );
+
+/*===========================================================================
+METHOD:
+ OMADMSetProvisioningFeature
+
+DESCRIPTION:
+ This function sets the OMA-DM device provisioning service
+ update feature setting
+
+PARAMETERS:
+ bProvisioning [ I ] - Device provisioning service update enabled
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG OMADMSetProvisioningFeature(
+ ULONG bProvisioning );
+
+/*===========================================================================
+METHOD:
+ OMADMSetPRLUpdateFeature
+
+DESCRIPTION:
+ This function sets the OMA-DM PRL service update feature setting
+
+PARAMETERS:
+ bPRLUpdate [ I ] - PRL service update enabled
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG OMADMSetPRLUpdateFeature(
+ ULONG bPRLUpdate );
+
+/*===========================================================================
+METHOD:
+ OriginateUSSD
+
+DESCRIPTION:
+ This function initiates a USSD operation
+
+PARAMETERS:
+ pInfo [ I ] - USSD information
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG OriginateUSSD( BYTE * pInfo );
+
+/*===========================================================================
+METHOD:
+ AnswerUSSD
+
+DESCRIPTION:
+ This function responds to a USSD request from the network
+
+PARAMETERS:
+ pInfo [ I ] - USSD information
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG AnswerUSSD( BYTE * pInfo );
+
+/*===========================================================================
+METHOD:
+ CancelUSSD
+
+DESCRIPTION:
+ This function cancels an in-progress USSD operation
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG CancelUSSD();
+
+/*===========================================================================
+METHOD:
+ UpgradeFirmware
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG UpgradeFirmware( CHAR * pDestinationPath );
+
+/*===========================================================================
+METHOD:
+ GetImageInfo
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetImageInfo(
+ CHAR * pPath,
+ ULONG * pFirmwareID,
+ ULONG * pTechnology,
+ ULONG * pCarrier,
+ ULONG * pRegion,
+ ULONG * pGPSCapability );
+
+/*===========================================================================
+METHOD:
+ GetImageStore
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetImageStore(
+ WORD pathSize,
+ CHAR * pImageStorePath );
+
+/*===========================================================================
+METHOD:
+ SetSessionStateCallback
+
+DESCRIPTION:
+ This function enables/disables the session state callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetSessionStateCallback( tFNSessionState pCallback );
+
+/*===========================================================================
+METHOD:
+ SetByteTotalsCallback
+
+DESCRIPTION:
+ This function enables/disables the RX/TX byte counts callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+ interval [ I ] - Interval in seconds (ignored when disabling)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetByteTotalsCallback(
+ tFNByteTotals pCallback,
+ BYTE interval );
+
+/*===========================================================================
+METHOD:
+ SetDataCapabilitiesCallback
+
+DESCRIPTION:
+ This function enables/disables the serving system data capabilities
+ callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetDataCapabilitiesCallback(
+ tFNDataCapabilities pCallback );
+
+/*===========================================================================
+METHOD:
+ SetDataBearerCallback
+
+DESCRIPTION:
+ This function enables/disables the data bearer status callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetDataBearerCallback( tFNDataBearer pCallback );
+
+/*===========================================================================
+METHOD:
+ SetDormancyStatusCallback
+
+DESCRIPTION:
+ This function enables/disables the dormancy status callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetDormancyStatusCallback(
+ tFNDormancyStatus pCallback );
+
+/*===========================================================================
+METHOD:
+ SetMobileIPStatusCallback
+
+DESCRIPTION:
+ This function enables/disables the mobile IP status callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetMobileIPStatusCallback(
+ tFNMobileIPStatus pCallback );
+
+/*===========================================================================
+METHOD:
+ SetActivationStatusCallback
+
+DESCRIPTION:
+ This function enables/disables the activation status callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetActivationStatusCallback(
+ tFNActivationStatus pCallback );
+
+/*===========================================================================
+METHOD:
+ SetPowerCallback
+
+DESCRIPTION:
+ Enable/disable power operating mode callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function
+
+RETURN VALUE:
+ ULONG
+===========================================================================*/
+ULONG SetPowerCallback( tFNPower pCallback );
+
+/*===========================================================================
+METHOD:
+ SetWirelessDisableCallback
+
+DESCRIPTION:
+ Enables/disables wireless disable state callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function
+
+RETURN VALUE:
+ ULONG
+===========================================================================*/
+ULONG SetWirelessDisableCallback(
+ tFNWirelessDisable pCallback );
+
+/*===========================================================================
+METHOD:
+ SetRoamingIndicatorCallback
+
+DESCRIPTION:
+ This function enables/disables the roaming indicator callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetRoamingIndicatorCallback(
+ tFNRoamingIndicator pCallback );
+
+/*===========================================================================
+METHOD:
+ SetSignalStrengthCallback
+
+DESCRIPTION:
+ This function enables/disables the signal strength callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+ thresholdsSize [ I ] - Number of elements the threshold array contain
+ (a maximum of 5 thresholds is supported), must
+ be 0 when disabling the callback
+ pThresholds [ I ] - Signal threshold array (each entry in dBm),
+ must be 0 when disabling the callback
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetSignalStrengthCallback(
+ tFNSignalStrength pCallback,
+ BYTE thresholdsSize,
+ INT8 * pThresholds );
+
+/*===========================================================================
+METHOD:
+ SetRFInfoCallback
+
+DESCRIPTION:
+ This function enables/disables the RF information callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetRFInfoCallback( tFNRFInfo pCallback );
+
+/*===========================================================================
+METHOD:
+ SetLURejectCallback
+
+DESCRIPTION:
+ This function enables/disables the LU reject callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetLURejectCallback( tFNLUReject pCallback );
+
+/*===========================================================================
+METHOD:
+ SetPLMNModeCallback
+
+DESCRIPTION:
+ This function enables/disables the PLMN mode callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetPLMNModeCallback( tFNPLMNMode pCallback );
+
+/*===========================================================================
+METHOD:
+ SetNewSMSCallback
+
+DESCRIPTION:
+ This function enables/disables the new SMS callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetNewSMSCallback( tFNNewSMS pCallback );
+
+/*===========================================================================
+METHOD:
+ SetNMEACallback
+
+DESCRIPTION:
+ This function enables/disables the NMEA sentence callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetNMEACallback( tFNNewNMEA pCallback );
+
+/*===========================================================================
+METHOD:
+ SetPDSStateCallback
+
+DESCRIPTION:
+ This function enables/disables the PDS service state callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetPDSStateCallback( tFNPDSState pCallback );
+
+/*===========================================================================
+METHOD:
+ SetCATEventCallback
+
+DESCRIPTION:
+ This function enables/disables the CAT event callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+ eventMask [ I ] - Bitmask of CAT events to register for
+ pErrorMask [ O ] - Error bitmask
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetCATEventCallback(
+ tFNCATEvent pCallback,
+ ULONG eventMask,
+ ULONG * pErrorMask );
+
+/*===========================================================================
+METHOD:
+ SetOMADMAlertCallback
+
+DESCRIPTION:
+ This function enables/disables the OMA-DM network initiated alert
+ callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetOMADMAlertCallback( tFNOMADMAlert pCallback );
+
+/*===========================================================================
+METHOD:
+ SetOMADMStateCallback
+
+DESCRIPTION:
+ This function enables/disables the OMA-DM state callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetOMADMStateCallback( tFNOMADMState pCallback );
+
+/*===========================================================================
+METHOD:
+ SetUSSDReleaseCallback
+
+DESCRIPTION:
+ This function enables/disables the USSD release callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetUSSDReleaseCallback( tFNUSSDRelease pCallback );
+
+/*===========================================================================
+METHOD:
+ SetUSSDNotificationCallback
+
+DESCRIPTION:
+ This function enables/disables the USSD notification callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetUSSDNotificationCallback(
+ tFNUSSDNotification pCallback );
+
+/*===========================================================================
+METHOD:
+ SetUSSDOriginationCallback
+
+DESCRIPTION:
+ Enable/disable USSD origination callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetUSSDOriginationCallback(
+ tFNUSSDOrigination pCallback );
+
+#ifdef __cplusplus
+ };
+#endif
+
diff --git a/gobi-api/GobiAPI_1.0.40/GobiConnectionMgmt/GobiConnectionMgmtExports.cpp b/gobi-api/GobiAPI_1.0.40/GobiConnectionMgmt/GobiConnectionMgmtExports.cpp
new file mode 100755
index 0000000..b847ca4
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/GobiConnectionMgmt/GobiConnectionMgmtExports.cpp
@@ -0,0 +1,5021 @@
+/*===========================================================================
+FILE:
+ GobiConnectionMgmtExports.cpp
+
+DESCRIPTION:
+ QUALCOMM Gobi 3000 Connection Management API 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 "GobiConnectionMgmt.h"
+#include "GobiConnectionMgmtAPI.h"
+
+//---------------------------------------------------------------------------
+// Definitions
+//---------------------------------------------------------------------------
+
+// Maximum length for adapter device path
+const ULONG MAX_AI_DEVICE_PATH = 256;
+
+// Maximum length for adapter key
+const ULONG MAX_AI_KEY = 16;
+
+//---------------------------------------------------------------------------
+// Pragmas (pack structs)
+//---------------------------------------------------------------------------
+#pragma pack( push, 1 )
+
+/*=========================================================================*/
+// Struct sAdapterInfo
+// Struct to represent Gobi adapter info
+/*=========================================================================*/
+struct sAdapterInfo
+{
+ public:
+ CHAR mPath[MAX_AI_DEVICE_PATH];
+ CHAR mKey[MAX_AI_KEY];
+};
+
+//---------------------------------------------------------------------------
+// Pragmas
+//---------------------------------------------------------------------------
+#pragma pack( pop )
+
+/*=========================================================================*/
+// Exported Methods
+/*=========================================================================*/
+
+/*===========================================================================
+METHOD:
+ QCWWANEnumerateDevices
+
+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 QCWWANEnumerateDevices(
+ BYTE * pDevicesSize,
+ BYTE * pDevices )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.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 <cGobiConnectionMgmt::tDeviceID> adapters;
+ adapters = pAPI->GetAvailableDevices();
+
+ ULONG sz = (ULONG)adapters.size();
+ if (sz > (ULONG)maxInstances)
+ {
+ sz = (ULONG)maxInstances;
+ }
+
+ sAdapterInfo * pOutput = (sAdapterInfo *)pDevices;
+ for (ULONG a = 0; a < sz; a++)
+ {
+ const cGobiConnectionMgmt::tDeviceID & id = adapters[a];
+
+ memset( &pOutput->mPath[0], 0, (SIZE_T)MAX_AI_DEVICE_PATH );
+ memset( &pOutput->mKey[0], 0, (SIZE_T)MAX_AI_KEY );
+
+ ULONG len = id.first.size();
+ if (len > 0)
+ {
+ if (len >= MAX_AI_DEVICE_PATH)
+ {
+ len = MAX_AI_DEVICE_PATH - 1;
+ }
+
+ memcpy( (LPVOID)&pOutput->mPath[0],
+ (LPVOID)id.first.c_str(),
+ (SIZE_T)len );
+ }
+
+ len = id.second.size();
+ if (len > 0)
+ {
+ if (len >= MAX_AI_KEY)
+ {
+ len = MAX_AI_KEY - 1;
+ }
+
+ memcpy( (LPVOID)&pOutput->mKey[0],
+ (LPCVOID)id.second.c_str(),
+ (SIZE_T)len );
+ }
+
+ pOutput++;
+ }
+
+ *pDevicesSize = (BYTE)sz;
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ QCWWANConnect
+
+DESCRIPTION:
+ This function connects the CM API library to the specified Gobi
+ device
+
+ Both device node and key are case sensitive
+
+PARAMETERS:
+ pDeviceNode [ I ] - The device node
+ pDeviceKey [ I ] - The device key (unique, stored on-device)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG QCWWANConnect(
+ CHAR * pDeviceNode,
+ CHAR * pDeviceKey )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ // Validate arguments
+ if (pDeviceNode == 0 && pDeviceKey != 0)
+ {
+ // If you specify a device key then you have to specify a device ID
+ return (ULONG)eGOBI_ERR_INVALID_ARG;
+ }
+
+ bool bConnect = pAPI->Connect( (LPCSTR)pDeviceNode,
+ (LPCSTR)pDeviceKey );
+ if (bConnect == false)
+ {
+ return (ULONG)pAPI->GetCorrectedLastError();
+ }
+
+ return (ULONG)eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ QCWWANCancel
+
+DESCRIPTION:
+ This function cancels the most recent outstanding request
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG QCWWANCancel()
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->CancelSend();
+}
+
+/*===========================================================================
+METHOD:
+ QCWWANDisconnect
+
+DESCRIPTION:
+ This function disconnects the CM API library from the currently
+ connected Gobi device
+
+PARAMETERS:
+ pState [ O ] - State of the current packet session
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG QCWWANDisconnect()
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ bool bDisco = pAPI->Disconnect();
+ if (bDisco == false)
+ {
+ return (ULONG)pAPI->GetCorrectedLastError();
+ }
+
+ return (ULONG)eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ QCWWANGetConnectedDeviceID
+
+DESCRIPTION:
+ This function returns the Node/key of the device the Gobi CM API library
+ is currently connected to
+
+PARAMETERS:
+ deviceNodeSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the device Node array can contain
+ pDeviceNode [ O ] - Device Node (NULL terminated string)
+ deviceKeySize [ I ] - The maximum number of characters (including NULL
+ terminator) that the device key array can contain
+ pDeviceKey [ O ] - Device key (NULL terminated string)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG QCWWANGetConnectedDeviceID(
+ ULONG deviceNodeSize,
+ CHAR * pDeviceNode,
+ ULONG deviceKeySize,
+ CHAR * pDeviceKey )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ // Validate arguments
+ if ( (deviceNodeSize == 0)
+ || (pDeviceNode == 0)
+ || (deviceKeySize == 0)
+ || (pDeviceKey == 0) )
+ {
+ return (ULONG)eGOBI_ERR_INVALID_ARG;
+ }
+
+ *pDeviceNode = 0;
+ *pDeviceKey = 0;
+
+ std::string devNode = "";
+ std::string devKey = "";
+ bool bOK = pAPI->GetConnectedDeviceID( devNode, devKey );
+ if (bOK == false)
+ {
+ return (ULONG)pAPI->GetCorrectedLastError();
+ }
+
+ ULONG lenNode = (ULONG)devNode.size();
+
+ // Space to perform the copy?
+ if (deviceNodeSize < lenNode + 1)
+ {
+ return eGOBI_ERR_BUFFER_SZ;
+ }
+
+ memcpy( (LPVOID)pDeviceNode, (LPVOID)devNode.c_str(), lenNode );
+
+ // Enforce null termination
+ pDeviceNode[lenNode] = 0;
+
+ ULONG lenKey = (ULONG)devKey.size();
+
+ // Space to perform the copy?
+ if (deviceKeySize < lenKey + 1)
+ {
+ return eGOBI_ERR_BUFFER_SZ;
+ }
+
+ memcpy( (LPVOID)pDeviceKey, (LPVOID)devKey.c_str(), lenKey );
+
+ // Enforce null termination
+ pDeviceKey[lenKey] = 0;
+
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ GetSessionState
+
+DESCRIPTION:
+ This function returns the state of the current packet data session
+
+PARAMETERS:
+ pState [ O ] - State of the current packet session
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetSessionState( ULONG * pState )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetSessionState( pState );
+}
+
+/*===========================================================================
+METHOD:
+ GetSessionDuration
+
+DESCRIPTION:
+ This function returns the duration of the current packet data session
+
+PARAMETERS:
+ pDuration [ O ] - Duration of the current packet session
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetSessionDuration( ULONGLONG * pDuration )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetSessionDuration( pDuration );
+}
+
+/*===========================================================================
+METHOD:
+ GetDormancyState
+
+DESCRIPTION:
+ This function returns the dormancy state of the current packet
+ data session (when connected)
+
+PARAMETERS:
+ pState [ O ] - Dormancy state of the current packet session
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetDormancyState( ULONG * pState )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetDormancyState( pState );
+}
+
+/*===========================================================================
+METHOD:
+ GetAutoconnect (Deprecated)
+
+DESCRIPTION:
+ This function returns the current autoconnect data session setting
+
+PARAMETERS:
+ pSetting [ O ] - NDIS autoconnect setting
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetAutoconnect( ULONG * pSetting )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ ULONG dummy;
+ return (ULONG)pAPI->GetEnhancedAutoconnect( pSetting, &dummy );
+}
+
+/*===========================================================================
+METHOD:
+ SetAutoconnect (Deprecated)
+
+DESCRIPTION:
+ This function sets the autoconnect data session setting
+
+PARAMETERS:
+ setting [ I ] - NDIS autoconnect disabled (0) or enabled (non-zero)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetAutoconnect( ULONG setting )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetEnhancedAutoconnect( setting, 0 );
+}
+
+/*===========================================================================
+METHOD:
+ GetEnhancedAutoconnect
+
+DESCRIPTION:
+ This function returns the current autoconnect data session setting
+
+PARAMETERS:
+ pSetting [ O ] - NDIS autoconnect setting
+ pRoamSetting [ O ] - NDIS autoconnect roam setting
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetEnhancedAutoconnect(
+ ULONG * pSetting,
+ ULONG * pRoamSetting )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetEnhancedAutoconnect( pSetting, pRoamSetting );
+}
+
+/*===========================================================================
+METHOD:
+ SetEnhancedAutoconnect
+
+DESCRIPTION:
+ This function sets the autoconnect data session setting
+
+PARAMETERS:
+ setting [ I ] - NDIS autoconnect setting
+ pRoamSetting [ I ] - (Optional) NDIS autoconnect roam setting
+
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetEnhancedAutoconnect(
+ ULONG setting,
+ ULONG * pRoamSetting )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetEnhancedAutoconnect( setting, pRoamSetting );
+}
+
+
+/*===========================================================================
+METHOD:
+ SetDefaultProfile
+
+DESCRIPTION:
+ This function writes the default profile settings to the device, the
+ default profile is used during autoconnect
+
+PARAMETERS:
+ profileType [ I ] - Profile type being written
+ pPDPType [ I ] - (Optional) PDP type
+ pIPAddress [ I ] - (Optional) Preferred assigned IPv4 address
+ pPrimaryDNS [ I ] - (Optional) Primary DNS IPv4 address
+ pSecondaryDNS [ I ] - (Optional) Secondary DNS IPv4 address
+ pAuthentication [ I ] - (Optional) Authentication algorithm bitmap
+ pName [ I ] - (Optional) The profile name or description
+ pAPNName [ I ] - (Optional) Access point name
+ pUsername [ I ] - (Optional) Username used during authentication
+ pPassword [ I ] - (Optional) Password used during authentication
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetDefaultProfile(
+ ULONG profileType,
+ ULONG * pPDPType,
+ ULONG * pIPAddress,
+ ULONG * pPrimaryDNS,
+ ULONG * pSecondaryDNS,
+ ULONG * pAuthentication,
+ CHAR * pName,
+ CHAR * pAPNName,
+ CHAR * pUsername,
+ CHAR * pPassword )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetDefaultProfile( profileType,
+ pPDPType,
+ pIPAddress,
+ pPrimaryDNS,
+ pSecondaryDNS,
+ pAuthentication,
+ pName,
+ pAPNName,
+ pUsername,
+ pPassword );
+}
+
+/*===========================================================================
+METHOD:
+ GetDefaultProfile
+
+DESCRIPTION:
+ This function reads the default profile settings from the device, the
+ default profile is used during autoconnect
+
+PARAMETERS:
+ profileType [ I ] - Profile type being read
+ pPDPType [ O ] - PDP type
+ pIPAddress [ O ] - Preferred assigned IPv4 address
+ pPrimaryDNS [ O ] - Primary DNS IPv4 address
+ pSecondaryDNS [ O ] - Secondary DNS IPv4 address
+ pAuthentication [ O ] - Authentication algorithm bitmap
+ nameSize [ I ] - The maximum number of characters (including
+ NULL terminator) that the profile name array
+ can contain
+ pName [ O ] - The profile name or description
+ apnSize [ I ] - The maximum number of characters (including
+ NULL terminator) that the APN name array
+ can contain
+ pAPNName [ O ] - Access point name represented as a NULL
+ terminated string (empty string returned when
+ unknown)
+ userSize [ I ] - The maximum number of characters (including
+ NULL terminator) that the username array
+ can contain
+ pUsername [ O ] - Username used during authentication
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetDefaultProfile(
+ ULONG profileType,
+ ULONG * pPDPType,
+ ULONG * pIPAddress,
+ ULONG * pPrimaryDNS,
+ ULONG * pSecondaryDNS,
+ ULONG * pAuthentication,
+ BYTE nameSize,
+ CHAR * pName,
+ BYTE apnSize,
+ CHAR * pAPNName,
+ BYTE userSize,
+ CHAR * pUsername )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetDefaultProfile( profileType,
+ pPDPType,
+ pIPAddress,
+ pPrimaryDNS,
+ pSecondaryDNS,
+ pAuthentication,
+ nameSize,
+ pName,
+ apnSize,
+ pAPNName,
+ userSize,
+ pUsername );
+}
+
+/*===========================================================================
+METHOD:
+ StartDataSession
+
+DESCRIPTION:
+ This function activates a packet data session
+
+PARAMETERS:
+ pTechnology [ I ] - (Optional) Technology bitmap
+ pPrimaryDNS [ I ] - (Optional) Primary DNS IPv4 address
+ pSecondaryDNS [ I ] - (Optional) Secondary DNS IPv4 address
+ pPrimaryNBNS [ I ] - (Optional) Primary NetBIOS NS IPv4 address
+ pSecondaryNBNS [ I ] - (Optional) Secondary NetBIOS NS IPv4 address
+ pAPNName [ I ] - (Optional) Access point name
+ pIPAddress [ I ] - (Optional) Preferred assigned IPv4 address
+ pAuthentication [ I ] - (Optional) Authentication algorithm bitmap
+ pUsername [ I ] - (Optional) Username used during authentication
+ pPassword [ I ] - (Optional) Password used during authentication
+ pSessionId [ O ] - The assigned session ID
+ pFailureReason [ O ] - Upon call failure the failure reason provided
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG StartDataSession(
+ ULONG * pTechnology,
+ ULONG * pPrimaryDNS,
+ ULONG * pSecondaryDNS,
+ ULONG * pPrimaryNBNS,
+ ULONG * pSecondaryNBNS,
+ CHAR * pAPNName,
+ ULONG * pIPAddress,
+ ULONG * pAuthentication,
+ CHAR * pUsername,
+ CHAR * pPassword,
+ ULONG * pSessionId,
+ ULONG * pFailureReason )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->StartDataSession( pTechnology,
+ pPrimaryDNS,
+ pSecondaryDNS,
+ pPrimaryNBNS,
+ pSecondaryNBNS,
+ pAPNName,
+ pIPAddress,
+ pAuthentication,
+ pUsername,
+ pPassword,
+ pSessionId,
+ pFailureReason );
+}
+
+/*===========================================================================
+METHOD:
+ CancelDataSession
+
+DESCRIPTION:
+ This function cancels an in-progress packet data session activation
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG CancelDataSession()
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return pAPI->CancelDataSession();
+}
+
+/*===========================================================================
+METHOD:
+ StopDataSession
+
+DESCRIPTION:
+ This function stops the current data session
+
+PARAMETERS:
+ sessionId [ I ] - The ID of the session to terminate
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG StopDataSession( ULONG sessionId )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return pAPI->StopDataSession( sessionId );
+}
+
+/*===========================================================================
+METHOD:
+ GetIPAddress
+
+DESCRIPTION:
+ This function returns the current packet data session IP address
+
+PARAMETERS:
+ pIPAddress [ O ] - Assigned IPv4 address
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetIPAddress( ULONG * pIPAddress )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return pAPI->GetIPAddress( pIPAddress );
+}
+
+/*===========================================================================
+METHOD:
+ GetConnectionRate
+
+DESCRIPTION:
+ This function returns connection rate information for the packet data
+ connection
+
+PARAMETERS:
+ pCurrentChannelTXRate [ O ] - Current channel TX rate (bps)
+ pCurrentChannelRXRate [ O ] - Current channel RX rate (bps)
+ pMaxChannelTXRate [ O ] - Maximum channel TX rate (bps)
+ pMaxChannelRXRate [ O ] - Maximum channel RX rate (bps)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetConnectionRate(
+ ULONG * pCurrentChannelTXRate,
+ ULONG * pCurrentChannelRXRate,
+ ULONG * pMaxChannelTXRate,
+ ULONG * pMaxChannelRXRate )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetConnectionRate( pCurrentChannelTXRate,
+ pCurrentChannelRXRate,
+ pMaxChannelTXRate,
+ pMaxChannelRXRate );
+}
+
+/*===========================================================================
+METHOD:
+ GetPacketStatus
+
+DESCRIPTION:
+ This function returns the packet data transfer statistics since the start
+ of the current packet data session
+
+PARAMETERS:
+ pTXPacketSuccesses [ O ] - Packets transmitted without error
+ pRXPacketSuccesses [ O ] - Packets received without error
+ pTXPacketErrors [ O ] - Outgoing packets with framing errors
+ pRXPacketErrors [ O ] - Incoming packets with framing errors
+ pTXPacketOverflows [ O ] - Packets dropped because TX buffer overflowed
+ pRXPacketOverflows [ O ] - Packets dropped because RX buffer overflowed
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetPacketStatus(
+ ULONG * pTXPacketSuccesses,
+ ULONG * pRXPacketSuccesses,
+ ULONG * pTXPacketErrors,
+ ULONG * pRXPacketErrors,
+ ULONG * pTXPacketOverflows,
+ ULONG * pRXPacketOverflows )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetPacketStatus( pTXPacketSuccesses,
+ pRXPacketSuccesses,
+ pTXPacketErrors,
+ pRXPacketErrors,
+ pTXPacketOverflows,
+ pRXPacketOverflows );
+}
+
+/*===========================================================================
+METHOD:
+ GetByteTotals
+
+DESCRIPTION:
+ This function returns the RX/TX byte counts since the start of the
+ current packet data session
+
+PARAMETERS:
+ pTXTotalBytes [ O ] - Bytes transmitted without error
+ pRXTotalBytes [ O ] - Bytes received without error
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetByteTotals(
+ ULONGLONG * pTXTotalBytes,
+ ULONGLONG * pRXTotalBytes )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetByteTotals( pTXTotalBytes, pRXTotalBytes );
+}
+
+/*===========================================================================
+METHOD:
+ SetMobileIP
+
+DESCRIPTION:
+ This function sets the current mobile IP setting
+
+PARAMETERS:
+ mode [ I ] - Desired mobile IP setting
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetMobileIP( ULONG mode )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return pAPI->SetMobileIP( mode );
+}
+
+/*===========================================================================
+METHOD:
+ GetMobileIP
+
+DESCRIPTION:
+ This function gets the current mobile IP setting
+
+PARAMETERS:
+ pMode [ O ] - Current mobile IP setting
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetMobileIP( ULONG * pMode )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetMobileIP( pMode );
+}
+
+/*===========================================================================
+METHOD:
+ SetActiveMobileIPProfile
+
+DESCRIPTION:
+ This function sets the active mobile IP profile index
+
+PARAMETERS:
+ pSPC [ I ] - Six digit service programming code
+ index [ I ] - Desired mobile IP profile index
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetActiveMobileIPProfile(
+ CHAR * pSPC,
+ BYTE index )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetActiveMobileIPProfile( pSPC, index );
+}
+
+/*===========================================================================
+METHOD:
+ GetActiveMobileIPProfile
+
+DESCRIPTION:
+ This function gets the the active mobile IP profile index
+
+PARAMETERS:
+ pIndex [ O ] - Active mobile IP profile index
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetActiveMobileIPProfile( BYTE * pIndex )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetActiveMobileIPProfile( pIndex );
+}
+
+/*===========================================================================
+METHOD:
+ SetMobileIPProfile
+
+DESCRIPTION:
+ This function sets the specified mobile IP profile settings
+
+PARAMETERS:
+ pSPC [ I ] - Six digit service programming code
+ index [ I ] - Mobile IP profile ID
+ pEnabled [ I ] - (Optional) Enable MIP profile?
+ pAddress [ I ] - (Optional) Home IPv4 address
+ pPrimaryHA [ I ] - (Optional) Primary home agent IPv4 address
+ pSecondaryHA [ I ] - (Optional) Secondary home agent IPv4 address
+ bRevTunneling [ I ] - (Optional) Enable reverse tunneling?
+ pNAI [ I ] - (Optional) Network access identifier string
+ pHASPI [ I ] - (Optional) HA security parameter index
+ pAAASPI [ I ] - (Optional) AAA security parameter index
+ pMNHA [ I ] - (Optional) MN-HA string
+ pMNAAA [ I ] - (Optional) MN-AAA string
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetMobileIPProfile(
+ CHAR * pSPC,
+ BYTE index,
+ BYTE * pEnabled,
+ ULONG * pAddress,
+ ULONG * pPrimaryHA,
+ ULONG * pSecondaryHA,
+ BYTE * pRevTunneling,
+ CHAR * pNAI,
+ ULONG * pHASPI,
+ ULONG * pAAASPI,
+ CHAR * pMNHA,
+ CHAR * pMNAAA )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetMobileIPProfile( pSPC,
+ index,
+ pEnabled,
+ pAddress,
+ pPrimaryHA,
+ pSecondaryHA,
+ pRevTunneling,
+ pNAI,
+ pHASPI,
+ pAAASPI,
+ pMNHA,
+ pMNAAA );
+}
+
+/*===========================================================================
+METHOD:
+ GetMobileIPProfile
+
+DESCRIPTION:
+ This function gets the specified mobile IP profile settings
+
+PARAMETERS:
+ index [ I ] - Mobile IP profile ID
+ pEnabled [ O ] - Mobile IP profile enabled?
+ pAddress [ O ] - Home IPv4 address
+ pPrimaryHA [ O ] - Primary home agent IPv4 address
+ pSecondaryHA [ O ] - Secondary home agent IPv4 address
+ pRevTunneling [ O ] - Reverse tunneling enabled?
+ naiSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the NAI array can contain
+ pNAI [ O ] - Network access identifier string
+ pHASPI [ O ] - HA security parameter index
+ pAAASPI [ O ] - AAA security parameter index
+ pHAState [ O ] - HA key state
+ pAAAState [ O ] - AAA key state
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetMobileIPProfile(
+ BYTE index,
+ BYTE * pEnabled,
+ ULONG * pAddress,
+ ULONG * pPrimaryHA,
+ ULONG * pSecondaryHA,
+ BYTE * pRevTunneling,
+ BYTE naiSize,
+ CHAR * pNAI,
+ ULONG * pHASPI,
+ ULONG * pAAASPI,
+ ULONG * pHAState,
+ ULONG * pAAAState )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetMobileIPProfile( index,
+ pEnabled,
+ pAddress,
+ pPrimaryHA,
+ pSecondaryHA,
+ pRevTunneling,
+ naiSize,
+ pNAI,
+ pHASPI,
+ pAAASPI,
+ pHAState,
+ pAAAState );
+}
+
+/*===========================================================================
+METHOD:
+ SetMobileIPParameters
+
+DESCRIPTION:
+ This function sets the specified mobile IP parameters
+
+PARAMETERS:
+ pSPC [ I ] - Six digit service programming code
+ pMode [ I ] - (Optional) Desired mobile IP setting
+ pRetryLimit [ I ] - (Optional) Retry attempt limit
+ pRetryInterval [ I ] - (Optional) Retry attempt interval
+ pReRegPeriod [ I ] - (Optional) Re-registration period
+ pReRegTraffic [ I ] - (Optional) Re-registration only with traffic?
+ pHAAuthenticator [ I ] - (Optional) MH-HA authenticator calculator?
+ pHA2002bis [ I ] - (Optional) MH-HA RFC 2002bis authentication?
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetMobileIPParameters(
+ CHAR * pSPC,
+ ULONG * pMode,
+ BYTE * pRetryLimit,
+ BYTE * pRetryInterval,
+ BYTE * pReRegPeriod,
+ BYTE * pReRegTraffic,
+ BYTE * pHAAuthenticator,
+ BYTE * pHA2002bis )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetMobileIPParameters( pSPC,
+ pMode,
+ pRetryLimit,
+ pRetryInterval,
+ pReRegPeriod,
+ pReRegTraffic,
+ pHAAuthenticator,
+ pHA2002bis );
+}
+
+/*===========================================================================
+METHOD:
+ GetMobileIPParameters
+
+DESCRIPTION:
+ This function gets the mobile IP parameters
+
+PARAMETERS:
+ pMode [ O ] - Current mobile IP setting
+ pRetryLimit [ O ] - Retry attempt limit
+ pRetryInterval [ O ] - Retry attempt interval
+ pReRegPeriod [ O ] - Re-registration period
+ pReRegTraffic [ O ] - Re-registration only with traffic?
+ pHAAuthenticator [ O ] - MH-HA authenticator calculator?
+ pHA2002bis [ O ] - MH-HA RFC 2002bis authentication?
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetMobileIPParameters(
+ ULONG * pMode,
+ BYTE * pRetryLimit,
+ BYTE * pRetryInterval,
+ BYTE * pReRegPeriod,
+ BYTE * pReRegTraffic,
+ BYTE * pHAAuthenticator,
+ BYTE * pHA2002bis )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetMobileIPParameters( pMode,
+ pRetryLimit,
+ pRetryInterval,
+ pReRegPeriod,
+ pReRegTraffic,
+ pHAAuthenticator,
+ pHA2002bis );
+}
+
+/*===========================================================================
+METHOD:
+ GetLastMobileIPError
+
+DESCRIPTION:
+ This function gets the last mobile IP error
+
+PARAMETERS:
+ pError [ O ] - Last mobile IP error
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetLastMobileIPError( ULONG * pError )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetLastMobileIPError( pError );
+}
+
+/*===========================================================================
+METHOD:
+ SetDNSSettings
+
+DESCRIPTION:
+ This function sets the DNS settings for the device
+
+PARAMETERS:
+ pPrimaryDNS [ I ] - (Optional) Primary DNS IPv4 address
+ pSecondaryDNS [ I ] - (Optional) Secondary DNS IPv4 address
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetDNSSettings(
+ ULONG * pPrimaryDNS,
+ ULONG * pSecondaryDNS )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetDNSSettings( pPrimaryDNS, pSecondaryDNS );
+}
+
+/*===========================================================================
+METHOD:
+ GetDNSSettings
+
+DESCRIPTION:
+ This function gets the DNS settings for the device
+
+PARAMETERS:
+ pPrimaryDNS [ O ] - Primary DNS IPv4 address
+ pSecondaryDNS [ O ] - Secondary DNS IPv4 address
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetDNSSettings(
+ ULONG * pPrimaryDNS,
+ ULONG * pSecondaryDNS )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetDNSSettings( pPrimaryDNS, pSecondaryDNS );
+}
+
+/*===========================================================================
+METHOD:
+ GetANAAAAuthenticationStatus
+
+DESCRIPTION:
+ This function gets the AN-AAA authentication status
+
+PARAMETERS:
+ pStatus [ O ] - AN-AAA authentication status
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetANAAAAuthenticationStatus( ULONG * pStatus )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetANAAAAuthenticationStatus( pStatus );
+}
+
+/*===========================================================================
+METHOD:
+ GetSignalStrengths
+
+DESCRIPTION:
+ This function gets the current available signal strengths (in dBm)
+ as measured by the device
+
+PARAMETERS:
+ pArraySizes [I/O] - Upon input the maximum number of elements
+ that each array can contain can contain.
+ Upon successful output the actual number
+ of elements in each array
+ pSignalStrengths [ O ] - Received signal strength array (dBm)
+ pRadioInterfaces [ O ] - Radio interface technology array
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetSignalStrengths(
+ ULONG * pArraySizes,
+ INT8 * pSignalStrengths,
+ ULONG * pRadioInterfaces )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetSignalStrengths( pArraySizes,
+ pSignalStrengths,
+ pRadioInterfaces );
+}
+
+/*===========================================================================
+METHOD:
+ GetRFInfo
+
+DESCRIPTION:
+ This function gets the current RF information
+
+PARAMETERS:
+ pInstanceSize [I/O] - Upon input the maximum number of elements that the
+ RF info instance array can contain. Upon success
+ the actual number of elements in the RF info
+ instance array
+ pInstances [ O ] - The RF info instance array
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetRFInfo(
+ BYTE * pInstanceSize,
+ BYTE * pInstances )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetRFInfo( pInstanceSize, pInstances );
+}
+
+
+
+/*===========================================================================
+METHOD:
+ PerformNetworkScan
+
+DESCRIPTION:
+ This function performs a scan for available networks
+
+PARAMETERS:
+ pInstanceSize [I/O] - Upon input the maximum number of elements that the
+ network info instance array can contain. Upon
+ success the actual number of elements in the
+ network info instance array
+ pInstances [ O ] - The network info instance array
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG PerformNetworkScan(
+ BYTE * pInstanceSize,
+ BYTE * pInstances )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->PerformNetworkScan( pInstanceSize, pInstances );
+}
+
+/*===========================================================================
+METHOD:
+ PerformNetworkRATScan
+
+DESCRIPTION:
+ This function performs a scan for available networks (includes RAT)
+
+PARAMETERS:
+ pInstanceSize [I/O] - Upon input the maximum number of elements that the
+ network info instance array can contain. Upon
+ success the actual number of elements in the
+ network info instance array
+ pInstances [ O ] - The network info instance array
+ pRATSize [I/O] - Upon input the maximum number of elements that the
+ RAT info instance array can contain. Upon success
+ the actual number of elements in the RAT info
+ instance array
+ pRATInstances [ O ] - The RAT info instance array
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG PerformNetworkRATScan(
+ BYTE * pInstanceSize,
+ BYTE * pInstances,
+ BYTE * pRATSize,
+ BYTE * pRATInstances )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->PerformNetworkRATScan( pInstanceSize,
+ pInstances,
+ pRATSize,
+ pRATInstances );
+}
+
+/*===========================================================================
+METHOD:
+ InitiateNetworkRegistration
+
+DESCRIPTION:
+ This function initiates a network registration
+
+PARAMETERS:
+ regType [ I ] - Registration type
+ mcc [ I ] - Mobile country code (ignored for auto registration)
+ mnc [ I ] - Mobile network code (ignored for auto registration)
+ rat [ I ] - Radio access type (ignored for auto registration)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG InitiateNetworkRegistration(
+ ULONG regType,
+ WORD mcc,
+ WORD mnc,
+ ULONG rat )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->InitiateNetworkRegistration( regType,
+ mcc,
+ mnc,
+ rat );
+}
+
+/*===========================================================================
+METHOD:
+ InitiateDomainAttach
+
+DESCRIPTION:
+ This function initiates a domain attach (or detach)
+
+PARAMETERS:
+ action [ I ] - PS attach action (attach or detach)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG InitiateDomainAttach( ULONG action )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->InitiateDomainAttach( action );
+}
+
+/*===========================================================================
+METHOD:
+ GetServingNetwork
+
+DESCRIPTION:
+ Gets information regarding the system that currently provides service
+ to the device
+
+PARAMETERS:
+ pRegistrationState [ O ] - Registration state
+ pCSDomain [ O ] - Circuit switch domain status
+ pPSDomain [ O ] - Packet switch domain status
+ pRAN [ O ] - Radio access network
+ pRadioIfacesSize [I/O] - Upon input the maximum number of elements
+ that the radio interfaces can contain. Upon
+ successful output the actual number of elements
+ in the radio interface array
+ pRadioIfaces [ O ] - The radio interface array
+ pRoaming [ O ] - Roaming indicator (0xFFFFFFFF - Unknown)
+ pMCC [ O ] - Mobile country code (0xFFFF - Unknown)
+ pMNC [ O ] - Mobile network code (0xFFFF - Unknown)
+ nameSize [ I ] - The maximum number of characters (including
+ NULL terminator) that the network name array
+ can contain
+ pName [ O ] - The network name or description represented
+ as a NULL terminated string (empty string
+ returned when unknown)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetServingNetwork(
+ ULONG * pRegistrationState,
+ ULONG * pCSDomain,
+ ULONG * pPSDomain,
+ ULONG * pRAN,
+ BYTE * pRadioIfacesSize,
+ BYTE * pRadioIfaces,
+ ULONG * pRoaming,
+ WORD * pMCC,
+ WORD * pMNC,
+ BYTE nameSize,
+ CHAR * pName )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetServingNetwork( pRegistrationState,
+ pCSDomain,
+ pPSDomain,
+ pRAN,
+ pRadioIfacesSize,
+ pRadioIfaces,
+ pRoaming,
+ pMCC,
+ pMNC,
+ nameSize,
+ pName );
+}
+
+/*===========================================================================
+METHOD:
+ GetServingNetworkCapabilities
+
+DESCRIPTION:
+ Gets information regarding the data capabilities of the system that
+ currently provides service to the device
+
+PARAMETERS:
+ pDataCapsSize [I/O] - Upon input the maximum number of elements that the
+ data capabilities array can contain. Upon success
+ the actual number of elements in the data
+ capabilities array
+ pDataCaps [ O ] - The data capabilities array
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetServingNetworkCapabilities(
+ BYTE * pDataCapsSize,
+ BYTE * pDataCaps )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetServingNetworkCapabilities( pDataCapsSize,
+ pDataCaps );
+}
+
+/*===========================================================================
+METHOD:
+ GetDataBearerTechnology
+
+DESCRIPTION:
+ This function retrieves the current data bearer technology (only
+ valid when connected)
+
+PARAMETERS:
+ pDataCaps [ O ] - The data bearer technology
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetDataBearerTechnology( ULONG * pDataBearer )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetDataBearerTechnology( pDataBearer );
+}
+
+/*===========================================================================
+METHOD:
+ GetHomeNetwork
+
+DESCRIPTION:
+ This function retrieves information about the home network of the device
+
+PARAMETERS:
+ pMCC [ O ] - Mobile country code
+ pMNC [ O ] - Mobile network code
+ nameSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the network name array can contain
+ pName [ O ] - The network name or description represented as a NULL
+ terminated string (empty string returned when unknown)
+ pSID [ O ] - Home network system ID (0xFFFF - Unknown)
+ pNID [ O ] - Home network ID (0xFFFF - Unknown)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetHomeNetwork(
+ WORD * pMCC,
+ WORD * pMNC,
+ BYTE nameSize,
+ CHAR * pName,
+ WORD * pSID,
+ WORD * pNID )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetHomeNetwork( pMCC,
+ pMNC,
+ nameSize,
+ pName,
+ pSID,
+ pNID );
+}
+
+/*===========================================================================
+METHOD:
+ SetNetworkPreference
+
+DESCRIPTION:
+ This function sets the network registration preference
+
+PARAMETERS:
+ technologyPref [ I ] - Technology preference bitmap
+ duration [ I ] - Duration of active preference
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetNetworkPreference(
+ ULONG technologyPref,
+ ULONG duration )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return pAPI->SetNetworkPreference( technologyPref, duration );
+}
+
+/*===========================================================================
+METHOD:
+ GetNetworkPreference
+
+DESCRIPTION:
+ This function returns the network registration preference
+
+PARAMETERS:
+ pTechnologyPref [ O ] - Technology preference bitmap
+ pDuration [ O ] - Duration of active preference
+ pPersistentTechnologyPref [ O ] - Persistent technology preference bitmap
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetNetworkPreference(
+ ULONG * pTechnologyPref,
+ ULONG * pDuration,
+ ULONG * pPersistentTechnologyPref )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetNetworkPreference( pTechnologyPref,
+ pDuration,
+ pPersistentTechnologyPref );
+}
+
+/*===========================================================================
+METHOD:
+ SetCDMANetworkParameters
+
+DESCRIPTION:
+ This function sets the desired CDMA network parameters
+
+PARAMETERS:
+ pSPC [ I ] - Six digit service programming code
+ pForceRev0 [ I ] - (Optional) Force CDMA 1x-EV-DO Rev. 0 mode?
+ pCustomSCP [ I ] - (Optional) Use a custom config for CDMA 1x-EV-DO SCP?
+ pProtocol [ I ] - (Optional) Protocol mask for custom SCP config
+ pBroadcast [ I ] - (Optional) Broadcast mask for custom SCP config
+ pApplication [ I ] - (Optional) Application mask for custom SCP config
+ pRoaming [ I ] - (Optional) Roaming preference
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetCDMANetworkParameters(
+ CHAR * pSPC,
+ BYTE * pForceRev0,
+ BYTE * pCustomSCP,
+ ULONG * pProtocol,
+ ULONG * pBroadcast,
+ ULONG * pApplication,
+ ULONG * pRoaming )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return pAPI->SetCDMANetworkParameters( pSPC,
+ pForceRev0,
+ pCustomSCP,
+ pProtocol,
+ pBroadcast,
+ pApplication,
+ pRoaming );
+}
+
+/*===========================================================================
+METHOD:
+ GetEVDONetworkParameters
+
+DESCRIPTION:
+ This function gets the current CDMA network parameters
+
+PARAMETERS:
+ pSCI [ O ] - Slot cycle index
+ pSCM [ O ] - Station class mark
+ pRegHomeSID [ O ] - Register on home SID?
+ pRegForeignSID [ O ] - Register on foreign SID?
+ pRegForeignNID [ O ] - Register on foreign NID?
+ pForceRev0 [ O ] - Force CDMA 1x-EV-DO Rev. 0 mode?
+ pCustomSCP [ O ] - Use a custom config for CDMA 1x-EV-DO SCP?
+ pProtocol [ O ] - Protocol mask for custom SCP config
+ pBroadcast [ O ] - Broadcast mask for custom SCP config
+ pApplication [ O ] - Application mask for custom SCP config
+ pRoaming [ O ] - Roaming preference
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetCDMANetworkParameters(
+ BYTE * pSCI,
+ BYTE * pSCM,
+ BYTE * pRegHomeSID,
+ BYTE * pRegForeignSID,
+ BYTE * pRegForeignNID,
+ BYTE * pForceRev0,
+ BYTE * pCustomSCP,
+ ULONG * pProtocol,
+ ULONG * pBroadcast,
+ ULONG * pApplication,
+ ULONG * pRoaming )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return pAPI->GetCDMANetworkParameters( pSCI,
+ pSCM,
+ pRegHomeSID,
+ pRegForeignSID,
+ pRegForeignNID,
+ pForceRev0,
+ pCustomSCP,
+ pProtocol,
+ pBroadcast,
+ pApplication,
+ pRoaming );
+}
+
+/*===========================================================================
+METHOD:
+ GetACCOLC
+
+DESCRIPTION:
+ This function returns the Access Overload Class (ACCOLC) of the device
+
+PARAMETERS:
+ pACCOLC [ O ] - The ACCOLC
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetACCOLC( BYTE * pACCOLC )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetACCOLC( pACCOLC );
+}
+
+/*===========================================================================
+METHOD:
+ SetACCOLC
+
+DESCRIPTION:
+ This function sets the Access Overload Class (ACCOLC) of the device
+
+PARAMETERS:
+ pSPC [ I ] - NULL terminated string representing the six digit
+ service programming code
+ accolc [ I ] - The ACCOLC
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetACCOLC(
+ CHAR * pSPC,
+ BYTE accolc )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return pAPI->SetACCOLC( pSPC, accolc );
+}
+
+/*===========================================================================
+METHOD:
+ GetPLMNMode
+
+DESCRIPTION:
+ This function returns the PLMN mode from the CSP
+
+PARAMETERS:
+ pMode [ O ] - PLMN mode
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetPLMNMode( ULONG * pMode )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return pAPI->GetPLMNMode( pMode );
+}
+
+/*===========================================================================
+METHOD:
+ GetPLMNName
+
+DESCRIPTION:
+ This function returns PLMN name information for the given MCC/MNC
+
+PARAMETERS:
+ mcc [ I ] - Mobile country code
+ mnc [ I ] - Mobile network code
+ pNamesSize [I/O] - Upon input the size in BYTEs of the name structure
+ array. Upon success the actual number of BYTEs
+ copied to the name structure array
+ pNames [ O ] - The name structure array
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetPLMNName(
+ USHORT mcc,
+ USHORT mnc,
+ ULONG * pNamesSize,
+ BYTE * pNames )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return pAPI->GetPLMNName( mcc, mnc, pNamesSize, pNames );
+}
+
+/*===========================================================================
+METHOD:
+ GetDeviceCapabilities
+
+DESCRIPTION:
+ This function gets device capabilities
+
+PARAMETERS:
+ pMaxTXChannelRate [ O ] - Maximum transmission rate (bps)
+ pMaxRXChannelRate [ O ] - Maximum reception rate (bps)
+ pDataServiceCapability [ O ] - CS/PS data service capability
+ pSimCapability [ O ] - Device SIM support
+ pRadioIfacesSize [I/O] - Upon input the maximum number of elements
+ that the radio interfaces can contain.
+ Upon successful output the actual number
+ of elements in the radio interface array
+ pRadioIfaces [ O ] - The radio interface array
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetDeviceCapabilities(
+ ULONG * pMaxTXChannelRate,
+ ULONG * pMaxRXChannelRate,
+ ULONG * pDataServiceCapability,
+ ULONG * pSimCapability,
+ ULONG * pRadioIfacesSize,
+ BYTE * pRadioIfaces )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetDeviceCapabilities( pMaxTXChannelRate,
+ pMaxRXChannelRate,
+ pDataServiceCapability,
+ pSimCapability,
+ pRadioIfacesSize,
+ pRadioIfaces );
+}
+
+/*===========================================================================
+METHOD:
+ GetManufacturer
+
+DESCRIPTION:
+ This function returns the device manufacturer name
+
+PARAMETERS:
+ stringSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the string array can contain
+ pString [ O ] - NULL terminated string
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetManufacturer(
+ BYTE stringSize,
+ CHAR * pString )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetManufacturer( stringSize, pString );
+}
+
+/*===========================================================================
+METHOD:
+ GetModelID
+
+DESCRIPTION:
+ This function returns the device model ID
+
+PARAMETERS:
+ stringSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the string array can contain
+ pString [ O ] - NULL terminated string
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetModelID(
+ BYTE stringSize,
+ CHAR * pString )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetModelID( stringSize, pString );
+}
+
+/*===========================================================================
+METHOD:
+ GetFirmwareRevision
+
+DESCRIPTION:
+ This function returns the device firmware revision
+
+PARAMETERS:
+ stringSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the string array can contain
+ pString [ O ] - NULL terminated string
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetFirmwareRevision(
+ BYTE stringSize,
+ CHAR * pString )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetFirmwareRevision( stringSize, pString );
+}
+
+/*===========================================================================
+METHOD:
+ GetFirmwareRevisions
+
+DESCRIPTION:
+ This function returns the device firmware (AMSS, boot, and PRI)
+ revisions
+
+PARAMETERS:
+ amssSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the AMSS string array can contain
+ pAMSSString [ O ] - NULL terminated AMSS revision string
+ bootSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the boot string array can contain
+ pBootString [ O ] - NULL terminated boot code revision string
+ priSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the PRI string array can contain
+ pPRIString [ O ] - NULL terminated PRI revision string
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetFirmwareRevisions(
+ BYTE amssSize,
+ CHAR * pAMSSString,
+ BYTE bootSize,
+ CHAR * pBootString,
+ BYTE priSize,
+ CHAR * pPRIString )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetFirmwareRevisions( amssSize,
+ pAMSSString,
+ bootSize,
+ pBootString,
+ priSize,
+ pPRIString );
+}
+
+/*===========================================================================
+METHOD:
+ GetFirmwareInfo
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetFirmwareInfo(
+ ULONG * pFirmwareID,
+ ULONG * pTechnology,
+ ULONG * pCarrier,
+ ULONG * pRegion,
+ ULONG * pGPSCapability )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetFirmwareInfo( pFirmwareID,
+ pTechnology,
+ pCarrier,
+ pRegion,
+ pGPSCapability );
+}
+
+/*===========================================================================
+METHOD:
+ GetVoiceNumber
+
+DESCRIPTION:
+ This function returns the voice number in use by the device
+
+PARAMETERS:
+ voiceNumberSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the voice number array can
+ contain
+ pVoiceNumber [ O ] - Voice number (MDN or ISDN) string
+ minSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the MIN array can contain
+ pMIN [ O ] - MIN string (empty string returned when MIN is
+ not supported/programmed)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetVoiceNumber(
+ BYTE voiceNumberSize,
+ CHAR * pVoiceNumber,
+ BYTE minSize,
+ CHAR * pMIN )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetVoiceNumber( voiceNumberSize,
+ pVoiceNumber,
+ minSize,
+ pMIN );
+}
+
+/*===========================================================================
+METHOD:
+ GetIMSI
+
+DESCRIPTION:
+ This function returns the device IMSI
+
+PARAMETERS:
+ stringSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the string array can contain
+ pString [ O ] - NULL terminated string
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetIMSI(
+ BYTE stringSize,
+ CHAR * pString )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetIMSI( stringSize, pString );
+}
+
+/*===========================================================================
+METHOD:
+ GetSerialNumbers
+
+DESCRIPTION:
+ This command returns all serial numbers assigned to the device
+
+PARAMETERS:
+ esnSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the ESN array can contain
+ pESNString [ O ] - ESN string (empty string returned when ESN is
+ not supported/programmed)
+ imeiSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the IMEI array can contain
+ pIMEIString [ O ] - IMEI string (empty string returned when IMEI is
+ not supported/programmed)
+ meidSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the MEID array can contain
+ pMEIDString [ O ] - MEID string (empty string returned when MEID is
+ not supported/programmed)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetSerialNumbers(
+ BYTE esnSize,
+ CHAR * pESNString,
+ BYTE imeiSize,
+ CHAR * pIMEIString,
+ BYTE meidSize,
+ CHAR * pMEIDString )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetSerialNumbers( esnSize,
+ pESNString,
+ imeiSize,
+ pIMEIString,
+ meidSize,
+ pMEIDString );
+}
+
+/*===========================================================================
+METHOD:
+ SetLock
+
+DESCRIPTION:
+ This function sets the user lock state maintained by the device
+
+PARAMETERS:
+ state [ I ] - Desired lock state
+ pCurrentPIN [ I ] - Current four digit PIN string
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetLock(
+ ULONG state,
+ CHAR * pCurrentPIN )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return pAPI->SetLock( state, pCurrentPIN );
+}
+
+/*===========================================================================
+METHOD:
+ QueryLock
+
+DESCRIPTION:
+ This function sets the user lock state maintained by the device
+
+PARAMETERS:
+ pState [ O ] - Current lock state
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG QueryLock( ULONG * pState )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->QueryLock( pState );
+}
+
+/*===========================================================================
+METHOD:
+ ChangeLockPIN
+
+DESCRIPTION:
+ This command sets the user lock code maintained by the device
+
+PARAMETERS:
+ pCurrentPIN [ O ] - Current four digit PIN string
+ pDesiredPIN [ O ] - New four digit PIN string
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG ChangeLockPIN(
+ CHAR * pCurrentPIN,
+ CHAR * pDesiredPIN )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return pAPI->ChangeLockPIN( pCurrentPIN, pDesiredPIN );
+}
+
+/*===========================================================================
+METHOD:
+ GetHardwareRevision
+
+DESCRIPTION:
+ This function returns the device hardware revision
+
+PARAMETERS:
+ stringSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the string array can contain
+ pString [ O ] - NULL terminated string
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetHardwareRevision(
+ BYTE stringSize,
+ CHAR * pString )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetHardwareRevision( stringSize, pString );
+}
+
+/*===========================================================================
+METHOD:
+ GetPRLVersion
+
+DESCRIPTION:
+ This function returns the version of the active Preferred Roaming List
+ (PRL) in use by the device
+
+PARAMETERS:
+ pPRLVersion [ O ] - The PRL version number
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetPRLVersion( WORD * pPRLVersion )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetPRLVersion( pPRLVersion );
+}
+
+/*===========================================================================
+METHOD:
+ GetERIFile
+
+DESCRIPTION:
+ This command returns the ERI file that is stored in EFS on the device
+
+PARAMETERS:
+ pFileSize [I/O] - Upon input the maximum number of bytes that the file
+ contents array can contain. Upon successful output
+ the actual number of bytes written to the file contents
+ array
+ pFile [ O ] - The file contents
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetERIFile(
+ ULONG * pFileSize,
+ BYTE * pFile )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetERIFile( pFileSize, pFile );
+}
+
+/*===========================================================================
+METHOD:
+ ActivateAutomatic
+
+DESCRIPTION:
+ This function requests the device to perform automatic service activation
+
+PARAMETERS:
+ pActivationCode [ I ] - Activation code (maximum string length of 12)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG ActivateAutomatic( CHAR * pActivationCode )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return pAPI->ActivateAutomatic( pActivationCode );
+}
+
+/*===========================================================================
+METHOD:
+ ActivateManual
+
+DESCRIPTION:
+ This function requests the device perform manual service activation
+
+PARAMETERS:
+ pSPC [ I ] - NULL terminated string representing the six digit
+ service programming code
+ sid [ I ] - System identification number
+ pMDN [ I ] - Mobile Directory Number string
+ pMIN [ I ] - Mobile Identification Number string
+ prlSize [ I ] - (Optional) Size of PRL file array
+ pPRL [ I ] - (Optional) The PRL file contents
+ pMNHA [ I ] - (Optional) MN-HA string
+ pMNAAA [ I ] - (Optional) MN-AAA string
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG ActivateManual(
+ CHAR * pSPC,
+ WORD sid,
+ CHAR * pMDN,
+ CHAR * pMIN,
+ ULONG prlSize,
+ BYTE * pPRL,
+ CHAR * pMNHA,
+ CHAR * pMNAAA )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return pAPI->ActivateManual( pSPC,
+ sid,
+ pMDN,
+ pMIN,
+ prlSize,
+ pPRL,
+ pMNHA,
+ pMNAAA );
+}
+
+/*===========================================================================
+METHOD:
+ ResetToFactoryDefaults
+
+DESCRIPTION:
+ This function requests the device reset configuration to factory defaults
+
+PARAMETERS:
+ pSPC [ I ] - NULL terminated string representing the six digit
+ service programming code
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG ResetToFactoryDefaults( CHAR * pSPC )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return pAPI->ResetToFactoryDefaults( pSPC );
+}
+
+/*===========================================================================
+METHOD:
+ GetActivationState
+
+DESCRIPTION:
+ This function returns the device activation state
+
+PARAMETERS:
+ pActivationState [ O ] - Service activation state
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetActivationState( ULONG * pActivationState )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetActivationState( pActivationState );
+}
+
+/*===========================================================================
+METHOD:
+ SetPower
+
+DESCRIPTION:
+ This function sets the operating mode of the device
+
+PARAMETERS:
+ powerMode [ I ] - Selected operating mode
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetPower( ULONG powerMode )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return pAPI->SetPower( powerMode );
+}
+
+/*===========================================================================
+METHOD:
+ GetPower
+
+DESCRIPTION:
+ This function returns the operating mode of the device
+
+PARAMETERS:
+ pPowerMode [ O ] - Current operating mode
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetPower( ULONG * pPowerMode )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetPower( pPowerMode );
+}
+
+/*===========================================================================
+METHOD:
+ GetOfflineReason
+
+DESCRIPTION:
+ This function returns the reason why the operating mode of the device
+ is currently offline
+
+PARAMETERS:
+ pReasonMask [ O ] - Bitmask of offline reasons
+ pbPlatform [ O ] - Offline due to being platform retricted?
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetOfflineReason(
+ ULONG * pReasonMask,
+ ULONG * pbPlatform )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetOfflineReason( pReasonMask, pbPlatform );
+}
+
+/*===========================================================================
+METHOD:
+ GetNetworkTime
+
+DESCRIPTION:
+ This function returns the current time of the device
+
+PARAMETERS:
+ pTimeStamp [ O ] - Count of 1.25ms that have elapsed from the start
+ of GPS time (Jan 6, 1980)
+ pTimeSource [ O ] - Source of the timestamp
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetNetworkTime(
+ ULONGLONG * pTimeCount,
+ ULONG * pTimeSource )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetNetworkTime( pTimeCount, pTimeSource );
+}
+
+/*===========================================================================
+METHOD:
+ ValidateSPC
+
+DESCRIPTION:
+ This function validates the service programming code
+
+PARAMETERS:
+ pSPC [ I ] - Six digit service programming code
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG ValidateSPC( CHAR * pSPC )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->ValidateSPC( pSPC );
+}
+
+/*===========================================================================
+METHOD:
+ DeleteSMS
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG DeleteSMS(
+ ULONG storageType,
+ ULONG * pMessageIndex,
+ ULONG * pMessageTag )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return pAPI->DeleteSMS( storageType, pMessageIndex, pMessageTag );
+}
+
+/*===========================================================================
+METHOD:
+ GetSMSList
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetSMSList(
+ ULONG storageType,
+ ULONG * pRequestedTag,
+ ULONG * pMessageListSize,
+ BYTE * pMessageList )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetSMSList( storageType,
+ pRequestedTag,
+ pMessageListSize,
+ pMessageList );
+}
+
+/*===========================================================================
+METHOD:
+ GetSMS
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetSMS(
+ ULONG storageType,
+ ULONG messageIndex,
+ ULONG * pMessageTag,
+ ULONG * pMessageFormat,
+ ULONG * pMessageSize,
+ BYTE * pMessage )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetSMS( storageType,
+ messageIndex,
+ pMessageTag,
+ pMessageFormat,
+ pMessageSize,
+ pMessage );
+}
+
+/*===========================================================================
+METHOD:
+ ModifySMSStatus
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG ModifySMSStatus(
+ ULONG storageType,
+ ULONG messageIndex,
+ ULONG messageTag )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return pAPI->ModifySMSStatus( storageType, messageIndex, messageTag );
+}
+
+/*===========================================================================
+METHOD:
+ SaveSMS
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG SaveSMS(
+ ULONG storageType,
+ ULONG messageFormat,
+ ULONG messageSize,
+ BYTE * pMessage,
+ ULONG * pMessageIndex )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SaveSMS( storageType,
+ messageFormat,
+ messageSize,
+ pMessage,
+ pMessageIndex );
+}
+
+/*===========================================================================
+METHOD:
+ SendSMS
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG SendSMS(
+ ULONG messageFormat,
+ ULONG messageSize,
+ BYTE * pMessage,
+ ULONG * pMessageFailureCode )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SendSMS( messageFormat,
+ messageSize,
+ pMessage,
+ pMessageFailureCode );
+}
+
+/*===========================================================================
+METHOD:
+ GetSMSCAddress
+
+DESCRIPTION:
+ This function returns 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:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetSMSCAddress(
+ BYTE addressSize,
+ CHAR * pSMSCAddress,
+ BYTE typeSize,
+ CHAR * pSMSCType )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetSMSCAddress( addressSize,
+ pSMSCAddress,
+ typeSize,
+ pSMSCType );
+}
+
+/*===========================================================================
+METHOD:
+ SetSMSCAddress
+
+DESCRIPTION:
+ This function sets the SMS center address
+
+PARAMETERS:
+ pSMSCAddress [ 0 ] - The SMS center address represented as a NULL
+ terminated string
+ pSMSCType [ 0 ] - The SMS center address type represented as a NULL
+ terminated string (optional)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetSMSCAddress(
+ CHAR * pSMSCAddress,
+ CHAR * pSMSCType )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetSMSCAddress( pSMSCAddress, pSMSCType );
+}
+
+/*===========================================================================
+METHOD:
+ GetSMSRoutes
+
+DESCRIPTION:
+ This function gets 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
+===========================================================================*/
+ULONG GetSMSRoutes(
+ BYTE * pRouteSize,
+ BYTE * pRoutes )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetSMSRoutes( pRouteSize, pRoutes );
+}
+
+/*===========================================================================
+METHOD:
+ SetSMSRoutes
+
+DESCRIPTION:
+ This function sets 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
+===========================================================================*/
+ULONG SetSMSRoutes(
+ BYTE * pRouteSize,
+ BYTE * pRoutes )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetSMSRoutes( pRouteSize, pRoutes );
+}
+
+/*===========================================================================
+METHOD:
+ UIMSetPINProtection
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG UIMSetPINProtection(
+ ULONG id,
+ ULONG bEnable,
+ CHAR * pValue,
+ ULONG * pVerifyRetriesLeft,
+ ULONG * pUnblockRetriesLeft )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->UIMSetPINProtection( id,
+ bEnable,
+ pValue,
+ pVerifyRetriesLeft,
+ pUnblockRetriesLeft );
+}
+
+/*===========================================================================
+METHOD:
+ UIMVerifyPIN
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG UIMVerifyPIN(
+ ULONG id,
+ CHAR * pValue,
+ ULONG * pVerifyRetriesLeft,
+ ULONG * pUnblockRetriesLeft )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->UIMVerifyPIN( id,
+ pValue,
+ pVerifyRetriesLeft,
+ pUnblockRetriesLeft );
+}
+
+/*===========================================================================
+METHOD:
+ UIMUnblockPIN
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG UIMUnblockPIN(
+ ULONG id,
+ CHAR * pPUKValue,
+ CHAR * pNewValue,
+ ULONG * pVerifyRetriesLeft,
+ ULONG * pUnblockRetriesLeft )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->UIMUnblockPIN( id,
+ pPUKValue,
+ pNewValue,
+ pVerifyRetriesLeft,
+ pUnblockRetriesLeft );
+}
+
+/*===========================================================================
+METHOD:
+ UIMChangePIN
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG UIMChangePIN(
+ ULONG id,
+ CHAR * pOldValue,
+ CHAR * pNewValue,
+ ULONG * pVerifyRetriesLeft,
+ ULONG * pUnblockRetriesLeft )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->UIMChangePIN( id,
+ pOldValue,
+ pNewValue,
+ pVerifyRetriesLeft,
+ pUnblockRetriesLeft );
+}
+
+/*===========================================================================
+METHOD:
+ UIMGetPINStatus
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG UIMGetPINStatus(
+ ULONG id,
+ ULONG * pStatus,
+ ULONG * pVerifyRetriesLeft,
+ ULONG * pUnblockRetriesLeft )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->UIMGetPINStatus( id,
+ pStatus,
+ pVerifyRetriesLeft,
+ pUnblockRetriesLeft );
+}
+
+/*===========================================================================
+METHOD:
+ UIMGetICCID
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG UIMGetICCID(
+ BYTE stringSize,
+ CHAR * pString )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->UIMGetICCID( stringSize, pString );
+}
+
+/*===========================================================================
+METHOD:
+ UIMGetControlKeyStatus
+
+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
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG UIMGetControlKeyStatus(
+ ULONG id,
+ ULONG * pStatus,
+ ULONG * pVerifyRetriesLeft,
+ ULONG * pUnblockRetriesLeft )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->UIMGetControlKeyBlockingStatus( id,
+ pStatus,
+ pVerifyRetriesLeft,
+ pUnblockRetriesLeft,
+ 0 );
+}
+
+/*===========================================================================
+METHOD:
+ UIMGetControlKeyBlockingStatus
+
+DESCRIPTION:
+ This function returns the blocking 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
+===========================================================================*/
+ULONG UIMGetControlKeyBlockingStatus(
+ ULONG id,
+ ULONG * pStatus,
+ ULONG * pVerifyRetriesLeft,
+ ULONG * pUnblockRetriesLeft,
+ ULONG * pbBlocking )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->UIMGetControlKeyBlockingStatus( id,
+ pStatus,
+ pVerifyRetriesLeft,
+ pUnblockRetriesLeft,
+ pbBlocking);
+}
+
+/*===========================================================================
+METHOD:
+ UIMSetControlKeyProtection
+
+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
+===========================================================================*/
+ULONG UIMSetControlKeyProtection(
+ ULONG id,
+ ULONG status,
+ CHAR * pValue,
+ ULONG * pVerifyRetriesLeft )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->UIMSetControlKeyProtection( id,
+ status,
+ pValue,
+ pVerifyRetriesLeft );
+}
+
+/*===========================================================================
+METHOD:
+ UIMUnblockControlKey
+
+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
+===========================================================================*/
+ULONG UIMUnblockControlKey(
+ ULONG id,
+ CHAR * pValue,
+ ULONG * pUnblockRetriesLeft )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->UIMUnblockControlKey( id,
+ pValue,
+ pUnblockRetriesLeft );
+}
+
+/*===========================================================================
+METHOD:
+ GetPDSState
+
+DESCRIPTION:
+ This function returns the current PDS state
+
+PARAMETERS:
+ pEnabled [ O ] - Current PDS state (0 = disabled)
+ pTracking [ O ] - Current PDS tracking session state
+
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetPDSState(
+ ULONG * pEnabled,
+ ULONG * pTracking )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetPDSState( pEnabled, pTracking );
+}
+
+/*===========================================================================
+METHOD:
+ SetPDSState
+
+DESCRIPTION:
+ This function sets the PDS state
+
+PARAMETERS:
+ enable [ I ] - Desired PDS state (0 = disable)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetPDSState( ULONG enable )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetPDSState( enable );
+}
+
+/*===========================================================================
+METHOD:
+ PDSInjectTimeReference
+
+DESCRIPTION:
+ This function injects a system time into the PDS engine
+
+PARAMETERS:
+ sysTime [ I ] - System time
+ sysDiscontinuities [ I ] - Number of system time discontinuities
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG PDSInjectTimeReference(
+ ULONGLONG systemTime,
+ USHORT systemDiscontinuities )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->PDSInjectTimeReference( systemTime,
+ systemDiscontinuities );
+}
+
+/*===========================================================================
+METHOD:
+ GetPDSDefaults
+
+DESCRIPTION:
+ This function returns the default tracking session configuration
+
+PARAMETERS:
+ pOperation [ O ] - Current session operating mode
+ pTimeout [ O ] - Maximum amount of time (seconds) to work on each fix
+ pInterval [ O ] - Interval (milliseconds) between fix requests
+ pAccuracy [ O ] - Current accuracy threshold (meters)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetPDSDefaults(
+ ULONG * pOperation,
+ BYTE * pTimeout,
+ ULONG * pInterval,
+ ULONG * pAccuracy )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetPDSDefaults( pOperation,
+ pTimeout,
+ pInterval,
+ pAccuracy );
+}
+
+/*===========================================================================
+METHOD:
+ SetPDSDefaults
+
+DESCRIPTION:
+ This function sets the default tracking session configuration
+
+PARAMETERS:
+ operation [ I ] - Desired session operating mode
+ timeout [ I ] - Maximum amount of time (seconds) to work on each fix
+ interval [ I ] - Interval (milliseconds) between fix requests
+ accuracy [ I ] - Desired accuracy threshold (meters)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetPDSDefaults(
+ ULONG operation,
+ BYTE timeout,
+ ULONG interval,
+ ULONG accuracy )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetPDSDefaults( operation,
+ timeout,
+ interval,
+ accuracy );
+}
+
+/*===========================================================================
+METHOD:
+ GetXTRAAutomaticDownload
+
+DESCRIPTION:
+ This function returns the XTRA automatic download configuration
+
+PARAMETERS:
+ pbEnabled [ O ] - Automatic download enabled?
+ pInterval [ O ] - Interval (hours) between XTRA downloads
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetXTRAAutomaticDownload(
+ ULONG * pbEnabled,
+ USHORT * pInterval )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetXTRAAutomaticDownload( pbEnabled, pInterval );
+}
+
+/*===========================================================================
+METHOD:
+ SetXTRAAutomaticDownload
+
+DESCRIPTION:
+ This function sets the XTRA automatic download configuration
+
+PARAMETERS:
+ bEnabled [ I ] - Automatic download enabled?
+ interval [ I ] - Interval (hours) between XTRA downloads
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetXTRAAutomaticDownload(
+ ULONG bEnabled,
+ USHORT interval )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetXTRAAutomaticDownload( bEnabled, interval );
+}
+
+/*===========================================================================
+METHOD:
+ GetXTRANetwork
+
+DESCRIPTION:
+ This function returns the XTRA WWAN network preference
+
+PARAMETERS:
+ pPreference [ O ] - XTRA WWAN network preference
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetXTRANetwork( ULONG * pPreference )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetXTRANetwork( pPreference );
+}
+
+/*===========================================================================
+METHOD:
+ SetXTRANetwork
+
+DESCRIPTION:
+ This function sets the XTRA WWAN network preference
+
+PARAMETERS:
+ preference [ I ] - XTRA WWAN network preference
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetXTRANetwork( ULONG preference )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetXTRANetwork( preference );
+}
+
+/*===========================================================================
+METHOD:
+ GetXTRAValidity
+
+DESCRIPTION:
+ This function returns the XTRA database validity period
+
+PARAMETERS:
+ pGPSWeek [ O ] - Starting GPS week of validity period
+ pGPSWeekOffset [ O ] - Starting GPS week offset (minutes) of validity period
+ pDuration [ O ] - Length of validity period (hours)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetXTRAValidity(
+ USHORT * pGPSWeek,
+ USHORT * pGPSWeekOffset,
+ USHORT * pDuration )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetXTRAValidity( pGPSWeek,
+ pGPSWeekOffset,
+ pDuration );
+}
+
+/*===========================================================================
+METHOD:
+ ForceXTRADownload
+
+DESCRIPTION:
+ This function forces the XTRA database to be downloaded to the device
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG ForceXTRADownload()
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->ForceXTRADownload();
+}
+
+/*===========================================================================
+METHOD:
+ GetXTRADataState
+
+DESCRIPTION:
+ This function returns the XTRA data positioning state
+
+PARAMETERS:
+ pState [ O ] - XTRA data positioning state
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetXTRADataState( ULONG * pState )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetXTRADataState( pState );
+}
+
+/*===========================================================================
+METHOD:
+ SetXTRADataState
+
+DESCRIPTION:
+ This function sets the XTRA data positioning state
+
+PARAMETERS:
+ state [ I ] - XTRA data positioning state
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetXTRADataState( ULONG state )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetXTRADataState( state );
+}
+
+/*===========================================================================
+METHOD:
+ GetXTRATimeState
+
+DESCRIPTION:
+ This function returns the XTRA time positioning state
+
+PARAMETERS:
+ pState [ O ] - XTRA time positioning state
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetXTRATimeState( ULONG * pState )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetXTRATimeState( pState );
+}
+
+/*===========================================================================
+METHOD:
+ SetXTRATimeState
+
+DESCRIPTION:
+ This function sets the XTRA time positioning state
+
+PARAMETERS:
+ state [ I ] - XTRA time positioning state
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetXTRATimeState( ULONG state )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetXTRATimeState( state );
+}
+
+/*===========================================================================
+METHOD:
+ GetAGPSConfig
+
+DESCRIPTION:
+ This function returns the PDS AGPS configuration
+
+PARAMETERS:
+ pServerAddress [ O ] - IPv4 address of AGPS server
+ pServerPort [ O ] - Port number of AGPS server
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetAGPSConfig(
+ ULONG * pServerAddress,
+ ULONG * pServerPort )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetAGPSConfig( pServerAddress, pServerPort );
+}
+
+/*===========================================================================
+METHOD:
+ SetAGPSConfig
+
+DESCRIPTION:
+ This function sets the PDS AGPS configuration
+
+PARAMETERS:
+ serverAddress [ I ] - IPv4 address of AGPS server
+ serverPort [ I ] - Port number of AGPS server
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetAGPSConfig(
+ ULONG serverAddress,
+ ULONG serverPort )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetAGPSConfig( serverAddress, serverPort );
+}
+
+/*===========================================================================
+METHOD:
+ GetServiceAutomaticTracking
+
+DESCRIPTION:
+ This function returns the automatic tracking state for the service
+
+PARAMETERS:
+ pbAuto [ O ] - Automatic tracking session started for service?
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetServiceAutomaticTracking( ULONG * pbAuto )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetServiceAutomaticTracking( pbAuto );
+}
+
+/*===========================================================================
+METHOD:
+ SetServiceAutomaticTracking
+
+DESCRIPTION:
+ This function sets the automatic tracking state for the service
+
+PARAMETERS:
+ pbAuto [ I ] - Start automatic tracking session for service?
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetServiceAutomaticTracking( ULONG bAuto )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetServiceAutomaticTracking( bAuto );
+}
+
+/*===========================================================================
+METHOD:
+ GetPortAutomaticTracking
+
+DESCRIPTION:
+ This function returns the automatic tracking configuration for the NMEA
+ COM port
+
+PARAMETERS:
+ pbAuto [ O ] - Automatic tracking enabled for NMEA COM port?
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetPortAutomaticTracking( ULONG * pbAuto )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetPortAutomaticTracking( pbAuto );
+}
+
+/*===========================================================================
+METHOD:
+ SetPortAutomaticTracking
+
+DESCRIPTION:
+ This function sets the automatic tracking configuration for the NMEA
+ COM port
+
+PARAMETERS:
+ pbAuto [ I ] - Enable automatic tracking for NMEA COM port?
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetPortAutomaticTracking( ULONG bAuto )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetPortAutomaticTracking( bAuto );
+}
+
+/*===========================================================================
+METHOD:
+ ResetPDSData
+
+DESCRIPTION:
+ This function resets the specified PDS data
+
+PARAMETERS:
+ pGPSDataMask [ I ] - Bitmask of GPS data to clear (optional)
+ pCellDataMask [ I ] - Bitmask of cell data to clear (optional)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG ResetPDSData(
+ ULONG * pGPSDataMask,
+ ULONG * pCellDataMask )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->ResetPDSData( pGPSDataMask, pCellDataMask );
+}
+
+/*===========================================================================
+METHOD:
+ CATSendTerminalResponse
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG CATSendTerminalResponse(
+ ULONG refID,
+ ULONG dataLen,
+ BYTE * pData )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->CATSendTerminalResponse( refID, dataLen, pData );
+}
+
+/*===========================================================================
+METHOD:
+ CATSendEnvelopeCommand
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG CATSendEnvelopeCommand(
+ ULONG cmdID,
+ ULONG dataLen,
+ BYTE * pData )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->CATSendEnvelopeCommand( cmdID, dataLen, pData );
+}
+
+/*===========================================================================
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetSMSWake(
+ ULONG * pbEnabled,
+ ULONG * pWakeMask )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetSMSWake( pbEnabled, pWakeMask );
+}
+
+/*===========================================================================
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetSMSWake(
+ ULONG bEnable,
+ ULONG wakeMask )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetSMSWake( bEnable, wakeMask );
+}
+
+/*===========================================================================
+METHOD:
+ OMADMStartSession
+
+DESCRIPTION:
+ This function starts an OMA-DM session
+
+PARAMETERS:
+ sessionType [ I ] - Type of session to initiate
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG OMADMStartSession( ULONG sessionType )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->OMADMStartSession( sessionType );
+}
+
+/*===========================================================================
+METHOD:
+ OMADMCancelSession
+
+DESCRIPTION:
+ This function cancels an ongoing OMA-DM session
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG OMADMCancelSession()
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->OMADMCancelSession();
+}
+
+/*===========================================================================
+METHOD:
+ OMADMGetSessionInfo
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG OMADMGetSessionInfo(
+ ULONG * pSessionState,
+ ULONG * pSessionType,
+ ULONG * pFailureReason,
+ BYTE * pRetryCount,
+ WORD * pSessionPause,
+ WORD * pTimeRemaining )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->OMADMGetSessionInfo( pSessionState,
+ pSessionType,
+ pFailureReason,
+ pRetryCount,
+ pSessionPause,
+ pTimeRemaining );
+}
+
+/*===========================================================================
+METHOD:
+ OMADMGetPendingNIA
+
+DESCRIPTION:
+ This function returns information about the pending network initiated
+ alert
+
+PARAMETERS:
+ pSessionType [ O ] - Type of session
+ pSessionID [ O ] - Unique session ID
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG OMADMGetPendingNIA(
+ ULONG * pSessionType,
+ USHORT * pSessionID )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->OMADMGetPendingNIA( pSessionType, pSessionID );
+}
+
+/*===========================================================================
+METHOD:
+ OMADMSendSelection
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG OMADMSendSelection(
+ ULONG selection,
+ USHORT sessionID )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->OMADMSendSelection( selection, sessionID );
+}
+
+/*===========================================================================
+METHOD:
+ OMADMGetFeatureSettings
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG OMADMGetFeatureSettings(
+ ULONG * pbProvisioning,
+ ULONG * pbPRLUpdate )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->OMADMGetFeatureSettings( pbProvisioning,
+ pbPRLUpdate );
+}
+
+/*===========================================================================
+METHOD:
+ OMADMSetProvisioningFeature
+
+DESCRIPTION:
+ This function sets the OMA-DM device provisioning service
+ update feature setting
+
+PARAMETERS:
+ bProvisioning [ I ] - Device provisioning service update enabled
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG OMADMSetProvisioningFeature(
+ ULONG bProvisioning )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->OMADMSetProvisioningFeature( bProvisioning );
+}
+
+/*===========================================================================
+METHOD:
+ OMADMSetPRLUpdateFeature
+
+DESCRIPTION:
+ This function sets the OMA-DM PRL service update feature setting
+
+PARAMETERS:
+ bPRLUpdate [ I ] - PRL service update enabled
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG OMADMSetPRLUpdateFeature(
+ ULONG bPRLUpdate )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->OMADMSetPRLUpdateFeature( bPRLUpdate );
+}
+
+/*===========================================================================
+METHOD:
+ OriginateUSSD
+
+DESCRIPTION:
+ This function initiates a USSD operation
+
+PARAMETERS:
+ pInfo [ I ] - USSD information
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG OriginateUSSD( BYTE * pInfo )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->OriginateUSSD( pInfo );
+}
+
+/*===========================================================================
+METHOD:
+ AnswerUSSD
+
+DESCRIPTION:
+ This function responds to a USSD request from the network
+
+PARAMETERS:
+ pInfo [ I ] - USSD information
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG AnswerUSSD( BYTE * pInfo )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->AnswerUSSD( pInfo );
+}
+
+/*===========================================================================
+METHOD:
+ CancelUSSD
+
+DESCRIPTION:
+ This function cancels an in-progress USSD operation
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG CancelUSSD()
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->CancelUSSD();
+}
+
+/*===========================================================================
+METHOD:
+ UpgradeFirmware
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG UpgradeFirmware( CHAR * pDestinationPath )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->UpgradeFirmware( pDestinationPath );
+}
+
+/*===========================================================================
+METHOD:
+ GetImageInfo
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetImageInfo(
+ CHAR * pPath,
+ ULONG * pFirmwareID,
+ ULONG * pTechnology,
+ ULONG * pCarrier,
+ ULONG * pRegion,
+ ULONG * pGPSCapability )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetImageInfo( pPath,
+ pFirmwareID,
+ pTechnology,
+ pCarrier,
+ pRegion,
+ pGPSCapability );
+}
+
+/*===========================================================================
+METHOD:
+ GetImageStore
+
+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:
+ ULONG - Return code
+===========================================================================*/
+ULONG GetImageStore(
+ WORD pathSize,
+ CHAR * pImageStorePath )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->GetImageStore( pathSize, pImageStorePath );
+}
+
+/*===========================================================================
+METHOD:
+ SetSessionStateCallback
+
+DESCRIPTION:
+ This function enables/disables the session state callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetSessionStateCallback( tFNSessionState pCallback )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetSessionStateCallback( pCallback );
+}
+
+/*===========================================================================
+METHOD:
+ SetByteTotalsCallback
+
+DESCRIPTION:
+ This function enables/disables the RX/TX byte counts callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+ interval [ I ] - Interval in seconds (ignored when disabling)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetByteTotalsCallback(
+ tFNByteTotals pCallback,
+ BYTE interval )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetByteTotalsCallback( pCallback, interval );
+}
+
+/*===========================================================================
+METHOD:
+ SetDataCapabilitiesCallback
+
+DESCRIPTION:
+ This function enables/disables the serving system data capabilities
+ callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetDataCapabilitiesCallback(
+ tFNDataCapabilities pCallback )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetDataCapabilitiesCallback( pCallback );
+}
+
+/*===========================================================================
+METHOD:
+ SetDataBearerCallback
+
+DESCRIPTION:
+ This function enables/disables the data bearer status callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetDataBearerCallback( tFNDataBearer pCallback )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetDataBearerCallback( pCallback );
+}
+
+/*===========================================================================
+METHOD:
+ SetDormancyStatusCallback
+
+DESCRIPTION:
+ This function enables/disables the dormancy status callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetDormancyStatusCallback(
+ tFNDormancyStatus pCallback )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetDormancyStatusCallback( pCallback );
+}
+
+/*===========================================================================
+METHOD:
+ SetMobileIPStatusCallback
+
+DESCRIPTION:
+ This function enables/disables the mobile IP status callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetMobileIPStatusCallback(
+ tFNMobileIPStatus pCallback )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetMobileIPStatusCallback( pCallback );
+}
+
+/*===========================================================================
+METHOD:
+ SetActivationStatusCallback
+
+DESCRIPTION:
+ This function enables/disables the activation status callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetActivationStatusCallback(
+ tFNActivationStatus pCallback )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetActivationStatusCallback( pCallback );
+}
+
+/*===========================================================================
+METHOD:
+ SetPowerCallback
+
+DESCRIPTION:
+ Enable/disable power operating mode callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetPowerCallback( tFNPower pCallback )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetPowerCallback( pCallback );
+}
+
+/*===========================================================================
+METHOD:
+ SetWirelessDisableCallback
+
+DESCRIPTION:
+ Enable/disable wireless disable state callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetWirelessDisableCallback(
+ tFNWirelessDisable pCallback )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetWirelessDisableCallback( pCallback );
+}
+
+/*===========================================================================
+METHOD:
+ SetRoamingIndicatorCallback
+
+DESCRIPTION:
+ This function enables/disables the roaming indicator callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetRoamingIndicatorCallback(
+ tFNRoamingIndicator pCallback )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetRoamingIndicatorCallback( pCallback );
+}
+
+/*===========================================================================
+METHOD:
+ SetSignalStrengthCallback
+
+DESCRIPTION:
+ This function enables/disables the signal strength callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+ thresholdsSize [ I ] - Number of elements the threshold array contain
+ (a maximum of 5 thresholds is supported), must
+ be 0 when disabling the callback
+ pThresholds [ I ] - Signal threshold array (each entry in dBm),
+ must be 0 when disabling the callback
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetSignalStrengthCallback(
+ tFNSignalStrength pCallback,
+ BYTE thresholdsSize,
+ INT8 * pThresholds )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ if (thresholdsSize > 0 && pThresholds == 0)
+ {
+ return (ULONG)eGOBI_ERR_INVALID_ARG;
+ }
+
+ std::list <INT8> thresholdsList;
+ for (BYTE t = 0; t < thresholdsSize; t++)
+ {
+ thresholdsList.push_back( pThresholds[t] );
+ }
+
+ return (ULONG)pAPI->SetSignalStrengthCallback( pCallback, thresholdsList );
+}
+
+/*===========================================================================
+METHOD:
+ SetRFInfoCallback
+
+DESCRIPTION:
+ This function enables/disables the RF information callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetRFInfoCallback( tFNRFInfo pCallback )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetRFInfoCallback( pCallback );
+}
+
+/*===========================================================================
+METHOD:
+ SetLURejectCallback
+
+DESCRIPTION:
+ This function enables/disables the LU reject callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetLURejectCallback( tFNLUReject pCallback )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetLURejectCallback( pCallback );
+}
+
+/*===========================================================================
+METHOD:
+ SetPLMNModeCallback
+
+DESCRIPTION:
+ Enable/disable PLMN mode callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetPLMNModeCallback( tFNPLMNMode pCallback )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetPLMNModeCallback( pCallback );
+}
+
+/*===========================================================================
+METHOD:
+ SetNewSMSCallback
+
+DESCRIPTION:
+ This function enables/disables the new SMS callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetNewSMSCallback( tFNNewSMS pCallback )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetNewSMSCallback( pCallback );
+}
+
+/*===========================================================================
+METHOD:
+ SetNMEACallback
+
+DESCRIPTION:
+ This function enables/disables the NMEA sentence callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetNMEACallback( tFNNewNMEA pCallback )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetNMEACallback( pCallback );
+}
+
+/*===========================================================================
+METHOD:
+ SetPDSStateCallback
+
+DESCRIPTION:
+ This function enables/disables the PDS service state callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetPDSStateCallback( tFNPDSState pCallback )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetPDSStateCallback( pCallback );
+}
+
+/*===========================================================================
+METHOD:
+ SetCATEventCallback
+
+DESCRIPTION:
+ This function enables/disables the CAT event callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+ eventMask [ I ] - Bitmask of CAT events to register for
+ pErrorMask [ O ] - Error bitmask
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetCATEventCallback(
+ tFNCATEvent pCallback,
+ ULONG eventMask,
+ ULONG * pErrorMask )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetCATEventCallback( pCallback, eventMask, pErrorMask );
+}
+
+/*===========================================================================
+METHOD:
+ SetOMADMAlertCallback
+
+DESCRIPTION:
+ This function enables/disables the OMA-DM network initiated alert
+ callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetOMADMAlertCallback( tFNOMADMAlert pCallback )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetOMADMAlertCallback( pCallback );
+}
+
+/*===========================================================================
+METHOD:
+ SetOMADMStateCallback
+
+DESCRIPTION:
+ This function enables/disables the OMA-DM state callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function (0 = disable)
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetOMADMStateCallback( tFNOMADMState pCallback )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetOMADMStateCallback( pCallback );
+}
+
+#ifdef VOICE_SUPPORT
+/*===========================================================================
+METHOD:
+ SetUSSDReleaseCallback
+
+DESCRIPTION:
+ Enable/disable USSD release callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetUSSDReleaseCallback(
+ tFNUSSDRelease pCallback )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetUSSDReleaseCallback( pCallback );
+}
+
+/*===========================================================================
+METHOD:
+ SetUSSDNotificationCallback
+
+DESCRIPTION:
+ Enable/disable USSD notification callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetUSSDNotificationCallback(
+ tFNUSSDNotification pCallback )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetUSSDNotificationCallback( pCallback );
+}
+
+/*===========================================================================
+METHOD:
+ SetUSSDOriginationCallback
+
+DESCRIPTION:
+ Enable/disable USSD origination callback function
+
+PARAMETERS:
+ pCallback [ I ] - Callback function
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+ULONG SetUSSDOriginationCallback(
+ tFNUSSDOrigination pCallback )
+{
+ cGobiConnectionMgmt * pAPI = gConnectionDLL.GetAPI();
+ if (pAPI == 0)
+ {
+ return (ULONG)eGOBI_ERR_INTERNAL;
+ }
+
+ return (ULONG)pAPI->SetUSSDOriginationCallback( pCallback );
+}
+#endif
+
diff --git a/gobi-api/GobiAPI_1.0.40/GobiConnectionMgmt/Makefile.am b/gobi-api/GobiAPI_1.0.40/GobiConnectionMgmt/Makefile.am
new file mode 100644
index 0000000..b6ac96c
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/GobiConnectionMgmt/Makefile.am
@@ -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
+
diff --git a/gobi-api/GobiAPI_1.0.40/GobiImageMgmt/GobiImageMgmt.cpp b/gobi-api/GobiAPI_1.0.40/GobiImageMgmt/GobiImageMgmt.cpp
new file mode 100755
index 0000000..8769be0
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/GobiImageMgmt/GobiImageMgmt.cpp
@@ -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 );
+}
diff --git a/gobi-api/GobiAPI_1.0.40/GobiImageMgmt/GobiImageMgmt.h b/gobi-api/GobiAPI_1.0.40/GobiImageMgmt/GobiImageMgmt.h
new file mode 100755
index 0000000..a14132e
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/GobiImageMgmt/GobiImageMgmt.h
@@ -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;
diff --git a/gobi-api/GobiAPI_1.0.40/GobiImageMgmt/GobiImageMgmtAPI.h b/gobi-api/GobiAPI_1.0.40/GobiImageMgmt/GobiImageMgmtAPI.h
new file mode 100755
index 0000000..dc7f682
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/GobiImageMgmt/GobiImageMgmtAPI.h
@@ -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
diff --git a/gobi-api/GobiAPI_1.0.40/GobiImageMgmt/GobiImageMgmtExports.cpp b/gobi-api/GobiAPI_1.0.40/GobiImageMgmt/GobiImageMgmtExports.cpp
new file mode 100755
index 0000000..d1a8555
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/GobiImageMgmt/GobiImageMgmtExports.cpp
@@ -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 );
+}
diff --git a/gobi-api/GobiAPI_1.0.40/GobiImageMgmt/Makefile.am b/gobi-api/GobiAPI_1.0.40/GobiImageMgmt/Makefile.am
new file mode 100644
index 0000000..1b46c13
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/GobiImageMgmt/Makefile.am
@@ -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
+
diff --git a/gobi-api/GobiAPI_1.0.40/GobiQDLService/99-GobiQDLService.rules b/gobi-api/GobiAPI_1.0.40/GobiQDLService/99-GobiQDLService.rules
new file mode 100755
index 0000000..a19007e
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/GobiQDLService/99-GobiQDLService.rules
@@ -0,0 +1,40 @@
+#===========================================================================
+# FILE:
+# 99-GobiQDLService.rules
+#
+# DESCRIPTION:
+# Udev rules for Qualcomm Downloader application (GobiQDLService)
+#
+# PUBLIC CLASSES AND METHODS:
+#
+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.
+#============================================================================
+
+ACTION=="add", SUBSYSTEM=="tty", KERNEL=="ttyUSB[0-9]*", ATTRS{idVendor}=="05c6", ATTRS{idProduct}=="920c", RUN+="/opt/Qualcomm/Gobi/GobiQDLService/GobiQDLService"
+
+
diff --git a/gobi-api/GobiAPI_1.0.40/GobiQDLService/Main.cpp b/gobi-api/GobiAPI_1.0.40/GobiQDLService/Main.cpp
new file mode 100755
index 0000000..427f10c
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/GobiQDLService/Main.cpp
@@ -0,0 +1,205 @@
+/*===========================================================================
+FILE:
+ Main.cpp
+
+DESCRIPTION:
+ Firmware downloader using cGobiQDLCore class
+
+PUBLIC CLASSES AND FUNCTIONS:
+ Run
+ main
+
+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 "MemoryMappedFile.h"
+
+#include <syslog.h>
+
+//---------------------------------------------------------------------------
+// Free Methods
+//---------------------------------------------------------------------------
+
+/*===========================================================================
+METHOD:
+ Run (Public Method)
+
+DESCRIPTION:
+ Simple QDL download
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool Run()
+{
+ cGobiQDLCore qdl;
+ bool bRC = qdl.Initialize();
+ if (bRC == false)
+ {
+ syslog( LOG_INFO, "Failed to initialize QDL core" );
+ return bRC;
+ }
+
+ qdl.SetQDLTimeout( 10000 );
+
+ std::vector <std::string> qdlPorts = qdl.GetAvailableQDLPorts();
+ if (qdlPorts.size() == 0)
+ {
+ syslog( LOG_INFO, "No QDL devices found" );
+ return false;
+ }
+
+ std::string portName = qdlPorts[0];
+ syslog( LOG_INFO, "Download started to port %s", portName.c_str() );
+
+ // Connect to port
+ ULONG maj = ULONG_MAX;
+ ULONG min = ULONG_MAX;
+ eGobiError err = qdl.OpenQDLPort( portName, 0, &maj, &min );
+ if (err != eGOBI_ERR_NONE)
+ {
+ syslog( LOG_INFO, "OpenQDLPort( %s ) = %d", portName.c_str(), err );
+ return false;
+ }
+
+ ULONG bufSz = 12;
+ sQDLRawImageID buf[12];
+ err = qdl.GetQDLImagesPreference( &bufSz, (BYTE *)&buf[0] );
+ if (err != eGOBI_ERR_NONE)
+ {
+ syslog( LOG_INFO, "GetQDLImagesPreference() = %d", err );
+ qdl.CloseQDLPort( false );
+ return false;
+ }
+
+ if (bufSz > 12)
+ {
+ syslog( LOG_INFO, "GetQDLImagesPreference(), bufSz = %lu", bufSz );
+ qdl.CloseQDLPort( false );
+ return false;
+ }
+
+ bool bErr = false;
+ for (ULONG i = 0; i < bufSz; i++)
+ {
+ std::string img = ::GetImageByUniqueID( &buf[i].mImageID[0] );
+ if (img.size() <= 0)
+ {
+ // Skip files we do not have access to
+ syslog( LOG_INFO, "GetImageByUniqueID() failure" );
+ return false;
+ }
+
+ ULONG fileMaj = 0;
+ ULONG fileMin = 0;
+ err = ::GetImageBootCompatibility( img.c_str(),
+ &fileMaj,
+ &fileMin );
+
+ if (err != eGOBI_ERR_NONE || fileMaj != maj)
+ {
+ // Skip files that may not be compatible
+ syslog( LOG_INFO, "GetImageBootCompatibility() failure [%d]", err );
+ return false;
+ }
+
+ cMemoryMappedFile imgFile( img.c_str() );
+ syslog( LOG_INFO, "Downloading %s", img.c_str() );
+
+ LPVOID pImgData = imgFile.GetContents();
+ ULONG imgSz = imgFile.GetSize();
+ if (pImgData == 0 || imgSz == 0)
+ {
+ syslog( LOG_INFO, "Image file failure [%s]", img.c_str() );
+ bErr = true;
+ return false;
+ }
+
+ ULONG blockSz = QDL_MAX_CHUNK_SIZE;
+ err = qdl.PrepareQDLImageWrite( buf[i].mImageType, imgSz, &blockSz );
+ if (err != eGOBI_ERR_NONE)
+ {
+ if (err == eGOBI_ERR_QDL_OPEN_SKIP)
+ {
+ // Device already has this file
+ continue;
+ }
+ else
+ {
+ syslog( LOG_INFO, "PrepareQDLImageWrite() = %d", err );
+ bErr = true;
+ break;
+ }
+ }
+
+ err = qdl.WriteQDLImageBlock( 0, imgSz, (BYTE *)pImgData );
+ if (err != eGOBI_ERR_NONE)
+ {
+ syslog( LOG_INFO, "WriteQDLImageBlock() = %d", err );
+ bErr = true;
+ break;
+ }
+ }
+
+ if (bErr == false)
+ {
+ syslog( LOG_INFO, "Download completed" );
+ BYTE errImg;
+ qdl.ValidateQDLImages( &errImg );
+ }
+
+ qdl.CloseQDLPort( true );
+}
+
+/*===========================================================================
+METHOD:
+ main (Public Method)
+
+DESCRIPTION:
+ Application entry point
+
+RETURN VALUE:
+ int - Process exit code
+===========================================================================*/
+int main()
+{
+ // Add PID to log statements
+ openlog( "GobiQDLService", LOG_PID, LOG_USER );
+
+ bool bSuccess = Run();
+
+ closelog();
+
+ return (bSuccess ? 0 : -1 );
+}
diff --git a/gobi-api/GobiAPI_1.0.40/GobiQDLService/Makefile.am b/gobi-api/GobiAPI_1.0.40/GobiQDLService/Makefile.am
new file mode 100644
index 0000000..077372e
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/GobiQDLService/Makefile.am
@@ -0,0 +1,28 @@
+INCLUDES = \
+ -I$(top_srcdir)/Core \
+ -I$(top_srcdir)/Shared
+
+bin_PROGRAMS = GobiQDLService
+
+GobiQDLService_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
+
+GobiQDLService_SOURCES = Main.cpp
+
+GobiQDLService_LDADD = \
+ $(top_builddir)/Database/QMI/libQMIDB.la \
+ $(top_builddir)/Shared/libShared.la \
+ $(top_builddir)/Core/libCore.la \
+ -lrt
+
diff --git a/gobi-api/GobiAPI_1.0.40/INSTALL b/gobi-api/GobiAPI_1.0.40/INSTALL
new file mode 100644
index 0000000..7d1c323
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/INSTALL
@@ -0,0 +1,365 @@
+Installation Instructions
+*************************
+
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
+2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+
+ Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved. This file is offered as-is,
+without warranty of any kind.
+
+Basic Installation
+==================
+
+ Briefly, the shell commands `./configure; make; make install' should
+configure, build, and install this package. The following
+more-detailed instructions are generic; see the `README' file for
+instructions specific to this package. Some packages provide this
+`INSTALL' file but do not implement all of the features documented
+below. The lack of an optional feature in a given package is not
+necessarily a bug. More recommendations for GNU packages can be found
+in *note Makefile Conventions: (standards)Makefile Conventions.
+
+ The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation. It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions. Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, and a
+file `config.log' containing compiler output (useful mainly for
+debugging `configure').
+
+ It can also use an optional file (typically called `config.cache'
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
+the results of its tests to speed up reconfiguring. Caching is
+disabled by default to prevent problems with accidental use of stale
+cache files.
+
+ If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release. If you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
+
+ The file `configure.ac' (or `configure.in') is used to create
+`configure' by a program called `autoconf'. You need `configure.ac' if
+you want to change it or regenerate `configure' using a newer version
+of `autoconf'.
+
+ The simplest way to compile this package is:
+
+ 1. `cd' to the directory containing the package's source code and type
+ `./configure' to configure the package for your system.
+
+ Running `configure' might take a while. While running, it prints
+ some messages telling which features it is checking for.
+
+ 2. Type `make' to compile the package.
+
+ 3. Optionally, type `make check' to run any self-tests that come with
+ the package, generally using the just-built uninstalled binaries.
+
+ 4. Type `make install' to install the programs and any data files and
+ documentation. When installing into a prefix owned by root, it is
+ recommended that the package be configured and built as a regular
+ user, and only the `make install' phase executed with root
+ privileges.
+
+ 5. Optionally, type `make installcheck' to repeat any self-tests, but
+ this time using the binaries in their final installed location.
+ This target does not install anything. Running this target as a
+ regular user, particularly if the prior `make install' required
+ root privileges, verifies that the installation completed
+ correctly.
+
+ 6. You can remove the program binaries and object files from the
+ source code directory by typing `make clean'. To also remove the
+ files that `configure' created (so you can compile the package for
+ a different kind of computer), type `make distclean'. There is
+ also a `make maintainer-clean' target, but that is intended mainly
+ for the package's developers. If you use it, you may have to get
+ all sorts of other programs in order to regenerate files that came
+ with the distribution.
+
+ 7. Often, you can also type `make uninstall' to remove the installed
+ files again. In practice, not all packages have tested that
+ uninstallation works correctly, even though it is required by the
+ GNU Coding Standards.
+
+ 8. Some packages, particularly those that use Automake, provide `make
+ distcheck', which can by used by developers to test that all other
+ targets like `make install' and `make uninstall' work correctly.
+ This target is generally not run by end users.
+
+Compilers and Options
+=====================
+
+ Some systems require unusual options for compilation or linking that
+the `configure' script does not know about. Run `./configure --help'
+for details on some of the pertinent environment variables.
+
+ You can give `configure' initial values for configuration parameters
+by setting variables in the command line or in the environment. Here
+is an example:
+
+ ./configure CC=c99 CFLAGS=-g LIBS=-lposix
+
+ *Note Defining Variables::, for more details.
+
+Compiling For Multiple Architectures
+====================================
+
+ You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory. To do this, you can use GNU `make'. `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script. `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'. This
+is known as a "VPATH" build.
+
+ With a non-GNU `make', it is safer to compile the package for one
+architecture at a time in the source code directory. After you have
+installed the package for one architecture, use `make distclean' before
+reconfiguring for another architecture.
+
+ On MacOS X 10.5 and later systems, you can create libraries and
+executables that work on multiple system types--known as "fat" or
+"universal" binaries--by specifying multiple `-arch' options to the
+compiler but only a single `-arch' option to the preprocessor. Like
+this:
+
+ ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+ CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+ CPP="gcc -E" CXXCPP="g++ -E"
+
+ This is not guaranteed to produce working output in all cases, you
+may have to build one architecture at a time and combine the results
+using the `lipo' tool if you have problems.
+
+Installation Names
+==================
+
+ By default, `make install' installs the package's commands under
+`/usr/local/bin', include files under `/usr/local/include', etc. You
+can specify an installation prefix other than `/usr/local' by giving
+`configure' the option `--prefix=PREFIX', where PREFIX must be an
+absolute file name.
+
+ You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files. If you
+pass the option `--exec-prefix=PREFIX' to `configure', the package uses
+PREFIX as the prefix for installing programs and libraries.
+Documentation and other data files still use the regular prefix.
+
+ In addition, if you use an unusual directory layout you can give
+options like `--bindir=DIR' to specify different values for particular
+kinds of files. Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them. In general, the
+default for these options is expressed in terms of `${prefix}', so that
+specifying just `--prefix' will affect all of the other directory
+specifications that were not explicitly provided.
+
+ The most portable way to affect installation locations is to pass the
+correct locations to `configure'; however, many packages provide one or
+both of the following shortcuts of passing variable assignments to the
+`make install' command line to change installation locations without
+having to reconfigure or recompile.
+
+ The first method involves providing an override variable for each
+affected directory. For example, `make install
+prefix=/alternate/directory' will choose an alternate location for all
+directory configuration variables that were expressed in terms of
+`${prefix}'. Any directories that were specified during `configure',
+but not in terms of `${prefix}', must each be overridden at install
+time for the entire installation to be relocated. The approach of
+makefile variable overrides for each directory variable is required by
+the GNU Coding Standards, and ideally causes no recompilation.
+However, some platforms have known limitations with the semantics of
+shared libraries that end up requiring recompilation when using this
+method, particularly noticeable in packages that use GNU Libtool.
+
+ The second method involves providing the `DESTDIR' variable. For
+example, `make install DESTDIR=/alternate/directory' will prepend
+`/alternate/directory' before all installation names. The approach of
+`DESTDIR' overrides is not required by the GNU Coding Standards, and
+does not work on platforms that have drive letters. On the other hand,
+it does better at avoiding recompilation issues, and works well even
+when some directory options were not specified in terms of `${prefix}'
+at `configure' time.
+
+Optional Features
+=================
+
+ If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+ Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System). The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+ For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+ Some packages offer the ability to configure how verbose the
+execution of `make' will be. For these packages, running `./configure
+--enable-silent-rules' sets the default to minimal output, which can be
+overridden with `make V=1'; while running `./configure
+--disable-silent-rules' sets the default to verbose, which can be
+overridden with `make V=0'.
+
+Particular systems
+==================
+
+ On HP-UX, the default C compiler is not ANSI C compatible. If GNU
+CC is not installed, it is recommended to use the following options in
+order to use an ANSI C compiler:
+
+ ./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
+
+and if that doesn't work, install pre-built binaries of GCC for HP-UX.
+
+ On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
+parse its `<wchar.h>' header file. The option `-nodtk' can be used as
+a workaround. If GNU CC is not installed, it is therefore recommended
+to try
+
+ ./configure CC="cc"
+
+and if that doesn't work, try
+
+ ./configure CC="cc -nodtk"
+
+ On Solaris, don't put `/usr/ucb' early in your `PATH'. This
+directory contains several dysfunctional programs; working variants of
+these programs are available in `/usr/bin'. So, if you need `/usr/ucb'
+in your `PATH', put it _after_ `/usr/bin'.
+
+ On Haiku, software installed for all users goes in `/boot/common',
+not `/usr/local'. It is recommended to use the following options:
+
+ ./configure --prefix=/boot/common
+
+Specifying the System Type
+==========================
+
+ There may be some features `configure' cannot figure out
+automatically, but needs to determine by the type of machine the package
+will run on. Usually, assuming the package is built to be run on the
+_same_ architectures, `configure' can figure that out, but if it prints
+a message saying it cannot guess the machine type, give it the
+`--build=TYPE' option. TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name which has the form:
+
+ CPU-COMPANY-SYSTEM
+
+where SYSTEM can have one of these forms:
+
+ OS
+ KERNEL-OS
+
+ See the file `config.sub' for the possible values of each field. If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the machine type.
+
+ If you are _building_ compiler tools for cross-compiling, you should
+use the option `--target=TYPE' to select the type of system they will
+produce code for.
+
+ If you want to _use_ a cross compiler, that generates code for a
+platform different from the build platform, you should specify the
+"host" platform (i.e., that on which the generated programs will
+eventually be run) with `--host=TYPE'.
+
+Sharing Defaults
+================
+
+ If you want to set default values for `configure' scripts to share,
+you can create a site shell script called `config.site' that gives
+default values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists. Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Defining Variables
+==================
+
+ Variables not defined in a site shell script can be set in the
+environment passed to `configure'. However, some packages may run
+configure again during the build, and the customized values of these
+variables may be lost. In order to avoid this problem, you should set
+them in the `configure' command line, using `VAR=value'. For example:
+
+ ./configure CC=/usr/local2/bin/gcc
+
+causes the specified `gcc' to be used as the C compiler (unless it is
+overridden in the site shell script).
+
+Unfortunately, this technique does not work for `CONFIG_SHELL' due to
+an Autoconf bug. Until the bug is fixed you can use this workaround:
+
+ CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
+
+`configure' Invocation
+======================
+
+ `configure' recognizes the following options to control how it
+operates.
+
+`--help'
+`-h'
+ Print a summary of all of the options to `configure', and exit.
+
+`--help=short'
+`--help=recursive'
+ Print a summary of the options unique to this package's
+ `configure', and exit. The `short' variant lists options used
+ only in the top level, while the `recursive' variant lists options
+ also present in any nested packages.
+
+`--version'
+`-V'
+ Print the version of Autoconf used to generate the `configure'
+ script, and exit.
+
+`--cache-file=FILE'
+ Enable the cache: use and save the results of the tests in FILE,
+ traditionally `config.cache'. FILE defaults to `/dev/null' to
+ disable caching.
+
+`--config-cache'
+`-C'
+ Alias for `--cache-file=config.cache'.
+
+`--quiet'
+`--silent'
+`-q'
+ Do not print messages saying which checks are being made. To
+ suppress all normal output, redirect it to `/dev/null' (any error
+ messages will still be shown).
+
+`--srcdir=DIR'
+ Look for the package's source code in directory DIR. Usually
+ `configure' can determine that directory automatically.
+
+`--prefix=DIR'
+ Use DIR as the installation prefix. *note Installation Names::
+ for more details, including other options available for fine-tuning
+ the installation locations.
+
+`--no-create'
+`-n'
+ Run the configure checks, but stop before creating any output
+ files.
+
+`configure' also accepts some other, not widely useful, options. Run
+`configure --help' for more details.
+
diff --git a/gobi-api/GobiAPI_1.0.40/Makefile.am b/gobi-api/GobiAPI_1.0.40/Makefile.am
new file mode 100644
index 0000000..654c675
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Makefile.am
@@ -0,0 +1,9 @@
+SUBDIRS= \
+ Database \
+ Shared \
+ Core \
+ GobiConnectionMgmt \
+ GobiImageMgmt \
+ GobiQDLService
+
+ACLOCAL_AMFLAGS = -I m4
diff --git a/gobi-api/GobiAPI_1.0.40/NEWS b/gobi-api/GobiAPI_1.0.40/NEWS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/NEWS
diff --git a/gobi-api/GobiAPI_1.0.40/README b/gobi-api/GobiAPI_1.0.40/README
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/README
diff --git a/gobi-api/GobiAPI_1.0.40/Shared/GobiError.h b/gobi-api/GobiAPI_1.0.40/Shared/GobiError.h
new file mode 100755
index 0000000..20117d5
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Shared/GobiError.h
@@ -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;
+};
diff --git a/gobi-api/GobiAPI_1.0.40/Shared/GobiImageDefinitions.h b/gobi-api/GobiAPI_1.0.40/Shared/GobiImageDefinitions.h
new file mode 100755
index 0000000..5fd3d57
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Shared/GobiImageDefinitions.h
@@ -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
+};
diff --git a/gobi-api/GobiAPI_1.0.40/Shared/GobiMBNMgmt.cpp b/gobi-api/GobiAPI_1.0.40/Shared/GobiMBNMgmt.cpp
new file mode 100755
index 0000000..ec76759
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Shared/GobiMBNMgmt.cpp
@@ -0,0 +1,943 @@
+/*===========================================================================
+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"
+
+//---------------------------------------------------------------------------
+// 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 += '/';
+ }
+
+ std::vector <std::string> files;
+ DepthSearch( folderSearch,
+ 0,
+ ".mbn",
+ files );
+
+ int fileNum = files.size();
+ for (int i = 0; i < fileNum; i++)
+ {
+ std::string mbnName = files[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 );
+ }
+ }
+
+ 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 += '/';
+ }
+
+ std::vector <std::string> files;
+ DepthSearch( folderSearch,
+ 0,
+ ".mbn",
+ files );
+
+ int fileNum = files.size();
+ for (int i = 0; i < fileNum; i++)
+ {
+ std::string mbnName = files[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;
+ }
+ }
+ }
+
+ if (retStr.size() > 0)
+ {
+ break;
+ }
+ }
+
+ return retStr;
+}
+
diff --git a/gobi-api/GobiAPI_1.0.40/Shared/GobiMBNMgmt.h b/gobi-api/GobiAPI_1.0.40/Shared/GobiMBNMgmt.h
new file mode 100755
index 0000000..ff93d55
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Shared/GobiMBNMgmt.h
@@ -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 );
+
+
diff --git a/gobi-api/GobiAPI_1.0.40/Shared/GobiQDLCore.cpp b/gobi-api/GobiAPI_1.0.40/Shared/GobiQDLCore.cpp
new file mode 100755
index 0000000..9d3857b
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Shared/GobiQDLCore.cpp
@@ -0,0 +1,943 @@
+/*===========================================================================
+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 "CoreUtilities.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/";
+
+ std::vector <std::string> files;
+ DepthSearch( path,
+ 2,
+ "ttyUSB",
+ files );
+
+ int fileNum = files.size();
+ for (int i = 0; i < fileNum; i++)
+ {
+ // Example "/sys/bus/usb/devices/8-1/8-1:1.1/ttyUSB0"
+ std::string nodePath = files[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;
+ int 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 );
+ }
+
+ 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;
+}
diff --git a/gobi-api/GobiAPI_1.0.40/Shared/GobiQDLCore.h b/gobi-api/GobiAPI_1.0.40/Shared/GobiQDLCore.h
new file mode 100755
index 0000000..2787361
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Shared/GobiQDLCore.h
@@ -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;
+};
+
diff --git a/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICore.cpp b/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICore.cpp
new file mode 100755
index 0000000..8ce7fad
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICore.cpp
@@ -0,0 +1,1018 @@
+/*===========================================================================
+FILE:
+ GobiQMICore.cpp
+
+DESCRIPTION:
+ QUALCOMM Gobi QMI Based API Core
+
+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"
+#include "ProtocolNotification.h"
+#include "CoreUtilities.h"
+
+//---------------------------------------------------------------------------
+// Definitions
+//---------------------------------------------------------------------------
+
+// Default timeout for Gobi QMI requests
+const ULONG DEFAULT_GOBI_QMI_TIMEOUT = 2000;
+
+/*=========================================================================*/
+// Free Methods
+/*=========================================================================*/
+
+/*===========================================================================
+METHOD:
+ FindTLV (Free Method)
+
+DESCRIPTION:
+ Find the given TLV
+
+PARAMETERS:
+ tlvs [ I ] - TLV parsing input vector
+ tlvKey [ I ] - Key of the TLV that is to be found
+
+RETURN VALUE:
+ cDataParser::tParsedFields
+===========================================================================*/
+sDB2NavInput FindTLV(
+ const std::vector <sDB2NavInput> & tlvs,
+ const sProtocolEntityKey & tlvKey )
+{
+ sDB2NavInput retNI;
+
+ // We need some TLVs to parse and a valid QMI DB key
+ ULONG tlvCount = (ULONG)tlvs.size();
+ if (tlvCount == 0 || tlvKey.mKey.size() < 3)
+ {
+ return retNI;
+ }
+
+ for (ULONG t = 0; t < tlvCount; t++)
+ {
+ const sDB2NavInput & ni = tlvs[t];
+ if (tlvKey.mKey == ni.mKey)
+ {
+ retNI = ni;
+ break;
+ }
+ }
+
+ return retNI;
+}
+
+/*===========================================================================
+METHOD:
+ ParseTLV (Free Method)
+
+DESCRIPTION:
+ Parse the given TLV to fields
+
+PARAMETERS:
+ db [ I ] - Database to use
+ qmiBuf [ I ] - Original buffer containing TLV (locks data)
+ tlvs [ I ] - TLV parsing input vector
+ tlvKey [ I ] - Key of the TLV that is to be parsed
+ bFieldStrings [ I ] - Generate field value strings?
+
+RETURN VALUE:
+ cDataParser::tParsedFields
+===========================================================================*/
+cDataParser::tParsedFields ParseTLV(
+ const cCoreDatabase & db,
+ const sProtocolBuffer & qmiBuf,
+ const std::vector <sDB2NavInput> & tlvs,
+ const sProtocolEntityKey & tlvKey,
+ bool bFieldStrings )
+{
+ cDataParser::tParsedFields retFields;
+
+ // We need some TLVs to parse and a valid QMI DB key
+ ULONG tlvCount = (ULONG)tlvs.size();
+ if (tlvCount == 0 || tlvKey.mKey.size() < 3)
+ {
+ return retFields;
+ }
+
+ for (ULONG t = 0; t < tlvCount; t++)
+ {
+ const sDB2NavInput & ni = tlvs[t];
+ if (tlvKey.mKey == ni.mKey)
+ {
+ cDataParser dp( db, qmiBuf, tlvKey, ni.mpPayload, ni.mPayloadLen );
+ dp.Parse( bFieldStrings, false );
+
+ retFields = dp.GetFields();
+ break;
+ }
+ }
+
+ return retFields;
+}
+
+/*=========================================================================*/
+// cGobiQMICore Methods
+/*=========================================================================*/
+
+/*===========================================================================
+METHOD:
+ cGobiQMICore (Public Method)
+
+DESCRIPTION:
+ Constructor
+
+RETURN VALUE:
+ None
+===========================================================================*/
+cGobiQMICore::cGobiQMICore()
+ : mbFailOnMultipleDevices( false ),
+ mDeviceNode( "" ),
+ mDeviceKey( "" ),
+ mLastError( eGOBI_ERR_NONE ),
+ mRequests( 16 ),
+ mLastNetStartID( (WORD)INVALID_QMI_TRANSACTION_ID )
+{
+ // Nothing to do
+}
+
+/*===========================================================================
+METHOD:
+ ~cGobiQMICore (Public Method)
+
+DESCRIPTION:
+ Destructor
+
+RETURN VALUE:
+ BOOL
+===========================================================================*/
+cGobiQMICore::~cGobiQMICore()
+{
+ Cleanup();
+}
+
+/*===========================================================================
+METHOD:
+ Initialize (Public Method)
+
+DESCRIPTION:
+ Initialize the object
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cGobiQMICore::Initialize()
+{
+ // Initialize database
+ mDB.Initialize();
+
+ // Allocate configured QMI servers
+ bool bOK = true;
+ std::set <tServerConfig>::const_iterator pIter = mServerConfig.begin();
+ while (pIter != mServerConfig.end())
+ {
+ cQMIProtocolServer * pSvr = 0;
+ pSvr = new cQMIProtocolServer( pIter->first, 8192, 512 );
+ if (pSvr == 0)
+ {
+ if (pIter->second == true)
+ {
+ bOK = false;
+ break;
+ }
+ }
+ else
+ {
+ mServers[pIter->first] = pSvr;
+ }
+
+ pIter++;
+ }
+
+ if (bOK == false)
+ {
+ Cleanup();
+ }
+
+ return bOK;
+}
+
+/*===========================================================================
+METHOD:
+ Cleanup (Public Method)
+
+DESCRIPTION:
+ Cleanup the object
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cGobiQMICore::Cleanup()
+{
+ Disconnect();
+
+ // Free allocated QMI servers
+ std::map <eQMIService, cQMIProtocolServer *>::const_iterator pIter;
+ pIter = mServers.begin();
+
+ while (pIter != mServers.end())
+ {
+ cQMIProtocolServer * pSvr = pIter->second;
+ if (pSvr != 0)
+ {
+ delete pSvr;
+ }
+
+ pIter++;
+ }
+
+ mServers.clear();
+
+ return true;
+}
+
+/*===========================================================================
+METHOD:
+ GetAvailableDevices (Public Method)
+
+DESCRIPTION:
+ Return the set of available Gobi network devices
+
+RETURN VALUE:
+ std::vector <tDeviceID> - Vector of device ID and device key pairs
+===========================================================================*/
+std::vector <cGobiQMICore::tDeviceID>
+cGobiQMICore::GetAvailableDevices()
+{
+ std::vector <tDeviceID> devices;
+
+ std::string path = "/sys/bus/usb/devices/";
+
+ std::vector <std::string> files;
+ DepthSearch( path,
+ 3,
+ "qcqmi",
+ files );
+
+ int fileNum = files.size();
+ for (int i = 0; i < fileNum; i++)
+ {
+ // Example "/sys/bus/usb/devices/8-1/8-1:1.0/GobiQMI/qcqmi0"
+ std::string nodePath = files[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 two directories to the interface level
+ std::string curPath = nodePath.substr( 0, lastSlash );
+ curPath = curPath.substr( 0, curPath.find_last_of( "/" ) );
+
+ // 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;
+ int ret = read( handle, buff, 2 );
+ if (ret == 2)
+ {
+ ret = strncmp( buff, "00", 2 );
+ if (ret == 0)
+ {
+ bFound = true;
+ }
+
+ ret = strncmp( buff, "05", 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, "920d", 4 );
+ if (ret == 0)
+ {
+ bFound = true;
+ }
+ }
+ close( handle );
+
+ if (bFound == false)
+ {
+ continue;
+ }
+
+ // Device node success!
+
+ // Get MEID of device node (via ioctl) to use as key
+ std::string deviceStr = "/dev/" + deviceNode;
+ std::string key = cQMIProtocolServer::GetDeviceMEID( deviceStr );
+
+ tDeviceID device;
+ device.first = deviceNode;
+ device.second = key;
+
+ devices.push_back( device );
+ }
+
+ return devices;
+}
+
+/*===========================================================================
+METHOD:
+ Connect (Public Method)
+
+DESCRIPTION:
+ Connect to the specified (or first detected) Gobi device
+
+ Both device node and key are case sensitive
+
+PARAMETERS:
+ pDeviceNode [ I ] - The device node
+ pDeviceKey [ I ] - The device key (unique, stored on-device)
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cGobiQMICore::Connect(
+ LPCSTR pDeviceNode,
+ LPCSTR pDeviceKey )
+{
+ // Assume failure
+ bool bRC = false;
+
+ // Clear last error recorded
+ ClearLastError();
+
+ // If you specify a device key then you have to specify a device ID
+ if (pDeviceNode == 0 && pDeviceKey != 0)
+ {
+ mLastError = eGOBI_ERR_INVALID_ARG;
+ return bRC;
+ }
+
+ // First we terminate the current connection
+ Disconnect();
+
+ // Query system for list of active Gobi devices
+ std::vector <tDeviceID> devices = GetAvailableDevices();
+
+ // Did we find any devices?
+ ULONG deviceCount = (ULONG)devices.size();
+ if (deviceCount == 0)
+ {
+ mLastError = eGOBI_ERR_NO_DEVICE;
+ return bRC;
+ }
+
+ std::string deviceKey = "";
+ if (pDeviceKey != 0)
+ {
+ deviceKey = pDeviceKey;
+ }
+
+ // Filter that list to include only the specified device?
+ if (pDeviceNode != 0)
+ {
+ std::vector <tDeviceID>::iterator current = devices.begin();
+ while (current != devices.end())
+ {
+ // Remove if device node doesn't match
+ if (current->first.compare( pDeviceNode ) != 0)
+ {
+ // Erase current element and update ourself to point to next
+ current = devices.erase( current );
+ }
+ // Remove if invalid key is specified
+ else if (deviceKey.size() != 0
+ && current->second.compare( deviceKey ) != 0)
+ {
+ current = devices.erase( current );
+ }
+ // All necessary parameters match
+ else
+ {
+ current++;
+ }
+ }
+ }
+
+ // Anything left after filtering?
+ deviceCount = (ULONG)devices.size();
+ if (deviceCount == 0)
+ {
+ mLastError = eGOBI_ERR_NO_DEVICE;
+ return bRC;
+ }
+
+ // Too many to choose from?
+ if (deviceCount > 1 && mbFailOnMultipleDevices == true)
+ {
+ mLastError = eGOBI_ERR_MULTIPLE_DEVICES;
+ return bRC;
+ }
+
+ // Store device ID/key strings
+ mDeviceNode = devices[0].first;
+ mDeviceKey = devices[0].second;
+
+ // Initalize/connect all configured QMI servers
+ std::map <eQMIService, cQMIProtocolServer *>::const_iterator pIter;
+ pIter = mServers.begin();
+
+ while (pIter != mServers.end())
+ {
+ cQMIProtocolServer * pSvr = pIter->second;
+ if (pSvr != 0)
+ {
+ // 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)
+ pSvr->Initialize();
+
+ std::string deviceStr = "/dev/" + mDeviceNode;
+ bRC = pSvr->Connect( deviceStr.c_str() );
+ if (bRC == false)
+ {
+ tServerConfig tsc( pIter->first, true );
+ if (mServerConfig.find( tsc ) != mServerConfig.end())
+ {
+ // Failure on essential server
+ break;
+ }
+ else
+ {
+ // QMI server non-essential (ignore failure)
+ bRC = true;
+ }
+ }
+ }
+
+ pIter++;
+ }
+
+ // Any server fail?
+ if (bRC == false)
+ {
+ // Yes, disconnect them all
+ Disconnect();
+
+ // ... and set the error code
+ mLastError = eGOBI_ERR_CONNECT;
+ }
+
+ return bRC;
+}
+
+/*===========================================================================
+METHOD:
+ Disconnect (Public Method)
+
+DESCRIPTION:
+ Disconnect from the currently connected Gobi device
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cGobiQMICore::Disconnect()
+{
+ // Clear last error recorded
+ ClearLastError();
+
+ // Assume failure
+ bool bRC = false;
+ if (mDeviceNode.size() > 0)
+ {
+ mDeviceNode.clear();
+ mDeviceKey.clear();
+ bRC = true;
+ }
+ else
+ {
+ mLastError = eGOBI_ERR_NO_CONNECTION;
+ }
+
+ // Disconnect/clean-up all configured QMI servers
+ std::map <eQMIService, cQMIProtocolServer *>::const_iterator pIter;
+ pIter = mServers.begin();
+
+ while (pIter != mServers.end())
+ {
+ cQMIProtocolServer * pSvr = pIter->second;
+ if (pSvr != 0)
+ {
+ pSvr->Disconnect();
+ pSvr->Exit();
+ }
+
+ pIter++;
+ }
+
+ return bRC;
+}
+
+/*===========================================================================
+METHOD:
+ GetConnectedDeviceID (Public Method)
+
+DESCRIPTION:
+ Get the device node/key of the currently connected Gobi device
+
+PARAMETERS:
+ devNode [ O ] - Device node (IE: qcqmi0)
+ devKey [ O ] - Device key (may be empty)
+
+RETURN VALUE:
+ bool
+===========================================================================*/
+bool cGobiQMICore::GetConnectedDeviceID(
+ std::string & devNode,
+ std::string & devKey )
+{
+ // Clear last error recorded
+ ClearLastError();
+
+ // Assume failure
+ bool bFound = false;
+ devNode.clear();
+ devKey.clear();
+
+ // Are all required servers connected?
+ bool bAllConnected = true;
+
+ std::map <eQMIService, cQMIProtocolServer *>::const_iterator pIter;
+ pIter = mServers.begin();
+
+ while (pIter != mServers.end())
+ {
+ tServerConfig tsc( pIter->first, true );
+ cQMIProtocolServer * pSvr = pIter->second;
+
+ if (mServerConfig.find( tsc ) != mServerConfig.end() && pSvr != 0)
+ {
+ if (pSvr->IsConnected() == false)
+ {
+ // Failure on essential server
+ bAllConnected = false;
+ break;
+ }
+ }
+
+ pIter++;
+ }
+
+ // Were we once connected?
+ if (mDeviceNode.size() > 0 && bAllConnected == true)
+ {
+ // Yes, but is our device still present?
+ // NOTE: This does not guarantee the device did not leave and come back
+ std::vector <tDeviceID> devices = GetAvailableDevices();
+ ULONG deviceCount = (ULONG)devices.size();
+
+ for (ULONG a = 0; a < deviceCount; a++)
+ {
+ if (devices[a].first == mDeviceNode)
+ {
+ // If there is a device key specified, it must match.
+ if (mDeviceKey.size() > 0)
+ {
+ if (devices[a].second == mDeviceKey)
+ {
+ devNode = devices[a].first;
+ devKey = devices[a].second;
+
+ bFound = true;
+ break;
+ }
+ }
+ else
+ {
+ devNode = devices[a].first;
+
+ bFound = true;
+ break;
+ }
+ }
+ }
+
+ if (bFound == false)
+ {
+ mLastError = eGOBI_ERR_NO_DEVICE;
+ }
+ }
+ else
+ {
+ // We are not connected
+ mLastError = eGOBI_ERR_NO_CONNECTION;
+ }
+
+ return bFound;
+}
+
+/*===========================================================================
+METHOD:
+ Send (Public Method)
+
+DESCRIPTION:
+ Send a request using the specified QMI protocol server and wait for (and
+ then return) the response
+
+PARAMETERS:
+ svc [ I ] - QMI service type
+ pRequest [ I ] - Request to schedule
+ to [ I ] - Timeout value (in milliseconds)
+
+RETURN VALUE:
+ sProtocolBuffer - The response (invalid when no response was received)
+===========================================================================*/
+sProtocolBuffer cGobiQMICore::Send(
+ eQMIService svc,
+ sSharedBuffer * pRequest,
+ ULONG to )
+{
+ // 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, to, 1, 1, &pn );
+ if (to == 0)
+ {
+ mLastError = eGOBI_ERR_INTERNAL;
+ return rsp;
+ }
+
+ // Grab the server
+ cQMIProtocolServer * pSvr = GetServer( svc );
+ if (pSvr == 0)
+ {
+ mLastError = eGOBI_ERR_INTERNAL;
+ return rsp;
+ }
+
+ // Are we connected?
+ if (mDeviceNode.size() <= 0 || pSvr->IsConnected() == false)
+ {
+ mLastError = eGOBI_ERR_NO_CONNECTION;
+ return rsp;
+ }
+
+ // Grab the log from the server
+ const cProtocolLog & protocolLog = pSvr->GetLog();
+
+ // Schedule the request
+ ULONG reqID = pSvr->AddRequest( req );
+ if (reqID == INVALID_REQUEST_ID)
+ {
+ mLastError = eGOBI_ERR_REQ_SCHEDULE;
+ return rsp;
+ }
+
+ // Store for external cancel
+ tServiceRequest sr( svc, reqID );
+ mRequests.AddElement( sr );
+
+ bool bReq = false;
+ bool bExit = false;
+ DWORD idx;
+
+ // Process up to the indicated timeout
+ while (bExit == false)
+ {
+ int wc = sigEvt.Wait( to, 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:
+ {
+ // Are we doing WDS business?
+ if (svc == eQMI_SVC_WDS)
+ {
+ // Grab the as-sent request
+ DWORD id = evt.mParam2;
+ sProtocolBuffer tmpReq = protocolLog.GetBuffer( id );
+ sSharedBuffer * pTmpRequest = tmpReq.GetSharedBuffer();
+ if (pTmpRequest != 0)
+ {
+ // Check the message ID
+ sQMIServiceBuffer actualReq( pTmpRequest );
+ ULONG msgID = actualReq.GetMessageID();
+ if (msgID == (ULONG)eQMI_WDS_START_NET)
+ {
+ // Grab the transaction ID
+ mLastNetStartID = actualReq.GetTransactionID();
+ }
+ }
+ }
+
+ bReq = 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
+ pSvr->RemoveRequest( reqID );
+ }
+
+ // Check that the device is still there?
+ if ( (mLastError == eGOBI_ERR_REQUEST)
+ || (mLastError == eGOBI_ERR_RESPONSE)
+ || (mLastError == eGOBI_ERR_REQUEST_TO)
+ || (mLastError == eGOBI_ERR_RESPONSE_TO) )
+ {
+ eGobiError tmp = mLastError;
+
+ std::string dummy;
+ GetConnectedDeviceID( dummy, dummy );
+ if (mLastError == eGOBI_ERR_NONE)
+ {
+ mLastError = tmp;
+ }
+ }
+
+ return rsp;
+}
+
+/*===========================================================================
+METHOD:
+ SendAndCheckReturn (Public Method)
+
+DESCRIPTION:
+ Send a request using the specified QMI protocol server and wait for (and
+ then validate) the response
+
+PARAMETERS:
+ svc [ I ] - QMI service type
+ pRequest [ I ] - Request to schedule
+ to [ I ] - Timeout value (in milliseconds)
+
+RETURN VALUE:
+ eGobiError - Corrected error code
+===========================================================================*/
+eGobiError cGobiQMICore::SendAndCheckReturn(
+ eQMIService svc,
+ sSharedBuffer * pRequest,
+ ULONG to )
+{
+ sProtocolBuffer rsp = Send( svc, pRequest, to );
+ if (rsp.IsValid() == false)
+ {
+ return GetCorrectedLastError();
+ }
+
+ // Did we receive a valid QMI response?
+ sQMIServiceBuffer qmiRsp( rsp.GetSharedBuffer() );
+ if (qmiRsp.IsValid() == false)
+ {
+ mLastError = eGOBI_ERR_MALFORMED_RSP;
+ return mLastError;
+ }
+
+ // Check the mandatory QMI result TLV for success
+ ULONG rc = 0;
+ ULONG ec = 0;
+ bool bResult = qmiRsp.GetResult( rc, ec );
+ if (bResult == false)
+ {
+ mLastError = eGOBI_ERR_MALFORMED_RSP;
+ return mLastError;
+ }
+ else if (rc != 0)
+ {
+ return GetCorrectedQMIError( ec );
+ }
+
+ // Success!
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ SendSimple (Public Method)
+
+DESCRIPTION:
+ Generate/send a request using the specified QMI protocol server and
+ wait for (and then return) the response
+
+PARAMETERS:
+ svc [ I ] - QMI service type
+ msgID [ I ] - QMI message ID of the request to generate
+ to [ I ] - Timeout value (in milliseconds)
+
+ NOTE: The request has to be a single byte in length, i.e. just a
+ command code, in order for success
+
+RETURN VALUE:
+ sProtocolBuffer - The response (invalid when no response was received)
+===========================================================================*/
+sProtocolBuffer cGobiQMICore::SendSimple(
+ eQMIService svc,
+ WORD msgID,
+ ULONG to )
+{
+ // Clear last error recorded
+ ClearLastError();
+
+ sProtocolBuffer rsp;
+
+ sSharedBuffer * pReq = 0;
+ pReq = sQMIServiceBuffer::BuildBuffer( svc, msgID );
+ if (pReq == 0)
+ {
+ mLastError = eGOBI_ERR_MEMORY;
+ return rsp;
+ }
+
+ rsp = Send( svc, pReq, to );
+ return rsp;
+}
+
+/*===========================================================================
+METHOD:
+ CancelSend (Public Method)
+
+DESCRIPTION:
+ Cancel the most recent in-progress Send() based operation
+
+RETURN VALUE:
+ eGobiError
+===========================================================================*/
+eGobiError cGobiQMICore::CancelSend()
+{
+ ULONG reqs = mRequests.GetTotalCount();
+ if (reqs == 0)
+ {
+ return eGOBI_ERR_NO_CANCELABLE_OP;
+ }
+
+ tServiceRequest elem( eQMI_SVC_ENUM_BEGIN, INVALID_REQUEST_ID );
+ bool bElem = mRequests.GetElement( --reqs, elem );
+ if (bElem == false)
+ {
+ return eGOBI_ERR_INTERNAL;
+ }
+
+ cQMIProtocolServer * pSvr = GetServer( elem.first );
+ if (pSvr == 0)
+ {
+ return eGOBI_ERR_INTERNAL;
+ }
+
+
+ bool bRemove = pSvr->RemoveRequest( elem.second );
+ if (bRemove == false)
+ {
+ return eGOBI_ERR_CANCEL_OP;
+ }
+
+ return eGOBI_ERR_NONE;
+}
diff --git a/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICore.h b/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICore.h
new file mode 100755
index 0000000..0ef9c42
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICore.h
@@ -0,0 +1,1028 @@
+/*===========================================================================
+FILE:
+ GobiQMICore.h
+
+DESCRIPTION:
+ QUALCOMM Gobi QMI Based API Core
+
+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.
+==========================================================================*/
+
+/*=========================================================================*/
+// Pragmas
+/*=========================================================================*/
+#pragma once
+
+//---------------------------------------------------------------------------
+// Include Files
+//---------------------------------------------------------------------------
+#include "CoreDatabase.h"
+#include "ProtocolBuffer.h"
+#include "QMIProtocolServer.h"
+#include "DataParser.h"
+#include "DataPacker.h"
+#include "DB2Utilities.h"
+#include "SyncQueue.h"
+#include "GobiError.h"
+#include "GobiMBNMgmt.h"
+
+//---------------------------------------------------------------------------
+// Definitions
+//---------------------------------------------------------------------------
+
+// Default timeout for Gobi QMI requests
+extern const ULONG DEFAULT_GOBI_QMI_TIMEOUT;
+
+/*=========================================================================*/
+// Prototypes
+/*=========================================================================*/
+
+// Find the given TLV
+sDB2NavInput FindTLV(
+ const std::vector <sDB2NavInput> & tlvs,
+ const sProtocolEntityKey & tlvKey );
+
+// Parse the given TLV to fields
+cDataParser::tParsedFields ParseTLV(
+ const cCoreDatabase & db,
+ const sProtocolBuffer & qmiBuf,
+ const std::vector <sDB2NavInput> & tlvs,
+ const sProtocolEntityKey & tlvKey,
+ bool bFieldStrings = false );
+
+/*=========================================================================*/
+// Class cGobiQMICore
+/*=========================================================================*/
+class cGobiQMICore
+{
+ public:
+ // Constructor
+ cGobiQMICore();
+
+ // Destructor
+ virtual ~cGobiQMICore();
+
+ // Initialize the object
+ virtual bool Initialize();
+
+ // Cleanup the object
+ virtual bool Cleanup();
+
+ // (Inline) Return the QMI database
+ const cCoreDatabase & GetDatabase()
+ {
+ return mDB;
+ };
+
+ // (Inline) Return the server as determined by the service type
+ cQMIProtocolServer * GetServer( eQMIService svc )
+ {
+ cQMIProtocolServer * pSvr = 0;
+
+ std::map <eQMIService, cQMIProtocolServer *>::const_iterator pIter;
+ pIter = mServers.find( svc );
+
+ if (pIter != mServers.end())
+ {
+ pSvr = pIter->second;
+ }
+
+ return pSvr;
+ };
+
+ // (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 QMI error (if this happens to indicate
+ // that no error occurred then return the mapped eQMI_ERR_INTERNAL
+ // value)
+ eGobiError GetCorrectedQMIError( ULONG qmiErrorCode )
+ {
+ ULONG ec = (ULONG)eQMI_ERR_INTERNAL + (ULONG)eGOBI_ERR_QMI_OFFSET;
+ if (qmiErrorCode != (ULONG)eQMI_ERR_NONE)
+ {
+ ec = qmiErrorCode + (ULONG)eGOBI_ERR_QMI_OFFSET;
+ }
+
+ return (eGobiError)ec;
+ };
+
+ // Return the set of available Gobi devices
+ typedef std::pair <std::string, std::string> tDeviceID;
+ virtual std::vector <tDeviceID> GetAvailableDevices();
+
+ // Connect to the specified (or first detected) Gobi device
+ virtual bool Connect(
+ LPCSTR pDeviceNode = 0,
+ LPCSTR pDeviceKey = 0 );
+
+ // Disconnect from the currently connected Gobi device
+ virtual bool Disconnect();
+
+ // Get the device ID of the currently connected Gobi device
+ virtual bool GetConnectedDeviceID(
+ std::string & devNode,
+ std::string & devKey );
+
+ // Send a request using the specified QMI protocol server and wait
+ // for (and then return) the response
+ sProtocolBuffer Send(
+ eQMIService svc,
+ sSharedBuffer * pRequest,
+ ULONG to = DEFAULT_GOBI_QMI_TIMEOUT );
+
+ // Send a request using the specified QMI protocol server and wait
+ // for (and then validate) the response
+ eGobiError SendAndCheckReturn(
+ eQMIService svc,
+ sSharedBuffer * pRequest,
+ ULONG to = DEFAULT_GOBI_QMI_TIMEOUT );
+
+ // Generate/send a request using the specified QMI protocol server
+ // and wait for (and then return) the response
+ sProtocolBuffer SendSimple(
+ eQMIService svc,
+ WORD msgID,
+ ULONG to = DEFAULT_GOBI_QMI_TIMEOUT );
+
+ // Cancel the most recent in-progress Send() based operation
+ eGobiError CancelSend();
+
+#ifdef WDS_SUPPORT
+ // Return the state of the current packet data session
+ eGobiError GetSessionState( ULONG * pState );
+
+ // Return the duration of the current packet data session
+ eGobiError GetSessionDuration( ULONGLONG * pDuration );
+
+ // Return the active/total durations of the current packet data session
+ eGobiError GetSessionDurations(
+ ULONGLONG * pActiveDuration,
+ ULONGLONG * pTotalDuration );
+
+ // Return the dormancy state of the current packet session
+ eGobiError GetDormancyState( ULONG * pState );
+
+ // Return the current autoconnect data session setting
+ eGobiError GetEnhancedAutoconnect(
+ ULONG * pSetting,
+ ULONG * pRoamSetting );
+
+ // Set the autoconnect data session setting
+ eGobiError SetEnhancedAutoconnect(
+ ULONG setting,
+ ULONG * pRoamSetting );
+
+ // Write the default profile settings to the device
+ eGobiError SetDefaultProfile(
+ ULONG profileType,
+ ULONG * pPDPType,
+ ULONG * pIPAddress,
+ ULONG * pPrimaryDNS,
+ ULONG * pSecondaryDNS,
+ ULONG * pAuthentication,
+ CHAR * pName,
+ CHAR * pAPNName,
+ CHAR * pUsername,
+ CHAR * pPassword );
+
+ // Read the default profile settings from the device
+ eGobiError GetDefaultProfile(
+ ULONG profileType,
+ ULONG * pPDPType,
+ ULONG * pIPAddress,
+ ULONG * pPrimaryDNS,
+ ULONG * pSecondaryDNS,
+ ULONG * pAuthentication,
+ BYTE nameSize,
+ CHAR * pName,
+ BYTE apnSize,
+ CHAR * pAPNName,
+ BYTE userSize,
+ CHAR * pUsername );
+
+ // Activate a packet data session
+ eGobiError StartDataSession(
+ ULONG * pTechnology,
+ ULONG * pPrimaryDNS,
+ ULONG * pSecondaryDNS,
+ ULONG * pPrimaryNBNS,
+ ULONG * pSecondaryNBNS,
+ CHAR * pAPNName,
+ ULONG * pIPAddress,
+ ULONG * pAuthentication,
+ CHAR * pUsername,
+ CHAR * pPassword,
+ ULONG * pSessionId,
+ ULONG * pFailureReason );
+
+ // Cancel an in-progress packet data session activation
+ eGobiError CancelDataSession();
+
+ // Stop the current data session
+ eGobiError StopDataSession( ULONG sessionId );
+
+ // Return the current packet data session IP address
+ eGobiError GetIPAddress( ULONG * pIPAddress );
+
+ // Return connection rate information for the packet data connection
+ eGobiError GetConnectionRate(
+ ULONG * pCurrentChannelTXRate,
+ ULONG * pCurrentChannelRXRate,
+ ULONG * pMaxChannelTXRate,
+ ULONG * pMaxChannelRXRate );
+
+ // Return the packet data transfer statistics
+ eGobiError GetPacketStatus(
+ ULONG * pTXPacketSuccesses,
+ ULONG * pRXPacketSuccesses,
+ ULONG * pTXPacketErrors,
+ ULONG * pRXPacketErrors,
+ ULONG * pTXPacketOverflows,
+ ULONG * pRXPacketOverflows );
+
+ // Returns the RX/TX byte counts
+ eGobiError GetByteTotals(
+ ULONGLONG * pTXTotalBytes,
+ ULONGLONG * pRXTotalBytes );
+
+ // Set the current mobile IP setting
+ eGobiError SetMobileIP( ULONG mode );
+
+ // Get the current mobile IP setting
+ eGobiError GetMobileIP( ULONG * pMode );
+
+ // Set the active mobile IP profile index
+ eGobiError SetActiveMobileIPProfile(
+ CHAR * pSPC,
+ BYTE index );
+
+ // Get the active mobile IP profile index
+ eGobiError GetActiveMobileIPProfile( BYTE * pIndex );
+
+ // Set the specified mobile IP profile settings
+ eGobiError SetMobileIPProfile(
+ CHAR * pSPC,
+ BYTE index,
+ BYTE * pEnabled,
+ ULONG * pAddress,
+ ULONG * pPrimaryHA,
+ ULONG * pSecondaryHA,
+ BYTE * pRevTunneling,
+ CHAR * pNAI,
+ ULONG * pHASPI,
+ ULONG * pAAASPI,
+ CHAR * pMNHA,
+ CHAR * pMNAAA );
+
+ // Get the specified mobile IP profile settings
+ eGobiError GetMobileIPProfile(
+ BYTE index,
+ BYTE * pEnabled,
+ ULONG * pAddress,
+ ULONG * pPrimaryHA,
+ ULONG * pSecondaryHA,
+ BYTE * pRevTunneling,
+ BYTE naiSize,
+ CHAR * pNAI,
+ ULONG * pHASPI,
+ ULONG * pAAASPI,
+ ULONG * pHAState,
+ ULONG * pAAAState );
+
+ // Set the mobile IP parameters
+ eGobiError SetMobileIPParameters(
+ CHAR * pSPC,
+ ULONG * pMode,
+ BYTE * pRetryLimit,
+ BYTE * pRetryInterval,
+ BYTE * pReRegPeriod,
+ BYTE * pReRegTraffic,
+ BYTE * pHAAuthenticator,
+ BYTE * pHA2002bis );
+
+ // Get the mobile IP parameters
+ eGobiError GetMobileIPParameters(
+ ULONG * pMode,
+ BYTE * pRetryLimit,
+ BYTE * pRetryInterval,
+ BYTE * pReRegPeriod,
+ BYTE * pReRegTraffic,
+ BYTE * pHAAuthenticator,
+ BYTE * pHA2002bis );
+
+ // Get the last mobile IP error
+ eGobiError GetLastMobileIPError( ULONG * pError );
+
+ // Set the DNS settings for the device
+ eGobiError SetDNSSettings(
+ ULONG * pPrimaryDNS,
+ ULONG * pSecondaryDNS );
+
+ // Get the DNS settings for the device
+ eGobiError GetDNSSettings(
+ ULONG * pPrimaryDNS,
+ ULONG * pSecondaryDNS );
+#endif
+
+#ifdef NAS_SUPPORT
+ // Get the AN-AAA authentication status
+ eGobiError GetANAAAAuthenticationStatus( ULONG * pStatus );
+
+ // Get the current available signal strengths (in dBm)
+ eGobiError GetSignalStrengths(
+ ULONG * pArraySizes,
+ INT8 * pSignalStrengths,
+ ULONG * pRadioInterfaces );
+
+ // Get the current RF information
+ eGobiError GetRFInfo(
+ BYTE * pInstanceSize,
+ BYTE * pInstances );
+
+ // Perform a scan for available networks
+ eGobiError PerformNetworkScan(
+ BYTE * pInstanceSize,
+ BYTE * pInstances );
+
+ // Perform a scan for available networks (includes RAT)
+ eGobiError PerformNetworkRATScan(
+ BYTE * pInstanceSize,
+ BYTE * pInstances,
+ BYTE * pRATSize,
+ BYTE * pRATInstances );
+
+ // Initiate a network registration
+ eGobiError InitiateNetworkRegistration(
+ ULONG regType,
+ WORD mcc,
+ WORD mnc,
+ ULONG rat );
+
+ // Initiate a domain attach (or detach)
+ eGobiError InitiateDomainAttach( ULONG action );
+
+ // Get information regarding the system that currently provides service
+ eGobiError GetServingNetwork(
+ ULONG * pRegistrationState,
+ ULONG * pCSDomain,
+ ULONG * pPSDomain,
+ ULONG * pRAN,
+ BYTE * pRadioIfacesSize,
+ BYTE * pRadioIfaces,
+ ULONG * pRoaming,
+ WORD * pMCC,
+ WORD * pMNC,
+ BYTE nameSize,
+ CHAR * pName );
+
+ // Get data capabilities of serving network system
+ eGobiError GetServingNetworkCapabilities(
+ BYTE * pDataCapssSize,
+ BYTE * pDataCaps );
+
+ // Retrieves the current data bearer technology
+ eGobiError GetDataBearerTechnology( ULONG * pDataBearer );
+
+ // Retrieve information about the home network of the device
+ eGobiError GetHomeNetwork(
+ WORD * pMCC,
+ WORD * pMNC,
+ BYTE nameSize,
+ CHAR * pName,
+ WORD * pSID,
+ WORD * pNID );
+
+ // Sets the network registration preference
+ eGobiError SetNetworkPreference(
+ ULONG technologyPref,
+ ULONG duration );
+
+ // Return the network registration preference
+ eGobiError GetNetworkPreference(
+ ULONG * pTechnologyPref,
+ ULONG * pDuration,
+ ULONG * pPersistentTechnologyPref );
+
+ // Set the current CDMA network parameters
+ eGobiError SetCDMANetworkParameters(
+ CHAR * pSPC,
+ BYTE * pForceRev0,
+ BYTE * pCustomSCP,
+ ULONG * pProtocol,
+ ULONG * pBroadcast,
+ ULONG * pApplication,
+ ULONG * pRoaming );
+
+ // Return the current CDMA network parameters
+ eGobiError GetCDMANetworkParameters(
+ BYTE * pSCI,
+ BYTE * pSCM,
+ BYTE * pRegHomeSID,
+ BYTE * pRegForeignSID,
+ BYTE * pRegForeignNID,
+ BYTE * pForceRev0,
+ BYTE * pCustomSCP,
+ ULONG * pProtocol,
+ ULONG * pBroadcast,
+ ULONG * pApplication,
+ ULONG * pRoaming );
+
+ // Return the Access Overload Class (ACCOLC) of the device
+ eGobiError GetACCOLC( BYTE * pACCOLC );
+
+ // Set the Access Overload Class (ACCOLC) of the device
+ eGobiError SetACCOLC(
+ CHAR * pSPC,
+ BYTE accolc );
+
+ // Return the PLMN mode from the CSP
+ eGobiError GetPLMNMode( ULONG * pMode );
+
+ // Return PLMN name information for the given MCC/MNC
+ eGobiError GetPLMNName(
+ USHORT mcc,
+ USHORT mnc,
+ ULONG * pNamesSize,
+ BYTE * pNames );
+#endif
+
+#ifdef DMS_SUPPORT
+ // Get device capabilities
+ eGobiError GetDeviceCapabilities(
+ ULONG * pMaxTXChannelRate,
+ ULONG * pMaxRXChannelRate,
+ ULONG * pDataServiceCapability,
+ ULONG * pSimCapability,
+ ULONG * pRadioIfacesSize,
+ BYTE * pRadioIfaces );
+
+ // Return the device manufacturer name
+ eGobiError GetManufacturer(
+ BYTE stringSize,
+ CHAR * pString );
+
+ // Return the device model ID
+ eGobiError GetModelID(
+ BYTE stringSize,
+ CHAR * pString );
+
+ // Return the device firmware revision
+ eGobiError GetFirmwareRevision(
+ BYTE stringSize,
+ CHAR * pString );
+
+ // Return the device firmware revisions
+ eGobiError GetFirmwareRevisions(
+ BYTE amssSize,
+ CHAR * pAMSSString,
+ BYTE bootSize,
+ CHAR * pBootString,
+ BYTE priSize,
+ CHAR * pPRIString );
+
+ // Return the voice number in use by the device
+ eGobiError GetVoiceNumber(
+ BYTE voiceNumberSize,
+ CHAR * pVoiceNumber,
+ BYTE minSize,
+ CHAR * pMIN );
+
+ // Return the device IMSI
+ eGobiError GetIMSI(
+ BYTE stringSize,
+ CHAR * pString );
+
+ // Return all serial numbers assigned to the device
+ eGobiError GetSerialNumbers(
+ BYTE esnSize,
+ CHAR * pESNString,
+ BYTE imeiSize,
+ CHAR * pIMEIString,
+ BYTE meidSize,
+ CHAR * pMEIDString );
+
+ // Set the user lock state maintained by the device
+ eGobiError SetLock(
+ ULONG state,
+ CHAR * pCurrentPIN );
+
+ // Set the user lock state maintained by the device
+ eGobiError QueryLock( ULONG * pState );
+
+ // Set the user lock code maintained by the device
+ eGobiError ChangeLockPIN(
+ CHAR * pCurrentPIN,
+ CHAR * pDesiredPIN );
+
+ // Return the device hardware revision
+ eGobiError GetHardwareRevision(
+ BYTE stringSize,
+ CHAR * pString );
+
+ // Return the version of the active Preferred Roaming List (PRL)
+ eGobiError GetPRLVersion( WORD * pPRLVersion );
+
+ // Return the ERI file that is stored in EFS on the device
+ eGobiError GetERIFile(
+ ULONG * pFileSize,
+ BYTE * pFile );
+
+ // Request the device to perform automatic service activation
+ eGobiError ActivateAutomatic( CHAR * pActivationCode );
+
+ // Request the device perform manual service activation
+ eGobiError ActivateManual(
+ CHAR * pSPC,
+ WORD sid,
+ CHAR * pMDN,
+ CHAR * pMIN,
+ ULONG prlSize,
+ BYTE * pPRL,
+ CHAR * pMNHA,
+ CHAR * pMNAAA );
+
+ // Requests the device reset configuration to factory defaults
+ eGobiError ResetToFactoryDefaults( CHAR * pSPC );
+
+ // Return the device activation state
+ eGobiError GetActivationState( ULONG * pActivationState );
+
+ // Set the operating mode of the device`
+ eGobiError SetPower( ULONG powerMode );
+
+ // Return the operating mode of the device
+ eGobiError GetPower( ULONG * pPowerMode );
+
+ // Return operating mode info from the device
+ eGobiError GetPowerInfo(
+ ULONG * pPowerMode,
+ ULONG * pReasonMask,
+ ULONG * pbPlatform );
+
+ // Return the reason why the device is currently offline
+ eGobiError GetOfflineReason(
+ ULONG * pReasonMask,
+ ULONG * pbPlatform );
+
+ // Return the current time of the device
+ eGobiError GetNetworkTime(
+ ULONGLONG * pTimeCount,
+ ULONG * pTimeSource );
+
+ // Validates the service programming code
+ eGobiError ValidateSPC( CHAR * pSPC );
+#endif
+
+#ifdef UIM_SUPPORT
+ // Enable or disable protection of UIM contents by a given PIN
+ eGobiError UIMSetPINProtection(
+ ULONG id,
+ ULONG bEnable,
+ CHAR * pValue,
+ ULONG * pVerifyRetriesLeft,
+ ULONG * pUnblockRetriesLeft );
+
+ // Verify the PIN before accessing the UIM contents
+ eGobiError UIMVerifyPIN(
+ ULONG id,
+ CHAR * pValue,
+ ULONG * pVerifyRetriesLeft,
+ ULONG * pUnblockRetriesLeft );
+
+ // Unblock a blocked PIN
+ eGobiError UIMUnblockPIN(
+ ULONG id,
+ CHAR * pPUKValue,
+ CHAR * pNewValue,
+ ULONG * pVerifyRetriesLeft,
+ ULONG * pUnblockRetriesLeft );
+
+ // Change the PIN value
+ eGobiError UIMChangePIN(
+ ULONG id,
+ CHAR * pOldValue,
+ CHAR * pNewValue,
+ ULONG * pVerifyRetriesLeft,
+ ULONG * pUnblockRetriesLeft );
+
+ // Return the status of the pin
+ eGobiError UIMGetPINStatus(
+ ULONG id,
+ ULONG * pStatus,
+ ULONG * pVerifyRetriesLeft,
+ ULONG * pUnblockRetriesLeft );
+
+ // Return the UIM ICCID
+ eGobiError UIMGetICCID(
+ BYTE stringSize,
+ CHAR * pString );
+
+ // Return the blocking status of the specified facility control key
+ eGobiError UIMGetControlKeyBlockingStatus(
+ ULONG id,
+ ULONG * pStatus,
+ ULONG * pVerifyRetriesLeft,
+ ULONG * pUnblockRetriesLeft,
+ ULONG * pbBlocking );
+
+ // Change the specified facility control key
+ eGobiError UIMSetControlKeyProtection(
+ ULONG id,
+ ULONG status,
+ CHAR * pValue,
+ ULONG * pVerifyRetriesLeft );
+
+ // Unblock the specified facility control key
+ eGobiError UIMUnblockControlKey(
+ ULONG id,
+ CHAR * pValue,
+ ULONG * pUnblockRetriesLeft );
+#endif
+
+#ifdef WMS_SUPPORT
+ // Delete one or more SMS messages from device memory
+ eGobiError DeleteSMS(
+ ULONG storageType,
+ ULONG * pMessageIndex,
+ ULONG * pMessageTag );
+
+ // Return the list of SMS messages stored on the device
+ eGobiError GetSMSList(
+ ULONG storageType,
+ ULONG * pRequestedTag,
+ ULONG * pMessageListSize,
+ BYTE * pMessageList );
+
+ // Return an SMS message from device memory
+ eGobiError GetSMS(
+ ULONG storageType,
+ ULONG messageIndex,
+ ULONG * pMessageTag,
+ ULONG * pMessageFormat,
+ ULONG * pMessageSize,
+ BYTE * pMessage );
+
+ // Modify the status of an SMS message
+ eGobiError ModifySMSStatus(
+ ULONG storageType,
+ ULONG messageIndex,
+ ULONG messageTag );
+
+ // Save an SMS message to device memory
+ eGobiError SaveSMS(
+ ULONG storageType,
+ ULONG messageFormat,
+ ULONG messageSize,
+ BYTE * pMessage,
+ ULONG * pMessageIndex );
+
+ // Send an SMS message for immediate over the air transmission
+ eGobiError SendSMS(
+ ULONG messageFormat,
+ ULONG messageSize,
+ BYTE * pMessage,
+ ULONG * pMessageFailureCode );
+
+ // Return the SMS center address
+ eGobiError GetSMSCAddress(
+ BYTE addressSize,
+ CHAR * pSMSCAddress,
+ BYTE typeSize,
+ CHAR * pSMSCType );
+
+ // Set the SMS center address
+ eGobiError SetSMSCAddress(
+ CHAR * pSMSCAddress,
+ CHAR * pSMSCType );
+
+ // Get the current incoming SMS routing information
+ eGobiError GetSMSRoutes(
+ BYTE * pRouteSize,
+ BYTE * pRoutes );
+
+ // Set the desired incoming SMS routing information
+ eGobiError SetSMSRoutes(
+ BYTE * pRouteSize,
+ BYTE * pRoutes );
+#endif
+
+#ifdef PDS_SUPPORT
+ // Return the current PDS state
+ eGobiError GetPDSState(
+ ULONG * pEnabled,
+ ULONG * pTracking );
+
+ // Set the PDS state
+ eGobiError SetPDSState( ULONG enable );
+
+ // Inject a system time into the PDS engine
+ eGobiError PDSInjectTimeReference(
+ ULONGLONG systemTime,
+ USHORT systemDiscontinuities );
+
+ // Return the default tracking session configuration
+ eGobiError GetPDSDefaults(
+ ULONG * pOperation,
+ BYTE * pTimeout,
+ ULONG * pInterval,
+ ULONG * pAccuracy );
+
+ // Set the default tracking session configuration
+ eGobiError SetPDSDefaults(
+ ULONG operation,
+ BYTE timeout,
+ ULONG interval,
+ ULONG accuracy );
+
+ // Return the XTRA automatic download configuration
+ eGobiError GetXTRAAutomaticDownload(
+ ULONG * pbEnabled,
+ USHORT * pInterval );
+
+ // Set the XTRA automatic download configuration
+ eGobiError SetXTRAAutomaticDownload(
+ ULONG bEnabled,
+ USHORT interval );
+
+ // Return the XTRA WWAN network preference
+ eGobiError GetXTRANetwork( ULONG * pPreference );
+
+ // Set the XTRA WWAN network preference
+ eGobiError SetXTRANetwork( ULONG preference );
+
+ // Return the XTRA database validity period
+ eGobiError GetXTRAValidity(
+ USHORT * pGPSWeek,
+ USHORT * pGPSWeekOffset,
+ USHORT * pDuration );
+
+ // Force the XTRA database to be downloaded to the device
+ eGobiError ForceXTRADownload();
+
+ // Return the XTRA data positioning state
+ eGobiError GetXTRADataState( ULONG * pState );
+
+ // Set the XTRA data positioning state
+ eGobiError SetXTRADataState( ULONG state );
+
+ // Return the XTRA time positioning state
+ eGobiError GetXTRATimeState( ULONG * pState );
+
+ // Set the XTRA time positioning state
+ eGobiError SetXTRATimeState( ULONG state );
+
+ // Return the PDS AGPS configuration
+ eGobiError GetAGPSConfig(
+ ULONG * pServerAddress,
+ ULONG * pServerPort );
+
+ // Set the PDS AGPS configuration
+ eGobiError SetAGPSConfig(
+ ULONG serverAddress,
+ ULONG serverPort );
+
+ // Return the automatic tracking state for the service
+ eGobiError GetServiceAutomaticTracking( ULONG * pbAuto );
+
+ // Set the automatic tracking state for the service
+ eGobiError SetServiceAutomaticTracking( ULONG bAuto );
+
+ // Return the automatic tracking config for the NMEA COM port
+ eGobiError GetPortAutomaticTracking( ULONG * pbAuto );
+
+ // Set the automatic tracking config for the NMEA COM port
+ eGobiError SetPortAutomaticTracking( ULONG bAuto );
+
+ // Reset the specified PDS data
+ eGobiError ResetPDSData(
+ ULONG * pGPSDataMask,
+ ULONG * pCellDataMask );
+#endif
+
+#ifdef CAT_SUPPORT
+ // Send the terminal response to the device
+ eGobiError CATSendTerminalResponse(
+ ULONG refID,
+ ULONG dataLen,
+ BYTE * pData );
+
+ // Send the envelope command to the device
+ eGobiError CATSendEnvelopeCommand(
+ ULONG cmdID,
+ ULONG dataLen,
+ BYTE * pData );
+#endif
+
+#ifdef RMS_SUPPORT
+ // Query the state of the SMS wake functionality
+ eGobiError GetSMSWake(
+ ULONG * pbEnabled,
+ ULONG * pWakeMask );
+
+ // Enable/disable the SMS wake functionality
+ eGobiError SetSMSWake(
+ ULONG bEnable,
+ ULONG wakeMask );
+#endif
+
+#ifdef OMA_SUPPORT
+ // Start an OMA-DM session
+ eGobiError OMADMStartSession( ULONG sessionType );
+
+ // Cancel an ongoing OMA-DM session
+ eGobiError OMADMCancelSession();
+
+ // Return info related to the current (or previous) OMA-DM session
+ eGobiError OMADMGetSessionInfo(
+ ULONG * pSessionState,
+ ULONG * pSessionType,
+ ULONG * pFailureReason,
+ BYTE * pRetryCount,
+ WORD * pSessionPause,
+ WORD * pTimeRemaining );
+
+ // Return information about the pending network initiated alert
+ eGobiError OMADMGetPendingNIA(
+ ULONG * pSessionType,
+ USHORT * pSessionID );
+
+ // Send the specified OMA-DM selection for the current network
+ // initiated session
+ eGobiError OMADMSendSelection(
+ ULONG selection,
+ USHORT sessionID );
+
+ // Return the OMA-DM feature settings
+ eGobiError OMADMGetFeatureSettings(
+ ULONG * pbProvisioning,
+ ULONG * pbPRLUpdate );
+
+ // Set the OMA-DM device provisioning service update feature setting
+ eGobiError OMADMSetProvisioningFeature( ULONG bProvisioning );
+
+ // Set the OMA-DM PRL service update feature setting
+ eGobiError OMADMSetPRLUpdateFeature( ULONG bPRLUpdate );
+#endif
+
+#ifdef VOICE_SUPPORT
+ // Initiates a USSD operation
+ eGobiError OriginateUSSD( BYTE * pInfo );
+
+ // Respond to a USSD request from the network
+ eGobiError AnswerUSSD( BYTE * pInfo );
+
+ // Cancels an in-progress USSD operation
+ eGobiError CancelUSSD();
+#endif
+
+#ifdef IMG_SUPPORT
+ // Get the current image preference list
+ eGobiError GetImagesPreference(
+ ULONG * pImageListSize,
+ BYTE * pImageList );
+
+ // Set the current image preference list
+ eGobiError SetImagesPreference(
+ ULONG imageListSize,
+ BYTE * pImageList,
+ ULONG bForceDownload,
+ BYTE modemIndex,
+ ULONG * pImageTypesSize,
+ BYTE * pImageTypes );
+
+ // Return the boot and recovery image download mode
+ eGobiError GetBARMode( ULONG * pBARMode );
+
+ // Request the device enter boot and recovery image download mode
+ eGobiError SetBARMode();
+
+ // Get the list of images stored on the device
+ eGobiError GetStoredImages(
+ ULONG * pImageListSize,
+ BYTE * pImageList );
+
+ // Return info about the specified image from the device
+ eGobiError GetStoredImageInfo(
+ ULONG imageInfoSize,
+ BYTE * pImageInfo,
+ ULONG * pMajorVersion,
+ ULONG * pMinorVersion,
+ ULONG * pVersionID,
+ CHAR * pInfo,
+ ULONG * pLockID );
+
+ // Delete the specified image from the device
+ eGobiError DeleteStoredImage(
+ ULONG imageInfoSize,
+ BYTE * pImageInfo );
+#endif
+
+#ifdef IMG2K_SUPPORT
+ eGobiError GetFirmwareInfo(
+ ULONG * pFirmwareID,
+ ULONG * pTechnology,
+ ULONG * pCarrier,
+ ULONG * pRegion,
+ ULONG * pGPSCapability );
+
+ // Upgrade firmware
+ eGobiError UpgradeFirmware( CHAR * pDestinationPath );
+
+ // Return image information
+ eGobiError GetImageInfo(
+ CHAR * pPath,
+ ULONG * pFirmwareID,
+ ULONG * pTechnology,
+ ULONG * pCarrier,
+ ULONG * pRegion,
+ ULONG * pGPSCapability );
+
+ // Return the image store folder
+ eGobiError GetImageStore(
+ WORD pathSize,
+ CHAR * pImageStorePath );
+#endif
+
+ protected:
+ /* Database used for packing/parsing QMI protocol entities */
+ cCoreDatabase mDB;
+
+ /* Service type/service is required for object operation */
+ typedef std::pair <eQMIService, bool> tServerConfig;
+
+ /* Servers object is configured to support */
+ std::set <tServerConfig> mServerConfig;
+
+ /* QMI protocol servers */
+ std::map <eQMIService, cQMIProtocolServer *> mServers;
+
+ /* Fail connect attempts when multiple devices are present? */
+ bool mbFailOnMultipleDevices;
+
+ /* Device node that this object is currently connected to */
+ std::string mDeviceNode;
+
+ /* Device key string of connected device (may be empty) */
+ std::string mDeviceKey;
+
+ /* Last error recorded */
+ eGobiError mLastError;
+
+ /* Outstanding requests */
+ typedef std::pair <eQMIService, ULONG> tServiceRequest;
+ cSyncQueue <tServiceRequest> mRequests;
+
+ /* Last recorded QMI_WDS_START_NET transaction ID */
+ WORD mLastNetStartID;
+};
diff --git a/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreCAT.cpp b/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreCAT.cpp
new file mode 100755
index 0000000..1d36e0c
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreCAT.cpp
@@ -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 );
+}
diff --git a/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreDMS.cpp b/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreDMS.cpp
new file mode 100755
index 0000000..16499a8
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreDMS.cpp
@@ -0,0 +1,2050 @@
+/*===========================================================================
+FILE:
+ GobiQMICoreDMS.cpp
+
+DESCRIPTION:
+ QUALCOMM Gobi QMI Based API Core (DMS 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:
+ GetDeviceCapabilities (Public Method)
+
+DESCRIPTION:
+ This function gets device capabilities
+
+PARAMETERS:
+ pMaxTXChannelRate [ O ] - Maximum transmission rate (bps)
+ pMaxRXChannelRate [ O ] - Maximum reception rate (bps)
+ pDataServiceCapability [ O ] - CS/PS data service capability
+ pSimCapability [ O ] - Device SIM support
+ pRadioIfacesSize [I/O] - Upon input the maximum number of elements
+ that the radio interfaces can contain.
+ Upon successful output the actual number
+ of elements in the radio interface array
+ pRadioIfaces [ O ] - The radio interface array
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetDeviceCapabilities(
+ ULONG * pMaxTXChannelRate,
+ ULONG * pMaxRXChannelRate,
+ ULONG * pDataServiceCapability,
+ ULONG * pSimCapability,
+ ULONG * pRadioIfacesSize,
+ BYTE * pRadioIfaces )
+{
+ // Validate arguments
+ if ( (pMaxTXChannelRate == 0)
+ || (pMaxRXChannelRate == 0)
+ || (pDataServiceCapability == 0)
+ || (pSimCapability == 0)
+ || (pRadioIfacesSize == 0)
+ || (*pRadioIfacesSize == 0)
+ || (pRadioIfaces == 0) )
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ ULONG maxRadioIfaces = (ULONG)*pRadioIfacesSize;
+
+ // Assume failure
+ *pRadioIfacesSize = 0;
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_DMS_GET_CAPS;
+ 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, 1 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 5)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ // Populate the variables
+ *pMaxTXChannelRate = pf[0].mValue.mU32;
+ *pMaxRXChannelRate = pf[1].mValue.mU32;
+ *pDataServiceCapability = pf[2].mValue.mU32;
+ *pSimCapability = pf[3].mValue.mU8;
+
+ ULONG activeRadioIfaces = (ULONG)pf[4].mValue.mU8;
+ if (pf.size() < 5 + activeRadioIfaces)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ if (activeRadioIfaces > maxRadioIfaces)
+ {
+ activeRadioIfaces = maxRadioIfaces;
+ }
+
+ ULONG * pOutRadioIfaces = (ULONG *)pRadioIfaces;
+ for (ULONG r = 0; r < activeRadioIfaces; r++)
+ {
+ *pOutRadioIfaces++ = pf[5 + r].mValue.mU32;
+ }
+
+ *pRadioIfacesSize = activeRadioIfaces;
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ GetManufacturer (Public Method)
+
+DESCRIPTION:
+ This function returns the device manufacturer name
+
+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::GetManufacturer(
+ 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_GET_MANUFACTURER;
+ 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, 1 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ LONG strLen = pf[0].mValueString.size();
+ if (strLen <= 0)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ // Space to perform the copy?
+ if (stringSize < strLen + 1)
+ {
+ return eGOBI_ERR_BUFFER_SZ;
+ }
+
+ memcpy( (LPVOID)pString, (LPCSTR)pf[0].mValueString.c_str(), strLen );
+ pString[strLen] = 0;
+
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ GetModelID (Public Method)
+
+DESCRIPTION:
+ This function returns the device model ID
+
+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::GetModelID(
+ 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_GET_MODEL_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, 1 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ LONG strLen = pf[0].mValueString.size();
+ if (strLen <= 0)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ // Space to perform the copy?
+ if (stringSize < strLen + 1)
+ {
+ return eGOBI_ERR_BUFFER_SZ;
+ }
+
+ memcpy( (LPVOID)pString, (LPCSTR)pf[0].mValueString.c_str(), strLen );
+ pString[strLen] = 0;
+
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ GetFirmwareRevision (Public Method)
+
+DESCRIPTION:
+ This function returns the device firmware revision
+
+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::GetFirmwareRevision(
+ 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_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 (PRI revision)
+ sProtocolEntityKey tlvKey( eDB2_ET_QMI_DMS_RSP, msgID, 17 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 1 || pf[0].mValueString.size() <= 0)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ std::string tmpPRI = pf[0].mValueString;
+ ULONG lenPRI = (ULONG)tmpPRI.size();
+
+ // Space to perform the copy?
+ if (stringSize < lenPRI + 1)
+ {
+ return eGOBI_ERR_BUFFER_SZ;
+ }
+
+ memcpy( (LPVOID)pString, (LPCSTR)tmpPRI.c_str(), lenPRI + 1 );
+
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ GetFirmwareRevisions (Public Method)
+
+DESCRIPTION:
+ This function returns the device firmware (AMSS, boot, and PRI)
+ revisions
+
+PARAMETERS:
+ amssSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the AMSS string array can contain
+ pAMSSString [ O ] - NULL terminated AMSS revision string
+ bootSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the boot string array can contain
+ pBootString [ O ] - NULL terminated boot code revision string
+ priSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the PRI string array can contain
+ pPRIString [ O ] - NULL terminated PRI revision string
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetFirmwareRevisions(
+ BYTE amssSize,
+ CHAR * pAMSSString,
+ BYTE bootSize,
+ CHAR * pBootString,
+ BYTE priSize,
+ CHAR * pPRIString )
+{
+ // Validate arguments
+ if ( (amssSize == 0 || pAMSSString == 0)
+ || (bootSize == 0 || pBootString == 0)
+ || (priSize == 0 || pPRIString == 0) )
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ // Assume failure
+ *pAMSSString = 0;
+ *pBootString = 0;
+ *pPRIString = 0;
+
+ // 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 (PRI revision)
+ sProtocolEntityKey tlvKey( eDB2_ET_QMI_DMS_RSP, msgID, 17 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 1 || pf[0].mValueString.size() <= 0)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ std::string tmpPRI = pf[0].mValueString;
+ ULONG lenPRI = (ULONG)tmpPRI.size();
+
+ // Space to perform the copy?
+ if (priSize < lenPRI + 1)
+ {
+ return eGOBI_ERR_BUFFER_SZ;
+ }
+
+ memcpy( (LPVOID)pPRIString, (LPCSTR)tmpPRI.c_str(), lenPRI + 1 );
+
+ // Parse the TLV we want (boot code revision)
+ tlvKey = sProtocolEntityKey( eDB2_ET_QMI_DMS_RSP, msgID, 16 );
+ pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 1 || pf[0].mValueString.size() <= 0)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ std::string tmpBoot = pf[0].mValueString;
+ ULONG lenBoot = (ULONG)tmpBoot.size();
+
+ // Space to perform the copy?
+ if (bootSize < lenBoot + 1)
+ {
+ return eGOBI_ERR_BUFFER_SZ;
+ }
+
+ memcpy( (LPVOID)pBootString, (LPCSTR)tmpBoot.c_str(), lenBoot + 1 );
+
+ // 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;
+ }
+
+ std::string tmpAMSS = pf[0].mValueString;
+ ULONG lenAMSS = (ULONG)tmpAMSS.size();
+
+ // Space to perform the copy?
+ if (amssSize < lenAMSS + 1)
+ {
+ return eGOBI_ERR_BUFFER_SZ;
+ }
+
+ memcpy( (LPVOID)pAMSSString, (LPCSTR)tmpAMSS.c_str(), lenAMSS + 1 );
+
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ GetVoiceNumber (Public Method)
+
+DESCRIPTION:
+ This function returns the voice number in use by the device
+
+PARAMETERS:
+ voiceNumberSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the voice number array can
+ contain
+ pVoiceNumber [ O ] - Voice number (MDN or ISDN) string
+ minSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the MIN array can contain
+ pMIN [ O ] - MIN string (empty string returned when MIN is
+ not supported/programmed)
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetVoiceNumber(
+ BYTE voiceNumberSize,
+ CHAR * pVoiceNumber,
+ BYTE minSize,
+ CHAR * pMIN )
+{
+ // Validate arguments
+ if (voiceNumberSize == 0 || pVoiceNumber == 0 || minSize == 0 || pMIN == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ // Assume failure
+ *pVoiceNumber = 0;
+ *pMIN = 0;
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_DMS_GET_NUMBER;
+ 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 tlvKey1( eDB2_ET_QMI_DMS_RSP, msgID, 1 );
+ cDataParser::tParsedFields pf1 = ParseTLV( db, rsp, tlvs, tlvKey1 );
+ if (pf1.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ LONG strLen = pf1[0].mValueString.size();
+ if (strLen <= 0)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ // Space to perform the copy?
+ if (voiceNumberSize < strLen + 1)
+ {
+ return eGOBI_ERR_BUFFER_SZ;
+ }
+
+ memcpy( (LPVOID)pVoiceNumber, (LPCSTR)pf1[0].mValueString.c_str(), strLen );
+ pVoiceNumber[strLen] = 0;
+
+ // Parse the optional TLV we want (by DB key)
+ sProtocolEntityKey tlvKey2( eDB2_ET_QMI_DMS_RSP, msgID, 16 );
+ cDataParser::tParsedFields pf2 = ParseTLV( db, rsp, tlvs, tlvKey2 );
+ if (pf2.size() >= 1)
+ {
+ strLen = pf2[0].mValueString.size();
+ if (strLen <= 0)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ // Space to perform the copy?
+ if (minSize < strLen + 1)
+ {
+ return eGOBI_ERR_BUFFER_SZ;
+ }
+
+ memcpy( (LPVOID)pMIN, (LPCSTR)pf2[0].mValueString.c_str(), strLen );
+ pMIN[strLen] = 0;
+ }
+
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ GetIMSI (Public Method)
+
+DESCRIPTION:
+ This function returns the device IMSI
+
+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::GetIMSI(
+ 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_GET_IMSI;
+ 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 tmpIMSI = pf[0].mValueString;
+ ULONG lenIMSI = (ULONG)tmpIMSI.size();
+
+ // Space to perform the copy?
+ if (stringSize < lenIMSI + 1)
+ {
+ return eGOBI_ERR_BUFFER_SZ;
+ }
+
+ memcpy( (LPVOID)pString, (LPCSTR)tmpIMSI.c_str(), lenIMSI + 1 );
+
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ GetSerialNumbers (Public Method)
+
+DESCRIPTION:
+ This command returns all serial numbers assigned to the device
+
+PARAMETERS:
+ esnSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the ESN array can contain
+ pESNString [ O ] - ESN string (empty string returned when ESN is
+ not supported/programmed)
+ imeiSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the IMEI array can contain
+ pIMEIString [ O ] - IMEI string (empty string returned when IMEI is
+ not supported/programmed)
+ meidSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the MEID array can contain
+ pMEIDString [ O ] - MEID string (empty string returned when MEID is
+ not supported/programmed)
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetSerialNumbers(
+ BYTE esnSize,
+ CHAR * pESNString,
+ BYTE imeiSize,
+ CHAR * pIMEIString,
+ BYTE meidSize,
+ CHAR * pMEIDString )
+{
+ // Validate arguments
+ if ( (esnSize == 0)
+ || (pESNString == 0)
+ || (imeiSize == 0)
+ || (pIMEIString == 0)
+ || (meidSize == 0)
+ || (pMEIDString == 0) )
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ // Assume failure
+ *pESNString = 0;
+ *pIMEIString = 0;
+ *pMEIDString = 0;
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_DMS_GET_IDS;
+ 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 optional TLV we want (by DB key)
+ sProtocolEntityKey tlvKey1( eDB2_ET_QMI_DMS_RSP, msgID, 16 );
+ cDataParser::tParsedFields pf1 = ParseTLV( db, rsp, tlvs, tlvKey1 );
+ if (pf1.size() >= 1)
+ {
+ LONG strLen = pf1[0].mValueString.size();
+ if (strLen <= 0)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ // Space to perform the copy?
+ if (esnSize < strLen + 1)
+ {
+ return eGOBI_ERR_BUFFER_SZ;
+ }
+
+ memcpy( (LPVOID)pESNString, (LPCSTR)pf1[0].mValueString.c_str(), strLen );
+ pESNString[strLen] = 0;
+ }
+
+ // Parse the optional TLV we want (by DB key)
+ sProtocolEntityKey tlvKey2( eDB2_ET_QMI_DMS_RSP, msgID, 17 );
+ cDataParser::tParsedFields pf2 = ParseTLV( db, rsp, tlvs, tlvKey2 );
+ if (pf2.size() >= 1)
+ {
+ LONG strLen = pf2[0].mValueString.size();
+ if (strLen <= 0)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ // Space to perform the copy?
+ if (imeiSize < strLen + 1)
+ {
+ return eGOBI_ERR_BUFFER_SZ;
+ }
+
+ memcpy( (LPVOID)pIMEIString, (LPCSTR)pf2[0].mValueString.c_str(), strLen );
+ pIMEIString[strLen] = 0;
+ }
+
+ // Parse the optional TLV we want (by DB key)
+ sProtocolEntityKey tlvKey3( eDB2_ET_QMI_DMS_RSP, msgID, 18 );
+ cDataParser::tParsedFields pf3 = ParseTLV( db, rsp, tlvs, tlvKey3 );
+ if (pf3.size() >= 1)
+ {
+ LONG strLen = pf3[0].mValueString.size();
+ if (strLen <= 0)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ // Space to perform the copy?
+ if (meidSize < strLen + 1)
+ {
+ return eGOBI_ERR_BUFFER_SZ;
+ }
+
+ memcpy( (LPVOID)pMEIDString, (LPCSTR)pf3[0].mValueString.c_str(), strLen );
+ pMEIDString[strLen] = 0;
+ }
+
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ SetLock (Public Method)
+
+DESCRIPTION:
+ This function sets the user lock state maintained by the device
+
+PARAMETERS:
+ state [ I ] - Desired lock state
+ pCurrentPIN [ I ] - Current four digit PIN string
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::SetLock(
+ ULONG state,
+ CHAR * pCurrentPIN )
+{
+ // Validate arguments
+ if (pCurrentPIN == 0 || pCurrentPIN[0] == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ std::string thePIN( pCurrentPIN );
+ if (thePIN.size() > 4)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ int nNonDigit = thePIN.find_first_not_of( "0123456789" );
+ std::string digitPIN = thePIN.substr( 0, nNonDigit );
+ if (digitPIN.size() != thePIN.size())
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ WORD msgID = (WORD)eQMI_DMS_SET_USER_LOCK_STATE;
+ std::vector <sDB2PackingInput> piv;
+
+ // "%u %s"
+ std::ostringstream tmp;
+ tmp << (UINT)state << " " << thePIN;
+
+ 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 );
+
+ // Send the QMI request, check result, and return
+ return SendAndCheckReturn( eQMI_SVC_DMS, pRequest );
+}
+
+/*===========================================================================
+METHOD:
+ QueryLock (Public Method)
+
+DESCRIPTION:
+ This function sets the user lock state maintained by the device
+
+PARAMETERS:
+ pState [ O ] - Current lock state
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::QueryLock( ULONG * pState )
+{
+ // Validate arguments
+ if (pState == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_DMS_GET_USER_LOCK_STATE;
+ 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, 1 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ // Populate the mode
+ *pState = pf[0].mValue.mU32;
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ ChangeLockPIN (Public Method)
+
+DESCRIPTION:
+ This command sets the user lock code maintained by the device
+
+PARAMETERS:
+ pCurrentPIN [ O ] - Current four digit PIN string
+ pDesiredPIN [ O ] - New four digit PIN string
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::ChangeLockPIN(
+ CHAR * pCurrentPIN,
+ CHAR * pDesiredPIN )
+{
+ // Validate arguments
+ if ( (pCurrentPIN == 0)
+ || (pCurrentPIN[0] == 0)
+ || (pDesiredPIN == 0)
+ || (pDesiredPIN[0] == 0) )
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ std::string theCurPIN( pCurrentPIN );
+ if (theCurPIN.size() > 4)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ int nNonDigit = theCurPIN.find_first_not_of( "0123456789" );
+ std::string digitCurPIN = theCurPIN.substr( 0, nNonDigit );
+ if (digitCurPIN.size() != theCurPIN.size())
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ std::string theNewPIN( pDesiredPIN );
+ if (theNewPIN.size() > 4)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ nNonDigit = theNewPIN.find_first_not_of( "0123456789" );
+ std::string digitNewPIN = theNewPIN.substr( 0, nNonDigit );
+ if (digitNewPIN.size() != theNewPIN.size())
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ WORD msgID = (WORD)eQMI_DMS_SET_USER_LOCK_CODE;
+ std::vector <sDB2PackingInput> piv;
+
+ // "%s %s"
+ std::ostringstream tmp;
+ tmp << theCurPIN << " " << theNewPIN;
+
+ 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 );
+
+ // Send the QMI request, check result, and return
+ return SendAndCheckReturn( eQMI_SVC_DMS, pRequest );
+}
+
+/*===========================================================================
+METHOD:
+ GetHardwareRevision (Public Method)
+
+DESCRIPTION:
+ This function returns the device hardware revision
+
+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::GetHardwareRevision(
+ 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_GET_MSM_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, 1 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ LONG strLen = pf[0].mValueString.size();
+ if (strLen <= 0)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ // Space to perform the copy?
+ if (stringSize < strLen + 1)
+ {
+ return eGOBI_ERR_BUFFER_SZ;
+ }
+
+ memcpy( (LPVOID)pString, (LPCSTR)pf[0].mValueString.c_str(), strLen );
+ pString[strLen] = 0;
+
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ GetPRLVersion (Public Method)
+
+DESCRIPTION:
+ This function returns the version of the active Preferred Roaming List
+ (PRL) in use by the device
+
+PARAMETERS:
+ pPRLVersion [ O ] - The PRL version number
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetPRLVersion( WORD * pPRLVersion )
+{
+ // Validate arguments
+ if (pPRLVersion == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_DMS_GET_PRL_VERSION;
+ 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, 1 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ *pPRLVersion = pf[0].mValue.mU16;
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ GetERIFile (Public Method)
+
+DESCRIPTION:
+ This command returns the ERI file that is stored in EFS on the device
+
+PARAMETERS:
+ pFileSize [I/O] - Upon input the maximum number of bytes that the file
+ contents array can contain. Upon successful output
+ the actual number of bytes written to the file contents
+ array
+ pFile [ O ] - The file contents
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetERIFile(
+ ULONG * pFileSize,
+ BYTE * pFile )
+{
+ // Validate arguments
+ if (pFileSize == 0 || *pFileSize == 0 || pFile == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ // Assume failure
+ ULONG maxFileSize = *pFileSize;
+ *pFileSize = 0;
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_DMS_READ_ERI_FILE;
+ 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, 1 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ ULONG fileSz = pf[0].mValue.mU16;
+ if (pf.size() < 1 + fileSz)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ // Space to copy into?
+ if (fileSz > maxFileSize)
+ {
+ return eGOBI_ERR_BUFFER_SZ;
+ }
+
+ for (ULONG f = 0; f < fileSz; f++)
+ {
+ pFile[f] = pf[1 + f].mValue.mU8;
+ }
+
+ *pFileSize = fileSz;
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ ActivateAutomatic (Public Method)
+
+DESCRIPTION:
+ This function requests the device to perform automatic service activation
+
+PARAMETERS:
+ pActivationCode [ I ] - Activation code (maximum string length of 12)
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::ActivateAutomatic( CHAR * pActivationCode )
+{
+ // Validate arguments
+ if ( (pActivationCode == 0)
+ || (pActivationCode[0] == 0) )
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ std::string ac( pActivationCode );
+ if (ac.size() > 12)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ WORD msgID = (WORD)eQMI_DMS_ACTIVATE_AUTOMATIC;
+ std::vector <sDB2PackingInput> piv;
+
+ std::ostringstream tmp;
+ tmp << (ULONG)ac.size() << " \"" << ac << "\"";
+
+ 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 );
+
+ /// Send the QMI request, check result, and return
+ return SendAndCheckReturn( eQMI_SVC_DMS, pRequest, 300000 );
+}
+
+/*===========================================================================
+METHOD:
+ ActivateManual (Public Method)
+
+DESCRIPTION:
+ This function requests the device perform manual service activation,
+ after a successful request the device is then asked to reset
+
+PARAMETERS:
+ pSPC [ I ] - NULL terminated string representing the six digit
+ service programming code
+ sid [ I ] - System identification number
+ pMDN [ I ] - Mobile Directory Number string
+ pMIN [ I ] - Mobile Identification Number string
+ prlSize [ I ] - (Optional) Size of PRL file array
+ pPRL [ I ] - (Optional) The PRL file contents
+ pMNHA [ I ] - (Optional) MN-HA string
+ pMNAAA [ I ] - (Optional) MN-AAA string
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::ActivateManual(
+ CHAR * pSPC,
+ WORD sid,
+ CHAR * pMDN,
+ CHAR * pMIN,
+ ULONG prlSize,
+ BYTE * pPRL,
+ CHAR * pMNHA,
+ CHAR * pMNAAA )
+{
+ // Validate arguments
+ if ( (pSPC == 0)
+ || (pSPC[0] == 0)
+ || (pMDN == 0)
+ || (pMDN[0] == 0)
+ || (pMIN == 0)
+ || (pMIN[0] == 0)
+ || (prlSize > QMI_DMS_MAX_PRL_SIZE) )
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ std::string spc( pSPC );
+ if (spc.size() > 6)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ int nNonDigit = spc.find_first_not_of( "0123456789" );
+ std::string digitSPC = spc.substr( 0, nNonDigit );
+ if (digitSPC.size() != spc.size())
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ std::string theMDN( pMDN );
+ if (theMDN.size() > 16)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ nNonDigit = theMDN.find_first_not_of( "0123456789" );
+ std::string digitMDN = theMDN.substr( 0, nNonDigit );
+ if (digitMDN.size() != theMDN.size())
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ std::string theMIN( pMIN );
+ if (theMIN.size() > 16)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ nNonDigit = theMIN.find_first_not_of( "0123456789" );
+ std::string digitMIN = theMIN.substr( 0, nNonDigit );
+ if (digitMIN.size() != theMIN.size())
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ std::string theMNHA;
+ if (pMNHA != 0 && pMNHA[0] != 0)
+ {
+ theMNHA = pMNHA;
+ if (theMNHA.size() > 16)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+ }
+
+ std::string theMNAAA;
+ if (pMNAAA != 0 && pMNAAA[0] != 0)
+ {
+ theMNAAA = pMNAAA;
+ if (theMNAAA.size() > 16)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+ }
+
+ WORD msgID = (WORD)eQMI_DMS_ACTIVATE_MANUAL;
+ std::vector <sDB2PackingInput> piv;
+
+ // "%s %u %d %s %d %s"
+ std::ostringstream tmp;
+ tmp << spc << " " << (UINT)sid << " " << theMDN.size() << " " << theMDN
+ << " " << theMIN.size() << " " << theMIN;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_DMS_REQ, msgID, 1 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
+ piv.push_back( pi );
+
+ if (theMNHA.size() > 0)
+ {
+ sProtocolEntityKey pek1( eDB2_ET_QMI_DMS_REQ, msgID, 17 );
+ std::ostringstream tmp;
+ tmp << (int)theMNHA.size() << " \"" << theMNHA << "\"";
+
+ sDB2PackingInput pi1( pek1, (LPCSTR)tmp.str().c_str() );
+ piv.push_back( pi1 );
+ }
+
+ if (theMNAAA.size() > 0)
+ {
+ sProtocolEntityKey pek1( eDB2_ET_QMI_DMS_REQ, msgID, 18 );
+ std::ostringstream tmp;
+ tmp << (int)theMNAAA.size() << " \"" << theMNAAA << "\"";
+
+ sDB2PackingInput pi1( pek1, (LPCSTR)tmp.str().c_str() );
+ piv.push_back( pi1 );
+ }
+
+ // Do we need to go through the anguish of the segmented PRL?
+ if (prlSize > 0)
+ {
+ ULONG blockSz = QMI_DMS_MAX_PRL_BLOCK;
+
+ // Determine number of writes
+ ULONG writes = prlSize / blockSz;
+ if ((prlSize % blockSz) != 0)
+ {
+ writes++;
+ }
+
+ ULONG offset = 0;
+ ULONG to = DEFAULT_GOBI_QMI_TIMEOUT;
+
+ // Generate and send requests
+ eGobiError err = eGOBI_ERR_NONE;
+ for (ULONG w = 0; w < writes; w++)
+ {
+ if (w == writes - 1)
+ {
+ to = 300000;
+ if ((prlSize % blockSz) != 0)
+ {
+ blockSz = prlSize % blockSz;
+ }
+ }
+
+ std::vector <sDB2PackingInput> pivLocal = piv;
+
+ // "%u %u %u"
+ std::ostringstream tmp2;
+ tmp2 << (UINT)prlSize << " " << (UINT)blockSz
+ << " " << (UINT)w;
+ for (ULONG p = 0; p < blockSz; p++)
+ {
+ tmp2 << " " << (UINT)pPRL[offset + p];
+ }
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_DMS_REQ, msgID, 19 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp2.str().c_str() );
+ pivLocal.push_back( pi );
+
+ // Pack up the QMI request
+ const cCoreDatabase & db = GetDatabase();
+ sSharedBuffer * pRequest = DB2PackQMIBuffer( db, pivLocal );
+
+ // Send the QMI request, check result, and return
+ err = SendAndCheckReturn( eQMI_SVC_DMS, pRequest, to );
+ if (err != eGOBI_ERR_NONE)
+ {
+ break;
+ }
+ else
+ {
+ offset += blockSz;
+ }
+ }
+
+ if (err != eGOBI_ERR_NONE)
+ {
+ return err;
+ }
+ }
+ else
+ {
+ // 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, 300000 );
+ if (rc != eGOBI_ERR_NONE)
+ {
+ return rc;
+ }
+ }
+
+ // Ask device to power down
+ eGobiError rc = SetPower( 5 );
+ if (rc != eGOBI_ERR_NONE)
+ {
+ return eGOBI_ERR_RESET;
+ }
+
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ ResetToFactoryDefaults (Public Method)
+
+DESCRIPTION:
+ This function requests the device reset configuration to factory defaults,
+ after a successful request the device is then asked to reset
+
+PARAMETERS:
+ pSPC [ I ] - NULL terminated string representing the six digit
+ service programming code
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::ResetToFactoryDefaults( CHAR * pSPC )
+{
+ // Validate arguments
+ if (pSPC == 0 || pSPC[0] == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ std::string spc( pSPC );
+ if (spc.size() > 6)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ int nNonDigit = spc.find_first_not_of( "0123456789" );
+ std::string digitSPC = spc.substr( 0, nNonDigit );
+ if (digitSPC.size() != spc.size())
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ WORD msgID = (WORD)eQMI_DMS_FACTORY_DEFAULTS;
+ std::vector <sDB2PackingInput> piv;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_DMS_REQ, msgID, 1 );
+ sDB2PackingInput pi( pek, (LPCSTR)spc.c_str() );
+ piv.push_back( pi );
+
+ // Pack up the QMI request
+ const cCoreDatabase & db = GetDatabase();
+ sSharedBuffer * pRequest = DB2PackQMIBuffer( db, piv );
+
+ // Send the QMI request and check result
+ eGobiError rc = SendAndCheckReturn( eQMI_SVC_DMS, pRequest, 300000 );
+ 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 eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ GetActivationState (Public Method)
+
+DESCRIPTION:
+ This function returns the device activation state
+
+PARAMETERS:
+ pActivationState [ O ] - Service activation state
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetActivationState( ULONG * pActivationState )
+{
+ // Validate arguments
+ if (pActivationState == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_DMS_GET_ACTIVATED_STATE;
+ 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, 1 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ *pActivationState = pf[0].mValue.mU32;
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ SetPower (Public Method)
+
+DESCRIPTION:
+ This function sets the operating mode of the device
+
+PARAMETERS:
+ powerMode [ I ] - Selected operating mode
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::SetPower( ULONG powerMode )
+{
+ WORD msgID = (WORD)eQMI_DMS_SET_OPERATING_MODE;
+ std::vector <sDB2PackingInput> piv;
+
+ std::ostringstream tmp;
+ tmp << (UINT)powerMode;
+
+ 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 );
+
+ // Send the QMI request, check result, and return
+ return SendAndCheckReturn( eQMI_SVC_DMS, pRequest );
+}
+
+/*===========================================================================
+METHOD:
+ GetPower (Public Method)
+
+DESCRIPTION:
+ This function returns the operating mode of the device
+
+PARAMETERS:
+ pPowerMode [ O ] - Current operating mode
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetPower( ULONG * pPowerMode )
+{
+ // Validate arguments
+ if (pPowerMode == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ // Assume failure
+ *pPowerMode = ULONG_MAX;
+
+ ULONG reasonMask = 0;
+ ULONG bPlatform = 0;
+ eGobiError rc = GetPowerInfo( pPowerMode, &reasonMask, &bPlatform );
+ return rc;
+}
+
+/*===========================================================================
+METHOD:
+ GetPowerInfo (Public Method)
+
+DESCRIPTION:
+ This function returns operating mode info from the device
+
+PARAMETERS:
+ pPowerMode [ O ] - Current operating mode
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetPowerInfo(
+ ULONG * pPowerMode,
+ ULONG * pReasonMask,
+ ULONG * pbPlatform )
+{
+ // Validate arguments
+ if (pPowerMode == 0 || pReasonMask == 0 || pbPlatform == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ // Assume failure
+ *pPowerMode = ULONG_MAX;
+ *pReasonMask = 0;
+ *pbPlatform = 0;
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_DMS_GET_OPERTAING_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, 1 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ *pPowerMode = pf[0].mValue.mU32;
+
+ // Parse the TLV we want (by DB key)
+ tlvKey = sProtocolEntityKey( eDB2_ET_QMI_DMS_RSP, msgID, 16 );
+ pf = ParseTLV( db, rsp, tlvs, tlvKey );
+
+ // Convert back to a bitmask
+ ULONG fieldCount = (ULONG)pf.size();
+ if (fieldCount > 16)
+ {
+ fieldCount = 16;
+ }
+
+ for (ULONG f = 0; f < fieldCount; f++)
+ {
+ ULONG val = (ULONG)pf[f].mValue.mU8 & 0x00000001;
+ *pReasonMask |= (val << f);
+ }
+
+ // Parse the TLV we want (by DB key)
+ tlvKey = sProtocolEntityKey( eDB2_ET_QMI_DMS_RSP, msgID, 17 );
+ pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() >= 1)
+ {
+ *pbPlatform = (ULONG)pf[0].mValue.mU8;
+ }
+
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ GetOfflineReason
+
+DESCRIPTION:
+ This function returns the reason why the operating mode of the device
+ is currently offline
+
+PARAMETERS:
+ pReasonMask [ O ] - Bitmask of offline reasons
+ pbPlatform [ O ] - Offline due to being platform retricted?
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetOfflineReason(
+ ULONG * pReasonMask,
+ ULONG * pbPlatform )
+{
+ // Validate arguments
+ if (pReasonMask == 0 || pbPlatform == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ // Assume failure
+ *pReasonMask = 0;
+ *pbPlatform = 0;
+
+ ULONG powerMode = 0;
+ eGobiError rc = GetPowerInfo( &powerMode, pReasonMask, pbPlatform );
+
+ return rc;
+}
+
+/*===========================================================================
+METHOD:
+ GetNetworkTime (Public Method)
+
+DESCRIPTION:
+ This function returns the current time of the device
+
+PARAMETERS:
+ pTimeStamp [ O ] - Count of 1.25ms that have elapsed from the start
+ of GPS time (Jan 6, 1980)
+ pTimeSource [ O ] - Source of the timestamp
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetNetworkTime(
+ ULONGLONG * pTimeCount,
+ ULONG * pTimeSource )
+{
+ // Validate arguments
+ if (pTimeCount == 0 || pTimeSource == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_DMS_GET_TIME;
+ 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, 1 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ *pTimeCount = pf[0].mValue.mU64;
+ *pTimeSource = pf[1].mValue.mU32;
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ ValidateSPC (Public Method)
+
+DESCRIPTION:
+ This function validates the service programming code
+
+PARAMETERS:
+ pSPC [ I ] - Six digit service programming code
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::ValidateSPC( CHAR * pSPC )
+{
+ // Validate arguments
+ if (pSPC == 0 || pSPC[0] == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ std::string spc( pSPC );
+ if (spc.size() > 6)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ int nNonDigit = spc.find_first_not_of( "0123456789" );
+ std::string digitSPC = spc.substr( 0, nNonDigit );
+ if (digitSPC.size() != spc.size())
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ WORD msgID = (WORD)eQMI_DMS_VALIDATE_SPC;
+ std::vector <sDB2PackingInput> piv;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_DMS_REQ, msgID, 1 );
+ sDB2PackingInput pi( pek, (LPCSTR)spc.c_str() );
+ piv.push_back( pi );
+
+ // Pack up the QMI request
+ const cCoreDatabase & db = GetDatabase();
+ sSharedBuffer * pRequest = DB2PackQMIBuffer( db, piv );
+
+ // Send the QMI request and check result
+ return SendAndCheckReturn( eQMI_SVC_DMS, pRequest );
+}
diff --git a/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreImg.cpp b/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreImg.cpp
new file mode 100755
index 0000000..5f1d9c7
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreImg.cpp
@@ -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 );
+}
diff --git a/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreImg2k.cpp b/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreImg2k.cpp
new file mode 100755
index 0000000..09ee728
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreImg2k.cpp
@@ -0,0 +1,562 @@
+/*===========================================================================
+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"
+
+//---------------------------------------------------------------------------
+// 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 += '/';
+ }
+
+ std::vector <std::string> files;
+ DepthSearch( folderSearch,
+ 0,
+ ".mbn",
+ files );
+
+ int fileNum = files.size();
+ for (int i = 0; i < fileNum; i++)
+ {
+ std::string mbnName = files[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;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // 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;
+}
diff --git a/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreNAS.cpp b/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreNAS.cpp
new file mode 100755
index 0000000..27c2278
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreNAS.cpp
@@ -0,0 +1,1986 @@
+/*===========================================================================
+FILE:
+ GobiQMICoreNAS.cpp
+
+DESCRIPTION:
+ QUALCOMM Gobi QMI Based API Core (NAS 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
+//---------------------------------------------------------------------------
+
+// Maximum length for a scanned network description
+const ULONG MAX_SNI_DESCRIPTION_LEN = 255;
+
+//---------------------------------------------------------------------------
+// Pragmas (pack structs)
+//---------------------------------------------------------------------------
+#pragma pack( push, 1 )
+
+/*=========================================================================*/
+// Struct sEVDOCustomSCPConfig
+// Struct to represent CDMA 1xEV-DO custom SCP config
+/*=========================================================================*/
+struct sEVDOCustomSCPConfig
+{
+ public:
+ BYTE mbActive;
+ ULONG mProtocolMask;
+ ULONG mBroadcastMask;
+ ULONG mApplicationMask;
+};
+
+/*=========================================================================*/
+// Struct sScannedNetworkInfo
+// Struct to represent scanned network information
+/*=========================================================================*/
+struct sScannedNetworkInfo
+{
+ public:
+ USHORT mMCC;
+ USHORT mMNC;
+ ULONG mInUse;
+ ULONG mRoaming;
+ ULONG mForbidden;
+ ULONG mPreferred;
+ CHAR mDescription[MAX_SNI_DESCRIPTION_LEN];
+};
+
+/*=========================================================================*/
+// Struct sScannedNetworkRATInfo
+// Struct to represent scanned network RAT information
+/*=========================================================================*/
+struct sScannedNetworkRATInfo
+{
+ public:
+ USHORT mMCC;
+ USHORT mMNC;
+ ULONG mRAT;
+};
+
+//---------------------------------------------------------------------------
+// Pragmas
+//---------------------------------------------------------------------------
+#pragma pack( pop )
+
+/*=========================================================================*/
+// cGobiQMICore Methods
+/*=========================================================================*/
+
+/*===========================================================================
+METHOD:
+ GetANAAAAuthenticationStatus (Public Method)
+
+DESCRIPTION:
+ This function gets the AN-AAA authentication status
+
+PARAMETERS:
+ pStatus [ O ] - AN-AAA authentication status
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetANAAAAuthenticationStatus( ULONG * pStatus )
+{
+ // Validate arguments
+ if (pStatus == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_NAS_GET_AAA_AUTH_STATUS;
+ sProtocolBuffer rsp = SendSimple( eQMI_SVC_NAS, 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_NAS_RSP, msgID, 1 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ // Populate the index
+ *pStatus = (ULONG)pf[0].mValue.mU32;
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ GetSignalStrengths (Public Method)
+
+DESCRIPTION:
+ This function gets the current available signal strengths (in dBm)
+ as measured by the device
+
+PARAMETERS:
+ pArraySizes [I/O] - Upon input the maximum number of elements
+ that each array can contain can contain.
+ Upon successful output the actual number
+ of elements in each array
+ pSignalStrengths [ O ] - Received signal strength array (dBm)
+ pRadioInterfaces [ O ] - Radio interface technology array
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetSignalStrengths(
+ ULONG * pArraySizes,
+ INT8 * pSignalStrengths,
+ ULONG * pRadioInterfaces )
+{
+ // Validate arguments
+ if ( (pArraySizes == 0)
+ || (*pArraySizes == 0)
+ || (pSignalStrengths == 0)
+ || (pRadioInterfaces == 0) )
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ ULONG maxSignals = (ULONG)*pArraySizes;
+
+ // Assume failure
+ *pArraySizes = 0;
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_NAS_GET_RSSI;
+ sProtocolBuffer rsp = SendSimple( eQMI_SVC_NAS, 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_NAS_RSP, msgID, 1 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 2)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ // Remove any values outside the legal range
+ std::map <ULONG, INT8> sigMap;
+
+ INT8 sigVal = pf[0].mValue.mS8;
+ ULONG radioVal = pf[1].mValue.mU32;
+ if (sigVal <= -30 && sigVal > -125 && radioVal != 0)
+ {
+ sigMap[radioVal] = sigVal;
+ }
+
+ // Parse the TLV we want (by DB key)
+ tlvKey = sProtocolEntityKey( eDB2_ET_QMI_NAS_RSP, msgID, 16 );
+ pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() > 2)
+ {
+ ULONG fi = 0;
+ ULONG auxSigs = (ULONG)pf[fi++].mValue.mU16;
+ if (pf.size() >= 1 + 2 * auxSigs)
+ {
+ for (ULONG s = 0; s < auxSigs; s++, fi += 2)
+ {
+ sigVal = pf[fi].mValue.mS8;
+ radioVal = pf[fi + 1].mValue.mU32;
+ if (sigVal <= -30 && sigVal > -125 && radioVal != 0)
+ {
+ sigMap[radioVal] = sigVal;
+ }
+ }
+ }
+ }
+
+ ULONG sigCount = 0;
+ std::map <ULONG, INT8>::const_iterator pIter;
+ for (pIter = sigMap.begin(); pIter != sigMap.end(); pIter++, sigCount++)
+ {
+ if (sigCount < maxSignals)
+ {
+ pSignalStrengths[sigCount] = pIter->second;
+ pRadioInterfaces[sigCount] = pIter->first;
+ *pArraySizes = sigCount + 1;
+ }
+ }
+
+ // No valid signals?
+ if (sigCount == 0)
+ {
+ return eGOBI_ERR_NO_SIGNAL;
+ }
+
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ GetRFInfo (Public Method)
+
+DESCRIPTION:
+ This function gets the current RF information
+
+PARAMETERS:
+ pInstanceSize [I/O] - Upon input the maximum number of elements that the
+ RF info instance array can contain. Upon success
+ the actual number of elements in the RF info
+ instance array
+ pInstances [ O ] - The RF info instance array
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetRFInfo(
+ BYTE * pInstanceSize,
+ BYTE * pInstances )
+{
+ // Validate arguments
+ if (pInstanceSize == 0 || *pInstanceSize == 0 || pInstances == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ // Assume failure
+ BYTE maxInstances = *pInstanceSize;
+ *pInstanceSize = 0;
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_NAS_GET_RF_INFO;
+ sProtocolBuffer rsp = SendSimple( eQMI_SVC_NAS, 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_NAS_RSP, msgID, 1 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+
+ ULONG fieldCount = (ULONG)pf.size();
+ if (fieldCount < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ BYTE ifaceCount = pf[0].mValue.mU8;
+ if (fieldCount < 1 + ((ULONG)ifaceCount * 3))
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ if (ifaceCount > maxInstances)
+ {
+ ifaceCount = maxInstances;
+ }
+
+ ULONG * pOutput = (ULONG *)pInstances;
+ for (BYTE i = 0; i < ifaceCount; i++)
+ {
+ ULONG offset = 3 * (ULONG)i;
+
+ *pOutput++ = pf[offset + 1].mValue.mU32;
+ *pOutput++ = pf[offset + 2].mValue.mU32;
+ *pOutput++ = (ULONG)pf[offset + 3].mValue.mU16;
+ }
+
+ *pInstanceSize = ifaceCount;
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ PerformNetworkScan (Public Method)
+
+DESCRIPTION:
+ This function performs a scan for available networks
+
+PARAMETERS:
+ pInstanceSize [I/O] - Upon input the maximum number of elements that the
+ network info instance array can contain. Upon
+ success the actual number of elements in the
+ network info instance array
+ pInstances [ O ] - The network info instance array
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::PerformNetworkScan(
+ BYTE * pInstanceSize,
+ BYTE * pInstances )
+{
+ // Validate arguments
+ if ( (pInstanceSize == 0)
+ || (*pInstanceSize == 0)
+ || (pInstances == 0) )
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ BYTE maxInstances = *pInstanceSize;
+
+ // Assume failure
+ *pInstanceSize = 0;
+
+ // This can take a really long time
+ ULONG to = MAX_REQ_TIMEOUT;
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_NAS_SCAN_NETS;
+ sProtocolBuffer rsp = SendSimple( eQMI_SVC_NAS, msgID, to );
+ 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_NAS_RSP, msgID, 16 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+
+ ULONG maxIdx = (ULONG)pf.size();
+ if (maxIdx-- < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ ULONG idx = 0;
+ BYTE netCount = pf[idx++].mValue.mU8;
+ if (netCount > maxInstances)
+ {
+ netCount = maxInstances;
+ }
+
+ sScannedNetworkInfo * pNet = (sScannedNetworkInfo *)pInstances;
+ for (BYTE i = 0; i < netCount; i++)
+ {
+ // Validate field count
+ if (idx + 6 > maxIdx)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ pNet->mMCC = pf[idx++].mValue.mU16;
+ pNet->mMNC = pf[idx++].mValue.mU16;
+ pNet->mInUse = pf[idx++].mValue.mU32;
+ pNet->mRoaming = pf[idx++].mValue.mU32;
+ pNet->mForbidden = pf[idx++].mValue.mU32;
+ pNet->mPreferred = pf[idx++].mValue.mU32;
+
+ memset( &pNet->mDescription[0], 0, (SIZE_T)MAX_SNI_DESCRIPTION_LEN );
+
+ BYTE descLen = pf[idx++].mValue.mU8;
+ if (descLen > 0)
+ {
+ std::string netDesc( pf[idx++].mValueString );
+
+ ULONG actualLen = netDesc.size();
+ if (actualLen >= MAX_SNI_DESCRIPTION_LEN)
+ {
+ actualLen = MAX_SNI_DESCRIPTION_LEN - 1;
+ }
+
+ memcpy( (LPVOID)&pNet->mDescription[0],
+ (LPCSTR)netDesc.c_str(),
+ (SIZE_T)actualLen );
+ }
+
+ pNet++;
+ }
+
+ *pInstanceSize = netCount;
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ PerformNetworkRATScan (Public Method)
+
+DESCRIPTION:
+ This function performs a scan for available networks (includes RAT)
+
+PARAMETERS:
+ pInstanceSize [I/O] - Upon input the maximum number of elements that the
+ network info instance array can contain. Upon
+ success the actual number of elements in the
+ network info instance array
+ pInstances [ O ] - The network info instance array
+ pRATSize [I/O] - Upon input the maximum number of elements that the
+ RAT info instance array can contain. Upon success
+ the actual number of elements in the RAT info
+ instance array
+ pRATInstances [ O ] - The RAT info instance array
+
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::PerformNetworkRATScan(
+ BYTE * pInstanceSize,
+ BYTE * pInstances,
+ BYTE * pRATSize,
+ BYTE * pRATInstances )
+{
+ // Validate arguments
+ if ( (pInstanceSize == 0)
+ || (*pInstanceSize == 0)
+ || (pInstances == 0)
+ || (pRATSize == 0)
+ || (*pRATSize == 0)
+ || (pRATInstances == 0) )
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ BYTE maxInstances = *pInstanceSize;
+ BYTE maxRATInstances = *pRATSize;
+
+ // Assume failure
+ *pInstanceSize = 0;
+ *pRATSize = 0;
+
+ // This can take a really long time
+ ULONG to = MAX_REQ_TIMEOUT;
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_NAS_SCAN_NETS;
+ sProtocolBuffer rsp = SendSimple( eQMI_SVC_NAS, msgID, to );
+ 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_NAS_RSP, msgID, 16 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+
+ ULONG maxIdx = (ULONG)pf.size();
+ if (maxIdx-- < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ ULONG idx = 0;
+ BYTE netCount = pf[idx++].mValue.mU8;
+ if (netCount > maxInstances)
+ {
+ netCount = maxInstances;
+ }
+
+ sScannedNetworkInfo * pNet = (sScannedNetworkInfo *)pInstances;
+ for (BYTE i = 0; i < netCount; i++)
+ {
+ // Validate field count
+ if (idx + 6 > maxIdx)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ pNet->mMCC = pf[idx++].mValue.mU16;
+ pNet->mMNC = pf[idx++].mValue.mU16;
+ pNet->mInUse = pf[idx++].mValue.mU32;
+ pNet->mRoaming = pf[idx++].mValue.mU32;
+ pNet->mForbidden = pf[idx++].mValue.mU32;
+ pNet->mPreferred = pf[idx++].mValue.mU32;
+
+ memset( &pNet->mDescription[0], 0, (SIZE_T)MAX_SNI_DESCRIPTION_LEN );
+
+ BYTE descLen = pf[idx++].mValue.mU8;
+ if (descLen > 0)
+ {
+ std::string netDesc( pf[idx++].mValueString );
+
+ ULONG actualLen = netDesc.size();
+ if (actualLen >= MAX_SNI_DESCRIPTION_LEN)
+ {
+ actualLen = MAX_SNI_DESCRIPTION_LEN - 1;
+ }
+
+ LPCSTR pNetDesc = netDesc.c_str();
+ memcpy( (LPVOID)&pNet->mDescription[0],
+ (LPCVOID)pNetDesc,
+ (SIZE_T)actualLen );
+ }
+
+ pNet++;
+ }
+
+ // Parse the TLV we want (by DB key)
+ tlvKey = sProtocolEntityKey( eDB2_ET_QMI_NAS_RSP, msgID, 17 );
+ pf = ParseTLV( db, rsp, tlvs, tlvKey );
+
+ maxIdx = (ULONG)pf.size();
+ if (maxIdx-- < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ idx = 0;
+ BYTE ratCount = pf[idx++].mValue.mU8;
+ if (ratCount > maxRATInstances)
+ {
+ ratCount = maxRATInstances;
+ }
+
+ sScannedNetworkRATInfo * pRAT = (sScannedNetworkRATInfo *)pRATInstances;
+ for (BYTE r = 0; r < ratCount; r++)
+ {
+ // Validate field count
+ if (idx + 2 > maxIdx)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ pRAT->mMCC = pf[idx++].mValue.mU16;
+ pRAT->mMNC = pf[idx++].mValue.mU16;
+ pRAT->mRAT = pf[idx++].mValue.mU32;
+ pRAT++;
+ }
+
+ *pInstanceSize = netCount;
+ *pRATSize = ratCount;
+
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ InitiateNetworkRegistration (Public Method)
+
+DESCRIPTION:
+ This function initiates a network registration
+
+PARAMETERS:
+ regType [ I ] - Registration type
+ mcc [ I ] - Mobile country code (ignored for auto registration)
+ mnc [ I ] - Mobile network code (ignored for auto registration)
+ rat [ I ] - Radio access type (ignored for auto registration)
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::InitiateNetworkRegistration(
+ ULONG regType,
+ WORD mcc,
+ WORD mnc,
+ ULONG rat )
+{
+ WORD msgID = (WORD)eQMI_NAS_REGISTER_NET;
+ std::vector <sDB2PackingInput> piv;
+
+ std::ostringstream tmp;
+ tmp << (UINT)regType;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_NAS_REQ, msgID, 1 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
+ piv.push_back( pi );
+
+ if (regType == 2)
+ {
+ // We need to add the manual registration data
+ // "%hu %hu %u"
+ std::ostringstream tmp2;
+ tmp2 << (USHORT)mcc << " " << (USHORT)mnc << " "
+ << (UINT)rat;
+
+ pek = sProtocolEntityKey( eDB2_ET_QMI_NAS_REQ, msgID, 16 );
+ pi = sDB2PackingInput( pek, (LPCSTR)tmp2.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_NAS, pRequest, 30000 );
+}
+
+/*===========================================================================
+METHOD:
+ InitiateDomainAttach (Public Method)
+
+DESCRIPTION:
+ This function initiates a domain attach (or detach)
+
+PARAMETERS:
+ action [ I ] - PS attach action (attach or detach)
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::InitiateDomainAttach( ULONG action )
+{
+ WORD msgID = (WORD)eQMI_NAS_ATTACH_DETACH;
+ std::vector <sDB2PackingInput> piv;
+
+ std::ostringstream tmp;
+ tmp << (UINT)action;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_NAS_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 );
+
+ // Send the QMI request, check result, and return
+ return SendAndCheckReturn( eQMI_SVC_NAS, pRequest, 30000 );
+}
+
+/*===========================================================================
+METHOD:
+ GetServingNetwork (Public Method)
+
+DESCRIPTION:
+ Gets information regarding the system that currently provides service
+ to the device
+
+PARAMETERS:
+ pRegistrationState [ O ] - Registration state
+ pCSDomain [ O ] - Circuit switch domain status
+ pPSDomain [ O ] - Packet switch domain status
+ pRAN [ O ] - Radio access network
+ pRadioIfacesSize [I/O] - Upon input the maximum number of elements
+ that the radio interfaces can contain. Upon
+ successful output the actual number of elements
+ in the radio interface array
+ pRadioIfaces [ O ] - The radio interface array
+ pRoaming [ O ] - Roaming indicator (0xFFFFFFFF - Unknown)
+ pMCC [ O ] - Mobile country code (0xFFFF - Unknown)
+ pMNC [ O ] - Mobile network code (0xFFFF - Unknown)
+ nameSize [ I ] - The maximum number of characters (including
+ NULL terminator) that the network name array
+ can contain
+ pName [ O ] - The network name or description represented
+ as a NULL terminated string (empty string
+ returned when unknown)
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetServingNetwork(
+ ULONG * pRegistrationState,
+ ULONG * pCSDomain,
+ ULONG * pPSDomain,
+ ULONG * pRAN,
+ BYTE * pRadioIfacesSize,
+ BYTE * pRadioIfaces,
+ ULONG * pRoaming,
+ WORD * pMCC,
+ WORD * pMNC,
+ BYTE nameSize,
+ CHAR * pName )
+{
+ // Validate arguments
+ if ( (pRegistrationState == 0)
+ || (pCSDomain == 0)
+ || (pPSDomain == 0)
+ || (pRAN == 0)
+ || (pRadioIfacesSize == 0)
+ || (*pRadioIfacesSize == 0)
+ || (pRadioIfaces == 0)
+ || (pRoaming == 0)
+ || (pMCC == 0)
+ || (pMNC == 0)
+ || (nameSize == 0)
+ || (pName == 0) )
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ BYTE maxRadioIfaces = *pRadioIfacesSize;
+
+ // Assume failure
+ *pRadioIfacesSize = 0;
+ *pRoaming = ULONG_MAX;
+ *pMCC = USHRT_MAX;
+ *pMNC = USHRT_MAX;
+ *pName = 0;
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_NAS_GET_SS_INFO;
+ sProtocolBuffer rsp = SendSimple( eQMI_SVC_NAS, 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 tlvKey1( eDB2_ET_QMI_NAS_RSP, msgID, 1 );
+ cDataParser::tParsedFields pf1 = ParseTLV( db, rsp, tlvs, tlvKey1 );
+ if (pf1.size() < 5)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ // Populate the variables
+ *pRegistrationState = pf1[0].mValue.mU32;
+ *pCSDomain = pf1[1].mValue.mU32;
+ *pPSDomain = pf1[2].mValue.mU32;
+ *pRAN = pf1[3].mValue.mU32;
+
+ BYTE activeRadioIfaces = pf1[4].mValue.mU8;
+ if (pf1.size() < 5 + (ULONG)activeRadioIfaces)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ if (activeRadioIfaces > maxRadioIfaces)
+ {
+ activeRadioIfaces = maxRadioIfaces;
+ }
+
+ ULONG * pOutRadioIfaces = (ULONG *)pRadioIfaces;
+ for (ULONG r = 0; r < activeRadioIfaces; r++)
+ {
+ *pOutRadioIfaces++ = pf1[5 + r].mValue.mU32;
+ }
+
+ *pRadioIfacesSize = activeRadioIfaces;
+
+ // Parse the optional TLV we want (by DB key)
+ sProtocolEntityKey tlvKey2( eDB2_ET_QMI_NAS_RSP, msgID, 16 );
+ cDataParser::tParsedFields pf2 = ParseTLV( db, rsp, tlvs, tlvKey2 );
+ if (pf2.size() >= 1)
+ {
+ *pRoaming = pf2[0].mValue.mU32;
+ }
+
+ // Parse the optional TLV we want (by DB key)
+ sProtocolEntityKey tlvKey3( eDB2_ET_QMI_NAS_RSP, msgID, 18 );
+ cDataParser::tParsedFields pf3 = ParseTLV( db, rsp, tlvs, tlvKey3 );
+ if (pf3.size() >= 3)
+ {
+ *pMCC = pf3[0].mValue.mU16;
+ *pMNC = pf3[1].mValue.mU16;
+
+ // Network name?
+ if (pf3[2].mValue.mU8 > 0 && pf3.size() >= 4)
+ {
+ LONG strLen = pf3[3].mValueString.size();
+ if (strLen > 0)
+ {
+ // Space to perform the copy?
+ if (nameSize < strLen + 1)
+ {
+ return eGOBI_ERR_BUFFER_SZ;
+ }
+
+ memcpy( (LPVOID)pName, (LPCSTR)pf3[3].mValueString.c_str(), strLen );
+ pName[strLen] = 0;
+ }
+ }
+ }
+
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ GetServingNetworkCapabilities (Public Method)
+
+DESCRIPTION:
+ Gets information regarding the data capabilities of the system that
+ currently provides service to the device
+
+PARAMETERS:
+ pDataCapsSize [I/O] - Upon input the maximum number of elements that the
+ data capabilities array can contain. Upon success
+ the actual number of elements in the data
+ capabilities array
+ pDataCaps [ O ] - The data capabilities array
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetServingNetworkCapabilities(
+ BYTE * pDataCapsSize,
+ BYTE * pDataCaps )
+{
+ // Validate arguments
+ if ( (pDataCapsSize == 0)
+ || (*pDataCapsSize == 0)
+ || (pDataCaps == 0) )
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ BYTE maxDataCaps = *pDataCapsSize;
+
+ // Assume failure
+ *pDataCapsSize = 0;
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_NAS_GET_SS_INFO;
+ sProtocolBuffer rsp = SendSimple( eQMI_SVC_NAS, 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_NAS_RSP, msgID, 17 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ BYTE activeDataCaps = pf[0].mValue.mU8;
+ if (pf.size() < 1 + (ULONG)activeDataCaps)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ if (activeDataCaps > maxDataCaps)
+ {
+ activeDataCaps = maxDataCaps;
+ }
+
+ ULONG * pOutDataCaps = (ULONG *)pDataCaps;
+ for (ULONG d = 0; d < activeDataCaps; d++)
+ {
+ *pOutDataCaps++ = pf[1 + d].mValue.mU32;
+ }
+
+ *pDataCapsSize = activeDataCaps;
+
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ GetDataBearerTechnology (Public Method)
+
+DESCRIPTION:
+ This function retrieves the current data bearer technology (only
+ valid when connected)
+
+PARAMETERS:
+ pDataCaps [ O ] - The data bearer technology
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetDataBearerTechnology( ULONG * pDataBearer )
+{
+ // Validate arguments
+ if (pDataBearer == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_WDS_GET_DATA_BEARER;
+ sProtocolBuffer rsp = SendSimple( eQMI_SVC_WDS, 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_WDS_RSP, msgID, 1 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ // Populate the state
+ *pDataBearer = pf[0].mValue.mU32;
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ GetHomeNetwork (Public Method)
+
+DESCRIPTION:
+ This function retrieves information about the home network of the device
+
+PARAMETERS:
+ pMCC [ O ] - Mobile country code
+ pMNC [ O ] - Mobile network code
+ nameSize [ I ] - The maximum number of characters (including
+ NULL terminator) that the network name array
+ can contain
+ pName [ O ] - The network name or description represented
+ as a NULL terminated string (empty string
+ returned when unknown)
+ pSID [ O ] - Home network system ID (0xFFFF - Unknown)
+ pNID [ O ] - Home network ID (0xFFFF - Unknown)
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetHomeNetwork(
+ WORD * pMCC,
+ WORD * pMNC,
+ BYTE nameSize,
+ CHAR * pName,
+ WORD * pSID,
+ WORD * pNID )
+{
+ // Validate arguments
+ if ( (pMCC == 0)
+ || (pMNC == 0)
+ || (nameSize == 0)
+ || (pName == 0)
+ || (pSID == 0) )
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ // Assume failure
+ *pName = 0;
+ *pSID = USHRT_MAX;
+ *pNID = USHRT_MAX;
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_NAS_GET_HOME_INFO;
+ sProtocolBuffer rsp = SendSimple( eQMI_SVC_NAS, 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 tlvKey1( eDB2_ET_QMI_NAS_RSP, msgID, 1 );
+ cDataParser::tParsedFields pf1 = ParseTLV( db, rsp, tlvs, tlvKey1 );
+ if (pf1.size() < 3)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ // Populate the variables
+ *pMCC = pf1[0].mValue.mU16;
+ *pMNC = pf1[1].mValue.mU16;
+
+ // Network name?
+ if (pf1[2].mValue.mU8 > 0 && pf1.size() >= 4)
+ {
+ LONG strLen = pf1[3].mValueString.size();
+ if (strLen > 0)
+ {
+ // Space to perform the copy?
+ if (nameSize < strLen + 1)
+ {
+ return eGOBI_ERR_BUFFER_SZ;
+ }
+
+ memcpy( (LPVOID)pName, (LPCSTR)pf1[3].mValueString.c_str(), strLen );
+ pName[strLen] = 0;
+ }
+ }
+
+ // Parse the optional TLV we want (by DB key)
+ sProtocolEntityKey tlvKey2( eDB2_ET_QMI_NAS_RSP, msgID, 16 );
+ cDataParser::tParsedFields pf2 = ParseTLV( db, rsp, tlvs, tlvKey2 );
+ if (pf2.size() >= 2)
+ {
+ *pSID = pf2[0].mValue.mU16;
+ *pNID = pf2[1].mValue.mU16;
+ }
+
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ SetNetworkPreference (Public Method)
+
+DESCRIPTION:
+ This function sets the network registration preference
+
+PARAMETERS:
+ technologyPref [ I ] - Technology preference bitmap
+ duration [ I ] - Duration of active preference
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::SetNetworkPreference(
+ ULONG technologyPref,
+ ULONG duration )
+{
+ // Buffer to hold technology preference TLV (ID = 1)
+ const ULONG TLV_HDR_SZ = (ULONG)sizeof( sQMIRawContentHeader );
+ BYTE req[3 + TLV_HDR_SZ];
+
+ // Fill out TLV header
+ sQMIRawContentHeader * pTLV = (sQMIRawContentHeader *)&req[0];
+ pTLV->mLength = 3;
+ pTLV->mTypeID = 1;
+
+ // Copy packed technology preference WORD as-is
+ WORD * pTmp = (WORD *)&req[TLV_HDR_SZ];
+ *pTmp = (WORD)technologyPref;
+
+ // Fill out duration
+ req[TLV_HDR_SZ + 2] = (BYTE)duration;
+
+ // Pack TLV into a QMI NAS request
+ sSharedBuffer * pRequest = 0;
+ pRequest = sQMIServiceBuffer::BuildBuffer( eQMI_SVC_NAS,
+ eQMI_NAS_SET_TECH_PREF,
+ false,
+ false,
+ &req[0],
+ 3 + TLV_HDR_SZ );
+
+ // Send the QMI request, check result, and return
+ return SendAndCheckReturn( eQMI_SVC_NAS, pRequest );
+}
+
+/*===========================================================================
+METHOD:
+ GetNetworkPreference (Public Method)
+
+DESCRIPTION:
+ This function returns the network registration preference
+
+PARAMETERS:
+ pTechnologyPref [ O ] - Technology preference bitmap
+ pDuration [ O ] - Duration of active preference
+ pPersistentTechnologyPref [ O ] - Persistent technology preference bitmap
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetNetworkPreference(
+ ULONG * pTechnologyPref,
+ ULONG * pDuration,
+ ULONG * pPersistentTechnologyPref )
+{
+ // Validate arguments
+ if ( (pTechnologyPref == 0)
+ || (pDuration == 0)
+ || (pPersistentTechnologyPref == 0) )
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_NAS_GET_TECH_PREF;
+ sProtocolBuffer rsp = SendSimple( eQMI_SVC_NAS, 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 );
+
+ // Parse the TLV we want (by DB key)
+ sProtocolEntityKey tlvKey1( eDB2_ET_QMI_NAS_RSP, msgID, 1 );
+ sDB2NavInput ni1 = FindTLV( tlvs, tlvKey1 );
+ if (ni1.mPayloadLen < 3)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ const BYTE * pData = ni1.mpPayload;
+ const WORD * pTmp = (const WORD *)pData;
+ pData += 2;
+
+ // Populate the variables
+ *pTechnologyPref = (ULONG)*pTmp;
+ *pDuration = (ULONG)*pData;
+
+ // Until we know any better the persistent setting is the current setting
+ *pPersistentTechnologyPref = *pTechnologyPref;
+
+ // Parse the optional TLV we want (by DB key)
+ sProtocolEntityKey tlvKey2( eDB2_ET_QMI_NAS_RSP, msgID, 16 );
+ sDB2NavInput ni2 = FindTLV( tlvs, tlvKey2 );
+ if (ni2.mPayloadLen >= 2)
+ {
+ pTmp = (const WORD *)ni2.mpPayload;
+ *pPersistentTechnologyPref = (ULONG)*pTmp;
+ }
+
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ SetCDMANetworkParameters (Public Method)
+
+DESCRIPTION:
+ This function sets the desired CDMA network parameters
+
+PARAMETERS:
+ pSPC [ I ] - Six digit service programming code
+ pForceRev0 [ I ] - (Optional) Force CDMA 1x-EV-DO Rev. 0 mode?
+ pCustomSCP [ I ] - (Optional) Use a custom config for CDMA 1x-EV-DO SCP?
+ pProtocol [ I ] - (Optional) Protocol mask for custom SCP config
+ pBroadcast [ I ] - (Optional) Broadcast mask for custom SCP config
+ pApplication [ I ] - (Optional) Application mask for custom SCP config
+ pRoaming [ I ] - (Optional) Roaming preference
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::SetCDMANetworkParameters(
+ CHAR * pSPC,
+ BYTE * pForceRev0,
+ BYTE * pCustomSCP,
+ ULONG * pProtocol,
+ ULONG * pBroadcast,
+ ULONG * pApplication,
+ ULONG * pRoaming )
+{
+ // If you specify one of the custom SCP config fields then you must
+ // specify them all
+ ULONG scpCount = 0;
+ if (pCustomSCP != 0)
+ {
+ scpCount++;
+ }
+
+ if (pProtocol != 0)
+ {
+ scpCount++;
+ }
+
+ if (pBroadcast != 0)
+ {
+ scpCount++;
+ }
+
+ if (pApplication != 0)
+ {
+ scpCount++;
+ }
+
+ if (scpCount != 0 && scpCount != 4)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ // Rev. 0 and SCP custom config are mutually exclusive
+ if (pForceRev0 != 0 && scpCount == 4)
+ {
+ if (*pForceRev0 != 0 && *pCustomSCP != 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+ }
+
+ WORD msgID = (WORD)eQMI_NAS_SET_NET_PARAMS;
+ std::vector <sDB2PackingInput> piv;
+
+ // Need to start with SPC?
+ if (pForceRev0 != 0 || scpCount == 4)
+ {
+ // Validate arguments
+ if (pSPC == 0 || pSPC[0] == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ std::string spc( pSPC );
+ if (spc.size() > 6)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ int nNonDigit = spc.find_first_not_of( "0123456789" );
+ std::string digitSPC = spc.substr( 0, nNonDigit );
+ if (digitSPC.size() != spc.size())
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_NAS_REQ, msgID, 16 );
+ sDB2PackingInput pi( pek, (LPCSTR)spc.c_str() );
+ piv.push_back( pi );
+ }
+
+ if (pForceRev0 != 0)
+ {
+ // "%u"
+ std::ostringstream tmp;
+ tmp << (UINT)(*pForceRev0 == 0 ? 0 : 1);
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_NAS_REQ, msgID, 20 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ if (scpCount == 4)
+ {
+ // "%u %u %u %u %u %u %u %u %u %u %u %u"
+ std::ostringstream tmp;
+ tmp << (UINT)(*pCustomSCP == 0 ? 0 : 1)
+ << (UINT)(*pProtocol & 0x00000001 ? 1 : 0)
+ << (UINT)(*pProtocol & 0x00000002 ? 1 : 0)
+ << (UINT)(*pProtocol & 0x00000004 ? 1 : 0)
+ << (UINT)(*pProtocol & 0x00000008 ? 1 : 0)
+ << (UINT)(*pProtocol & 0x00000010 ? 1 : 0)
+ << (UINT)(*pProtocol & 0x00000020 ? 1 : 0)
+ << (UINT)(*pProtocol & 0x00000040 ? 1 : 0)
+ << (UINT)(*pProtocol & 0x00000080 ? 1 : 0)
+ << (UINT)(*pBroadcast & 0x00000001 ? 1 : 0)
+ << (UINT)(*pApplication & 0x00000001 ? 1 : 0)
+ << (UINT)(*pApplication & 0x00000002 ? 1 : 0);
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_NAS_REQ, msgID, 21 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ if (pRoaming != 0)
+ {
+ // "%u"
+ std::ostringstream tmp;
+ tmp << (UINT)*pRoaming;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_NAS_REQ, msgID, 22 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ // We require something to actually configure
+ if (piv.size() == 0)
+ {
+ // Much ado about nothing
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ // 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_NAS, pRequest, 5000 );
+}
+
+/*===========================================================================
+METHOD:
+ GetCDMANetworkParameters (Public Method)
+
+DESCRIPTION:
+ This function gets the current CDMA network parameters
+
+PARAMETERS:
+ pSCI [ O ] - Slot cycle index
+ pSCM [ O ] - Station class mark
+ pRegHomeSID [ O ] - Register on home SID?
+ pRegForeignSID [ O ] - Register on foreign SID?
+ pRegForeignNID [ O ] - Register on foreign NID?
+ pForceRev0 [ O ] - Force CDMA 1x-EV-DO Rev. 0 mode?
+ pCustomSCP [ O ] - Use a custom config for CDMA 1x-EV-DO SCP?
+ pProtocol [ O ] - Protocol mask for custom SCP config
+ pBroadcast [ O ] - Broadcast mask for custom SCP config
+ pApplication [ O ] - Application mask for custom SCP config
+ pRoaming [ O ] - Roaming preference
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetCDMANetworkParameters(
+ BYTE * pSCI,
+ BYTE * pSCM,
+ BYTE * pRegHomeSID,
+ BYTE * pRegForeignSID,
+ BYTE * pRegForeignNID,
+ BYTE * pForceRev0,
+ BYTE * pCustomSCP,
+ ULONG * pProtocol,
+ ULONG * pBroadcast,
+ ULONG * pApplication,
+ ULONG * pRoaming )
+{
+ // Validate arguments
+ if ( (pSCI == 0)
+ || (pSCM == 0)
+ || (pRegHomeSID == 0)
+ || (pRegForeignSID == 0)
+ || (pRegForeignNID == 0)
+ || (pForceRev0 == 0)
+ || (pCustomSCP == 0)
+ || (pProtocol == 0)
+ || (pBroadcast == 0)
+ || (pApplication == 0)
+ || (pRoaming == 0) )
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ *pSCI = UCHAR_MAX;
+ *pSCM = UCHAR_MAX;
+ *pRegHomeSID = UCHAR_MAX;
+ *pRegForeignSID = UCHAR_MAX;
+ *pRegForeignNID = UCHAR_MAX;
+ *pForceRev0 = UCHAR_MAX;
+ *pCustomSCP = UCHAR_MAX;
+ *pProtocol = ULONG_MAX;
+ *pBroadcast = ULONG_MAX;
+ *pApplication = ULONG_MAX;
+ *pRoaming = UCHAR_MAX;
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_NAS_GET_NET_PARAMS;
+ sProtocolBuffer rsp = SendSimple( eQMI_SVC_NAS, 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 TLVs we want (by DB key)
+ sProtocolEntityKey tlvKey( eDB2_ET_QMI_NAS_RSP, msgID, 17 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() >= 1)
+ {
+ *pSCI = pf[0].mValue.mU8;
+ }
+
+ tlvKey = sProtocolEntityKey( eDB2_ET_QMI_NAS_RSP, msgID, 18 );
+ pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() >= 1)
+ {
+ *pSCM = pf[0].mValue.mU8;
+ }
+
+ tlvKey = sProtocolEntityKey( eDB2_ET_QMI_NAS_RSP, msgID, 19 );
+ pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() >= 3)
+ {
+ *pRegHomeSID = pf[0].mValue.mU8;
+ *pRegForeignSID = pf[0].mValue.mU8;
+ *pRegForeignNID = pf[0].mValue.mU8;
+ }
+
+ tlvKey = sProtocolEntityKey( eDB2_ET_QMI_NAS_RSP, msgID, 20 );
+ pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() >= 1)
+ {
+ *pForceRev0 = pf[0].mValue.mU8;
+ }
+
+ tlvKey = sProtocolEntityKey ( eDB2_ET_QMI_NAS_RSP, msgID, 21 );
+ sDB2NavInput ni = FindTLV( tlvs, tlvKey );
+ if (ni.mPayloadLen >= (ULONG)sizeof( sEVDOCustomSCPConfig ))
+ {
+ const sEVDOCustomSCPConfig * pData = 0;
+ pData = (const sEVDOCustomSCPConfig *)ni.mpPayload;
+
+ *pCustomSCP = pData->mbActive;
+ *pProtocol = pData->mProtocolMask;
+ *pBroadcast = pData->mBroadcastMask;
+ *pApplication = pData->mApplicationMask;
+ }
+
+ tlvKey = sProtocolEntityKey( eDB2_ET_QMI_NAS_RSP, msgID, 22 );
+ pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() >= 1)
+ {
+ *pRoaming = pf[0].mValue.mU32;
+ }
+
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ GetACCOLC (Public Method)
+
+DESCRIPTION:
+ This function returns the Access Overload Class (ACCOLC) of the device
+
+PARAMETERS:
+ pACCOLC [ O ] - The ACCOLC
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetACCOLC( BYTE * pACCOLC )
+{
+ // Validate arguments
+ if (pACCOLC == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_NAS_GET_ACCOLC;
+ sProtocolBuffer rsp = SendSimple( eQMI_SVC_NAS, 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_NAS_RSP, msgID, 1 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ // Populate the ACCOLC
+ *pACCOLC = pf[0].mValue.mU8;
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ SetACCOLC (Public Method)
+
+DESCRIPTION:
+ This function sets the Access Overload Class (ACCOLC) of the device
+
+PARAMETERS:
+ pSPC [ I ] - NULL terminated string representing the six digit
+ service programming code
+ accolc [ I ] - The ACCOLC
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::SetACCOLC(
+ CHAR * pSPC,
+ BYTE accolc )
+{
+ // Validate arguments
+ if (pSPC == 0 || pSPC[0] == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ std::string spc( pSPC );
+ if (spc.size() > 6)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ int nNonDigit = spc.find_first_not_of( "0123456789" );
+ std::string digitSPC = spc.substr( 0, nNonDigit );
+ if (digitSPC.size() != spc.size())
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ WORD msgID = (WORD)eQMI_NAS_SET_ACCOLC;
+ std::vector <sDB2PackingInput> piv;
+
+ // "%s %u"
+ std::ostringstream tmp;
+ tmp << spc << " " << (UINT)accolc;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_NAS_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_NAS, pRequest, 5000 );
+}
+
+/*===========================================================================
+METHOD:
+ GetPLMNMode (Public Method)
+
+DESCRIPTION:
+ This function returns the PLMN mode from the CSP
+
+PARAMETERS:
+ pMode [ O ] - PLMN mode
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetPLMNMode( ULONG * pMode )
+{
+ // Validate arguments
+ if (pMode == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_NAS_GET_PLMN_MODE;
+ sProtocolBuffer rsp = SendSimple( eQMI_SVC_NAS, 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_NAS_RSP, msgID, 16 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ // Populate the PLMN mode
+ *pMode = (ULONG)pf[0].mValue.mU8;
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ GetPLMNName (Public Method)
+
+DESCRIPTION:
+ This function returns PLMN name information for the given MCC/MNC
+
+PARAMETERS:
+ mcc [ I ] - Mobile country code
+ mnc [ I ] - Mobile network code
+ pNamesSize [I/O] - Upon input the size in BYTEs of the name structure
+ array. Upon success the actual number of BYTEs
+ copied to the name structure array
+ pNames [ O ] - The name structure array
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetPLMNName(
+ USHORT mcc,
+ USHORT mnc,
+ ULONG * pNamesSize,
+ BYTE * pNames )
+{
+ // Validate arguments
+ if ( (pNamesSize == 0)
+ || (*pNamesSize == 0)
+ || (pNames == 0) )
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ ULONG maxSz = *pNamesSize;
+ *pNamesSize = 0;
+
+
+ WORD msgID = (WORD)eQMI_NAS_GET_PLMN_NAME;
+ std::vector <sDB2PackingInput> piv;
+
+ // "%hu %hu"
+ std::ostringstream tmp;
+ tmp << mcc << " " << mnc;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_NAS_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 );
+
+
+ sProtocolBuffer rsp = Send( eQMI_SVC_NAS, 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 16
+ 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())
+ {
+ 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;
+ }
+
+ *pNamesSize = needSz;
+ if (needSz > maxSz)
+ {
+ return eGOBI_ERR_BUFFER_SZ;
+ }
+
+ pHdr++;
+ const BYTE * pData = (const BYTE *)pHdr;
+
+ memcpy( (LPVOID)pNames,
+ (LPCVOID)pData,
+ (SIZE_T)needSz );
+
+ return eGOBI_ERR_NONE;
+}
diff --git a/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreOMA.cpp b/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreOMA.cpp
new file mode 100755
index 0000000..713a7ab
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreOMA.cpp
@@ -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 );
+}
diff --git a/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICorePDS.cpp b/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICorePDS.cpp
new file mode 100755
index 0000000..b3cc60d
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICorePDS.cpp
@@ -0,0 +1,1292 @@
+/*===========================================================================
+FILE:
+ GobiQMICorePDS.cpp
+
+DESCRIPTION:
+ QUALCOMM Gobi QMI Based API Core (PDS 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:
+ GetPDSState (Public Method)
+
+DESCRIPTION:
+ This function returns the current PDS state
+
+PARAMETERS:
+ pEnabled [ O ] - Current PDS state (0 = disabled)
+ pTracking [ O ] - Current PDS tracking session state
+
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetPDSState(
+ ULONG * pEnabled,
+ ULONG * pTracking )
+{
+ // Validate arguments
+ if (pEnabled == 0 || pTracking == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ *pEnabled = ULONG_MAX;
+ *pTracking = ULONG_MAX;
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_PDS_GET_STATE;
+ sProtocolBuffer rsp = SendSimple( eQMI_SVC_PDS, 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_PDS_RSP, msgID, 1 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 2)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ *pEnabled = pf[0].mValue.mU32;
+ *pTracking = pf[1].mValue.mU32;
+
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ SetPDSState (Public Method)
+
+DESCRIPTION:
+ This function sets the PDS state
+
+PARAMETERS:
+ enable [ I ] - Desired PDS state (0 = disable)
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::SetPDSState( ULONG enable )
+{
+ WORD msgID = (WORD)eQMI_PDS_SET_STATE;
+ std::vector <sDB2PackingInput> piv;
+
+ LPCSTR pVal = enable != 0 ? "1" : "0";
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_PDS_REQ, msgID, 1 );
+ sDB2PackingInput pi( pek, pVal );
+ 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_PDS, pRequest, 5000 );
+}
+
+/*===========================================================================
+METHOD:
+ PDSInjectTimeReference (Public Method)
+
+DESCRIPTION:
+ This function injects a system time into the PDS engine
+
+PARAMETERS:
+ sysTime [ I ] - System time
+ sysDiscontinuities [ I ] - Number of system time discontinuities
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::PDSInjectTimeReference(
+ ULONGLONG systemTime,
+ USHORT systemDiscontinuities )
+{
+ WORD msgID = (WORD)eQMI_PDS_INJECT_TIME;
+ std::vector <sDB2PackingInput> piv;
+
+ std::ostringstream tmp;
+ tmp << systemTime << " " << systemDiscontinuities;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_PDS_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_PDS, pRequest );
+}
+
+/*===========================================================================
+METHOD:
+ GetPDSDefaults (Public Method)
+
+DESCRIPTION:
+ This function returns the default tracking session configuration
+
+PARAMETERS:
+ pOperation [ O ] - Current session operating mode
+ pTimeout [ O ] - Maximum amount of time (seconds) to work on each fix
+ pInterval [ O ] - Interval (milliseconds) between fix requests
+ pAccuracy [ O ] - Current accuracy threshold (meters)
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetPDSDefaults(
+ ULONG * pOperation,
+ BYTE * pTimeout,
+ ULONG * pInterval,
+ ULONG * pAccuracy )
+{
+ // Validate arguments
+ if (pOperation == 0 || pTimeout == 0 || pInterval == 0 || pAccuracy == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ *pOperation = ULONG_MAX;
+ *pTimeout = UCHAR_MAX;
+ *pInterval = ULONG_MAX;
+ *pAccuracy = ULONG_MAX;
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_PDS_GET_DEFAULTS;
+ sProtocolBuffer rsp = SendSimple( eQMI_SVC_PDS, 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_PDS_RSP, msgID, 1 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 4)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ // Original QMI doc claimed milliseconds, turned out to be seconds
+ ULONG apiInterval = pf[2].mValue.mU32 * 1000;
+
+ *pOperation = pf[0].mValue.mU32;
+ *pTimeout = pf[1].mValue.mU8;
+ *pInterval = apiInterval;
+ *pAccuracy = pf[3].mValue.mU32;
+
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ SetPDSDefaults (Public Method)
+
+DESCRIPTION:
+ This function sets the default tracking session configuration
+
+PARAMETERS:
+ operation [ I ] - Desired session operating mode
+ timeout [ I ] - Maximum amount of time (seconds) to work on each fix
+ interval [ I ] - Interval (milliseconds) between fix requests
+ accuracy [ I ] - Desired accuracy threshold (meters)
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::SetPDSDefaults(
+ ULONG operation,
+ BYTE timeout,
+ ULONG interval,
+ ULONG accuracy )
+{
+ WORD msgID = (WORD)eQMI_PDS_SET_DEFAULTS;
+ std::vector <sDB2PackingInput> piv;
+
+ // Original QMI doc claimed milliseconds, turned out to be seconds
+ ULONG qmiInterval = interval / 1000;
+
+ // "%u %u %u %u"
+ std::ostringstream tmp;
+ tmp << (UINT)operation << " " << (UINT)timeout << " " << (UINT)qmiInterval
+ << " " << (UINT)accuracy;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_PDS_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_PDS, pRequest );
+}
+
+/*===========================================================================
+METHOD:
+ GetXTRAAutomaticDownload (Public Method)
+
+DESCRIPTION:
+ This function returns the XTRA automatic download configuration
+
+PARAMETERS:
+ pbEnabled [ O ] - Automatic download enabled?
+ pInterval [ O ] - Interval (hours) between XTRA downloads
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetXTRAAutomaticDownload(
+ ULONG * pbEnabled,
+ USHORT * pInterval )
+{
+ // Validate arguments
+ if (pbEnabled == 0 || pInterval == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ *pbEnabled = ULONG_MAX;
+ *pInterval = USHRT_MAX;
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_PDS_GET_XTRA_PARAMS;
+ sProtocolBuffer rsp = SendSimple( eQMI_SVC_PDS, 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_PDS_RSP, msgID, 16 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 2)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ *pbEnabled = pf[0].mValue.mU32;
+ *pInterval = pf[1].mValue.mU16;
+
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ SetXTRAAutomaticDownload (Public Method)
+
+DESCRIPTION:
+ This function sets the XTRA automatic download configuration
+
+PARAMETERS:
+ bEnabled [ I ] - Automatic download enabled?
+ interval [ I ] - Interval (hours) between XTRA downloads
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::SetXTRAAutomaticDownload(
+ ULONG bEnabled,
+ USHORT interval )
+{
+ WORD msgID = (WORD)eQMI_PDS_SET_XTRA_PARAMS;
+ std::vector <sDB2PackingInput> piv;
+
+ // "%u %hu"
+ std::ostringstream tmp;
+ tmp << (UINT)bEnabled << " " << (USHORT)interval;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_PDS_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_PDS, pRequest );
+}
+
+/*===========================================================================
+METHOD:
+ GetXTRANetwork (Public Method)
+
+DESCRIPTION:
+ This function returns the XTRA WWAN network preference
+
+PARAMETERS:
+ pPreference [ O ] - XTRA WWAN network preference
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetXTRANetwork( ULONG * pPreference )
+{
+ // Validate arguments
+ if (pPreference == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ *pPreference = ULONG_MAX;
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_PDS_GET_XTRA_PARAMS;
+ sProtocolBuffer rsp = SendSimple( eQMI_SVC_PDS, 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_PDS_RSP, msgID, 18 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ *pPreference = pf[0].mValue.mU32;
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ SetXTRANetwork (Public Method)
+
+DESCRIPTION:
+ This function sets the XTRA WWAN network preference
+
+PARAMETERS:
+ preference [ I ] - XTRA WWAN network preference
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::SetXTRANetwork( ULONG preference )
+{
+ WORD msgID = (WORD)eQMI_PDS_SET_XTRA_PARAMS;
+ std::vector <sDB2PackingInput> piv;
+
+ std::ostringstream tmp;
+ tmp << (UINT)preference;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_PDS_REQ, msgID, 18 );
+ 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_PDS, pRequest );
+}
+
+/*===========================================================================
+METHOD:
+ GetXTRAValidity (Public Method)
+
+DESCRIPTION:
+ This function returns the XTRA database validity period
+
+PARAMETERS:
+ pGPSWeek [ O ] - Starting GPS week of validity period
+ pGPSWeekOffset [ O ] - Starting GPS week offset (minutes) of validity period
+ pDuration [ O ] - Length of validity period (hours)
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetXTRAValidity(
+ USHORT * pGPSWeek,
+ USHORT * pGPSWeekOffset,
+ USHORT * pDuration )
+{
+ // Validate arguments
+ if (pGPSWeek == 0 || pGPSWeekOffset == 0 || pDuration == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ *pGPSWeek = USHRT_MAX;
+ *pGPSWeekOffset = USHRT_MAX;
+ *pDuration = USHRT_MAX;
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_PDS_GET_XTRA_PARAMS;
+ sProtocolBuffer rsp = SendSimple( eQMI_SVC_PDS, 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_PDS_RSP, msgID, 19 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 3)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ *pGPSWeek = pf[0].mValue.mU16;
+ *pGPSWeekOffset = pf[1].mValue.mU16;
+ *pDuration = pf[2].mValue.mU16;
+
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ ForceXTRADownload (Public Method)
+
+DESCRIPTION:
+ This function forces the XTRA database to be downloaded to the device
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::ForceXTRADownload()
+{
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_PDS_FORCE_XTRA_DL;
+ sProtocolBuffer rsp = SendSimple( eQMI_SVC_PDS, 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:
+ GetXTRADataState (Public Method)
+
+DESCRIPTION:
+ This function returns the XTRA data positioning state
+
+PARAMETERS:
+ pState [ O ] - XTRA data positioning state
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetXTRADataState( ULONG * pState )
+{
+ // Validate arguments
+ if (pState == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ *pState = ULONG_MAX;
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_PDS_GET_METHODS;
+ sProtocolBuffer rsp = SendSimple( eQMI_SVC_PDS, 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_PDS_RSP, msgID, 17 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ *pState = pf[0].mValue.mU32;
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ SetXTRADataState (Public Method)
+
+DESCRIPTION:
+ This function sets the XTRA data positioning state
+
+PARAMETERS:
+ state [ I ] - XTRA data positioning state
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::SetXTRADataState( ULONG state )
+{
+ WORD msgID = (WORD)eQMI_PDS_SET_METHODS;
+ std::vector <sDB2PackingInput> piv;
+
+ std::ostringstream tmp;
+ tmp << state;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_PDS_REQ, msgID, 17 );
+ 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 );
+ if (pRequest == 0)
+ {
+ return eGOBI_ERR_MEMORY;
+ }
+
+ // Send the QMI request, check result, and return
+ return SendAndCheckReturn( eQMI_SVC_PDS, pRequest );
+}
+
+/*===========================================================================
+METHOD:
+ GetXTRATimeState (Public Method)
+
+DESCRIPTION:
+ This function returns the XTRA time positioning state
+
+PARAMETERS:
+ pState [ O ] - XTRA time positioning state
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetXTRATimeState( ULONG * pState )
+{
+ // Validate arguments
+ if (pState == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ *pState = ULONG_MAX;
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_PDS_GET_METHODS;
+ sProtocolBuffer rsp = SendSimple( eQMI_SVC_PDS, 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_PDS_RSP, msgID, 16 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ *pState = pf[0].mValue.mU32;
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ SetXTRATimeState (Public Method)
+
+DESCRIPTION:
+ This function sets the XTRA time positioning state
+
+PARAMETERS:
+ state [ I ] - XTRA time positioning state
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::SetXTRATimeState( ULONG state )
+{
+ WORD msgID = (WORD)eQMI_PDS_SET_METHODS;
+ std::vector <sDB2PackingInput> piv;
+
+ std::ostringstream tmp;
+ tmp << state;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_PDS_REQ, msgID, 16 );
+ 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 );
+ if (pRequest == 0)
+ {
+ return eGOBI_ERR_MEMORY;
+ }
+
+ // Send the QMI request, check result, and return
+ return SendAndCheckReturn( eQMI_SVC_PDS, pRequest );
+}
+
+/*===========================================================================
+METHOD:
+ GetAGPSConfig (Public Method)
+
+DESCRIPTION:
+ This function returns the PDS AGPS configuration
+
+PARAMETERS:
+ pServerAddress [ O ] - IPv4 address of AGPS server
+ pServerPort [ O ] - Port number of AGPS server
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetAGPSConfig(
+ ULONG * pServerAddress,
+ ULONG * pServerPort )
+{
+ // Validate arguments
+ if (pServerAddress == 0 || pServerPort == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ *pServerAddress = ULONG_MAX;
+ *pServerPort = ULONG_MAX;
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_PDS_GET_AGPS_CONFIG;
+ sProtocolBuffer rsp = SendSimple( eQMI_SVC_PDS, 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_PDS_RSP, msgID, 16 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 5)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ ULONG ip4 = (ULONG)pf[0].mValue.mU8;
+ ULONG ip3 = (ULONG)pf[1].mValue.mU8 << 8;
+ ULONG ip2 = (ULONG)pf[2].mValue.mU8 << 16;
+ ULONG ip1 = (ULONG)pf[3].mValue.mU8 << 24;
+ *pServerAddress = (ip4 | ip3 | ip2 | ip1);
+ *pServerPort = pf[4].mValue.mU32;
+
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ SetAGPSConfig (Public Method)
+
+DESCRIPTION:
+ This function sets the PDS AGPS configuration
+
+PARAMETERS:
+ serverAddress [ I ] - IPv4 address of AGPS server
+ serverPort [ I ] - Port number of AGPS server
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::SetAGPSConfig(
+ ULONG serverAddress,
+ ULONG serverPort )
+{
+ WORD msgID = (WORD)eQMI_PDS_SET_AGPS_CONFIG;
+ std::vector <sDB2PackingInput> piv;
+
+ ULONG ip4 = (serverAddress & 0x000000FF);
+ ULONG ip3 = (serverAddress & 0x0000FF00) >> 8;
+ ULONG ip2 = (serverAddress & 0x00FF0000) >> 16;
+ ULONG ip1 = (serverAddress & 0xFF000000) >> 24;
+
+
+ // "%u %u %u %u %u"
+ std::ostringstream tmp;
+ tmp << (UINT)ip4 << " " << (UINT)ip3 << " " << (UINT)ip2
+ << " " << (UINT)ip1 << " " << (UINT)serverPort;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_PDS_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_PDS, pRequest );
+}
+
+/*===========================================================================
+METHOD:
+ GetServiceAutomaticTracking (Public Method)
+
+DESCRIPTION:
+ This function returns the automatic tracking state for the service
+
+PARAMETERS:
+ pbAuto [ O ] - Automatic tracking session started for service?
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetServiceAutomaticTracking( ULONG * pbAuto )
+{
+ // Validate arguments
+ if (pbAuto == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_PDS_GET_SVC_AUTOTRACK;
+ sProtocolBuffer rsp = SendSimple( eQMI_SVC_PDS, 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_PDS_RSP, msgID, 1 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ *pbAuto = pf[0].mValue.mU32;
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ SetServiceAutomaticTracking (Public Method)
+
+DESCRIPTION:
+ This function sets the automatic tracking state for the service
+
+PARAMETERS:
+ pbAuto [ I ] - Start automatic tracking session for service?
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::SetServiceAutomaticTracking( ULONG bAuto )
+{
+ WORD msgID = (WORD)eQMI_PDS_SET_SVC_AUTOTRACK;
+ std::vector <sDB2PackingInput> piv;
+
+ std::ostringstream tmp;
+ tmp << (ULONG)(bAuto != 0);
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_PDS_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_PDS, pRequest );
+}
+
+/*===========================================================================
+METHOD:
+ GetPortAutomaticTracking (Public Method)
+
+DESCRIPTION:
+ This function returns the automatic tracking configuration for the NMEA
+ COM port
+
+PARAMETERS:
+ pbAuto [ O ] - Automatic tracking enabled for NMEA COM port?
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetPortAutomaticTracking( ULONG * pbAuto )
+{
+ // Validate arguments
+ if (pbAuto == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_PDS_GET_COM_AUTOTRACK;
+ sProtocolBuffer rsp = SendSimple( eQMI_SVC_PDS, 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_PDS_RSP, msgID, 1 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ *pbAuto = pf[0].mValue.mU32;
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ SetPortAutomaticTracking (Public Method)
+
+DESCRIPTION:
+ This function sets the automatic tracking configuration for the NMEA
+ COM port
+
+PARAMETERS:
+ pbAuto [ I ] - Enable automatic tracking for NMEA COM port?
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::SetPortAutomaticTracking( ULONG bAuto )
+{
+ WORD msgID = (WORD)eQMI_PDS_SET_COM_AUTOTRACK;
+ std::vector <sDB2PackingInput> piv;
+
+ std::ostringstream tmp;
+ tmp << (ULONG)(bAuto != 0);
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_PDS_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_PDS, pRequest );
+}
+
+/*===========================================================================
+METHOD:
+ ResetPDSData (Public Method)
+
+DESCRIPTION:
+ This function resets the specified PDS data
+
+PARAMETERS:
+ pGPSDataMask [ I ] - Bitmask of GPS data to clear (optional)
+ pCellDataMask [ I ] - Bitmask of cell data to clear (optional)
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::ResetPDSData(
+ ULONG * pGPSDataMask,
+ ULONG * pCellDataMask )
+{
+ // Validate arguments (one must be present)
+ if (pGPSDataMask == 0 && pCellDataMask == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ WORD msgID = (WORD)eQMI_PDS_RESET_DATA;
+ std::vector <sDB2PackingInput> piv;
+
+ if (pGPSDataMask != 0)
+ {
+ ULONG mask = *pGPSDataMask;
+
+ // Note that we are being lazy here by specifying more arguments
+ // than the DB description defines; that will not cause a problem
+ // and we don't want to have to update this code should more bits
+ // be defined
+ std::ostringstream tmp;
+ for (ULONG b = 0; b < 32; b++)
+ {
+ ULONG bit = mask & 0x00000001;
+ mask = mask >> 1;
+
+ tmp << bit << " ";
+ }
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_PDS_REQ, msgID, 16 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ if (pCellDataMask != 0)
+ {
+ ULONG mask = *pCellDataMask;
+
+ std::ostringstream tmp;
+ for (ULONG b = 0; b < 32; b++)
+ {
+ ULONG bit = mask & 0x00000001;
+ mask = mask >> 1;
+
+ tmp << bit << " ";
+ }
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_PDS_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_PDS, pRequest );
+}
diff --git a/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreRMS.cpp b/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreRMS.cpp
new file mode 100755
index 0000000..b8c3037
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreRMS.cpp
@@ -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 );
+}
+
diff --git a/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreSMS.cpp b/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreSMS.cpp
new file mode 100755
index 0000000..789280d
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreSMS.cpp
@@ -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 );
+}
diff --git a/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreUIM.cpp b/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreUIM.cpp
new file mode 100755
index 0000000..e293d22
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreUIM.cpp
@@ -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;
+}
diff --git a/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreWDS.cpp b/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreWDS.cpp
new file mode 100755
index 0000000..9a6677d
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Shared/GobiQMICoreWDS.cpp
@@ -0,0 +1,2804 @@
+/*===========================================================================
+FILE:
+ GobiQMICoreWDS.cpp
+
+DESCRIPTION:
+ QUALCOMM Gobi QMI Based API Core (WDS 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:
+ GetSessionState (Public Method)
+
+DESCRIPTION:
+ This function returns the state of the current packet data session
+
+PARAMETERS:
+ pState [ O ] - State of the current packet session
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetSessionState( ULONG * pState )
+{
+ // Validate arguments
+ if (pState == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_WDS_GET_PKT_STATUS;
+ sProtocolBuffer rsp = SendSimple( eQMI_SVC_WDS, 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_WDS_RSP, msgID, 1 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ // Populate the state
+ *pState = pf[0].mValue.mU32;
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ GetSessionDuration (Public Method)
+
+DESCRIPTION:
+ This function returns the duration of the current packet data session
+
+PARAMETERS:
+ pDuration [ O ] - Duration of the current packet session
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetSessionDuration( ULONGLONG * pDuration )
+{
+ // Validate arguments
+ if (pDuration == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_WDS_GET_DURATION;
+ sProtocolBuffer rsp = SendSimple( eQMI_SVC_WDS, 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_WDS_RSP, msgID, 1 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ // Populate the state
+ *pDuration = pf[0].mValue.mU64;
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ GetSessionDurations (Public Method)
+
+DESCRIPTION:
+ This function returns the the active/total durations of the current
+ packet data session
+
+PARAMETERS:
+ pActiveDuration [ O ] - Active duration of the current packet session
+ pTotalDuration [ O ] - Total duration of the current packet session
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetSessionDurations(
+ ULONGLONG * pActiveDuration,
+ ULONGLONG * pTotalDuration )
+{
+ // Validate arguments
+ if (pActiveDuration == 0 || pTotalDuration == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_WDS_GET_DURATION;
+ sProtocolBuffer rsp = SendSimple( eQMI_SVC_WDS, 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_WDS_RSP, msgID, 1 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ // Populate the total duration
+ *pTotalDuration = pf[0].mValue.mU64;
+
+ // Parse the TLV we want (by DB key)
+ tlvKey = sProtocolEntityKey( eDB2_ET_QMI_WDS_RSP, msgID, 17 );
+ pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ // Populate the active duration
+ *pActiveDuration = pf[0].mValue.mU64;
+
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ GetDormancyState (Public Method)
+
+DESCRIPTION:
+ This function returns the dormancy state of the current packet
+ data session (when connected)
+
+PARAMETERS:
+ pState [ O ] - Dormancy state of the current packet session
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetDormancyState( ULONG * pState )
+{
+ // Validate arguments
+ if (pState == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_WDS_GET_DORMANCY;
+ sProtocolBuffer rsp = SendSimple( eQMI_SVC_WDS, 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_WDS_RSP, msgID, 1 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ // Populate the state
+ *pState = pf[0].mValue.mU32;
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ GetEnhancedAutoconnect (Public Method)
+
+DESCRIPTION:
+ This function returns the current autoconnect data session setting
+
+PARAMETERS:
+ pSetting [ O ] - NDIS autoconnect setting
+ pRoamSetting [ O ] - NDIS autoconnect roam setting
+
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetEnhancedAutoconnect(
+ ULONG * pSetting,
+ ULONG * pRoamSetting )
+{
+ // Validate arguments
+ if (pSetting == 0 || pRoamSetting == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ *pSetting = ULONG_MAX;
+ *pRoamSetting = ULONG_MAX;
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_WDS_GET_AUTOCONNECT;
+ sProtocolBuffer rsp = SendSimple( eQMI_SVC_WDS, 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();
+
+ sProtocolEntityKey tlvKey( eDB2_ET_QMI_WDS_RSP, msgID, 1 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ *pSetting = (ULONG)pf[0].mValue.mU32;
+
+ // Parse the TLV we want (by DB key)
+ tlvKey = sProtocolEntityKey( eDB2_ET_QMI_WDS_RSP, msgID, 16 );
+ pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() > 0)
+ {
+ *pRoamSetting = (ULONG)pf[0].mValue.mU32;
+ }
+
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ SetEnhancedAutoconnect (Public Method)
+
+DESCRIPTION:
+ This function sets the autoconnect data session setting
+
+PARAMETERS:
+ setting [ I ] - NDIS autoconnect setting
+ pRoamSetting [ I ] - (Optional) NDIS autoconnect roam setting
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::SetEnhancedAutoconnect(
+ ULONG setting,
+ ULONG * pRoamSetting )
+{
+ WORD msgID = (WORD)eQMI_WDS_SET_AUTOCONNECT;
+ std::vector <sDB2PackingInput> piv;
+
+ // "%u"
+ std::ostringstream tmp;
+ tmp << setting;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 1 );
+ sDB2PackingInput pi( pek, tmp.str().c_str() );
+ piv.push_back( pi );
+
+ if (pRoamSetting != 0)
+ {
+ std::ostringstream tmp2;
+ tmp2 << *pRoamSetting;
+
+ sProtocolEntityKey pek1( eDB2_ET_QMI_WDS_REQ, msgID, 16 );
+ sDB2PackingInput pi1( pek1, tmp2.str().c_str() );
+ piv.push_back( pi1 );
+ }
+
+ ULONG to = 5000;
+ if (setting == 1)
+ {
+ // Connections can take a long time
+ to = 300000;
+ }
+
+ // 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_WDS, pRequest, to );
+}
+
+/*===========================================================================
+METHOD:
+ SetDefaultProfile (Public Method)
+
+DESCRIPTION:
+ This function writes the default profile settings to the device, the
+ default profile is used during autoconnect
+
+PARAMETERS:
+ profileType [ I ] - Profile type being written
+ pPDPType [ I ] - (Optional) PDP type
+ pIPAddress [ I ] - (Optional) Preferred assigned IPv4 address
+ pPrimaryDNS [ I ] - (Optional) Primary DNS IPv4 address
+ pSecondaryDNS [ I ] - (Optional) Secondary DNS IPv4 address
+ pAuthentication [ I ] - (Optional) Authentication algorithm bitmap
+ pName [ I ] - (Optional) The profile name or description
+ pAPNName [ I ] - (Optional) Access point name
+ pUsername [ I ] - (Optional) Username used during authentication
+ pPassword [ I ] - (Optional) Password used during authentication
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::SetDefaultProfile(
+ ULONG profileType,
+ ULONG * pPDPType,
+ ULONG * pIPAddress,
+ ULONG * pPrimaryDNS,
+ ULONG * pSecondaryDNS,
+ ULONG * pAuthentication,
+ CHAR * pName,
+ CHAR * pAPNName,
+ CHAR * pUsername,
+ CHAR * pPassword )
+{
+ WORD msgID = (WORD)eQMI_WDS_MODIFY_PROFILE;
+ std::vector <sDB2PackingInput> piv;
+
+ // "%u 1"
+ std::ostringstream tmp;
+ tmp << (UINT)profileType << " 1";
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 1 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
+ piv.push_back( pi );
+
+ if (pName != 0)
+ {
+ std::ostringstream tmp2;
+ if (pName[0] != 0)
+ {
+ tmp2 << "\"" << pName << "\"";
+ }
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 16 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp2.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ if (pPDPType != 0)
+ {
+ // "%u"
+ std::ostringstream tmp2;
+ tmp2 << (UINT)*pPDPType;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 17 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp2.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ if (pAPNName != 0)
+ {
+ std::ostringstream tmp2;
+ if (pAPNName[0] != 0)
+ {
+ tmp2 << "\"" << pAPNName << "\"";
+ }
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 20 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp2.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ if (pPrimaryDNS != 0)
+ {
+ ULONG ip4 = (*pPrimaryDNS & 0x000000FF);
+ ULONG ip3 = (*pPrimaryDNS & 0x0000FF00) >> 8;
+ ULONG ip2 = (*pPrimaryDNS & 0x00FF0000) >> 16;
+ ULONG ip1 = (*pPrimaryDNS & 0xFF000000) >> 24;
+
+ // "%u %u %u %u"
+ std::ostringstream tmp2;
+ tmp2 << (UINT)ip4 << " " << (UINT)ip3 << " " << (UINT)ip2
+ << " " << (UINT)ip1;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 21 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp2.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ if (pSecondaryDNS != 0)
+ {
+ ULONG ip4 = (*pSecondaryDNS & 0x000000FF);
+ ULONG ip3 = (*pSecondaryDNS & 0x0000FF00) >> 8;
+ ULONG ip2 = (*pSecondaryDNS & 0x00FF0000) >> 16;
+ ULONG ip1 = (*pSecondaryDNS & 0xFF000000) >> 24;
+
+ // "%u %u %u %u"
+ std::ostringstream tmp2;
+ tmp2 << (UINT)ip4 << " " << (UINT)ip3 << " " << (UINT)ip2
+ << " " << (UINT)ip1;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 22 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp2.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ if (pUsername != 0)
+ {
+ std::ostringstream tmp2;
+ if (pUsername[0] != 0)
+ {
+ tmp2 << "\"" << pUsername << "\"";
+ }
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 27 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp2.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ if (pPassword != 0)
+ {
+ std::ostringstream tmp2;
+ if (pPassword[0] != 0)
+ {
+ tmp2 << "\"" << pPassword << "\"";
+ }
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 28 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp2.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ if (pAuthentication != 0)
+ {
+ ULONG pap = *pAuthentication & 0x00000001;
+ ULONG chap = *pAuthentication & 0x00000002;
+
+ // "%u %u"
+ std::ostringstream tmp2;
+ tmp2 << (UINT)pap << " " << (UINT)chap;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 29 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp2.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ if (pIPAddress != 0)
+ {
+ ULONG ip4 = (*pIPAddress & 0x000000FF);
+ ULONG ip3 = (*pIPAddress & 0x0000FF00) >> 8;
+ ULONG ip2 = (*pIPAddress & 0x00FF0000) >> 16;
+ ULONG ip1 = (*pIPAddress & 0xFF000000) >> 24;
+
+ // "%u %u %u %u"
+ std::ostringstream tmp2;
+ tmp2 << (UINT)ip4 << " " << (UINT)ip3 << " " << (UINT)ip2
+ << " " << (UINT)ip1;
+
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 30 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp2.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ // We need to be doing something here (beyond profile type)
+ if (piv.size() <= 1)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ // Pack up and send the QMI request
+ const cCoreDatabase & db = GetDatabase();
+ sSharedBuffer * pRequest = DB2PackQMIBuffer( db, piv );
+
+ // Send the QMI request, check result, and return
+ return SendAndCheckReturn( eQMI_SVC_WDS, pRequest );
+}
+
+/*===========================================================================
+METHOD:
+ GetDefaultProfile (Public Method)
+
+DESCRIPTION:
+ This function reads the default profile settings from the device, the
+ default profile is used during autoconnect
+
+PARAMETERS:
+ profileType [ I ] - Profile type being read
+ pPDPType [ O ] - PDP type
+ pIPAddress [ O ] - Preferred assigned IPv4 address
+ pPrimaryDNS [ O ] - Primary DNS IPv4 address
+ pSecondaryDNS [ O ] - Secondary DNS IPv4 address
+ pAuthentication [ O ] - Authentication algorithm bitmap
+ nameSize [ I ] - The maximum number of characters (including
+ NULL terminator) that the profile name array
+ can contain
+ pName [ O ] - The profile name or description
+ apnSize [ I ] - The maximum number of characters (including
+ NULL terminator) that the APN name array
+ can contain
+ pAPNName [ O ] - Access point name represented as a NULL
+ terminated string (empty string returned when
+ unknown)
+ userSize [ I ] - The maximum number of characters (including
+ NULL terminator) that the username array
+ can contain
+ pUsername [ O ] - Username used during authentication
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetDefaultProfile(
+ ULONG profileType,
+ ULONG * pPDPType,
+ ULONG * pIPAddress,
+ ULONG * pPrimaryDNS,
+ ULONG * pSecondaryDNS,
+ ULONG * pAuthentication,
+ BYTE nameSize,
+ CHAR * pName,
+ BYTE apnSize,
+ CHAR * pAPNName,
+ BYTE userSize,
+ CHAR * pUsername )
+{
+ // Validate arguments
+ if ( (pPDPType == 0)
+ || (pIPAddress == 0)
+ || (pPrimaryDNS == 0)
+ || (pSecondaryDNS == 0)
+ || (pAuthentication == 0)
+ || (nameSize == 0)
+ || (pName == 0)
+ || (apnSize == 0)
+ || (pAPNName == 0)
+ || (userSize == 0)
+ || (pUsername == 0) )
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ *pPDPType = ULONG_MAX;
+ *pIPAddress = ULONG_MAX;
+ *pPrimaryDNS = ULONG_MAX;
+ *pSecondaryDNS = ULONG_MAX;
+ *pAuthentication = ULONG_MAX;
+ pName[0] = 0;
+ pAPNName[0] = 0;
+ pUsername[0] = 0;
+
+ WORD msgID = (WORD)eQMI_WDS_GET_DEFAULTS;
+ std::vector <sDB2PackingInput> piv;
+
+ // "%u 0"
+ std::ostringstream tmp;
+ tmp << (UINT)profileType << " 0";
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_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_WDS, 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 );
+ }
+
+ // Prepare TLVs for parsing
+ std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiRsp );
+
+ sProtocolEntityKey tlvKey( eDB2_ET_QMI_WDS_RSP, msgID, 16 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() >= 1)
+ {
+ LONG strLen = pf[0].mValueString.size();
+ if (strLen <= 0)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ // Space to perform the copy?
+ if (nameSize < strLen + 1)
+ {
+ return eGOBI_ERR_BUFFER_SZ;
+ }
+
+ memcpy( (LPVOID)pName, (LPCSTR)pf[0].mValueString.c_str(), strLen );
+ pName[strLen] = 0;
+ }
+
+ tlvKey = sProtocolEntityKey( eDB2_ET_QMI_WDS_RSP, msgID, 17 );
+ pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() >= 1)
+ {
+ *pPDPType = pf[0].mValue.mU32;
+ }
+
+ tlvKey = sProtocolEntityKey( eDB2_ET_QMI_WDS_RSP, msgID, 20 );
+ pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() >= 1)
+ {
+ LONG strLen = pf[0].mValueString.size();
+ if (strLen <= 0)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ // Space to perform the copy?
+ if (apnSize < strLen + 1)
+ {
+ return eGOBI_ERR_BUFFER_SZ;
+ }
+
+ memcpy( (LPVOID)pAPNName, (LPCSTR)pf[0].mValueString.c_str(), strLen );
+ pAPNName[strLen] = 0;
+ }
+
+ tlvKey = sProtocolEntityKey( eDB2_ET_QMI_WDS_RSP, msgID, 21 );
+ pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() >= 4)
+ {
+ ULONG ip4 = (ULONG)pf[0].mValue.mU8;
+ ULONG ip3 = (ULONG)pf[1].mValue.mU8 << 8;
+ ULONG ip2 = (ULONG)pf[2].mValue.mU8 << 16;
+ ULONG ip1 = (ULONG)pf[3].mValue.mU8 << 24;
+ *pPrimaryDNS = (ip4 | ip3 | ip2 | ip1);
+ }
+
+ tlvKey = sProtocolEntityKey( eDB2_ET_QMI_WDS_RSP, msgID, 22 );
+ pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() >= 4)
+ {
+ ULONG ip4 = (ULONG)pf[0].mValue.mU8;
+ ULONG ip3 = (ULONG)pf[1].mValue.mU8 << 8;
+ ULONG ip2 = (ULONG)pf[2].mValue.mU8 << 16;
+ ULONG ip1 = (ULONG)pf[3].mValue.mU8 << 24;
+ *pSecondaryDNS = (ip4 | ip3 | ip2 | ip1);
+ }
+
+ tlvKey = sProtocolEntityKey( eDB2_ET_QMI_WDS_RSP, msgID, 27 );
+ pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() >= 1)
+ {
+ LONG strLen = pf[0].mValueString.size();
+ if (strLen <= 0)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ // Space to perform the copy?
+ if (userSize < strLen + 1)
+ {
+ return eGOBI_ERR_BUFFER_SZ;
+ }
+
+ memcpy( (LPVOID)pUsername, (LPCSTR)pf[0].mValueString.c_str(), strLen );
+ pUsername[strLen] = 0;
+ }
+
+ tlvKey = sProtocolEntityKey( eDB2_ET_QMI_WDS_RSP, msgID, 29 );
+ pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() >= 2)
+ {
+ ULONG pap = (ULONG)pf[0].mValue.mU8;
+ ULONG chap = (ULONG)pf[1].mValue.mU8 << 1;
+
+ *pAuthentication = (pap | chap);
+ }
+
+ tlvKey = sProtocolEntityKey( eDB2_ET_QMI_WDS_RSP, msgID, 30 );
+ pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() >= 4)
+ {
+ ULONG ip4 = (ULONG)pf[0].mValue.mU8;
+ ULONG ip3 = (ULONG)pf[1].mValue.mU8 << 8;
+ ULONG ip2 = (ULONG)pf[2].mValue.mU8 << 16;
+ ULONG ip1 = (ULONG)pf[3].mValue.mU8 << 24;
+ *pIPAddress = (ip4 | ip3 | ip2 | ip1);
+ }
+
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ StartDataSession (Public Method)
+
+DESCRIPTION:
+ This function activates a packet data session
+
+PARAMETERS:
+ pTechnology [ I ] - (Optional) Technology bitmap
+ pPrimaryDNS [ I ] - (Optional) Primary DNS IPv4 address
+ pSecondaryDNS [ I ] - (Optional) Secondary DNS IPv4 address
+ pPrimaryNBNS [ I ] - (Optional) Primary NetBIOS NS IPv4 address
+ pSecondaryNBNS [ I ] - (Optional) Secondary NetBIOS NS IPv4 address
+ pAPNName [ I ] - (Optional) Access point name
+ pIPAddress [ I ] - (Optional) Preferred assigned IPv4 address
+ pAuthentication [ I ] - (Optional) Authentication algorithm bitmap
+ pUsername [ I ] - (Optional) Username used during authentication
+ pPassword [ I ] - (Optional) Password used during authentication
+ pSessionId [ O ] - The assigned session ID
+ pFailureReason [ O ] - Upon call failure the failure reason
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::StartDataSession(
+ ULONG * pTechnology,
+ ULONG * pPrimaryDNS,
+ ULONG * pSecondaryDNS,
+ ULONG * pPrimaryNBNS,
+ ULONG * pSecondaryNBNS,
+ CHAR * pAPNName,
+ ULONG * pIPAddress,
+ ULONG * pAuthentication,
+ CHAR * pUsername,
+ CHAR * pPassword,
+ ULONG * pSessionId,
+ ULONG * pFailureReason )
+{
+ *pFailureReason = (ULONG)eQMI_CALL_END_REASON_UNSPECIFIED;
+
+ // Validate arguments
+ if (pSessionId == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ WORD msgID = (WORD)eQMI_WDS_START_NET;
+ std::vector <sDB2PackingInput> piv;
+
+ if (pTechnology != 0)
+ {
+ ULONG umts = *pTechnology & 0x00000001;
+ ULONG cdma = *pTechnology & 0x00000002;
+
+ // "%u %u"
+ std::ostringstream tmp;
+ tmp << (UINT)umts << " " << (UINT)cdma;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 48 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ if (pPrimaryDNS != 0)
+ {
+ ULONG ip4 = (*pPrimaryDNS & 0x000000FF);
+ ULONG ip3 = (*pPrimaryDNS & 0x0000FF00) >> 8;
+ ULONG ip2 = (*pPrimaryDNS & 0x00FF0000) >> 16;
+ ULONG ip1 = (*pPrimaryDNS & 0xFF000000) >> 24;
+
+ // "%u %u %u %u"
+ std::ostringstream tmp;
+ tmp << (UINT)ip4 << " " << (UINT)ip3 << " " << (UINT)ip2
+ << " " << (UINT)ip1;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 16 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ if (pSecondaryDNS != 0)
+ {
+ ULONG ip4 = (*pSecondaryDNS & 0x000000FF);
+ ULONG ip3 = (*pSecondaryDNS & 0x0000FF00) >> 8;
+ ULONG ip2 = (*pSecondaryDNS & 0x00FF0000) >> 16;
+ ULONG ip1 = (*pSecondaryDNS & 0xFF000000) >> 24;
+
+ // "%u %u %u %u"
+ std::ostringstream tmp;
+ tmp << (UINT)ip4 << " " << (UINT)ip3 << " " << (UINT)ip2
+ << " " << (UINT)ip1;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 17 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ if (pPrimaryNBNS != 0)
+ {
+ ULONG ip4 = (*pPrimaryNBNS & 0x000000FF);
+ ULONG ip3 = (*pPrimaryNBNS & 0x0000FF00) >> 8;
+ ULONG ip2 = (*pPrimaryNBNS & 0x00FF0000) >> 16;
+ ULONG ip1 = (*pPrimaryNBNS & 0xFF000000) >> 24;
+
+ // "%u %u %u %u"
+ std::ostringstream tmp;
+ tmp << (UINT)ip4 << " " << (UINT)ip3 << " " << (UINT)ip2
+ << " " << (UINT)ip1;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 18 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ if (pSecondaryNBNS != 0)
+ {
+ ULONG ip4 = (*pSecondaryNBNS & 0x000000FF);
+ ULONG ip3 = (*pSecondaryNBNS & 0x0000FF00) >> 8;
+ ULONG ip2 = (*pSecondaryNBNS & 0x00FF0000) >> 16;
+ ULONG ip1 = (*pSecondaryNBNS & 0xFF000000) >> 24;
+
+ // "%u %u %u %u"
+ std::ostringstream tmp;
+ tmp << (UINT)ip4 << " " << (UINT)ip3 << " " << (UINT)ip2
+ << " " << (UINT)ip1;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 19 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ if (pAPNName != 0)
+ {
+ std::ostringstream tmp;
+ if (pAPNName[0] != 0)
+ {
+ tmp << "\"" << pAPNName << "\"";
+ }
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 20 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ if (pIPAddress != 0)
+ {
+ ULONG ip4 = (*pIPAddress & 0x000000FF);
+ ULONG ip3 = (*pIPAddress & 0x0000FF00) >> 8;
+ ULONG ip2 = (*pIPAddress & 0x00FF0000) >> 16;
+ ULONG ip1 = (*pIPAddress & 0xFF000000) >> 24;
+
+ // "%u %u %u %u"
+ std::ostringstream tmp;
+ tmp << (UINT)ip4 << " " << (UINT)ip3 << " " << (UINT)ip2
+ << " " << (UINT)ip1;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 21 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ if (pAuthentication != 0)
+ {
+ ULONG pap = *pAuthentication & 0x00000001;
+ ULONG chap = *pAuthentication & 0x00000002;
+
+ // "%u %u"
+ std::ostringstream tmp;
+ tmp << (UINT)pap << " " << (UINT)chap;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 22 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ if (pUsername != 0)
+ {
+ std::ostringstream tmp;
+ if (pUsername[0] != 0)
+ {
+ tmp << "\"" << pUsername << "\"";
+ }
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 23 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ if (pPassword != 0)
+ {
+ std::ostringstream tmp;
+ if (pPassword[0] != 0)
+ {
+ tmp << "\"" << pPassword << "\"";
+ }
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 24 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ sProtocolBuffer rsp;
+ if (piv.size() > 0)
+ {
+ // Pack up and send the QMI request
+ const cCoreDatabase & db = GetDatabase();
+ sSharedBuffer * pRequest = DB2PackQMIBuffer( db, piv );
+ if (pRequest == 0)
+ {
+ return eGOBI_ERR_MEMORY;
+ }
+ else
+ {
+ rsp = Send( eQMI_SVC_WDS, pRequest, 300000 );
+ }
+ }
+ else
+ {
+ // Generate and send the QMI request
+ rsp = SendSimple( eQMI_SVC_WDS, msgID, 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 );
+ const cCoreDatabase & db = GetDatabase();
+
+ // Parse the TLV we want (by DB key)
+ sProtocolEntityKey tlvKey( eDB2_ET_QMI_WDS_RSP, msgID, 16 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() >= 1)
+ {
+ *pFailureReason = pf[0].mValue.mU32;
+ }
+
+ 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_WDS_RSP, msgID, 1 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ // Populate the session ID
+ *pSessionId = pf[0].mValue.mU32;
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ CancelDataSession (Public Method)
+
+DESCRIPTION:
+ Cancel an in-progress packet data session activation
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::CancelDataSession()
+{
+ if (mLastNetStartID == (WORD)INVALID_QMI_TRANSACTION_ID)
+ {
+ return eGOBI_ERR_NO_CANCELABLE_OP;
+ }
+
+ WORD msgID = (WORD)eQMI_WDS_ABORT;
+ std::vector <sDB2PackingInput> piv;
+
+ // %hu
+ std::ostringstream tmp;
+ tmp << mLastNetStartID;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_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
+ mLastNetStartID = (WORD)INVALID_QMI_TRANSACTION_ID;
+ return SendAndCheckReturn( eQMI_SVC_WDS, pRequest, 60000 );
+}
+
+/*===========================================================================
+METHOD:
+ StopDataSession (Public Method)
+
+DESCRIPTION:
+ This function stops the current data session
+
+PARAMETERS:
+ sessionId [ I ] - The ID of the session to terminate
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::StopDataSession( ULONG sessionId )
+{
+ WORD msgID = (WORD)eQMI_WDS_STOP_NET;
+ std::vector <sDB2PackingInput> piv;
+
+ // "%u"
+ std::ostringstream tmp;
+ tmp << (UINT)sessionId;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_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_WDS, pRequest, 60000 );
+}
+
+/*===========================================================================
+METHOD:
+ GetIPAddress
+
+DESCRIPTION:
+ This function returns the current packet data session IP address
+
+PARAMETERS:
+ pIPAddress [ I ] - Assigned IPv4 address
+
+RETURN VALUE:
+ ULONG - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetIPAddress( ULONG * pIPAddress )
+{
+ // Validate arguments
+ if (pIPAddress == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ // Assume failure
+ *pIPAddress = ULONG_MAX;
+
+ WORD msgID = (WORD)eQMI_WDS_GET_SETTINGS;
+ std::vector <sDB2PackingInput> piv;
+
+ std::string tmp = "0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0";
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 16 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp.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_WDS, 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 );
+ }
+
+ // Prepare TLVs for parsing
+ std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiRsp );
+
+ // Parse the TLVs we want (IP address)
+ sProtocolEntityKey tlvKey( eDB2_ET_QMI_WDS_RSP, msgID, 30 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 4)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ ULONG ip4 = (ULONG)pf[0].mValue.mU8;
+ ULONG ip3 = (ULONG)pf[1].mValue.mU8 << 8;
+ ULONG ip2 = (ULONG)pf[2].mValue.mU8 << 16;
+ ULONG ip1 = (ULONG)pf[3].mValue.mU8 << 24;
+ *pIPAddress = (ip4 | ip3 | ip2 | ip1);
+
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ GetConnectionRate (Public Method)
+
+DESCRIPTION:
+ This function returns connection rate information for the packet data
+ connection
+
+PARAMETERS:
+ pCurrentChannelTXRate [ O ] - Current channel TX rate (bps)
+ pCurrentChannelRXRate [ O ] - Current channel RX rate (bps)
+ pMaxChannelTXRate [ O ] - Maximum channel TX rate (bps)
+ pMaxChannelRXRate [ O ] - Maximum channel RX rate (bps)
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetConnectionRate(
+ ULONG * pCurrentChannelTXRate,
+ ULONG * pCurrentChannelRXRate,
+ ULONG * pMaxChannelTXRate,
+ ULONG * pMaxChannelRXRate )
+{
+ // Validate arguments
+ if ( (pCurrentChannelTXRate == 0)
+ || (pCurrentChannelRXRate == 0)
+ || (pMaxChannelTXRate == 0)
+ || (pMaxChannelRXRate == 0) )
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_WDS_GET_RATES;
+ sProtocolBuffer rsp = SendSimple( eQMI_SVC_WDS, 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_WDS_RSP, msgID, 1 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 4)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ // Populate the rates
+ *pCurrentChannelTXRate = pf[0].mValue.mU32;
+ *pCurrentChannelRXRate = pf[1].mValue.mU32;
+ *pMaxChannelTXRate = pf[2].mValue.mU32;
+ *pMaxChannelRXRate = pf[3].mValue.mU32;
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ GetPacketStatus (Public Method)
+
+DESCRIPTION:
+ This function returns the packet data transfer statistics since the start
+ of the current packet data session
+
+PARAMETERS:
+ pTXPacketSuccesses [ O ] - Packets transmitted without error
+ pRXPacketSuccesses [ O ] - Packets received without error
+ pTXPacketErrors [ O ] - Outgoing packets with framing errors
+ pRXPacketErrors [ O ] - Incoming packets with framing errors
+ pTXPacketOverflows [ O ] - Packets dropped because TX buffer overflowed
+ pRXPacketOverflows [ O ] - Packets dropped because RX buffer overflowed
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetPacketStatus(
+ ULONG * pTXPacketSuccesses,
+ ULONG * pRXPacketSuccesses,
+ ULONG * pTXPacketErrors,
+ ULONG * pRXPacketErrors,
+ ULONG * pTXPacketOverflows,
+ ULONG * pRXPacketOverflows )
+{
+ // Validate arguments
+ if ( (pTXPacketSuccesses == 0)
+ || (pRXPacketSuccesses == 0)
+ || (pTXPacketErrors == 0)
+ || (pRXPacketErrors == 0)
+ || (pTXPacketOverflows == 0)
+ || (pRXPacketOverflows == 0) )
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ WORD msgID = (WORD)eQMI_WDS_GET_STATISTICS;
+ std::vector <sDB2PackingInput> piv;
+
+ std::string tmp = "1 1 1 1 1 1 0 0";
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 1 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp.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_WDS, 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 );
+ }
+
+ // Prepare TLVs for parsing
+ std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiRsp );
+
+ // Parse the TLVs we want (by DB key)
+ sProtocolEntityKey tlvKey1( eDB2_ET_QMI_WDS_RSP, msgID, 16 );
+ cDataParser::tParsedFields pf1 = ParseTLV( db, rsp, tlvs, tlvKey1 );
+ if (pf1.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ sProtocolEntityKey tlvKey2( eDB2_ET_QMI_WDS_RSP, msgID, 17 );
+ cDataParser::tParsedFields pf2 = ParseTLV( db, rsp, tlvs, tlvKey2 );
+ if (pf2.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ sProtocolEntityKey tlvKey3( eDB2_ET_QMI_WDS_RSP, msgID, 18 );
+ cDataParser::tParsedFields pf3 = ParseTLV( db, rsp, tlvs, tlvKey3 );
+ if (pf3.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ sProtocolEntityKey tlvKey4( eDB2_ET_QMI_WDS_RSP, msgID, 19 );
+ cDataParser::tParsedFields pf4 = ParseTLV( db, rsp, tlvs, tlvKey4 );
+ if (pf4.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ sProtocolEntityKey tlvKey5( eDB2_ET_QMI_WDS_RSP, msgID, 20 );
+ cDataParser::tParsedFields pf5 = ParseTLV( db, rsp, tlvs, tlvKey5 );
+ if (pf5.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ sProtocolEntityKey tlvKey6( eDB2_ET_QMI_WDS_RSP, msgID, 21 );
+ cDataParser::tParsedFields pf6 = ParseTLV( db, rsp, tlvs, tlvKey5 );
+ if (pf6.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ // Populate the statistics
+ *pTXPacketSuccesses = pf1[0].mValue.mU32;
+ *pRXPacketSuccesses = pf2[0].mValue.mU32;
+ *pTXPacketErrors = pf3[0].mValue.mU32;
+ *pRXPacketErrors = pf4[0].mValue.mU32;
+ *pTXPacketOverflows = pf5[0].mValue.mU32;
+ *pRXPacketOverflows = pf6[0].mValue.mU32;
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ GetByteTotals (Public Method)
+
+DESCRIPTION:
+ This function returns the RX/TX byte counts since the start of the
+ current packet data session
+
+PARAMETERS:
+ pTXTotalBytes [ O ] - Bytes transmitted without error
+ pRXTotalBytes [ O ] - Bytes received without error
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetByteTotals(
+ ULONGLONG * pTXTotalBytes,
+ ULONGLONG * pRXTotalBytes )
+{
+ // Validate arguments
+ if (pTXTotalBytes == 0 || pRXTotalBytes == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ WORD msgID = (WORD)eQMI_WDS_GET_STATISTICS;
+ std::vector <sDB2PackingInput> piv;
+
+ std::string tmp = "0 0 0 0 0 0 1 1";
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 1 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp.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_WDS, 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 );
+ }
+
+ // Prepare TLVs for parsing
+ std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiRsp );
+
+ sProtocolEntityKey tlvKey1( eDB2_ET_QMI_WDS_RSP, msgID, 25 );
+ cDataParser::tParsedFields pf1 = ParseTLV( db, rsp, tlvs, tlvKey1 );
+ if (pf1.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ sProtocolEntityKey tlvKey2( eDB2_ET_QMI_WDS_RSP, msgID, 26 );
+ cDataParser::tParsedFields pf2 = ParseTLV( db, rsp, tlvs, tlvKey2 );
+ if (pf2.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ // Populate the statistics
+ *pTXTotalBytes = pf1[0].mValue.mU64;
+ *pRXTotalBytes = pf2[0].mValue.mU64;
+
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ SetMobileIP (Public Method)
+
+DESCRIPTION:
+ This function sets the current mobile IP setting
+
+PARAMETERS:
+ mode [ I ] - Desired mobile IP setting
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::SetMobileIP( ULONG mode )
+{
+ WORD msgID = (WORD)eQMI_WDS_SET_MIP;
+ std::vector <sDB2PackingInput> piv;
+
+ // "%u"
+ std::ostringstream tmp;
+ tmp << (UINT)mode;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_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_WDS, pRequest );
+}
+
+/*===========================================================================
+METHOD:
+ GetMobileIP (Public Method)
+
+DESCRIPTION:
+ This function gets the current mobile IP setting
+
+PARAMETERS:
+ pMode [ I ] - Desired mobile IP setting
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetMobileIP( ULONG * pMode )
+{
+ // Validate arguments
+ if (pMode == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_WDS_GET_MIP;
+ sProtocolBuffer rsp = SendSimple( eQMI_SVC_WDS, 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_WDS_RSP, msgID, 1 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ // Populate the mode
+ *pMode = pf[0].mValue.mU32;
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ SetActiveMobileIPProfile (Public Method)
+
+DESCRIPTION:
+ This function sets the active mobile IP profile index
+
+PARAMETERS:
+ pSPC [ I ] - Six digit service programming code
+ index [ I ] - Desired mobile IP profile index
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::SetActiveMobileIPProfile(
+ CHAR * pSPC,
+ BYTE index )
+{
+ // Validate arguments
+ if (pSPC == 0 || pSPC[0] == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ std::string spc( pSPC );
+ if (spc.size() > 6)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ int nNonDigit = spc.find_first_not_of( "0123456789" );
+ std::string digitSPC = spc.substr( 0, nNonDigit );
+ if (digitSPC.size() != spc.size())
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ WORD msgID = (WORD)eQMI_WDS_SET_ACTIVE_MIP;
+ std::vector <sDB2PackingInput> piv;
+
+ // "%s %u"
+ std::ostringstream tmp;
+ tmp << spc << " " << (UINT)index;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_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_WDS, pRequest );
+}
+
+/*===========================================================================
+METHOD:
+ GetActiveMobileIPProfile (Public Method)
+
+DESCRIPTION:
+ This function gets the the active mobile IP profile index
+
+PARAMETERS:
+ pIndex [ O ] - Active mobile IP profile index
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetActiveMobileIPProfile( BYTE * pIndex )
+{
+ // Validate arguments
+ if (pIndex == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_WDS_GET_ACTIVE_MIP;
+ sProtocolBuffer rsp = SendSimple( eQMI_SVC_WDS, 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_WDS_RSP, msgID, 1 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ // Populate the index
+ *pIndex = pf[0].mValue.mU8;
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ SetMobileIPProfile (Public Method)
+
+DESCRIPTION:
+ This function sets the specified mobile IP profile settings
+
+PARAMETERS:
+ pSPC [ I ] - Six digit service programming code
+ index [ I ] - Mobile IP profile ID
+ pEnabled [ I ] - (Optional) Enable MIP profile?
+ pAddress [ I ] - (Optional) Home IPv4 address
+ pPrimaryHA [ I ] - (Optional) Primary home agent IPv4 address
+ pSecondaryHA [ I ] - (Optional) Secondary home agent IPv4 address
+ pRevTunneling [ I ] - (Optional) Enable reverse tunneling?
+ pNAI [ I ] - (Optional) Network access identifier string
+ pHASPI [ I ] - (Optional) HA security parameter index
+ pAAASPI [ I ] - (Optional) AAA security parameter index
+ pMNHA [ I ] - (Optional) MN-HA string
+ pMNAAA [ I ] - (Optional) MN-AAA string
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::SetMobileIPProfile(
+ CHAR * pSPC,
+ BYTE index,
+ BYTE * pEnabled,
+ ULONG * pAddress,
+ ULONG * pPrimaryHA,
+ ULONG * pSecondaryHA,
+ BYTE * pRevTunneling,
+ CHAR * pNAI,
+ ULONG * pHASPI,
+ ULONG * pAAASPI,
+ CHAR * pMNHA,
+ CHAR * pMNAAA )
+{
+ // Validate arguments
+ if (pSPC == 0 || pSPC[0] == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ std::string spc( pSPC );
+ if (spc.size() > 6)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ int nNonDigit = spc.find_first_not_of( "0123456789" );
+ std::string digitSPC = spc.substr( 0, nNonDigit );
+ if (digitSPC.size() != spc.size())
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ WORD msgID = (WORD)eQMI_WDS_SET_MIP_PROFILE;
+ std::vector <sDB2PackingInput> piv;
+
+ // "%s %u"
+ std::ostringstream tmp;
+ tmp << spc << " " << (UINT)index;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 1 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
+ piv.push_back( pi );
+
+ // Enabled flag provided?
+ if (pEnabled != 0)
+ {
+ // "%u"
+ std::ostringstream tmp2;
+ tmp2 << (UINT)(*pEnabled == 0 ? 0 : 1);
+
+ pek = sProtocolEntityKey( eDB2_ET_QMI_WDS_REQ, msgID, 16 );
+ pi = sDB2PackingInput( pek, (LPCSTR)tmp2.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ // Home address provided?
+ if (pAddress != 0)
+ {
+ ULONG ip4 = (*pAddress & 0x000000FF);
+ ULONG ip3 = (*pAddress & 0x0000FF00) >> 8;
+ ULONG ip2 = (*pAddress & 0x00FF0000) >> 16;
+ ULONG ip1 = (*pAddress & 0xFF000000) >> 24;
+
+ // "%u %u %u %u"
+ std::ostringstream tmp2;
+ tmp2 << (UINT)ip4 << " " << (UINT)ip3 << " " << (UINT)ip2
+ << " " << (UINT)ip1;
+
+ pek = sProtocolEntityKey( eDB2_ET_QMI_WDS_REQ, msgID, 17 );
+ pi = sDB2PackingInput( pek, (LPCSTR)tmp2.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ // Primary HA address provided?
+ if (pPrimaryHA != 0)
+ {
+ ULONG ip4 = (*pPrimaryHA & 0x000000FF);
+ ULONG ip3 = (*pPrimaryHA & 0x0000FF00) >> 8;
+ ULONG ip2 = (*pPrimaryHA & 0x00FF0000) >> 16;
+ ULONG ip1 = (*pPrimaryHA & 0xFF000000) >> 24;
+
+ // "%u %u %u %u"
+ std::ostringstream tmp2;
+ tmp2 << (UINT)ip4 << " " << (UINT)ip3 << " " << (UINT)ip2
+ << " " << (UINT)ip1;
+
+ pek = sProtocolEntityKey( eDB2_ET_QMI_WDS_REQ, msgID, 18 );
+ pi = sDB2PackingInput( pek, (LPCSTR)tmp2.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ // Secondary HA address provided?
+ if (pSecondaryHA != 0)
+ {
+ ULONG ip4 = (*pSecondaryHA & 0x000000FF);
+ ULONG ip3 = (*pSecondaryHA & 0x0000FF00) >> 8;
+ ULONG ip2 = (*pSecondaryHA & 0x00FF0000) >> 16;
+ ULONG ip1 = (*pSecondaryHA & 0xFF000000) >> 24;
+
+ // "%u %u %u %u"
+ std::ostringstream tmp2;
+ tmp2 << (UINT)ip4 << " " << (UINT)ip3 << " " << (UINT)ip2
+ << " " << (UINT)ip1;
+
+ pek = sProtocolEntityKey( eDB2_ET_QMI_WDS_REQ, msgID, 19 );
+ pi = sDB2PackingInput( pek, (LPCSTR)tmp2.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ // Reverse tunneling flag provided?
+ if (pRevTunneling != 0)
+ {
+ // "%u"
+ std::ostringstream tmp2;
+ tmp2 << (UINT)(*pRevTunneling == 0 ? 0 : 1);
+
+ pek = sProtocolEntityKey( eDB2_ET_QMI_WDS_REQ, msgID, 20 );
+ pi = sDB2PackingInput( pek, (LPCSTR)tmp2.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ // NAI provided?
+ if (pNAI != 0)
+ {
+ std::ostringstream tmp2;
+ if (pNAI[0] != 0)
+ {
+ tmp2 << "\"" << pNAI << "\"";
+ }
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 21 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp2.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ // HA SPI provided?
+ if (pHASPI != 0)
+ {
+ // "%u"
+ std::ostringstream tmp2;
+ tmp2 << (UINT)*pHASPI;
+
+ pek = sProtocolEntityKey( eDB2_ET_QMI_WDS_REQ, msgID, 22 );
+ pi = sDB2PackingInput( pek, (LPCSTR)tmp2.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ // AAA SPI provided?
+ if (pAAASPI != 0)
+ {
+ // "%u"
+ std::ostringstream tmp2;
+ tmp2 << (UINT)*pAAASPI;
+
+ pek = sProtocolEntityKey( eDB2_ET_QMI_WDS_REQ, msgID, 23 );
+ pi = sDB2PackingInput( pek, (LPCSTR)tmp2.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ // MN-HA key provided?
+ if (pMNHA != 0)
+ {
+ std::ostringstream tmp2;
+ if (pMNHA[0] != 0)
+ {
+ tmp2 << "\"" << pMNHA << "\"";
+ }
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 24 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp2.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ // MN-AAA key provided?
+ if (pMNAAA != 0)
+ {
+ std::ostringstream tmp2;
+ if (pMNAAA[0] != 0)
+ {
+ tmp2 << "\"" << pMNAAA << "\"";
+ }
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 25 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ // We require at least one of the optional arguments
+ if (piv.size() <= 1)
+ {
+ // Much ado about nothing
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ // 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_WDS, pRequest );
+}
+
+/*===========================================================================
+METHOD:
+ GetMobileIPProfile (Public Method)
+
+DESCRIPTION:
+ This function gets the specified mobile IP profile settings
+
+PARAMETERS:
+ index [ I ] - Mobile IP profile ID
+ pEnabled [ O ] - MIP profile enabled?
+ pAddress [ O ] - Home IPv4 address
+ pPrimaryHA [ O ] - Primary home agent IPv4 address
+ pSecondaryHA [ O ] - Secondary home agent IPv4 address
+ pRevTunneling [ O ] - Reverse tunneling enabled?
+ naiSize [ I ] - The maximum number of characters (including NULL
+ terminator) that the NAI array can contain
+ pNAI [ O ] - Network access identifier string
+ pHASPI [ O ] - HA security parameter index
+ pAAASPI [ O ] - AAA security parameter index
+ pHAState [ O ] - HA key state
+ pAAAState [ O ] - AAA key state
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetMobileIPProfile(
+ BYTE index,
+ BYTE * pEnabled,
+ ULONG * pAddress,
+ ULONG * pPrimaryHA,
+ ULONG * pSecondaryHA,
+ BYTE * pRevTunneling,
+ BYTE naiSize,
+ CHAR * pNAI,
+ ULONG * pHASPI,
+ ULONG * pAAASPI,
+ ULONG * pHAState,
+ ULONG * pAAAState )
+{
+
+ // Validate arguments
+ if ( (pEnabled == 0)
+ || (pAddress == 0)
+ || (pPrimaryHA == 0)
+ || (pSecondaryHA == 0)
+ || (pRevTunneling == 0)
+ || (naiSize == 0)
+ || (pNAI == 0)
+ || (pHASPI == 0)
+ || (pAAASPI == 0)
+ || (pHAState == 0)
+ || (pAAAState == 0) )
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ // Assume errors
+ *pEnabled = UCHAR_MAX;
+ *pAddress = ULONG_MAX;
+ *pPrimaryHA = ULONG_MAX;
+ *pSecondaryHA = ULONG_MAX;
+ *pRevTunneling = UCHAR_MAX;
+ *pHASPI = ULONG_MAX;
+ *pAAASPI = ULONG_MAX;
+ *pHAState = ULONG_MAX;
+ *pAAAState = ULONG_MAX;
+
+ WORD msgID = (WORD)eQMI_WDS_GET_MIP_PROFILE;
+ std::vector <sDB2PackingInput> piv;
+
+ // "%u"
+ std::ostringstream arg;
+ arg << (UINT)index;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 1 );
+ sDB2PackingInput pi( pek, (LPCSTR)arg.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_WDS, 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 );
+ }
+
+ // Prepare TLVs for parsing
+ std::vector <sDB2NavInput> tlvs = DB2ReduceQMIBuffer( qmiRsp );
+
+ sProtocolEntityKey tlvKey1( eDB2_ET_QMI_WDS_RSP, msgID, 16 );
+ cDataParser::tParsedFields pf1 = ParseTLV( db, rsp, tlvs, tlvKey1 );
+ if (pf1.size() >= 1)
+ {
+ *pEnabled = pf1[0].mValue.mU8;
+ }
+
+ sProtocolEntityKey tlvKey2( eDB2_ET_QMI_WDS_RSP, msgID, 17 );
+ cDataParser::tParsedFields pf2 = ParseTLV( db, rsp, tlvs, tlvKey2 );
+ if (pf2.size() >= 4)
+ {
+ ULONG ip4 = (ULONG)pf2[0].mValue.mU8;
+ ULONG ip3 = (ULONG)pf2[1].mValue.mU8 << 8;
+ ULONG ip2 = (ULONG)pf2[2].mValue.mU8 << 16;
+ ULONG ip1 = (ULONG)pf2[3].mValue.mU8 << 24;
+ *pAddress = (ip4 | ip3 | ip2 | ip1);
+ }
+
+
+ sProtocolEntityKey tlvKey3( eDB2_ET_QMI_WDS_RSP, msgID, 18 );
+ cDataParser::tParsedFields pf3 = ParseTLV( db, rsp, tlvs, tlvKey3 );
+ if (pf3.size() >= 4)
+ {
+ ULONG ip4 = (ULONG)pf3[0].mValue.mU8;
+ ULONG ip3 = (ULONG)pf3[1].mValue.mU8 << 8;
+ ULONG ip2 = (ULONG)pf3[2].mValue.mU8 << 16;
+ ULONG ip1 = (ULONG)pf3[3].mValue.mU8 << 24;
+ *pPrimaryHA = (ip4 | ip3 | ip2 | ip1);
+ }
+
+ sProtocolEntityKey tlvKey4( eDB2_ET_QMI_WDS_RSP, msgID, 19 );
+ cDataParser::tParsedFields pf4 = ParseTLV( db, rsp, tlvs, tlvKey4 );
+ if (pf4.size() >= 4)
+ {
+ ULONG ip4 = (ULONG)pf4[0].mValue.mU8;
+ ULONG ip3 = (ULONG)pf4[1].mValue.mU8 << 8;
+ ULONG ip2 = (ULONG)pf4[2].mValue.mU8 << 16;
+ ULONG ip1 = (ULONG)pf4[3].mValue.mU8 << 24;
+ *pSecondaryHA = (ip4 | ip3 | ip2 | ip1);
+ }
+
+ sProtocolEntityKey tlvKey5( eDB2_ET_QMI_WDS_RSP, msgID, 20 );
+ cDataParser::tParsedFields pf5 = ParseTLV( db, rsp, tlvs, tlvKey5 );
+ if (pf5.size() >= 1)
+ {
+ *pRevTunneling = pf5[0].mValue.mU8;
+ }
+
+ sProtocolEntityKey tlvKey6( eDB2_ET_QMI_WDS_RSP, msgID, 21 );
+ cDataParser::tParsedFields pf6 = ParseTLV( db, rsp, tlvs, tlvKey6 );
+ if (pf6.size() >= 1)
+ {
+ LONG strLen = pf6[0].mValueString.size();
+ if (strLen <= 0)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ // Space to perform the copy?
+ if (naiSize < strLen + 1)
+ {
+ return eGOBI_ERR_BUFFER_SZ;
+ }
+
+ memcpy( (LPVOID)pNAI, (LPCSTR)pf6[0].mValueString.c_str(), strLen );
+ pNAI[strLen] = 0;
+ }
+
+ sProtocolEntityKey tlvKey7( eDB2_ET_QMI_WDS_RSP, msgID, 22 );
+ cDataParser::tParsedFields pf7 = ParseTLV( db, rsp, tlvs, tlvKey7 );
+ if (pf7.size() >= 1)
+ {
+ *pHASPI = pf7[0].mValue.mU32;
+ }
+
+ sProtocolEntityKey tlvKey8( eDB2_ET_QMI_WDS_RSP, msgID, 23 );
+ cDataParser::tParsedFields pf8 = ParseTLV( db, rsp, tlvs, tlvKey8 );
+ if (pf8.size() >= 1)
+ {
+ *pAAASPI = pf8[0].mValue.mU32;
+ }
+ sProtocolEntityKey tlvKey9( eDB2_ET_QMI_WDS_RSP, msgID, 26 );
+ cDataParser::tParsedFields pf9 = ParseTLV( db, rsp, tlvs, tlvKey9 );
+ if (pf9.size() >= 1)
+ {
+ *pHAState = pf9[0].mValue.mU32;
+ }
+
+ sProtocolEntityKey tlvKey10( eDB2_ET_QMI_WDS_RSP, msgID, 27 );
+ cDataParser::tParsedFields pf10 = ParseTLV( db, rsp, tlvs, tlvKey10 );
+ if (pf10.size() >= 1)
+ {
+ *pAAAState = pf10[0].mValue.mU32;
+ }
+
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ SetMobileIPParameters (Public Method)
+
+DESCRIPTION:
+ This function sets the specified mobile IP parameters
+
+PARAMETERS:
+ pSPC [ I ] - Six digit service programming code
+ pMode [ I ] - (Optional) Desired mobile IP setting
+ pRetryLimit [ I ] - (Optional) Retry attempt limit
+ pRetryInterval [ I ] - (Optional) Retry attempt interval
+ pReRegPeriod [ I ] - (Optional) Re-registration period
+ pReRegTraffic [ I ] - (Optional) Re-registration only with traffic?
+ pHAAuthenticator [ I ] - (Optional) MH-HA authenticator calculator?
+ pHA2002bis [ I ] - (Optional) MH-HA RFC 2002bis authentication?
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::SetMobileIPParameters(
+ CHAR * pSPC,
+ ULONG * pMode,
+ BYTE * pRetryLimit,
+ BYTE * pRetryInterval,
+ BYTE * pReRegPeriod,
+ BYTE * pReRegTraffic,
+ BYTE * pHAAuthenticator,
+ BYTE * pHA2002bis )
+{
+ // Validate arguments
+ if (pSPC == 0 || pSPC[0] == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ std::string spc( pSPC );
+ if (spc.size() > 6)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ int nNonDigit = spc.find_first_not_of( "0123456789" );
+ std::string digitSPC = spc.substr( 0, nNonDigit );
+ if (digitSPC.size() != spc.size())
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ WORD msgID = (WORD)eQMI_WDS_SET_MIP_PARAMS;
+ std::vector <sDB2PackingInput> piv;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 1 );
+ sDB2PackingInput pi( pek, (LPCSTR)spc.c_str() );
+ piv.push_back( pi );
+
+ // Mode provided?
+ if (pMode != 0)
+ {
+ // "%u"
+ std::ostringstream tmp;
+ tmp << (UINT)*pMode;
+
+ pek = sProtocolEntityKey( eDB2_ET_QMI_WDS_REQ, msgID, 16 );
+ pi = sDB2PackingInput( pek, (LPCSTR)tmp.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ // Retry limit provided?
+ if (pRetryLimit != 0)
+ {
+ std::ostringstream tmp;
+ tmp << (UINT)*pRetryLimit;
+
+ pek = sProtocolEntityKey( eDB2_ET_QMI_WDS_REQ, msgID, 17 );
+ pi = sDB2PackingInput( pek, (LPCSTR)tmp.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ // Retry interval provided?
+ if (pRetryInterval != 0)
+ {
+ std::ostringstream tmp;
+ tmp << (UINT)*pRetryInterval;
+
+ pek = sProtocolEntityKey( eDB2_ET_QMI_WDS_REQ, msgID, 18 );
+ pi = sDB2PackingInput( pek, (LPCSTR)tmp.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ // Re-registration period provided?
+ if (pReRegPeriod != 0)
+ {
+ std::ostringstream tmp;
+ tmp << (UINT)*pReRegPeriod;
+
+ pek = sProtocolEntityKey( eDB2_ET_QMI_WDS_REQ, msgID, 19 );
+ pi = sDB2PackingInput( pek, (LPCSTR)tmp.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ // Re-registration on traffic flag provided?
+ if (pReRegTraffic != 0)
+ {
+ std::ostringstream tmp;
+ tmp << (UINT)(*pReRegTraffic == 0 ? 0 : 1);
+
+ pek = sProtocolEntityKey( eDB2_ET_QMI_WDS_REQ, msgID, 20 );
+ pi = sDB2PackingInput( pek, (LPCSTR)tmp.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ // HA authenticator flag provided?
+ if (pHAAuthenticator != 0)
+ {
+ std::ostringstream tmp;
+ tmp << (UINT)(*pHAAuthenticator == 0 ? 0 : 1);
+
+ pek = sProtocolEntityKey( eDB2_ET_QMI_WDS_REQ, msgID, 21 );
+ pi = sDB2PackingInput( pek, (LPCSTR)tmp.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ // HA RFC2002bis authentication flag provided?
+ if (pHA2002bis != 0)
+ {
+ std::ostringstream tmp;
+ tmp << (UINT)(*pHA2002bis == 0 ? 0 : 1);
+
+ pek = sProtocolEntityKey( eDB2_ET_QMI_WDS_REQ, msgID, 22 );
+ pi = sDB2PackingInput( pek, (LPCSTR)tmp.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ // We require at least one of the optional arguments
+ if (piv.size() <= 1)
+ {
+ // Much ado about nothing
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ // 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_WDS, pRequest );
+}
+
+/*===========================================================================
+METHOD:
+ GetMobileIPParameters (Public Method)
+
+DESCRIPTION:
+ This function gets the mobile IP parameters
+
+PARAMETERS:
+ pMode [ 0 ] - Current mobile IP setting
+ pRetryLimit [ 0 ] - Retry attempt limit
+ pRetryInterval [ 0 ] - Retry attempt interval
+ pReRegPeriod [ 0 ] - Re-registration period
+ pReRegTraffic [ 0 ] - Re-registration only with traffic?
+ pHAAuthenticator [ 0 ] - MH-HA authenticator calculator?
+ pHA2002bis [ 0 ] - MH-HA RFC 2002bis authentication?
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetMobileIPParameters(
+ ULONG * pMode,
+ BYTE * pRetryLimit,
+ BYTE * pRetryInterval,
+ BYTE * pReRegPeriod,
+ BYTE * pReRegTraffic,
+ BYTE * pHAAuthenticator,
+ BYTE * pHA2002bis )
+{
+ // Validate arguments
+ if ( (pMode == 0)
+ || (pRetryLimit == 0)
+ || (pRetryInterval == 0)
+ || (pReRegPeriod == 0)
+ || (pReRegTraffic == 0)
+ || (pHAAuthenticator == 0)
+ || (pHA2002bis == 0) )
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ *pMode = ULONG_MAX;
+ *pRetryLimit = UCHAR_MAX;
+ *pRetryInterval = UCHAR_MAX;
+ *pReRegPeriod = UCHAR_MAX;
+ *pReRegTraffic = UCHAR_MAX;
+ *pHAAuthenticator = UCHAR_MAX;
+ *pHA2002bis = UCHAR_MAX;
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_WDS_GET_MIP_PARAMS;
+ sProtocolBuffer rsp = SendSimple( eQMI_SVC_WDS, 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_WDS_RSP, msgID, 16 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() >= 1)
+ {
+ *pMode = pf[0].mValue.mU32;
+ }
+
+ tlvKey = sProtocolEntityKey ( eDB2_ET_QMI_WDS_RSP, msgID, 17 );
+ pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() >= 1)
+ {
+ *pRetryLimit = pf[0].mValue.mU8;
+ }
+
+ tlvKey = sProtocolEntityKey ( eDB2_ET_QMI_WDS_RSP, msgID, 18 );
+ pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() >= 1)
+ {
+ *pRetryInterval = pf[0].mValue.mU8;
+ }
+
+ tlvKey = sProtocolEntityKey ( eDB2_ET_QMI_WDS_RSP, msgID, 19 );
+ pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() >= 1)
+ {
+ *pReRegPeriod = pf[0].mValue.mU8;
+ }
+
+ tlvKey = sProtocolEntityKey ( eDB2_ET_QMI_WDS_RSP, msgID, 20 );
+ pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() >= 1)
+ {
+ *pReRegTraffic = pf[0].mValue.mU8;
+ }
+
+ tlvKey = sProtocolEntityKey ( eDB2_ET_QMI_WDS_RSP, msgID, 21 );
+ pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() >= 1)
+ {
+ *pHAAuthenticator = pf[0].mValue.mU8;
+ }
+
+
+ tlvKey = sProtocolEntityKey ( eDB2_ET_QMI_WDS_RSP, msgID, 22 );
+ pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() >= 1)
+ {
+ *pHA2002bis = pf[0].mValue.mU8;
+ }
+
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ GetLastMobileIPError (Public Method)
+
+DESCRIPTION:
+ This function gets the last mobile IP error
+
+PARAMETERS:
+ pError [ 0 ] - Last mobile IP error
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetLastMobileIPError( ULONG * pError )
+{
+ // Validate arguments
+ if (pError == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_WDS_GET_LAST_MIP_STATUS;
+ sProtocolBuffer rsp = SendSimple( eQMI_SVC_WDS, 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_WDS_RSP, msgID, 1 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() < 1)
+ {
+ return eGOBI_ERR_INVALID_RSP;
+ }
+
+ // Populate the index
+ *pError = (ULONG)pf[0].mValue.mU8;
+ return eGOBI_ERR_NONE;
+}
+
+/*===========================================================================
+METHOD:
+ SetDNSSettings
+
+DESCRIPTION:
+ This function sets the DNS settings for the device
+
+PARAMETERS:
+ pPrimaryDNS [ I ] - (Optional) Primary DNS IPv4 address
+ pSecondaryDNS [ I ] - (Optional) Secondary DNS IPv4 address
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::SetDNSSettings(
+ ULONG * pPrimaryDNS,
+ ULONG * pSecondaryDNS )
+{
+ // Validate arguments
+ if (pPrimaryDNS == 0 && pSecondaryDNS == 0)
+ {
+ // At least one must be specified
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ WORD msgID = (WORD)eQMI_WDS_SET_DNS;
+ std::vector <sDB2PackingInput> piv;
+
+ if (pPrimaryDNS != 0)
+ {
+ ULONG ip4 = (*pPrimaryDNS & 0x000000FF);
+ ULONG ip3 = (*pPrimaryDNS & 0x0000FF00) >> 8;
+ ULONG ip2 = (*pPrimaryDNS & 0x00FF0000) >> 16;
+ ULONG ip1 = (*pPrimaryDNS & 0xFF000000) >> 24;
+
+ // "%u %u %u %u"
+ std::ostringstream tmp;
+ tmp << (UINT)ip4 << " " << (UINT)ip3 << " " << (UINT)ip2
+ << " " << (UINT)ip1;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 16 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ if (pSecondaryDNS != 0)
+ {
+ ULONG ip4 = (*pSecondaryDNS & 0x000000FF);
+ ULONG ip3 = (*pSecondaryDNS & 0x0000FF00) >> 8;
+ ULONG ip2 = (*pSecondaryDNS & 0x00FF0000) >> 16;
+ ULONG ip1 = (*pSecondaryDNS & 0xFF000000) >> 24;
+
+ // "%u %u %u %u"
+ std::ostringstream tmp;
+ tmp << (UINT)ip4 << " " << (UINT)ip3 << " " << (UINT)ip2
+ << " " << (UINT)ip1;
+
+ sProtocolEntityKey pek( eDB2_ET_QMI_WDS_REQ, msgID, 17 );
+ sDB2PackingInput pi( pek, (LPCSTR)tmp.str().c_str() );
+ piv.push_back( pi );
+ }
+
+ // Pack up and send the QMI request
+ const cCoreDatabase & db = GetDatabase();
+ sSharedBuffer * pRequest = DB2PackQMIBuffer( db, piv );
+
+ // Send the QMI request, check result, and return
+ return SendAndCheckReturn( eQMI_SVC_WDS, pRequest );
+}
+
+/*===========================================================================
+METHOD:
+ GetDNSSettings
+
+DESCRIPTION:
+ This function gets the DNS settings for the device
+
+PARAMETERS:
+ pPrimaryDNS [ O ] - Primary DNS IPv4 address
+ pSecondaryDNS [ O ] - Secondary DNS IPv4 address
+
+RETURN VALUE:
+ eGobiError - Return code
+===========================================================================*/
+eGobiError cGobiQMICore::GetDNSSettings(
+ ULONG * pPrimaryDNS,
+ ULONG * pSecondaryDNS )
+{
+ // Validate arguments
+ if (pPrimaryDNS == 0 || pSecondaryDNS == 0)
+ {
+ return eGOBI_ERR_INVALID_ARG;
+ }
+
+ *pPrimaryDNS = 0;
+ *pSecondaryDNS = 0;
+
+ // Generate and send the QMI request
+ WORD msgID = (WORD)eQMI_WDS_GET_DNS;
+ sProtocolBuffer rsp = SendSimple( eQMI_SVC_WDS, 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_WDS_RSP, msgID, 16 );
+ cDataParser::tParsedFields pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() >= 4)
+ {
+ ULONG ip4 = (ULONG)pf[0].mValue.mU8;
+ ULONG ip3 = (ULONG)pf[1].mValue.mU8 << 8;
+ ULONG ip2 = (ULONG)pf[2].mValue.mU8 << 16;
+ ULONG ip1 = (ULONG)pf[3].mValue.mU8 << 24;
+ *pPrimaryDNS = (ip4 | ip3 | ip2 | ip1);
+ }
+
+ tlvKey = sProtocolEntityKey( eDB2_ET_QMI_WDS_RSP, msgID, 17 );
+ pf = ParseTLV( db, rsp, tlvs, tlvKey );
+ if (pf.size() >= 4)
+ {
+ ULONG ip4 = (ULONG)pf[0].mValue.mU8;
+ ULONG ip3 = (ULONG)pf[1].mValue.mU8 << 8;
+ ULONG ip2 = (ULONG)pf[2].mValue.mU8 << 16;
+ ULONG ip1 = (ULONG)pf[3].mValue.mU8 << 24;
+ *pSecondaryDNS = (ip4 | ip3 | ip2 | ip1);
+ }
+
+ return eGOBI_ERR_NONE;
+}
diff --git a/gobi-api/GobiAPI_1.0.40/Shared/GobiQMIVoice.cpp b/gobi-api/GobiAPI_1.0.40/Shared/GobiQMIVoice.cpp
new file mode 100755
index 0000000..99120ae
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Shared/GobiQMIVoice.cpp
@@ -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;
+}
+
diff --git a/gobi-api/GobiAPI_1.0.40/Shared/Makefile.am b/gobi-api/GobiAPI_1.0.40/Shared/Makefile.am
new file mode 100644
index 0000000..dfa9640
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/Shared/Makefile.am
@@ -0,0 +1,41 @@
+noinst_LTLIBRARIES = libShared.la
+
+INCLUDES = \
+ -I$(top_srcdir)/Core
+
+libShared_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
+
+libShared_la_SOURCES = \
+ GobiError.h \
+ GobiImageDefinitions.h \
+ GobiMBNMgmt.cpp \
+ GobiMBNMgmt.h \
+ GobiQDLCore.cpp \
+ GobiQDLCore.h \
+ GobiQMICoreCAT.cpp \
+ GobiQMICore.cpp \
+ GobiQMICoreDMS.cpp \
+ GobiQMICore.h \
+ GobiQMICoreImg2k.cpp \
+ GobiQMICoreImg.cpp \
+ GobiQMICoreNAS.cpp \
+ GobiQMICoreOMA.cpp \
+ GobiQMICorePDS.cpp \
+ GobiQMICoreRMS.cpp \
+ GobiQMICoreSMS.cpp \
+ GobiQMICoreUIM.cpp \
+ GobiQMICoreWDS.cpp \
+ GobiQMIVoice.cpp
+
diff --git a/gobi-api/GobiAPI_1.0.40/autogen.sh b/gobi-api/GobiAPI_1.0.40/autogen.sh
new file mode 100755
index 0000000..4fa6c5d
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/autogen.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+# Run this to generate all the initial makefiles, etc.
+# NOTE
+# This autogen.sh is only used when building libqcdm separately from ModemManager
+
+srcdir=`dirname $0`
+test -z "$srcdir" && srcdir=.
+REQUIRED_AUTOMAKE_VERSION=1.7
+PKG_NAME=GobiAPI
+
+(test -f $srcdir/configure.ac \
+ && test -f $srcdir/Core/QDLEnum.h) || {
+ echo -n "**Error**: Directory "\`$srcdir\'" does not look like the"
+ echo " top-level $PKG_NAME directory"
+ exit 1
+}
+
+(cd $srcdir;
+ mkdir m4
+ autoreconf --install --symlink &&
+ autoreconf &&
+ ./configure --enable-maintainer-mode $@
+)
diff --git a/gobi-api/GobiAPI_1.0.40/configure.ac b/gobi-api/GobiAPI_1.0.40/configure.ac
new file mode 100644
index 0000000..7f772f4
--- /dev/null
+++ b/gobi-api/GobiAPI_1.0.40/configure.ac
@@ -0,0 +1,30 @@
+AC_PREREQ(2.52)
+
+AC_INIT(GobiAPI, 1.0.40, foo@it.com, GobiAPI)
+AM_INIT_AUTOMAKE([1.9 subdir-objects tar-ustar no-dist-gzip dist-bzip2])
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+AM_MAINTAINER_MODE
+
+AC_CONFIG_MACRO_DIR([m4])
+
+AC_CONFIG_HEADERS(config.h)
+
+dnl Required programs
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_CXX
+AC_PROG_INSTALL
+LT_INIT
+
+AC_CONFIG_FILES([
+Makefile
+Core/Makefile
+Database/Makefile
+Database/QMI/Makefile
+Shared/Makefile
+GobiConnectionMgmt/Makefile
+GobiImageMgmt/Makefile
+GobiQDLService/Makefile
+])
+AC_OUTPUT
+