Skip to content
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6076675
Modified code to port s_plus_p_gw_eps_bearer_context_information_t to…
rsarwad Nov 25, 2022
504e00d
Merge remote-tracking branch 'upstream/master' into 11191_spgw_teid_c…
rsarwad Nov 30, 2022
b146a62
Modified code to port s_plus_p_gw_eps_bearer_context_information_t to…
rsarwad Dec 7, 2022
aca564e
Merge remote-tracking branch 'upstream/master' into 11191_spgw_teid_c…
rsarwad Dec 7, 2022
cae3d2b
Cleaned up the code
rsarwad Dec 7, 2022
78e007b
Checking in the updated spgw_state.proto/pb.go file
rsarwad Dec 8, 2022
0d9d9ec
Merge remote-tracking branch 'upstream/master' into 11191_spgw_teid_c…
rsarwad Dec 12, 2022
8cd5237
Fixed the issue found during s1ap integ_tests
rsarwad Dec 16, 2022
986ebca
Merge remote-tracking branch 'upstream/master' into 11191_spgw_teid_c…
rsarwad Dec 16, 2022
2cf7c66
Removed the file, test_spgw_state_converter.cpp
rsarwad Dec 20, 2022
492cdd0
Addressed self comments
rsarwad Dec 20, 2022
bc721b4
Merge remote-tracking branch 'upstream/master' into 11191_spgw_teid_c…
rsarwad Dec 20, 2022
2b5e6c7
Addressed self review comments
rsarwad Dec 21, 2022
b58948f
Addressed review comment
rsarwad Dec 22, 2022
cf5ec0b
Addressed review comment
rsarwad Dec 22, 2022
d1cd375
Fixed cpp lint errors
rsarwad Dec 22, 2022
73d84cb
Merge branch '11191_spgw_teid_ctxt_changes' of https://github.com/rsa…
rsarwad Dec 22, 2022
9b90fdc
Merge remote-tracking branch 'upstream/master' into 11191_spgw_teid_c…
rsarwad Dec 22, 2022
d127f5c
Addressed review comment
rsarwad Dec 22, 2022
30593e8
Merge remote-tracking branch 'upstream/master' into 11191_spgw_teid_c…
rsarwad Dec 23, 2022
d7256a0
Addressed review comment
rsarwad Dec 27, 2022
293a884
Merge remote-tracking branch 'upstream/master' into 11191_spgw_teid_c…
rsarwad Dec 27, 2022
0e1e596
Merge remote-tracking branch 'upstream/master' into 11191_spgw_teid_c…
rsarwad Dec 28, 2022
f34345e
Merge remote-tracking branch 'upstream/master' into 11191_spgw_teid_c…
rsarwad Jan 2, 2023
348dd09
Merge remote-tracking branch 'upstream/master' into 11191_spgw_teid_c…
rsarwad Jan 2, 2023
4f0a450
Merge remote-tracking branch 'upstream/master' into 11191_spgw_teid_c…
rsarwad Jan 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
930 changes: 583 additions & 347 deletions lte/cloud/go/protos/oai/spgw_state.pb.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lte/gateway/c/core/common/dynamic_memory_check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void bdestroy_wrapper(bstring* b) {
// TODO(rsarwad): rename free_wrapper once all tasks are migrated to cpp.
// Shall be addressed while addressing issue_id: 13096
void free_cpp_wrapper(void** ptr) {
if (ptr) {
if ((ptr) && (*ptr)) {
delete *ptr;
*ptr = nullptr;
}
Expand Down
36 changes: 27 additions & 9 deletions lte/gateway/c/core/oai/include/sgw_context_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,46 @@ extern "C" {

#define INITIAL_SGW_S8_S1U_TEID 0x7FFFFFFF
void sgw_display_sgw_eps_bearer_context(
const sgw_eps_bearer_ctxt_t* eps_bearer_ctxt);
const magma::lte::oai::SgwEpsBearerContext* eps_bearer_ctxt);
void sgw_display_s11_bearer_context_information(
log_proto_t module,
magma::lte::oai::S11BearerContext* sgw_context_information);

// TODO(rsarwad): to be removed while porting sgw_s8 task
void sgw_s8_display_sgw_eps_bearer_context(
const sgw_eps_bearer_ctxt_t* eps_bearer_ctxt);

void sgw_s8_display_s11_bearer_context_information(
log_proto_t module,
sgw_eps_bearer_context_information_t* sgw_context_information);

sgw_eps_bearer_ctxt_t* sgw_s8_cm_get_eps_bearer_entry(
sgw_pdn_connection_t* const sgw_pdn_connection, ebi_t ebi);

mme_sgw_tunnel_t* sgw_cm_create_s11_tunnel(teid_t remote_teid,
teid_t local_teid);
s_plus_p_gw_eps_bearer_context_information_t*
magma::lte::oai::S11BearerContext*
sgw_cm_create_bearer_context_information_in_collection(teid_t teid);
magma::proto_map_rc_t sgw_cm_remove_bearer_context_information(teid_t teid,
imsi64_t imsi64);
sgw_eps_bearer_ctxt_t* sgw_cm_create_eps_bearer_ctxt_in_collection(
sgw_pdn_connection_t* const sgw_pdn_connection, const ebi_t eps_bearer_idP);
sgw_eps_bearer_ctxt_t* sgw_cm_insert_eps_bearer_ctxt_in_collection(
sgw_pdn_connection_t* const sgw_pdn_connection,
sgw_eps_bearer_ctxt_t* const sgw_eps_bearer_ctxt);
sgw_eps_bearer_ctxt_t* sgw_cm_get_eps_bearer_entry(
sgw_pdn_connection_t* const sgw_pdn_connection, ebi_t ebi);

magma::proto_map_rc_t sgw_cm_insert_eps_bearer_ctxt_in_collection(
magma::lte::oai::SgwPdnConnection* const sgw_pdn_connection,
magma::lte::oai::SgwEpsBearerContext* const sgw_eps_bearer_ctxt);

// Returns SPGW state pointer for given UE indexed by IMSI
s_plus_p_gw_eps_bearer_context_information_t* sgw_cm_get_spgw_context(
teid_t teid);
magma::lte::oai::S11BearerContext* sgw_cm_get_spgw_context(teid_t teid);
spgw_ue_context_t* spgw_get_ue_context(imsi64_t imsi64);
spgw_ue_context_t* spgw_create_or_get_ue_context(imsi64_t imsi64);

status_code_e spgw_update_teid_in_ue_context(imsi64_t imsi64, teid_t teid);

magma::proto_map_rc_t sgw_cm_get_eps_bearer_entry(
magma::lte::oai::SgwPdnConnection* const sgw_pdn_connection, ebi_t ebi,
magma::lte::oai::SgwEpsBearerContext* bearer_context_p);

magma::proto_map_rc_t sgw_update_eps_bearer_entry(
magma::lte::oai::SgwPdnConnection* sgw_pdn_connection_p, uint32_t ebi,
magma::lte::oai::SgwEpsBearerContext* bearer_context_p);
22 changes: 22 additions & 0 deletions lte/gateway/c/core/oai/include/sgw_ie_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,28 @@ typedef struct {
uint8_t mnc[3];
} ServingNetwork_t;

#define FTEID_T_2_PROTO_IP(fte_p, ip_p) \
do { \
if ((fte_p)->ipv4) { \
(ip_p)->set_pdn_type(IPv4); \
char ip4_str[INET_ADDRSTRLEN]; \
inet_ntop(AF_INET, (&(fte_p)->ipv4_address.s_addr), ip4_str, \
INET_ADDRSTRLEN); \
(ip_p)->set_ipv4_addr(ip4_str); \
} \
if ((fte_p)->ipv6) { \
if ((fte_p)->ipv4) { \
(ip_p)->set_pdn_type(IPv4_AND_v6); \
} else { \
(ip_p)->set_pdn_type(IPv6); \
} \
char ip6_str[INET6_ADDRSTRLEN]; \
inet_ntop(AF_INET6, &((fte_p)->ipv6_address), ip6_str, \
INET6_ADDRSTRLEN); \
(ip_p)->set_ipv6_addr(ip6_str); \
} \
} while (0)

#define FTEID_T_2_IP_ADDRESS_T(fte_p, ip_p) \
do { \
if ((fte_p)->ipv4) { \
Expand Down
10 changes: 8 additions & 2 deletions lte/gateway/c/core/oai/include/spgw_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,18 @@ void spgw_free_s11_bearer_context_information(void**);
* Frees pdn connection and its contained objects
* @param pdn_connection_p
*/
void sgw_free_pdn_connection(sgw_pdn_connection_t* pdn_connection_p);
void sgw_free_pdn_connection(
magma::lte::oai::SgwPdnConnection* pdn_connection_p);
/**
* Frees sgw_eps_bearer_ctxt entry
* @param sgw_eps_bearer_ctxt
*/
void sgw_free_eps_bearer_context(sgw_eps_bearer_ctxt_t** sgw_eps_bearer_ctxt);
// TODO(rsarwad): Need to be removed while porting bearer contexts for s8 task
void sgw_s8_free_eps_bearer_context(
sgw_eps_bearer_ctxt_t** sgw_eps_bearer_ctxt);

void sgw_remove_eps_bearer_context(
magma::lte::oai::SgwPdnConnection* pdn_connection_p, uint32_t ebi);
/**
* Callback function for freeing the ue context while removing an entry from
* state_ue_map
Expand Down
13 changes: 9 additions & 4 deletions lte/gateway/c/core/oai/include/spgw_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

#pragma once

#include "lte/protos/oai/spgw_state.pb.h"

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -82,9 +84,8 @@ typedef struct sgw_s11_teid_s {
} sgw_s11_teid_t;

// Map- Key:teid (uint32_t) ,
// Data:s_plus_p_gw_eps_bearer_context_information_s*
typedef magma::proto_map_s<uint32_t,
struct s_plus_p_gw_eps_bearer_context_information_s*>
// Data: S11BearerContext*
typedef magma::proto_map_s<uint32_t, magma::lte::oai::S11BearerContext*>
state_teid_map_t;

typedef struct spgw_ue_context_s {
Expand All @@ -95,6 +96,10 @@ typedef struct spgw_ue_context_s {
typedef magma::proto_map_s<uint64_t, struct spgw_ue_context_s*>
map_uint64_spgw_ue_context_t;

// Map- Key: eps_bearer_id(uint32), Data: SgwEpsBearerContext
typedef magma::proto_map_s<uint32_t, magma::lte::oai::SgwEpsBearerContext>
map_uint32_spgw_eps_bearer_context_t;

// Data entry for s11teid2mme
typedef struct mme_sgw_tunnel_s {
uint32_t local_teid; ///< Local tunnel endpoint Identifier
Expand Down Expand Up @@ -133,5 +138,5 @@ typedef struct spgw_state_s {

void handle_s5_create_session_response(
spgw_state_t* state,
s_plus_p_gw_eps_bearer_context_information_t* new_bearer_ctxt_info_p,
magma::lte::oai::S11BearerContext* new_bearer_ctxt_info_p,
s5_create_session_response_t session_resp);
4 changes: 2 additions & 2 deletions lte/gateway/c/core/oai/lib/directoryd/directoryd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ bool directoryd_update_location(char* imsi, char* location) {
return true;
}

bool directoryd_update_record_field(char* imsi, char* key, char* value) {
bool directoryd_update_record_field(char* imsi, std::string key, char* value) {
// Actual GW_ID will be filled in the cloud
magma::GatewayDirectoryServiceClient::UpdateRecordField(
"IMSI" + std::string(imsi), std::string(key), std::string(value),
"IMSI" + std::string(imsi), key, std::string(value),
[&](grpc::Status status, magma::Void response) {
directoryd_rpc_call_done(status);
});
Expand Down
11 changes: 2 additions & 9 deletions lte/gateway/c/core/oai/lib/directoryd/directoryd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@

#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#include <string>
/*
* This enum should have the same definition as TableID in directoryd.proto .
*
Expand All @@ -36,8 +33,4 @@ bool directoryd_remove_location(char* imsi);

bool directoryd_update_location(char* imsi, char* location);

bool directoryd_update_record_field(char* imsi, char* key, char* value);

#ifdef __cplusplus
}
#endif
bool directoryd_update_record_field(char* imsi, std::string key, char* value);
40 changes: 17 additions & 23 deletions lte/gateway/c/core/oai/lib/mobility_client/MobilityClientAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "lte/gateway/c/core/oai/common/common_types.h"
#include "lte/gateway/c/core/oai/common/conversions.h"
#include "lte/gateway/c/core/oai/common/log.h"
#include "lte/gateway/c/core/oai/include/spgw_types.hpp"
#include "lte/gateway/c/core/oai/lib/itti/intertask_interface.h"
#include "lte/gateway/c/core/oai/lib/mobility_client/MobilityServiceClient.hpp"
#include "orc8r/gateway/c/common/service303/MetricsHelpers.hpp"
Expand Down Expand Up @@ -65,15 +64,13 @@ int get_assigned_ipv4_block(int index, struct in_addr* netaddr,
return status;
}

int pgw_handle_allocate_ipv4_address(const char* subscriber_id, const char* apn,
const char* pdn_type, teid_t context_teid,
ebi_t eps_bearer_id) {
int pgw_handle_allocate_ipv4_address(const std::string subscriber_id_str,
const std::string apn_str,
const std::string pdn_type_str,
teid_t context_teid, ebi_t eps_bearer_id) {
#if MME_UNIT_TEST
return RETURNok; // skip this call for unit testing
#endif
auto subscriber_id_str = std::string(subscriber_id);
auto apn_str = std::string(apn);
auto pdn_type_str = std::string(pdn_type);
MobilityServiceClient::getInstance().AllocateIPv4AddressAsync(
subscriber_id_str, apn_str,
[subscriber_id_str, apn_str, pdn_type_str, context_teid, eps_bearer_id](
Expand Down Expand Up @@ -150,8 +147,8 @@ static void handle_allocate_ipv4_address_status(
send_msg_to_task(&grpc_service_task_zmq_ctx, TASK_SPGW_APP, message_p);
}

void release_ipv4_address(const char* subscriber_id, const char* apn,
const struct in_addr* addr) {
void release_ipv4_address(const std::string subscriber_id,
const std::string apn, const struct in_addr* addr) {
#if !MME_UNIT_TEST
MobilityServiceClient::getInstance().ReleaseIPv4Address(subscriber_id, apn,
*addr);
Expand All @@ -176,15 +173,13 @@ int get_subscriber_id_from_ipv4(const struct in_addr* addr,
return status;
}

int pgw_handle_allocate_ipv6_address(const char* subscriber_id, const char* apn,
const char* pdn_type, teid_t context_teid,
ebi_t eps_bearer_id) {
int pgw_handle_allocate_ipv6_address(const std::string subscriber_id_str,
const std::string apn_str,
const std::string pdn_type_str,
teid_t context_teid, ebi_t eps_bearer_id) {
#if MME_UNIT_TEST
return RETURNok;
#endif
auto subscriber_id_str = std::string(subscriber_id);
auto apn_str = std::string(apn);
auto pdn_type_str = std::string(pdn_type);
// Make an RPC call to Mobilityd
MobilityServiceClient::getInstance().AllocateIPv6AddressAsync(
subscriber_id_str, apn_str,
Expand Down Expand Up @@ -269,16 +264,14 @@ static void handle_allocate_ipv6_address_status(
send_msg_to_task(&grpc_service_task_zmq_ctx, TASK_SPGW_APP, message_p);
}

int pgw_handle_allocate_ipv4v6_address(const char* subscriber_id,
const char* apn, const char* pdn_type,
int pgw_handle_allocate_ipv4v6_address(const std::string subscriber_id_str,
const std::string apn_str,
const std::string pdn_type_str,
teid_t context_teid,
ebi_t eps_bearer_id) {
#if MME_UNIT_TEST
return RETURNok;
#endif
auto subscriber_id_str = std::string(subscriber_id);
auto apn_str = std::string(apn);
auto pdn_type_str = std::string(pdn_type);
// Get IPv4v6 address
MobilityServiceClient::getInstance().AllocateIPv4v6AddressAsync(
subscriber_id_str, apn_str,
Expand Down Expand Up @@ -373,13 +366,14 @@ static void handle_allocate_ipv4v6_address_status(
send_msg_to_task(&grpc_service_task_zmq_ctx, TASK_SPGW_APP, message_p);
}

void release_ipv6_address(const char* subscriber_id, const char* apn,
const struct in6_addr* addr) {
void release_ipv6_address(const std::string subscriber_id,
const std::string apn, const struct in6_addr* addr) {
MobilityServiceClient::getInstance().ReleaseIPv6Address(subscriber_id, apn,
*addr);
}

void release_ipv4v6_address(const char* subscriber_id, const char* apn,
void release_ipv4v6_address(const std::string subscriber_id,
const std::string apn,
const struct in_addr* ipv4_addr,
const struct in6_addr* ipv6_addr) {
MobilityServiceClient::getInstance().ReleaseIPv4v6Address(
Expand Down
40 changes: 21 additions & 19 deletions lte/gateway/c/core/oai/lib/mobility_client/MobilityClientAPI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
* [email protected]
*/

#ifndef RPC_CLIENT_H
#define RPC_CLIENT_H
#pragma once

#include "stdint.h"
#include <stdint.h>

#include <string>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
Found C++ system header after other header. Should be: MobilityClientAPI.h, c system, c++ system, other. [build/include_order] [4]


#ifdef __cplusplus
extern "C" {
Expand All @@ -31,7 +32,6 @@ extern "C" {
#endif

#include "lte/gateway/c/core/common/dynamic_memory_check.h"
#include "lte/gateway/c/core/oai/include/spgw_state.hpp"

// Status codes from gRPC
#define RPC_STATUS_OK 0
Expand Down Expand Up @@ -75,9 +75,10 @@ int get_assigned_ipv4_block(int index, struct in_addr* netaddr,
* @param pdn_type str for PDN type (ipv4, ipv6...)
* @return status of gRPC call
*/
int pgw_handle_allocate_ipv4_address(const char* subscriber_id, const char* apn,
const char* pdn_type, teid_t context_teid,
ebi_t eps_bearer_id);
int pgw_handle_allocate_ipv4_address(const std::string subscriber_id,
const std::string apn,
const std::string pdn_type,
teid_t context_teid, ebi_t eps_bearer_id);

/**
* Allocate IP address from MobilityServiceClient over gRPC (non-blocking),
Expand All @@ -89,9 +90,10 @@ int pgw_handle_allocate_ipv4_address(const char* subscriber_id, const char* apn,
* @return status of gRPC call
*/

int pgw_handle_allocate_ipv6_address(const char* subscriber_id, const char* apn,
const char* pdn_type, teid_t context_teid,
ebi_t eps_bearer_id);
int pgw_handle_allocate_ipv6_address(const std::string subscriber_id,
const std::string apn,
const std::string pdn_type,
teid_t context_teid, ebi_t eps_bearer_id);

/*
* Release an allocated IP address.
Expand All @@ -102,8 +104,8 @@ int pgw_handle_allocate_ipv6_address(const char* subscriber_id, const char* apn,
* @param subscriber_id: subscriber id string, i.e. IMSI
* @param addr: IP address to release
*/
void release_ipv4_address(const char* subscriber_id, const char* apn,
const struct in_addr* addr);
void release_ipv4_address(const std::string subscriber_id,
const std::string apn, const struct in_addr* addr);

/*
* Release an allocated IP address.
Expand All @@ -115,8 +117,8 @@ void release_ipv4_address(const char* subscriber_id, const char* apn,
* @param apn: access point name string, e.g., "ims", "internet", etc.
* @param addr: IPv6 address to release in "host byte order
*/
void release_ipv6_address(const char* subscriber_id, const char* apn,
const struct in6_addr* addr);
void release_ipv6_address(const std::string subscriber_id,
const std::string apn, const struct in6_addr* addr);

/*
* Release an allocated IP address.
Expand All @@ -129,7 +131,8 @@ void release_ipv6_address(const char* subscriber_id, const char* apn,
* @param ipv4_addr: IPv4 address to release in "host byte order
* @param ipv6_addr: IPv6 address to release in "host byte order
*/
void release_ipv4v6_address(const char* subscriber_id, const char* apn,
void release_ipv4v6_address(const std::string subscriber_id,
const std::string apn,
const struct in_addr* ipv4_addr,
const struct in6_addr* ipv6_addr);

Expand Down Expand Up @@ -168,9 +171,8 @@ int get_subscriber_id_from_ipv4(const struct in_addr* addr,
* @return status of gRPC call
*/

int pgw_handle_allocate_ipv4v6_address(const char* subscriber_id,
const char* apn, const char* pdn_type,
int pgw_handle_allocate_ipv4v6_address(const std::string subscriber_id_str,
const std::string apn_str,
const std::string pdn_type_str,
teid_t context_teid,
ebi_t eps_bearer_id);

#endif // RPC_CLIENT_H
2 changes: 1 addition & 1 deletion lte/gateway/c/core/oai/lib/pcef/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set(CMAKE_CXX_FLAGS "-Wno-write-strings -Wno-literal-suffix")

# compile the needed protos
set(PCEF_ORC8R_CPP_PROTOS mconfig/mconfigs)
set(PCEF_LTE_CPP_PROTOS policydb session_manager)
set(PCEF_LTE_CPP_PROTOS policydb session_manager oai/spgw_state oai/sgw_state oai/common_types oai/std_3gpp_types)
set(PCEF_ORC8R_GRPC_PROTOS "")
set(PCEF_LTE_GRPC_PROTOS session_manager)

Expand Down
Loading