Fixed mismatch in files between openbts and smqueue.

Fixed all places where + was not being sent. Plus can't be sent as a digit it has to be encoded as an international type.
Fixed error where # is displayed in reply address for +.
SMS reply not working with plus in from address.
Fixed all places in smqueue that crash on purpose when bad data is found.
Fixed several other crashes related to handling missing tags.
Added support for receiving addresses with and without +. Whether a + is received or not depends on what the sender enters.
3gpp mode is working.
Fixed error where smqueue gets into an infinite loop when restarted with bad messages in the queue.
This commit is contained in:
svangundy
2014-04-08 12:43:39 +02:00
committed by Michael Iedema
parent ae8258ec61
commit 50f2a2de43
4 changed files with 42 additions and 20 deletions

View File

@@ -216,7 +216,10 @@ static int encode(char c, bool *invalid)
return 0; // Not sure what to do.
}
/*
* If digit string starts with a plus strip off the plus. I suspect that this get encoded as an international type somewhere else
* The write function send digits/information and the parse function decodes and store digits/incomming information. SVG
*/
void L3BCDDigits::write(L3Frame& dest, size_t &wp) const
{
bool invalid = false;
@@ -255,8 +258,8 @@ ostream& operator<<(ostream& os, const L3BCDDigits& digits)
void L3CalledPartyBCDNumber::writeV( L3Frame &dest, size_t &wp ) const
{
dest.writeField(wp, 0x01, 1);
LOG(DEBUG) << "writeV mType" << mType;
dest.writeField(wp, 0x01, 1); // dest.writeField(wp, *digits() == '+' ? InternationalNumber : mType, 3); // Don't think this makes sense
//LOG(DEBUG) << "writeV mType " << mType << " first digit " << *digits();
dest.writeField(wp, mType, 3);
dest.writeField(wp, mPlan, 4);
mDigits.write(dest,wp);
@@ -268,7 +271,7 @@ void L3CalledPartyBCDNumber::parseV( const L3Frame &src, size_t &rp, size_t expe
// ext bit must be 1
if (src.readField(rp, 1) != 1) L3_READ_ERROR;
mType = (TypeOfNumber)src.readField(rp, 3);
LOG(DEBUG) << "parseV mType" << mType;
//LOG(DEBUG) << "parseV mType " << mType;
mPlan = (NumberingPlan)src.readField(rp, 4);
mDigits.parse(src,rp,expectedLength-1, mType == InternationalNumber);
}
@@ -293,7 +296,7 @@ void L3CallingPartyBCDNumber::writeV( L3Frame &dest, size_t &wp ) const
{
// If Octet3a is extended, then write 0 else 1.
dest.writeField(wp, (!mHaveOctet3a & 0x01), 1);
LOG(DEBUG) << "writeV mType" << mType << " first digit " << *digits();
LOG(DEBUG) << "writeV mType " << mType << " first digit " << *digits();
dest.writeField(wp, mType, 3);
dest.writeField(wp, mPlan, 4);
@@ -319,7 +322,7 @@ void L3CallingPartyBCDNumber::parseV( const L3Frame &src, size_t &rp, size_t exp
// Read out first bit = 1.
mHaveOctet3a = !src.readField(rp, 1); // Bit is reversed 0 means you have an octet
mType = (TypeOfNumber)src.readField(rp, 3);
LOG(DEBUG) << "parseV mType" << mType;
//LOG(DEBUG) << "parseV mType " << mType;
mPlan = (NumberingPlan)src.readField(rp, 4);
remainingLength -= 1;

View File

@@ -22,7 +22,7 @@
#include "GSML3Message.h"
#include <iostream>
#include <ControlTransfer.h>
#include <Logger.h>
namespace GSM {
@@ -179,12 +179,17 @@ private:
public:
L3CallingPartyBCDNumber()
:mType(UnknownTypeOfNumber),mPlan(UnknownPlan)
:mType(UnknownTypeOfNumber), mPlan(UnknownPlan),
mHaveOctet3a(false)
{ }
L3CallingPartyBCDNumber( const char * wDigits )
:mType(NationalNumber),mPlan(E164Plan),mDigits(wDigits)
{ }
:mPlan(E164Plan), mDigits(wDigits),
mHaveOctet3a(false)
{
mType = (wDigits[0] == '+') ? GSM::InternationalNumber : GSM::NationalNumber;
LOG(DEBUG) << "L3CallingPartyBCDNumber ctor type=" << mType << " Digits " << wDigits;
}
L3CallingPartyBCDNumber(const L3CallingPartyBCDNumber &other)
:mType(other.mType),mPlan(other.mPlan),mDigits(other.mDigits),
@@ -224,8 +229,11 @@ public:
{ }
L3CalledPartyBCDNumber(const char * wDigits)
:mType(NationalNumber),mPlan(E164Plan),mDigits(wDigits)
{ }
:mPlan(E164Plan), mDigits(wDigits)
{
mType = (wDigits[0] == '+') ? GSM::InternationalNumber : GSM::NationalNumber;
LOG(DEBUG) << "L3CallingPartyBCDNumber ctor type=" << mType << " Digits " << wDigits;
}
// (pat) This auto-conversion from CallingParty to CalledParty was used in the SMS code,
// however, it was creating a disaster during unintended auto-conversions of L3Messages,

View File

@@ -86,7 +86,7 @@ RPData *SMS::hex2rpdata(const char *hexstring)
BitVector2 RPDUbits(strlen(hexstring)*4);
if (!RPDUbits.unhex(hexstring)) {
return false;
return NULL;
}
LOG(DEBUG) << "SMS RPDU bits: " << RPDUbits;
@@ -116,7 +116,7 @@ RPData *SMS::hex2rpdata(const char *hexstring)
TLMessage *SMS::parseTPDU(const TLFrame& TPDU, bool directionUplink)
{
LOG(DEBUG) << "SMS: parseTPDU MTI=" << TPDU.MTI();
LOG(DEBUG) << "SMS: parseTPDU MTI=" << (TLMessage::MessageType)TPDU.MTI();
if (directionUplink) {
// Handle just the uplink cases.
switch ((TLMessage::MessageType)TPDU.MTI()) {
@@ -248,11 +248,12 @@ void RPUserData::parseV(const L3Frame& src, size_t &rp, size_t expectedLength)
SMS_READ_ERROR;
}
mTPDU.resize(numBits);
LOG(DEBUG) << "mTPDU length=" << mTPDU.length() << "data=" << mTPDU;
LOG(DEBUG) << "mTPDU length=" << mTPDU.length() << " data=" << mTPDU;
src.segmentCopyTo(mTPDU,rp,numBits);
rp += numBits;
}
void RPUserData::writeV(L3Frame& dest, size_t &wp) const
{
unsigned numBits = mTPDU.size();
@@ -299,6 +300,7 @@ void RPData::parseBody(const RLFrame& src, size_t &rp)
mOriginator.parseLV(src,rp);
mDestination.parseLV(src,rp);
mUserData.parseLV(src,rp);
//LOG(DEBUG) << "parseBody orig=" << mOriginator << " dest=" << mDestination;
}
@@ -307,6 +309,7 @@ void RPData::writeBody(RLFrame& dest, size_t& wp) const
// GSM 04.11 7.3.1.1
// This is the downlink form.
mOriginator.writeLV(dest,wp);
//LOG(DEBUG) << "writeBody orig=" << mOriginator << " dest=" << mDestination;
mDestination.writeLV(dest,wp);
mUserData.writeLV(dest,wp);
}
@@ -386,6 +389,7 @@ void TLAddress::parse(const TLFrame& src, size_t& rp)
if (src.readField(rp, 1) != 1) SMS_READ_ERROR;
mType = (TypeOfNumber)src.readField(rp, 3);
mPlan = (NumberingPlan)src.readField(rp, 4);
//LOG(DEBUG) << "parse mType " << mType;
mDigits.parse(src,rp,length, mType == InternationalNumber);
}
@@ -757,6 +761,7 @@ void TLSubmit::parseBody(const TLFrame& src, size_t& rp)
parseSRR(src);
mMR = src.readField(rp,8);
mDA.parse(src,rp);
//LOG(DEBUG) << "Destination " << mDA.digits();
mPI = src.readField(rp,8);
mDCS = src.readField(rp,8);
mVP.VPF(mVPF);

View File

@@ -28,7 +28,7 @@
#include <GSML3Message.h>
#include <GSML3CCElements.h>
#include <GSML3MMElements.h>
#include <Logger.h>
namespace SMS {
@@ -81,13 +81,19 @@ public:
TLAddress(GSM::TypeOfNumber wType, GSM::NumberingPlan wPlan, const char* wDigits)
:TLElement(),
mType(wType),mPlan(wPlan),mDigits(wDigits)
{ }
mPlan(wPlan), mDigits(wDigits)
{
mType = (wDigits[0] == '+') ? GSM::InternationalNumber : GSM::NationalNumber;
LOG(DEBUG) << "TLaddrress ctor type=" << mType << " Digits " << wDigits;
}
TLAddress(const char* wDigits)
:TLElement(),
mType(GSM::NationalNumber),mPlan(GSM::E164Plan),mDigits(wDigits)
{ }
mPlan(GSM::E164Plan), mDigits(wDigits)
{
mType = (wDigits[0] == '+') ? GSM::InternationalNumber : GSM::NationalNumber;
LOG(DEBUG) << "TLaddrress ctor type=" << mType << " Digits " << wDigits;
}
const char *digits() const { return mDigits.digits(); }
GSM::TypeOfNumber type() const { return mType; }