Receive the identity response which may be IMSI or IMEI
| 480 | |
| 481 | // Receive the identity response which may be IMSI or IMEI |
| 482 | MachineStatus LUStart::stateRecvIdentityResponse(const GSM::L3IdentityResponse *resp) |
| 483 | { |
| 484 | //const GSM::L3IdentityResponse *resp = dynamic_cast<typeof(resp)>(l3msg); |
| 485 | LOG(INFO) << *resp; |
| 486 | MobileIDType idtype = resp->mobileID().type(); |
| 487 | // Meaningful IdentityResponse? |
| 488 | |
| 489 | // Store the result, even if it was not what we asked for. |
| 490 | if (idtype == IMSIType) { |
| 491 | string imsi = string(resp->mobileID().digits()); |
| 492 | |
| 493 | { |
| 494 | // Check for perfidy on the part of the MS. We're checking that it did not send two different IMSIs in the same attempt, |
| 495 | // something that will probably never happen. |
| 496 | string prevImsi = getImsi(); |
| 497 | if (prevImsi.size() && prevImsi != imsi) { |
| 498 | LOG(ERR) << "MS returned two different IMSIs"; |
| 499 | MMRejectCause failCause = L3RejectCause::InvalidMandatoryInformation; |
| 500 | // There is no ludata()->store yet so just set it directly: |
| 501 | gTMSITable.tmsiTabSetRejected(imsi,(int)failCause); |
| 502 | // I dont know what the cause should be here, but if this ever happens, we dont care. |
| 503 | channel()->l3sendm(L3LocationUpdatingReject(failCause)); |
| 504 | return closeChannel(L3RRCause::NormalEvent,RELEASE); |
| 505 | } |
| 506 | } |
| 507 | |
| 508 | tran()->setSubscriberImsi(imsi,false); |
| 509 | //gMMLayer.mmBlockImsi(imsi); |
| 510 | |
| 511 | // If this is the second attempt, we could check if this IMSI matches what we had on record, |
| 512 | // and if so just reject immediately, but this doesn't happen often and I'm just going to let it proceed again |
| 513 | // with the whole registration process. |
| 514 | LOG(DEBUG) <<LOGVAR(imsi) <<LOGVAR(ludata()->mSecondAttempt) <<LOGVAR(ludata()->mPrevRegisterAttemptImsi) <<LOGVAR(ludata()->getTmsiStatus()); |
| 515 | if (ludata()->mSecondAttempt == 0) { |
| 516 | // The MS sent a TMSI that was unrecognized, so we queried for the IMSI. |
| 517 | assert(ludata()->getTmsiStatus() == tmsiNone); |
| 518 | } else { |
| 519 | // The second attempt means that registration by TMSI failed, so we queried for the imsi. |
| 520 | // If the IMSI matches what is in the TMSI table, it is a genuine failure. |
| 521 | devassert(ludata()->mPrevRegisterAttemptImsi.size()); |
| 522 | if (ludata()->mPrevRegisterAttemptImsi == imsi) { |
| 523 | // It was not a TMSI collision; this subscriber is really unauthorized. |
| 524 | // The register procedure already called regSetFail. |
| 525 | devassert(ludata()->mRegistrationResult.isValid()); |
| 526 | return callMachStart(new LUFinish(tran())); |
| 527 | } |
| 528 | // We already assigned the new imsi above. We just fall through to try another registration. |
| 529 | assert(ludata()->getTmsiStatus() == tmsiFailed); |
| 530 | } |
| 531 | } else if (idtype == IMEIType) { |
| 532 | // We do not check whether the IMEI matches what we may have stored already because |
| 533 | // we dont care if the user has switched their SIM card to a new handset. |
| 534 | ludata()->store.setImei(string(resp->mobileID().digits())); |
| 535 | } else { |
| 536 | LOG(WARNING) << "MS Identity Response unexpected type: " << idtype; |
| 537 | return MachineStatusOK; // Just ignore it. T3270 is still running. Maybe it will return what we asked for later. |
| 538 | } |
| 539 |
nothing calls this directly
no test coverage detected