/*****************************************************************************
 * Copyright (C) Gemalto M2M GmbH
 *****************************************************************************
 * Project: IMC-RIL-Driver
 *****************************************************************************
 * Author : Wireless Modules RD SW A2
 *****************************************************************************
 * $Workfile: Y:/z_ms-d/src/working/Quinn/RilDrv/smscmn.h $
 * $Revision: /main/ms-d/6 $
 *     $Date: 2013-04-26 09:17:21 $
 *   $Author: pmackent $
 *****************************************************************************
 * Target:
 *  Microsoft Windows Mobile 5.0
 *****************************************************************************
 * Description:
 *  Gemalto IMC RIL
 *****************************************************************************
 *
 * $Log: Y:/z_ms-d/src/working/Quinn/RilDrv/smscmn.h$ 
 * 
 * /main/ms-d/6   2013-04-26 09:17:21   pmackent 
 * Parsing of CDMA status reports added
 *
 * /main/ms-d/5   2012-04-18 13:46:30   ctna0256
 * Introducing PVS8
 * Implementing CDMA-SMS
 * Various CDMA enhancements
 *
 * /main/ms-d/4   2008-08-22 10:27:54   ctna0256
 * Set Cinterion copyright text
 *
 * /main/ms-d/3   2008-08-21 09:35:34   ctna0256
 * Prepared for new disclaimer handling
 *
 * /main/ms-d/2   2007-11-16 17:23:55   mp49210
 * Corrected array length calculation
 *
 * /main/ms-d/1   2006-10-25 16:52:11   wm36264
 * First transformation from classic RIL
 *
*/

//////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2008 Gemalto M2M GmbH
// Copyright (C) 2006-2008 Siemens AG
// Copyright (C) 2003 Intrinsyc Europe Ltd.
//
// Version: 1.0
// Date:    dummy
//
//////////////////////////////////////////////////////////////////////////////

/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
Copyright (c) 1995-1999  Microsoft Corporation
--*/

#pragma once

#define MAX_MSGBUFFER 1024

// Address length for modules which doesn't encode the SMSC address prepended to a message
#define SMS_BOGUS_ADDR_LENGTH    12


//
// Address types
//
static const BYTE g_rgbAddrTypes[] =
{
    0x00,   // RIL_ADDRTYPE_UNKNOWN
    0x01,   // RIL_ADDRTYPE_INTERNATIONAL
    0x02,   // RIL_ADDRTYPE_NATIONAL
    0x03,   // RIL_ADDRTYPE_NETWKSPECIFIC
    0x04,   // RIL_ADDRTYPE_SUBSCRIBER
    0x05,   // RIL_ADDRTYPE_ALPHANUM
    0x06,   // RIL_ADDRTYPE_ABBREV
};
#define NUM_ADDRTYPES   (sizeof(g_rgbAddrTypes) / sizeof(BYTE))


//
// Numbering plans
//
static const BYTE g_rgbNumPlans[] =
{
    0x00,   // RIL_NUMPLAN_UNKNOWN
    0x01,   // RIL_NUMPLAN_TELEPHONE
    0x03,   // RIL_NUMPLAN_DATA
    0x04,   // RIL_NUMPLAN_TELEX
    0x08,   // RIL_NUMPLAN_NATIONAL
    0x09,   // RIL_NUMPLAN_PRIVATE
    0x0a,   // RIL_NUMPLAN_ERMES
};
#define NUM_NUMPLANS   (sizeof(g_rgbNumPlans) / sizeof(BYTE))


//
// ProtocolID types
//
static const DWORD g_rgdwProtocolIDs[] =
{
    0x00,   // RIL_MSGPROTOCOL_UNKNOWN
    0x00,   // RIL_MSGPROTOCOL_SMETOSME
    0x20,   // RIL_MSGPROTOCOL_IMPLICIT
    0x21,   // RIL_MSGPROTOCOL_TELEX
    0x22,   // RIL_MSGPROTOCOL_TELEFAX_GROUP3
    0x23,   // RIL_MSGPROTOCOL_TELEFAX_GROUP4
    0x24,   // RIL_MSGPROTOCOL_VOICEPHONE
    0x25,   // RIL_MSGPROTOCOL_ERMES
    0x26,   // RIL_MSGPROTOCOL_PAGING
    0x27,   // RIL_MSGPROTOCOL_VIDEOTEX
    0x28,   // RIL_MSGPROTOCOL_TELETEX
    0x29,   // RIL_MSGPROTOCOL_TELETEX_PSPDN
    0x2a,   // RIL_MSGPROTOCOL_TELETEX_CSPDN
    0x2b,   // RIL_MSGPROTOCOL_TELETEX_PSTN
    0x2c,   // RIL_MSGPROTOCOL_TELETEX_ISDN
    0x2d,   // RIL_MSGPROTOCOL_UCI
    0x30,   // RIL_MSGPROTOCOL_MSGHANDLING
    0x31,   // RIL_MSGPROTOCOL_X400
    0x32,   // RIL_MSGPROTOCOL_EMAIL
    0x38,   // RIL_MSGPROTOCOL_SCSPECIFIC1
    0x39,   // RIL_MSGPROTOCOL_SCSPECIFIC2
    0x3a,   // RIL_MSGPROTOCOL_SCSPECIFIC3
    0x3b,   // RIL_MSGPROTOCOL_SCSPECIFIC4
    0x3c,   // RIL_MSGPROTOCOL_SCSPECIFIC5
    0x3d,   // RIL_MSGPROTOCOL_SCSPECIFIC6
    0x3e,   // RIL_MSGPROTOCOL_SCSPECIFIC7
    0x3f,   // RIL_MSGPROTOCOL_GSMSTATION
    0x40,   // RIL_MSGPROTOCOL_SM_TYPE0
    0x41,   // RIL_MSGPROTOCOL_RSM_TYPE1
    0x42,   // RIL_MSGPROTOCOL_RSM_TYPE2
    0x43,   // RIL_MSGPROTOCOL_RSM_TYPE3
    0x44,   // RIL_MSGPROTOCOL_RSM_TYPE4
    0x45,   // RIL_MSGPROTOCOL_RSM_TYPE5
    0x46,   // RIL_MSGPROTOCOL_RSM_TYPE6
    0x47,   // RIL_MSGPROTOCOL_RSM_TYPE7
    0x5f,   // RIL_MSGPROTOCOL_RETURNCALL
    0x7d,   // RIL_MSGPROTOCOL_ME_DOWNLOAD
    0x7e,   // RIL_MSGPROTOCOL_DEPERSONALIZATION
    0x7f,   // RIL_MSGPROTOCOL_SIM_DOWNLOAD
};
#define NUM_PROTOCOLIDS (sizeof(g_rgdwProtocolIDs) / sizeof(DWORD))


//
// Status-Report values
//
static const DWORD g_rgdwDlvStatus[] =
{
    0xff,   // UNUSED
    0x00,   // RIL_MSGDLVSTATUS_RECEIVEDBYSME
    0x01,   // RIL_MSGDLVSTATUS_FORWARDEDTOSME
    0x02,   // RIL_MSGDLVSTATUS_REPLACEDBYSC
    0x20,   // RIL_MSGDLVSTATUS_CONGESTION_TRYING
    0x21,   // RIL_MSGDLVSTATUS_SMEBUSY_TRYING
    0x22,   // RIL_MSGDLVSTATUS_SMENOTRESPONDING_TRYING
    0x23,   // RIL_MSGDLVSTATUS_SVCREJECTED_TRYING
    0x24,   // RIL_MSGDLVSTATUS_QUALITYUNAVAIL_TRYING
    0x25,   // RIL_MSGDLVSTATUS_SMEERROR_TRYING
    0x60,   // RIL_MSGDLVSTATUS_CONGESTION
    0x61,   // RIL_MSGDLVSTATUS_SMEBUSY
    0x62,   // RIL_MSGDLVSTATUS_SMENOTRESPONDING
    0x63,   // RIL_MSGDLVSTATUS_SVCREJECTED
    0x64,   // RIL_MSGDLVSTATUS_QUALITYUNAVAIL_TEMP
    0x65,   // RIL_MSGDLVSTATUS_SMEERROR
    0x40,   // RIL_MSGDLVSTATUS_REMOTEPROCERROR
    0x41,   // RIL_MSGDLVSTATUS_INCOMPATIBLEDEST
    0x42,   // RIL_MSGDLVSTATUS_CONNECTIONREJECTED
    0x43,   // RIL_MSGDLVSTATUS_NOTOBTAINABLE
    0x44,   // RIL_MSGDLVSTATUS_QUALITYUNAVAIL
    0x45,   // RIL_MSGDLVSTATUS_NOINTERNETWORKING
    0x46,   // RIL_MSGDLVSTATUS_VPEXPIRED
    0x47,   // RIL_MSGDLVSTATUS_DELETEDBYORIGSME
    0x48,   // RIL_MSGDLVSTATUS_DELETEDBYSC
    0x49,   // RIL_MSGDLVSTATUS_NOLONGEREXISTS
};
#define NUM_DLVSTATUS   (sizeof(g_rgdwDlvStatus) / sizeof(DWORD))


//
// Unified FILETIME-ULARGE_INTEGER struct
//
struct FILETIME_ULARGEINT {
    union {
        FILETIME ft;
        ULARGE_INTEGER uli;
    };
};


HRESULT ParseCellBroadcastMessage(const LPCSTR sIn, const UINT cbIn, RILMESSAGE& rrmMsg);
HRESULT ParseSMSMessage(const LPCSTR sIn, const UINT cbIn, BOOL fIncoming, BOOL fPrependedSMSC, RILMESSAGE& rrmMsg);
HRESULT ParseSMSCDMAMessage(const LPCSTR sIn, const UINT cbIn, BOOL fIncoming, RILMESSAGE& rrmMsg);
HRESULT EncodeSMSMessage(const RILMESSAGE& rmMsg, const LPSTR sOut, const UINT cbOut, UINT& rcbUsed,
                         UINT& rnGSMLength);
HRESULT ParseCdmaStatusMessage(const LPCSTR sIn, const UINT cbIn, RILMESSAGE& rrmMsg);


