Merge remote-tracking branch 'origin/cleanup-20220125' into integration_2022_wk08

This commit is contained in:
Robert Schmidt
2022-02-19 19:34:01 +01:00
108 changed files with 257 additions and 12685 deletions
+20 -90
View File
@@ -1019,7 +1019,6 @@ add_boolean_option(TRACE_RLC_UM_TX_STATUS False "TRACE for RLC UM, TO BE CHANGE
##########################
#add_boolean_option(LINK_ENB_PDCP_TO_IP_DRIVER False "For eNB, PDCP communicate with a IP driver")
#add_boolean_option(LINK_ENB_PDCP_TO_GTPV1U True "For eNB, PDCP communicate with GTP-U protocol (eNB<->S-GW)")
add_definitions(-DNEW_GTPU=1)
##########################
# RRC LAYER OPTIONS
@@ -1097,8 +1096,7 @@ include_directories("${OPENAIR3_DIR}/S1AP")
include_directories("${OPENAIR2_DIR}/X2AP")
include_directories("${OPENAIR2_DIR}/M2AP")
include_directories("${OPENAIR2_DIR}/F1AP")
include_directories("${OPENAIR3_DIR}/UDP")
include_directories("${OPENAIR3_DIR}/GTPV1-U")
include_directories("${OPENAIR3_DIR}/ocp-gtpu")
include_directories("${OPENAIR3_DIR}/M3AP")
include_directories("${OPENAIR3_DIR}/MME_APP")
include_directories("${OPENAIR_DIR}/targets/COMMON")
@@ -1111,7 +1109,6 @@ include_directories("${OPENAIR2_DIR}/ENB_APP/CONTROL_MODULES/S1AP")
include_directories("${OPENAIR2_DIR}/UTIL/OSA")
include_directories("${OPENAIR2_DIR}/UTIL/LFDS/liblfds6.1.1/liblfds611/inc")
include_directories("${OPENAIR2_DIR}/UTIL/LFDS/liblfds7.0.0/liblfds700/inc")
include_directories("${OPENAIR2_DIR}/LAYER2/PROTO_AGENT")
include_directories("${OPENAIR2_DIR}/UTIL/MEM")
include_directories("${OPENAIR2_DIR}/UTIL/LISTS")
include_directories("${OPENAIR2_DIR}/UTIL/FIFO")
@@ -1124,8 +1121,6 @@ include_directories("${OPENAIR2_DIR}/UTIL/CLI")
include_directories("${OPENAIR2_DIR}/UTIL/OPT")
include_directories("${OPENAIR2_DIR}/UTIL/OMV")
include_directories("${OPENAIR2_DIR}/RRC/LTE/MESSAGES")
include_directories("${OPENAIR3_DIR}/GTPV1-U/nw-gtpv1u/shared")
include_directories("${OPENAIR3_DIR}/GTPV1-U/nw-gtpv1u/include")
include_directories("${OPENAIR_DIR}")
# Utilities Library
@@ -1279,18 +1274,6 @@ include_directories (${FSPT_C_DIR})
# set(ASYNC_IF_LIB ASYNC_IF)
# include_directories(${OPENAIR2_DIR}/UTIL/ASYNC_IF)
add_library(PROTO_AGENT
${OPENAIR2_DIR}/LAYER2/PROTO_AGENT/proto_agent_handler.c
${OPENAIR2_DIR}/LAYER2/PROTO_AGENT/proto_agent_common.c
${OPENAIR2_DIR}/LAYER2/PROTO_AGENT/proto_agent.c
${OPENAIR2_DIR}/LAYER2/PROTO_AGENT/proto_agent_net_comm.c
${OPENAIR2_DIR}/LAYER2/PROTO_AGENT/proto_agent_async.c
)
set(PROTO_AGENT_LIB PROTO_AGENT)
include_directories(${OPENAIR2_DIR}/LAYER2/PROTO_AGENT)
set(PROTOBUF_LIB "protobuf-c")
#set(PROTOBUF_LIB "protobuf") #for Cpp
@@ -2161,7 +2144,6 @@ add_library(L2_NR
${MAC_NR_SRC}
${GNB_APP_SRC}
)
target_compile_definitions(L2_NR PUBLIC NEW_GTPU)
add_library(L2_LTE_NR
${L2_RRC_SRC}
@@ -2169,7 +2151,6 @@ add_library(L2_LTE_NR
${ENB_APP_SRC}
${MCE_APP_SRC}
)
target_compile_definitions(L2_LTE_NR PUBLIC NEW_GTPU)
add_dependencies(L2_NR rrc_flag nr_rrc_flag s1ap_flag x2_flag)
@@ -2210,32 +2191,14 @@ add_library(CN_UTILS
${OPENAIR3_DIR}/UTILS/mcc_mnc_itu.c
)
set(GTPV1U_DIR ${OPENAIR3_DIR}/GTPV1-U)
add_library (GTPV1U_OCP
add_library (GTPV1U
${NR_RRC_DIR}/rrc_gNB_GTPV1U.c
${RRC_DIR}/rrc_eNB_GTPV1U.c
${OPENAIR3_DIR}/ocp-gtpu/gtp_itf.cpp
)
target_compile_definitions(GTPV1U_OCP PUBLIC NEW_GTPU)
add_dependencies(GTPV1U_OCP rrc_flag)
add_dependencies(GTPV1U rrc_flag)
include_directories(${OPENAIR3_DIR}/ocp-gtp)
#NR case
set (NR_GTPV1U_SRC
${NR_RRC_DIR}/rrc_gNB_GTPV1U.c
${RRC_DIR}/rrc_eNB_GTPV1U.c
${GTPV1U_DIR}/gtpv1u_eNB.c
${GTPV1U_DIR}/gtpv1u_gNB.c
${GTPV1U_DIR}/nw-gtpv1u/src/NwGtpv1uTunnelEndPoint.c
${GTPV1U_DIR}/nw-gtpv1u/src/NwGtpv1uTrxn.c
${GTPV1U_DIR}/nw-gtpv1u/src/NwGtpv1uMsg.c
${GTPV1U_DIR}/nw-gtpv1u/src/NwGtpv1u.c
${GTPV1U_DIR}/gtpv1u_teid_pool.c
)
add_library(NR_GTPV1U ${NR_GTPV1U_SRC})
add_dependencies(NR_GTPV1U rrc_flag)
set (MME_APP_SRC
${OPENAIR3_DIR}/MME_APP/mme_app.c
${OPENAIR3_DIR}/MME_APP/mme_config.c
@@ -2251,9 +2214,6 @@ set(SCTP_SRC
add_library(SCTP_CLIENT ${SCTP_SRC})
add_dependencies(SCTP_CLIENT rrc_flag)
add_library(UDP ${OPENAIR3_DIR}/UDP/udp_eNB_task.c)
add_dependencies(UDP rrc_flag)
set(NAS_SRC ${OPENAIR3_DIR}/NAS/)
set(libnas_api_OBJS
${NAS_SRC}COMMON/API/NETWORK/as_message.c
@@ -2808,9 +2768,9 @@ add_dependencies(lte-softmodem rrc_flag s1ap_flag x2_flag oai_iqplayer)
target_link_libraries (lte-softmodem
-Wl,--start-group
RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB M2AP_LIB M2AP_ENB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB GTPV1U_OCP F1AP_LIB F1AP SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB SCHED_RU_LIB
RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB M2AP_LIB M2AP_ENB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB GTPV1U F1AP_LIB F1AP SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP SCHED_LIB SCHED_RU_LIB
PHY_COMMON PHY PHY_RU LFDS L2 L2_LTE NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB MISC_NFAPI_LTE_LIB LFDS7
${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ITTI ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} ${FSPT_MSG_LIB} ${PROTO_AGENT_LIB}
${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ITTI ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} ${FSPT_MSG_LIB}
-Wl,--end-group z dl)
target_link_libraries (lte-softmodem ${LIBXML2_LIBRARIES})
@@ -2852,40 +2812,12 @@ add_dependencies(ocp-enb rrc_flag s1ap_flag x2_flag oai_iqplayer coding params_l
target_link_libraries (ocp-enb
-Wl,--start-group
RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB GTPV1U_OCP SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB SCHED_RU_LIB
RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP SCHED_LIB SCHED_RU_LIB
PHY_COMMON PHY PHY_RU LFDS L2 L2_LTE NFAPI_COMMON_LIB NFAPI_LIB MISC_NFAPI_LTE_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB LFDS7 SIMU_COMMON
${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ITTI ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} ${FSPT_MSG_LIB} ${PROTO_AGENT_LIB}
${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ITTI ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} ${FSPT_MSG_LIB}
-Wl,--end-group z dl)
target_link_libraries (ocp-enb ${LIBXML2_LIBRARIES} pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} sctp ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${LIB_LMS_LIBRARIES} ${T_LIB})
add_executable(cu_test
${OPENAIR2_DIR}/LAYER2/PROTO_AGENT/cu_test.c
${OPENAIR2_DIR}/LAYER2/PROTO_AGENT/proto_agent_handler.c
${OPENAIR2_DIR}/LAYER2/PROTO_AGENT/proto_agent_common.c
${OPENAIR2_DIR}/LAYER2/PROTO_AGENT/proto_agent.c
${OPENAIR2_DIR}/LAYER2/PROTO_AGENT/proto_agent_net_comm.c
${OPENAIR2_DIR}/LAYER2/PROTO_AGENT/proto_agent_async.c
${T_SOURCE}
)
target_link_libraries(cu_test
${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FSPT_MSG_LIB} ${PROTOBUF_LIB}
${PROTO_AGENT_LIB} pthread UTIL ${T_LIB} dl ITTI
)
add_executable(du_test
${OPENAIR2_DIR}/LAYER2/PROTO_AGENT/du_test.c
${OPENAIR2_DIR}/LAYER2/PROTO_AGENT/proto_agent_handler.c
${OPENAIR2_DIR}/LAYER2/PROTO_AGENT/proto_agent_common.c
${OPENAIR2_DIR}/LAYER2/PROTO_AGENT/proto_agent.c
${OPENAIR2_DIR}/LAYER2/PROTO_AGENT/proto_agent_net_comm.c
${OPENAIR2_DIR}/LAYER2/PROTO_AGENT/proto_agent_async.c
${T_SOURCE}
)
target_link_libraries(du_test
${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FSPT_MSG_LIB} ${PROTOBUF_LIB}
${PROTO_AGENT_LIB} pthread UTIL ${T_LIB} dl ITTI
)
add_executable(oairu
${OPENAIR_TARGETS}/RT/USER/lte-ru.c
${OPENAIR_TARGETS}/RT/USER/ru_control.c
@@ -2946,13 +2878,13 @@ endif()
target_link_libraries (lte-uesoftmodem
-Wl,--start-group
RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB X2AP_ENB M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB
SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON
SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON
PHY_UE PHY_RU LFDS L2_UE L2_LTE LFDS7 SIMU_COMMON SIMU NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_USER_LIB MISC_NFAPI_LTE_LIB
${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ITTI ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${ATLAS_LIBRARIES}
-Wl,--end-group z dl)
target_link_libraries (lte-uesoftmodem ${LIBXML2_LIBRARIES})
target_link_libraries (lte-uesoftmodem pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} sctp ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES})
target_link_libraries (lte-uesoftmodem pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} sctp ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES})
target_link_libraries (lte-uesoftmodem ${LIB_LMS_LIBRARIES})
target_link_libraries (lte-uesoftmodem ${T_LIB})
@@ -2988,13 +2920,12 @@ add_executable(nr-softmodem
${OPENAIR2_DIR}/ENB_APP/flexran_agent_ran_api_to_fix.c
)
target_compile_definitions(nr-softmodem PUBLIC NEW_GTPU)
target_link_libraries (nr-softmodem
-Wl,--start-group
UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_NR_COMMON PHY_RU LFDS GTPV1U_OCP SECU_CN SECU_OSA
UTIL HASHTABLE SCTP_CLIENT SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_NR_COMMON PHY_RU LFDS GTPV1U SECU_CN SECU_OSA
ITTI ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} RRC_LIB NR_RRC_LIB
NGAP_LIB NGAP_GNB S1AP_LIB S1AP_ENB L2_LTE_NR L2_NR MAC_NR_COMMON NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB
X2AP_LIB X2AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB ${PROTO_AGENT_LIB} ${FSPT_MSG_LIB}
X2AP_LIB X2AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB ${FSPT_MSG_LIB}
-Wl,--end-group z dl)
target_link_libraries (nr-softmodem ${LIBXML2_LIBRARIES})
@@ -3031,7 +2962,7 @@ add_executable(ocp-gnb
target_link_libraries (ocp-gnb
-Wl,--start-group
UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_NR_COMMON PHY_RU LFDS GTPV1U_OCP SECU_CN SECU_OSA
UTIL HASHTABLE SCTP_CLIENT SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_NR_COMMON PHY_RU LFDS GTPV1U SECU_CN SECU_OSA
ITTI ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} RRC_LIB NR_RRC_LIB
NGAP_LIB NGAP_GNB S1AP_LIB S1AP_ENB L2_LTE_NR L2_NR MAC_NR_COMMON NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB
X2AP_LIB X2AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB SIMU_COMMON
@@ -3075,7 +3006,7 @@ add_executable(nr-uesoftmodem
target_link_libraries (nr-uesoftmodem
-Wl,--start-group
RRC_LIB NR_RRC_LIB NGAP_LIB NGAP_GNB SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_RU_LIB SCHED_UE_LIB SCHED_NR_UE_LIB
RRC_LIB NR_RRC_LIB NGAP_LIB NGAP_GNB SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT SCHED_RU_LIB SCHED_UE_LIB SCHED_NR_UE_LIB
PHY_COMMON PHY_NR_COMMON PHY_UE PHY_NR_UE PHY_RU LFDS NR_L2_UE L2_UE_LTE_NR MAC_NR_COMMON NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB
NFAPI_USER_LIB MISC_NFAPI_NR_LIB S1AP_LIB S1AP_ENB
${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ITTI ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 ${ATLAS_LIBRARIES}
@@ -3084,7 +3015,7 @@ target_link_libraries (nr-uesoftmodem
-Wl,--end-group z dl)
target_link_libraries (nr-uesoftmodem ${LIBXML2_LIBRARIES})
target_link_libraries (nr-uesoftmodem pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES})
target_link_libraries (nr-uesoftmodem pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES})
target_link_libraries (nr-uesoftmodem ${LIB_LMS_LIBRARIES})
target_link_libraries (nr-uesoftmodem ${T_LIB})
@@ -3329,7 +3260,7 @@ add_executable(test_epc_generate_scenario
${OPENAIR3_DIR}/S1AP/s1ap_eNB_defs.h
)
target_link_libraries (test_epc_generate_scenario
-Wl,--start-group RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB X2AP_ENB M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB F1AP_LIB F1AP GTPV1U_OCP LIB_NAS_UE SECU_CN UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB PHY LFDS ITTI ${MSC_LIB} L2 -Wl,--end-group pthread m rt crypt sctp ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${CONFIG_LIB}
-Wl,--start-group RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB X2AP_ENB M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB F1AP_LIB F1AP GTPV1U LIB_NAS_UE SECU_CN UTIL HASHTABLE SCTP_CLIENT MME_APP SCHED_LIB PHY LFDS ITTI ${MSC_LIB} L2 -Wl,--end-group pthread m rt crypt sctp ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${CONFIG_LIB}
)
add_executable(test_epc_play_scenario
@@ -3348,7 +3279,7 @@ add_executable(test_epc_play_scenario
)
target_include_directories(test_epc_play_scenario PUBLIC /usr/local/share/asn1c)
target_link_libraries (test_epc_play_scenario
-Wl,--start-group RRC_LIB S1AP_LIB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB F1AP_LIB F1AP GTPV1U_OCP LIB_NAS_UE SECU_CN UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB PHY_NR_COMMON PHY_COMMON PHY PHY_UE LFDS ITTI ${MSC_LIB} -Wl,--end-group pthread m rt crypt sctp ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${CONFIG_LIB}
-Wl,--start-group RRC_LIB S1AP_LIB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB F1AP_LIB F1AP GTPV1U LIB_NAS_UE SECU_CN UTIL HASHTABLE SCTP_CLIENT MME_APP SCHED_LIB PHY_NR_COMMON PHY_COMMON PHY PHY_UE LFDS ITTI ${MSC_LIB} -Wl,--end-group pthread m rt crypt sctp ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${CONFIG_LIB}
)
@@ -3394,8 +3325,8 @@ if (${T_TRACER})
NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_VNF_LIB NFAPI_USER_LIB
PHY_COMMON PHY PHY_UE PHY_NR PHY_NR_COMMON PHY_NR_UE PHY_RU PHY_MEX
L2 L2_LTE L2_NR L2_LTE_NR L2_UE NR_L2_UE L2_UE_LTE_NR MAC_NR_COMMON MAC_NR MAC_UE_NR NGAP_GNB
CN_UTILS GTPV1U_OCP GTPV1U_OCP SCTP_CLIENT MME_APP UDP LIB_NAS_UE NB_IoT LFDS LFDS7 SIMU_COMMON SIMU SIMU_ETH OPENAIR0_LIB
ldpc_orig ldpc_optim ldpc_optim8seg ldpc PROTO_AGENT dfts)
CN_UTILS GTPV1U SCTP_CLIENT MME_APP LIB_NAS_UE NB_IoT LFDS LFDS7 SIMU_COMMON SIMU SIMU_ETH OPENAIR0_LIB
ldpc_orig ldpc_optim ldpc_optim8seg ldpc dfts)
if (TARGET ${i})
add_dependencies(${i} generate_T)
endif()
@@ -3499,14 +3430,13 @@ add_executable(nr-ittisim
${CONFIG_SOURCES}
${SHLIB_LOADER_SOURCES}
)
target_compile_definitions(nr-ittisim PUBLIC NEW_GTPU)
target_link_libraries (nr-ittisim
-Wl,--start-group
UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_NR_COMMON PHY_RU LFDS GTPV1U_OCP SECU_CN SECU_OSA
UTIL HASHTABLE SCTP_CLIENT SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_NR_COMMON PHY_RU LFDS GTPV1U SECU_CN SECU_OSA
ITTI ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7 ${MSC_LIB} ${RAL_LIB} ${NAS_SIM_LIB} RRC_LIB NR_RRC_LIB
NGAP_LIB NGAP_GNB S1AP_LIB S1AP_ENB L2_LTE_NR L2_NR MAC_NR_COMMON NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB
X2AP_LIB X2AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB ${PROTO_AGENT_LIB} ${FSPT_MSG_LIB}
X2AP_LIB X2AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB ${FSPT_MSG_LIB}
PHY_NR_UE SCHED_NR_UE_LIB NR_L2_UE
-Wl,--end-group z dl)
+1 -9
View File
@@ -42,17 +42,11 @@
//#include "ENB_APP/enb_config.h"
#include "flexran_agent_defs.h"
#include "gtpv1u.h"
#include "NwGtpv1u.h"
#include "NwGtpv1uMsg.h"
#include "NwGtpv1uPrivate.h"
#include "gtpv1u_eNB_defs.h"
#include "gtpv1u_gNB_defs.h"
#include "PHY/defs_L1_NB_IoT.h"
#include "RRC/LTE/defs_NB_IoT.h"
#include "RRC/LTE/rrc_defs.h"
#include "RRC/NR/nr_rrc_defs.h"
#include <openair3/ocp-gtpu/gtpv1u_eNB_task.h>
typedef struct {
@@ -110,8 +104,6 @@ typedef struct {
struct gNB_MAC_INST_s **nrmac;
/// GTPu descriptor
gtpv1u_data_t *gtpv1u_data_g;
/// NR GTPu descriptor
nr_gtpv1u_data_t *nr_gtpv1u_data_g;
/// RU descriptors. These describe what each radio unit is supposed to do and contain the necessary functions for fronthaul interfaces
struct RU_t_s **ru;
/// Mask to indicate fronthaul setup status of RU (hard-limit to 64 RUs)
+13 -5
View File
@@ -25,14 +25,22 @@
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <sys/types.h>
#include <unistd.h>
#include <platform_types.h>
#include "backtrace.h"
#define _Assert_Exit_ \
fprintf(stderr, "\nExiting execution\n"); \
fflush(stdout); \
fflush(stderr); \
abort();
#define _Assert_Exit_ \
if (getenv("gdbStacks")) { \
char tmp [1000]; \
sprintf(tmp,"gdb -ex='set confirm off' -ex 'thread apply all bt' -ex q -p %d > /tmp/full_stacks.%d < /dev/null", \
getpid(), getpid()); \
system(tmp); \
} \
fprintf(stderr, "\nExiting execution\n"); \
fflush(stdout); \
fflush(stderr); \
abort();
#define _Assert_(cOND, aCTION, fORMAT, aRGS...) \
do { \
-34
View File
@@ -1,34 +0,0 @@
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file ue_power.h
* \brief support routines used in MAC and PHY
* \author R. Knopp, F. Kaltenberger
* \date 2020
* \version 0.1
* \company Eurecom
* \email: knopp@eurecom.fr,florian.kaltenberger@eurecom.fr
* \note
* \warning
*/
int16_t estimate_ue_tx_power(int norm,uint32_t tbs, uint32_t nb_rb, uint8_t control_only, lte_prefix_type_t ncp, uint8_t use_srs);
+2 -4
View File
@@ -256,8 +256,8 @@ typedef struct IttiMsgText_s {
#include <openair3/MME_APP/mme_app.h>
//#include <proto.h>
#include <openair3/GTPV1-U/gtpv1u_eNB_task.h>
#include <openair3/GTPV1-U/gtpv1u_gNB_task.h>
#include <openair3/ocp-gtpu/gtpv1u_eNB_task.h>
#include <openair3/ocp-gtpu/gtpv1u_gNB_task.h>
void *rrc_enb_process_itti_msg(void *);
#include <openair3/SCTP/sctp_eNB_task.h>
#include <openair3/NGAP/ngap_gNB.h>
@@ -340,8 +340,6 @@ void *rrc_enb_process_msg(void *);
TASK_DEF(TASK_RAL_UE, TASK_PRIORITY_MED, 200, NULL, NULL) \
TASK_DEF(TASK_MSC, TASK_PRIORITY_MED, 200, NULL, NULL)\
TASK_DEF(TASK_GTPV1_U, TASK_PRIORITY_MED, 1000,NULL, NULL)\
TASK_DEF(OCP_GTPV1_U, TASK_PRIORITY_MED, 1000,NULL, NULL)\
TASK_DEF(TASK_UDP, TASK_PRIORITY_MED, 1000, NULL, NULL)\
TASK_DEF(TASK_CU_F1, TASK_PRIORITY_MED, 200, NULL, NULL) \
TASK_DEF(TASK_DU_F1, TASK_PRIORITY_MED, 200, NULL, NULL) \
TASK_DEF(TASK_RRC_UE_SIM, TASK_PRIORITY_MED, 200, NULL, NULL) \
+1 -1
View File
@@ -369,7 +369,7 @@ gtpv1u_create_s1u_tunnel(), delete tunnel, ... functions are called inside the o
# New GTP
## initialization
ocp_gtpv1uTask(): this creates only the thread, doesn't configure anything
gtpv1uTask(): this creates only the thread, doesn't configure anything
gtpv1Init(): creates a listening socket to Linux for a given reception and select a local IP address
## newGtpuCreateTunnel()
+5 -33
View File
@@ -365,7 +365,7 @@ int create_gNB_tasks(uint32_t gnb_nb) {
//Use check on x2ap to consider the NSA scenario and check on AMF_MODE_ENABLED for the SA scenario
if(is_x2ap_enabled() || AMF_MODE_ENABLED) {
if (itti_create_task (TASK_GTPV1_U, &nr_gtpv1u_gNB_task, NULL) < 0) {
if (itti_create_task (TASK_GTPV1_U, &gtpv1uTask, NULL) < 0) {
LOG_E(GTPU, "Create task for GTPV1U failed\n");
return -1;
}
@@ -589,48 +589,20 @@ static void wait_nfapi_init(char *thread_name) {
}
void init_pdcp(void) {
uint32_t pdcp_initmask = (IS_SOFTMODEM_NOS1) ?
PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT | ENB_NAS_USE_TUN_BIT | SOFTMODEM_NOKRNMOD_BIT:
LINK_ENB_PDCP_TO_GTPV1U_BIT;
if (!get_softmodem_params()->nsa) {
if (!NODE_IS_DU(RC.nrrrc[0]->node_type)) {
//pdcp_layer_init();
uint32_t pdcp_initmask = (IS_SOFTMODEM_NOS1) ?
(PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT) : LINK_ENB_PDCP_TO_GTPV1U_BIT;
if (IS_SOFTMODEM_NOS1) {
printf("IS_SOFTMODEM_NOS1 option enabled \n");
pdcp_initmask = pdcp_initmask | ENB_NAS_USE_TUN_BIT | SOFTMODEM_NOKRNMOD_BIT;
}
nr_pdcp_module_init(pdcp_initmask, 0);
if (NODE_IS_CU(RC.nrrrc[0]->node_type)) {
LOG_I(PDCP, "node is CU, pdcp send rlc_data_req by proto_agent \n");
pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t)proto_agent_send_rlc_data_req);
} else {
LOG_I(PDCP, "node is gNB \n");
pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t) rlc_data_req);
pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) pdcp_data_ind);
}
} else {
LOG_I(PDCP, "node is DU, rlc send pdcp_data_ind by proto_agent \n");
pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) proto_agent_send_pdcp_data_ind);
}
} else {
pdcp_layer_init();
uint32_t pdcp_initmask = (IS_SOFTMODEM_NOS1) ?
(PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT) : LINK_ENB_PDCP_TO_GTPV1U_BIT;
if (IS_SOFTMODEM_NOS1) {
printf("IS_SOFTMODEM_NOS1 option enabled \n");
pdcp_initmask = pdcp_initmask | ENB_NAS_USE_TUN_BIT | SOFTMODEM_NOKRNMOD_BIT;
}
nr_pdcp_module_init(pdcp_initmask, 0);
pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t) rlc_data_req);
pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) pdcp_data_ind);
}
}
int main( int argc, char **argv ) {
int ru_id, CC_id = 0;
start_background_system();
+1 -1
View File
@@ -5,7 +5,6 @@
#include "flexran_agent.h"
#include "PHY/defs_gNB.h"
#include "proto_agent.h"
#define DEFAULT_DLF 2680000000
@@ -65,5 +64,6 @@ void init_gNB_afterRU(void);
extern int stop_L1L2(module_id_t gnb_id);
extern int restart_L1L2(module_id_t gnb_id);
void init_pdcp(void);
#endif
+2 -1
View File
@@ -18,7 +18,8 @@
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#define _GNU_SOURCE
#include <pthread.h>
#include <openair1/PHY/impl_defs_top.h>
#include "executables/nr-uesoftmodem.h"
#include "PHY/phy_extern_nr_ue.h"
-6
View File
@@ -49,12 +49,6 @@ void reset_stats(FL_OBJECT *button, long arg) {
int i,j,k;
PHY_VARS_eNB *phy_vars_eNB = RC.eNB[0][0];
printf("XXX %d %d %d\n",
sizeofArray(phy_vars_eNB->UE_stats),
sizeofArray( phy_vars_eNB->UE_stats[i].dlsch_NAK),
sizeofArray( *phy_vars_eNB->UE_stats[i].dlsch_NAK)
);
for (i=0; i<sizeofArray(phy_vars_eNB->UE_stats); i++) {
for (k=0; k<sizeofArray(phy_vars_eNB->UE_stats[i].dlsch_NAK); k++) { //harq_processes
for (j=0; j<sizeofArray(*phy_vars_eNB->UE_stats[i].dlsch_NAK); j++) {
View File
+6 -1
View File
@@ -175,7 +175,12 @@ gtpv1u_update_ngu_tunnel(
return 0;
}
int ocp_gtpv1u_delete_s1u_tunnel(const instance_t instance, const gtpv1u_enb_delete_tunnel_req_t *const req_pP) {
int gtpv1u_delete_s1u_tunnel(const instance_t instance, const gtpv1u_enb_delete_tunnel_req_t *const req_pP) {
return 0;
}
int gtpv1u_delete_ngu_tunnel( const instance_t instance,
gtpv1u_gnb_delete_tunnel_req_t *req) {
return 0;
}
+6 -1
View File
@@ -143,7 +143,12 @@ gtpv1u_update_ngu_tunnel(
return 0;
}
int ocp_gtpv1u_delete_s1u_tunnel(const instance_t instance, const gtpv1u_enb_delete_tunnel_req_t *const req_pP) {
int gtpv1u_delete_s1u_tunnel(const instance_t instance, const gtpv1u_enb_delete_tunnel_req_t *const req_pP) {
return 0;
}
int gtpv1u_delete_ngu_tunnel( const instance_t instance,
gtpv1u_gnb_delete_tunnel_req_t *req) {
return 0;
}
+2 -2
View File
@@ -688,8 +688,8 @@ int main(int argc, char **argv)
ack_nack_errors+=((actual_payload^payload_received)&1) + (((actual_payload^payload_received)&2)>>1);
}
else if (format==2) {
nfapi_nr_uci_pucch_pdu_format_2_3_4_t uci_pdu;
nfapi_nr_pucch_pdu_t pucch_pdu;
nfapi_nr_uci_pucch_pdu_format_2_3_4_t uci_pdu={0};
nfapi_nr_pucch_pdu_t pucch_pdu={0};
pucch_pdu.rnti = 0x1234;
pucch_pdu.subcarrier_spacing = 1;
pucch_pdu.group_hop_flag = PUCCH_GroupHopping&1;
+6 -1
View File
@@ -139,7 +139,12 @@ gtpv1u_create_s1u_tunnel(
return 0;
}
int ocp_gtpv1u_delete_s1u_tunnel(const instance_t instance, const gtpv1u_enb_delete_tunnel_req_t *const req_pP) {
int gtpv1u_delete_s1u_tunnel(const instance_t instance, const gtpv1u_enb_delete_tunnel_req_t *const req_pP) {
return 0;
}
int gtpv1u_delete_ngu_tunnel( const instance_t instance,
gtpv1u_gnb_delete_tunnel_req_t *req) {
return 0;
}
+1 -1
View File
@@ -125,7 +125,7 @@ void fill_channel_desc(channel_desc_t *chan_desc,
chan_desc->ch[i] = (struct complexd *) malloc(channel_length * sizeof(struct complexd));
for (i = 0; i<nb_tx*nb_rx; i++)
chan_desc->chF[i] = (struct complexd *) malloc(1200 * sizeof(struct complexd)); // allocate for up to 100 RBs, 12 samples per RB
chan_desc->chF[i] = (struct complexd *) malloc(12*257 * sizeof(struct complexd)); // allocate for up to 257 RBs, 12 samples per RB
LOG_D(OCM,"[CHANNEL] Filling a (nb_taps %d)\n",nb_taps);
+2 -8
View File
@@ -19,18 +19,12 @@
* contact@openairinterface.org
*/
MESSAGE_DEF(GTPV1U_ENB_UPDATE_TUNNEL_REQ, MESSAGE_PRIORITY_MED, gtpv1u_enb_update_tunnel_req_t, Gtpv1uUpdateTunnelReq)
MESSAGE_DEF(GTPV1U_ENB_UPDATE_TUNNEL_RESP, MESSAGE_PRIORITY_MED, gtpv1u_enb_update_tunnel_resp_t, Gtpv1uUpdateTunnelResp)
MESSAGE_DEF(GTPV1U_ENB_DELETE_TUNNEL_REQ, MESSAGE_PRIORITY_MED, gtpv1u_enb_delete_tunnel_req_t, Gtpv1uDeleteTunnelReq)
MESSAGE_DEF(GTPV1U_ENB_DELETE_TUNNEL_RESP, MESSAGE_PRIORITY_MED, gtpv1u_enb_delete_tunnel_resp_t, Gtpv1uDeleteTunnelResp)
MESSAGE_DEF(GTPV1U_ENB_TUNNEL_DATA_IND, MESSAGE_PRIORITY_MED, gtpv1u_enb_tunnel_data_ind_t, Gtpv1uTunnelDataInd)
MESSAGE_DEF(GTPV1U_ENB_TUNNEL_DATA_REQ, MESSAGE_PRIORITY_MED, gtpv1u_enb_tunnel_data_req_t, Gtpv1uTunnelDataReq)
MESSAGE_DEF(GTPV1U_ENB_DATA_FORWARDING_REQ, MESSAGE_PRIORITY_MED, gtpv1u_enb_data_forwarding_req_t,Gtpv1uDataForwardingReq)
MESSAGE_DEF(GTPV1U_ENB_DATA_FORWARDING_IND, MESSAGE_PRIORITY_MED, gtpv1u_enb_data_forwarding_ind_t,Gtpv1uDataForwardingInd)
MESSAGE_DEF(GTPV1U_ENB_END_MARKER_REQ, MESSAGE_PRIORITY_MED, gtpv1u_enb_end_marker_req_t, Gtpv1uEndMarkerReq)
MESSAGE_DEF(GTPV1U_ENB_END_MARKER_IND, MESSAGE_PRIORITY_MED, gtpv1u_enb_end_marker_ind_t, Gtpv1uEndMarkerInd)
MESSAGE_DEF(GTPV1U_REQ, MESSAGE_PRIORITY_MED, Gtpv1uReq, gtpv1uReq)
MESSAGE_DEF(GTPV1U_REQ, MESSAGE_PRIORITY_MED, Gtpv1uReq, gtpv1uReq)
MESSAGE_DEF(GTPV1U_GNB_DELETE_TUNNEL_REQ, MESSAGE_PRIORITY_MED, gtpv1u_gnb_delete_tunnel_req_t, NRGtpv1uDeleteTunnelReq)
MESSAGE_DEF(GTPV1U_GNB_DELETE_TUNNEL_RESP, MESSAGE_PRIORITY_MED, gtpv1u_gnb_delete_tunnel_resp_t, NRGtpv1uDeleteTunnelResp)
MESSAGE_DEF(GTPV1U_GNB_TUNNEL_DATA_REQ, MESSAGE_PRIORITY_MED, gtpv1u_gnb_tunnel_data_req_t, NRGtpv1uTunnelDataReq)
-8
View File
@@ -28,10 +28,6 @@
#define GTPV1U_MAX_BEARERS_PER_UE max_val_LTE_DRB_Identity
#define NR_GTPV1U_MAX_BEARERS_PER_UE max_val_NR_DRB_Identity
#define GTPV1U_ENB_UPDATE_TUNNEL_REQ(mSGpTR) (mSGpTR)->ittiMsg.Gtpv1uUpdateTunnelReq
#define GTPV1U_ENB_UPDATE_TUNNEL_RESP(mSGpTR) (mSGpTR)->ittiMsg.Gtpv1uUpdateTunnelResp
#define GTPV1U_ENB_DELETE_TUNNEL_REQ(mSGpTR) (mSGpTR)->ittiMsg.Gtpv1uDeleteTunnelReq
#define GTPV1U_ENB_DELETE_TUNNEL_RESP(mSGpTR) (mSGpTR)->ittiMsg.Gtpv1uDeleteTunnelResp
#define GTPV1U_ENB_TUNNEL_DATA_IND(mSGpTR) (mSGpTR)->ittiMsg.Gtpv1uTunnelDataInd
#define GTPV1U_ENB_TUNNEL_DATA_REQ(mSGpTR) (mSGpTR)->ittiMsg.Gtpv1uTunnelDataReq
#define GTPV1U_ENB_DATA_FORWARDING_REQ(mSGpTR) (mSGpTR)->ittiMsg.Gtpv1uDataForwardingReq
@@ -41,8 +37,6 @@
#define GTPV1U_REQ(mSGpTR) (mSGpTR)->ittiMsg.gtpv1uReq
#define GTPV1U_GNB_DELETE_TUNNEL_REQ(mSGpTR) (mSGpTR)->ittiMsg.NRGtpv1uDeleteTunnelReq
#define GTPV1U_GNB_DELETE_TUNNEL_RESP(mSGpTR) (mSGpTR)->ittiMsg.NRGtpv1uDeleteTunnelResp
#define GTPV1U_GNB_TUNNEL_DATA_REQ(mSGpTR) (mSGpTR)->ittiMsg.NRGtpv1uTunnelDataReq
#define GTPV1U_ALL_TUNNELS_TEID (teid_t)0xFFFFFFFF
@@ -200,7 +194,6 @@ typedef struct gtpv1u_gnb_create_tunnel_resp_s {
pdusessionid_t pdusession_id[NR_GTPV1U_MAX_BEARERS_PER_UE];
transport_layer_addr_t gnb_addr;
} gtpv1u_gnb_create_tunnel_resp_t;
typedef struct gtpv1u_gnb_delete_tunnel_req_s {
rnti_t rnti;
uint8_t num_pdusession;
@@ -212,7 +205,6 @@ typedef struct gtpv1u_gnb_delete_tunnel_resp_s {
uint8_t status; ///< Status of NGU endpoint deleteion (Failed = 0xFF or Success = 0x0)
teid_t gnb_NGu_teid; ///< local NGU Tunnel Endpoint Identifier to be deleted
} gtpv1u_gnb_delete_tunnel_resp_t;
typedef struct gtpv1u_gnb_tunnel_data_req_s {
uint8_t *buffer;
uint32_t length;
+1 -2
View File
@@ -55,7 +55,6 @@
#include "common/config/config_userapi.h"
#include "RRC_config_tools.h"
#include "enb_paramdef.h"
#include "proto_agent.h"
#include "executables/thread-common.h"
#include <openair3/ocp-gtpu/gtp_itf.h>
@@ -2080,7 +2079,7 @@ int RCconfig_gtpu(void ) {
GTPV1U_REQ(message).localPort = enb_port_for_S1U;
strcpy(GTPV1U_REQ(message).localAddrStr,address);
sprintf(GTPV1U_REQ(message).localPortStr,"%d", enb_port_for_S1U);
itti_send_msg_to_task (TASK_VARIABLE, 0, message); // data model is wrong: gtpu doesn't have enb_id (or module_id)
itti_send_msg_to_task (TASK_GTPV1_U, 0, message); // data model is wrong: gtpu doesn't have enb_id (or module_id)
} else
LOG_E(GTPU,"invalid address for S1U\n");
+1 -2
View File
@@ -35,7 +35,6 @@
#include "f1ap_cu_rrc_message_transfer.h"
#include "f1ap_cu_ue_context_management.h"
#include "f1ap_cu_task.h"
#include "proto_agent.h"
#include <openair3/ocp-gtpu/gtp_itf.h>
//Fixme: Uniq dirty DU instance, by global var, datamodel need better management
@@ -47,7 +46,7 @@ static instance_t cu_task_create_gtpu_instance_to_du(eth_params_t *IPaddrs) {
strncpy(tmp.destinationHost, IPaddrs->remote_addr, sizeof(tmp.destinationHost)-1);
sprintf(tmp.originService, "%d", IPaddrs->my_portd);
sprintf(tmp.destinationService, "%d", IPaddrs->remote_portd);
return ocp_gtpv1Init(tmp);
return gtpv1Init(tmp);
}
static void cu_task_handle_sctp_association_ind(instance_t instance, sctp_new_association_ind_t *sctp_new_association_ind,
+1 -2
View File
@@ -35,7 +35,6 @@
#include "f1ap_du_ue_context_management.h"
#include "f1ap_du_rrc_message_transfer.h"
#include "f1ap_du_task.h"
#include "proto_agent.h"
#include <openair3/ocp-gtpu/gtp_itf.h>
//Fixme: Uniq dirty DU instance, by global var, datamodel need better management
@@ -103,7 +102,7 @@ static instance_t du_create_gtpu_instance_to_cu(char *CUaddr, uint16_t CUport, c
strncpy(tmp.destinationHost, CUaddr, sizeof(tmp.destinationHost)-1);
sprintf(tmp.originService, "%d", DUport);
sprintf(tmp.destinationService, "%d", CUport);
return ocp_gtpv1Init(tmp);
return gtpv1Init(tmp);
}
void *F1AP_DU_task(void *arg) {
+1 -29
View File
@@ -31,8 +31,8 @@
#include <stdio.h>
#include <nr_pdcp/nr_pdcp.h>
#include <softmodem-common.h>
#include <nr-softmodem.h>
#include <split_headers.h>
#include <proto_agent.h>
#include "gnb_app.h"
#include "gnb_config.h"
@@ -135,34 +135,6 @@ static uint32_t gNB_app_register_x2(uint32_t gnb_id_start, uint32_t gnb_id_end)
/*------------------------------------------------------------------------------*/
static void init_pdcp(void) {
if (!NODE_IS_DU(RC.nrrrc[0]->node_type)) {
pdcp_layer_init();
uint32_t pdcp_initmask = (IS_SOFTMODEM_NOS1) ?
(PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT) : LINK_ENB_PDCP_TO_GTPV1U_BIT;
if (IS_SOFTMODEM_NOS1) {
LOG_I(PDCP, "IS_SOFTMODEM_NOS1 option enabled\n");
pdcp_initmask = pdcp_initmask | ENB_NAS_USE_TUN_BIT | SOFTMODEM_NOKRNMOD_BIT;
}
nr_pdcp_module_init(pdcp_initmask, 0);
if (NODE_IS_CU(RC.nrrrc[0]->node_type)) {
LOG_I(PDCP, "node is CU, pdcp send rlc_data_req by proto_agent \n");
pdcp_set_rlc_data_req_func(proto_agent_send_rlc_data_req);
} else {
LOG_I(PDCP, "node is gNB \n");
pdcp_set_rlc_data_req_func(rlc_data_req);
pdcp_set_pdcp_data_ind_func(pdcp_data_ind);
}
} else {
LOG_I(PDCP, "node is DU, rlc send pdcp_data_ind by proto_agent \n");
pdcp_set_pdcp_data_ind_func(proto_agent_send_pdcp_data_ind);
}
}
/*------------------------------------------------------------------------------*/
void *gNB_app_task(void *args_p)
{
+1 -1
View File
@@ -1227,7 +1227,7 @@ int RCconfig_nr_gtpu(void ) {
GTPV1U_REQ(message).localPort = port;
strcpy(GTPV1U_REQ(message).localAddrStr,address);
sprintf(GTPV1U_REQ(message).localPortStr,"%d", port);
itti_send_msg_to_task (TASK_VARIABLE, 0, message); // data model is wrong: gtpu doesn't have enb_id (or module_id)
itti_send_msg_to_task (TASK_GTPV1_U, 0, message); // data model is wrong: gtpu doesn't have enb_id (or module_id)
} else
LOG_E(GTPU,"invalid address for NGU or S1U\n");
+2 -3
View File
@@ -60,7 +60,6 @@
#include <pthread.h>
# include "gtpv1u_eNB_task.h"
# include "gtpv1u.h"
#include <openair3/ocp-gtpu/gtp_itf.h>
#include "ENB_APP/enb_config.h"
@@ -229,7 +228,7 @@ rlc_op_status_t cu_send_to_du(const protocol_ctxt_t *const ctxt,
LOG_D(PDCP, "%s() (drb %ld) sending message to gtp size %d\n",
__func__, rb_id, size);
extern instance_t CUuniqInstance;
itti_send_msg_to_task(TASK_VARIABLE, CUuniqInstance, message_p);
itti_send_msg_to_task(TASK_GTPV1_U, CUuniqInstance, message_p);
return TRUE;
}
@@ -1078,7 +1077,7 @@ pdcp_data_ind(
GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).offset = GTPU_HEADER_OVERHEAD_MAX;
GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).rnti = ctxt_pP->rnti;
GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).rab_id = rb_id + 4;
itti_send_msg_to_task(TASK_VARIABLE, INSTANCE_DEFAULT, message_p);
itti_send_msg_to_task(TASK_GTPV1_U, INSTANCE_DEFAULT, message_p);
packet_forwarded = TRUE;
}
} else {
-2
View File
@@ -85,8 +85,6 @@ extern struct msghdr nas_msg_rx;
# include "gtpv1u_eNB_task.h"
# include "gtpv1u_eNB_defs.h"
extern int gtpv1u_new_data_req( uint8_t enb_module_idP, rnti_t ue_rntiP, uint8_t rab_idP, uint8_t *buffer_pP, uint32_t buf_lenP, uint32_t buf_offsetP);
uint16_t ue_id_g; // Global variable to identify the ID for each UE. It is updated in main() of lte-uesoftmodem.c
-172
View File
@@ -1,172 +0,0 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <sys/time.h>
#include "ENB_APP/enb_paramdef.h"
#include "LAYER2/PROTO_AGENT/proto_agent.h"
#define BUF_MAX 1400
int recv_client = 0;
FILE *output;
void usage(char *prg_name) {
fprintf(stderr, "usage: %s <file or ->\n", prg_name);
fprintf(stderr, " - is stdin\n");
fprintf(stderr, " received packets are written to stdout\n");
}
long uelapsed(struct timeval *s, struct timeval *e) {
return e->tv_sec * 1000000 + e->tv_usec - (s->tv_sec * 1000000 + s->tv_usec);
}
boolean_t
pdcp_data_ind(
const protocol_ctxt_t *const ctxt_pP,
const srb_flag_t srb_flagP,
const MBMS_flag_t MBMS_flagP,
const rb_id_t rb_idP,
const sdu_size_t sdu_buffer_sizeP,
mem_block_t *const sdu_buffer_pP
) {
fwrite(sdu_buffer_pP->data, sdu_buffer_sizeP, 1, stdout);
fflush(stdout);
free_mem_block(sdu_buffer_pP, __func__);
/* cannot free because of const */
//free(ctxt_pP);
recv_client = 1;
return 0;
}
void close_proto_agent(void) {
proto_agent_stop(0);
}
int main(int argc, char *argv[]) {
const cudu_params_t params = {
.local_ipv4_address = "192.168.12.45",
.local_port = 6464,
.remote_ipv4_address = "192.168.12.45",
.remote_port = 6465
};
protocol_ctxt_t p;
memset(&p, 0, sizeof p);
mem_block_t mem;
char s[BUF_MAX];
size_t size, totsize = 0;
struct timeval t_start, t_end;
FILE *f;
if (argc != 2) {
usage(argv[0]);
return 1;
}
if (strcmp(argv[1], "-") == 0) {
f = stdin;
} else {
f = fopen(argv[1], "r");
}
if (!f) {
fprintf(stderr, "cannot open %s: %s\n", argv[1], strerror(errno));
return 2;
}
pool_buffer_init();
if (proto_agent_start(0, &params) != 0) {
fprintf(stderr, "error on proto_agent_start()\n");
fclose(f);
return 3;
}
atexit(close_proto_agent);
/* wait for first packet of client */
while (!recv_client) sleep(1);
fprintf(stderr, "reading file\n");
/* now send back at the same time */
gettimeofday(&t_start, NULL);
while ((size = fread(s, 1, BUF_MAX, f)) > 0) {
usleep(10);
totsize += size;
mem.data = &s[0];
proto_agent_send_rlc_data_req(&p, 0, 0, 0, 0, 0, size, &mem);
}
gettimeofday(&t_end, NULL);
fclose(f);
long us = uelapsed(&t_start, &t_end);
fprintf(stderr, "read %zu bytes in %ld ms -> %.3fMB/s, %.3fMbps\n",
totsize, us / 1000, ((float) totsize ) / us,
((float) totsize) / us * 8);
fprintf(stderr, "check files using 'diff afile bfile'\n");
/* give some time in case the other direction is slower */
sleep(5);
return 0;
}
/*
*********************************************************
* arbitrary functions, needed for linking (used or not) *
*********************************************************
*/
rlc_op_status_t rlc_data_req (const protocol_ctxt_t *const ctxt_pP,
const srb_flag_t srb_flagP,
const MBMS_flag_t MBMS_flagP,
const rb_id_t rb_idP,
const mui_t muiP,
confirm_t confirmP,
sdu_size_t sdu_sizeP,
mem_block_t *sdu_pP,
const uint32_t *const sourceL2Id,
const uint32_t *const destinationL2Id
) {
fprintf(stderr, "This should never be called on the CU\n");
exit(1);
}
pthread_t new_thread(void *(*f)(void *), void *b) {
pthread_t t;
pthread_attr_t att;
if (pthread_attr_init(&att)) {
fprintf(stderr, "pthread_attr_init err\n");
exit(1);
}
if (pthread_attr_setdetachstate(&att, PTHREAD_CREATE_DETACHED)) {
fprintf(stderr, "pthread_attr_setdetachstate err\n");
exit(1);
}
if (pthread_create(&t, &att, f, b)) {
fprintf(stderr, "pthread_create err\n");
exit(1);
}
if (pthread_attr_destroy(&att)) {
fprintf(stderr, "pthread_attr_destroy err\n");
exit(1);
}
return t;
}
int log_header(char *log_buffer, int buffsize, int comp, int level,const char *format) {
return 0;
}
int config_get(paramdef_t *params,int numparams, char *prefix) {
return 0;
}
int config_process_cmdline(paramdef_t *cfgoptions,int numoptions, char *prefix) {
return 0;
}
-163
View File
@@ -1,163 +0,0 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <sys/time.h>
#include "ENB_APP/enb_paramdef.h"
#include "LAYER2/PROTO_AGENT/proto_agent.h"
#define BUF_MAX 1400
void usage(char *prg_name) {
fprintf(stderr, "usage: %s <file or ->\n", prg_name);
fprintf(stderr, " - is stdin\n");
fprintf(stderr, " received packets are written to stdout\n");
}
long uelapsed(struct timeval *s, struct timeval *e) {
return e->tv_sec * 1000000 + e->tv_usec - (s->tv_sec * 1000000 + s->tv_usec);
}
rlc_op_status_t rlc_data_req (const protocol_ctxt_t *const ctxt_pP,
const srb_flag_t srb_flagP,
const MBMS_flag_t MBMS_flagP,
const rb_id_t rb_idP,
const mui_t muiP,
confirm_t confirmP,
sdu_size_t sdu_sizeP,
mem_block_t *sdu_pP,
const uint32_t *const sourceL2Id,
const uint32_t *const destinationL2Id
) {
fwrite(sdu_pP->data, sdu_sizeP, 1, stdout);
fflush(stdout);
free_mem_block(sdu_pP, __func__);
//free(ctxt_pP);
return 0;
}
void close_proto_agent(void) {
proto_agent_stop(0);
}
int main(int argc, char *argv[]) {
const cudu_params_t params = {
.local_ipv4_address = "192.168.12.45",
.local_port = 6465,
.remote_ipv4_address = "192.168.12.45",
.remote_port = 6464
};
protocol_ctxt_t p;
memset(&p, 0, sizeof p);
mem_block_t mem;
char s[BUF_MAX];
size_t size, totsize = 0;
struct timeval t_start, t_end;
FILE *f;
if (argc != 2) {
usage(argv[0]);
return 1;
}
if (strcmp(argv[1], "-") == 0) {
f = stdin;
} else {
f = fopen(argv[1], "r");
}
if (!f) {
fprintf(stderr, "cannot open %s: %s\n", argv[1], strerror(errno));
return 2;
}
pool_buffer_init();
if (proto_agent_start(0, &params) != 0) {
fprintf(stderr, "error on proto_agent_start()\n");
fclose(f);
return 3;
}
atexit(close_proto_agent);
gettimeofday(&t_start, NULL);
while ((size = fread(s, 1, BUF_MAX, f)) > 0) {
usleep(10);
totsize += size;
mem.data = &s[0];
proto_agent_send_pdcp_data_ind(&p, 0, 0, 0, size, &mem);
}
gettimeofday(&t_end, NULL);
fclose(f);
long us = uelapsed(&t_start, &t_end);
fprintf(stderr, "read %zu bytes in %ld ms -> %.3fMB/s, %.3fMbps\n",
totsize, us / 1000, ((float) totsize ) / us,
((float) totsize) / us * 8);
fprintf(stderr, "check files using 'diff afile bfile'\n");
/* wait, we are possibly receiving data */
sleep(5);
return 0;
}
/*
*********************************************************
* arbitrary functions, needed for linking (used or not) *
*********************************************************
*/
boolean_t
pdcp_data_ind(
const protocol_ctxt_t *const ctxt_pP,
const srb_flag_t srb_flagP,
const MBMS_flag_t MBMS_flagP,
const rb_id_t rb_idP,
const sdu_size_t sdu_buffer_sizeP,
mem_block_t *const sdu_buffer_pP
) {
fprintf(stderr, "This should never be called on the DU\n");
exit(1);
}
pthread_t new_thread(void *(*f)(void *), void *b) {
pthread_t t;
pthread_attr_t att;
if (pthread_attr_init(&att)) {
fprintf(stderr, "pthread_attr_init err\n");
exit(1);
}
if (pthread_attr_setdetachstate(&att, PTHREAD_CREATE_DETACHED)) {
fprintf(stderr, "pthread_attr_setdetachstate err\n");
exit(1);
}
if (pthread_create(&t, &att, f, b)) {
fprintf(stderr, "pthread_create err\n");
exit(1);
}
if (pthread_attr_destroy(&att)) {
fprintf(stderr, "pthread_attr_destroy err\n");
exit(1);
}
return t;
}
int log_header(char *log_buffer, int buffsize, int comp, int level,const char *format) {
return 0;
}
int config_get(paramdef_t *params,int numparams, char *prefix) {
return 0;
}
int config_process_cmdline(paramdef_t *cfgoptions,int numoptions, char *prefix) {
return 0;
}
-278
View File
@@ -1,278 +0,0 @@
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file enb_agent.h
* \brief top level enb agent receive thread and itti task
* \author Navid Nikaein and Xenofon Foukas
* \date 2016
* \version 0.1
*/
#define _GNU_SOURCE
#include "proto_agent_common.h"
#include "common/utils/LOG/log.h"
#include "proto_agent.h"
#include "assertions.h"
#include "proto_agent_net_comm.h"
#include "proto_agent_async.h"
#include <common/utils/system.h>
#include <pthread.h>
#define ENB_AGENT_MAX 9
proto_agent_instance_t proto_agent[MAX_DU];
//pthread_t new_thread(void *(*f)(void *), void *b);
Protocol__FlexsplitMessage *proto_agent_timeout_fsp(void *args);
#define TEST_MOD 0
#define ECHO
/* Server side function; upon a new connection
reception, sends the hello packets
*/
int proto_agent_start(mod_id_t mod_id, const cudu_params_t *p) {
int channel_id;
// RS: CUDU does not work!
//DevAssert(p->local_interface);
//DevAssert(p->local_ipv4_address);
//DevAssert(p->local_port > 1024); // "unprivileged" port
//DevAssert(p->remote_ipv4_address);
//DevAssert(p->remote_port > 1024); // "unprivileged" port
proto_agent[mod_id].mod_id = mod_id;
proto_agent[mod_id].exit = 0;
/* Initialize the channel container */
/* TODO only initialize the first time */
proto_agent_init_channel_container();
/*Create the async channel info*/
proto_agent_async_channel_t *channel_info;
channel_info = proto_agent_async_channel_info(mod_id, p->local_ipv4_address, p->local_port,
p->remote_ipv4_address, p->remote_port);
if (!channel_info) goto error;
/* Create a channel using the async channel info */
channel_id = proto_agent_create_channel((void *) channel_info,
proto_agent_async_msg_send,
proto_agent_async_msg_recv,
proto_agent_async_release);
if (channel_id <= 0) goto error;
proto_agent_channel_t *channel = proto_agent_get_channel(channel_id);
if (!channel) goto error;
proto_agent[mod_id].channel = channel;
/* Register the channel for all underlying agents (use ENB_AGENT_MAX) */
proto_agent_register_channel(mod_id, channel, ENB_AGENT_MAX);
// Code for sending the HELLO/ECHO_REQ message once a connection is established
//uint8_t *msg = NULL;
//Protocol__FlexsplitMessage *init_msg=NULL;
//if (udp == 0)
//{
// // If the comm is not UDP, allow the server to send the first packet over the channel
// //printf( "Proto agent Server: Calling the echo_request packet constructor\n");
// msg_flag = proto_agent_echo_request(mod_id, NULL, &init_msg);
// if (msg_flag != 0)
// goto error;
//
// int msgsize = 0;
// if (init_msg != NULL)
// msg = proto_agent_pack_message(init_msg, &msgsize);
// if (msg!= NULL)
// {
// LOG_D(PROTO_AGENT, "Server sending the message over the async channel\n");
// proto_agent_async_msg_send((void *)msg, (int) msgsize, 1, (void *) channel_info);
// }
// /* After sending the message, wait for any replies;
// the server thread blocks until it reads any data
// over the channel
// */
//}
//proto_agent[mod_id].recv_thread = new_thread(proto_agent_receive, &proto_agent[mod_id]);
threadCreate(&proto_agent[mod_id].recv_thread, proto_agent_receive, &proto_agent[mod_id], "proto", -1, OAI_PRIORITY_RT_LOW);
fprintf(stderr, "[PROTO_AGENT] server started at port %s:%d\n", p->local_ipv4_address, p->local_port);
return 0;
error:
LOG_E(PROTO_AGENT, "there was an error\n");
return 1;
}
void proto_agent_stop(mod_id_t mod_id) {
if (!proto_agent[mod_id].channel) return;
/* unlock the independent read thread proto_agent_receive() */
proto_agent[mod_id].exit = 1;
proto_agent_async_msg_recv_unlock(proto_agent[mod_id].channel->channel_info);
proto_agent_async_release(proto_agent[mod_id].channel);
proto_agent_destroy_channel(proto_agent[mod_id].channel->channel_id);
free(proto_agent[mod_id].channel);
proto_agent[mod_id].channel = NULL;
LOG_W(PROTO_AGENT, "server stopped\n");
}
//void
//proto_agent_send_hello(void)
//{
// uint8_t *msg = NULL;
// Protocol__FlexsplitMessage *init_msg=NULL;
// int msg_flag = 0;
//
//
// //printf( "PDCP agent: Calling the HELLO packet constructor\n");
// msg_flag = proto_agent_hello(proto_agent[TEST_MOD].mod_id, NULL, &init_msg);
//
// int msgsize = 0;
// if (msg_flag == 0)
// {
// proto_agent_serialize_message(init_msg, &msg, &msgsize);
// }
//
// LOG_D(PROTO_AGENT, "Agent sending the message over the async channel\n");
// proto_agent_async_msg_send((void *)msg, (int) msgsize, 1, (void *) client_channel[TEST_MOD]);
//}
rlc_op_status_t proto_agent_send_rlc_data_req(const protocol_ctxt_t *const ctxt_pP,
const srb_flag_t srb_flagP, const MBMS_flag_t MBMS_flagP,
const rb_id_t rb_idP, const mui_t muiP,
confirm_t confirmP, sdu_size_t sdu_sizeP, mem_block_t *sdu_pP,const uint32_t *const SrcID, const uint32_t *const DstID) {
uint8_t *msg = NULL;
Protocol__FlexsplitMessage *init_msg=NULL;
int msg_flag = 0;
int msgsize = 0;
mod_id_t mod_id = ctxt_pP->module_id;
data_req_args args;
DevAssert(proto_agent[mod_id].channel);
DevAssert(proto_agent[mod_id].channel->channel_info);
args.ctxt = ctxt_pP;
args.srb_flag = srb_flagP;
args.MBMS_flag = MBMS_flagP;
args.rb_id = rb_idP;
args.mui = muiP;
args.confirm = confirmP;
args.sdu_size = sdu_sizeP;
args.sdu_p = sdu_pP;
msg_flag = proto_agent_pdcp_data_req(mod_id, (void *) &args, &init_msg);
if (msg_flag != 0 || !init_msg) goto error;
msg = proto_agent_pack_message(init_msg, &msgsize);
if (!msg) goto error;
proto_agent_async_msg_send((void *)msg, (int) msgsize, 1, proto_agent[mod_id].channel->channel_info);
free_mem_block(sdu_pP, __func__);
return RLC_OP_STATUS_OK;
error:
LOG_E(PROTO_AGENT, "PROTO_AGENT there was an error\n");
return RLC_OP_STATUS_INTERNAL_ERROR;
}
boolean_t proto_agent_send_pdcp_data_ind(const protocol_ctxt_t *const ctxt_pP, const srb_flag_t srb_flagP,
const MBMS_flag_t MBMS_flagP, const rb_id_t rb_idP,
sdu_size_t sdu_sizeP, mem_block_t *sdu_pP,
const uint32_t *const SrcID, const uint32_t *const DstID) {
uint8_t *msg = NULL;
Protocol__FlexsplitMessage *init_msg = NULL;
int msg_flag = 0;
int msgsize = 0;
mod_id_t mod_id = ctxt_pP->module_id;
data_req_args args;
DevAssert(proto_agent[mod_id].channel);
DevAssert(proto_agent[mod_id].channel->channel_info);
args.ctxt = ctxt_pP;
args.srb_flag = srb_flagP;
args.MBMS_flag = MBMS_flagP;
args.rb_id = rb_idP;
args.sdu_size = sdu_sizeP;
args.sdu_p = sdu_pP;
msg_flag = proto_agent_pdcp_data_ind(mod_id, (void *) &args, &init_msg);
if (msg_flag != 0 || !init_msg) goto error;
msg = proto_agent_pack_message(init_msg, &msgsize);
if (!msg) goto error;
proto_agent_async_msg_send((void *)msg, (int) msgsize, 1, proto_agent[mod_id].channel->channel_info);
free_mem_block(sdu_pP, __func__);
return TRUE;
error:
LOG_E(PROTO_AGENT, "there was an error in %s\n", __func__);
return FALSE;
}
void *
proto_agent_receive(void *args) {
proto_agent_instance_t *inst = args;
void *data = NULL;
int size;
int priority;
err_code_t err_code;
pthread_setname_np(pthread_self(), "proto_rx");
Protocol__FlexsplitMessage *msg;
uint8_t *ser_msg;
while (1) {
msg = NULL;
ser_msg = NULL;
if ((size = proto_agent_async_msg_recv(&data, &priority, inst->channel->channel_info)) < 0) {
err_code = PROTOCOL__FLEXSPLIT_ERR__MSG_ENQUEUING;
goto error;
}
if (inst->exit) break;
LOG_D(PROTO_AGENT, "Server side Received message with size %d and priority %d, calling message handle\n", size, priority);
msg = proto_agent_handle_message(inst->mod_id, data, size);
if (!msg) {
LOG_D(PROTO_AGENT, "msg to send back is NULL\n");
continue;
}
ser_msg = proto_agent_pack_message(msg, &size);
if (!ser_msg) {
continue;
}
LOG_D(PROTO_AGENT, "Server sending the reply message over the async channel\n");
if (proto_agent_async_msg_send((void *)ser_msg, (int) size, 1, inst->channel->channel_info)) {
err_code = PROTOCOL__FLEXSPLIT_ERR__MSG_ENQUEUING;
goto error;
}
LOG_D(PROTO_AGENT, "sent message with size %d\n", size);
}
return NULL;
error:
LOG_E(PROTO_AGENT, "proto_agent_receive(): error %d occured\n",err_code);
return NULL;
}
-49
View File
@@ -1,49 +0,0 @@
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file proto_agent.h
* \brief top level protocol agent
* \author Navid Nikaein and Xenofon Foukas
* \date 2016
* \version 0.1
*/
#ifndef PROTO_AGENT_H_
#define PROTO_AGENT_H_
#include "ENB_APP/enb_config.h" // for enb properties
#include "proto_agent_common.h"
#include "LAYER2/NR_MAC_gNB/nr_mac_gNB.h"
#include "RRC/NR/nr_rrc_defs.h"
void *proto_agent_receive(void *args);
int proto_agent_start(mod_id_t mod_id, const cudu_params_t *p);
void proto_agent_stop(mod_id_t mod_id);
rlc_op_status_t proto_agent_send_rlc_data_req( const protocol_ctxt_t *const ctxt_pP,
const srb_flag_t srb_flagP, const MBMS_flag_t MBMS_flagP,
const rb_id_t rb_idP, const mui_t muiP, confirm_t confirmP,
sdu_size_t sdu_sizeP, mem_block_t *sdu_pP,const uint32_t *const SrcID, const uint32_t *const DstID);
pdcp_data_ind_t proto_agent_send_pdcp_data_ind;
#endif
@@ -1,93 +0,0 @@
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include "proto_agent_async.h"
#include "proto_agent_defs.h"
#include "common/utils/LOG/log.h"
proto_agent_async_channel_t *
proto_agent_async_channel_info(mod_id_t mod_id, const char *bind_ip, uint16_t bind_port,
const char* peer_ip, uint16_t peer_port)
{
proto_agent_async_channel_t *channel;
channel = malloc(sizeof(proto_agent_async_channel_t));
if (channel == NULL)
goto error;
channel->enb_id = mod_id;
channel->link = new_link_udp_server(bind_ip, bind_port);
if (channel->link == NULL) goto error;
channel->send_queue = new_message_queue();
if (channel->send_queue == NULL) goto error;
channel->receive_queue = new_message_queue();
if (channel->receive_queue == NULL) goto error;
channel->manager = create_link_manager(channel->send_queue,
channel->receive_queue,
channel->link);
/* manually set remote IP&port for UDP server remote end */
channel->manager->peer_port = peer_port;
channel->manager->peer_addr = peer_ip;
if (channel->manager == NULL) goto error;
return channel;
error:
if (channel)
free(channel);
LOG_E(PROTO_AGENT, "error creating proto_agent_async_channel_t\n");
return NULL;
}
int proto_agent_async_msg_send(void *data, int size, int priority, void *channel_info)
{
proto_agent_async_channel_t *channel = channel_info;
return message_put(channel->send_queue, data, size, priority);
}
int proto_agent_async_msg_recv(void **data, int *priority, void *channel_info)
{
proto_agent_async_channel_t *channel = channel_info;
return message_get(channel->receive_queue, data, priority);
}
void proto_agent_async_msg_recv_unlock(proto_agent_async_channel_t *channel) {
message_get_unlock(channel->receive_queue);
}
void proto_agent_async_release(proto_agent_channel_t *channel)
{
proto_agent_async_channel_t *channel_info = channel->channel_info;
destroy_link_manager(channel_info->manager);
destroy_message_queue(channel_info->send_queue);
destroy_message_queue(channel_info->receive_queue);
close_link(channel_info->link);
free(channel_info);
}
@@ -1,56 +0,0 @@
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file enb_agent_async.h
* \brief channel implementation for async interface
* \author Xenofon Foukas
* \date 2016
* \version 0.1
*/
#ifndef PROTO_AGENT_ASYNC_H_
#define PROTO_AGENT_ASYNC_H_
#include "proto_agent_net_comm.h"
typedef struct proto_agent_async_channel_s {
mod_id_t enb_id;
socket_link_t *link;
message_queue_t *send_queue;
message_queue_t *receive_queue;
link_manager_t *manager;
} proto_agent_async_channel_t;
proto_agent_async_channel_t *
proto_agent_async_channel_info(mod_id_t mod_id, const char *bind_ip, uint16_t bind_port,
const char *peer_ip, uint16_t peer_port);
int proto_agent_async_msg_send(void *data, int size, int priority, void *channel_info);
int proto_agent_async_msg_recv(void **data, int *priority, void *channel_info);
/* unlocks a running proto_agent_async_msg_recv() */
void proto_agent_async_msg_recv_unlock(proto_agent_async_channel_t *channel);
void proto_agent_async_release(proto_agent_channel_t *channel);
#endif /*PROTO_AGENT_ASYNC_H_*/
@@ -1,719 +0,0 @@
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file proto_agent_common.c
* \brief common primitives for all agents
* \author Navid Nikaein and Xenofon Foukas
* \date 2016
* \version 0.1
*/
#include<stdio.h>
#include <dlfcn.h>
#include <time.h>
#include "PHY/phy_extern.h"
#include "proto_agent_common.h"
#include "common/utils/LOG/log.h"
#include "common/ran_context.h"
extern RAN_CONTEXT_t RC;
/*
* message primitives
*/
// Function to fill in the dl_data header (32bits) with the appropriate fields (doing bitwise operations)
void fill_dl_data_header(int pdu_type, int spare, int seq_no, uint32_t *header) {
uint32_t type = pdu_type;
uint32_t spare_ = spare;
uint32_t seq = seq_no;
type = type << 28;
spare_ = spare_ << 24;
*header = (type | spare_);
*header = (*header | seq);
return;
}
// Function to retrieve data from the dl_data header (32bits) (doing bitwise operations)
void read_dl_data_header(int *pdu_type, int *spare, int *seqno, uint32_t header) {
*pdu_type = header;
*spare = header;
*seqno = header;
*pdu_type = *pdu_type >> 28;
*spare = *spare << 4;
*spare = *spare >> 28;
*seqno = *seqno << 8;
*seqno = *seqno >> 8;
return;
}
int f1u_serialize_message(Protocol__F1uMessage *msg, void **buf,int *size) {
*size = protocol__f1u_message__get_packed_size(msg);
*buf = malloc(*size);
if (!(*buf))
goto error;
protocol__f1u_message__pack(msg, *buf);
return 0;
error:
LOG_E(F1U, "an error occured\n");
return -1;
}
int f1u_deserialize_message(void *data, int size, Protocol__F1uMessage **msg) {
*msg = protocol__f1u_message__unpack(NULL, size, data);
if (*msg == NULL)
goto error;
return 0;
error:
LOG_E(F1U, "%s: an error occured\n", __FUNCTION__);
return -1;
}
int f1u_dl_data_create_header(uint32_t pdu_type, uint32_t f1u_sn, Protocol__DlDataHeader **header) {
*header = malloc(sizeof(Protocol__DlDataHeader));
if(*header == NULL)
goto error;
protocol__dl_data_header__init(*header);
LOG_D(F1U, "Initialized the DL Data User header\n");
fill_dl_data_header(pdu_type, 0, f1u_sn, &(*header)->fields);
return 0;
error:
LOG_E(F1U, "%s: an error occured\n", __FUNCTION__);
return -1;
}
int f1u_dl_data(const void *params, Protocol__F1uMessage **msg) {
// Initialize the PDCP params
dl_data_args *args = (dl_data_args *)params;
Protocol__DlDataHeader *header;
if (f1u_dl_data_create_header(args->pdu_type, args->sn, &header) != 0)
goto error;
Protocol__DlUserData *dl_data = NULL;
*msg = malloc(sizeof(Protocol__DlUserData));
if(*msg == NULL)
goto error;
// FIXME: Is the following used? It seems to be overwritten by the function
// protocol__dl_user_data__init() anyway
//dl_data = *msg;
protocol__dl_user_data__init(dl_data);
// Copy data to the bytes structure
dl_data->pdu.data = malloc(args->sdu_size);
dl_data->pdu.len = args->sdu_size;
memcpy(dl_data->pdu.data, args->sdu_p, args->sdu_size);
dl_data->frame = args->frame;
dl_data->subframe = args->subframe;
dl_data->rnti = args->rnti;
dl_data->header = header;
return 0;
error:
if(header != NULL)
free(header);
if(*msg != NULL)
free(*msg);
LOG_E(F1U, "%s: an error occured\n", __FUNCTION__);
return -1;
}
int proto_agent_serialize_message(Protocol__FlexsplitMessage *msg, uint8_t **buf, int *size) {
*size = protocol__flexsplit_message__get_packed_size(msg);
*buf = malloc(*size);
if (!(*buf))
goto error;
protocol__flexsplit_message__pack(msg, *buf);
return 0;
error:
LOG_E(MAC, "an error occured\n");
return -1;
}
/* We assume that the buffer size is equal to the message size.
Should be chekced durint Tx/Rx */
int proto_agent_deserialize_message(void *data, int size, Protocol__FlexsplitMessage **msg) {
*msg = protocol__flexsplit_message__unpack(NULL, size, data);
if (*msg == NULL)
goto error;
return 0;
error:
LOG_E(MAC, "%s: an error occured\n", __FUNCTION__);
return -1;
}
int fsp_create_header(xid_t xid, Protocol__FspType type, Protocol__FspHeader **header) {
*header = malloc(sizeof(Protocol__FspHeader));
if(*header == NULL)
goto error;
protocol__fsp_header__init(*header);
LOG_D(PROTO_AGENT, "Initialized the PROTOBUF message header\n");
(*header)->version = FLEXSPLIT_VERSION;
LOG_D(PROTO_AGENT, "Set the vversion to FLEXSPLIT_VERSION\n");
(*header)->has_version = 1;
(*header)->type = type;
(*header)->has_type = 1;
(*header)->xid = xid;
(*header)->has_xid = 1;
return 0;
error:
LOG_E(MAC, "%s: an error occured\n", __FUNCTION__);
return -1;
}
int just_print(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg) {
return 1;
}
int proto_agent_pdcp_data_req(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg) {
Protocol__FspCtxt *ctxt = NULL;
Protocol__FspRlcPdu *pdu = NULL;
Protocol__FspRlcData *rlc_data = NULL;
Protocol__FspRlcDataReq *data_req = NULL;
// Initialize the PDCP params
data_req_args *args = (data_req_args *)params;
// Create the protobuf header
Protocol__FspHeader *header;
xid_t xid = mod_id;
LOG_D(PROTO_AGENT, "creating the data_req message\n");
if (fsp_create_header(xid, PROTOCOL__FSP_TYPE__FSPT_RLC_DATA_REQ, &header) != 0)
goto error;
/* Begin constructing the messages. They are defined as follows:
* 1) fspRlcPdu is storing the bytes of the packet
* 2) Message fspRlcData is packing the packet + the context of the PDCP (separate message)
* 3) Messge fspRlcDataReq is packing the header, enb_id and fspRlcData
*/
ctxt = malloc(sizeof(Protocol__FspCtxt));
pdu = malloc(sizeof(Protocol__FspRlcPdu));
rlc_data = malloc(sizeof(Protocol__FspRlcData));
data_req = malloc(sizeof(Protocol__FspRlcDataReq));
protocol__fsp_ctxt__init(ctxt);
protocol__fsp_rlc_pdu__init(pdu);
protocol__fsp_rlc_data__init(rlc_data);
protocol__fsp_rlc_data_req__init(data_req);
// Copy data to the RlcPdu structure
pdu->fsp_pdu_data.data = malloc(args->sdu_size);
pdu->fsp_pdu_data.len = args->sdu_size;
memcpy(pdu->fsp_pdu_data.data, args->sdu_p->data, args->sdu_size);
pdu->has_fsp_pdu_data = 1;
// Copy data to the ctxt structure
ctxt->fsp_mod_id = args->ctxt->module_id;
ctxt->fsp_enb_flag = args->ctxt->enb_flag;
ctxt->fsp_instance = args->ctxt->instance;
ctxt->fsp_rnti = args->ctxt->rnti;
ctxt->fsp_frame = args->ctxt->frame;
ctxt->fsp_subframe = args->ctxt->subframe;
ctxt->fsp_enb_index = args->ctxt->eNB_index;
ctxt->has_fsp_mod_id = 1;
ctxt->has_fsp_enb_flag = 1;
ctxt->has_fsp_instance = 1;
ctxt->has_fsp_rnti = 1;
ctxt->has_fsp_frame = 1;
ctxt->has_fsp_subframe = 1;
ctxt->has_fsp_enb_index = 1;
rlc_data->fsp_ctxt = ctxt;
rlc_data->fsp_srb_flag = args->srb_flag;
rlc_data->fsp_mbms_flag = args->MBMS_flag;
rlc_data->fsp_rb_id = args->rb_id;
rlc_data->fsp_muip = args->mui;
rlc_data->fsp_confirm = args->confirm;
rlc_data->fsp_sdu_buffer_size = args->sdu_size;
rlc_data->fsp_pdu = pdu;
rlc_data->has_fsp_srb_flag = 1;
rlc_data->has_fsp_mbms_flag = 1;
rlc_data->has_fsp_rb_id = 1;
rlc_data->has_fsp_muip = 1;
rlc_data->has_fsp_confirm = 1;
rlc_data->has_fsp_sdu_buffer_size = 1;
// Up to here, everything is a signle message that is packed inside another. The final data_req
// will be created later, after the setting of all variables
data_req->header = header;
data_req->enb_id = mod_id;
data_req->has_enb_id = 1;
data_req->pdcp_data = rlc_data;
*msg = malloc(sizeof(Protocol__FlexsplitMessage));
if(*msg == NULL)
goto error;
protocol__flexsplit_message__init(*msg);
(*msg)->msg_case = PROTOCOL__FLEXSPLIT_MESSAGE__MSG_DATA_REQ_MSG;
(*msg)->msg_dir = PROTOCOL__FLEXSPLIT_DIRECTION__INITIATING_MESSAGE; //we will be waiting for the ACK
(*msg)->has_msg_dir = 1;
(*msg)->data_req_msg = data_req;
return 0;
error:
if(header != NULL)
free(header);
if(pdu!=NULL)
free(pdu);
if(rlc_data!=NULL)
free(rlc_data);
if(data_req!= NULL)
free(data_req);
if(*msg != NULL)
free(*msg);
LOG_E(MAC, "%s: an error occured\n", __FUNCTION__);
return -1;
}
int proto_agent_destroy_pdcp_data_req(Protocol__FlexsplitMessage *msg) {
if(msg->msg_case != PROTOCOL__FLEXSPLIT_MESSAGE__MSG_DATA_REQ_MSG)
goto error;
free(msg->data_req_msg->header);
free(msg->data_req_msg->pdcp_data->fsp_pdu->fsp_pdu_data.data);
free(msg->data_req_msg->pdcp_data->fsp_pdu);
free(msg->data_req_msg->pdcp_data->fsp_ctxt);
free(msg->data_req_msg->pdcp_data);
free(msg->data_req_msg);
free(msg);
return 0;
error:
LOG_E(MAC, "%s: an error occured\n", __FUNCTION__);
return -1;
}
int proto_agent_get_ack_result(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg) {
/* code useless in this status: return 0 anyways
rlc_op_status_t result = 0;
printf("PROTO_AGENT: handling the data_req_ack message\n");
Protocol__FlexsplitMessage *input = (Protocol__FlexsplitMessage *)params;
Protocol__FspRlcDataReqAck *data_ack = input->data_req_ack;
result = data_ack->result;
printf("PROTO_AGENT: ACK RESULT IS %u\n", result);
ack_result = result;
*/
return 0;
}
int proto_agent_pdcp_data_req_process(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg) {
rlc_op_status_t result = 0;
Protocol__FlexsplitMessage *input = (Protocol__FlexsplitMessage *)params;
Protocol__FspRlcDataReq *data_req = input->data_req_msg;
Protocol__FspCtxt *ctxt = NULL;
Protocol__FspRlcData *rlc_data = NULL;
rlc_data = data_req->pdcp_data;
ctxt = rlc_data->fsp_ctxt;
protocol_ctxt_t ctxt_pP;
srb_flag_t srb_flagP = 0;
rb_id_t rb_idP = 0;
mui_t muiP = 0;
confirm_t confirmP = 0;
MBMS_flag_t flag_MBMS = 0;
sdu_size_t pdcp_pdu_size = 0;
mem_block_t *pdcp_pdu_p = NULL;
// Create a new protocol context for handling the packet
ctxt_pP.module_id = ctxt->fsp_mod_id;
ctxt_pP.enb_flag = ctxt->fsp_enb_flag;
ctxt_pP.instance = ctxt->fsp_instance;
ctxt_pP.rnti = ctxt->fsp_rnti;
ctxt_pP.frame = ctxt->fsp_frame;
ctxt_pP.subframe = ctxt->fsp_subframe;
ctxt_pP.eNB_index = ctxt->fsp_enb_index;
srb_flagP = rlc_data->fsp_srb_flag;
flag_MBMS = rlc_data->fsp_mbms_flag;
rb_idP = rlc_data->fsp_rb_id;
muiP = rlc_data->fsp_muip;
confirmP = rlc_data->fsp_confirm;
pdcp_pdu_size = rlc_data->fsp_pdu->fsp_pdu_data.len;
pdcp_pdu_p = get_free_mem_block(pdcp_pdu_size, __func__);
if (!pdcp_pdu_p) {
LOG_E(PROTO_AGENT, "%s: an error occured\n", __FUNCTION__);
return -1;
}
memcpy(pdcp_pdu_p->data, rlc_data->fsp_pdu->fsp_pdu_data.data, pdcp_pdu_size);
if (RC.nrrrc) {
LOG_D(PROTO_AGENT, "proto_agent received pdcp_data_req \n");
// for (int i = 0; i < pdcp_pdu_size; i++)
// printf(" %2.2x", (unsigned char)pdcp_pdu_p->data[i]);
// printf("\n");
du_rlc_data_req(&ctxt_pP, srb_flagP, flag_MBMS, rb_idP, muiP, confirmP, pdcp_pdu_size, pdcp_pdu_p);
result = 1;
} else {
result = rlc_data_req(&ctxt_pP, srb_flagP, flag_MBMS, rb_idP, muiP, confirmP, pdcp_pdu_size, pdcp_pdu_p, NULL, NULL);
}
return result;
}
int proto_agent_destroy_pdcp_data_ind(Protocol__FlexsplitMessage *msg) {
if(msg->msg_case != PROTOCOL__FLEXSPLIT_MESSAGE__MSG_DATA_IND_MSG)
goto error;
free(msg->data_ind_msg->header);
free(msg->data_ind_msg->rlc_data->fsp_pdu->fsp_pdu_data.data);
free(msg->data_ind_msg->rlc_data->fsp_pdu);
free(msg->data_ind_msg->rlc_data->fsp_ctxt);
free(msg->data_ind_msg->rlc_data);
free(msg->data_ind_msg);
free(msg);
return 0;
error:
LOG_E(MAC, "%s: an error occured\n", __FUNCTION__);
return -1;
}
int proto_agent_pdcp_data_ind(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg) {
Protocol__FspCtxt *ctxt = NULL;
Protocol__FspRlcPdu *pdu = NULL;
Protocol__FspRlcData *rlc_data = NULL;
Protocol__FspPdcpDataInd *data_ind = NULL;
// Initialize the PDCP params
data_req_args *args = (data_req_args *)params;
// Create the protobuf header
Protocol__FspHeader *header;
xid_t xid = mod_id;
LOG_D(PROTO_AGENT, "creating the data_ind message\n");
if (fsp_create_header(xid, PROTOCOL__FSP_TYPE__FSPT_PDCP_DATA_IND, &header) != 0)
goto error;
/* Begin constructing the messages. They are defined as follows:
* 1) fspRlcPdu is storing the bytes of the packet
* 2) Message fspRlcData is packing the packet + the context of the PDCP (separate message)
* 3) Messge fspRlcDataReq is packing the header, enb_id and fspRlcData
*/
ctxt = malloc(sizeof(Protocol__FspCtxt));
pdu = malloc(sizeof(Protocol__FspRlcPdu));
rlc_data = malloc(sizeof(Protocol__FspRlcData));
data_ind = malloc(sizeof(Protocol__FspPdcpDataInd));
protocol__fsp_ctxt__init(ctxt);
protocol__fsp_rlc_pdu__init(pdu);
protocol__fsp_rlc_data__init(rlc_data);
protocol__fsp_pdcp_data_ind__init(data_ind);
// Copy data to the RlcPdu structure
pdu->fsp_pdu_data.data = malloc(args->sdu_size);
pdu->fsp_pdu_data.len = args->sdu_size;
memcpy(pdu->fsp_pdu_data.data, args->sdu_p->data, args->sdu_size);
pdu->has_fsp_pdu_data = 1;
// Copy data to the ctxt structure
ctxt->fsp_mod_id = args->ctxt->module_id;
ctxt->fsp_enb_flag = args->ctxt->enb_flag;
ctxt->fsp_instance = args->ctxt->instance;
ctxt->fsp_rnti = args->ctxt->rnti;
ctxt->fsp_frame = args->ctxt->frame;
ctxt->fsp_subframe = args->ctxt->subframe;
ctxt->fsp_enb_index = args->ctxt->eNB_index;
ctxt->has_fsp_mod_id = 1;
ctxt->has_fsp_enb_flag = 1;
ctxt->has_fsp_instance = 1;
ctxt->has_fsp_rnti = 1;
ctxt->has_fsp_frame = 1;
ctxt->has_fsp_subframe = 1;
ctxt->has_fsp_enb_index = 1;
rlc_data->fsp_ctxt = ctxt;
rlc_data->fsp_srb_flag = args->srb_flag;
rlc_data->fsp_mbms_flag = args->MBMS_flag;
rlc_data->fsp_rb_id = args->rb_id;
rlc_data->fsp_sdu_buffer_size = args->sdu_size;
rlc_data->fsp_pdu = pdu;
rlc_data->has_fsp_srb_flag = 1;
rlc_data->has_fsp_mbms_flag = 1;
rlc_data->has_fsp_rb_id = 1;
rlc_data->has_fsp_sdu_buffer_size = 1;
// Up to here, everything is a signle message that is packed inside another. The final data_req
// will be created later, after the setting of all variables
data_ind->header = header;
data_ind->enb_id = mod_id;
data_ind->has_enb_id = 1;
data_ind->rlc_data = rlc_data;
*msg = malloc(sizeof(Protocol__FlexsplitMessage));
if(*msg == NULL)
goto error;
protocol__flexsplit_message__init(*msg);
LOG_D(PROTO_AGENT,"setting the message case to %d\n", PROTOCOL__FLEXSPLIT_MESSAGE__MSG_DATA_IND_MSG);
(*msg)->msg_case = PROTOCOL__FLEXSPLIT_MESSAGE__MSG_DATA_IND_MSG;
(*msg)->msg_dir = PROTOCOL__FLEXSPLIT_DIRECTION__INITIATING_MESSAGE; //we will be waiting for the ACK
(*msg)->has_msg_dir = 1;
(*msg)->data_ind_msg = data_ind; //data_req;
return 0;
error:
if(header != NULL)
free(header);
if(pdu!=NULL)
free(pdu);
if(rlc_data!=NULL)
free(rlc_data);
if(data_ind!= NULL)
free(data_ind);
if(*msg != NULL)
free(*msg);
LOG_E(MAC, "%s: an error occured\n", __FUNCTION__);
return -1;
}
int proto_agent_pdcp_data_ind_process(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg) {
boolean_t result = 0;
Protocol__FlexsplitMessage *input = (Protocol__FlexsplitMessage *)params;
Protocol__FspPdcpDataInd *data_ind = input->data_ind_msg;
Protocol__FspCtxt *ctxt = NULL;
Protocol__FspRlcData *rlc_data = NULL;
rlc_data = data_ind->rlc_data;
ctxt = rlc_data->fsp_ctxt;
protocol_ctxt_t ctxt_pP;
srb_flag_t srb_flagP = 0;
rb_id_t rb_idP = 0;
sdu_size_t pdcp_pdu_size = 0;
MBMS_flag_t flag_MBMS = 0;
mem_block_t *pdcp_pdu_p = NULL;
// Create a new protocol context for handling the packet
ctxt_pP.module_id = ctxt->fsp_mod_id;
ctxt_pP.enb_flag = ctxt->fsp_enb_flag;
ctxt_pP.instance = ctxt->fsp_instance;
ctxt_pP.rnti = ctxt->fsp_rnti;
ctxt_pP.frame = ctxt->fsp_frame;
ctxt_pP.subframe = ctxt->fsp_subframe;
ctxt_pP.brOption = 0;
ctxt_pP.eNB_index = ctxt->fsp_enb_index;
srb_flagP = rlc_data->fsp_srb_flag;
flag_MBMS = rlc_data->fsp_mbms_flag;
rb_idP = rlc_data->fsp_rb_id;
pdcp_pdu_size = rlc_data->fsp_pdu->fsp_pdu_data.len;
pdcp_pdu_p = get_free_mem_block(pdcp_pdu_size, __func__);
if (!pdcp_pdu_p) goto error;
memcpy(pdcp_pdu_p->data, rlc_data->fsp_pdu->fsp_pdu_data.data, pdcp_pdu_size);
// if (xid == 1)
// pdcp_data_ind_wifi((const protocol_ctxt_t*) ctxt_pP, (const srb_flag_t) srb_flagP, (const MBMS_flag_t) flag_MBMS, (const rb_id_t) rb_idP, pdcp_pdu_size, pdcp_pdu_p);
// else if (xid == 0) // FIXME: USE a preprocessed definition
LOG_D(PROTO_AGENT, "[inst %ld] Received PDCP PDU with size %d for UE RNTI %x RB %ld, Calling pdcp_data_ind\n", ctxt_pP.instance, pdcp_pdu_size,ctxt_pP.rnti,rb_idP);
result = pdcp_data_ind(&ctxt_pP,
srb_flagP,
flag_MBMS,
rb_idP,
pdcp_pdu_size,
pdcp_pdu_p, NULL, NULL);
return result;
error:
if (pdcp_pdu_p)
free_mem_block(pdcp_pdu_p, __func__);
LOG_E(MAC, "%s: an error occured\n", __FUNCTION__);
return -1;
}
int proto_agent_hello(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg) {
Protocol__FspHeader *header;
Protocol__FspHello *hello_msg = NULL;
/*TODO: Need to set random xid or xid from received hello message*/
xid_t xid = mod_id;
if (fsp_create_header(xid, PROTOCOL__FSP_TYPE__FSPT_HELLO, &header) != 0)
goto error;
LOG_D(PROTO_AGENT, "creating the HELLO message\n");
hello_msg = malloc(sizeof(Protocol__FspHello));
if(hello_msg == NULL)
goto error;
protocol__fsp_hello__init(hello_msg);
hello_msg->header = header;
*msg = malloc(sizeof(Protocol__FlexsplitMessage));
if(*msg == NULL)
goto error;
protocol__flexsplit_message__init(*msg);
(*msg)->msg_case = PROTOCOL__FLEXSPLIT_MESSAGE__MSG_HELLO_MSG;
(*msg)->msg_dir = PROTOCOL__FLEXSPLIT_DIRECTION__SUCCESSFUL_OUTCOME;
(*msg)->has_msg_dir = 1;
(*msg)->hello_msg = hello_msg;
return 0;
error:
if(header != NULL)
free(header);
if(hello_msg!=NULL)
free(hello_msg);
if(*msg != NULL)
free(*msg);
LOG_E(MAC, "%s: an error occured\n", __FUNCTION__);
return -1;
}
int proto_agent_destroy_hello(Protocol__FlexsplitMessage *msg) {
if(msg->msg_case != PROTOCOL__FLEXSPLIT_MESSAGE__MSG_HELLO_MSG)
goto error;
free(msg->hello_msg->header);
free(msg->hello_msg);
free(msg);
return 0;
error:
LOG_E(MAC, "%s: an error occured\n", __FUNCTION__);
return -1;
}
int proto_agent_echo_request(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg) {
Protocol__FspHeader *header;
Protocol__FspEchoRequest *echo_request_msg = NULL;
xid_t xid = mod_id;
if (fsp_create_header(xid, PROTOCOL__FSP_TYPE__FSPT_ECHO_REQUEST, &header) != 0)
goto error;
LOG_D(PROTO_AGENT, "creating the echo request message\n");
echo_request_msg = malloc(sizeof(Protocol__FspEchoRequest));
if(echo_request_msg == NULL)
goto error;
protocol__fsp_echo_request__init(echo_request_msg);
echo_request_msg->header = header;
*msg = malloc(sizeof(Protocol__FlexsplitMessage));
if(*msg == NULL)
goto error;
protocol__flexsplit_message__init(*msg);
LOG_D(PROTO_AGENT,"setting the message direction to %d\n", PROTOCOL__FLEXSPLIT_MESSAGE__MSG_ECHO_REQUEST_MSG);
(*msg)->msg_case = PROTOCOL__FLEXSPLIT_MESSAGE__MSG_ECHO_REQUEST_MSG;
(*msg)->msg_dir = PROTOCOL__FLEXSPLIT_DIRECTION__INITIATING_MESSAGE;
(*msg)->has_msg_dir = 1;
(*msg)->echo_request_msg = echo_request_msg;
return 0;
error:
if(header != NULL)
free(header);
if(echo_request_msg != NULL)
free(echo_request_msg);
if(*msg != NULL)
free(*msg);
return -1;
}
int proto_agent_destroy_echo_request(Protocol__FlexsplitMessage *msg) {
if(msg->msg_case != PROTOCOL__FLEXSPLIT_MESSAGE__MSG_ECHO_REQUEST_MSG)
goto error;
free(msg->echo_request_msg->header);
free(msg->echo_request_msg);
free(msg);
return 0;
error:
LOG_E(MAC, "%s: an error occured\n", __FUNCTION__);
return -1;
}
int proto_agent_echo_reply(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg) {
xid_t xid;
Protocol__FlexsplitMessage *input = (Protocol__FlexsplitMessage *)params;
Protocol__FspEchoRequest *echo_req = input->echo_request_msg;
Protocol__FspEchoReply *echo_reply_msg = NULL;
xid = (echo_req->header)->xid;
LOG_D(PROTO_AGENT, "creating the echo reply message\n");
Protocol__FspHeader *header;
if (fsp_create_header(xid, PROTOCOL__FSP_TYPE__FSPT_ECHO_REPLY, &header) != 0)
goto error;
echo_reply_msg = malloc(sizeof(Protocol__FspEchoReply));
if(echo_reply_msg == NULL)
goto error;
protocol__fsp_echo_reply__init(echo_reply_msg);
echo_reply_msg->header = header;
*msg = malloc(sizeof(Protocol__FlexsplitMessage));
if(*msg == NULL)
goto error;
protocol__flexsplit_message__init(*msg);
(*msg)->msg_case = PROTOCOL__FLEXSPLIT_MESSAGE__MSG_ECHO_REPLY_MSG;
(*msg)->msg_dir = PROTOCOL__FLEXSPLIT_DIRECTION__SUCCESSFUL_OUTCOME;
(*msg)->has_msg_dir = 1;
(*msg)->echo_reply_msg = echo_reply_msg;
return 0;
error:
if(header != NULL)
free(header);
if(echo_reply_msg != NULL)
free(echo_reply_msg);
if(*msg != NULL)
free(*msg);
LOG_E(MAC, "%s: an error occured\n", __FUNCTION__);
return -1;
}
int proto_agent_destroy_echo_reply(Protocol__FlexsplitMessage *msg) {
if(msg->msg_case != PROTOCOL__FLEXSPLIT_MESSAGE__MSG_ECHO_REPLY_MSG)
goto error;
free(msg->echo_reply_msg->header);
free(msg->echo_reply_msg);
free(msg);
return 0;
error:
LOG_E(MAC, "%s: an error occured\n", __FUNCTION__);
return -1;
}
@@ -1,138 +0,0 @@
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file enb_agent_common.h
* \brief common message primitves and utilities
* \author Navid Nikaein and Xenofon Foukas
* \date 2016
* \version 0.1
*/
#ifndef PROTO_AGENT_COMMON_H_
#define PROTO_AGENT_COMMON_H_
#include <time.h>
#include "flexsplit.pb-c.h"
// Do not need these
//#include "stats_messages.pb-c.h"
//#include "stats_common.pb-c.h"
#include "proto_agent_defs.h"
//#include "ENB_APP/enb_config.h"
#include "UTIL/MEM/mem_block.h"
//#include "LAYER2/MAC/extern.h"
//#include "LAYER2/RLC/rlc.h"
# include "tree.h"
# include "intertask_interface.h"
#define FLEXSPLIT_VERSION 0
typedef int (*proto_agent_message_decoded_callback)(
mod_id_t mod_id,
const void *params,
Protocol__FlexsplitMessage **msg
);
typedef int (*proto_agent_message_destruction_callback)(
Protocol__FlexsplitMessage *msg
);
/**********************************
* progRAN protocol messages helper
* functions and generic handlers
**********************************/
int proto_agent_serialize_message(Protocol__FlexsplitMessage *msg, uint8_t **buf, int *size);
int proto_agent_deserialize_message(void *data, int size, Protocol__FlexsplitMessage **msg);
uint8_t *proto_agent_pack_message(Protocol__FlexsplitMessage *msg, int *size);
err_code_t proto_agent_destroy_flexsplit_message(Protocol__FlexsplitMessage *msg);
int fsp_create_header(xid_t xid, Protocol__FspType type, Protocol__FspHeader **header);
int proto_agent_hello(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg);
int proto_agent_destroy_hello(Protocol__FlexsplitMessage *msg);
int proto_agent_echo_request(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg);
int proto_agent_destroy_echo_request(Protocol__FlexsplitMessage *msg);
int proto_agent_echo_reply(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg);
int proto_agent_destroy_echo_reply(Protocol__FlexsplitMessage *msg);
int proto_agent_pdcp_data_req(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg);
int proto_agent_pdcp_data_req_process(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg);
int proto_agent_destroy_pdcp_data_req(Protocol__FlexsplitMessage *msg);
int proto_agent_pdcp_data_ind(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg);
int proto_agent_destroy_pdcp_data_ind(Protocol__FlexsplitMessage *msg);
int proto_agent_pdcp_data_ind_process(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg);
int just_print(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg);
int proto_agent_get_ack_result(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg);
Protocol__FlexsplitMessage* proto_agent_handle_message (mod_id_t mod_id,
uint8_t *data,
int size);
Protocol__FlexsplitMessage *proto_agent_handle_timed_task(void *args);
typedef struct _data_req_args data_req_args;
typedef struct _dl_data_args dl_data_args;
struct _data_req_args{
const protocol_ctxt_t* ctxt;
srb_flag_t srb_flag;
MBMS_flag_t MBMS_flag;
rb_id_t rb_id;
mui_t mui;
confirm_t confirm;
sdu_size_t sdu_size;
mem_block_t *sdu_p;
};
struct _dl_data_args{
uint8_t pdu_type;
uint32_t sn;
frame_t frame;
sub_frame_t subframe;
rnti_t rnti;
sdu_size_t sdu_size;
mem_block_t *sdu_p;
};
#endif
@@ -1,118 +0,0 @@
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file enb_agent_defs.h
* \brief enb agent common definitions
* \author Navid Nikaein and Xenofon Foukas
* \date 2016
* \version 0.1
*/
#ifndef PROTO_AGENT_DEFS_H_
#define PROTO_AGENT_DEFS_H_
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <string.h>
#include "openairinterface5g_limits.h"
#include "UTIL/ASYNC_IF/link_manager.h"
#define DEFAULT_PROTO_AGENT_IPv4_ADDRESS "127.0.0.1"
#define DEFAULT_PROTO_AGENT_PORT 2210
#define DEFAULT_PROTO_AGENT_CACHE "/mnt/oai_agent_cache"
typedef enum {
PROTO_AGENT_DEFAULT=0,
ENB_AGENT_PHY=1,
ENB_AGENT_MAC=2,
ENB_AGENT_RLC=3,
ENB_AGENT_PDCP=4,
ENB_AGENT_RRC=5,
ENB_AGENT_S1AP=6,
ENB_AGENT_GTP=7,
ENB_AGENT_X2AP=8,
ENB_AGENT_MAX=9,
} proto_agent_id_t;
/*
typedef enum {
ENB_AGENT_ACTION_NONE = 0x0,
ENB_AGENT_ACTION_SEND = 0x1,
ENB_AGENT_ACTION_APPLY = 0x2,
ENB_AGENT_ACTION_CLEAR = 0x4,
ENB_AGENT_ACTION_WRITE = 0x8,
ENB_AGENT_ACTION_FILTER = 0x10,
ENB_AGENT_ACTION_PREPROCESS = 0x20,
ENB_AGENT_ACTION_METER = 0x40,
ENB_AGENT_ACTION_MAX = 0x7f,
} agent_action_t;
*/
/*
typedef enum {
RAN_LTE_OAI= 0,
RAN_NAME_MAX = 0x7f,
} ran_name_t;
*/
typedef uint8_t xid_t;
typedef uint8_t mod_id_t; // module or enb id
typedef uint8_t lcid_t;
typedef int32_t err_code_t;
typedef struct {
/* general info */
/* stats */
uint32_t total_rx_msg;
uint32_t total_tx_msg;
uint32_t rx_msg[NUMBER_OF_eNB_MAX];
uint32_t tx_msg[NUMBER_OF_eNB_MAX];
} proto_agent_info_t;
/* forward declaration */
struct proto_agent_channel_s;
typedef struct proto_agent_instance_s {
mod_id_t mod_id;
proto_agent_info_t agent_info;
struct proto_agent_channel_s *channel;
pthread_t recv_thread;
uint8_t exit;
} proto_agent_instance_t;
#endif
@@ -1,138 +0,0 @@
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file enb_agent_handler.c
* \brief enb agent tx and rx message handler
* \author Navid Nikaein and Xenofon Foukas
* \date 2016
* \version 0.1
*/
#include "proto_agent_common.h"
#include "common/utils/LOG/log.h"
#include "assertions.h"
proto_agent_message_decoded_callback proto_agent_messages_callback[][3] = {
{proto_agent_hello, 0, 0}, /* agent hello */
{proto_agent_echo_reply, 0, 0}, /* echo */
{0, just_print, 0}, /* just print */
{proto_agent_pdcp_data_req_process, proto_agent_pdcp_data_req_process, 0}, /* PDCP data REQ */
{0, proto_agent_get_ack_result, 0}, /* get ACK result */
{proto_agent_pdcp_data_ind_process, proto_agent_pdcp_data_ind_process, 0}, /* PDCP data IND */
{0, just_print, 0}, /* just print */
};
proto_agent_message_destruction_callback proto_message_destruction_callback[] = {
proto_agent_destroy_hello,
proto_agent_destroy_echo_request,
proto_agent_destroy_echo_reply,
proto_agent_destroy_pdcp_data_req,
0,
proto_agent_destroy_pdcp_data_ind,
0,
};
//static const char *proto_agent_direction2String[] = {
// "", /* not_set */
// "originating message", /* originating message */
// "successfull outcome", /* successfull outcome */
// "unsuccessfull outcome", /* unsuccessfull outcome */
//};
Protocol__FlexsplitMessage* proto_agent_handle_message (mod_id_t mod_id,
uint8_t *data,
int size){
Protocol__FlexsplitMessage *decoded_message = NULL;
Protocol__FlexsplitMessage *reply_message = NULL;
err_code_t err_code;
DevAssert(data != NULL);
LOG_D(PROTO_AGENT, "Deserializing message with size %u \n", size);
if (proto_agent_deserialize_message(data, (int) size, &decoded_message) < 0) {
err_code= PROTOCOL__FLEXSPLIT_ERR__MSG_DECODING;
goto error;
}
/* after deserialization, we don't need the original data memory anymore */
free(data);
Protocol__FspHeader *header = (Protocol__FspHeader*) decoded_message;
if (header->has_type)
{
LOG_D(PROTO_AGENT, "Deserialized MSG type is %d and %u\n", decoded_message->msg_case, decoded_message->msg_dir);
}
if ((decoded_message->msg_case > sizeof(proto_agent_messages_callback) / (3*sizeof(proto_agent_message_decoded_callback))) ||
(decoded_message->msg_dir > PROTOCOL__FLEXSPLIT_DIRECTION__UNSUCCESSFUL_OUTCOME))
{
err_code= PROTOCOL__FLEXSPLIT_ERR__MSG_NOT_HANDLED;
LOG_D(PROTO_AGENT,"Handling message: MSG NOT handled, going to error\n");
goto error;
}
err_code = ((*proto_agent_messages_callback[decoded_message->msg_case-1][decoded_message->msg_dir-1])(mod_id, (void *) decoded_message, &reply_message));
if ( err_code < 0 )
{
LOG_I(PROTO_AGENT, "decoded_message case : %d, direction : %d \n", decoded_message->msg_case-1, decoded_message->msg_dir-1);
goto error;
}
protocol__flexsplit_message__free_unpacked(decoded_message, NULL);
LOG_D(PROTO_AGENT,"Returning REPLY message after the callback\n");
return reply_message;
error:
LOG_E(PROTO_AGENT,"errno %d occured\n",err_code);
return NULL;
}
uint8_t *proto_agent_pack_message(Protocol__FlexsplitMessage *msg, int *size)
{
uint8_t *buffer;
err_code_t err_code = PROTOCOL__FLEXSPLIT_ERR__NO_ERR;
if (proto_agent_serialize_message(msg, &buffer, size) < 0 ) {
err_code = PROTOCOL__FLEXSPLIT_ERR__MSG_ENCODING;
goto error;
}
if (proto_message_destruction_callback[msg->msg_case-1])
err_code = ((*proto_message_destruction_callback[msg->msg_case-1])(msg));
DevAssert(buffer !=NULL);
LOG_D(PROTO_AGENT,"Serialized the enb mac stats reply (size %d)\n", *size);
return buffer;
error :
LOG_E(PROTO_AGENT,"errno %d occured\n",err_code);
return NULL;
}
err_code_t proto_agent_destroy_flexsplit_message(Protocol__FlexsplitMessage *msg) {
return ((*proto_message_destruction_callback[msg->msg_case-1])(msg));
}
@@ -1,152 +0,0 @@
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file enb_agent_net_comm.c
* \brief enb agent network interface abstraction
* \author Xenofon Foukas
* \date 2016
* \version 0.1
*/
#include "proto_agent_net_comm.h"
#include "common/utils/LOG/log.h"
proto_agent_channel_t *proto_channel[NUMBER_OF_eNB_MAX][ENB_AGENT_MAX];
static proto_agent_channel_instance_t channel_instance;
int proto_agent_channel_id = 0;
int proto_agent_register_channel(mod_id_t mod_id, proto_agent_channel_t *channel, proto_agent_id_t agent_id) {
int i;
if (channel == NULL) {
return -1;
}
if (agent_id == ENB_AGENT_MAX) {
for (i = 0; i < ENB_AGENT_MAX; i++) {
proto_channel[mod_id][i] = channel;
}
} else {
proto_channel[mod_id][agent_id] = channel;
}
return 0;
}
void proto_agent_unregister_channel(mod_id_t mod_id, proto_agent_id_t agent_id) {
int i;
if (agent_id == ENB_AGENT_MAX) {
for (i = 0; i < ENB_AGENT_MAX; i++) {
proto_channel[mod_id][i] = NULL;
}
} else {
proto_channel[mod_id][agent_id] = NULL;
}
}
int proto_agent_create_channel(void *channel_info,
int (*msg_send)(void *data, int size, int priority, void *channel_info),
int (*msg_recv)(void **data, int *priority, void *channel_info),
void (*release)(proto_agent_channel_t *channel)) {
int channel_id = ++proto_agent_channel_id;
proto_agent_channel_t *channel = (proto_agent_channel_t *) malloc(sizeof(proto_agent_channel_t));
channel->channel_id = channel_id;
channel->channel_info = channel_info;
channel->msg_send = msg_send;
channel->msg_recv = msg_recv;
channel->release = release;
/*element should be a real pointer*/
RB_INSERT(proto_agent_channel_map, &channel_instance.proto_agent_head, channel);
LOG_D(PROTO_AGENT, "Created a new channel with id 0x%x\n", channel->channel_id);
return channel_id;
}
int proto_agent_destroy_channel(int channel_id) {
int i, j;
/*Check to see if channel exists*/
struct proto_agent_channel_s *e = NULL;
struct proto_agent_channel_s search;
memset(&search, 0, sizeof(struct proto_agent_channel_s));
e = RB_FIND(proto_agent_channel_map, &channel_instance.proto_agent_head, &search);
if (e == NULL) {
return -1;
}
/*Unregister the channel from all agents*/
for (i = 0; i < NUMBER_OF_eNB_MAX; i++) {
for (j = 0; j < ENB_AGENT_MAX; j++) {
if (proto_channel[i][j] != NULL) {
if (proto_channel[i][j]->channel_id == e->channel_id) {
proto_channel[i][j] = NULL;
}
}
}
}
/*Remove the channel from the tree and free memory*/
RB_REMOVE(proto_agent_channel_map, &channel_instance.proto_agent_head, e);
e->release(e);
free(e);
return 0;
}
err_code_t proto_agent_init_channel_container(void) {
int i, j;
LOG_D(PROTO_AGENT, "init RB tree for channel container\n");
RB_INIT(&channel_instance.proto_agent_head);
for (i = 0; i < NUMBER_OF_eNB_MAX; i++) {
for (j = 0; j < ENB_AGENT_MAX; j++) {
proto_channel[i][j] = NULL;
}
}
return 0;
}
RB_GENERATE(proto_agent_channel_map,proto_agent_channel_s, entry, proto_agent_compare_channel);
int proto_agent_compare_channel(struct proto_agent_channel_s *a, struct proto_agent_channel_s *b) {
if (a->channel_id < b->channel_id) return -1;
if (a->channel_id > b->channel_id) return 1;
// equal timers
return 0;
}
proto_agent_channel_t * proto_agent_get_channel(int channel_id) {
struct proto_agent_channel_s search;
memset(&search, 0, sizeof(struct proto_agent_channel_s));
search.channel_id = channel_id;
return RB_FIND(proto_agent_channel_map, &channel_instance.proto_agent_head, &search);
}
@@ -1,82 +0,0 @@
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file enb_agent_net_comm.h
* \brief enb agent network interface abstraction
* \autho Xenofon Foukas
* \date 2016
* \version 0.1
*/
#ifndef PROTO_AGENT_NET_COMM_H_
#define PROTO_AGENT_NET_COMM_H_
#include "proto_agent_defs.h"
#include "tree.h"
#define ENB_AGENT_MAX 9
/* forward declaration */
struct proto_agent_async_channel_s;
/*Channel related information used for Tx/Rx of protocol messages*/
typedef struct proto_agent_channel_s {
RB_ENTRY(proto_agent_channel_s) entry;
int channel_id;
struct proto_agent_async_channel_s *channel_info;
/*Callbacks for channel message Tx and Rx*/
int (*msg_send)(void *data, int size, int priority, void *channel_info);
int (*msg_recv)(void **data, int *priority, void *channel_info);
void (*release)(struct proto_agent_channel_s *channel);
} proto_agent_channel_t;
typedef struct proto_agent_channel_instance_s{
RB_HEAD(proto_agent_channel_map, proto_agent_channel_s) proto_agent_head;
} proto_agent_channel_instance_t;
/*Register a channel to an agent. Use ENB_AGENT_MAX to register the
*same channel to all agents*/
int proto_agent_register_channel(mod_id_t mod_id, proto_agent_channel_t *channel, proto_agent_id_t agent_id);
/*Unregister the current channel of an agent. Use ENB_AGENT_MAX to unregister all channels*/
void proto_agent_unregister_channel(mod_id_t mod_id, proto_agent_id_t agent_id);
/*Create a new channel. Returns the id of the new channel or negative number otherwise*/
int proto_agent_create_channel(void *channel_info,
int (*msg_send)(void *data, int size, int priority, void *channel_info),
int (*msg_recv)(void **data, int *priority, void *channel_info),
void (*release)(proto_agent_channel_t *channel));
/*Unregister a channel from all agents and destroy it. Returns 0 in case of success*/
int proto_agent_destroy_channel(int channel_id);
/*Return an agent communication channel based on its id*/
proto_agent_channel_t * proto_agent_get_channel(int channel_id);
/*Should be called before performing any channel operations*/
err_code_t proto_agent_init_channel_container(void);
int proto_agent_compare_channel(struct proto_agent_channel_s *a, struct proto_agent_channel_s *b);
/* RB_PROTOTYPE is for .h files */
RB_PROTOTYPE(proto_agent_channel_map, proto_agent_channel_s, entry, proto_agent_compare_channel);
#endif /*ENB_AGENT_COMM_H_*/
@@ -1,16 +0,0 @@
#ifndef __PROTO_AGENT_RLC_PRIMITIVES_H__
#define __PROTO_AGENT_RLC_PRIMITIVES_H__
#include "RRC/LTE/rrc_defs.h"
#include "LAYER2/PROTO_AGENT/proto_agent.h"
// PROTO AGENT
pthread_t async_server_thread;
int async_server_thread_finalize (void);
void async_server_thread_init (void);
pthread_mutex_t async_server_lock;
pthread_cond_t async_server_notify;
int async_server_shutdown;
#endif
+2 -2
View File
@@ -674,7 +674,7 @@ static void deliver_sdu_drb(void *_ue, nr_pdcp_entity_t *entity,
sdap_gnb_ul_header_handler(buf[0]); // Handler for the UL gNB SDAP Header
}
LOG_D(PDCP, "%s() (drb %d) sending message to gtp size %d\n", __func__, rb_id, size-offset);
itti_send_msg_to_task(TASK_VARIABLE, INSTANCE_DEFAULT, message_p);
itti_send_msg_to_task(TASK_GTPV1_U, INSTANCE_DEFAULT, message_p);
}
}
}
@@ -728,7 +728,7 @@ rb_found:
LOG_D(PDCP, "%s() (drb %d) sending message to gtp size %d\n",
__func__, rb_id, size);
extern instance_t CUuniqInstance;
itti_send_msg_to_task(TASK_VARIABLE, CUuniqInstance, message_p);
itti_send_msg_to_task(TASK_GTPV1_U, CUuniqInstance, message_p);
} else {
memblock = get_free_mem_block(size, __FUNCTION__);
+1 -3
View File
@@ -40,8 +40,6 @@
#include "openair2/F1AP/f1ap_du_rrc_message_transfer.h"
#include "openair2/LAYER2/PROTO_AGENT/proto_agent.h"
extern RAN_CONTEXT_t RC;
#include <stdint.h>
@@ -518,7 +516,7 @@ rb_found:
req->pdusession_id=rb_id;
LOG_D(RLC, "Received uplink user-plane traffic at RLC-DU to be sent to the CU, size %d \n", size);
extern instance_t DUuniqInstance;
itti_send_msg_to_task(OCP_GTPV1_U, DUuniqInstance, msg);
itti_send_msg_to_task(TASK_GTPV1_U, DUuniqInstance, msg);
return;
}
}
+1 -1
View File
@@ -440,7 +440,7 @@ rb_found:
req->rnti=ue->rnti;
req->rab_id=rb_id+4;
LOG_D(RLC, "Received uplink user-plane traffic at RLC-DU to be sent to the CU, size %d \n", size);
itti_send_msg_to_task(OCP_GTPV1_U, DUuniqInstance, msg);
itti_send_msg_to_task(TASK_GTPV1_U, DUuniqInstance, msg);
return;
}
}
-2
View File
@@ -54,8 +54,6 @@
#include "common/config/config_userapi.h"
#include "RRC_config_tools.h"
#include "enb_paramdef.h"
#include "proto_agent.h"
#include "m3ap_MCE.h"
@@ -30,6 +30,10 @@
* \warning
*/
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "PHY/defs_nr_UE.h"
#include "NR_IF_Module.h"
#include "NR_MAC_UE/mac_proto.h"
-14
View File
@@ -9572,20 +9572,6 @@ void *rrc_enb_process_itti_msg(void *notUsed) {
rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_COMMAND(msg_p, msg_name_p, instance);
break;
case GTPV1U_ENB_DELETE_TUNNEL_RESP: {
rrc_eNB_ue_context_t *ue = rrc_eNB_get_ue_context(RC.rrc[instance], GTPV1U_ENB_DELETE_TUNNEL_RESP(msg_p).rnti);
if (ue != NULL
&& ue->ue_context.ue_release_timer_rrc > 0
&& (ue->ue_context.handover_info == NULL ||
(ue->ue_context.handover_info->state != HO_RELEASE &&
ue->ue_context.handover_info->state != HO_CANCEL))) {
ue->ue_context.ue_release_timer_rrc = ue->ue_context.ue_release_timer_thres_rrc;
}
break;
}
case S1AP_PATH_SWITCH_REQ_ACK:
LOG_I(RRC, "[eNB %ld] received path switch ack %s\n", instance, msg_name_p);
rrc_eNB_process_S1AP_PATH_SWITCH_REQ_ACK(msg_p, msg_name_p, instance);
+2 -2
View File
@@ -210,7 +210,7 @@ boolean_t gtpv_data_req_new (
GTPV1U_ENB_END_MARKER_REQ(msg).offset = GTPU_HEADER_OVERHEAD_MAX;
LOG_I(GTPU, "Send End Marker to GTPV1-U at frame %d and subframe %d \n", ctxt->frame,ctxt->subframe);
itti_send_msg_to_task(TASK_GTPV1_U, ENB_MODULE_ID_TO_INSTANCE(ctxt->module_id), msg);
return NW_GTPV1U_OK;
return 0;
}
/* target enb */
@@ -225,7 +225,7 @@ boolean_t gtpv_data_req_new (
gtpv1u_enb_delete_tunnel_req_t delete_tunnel_req;
memset(&delete_tunnel_req, 0, sizeof(delete_tunnel_req));
delete_tunnel_req.rnti = ctxt->rnti;
gtpv1u_delete_x2u_tunnel(ctxt->module_id, &delete_tunnel_req, GTPV1U_TARGET_ENB);
gtpv1u_delete_x2u_tunnel(ctxt->module_id, &delete_tunnel_req);
return true;
} else {
/* data packet */
-1
View File
@@ -36,7 +36,6 @@
#include "rrc_eNB_S1AP.h"
#include "enb_config.h"
#include "common/ran_context.h"
#include "gtpv1u.h"
#include "s1ap_eNB.h"
#include "s1ap_eNB_defs.h"
-3
View File
@@ -112,9 +112,6 @@ void apply_macrlc_config(gNB_RRC_INST *rrc,
rrc_gNB_ue_context_t *const ue_context_pP,
const protocol_ctxt_t *const ctxt_pP );
void apply_pdcp_config(rrc_gNB_ue_context_t *const ue_context_pP,
const protocol_ctxt_t *const ctxt_pP );
void
rrc_gNB_generate_RRCSetup(
const protocol_ctxt_t *const ctxt_pP,
+7 -37
View File
@@ -30,6 +30,10 @@
#define RRC_GNB_C
#define RRC_GNB_C
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "nr_rrc_config.h"
#include "nr_rrc_defs.h"
#include "nr_rrc_extern.h"
@@ -103,27 +107,6 @@
extern RAN_CONTEXT_t RC;
extern boolean_t nr_rrc_pdcp_config_asn1_req(
const protocol_ctxt_t *const ctxt_pP,
NR_SRB_ToAddModList_t *const srb2add_list,
NR_DRB_ToAddModList_t *const drb2add_list,
NR_DRB_ToReleaseList_t *const drb2release_list,
const uint8_t security_modeP,
uint8_t *const kRRCenc,
uint8_t *const kRRCint,
uint8_t *const kUPenc,
uint8_t *const kUPint
,LTE_PMCH_InfoList_r9_t *pmch_InfoList_r9
,rb_id_t *const defaultDRB,
struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list);
extern rlc_op_status_t nr_rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP,
const NR_SRB_ToAddModList_t * const srb2add_listP,
const NR_DRB_ToAddModList_t * const drb2add_listP,
const NR_DRB_ToReleaseList_t * const drb2release_listP,
const LTE_PMCH_InfoList_r9_t * const pmch_InfoList_r9_pP,
struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list);
static inline uint64_t bitStr_to_uint64(BIT_STRING_t *asn);
mui_t rrc_gNB_mui = 0;
@@ -2195,7 +2178,6 @@ rrc_gNB_decode_dcch(
asn_dec_rval_t dec_rval;
NR_UL_DCCH_Message_t *ul_dcch_msg = NULL;
struct rrc_gNB_ue_context_s *ue_context_p = NULL;
MessageDef *msg_delete_tunnels_p = NULL;
uint8_t xid;
int i;
@@ -2294,21 +2276,17 @@ rrc_gNB_decode_dcch(
xid = ul_dcch_msg->message.choice.c1->choice.rrcReconfigurationComplete->rrc_TransactionIdentifier;
ue_context_p->ue_context.pdu_session_release_command_flag = 0;
//gtp tunnel delete
msg_delete_tunnels_p = itti_alloc_new_message(TASK_RRC_GNB, 0, GTPV1U_GNB_DELETE_TUNNEL_REQ);
memset(&GTPV1U_GNB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p), 0, sizeof(GTPV1U_GNB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p)));
GTPV1U_GNB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).rnti = ue_context_p->ue_context.rnti;
gtpv1u_gnb_delete_tunnel_req_t req={0};
for(i = 0; i < NB_RB_MAX; i++) {
if(xid == ue_context_p->ue_context.pduSession[i].xid) {
GTPV1U_GNB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).pdusession_id[GTPV1U_GNB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).num_pdusession++] =
req.pdusession_id[req.num_pdusession++] =
ue_context_p->ue_context.gnb_gtp_psi[i];
ue_context_p->ue_context.gnb_gtp_teid[i] = 0;
memset(&ue_context_p->ue_context.gnb_gtp_addrs[i], 0, sizeof(ue_context_p->ue_context.gnb_gtp_addrs[i]));
ue_context_p->ue_context.gnb_gtp_psi[i] = 0;
}
}
itti_send_msg_to_task(TASK_GTPV1_U, ctxt_pP->instance, msg_delete_tunnels_p);
gtpv1u_delete_ngu_tunnel(ctxt_pP->instance, &req);
//NGAP_PDUSESSION_RELEASE_RESPONSE
rrc_gNB_send_NGAP_PDUSESSION_RELEASE_RESPONSE(ctxt_pP, ue_context_p, xid);
} else if (ue_context_p->ue_context.established_pdu_sessions_flag != 1) {
@@ -3641,9 +3619,6 @@ void *rrc_gnb_task(void *args_p) {
rrc_gNB_process_NGAP_PDUSESSION_RELEASE_COMMAND(msg_p, msg_name_p, instance);
break;
case GTPV1U_GNB_DELETE_TUNNEL_RESP:
break;
/* Messages from gNB app */
case NRRRC_CONFIGURATION_REQ:
LOG_I(NR_RRC, "[gNB %ld] Received %s : %p\n", instance, msg_name_p,&NRRRC_CONFIGURATION_REQ(msg_p));
@@ -3693,11 +3668,6 @@ void *rrc_gnb_task(void *args_p) {
rrc_gNB_process_dc_overall_timeout(GNB_INSTANCE_TO_MODULE_ID(instance), &X2AP_ENDC_DC_OVERALL_TIMEOUT(msg_p));
break;
/* Messages from GTP */
case GTPV1U_ENB_DELETE_TUNNEL_RESP:
/* nothing to do? */
break;
case NGAP_UE_CONTEXT_RELEASE_REQ:
rrc_gNB_process_NGAP_UE_CONTEXT_RELEASE_REQ(msg_p, msg_name_p, instance);
break;
+5 -8
View File
@@ -33,7 +33,6 @@
#include "rrc_eNB_S1AP.h"
#include "gnb_config.h"
#include "common/ran_context.h"
#include "gtpv1u.h"
#include "asn1_conversions.h"
#include "intertask_interface.h"
@@ -44,6 +43,7 @@
#include "gtpv1u_eNB_task.h"
#include "gtpv1u_gNB_task.h"
#include <openair3/ocp-gtpu/gtp_itf.h>
#include "RRC/LTE/rrc_eNB_GTPV1U.h"
#include "RRC/NR/rrc_gNB_GTPV1U.h"
@@ -1395,7 +1395,6 @@ rrc_gNB_process_NGAP_PDUSESSION_RELEASE_COMMAND(
protocol_ctxt_t ctxt;
pdusession_release_t pdusession_release_params[NGAP_MAX_PDUSESSION];
uint8_t nb_pdusessions_torelease;
MessageDef *msg_delete_tunnels_p = NULL;
uint8_t xid;
int i, pdusession;
uint8_t b_existed,is_existed;
@@ -1473,20 +1472,18 @@ rrc_gNB_process_NGAP_PDUSESSION_RELEASE_COMMAND(
} else {
//gtp tunnel delete
LOG_I(NR_RRC, "gtp tunnel delete \n");
msg_delete_tunnels_p = itti_alloc_new_message(TASK_RRC_GNB, 0, GTPV1U_GNB_DELETE_TUNNEL_REQ);
memset(&GTPV1U_GNB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p), 0, sizeof(GTPV1U_GNB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p)));
GTPV1U_GNB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).rnti = ue_context_p->ue_context.rnti;
gtpv1u_gnb_delete_tunnel_req_t req={0};
req.rnti = ue_context_p->ue_context.rnti;
for(i = 0; i < NB_RB_MAX; i++) {
if(xid == ue_context_p->ue_context.pduSession[i].xid) {
GTPV1U_GNB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).pdusession_id[GTPV1U_GNB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).num_pdusession++] = ue_context_p->ue_context.gnb_gtp_psi[i];
req.pdusession_id[req.num_pdusession++] = ue_context_p->ue_context.gnb_gtp_psi[i];
ue_context_p->ue_context.gnb_gtp_teid[i] = 0;
memset(&ue_context_p->ue_context.gnb_gtp_addrs[i], 0, sizeof(ue_context_p->ue_context.gnb_gtp_addrs[i]));
ue_context_p->ue_context.gnb_gtp_psi[i] = 0;
}
}
itti_send_msg_to_task(TASK_GTPV1_U, instance, msg_delete_tunnels_p);
gtpv1u_delete_ngu_tunnel(instance, &req);
//NGAP_PDUSESSION_RELEASE_RESPONSE
rrc_gNB_send_NGAP_PDUSESSION_RELEASE_RESPONSE(&ctxt, ue_context_p, xid);
LOG_I(NR_RRC, "Send PDU Session Release Response \n");
-185
View File
@@ -1,185 +0,0 @@
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*
May 10, 2001
Modified in June, 2001, to include the length non multiple of 8
crc_byte.c
Byte oriented implementation of CRC's
*/
#include "rtos_header.h"
#include "platform_types.h"
/*ref 25.222 v4.0.0 , p12 */
/* the highest degree is set by default */
unsigned int poly24 = 0x80006100; // 1000 0000 0000 0000 0110 0001 D^24 + D^23 + D^6 + D^5 + D + 1
unsigned int poly16 = 0x10210000; // 0001 0000 0010 0001 D^16 + D^12 + D^5 + 1
unsigned int poly12 = 0x80F00000; // 1000 0000 1111 D^12 + D^11 + D^3 + D^2 + D + 1
unsigned int poly8 = 0x9B000000; // 1001 1011 D^8 + D^7 + D^4 + D^3 + D + 1
/*********************************************************
For initialization && verification purposes,
bit by bit implementation with any polynomial
The first bit is in the MSB of each byte
*********************************************************/
static unsigned int
crcbit (unsigned char * inputptr, int octetlen, unsigned int poly)
{
unsigned int i, crc = 0, c;
while (octetlen-- > 0) {
c = (*inputptr++) << 24;
for (i = 8; i != 0; i--) {
if ((1 << 31) & (c ^ crc))
crc = (crc << 1) ^ poly;
else
crc <<= 1;
c <<= 1;
}
}
return crc;
}
/*********************************************************
crc table initialization
*********************************************************/
static unsigned int crc24Table[256];
static unsigned short crc16Table[256];
static unsigned short crc12Table[256];
static unsigned char crc8Table[256];
void
crcTableInit ()
{
unsigned char c = 0;
do {
crc24Table[c] = crcbit (&c, 1, poly24);
crc16Table[c] = (unsigned short) (crcbit (&c, 1, poly16) >> 16);
crc12Table[c] = (unsigned short) (crcbit (&c, 1, poly12) >> 16);
crc8Table[c] = (unsigned char) (crcbit (&c, 1, poly8) >> 24);
} while (++c);
}
/*********************************************************
Byte by byte implementations,
assuming initial byte is 0 padded (in MSB) if necessary
*********************************************************/
unsigned int
crc24 (unsigned char * inptr, int bitlen)
{
int octetlen, resbit;
unsigned int crc = 0;
octetlen = bitlen / 8; /* Change in octets */
resbit = (bitlen % 8);
while (octetlen-- > 0) {
crc = (crc << 8) ^ crc24Table[(*inptr++) ^ (crc >> 24)];
}
if (resbit > 0)
crc = (crc << resbit) ^ crc24Table[((*inptr) >> (8 - resbit)) ^ (crc >> (32 - resbit))];
return crc;
}
unsigned int
crc16 (unsigned char * inptr, int bitlen)
{
int octetlen, resbit;
unsigned int crc = 0;
octetlen = bitlen / 8; /* Change in octets */
resbit = (bitlen % 8);
while (octetlen-- > 0) {
crc = (crc << 8) ^ (crc16Table[(*inptr++) ^ (crc >> 24)] << 16);
}
if (resbit > 0)
crc = (crc << resbit) ^ (crc16Table[((*inptr) >> (8 - resbit)) ^ (crc >> (32 - resbit))] << 16);
return crc;
}
unsigned int
crc12 (unsigned char * inptr, int bitlen)
{
int octetlen, resbit;
unsigned int crc = 0;
octetlen = bitlen / 8; /* Change in octets */
resbit = (bitlen % 8);
while (octetlen-- > 0) {
crc = (crc << 8) ^ (crc12Table[(*inptr++) ^ (crc >> 24)] << 16);
}
if (resbit > 0)
crc = (crc << resbit) ^ (crc12Table[((*inptr) >> (8 - resbit)) ^ (crc >> (32 - resbit))] << 16);
return crc;
}
unsigned int
crc8 (unsigned char * inptr, int bitlen)
{
int octetlen, resbit;
unsigned int crc = 0;
octetlen = bitlen / 8; /* Change in octets */
resbit = (bitlen % 8);
while (octetlen-- > 0) {
crc = crc8Table[(*inptr++) ^ (crc >> 24)] << 24;
}
if (resbit > 0)
crc = (crc << resbit) ^ (crc8Table[((*inptr) >> (8 - resbit)) ^ (crc >> (32 - resbit))] << 24);
return crc;
}
/*******************************************************************/
/**
Test code
********************************************************************/
/* #ifdef MAIN
#include <stdio.h>
main()
{
unsigned char test[] = "Thebigredfox";
crcTableInit();
printf("%x\n", crcbit(test, sizeof(test) - 1, poly24));
printf("%x\n", crc24(test, (sizeof(test) - 1)*8));
printf("%x\n", crcbit(test, sizeof(test) - 1, poly8));
printf("%x\n", crc8(test, (sizeof(test) - 1)*8));
}
#endif */
-30
View File
@@ -1,30 +0,0 @@
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*
random_proto_extern.h
-------------------
AUTHOR : Lionel GAUTHIER
COMPANY : EURECOM
EMAIL : Lionel.Gauthier@eurecom.fr
***************************************************************************/
extern int uniform (void);
-116
View File
@@ -1,116 +0,0 @@
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file taus.c
* \brief random number generator per OAI component
* \author Navid Nikaein
* \date 2011 - 2014
* \version 0.1
* \email navid.nikaein@eurecom.fr
* \warning
* @ingroup util
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include "oml.h"
unsigned int s0[MAX_NUM_COMPS], s1[MAX_NUM_COMPS], s2[MAX_NUM_COMPS], b[MAX_NUM_COMPS], r[MAX_NUM_COMPS];
inline unsigned int taus(unsigned int comp) {
b[comp] = (((s0[comp] << 13) ^ s0[comp]) >> 19);
s0[comp] = (((s0[comp] & 0xFFFFFFFE) << 12)^ b[comp]);
b[comp] = (((s1[comp] << 2) ^ s1[comp]) >> 25);
s1[comp] = (((s1[comp] & 0xFFFFFFF8) << 4)^ b[comp]);
b[comp] = (((s2[comp] << 3) ^ s2[comp]) >> 11);
s2[comp] = (((s2[comp] & 0xFFFFFFF0) << 17)^ b[comp]);
r[comp] = s0[comp] ^ s1[comp] ^ s2[comp];
return r[comp];
}
/*void set_taus_seed(unsigned int seed_type) {
unsigned int i; // i index of component
for (i=MIN_NUM_COMPS; i < MAX_NUM_COMPS ; i ++) {
switch (seed_type) {
case 0: // use rand func
if (i == 0) srand(time(NULL));
s0[i] = ((unsigned int)rand());
s1[i] = ((unsigned int)rand());
s2[i] = ((unsigned int)rand());
printf("Initial seeds use rand: s0[%u] = 0x%x, s1[%u] = 0x%x, s2[%u] = 0x%x\n", i, s0[i], i, s1[i], i, s2[i]);
break;
case 1: // use rand with seed
if (i == 0) srand(0x1e23d851);
s0[i] = ((unsigned int)rand());
s1[i] = ((unsigned int)rand());
s2[i] = ((unsigned int)rand());
printf("Initial seeds use rand with seed : s0[%u] = 0x%x, s1[%u] = 0x%x, s2[%u] = 0x%x\n", i, s0[i], i, s1[i], i, s2[i]);
break;
default:
break;
}
}
}*/
int get_rand (unsigned int comp) {
if ((comp > MIN_NUM_COMPS) && (comp < MAX_NUM_COMPS))
return r[comp];
else {
//LOG_E(RNG,"unknown component %d\n",comp);
return -1;
}
}
unsigned int dtaus(unsigned int comp, unsigned int a, unsigned b) {
return (int) (((double)taus(comp)/(double)0xffffffff)* (double)(b-a) + (double)a);
}
/*
#ifdef STANDALONE
main() {
unsigned int i,randomg, randphy;
set_taus_seed(0);
printf("dtaus %d \n",dtaus(PHY, 1000, 1000000));
do {//for (i=0;i<10;i++){
randphy = taus(PHY);
randomg = taus(OTG);
i++;
// printf("rand for OMG (%d,0x%x) PHY (%d,0x%x)\n",OMG, randomg, PHY, randphy);
} while (randphy != randomg);
printf("after %d run: get rand for (OMG 0x%x, PHY 0x%x)\n",i, get_rand(OTG), get_rand(PHY));
}
#endif
*/
-58
View File
@@ -1,58 +0,0 @@
#/*
# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
# * contributor license agreements. See the NOTICE file distributed with
# * this work for additional information regarding copyright ownership.
# * The OpenAirInterface Software Alliance licenses this file to You under
# * the OAI Public License, Version 1.1 (the "License"); you may not use this file
# * except in compliance with the License.
# * You may obtain a copy of the License at
# *
# * http://www.openairinterface.org/?page_id=698
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# *-------------------------------------------------------------------------------
# * For more information about the OpenAirInterface (OAI) Software Alliance:
# * contact@openairinterface.org
# */
AM_CFLAGS = @ADD_CFLAGS@ \
-I$(top_srcdir)/COMMON \
-I$(top_srcdir)/NAS/EURECOM-NAS/src/api/network \
-I$(top_srcdir)/NAS/EURECOM-NAS/src/include \
-I$(top_srcdir)/NAS/EURECOM-NAS/src/ies \
-I$(top_srcdir)/NAS/EURECOM-NAS/src/emm/msg \
-I$(top_srcdir)/NAS/EURECOM-NAS/src/esm/msg \
-I$(top_srcdir)/NAS/EURECOM-NAS/src/util \
-I$(top_srcdir)/INTERTASK_INTERFACE \
-I$(top_srcdir)/GTPV1-U/nw-gtpv1u/include \
-I$(top_srcdir)/GTPV1-U/nw-gtpv1u/shared \
-I$(top_srcdir)/UTILS \
-I$(top_srcdir)/UTILS/HASHTABLE \
-I$(top_srcdir)/UTILS/TIMER
noinst_LTLIBRARIES = libgtpv1u.la
libgtpv1u_la_LDFLAGS = -all-static
libgtpv1u_la_SOURCES = \
gtpv1u_task.c gtpv1u.h \
gtpv1u_teid_pool.c \
nw-gtpv1u/shared/NwTypes.h \
nw-gtpv1u/shared/NwUtils.h \
nw-gtpv1u/shared/NwGtpv1uError.h \
nw-gtpv1u/shared/NwLog.h \
nw-gtpv1u/shared/NwGtpv1uIe.h \
nw-gtpv1u/shared/NwGtpv1uMsg.h \
nw-gtpv1u/shared/NwGtpv1u.h \
nw-gtpv1u/include/NwGtpv1uPrivate.h \
nw-gtpv1u/include/NwGtpv1uLog.h \
nw-gtpv1u/include/NwGtpv1uTrxn.h \
nw-gtpv1u/include/NwGtpv1uTunnelEndPoint.h \
nw-gtpv1u/src/NwGtpv1uTunnelEndPoint.c \
nw-gtpv1u/src/NwGtpv1uTrxn.c \
nw-gtpv1u/src/NwGtpv1uMsg.c \
nw-gtpv1u/src/NwGtpv1u.c
-67
View File
@@ -1,67 +0,0 @@
#/*
# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
# * contributor license agreements. See the NOTICE file distributed with
# * this work for additional information regarding copyright ownership.
# * The OpenAirInterface Software Alliance licenses this file to You under
# * the OAI Public License, Version 1.1 (the "License"); you may not use this file
# * except in compliance with the License.
# * You may obtain a copy of the License at
# *
# * http://www.openairinterface.org/?page_id=698
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# *-------------------------------------------------------------------------------
# * For more information about the OpenAirInterface (OAI) Software Alliance:
# * contact@openairinterface.org
# */
OUTDIR = .
libgtpv1u_OBJECTS = \
nw-gtpv1u/src/NwGtpv1uTunnelEndPoint.o \
nw-gtpv1u/src/NwGtpv1uTrxn.o \
nw-gtpv1u/src/NwGtpv1uMsg.o \
nw-gtpv1u/src/NwGtpv1u.o \
gtpv1u_eNB.o \
gtpv1u_teid_pool.o
# pull in dependency info for *existing* .o files
-include $(OUTDIR)/*.d
CFLAGS = \
-Wall \
$(GTPV1U_CFLAGS) \
-DENB_MODE \
-Werror=uninitialized \
-Werror=implicit-function-declaration
$(OUTDIR)/%.o : %.c
@echo "Compiling $<"
@if [ ! -d $(dir $@) ]; then mkdir -p $(dir $@); fi;
@$(CC) -c $(CFLAGS) -o $@ $<
@$(CC) -MM $(CFLAGS) $< > $(basename $@).d
@mv -f $(basename $@).d $(basename $@).d.tmp
@sed -e 's|.*:|$@:|' < $(basename $@).d.tmp > $(basename $@).d
@sed -e 's/.*://' -e 's/\\$$//' < $(basename $@).d.tmp | fmt -1 | \
sed -e 's/^ *//' -e 's/$$/:/' >> $(basename $@).d
@rm -f $(basename $@).d.tmp
objsdir:
@if [ ! -d $(OUTDIR) ]; then mkdir -p $(OUTDIR); fi;
$(OUTDIR)/libgtpv1u.a: $(addprefix $(OUTDIR)/,$(libgtpv1u_OBJECTS))
@echo Creating GTPV1U archive
@$(AR) rcs $@ $(addprefix $(OUTDIR)/,$(libgtpv1u_OBJECTS))
clean:
@$(RM_F_V) $(OUTDIR)/nw-gtpv1u/src/*.o
@$(RM_F_V) $(OUTDIR)/nw-gtpv1u/src/*.d
@$(RM_F_V) $(OUTDIR)/*.o
@$(RM_F_V) $(OUTDIR)/*.d
@$(RM_F_V) $(OUTDIR)/libgtpv1u.a
cleanall: clean
-55
View File
@@ -1,55 +0,0 @@
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file gtpv1u.h
* \brief
* \author Sebastien ROUX, Lionel Gauthier
* \company Eurecom
* \email: lionel.gauthier@eurecom.fr
*/
#ifndef GTPV1_U_H_
#define GTPV1_U_H_
#define GTPU_STACK_ENB 0
#define GTPU_STACK_SGW 1
/* When gtpv1u is compiled for eNB use MACRO from UTILS/log.h,
* otherwise use standard fprintf as logger.
*/
#if defined(ENB_MODE)
# define GTPU_DEBUG(x, args...) LOG_D(GTPU, x, ##args)
# define GTPU_INFO(x, args...) LOG_I(GTPU, x, ##args)
# define GTPU_WARNING(x, args...) LOG_W(GTPU, x, ##args)
# define GTPU_ERROR(x, args...) LOG_E(GTPU, x, ##args)
#else
# define GTPU_DEBUG(x, args...) fprintf(stdout, "[GTPU][D]"x, ##args)
# define GTPU_INFO(x, args...) fprintf(stdout, "[GTPU][I]"x, ##args)
# define GTPU_WARNING(x, args...) fprintf(stdout, "[GTPU][W]"x, ##args)
# define GTPU_ERROR(x, args...) fprintf(stderr, "[GTPU][E]"x, ##args)
#endif
//#warning "TO BE REFINED"
# define GTPU_HEADER_OVERHEAD_MAX 64
uint32_t gtpv1u_new_teid(void);
#endif /* GTPV1_U_H_ */
File diff suppressed because it is too large Load Diff
-69
View File
@@ -1,69 +0,0 @@
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file gtpv1u_eNB_task.h
* \brief
* \author Lionel Gauthier
* \company Eurecom
* \email: lionel.gauthier@eurecom.fr
*/
#ifndef GTPV1U_ENB_TASK_H_
#define GTPV1U_ENB_TASK_H_
/*
int
gtpv1u_new_data_req(
uint8_t enb_id,
uint8_t ue_id,
uint8_t rab_id,
uint8_t *buffer,
uint32_t buf_len,
uint32_t buf_offset);*/
int gtpv1u_eNB_init(void);
void *gtpv1u_eNB_process_itti_msg(void*);
void *gtpv1u_eNB_task(void *args);
int
gtpv1u_create_x2u_tunnel(
const instance_t instanceP,
const gtpv1u_enb_create_x2u_tunnel_req_t * const create_tunnel_req_pP,
gtpv1u_enb_create_x2u_tunnel_resp_t * const create_tunnel_resp_pP);
int
gtpv1u_create_s1u_tunnel(
const instance_t instanceP,
const gtpv1u_enb_create_tunnel_req_t * const create_tunnel_req_pP,
gtpv1u_enb_create_tunnel_resp_t * const create_tunnel_resp_pP);
int
gtpv1u_update_s1u_tunnel(
const instance_t instanceP,
const gtpv1u_enb_create_tunnel_req_t * const create_tunnel_req_pP,
const rnti_t prior_rnti);
int gtpv1u_delete_x2u_tunnel(
const instance_t instanceP,
const gtpv1u_enb_delete_tunnel_req_t * const req_pP,
int enbflag);
#endif /* GTPV1U_ENB_TASK_H_ */
File diff suppressed because it is too large Load Diff
-108
View File
@@ -1,108 +0,0 @@
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file gtpv1u_gNB_defs.h
* \brief
* \author Yoshio INOUE, Masayuki HARADA
* \date 2020
* \version 0.1
* \email: yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com
* (yoshio.inoue%40fujitsu.com%2cmasayuki.harada%40fujitsu.com)
*/
#include "hashtable.h"
#include "NR_asn_constant.h"
#ifndef GTPV1U_GNB_DEFS_H_
#define GTPV1U_GNB_DEFS_H_
#include "NwGtpv1u.h"
#define GTPV1U_UDP_PORT (2152)
#define NR_GTPV1U_MAX_BEARERS_ID (max_val_NR_DRB_Identity - 3)
#define GTPV1U_SOURCE_GNB (0)
#define GTPV1U_TARGET_GNB (1)
#define GTPV1U_MSG_FROM_SOURCE_GNB (0)
#define GTPV1U_MSG_FROM_UPF (1)
typedef struct nr_gtpv1u_teid_data_s {
/* UE identifier for oaisim stack */
module_id_t gnb_id;
rnti_t ue_id;
pdusessionid_t pdu_session_id;
} nr_gtpv1u_teid_data_t;
typedef struct nr_gtpv1u_bearer_s {
/* TEID used in dl and ul */
teid_t teid_gNB; ///< gNB TEID
uintptr_t teid_gNB_stack_session; ///< gNB TEID
teid_t teid_upf; ///< Remote TEID
in_addr_t upf_ip_addr;
struct in6_addr upf_ip6_addr;
teid_t teid_tgNB;
in_addr_t tgnb_ip_addr; ///< target gNB ipv4
struct in6_addr tgnb_ip6_addr; ///< target gNB ipv6
tcp_udp_port_t port;
//NwGtpv1uStackSessionHandleT stack_session;
bearer_state_t state;
} nr_gtpv1u_bearer_t;
typedef struct nr_gtpv1u_ue_data_s {
/* UE identifier for oaisim stack */
rnti_t ue_id;
/* Unique identifier used between PDCP and GTP-U to distinguish UEs */
uint32_t instance_id;
int num_bearers;
/* Bearer related data.
* Note that the first LCID available for data is 3 and we fixed the maximum
* number of e-rab per UE to be (32 [id range]), max RB is 11. The real rb id will 3 + rab_id (3..32).
*/
nr_gtpv1u_bearer_t bearers[NR_GTPV1U_MAX_BEARERS_ID];
//RB_ENTRY(gtpv1u_ue_data_s) gtpv1u_ue_node;
} nr_gtpv1u_ue_data_t;
typedef struct nr_gtpv1u_data_s {
/* nwgtpv1u stack internal data */
NwGtpv1uStackHandleT gtpv1u_stack;
/* RB tree of UEs */
hash_table_t *ue_mapping; // PDCP->GTPV1U
hash_table_t *teid_mapping; // GTPV1U -> PDCP
//RB_HEAD(gtpv1u_ue_map, gtpv1u_ue_data_s) gtpv1u_ue_map_head;
/* Local IP address to use */
in_addr_t gnb_ip_address_for_NGu_up;
/* UDP internal data */
//udp_data_t udp_data;
uint16_t seq_num;
uint8_t restart_counter;
} nr_gtpv1u_data_t;
#endif /* GTPV1U_GNB_DEFS_H_ */
-97
View File
@@ -1,97 +0,0 @@
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef GTPV1U_SGW_DEFS_H_
#define GTPV1U_SGW_DEFS_H_
#include "mme_config.h"
#include "NwGtpv1u.h"
#include "gtpv1u.h"
#include "hashtable.h"
#include "common_types.h"
#define GTPV1U_UDP_PORT (2152)
#define MAX_BEARERS_PER_UE (11)
typedef enum {
BEARER_DOWN = 0,
BEARER_IN_CONFIG,
BEARER_UP,
BEARER_DL_HANDOVER,
BEARER_UL_HANDOVER,
BEARER_MAX,
} bearer_state_t;
#define BUFFER_TO_uint32_t(buf, x) \
do { \
x = ((uint32_t)((buf)[0]) ) | \
((uint32_t)((buf)[1]) << 8) | \
((uint32_t)((buf)[2]) << 16) | \
((uint32_t)((buf)[3]) << 24); \
} while(0)
typedef struct gtpv1u_teid2enb_info_s {
/* TEID used in dl and ul */
uint32_t teid_enb; ///< Remote eNB TEID
ip_address_t enb_ip_addr;
bearer_state_t state;
uint16_t port; /// LG ???
} gtpv1u_teid2enb_info_t;
/*struct gtpv1u_ue_data_s {
// UE identifier for oaisim stack
uint8_t ue_id;
// Unique identifier used between PDCP and GTP-U to distinguish UEs
uint32_t instance_id;
// Bearer related data.
// Note that the first LCID available for data is 3 and we fixed the maximum
// number of e-rab per UE to be 11. The real rb id will 3 + rab_id (0..10).
//
struct gtpv1u_bearer_s bearers[MAX_BEARERS_PER_UE];
RB_ENTRY(gtpv1u_ue_data_s) gtpv1u_ue_node;
};*/
typedef struct {
/* nwgtpv1u stack internal data */
NwGtpv1uStackHandleT gtpv1u_stack;
/* RB tree of UEs */
//RB_HEAD(gtpv1u_ue_map, gtpv1u_ue_data_s) gtpv1u_ue_map_head;
/* Local IP address to use */
uint32_t sgw_ip_address_for_S1u_S12_S4_up;
char *ip_addr;
uint16_t seq_num;
uint8_t restart_counter;
//gtpv1u_teid2enb_info_t* teid2enb_mapping[];
hash_table_t *S1U_mapping;
} gtpv1u_data_t;
int gtpv1u_init(const mme_config_t *mme_config);
#endif /* GTPV1U_SGW_DEFS_H_ */
-47
View File
@@ -1,47 +0,0 @@
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file gtpv1u_task.c
* \brief
* \author Lionel Gauthier
* \company Eurecom
* \email: lionel.gauthier@eurecom.fr
*/
#include <stdlib.h>
#include <stdint.h>
#include "gtpv1u.h"
//#define GTPV1U_LINEAR_TEID_ALLOCATION 1
#ifdef GTPV1U_LINEAR_TEID_ALLOCATION
static uint32_t g_gtpv1u_teid = 0;
#endif
uint32_t gtpv1u_new_teid(void)
{
#ifdef GTPV1U_LINEAR_TEID_ALLOCATION
g_gtpv1u_teid = g_gtpv1u_teid + 1;
return g_gtpv1u_teid;
#else
return random() + random() % (RAND_MAX - 1) + 1;
#endif
}
-1
View File
@@ -1 +0,0 @@
Amit Chawre
-26
View File
@@ -1,26 +0,0 @@
Copyright (c) 2010-2011 Amit Chawre <http://www.amitchawre.net/contact.html>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
View File
View File
@@ -1,83 +0,0 @@
/*----------------------------------------------------------------------------*
* *
* n w - g t p v 2 u *
* G P R S T u n n e l i n g P r o t o c o l v 2 u S t a c k *
* *
* *
* Copyright (c) 2010-2011 Amit Chawre *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* 3. The name of the author may not be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR *
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES *
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. *
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, *
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT *
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF *
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
*----------------------------------------------------------------------------*/
#ifndef __NW_GTPV1U_LOG_H__
#define __NW_GTPV1U_LOG_H__
#include <stdio.h>
#include "NwLog.h"
/**
* @file NwGtpv1uLog.h
* @brief This header contains logging related definitions.
*/
#ifdef __cplusplus
extern "C" {
#endif
/*---------------------------------------------------------------------------
* Log Macro Definition
*--------------------------------------------------------------------------*/
#define NW_LOG(_gtpv1uHandle, _logLevel, ...) \
do { \
if(((NwGtpv1uStackT*)(_gtpv1uHandle))->logLevel >= _logLevel) \
{ \
char _logBuf[1024]; \
snprintf(_logBuf, 1024, __VA_ARGS__); \
((NwGtpv1uStackT*)(_gtpv1uHandle))->logMgr.logReqCallback(((NwGtpv1uStackT*)_gtpv1uHandle)->logMgr.logMgrHandle, _logLevel, __FILE__, __LINE__, _logBuf);\
} \
} while(0)
#define NW_ENTER(_gtpv1uHandle) \
do { \
NW_LOG(_gtpv1uHandle, NW_LOG_LEVEL_DEBG, "Entering '%s'", __func__);\
} while(0)
#define NW_LEAVE(_gtpv1uHandle) \
do { \
NW_LOG(_gtpv1uHandle, NW_LOG_LEVEL_DEBG, "Leaving '%s'", __func__);\
} while(0)
#ifdef __cplusplus
}
#endif
#endif /* __NW_TYPES_H__ */
/*--------------------------------------------------------------------------*
* E N D O F F I L E *
*--------------------------------------------------------------------------*/
@@ -1,227 +0,0 @@
/*----------------------------------------------------------------------------*
* *
* n w - g t p v 2 u *
* n w - g t p v 2 u *
* G P R S T u n n e l i n g P r o t o c o l v 2 u S t a c k *
* *
* *
* Copyright (c) 2010-2011 Amit Chawre *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* 3. The name of the author may not be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR *
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES *
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. *
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, *
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT *
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF *
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
*----------------------------------------------------------------------------*/
#ifndef __NW_GTPV1U_PRIVATE_H__
#define __NW_GTPV1U_PRIVATE_H__
#include "tree.h"
#include "queue.h"
#include "NwTypes.h"
#include "NwGtpv1uError.h"
#include "NwGtpv1u.h"
#include "NwGtpv1uMsg.h"
/**
* @file NwGtpv1uPrivate.h
* @brief This header file contains nw-gtpv1u private definitions not to be
* exposed to user application.
*/
#ifdef __cplusplus
extern "C" {
#endif
#define NW_GTPV1U_MALLOC(_stack, _size, _mem, _type) \
do { \
if(((NwGtpv1uStackT*)(_stack))->memMgr.memAlloc && ((NwGtpv1uStackT*)(_stack))->memMgr.memFree )\
{ \
_mem = (_type) ((NwGtpv1uStackT*) (_stack))->memMgr.memAlloc(((NwGtpv1uStackT*) (_stack))->memMgr.hMemMgr, _size, __FILE__, __LINE__);\
} \
else \
{ \
_mem = (_type) malloc (_size); \
} \
} while (0)
/*--------------------------------------------------------------------------*
* G T P U S T A C K O B J E C T T Y P E D E F I N I T I O N *
*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*
* GRPS Tunneling Protocol Stack Class Definition
*--------------------------------------------------------------------------*/
/**
* gtpv1u stack class definition
*/
typedef struct NwGtpv1uStack {
uint32_t stackType;/**< GTPU_STACK_ENB or GTPU_STACK_SGW */
NwPtrT id;
uint32_t seq;
NwGtpv1uUlpEntityT ulp;
NwGtpv1uUdpEntityT udp;
NwGtpv1uMemMgrEntityT memMgr;
NwGtpv1uTimerMgrEntityT tmrMgr;
NwGtpv1uLogMgrEntityT logMgr;
uint32_t logLevel;
RB_HEAD( NwGtpv1uOutstandingTxSeqNumTrxnMap, NwGtpv1uTrxn) outstandingTxSeqNumMap;
RB_HEAD( NwGtpv1uOutstandingRxSeqNumTrxnMap, NwGtpv1uTrxn) outstandingRxSeqNumMap;
RB_HEAD(NwGtpv1uTunnelEndPointTMap, NwGtpv1uTunnelEndPoint) sessionMap;
RB_HEAD(NwGtpv1uTunnelEndPointIdentifierMap, NwGtpv1uTunnelEndPoint) teidMap;
} NwGtpv1uStackT;
/**
* GTP Tunnel End Point class definition
*/
typedef struct NwGtpv1uTunnelEndPoint {
uint32_t teid; /**< Gtpu Tunnel End Point Identifier */
uint32_t peerAddr; /**< Peer IP address for the session */
NwGtpv1uStackT* pStack; /**< Pointer to the parent stack */
NwGtpv1uUlpSessionHandleT hUlpSession; /**< ULP session handle for the session */
RB_ENTRY (NwGtpv1uTunnelEndPoint) sessionMapRbtNode; /**< RB Tree Data Structure Node */
struct NwGtpv1uTunnelEndPoint *next;
} NwGtpv1uTunnelEndPointT;
/*--------------------------------------------------------------------------*
* Timeout Info Type Definition
*--------------------------------------------------------------------------*/
/**
* gtpv1u timeout info
*/
typedef struct NwGtpv1uTimeoutInfo {
NwGtpv1uStackHandleT hStack;
void* timeoutArg;
NwGtpv1uRcT (*timeoutCallbackFunc)(void*);
} NwGtpv1uTimeoutInfoT;
/**
* Start a transaction response timer
*
* @param[in] thiz Pointer to stack instance
* @param[in] timeoutArg Arg to timeout function.
* @param[out] phTmr Pointer to timer handle.
* @return NW_GTPV1U_OK on success.
*/
NwGtpv1uRcT
nwGtpStartTrxnPeerRspTimer(NwGtpv1uStackT* thiz, NwGtpv1uTimeoutInfoT* timeoutInfo, NwGtpv1uTimerHandleT* phTmr);
/**
* Stop a transaction response timer
*
* @param[in] thiz Pointer to stack instance
* @param[out] phTmr Pointer to timer handle.
* @return NW_GTPV1U_OK on success.
*/
NwGtpv1uRcT
nwGtpStopTrxnPeerRspTimer(NwGtpv1uStackT* thiz, NwGtpv1uTimerHandleT* phTmr);
#define NW_GTPV1U_MAX_MSG_LEN (4096) /**< Maximum supported gtpv1u packet length including header */
/**
* NwGtpv1uMsgT holds gtpv1u messages to/from the peer.
*/
typedef struct NwGtpv1uMsg {
uint8_t version;
uint8_t protocolType;
uint8_t extHdrFlag;
uint8_t seqNumFlag;
uint16_t npduNumFlag;
uint32_t msgType;
uint16_t msgLen;
uint32_t teid;
uint16_t seqNum;
uint8_t npduNum;
uint8_t nextExtHdrType;
uint8_t* msgBuf;
uint32_t msgBufLen;
uint32_t msgBufOffset;
struct NwGtpv1uMsg* next;
} NwGtpv1uMsgT;
/*--------------------------------------------------------------------------*
* R6/R4 Transaction Context Type Definition
*--------------------------------------------------------------------------*/
/**
* Transaction structure
*/
typedef struct NwGtpv1uTrxn {
uint32_t seqNum;
uint32_t peerIp;
uint32_t peerPort;
uint8_t maxRetries;
uint8_t t3Timer;
NwGtpv1uTimerHandleT hRspTmr;
NwGtpv1uTimeoutInfoT peerRspTimeoutInfo;
NwGtpv1uStackT* pStack;
NwGtpv1uTunnelEndPointT* pSession;
uint32_t hUlpTrxn;
NwGtpv1uMsgT* pMsg;
RB_ENTRY (NwGtpv1uTrxn) outstandingTxSeqNumMapRbtNode; /**< RB Tree Data Structure Node */
RB_ENTRY (NwGtpv1uTrxn) outstandingRxSeqNumMapRbtNode; /**< RB Tree Data Structure Node */
struct NwGtpv1uTrxn* next;
} NwGtpv1uTrxnT;
/**
* GTPv2 message header structure
*/
#pragma pack(1)
typedef struct NwGtpv1uMsgHeader {
uint8_t PN:1;
uint8_t S:1;
uint8_t E:1;
uint8_t spare:1;
uint8_t PT:1;
uint8_t version:3;
uint8_t msgType;
uint16_t msgLength;
uint32_t teid;
} NwGtpv1uMsgHeaderT;
#pragma pack()
#ifdef __cplusplus
}
#endif
#endif /* __NW_GTPV1U_PRIVATE_H__ */
/*--------------------------------------------------------------------------*
* E N D O F F I L E *
*--------------------------------------------------------------------------*/
@@ -1,88 +0,0 @@
/*----------------------------------------------------------------------------*
* *
* n w - g t p v 2 u *
* G P R S T u n n e l i n g P r o t o c o l v 2 u S t a c k *
* *
* *
* Copyright (c) 2010-2011 Amit Chawre *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* 3. The name of the author may not be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR *
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES *
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. *
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, *
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT *
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF *
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
*----------------------------------------------------------------------------*/
/**
* @file NwGtpv1uTrxn.h
* @author Amit Chawre
* @brief
*
* This header file contains required definitions and functions
* prototypes used by gtpv1u transactions.
*
**/
#ifndef __NW_GTPV1U_TRXN_H__
#define __NW_GTPV1U_TRXN_H__
#ifdef __cplusplus
extern "C" {
#endif
NwGtpv1uRcT
nwGtpv1uTrxnNew( NW_IN NwGtpv1uStackT* thiz,
NW_OUT NwGtpv1uTrxnT **ppTrxn);
NwGtpv1uRcT
nwGtpv1uTrxnWithSeqNew( NW_IN NwGtpv1uStackT* thiz,
NW_IN uint32_t seqNum,
NW_OUT NwGtpv1uTrxnT **ppTrxn);
NwGtpv1uRcT
nwGtpv1uTrxnDelete( NW_INOUT NwGtpv1uTrxnT **ppTrxn);
NwGtpv1uRcT
nwGtpv1uTrxnNew( NW_IN NwGtpv1uStackT* thiz,
NW_OUT NwGtpv1uTrxnT **ppTrxn);
NwGtpv1uRcT
nwGtpv1uTrxnDelete( NW_INOUT NwGtpv1uTrxnT **pthiz);
NwGtpv1uRcT
nwGtpv1uTrxnCreateAndSendMsg( NW_IN NwGtpv1uStackT* thiz,
NW_IN NwGtpv1uTrxnT *pTrxn,
NW_IN uint32_t peerIp,
NW_IN uint32_t peerPort,
NW_IN NwGtpv1uMsgT *pMsg);
#ifdef __cplusplus
}
#endif
#endif /* __NW_GTPV1U_TRXN_H__ */
/*--------------------------------------------------------------------------*
* E N D O F F I L E *
*--------------------------------------------------------------------------*/
@@ -1,85 +0,0 @@
/*----------------------------------------------------------------------------*
* *
* n w - g t p v 2 u *
* G P R S T u n n e l i n g P r o t o c o l v 2 u S t a c k *
* *
* *
* Copyright (c) 2010-2011 Amit Chawre *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* 3. The name of the author may not be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR *
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES *
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. *
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, *
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT *
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF *
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
*----------------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "NwTypes.h"
#include "NwUtils.h"
#include "NwGtpv1uError.h"
#include "NwGtpv1uPrivate.h"
#include "NwGtpv1uMsg.h"
#include "NwGtpv1u.h"
#include "NwGtpv1uLog.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __NW_GTPV1U_CONNECTION_H__
#define __NW_GTPV1U_CONNECTION_H__
/**
Constructor
@return Pointer to session on success, NULL n failure.
*/
NwGtpv1uTunnelEndPointT*
nwGtpTunnelEndPointNew(struct NwGtpv1uStack* pStack);
/**
Destructor
@param[in] thiz: Pointer to session
@return NW_GTPV1U_OK on success.
*/
NwGtpv1uRcT
nwGtpTunnelEndPointDestroy(struct NwGtpv1uStack* pStack, NwGtpv1uTunnelEndPointT* thiz);
NwGtpv1uRcT
nwGtpSessionSendMsgApiToUlpEntity(NwGtpv1uTunnelEndPointT* thiz,
NwGtpv1uMsgT *pMsg);
#ifdef __cplusplus
}
#endif
#endif
/*--------------------------------------------------------------------------*
* E N D O F F I L E *
*--------------------------------------------------------------------------*/
@@ -1,562 +0,0 @@
/*----------------------------------------------------------------------------*
* *
* n w - g t p v 2 u *
* G P R S T u n n e l i n g P r o t o c o l v 2 u S t a c k *
* *
* *
* Copyright (c) 2010-2011 Amit Chawre *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* 3. The name of the author may not be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR *
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES *
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. *
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, *
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT *
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF *
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
*----------------------------------------------------------------------------*/
#ifndef __NW_GTPV1U_H__
#define __NW_GTPV1U_H__
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include "NwTypes.h"
#include "NwGtpv1uError.h"
/**
* @file NwGtpv1u.h
* @author Amit Chawre
* @brief
*
* This header file contains all required definitions and functions
* prototypes for using nw-gtpv1u library.
*
**/
#define NW_GTPU_VERSION (0x01)
#define NW_GTP_PROTOCOL_TYPE_GTP (0x01)
#define NW_GTP_PROTOCOL_TYPE_GTP_PRIME (0x00)
/*--------------------------------------------------------------------------*
* S H A R E D A P I M A C R O S *
*--------------------------------------------------------------------------*/
#define NW_GTP_ECHO_REQ (1)
#define NW_GTP_ECHO_RSP (2)
#define NW_GTP_ERROR_INDICATION (26)
#define NW_GTP_SUPPORTED_EXTENSION_HEADER_INDICATION (31)
#define NW_GTP_END_MARKER (254)
#define NW_GTP_GPDU (255)
/*---------------------------------------------------------------------------
* Opaque Gtpv2 Stack Handles
*--------------------------------------------------------------------------*/
typedef NwPtrT NwGtpv1uStackHandleT; /**< Gtpv2 Stack Handle */
typedef NwPtrT NwGtpv1uUlpHandleT; /**< Gtpv2 Stack Ulp Entity Handle */
typedef NwPtrT NwGtpv1uUdpHandleT; /**< Gtpv2 Stack Udp Entity Handle */
typedef NwPtrT NwGtpv1uMemMgrHandleT; /**< Gtpv2 Stack Mem Manager Handle */
typedef NwPtrT NwGtpv1uTimerMgrHandleT; /**< Gtpv2 Stack Timer Manager Handle */
typedef NwPtrT NwGtpv1uLogMgrHandleT; /**< Gtpv2 Stack Log Mnagaer Handle */
typedef NwPtrT NwGtpv1uTimerHandleT; /**< Gtpv2 Stack Timer Handle */
typedef NwPtrT NwGtpv1uMsgHandleT; /**< Gtpv2 Msg Handle */
typedef struct NwGtpv1uStackConfig {
uint16_t udpSrcPort;
} NwGtpv1uStackConfigT;
/*--------------------------------------------------------------------------*
* S T A C K A P I D E F I N I T I O N S *
*--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
* Gtpv2 Stack ULP API type definitions
*--------------------------------------------------------------------------*/
/**
* APIs types between ULP and Stack
*/
typedef enum {
/* APIs from ULP to stack */
NW_GTPV1U_ULP_API_CREATE_TUNNEL_ENDPOINT = 0x00000000, /**< Create a local teid context on stack */
NW_GTPV1U_ULP_API_DESTROY_TUNNEL_ENDPOINT, /**< Delete a local teid context on stack */
NW_GTPV1U_ULP_API_INITIAL_REQ, /**< Send a Initial Request over a session */
NW_GTPV1U_ULP_API_TRIGGERED_REQ, /**< Send a Initial Request over a session */
NW_GTPV1U_ULP_API_TRIGGERED_RSP, /**< Send a Trigger Response over a session */
NW_GTPV1U_ULP_API_SEND_TPDU, /**< Send a T-PDU message over teid context */
/* APIs from stack to ULP */
NW_GTPV1U_ULP_API_RECV_TPDU, /**< Receive a gtpv1u T-PDU from stack */
NW_GTPV1U_ULP_API_RECV_MSG, /**< Receive a gtpv1u message from stack */
NW_GTPV1U_ULP_API_RSP_FAILURE, /**< Rsp failure for gtpv2 message from stack */
/* Do not add below this */
NW_GTPV1U_ULP_API_END = 0xFFFFFFFF,
} NwGtpv1uUlpApiTypeT;
/*---------------------------------------------------------------------------
* Gtpv2 Stack API information elements definitions
*--------------------------------------------------------------------------*/
typedef NwPtrT NwGtpv1uStackSessionHandleT;/**< Gtpv2 Stack session Handle */
typedef uint8_t NwGtpv1uMsgTypeT; /**< Gtpv2 Msg Type */
typedef NwPtrT NwGtpv1uTrxnHandleT; /**< Gtpv2 Transaction Handle */
typedef NwPtrT NwGtpv1uUlpTrxnHandleT; /**< Gtpv2 Ulp Transaction Handle */
typedef NwPtrT NwGtpv1uUlpSessionHandleT; /**< Gtpv2 Ulp session Handle */
/**
* API information elements between ULP and Stack for
* creating a session.
*/
typedef struct {
NW_IN uint32_t teid;
NW_IN NwGtpv1uUlpSessionHandleT hUlpSession;
NW_OUT NwGtpv1uStackSessionHandleT hStackSession;
} NwGtpv1uCreateTunnelEndPointT;
/**
* API information elements between ULP and Stack for
* destroying a session.
*/
typedef struct {
NW_IN NwGtpv1uStackSessionHandleT hStackSessionHandle;
} NwGtpv1uDestroyTunnelEndPointT;
/**
* API information elements between ULP and Stack for
* sending a Gtpv1u initial message.
*/
typedef struct {
NW_IN NwGtpv1uUlpTrxnHandleT hUlpTrxn;
NW_IN uint32_t peerIp;
NW_IN uint32_t peerPort;
NW_IN uint8_t flags;
NW_IN uint32_t teid;
} NwGtpv1uInitialReqInfoT;
/**
* API information elements between ULP and Stack for
* sending a Gtpv1u triggered response message.
*/
typedef struct {
NW_IN NwGtpv1uUlpTrxnHandleT hUlpTrxn;
NW_IN uint32_t peerIp;
NW_IN uint32_t peerPort;
NW_IN uint8_t flags;
NW_IN uint32_t teid;
NW_IN uint32_t seqNum;
NW_IN NwGtpv1uMsgHandleT hMsg;
} NwGtpv1uTriggeredRspInfoT;
/**
* API information elements between ULP and Stack for
* sending a Gtpv1u triggered request message.
*/
typedef struct {
NW_IN NwGtpv1uUlpTrxnHandleT hUlpTrxn;
NW_IN uint32_t peerIp;
NW_IN uint32_t peerPort;
NW_IN uint8_t flags;
NW_IN uint32_t teid;
NW_IN uint32_t seqNum;
NW_IN NwGtpv1uMsgHandleT hMsg;
} NwGtpv1uTriggeredReqInfoT;
/**
* API information elements between ULP and Stack for
* sending a Gtpv2 message over a session.
*/
typedef struct {
NW_IN uint32_t teid;
NW_IN uint32_t ipAddr;
NW_IN uint8_t flags;
NW_IN NwGtpv1uMsgHandleT hMsg;
} NwGtpv1uSendtoInfoT;
/**
* API information elements between ULP and Stack for
* sending a Gtpv2 message over a session.
*/
typedef struct {
NW_OUT NwGtpv1uStackSessionHandleT hStackSessionHandle;
NW_INOUT NwGtpv1uTrxnHandleT hTrxn;
NW_IN NwGtpv1uUlpTrxnHandleT hUlpTrxn;
NW_IN NwGtpv1uMsgTypeT msgType;
NW_IN uint8_t flags;
NW_IN NwGtpv1uMsgHandleT hMsg;
} NwGtpv1uSendMsgInfoT;
/**
* API information elements between ULP and Stack for
* receiving a Gtpv2 message over a session from stack.
*/
typedef struct {
NW_IN NwGtpv1uUlpSessionHandleT hUlpSession;
NW_IN NwGtpv1uUlpTrxnHandleT hUlpTrxn;
NW_IN uint32_t teid;
NW_IN uint32_t peerIp;
NW_IN uint32_t peerPort;
NW_IN uint32_t msgType; /**< Message type */
NW_IN NwGtpv1uMsgHandleT hMsg; /**< Gtp Message handle */
} NwGtpv1uRecvMsgInfoT;
/**
* API information elements between ULP and Stack for
* receiving a Gtpv2 message over a session from stack.
*/
typedef struct {
NW_IN NwGtpv1uUlpSessionHandleT hUlpSession;
NW_IN NwGtpv1uTrxnHandleT hTrxn;
} NwGtpv1uNackInfoT;
/*---------------------------------------------------------------------------
* Gtpv2 Stack API structure definition
*--------------------------------------------------------------------------*/
/**
* API structure between ULP and Stack
*/
typedef struct {
NwGtpv1uUlpApiTypeT apiType;
NwGtpv1uMsgHandleT hMsg;
union {
NwGtpv1uCreateTunnelEndPointT createTunnelEndPointInfo;
NwGtpv1uDestroyTunnelEndPointT destroyTunnelEndPointInfo;
NwGtpv1uInitialReqInfoT initialReqInfo;
NwGtpv1uTriggeredRspInfoT triggeredRspInfo;
NwGtpv1uTriggeredReqInfoT triggeredReqInfo;
NwGtpv1uSendtoInfoT sendtoInfo;
NwGtpv1uSendMsgInfoT sendMsgInfo;
NwGtpv1uRecvMsgInfoT recvMsgInfo;
NwGtpv1uNackInfoT nackMsgInfo;
} apiInfo;
} NwGtpv1uUlpApiT;
/*--------------------------------------------------------------------------*
* S T A C K E N T I T I E S D E F I N I T I O N S *
*--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
* ULP Entity Definitions
*--------------------------------------------------------------------------*/
/**
* Gtpv2 ULP entity definition
*/
typedef struct {
NwGtpv1uUlpHandleT hUlp;
NwGtpv1uRcT (*ulpReqCallback) ( NW_IN NwGtpv1uUlpHandleT hUlp,
NW_IN NwGtpv1uUlpApiT *pUlpApi);
} NwGtpv1uUlpEntityT;
/*---------------------------------------------------------------------------
* UDP Entity Definitions
*--------------------------------------------------------------------------*/
/**
* Gtpv2 UDP entity definition
*/
typedef struct {
NwGtpv1uUdpHandleT hUdp;
NwGtpv1uRcT (*udpDataReqCallback) ( NW_IN NwGtpv1uUdpHandleT udpHandle,
NW_IN uint8_t* dataBuf,
NW_IN uint32_t dataSize,
NW_IN uint32_t dataOffset,
NW_IN uint32_t peerIP,
NW_IN uint16_t peerPort);
} NwGtpv1uUdpEntityT;
/**
* Gtpv1u Memory Manager entity definition
*/
typedef struct {
NwGtpv1uMemMgrHandleT hMemMgr;
void* (*memAlloc)( NW_IN NwGtpv1uMemMgrHandleT hMemMgr,
NW_IN uint32_t memSize,
NW_IN NwCharT* fileName,
NW_IN uint32_t lineNumber);
void (*memFree) ( NW_IN NwGtpv1uMemMgrHandleT hMemMgr,
NW_IN void* hMem,
NW_IN NwCharT* fileName,
NW_IN uint32_t lineNumber);
} NwGtpv1uMemMgrEntityT;
/*---------------------------------------------------------------------------
* Timer Entity Definitions
*--------------------------------------------------------------------------*/
#define NW_GTPV1U_TMR_TYPE_ONE_SHOT (0)
#define NW_GTPV1U_TMR_TYPE_REPETITIVE (1)
/**
* Gtpv2 Timer Manager entity definition
*/
typedef struct {
NwGtpv1uTimerMgrHandleT tmrMgrHandle;
NwGtpv1uRcT (*tmrStartCallback)( NW_IN NwGtpv1uTimerMgrHandleT tmrMgrHandle,
NW_IN uint32_t timeoutSecs,
NW_IN uint32_t timeoutUsec,
NW_IN uint32_t tmrType,
NW_IN void* tmrArg,
NW_OUT NwGtpv1uTimerHandleT* tmrHandle);
NwGtpv1uRcT (*tmrStopCallback) ( NW_IN NwGtpv1uTimerMgrHandleT tmrMgrHandle,
NW_IN NwGtpv1uTimerHandleT tmrHandle);
} NwGtpv1uTimerMgrEntityT;
/*---------------------------------------------------------------------------
* Log Entity Definitions
*--------------------------------------------------------------------------*/
/**
* Gtpv2 Log manager entity definition
*/
typedef struct {
NwGtpv1uLogMgrHandleT logMgrHandle;
NwGtpv1uRcT (*logReqCallback) (NW_IN NwGtpv1uLogMgrHandleT logMgrHandle,
NW_IN uint32_t logLevel,
NW_IN NwCharT* file,
NW_IN uint32_t line,
NW_IN NwCharT* logStr);
} NwGtpv1uLogMgrEntityT;
/*--------------------------------------------------------------------------*
* P U B L I C F U N C T I O N S *
*--------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C" {
#endif
/*---------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------*/
/**
Initialize the nw-gtpv1u stack.
@param[in,out] phGtpv1uStackHandle : Pointer to stack handle
@param[in] stackType : GTPU_STACK_ENB or GTPU_STACK_SGW
*/
NwGtpv1uRcT
nwGtpv1uInitialize( NW_INOUT NwGtpv1uStackHandleT* phGtpv1uStackHandle, uint32_t stackType);
/*---------------------------------------------------------------------------
* Destructor
*--------------------------------------------------------------------------*/
/**
Destroy the nw-gtpv1u stack.
@param[in] hGtpv1uStackHandle : Stack handle
*/
NwGtpv1uRcT
nwGtpv1uFinalize( NW_IN NwGtpv1uStackHandleT hGtpv1uStackHandle);
/*---------------------------------------------------------------------------
* Configuration Get/Set Operations
*--------------------------------------------------------------------------*/
/**
Set Configuration for the nw-gtpv1u stack.
@param[in,out] phGtpv1uStackHandle : Pointer to stack handle
*/
NwGtpv1uRcT
NwGtpv1uConfigSet( NW_IN NwGtpv1uStackHandleT* phGtpv1uStackHandle, NW_IN NwGtpv1uStackConfigT* pConfig);
/**
Get Configuration for the nw-gtpv1u stack.
@param[in,out] phGtpv1uStackHandle : Pointer to stack handle
*/
NwGtpv1uRcT
NwGtpv1uConfigGet( NW_IN NwGtpv1uStackHandleT* phGtpv1uStackHandle, NW_OUT NwGtpv1uStackConfigT* pConfig);
/**
Set ULP entity for the stack.
@param[in] hGtpv1uStackHandle : Stack handle
@param[in] pUlpEntity : Pointer to ULP entity.
@return NW_GTPV1U_OK on success.
*/
NwGtpv1uRcT
nwGtpv1uSetUlpEntity( NW_IN NwGtpv1uStackHandleT hGtpv1uStackHandle,
NW_IN NwGtpv1uUlpEntityT* pUlpEntity);
/**
Set UDP entity for the stack.
@param[in] hGtpv1uStackHandle : Stack handle
@param[in] pUdpEntity : Pointer to UDP entity.
@return NW_GTPV1U_OK on success.
*/
NwGtpv1uRcT
nwGtpv1uSetUdpEntity( NW_IN NwGtpv1uStackHandleT hGtpv1uStackHandle,
NW_IN NwGtpv1uUdpEntityT* pUdpEntity);
/**
Set MemMgr entity for the stack.
@param[in] hGtpv1uStackHandle : Stack handle
@param[in] pMemMgr : Pointer to Memory Manager.
@return NW_GTPV1U_OK on success.
*/
NwGtpv1uRcT
nwGtpv1uSetMemMgrEntity( NW_IN NwGtpv1uStackHandleT hGtpv1uStackHandle,
NW_IN NwGtpv1uMemMgrEntityT* pMemMgr);
/**
Set TmrMgr entity for the stack.
@param[in] hGtpv1uStackHandle : Stack handle
@param[in] pTmrMgr : Pointer to Timer Manager.
@return NW_GTPV1U_OK on success.
*/
NwGtpv1uRcT
nwGtpv1uSetTimerMgrEntity( NW_IN NwGtpv1uStackHandleT hGtpv1uStackHandle,
NW_IN NwGtpv1uTimerMgrEntityT* pTmrMgr);
/**
Set LogMgr entity for the stack.
@param[in] hGtpv1uStackHandle : Stack handle
@param[in] pLogMgr : Pointer to Log Manager.
@return NW_GTPV1U_OK on success.
*/
NwGtpv1uRcT
nwGtpv1uSetLogMgrEntity( NW_IN NwGtpv1uStackHandleT hGtpv1uStackHandle,
NW_IN NwGtpv1uLogMgrEntityT* pLogMgr);
/**
Set log level for the stack.
@param[in] hGtpv1uStackHandle : Stack handle
@param[in] logLevel : Log level.
@return NW_GTPV1U_OK on success.
*/
NwGtpv1uRcT
nwGtpv1uSetLogLevel( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NW_IN uint32_t logLevel);
/*---------------------------------------------------------------------------
* Process Request from Udp Layer
*--------------------------------------------------------------------------*/
/**
Process Data Request from UDP entity.
@param[in] hGtpv1uStackHandle : Stack handle
@param[in] udpData : Pointer to received UDP data.
@param[in] udpDataLen : Received data length.
@param[in] dstPort : Received on port.
@param[in] from : Received from peer information.
@return NW_GTPV1U_OK on success.
*/
NwGtpv1uRcT
nwGtpv1uProcessUdpReq( NW_IN NwGtpv1uStackHandleT hGtpv1uStackHandle,
NW_IN uint8_t* udpData,
NW_IN uint32_t udpDataLen,
NW_IN uint16_t peerPort,
NW_IN uint32_t peerIP);
/*---------------------------------------------------------------------------
* Process Request from Upper Layer
*--------------------------------------------------------------------------*/
/**
Process Request from ULP entity.
@param[in] hGtpv1uStackHandle : Stack handle
@param[in] pLogMgr : Pointer to Ulp Req.
@return NW_GTPV1U_OK on success.
*/
NwGtpv1uRcT
nwGtpv1uProcessUlpReq( NW_IN NwGtpv1uStackHandleT hGtpv1uStackHandle,
NW_IN NwGtpv1uUlpApiT *ulpReq);
/*---------------------------------------------------------------------------
* Process Timer timeout Request from Timer Manager
*--------------------------------------------------------------------------*/
/**
Process Timer timeout Request from Timer Manager
@param[in] pLogMgr : Pointer timeout arguments.
@return NW_GTPV1U_OK on success.
*/
NwGtpv1uRcT
nwGtpv1uProcessTimeout( NW_IN void* timeoutArg);
NwGtpv1uRcT
nwGtpv1uPeerRspTimeout(void* arg);
#ifdef __cplusplus
}
#endif
#endif /* __NW_GTPV1U_H__ */
/*--------------------------------------------------------------------------*
* E N D O F F I L E *
*--------------------------------------------------------------------------*/
@@ -1,63 +0,0 @@
/*----------------------------------------------------------------------------*
* *
* n w - g t p v 2 c *
* G P R S T u n n e l i n g P r o t o c o l v 2 c S t a c k *
* *
* *
* Copyright (c) 2010-2011 Amit Chawre *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* 3. The name of the author may not be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR *
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES *
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. *
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, *
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT *
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF *
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
*----------------------------------------------------------------------------*/
#ifndef __NW_GTPV1U_ERROR_H__
#define __NW_GTPV1U_ERROR_H__
/**
* @file NwGtpv1uError.h
* @brief This header file contains return error code type definitions.
*/
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
NW_GTPV1U_OK = 0x00000000,
NW_GTPV1U_MANDATORY_IE_DUPLICATE,
NW_GTPV1U_MANDATORY_IE_MISSING,
NW_GTPV1U_MSG_MALFORMED,
NW_GTPV1U_FAILURE = 0xFFFFFFFE
}
NwGtpv1uRcT;
#ifdef __cplusplus
}
#endif
#endif /* __NW_GTPV1U_ERROR_H__*/
@@ -1,66 +0,0 @@
/*----------------------------------------------------------------------------*
* *
* n w - g t p v 2 u *
* G P R S T u n n e l i n g P r o t o c o l v 2 u S t a c k *
* *
* *
* Copyright (c) 2010-2011 Amit Chawre *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* 3. The name of the author may not be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR *
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES *
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. *
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, *
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT *
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF *
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
*----------------------------------------------------------------------------*/
/**
* @file NwGtpv1uIe.h
* @brief This header file contains Information Element definitions for GTPv1u
* as per 3GPP TS 29281-930.
*/
#ifndef __NW_GTPV1U_IE_H__
#define __NW_GTPV1U_IE_H__
/*--------------------------------------------------------------------------*
* G T P V 2 U I E T Y P E M A C R O D E F I N I T I O N S *
*--------------------------------------------------------------------------*/
#define NW_GTPV1U_IE_RECOVERY (14)
#define NW_GTPV1U_IE_TEID_DATA_I (15)
#define NW_GTPV1U_IE_GSN_ADDRESS (133)
#define NW_GTPV1U_IE_EXT_HDR_TYPE_LIST (141)
#define NW_GTPV1U_IE_PRIVATE_EXTENSION (255)
/*--------------------------------------------------------------------------*
* G T P V 2 U C A U S E V A L U E D E F I N I T I O N S *
*--------------------------------------------------------------------------*/
#define NW_GTPV1U_CAUSE_REQUEST_ACCEPTED (16)
#define NW_GTPV1U_CAUSE_MANDATORY_IE_MISSING (70)
#endif /* __NW_GTPV1U_IE_H__ */
/*--------------------------------------------------------------------------*
* E N D O F F I L E *
*--------------------------------------------------------------------------*/
@@ -1,317 +0,0 @@
/*----------------------------------------------------------------------------*
* *
* n w - g t p v 2 u *
* G P R S T u n n e l i n g P r o t o c o l v 2 u S t a c k *
* *
* *
* Copyright (c) 2010-2011 Amit Chawre *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* 3. The name of the author may not be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR *
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES *
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. *
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, *
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT *
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF *
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
*----------------------------------------------------------------------------*/
#ifndef __NW_GTPV1U_MSG_H__
#define __NW_GTPV1U_MSG_H__
#include "NwTypes.h"
#include "NwGtpv1u.h"
/**
* @file NwGtpv1uMsg.h
* @brief This file defines APIs for to build new outgoing gtpv1u messages and to parse incoming messages.
*/
#ifdef __cplusplus
extern "C" {
#endif
/*--------------------------------------------------------------------------*
* G T P V 2 C I E D A T A - T Y P E D E F I N I T I O N S *
*--------------------------------------------------------------------------*/
#pragma pack(1)
typedef struct NwGtpv1uIeTv1 {
uint8_t t;
uint8_t v;
} NwGtpv1uIeTv1T;
typedef struct NwGtpv1uIeTv2 {
uint8_t t;
uint8_t v;
} NwGtpv1uIeTv2T;
typedef struct NwGtpv1uIeTv4 {
uint8_t t;
uint32_t v;
} NwGtpv1uIeTv4T;
typedef struct NwGtpv1uIeTlv {
uint8_t t;
uint16_t l;
} NwGtpv1uIeTlvT;
#pragma pack()
/**
* Allocate a GPDU gtpv1u message.
*
* @param[in] hGtpuStackHandle : gtpv1u stack handle.
* @param[in] teidPresent : TEID is present flag.
* @param[in] teid : TEID for this message.
* @param[in] seqNum : Sequence number for this message.
* @param[out] phMsg : Pointer to message handle.
*/
NwGtpv1uRcT
nwGtpv1uMsgNew( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NW_IN uint8_t seqNumFlag,
NW_IN uint8_t npduNumFlag,
NW_IN uint8_t extHdrFlag,
NW_IN uint8_t msgType,
NW_IN uint8_t teid,
NW_IN uint16_t seqNum,
NW_IN uint8_t npduNum,
NW_IN uint8_t nextExtHeader,
NW_OUT NwGtpv1uMsgHandleT *phMsg);
/**
* Allocate a gtpv1u message.
*
* @param[in] hGtpuStackHandle : gtpv1u stack handle.
* @param[in] teid : TEID for this message.
* @param[in] seqNumFlag : Sequence number flag for this message.
* @param[in] seqNum : Sequence number for this message.
* @param[in] pTpdu: T-PDU for this message.
* @param[in] tpduLength: T-PDU length for this message.
* @param[out] phMsg : Pointer to message handle.
*/
NwGtpv1uRcT
nwGtpv1uGpduMsgNew( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NW_IN uint32_t teid,
NW_IN uint8_t seqNumFlag,
NW_IN uint16_t seqNum,
NW_IN uint8_t* tpdu,
NW_IN uint16_t tpduLength,
NW_IN uint32_t tpduOffset,
NW_OUT NwGtpv1uMsgHandleT *phMsg);
/**
* Allocate a gtpv1u message from another gtpv1u message.
*
* @param[in] hGtpuStackHandle : gtpv1u stack handle.
* @param[out] hMsg : Handle to input message.
* @param[out] phMsg : Pointer to message handle.
*/
NwGtpv1uRcT
nwGtpv1uMsgFromMsgNew( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NW_IN NwGtpv1uMsgHandleT hMsg,
NW_OUT NwGtpv1uMsgHandleT *phMsg);
/**
* Allocate a gtpv1u message from data buffer.
*
* @param[in] hGtpuStackHandle : gtpv1u stack handle.
* @param[in] pBuf: Buffer to be copied in this message.
* @param[in] bufLen: Buffer length to be copied in this message.
* @param[out] phMsg : Pointer to message handle.
*/
NwGtpv1uRcT
nwGtpv1uMsgFromBufferNew( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NW_IN uint8_t* pBuf,
NW_IN uint32_t bufLen,
NW_OUT NwGtpv1uMsgHandleT *phMsg);
/**
* Free a gtpv1u message.
*
* @param[in] hGtpuStackHandle : gtpv1u stack handle.
* @param[in] hMsg : Message handle.
*/
NwGtpv1uRcT
nwGtpv1uMsgDelete( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NW_IN NwGtpv1uMsgHandleT hMsg);
/**
* Set TEID for gtpv1u message.
*
* @param[in] hMsg : Message handle.
* @param[in] teid: TEID value.
*/
NwGtpv1uRcT
nwGtpv1uMsgSetTeid(NW_IN NwGtpv1uMsgHandleT hMsg, uint32_t teid);
/**
* Set TEID present flag for gtpv1u message.
*
* @param[in] hMsg : Message handle.
* @param[in] teidPesent: Flag boolean value.
*/
NwGtpv1uRcT
nwGtpv1uMsgSetTeidPresent(NW_IN NwGtpv1uMsgHandleT hMsg, NwBoolT teidPresent);
/**
* Set sequence for gtpv1u message.
*
* @param[in] hMsg : Message handle.
* @param[in] seqNum: Flag boolean value.
*/
NwGtpv1uRcT
nwGtpv1uMsgSetSeqNumber(NW_IN NwGtpv1uMsgHandleT hMsg, uint32_t seqNum);
/**
* Get TEID present for gtpv1u message.
*
* @param[in] hMsg : Message handle.
*/
uint32_t
nwGtpv1uMsgGetTeid(NW_IN NwGtpv1uMsgHandleT hMsg);
/**
* Get TEID present for gtpv1u message.
*
* @param[in] hMsg : Message handle.
*/
NwBoolT
nwGtpv1uMsgGetTeidPresent(NW_IN NwGtpv1uMsgHandleT hMsg);
/**
* Get sequence number for gtpv1u message.
*
* @param[in] hMsg : Message handle.
*/
uint32_t
nwGtpv1uMsgGetSeqNumber(NW_IN NwGtpv1uMsgHandleT hMsg);
/**
* Get tpdu for gtpv1u message.
*
* @param[in] hMsg : Message handle.
* @param[inout] pTpduBuf : Buffer to copy the T-PDU.
* @param[out] hMsg : T-PDU length.
*/
uint32_t
nwGtpv1uMsgGetTpdu(NW_IN NwGtpv1uMsgHandleT hMsg, uint8_t* pTpduBuf, uint32_t* pTpduLength);
uint8_t*
nwGtpv1uMsgGetTpduHandle(NW_IN NwGtpv1uMsgHandleT hMsg);
uint32_t
nwGtpv1uMsgGetTpduLength(NW_IN NwGtpv1uMsgHandleT hMsg);
/**
* Add a gtpv1u information element of length 1 to gtpv1u mesasge.
*
* @param[in] hMsg : Handle to gtpv1u message.
* @param[in] type : IE type.
* @param[in] value : IE value.
*/
NwGtpv1uRcT
nwGtpv1uMsgAddIeTV1(NW_IN NwGtpv1uMsgHandleT hMsg,
NW_IN uint8_t type,
NW_IN uint8_t value);
/**
* Add a gtpv1u information element of length 2 to gtpv1u mesasge.
*
* @param[in] hMsg : Handle to gtpv1u message.
* @param[in] type : IE type.
* @param[in] value : IE value.
*/
NwGtpv1uRcT
nwGtpv1uMsgAddIeTV2(NW_IN NwGtpv1uMsgHandleT hMsg,
NW_IN uint8_t type,
NW_IN uint16_t length,
NW_IN uint16_t value);
/**
* Add a gtpv1u information element of length 4 to gtpv1u mesasge.
*
* @param[in] hMsg : Handle to gtpv1u message.
* @param[in] type : IE type.
* @param[in] value : IE value.
*/
NwGtpv1uRcT
nwGtpv1uMsgAddIeTV4(NW_IN NwGtpv1uMsgHandleT hMsg,
NW_IN uint8_t type,
NW_IN uint16_t length,
NW_IN uint32_t value);
/**
* Add a gtpv1u information element of variable length to gtpv1u mesasge.
*
* @param[in] hMsg : Handle to gtpv1u message.
* @param[in] type : IE type.
* @param[in] length : IE length.
* @param[in] value : IE value.
*/
NwGtpv1uRcT
nwGtpv1uMsgAddIe(NW_IN NwGtpv1uMsgHandleT hMsg,
NW_IN uint8_t type,
NW_IN uint16_t length,
NW_IN uint8_t* pVal);
/**
* Dump the contents of gtpv1u mesasge.
*
* @param[in] hMsg : Handle to gtpv1u message.
* @param[in] fp: Pointer to output file.
*/
NwGtpv1uRcT
nwGtpv1uMsgHexDump(NwGtpv1uMsgHandleT hMsg, FILE* fp);
uint32_t
nwGtpv1uMsgGetMsgType(NW_IN NwGtpv1uMsgHandleT hMsg);
#ifdef __cplusplus
}
#endif
#endif /* __NW_TYPES_H__ */
/*--------------------------------------------------------------------------*
* E N D O F F I L E *
*--------------------------------------------------------------------------*/
-88
View File
@@ -1,88 +0,0 @@
/*----------------------------------------------------------------------------*
* *
* n w - g t p v 2 c *
* G P R S T u n n e l i n g P r o t o c o l v 2 c S t a c k *
* *
* *
* Copyright (c) 2010-2011 Amit Chawre *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* 3. The name of the author may not be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR *
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES *
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. *
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, *
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT *
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF *
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
*----------------------------------------------------------------------------*/
#ifndef __NW_LOG_H__
#define __NW_LOG_H__
#include <libgen.h>
#include "NwTypes.h"
/**
* @file NwLog.h
* @brief This header file contains global shared logging definitions.
*/
#ifdef __cplusplus
extern "C" {
#endif
/*---------------------------------------------------------------------------
* Log Level Definitions
*--------------------------------------------------------------------------*/
#define NW_LOG_LEVEL_EMER (0) /**< system is unusable */
#define NW_LOG_LEVEL_ALER (1) /**< action must be taken immediately*/
#define NW_LOG_LEVEL_CRIT (2) /**< critical conditions */
#define NW_LOG_LEVEL_ERRO (3) /**< error conditions */
#define NW_LOG_LEVEL_WARN (4) /**< warning conditions */
#define NW_LOG_LEVEL_NOTI (5) /**< normal but signification condition */
#define NW_LOG_LEVEL_INFO (6) /**< informational */
#define NW_LOG_LEVEL_DEBG (7) /**< debug-level messages */
// static
// NwCharT* gLogLevelStr[] = {"EMER", "ALER", "CRIT", "ERRO", "WARN", "NOTI", "INFO", "DEBG"};
/*---------------------------------------------------------------------------
* IPv4 logging macros
*--------------------------------------------------------------------------*/
#define NW_IPV4_ADDR "%u.%u.%u.%u"
#define NW_IPV4_ADDR_FORMAT(__addr) (uint8_t)((__addr) & 0x000000ff), \
(uint8_t)(((__addr) & 0x0000ff00) >> 8 ), \
(uint8_t)(((__addr) & 0x00ff0000) >> 16), \
(uint8_t)(((__addr) & 0xff000000) >> 24)
#define NW_IPV4_ADDR_FORMATP(__paddr) (uint8_t)(*((uint8_t*)(__paddr)) & 0x000000ff), \
(uint8_t)(*((uint8_t*)(__paddr + 1)) & 0x000000ff), \
(uint8_t)(*((uint8_t*)(__paddr + 2)) & 0x000000ff), \
(uint8_t)(*((uint8_t*)(__paddr + 3)) & 0x000000ff)
#ifdef __cplusplus
}
#endif
#endif /* __NW_LOG_H__ */
@@ -1,78 +0,0 @@
/*----------------------------------------------------------------------------*
* *
* n w - g t p v 2 c *
* G P R S T u n n e l i n g P r o t o c o l v 2 c S t a c k *
* *
* *
* Copyright (c) 2010-2011 Amit Chawre *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* 3. The name of the author may not be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR *
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES *
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. *
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, *
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT *
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF *
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
*----------------------------------------------------------------------------*/
#include <stdlib.h>
#include <stdint.h>
#ifndef __NW_TYPES_H__
#define __NW_TYPES_H__
/**
* @file NwTypes.h
* @brief This header file contains basic type definitions.
*/
#ifdef __cplusplus
extern "C" {
#endif
#define NW_IN /**< An input argument */
#define NW_OUT /**< An output argumnet */
#define NW_INOUT /**< An input and output argument */
#define NW_TRUE (1) /**< Truth value */
#define NW_FALSE (0) /**< False value */
typedef signed char NwS8T; /**< Signed 1 byte */
typedef signed short NwS16T; /**< Signed 2 byte */
typedef signed int NwS32T; /**< Signed 4 byte */
typedef signed long long NwS64T; /**< Signed 8 byte */
typedef uintptr_t NwPtrT; /**< Use this for generic pointers */
typedef unsigned int NwHandleT; /**< Use this for generic handles */
typedef char NwBoolT; /**< Use this for booleans */
typedef char NwCharT; /**< Use this for strings */
typedef signed int NwFdT; /**< Use this for file descriptor */
#ifdef __cplusplus
}
#endif
#endif /* __NW_TYPES_H__ */
@@ -1,68 +0,0 @@
/*----------------------------------------------------------------------------*
* *
* n w - g t p v 2 c *
* G P R S T u n n e l i n g P r o t o c o l v 2 c S t a c k *
* *
* *
* Copyright (c) 2010-2011 Amit Chawre *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* 3. The name of the author may not be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR *
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES *
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. *
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, *
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT *
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF *
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
*----------------------------------------------------------------------------*/
#include <assert.h>
#ifndef __NW_UTILS_H__
#define __NW_UTILS_H__
/**
* @file NwUtils.h
* @brief This header file contains utility macro and function definitions.
*/
#define NW_ASSERT assert /**< Assertion */
#define NW_CHK_NULL_PTR(_ptr) NW_ASSERT(_ptr != NULL) /**< Null pointer check */
#define NW_HTONS(x) ( ( ((x) & 0xff00) >> 8 ) | ( ((x) & 0x00ff) << 8 ) )
#define NW_HTONL(x) ( ( ((x) & 0xff000000) >> 24 ) | ( ( (x) & 0x00ff0000 ) >> 8 ) | \
( ( (x) & 0x0000ff00 ) << 8 ) | ( ( (x) & 0x000000ff) << 24 ) )
#define NW_HTONLL(x) ( \
( ( ((uint64_t)x) & 0xff00000000000000ULL ) >> 56 ) | ( ( ((uint64_t)x) & 0x00ff000000000000ULL ) >> 40 ) | \
( ( ((uint64_t)x) & 0x0000ff0000000000ULL ) >> 24 ) | ( ( ((uint64_t)x) & 0x000000ff00000000ULL ) >> 8 ) | \
( ( ((uint64_t)x) & 0x000000000000ff00ULL ) << 40 ) | ( ( ((uint64_t)x) & 0x00000000000000ffULL ) << 56 ) | \
( ( ((uint64_t)x) & 0x0000000000ff0000ULL ) << 24 ) | ( ( ((uint64_t)x) & 0x00000000ff000000ULL ) << 8 ) \
)
#define NW_NTOHS NW_HTONS
#define NW_NTOHL NW_HTONL
#define NW_NTOHLL NW_HTONLL
#endif /* __NW_UTILS_H__ */
File diff suppressed because it is too large Load Diff
@@ -1,558 +0,0 @@
/*----------------------------------------------------------------------------*
* *
* n w - g t p v 2 u *
* G P R S T u n n e l i n g P r o t o c o l v 2 u S t a c k *
* *
* *
* Copyright (c) 2010-2011 Amit Chawre *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* 3. The name of the author may not be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR *
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES *
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. *
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, *
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT *
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF *
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
*----------------------------------------------------------------------------*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "NwTypes.h"
#include "NwLog.h"
#include "NwUtils.h"
#include "NwGtpv1uLog.h"
#include "NwGtpv1u.h"
#include "NwGtpv1uPrivate.h"
#include "NwGtpv1uMsg.h"
#include "assertions.h"
#include "gtpv1u.h"
#if defined(ENB_MODE)
#include "common/utils/LOG/log.h"
#endif
#define NW_GTPV1U_EPC_SPECIFIC_HEADER_SIZE (12) /**< Size of GTPv1u EPC specific header */
#define NW_GTPV1U_EPC_MIN_HEADER_SIZE (8)
#ifdef __cplusplus
extern "C" {
#endif
static NwGtpv1uMsgT *gpGtpv1uMsgPool = NULL;
NwGtpv1uRcT
nwGtpv1uMsgNew( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NW_IN uint8_t seqNumFlag,
NW_IN uint8_t npduNumFlag,
NW_IN uint8_t extHdrFlag,
NW_IN uint8_t msgType,
NW_IN uint8_t teid,
NW_IN uint16_t seqNum,
NW_IN uint8_t npduNum,
NW_IN uint8_t nextExtHeader,
NW_OUT NwGtpv1uMsgHandleT *phMsg)
{
NwGtpv1uStackT *pStack = (NwGtpv1uStackT *) hGtpuStackHandle;
NwGtpv1uMsgT *pMsg;
if(gpGtpv1uMsgPool) {
pMsg = gpGtpv1uMsgPool;
gpGtpv1uMsgPool = gpGtpv1uMsgPool->next;
} else {
NW_GTPV1U_MALLOC(pStack, sizeof(NwGtpv1uMsgT), pMsg, NwGtpv1uMsgT *);
}
if(pMsg) {
pMsg->version = NW_GTPU_VERSION;
pMsg->protocolType = NW_GTP_PROTOCOL_TYPE_GTP;
pMsg->seqNumFlag = seqNumFlag;
pMsg->npduNumFlag = npduNumFlag;
pMsg->extHdrFlag = extHdrFlag;
pMsg->msgType = msgType;
if(seqNumFlag) {
pMsg->seqNum = seqNum;
}
if(npduNumFlag) {
pMsg->npduNum = npduNum;
}
if(extHdrFlag) {
pMsg->nextExtHdrType = nextExtHeader;
}
pMsg->msgLen = ((pMsg->seqNumFlag || pMsg->npduNumFlag
|| pMsg->extHdrFlag) ?
4 : 0);
//NW_GTPV1U_EPC_SPECIFIC_HEADER_SIZE : (NW_GTPV1U_EPC_SPECIFIC_HEADER_SIZE - 4));
pMsg->msgBuf = NULL;
pMsg->msgBufLen = 0;
pMsg->msgBufOffset = 0;
*phMsg = (NwGtpv1uMsgHandleT) pMsg;
return NW_GTPV1U_OK;
}
return NW_GTPV1U_FAILURE;
}
NwGtpv1uRcT
nwGtpv1uGpduMsgNew( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NW_IN uint32_t teid,
NW_IN uint8_t seqNumFlag,
NW_IN uint16_t seqNum,
NW_IN uint8_t *tpdu,
NW_IN uint16_t tpduLength,
NW_IN uint32_t tpduOffset,
NW_OUT NwGtpv1uMsgHandleT *phMsg)
{
NwGtpv1uStackT *pStack = (NwGtpv1uStackT *) hGtpuStackHandle;
NwGtpv1uMsgT *pMsg;
//uint32_t header_len = 0;
uint32_t msgExtraLen = 0;
if(gpGtpv1uMsgPool) {
pMsg = gpGtpv1uMsgPool;
gpGtpv1uMsgPool = gpGtpv1uMsgPool->next;
} else {
NW_GTPV1U_MALLOC(pStack, sizeof(NwGtpv1uMsgT), pMsg, NwGtpv1uMsgT *);
}
if(pMsg) {
msgExtraLen = (((seqNumFlag) || (NW_FALSE) || (NW_FALSE) ) ?
(NW_GTPV1U_EPC_SPECIFIC_HEADER_SIZE - NW_GTPV1U_EPC_MIN_HEADER_SIZE) : 0);
AssertFatal((msgExtraLen + NW_GTPV1U_EPC_MIN_HEADER_SIZE) <= tpduOffset,
"Mismatch GTPU len, msgExtraLen %u tpduOffset %u",
msgExtraLen,
(uint32_t) tpduOffset);
pMsg->msgBuf = tpdu;
pMsg->msgBufLen = tpduLength + msgExtraLen + NW_GTPV1U_EPC_MIN_HEADER_SIZE;
pMsg->msgBufOffset = tpduOffset - (msgExtraLen + NW_GTPV1U_EPC_MIN_HEADER_SIZE);
#if defined(LOG_GTPU) && LOG_GTPU > 0
GTPU_DEBUG("MSG length %u, offset %u -> length %u offset %u\n",
tpduLength, tpduOffset,
pMsg->msgBufLen, pMsg->msgBufOffset);
#endif
// Version field: This field is used to determine the version of the GTP-U protocol.
// The version number shall be set to '1'.
pMsg->version = NW_GTPU_VERSION;
// Protocol Type (PT): This bit is used as a protocol discriminator between GTP (when PT is '1')
// and GTP' (when PT is '0'). GTP is described in this document and the GTP' protocol in 3GPP TS 32.295 [8].
// Note that the interpretation of the header fields may be different in GTP' than in GTP.
pMsg->protocolType = NW_GTP_PROTOCOL_TYPE_GTP;
// Extension Header flag (E): This flag indicates the presence of a meaningful value of the Next Extension
// Header field. When it is set to '0', the Next Extension Header field either is not present or, if present,
// shall not be interpreted.
pMsg->extHdrFlag = NW_FALSE;
// Sequence number flag (S): This flag indicates the presence of a meaningful value of the Sequence Number field.
// When it is set to '0', the Sequence Number field either is not present or, if present, shall not be interpreted.
// When it is set to '1', the Sequence Number field is present, and shall be interpreted, as described below in
// this section.
// For the Echo Request, Echo Response, Error Indication and Supported Extension Headers Notification
// messages, the S flag shall be set to '1'. Since the use of Sequence Numbers is optional for G-PDUs, the PGW,
// SGW, ePDG and eNodeB should set the flag to '0'. However, when a G-PDU (T-PDU+header) is being relayed
// by the Indirect Data Forwarding for Inter RAT HO procedure, then if the received G-PDU has the S flag set to
// '1', then the relaying entity shall set S flag to '1' and forward the G-PDU (T-PDU+header). In an End marker
// message the S flag shall be set to '0'.
pMsg->seqNumFlag = (seqNumFlag? NW_TRUE : NW_FALSE);
pMsg->seqNum = seqNum;
// N-PDU Number flag (PN): This flag indicates the presence of a meaningful value of the N-PDU Number field.
// When it is set to '0', the N-PDU Number field either is not present, or, if present, shall not be interpreted.
// When it is set to '1', the N-PDU Number field is present, and shall be interpreted.
pMsg->npduNumFlag = NW_FALSE;
pMsg->npduNum = 0x00;
// Message Type: This field indicates the type of GTP-U message.
pMsg->msgType = NW_GTP_GPDU;
// Length: This field indicates the length in octets of the payload, i.e. the rest of the packet following the
// mandatory part of the GTP header (that is the first 8 octets).
// The Sequence Number, the N-PDU Number or any Extension headers shall be considered to be part of the payload,
// i.e. included in the length count.
//header_len = ((pMsg->seqNumFlag || pMsg->npduNumFlag || pMsg->extHdrFlag ) ?
// NW_GTPV1U_EPC_SPECIFIC_HEADER_SIZE : NW_GTPV1U_EPC_MIN_HEADER_SIZE);
pMsg->msgLen = msgExtraLen + tpduLength;
// Tunnel Endpoint Identifier (TEID): This field unambiguously identifies a tunnel endpoint in the receiving
// GTP-U protocol entity. The receiving end side of a GTP tunnel locally assigns the TEID value the transmitting
// side has to use. The TEID shall be used by the receiving entity to find the PDP context, except for the
// following cases:
// - The Echo Request/Response and Supported Extension Headers notification messages, where the Tunnel
// Endpoint Identifier shall be set to all zeroes.
// - The Error Indication message where the Tunnel Endpoint Identifier shall be set to all zeros.
pMsg->teid = teid;
pMsg->nextExtHdrType= 0x00;
//memcpy(pMsg->msgBuf + header_len, tpdu, tpduLength);
*phMsg = (NwGtpv1uMsgHandleT) pMsg;
return NW_GTPV1U_OK;
}
return NW_GTPV1U_FAILURE;
}
NwGtpv1uRcT
nwGtpv1uMsgFromMsgNew( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NW_IN NwGtpv1uMsgHandleT hMsg,
NW_OUT NwGtpv1uMsgHandleT *phMsg)
{
NwGtpv1uStackT *pStack = (NwGtpv1uStackT *) hGtpuStackHandle;
NwGtpv1uMsgT *pMsg;
if(gpGtpv1uMsgPool) {
pMsg = gpGtpv1uMsgPool;
gpGtpv1uMsgPool = gpGtpv1uMsgPool->next;
} else {
NW_GTPV1U_MALLOC(pStack, sizeof(NwGtpv1uMsgT), pMsg, NwGtpv1uMsgT *);
}
if(pMsg) {
memcpy(pMsg, (NwGtpv1uMsgT *)hMsg, sizeof(NwGtpv1uMsgT));
*phMsg = (NwGtpv1uMsgHandleT) pMsg;
return NW_GTPV1U_OK;
}
return NW_GTPV1U_FAILURE;
}
NwGtpv1uRcT
nwGtpv1uMsgFromBufferNew( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NW_IN uint8_t *pBuf,
NW_IN uint32_t bufLen,
NW_OUT NwGtpv1uMsgHandleT *phMsg)
{
NwGtpv1uStackT *pStack = (NwGtpv1uStackT *) hGtpuStackHandle;
NwGtpv1uMsgT *pMsg;
if(gpGtpv1uMsgPool) {
pMsg = gpGtpv1uMsgPool;
gpGtpv1uMsgPool = gpGtpv1uMsgPool->next;
} else {
NW_GTPV1U_MALLOC(pStack, sizeof(NwGtpv1uMsgT), pMsg, NwGtpv1uMsgT *);
}
if(pMsg) {
pMsg->msgBuf = pBuf;
pMsg->version = ((*pBuf) & 0xE0) >> 5;
pMsg->protocolType = ((*pBuf) & 0x10) >> 4;
pMsg->extHdrFlag = ((*pBuf) & 0x04) >> 2;
pMsg->seqNumFlag = ((*pBuf) & 0x02) >> 1;
pMsg->npduNumFlag = ((*pBuf) & 0x01);
pBuf++;
pMsg->msgType = *(pBuf);
pBuf++;
pBuf += 2;
pMsg->teid = ntohl(*((uint32_t *)pBuf));
pBuf += 4;
if(pMsg->extHdrFlag || pMsg->seqNumFlag || pMsg->npduNumFlag) {
pMsg->seqNum = ntohs(*(((uint16_t *)pBuf)));
pBuf += 2;
pMsg->npduNum = *(pBuf++);
pMsg->nextExtHdrType = *(pBuf++);
}
pMsg->msgBufOffset = (uint32_t)(pBuf - pMsg->msgBuf);
pMsg->msgBufLen = bufLen - pMsg->msgBufOffset;
pMsg->msgLen = bufLen;
#if defined(LOG_GTPU) && LOG_GTPU > 0
GTPU_DEBUG("nwGtpv1uMsgFromBufferNew() msgLen %u msgBufLen %u msgBufOffset %u ",
pMsg->msgLen, pMsg->msgBufLen, pMsg->msgBufOffset);
#endif
*phMsg = (NwGtpv1uMsgHandleT) pMsg;
return NW_GTPV1U_OK;
}
return NW_GTPV1U_FAILURE;
}
NwGtpv1uRcT
nwGtpv1uMsgDelete( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NW_IN NwGtpv1uMsgHandleT hMsg)
{
((NwGtpv1uMsgT *)hMsg)->next = gpGtpv1uMsgPool;
gpGtpv1uMsgPool = (NwGtpv1uMsgT *) hMsg;
return NW_GTPV1U_OK;
}
/**
* Set TEID for gtpv1u message.
*
* @param[in] hMsg : Message handle.
* @param[in] teid: TEID value.
*/
NwGtpv1uRcT
nwGtpv1uMsgSetTeid(NW_IN NwGtpv1uMsgHandleT hMsg, uint32_t teid)
{
NwGtpv1uMsgT *thiz = (NwGtpv1uMsgT *) hMsg;
thiz->teid = teid;
#if defined(LOG_GTPU) && LOG_GTPU > 0
GTPU_DEBUG("nwGtpv1uMsgSetTeid() teid %u", teid);
#endif
return NW_GTPV1U_OK;
}
/**
* Set sequence for gtpv1u message.
*
* @param[in] hMsg : Message handle.
* @param[in] seqNum: Flag boolean value.
*/
NwGtpv1uRcT
nwGtpv1uMsgSetSeqNumber(NW_IN NwGtpv1uMsgHandleT hMsg, uint32_t seqNum)
{
NwGtpv1uMsgT *thiz = (NwGtpv1uMsgT *) hMsg;
thiz->seqNum = seqNum;
return NW_GTPV1U_OK;
}
/**
* Get TEID present for gtpv1u message.
*
* @param[in] hMsg : Message handle.
*/
uint32_t
nwGtpv1uMsgGetTeid(NW_IN NwGtpv1uMsgHandleT hMsg)
{
NwGtpv1uMsgT *thiz = (NwGtpv1uMsgT *) hMsg;
return (thiz->teid);
}
/**
* Get sequence number for gtpv1u message.
*
* @param[in] hMsg : Message handle.
*/
uint32_t
nwGtpv1uMsgGetSeqNumber(NW_IN NwGtpv1uMsgHandleT hMsg)
{
NwGtpv1uMsgT *thiz = (NwGtpv1uMsgT *) hMsg;
return (thiz->seqNum);
}
/**
* Get msg type for gtpv1u message.
*
* @param[in] hMsg : Message handle.
*/
uint32_t
nwGtpv1uMsgGetMsgType(NW_IN NwGtpv1uMsgHandleT hMsg)
{
NwGtpv1uMsgT *thiz = (NwGtpv1uMsgT *) hMsg;
return (thiz->msgType);
}
/**
* Get tpdu for gtpv1u message.
*
* @param[in] hMsg : Message handle.
*/
NwGtpv1uRcT
nwGtpv1uMsgGetTpdu(NW_IN NwGtpv1uMsgHandleT hMsg, uint8_t *pTpduBuf,
uint32_t *pTpduLength)
{
NwGtpv1uMsgT *thiz = (NwGtpv1uMsgT *) hMsg;
uint8_t headerLength = ((thiz->seqNumFlag || thiz->extHdrFlag
|| thiz->npduNumFlag) ? 12 : 8);
*pTpduLength = thiz->msgLen - headerLength;
memcpy(pTpduBuf, thiz->msgBuf + headerLength, *pTpduLength);
return NW_GTPV1U_OK;
}
uint8_t *
nwGtpv1uMsgGetTpduHandle(NW_IN NwGtpv1uMsgHandleT hMsg)
{
NwGtpv1uMsgT *thiz = (NwGtpv1uMsgT *) hMsg;
return (thiz->msgBuf + ((thiz->seqNumFlag || thiz->extHdrFlag
|| thiz->npduNumFlag) ? 12 : 8));
}
uint32_t
nwGtpv1uMsgGetTpduLength(NW_IN NwGtpv1uMsgHandleT hMsg)
{
NwGtpv1uMsgT *thiz = (NwGtpv1uMsgT *) hMsg;
return (thiz->msgLen - ((thiz->seqNumFlag || thiz->extHdrFlag
|| thiz->npduNumFlag) ? 12 : 8));
}
NwGtpv1uRcT
nwGtpv1uMsgAddIeTV1(NW_IN NwGtpv1uMsgHandleT hMsg,
NW_IN uint8_t type,
NW_IN uint8_t value)
{
NwGtpv1uMsgT *pMsg = (NwGtpv1uMsgT *) hMsg;
NwGtpv1uIeTv1T *pIe;
pIe = (NwGtpv1uIeTv1T *) (pMsg->msgBuf + pMsg->msgLen);
pIe->t = type;
pIe->v = value;
pMsg->msgLen += sizeof(NwGtpv1uIeTv1T);
return NW_GTPV1U_OK;
}
NwGtpv1uRcT
nwGtpv1uMsgAddIeTV2(NW_IN NwGtpv1uMsgHandleT hMsg,
NW_IN uint8_t type,
NW_IN uint16_t length,
NW_IN uint16_t value)
{
NwGtpv1uMsgT *pMsg = (NwGtpv1uMsgT *) hMsg;
NwGtpv1uIeTv2T *pIe;
pIe = (NwGtpv1uIeTv2T *) (pMsg->msgBuf + pMsg->msgLen);
pIe->t = type;
pIe->v = htons(value);
pMsg->msgLen += sizeof(NwGtpv1uIeTv2T);
return NW_GTPV1U_OK;
}
NwGtpv1uRcT
nwGtpv1uMsgAddIeTV4(NW_IN NwGtpv1uMsgHandleT hMsg,
NW_IN uint8_t type,
NW_IN uint16_t length,
NW_IN uint32_t value)
{
NwGtpv1uMsgT *pMsg = (NwGtpv1uMsgT *) hMsg;
NwGtpv1uIeTv4T *pIe;
pIe = (NwGtpv1uIeTv4T *) (pMsg->msgBuf + pMsg->msgLen);
pIe->t = type;
pIe->v = htonl(value);
pMsg->msgLen += sizeof(NwGtpv1uIeTv4T);
return NW_GTPV1U_OK;
}
NwGtpv1uRcT
nwGtpv1uMsgAddIe(NW_IN NwGtpv1uMsgHandleT hMsg,
NW_IN uint8_t type,
NW_IN uint16_t length,
NW_IN uint8_t *pVal)
{
NwGtpv1uMsgT *pMsg = (NwGtpv1uMsgT *) hMsg;
NwGtpv1uIeTlvT *pIe;
pIe = (NwGtpv1uIeTlvT *) (pMsg->msgBuf + pMsg->msgLen);
pIe->t = type;
pIe->l = htons(length);
memcpy(pIe + 4, pVal, length);
pMsg->msgLen += (4 + length);
return NW_GTPV1U_OK;
}
NwGtpv1uRcT
nwGtpv1uMsgHexDump(NwGtpv1uMsgHandleT hMsg, FILE *fp)
{
NwGtpv1uMsgT *pMsg = (NwGtpv1uMsgT *) hMsg;
uint8_t *data = pMsg->msgBuf;
uint32_t size = pMsg->msgLen;
unsigned char *p = (unsigned char *)data;
unsigned char c;
int n;
char bytestr[4] = {0};
char addrstr[10] = {0};
char hexstr[ 16*3 + 5] = {0};
char charstr[16*1 + 5] = {0};
fprintf((FILE *)fp, "\n");
for(n=1; n<=size; n++) {
if (n%16 == 1) {
/* store address for this line */
snprintf(addrstr, sizeof(addrstr), "%.4lx",
(p-data) );
}
c = *p;
if (isalnum(c) == 0) {
c = '.';
}
/* store hex str (for left side) */
snprintf(bytestr, sizeof(bytestr), "%02X ", *p);
strncat(hexstr, bytestr, sizeof(hexstr)-strlen(hexstr)-1);
/* store char str (for right side) */
snprintf(bytestr, sizeof(bytestr), "%c", c);
strncat(charstr, bytestr, sizeof(charstr)-strlen(charstr)-1);
if(n%16 == 0) {
/* line completed */
fprintf((FILE *)fp, "[%4.4s] %-50.50s %s\n", addrstr, hexstr, charstr);
hexstr[0] = 0;
charstr[0] = 0;
} else if(n%8 == 0) {
/* half line: add whitespaces */
strncat(hexstr, " ", sizeof(hexstr)-strlen(hexstr)-1);
strncat(charstr, " ", sizeof(charstr)-strlen(charstr)-1);
}
p++; /* next byte */
}
if (strlen(hexstr) > 0) {
/* print rest of buffer if not empty */
fprintf((FILE *)fp, "[%4.4s] %-50.50s %s\n", addrstr, hexstr, charstr);
}
fprintf((FILE *)fp, "\n");
return NW_GTPV1U_OK;
}
#ifdef __cplusplus
}
#endif
/*--------------------------------------------------------------------------*
* E N D O F F I L E *
*--------------------------------------------------------------------------*/
@@ -1,399 +0,0 @@
/*----------------------------------------------------------------------------*
* *
* n w - g t p v 2 u *
* G P R S T u n n e l i n g P r o t o c o l v 2 u S t a c k *
* *
* *
* Copyright (c) 2010-2011 Amit Chawre *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* 3. The name of the author may not be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR *
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES *
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. *
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, *
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT *
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF *
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
*----------------------------------------------------------------------------*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "NwTypes.h"
#include "NwLog.h"
#include "NwUtils.h"
#include "NwGtpv1uLog.h"
#include "NwGtpv1u.h"
#include "NwGtpv1uPrivate.h"
#include "NwGtpv1uTrxn.h"
/*--------------------------------------------------------------------------*
* P R I V A T E D E C L A R A T I O N S *
*--------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C" {
#endif
static NwGtpv1uTrxnT *gpGtpv1uTrxnPool = NULL;
/*--------------------------------------------------------------------------*
* P R I V A T E F U N C T I O N S *
*--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
* Send msg retransmission to peer via data request to UDP Entity
*--------------------------------------------------------------------------*/
static NwGtpv1uRcT
nwGtpv1uTrxnSendMsgRetransmission(NwGtpv1uTrxnT *thiz)
{
NwGtpv1uRcT rc;
NW_ASSERT(thiz);
NW_ASSERT(thiz->pMsg);
rc = thiz->pStack->udp.udpDataReqCallback(thiz->pStack->udp.hUdp,
thiz->pMsg->msgBuf,
thiz->pMsg->msgLen,
thiz->pMsg->msgBufOffset,
thiz->peerIp,
thiz->peerPort);
return rc;
}
static NwGtpv1uRcT
nwGtpv1uTrxnPeerRspTimeout(void *arg)
{
NwGtpv1uRcT rc = NW_GTPV1U_OK;
NwGtpv1uTrxnT *thiz;
NwGtpv1uStackT *pStack;
NwGtpv1uTimeoutInfoT *timeoutInfo = arg;
thiz = ((NwGtpv1uTrxnT *)timeoutInfo->timeoutArg);
pStack = thiz->pStack;
NW_ASSERT(pStack);
NW_LOG(pStack, NW_LOG_LEVEL_WARN, "T3 timer expired for transaction 0x%p",
thiz);
rc = nwGtpv1uTrxnSendMsgRetransmission(thiz);
if(thiz->maxRetries) {
rc = pStack->tmrMgr.tmrStartCallback(pStack->tmrMgr.tmrMgrHandle,
thiz->t3Timer, 0, NW_GTPV1U_TMR_TYPE_ONE_SHOT, (void *)timeoutInfo,
&thiz->hRspTmr);
thiz->maxRetries--;
} else {
NwGtpv1uUlpApiT ulpApi;
ulpApi.apiType = NW_GTPV1U_ULP_API_RSP_FAILURE;
ulpApi.apiInfo.recvMsgInfo.msgType = nwGtpv1uMsgGetMsgType((
NwGtpv1uMsgHandleT)thiz->pMsg);
ulpApi.apiInfo.recvMsgInfo.hUlpTrxn = thiz->hUlpTrxn;
ulpApi.apiInfo.recvMsgInfo.peerIp = thiz->peerIp;
ulpApi.apiInfo.recvMsgInfo.peerPort = thiz->peerPort;
thiz->hRspTmr = 0;
rc = nwGtpv1uTrxnDelete(&thiz);
NW_ASSERT(rc == NW_GTPV1U_OK);
rc = pStack->ulp.ulpReqCallback(pStack->ulp.hUlp, &ulpApi);
NW_ASSERT(rc == NW_GTPV1U_OK);
}
return rc;
}
/**
Send timer start request to TmrMgr Entity.
@param[in] thiz : Pointer to transaction
@param[in] timeoutCallbackFunc : Timeout handler callback function.
@return NW_GTPV1U_OK on success.
*/
static NwGtpv1uRcT
nwGtpv1uTrxnStartPeerRspTimer(NwGtpv1uTrxnT *thiz,
NwGtpv1uRcT (*timeoutCallbackFunc)(void *))
{
NwGtpv1uRcT rc;
NwGtpv1uTimeoutInfoT *timeoutInfo;
NW_ASSERT(thiz->pStack->tmrMgr.tmrStartCallback != NULL);
timeoutInfo = &thiz->peerRspTimeoutInfo;
timeoutInfo->timeoutArg = thiz;
timeoutInfo->timeoutCallbackFunc = timeoutCallbackFunc;
timeoutInfo->hStack = (NwGtpv1uStackHandleT)thiz->pStack;
rc = thiz->pStack->tmrMgr.tmrStartCallback(thiz->pStack->tmrMgr.tmrMgrHandle,
thiz->t3Timer, 0, NW_GTPV1U_TMR_TYPE_ONE_SHOT, (void *)timeoutInfo,
&thiz->hRspTmr);
return rc;
}
/**
Send timer stop request to TmrMgr Entity.
@param[in] thiz : Pointer to transaction
@return NW_GTPV1U_OK on success.
*/
static NwGtpv1uRcT
nwGtpv1uTrxnStopPeerRspTimer(NwGtpv1uTrxnT *thiz)
{
NwGtpv1uRcT rc;
NW_ASSERT(thiz->pStack->tmrMgr.tmrStopCallback != NULL);
rc = thiz->pStack->tmrMgr.tmrStopCallback(thiz->pStack->tmrMgr.tmrMgrHandle,
thiz->hRspTmr);
thiz->hRspTmr = 0;
return rc;
}
/*--------------------------------------------------------------------------*
* P U B L I C F U N C T I O N S *
*--------------------------------------------------------------------------*/
/**
* Constructor
*
* @param[in] thiz : Pointer to stack
* @param[out] ppTrxn : Pointer to pointer to Trxn object.
* @return NW_GTPV1U_OK on success.
*/
NwGtpv1uRcT
nwGtpv1uTrxnNew( NW_IN NwGtpv1uStackT *thiz,
NW_OUT NwGtpv1uTrxnT **ppTrxn)
{
NwGtpv1uRcT rc = NW_GTPV1U_OK;
NwGtpv1uTrxnT *pTrxn;
if(gpGtpv1uTrxnPool) {
pTrxn = gpGtpv1uTrxnPool;
gpGtpv1uTrxnPool = gpGtpv1uTrxnPool->next;
} else {
NW_GTPV1U_MALLOC(thiz, sizeof(NwGtpv1uTrxnT), pTrxn, NwGtpv1uTrxnT *);
}
if (pTrxn) {
pTrxn->maxRetries = 2;
pTrxn->pStack = thiz;
pTrxn->t3Timer = 2;
pTrxn->seqNum = thiz->seq;
/* Increment sequence number */
thiz->seq++;
if(thiz->seq == 0x800000) {
thiz->seq = 0;
}
} else {
rc = NW_GTPV1U_FAILURE;
}
NW_LOG(thiz, NW_LOG_LEVEL_DEBG, "Created transaction 0x%p", pTrxn);
*ppTrxn = pTrxn;
return rc;
}
/**
* Overloaded Constructor
*
* @param[in] thiz : Pointer to stack.
* @param[in] seqNum : Sequence number for this transaction.
* @param[out] ppTrxn : Pointer to pointer to Trxn object.
* @return NW_GTPV1U_OK on success.
*/
NwGtpv1uRcT
nwGtpv1uTrxnWithSeqNew( NW_IN NwGtpv1uStackT *thiz,
NW_IN uint32_t seqNum,
NW_OUT NwGtpv1uTrxnT **ppTrxn)
{
NwGtpv1uRcT rc = NW_GTPV1U_OK;
NwGtpv1uTrxnT *pTrxn;
if(gpGtpv1uTrxnPool) {
pTrxn = gpGtpv1uTrxnPool;
gpGtpv1uTrxnPool = gpGtpv1uTrxnPool->next;
} else {
NW_GTPV1U_MALLOC(thiz, sizeof(NwGtpv1uTrxnT), pTrxn, NwGtpv1uTrxnT *);
}
if (pTrxn) {
pTrxn->maxRetries = 2;
pTrxn->pStack = thiz;
pTrxn->t3Timer = 2;
pTrxn->seqNum = seqNum;
pTrxn->pMsg = NULL;
} else {
rc = NW_GTPV1U_FAILURE;
}
NW_LOG(thiz, NW_LOG_LEVEL_DEBG, "Created transaction 0x%p", pTrxn);
*ppTrxn = pTrxn;
return rc;
}
/**
* Destructor
*
* @param[out] pthiz : Pointer to pointer to Trxn object.
* @return NW_GTPV1U_OK on success.
*/
NwGtpv1uRcT
nwGtpv1uTrxnDelete( NW_INOUT NwGtpv1uTrxnT **pthiz)
{
NwGtpv1uRcT rc = NW_GTPV1U_OK;
NwGtpv1uStackT *pStack;
NwGtpv1uTrxnT *thiz = *pthiz;
pStack = thiz->pStack;
if(thiz->hRspTmr) {
rc = nwGtpv1uTrxnStopPeerRspTimer(thiz);
NW_ASSERT(rc == NW_GTPV1U_OK);
}
if(thiz->pMsg) {
rc = nwGtpv1uMsgDelete((NwGtpv1uStackHandleT)pStack,
(NwGtpv1uMsgHandleT)thiz->pMsg);
NW_ASSERT(rc == NW_GTPV1U_OK);
}
thiz->next = gpGtpv1uTrxnPool;
gpGtpv1uTrxnPool = thiz;
NW_LOG(pStack, NW_LOG_LEVEL_DEBG, "Purged transaction 0x%p", thiz);
*pthiz = NULL;
return rc;
}
#if 1
/**
* Send msg to peer via data request to UDP Entity
*
* @param[in] thiz : Pointer to stack.
* @param[in] pTrxn : Pointer to Trxn object.
* @param[in] peerIp : Peer Ip address.
* @param[in] peerPort : Peer Ip port.
* @param[in] pMsg : Message to be sent.
* @return NW_GTPV1U_OK on success.
*/
NwGtpv1uRcT
nwGtpv1uTrxnCreateAndSendMsg( NW_IN NwGtpv1uStackT *thiz,
NW_IN NwGtpv1uTrxnT *pTrxn,
NW_IN uint32_t peerIp,
NW_IN uint32_t peerPort,
NW_IN NwGtpv1uMsgT *pMsg)
{
NwGtpv1uRcT rc;
uint8_t *msgHdr;
NW_ASSERT(thiz);
NW_ASSERT(pMsg);
msgHdr = &pMsg->msgBuf[pMsg->msgBufOffset];
NW_ASSERT(msgHdr != NULL);
*(msgHdr++) = (pMsg->version << 5) |
(pMsg->protocolType << 4) |
(pMsg->extHdrFlag << 2) |
(pMsg->seqNumFlag << 1) |
(pMsg->npduNumFlag);
*(msgHdr++) = (pMsg->msgType);
*((uint16_t *) msgHdr) = htons(pMsg->msgLen);
msgHdr += 2;
*((uint32_t *) msgHdr) = htonl(pMsg->teid);
msgHdr += 4;
if(pMsg->seqNumFlag | pMsg->extHdrFlag | pMsg->npduNumFlag) {
if(pMsg->seqNumFlag) {
*((uint16_t *) msgHdr) = htons((pTrxn ? pTrxn->seqNum : pMsg->seqNum));
} else {
*((uint16_t *) msgHdr) = 0x0000;
}
msgHdr += 2;
if(pMsg->npduNumFlag) {
*((uint8_t *) msgHdr) = pMsg->npduNumFlag;
} else {
*((uint8_t *) msgHdr) = 0x00;
}
msgHdr++;
if(pMsg->extHdrFlag) {
*((uint8_t *) msgHdr) = pMsg->extHdrFlag;
} else {
*((uint8_t *) msgHdr) = 0x00;
}
msgHdr++;
}
NW_ASSERT(thiz->udp.udpDataReqCallback != NULL);
rc = thiz->udp.udpDataReqCallback(thiz->udp.hUdp,
pMsg->msgBuf,
pMsg->msgLen,
pMsg->msgBufOffset,
peerIp,
peerPort);
/* Save the message for retransmission */
if(rc == NW_GTPV1U_OK && pTrxn) {
pTrxn->pMsg = pMsg;
pTrxn->peerIp = peerIp;
pTrxn->peerPort = peerPort;
rc = nwGtpv1uTrxnStartPeerRspTimer(pTrxn, nwGtpv1uTrxnPeerRspTimeout);
NW_ASSERT(rc == NW_GTPV1U_OK);
}
return rc;
}
#endif
#ifdef __cplusplus
}
#endif
/*--------------------------------------------------------------------------*
* E N D O F F I L E *
*--------------------------------------------------------------------------*/
@@ -1,135 +0,0 @@
/*----------------------------------------------------------------------------*
* *
* n w - g t p v 2 u *
* G P R S T u n n e l i n g P r o t o c o l v 2 u S t a c k *
* *
* *
* Copyright (c) 2010-2011 Amit Chawre *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* 3. The name of the author may not be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR *
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES *
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. *
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, *
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT *
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF *
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
*----------------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "NwTypes.h"
#include "NwUtils.h"
#include "NwGtpv1uError.h"
#include "NwGtpv1uPrivate.h"
#include "NwGtpv1uMsg.h"
#include "NwGtpv1uTunnelEndPoint.h"
#include "NwGtpv1u.h"
#include "NwGtpv1uLog.h"
#ifdef __cplusplus
extern "C" {
#endif
/*--------------------------------------------------------------------------*
* P R I V A T E D E C L A R A T I O N S *
*--------------------------------------------------------------------------*/
static NwGtpv1uTunnelEndPointT *gpTunnelEndPointPool = NULL;
/*--------------------------------------------------------------------------*
* P U B L I C F U N C T I O N S *
*--------------------------------------------------------------------------*/
/**
Constructor
@param[in] msid: MSID
@param[in] peerAddr: Address of the peer.
@return Pointer to Session on success, NULL on failure.
*/
NwGtpv1uTunnelEndPointT *
nwGtpTunnelEndPointNew(struct NwGtpv1uStack *pStack)
{
NwGtpv1uTunnelEndPointT *thiz;
if(gpTunnelEndPointPool) {
thiz = gpTunnelEndPointPool;
gpTunnelEndPointPool = gpTunnelEndPointPool->next;
} else {
NW_GTPV1U_MALLOC(pStack, sizeof(NwGtpv1uTunnelEndPointT), thiz,
NwGtpv1uTunnelEndPointT *);
}
return thiz;
}
/**
Destructor
@param[in] thiz: Pointer to session
@return NW_GTPV1U_OK on success.
*/
NwGtpv1uRcT
nwGtpTunnelEndPointDestroy(struct NwGtpv1uStack *pStack,
NwGtpv1uTunnelEndPointT *thiz)
{
thiz->next = gpTunnelEndPointPool;
gpTunnelEndPointPool = thiz;
return NW_GTPV1U_OK;
}
/**
Purge a Transaction for a Session.
@param[in] thiz: Pointer to session
@param[in,out] pTrxn: Pointer to the trxn.
@return NW_GTPV1U_OK on success.
*/
NwGtpv1uRcT
nwGtpSessionSendMsgApiToUlpEntity(NwGtpv1uTunnelEndPointT *thiz,
NwGtpv1uMsgT *pMsg)
{
NwGtpv1uRcT rc = NW_GTPV1U_OK;
NwGtpv1uUlpApiT api;
api.apiType = NW_GTPV1U_ULP_API_RECV_TPDU;
api.apiInfo.recvMsgInfo.hUlpSession = thiz->hUlpSession;
api.apiInfo.recvMsgInfo.teid = thiz->teid;
api.apiInfo.recvMsgInfo.hMsg = (NwGtpv1uMsgHandleT)pMsg;
NW_ASSERT(thiz->pStack->ulp.ulpReqCallback != NULL);
thiz->pStack->ulp.ulpReqCallback(thiz->pStack->ulp.hUlp, &api);
return rc;
}
#ifdef __cplusplus
}
#endif
/*--------------------------------------------------------------------------*
* E N D O F F I L E *
*--------------------------------------------------------------------------*/
@@ -1,5 +0,0 @@
# this is example-file: Makefile.am
# the subdirectories of the project to go into
SUBDIRS = \
nw-helloworld
@@ -1,461 +0,0 @@
# Makefile.in generated by automake 1.10.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
# this is example-file: Makefile.am
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
subdir = nw-gtpv1u/test-app
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_CLEAN_FILES =
SOURCES =
DIST_SOURCES =
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
html-recursive info-recursive install-data-recursive \
install-dvi-recursive install-exec-recursive \
install-html-recursive install-info-recursive \
install-pdf-recursive install-ps-recursive install-recursive \
installcheck-recursive installdirs-recursive pdf-recursive \
ps-recursive uninstall-recursive
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_CFLAGS = @AM_CFLAGS@
AM_LDFLAGS = @AM_LDFLAGS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build_alias = @build_alias@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host_alias = @host_alias@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
# the subdirectories of the project to go into
SUBDIRS = \
nw-helloworld
all: all-recursive
.SUFFIXES:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu nw-gtpv1u/test-app/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu nw-gtpv1u/test-app/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
# (1) if the variable is set in `config.status', edit `config.status'
# (which will cause the Makefiles to be regenerated when you run `make');
# (2) otherwise, pass the desired values on the `make' command line.
$(RECURSIVE_TARGETS):
@failcom='exit 1'; \
for f in x $$MAKEFLAGS; do \
case $$f in \
*=* | --[!k]*);; \
*k*) failcom='fail=yes';; \
esac; \
done; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
$(RECURSIVE_CLEAN_TARGETS):
@failcom='exit 1'; \
for f in x $$MAKEFLAGS; do \
case $$f in \
*=* | --[!k]*);; \
*k*) failcom='fail=yes';; \
esac; \
done; \
dot_seen=no; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
rev=''; for subdir in $$list; do \
if test "$$subdir" = "."; then :; else \
rev="$$subdir $$rev"; \
fi; \
done; \
rev="$$rev ."; \
target=`echo $@ | sed s/-recursive//`; \
for subdir in $$rev; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done && test -z "$$fail"
tags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
done
ctags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
done
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -d "$(distdir)/$$subdir" \
|| $(MKDIR_P) "$(distdir)/$$subdir" \
|| exit 1; \
distdir=`$(am__cd) $(distdir) && pwd`; \
top_distdir=`$(am__cd) $(top_distdir) && pwd`; \
(cd $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$$top_distdir" \
distdir="$$distdir/$$subdir" \
am__remove_distdir=: \
am__skip_length_check=: \
distdir) \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-recursive
all-am: Makefile
installdirs: installdirs-recursive
installdirs-am:
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-recursive
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-recursive
clean-am: clean-generic mostlyclean-am
distclean: distclean-recursive
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-tags
dvi: dvi-recursive
dvi-am:
html: html-recursive
info: info-recursive
info-am:
install-data-am:
install-dvi: install-dvi-recursive
install-exec-am:
install-html: install-html-recursive
install-info: install-info-recursive
install-man:
install-pdf: install-pdf-recursive
install-ps: install-ps-recursive
installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-generic
pdf: pdf-recursive
pdf-am:
ps: ps-recursive
ps-am:
uninstall-am:
.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \
install-strip
.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
all all-am check check-am clean clean-generic ctags \
ctags-recursive distclean distclean-generic distclean-tags \
distdir dvi dvi-am html html-am info info-am install \
install-am install-data install-data-am install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am install-man \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
installdirs-am maintainer-clean maintainer-clean-generic \
mostlyclean mostlyclean-generic pdf pdf-am ps ps-am tags \
tags-recursive uninstall uninstall-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
@@ -1,17 +0,0 @@
bin_PROGRAMS = helloworld
AM_CFLAGS = -D__WITH_LIBEVENT__ -I../../shared -I../../include -I../../test-app/nw-udp -I../../test-app/nw-log @AM_CFLAGS@
helloworld_SOURCES = \
NwEvt.h\
NwMiniLogMgrEntity.h\
NwMiniTmrMgrEntity.h\
NwMiniUlpEntity.h\
NwMiniUdpEntity.h\
NwMiniLogMgrEntity.c\
NwMiniTmrMgrEntity.c\
NwMiniUlpEntity.c\
NwMiniUdpEntity.c\
helloworld.c
helloworld_LDADD = ../../src/libNwGtpv1u.a -levent $(AM_LDFLAGS)
@@ -1,433 +0,0 @@
# Makefile.in generated by automake 1.10.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
bin_PROGRAMS = helloworld$(EXEEXT)
subdir = nw-gtpv1u/test-app/nw-helloworld
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_CLEAN_FILES =
am__installdirs = "$(DESTDIR)$(bindir)"
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
PROGRAMS = $(bin_PROGRAMS)
am_helloworld_OBJECTS = NwMiniLogMgrEntity.$(OBJEXT) \
NwMiniTmrMgrEntity.$(OBJEXT) NwMiniUlpEntity.$(OBJEXT) \
NwMiniUdpEntity.$(OBJEXT) helloworld.$(OBJEXT)
helloworld_OBJECTS = $(am_helloworld_OBJECTS)
am__DEPENDENCIES_1 =
helloworld_DEPENDENCIES = ../../src/libNwGtpv1u.a \
$(am__DEPENDENCIES_1)
DEFAULT_INCLUDES = -I.@am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(helloworld_SOURCES)
DIST_SOURCES = $(helloworld_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_CFLAGS = -D__WITH_LIBEVENT__ -I../../shared -I../../include -I../../test-app/nw-udp -I../../test-app/nw-log @AM_CFLAGS@
AM_LDFLAGS = @AM_LDFLAGS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build_alias = @build_alias@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host_alias = @host_alias@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
helloworld_SOURCES = \
NwEvt.h\
NwMiniLogMgrEntity.h\
NwMiniTmrMgrEntity.h\
NwMiniUlpEntity.h\
NwMiniUdpEntity.h\
NwMiniLogMgrEntity.c\
NwMiniTmrMgrEntity.c\
NwMiniUlpEntity.c\
NwMiniUdpEntity.c\
helloworld.c
helloworld_LDADD = ../../src/libNwGtpv1u.a -levent $(AM_LDFLAGS)
all: all-am
.SUFFIXES:
.SUFFIXES: .c .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu nw-gtpv1u/test-app/nw-helloworld/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu nw-gtpv1u/test-app/nw-helloworld/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
@list='$(bin_PROGRAMS)'; for p in $$list; do \
p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
if test -f $$p \
; then \
f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
$(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
else :; fi; \
done
uninstall-binPROGRAMS:
@$(NORMAL_UNINSTALL)
@list='$(bin_PROGRAMS)'; for p in $$list; do \
f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
rm -f "$(DESTDIR)$(bindir)/$$f"; \
done
clean-binPROGRAMS:
-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
helloworld$(EXEEXT): $(helloworld_OBJECTS) $(helloworld_DEPENDENCIES)
@rm -f helloworld$(EXEEXT)
$(LINK) $(helloworld_OBJECTS) $(helloworld_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/NwMiniLogMgrEntity.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/NwMiniTmrMgrEntity.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/NwMiniUdpEntity.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/NwMiniUlpEntity.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/helloworld.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
.c.obj:
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(PROGRAMS)
installdirs:
for dir in "$(DESTDIR)$(bindir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-binPROGRAMS clean-generic mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-exec-am: install-binPROGRAMS
install-html: install-html-am
install-info: install-info-am
install-man:
install-pdf: install-pdf-am
install-ps: install-ps-am
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-binPROGRAMS
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
clean-generic ctags distclean distclean-compile \
distclean-generic distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-binPROGRAMS \
install-data install-data-am install-dvi install-dvi-am \
install-exec install-exec-am install-html install-html-am \
install-info install-info-am install-man install-pdf \
install-pdf-am install-ps install-ps-am install-strip \
installcheck installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
uninstall-am uninstall-binPROGRAMS
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
@@ -1,80 +0,0 @@
/*----------------------------------------------------------------------------*
* *
* Copyright (c) 2010-2011 Amit Chawre *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* 3. The name of the author may not be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR *
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES *
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. *
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, *
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT *
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF *
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
*----------------------------------------------------------------------------*/
#ifndef __NW_EVT_H__
#define __NW_EVT_H__
/**
* @file NwEvt.h
* @brief
*/
#ifdef __WITH_LIBEVENT__
#include <event.h>
typedef struct event NwEventT;
#define NW_EVT_READ (EV_READ)
#define NW_EVT_PERSIST (EV_PERSIST)
#define NW_EVT_CALLBACK(__cbFunc) __cbFunc(int fd, short event, void *arg)
#define NW_TMR_CALLBACK(__cbFunc) __cbFunc(int fd, short event, void *arg)
#define NW_EVT_INIT event_init
#define NW_EVT_LOOP event_dispatch
#define NW_EVENT_ADD(__ev, __evSelObj, __evCallback, __evCallbackArg, __evFlags) \
do { \
event_set(&(__ev), __evSelObj, __evFlags, __evCallback, __evCallbackArg); \
event_add(&(__ev), NULL); \
} while(0)
#else
#warning "Event library not defined!"
/* HACK : Defining dummy values for compilation!*/
typedef struct {
int __tbd;
} NwEventT;
#define NW_EVT_READ (0)
#define NW_EVT_PERSIST (1)
#define NW_EVT_CALLBACK(__cbFunc) __cbFunc(void *arg)
#define NW_TMR_CALLBACK(__cbFunc) __cbFunc(void *arg)
#define NW_EVT_INIT() do { printf("error: Event library not defined!\n"); exit (0); } while(0)
#define NW_EVT_LOOP() do { printf("error: Event library not defined!\n"); exit (0); } while(0)
#define NW_EVENT_ADD(...) do { printf("error: Event library not defined!\n"); exit (0); } while(0)
#endif
#endif /* __NW_EVT_H__ */
@@ -1,62 +0,0 @@
/*----------------------------------------------------------------------------*
* *
* M I N I M A L I S T I C L O G M G R E N T I T Y *
* *
* Copyright (C) 2010 Amit Chawre. *
* *
*----------------------------------------------------------------------------*/
/**
* @file hello-world.c
* @brief This file contains example of a minimalistic log manager entity.
*/
#include <stdio.h>
#include <assert.h>
#include "NwLog.h"
#include "NwEvt.h"
#include "NwGtpv1u.h"
#include "NwMiniLogMgrEntity.h"
#ifdef __cplusplus
extern "C" {
#endif
uint32_t g_log_level = NW_LOG_LEVEL_INFO;
/*---------------------------------------------------------------------------
* Public functions
*--------------------------------------------------------------------------*/
NwGtpv1uRcT nwMiniLogMgrInit(NwMiniLogMgrT *thiz, uint32_t logLevel )
{
thiz->logLevel = logLevel;
return NW_GTPV1U_OK;
}
NwGtpv1uRcT nwMiniLogMgrSetLogLevel(NwMiniLogMgrT *thiz, uint32_t logLevel)
{
thiz->logLevel = logLevel;
}
NwGtpv1uRcT nwMiniLogMgrLogRequest (NwGtpv1uLogMgrHandleT hLogMgr,
uint32_t logLevel,
NwCharT *file,
uint32_t line,
NwCharT *logStr)
{
NwMiniLogMgrT *thiz = (NwMiniLogMgrT *) hLogMgr;
if(thiz->logLevel >= logLevel) {
printf("NWGTPv2U-STK %s - %s <%s,%u>\n", gLogLevelStr[logLevel], logStr,
basename(file), line);
}
return NW_GTPV1U_OK;
}
#ifdef __cplusplus
}
#endif
@@ -1,57 +0,0 @@
/*----------------------------------------------------------------------------*
* *
* M I N I M A L I S T I C L O G M G R E N T I T Y *
* *
* Copyright (C) 2010 Amit Chawre. *
* *
*----------------------------------------------------------------------------*/
/**
* @file hello-world.c
* @brief This file contains example of a minimalistic log manager entity.
*/
#include <stdio.h>
#include <assert.h>
#include "NwEvt.h"
#include "NwLog.h"
#ifndef __NW_MINI_LOG_MGR_H__
#define __NW_MINI_LOG_MGR_H__
#ifndef NW_ASSERT
#define NW_ASSERT assert
#endif
extern uint32_t g_log_level;
#define NW_LOG( _logLevel, ...) \
do { \
if(g_log_level >= _logLevel) \
{ \
char _logStr[1024]; \
snprintf(_logStr, 1024, __VA_ARGS__); \
printf("NWGTPv2U-APP %s - %s <%s,%d>\n", gLogLevelStr[_logLevel], _logStr, basename(__FILE__), __LINE__);\
} \
} while(0)
typedef struct {
uint8_t logLevel;
} NwMiniLogMgrT;
#ifdef __cplusplus
extern "C" {
#endif
NwGtpv1uRcT nwMiniLogMgrLogRequest (NwGtpv1uLogMgrHandleT logMgrHandle,
uint32_t logLevel,
NwCharT* file,
uint32_t line,
NwCharT* logStr);
#ifdef __cplusplus
}
#endif
#endif
@@ -1,101 +0,0 @@
/*----------------------------------------------------------------------------*
* *
* M I N I M A L I S T I C T M R M G R E N T I T Y *
* *
* Copyright (C) 2010 Amit Chawre. *
* *
*----------------------------------------------------------------------------*/
/**
* @file NwMiniTmrMgrEntity.c
* @brief This file ontains example of a minimalistic timer manager entity.
*/
#include <stdio.h>
#include <assert.h>
#include "NwEvt.h"
#include "NwGtpv1u.h"
#include "NwMiniLogMgrEntity.h"
#include "NwMiniTmrMgrEntity.h"
#ifndef NW_ASSERT
#define NW_ASSERT assert
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*---------------------------------------------------------------------------
* Private functions
*--------------------------------------------------------------------------*/
static void
NW_TMR_CALLBACK(nwMiniTmrMgrHandleTimeout)
{
NwGtpv1uRcT rc;
NwMiniTmrMgrEntityT *pTmr = (NwMiniTmrMgrEntityT *) arg;
/*---------------------------------------------------------------------------
* Send Timeout Request to GTPv1u Stack Instance
*--------------------------------------------------------------------------*/
rc = nwGtpv1uProcessTimeout(pTmr->timeoutArg);
NW_ASSERT( rc == NW_GTPV1U_OK );
free(pTmr);
return;
}
/*---------------------------------------------------------------------------
* Public functions
*--------------------------------------------------------------------------*/
NwGtpv1uRcT nwTimerStart( NwGtpv1uTimerMgrHandleT tmrMgrHandle,
uint32_t timeoutSec,
uint32_t timeoutUsec,
uint32_t tmrType,
void *timeoutArg,
NwGtpv1uTimerHandleT *hTmr)
{
NwGtpv1uRcT rc = NW_GTPV1U_OK;
NwMiniTmrMgrEntityT *pTmr;
struct timeval tv;
NW_LOG(NW_LOG_LEVEL_INFO,
"Received start timer request from stack with timer type %d , arg %x, for %d sec and %d usec",
tmrType, (unsigned int)timeoutArg, timeoutSec, timeoutUsec);
pTmr = (NwMiniTmrMgrEntityT *) malloc (sizeof(NwMiniTmrMgrEntityT));
/* set the timevalues*/
timerclear(&tv);
tv.tv_sec = timeoutSec;
tv.tv_usec = timeoutUsec;
pTmr->timeoutArg = timeoutArg;
evtimer_set(&pTmr->ev, nwMiniTmrMgrHandleTimeout, pTmr);
/*add event*/
event_add(&(pTmr->ev), &tv);
*hTmr = (NwGtpv1uTimerHandleT)pTmr;
return rc;
}
NwGtpv1uRcT nwTimerStop( NwGtpv1uTimerMgrHandleT tmrMgrHandle,
NwGtpv1uTimerHandleT hTmr)
{
NW_LOG(NW_LOG_LEVEL_INFO,
"Received stop timer request from stack for timer handle %d", hTmr);
evtimer_del(&(((NwMiniTmrMgrEntityT *)hTmr)->ev));
free((void *)hTmr);
return NW_GTPV1U_OK;
}
#ifdef __cplusplus
}
#endif
@@ -1,53 +0,0 @@
/*----------------------------------------------------------------------------*
* *
* M I N I M A L I S T I C T M R M G R E N T I T Y *
* *
* Copyright (C) 2010 Amit Chawre. *
* *
*----------------------------------------------------------------------------*/
/**
* @file NwMiniTmrMgrEntity.c
* @brief This file ontains example of a minimalistic timer manager entity.
*/
#include <stdio.h>
#include <assert.h>
#include "NwEvt.h"
#include "NwLog.h"
#ifndef __NW_MINI_TMR_MGR_H__
#define __NW_MINI_TMR_MGR_H__
#ifndef NW_ASSERT
#define NW_ASSERT assert
#endif
typedef struct {
NwEventT ev;
void* timeoutArg;
} NwMiniTmrMgrEntityT;
#ifdef __cplusplus
extern "C" {
#endif
NwGtpv1uRcT nwTimerStart( NwGtpv1uTimerMgrHandleT tmrMgrHandle,
uint32_t timeoutSec,
uint32_t timeoutUsec,
uint32_t tmrType,
void* timeoutArg,
NwGtpv1uTimerHandleT* hTmr);
NwGtpv1uRcT nwTimerStop( NwGtpv1uTimerMgrHandleT tmrMgrHandle,
NwGtpv1uTimerHandleT hTmr);
#ifdef __cplusplus
}
#endif
#endif
@@ -1,157 +0,0 @@
/*----------------------------------------------------------------------------*
* *
* M I N I M A L I S T I C U D P E N T I T Y *
* *
* Copyright (C) 2010 Amit Chawre. *
* *
*----------------------------------------------------------------------------*/
/**
* @file NwMiniUdpEntity.c
* @brief This file contains example of a minimalistic ULP entity.
*/
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include "NwEvt.h"
#include "NwGtpv1u.h"
#include "NwMiniLogMgrEntity.h"
#include "NwMiniUdpEntity.h"
#ifndef NW_ASSERT
#define NW_ASSERT assert
#endif
#define MAX_UDP_PAYLOAD_LEN (4096)
#ifdef __cplusplus
extern "C" {
#endif
/*---------------------------------------------------------------------------
* Private functions
*--------------------------------------------------------------------------*/
static
void NW_TMR_CALLBACK(nwUdpDataIndicationCallbackData)
{
NwGtpv1uRcT rc;
uint8_t udpBuf[MAX_UDP_PAYLOAD_LEN];
NwS32T bytesRead;
uint32_t peerLen;
struct sockaddr_in peer;
NwMiniUdpEntityT *thiz = (NwMiniUdpEntityT *) arg;
peerLen = sizeof(peer);
bytesRead = recvfrom(thiz->hSocket, udpBuf, MAX_UDP_PAYLOAD_LEN , 0,
(struct sockaddr *) &peer,(socklen_t *) &peerLen);
if(bytesRead) {
NW_LOG(NW_LOG_LEVEL_DEBG, "Received UDP message of length %u from %X:%u",
bytesRead, ntohl(peer.sin_addr.s_addr), ntohs(peer.sin_port));
rc = nwGtpv1uProcessUdpReq(thiz->hGtpv1uStack, udpBuf, bytesRead,
peer.sin_port, peer.sin_addr.s_addr);
} else {
NW_LOG(NW_LOG_LEVEL_ERRO, "%s", strerror(errno));
}
}
/*---------------------------------------------------------------------------
* Public functions
*--------------------------------------------------------------------------*/
NwGtpv1uRcT nwMiniUdpInit(NwMiniUdpEntityT *thiz,
NwGtpv1uStackHandleT hGtpv1uStack, uint8_t *ipAddr)
{
int sd;
struct sockaddr_in addr;
sd = socket(AF_INET, SOCK_DGRAM, 0);
if (sd < 0) {
NW_LOG(NW_LOG_LEVEL_ERRO, "%s", strerror(errno));
NW_ASSERT(0);
}
addr.sin_family = AF_INET;
addr.sin_port = htons(2152);
addr.sin_addr.s_addr = inet_addr(ipAddr);
memset(addr.sin_zero, '\0', sizeof (addr.sin_zero));
if(bind(sd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
NW_LOG(NW_LOG_LEVEL_ERRO, "%s", strerror(errno));
NW_ASSERT(0);
}
event_set(&(thiz->ev), sd, EV_READ|EV_PERSIST, nwUdpDataIndicationCallbackData,
thiz);
event_add(&(thiz->ev), NULL);
thiz->hSocket = sd;
thiz->hGtpv1uStack = hGtpv1uStack;
return NW_GTPV1U_OK;
}
NwGtpv1uRcT nwMiniUdpDestroy(NwMiniUdpEntityT *thiz)
{
close(thiz->hSocket);
}
NwGtpv1uRcT nwMiniUdpDataReq(NwGtpv1uUdpHandleT udpHandle,
uint8_t *dataBuf,
uint32_t dataSize,
uint32_t peerIpAddr,
uint32_t peerPort)
{
struct sockaddr_in peerAddr;
NwS32T bytesSent;
NwMiniUdpEntityT *thiz = (NwMiniUdpEntityT *) udpHandle;
peerAddr.sin_family = AF_INET;
peerAddr.sin_port = htons(peerPort);
peerAddr.sin_addr.s_addr = (peerIpAddr);
memset(peerAddr.sin_zero, '\0', sizeof (peerAddr.sin_zero));
NW_LOG(NW_LOG_LEVEL_DEBG,
"Sending %u bytes on handle 0x%x to peer %u.%u.%u.%u:%u", dataSize, udpHandle,
(peerIpAddr & 0x000000ff),
(peerIpAddr & 0x0000ff00) >> 8,
(peerIpAddr & 0x00ff0000) >> 16,
(peerIpAddr & 0xff000000) >> 24,
peerPort);
bytesSent = sendto (thiz->hSocket, dataBuf, dataSize, 0,
(struct sockaddr *) &peerAddr, sizeof(peerAddr));
if(bytesSent < 0) {
NW_LOG(NW_LOG_LEVEL_ERRO, "%s", strerror(errno));
} else {
NW_LOG(NW_LOG_LEVEL_DEBG, "Sent %u bytes on handle 0x%x to peer %u.%u.%u.%u",
dataSize, udpHandle,
(peerIpAddr & 0x000000ff),
(peerIpAddr & 0x0000ff00) >> 8,
(peerIpAddr & 0x00ff0000) >> 16,
(peerIpAddr & 0xff000000) >> 24);
}
return NW_GTPV1U_OK;
}
#ifdef __cplusplus
}
#endif
@@ -1,51 +0,0 @@
/*----------------------------------------------------------------------------*
* *
* M I N I M A L I S T I C U D P E N T I T Y *
* *
* Copyright (C) 2010 Amit Chawre. *
* *
*----------------------------------------------------------------------------*/
/**
* @file NwMiniUdpEntity.h
* @brief This file contains example of a minimalistic ULP entity.
*/
#include <stdio.h>
#include <assert.h>
#include "NwEvt.h"
#include "NwLog.h"
#ifndef __NW_MINI_UDP_ENTITY_H__
#define __NW_MINI_UDP_ENTITY_H__
#ifndef NW_ASSERT
#define NW_ASSERT assert
#endif
typedef struct {
uint32_t hSocket;
NwEventT ev;
NwGtpv1uStackHandleT hGtpv1uStack;
} NwMiniUdpEntityT;
#ifdef __cplusplus
extern "C" {
#endif
NwGtpv1uRcT nwMiniUdpInit(NwMiniUdpEntityT* thiz, NwGtpv1uStackHandleT hGtpv1uStack, uint8_t* ipAddr);
NwGtpv1uRcT nwMiniUdpDestroy(NwMiniUdpEntityT* thiz);
NwGtpv1uRcT nwMiniUdpDataReq(NwGtpv1uUdpHandleT udpHandle,
uint8_t* dataBuf,
uint32_t dataSize,
uint32_t peerAddr,
uint32_t peerPort);
#ifdef __cplusplus
}
#endif
#endif
@@ -1,309 +0,0 @@
/*----------------------------------------------------------------------------*
* *
* M I N I M A L I S T I C U L P E N T I T Y *
* *
* Copyright (C) 2010 Amit Chawre. *
* *
*----------------------------------------------------------------------------*/
/**
* @file NwMiniUlpEntity.c
* @brief This file contains example of a minimalistic ULP entity.
*/
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
#include "NwEvt.h"
#include "NwGtpv1u.h"
#include "NwGtpv1uIe.h"
#include "NwMiniLogMgrEntity.h"
#include "NwMiniUlpEntity.h"
#ifndef NW_ASSERT
#define NW_ASSERT assert
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*---------------------------------------------------------------------------
* Private Functions
*--------------------------------------------------------------------------*/
#define MAX_UDP_PAYLOAD_LEN (4096)
NwGtpv1uRcT
nwMiniUlpSendEchoRequestToPeer(NwMiniUlpEntityT *thiz, uint32_t peerIp)
{
NwGtpv1uRcT rc;
NwGtpv1uUlpApiT ulpReq;
/*
* Send Message Request to Gtpv1u Stack Instance
*/
ulpReq.apiType = NW_GTPV1U_ULP_API_INITIAL_REQ;
ulpReq.apiInfo.initialReqInfo.hUlpTrxn = (NwGtpv1uUlpTrxnHandleT)thiz;
ulpReq.apiInfo.initialReqInfo.teid = 0x00;
ulpReq.apiInfo.initialReqInfo.peerIp = (peerIp);
ulpReq.apiInfo.initialReqInfo.peerPort = 2152;
/* Send Echo Request*/
rc = nwGtpv1uMsgNew( thiz->hGtpv1uStack,
NW_TRUE, /* SeqNum flag */
NW_FALSE,
NW_FALSE,
NW_GTP_ECHO_REQ, /* Msg Type */
0x00000000UL, /* TEID */
0x5678, /* Seq Number */
0,
0,
(&ulpReq.hMsg));
NW_ASSERT( rc == NW_GTPV1U_OK );
rc = nwGtpv1uMsgAddIeTV1((ulpReq.hMsg), NW_GTPV1U_IE_RECOVERY,
thiz->restartCounter);
NW_ASSERT( rc == NW_GTPV1U_OK );
rc = nwGtpv1uProcessUlpReq(thiz->hGtpv1uStack, &ulpReq);
NW_ASSERT( rc == NW_GTPV1U_OK );
return NW_GTPV1U_OK;
}
static
void NW_EVT_CALLBACK(nwMiniUlpDataIndicationCallbackData)
{
NwMiniUlpEntityT *thiz = (NwMiniUlpEntityT *) arg;
NwGtpv1uRcT rc;
uint8_t udpBuf[MAX_UDP_PAYLOAD_LEN];
NwS32T bytesRead;
uint32_t peerLen;
struct sockaddr_in peer;
peerLen = sizeof(peer);
bytesRead = recvfrom(thiz->hSocket, udpBuf, MAX_UDP_PAYLOAD_LEN , 0,
(struct sockaddr *) &peer,(socklen_t *) &peerLen);
if(bytesRead) {
NW_LOG(NW_LOG_LEVEL_DEBG, "Received UDP message of length %u from %X:%u",
bytesRead, ntohl(peer.sin_addr.s_addr), ntohs(peer.sin_port));
rc = nwMiniUlpTpduSend(thiz, udpBuf, bytesRead, thiz->localPort[fd]);
} else {
NW_LOG(NW_LOG_LEVEL_ERRO, "%s", strerror(errno));
}
}
/*---------------------------------------------------------------------------
* Public Functions
*--------------------------------------------------------------------------*/
NwGtpv1uRcT
nwMiniUlpInit(NwMiniUlpEntityT *thiz, NwGtpv1uStackHandleT hGtpv1uStack)
{
NwGtpv1uRcT rc;
thiz->hGtpv1uStack = hGtpv1uStack;
return NW_GTPV1U_OK;
}
NwGtpv1uRcT
nwMiniUlpDestroy(NwMiniUlpEntityT *thiz)
{
NW_ASSERT(thiz);
memset(thiz, 0, sizeof(NwMiniUlpEntityT));
return NW_GTPV1U_OK;
}
NwGtpv1uRcT
nwMiniUlpCreateConn(NwMiniUlpEntityT *thiz, char *localIpStr, uint16_t localport,
char *peerIpStr)
{
NwGtpv1uRcT rc;
int sd;
struct sockaddr_in addr;
NwGtpv1uUlpApiT ulpReq;
strcpy(thiz->peerIpStr, peerIpStr);
/*
* Create local tunnel endpoint
*/
NW_LOG(NW_LOG_LEVEL_NOTI, "Creating tunnel endpoint with teid %d", localport);
ulpReq.apiType =
NW_GTPV1U_ULP_API_CREATE_TUNNEL_ENDPOINT;
ulpReq.apiInfo.createTunnelEndPointInfo.teid = localport;
ulpReq.apiInfo.createTunnelEndPointInfo.hUlpSession =
(NwGtpv1uUlpSessionHandleT)thiz;
rc = nwGtpv1uProcessUlpReq(thiz->hGtpv1uStack, &ulpReq);
NW_ASSERT( rc == NW_GTPV1U_OK );
thiz->hGtpv1uConn = ulpReq.apiInfo.createTunnelEndPointInfo.hStackSession;
/*
* Create local udp listening endpoint
*/
sd = socket(AF_INET, SOCK_DGRAM, 0);
if (sd < 0) {
NW_LOG(NW_LOG_LEVEL_ERRO, "%s", strerror(errno));
NW_ASSERT(0);
}
addr.sin_family = AF_INET;
addr.sin_port = htons(localport);
addr.sin_addr.s_addr = inet_addr(localIpStr);
memset(addr.sin_zero, '\0', sizeof (addr.sin_zero));
if(bind(sd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
NW_LOG(NW_LOG_LEVEL_ERRO, "%s", strerror(errno));
NW_ASSERT(0);
}
event_set(&(thiz->ev[sd]), sd, EV_READ|EV_PERSIST,
nwMiniUlpDataIndicationCallbackData, thiz);
event_add(&(thiz->ev[sd]), NULL);
thiz->localPort[sd] = localport;
/*
* Create local udp for sendign data
*/
sd = socket(AF_INET, SOCK_DGRAM, 0);
if (sd < 0) {
NW_LOG(NW_LOG_LEVEL_ERRO, "%s", strerror(errno));
NW_ASSERT(0);
}
thiz->hSocket = sd;
return NW_GTPV1U_OK;
}
NwGtpv1uRcT
nwMiniUlpDestroyConn(NwMiniUlpEntityT *thiz)
{
NwGtpv1uRcT rc;
NwGtpv1uUlpApiT ulpReq;
/*---------------------------------------------------------------------------
* Send Destroy Session Request to GTPv1u Stack Instance
*--------------------------------------------------------------------------*/
ulpReq.apiType = NW_GTPV1U_ULP_API_DESTROY_TUNNEL_ENDPOINT;
ulpReq.apiInfo.destroyTunnelEndPointInfo.hStackSessionHandle = thiz->hGtpv1uConn;
rc = nwGtpv1uProcessUlpReq(thiz->hGtpv1uStack, &ulpReq);
NW_ASSERT( rc == NW_GTPV1U_OK );
thiz->hGtpv1uConn = 0;
return NW_GTPV1U_OK;
}
NwGtpv1uRcT
nwMiniUlpTpduSend(NwMiniUlpEntityT *thiz, uint8_t *tpduBuf, uint32_t tpduLen ,
uint16_t fromPort)
{
NwGtpv1uRcT rc;
NwGtpv1uUlpApiT ulpReq;
/*
* Send Message Request to GTPv1u Stack Instance
*/
ulpReq.apiType = NW_GTPV1U_ULP_API_SEND_TPDU;
ulpReq.apiInfo.sendtoInfo.teid = fromPort;
ulpReq.apiInfo.sendtoInfo.ipAddr = inet_addr(thiz->peerIpStr);
rc = nwGtpv1uGpduMsgNew( thiz->hGtpv1uStack,
fromPort,
NW_FALSE,
thiz->seqNum++,
tpduBuf,
tpduLen,
&(ulpReq.apiInfo.sendtoInfo.hMsg));
NW_ASSERT( rc == NW_GTPV1U_OK );
rc = nwGtpv1uProcessUlpReq(thiz->hGtpv1uStack, &ulpReq);
NW_ASSERT( rc == NW_GTPV1U_OK );
rc = nwGtpv1uMsgDelete(thiz->hGtpv1uStack, (ulpReq.apiInfo.sendtoInfo.hMsg));
NW_ASSERT( rc == NW_GTPV1U_OK );
return NW_GTPV1U_OK;
}
NwGtpv1uRcT
nwMiniUlpProcessStackReqCallback (NwGtpv1uUlpHandleT hUlp,
NwGtpv1uUlpApiT *pUlpApi)
{
NwMiniUlpEntityT *thiz;
NW_ASSERT(pUlpApi != NULL);
thiz = (NwMiniUlpEntityT *) hUlp;
switch(pUlpApi->apiType) {
case NW_GTPV1U_ULP_API_RECV_TPDU: {
struct sockaddr_in peerAddr;
NwS32T bytesSent;
uint8_t dataBuf[4096];
uint32_t dataSize;
uint32_t peerIpAddr = (inet_addr(thiz->peerIpStr));
NW_ASSERT( NW_GTPV1U_OK == nwGtpv1uMsgGetTpdu(pUlpApi->apiInfo.recvMsgInfo.hMsg,
dataBuf, &dataSize) );
NW_LOG(NW_LOG_LEVEL_DEBG, "Received TPDU from gtpv1u stack %u!",
pUlpApi->apiInfo.recvMsgInfo.teid);
peerAddr.sin_family = AF_INET;
peerAddr.sin_port = htons(pUlpApi->apiInfo.recvMsgInfo.teid);
peerAddr.sin_addr.s_addr = (peerIpAddr);
memset(peerAddr.sin_zero, '\0', sizeof (peerAddr.sin_zero));
bytesSent = sendto (thiz->hSocket, dataBuf, dataSize, 0,
(struct sockaddr *) &peerAddr, sizeof(peerAddr));
if(bytesSent < 0) {
NW_LOG(NW_LOG_LEVEL_ERRO, "%s", strerror(errno));
NW_ASSERT(0);
} else {
NW_LOG(NW_LOG_LEVEL_DEBG, "Sent %u bytes to peer %u.%u.%u.%u", dataSize,
(peerIpAddr & 0x000000ff),
(peerIpAddr & 0x0000ff00) >> 8,
(peerIpAddr & 0x00ff0000) >> 16,
(peerIpAddr & 0xff000000) >> 24);
}
NW_ASSERT(nwGtpv1uMsgDelete(thiz->hGtpv1uStack,
(pUlpApi->apiInfo.recvMsgInfo.hMsg)) == NW_GTPV1U_OK);
}
break;
default:
NW_LOG(NW_LOG_LEVEL_WARN, "Received undefined UlpApi (%d) from gtpv1u stack!",
pUlpApi->apiType);
}
return NW_GTPV1U_OK;
}
#ifdef __cplusplus
}
#endif
@@ -1,64 +0,0 @@
/*----------------------------------------------------------------------------*
* *
* M I N I M A L I S T I C U L P E N T I T Y *
* *
* Copyright (C) 2010 Amit Chawre. *
* *
*----------------------------------------------------------------------------*/
/**
* @file NwMiniUlpEntity.h
* @brief This file contains example of a minimalistic ULP entity.
*/
#include <stdio.h>
#include <assert.h>
#include "NwEvt.h"
#include "NwLog.h"
#ifndef __NW_MINI_ULP_H__
#define __NW_MINI_ULP_H__
typedef struct {
int hSocket;
uint16_t seqNum;
uint8_t restartCounter;
uint8_t localIpStr[16];
uint8_t peerIpStr[16];
uint32_t localPort[1025];
NwEventT ev[1025];
NwGtpv1uStackHandleT hGtpv1uStack;
NwGtpv1uStackSessionHandleT hGtpv1uConn;
} NwMiniUlpEntityT;
#ifdef __cplusplus
extern "C" {
#endif
NwGtpv1uRcT
nwMiniUlpInit(NwMiniUlpEntityT* thiz, NwGtpv1uStackHandleT hGtpv1uStack);
NwGtpv1uRcT
nwMiniUlpDestroy(NwMiniUlpEntityT* thiz);
NwGtpv1uRcT
nwMiniUlpCreateConn(NwMiniUlpEntityT* thiz, char* localIpStr, uint16_t localPort, char* peerIpStr);
NwGtpv1uRcT
nwMiniUlpDestroyConn(NwMiniUlpEntityT* thiz);
NwGtpv1uRcT
nwMiniUlpSendMsg(NwMiniUlpEntityT* thiz);
NwGtpv1uRcT
nwMiniUlpTpduSend(NwMiniUlpEntityT* thiz, uint8_t* tpduBuf, uint32_t tpduLen , uint16_t fromPort);
NwGtpv1uRcT
nwMiniUlpProcessStackReqCallback (NwGtpv1uUlpHandleT hUlp,
NwGtpv1uUlpApiT *pUlpApi);
#ifdef __cplusplus
}
#endif
#endif
@@ -1,207 +0,0 @@
/*----------------------------------------------------------------------------*
* *
* n w - g t p v 2 u *
* G P R S T u n n e l i n g P r o t o c o l v 2 u S t a c k *
* *
* M I N I M A L I S T I C D E M O N S T R A T I O N *
* *
* Copyright (C) 2010 Amit Chawre. *
* *
*----------------------------------------------------------------------------*/
/**
* @file hello-world.c
* @brief This is a test program demostrating usage of nw-gtpv2 library.
*/
#include <stdio.h>
#include <assert.h>
#include "NwEvt.h"
#include "NwGtpv1u.h"
#include "NwMiniLogMgrEntity.h"
#include "NwMiniTmrMgrEntity.h"
#include "NwMiniUdpEntity.h"
#include "NwMiniUlpEntity.h"
#ifndef NW_ASSERT
#define NW_ASSERT assert
#endif
/*---------------------------------------------------------------------------
* T H E M A I N F U N C T I O N
*--------------------------------------------------------------------------*/
int main(int argc, char *argv[])
{
NwGtpv1uRcT rc;
char *logLevelStr;
uint32_t logLevel;
uint32_t num_of_connections;
NwGtpv1uStackHandleT hGtpv1uStack = 0;
NwMiniUlpEntityT ulpObj;
NwMiniUdpEntityT udpObj;
NwMiniLogMgrT logObj;
NwGtpv1uUlpEntityT ulp;
NwGtpv1uUdpEntityT udp;
NwGtpv1uTimerMgrEntityT tmrMgr;
NwGtpv1uLogMgrEntityT logMgr;
if(argc != 4) {
printf("Usage: %s <num-of-connections> <local-ip> <peer-ip>\n", argv[0]);
exit(0);
}
logLevelStr = getenv ("NW_LOG_LEVEL");
if(logLevelStr == NULL) {
logLevel = NW_LOG_LEVEL_INFO;
} else {
if(strncmp(logLevelStr, "EMER",4) == 0) {
logLevel = NW_LOG_LEVEL_EMER;
} else if(strncmp(logLevelStr, "ALER",4) == 0) {
logLevel = NW_LOG_LEVEL_ALER;
} else if(strncmp(logLevelStr, "CRIT",4) == 0) {
logLevel = NW_LOG_LEVEL_CRIT;
} else if(strncmp(logLevelStr, "ERRO",4) == 0) {
logLevel = NW_LOG_LEVEL_ERRO ;
} else if(strncmp(logLevelStr, "WARN",4) == 0) {
logLevel = NW_LOG_LEVEL_WARN;
} else if(strncmp(logLevelStr, "NOTI",4) == 0) {
logLevel = NW_LOG_LEVEL_NOTI;
} else if(strncmp(logLevelStr, "INFO",4) == 0) {
logLevel = NW_LOG_LEVEL_INFO;
} else if(strncmp(logLevelStr, "DEBG",4) == 0) {
logLevel = NW_LOG_LEVEL_DEBG;
}
}
/*---------------------------------------------------------------------------
* Initialize event library
*--------------------------------------------------------------------------*/
NW_EVT_INIT();
/*---------------------------------------------------------------------------
* Initialize Log Manager
*--------------------------------------------------------------------------*/
nwMiniLogMgrInit(&logObj, logLevel);
/*---------------------------------------------------------------------------
* Create GTPv1u Stack Instance
*--------------------------------------------------------------------------*/
rc = nwGtpv1uInitialize(&hGtpv1uStack, GTPU_STACK_ENB);
if(rc != NW_GTPV1U_OK) {
NW_LOG(NW_LOG_LEVEL_ERRO,
"Failed to create gtpv1u stack instance. Error '%u' occured", rc);
exit(1);
}
NW_LOG(NW_LOG_LEVEL_INFO, "Gtpv1u Stack Handle '%X' Creation Successful!",
hGtpv1uStack);
/*---------------------------------------------------------------------------
* Set up Ulp Entity
*--------------------------------------------------------------------------*/
rc = nwMiniUlpInit(&ulpObj, hGtpv1uStack);
NW_ASSERT( rc == NW_GTPV1U_OK );
ulp.hUlp = (NwGtpv1uUlpHandleT) &ulpObj;
ulp.ulpReqCallback = nwMiniUlpProcessStackReqCallback;
rc = nwGtpv1uSetUlpEntity(hGtpv1uStack, &ulp);
NW_ASSERT( rc == NW_GTPV1U_OK );
/*---------------------------------------------------------------------------
* Set up Udp Entity
*--------------------------------------------------------------------------*/
rc = nwMiniUdpInit(&udpObj, hGtpv1uStack, (argv[2]));
NW_ASSERT( rc == NW_GTPV1U_OK );
udp.hUdp = (NwGtpv1uUdpHandleT) &udpObj;
udp.udpDataReqCallback = nwMiniUdpDataReq;
rc = nwGtpv1uSetUdpEntity(hGtpv1uStack, &udp);
NW_ASSERT( rc == NW_GTPV1U_OK );
/*---------------------------------------------------------------------------
* Set up Log Entity
*--------------------------------------------------------------------------*/
tmrMgr.tmrMgrHandle = 0;
tmrMgr.tmrStartCallback = nwTimerStart;
tmrMgr.tmrStopCallback = nwTimerStop;
rc = nwGtpv1uSetTimerMgrEntity(hGtpv1uStack, &tmrMgr);
NW_ASSERT( rc == NW_GTPV1U_OK );
/*---------------------------------------------------------------------------
* Set up Log Entity
*--------------------------------------------------------------------------*/
logMgr.logMgrHandle = (NwGtpv1uLogMgrHandleT) &logObj;
logMgr.logReqCallback = nwMiniLogMgrLogRequest;
rc = nwGtpv1uSetLogMgrEntity(hGtpv1uStack, &logMgr);
NW_ASSERT( rc == NW_GTPV1U_OK );
/*---------------------------------------------------------------------------
* Set GTPv1u log level
*--------------------------------------------------------------------------*/
rc = nwGtpv1uSetLogLevel(hGtpv1uStack, logLevel);
/*---------------------------------------------------------------------------
* Send Create Session Request to GTPv1u Stack Instance
*--------------------------------------------------------------------------*/
num_of_connections = atoi(argv[1]);
while ( num_of_connections-- ) {
//rc = nwMiniUlpCreateConn(&ulpObj, argv[2], 1234 + num_of_connections, argv[3]);
rc = nwMiniUlpSendEchoRequestToPeer(&ulpObj, inet_addr(argv[3]));
NW_ASSERT( rc == NW_GTPV1U_OK );
}
/*---------------------------------------------------------------------------
* Event loop
*--------------------------------------------------------------------------*/
NW_EVT_LOOP();
NW_LOG(NW_LOG_LEVEL_ERRO, "Exit from eventloop, no events to process!");
/*---------------------------------------------------------------------------
* Send Destroy Session Request to GTPv1u Stack Instance
*--------------------------------------------------------------------------*/
rc = nwMiniUlpDestroyConn(&ulpObj);
NW_ASSERT( rc == NW_GTPV1U_OK );
/*---------------------------------------------------------------------------
* Destroy GTPv1u Stack Instance
*--------------------------------------------------------------------------*/
rc = nwGtpv1uFinalize(hGtpv1uStack);
if(rc != NW_GTPV1U_OK) {
NW_LOG(NW_LOG_LEVEL_ERRO,
"Failed to finalize gtpv1u stack instance. Error '%u' occured", rc);
} else {
NW_LOG(NW_LOG_LEVEL_INFO, "Gtpv1u Stack Handle '%X' Finalize Successful!",
hGtpv1uStack);
}
return rc;
}
-1
View File
@@ -54,7 +54,6 @@
#include "common/config/config_userapi.h"
#include "RRC_config_tools.h"
#include "enb_paramdef.h"
#include "proto_agent.h"
int RCconfig_MME(void ) {
//int num_enbs = 0;
-447
View File
@@ -1,447 +0,0 @@
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file udp_eNB_task.c
* \brief
* \author Sebastien ROUX, Lionel Gauthier
* \company Eurecom
* \email: lionel.gauthier@eurecom.fr
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <pthread.h>
#include "queue.h"
#include "intertask_interface.h"
#include "assertions.h"
#include "udp_eNB_task.h"
#include "common/utils/LOG/log.h"
#include "common/utils/LOG/vcd_signal_dumper.h"
#include "msc.h"
#define IPV4_ADDR "%u.%u.%u.%u"
#define IPV4_ADDR_FORMAT(aDDRESS) \
(uint8_t)((aDDRESS) & 0x000000ff), \
(uint8_t)(((aDDRESS) & 0x0000ff00) >> 8 ), \
(uint8_t)(((aDDRESS) & 0x00ff0000) >> 16), \
(uint8_t)(((aDDRESS) & 0xff000000) >> 24)
struct udp_socket_desc_s {
int sd; /* Socket descriptor to use */
pthread_t listener_thread; /* Thread affected to recv */
char *local_address; /* Local ipv4 address to use */
uint16_t local_port; /* Local port to use */
task_id_t task_id; /* Task who has requested the new endpoint */
STAILQ_ENTRY(udp_socket_desc_s) entries;
};
static STAILQ_HEAD(udp_socket_list_s, udp_socket_desc_s) udp_socket_list;
static pthread_mutex_t udp_socket_list_mutex = PTHREAD_MUTEX_INITIALIZER;
static
struct udp_socket_desc_s *
udp_eNB_get_socket_desc(task_id_t task_id);
void udp_eNB_process_file_descriptors(
struct epoll_event *events,
int nb_events);
static
int
udp_eNB_create_socket(
int port,
char *ip_addr,
task_id_t task_id);
int
udp_eNB_send_to(
int sd,
uint16_t port,
uint32_t address,
const uint8_t *buffer,
uint32_t length);
void udp_eNB_receiver(struct udp_socket_desc_s *udp_sock_pP);
void *udp_eNB_task(void *args_p);
int udp_enb_init(void);
/* @brief Retrieve the descriptor associated with the task_id
*/
static
struct udp_socket_desc_s *udp_eNB_get_socket_desc(task_id_t task_id)
{
struct udp_socket_desc_s *udp_sock_p = NULL;
#if defined(LOG_UDP) && LOG_UDP > 0
LOG_T(UDP_, "Looking for task %d\n", task_id);
#endif
STAILQ_FOREACH(udp_sock_p, &udp_socket_list, entries) {
if (udp_sock_p->task_id == task_id) {
#if defined(LOG_UDP) && LOG_UDP > 0
LOG_T(UDP_, "Found matching task desc\n");
#endif
break;
}
}
return udp_sock_p;
}
void udp_eNB_process_file_descriptors(struct epoll_event *events, int nb_events)
{
int i;
struct udp_socket_desc_s *udp_sock_p = NULL;
if (events == NULL) {
return;
}
for (i = 0; i < nb_events; i++) {
STAILQ_FOREACH(udp_sock_p, &udp_socket_list, entries) {
if (udp_sock_p->sd == events[i].data.fd) {
#if defined(LOG_UDP) && LOG_UDP > 0
LOG_D(UDP_, "Found matching task desc\n");
#endif
udp_eNB_receiver(udp_sock_p);
break;
}
}
}
}
static
int udp_eNB_create_socket(int port, char *ip_addr, task_id_t task_id)
{
struct udp_socket_desc_s *udp_socket_desc_p = NULL;
int sd, rc;
struct sockaddr_in sin;
LOG_I(UDP_, "Initializing UDP for local address %s with port %d\n", ip_addr, port);
sd = socket(AF_INET, SOCK_DGRAM, 0);
AssertFatal(sd > 0, "UDP: Failed to create new socket: (%s:%d)\n", strerror(errno), errno);
memset(&sin, 0, sizeof(struct sockaddr_in));
sin.sin_family = AF_INET;
sin.sin_port = htons(port);
if (ip_addr == NULL) {
sin.sin_addr.s_addr = inet_addr(INADDR_ANY);
} else {
sin.sin_addr.s_addr = inet_addr(ip_addr);
}
if ((rc = bind(sd, (struct sockaddr *)&sin, sizeof(struct sockaddr_in))) < 0) {
close(sd);
LOG_E(UDP_, "Failed to bind socket: (%s:%d) address %s port %d\n", strerror(errno), errno, ip_addr, port);
return -1;
}
/* Create a new descriptor for this connection */
udp_socket_desc_p = calloc(1, sizeof(struct udp_socket_desc_s));
DevAssert(udp_socket_desc_p != NULL);
udp_socket_desc_p->sd = sd;
udp_socket_desc_p->local_address = ip_addr;
udp_socket_desc_p->local_port = port;
udp_socket_desc_p->task_id = task_id;
LOG_I(UDP_, "Inserting new descriptor for task %d, sd %d\n", udp_socket_desc_p->task_id, udp_socket_desc_p->sd);
pthread_mutex_lock(&udp_socket_list_mutex);
STAILQ_INSERT_TAIL(&udp_socket_list, udp_socket_desc_p, entries);
pthread_mutex_unlock(&udp_socket_list_mutex);
itti_subscribe_event_fd(TASK_UDP, sd);
LOG_I(UDP_, "Initializing UDP for local address %s with port %d: DONE\n", ip_addr, port);
return sd;
}
int
udp_eNB_send_to(
int sd,
uint16_t port,
uint32_t address,
const uint8_t *buffer,
uint32_t length)
{
struct sockaddr_in to;
socklen_t to_length;
if (sd <= 0 || ((buffer == NULL) && (length > 0))) {
LOG_E(UDP_, "udp_send_to: bad param\n");
return -1;
}
memset(&to, 0, sizeof(struct sockaddr_in));
to_length = sizeof(to);
to.sin_family = AF_INET;
to.sin_port = htons(port);
to.sin_addr.s_addr = address;
if (sendto(sd, (void *)buffer, (size_t)length, 0, (struct sockaddr *)&to,
to_length) < 0) {
LOG_E(UDP_,
"[SD %d] Failed to send data to "IPV4_ADDR" on port %d, buffer size %u\n",
sd, IPV4_ADDR_FORMAT(address), port, length);
return -1;
}
#if defined(LOG_UDP) && LOG_UDP > 0
LOG_I(UDP_, "[SD %d] Successfully sent to "IPV4_ADDR
" on port %d, buffer size %u, buffer address %x\n",
sd, IPV4_ADDR_FORMAT(address), port, length, buffer);
#endif
return 0;
}
void udp_eNB_receiver(struct udp_socket_desc_s *udp_sock_pP)
{
uint8_t l_buffer[NFAPI_MAX_PACKED_MESSAGE_SIZE];
int n;
socklen_t from_len;
struct sockaddr_in addr;
MessageDef *message_p = NULL;
udp_data_ind_t *udp_data_ind_p = NULL;
uint8_t *forwarded_buffer = NULL;
if (1) {
from_len = (socklen_t)sizeof(struct sockaddr_in);
if ((n = recvfrom(udp_sock_pP->sd, l_buffer, sizeof(l_buffer), MSG_TRUNC,
(struct sockaddr *)&addr, &from_len)) < 0) {
LOG_E(UDP_, "Recvfrom failed %s\n", strerror(errno));
return;
} else if (n > sizeof(l_buffer)) {
LOG_E(UDP_, "%s(%d). Message truncated. %d\n", __FUNCTION__, __LINE__, n);
return;
} else if (n == 0) {
LOG_W(UDP_, "Recvfrom returned 0\n");
return;
} else {
forwarded_buffer = itti_malloc(TASK_UDP, udp_sock_pP->task_id, n*sizeof(uint8_t));
DevAssert(forwarded_buffer != NULL);
memcpy(forwarded_buffer, l_buffer, n);
message_p = itti_alloc_new_message(TASK_UDP, 0, UDP_DATA_IND);
DevAssert(message_p != NULL);
udp_data_ind_p = &message_p->ittiMsg.udp_data_ind;
udp_data_ind_p->buffer = forwarded_buffer;
udp_data_ind_p->buffer_length = n;
udp_data_ind_p->peer_port = htons(addr.sin_port);
udp_data_ind_p->peer_address = addr.sin_addr.s_addr;
#if defined(LOG_UDP) && LOG_UDP > 0
LOG_I(UDP_, "Msg of length %d received from %s:%u\n",
n, inet_ntoa(addr.sin_addr), ntohs(addr.sin_port));
#endif
/* TODO: this is a hack. Let's accept failures and do nothing when
* it happens. Since itti_send_msg_to_task crashes when the message
* queue is full we wrote itti_try_send_msg_to_task that returns -1
* if the queue is full.
*/
/* look for HACK_RLC_UM_LIMIT for others places related to the hack. Please do not remove this comment. */
if (itti_send_msg_to_task(udp_sock_pP->task_id, INSTANCE_DEFAULT, message_p) < 0) {
LOG_E(UDP_, "Failed to send message %d to task %d\n",
UDP_DATA_IND,
udp_sock_pP->task_id);
itti_free(TASK_UDP, message_p);
itti_free(TASK_UDP, forwarded_buffer);
return;
}
}
}
//close(udp_sock_p->sd);
//udp_sock_p->sd = -1;
//pthread_mutex_lock(&udp_socket_list_mutex);
//STAILQ_REMOVE(&udp_socket_list, udp_sock_p, udp_socket_desc_s, entries);
//pthread_mutex_unlock(&udp_socket_list_mutex);
}
void *udp_eNB_task(void *args_p)
{
int nb_events;
struct epoll_event *events;
MessageDef *received_message_p = NULL;
//const char *msg_name = NULL;
//instance_t instance = 0;
udp_enb_init();
itti_mark_task_ready(TASK_UDP);
MSC_START_USE();
while(1) {
itti_receive_msg(TASK_UDP, &received_message_p);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UDP_ENB_TASK, VCD_FUNCTION_IN);
#if defined(LOG_UDP) && LOG_UDP > 0
LOG_D(UDP_, "Got message %p\n", &received_message_p);
#endif
if (received_message_p != NULL) {
//msg_name = ITTI_MSG_NAME (received_message_p);
//instance = ITTI_MSG_DESTINATION_INSTANCE (received_message_p);
switch (ITTI_MSG_ID(received_message_p)) {
case UDP_INIT: {
LOG_D(UDP_, "Received UDP_INIT\n");
udp_init_t *udp_init_p;
udp_init_p = &received_message_p->ittiMsg.udp_init;
udp_eNB_create_socket(
udp_init_p->port,
udp_init_p->address,
ITTI_MSG_ORIGIN_ID(received_message_p));
}
break;
case UDP_DATA_REQ: {
#if defined(LOG_UDP) && LOG_UDP > 0
LOG_D(UDP_, "Received UDP_DATA_REQ\n");
#endif
int udp_sd = -1;
ssize_t bytes_written;
struct udp_socket_desc_s *udp_sock_p = NULL;
udp_data_req_t *udp_data_req_p;
struct sockaddr_in peer_addr;
udp_data_req_p = &received_message_p->ittiMsg.udp_data_req;
memset(&peer_addr, 0, sizeof(struct sockaddr_in));
peer_addr.sin_family = AF_INET;
peer_addr.sin_port = htons(udp_data_req_p->peer_port);
peer_addr.sin_addr.s_addr = udp_data_req_p->peer_address;
pthread_mutex_lock(&udp_socket_list_mutex);
udp_sock_p = udp_eNB_get_socket_desc(ITTI_MSG_ORIGIN_ID(received_message_p));
if (udp_sock_p == NULL) {
LOG_E(UDP_,
"Failed to retrieve the udp socket descriptor "
"associated with task %d\n",
ITTI_MSG_ORIGIN_ID(received_message_p));
pthread_mutex_unlock(&udp_socket_list_mutex);
if (udp_data_req_p->buffer) {
itti_free(ITTI_MSG_ORIGIN_ID(received_message_p), udp_data_req_p->buffer);
}
goto on_error;
}
udp_sd = udp_sock_p->sd;
pthread_mutex_unlock(&udp_socket_list_mutex);
//#if defined(LOG_UDP) && LOG_UDP > 0
LOG_D(UDP_, "[%d] Sending message of size %u to "IPV4_ADDR" and port %u\n",
udp_sd,
udp_data_req_p->buffer_length,
IPV4_ADDR_FORMAT(udp_data_req_p->peer_address),
udp_data_req_p->peer_port);
//#endif
bytes_written = sendto(
udp_sd,
&udp_data_req_p->buffer[udp_data_req_p->buffer_offset],
udp_data_req_p->buffer_length,
0,
(struct sockaddr *)&peer_addr,
sizeof(struct sockaddr_in));
if (bytes_written != udp_data_req_p->buffer_length) {
LOG_E(UDP_, "There was an error while writing to socket %d rc %zd"
"(%d:%s) May be normal if GTPU kernel module loaded on same host (may NF_DROP IP packet)\n",
udp_sd, bytes_written, errno, strerror(errno));
}
itti_free(ITTI_MSG_ORIGIN_ID(received_message_p), udp_data_req_p->buffer);
}
break;
case TERMINATE_MESSAGE: {
LOG_W(UDP_, " *** Exiting UDP thread\n");
itti_exit_task();
}
break;
case MESSAGE_TEST: {
} break;
default: {
LOG_W(UDP_, "Unkwnon message ID %d:%s\n",
ITTI_MSG_ID(received_message_p),
ITTI_MSG_NAME(received_message_p));
}
break;
}
on_error:
itti_free (ITTI_MSG_ORIGIN_ID(received_message_p), received_message_p);
received_message_p = NULL;
}
nb_events = itti_get_events(TASK_UDP, &events);
/* Now handle notifications for other sockets */
if (nb_events > 0) {
#if defined(LOG_UDP) && LOG_UDP > 0
LOG_D(UDP_, "UDP task Process %d events\n",nb_events);
#endif
udp_eNB_process_file_descriptors(events, nb_events);
}
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UDP_ENB_TASK, VCD_FUNCTION_OUT);
}
LOG_I(UDP_, "Task UDP eNB exiting\n");
return NULL;
}
int udp_enb_init(void)
{
LOG_I(UDP_, "Initializing UDP task interface\n");
STAILQ_INIT(&udp_socket_list);
LOG_I(UDP_, "Initializing UDP task interface: DONE\n");
return 0;
}
-97
View File
@@ -1,97 +0,0 @@
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file udp_eNB_task.h
* \brief
* \author Sebastien ROUX, Lionel Gauthier
* \company Eurecom
* \email: lionel.gauthier@eurecom.fr
*/
#include <pthread.h>
#include <stdint.h>
#ifndef UDP_ENB_TASK_H_
#define UDP_ENB_TASK_H_
#include "enb_config.h"
/** \brief UDP recv callback prototype. Will be called every time a payload is
* received on socket.
* \param port Port on which data had been received
* \param address Sender Ipv4 address
* \param buffer Pointer to data (should be freed by user)
* \param length Length of message received
* \param arg_p User provided argument (transparent for wrappers)
* @returns Execution result
*/
typedef int (*udp_recv_callback)(uint16_t port,
uint32_t address,
uint8_t *buffer,
uint32_t length,
void *arg_p);
typedef struct {
int sd; /* Socket descriptor to use */
pthread_t listener_thread; /* Thread affected to recv */
char *local_address; /* Local ipv4 address to use */
uint16_t local_port; /* Local port to use */
task_id_t task_id; /* Task who has requested the new endpoint */
} udp_data_t;
/** \brief Create new datagram connection-less socket and create new thread
* for data in downstream.
* \param ip_addr Local IPv4 address to use
* \param port Local port to use
* \param udp_data_p
* \param recv_callback Pointer to data (should be freed by user)
* \param arg_p Optionnal argument to pass to recv_callback
* @returns < 0 on failure or socket descriptor on success
*/
int udp_create_connection(char *ip_addr, uint16_t port,
udp_data_t *udp_data_p,
udp_recv_callback recv_callback,
void *arg_p);
/** \brief Send buffer to remote peer.
* \param sd socket descriptor to use
* \param port remote port
* \param address remote address
* \param buffer Data buffer to send
* \param length Buffer length
* @returns < 0 on failure or socket descriptor on success
*/
int udp_send_to(int sd, uint16_t port, uint32_t address,
const uint8_t *buffer, uint32_t length);
/** \brief UDP ITTI task on eNB.
* \param args_p
* @returns always NULL
*/
void *udp_eNB_task(void *args_p);
/** \brief init UDP layer.
* \param enb_config_p configuration of eNB
* @returns always 0
*/
int udp_enb_init(void);
#endif /* UDP_ENB_TASK_H_ */
+89 -48
View File
@@ -46,7 +46,7 @@ typedef struct Gtpv1uMsgHeader {
#define GTP_GPDU (255)
typedef struct ocp_gtpv1u_bearer_s {
typedef struct gtpv1u_bearer_s {
/* TEID used in dl and ul */
teid_t teid_incoming; ///< eNB TEID
teid_t teid_outgoing; ///< Remote TEID
@@ -55,10 +55,10 @@ typedef struct ocp_gtpv1u_bearer_s {
tcp_udp_port_t outgoing_port;
uint16_t seqNum;
uint8_t npduNum;
} ocp_gtpv1u_bearer_t;
} gtpv1u_bearer_t;
typedef struct {
map<int, ocp_gtpv1u_bearer_t> bearers;
map<int, gtpv1u_bearer_t> bearers;
} teidData_t;
typedef struct {
@@ -79,7 +79,7 @@ class gtpEndPoint {
// this allow using non standard gtp port number (different from 2152)
// and so, for example tu run 4G and 5G cores on one system
tcp_udp_port_t get_dstport() {
return (tcp_udp_port_t)atol(addr.destinationService);
return (tcp_udp_port_t)atol(addr.destinationService);
}
};
@@ -106,10 +106,10 @@ instance_t legacyInstanceMapping=0;
#define compatInst(a) ((a)==0 || (a)==INSTANCE_DEFAULT?legacyInstanceMapping:a)
#define GTPV1U_HEADER_SIZE (8)
static int gtpv1uCreateAndSendMsg(int h, uint32_t peerIp, uint16_t peerPort, int msgType, teid_t teid, uint8_t *Msg,int msgLen,
bool seqNumFlag, bool npduNumFlag, bool extHdrFlag, int seqNum, int npduNum, int extHdrType) {
static int gtpv1uCreateAndSendMsg(int h, uint32_t peerIp, uint16_t peerPort, int msgType, teid_t teid, uint8_t *Msg,int msgLen,
bool seqNumFlag, bool npduNumFlag, bool extHdrFlag, int seqNum, int npduNum, int extHdrType) {
AssertFatal(extHdrFlag==false,"Not developped");
int headerAdditional=0;
@@ -149,6 +149,7 @@ instance_t legacyInstanceMapping=0;
to.sin_addr.s_addr = peerIp ;
LOG_D(GTPU,"sending packet size: %d to %s\n",fullSize, inet_ntoa(to.sin_addr) );
int ret;
if ((ret=sendto(h, (void *)buffer, (size_t)fullSize, 0,(struct sockaddr *)&to, sizeof(to) )) != fullSize ) {
LOG_E(GTPU, "[SD %d] Failed to send data to " IPV4_ADDR " on port %d, buffer size %u, ret: %d, errno: %d\n",
h, IPV4_ADDR_FORMAT(peerIp), peerPort, fullSize, ret, errno);
@@ -173,7 +174,7 @@ static void gtpv1uSend(instance_t instance, gtpv1u_enb_tunnel_data_req_t *req, b
return;
}
map<int, ocp_gtpv1u_bearer_t>::iterator ptr2=ptrRnti->second.bearers.find(rab_id);
map<int, gtpv1u_bearer_t>::iterator ptr2=ptrRnti->second.bearers.find(rab_id);
if ( ptr2 == ptrRnti->second.bearers.end() ) {
LOG_E(GTPU,"[%ld] GTP-U instance: sending a packet to a non existant RNTI:RAB: %x/%x\n", instance, rnti, rab_id);
@@ -191,12 +192,12 @@ static void gtpv1uSend(instance_t instance, gtpv1u_enb_tunnel_data_req_t *req, b
ptr2->second.npduNum++;
// copy to release the mutex
ocp_gtpv1u_bearer_t tmp=ptr2->second;
gtpv1u_bearer_t tmp=ptr2->second;
pthread_mutex_unlock(&globGtp.gtp_lock);
gtpv1uCreateAndSendMsg(compatInst(instance),
tmp.outgoing_ip_addr,
tmp.outgoing_port,
GTP_GPDU,
GTP_GPDU,
tmp.teid_outgoing,
buffer, length, seqNumFlag, npduNumFlag, false, tmp.seqNum, tmp.npduNum, 0) ;
}
@@ -216,7 +217,7 @@ static void gtpv1uSend2(instance_t instance, gtpv1u_gnb_tunnel_data_req_t *req,
return;
}
map<int, ocp_gtpv1u_bearer_t>::iterator ptr2=ptrRnti->second.bearers.find(rab_id);
map<int, gtpv1u_bearer_t>::iterator ptr2=ptrRnti->second.bearers.find(rab_id);
if ( ptr2 == ptrRnti->second.bearers.end() ) {
LOG_D(GTPU,"GTP-U instance: %ld sending a packet to a non existant RNTI:RAB: %x/%x\n", instance, rnti, rab_id);
@@ -234,12 +235,12 @@ static void gtpv1uSend2(instance_t instance, gtpv1u_gnb_tunnel_data_req_t *req,
ptr2->second.npduNum++;
// copy to release the mutex
ocp_gtpv1u_bearer_t tmp=ptr2->second;
gtpv1u_bearer_t tmp=ptr2->second;
pthread_mutex_unlock(&globGtp.gtp_lock);
gtpv1uCreateAndSendMsg(compatInst(instance),
tmp.outgoing_ip_addr,
tmp.outgoing_port,
GTP_GPDU,
GTP_GPDU,
tmp.teid_outgoing,
buffer, length, seqNumFlag, npduNumFlag, false, tmp.seqNum, tmp.npduNum, 0) ;
}
@@ -257,7 +258,7 @@ static void gtpv1uEndTunnel(instance_t instance, gtpv1u_enb_tunnel_data_req_t *r
return;
}
map<int, ocp_gtpv1u_bearer_t>::iterator ptr2=ptrRnti->second.bearers.find(rab_id);
map<int, gtpv1u_bearer_t>::iterator ptr2=ptrRnti->second.bearers.find(rab_id);
if ( ptr2 == ptrRnti->second.bearers.end() ) {
LOG_E(GTPU,"[%ld] GTP-U sending a packet to a non existant RNTI:RAB: %x/%x\n", instance, rnti, rab_id);
@@ -267,7 +268,7 @@ static void gtpv1uEndTunnel(instance_t instance, gtpv1u_enb_tunnel_data_req_t *r
LOG_D(GTPU,"[%ld] sending a end packet packet to RNTI:RAB:teid %x/%x/%x\n",
instance, rnti, rab_id,ptr2->second.teid_outgoing);
ocp_gtpv1u_bearer_t tmp=ptr2->second;
gtpv1u_bearer_t tmp=ptr2->second;
pthread_mutex_unlock(&globGtp.gtp_lock);
Gtpv1uMsgHeaderT msgHdr;
// N should be 0 for us (it was used only in 2G and 3G)
@@ -309,6 +310,7 @@ static int udpServerSocket(openAddr_s addr) {
LOG_E(GTPU,"getaddrinfo error: %s\n", gai_strerror(status));
return -1;
}
int sockfd=-1;
// loop through all the results and bind to the first we can
@@ -383,12 +385,12 @@ static int udpServerSocket(openAddr_s addr) {
return sockfd;
}
instance_t ocp_gtpv1Init(openAddr_t context) {
instance_t gtpv1Init(openAddr_t context) {
pthread_mutex_lock(&globGtp.gtp_lock);
int id=udpServerSocket(context);
if (id>=0) {
itti_subscribe_event_fd(OCP_GTPV1_U, id);
itti_subscribe_event_fd(TASK_GTPV1_U, id);
} else
LOG_E(GTPU,"can't create GTP-U instance\n");
@@ -408,7 +410,7 @@ void GtpuUpdateTunnelOutgoingTeid(instance_t instance, rnti_t rnti, ebi_t bearer
return;
}
map<int, ocp_gtpv1u_bearer_t>::iterator ptr2=ptrRnti->second.bearers.find(bearer_id);
map<int, gtpv1u_bearer_t>::iterator ptr2=ptrRnti->second.bearers.find(bearer_id);
if ( ptr2 == ptrRnti->second.bearers.end() ) {
LOG_E(GTPU,"[%ld] Update tunnel for a existing rnti %x, but wrong bearer_id %u\n", instance, rnti, bearer_id);
@@ -447,7 +449,7 @@ teid_t newGtpuCreateTunnel(instance_t instance, rnti_t rnti, int incoming_bearer
inst->te2ue_mapping[incoming_teid].callBack=callBack;
ocp_gtpv1u_bearer_t *tmp=&inst->ue2te_mapping[rnti].bearers[outgoing_bearer_id];
gtpv1u_bearer_t *tmp=&inst->ue2te_mapping[rnti].bearers[outgoing_bearer_id];
int addrs_length_in_bytes = remoteAddr.length / 8;
@@ -487,21 +489,21 @@ teid_t newGtpuCreateTunnel(instance_t instance, rnti_t rnti, int incoming_bearer
return incoming_teid;
}
int ocp_gtpv1u_create_s1u_tunnel(instance_t instance,
const gtpv1u_enb_create_tunnel_req_t *create_tunnel_req,
gtpv1u_enb_create_tunnel_resp_t *create_tunnel_resp) {
int gtpv1u_create_s1u_tunnel(instance_t instance,
const gtpv1u_enb_create_tunnel_req_t *create_tunnel_req,
gtpv1u_enb_create_tunnel_resp_t *create_tunnel_resp) {
LOG_D(GTPU, "[%ld] Start create tunnels for RNTI %x, num_tunnels %d, sgw_S1u_teid %x\n",
instance,
create_tunnel_req->rnti,
create_tunnel_req->num_tunnels,
create_tunnel_req->sgw_S1u_teid[0]);
tcp_udp_port_t dstport=globGtp.instances[compatInst(instance)].get_dstport();
for (int i = 0; i < create_tunnel_req->num_tunnels; i++) {
AssertFatal(create_tunnel_req->eps_bearer_id[i] > 4,
"From legacy code not clear, seems impossible (bearer=%d)\n",
create_tunnel_req->eps_bearer_id[i]);
int incoming_rb_id=create_tunnel_req->eps_bearer_id[i]-4;
teid_t teid=newGtpuCreateTunnel(compatInst(instance), create_tunnel_req->rnti,
incoming_rb_id,
create_tunnel_req->eps_bearer_id[i],
@@ -521,7 +523,7 @@ int ocp_gtpv1u_create_s1u_tunnel(instance_t instance,
return !GTPNOK;
}
int ocp_gtpv1u_update_s1u_tunnel(
int gtpv1u_update_s1u_tunnel(
const instance_t instance,
const gtpv1u_enb_create_tunnel_req_t *const create_tunnel_req,
const rnti_t prior_rnti
@@ -546,7 +548,7 @@ int ocp_gtpv1u_update_s1u_tunnel(
LOG_W(GTPU,"[%ld] Update a not existing tunnel, start create the new one (new rnti %x, old rnti %x)\n", instance, create_tunnel_req->rnti, prior_rnti);
pthread_mutex_unlock(&globGtp.gtp_lock);
gtpv1u_enb_create_tunnel_resp_t tmp;
(void)ocp_gtpv1u_create_s1u_tunnel(instance, create_tunnel_req, &tmp);
(void)gtpv1u_create_s1u_tunnel(instance, create_tunnel_req, &tmp);
return 0;
}
@@ -565,11 +567,12 @@ int gtpv1u_create_ngu_tunnel( const instance_t instance,
create_tunnel_req->num_tunnels,
create_tunnel_req->outgoing_teid[0]);
tcp_udp_port_t dstport=globGtp.instances[compatInst(instance)].get_dstport();
for (int i = 0; i < create_tunnel_req->num_tunnels; i++) {
teid_t teid=newGtpuCreateTunnel(instance, create_tunnel_req->rnti,
create_tunnel_req->incoming_rb_id[i],
create_tunnel_req->pdusession_id[i],
create_tunnel_req->outgoing_teid[i],
create_tunnel_req->outgoing_teid[i],
create_tunnel_req->dst_addr[i], dstport,
sdap_gnb_data_req);
create_tunnel_resp->status=0;
@@ -593,14 +596,14 @@ int gtpv1u_update_ngu_tunnel(
return GTPNOK;
}
int ocp_gtpv1u_create_x2u_tunnel(
int gtpv1u_create_x2u_tunnel(
const instance_t instanceP,
const gtpv1u_enb_create_x2u_tunnel_req_t *const create_tunnel_req_pP,
gtpv1u_enb_create_x2u_tunnel_resp_t *const create_tunnel_resp_pP) {
AssertFatal( false, "to be developped\n");
}
int newGtpuDeleteTunnel(instance_t instance, rnti_t rnti) {
int newGtpuDeleteAllTunnels(instance_t instance, rnti_t rnti) {
LOG_D(GTPU, "[%ld] Start delete tunnels for RNTI %x\n",
instance, rnti);
pthread_mutex_lock(&globGtp.gtp_lock);
@@ -630,24 +633,64 @@ int newGtpuDeleteTunnel(instance_t instance, rnti_t rnti) {
// Legacy delete tunnel finish by deleting all the rnti
// so the list of bearer provided is only a design bug
int ocp_gtpv1u_delete_s1u_tunnel( const instance_t instance,
const gtpv1u_enb_delete_tunnel_req_t *const req_pP) {
return newGtpuDeleteTunnel(instance, req_pP->rnti);
int gtpv1u_delete_s1u_tunnel( const instance_t instance,
const gtpv1u_enb_delete_tunnel_req_t *const req_pP) {
return newGtpuDeleteAllTunnels(instance, req_pP->rnti);
}
int newGtpuDeleteTunnels(instance_t instance, rnti_t rnti, int nbTunnels, pdusessionid_t *pdusession_id) {
LOG_D(GTPU, "[%ld] Start delete tunnels for RNTI %x\n",
instance, rnti);
pthread_mutex_lock(&globGtp.gtp_lock);
auto inst=&globGtp.instances[compatInst(instance)];
auto ptrRNTI=inst->ue2te_mapping.find(rnti);
if ( ptrRNTI == inst->ue2te_mapping.end() ) {
LOG_W(GTPU,"[%ld] Delete GTP tunnels for rnti: %x, but no tunnel exits\n", instance, rnti);
pthread_mutex_unlock(&globGtp.gtp_lock);
return -1;
}
int nb=0;
for (int i=0; i<nbTunnels; i++) {
auto ptr2=ptrRNTI->second.bearers.find(pdusession_id[i]);
if ( ptr2 == ptrRNTI->second.bearers.end() ) {
LOG_E(GTPU,"[%ld] GTP-U instance: delete of not existing tunnel RNTI:RAB: %x/%x\n", instance, rnti,pdusession_id[i]);
} else {
inst->te2ue_mapping.erase(ptr2->second.teid_incoming);
nb++;
}
}
if (ptrRNTI->second.bearers.size() == 0 )
// no tunnels on this rnti, erase the ue entry
inst->ue2te_mapping.erase(ptrRNTI);
pthread_mutex_unlock(&globGtp.gtp_lock);
LOG_I(GTPU, "[%ld] Deleted all tunnels for RNTI %x (%d tunnels deleted)\n", instance, rnti, nb);
return !GTPNOK;
}
int gtpv1u_delete_x2u_tunnel( const instance_t instanceP,
const gtpv1u_enb_delete_tunnel_req_t *const req_pP,
int enbflag) {
const gtpv1u_enb_delete_tunnel_req_t *const req_pP) {
LOG_E(GTPU,"x2 tunnel not implemented\n");
return 0;
}
int gtpv1u_delete_ngu_tunnel( const instance_t instance,
gtpv1u_gnb_delete_tunnel_req_t *req) {
return newGtpuDeleteTunnels(instance, req->rnti, req->num_pdusession, req->pdusession_id);
}
static int Gtpv1uHandleEchoReq(int h,
uint8_t *msgBuf,
uint32_t msgBufLen,
uint16_t peerPort,
uint32_t peerIp) {
Gtpv1uMsgHeaderT *msgHdr = (Gtpv1uMsgHeaderT *) msgBuf;
if ( msgHdr->version != 1 || msgHdr->PT != 1 ) {
LOG_E(GTPU, "[%d] Received a packet that is not GTP header\n", h);
return GTPNOK;
@@ -658,14 +701,12 @@ static int Gtpv1uHandleEchoReq(int h,
return GTPNOK;
}
uint16_t seq=ntohs(*(uint16_t*)(msgHdr+1));
uint16_t seq=ntohs(*(uint16_t *)(msgHdr+1));
LOG_D(GTPU, "[%d] Received a echo request, TEID: %d, seq: %hu\n", h, msgHdr->teid, seq);
uint8_t recovery[2]={14,0};
uint8_t recovery[2]= {14,0};
return gtpv1uCreateAndSendMsg(h, peerIp, peerPort, GTP_ECHO_RSP, ntohl(msgHdr->teid),
recovery, sizeof recovery,
1, 0, 0, seq, 0, 0);
recovery, sizeof recovery,
1, 0, 0, seq, 0, 0);
}
static int Gtpv1uHandleError(int h,
@@ -871,14 +912,14 @@ void gtpv1uReceiver(int h) {
#include <openair2/ENB_APP/enb_paramdef.h>
void *ocp_gtpv1uTask(void *args) {
void *gtpv1uTask(void *args) {
while(1) {
/* Trying to fetch a message from the message queue.
If the queue is empty, this function will block till a
message is sent to the task.
*/
MessageDef *message_p = NULL;
itti_receive_msg(OCP_GTPV1_U, &message_p);
itti_receive_msg(TASK_GTPV1_U, &message_p);
if (message_p != NULL ) {
openAddr_t addr= {0};
@@ -888,7 +929,7 @@ void *ocp_gtpv1uTask(void *args) {
case GTPV1U_ENB_TUNNEL_DATA_REQ: {
gtpv1uSend(compatInst(ITTI_MSG_DESTINATION_INSTANCE(message_p)),
&GTPV1U_ENB_TUNNEL_DATA_REQ(message_p), false, false);
itti_free(OCP_GTPV1_U, GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).buffer);
itti_free(TASK_GTPV1_U, GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).buffer);
}
break;
@@ -908,7 +949,7 @@ void *ocp_gtpv1uTask(void *args) {
case GTPV1U_ENB_END_MARKER_REQ:
gtpv1uEndTunnel(compatInst(ITTI_MSG_DESTINATION_INSTANCE(message_p)),
&GTPV1U_ENB_TUNNEL_DATA_REQ(message_p));
itti_free(OCP_GTPV1_U, GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).buffer);
itti_free(TASK_GTPV1_U, GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).buffer);
break;
case GTPV1U_ENB_DATA_FORWARDING_REQ:
@@ -923,7 +964,7 @@ void *ocp_gtpv1uTask(void *args) {
strcpy(addr.originHost, GTPV1U_REQ(message_p).localAddrStr);
strcpy(addr.originService, GTPV1U_REQ(message_p).localPortStr);
strcpy(addr.destinationService,addr.originService);
AssertFatal((legacyInstanceMapping=ocp_gtpv1Init(addr))!=0,"Instance 0 reserved for legacy\n");
AssertFatal((legacyInstanceMapping=gtpv1Init(addr))!=0,"Instance 0 reserved for legacy\n");
break;
default:
@@ -932,12 +973,12 @@ void *ocp_gtpv1uTask(void *args) {
break;
}
AssertFatal(EXIT_SUCCESS==itti_free(OCP_GTPV1_U, message_p), "Failed to free memory!\n");
AssertFatal(EXIT_SUCCESS==itti_free(TASK_GTPV1_U, message_p), "Failed to free memory!\n");
}
struct epoll_event *events;
int nb_events = itti_get_events(OCP_GTPV1_U, &events);
int nb_events = itti_get_events(TASK_GTPV1_U, &events);
for (int i = 0; i < nb_events; i++)
if ((events[i].events&EPOLLIN))
+15 -26
View File
@@ -8,19 +8,6 @@
extern "C" {
#endif
#include <openair3/GTPV1-U/gtpv1u_eNB_defs.h>
#if defined(NEW_GTPU)
#define gtpv1u_create_s1u_tunnel ocp_gtpv1u_create_s1u_tunnel
#define gtpv1u_update_s1u_tunnel ocp_gtpv1u_update_s1u_tunnel
#define gtpv1u_delete_s1u_tunnel ocp_gtpv1u_delete_s1u_tunnel
#define gtpv1u_create_x2u_tunnel ocp_gtpv1u_create_x2u_tunnel
#define gtpv1u_eNB_task ocp_gtpv1uTask
#define nr_gtpv1u_gNB_task ocp_gtpv1uTask
#define TASK_VARIABLE OCP_GTPV1_U
#else
#define TASK_VARIABLE TASK_GTPV1_U
#endif
typedef boolean_t (*gtpCallback)(
protocol_ctxt_t *ctxt_pP,
const srb_flag_t srb_flagP,
@@ -32,7 +19,7 @@ typedef boolean_t (*gtpCallback)(
const pdcp_transmission_mode_t modeP,
const uint32_t *sourceL2Id,
const uint32_t *destinationL2Id);
typedef struct openAddr_s {
char originHost[HOST_NAME_MAX];
char originService[HOST_NAME_MAX];
@@ -43,18 +30,18 @@ typedef struct openAddr_s {
// the init function create a gtp instance and return the gtp instance id
// the parameter originInstance will be sent back in each message from gtp to the creator
void ocp_gtpv1uReceiver(int h);
void ocp_gtpv1uProcessTimeout(int handle,void *arg);
int ocp_gtpv1u_create_s1u_tunnel(const instance_t instance, const gtpv1u_enb_create_tunnel_req_t *create_tunnel_req,
gtpv1u_enb_create_tunnel_resp_t *create_tunnel_resp);
int ocp_gtpv1u_update_s1u_tunnel(const instance_t instanceP,
const gtpv1u_enb_create_tunnel_req_t *create_tunnel_req_pP,
const rnti_t prior_rnti
);
int ocp_gtpv1u_delete_s1u_tunnel( const instance_t instance, const gtpv1u_enb_delete_tunnel_req_t *const req_pP);
void gtpv1uReceiver(int h);
void gtpv1uProcessTimeout(int handle,void *arg);
int gtpv1u_create_s1u_tunnel(const instance_t instance, const gtpv1u_enb_create_tunnel_req_t *create_tunnel_req,
gtpv1u_enb_create_tunnel_resp_t *create_tunnel_resp);
int gtpv1u_update_s1u_tunnel(const instance_t instanceP,
const gtpv1u_enb_create_tunnel_req_t *create_tunnel_req_pP,
const rnti_t prior_rnti
);
int gtpv1u_delete_s1u_tunnel( const instance_t instance, const gtpv1u_enb_delete_tunnel_req_t *const req_pP);
int gtpv1u_delete_s1u_tunnel( const instance_t instance, const gtpv1u_enb_delete_tunnel_req_t *const req_pP);
int ocp_gtpv1u_create_x2u_tunnel(
int gtpv1u_create_x2u_tunnel(
const instance_t instanceP,
const gtpv1u_enb_create_x2u_tunnel_req_t *const create_tunnel_req_pP,
gtpv1u_enb_create_x2u_tunnel_resp_t *const create_tunnel_resp_pP);
@@ -64,8 +51,10 @@ int ocp_gtpv1u_create_x2u_tunnel(
teid_t newGtpuCreateTunnel(instance_t instance, rnti_t rnti, int incoming_bearer_id, int outgoing_rb_id, teid_t teid,
transport_layer_addr_t remoteAddr, int port, gtpCallback callBack);
void GtpuUpdateTunnelOutgoingTeid(instance_t instance, rnti_t rnti, ebi_t bearer_id, teid_t newOutgoingTeid);
instance_t ocp_gtpv1Init(openAddr_t context);
void *ocp_gtpv1uTask(void *args);
int newGtpuDeleteAllTunnels(instance_t instance, rnti_t rnti);
int newGtpuDeleteTunnels(instance_t instance, rnti_t rnti, int nbTunnels, pdusessionid_t *pdusession_id);
instance_t gtpv1Init(openAddr_t context);
void *gtpv1uTask(void *args);
#ifdef __cplusplus
}

Some files were not shown because too many files have changed in this diff Show More