MCPcopy Create free account
hub / github.com/RangeNetworks/openbts / startMOSMS

Function startMOSMS

Control/L3SMSControl.cpp:363–411  ·  view source on GitHub ↗

There can be a max of two simultaneous MO-SMS. The CM Service Request to start a new MO-SMS during an existing one may arrive before the final ACK of the previous MO-SMS, as per GSM 4.11 5.4 Therefore there are two MO-SMS possible: MMContext::TE_MOSMS1 is the old one and TE_MOSMS2 is the new one.

Source from the content-addressed store, hash-verified

361// The CM Service Request to start a new MO-SMS during an existing one may arrive before the final ACK of the previous MO-SMS, as per GSM 4.11 5.4
362// Therefore there are two MO-SMS possible: MMContext::TE_MOSMS1 is the old one and TE_MOSMS2 is the new one.
363void startMOSMS(const GSM::L3MMMessage *l3msg, MMContext *mmchan)
364{
365 LOG(DEBUG) <<mmchan;
366 //now we allocate below: TranEntry *tran = TranEntry::newMO(dcch, L3CMServiceType::ShortMessage);
367
368 //MMContext *set = dcch->chanGetContext(true);
369 RefCntPointer<TranEntry> prevMOSMS = mmchan->mmGetTran(MMContext::TE_MOSMS1);
370 if (! prevMOSMS.self()) {
371 // happiness.
372 //set->setTran(MMContext::TE_MOSMS1,tran);
373 //tran->teConnectChannel(dcch,TE_MOSMS1);
374 } else {
375 // Check for perfidy on the part of the MS: it cannot start a new MO-SMS unless the previous is nearly finished.
376 //SmsState smsState = getCurrentSMSState();
377 MachineBase *base = prevMOSMS->currentProcedure();
378 bool badbunny = false;
379 if (base) { // This may happen if the MS is a bad bunny and sends two CM Sevice Requests effectively simultaneously.
380 MOSMSMachine *smssm = dynamic_cast<typeof(smssm)>(base);
381 if (! smssm || smssm->mSmsState != MoSmsWaitForAck) {
382 badbunny = true;
383 }
384 } else {
385 badbunny = true;
386 }
387
388 if (badbunny) {
389 LOG(ERR) << "Received new MO-SMS before previous MO-SMS completed"<<LOGVAR2("MOSMS",prevMOSMS.self())<<l3msg;
390 // Now what? We've already got an SMS running...
391 return; // Just ignore it.
392 }
393
394 RefCntPointer<TranEntry> prevMOSMS2 = mmchan->mmGetTran(MMContext::TE_MOSMS2);
395 if (prevMOSMS2.self()) {
396 LOG(ERR) <<"Received third simultaneous MO-SMS, which is illegal:"<<LOGVAR2("MO-SMS1",prevMOSMS.self())<<LOGVAR2("MO-SMS2",prevMOSMS2.self());
397 // Now what? We could kill the oldest one or reject the new one.
398 // Kill the oldest one, on the assumption that this indicates a bug in our code and that SMS is hung.
399 prevMOSMS->teCancel(); // Promotes TE_MOSMS2 to TE_MOSMS1
400 devassert(mmchan->mmGetTran(MMContext::TE_MOSMS2) == NULL);
401 }
402 //mmchan->setTran(MMContext::TE_MOSMS2,tran);
403 //tran->teConnectChannel(mmchan,MMContext::TE_MOSMS2);
404 }
405 TranEntry *tran = TranEntry::newMOSMS(mmchan);
406
407 // Fire up an SMS state machine for this transaction.
408 MOSMSMachine *mocp = new MOSMSMachine(tran);
409 // The message is CMServiceRequest.
410 tran->lockAndStart(mocp,(GSM::L3Message*)l3msg);
411}
412
413// Return true on success.
414bool MTSMSMachine::createRPData(RPData &rp_data)

Callers 1

NewCMServiceResponderFunction · 0.85

Calls 4

mmGetTranMethod · 0.80
teCancelMethod · 0.80
lockAndStartMethod · 0.80
currentProcedureMethod · 0.45

Tested by

no test coverage detected