当前位置: 首页>>代码示例>>C++>>正文


C++ TransactionEntry::message方法代码示例

本文整理汇总了C++中TransactionEntry::message方法的典型用法代码示例。如果您正苦于以下问题:C++ TransactionEntry::message方法的具体用法?C++ TransactionEntry::message怎么用?C++ TransactionEntry::message使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TransactionEntry的用法示例。


在下文中一共展示了TransactionEntry::message方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: checkInvite

bool SIPInterface::checkInvite( osip_message_t * msg)
{
	LOG(DEBUG);

	// This code dispatches new transactions coming from the network-side SIP interface.
	// All transactions originating here are going to be mobile-terminated.
	// Yes, this method is too long and needs to be broken up into smaller steps.

	// Is there even a method?
	const char *method = msg->sip_method;
	if (!method) return false;

	// Check for INVITE or MESSAGE methods.
	// Check channel availability now, too.
	GSM::ChannelType requiredChannel;
	bool channelAvailable = false;
	GSM::L3CMServiceType serviceType;
	// pretty sure strings are garbage collected
	string proxy = get_return_address(msg);
	if (strcmp(method,"INVITE") == 0) {
		// INVITE is for MTC.
		// Set the required channel type to match the assignment style.
		if (gConfig.defines("Control.VEA")) {
			// Very early assignment.
			requiredChannel = GSM::TCHFType;
			channelAvailable = gBTS.TCHAvailable();
		} else {
			// Early assignment
			requiredChannel = GSM::SDCCHType;
			channelAvailable = gBTS.SDCCHAvailable() && gBTS.TCHAvailable();
		}
		serviceType = L3CMServiceType::MobileTerminatedCall;
	}
	else if (strcmp(method,"MESSAGE") == 0) {
		// MESSAGE is for MTSMS.
		requiredChannel = GSM::SDCCHType;
		channelAvailable = gBTS.SDCCHAvailable();
		serviceType = L3CMServiceType::MobileTerminatedShortMessage;
	}
	else {
		// Not a method handled here.
		LOG(DEBUG) << "non-initiating SIP method " << method;
		return false;
	}

	// Get request username (IMSI) from invite. 
	const char* IMSI = extractIMSI(msg);
	if (!IMSI) {
		// FIXME -- Send appropriate error (404) on SIP interface.
		LOG(WARNING) << "Incoming INVITE/MESSAGE with no IMSI";
		return false;
	}
	L3MobileIdentity mobileID(IMSI);

	// Get the SIP call ID.
	const char * callIDNum = extractCallID(msg);	
	if (!callIDNum) {
		// FIXME -- Send appropriate error on SIP interface.
		LOG(WARNING) << "Incoming INVITE/MESSAGE with no call ID";
		return false;
	}


	// Find any active transaction for this IMSI with an assigned TCH or SDCCH.
	GSM::LogicalChannel *chan = gTransactionTable.findChannel(mobileID);
	if (chan) {
		// If the type is TCH and the service is SMS, get the SACCH.
		// Otherwise, for now, just say chan=NULL.
		if (serviceType==L3CMServiceType::MobileTerminatedShortMessage && chan->type()==FACCHType) {
			chan = chan->SACCH();
		} else {
			// FIXME -- This will change to support multiple transactions.
			chan = NULL;
		}
	}

	// Check SIP map.  Repeated entry?  Page again.
	if (mSIPMap.map().readNoBlock(callIDNum) != NULL) { 
		TransactionEntry* transaction= gTransactionTable.find(mobileID,callIDNum);
		// There's a FIFO but no trasnaction record?
		if (!transaction) {
			LOG(WARNING) << "repeated INVITE/MESSAGE with no transaction record";
			// Delete the bogus FIFO.
			mSIPMap.remove(callIDNum);
			return false;
		}
		// There is transaction already.  Send trying, if appropriate.
		if (serviceType!=L3CMServiceType::MobileTerminatedShortMessage) transaction->MTCSendTrying();
		// And if no channel is established yet, page again.
		if (!chan) {
			LOG(INFO) << "repeated SIP INVITE/MESSAGE, repaging for transaction " << *transaction; 
			gBTS.pager().addID(mobileID,requiredChannel,*transaction);
		}
		return false;
	}

	// So we will need a new channel.
	// Check gBTS for channel availability.
	if (!chan && !channelAvailable) {
		// FIXME -- Send 503 "Service Unavailable" response on SIP interface.
//.........这里部分代码省略.........
开发者ID:5728136cs,项目名称:Mobile_Netze_HM_OpenBTS_Handover,代码行数:101,代码来源:SIPInterface.cpp

示例2: checkInvite

bool SIPInterface::checkInvite( osip_message_t * msg )
{
	LOG(DEBUG);

	// Is there even a method?
	const char *method = msg->sip_method;
	if (!method) return false;

	// Check for INVITE or MESSAGE methods.
	GSM::ChannelType requiredChannel;
	bool channelAvailable = false;
	bool shouldPage = true;
	GSM::L3CMServiceType serviceType;
	if (strcmp(method,"INVITE") == 0) {
		// INVITE is for MTC.
		// Set the required channel type to match the assignment style.
		if (gConfig.defines("GSM.VEA")) {
			// Very early assignment.
			requiredChannel = GSM::TCHFType;
			channelAvailable = gBTS.TCHAvailable();
		} else {
			// Early assignment
			requiredChannel = GSM::SDCCHType;
			channelAvailable = gBTS.SDCCHAvailable() && gBTS.TCHAvailable();
		}
		serviceType = L3CMServiceType::MobileTerminatedCall;
	}
	else if (strcmp(method,"MESSAGE") == 0) {
		// MESSAGE is for MTSMS or USSD
      if (  strcmp(gConfig.getStr("USSD.SIP.user"), msg->from->url->username)==0
         && strcmp(gConfig.getStr("USSD.SIP.domain"), msg->from->url->host)==0)
      {
         LOG(INFO) << "received MESSAGE is USSD from: "
                   << msg->from->url->username << "@" << msg->from->url->host;
         requiredChannel = GSM::SDCCHType;
			// TODO:: Understand how to behave when we need to page?
         channelAvailable = true; //gBTS.SDCCHAvailable();
         serviceType = L3CMServiceType::SupplementaryService;
      }
      else
      {
         LOG(INFO) << "received MESSAGE is SMS from: "
                   << msg->from->url->username << "@" << msg->from->url->host;
         requiredChannel = GSM::SDCCHType;
         channelAvailable = gBTS.SDCCHAvailable();
         serviceType = L3CMServiceType::MobileTerminatedShortMessage;
      }
	}
	else {
		// We must not handle this method.
		LOG(DEBUG) << "non-initiating SIP method " << method;
		return false;
	}

	// Check gBTS for channel availability.
	if (!channelAvailable) {
		// FIXME -- Send 503 "Service Unavailable" response on SIP interface.
		LOG(NOTICE) << "MTC CONGESTION, no " << requiredChannel << " availble for assignment";
		return false;
	}
	LOG(INFO) << "set up MTC paging for channel=" << requiredChannel;

	// Get call_id from invite message.
	if (!msg->call_id) {
		// FIXME -- Send appropriate error on SIP interface.
		LOG(WARN) << "Incoming INVITE/MESSAGE with no call ID";
		return false;
	}

	// Don't free call_id_num.  It points into msg->call_id.
	const char * call_id_num = osip_call_id_get_number(msg->call_id);	

	// Get request username (IMSI) from invite. 
	// Form of the name is IMSI<digits>, and it should always be 19 char.
	const char * IMSI = msg->req_uri->username;
	LOG(INFO) << msg->sip_method << " to "<< IMSI;
	// IMSIs are 14 or 15 char + "IMSI" prefix
	unsigned namelen = strlen(IMSI);
	if ((namelen>19)||(namelen<18)) {
		LOG(WARN) << "INVITE/MESSAGE with malformed username \"" << IMSI << "\"";
		return false;
	}
	// Skip first 4 char "IMSI".
	IMSI+=4;
	// Make the mobile id we need for transaction and paging entries.
	L3MobileIdentity mobile_id(IMSI);

	// Check SIP map.  Repeated entry?  Page again.
	// Skip this for USSD.
	if (  mSIPMap.map().readNoBlock(call_id_num) != NULL) {
		TransactionEntry transaction;
		if (!gTransactionTable.find(mobile_id,transaction)) {
			// FIXME -- Send "call leg non-existent" response on SIP interface.
			LOG(WARN) << "repeated INVITE/MESSAGE with no transaction record";
			// Delete the bogus FIFO.
			mSIPMap.remove(call_id_num);
			return false;
		}
		LOG(INFO) << "repeated SIP INVITE/MESSAGE, repaging for transaction " << transaction; 
		gBTS.pager().addID(mobile_id,requiredChannel,transaction);	
//.........这里部分代码省略.........
开发者ID:0x7678,项目名称:openbts-uhd,代码行数:101,代码来源:SIPInterface.cpp

示例3: MTSMSController

void Control::MTSMSController(TransactionEntry& transaction, 
						LogicalChannel *LCH)
{
	assert(LCH);

	// HACK: At this point if the message starts with "RRLP" then we don't do SMS at all,
	// but instead to an RRLP transaction over the already allocated LogicalChannel.
	const char* m = transaction.message(); // NOTE - not very nice, my way of checking.
	if ((strlen(m) > 4) && (std::string("RRLP") == std::string(m, m+4))) {
		const char *transaction_hex = transaction.message() + 4;
		BitVector rrlp_position_request(strlen(transaction_hex)*4);
		rrlp_position_request.unhex(transaction_hex);
		LOG(INFO) << "MTSMS: Sending RRLP";
		// TODO - how to get mobID here?
		L3MobileIdentity mobID = L3MobileIdentity("000000000000000");
		RRLP::PositionResult pr = GSM::RRLP::doRRLPQuery(mobID, LCH, rrlp_position_request);
		if (pr.mValid) // in this case we only want to log the results which contain lat/lon
			logMSInfo(LCH, pr, mobID);
		LOG(INFO) << "MTSMS: Closing channel after RRLP";
		LCH->send(L3ChannelRelease());
		clearTransactionHistory(transaction);
		return;
	}

	// See GSM 04.11 Arrow Diagram A5 for the transaction
	// Step 1	Network->MS	CP-DATA containing RP-DATA
	// Step 2	MS->Network	CP-ACK
	// Step 3	MS->Network	CP-DATA containing RP-ACK
	// Step 4	Network->MS	CP-ACK

	// LAPDm operation, from GSM 04.11, Annex F:
	// """
	// Case B: Mobile terminating short message transfer, no parallel call:
	// The network side, i.e. the BSS will initiate SAPI3 establishment by a
	// SABM command on the SDCCH when the first CP-Data message is received
	// from the MSC. If no hand over occurs, the link will stay up until the
	// MSC has given the last CP-ack and invokes the clearing procedure. 
	// """

	LOG(INFO) << "MTSMS: transaction: "<< transaction;
	LCH->transactionID(transaction.ID());	
	SIPEngine& engine = transaction.SIP();

	// Update transaction state.
	transaction.Q931State(TransactionEntry::SMSDelivering);
	gTransactionTable.update(transaction);

	try {
		bool success = deliverSMSToMS(transaction.calling().digits(),transaction.message(),random()%7,LCH);

		// Close the Dm channel.
		LOG(INFO) << "MTSMS: closing";
		LCH->send(L3ChannelRelease());

		// Ack in SIP domain and update transaction state.
		if (success) {
			engine.MTSMSSendOK();
			clearTransactionHistory(transaction);
		}
	}
	catch (UnexpectedMessage) {
		// TODO -- MUST SEND PERMANENT ERROR HERE!!!!!!!!!
		engine.MTSMSSendOK();
		LCH->send(L3ChannelRelease());
		clearTransactionHistory(transaction);
	}
	catch (UnsupportedMessage) {
		// TODO -- MUST SEND PERMANENT ERROR HERE!!!!!!!!!
		engine.MTSMSSendOK();
		LCH->send(L3ChannelRelease());
		clearTransactionHistory(transaction);
	}
}
开发者ID:0x7678,项目名称:openbts-uhd,代码行数:73,代码来源:SMSControl.cpp


注:本文中的TransactionEntry::message方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。