Skip to content

Commit 627a5de

Browse files
committed
Adding common utility file to have common functions defined
Signed-off-by: rashmi <[email protected]>
1 parent e48c77b commit 627a5de

File tree

3 files changed

+76
-2
lines changed

3 files changed

+76
-2
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#define pragma once
2+
3+
#ifdef __cplusplus
4+
extern "C" {
5+
#endif
6+
7+
#include "mme_config.h"
8+
#include "log.h"
9+
#include "conversions.h"
10+
#include "common_defs.h"
11+
12+
int match_fed_mode_map(const char* imsi, log_proto_t module);
13+
#ifdef __cplusplus
14+
}
15+
#endif

lte/gateway/c/oai/tasks/mme_app/mme_app_itti_messaging.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,4 @@ void mme_app_itti_sgsap_tmsi_reallocation_comp(
131131

132132
void mme_app_itti_sgsap_ue_activity_ind(
133133
const char* imsi, const unsigned int imsi_len);
134-
135-
int mme_app_match_fed_mode_map(const uint8_t* imsi, imsi64_t imsi64);
136134
#endif /* FILE_MME_APP_ITTI_MESSAGING_SEEN */

0 commit comments

Comments
 (0)