Skip to content

Commit

Permalink
Add s1ap_state get enb/ue funcs
Browse files Browse the repository at this point in the history
Summary:
As part of our goal to make MME stateless (can crash/update and come back up without losing enb/ue context), we are making the S1AP task stateless as a POC. To make a C program "stateless", we are going off the idea that only the database state needs to be good at all times -- therefore we let the message/state processing happen as normal except that the state is moved from separate globals into one global state that is committed to the db at the end of processing each message.

In this diff, we add getter functions for several parts of S1AP task state (get enb and ue). The purpose of this is to mask implementation detail about how ue's and enb's are stored so that we can change the implementation from OAI hashtable's with manual memory management to C++ maps in the future.

Reviewed By: ssanadhya

Differential Revision: D14685279

fbshipit-source-id: 7b99a936bab0af073bba91cc4c59dbbf626fd7f7
  • Loading branch information
sciencemanx authored and facebook-github-bot committed Apr 3, 2019
1 parent f65744f commit d68fac6
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 4 deletions.
4 changes: 0 additions & 4 deletions lte/gateway/c/oai/common/security_types.h
Expand Up @@ -38,10 +38,6 @@
#include "config.h"
#endif

#if !defined(HAVE_UINT128_T)
#include <gmp.h>
#endif

#ifndef FILE_SECURITY_TYPES_SEEN
#define FILE_SECURITY_TYPES_SEEN

Expand Down
39 changes: 39 additions & 0 deletions lte/gateway/c/oai/tasks/s1ap/s1ap_state.cpp
Expand Up @@ -114,6 +114,45 @@ void s1ap_state_put(s1ap_state_t *state)
in_use = false;
}

enb_description_t *s1ap_state_get_enb(
s1ap_state_t *state,
sctp_assoc_id_t assoc_id)
{
enb_description_t *enb = NULL;

hashtable_ts_get(&state->enbs, (const hash_key_t) assoc_id, (void **) &enb);

return enb;
}

ue_description_t *s1ap_state_get_ue_enbid(
s1ap_state_t *state,
enb_description_t *enb,
enb_ue_s1ap_id_t enb_ue_s1ap_id)
{
ue_description_t *ue = NULL;

hashtable_ts_get(
&enb->ue_coll, (const hash_key_t) enb_ue_s1ap_id, (void **) &ue);

return ue;
}

ue_description_t *s1ap_state_get_ue_mmeid(
s1ap_state_t *state,
mme_ue_s1ap_id_t mme_ue_s1ap_id)
{
ue_description_t *ue = NULL;

hashtable_ts_apply_callback_on_elements(
&state->enbs,
s1ap_enb_find_ue_by_mme_ue_id_cb,
&mme_ue_s1ap_id,
(void **) &ue);

return ue;
}

s1ap_state_t *s1ap_state_new(void)
{
s1ap_state_t *state;
Expand Down
13 changes: 13 additions & 0 deletions lte/gateway/c/oai/tasks/s1ap/s1ap_state.h
Expand Up @@ -27,6 +27,8 @@ extern "C" {

#include "hashtable.h"

#include "s1ap_mme.h"

typedef struct s1ap_state_s {
// contains eNB_description_s, key is eNB_description_s.enb_id (uint32_t)
hash_table_ts_t enbs;
Expand All @@ -40,6 +42,17 @@ void s1ap_state_exit(void);
s1ap_state_t *s1ap_state_get(void);
void s1ap_state_put(s1ap_state_t *state);

enb_description_t *s1ap_state_get_enb(
s1ap_state_t *state,
sctp_assoc_id_t assoc_id);
ue_description_t *s1ap_state_get_ue_enbid(
s1ap_state_t *state,
enb_description_t *enb,
enb_ue_s1ap_id_t enb_ue_s1ap_id);
ue_description_t *s1ap_state_get_ue_mmeid(
s1ap_state_t *state,
mme_ue_s1ap_id_t mme_ue_s1ap_id);

#ifdef __cplusplus
}
#endif

0 comments on commit d68fac6

Please sign in to comment.