mirror of
				https://github.com/RangeNetworks/openbts.git
				synced 2025-11-04 05:43:14 +00:00 
			
		
		
		
	Checkpoint check in. Basic smqueue 3gpp functionality is working. Many, I hope all, crashes on invalid data are gone. Not working: addresses with a plus in them, text mode. Flag to force tags from openbts is enabled
This commit is contained in:
		
				
					committed by
					
						
						Michael Iedema
					
				
			
			
				
	
			
			
			
						parent
						
							0d163d98c7
						
					
				
				
					commit
					ae8258ec61
				
			@@ -88,7 +88,7 @@ void SMSCommon::l3sendSms(const L3Message &msg, SAPI_t sapi)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
	Process the RPDU.
 | 
			
		||||
	Process the incomming RPDU.
 | 
			
		||||
	@param mobileID The sender's IMSI.
 | 
			
		||||
	@param RPDU The RPDU to process.
 | 
			
		||||
	@return true if successful.
 | 
			
		||||
@@ -100,33 +100,22 @@ bool MOSMSMachine::handleRPDU(const RLFrame& RPDU)
 | 
			
		||||
		case RPMessage::Data: {
 | 
			
		||||
			string contentType = gConfig.getStr("SMS.MIMEType");
 | 
			
		||||
			ostringstream body;
 | 
			
		||||
			string toAddress = "";
 | 
			
		||||
 | 
			
		||||
			if (contentType == "text/plain") {
 | 
			
		||||
				// TODO: Clean this mess up!
 | 
			
		||||
				RPData data;
 | 
			
		||||
				data.parse(RPDU);
 | 
			
		||||
				TLSubmit submit;
 | 
			
		||||
				submit.parse(data.TPDU());
 | 
			
		||||
				
 | 
			
		||||
				body << submit.UD().decode();	// (pat) TODO: efficiencize this.
 | 
			
		||||
				toAddress = string(submit.DA().digits());
 | 
			
		||||
			} else if (contentType == "application/vnd.3gpp.sms") {
 | 
			
		||||
				toAddress = "smsc";  // If encoded this is expected in destination address
 | 
			
		||||
				RPDU.hex(body);
 | 
			
		||||
			} else {
 | 
			
		||||
				LOG(ERR) << "\"" << contentType << "\" is not a valid SMS payload type";
 | 
			
		||||
			}
 | 
			
		||||
			// (pat) In this case the recipient address is buried in the message somewhere.
 | 
			
		||||
			string address = gConfig.getStr("SIP.SMSC");
 | 
			
		||||
 | 
			
		||||
			/* The SMSC is not defined, we are using an older version */
 | 
			
		||||
			if (address.length() == 0) {
 | 
			
		||||
				RPData data;
 | 
			
		||||
				data.parse(RPDU);
 | 
			
		||||
				TLSubmit submit;
 | 
			
		||||
				submit.parse(data.TPDU());
 | 
			
		||||
 | 
			
		||||
				address = string(submit.DA().digits());
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			// Steps:
 | 
			
		||||
			// 1 -- Complete transaction record.
 | 
			
		||||
			// 2 -- Send TL-SUBMIT to the server.
 | 
			
		||||
@@ -136,7 +125,7 @@ bool MOSMSMachine::handleRPDU(const RLFrame& RPDU)
 | 
			
		||||
			// Step 1 and 2 -- Complete the transaction record and send TL-SUMBIT to server.
 | 
			
		||||
			// Form the TLAddress into a CalledPartyNumber for the transaction.
 | 
			
		||||
			// Attach calledParty and message body to the transaction.
 | 
			
		||||
			SipDialog::newSipDialogMOSMS(tran()->tranID(), tran()->subscriber(), address, body.str(), contentType);
 | 
			
		||||
			SipDialog::newSipDialogMOSMS(tran()->tranID(), tran()->subscriber(), toAddress, body.str(), contentType);
 | 
			
		||||
			return true;
 | 
			
		||||
		}
 | 
			
		||||
		case RPMessage::Ack:
 | 
			
		||||
@@ -623,6 +612,7 @@ void initMTSMS(TranEntry *tran)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if UNUSED 	// (pat) what was I thinking here? 
 | 
			
		||||
xxxxxxxx This version is not used
 | 
			
		||||
// Parse an incoming SMS message into RPData, save everything else we need.
 | 
			
		||||
// We do this immediately upon reception of a SIP message to error check it before queueing it for delivery to an MS.
 | 
			
		||||
// Return result or NULL on failure.  SIP should return error 400 "Bad Request" in this case.
 | 
			
		||||
 
 | 
			
		||||
@@ -192,6 +192,7 @@ void L3BCDDigits::parse(const L3Frame& src, size_t &rp, size_t numOctets, bool i
 | 
			
		||||
{
 | 
			
		||||
	unsigned i=0;
 | 
			
		||||
	size_t readOctets = 0;
 | 
			
		||||
	LOG(DEBUG) << "parse international " << international;
 | 
			
		||||
	if (international) mDigits[i++] = '+';
 | 
			
		||||
	while (readOctets < numOctets) {
 | 
			
		||||
		unsigned d2 = src.readField(rp,4);
 | 
			
		||||
@@ -222,6 +223,7 @@ void L3BCDDigits::write(L3Frame& dest, size_t &wp) const
 | 
			
		||||
	unsigned index = 0;
 | 
			
		||||
	unsigned numDigits = strlen(mDigits);
 | 
			
		||||
	if (index < numDigits && mDigits[index] == '+') {
 | 
			
		||||
		LOG(DEBUG) << "write got +";
 | 
			
		||||
		index++;
 | 
			
		||||
	}
 | 
			
		||||
	while (index < numDigits) {
 | 
			
		||||
@@ -254,6 +256,7 @@ 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, mType, 3);
 | 
			
		||||
	dest.writeField(wp, mPlan, 4);
 | 
			
		||||
	mDigits.write(dest,wp);
 | 
			
		||||
@@ -265,6 +268,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;
 | 
			
		||||
	mPlan = (NumberingPlan)src.readField(rp, 4);
 | 
			
		||||
	mDigits.parse(src,rp,expectedLength-1, mType == InternationalNumber);
 | 
			
		||||
}
 | 
			
		||||
@@ -289,7 +293,8 @@ void L3CallingPartyBCDNumber::writeV( L3Frame &dest, size_t &wp ) const
 | 
			
		||||
{
 | 
			
		||||
	// If Octet3a is extended, then write 0 else 1.
 | 
			
		||||
	dest.writeField(wp, (!mHaveOctet3a & 0x01), 1);
 | 
			
		||||
	dest.writeField(wp, *digits() == '+' ? InternationalNumber : mType, 3);
 | 
			
		||||
	LOG(DEBUG) << "writeV mType" << mType << " first digit " << *digits();
 | 
			
		||||
	dest.writeField(wp, mType, 3);
 | 
			
		||||
	dest.writeField(wp, mPlan, 4);
 | 
			
		||||
 | 
			
		||||
	if(mHaveOctet3a){
 | 
			
		||||
@@ -306,14 +311,15 @@ void L3CallingPartyBCDNumber::writeV( L3Frame &dest, size_t &wp ) const
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// (pat) 24.018 10.5.4.9 quote: "This IE is not used in the MS to network direction."
 | 
			
		||||
// (pat) 24.008 10.5.4.9 quote: "This IE is not used in the MS to network direction."
 | 
			
		||||
// Which is a good thing because I do not think this parseV is correct.
 | 
			
		||||
void L3CallingPartyBCDNumber::parseV( const L3Frame &src, size_t &rp, size_t expectedLength) 
 | 
			
		||||
{
 | 
			
		||||
	size_t remainingLength = expectedLength;
 | 
			
		||||
	// Read out first bit = 1.
 | 
			
		||||
	mHaveOctet3a = ! src.readField(rp, 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;
 | 
			
		||||
	mPlan = (NumberingPlan)src.readField(rp, 4);
 | 
			
		||||
	remainingLength -= 1;
 | 
			
		||||
 | 
			
		||||
@@ -325,7 +331,7 @@ void L3CallingPartyBCDNumber::parseV( const L3Frame &src, size_t &rp, size_t exp
 | 
			
		||||
		remainingLength -= 1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	mDigits.parse(src,rp,remainingLength);
 | 
			
		||||
	mDigits.parse(src,rp,remainingLength, mType == InternationalNumber);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -58,7 +58,6 @@ using namespace Control;
 | 
			
		||||
 | 
			
		||||
const bool rtpUseRealTime = true;	// Enables a bug fix for the RTP library.
 | 
			
		||||
 | 
			
		||||
// TEMPORARY WORKAROUND : until smqueue can be brought up to speed, this needs enabling by default
 | 
			
		||||
bool gPeerIsBuggySmqueue = true;
 | 
			
		||||
 | 
			
		||||
// These need to be declared here instead of in the header because of interaction with InterthreadQueue.h.
 | 
			
		||||
 
 | 
			
		||||
@@ -79,11 +79,8 @@ SipDialog *SipDialog::newSipDialogMT(DialogType dtype, SipMessage *req)
 | 
			
		||||
		proxy = gConfig.getStr(dtype == SIPDTMTSMS ? "SIP.Proxy.SMS" : "SIP.Proxy.Speech");
 | 
			
		||||
	}
 | 
			
		||||
	SipDialog *dialog = new SipDialog(dtype,proxy,"INVITE or MESSAGE via");
 | 
			
		||||
	/* TEMPORARY WORKAROUND : smqueue needs to handle this "To:" header properly, disabled for now to ship 4.0.	
 | 
			
		||||
	// 2-2014: RFC 3267 8.2.6.2 says the UAS (sip server) MUST add a "to" tag to a response, and MAY add a "to" tag to a provisional (100) response.
 | 
			
		||||
	// The reason is in case the request is forked, the client could distinguish responses from multiple servers, a case that would not happen for us.
 | 
			
		||||
	dialog->dsSetLocalHeaderMT(&req->msmTo,true);	//dtype == SIPDTMTC);
 | 
			
		||||
	*/
 | 
			
		||||
	dialog->dsSetLocalHeaderMT(&req->msmTo,dtype == SIPDTMTC);
 | 
			
		||||
	dialog->dsSetRemoteHeader(&req->msmFrom);
 | 
			
		||||
	//dialog->mSipUsername = req->smUriUsername();	// IMSI/TMSI is in both the URI and the To: header.
 | 
			
		||||
 
 | 
			
		||||
@@ -75,6 +75,11 @@ CPMessage * SMS::parseSMS( const GSM::L3Frame& frame )
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Returns
 | 
			
		||||
	  RPData*
 | 
			
		||||
 | 
			
		||||
 */
 | 
			
		||||
RPData *SMS::hex2rpdata(const char *hexstring)
 | 
			
		||||
{
 | 
			
		||||
	RPData *rp_data = NULL;
 | 
			
		||||
@@ -381,7 +386,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);
 | 
			
		||||
	mDigits.parse(src,rp,length);
 | 
			
		||||
	mDigits.parse(src,rp,length, mType == InternationalNumber);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -71,7 +71,7 @@ class TLAddress : public TLElement {
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
 | 
			
		||||
	GSM::TypeOfNumber mType;
 | 
			
		||||
	GSM::TypeOfNumber mType;  // International and other flags
 | 
			
		||||
	GSM::NumberingPlan mPlan;
 | 
			
		||||
	GSM::L3BCDDigits mDigits;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user