Ignore User-Data-Header in SMS TPDU when decoding text in TLUserData::encode7bit().
This commit is contained in:
parent
ef988a4b2f
commit
970beeb816
|
@ -498,7 +498,6 @@ std::string TLUserData::decode() const
|
||||||
{
|
{
|
||||||
std::string text;
|
std::string text;
|
||||||
|
|
||||||
if (mUDHI) SMS_READ_ERROR; // We don't support user headers.
|
|
||||||
switch (mDCS) {
|
switch (mDCS) {
|
||||||
case 0:
|
case 0:
|
||||||
case 244:
|
case 244:
|
||||||
|
@ -512,10 +511,30 @@ std::string TLUserData::decode() const
|
||||||
LOG(NOTICE) << "badly formatted TL-UD";
|
LOG(NOTICE) << "badly formatted TL-UD";
|
||||||
SMS_READ_ERROR;
|
SMS_READ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t crp = 0;
|
||||||
|
unsigned text_length = mLength;
|
||||||
|
|
||||||
|
// Skip User-Data-Header. We don't decode it here.
|
||||||
|
// User-Data-Header handling is described in GSM 03.40 9.2.3.24
|
||||||
|
// and is pictured in GSM 03.40 Figure 9.2.3.24 (a)
|
||||||
|
if (mUDHI) {
|
||||||
|
// Length-of-User-Data-Header
|
||||||
|
unsigned udhl = mRawData.peekFieldReversed(crp,8);
|
||||||
|
// Calculate UDH length in septets, including fill bits.
|
||||||
|
unsigned udh_septets = (udhl*8 + 8 + 6) / 7;
|
||||||
|
// Adjust actual text position and length.
|
||||||
|
crp += udh_septets * 7;
|
||||||
|
text_length -= udh_septets;
|
||||||
|
LOG(DEBUG) << "UDHL(octets)=" << udhl
|
||||||
|
<< " UDHL(septets)=" << udh_septets
|
||||||
|
<< " pointer(bits)=" << crp
|
||||||
|
<< " text_length(septets)=" << text_length;
|
||||||
|
}
|
||||||
|
|
||||||
// Do decoding
|
// Do decoding
|
||||||
text.resize(mLength);
|
text.resize(text_length);
|
||||||
size_t crp=0;
|
for (unsigned i=0; i<text_length; i++) {
|
||||||
for (unsigned i=0; i<mLength; i++) {
|
|
||||||
char gsm = mRawData.readFieldReversed(crp,7);
|
char gsm = mRawData.readFieldReversed(crp,7);
|
||||||
text[i] = decodeGSMChar(gsm);
|
text[i] = decodeGSMChar(gsm);
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue