Skip to content

Commit 790162f

Browse files
authored
Added code to create SGW_S8 task (magma#5092)
* Created new task i.e SGW_S8 Signed-off-by: rashmi <[email protected]>
1 parent 5822412 commit 790162f

File tree

10 files changed

+134
-4
lines changed

10 files changed

+134
-4
lines changed

lte/gateway/c/oai/common/log.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,9 @@ int log_init(
656656
&g_oai_log.log_proto2str[LOG_S11][0], LOG_MAX_PROTO_NAME_LENGTH, "S11");
657657
snprintf(
658658
&g_oai_log.log_proto2str[LOG_S6A][0], LOG_MAX_PROTO_NAME_LENGTH, "S6A");
659+
snprintf(
660+
&g_oai_log.log_proto2str[LOG_SGW_S8][0], LOG_MAX_PROTO_NAME_LENGTH,
661+
"SGW_S8");
659662
snprintf(
660663
&g_oai_log.log_proto2str[LOG_SECU][0], LOG_MAX_PROTO_NAME_LENGTH, "SECU");
661664
snprintf(

lte/gateway/c/oai/common/log.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ typedef enum {
167167
LOG_ASYNC_SYSTEM,
168168
LOG_ASSERT,
169169
LOG_COMMON,
170+
LOG_SGW_S8,
170171
MAX_LOG_PROTOS,
171172
} log_proto_t;
172173

lte/gateway/c/oai/include/tasks_def.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,5 @@ TASK_DEF(TASK_HA)
7171
TASK_DEF(TASK_NGAP)
7272
/// AMF Application task
7373
TASK_DEF(TASK_AMF_APP)
74+
/// SGW_S8 task
75+
TASK_DEF(TASK_SGW_S8)

lte/gateway/c/oai/oai_mme/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ target_link_libraries(mme
4545
LIB_HASHTABLE LIB_S6A_PROXY
4646
TASK_S1AP TASK_SCTP_SERVER TASK_SGS TASK_SMS_ORC8R
4747
TASK_S6A TASK_MME_APP TASK_GRPC_SERVICE TASK_NAS TASK_HA
48-
${ITTI_LIB} ${GCOV_LIB}
48+
${ITTI_LIB} ${GCOV_LIB}
4949
-Wl,--end-group
5050
${LFDS} pthread m sctp rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES}
5151
${NETTLE_LIBRARIES} ${CONFIG_LIBRARIES} gnutls ${SERVICE303_LIB}
@@ -56,7 +56,7 @@ if ( NOT EMBEDDED_SGW )
5656
target_link_libraries(mme
5757
LIB_GTPV2C TASK_UDP)
5858
else ( EMBEDDED_SGW )
59-
target_link_libraries(mme TASK_SGW)
59+
target_link_libraries(mme TASK_SGW TASK_SGW_S8)
6060
endif ( NOT EMBEDDED_SGW )
6161

6262
if ( NOT S6A_OVER_GRPC )

lte/gateway/c/oai/oai_mme/oai_mme.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include "sgs_defs.h"
4444
#include "sms_orc8r_defs.h"
4545
#include "ha_defs.h"
46+
#include "sgw_s8_defs.h"
4647
#include "oai_mme.h"
4748
#include "pid_file.h"
4849
#include "service303_message_utils.h"
@@ -126,6 +127,7 @@ int main(int argc, char* argv[]) {
126127
CHECK_INIT_RETURN(sctp_init(&mme_config));
127128
#if EMBEDDED_SGW
128129
CHECK_INIT_RETURN(spgw_app_init(&spgw_config, mme_config.use_stateless));
130+
CHECK_INIT_RETURN(sgw_s8_init());
129131
#else
130132
CHECK_INIT_RETURN(udp_init());
131133
CHECK_INIT_RETURN(s11_mme_init(&mme_config));

lte/gateway/c/oai/tasks/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ add_subdirectory(ha) # TASK_HA
1313
if (EMBEDDED_SGW)
1414
add_subdirectory(gtpv1-u) # TASK_GTPV1U
1515
add_subdirectory(sgw) # TASK_SGW
16+
add_subdirectory(sgw_s8) # TASK_SGW_S8
1617
else (EMBEDDED_SGW)
1718
add_subdirectory(s11) # TASK_S11
1819
add_subdirectory(udp) #TASK_UDP

lte/gateway/c/oai/tasks/mme_app/mme_app_main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,8 @@ static void* mme_app_thread(__attribute__((unused)) void* args) {
456456
init_task_context(
457457
TASK_MME_APP,
458458
(task_id_t[]){TASK_SPGW_APP, TASK_SGS, TASK_SMS_ORC8R, TASK_S11, TASK_S6A,
459-
TASK_S1AP, TASK_SERVICE303, TASK_HA},
460-
8, handle_message, &mme_app_task_zmq_ctx);
459+
TASK_S1AP, TASK_SERVICE303, TASK_HA, TASK_SGW_S8},
460+
9, handle_message, &mme_app_task_zmq_ctx);
461461

462462
// Service started, but not healthy yet
463463
send_app_health_to_service303(&mme_app_task_zmq_ctx, TASK_MME_APP, false);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
set (SGW_S8_SRC
2+
sgw_s8_task.c
3+
)
4+
5+
add_library(TASK_SGW_S8 ${SGW_S8_SRC})
6+
7+
target_link_libraries(TASK_SGW_S8 COMMON LIB_BSTR LIB_HASHTABLE)
8+
9+
target_include_directories(TASK_SGW_S8 PUBLIC
10+
${CMAKE_CURRENT_SOURCE_DIR}
11+
)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
14+
#pragma once
15+
16+
#include "intertask_interface.h"
17+
18+
extern task_zmq_ctx_t sgw_s8_task_zmq_ctx;
19+
20+
int sgw_s8_init(void);
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The OpenAirInterface Software Alliance licenses this file to You under
6+
* the terms found in the LICENSE file in the root of this source tree.
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*-------------------------------------------------------------------------------
14+
* For more information about the OpenAirInterface (OAI) Software Alliance:
15+
16+
*/
17+
18+
/*! \file sgw_s8_task.c
19+
\brief
20+
\author
21+
\company
22+
\email:
23+
*/
24+
#define SGW_S8
25+
#define SGW_S8_TASK_C
26+
27+
#include <stdio.h>
28+
#include "log.h"
29+
#include "assertions.h"
30+
#include "common_defs.h"
31+
#include "itti_free_defined_msg.h"
32+
#include "sgw_s8_defs.h"
33+
34+
static int handle_message(zloop_t* loop, zsock_t* reader, void* arg);
35+
static void sgw_s8_exit(void);
36+
task_zmq_ctx_t sgw_s8_task_zmq_ctx;
37+
38+
static void* sgw_s8_thread(void* args) {
39+
itti_mark_task_ready(TASK_SGW_S8);
40+
init_task_context(
41+
TASK_SGW_S8, (task_id_t[]){TASK_MME_APP}, 1, handle_message,
42+
&sgw_s8_task_zmq_ctx);
43+
44+
zloop_start(sgw_s8_task_zmq_ctx.event_loop);
45+
sgw_s8_exit();
46+
return NULL;
47+
}
48+
49+
int sgw_s8_init(void) {
50+
OAILOG_DEBUG(LOG_SGW_S8, "Initializing SGW-S8 interface\n");
51+
52+
if (itti_create_task(TASK_SGW_S8, &sgw_s8_thread, NULL) < 0) {
53+
OAILOG_ERROR(LOG_SGW_S8, "Failed to create sgw_s8 task\n");
54+
return RETURNerror;
55+
}
56+
OAILOG_DEBUG(LOG_SGW_S8, "Done initialization of SGW_S8 interface\n");
57+
return RETURNok;
58+
}
59+
60+
static int handle_message(zloop_t* loop, zsock_t* reader, void* arg) {
61+
zframe_t* msg_frame = zframe_recv(reader);
62+
assert(msg_frame);
63+
MessageDef* received_message_p = (MessageDef*) zframe_data(msg_frame);
64+
65+
switch (ITTI_MSG_ID(received_message_p)) {
66+
case TERMINATE_MESSAGE: {
67+
itti_free_msg_content(received_message_p);
68+
zframe_destroy(&msg_frame);
69+
sgw_s8_exit();
70+
} break;
71+
72+
default: {
73+
OAILOG_DEBUG(
74+
LOG_SGW_S8, "Unkwnon message ID %d: %s\n",
75+
ITTI_MSG_ID(received_message_p), ITTI_MSG_NAME(received_message_p));
76+
} break;
77+
}
78+
79+
itti_free_msg_content(received_message_p);
80+
zframe_destroy(&msg_frame);
81+
return 0;
82+
}
83+
84+
//------------------------------------------------------------------------------
85+
static void sgw_s8_exit(void) {
86+
destroy_task_context(&sgw_s8_task_zmq_ctx);
87+
OAILOG_DEBUG(LOG_SGW_S8, "Finished cleaning up SGW_S8 task \n");
88+
OAI_FPRINTF_INFO("TASK_SGW_S8 terminated\n");
89+
pthread_exit(NULL);
90+
}

0 commit comments

Comments
 (0)