smsprotocols/smsstack/common/src/smsstacklog.cpp
changeset 62 8ef833fbf5aa
parent 42 3adadc800673
equal deleted inserted replaced
49:f50f4094acd7 62:8ef833fbf5aa
    26 #include "smsstacklogTraces.h"
    26 #include "smsstacklogTraces.h"
    27 #endif
    27 #endif
    28 
    28 
    29 #include "gsmupdu.h"
    29 #include "gsmupdu.h"
    30 #include "smsstacklog.h"
    30 #include "smsstacklog.h"
    31 #include <S32MEM.H>
    31 #include <s32mem.h>
    32 
    32 
    33 //
    33 //
    34 // All functions in this file are available only if logging is enabled.
    34 // All functions in this file are available only if logging is enabled.
    35 //
    35 //
    36 #ifdef OST_TRACE_COMPILER_IN_USE
    36 #ifdef OST_TRACE_COMPILER_IN_USE
    46  *  Converts a PDU from a buffer into a ASCII string and decodes it.
    46  *  Converts a PDU from a buffer into a ASCII string and decodes it.
    47  *
    47  *
    48  *  @param aPDU         PDU to log.
    48  *  @param aPDU         PDU to log.
    49  *  @param aCommandPdu  Flag to say if this is a command PDU.
    49  *  @param aCommandPdu  Flag to say if this is a command PDU.
    50  */
    50  */
    51 void LogSmsIfPDU(const TDesC8& aText, const TDesC8& aPDU, TBool aCommandPdu)
    51 void LogSmsIfPDUL(const TDesC8& aText, const TDesC8& aPDU, TBool aCommandPdu)
    52 	{
    52 	{
    53 	TBuf8<128>  tmpBuf;
    53 	TBuf8<128>  tmpBuf;
    54 
    54 
    55 	//
    55 	//
    56 	// Log the PDU as raw hex...
    56 	// Log the PDU as raw hex...
   201 	else
   201 	else
   202 		{
   202 		{
   203 		tmpBuf.Append(_L8("    -      -"));
   203 		tmpBuf.Append(_L8("    -      -"));
   204 		}
   204 		}
   205 
   205 
   206 	OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDU_1, "%s      HEX   MTI        RP UDHI  SRX  MMS   RD     VP", aText);
   206 	OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDUL_1, "%s      HEX   MTI        RP UDHI  SRX  MMS   RD     VP", aText);
   207 	OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDU_2, "%sFO:   0x%02X  %s", aText, (TUint)firstOctet, tmpBuf);
   207 	OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDUL_2, "%sFO:   0x%02X  %s", aText, (TUint)firstOctet, tmpBuf);
   208 
   208 
   209 	if (pduType == -1)
   209 	if (pduType == -1)
   210 		{
   210 		{
   211 		// Not supported!
   211 		// Not supported!
   212 		return;
   212 		return;
   218 	//
   218 	//
   219 	if (pduType == CSmsPDU::ESmsSubmit  ||
   219 	if (pduType == CSmsPDU::ESmsSubmit  ||
   220 	    pduType == CSmsPDU::ESmsStatusReport  ||
   220 	    pduType == CSmsPDU::ESmsStatusReport  ||
   221 	    pduType == CSmsPDU::ESmsCommand)
   221 	    pduType == CSmsPDU::ESmsCommand)
   222 		{
   222 		{
   223         OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDU_3, "%sMR:   0x%02X", aText, aPDU[octetOffset]);
   223         OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDUL_3, "%sMR:   0x%02X", aText, aPDU[octetOffset]);
   224         octetOffset++;
   224         octetOffset++;
   225 		}
   225 		}
   226 
   226 
   227 	//
   227 	//
   228 	// Command's PID, CT and MN...
   228 	// Command's PID, CT and MN...
   229 	//
   229 	//
   230 	if (pduType == CSmsPDU::ESmsCommand)
   230 	if (pduType == CSmsPDU::ESmsCommand)
   231 		{
   231 		{
   232 		OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDU_4, "%sPID:  0x%02X", aText, aPDU[octetOffset]);
   232 		OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDUL_4, "%sPID:  0x%02X", aText, aPDU[octetOffset]);
   233         octetOffset++;
   233         octetOffset++;
   234 
   234 
   235 		OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDU_5, "%sCT:   0x%02X", aText, aPDU[octetOffset]);
   235 		OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDUL_5, "%sCT:   0x%02X", aText, aPDU[octetOffset]);
   236         octetOffset++;
   236         octetOffset++;
   237 
   237 
   238 		OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDU_6, "%sMN:   0x%02X", aText, aPDU[octetOffset]);
   238 		OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDUL_6, "%sMN:   0x%02X", aText, aPDU[octetOffset]);
   239         octetOffset++;
   239         octetOffset++;
   240 		}
   240 		}
   241 
   241 
   242 	//
   242 	//
   243 	// Log the telephone number...
   243 	// Log the telephone number...
   259 			octetOffset++;
   259 			octetOffset++;
   260 			}
   260 			}
   261 		
   261 		
   262 		tmpBuf.SetLength(telLength);
   262 		tmpBuf.SetLength(telLength);
   263 
   263 
   264 		OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDU_7, "%sTEL:  0x%02X  %s", aText, (TUint)typeOfNumber, tmpBuf);
   264 		OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDUL_7, "%sTEL:  0x%02X  %s", aText, (TUint)typeOfNumber, tmpBuf);
   265 		}
   265 		}
   266 	else
   266 	else
   267 		{
   267 		{
   268 		OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDU_8, "%sTEL:  Illegal length value (%d)!", aText, telLength);
   268 		OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDUL_8, "%sTEL:  Illegal length value (%d)!", aText, telLength);
   269 		return;
   269 		return;
   270 		}
   270 		}
   271 
   271 
   272 	//
   272 	//
   273 	// PID and the DCS (submit and deliver only)...
   273 	// PID and the DCS (submit and deliver only)...
   274 	//
   274 	//
   275 	if (pduType == CSmsPDU::ESmsSubmit  ||  pduType == CSmsPDU::ESmsDeliver)
   275 	if (pduType == CSmsPDU::ESmsSubmit  ||  pduType == CSmsPDU::ESmsDeliver)
   276 		{
   276 		{
   277 		OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDU_9, "%sPID:  0x%02X", aText, aPDU[octetOffset]);
   277 		OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDUL_9, "%sPID:  0x%02X", aText, aPDU[octetOffset]);
   278 		octetOffset++;
   278 		octetOffset++;
   279 
   279 
   280 		tmpBuf.Zero();
   280 		tmpBuf.Zero();
   281 
   281 
   282 		TInt  dcs = aPDU[octetOffset];
   282 		TInt  dcs = aPDU[octetOffset];
   407 		else
   407 		else
   408 			{
   408 			{
   409 			tmpBuf.Append(_L8("-"));
   409 			tmpBuf.Append(_L8("-"));
   410 			}
   410 			}
   411 
   411 
   412 		OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDU_10, "%sDCS:  HEX   CLASS      DCS     INDICATION TYPE", aText);
   412 		OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDUL_10, "%sDCS:  HEX   CLASS      DCS     INDICATION TYPE", aText);
   413 		OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDU_11, "%s      0x%02X  %s", aText, (TUint) dcs, tmpBuf);
   413 		OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDUL_11, "%s      0x%02X  %s", aText, (TUint) dcs, tmpBuf);
   414 		}
   414 		}
   415 
   415 
   416 	//
   416 	//
   417 	// VP (submit only)...
   417 	// VP (submit only)...
   418 	//
   418 	//
   419 	if (pduType == CSmsPDU::ESmsSubmit)
   419 	if (pduType == CSmsPDU::ESmsSubmit)
   420 		{
   420 		{
   421 		if (vpf == EVpRel)
   421 		if (vpf == EVpRel)
   422 			{
   422 			{
   423 			OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDU_12, "%sVP:   %d (Relative)", aText, aPDU[octetOffset++]);
   423 			OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDUL_12, "%sVP:   %d (Relative)", aText, aPDU[octetOffset++]);
   424 			}
   424 			}
   425 		else if (vpf == EVpAbs)
   425 		else if (vpf == EVpAbs)
   426 			{
   426 			{
   427 			// absolute format	  -  TODO to look for the right format
   427 			// absolute format	  -  TODO to look for the right format
   428 			tmpBuf.Zero();
   428 			tmpBuf.Zero();
   430 			for (TInt index = 0;  index < 7;  index++)
   430 			for (TInt index = 0;  index < 7;  index++)
   431 				{
   431 				{
   432 				tmpBuf.AppendFormat(_L8("%02X"), aPDU[octetOffset + index]);
   432 				tmpBuf.AppendFormat(_L8("%02X"), aPDU[octetOffset + index]);
   433 				}
   433 				}
   434 			
   434 			
   435 			OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDU_13, "%sVP:   %s (Absolute)", aText, tmpBuf);
   435 			OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDUL_13, "%sVP:   %s (Absolute)", aText, tmpBuf);
   436 			octetOffset += 7;
   436 			octetOffset += 7;
   437 			}
   437 			}
   438 		else if (vpf == EVpEnh)
   438 		else if (vpf == EVpEnh)
   439 			{
   439 			{
   440 			// enhanced validity period   -  TODO to look for the right format
   440 			// enhanced validity period   -  TODO to look for the right format
   443 			for (TInt index = 0;  index < 7;  index++)
   443 			for (TInt index = 0;  index < 7;  index++)
   444 				{
   444 				{
   445 				tmpBuf.AppendFormat(_L8("%02X"), aPDU[octetOffset + index]);
   445 				tmpBuf.AppendFormat(_L8("%02X"), aPDU[octetOffset + index]);
   446 				}
   446 				}
   447 			
   447 			
   448 			OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDU_14, "%sVP:   %s (Enhanced)", aText, tmpBuf);
   448 			OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDUL_14, "%sVP:   %s (Enhanced)", aText, tmpBuf);
   449 			octetOffset += 7;
   449 			octetOffset += 7;
   450 			}
   450 			}
   451 		}
   451 		}
   452 
   452 
   453 	//
   453 	//
   460 		for (TInt index = 0;  index < 7;  index++)
   460 		for (TInt index = 0;  index < 7;  index++)
   461 			{
   461 			{
   462 			tmpBuf.AppendFormat(_L8("%02X"), aPDU[octetOffset + index]);
   462 			tmpBuf.AppendFormat(_L8("%02X"), aPDU[octetOffset + index]);
   463 			}
   463 			}
   464 			
   464 			
   465 		OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDU_15, "%sSCTS: %s", aText, tmpBuf);
   465 		OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDUL_15, "%sSCTS: %s", aText, tmpBuf);
   466 		octetOffset += 7;
   466 		octetOffset += 7;
   467 		}
   467 		}
   468 	
   468 	
   469 	//
   469 	//
   470 	// Getting the DT and the status of the SR (SR only)
   470 	// Getting the DT and the status of the SR (SR only)
   478 		for (TInt index = 0;  index < 7;  index++)
   478 		for (TInt index = 0;  index < 7;  index++)
   479 			{
   479 			{
   480 			tmpBuf.AppendFormat(_L8("%02X"), aPDU[octetOffset + index]);
   480 			tmpBuf.AppendFormat(_L8("%02X"), aPDU[octetOffset + index]);
   481 			}
   481 			}
   482 			
   482 			
   483 		OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDU_16, "%sDT:   %s", aText, tmpBuf);
   483 		OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDUL_16, "%sDT:   %s", aText, tmpBuf);
   484 		octetOffset += 7;
   484 		octetOffset += 7;
   485 
   485 
   486 		OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDU_17, "%sST:   %02X", aText, aPDU[octetOffset]);
   486 		OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDUL_17, "%sST:   %02X", aText, aPDU[octetOffset]);
   487 		octetOffset++;
   487 		octetOffset++;
   488 		}
   488 		}
   489 
   489 
   490 	//
   490 	//
   491 	// Getting the UDL   -    TODO to add UD later and to decode the UDH
   491 	// Getting the UDL   -    TODO to add UD later and to decode the UDH
   525 							}
   525 							}
   526 						}
   526 						}
   527 					}
   527 					}
   528 				else
   528 				else
   529 					{
   529 					{
   530 					OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDU_18, "%sUDL:  Problems with the ieidl_a %d being less that UDHL",aText, ieidl_a);
   530 					OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDUL_18, "%sUDL:  Problems with the ieidl_a %d being less that UDHL",aText, ieidl_a);
   531 					}
   531 					}
   532 	
   532 	
   533 				if ((ieidl_a + 1) > udhl)
   533 				if ((ieidl_a + 1) > udhl)
   534 					{
   534 					{
   535 					OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDU_19, "%sUDL:  Corrupted or implement decoding for second iei_b, iei_n!",aText);
   535 					OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDUL_19, "%sUDL:  Corrupted or implement decoding for second iei_b, iei_n!",aText);
   536 					}
   536 					}
   537 	
   537 	
   538 				OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDU_20, "%sUDL:  HEX    UDHL   IEI_A  IEIDL_A   ", aText);
   538 				OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDUL_20, "%sUDL:  HEX    UDHL   IEI_A  IEIDL_A   ", aText);
   539 
   539 
   540 				TBuf8<200> data;
   540 				TBuf8<200> data;
   541 				RDesWriteStream dataStream(data);
   541 				RDesWriteStream dataStream(data);
   542 
   542 
   543 				dataStream.WriteInt32L(aText.Length());
   543 				dataStream.WriteInt32L(aText.Length());
   550 
   550 
   551 				dataStream.WriteInt32L(tmpBuf.Length());
   551 				dataStream.WriteInt32L(tmpBuf.Length());
   552 				dataStream.WriteL(tmpBuf);
   552 				dataStream.WriteL(tmpBuf);
   553 
   553 
   554 				dataStream.Close();
   554 				dataStream.Close();
   555                 OstTraceDefData( OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDU_21, "%s      0x%02X   0x%02X   0x%02X   0x%02X  %s", data.Ptr(), data.Size() );
   555                 OstTraceDefData( OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDUL_21, "%s      0x%02X   0x%02X   0x%02X   0x%02X  %s", data.Ptr(), data.Size() );
   556 				}
   556 				}
   557 			else
   557 			else
   558 				{
   558 				{
   559 				OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDU_22, "%sUDL:  Corrupted because TP-UDHP is TRUE and TP-UDHL is less than 1!", aText);
   559 				OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDUL_22, "%sUDL:  Corrupted because TP-UDHP is TRUE and TP-UDHL is less than 1!", aText);
   560 				OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDU_23, "%sUDL:  HEX   UDHL   IEI_A", aText);
   560 				OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDUL_23, "%sUDL:  HEX   UDHL   IEI_A", aText);
   561 				OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDU_24, "%s      0x%02X    0x%02X", aText, udl, udhl);
   561 				OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDUL_24, "%s      0x%02X    0x%02X", aText, udl, udhl);
   562 				}
   562 				}
   563 			}
   563 			}
   564 		else
   564 		else
   565 			{
   565 			{
   566 			TInt  udl  = aPDU[octetOffset++];
   566 			TInt  udl  = aPDU[octetOffset++];
   567 			
   567 			
   568 			OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDU_25, "%sUDL:  HEX    UDHL", aText);
   568 			OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDUL_25, "%sUDL:  HEX    UDHL", aText);
   569 			OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDU_26, "%s      0x%02X   -", aText, udl);
   569 			OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, LOGSMSIFPDUL_26, "%s      0x%02X   -", aText, udl);
   570 			}
   570 			}
   571 		}
   571 		}
   572 	} // LogSmsIfPDU
   572 	} // LogSmsIfPDUL
   573 
   573 
   574 
   574 
   575 #ifdef OST_TRACE_COMPILER_IN_USE
   575 #ifdef OST_TRACE_COMPILER_IN_USE
   576 void LogSmsIfHexBuf(const TDesC8& aText, const TDesC8& aHexBuf)
   576 void LogSmsIfHexBuf(const TDesC8& aText, const TDesC8& aHexBuf)
   577 #else
   577 #else
   839 	// PDU...
   839 	// PDU...
   840 	//
   840 	//
   841 	tmpBuf.Copy(aText);
   841 	tmpBuf.Copy(aText);
   842 	tmpBuf.Append(_L8("  PDU: "));
   842 	tmpBuf.Append(_L8("  PDU: "));
   843 
   843 
   844 	LogSmsIfPDU(tmpBuf, aSmsGsmEntryV1.iMsgData, EFalse);
   844 	LogSmsIfPDUL(tmpBuf, aSmsGsmEntryV1.iMsgData, EFalse);
   845 	} // LogSmsIfSmsEntry
   845 	} // LogSmsIfSmsEntry
   846 
   846 
   847 
   847 
   848 /**
   848 /**
   849  *	Logs contents of TMobileSmsSendAttributesV1 object.
   849  *	Logs contents of TMobileSmsSendAttributesV1 object.
   954 		TBuf8<RMobilePhone::KMaxMobileTelNumberSize>  tmpBuf;
   954 		TBuf8<RMobilePhone::KMaxMobileTelNumberSize>  tmpBuf;
   955 		
   955 		
   956 		tmpBuf.Copy(aText);
   956 		tmpBuf.Copy(aText);
   957 		tmpBuf.Append(_L8("  iSubmitReport PDU: "));
   957 		tmpBuf.Append(_L8("  iSubmitReport PDU: "));
   958 
   958 
   959 		LogSmsIfPDU(tmpBuf, aAttrib.iSubmitReport, EFalse);
   959 		LogSmsIfPDUL(tmpBuf, aAttrib.iSubmitReport, EFalse);
   960 		}
   960 		}
   961 	} // LogSmsIfSendAttributes
   961 	} // LogSmsIfSendAttributes
   962 
   962 
   963 #endif // OST_TRACE_COMPILER_IN_USE
   963 #endif // OST_TRACE_COMPILER_IN_USE