|
| 1 | +/* |
| 2 | +Copyright 2020 The Magma Authors. |
| 3 | +
|
| 4 | +This source code is licensed under the BSD-style license found in the |
| 5 | +LICENSE file in the root directory of this source tree. |
| 6 | +
|
| 7 | +Unless required by applicable law or agreed to in writing, software |
| 8 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 9 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 10 | +See the License for the specific language governing permissions and |
| 11 | +limitations under the License. |
| 12 | +*/ |
| 13 | +#pragma once |
| 14 | + |
| 15 | +#include <stdint.h> |
| 16 | +#include <iostream> |
| 17 | +#include "common_utility_funs.h" |
| 18 | +#include "lte/protos/mconfig/mconfigs.pb.h" |
| 19 | + |
| 20 | +// Extract MCC and MNC from the imsi received and match with |
| 21 | +// configuration |
| 22 | +extern "C" int match_fed_mode_map(const char* imsi, log_proto_t module) { |
| 23 | + OAILOG_FUNC_IN(module); |
| 24 | + imsi64_t imsi64; |
| 25 | + IMSI_STRING_TO_IMSI64(imsi, &imsi64); |
| 26 | + uint8_t mcc_d1 = imsi[0] - '0'; |
| 27 | + uint8_t mcc_d2 = imsi[1] - '0'; |
| 28 | + uint8_t mcc_d3 = imsi[2] - '0'; |
| 29 | + uint8_t mnc_d1 = imsi[3] - '0'; |
| 30 | + uint8_t mnc_d2 = imsi[4] - '0'; |
| 31 | + uint8_t mnc_d3 = imsi[5] - '0'; |
| 32 | + if ((mcc_d1 < 0 || mcc_d1 > 9) || (mcc_d2 < 0 || mcc_d2 > 9) || |
| 33 | + (mcc_d3 < 0 || mcc_d3 > 9) || (mnc_d1 < 0 || mnc_d1 > 9) || |
| 34 | + (mnc_d2 < 0 || mnc_d2 > 9) || (mnc_d3 < 0 || mnc_d3 > 9)) { |
| 35 | + OAILOG_ERROR_UE(module, imsi64, "MCC/MNC is not a decimal digit \n"); |
| 36 | + OAILOG_FUNC_RETURN(module, RETURNerror); |
| 37 | + } |
| 38 | + for (uint8_t itr = 0; itr < mme_config.mode_map_config.num; itr++) { |
| 39 | + if (((mcc_d1 == mme_config.mode_map_config.mode_map[itr].plmn.mcc_digit1) && |
| 40 | + (mcc_d2 == mme_config.mode_map_config.mode_map[itr].plmn.mcc_digit2) && |
| 41 | + (mcc_d3 == mme_config.mode_map_config.mode_map[itr].plmn.mcc_digit3) && |
| 42 | + (mnc_d1 == mme_config.mode_map_config.mode_map[itr].plmn.mnc_digit1) && |
| 43 | + (mnc_d2 == |
| 44 | + mme_config.mode_map_config.mode_map[itr].plmn.mnc_digit2))) { |
| 45 | + if (mme_config.mode_map_config.mode_map[itr].plmn.mnc_digit3 != 0xf) { |
| 46 | + if (mnc_d3 != |
| 47 | + mme_config.mode_map_config.mode_map[itr].plmn.mnc_digit3) { |
| 48 | + continue; |
| 49 | + } |
| 50 | + } |
| 51 | + OAILOG_FUNC_RETURN(module, mme_config.mode_map_config.mode_map[itr].mode); |
| 52 | + } |
| 53 | + } |
| 54 | + // If the plmn is not configured set the default mode as hss + spgw_task. |
| 55 | + OAILOG_INFO_UE( |
| 56 | + module, imsi64, |
| 57 | + "PLMN is not configured. Selecting default mode: SPGW_SUBSCRIBER \n"); |
| 58 | + OAILOG_FUNC_RETURN( |
| 59 | + module, magma::mconfig::ModeMapItem_FederatedMode_SPGW_SUBSCRIBER); |
| 60 | +} |
| 61 | + |
0 commit comments