Beispiel #1
0
TLMessage *SMS::parseTPDU(const TLFrame& TPDU, bool directionUplink)
{
	LOG(DEBUG) << "SMS: parseTPDU MTI=" << (TLMessage::MessageType)TPDU.MTI();
	if (directionUplink) {
	  // Handle just the uplink cases.
	  switch ((TLMessage::MessageType)TPDU.MTI()) {
		case TLMessage::DELIVER_REPORT:
		case TLMessage::STATUS_REPORT:
			// FIXME -- Not implemented yet.
			LOG(WARNING) << "Unsupported TPDU type: " << (TLMessage::MessageType)TPDU.MTI();
			return NULL;
		case TLMessage::SUBMIT: {
			TLSubmit *submit = new TLSubmit;
			submit->parse(TPDU);
			LOG(INFO) << "SMS SMS-SUBMIT " << *submit;
			return submit;
		}
		default:
			return NULL;
	  }
	} else {
	  switch ((TLMessage::MessageType)TPDU.MTI()) {
		// 10-2013: Pat added the DELIVER which is the downlink message so we can parse it for reporting purposes.
		case TLMessage::DELIVER: {
			TLDeliver *deliver = new TLDeliver(TPDU);
			return deliver;
		}
		default:
			LOG(WARNING) << "parsing unsupported TPDU type: " << (TLMessage::MessageType)TPDU.MTI();
			return NULL;
	  }
	}
}
/**
	Process the RPDU.
	@param mobileID The sender's IMSI.
	@param RPDU The RPDU to process.
	@return true if successful.
*/
bool handleRPDU(TransactionEntry *transaction, const RLFrame& RPDU)
{
	LOG(DEBUG) << "SMS: handleRPDU MTI=" << RPDU.MTI();
	switch ((RPMessage::MessageType)RPDU.MTI()) {
		case RPMessage::Data: {
			string contentType = gConfig.getStr("SMS.MIMEType");
			ostringstream body;

			if (contentType == "text/plain") {
				// TODO: Clean this mess up!
				RPData data;
				data.parse(RPDU);
				TLSubmit submit;
				submit.parse(data.TPDU());
				
				body << submit.UD().decode();
			} else if (contentType == "application/vnd.3gpp.sms") {
				RPDU.hex(body);
			} else {
				LOG(ALERT) << "\"" << contentType << "\" is not a valid SMS payload type";
			}
			const char* address = NULL;
			if (gConfig.defines("SIP.SMSC")) address = gConfig.getStr("SIP.SMSC").c_str();

			/* The SMSC is not defined, we are using an older version */
			if (address == NULL) {
				RPData data;
				data.parse(RPDU);
				TLSubmit submit;
				submit.parse(data.TPDU());

				address = submit.DA().digits();
			}
			return sendSIP(transaction, address, body.str().data(),contentType.c_str());
		}
		case RPMessage::Ack:
		case RPMessage::SMMA:
			return true;
		case RPMessage::Error:
		default:
			return false;
	}
}
Beispiel #3
0
/**
	Process the incomming RPDU.
	@param mobileID The sender's IMSI.
	@param RPDU The RPDU to process.
	@return true if successful.
*/
bool MOSMSMachine::handleRPDU(const RLFrame& RPDU)
{
	LOG(DEBUG) << "SMS: handleRPDU MTI=" << RPDU.MTI();
	switch ((RPMessage::MessageType)RPDU.MTI()) {
		case RPMessage::Data: {
			string contentType = gConfig.getStr("SMS.MIMEType");
			ostringstream body;
			string toAddress = "";

			if (contentType == "text/plain") {
				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";
			}
			// Steps:
			// 1 -- Complete transaction record.
			// 2 -- Send TL-SUBMIT to the server.
			// 3 -- Wait for response or timeout.
			// 4 -- Return true for OK or ACCEPTED, false otherwise.

			// 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(), toAddress, body.str(), contentType);
			return true;
		}
		case RPMessage::Ack:
		case RPMessage::SMMA:
			return true;
		case RPMessage::Error:
		default:
			return false;
	}
}
Beispiel #4
0
TLMessage *SMS::parseTPDU(const TLFrame& TPDU)
{
	LOG(DEBUG) << "SMS: parseTPDU MTI=" << TPDU.MTI();
	// Handle just the uplink cases.
	switch ((TLMessage::MessageType)TPDU.MTI()) {
		case TLMessage::DELIVER_REPORT:
		case TLMessage::STATUS_REPORT:
			// FIXME -- Not implemented yet.
			LOG(WARNING) << "Unsupported TPDU type: " << (TLMessage::MessageType)TPDU.MTI();
			return NULL;
		case TLMessage::SUBMIT: {
			TLSubmit *submit = new TLSubmit;
			submit->parse(TPDU);
			LOG(INFO) << "SMS SMS-SUBMIT " << *submit;
			return submit;
		}
		default:
			return NULL;
	}
}