Skip to content

Commit 072426f

Browse files
committed
fix(agw): Modified code to port s1ap_state to protobuf structure
Signed-off-by: Rashmi <[email protected]>
1 parent 1f568cf commit 072426f

20 files changed

+243
-203
lines changed

lte/gateway/c/core/oai/include/s1ap_state.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ int s1ap_state_init(uint32_t max_ues, uint32_t max_enbs, bool use_stateless);
3333

3434
void s1ap_state_exit(void);
3535

36-
s1ap_state_t* get_s1ap_state(bool read_from_db);
36+
S1apState* get_s1ap_state(bool read_from_db);
3737

3838
void put_s1ap_state(void);
3939

40-
magma::lte::oai::EnbDescription* s1ap_state_get_enb(s1ap_state_t* state,
40+
magma::lte::oai::EnbDescription* s1ap_state_get_enb(S1apState* state,
4141
sctp_assoc_id_t assoc_id);
4242

4343
oai::UeDescription* s1ap_state_get_ue_enbid(
@@ -88,7 +88,7 @@ bool s1ap_ue_compare_by_imsi(__attribute__((unused)) uint64_t keyP,
8888
void remove_ues_without_imsi_from_ue_id_coll(void);
8989

9090
void clean_stale_enb_state(
91-
s1ap_state_t* state, oai::EnbDescription* new_enb_association);
91+
S1apState* state, oai::EnbDescription* new_enb_association);
9292

9393
} // namespace lte
9494
} // namespace magma

lte/gateway/c/core/oai/tasks/grpc_service/S1apServiceImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Status S1apServiceImpl::GetENBState(ServerContext* context, const Void* request,
4444
// Get state from S1APStateManager
4545
// TODO: Get state through ITTI message from S1AP task, as it's read only
4646
// it will not affect ownership
47-
s1ap_state_t* s1ap_state = get_s1ap_state(false);
47+
S1apState* s1ap_state = get_s1ap_state(false);
4848
if (s1ap_state != nullptr) {
4949
if (!(s1ap_state->enbs.size())) {
5050
return Status::OK;

lte/gateway/c/core/oai/tasks/ha/ha_service_handler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ bool sync_up_with_orc8r(void) {
7373
}
7474

7575
typedef struct callback_data_s {
76-
s1ap_state_t* s1ap_state;
76+
S1apState* s1ap_state;
7777
ha_agw_offload_req_t* request;
7878
} callback_data_t;
7979

@@ -94,7 +94,7 @@ bool trigger_agw_offload_for_ue(const hash_key_t keyP, void* const elementP,
9494
callback_data_t* callback_data = (callback_data_t*)parameterP;
9595
ha_agw_offload_req_t* offload_request =
9696
(ha_agw_offload_req_t*)callback_data->request;
97-
s1ap_state_t* s1ap_state = (s1ap_state_t*)callback_data->s1ap_state;
97+
S1apState* s1ap_state = (S1apState*)callback_data->s1ap_state;
9898
struct ue_mm_context_s* ue_context_p = (struct ue_mm_context_s*)elementP;
9999
bool any_flag = false; // true if we tried offloading any UE
100100

lte/gateway/c/core/oai/tasks/s1ap/s1ap_common.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ extern int asn1_xer_print;
429429

430430
/** \brief Function callback prototype.
431431
**/
432-
typedef status_code_e (*s1ap_message_handler_t)(s1ap_state_t* state,
432+
typedef status_code_e (*s1ap_message_handler_t)(S1apState* state,
433433
const sctp_assoc_id_t assoc_id,
434434
const sctp_stream_id_t stream,
435435
S1ap_S1AP_PDU_t* pdu);

lte/gateway/c/core/oai/tasks/s1ap/s1ap_mme.cpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,9 @@ static int s1ap_send_init_sctp(void) {
105105
}
106106

107107
static int handle_message(zloop_t* loop, zsock_t* reader, void* arg) {
108-
s1ap_state_t* state;
109108
MessageDef* received_message_p = receive_msg(reader);
110109
imsi64_t imsi64 = itti_get_associated_imsi(received_message_p);
111-
state = get_s1ap_state(false);
110+
S1apState* state = get_s1ap_state(false);
112111
AssertFatal(state != NULL, "failed to retrieve s1ap state (was null)");
113112

114113
bool is_task_state_same = false;
@@ -400,7 +399,7 @@ oai::EnbDescription* s1ap_new_enb(void) {
400399
}
401400

402401
//------------------------------------------------------------------------------
403-
oai::UeDescription* s1ap_new_ue(s1ap_state_t* state,
402+
oai::UeDescription* s1ap_new_ue(S1apState* state,
404403
const sctp_assoc_id_t sctp_assoc_id,
405404
enb_ue_s1ap_id_t enb_ue_s1ap_id) {
406405
oai::EnbDescription* enb_ref = NULL;
@@ -446,7 +445,7 @@ oai::UeDescription* s1ap_new_ue(s1ap_state_t* state,
446445
}
447446

448447
//------------------------------------------------------------------------------
449-
void s1ap_remove_ue(s1ap_state_t* state, oai::UeDescription* ue_ref) {
448+
void s1ap_remove_ue(S1apState* state, oai::UeDescription* ue_ref) {
450449
oai::EnbDescription* enb_ref = NULL;
451450

452451
// NULL reference...
@@ -476,7 +475,10 @@ void s1ap_remove_ue(s1ap_state_t* state, oai::UeDescription* ue_ref) {
476475
return;
477476
}
478477
s1ap_ue_state->remove(ue_ref->comp_s1ap_id());
479-
state->mmeid2associd.remove(mme_ue_s1ap_id);
478+
proto_map_uint32_uint32_t mmeid2associd_map.map =
479+
state->mutable_mmeid2associd();
480+
mmeid2associd_map.remove(mme_ue_s1ap_id);
481+
480482
magma::proto_map_uint32_uint64_t ue_id_coll;
481483
ue_id_coll.map = enb_ref->mutable_ue_id_map();
482484
ue_id_coll.remove(mme_ue_s1ap_id);
@@ -494,7 +496,7 @@ void s1ap_remove_ue(s1ap_state_t* state, oai::UeDescription* ue_ref) {
494496
OAILOG_INFO(LOG_S1AP, "Moving eNB state to S1AP_INIT \n");
495497
enb_ref->set_s1_state(magma::lte::oai::S1AP_INIT);
496498
set_gauge("s1_connection", 0, 1, "enb_name", enb_ref->enb_name());
497-
state->num_enbs--;
499+
state->set_num_enbs(state->num_enbs() - 1);
498500
} else if (enb_ref->s1_enb_state() == magma::lte::oai::S1AP_SHUTDOWN) {
499501
OAILOG_INFO(LOG_S1AP, "Deleting eNB \n");
500502
set_gauge("s1_connection", 0, 1, "enb_name", enb_ref->enb_name());
@@ -504,25 +506,27 @@ void s1ap_remove_ue(s1ap_state_t* state, oai::UeDescription* ue_ref) {
504506
}
505507

506508
//------------------------------------------------------------------------------
507-
void s1ap_remove_enb(s1ap_state_t* state, oai::EnbDescription* enb_ref) {
509+
void s1ap_remove_enb(S1apState* state, oai::EnbDescription* enb_ref) {
508510
if (enb_ref == NULL) {
509511
return;
510512
}
511513
magma::proto_map_uint32_uint64_t ue_id_coll;
514+
map_uint32_enb_description_t enb_map;
512515
enb_ref->set_s1_state(magma::lte::oai::S1AP_INIT);
513516

514517
ue_id_coll.map = enb_ref->mutable_ue_id_map();
515518
ue_id_coll.clear();
516519
OAILOG_INFO(LOG_S1AP, "Deleting eNB on assoc_id :%u\n",
517520
enb_ref->sctp_assoc_id());
518-
state->enbs.remove(enb_ref->sctp_assoc_id());
519-
state->num_enbs--;
521+
enb_map.map = state->mutable_enbs();
522+
enb_map.remove(enb_ref->sctp_assoc_id());
523+
state->set_num_enbs(state->num_enbs() - 1);
520524
}
521525

522526
static int handle_stats_timer(zloop_t* loop, int id, void* arg) {
523-
s1ap_state_t* s1ap_state_p = get_s1ap_state(false);
527+
S1apState* s1ap_state_p = get_s1ap_state(false);
524528
application_s1ap_stats_msg_t stats_msg;
525-
stats_msg.nb_enb_connected = s1ap_state_p->num_enbs;
529+
stats_msg.nb_enb_connected = s1ap_state_p->num_enbs();
526530
stats_msg.nb_s1ap_last_msg_latency = s1ap_last_msg_latency;
527531
return send_s1ap_stats_to_service303(&s1ap_task_zmq_ctx, TASK_S1AP,
528532
&stats_msg);

lte/gateway/c/core/oai/tasks/s1ap/s1ap_mme.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,21 @@ magma::lte::oai::EnbDescription* s1ap_new_enb(void);
6060
* \param enb_ue_s1ap_id ue ID over S1AP
6161
* @returns Reference to the new UE element in list
6262
**/
63-
oai::UeDescription* s1ap_new_ue(s1ap_state_t* state,
63+
oai::UeDescription* s1ap_new_ue(S1apState* state,
6464
sctp_assoc_id_t sctp_assoc_id,
6565
enb_ue_s1ap_id_t enb_ue_s1ap_id);
6666

6767
/** \brief Remove target UE from the list
6868
* \param ue_ref UE structure reference to remove
6969
**/
70-
void s1ap_remove_ue(s1ap_state_t* state,
70+
void s1ap_remove_ue(S1apState* state,
7171
oai::UeDescription* ue_ref);
7272

7373
/** \brief Remove target eNB from the list and remove any UE associated
7474
* \param enb_ref eNB structure reference to remove
7575
**/
76-
void s1ap_remove_enb(s1ap_state_t* state,
77-
magma::lte::oai::EnbDescription* enb_ref);
76+
void s1ap_remove_enb(S1apState* state,
77+
oai::EnbDescription* enb_ref);
7878

7979
void free_enb_description(void** ptr);
8080

0 commit comments

Comments
 (0)