Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
spbro
OpenXG-RAN
Commits
665e3e38
Commit
665e3e38
authored
Apr 30, 2024
by
root
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changes-1
parent
883724b9
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
783 additions
and
0 deletions
+783
-0
openair2/COMMON/xnap_messages_def.h
openair2/COMMON/xnap_messages_def.h
+35
-0
openair2/COMMON/xnap_messages_types.h
openair2/COMMON/xnap_messages_types.h
+169
-0
openair2/GNB_APP/gnb_app.c
openair2/GNB_APP/gnb_app.c
+8
-0
openair2/GNB_APP/gnb_config.c
openair2/GNB_APP/gnb_config.c
+64
-0
openair2/XNAP/xnap_gNB_defs.h
openair2/XNAP/xnap_gNB_defs.h
+95
-0
openair2/XNAP/xnap_gNB_management_procedures.c
openair2/XNAP/xnap_gNB_management_procedures.c
+175
-0
openair2/XNAP/xnap_gNB_management_procedures.h
openair2/XNAP/xnap_gNB_management_procedures.h
+46
-0
openair2/XNAP/xnap_gNB_task.c
openair2/XNAP/xnap_gNB_task.c
+150
-0
openair2/XNAP/xnap_gNB_task.h
openair2/XNAP/xnap_gNB_task.h
+41
-0
No files found.
openair2/COMMON/xnap_messages_def.h
0 → 100644
View file @
665e3e38
/*
* 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 xnap_messages_def.h
* \author Sreeshma Shiv <sreeshmau@iisc.ac.in>
* \date August 2023
* \version 1.0
*/
/* gNB application layer -> XNAP messages */
MESSAGE_DEF
(
XNAP_REGISTER_GNB_REQ
,
MESSAGE_PRIORITY_MED
,
xnap_register_gnb_req_t
,
xnap_register_gnb_req
)
/* XNAP -> gNB application layer messages */
/* handover messages XNAP <-> RRC */
MESSAGE_DEF
(
XNAP_SETUP_REQ
,
MESSAGE_PRIORITY_MED
,
xnap_setup_req_t
,
xnap_setup_req
)
MESSAGE_DEF
(
XNAP_SETUP_RESP
,
MESSAGE_PRIORITY_MED
,
xnap_setup_resp_t
,
xnap_setup_resp
)
MESSAGE_DEF
(
XNAP_SETUP_FAILURE
,
MESSAGE_PRIORITY_MED
,
xnap_setup_failure_t
,
xnap_setup_failure
)
openair2/COMMON/xnap_messages_types.h
0 → 100644
View file @
665e3e38
/*
* 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 xnap_messages_types.h
* \author Sreeshma Shiv <sreeshmau@iisc.ac.in>
* \date August 2023
* \version 1.0
*/
#ifndef XNAP_MESSAGES_TYPES_H_
#define XNAP_MESSAGES_TYPES_H_
// Defines to access message fields.
#define XNAP_REGISTER_GNB_REQ(mSGpTR) (mSGpTR)->ittiMsg.xnap_register_gnb_req
#define XNAP_SETUP_REQ(mSGpTR) (mSGpTR)->ittiMsg.xnap_setup_req
#define XNAP_SETUP_RESP(mSGpTR) (mSGpTR)->ittiMsg.xnap_setup_resp
#define XNAP_SETUP_FAILURE(mSGpTR) (mSGpTR)->ittiMsg.xnap_setup_failure
#define XNAP_MAX_NB_GNB_IP_ADDRESS 4
// gNB application layer -> XNAP messages
typedef
struct
xnap_net_ip_address_s
{
unsigned
ipv4
:
1
;
unsigned
ipv6
:
1
;
char
ipv4_address
[
16
];
char
ipv6_address
[
46
];
}
xnap_net_ip_address_t
;
typedef
struct
xnap_sctp_s
{
uint16_t
sctp_in_streams
;
uint16_t
sctp_out_streams
;
}
xnap_sctp_t
;
typedef
struct
xnap_net_config_t
{
uint8_t
nb_xn
;
xnap_net_ip_address_t
gnb_xn_ip_address
;
xnap_net_ip_address_t
target_gnb_xn_ip_address
[
XNAP_MAX_NB_GNB_IP_ADDRESS
];
uint32_t
gnb_port_for_XNC
;
xnap_sctp_t
sctp_streams
;
}
xnap_net_config_t
;
typedef
struct
xnap_plmn_t
{
uint16_t
mcc
;
uint16_t
mnc
;
uint8_t
mnc_digit_length
;
}
xnap_plmn_t
;
typedef
struct
xnap_amf_regioninfo_s
{
uint16_t
mcc
;
uint16_t
mnc
;
uint8_t
mnc_len
;
uint8_t
amf_region_id
;
}
xnap_amf_regioninfo_t
;
typedef
enum
xnap_mode_t
{
XNAP_MODE_TDD
=
0
,
XNAP_MODE_FDD
=
1
}
xnap_mode_t
;
typedef
struct
xnap_nr_frequency_info_t
{
uint32_t
arfcn
;
int
band
;
}
xnap_nr_frequency_info_t
;
typedef
struct
xnap_transmission_bandwidth_t
{
uint8_t
scs
;
uint16_t
nrb
;
}
xnap_transmission_bandwidth_t
;
typedef
struct
xnap_fdd_info_t
{
xnap_nr_frequency_info_t
ul_freqinfo
;
xnap_nr_frequency_info_t
dl_freqinfo
;
xnap_transmission_bandwidth_t
ul_tbw
;
xnap_transmission_bandwidth_t
dl_tbw
;
}
xnap_fdd_info_t
;
typedef
struct
xnap_tdd_info_t
{
xnap_nr_frequency_info_t
freqinfo
;
xnap_transmission_bandwidth_t
tbw
;
}
xnap_tdd_info_t
;
typedef
struct
xnap_snssai_s
{
uint8_t
sst
;
uint8_t
sd
;
}
xnap_snssai_t
;
typedef
struct
xnap_served_cell_info_t
{
// NR CGI
xnap_plmn_t
plmn
;
uint64_t
nr_cellid
;
// NR Global Cell Id
uint16_t
nr_pci
;
// NR Physical Cell Ids
/* Tracking area code */
uint32_t
tac
;
xnap_mode_t
mode
;
union
{
xnap_fdd_info_t
fdd
;
xnap_tdd_info_t
tdd
;
};
char
*
measurement_timing_information
;
}
xnap_served_cell_info_t
;
typedef
struct
xnap_setup_req_s
{
uint64_t
gNB_id
;
/* Tracking area code */
uint16_t
num_tai
;
uint32_t
tai_support
;
xnap_plmn_t
plmn_support
;
// Number of slide support items
uint16_t
num_snssai
;
xnap_snssai_t
snssai
[
2
];
xnap_amf_regioninfo_t
amf_region_info
;
uint8_t
num_cells_available
;
xnap_served_cell_info_t
info
;
}
xnap_setup_req_t
;
typedef
struct
xnap_setup_resp_s
{
int64_t
gNB_id
;
/* Tracking area code */
uint16_t
num_tai
;
uint32_t
tai_support
;
xnap_plmn_t
plmn_support
;
// Number of slide support items
uint16_t
num_ssi
;
uint8_t
sst
;
uint8_t
sd
;
uint16_t
nb_xn
;
//number of gNBs connected
xnap_served_cell_info_t
info
;
}
xnap_setup_resp_t
;
typedef
struct
xnap_register_gnb_req_s
{
xnap_setup_req_t
setup_req
;
xnap_net_config_t
net_config
;
char
*
gNB_name
;
}
xnap_register_gnb_req_t
;
typedef
enum
xnap_Cause_e
{
XNAP_CAUSE_NOTHING
,
/* No components present */
XNAP_CAUSE_RADIO_NETWORK
,
XNAP_CAUSE_TRANSPORT
,
XNAP_CAUSE_PROTOCOL
,
XNAP_CAUSE_MISC
,
}
xnap_Cause_t
;
typedef
struct
xnap_setup_failure_s
{
long
cause_value
;
xnap_Cause_t
cause_type
;
uint16_t
time_to_wait
;
uint16_t
criticality_diagnostics
;
}
xnap_setup_failure_t
;
#endif
/* XNAP_MESSAGES_TYPES_H_ */
openair2/GNB_APP/gnb_app.c
View file @
665e3e38
...
...
@@ -154,6 +154,14 @@ void *gNB_app_task(void *args_p)
itti_send_msg_to_task
(
TASK_CUCP_E1
,
0
,
msg
);
}
if
(
is_xnap_enabled
())
{
if
(
itti_create_task
(
TASK_CU_XNAP
,
xnap_task
,
NULL
)
<
0
)
{
LOG_E
(
XNAP
,
"Create task for XNAP failed
\n
"
);
}
}
else
{
LOG_I
(
XNAP
,
"XNAP is disabled.
\n
"
);
}
if
(
node_type
==
ngran_gNB_CUUP
)
{
AssertFatal
(
false
,
"To run CU-UP use executable nr-cuup
\n
"
);
}
...
...
openair2/GNB_APP/gnb_config.c
View file @
665e3e38
...
...
@@ -2239,6 +2239,70 @@ int gNB_app_handle_f1ap_gnb_cu_configuration_update(f1ap_gnb_cu_configuration_up
return
(
ret
);
}
xnap_net_config_t
Read_IPconfig_Xn
(
void
)
{
char
*
cidr
=
NULL
;
char
*
address
=
NULL
;
char
*
gnb_ipv4_address_for_NGU
=
NULL
;
uint32_t
gnb_port_for_NGU
=
0
;
char
*
gnb_ipv4_address_for_S1U
=
NULL
;
uint32_t
gnb_port_for_S1U
=
0
;
xnap_net_config_t
nc
=
{
0
};
paramdef_t
XnParams
[]
=
XnPARAMS_DESC
;
paramlist_def_t
XnParamList
=
{
GNB_CONFIG_STRING_TARGET_GNB_Xn_IP_ADDRESS
,
NULL
,
0
};
paramdef_t
NETParams
[]
=
GNBNETPARAMS_DESC
;
paramdef_t
SCTPParams
[]
=
GNBSCTPPARAMS_DESC
;
char
aprefix
[
MAX_OPTNAME_SIZE
*
2
+
8
];
config_getlist
(
config_get_if
(),
&
XnParamList
,
XnParams
,
sizeofArray
(
XnParams
),
aprefix
);
AssertFatal
(
XnParamList
.
numelt
<=
XNAP_MAX_NB_GNB_IP_ADDRESS
,
"value of XnParamList.numelt %d must be lower than XnAP_MAX_NB_GNB_IP_ADDRESS %d value: reconsider to increase "
"XNAP_MAX_NB_GNB_IP_ADDRESS
\n
"
,
XnParamList
.
numelt
,
XNAP_MAX_NB_GNB_IP_ADDRESS
);
for
(
int
l
=
0
;
l
<
XnParamList
.
numelt
;
l
++
)
{
nc
.
nb_xn
+=
1
;
strcpy
(
nc
.
target_gnb_xn_ip_address
[
l
].
ipv4_address
,
*
(
XnParamList
.
paramarray
[
l
][
GNB_Xn_IPV4_ADDRESS_IDX
].
strptr
));
strcpy
(
nc
.
target_gnb_xn_ip_address
[
l
].
ipv6_address
,
*
(
XnParamList
.
paramarray
[
l
][
GNB_Xn_IPV6_ADDRESS_IDX
].
strptr
));
if
(
strcmp
(
*
(
XnParamList
.
paramarray
[
l
][
GNB_Xn_IP_ADDRESS_PREFERENCE_IDX
].
strptr
),
"ipv4"
)
==
0
)
{
nc
.
target_gnb_xn_ip_address
[
l
].
ipv4
=
1
;
nc
.
target_gnb_xn_ip_address
[
l
].
ipv6
=
0
;
}
else
if
(
strcmp
(
*
(
XnParamList
.
paramarray
[
l
][
GNB_Xn_IP_ADDRESS_PREFERENCE_IDX
].
strptr
),
"ipv6"
)
==
0
)
{
nc
.
target_gnb_xn_ip_address
[
l
].
ipv4
=
0
;
nc
.
target_gnb_xn_ip_address
[
l
].
ipv6
=
1
;
}
else
if
(
strcmp
(
*
(
XnParamList
.
paramarray
[
l
][
GNB_Xn_IP_ADDRESS_PREFERENCE_IDX
].
strptr
),
"no"
)
==
0
)
{
nc
.
target_gnb_xn_ip_address
[
l
].
ipv4
=
1
;
nc
.
target_gnb_xn_ip_address
[
l
].
ipv6
=
1
;
}
}
sprintf
(
aprefix
,
"%s.[%i].%s"
,
GNB_CONFIG_STRING_GNB_LIST
,
0
,
GNB_CONFIG_STRING_NETWORK_INTERFACES_CONFIG
);
// NETWORK_INTERFACES
config_get
(
config_get_if
(),
NETParams
,
sizeofArray
(
NETParams
),
aprefix
);
nc
.
gnb_port_for_XNC
=
(
uint32_t
)
*
(
NETParams
[
GNB_PORT_FOR_XNC_IDX
].
uptr
);
if
((
NETParams
[
GNB_IPV4_ADDR_FOR_XNC_IDX
].
strptr
==
NULL
)
||
(
nc
.
gnb_port_for_XNC
==
0
))
{
LOG_E
(
RRC
,
"Add gNB IPv4 address and/or port for XNC in the CONF file!
\n
"
);
exit
(
1
);
}
cidr
=
*
(
NETParams
[
GNB_IPV4_ADDR_FOR_XNC_IDX
].
strptr
);
char
*
save
=
NULL
;
address
=
strtok_r
(
cidr
,
"/"
,
&
save
);
nc
.
gnb_xn_ip_address
.
ipv6
=
0
;
nc
.
gnb_xn_ip_address
.
ipv4
=
1
;
strcpy
(
nc
.
gnb_xn_ip_address
.
ipv4_address
,
address
);
// SCTP SETTING
nc
.
sctp_streams
.
sctp_out_streams
=
SCTP_OUT_STREAMS
;
nc
.
sctp_streams
.
sctp_in_streams
=
SCTP_IN_STREAMS
;
if
(
get_softmodem_params
()
->
sa
)
{
// sprintf(aprefix, "%s.[%i].%s", GNB_CONFIG_STRING_GNB_LIST, 0, GNB_CONFIG_STRING_SCTP_CONFIG);
config_get
(
config_get_if
(),
SCTPParams
,
sizeofArray
(
SCTPParams
),
aprefix
);
nc
.
sctp_streams
.
sctp_in_streams
=
(
uint16_t
)
*
(
SCTPParams
[
GNB_SCTP_INSTREAMS_IDX
].
uptr
);
nc
.
sctp_streams
.
sctp_out_streams
=
(
uint16_t
)
*
(
SCTPParams
[
GNB_SCTP_OUTSTREAMS_IDX
].
uptr
);
}
return
nc
;
}
ngran_node_t
get_node_type
(
void
)
{
paramdef_t
MacRLC_Params
[]
=
MACRLCPARAMS_DESC
;
...
...
openair2/XNAP/xnap_gNB_defs.h
0 → 100644
View file @
665e3e38
/* 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 <stdint.h>
#include "queue.h"
#include "tree.h"
#include "sctp_eNB_defs.h"
#include "xnap_messages_types.h"
#ifndef XNAP_GNB_DEFS_H_
#define XNAP_GNB_DEFS_H_
#define XNAP_GNB_NAME_LENGTH_MAX (150)
typedef
enum
{
/* Disconnected state: initial state for any association. */
XNAP_GNB_STATE_DISCONNECTED
=
0x0
,
/* State waiting for xn Setup response message if the target gNB accepts or
* Xn Setup failure if rejects the gNB.
*/
XNAP_GNB_STATE_WAITING
=
0x1
,
/* The gNB is successfully connected to another gNB. */
XNAP_GNB_STATE_CONNECTED
=
0x2
,
/* XnAP is ready, and the gNB is successfully connected to another gNB. */
XNAP_GNB_STATE_READY
=
0x3
,
XNAP_GNB_STATE_OVERLOAD
=
0x4
,
XNAP_GNB_STATE_RESETTING
=
0x5
,
/* Max number of states available */
XNAP_GNB_STATE_MAX
,
}
xnap_gNB_state_t
;
struct
xnap_gNB_instance_s
;
/* This structure describes association of gNBs over Xn */
typedef
struct
xnap_gNB_data_t
{
/* gNB descriptors tree, ordered by sctp assoc id */
RB_ENTRY
(
xnap_gNB_data_t
)
entry
;
char
*
gNB_name
;
/* target gNB ID */
uint64_t
gNB_id
;
/* Current gNB->gNB XnAP association state */
xnap_gNB_state_t
state
;
/* Number of input/ouput streams */
uint16_t
in_streams
;
uint16_t
out_streams
;
/* Connexion id used between SCTP/XNAP */
uint16_t
cnx_id
;
/* SCTP association id */
sctp_assoc_t
assoc_id
;
}
xnap_gNB_data_t
;
typedef
struct
xnap_gNB_instance_s
{
/* Number of target gNBs requested by gNB (tree size) */
uint32_t
xn_target_gnb_nb
;
/* Number of target gNBs for which association is pending */
uint32_t
xn_target_gnb_pending_nb
;
/* Number of target gNB successfully associated to gNB */
uint32_t
xn_target_gnb_associated_nb
;
/* Tree of XNAP gNB associations ordered by association ID */
RB_HEAD
(
xnap_gnb_tree
,
xnap_gNB_data_t
)
xnap_gnbs
;
// gNBs, indexed by assoc_id
size_t
num_gnbs
;
instance_t
instance
;
xnap_setup_req_t
setup_req
;
/* The gNB IP address to bind */
xnap_net_config_t
net_config
;
/* SCTP information */
xnap_sctp_t
sctp_streams
;
char
*
gNB_name
;
}
xnap_gNB_instance_t
;
#endif
/* XNAP_GNB_DEFS_H_ */
openair2/XNAP/xnap_gNB_management_procedures.c
0 → 100644
View file @
665e3e38
/*
* 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 <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "intertask_interface.h"
#include "assertions.h"
#include "conversions.h"
#include "xnap_common.h"
#include "xnap_gNB_defs.h"
#include "xnap_gNB_task.h"
// xnap_gNB_internal_data_t xnap_gNB_internal_data;
static
xnap_gNB_instance_t
*
xn_inst
[
NUMBER_OF_gNB_MAX
]
=
{
0
};
static
int
xnap_gNB_compare_assoc_id
(
const
xnap_gNB_data_t
*
p1
,
const
xnap_gNB_data_t
*
p2
)
{
if
(
p1
->
assoc_id
>
p2
->
assoc_id
)
return
1
;
if
(
p1
->
assoc_id
==
p2
->
assoc_id
)
return
0
;
return
-
1
;
/* p1->assoc_id < p1->assoc_id */
}
RB_GENERATE
(
xnap_gnb_tree
,
xnap_gNB_data_t
,
entry
,
xnap_gNB_compare_assoc_id
);
/*int xnap_gNB_compare_assoc_id(struct xnap_gNB_data_s *p1, struct xnap_gNB_data_s *p2)
{
if (p1->assoc_id == -1) {
if (p1->cnx_id < p2->cnx_id) {
return -1;
}
if (p1->cnx_id > p2->cnx_id) {
return 1;
}
} else {
if (p1->assoc_id < p2->assoc_id) {
return -1;
}
if (p1->assoc_id > p2->assoc_id) {
return 1;
}
}
return 0;
}*/
static
pthread_mutex_t
xn_inst_mtx
=
PTHREAD_MUTEX_INITIALIZER
;
void
createXninst
(
instance_t
instanceP
,
xnap_setup_req_t
*
req
,
xnap_net_config_t
*
nc
)
{
DevAssert
(
instanceP
==
0
);
pthread_mutex_lock
(
&
xn_inst_mtx
);
AssertFatal
(
xn_inst
[
0
]
==
NULL
,
"Attempted to initialize multiple Xn instances
\n
"
);
xn_inst
[
0
]
=
calloc
(
1
,
sizeof
(
xnap_gNB_instance_t
));
AssertFatal
(
xn_inst
[
0
]
!=
NULL
,
"out of memory
\n
"
);
if
(
req
)
xn_inst
[
0
]
->
setup_req
=
*
req
;
if
(
nc
)
xn_inst
[
0
]
->
net_config
=
*
nc
;
pthread_mutex_unlock
(
&
xn_inst_mtx
);
}
void
xnap_dump_trees
(
const
instance_t
instance
)
{
pthread_mutex_lock
(
&
xn_inst_mtx
);
printf
(
"%ld connected gNBs
\n
"
,
xn_inst
[
instance
]
->
num_gnbs
);
xnap_gNB_data_t
*
xnap_gnb_data_p
=
NULL
;
/* cast is necessary to eliminate warning "discards ‘const’ qualifier" */
RB_FOREACH
(
xnap_gnb_data_p
,
xnap_gnb_tree
,
&
((
xnap_gNB_instance_t
*
)
xn_inst
[
instance
])
->
xnap_gnbs
)
{
if
(
xnap_gnb_data_p
->
assoc_id
==
-
1
)
{
printf
(
"integrated gNB"
);
printf
(
"cnx_id %d
\n
"
,
xnap_gnb_data_p
->
cnx_id
);
}
else
{
printf
(
"assoc_id %d"
,
xnap_gnb_data_p
->
assoc_id
);
printf
(
"state %d
\n
"
,
xnap_gnb_data_p
->
state
);
printf
(
"cnx_id %d
\n
"
,
xnap_gnb_data_p
->
cnx_id
);
}
}
pthread_mutex_unlock
(
&
xn_inst_mtx
);
}
xnap_gNB_data_t
*
xnap_get_gNB
(
instance_t
instance
,
sctp_assoc_t
assoc_id
)
{
AssertFatal
(
assoc_id
!=
0
,
"illegal assoc_id == 0: should be -1 or >0)
\n
"
);
xnap_gNB_data_t
e
=
{.
assoc_id
=
assoc_id
};
pthread_mutex_lock
(
&
xn_inst_mtx
);
xnap_gNB_data_t
*
xnap_gnb
=
RB_FIND
(
xnap_gnb_tree
,
&
xn_inst
[
instance
]
->
xnap_gnbs
,
&
e
);
if
(
xnap_gnb
==
NULL
)
{
LOG_W
(
NR_RRC
,
"no gNB connected or not found for assoc_id %d:
\n
"
,
assoc_id
);
pthread_mutex_unlock
(
&
xn_inst_mtx
);
return
NULL
;
}
pthread_mutex_unlock
(
&
xn_inst_mtx
);
return
xnap_gnb
;
}
xnap_gNB_instance_t
*
xnap_gNB_get_instance
(
instance_t
instanceP
)
{
DevAssert
(
instanceP
==
0
);
pthread_mutex_lock
(
&
xn_inst_mtx
);
xnap_gNB_instance_t
*
instance_xnap
=
xn_inst
[
instanceP
];
pthread_mutex_unlock
(
&
xn_inst_mtx
);
return
instance_xnap
;
}
void
xnap_insert_gnb
(
instance_t
instance
,
xnap_gNB_data_t
*
xnap_gnb_data_p
)
{
pthread_mutex_lock
(
&
xn_inst_mtx
);
RB_INSERT
(
xnap_gnb_tree
,
&
xn_inst
[
instance
]
->
xnap_gnbs
,
xnap_gnb_data_p
);
xn_inst
[
instance
]
->
num_gnbs
++
;
pthread_mutex_unlock
(
&
xn_inst_mtx
);
}
void
xnap_handle_xn_setup_message
(
instance_t
instance
,
sctp_assoc_t
assoc_id
,
int
sctp_shutdown
)
{
if
(
sctp_shutdown
)
{
/* A previously connected gNB has been shutdown */
xnap_gNB_data_t
*
gnb_data_p
=
xnap_get_gNB
(
instance
,
assoc_id
);
if
(
gnb_data_p
==
NULL
)
{
LOG_W
(
XNAP
,
"no gNB connected or not found for assoc_id %d:
\n
"
,
assoc_id
);
return
;
}
pthread_mutex_lock
(
&
xn_inst_mtx
);
if
(
gnb_data_p
->
state
==
XNAP_GNB_STATE_CONNECTED
)
{
gnb_data_p
->
state
=
XNAP_GNB_STATE_DISCONNECTED
;
// Removing the gNB data from tree
RB_REMOVE
(
xnap_gnb_tree
,
&
xn_inst
[
instance
]
->
xnap_gnbs
,
gnb_data_p
);
if
(
xn_inst
[
instance
]
->
xn_target_gnb_associated_nb
>
0
)
{
/* Decrease associated gNB number */
xn_inst
[
instance
]
->
xn_target_gnb_associated_nb
--
;
}
/* If there are no more associated gNB */
if
(
xn_inst
[
instance
]
->
xn_target_gnb_associated_nb
==
0
)
{
// TODO : Inform GNB_APP ???
LOG_I
(
XNAP
,
"No more associated gNBs- Number of connected gNBS : %d
\n
"
,
xn_inst
[
instance
]
->
xn_target_gnb_associated_nb
);
}
}
}
else
{
/* Check that at least one setup message is pending */
DevCheck
(
xn_inst
[
instance
]
->
xn_target_gnb_pending_nb
>
0
,
instance
,
xn_inst
[
instance
]
->
xn_target_gnb_pending_nb
,
0
);
if
(
xn_inst
[
instance
]
->
xn_target_gnb_pending_nb
>
0
)
{
/* Decrease pending messages number */
xn_inst
[
instance
]
->
xn_target_gnb_pending_nb
--
;
}
/* If there are no more pending messages */
if
(
xn_inst
[
instance
]
->
xn_target_gnb_pending_nb
==
0
)
{
// TODO : Need to inform GNB_APP??
LOG_I
(
XNAP
,
"No more pending messages- Number of connected gNBS : %d"
,
xn_inst
[
instance
]
->
xn_target_gnb_associated_nb
);
}
}
pthread_mutex_unlock
(
&
xn_inst_mtx
);
}
openair2/XNAP/xnap_gNB_management_procedures.h
0 → 100644
View file @
665e3e38
/*
* 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 __XNAP_GNB_MANAGEMENT_PROCEDURES__H__
#define __XNAP_GNB_MANAGEMENT_PROCEDURES__H__
// void xnap_gNB_prepare_internal_data(void);
void
createXninst
(
instance_t
instanceP
,
xnap_setup_req_t
*
req
,
xnap_net_config_t
*
nc
);
// void xnap_dump_trees(void);
void
xnap_dump_trees
(
const
instance_t
instance
);
// void xnap_gNB_insert_new_instance(xnap_gNB_instance_t *new_instance_p);
xnap_gNB_instance_t
*
xnap_gNB_get_instance
(
instance_t
instanceP
);
// uint16_t xnap_gNB_fetch_add_global_cnx_id(void);
// void xnap_gNB_prepare_internal_data(void);
// xnap_gNB_data_t *xnap_is_gNB_id_in_list(uint32_t gNB_id);
// xnap_gNB_data_t *xnap_is_gNB_assoc_id_in_list(uint32_t sctp_assoc_id);
// xnap_gNB_data_t *xnap_is_gNB_pci_in_list(const uint32_t pci);
xnap_gNB_data_t
*
xnap_get_gNB
(
instance_t
instance
,
sctp_assoc_t
assoc_id
);
void
xnap_insert_gnb
(
instance_t
instance
,
xnap_gNB_data_t
*
xnap_gnb_data_p
);
void
xnap_handle_xn_setup_message
(
instance_t
instance
,
sctp_assoc_t
assoc_id
,
int
sctp_shutdown
);
#endif
/* __XNAP_GNB_MANAGEMENT_PROCEDURES__H__ */
openair2/XNAP/xnap_gNB_task.c
0 → 100644
View file @
665e3e38
/* 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 XNAP/xnap_gNB_task.c
* \brief XNAP tasks and functions definitions
* \author Sreeshma Shiv
* \date Aug 2023
* \version 1.0
* \email: sreeshmau@iisc.ac.in
*/
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <arpa/inet.h>
#include "intertask_interface.h"
#include <openair3/ocp-gtpu/gtp_itf.h>
#include "xnap_gNB_task.h"
#include "xnap_gNB_defs.h"
#include "xnap_gNB_management_procedures.h"
#include "xnap_gNB_handler.h"
#include "queue.h"
#include "assertions.h"
#include "conversions.h"
RB_PROTOTYPE
(
xnap_gnb_tree
,
xnap_gNB_data_t
,
entry
,
xnap_gNB_compare_assoc_id
);
void
*
xnap_task
(
void
*
arg
)
{
MessageDef
*
received_msg
=
NULL
;
int
result
;
LOG_D
(
XNAP
,
"Starting XNAP layer
\n
"
);
itti_mark_task_ready
(
TASK_XNAP
);
const
int
instance
=
0
;
xnap_net_config_t
xn_net_config
=
Read_IPconfig_Xn
();
createXninst
(
instance
,
NULL
,
xn_net_config
);
while
(
1
)
{
itti_receive_msg
(
TASK_XNAP
,
&
received_msg
);
LOG_D
(
XNAP
,
"Received message %d:%s
\n
"
,
ITTI_MSG_ID
(
received_msg
),
ITTI_MSG_NAME
(
received_msg
));
switch
(
ITTI_MSG_ID
(
received_msg
))
{
case
TERMINATE_MESSAGE
:
LOG_W
(
XNAP
,
"Exiting XNAP thread
\n
"
);
itti_exit_task
();
break
;
case
XNAP_REGISTER_GNB_REQ
:
{
xnap_gNB_init_sctp
(
ITTI_MSG_DESTINATION_INSTANCE
(
received_msg
),
xn_nc
);
}
break
;
case
XNAP_SETUP_FAILURE
:
// from rrc/xnap
xnap_gNB_generate_xn_setup_failure
(
ITTI_MSG_ORIGIN_INSTANCE
(
received_msg
),
&
XNAP_SETUP_FAILURE
(
received_msg
));
break
;
case
XNAP_SETUP_RESP
:
// from rrc
xnap_gNB_generate_xn_setup_response
(
ITTI_MSG_ORIGIN_INSTANCE
(
received_msg
),
&
XNAP_SETUP_RESP
(
received_msg
));
break
;
case
SCTP_INIT_MSG_MULTI_CNF
:
xnap_gNB_handle_sctp_init_msg_multi_cnf
(
ITTI_MSG_DESTINATION_INSTANCE
(
received_msg
),
&
received_msg
->
ittiMsg
.
sctp_init_msg_multi_cnf
);
break
;
case
SCTP_NEW_ASSOCIATION_RESP
:
xnap_gNB_handle_sctp_association_resp
(
ITTI_MSG_DESTINATION_INSTANCE
(
received_msg
),
&
received_msg
->
ittiMsg
.
sctp_new_association_resp
);
break
;
case
SCTP_NEW_ASSOCIATION_IND
:
xnap_gNB_handle_sctp_association_ind
(
ITTI_MSG_DESTINATION_INSTANCE
(
received_msg
),
&
received_msg
->
ittiMsg
.
sctp_new_association_ind
);
break
;
case
SCTP_DATA_IND
:
xnap_gNB_handle_sctp_data_ind
(
ITTI_MSG_DESTINATION_INSTANCE
(
received_msg
),
&
received_msg
->
ittiMsg
.
sctp_data_ind
);
break
;
default:
LOG_E
(
XNAP
,
"Received unhandled message: %d:%s
\n
"
,
ITTI_MSG_ID
(
received_msg
),
ITTI_MSG_NAME
(
received_msg
));
break
;
}
result
=
itti_free
(
ITTI_MSG_ORIGIN_ID
(
received_msg
),
received_msg
);
AssertFatal
(
result
==
EXIT_SUCCESS
,
"Failed to free memory (%d)!
\n
"
,
result
);
received_msg
=
NULL
;
}
return
NULL
;
}
#include "common/config/config_userapi.h"
int
is_xnap_enabled
(
void
)
{
static
volatile
int
config_loaded
=
0
;
static
volatile
int
enabled
=
0
;
static
pthread_mutex_t
mutex
=
PTHREAD_MUTEX_INITIALIZER
;
if
(
pthread_mutex_lock
(
&
mutex
))
goto
mutex_error
;
if
(
config_loaded
)
{
if
(
pthread_mutex_unlock
(
&
mutex
))
goto
mutex_error
;
return
enabled
;
}
char
*
enable_xn
=
NULL
;
paramdef_t
p
[]
=
{{
"enable_xn"
,
"yes/no"
,
0
,
.
strptr
=
&
enable_xn
,
.
defstrval
=
""
,
TYPE_STRING
,
0
}};
/* TODO: do it per module - we check only first gNB */
config_get
(
config_get_if
(),
p
,
sizeofArray
(
p
),
"gNBs.[0]"
);
if
(
enable_xn
!=
NULL
&&
strcmp
(
enable_xn
,
"yes"
)
==
0
)
{
enabled
=
1
;
}
/*Consider also the case of enabling XnAP for a gNB by parsing a gNB configuration file*/
config_get
(
config_get_if
(),
p
,
sizeofArray
(
p
),
"gNBs.[0]"
);
if
(
enable_xn
!=
NULL
&&
strcmp
(
enable_xn
,
"yes"
)
==
0
)
{
enabled
=
1
;
}
config_loaded
=
1
;
if
(
pthread_mutex_unlock
(
&
mutex
))
goto
mutex_error
;
return
enabled
;
mutex_error:
LOG_E
(
XNAP
,
"mutex error
\n
"
);
exit
(
1
);
}
openair2/XNAP/xnap_gNB_task.h
0 → 100644
View file @
665e3e38
/* 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 <stdio.h>
#include <stdint.h>
#ifndef XNAP_H_
#define XNAP_H_
#define XNAP_SCTP_PPID (61) ///< XNAP SCTP Payload Protocol Identifier (PPID)
#include "xnap_gNB_defs.h"
int
xnap_gNB_init_sctp
(
instance_t
instance_p
,
xnap_net_config_t
*
nc
);
void
*
xnap_task
(
void
*
arg
);
int
is_xnap_enabled
(
void
);
void
xnap_trigger
(
void
);
#endif
/* XNAP_H_ */
/**
* @}
*/
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment