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
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
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
OpenXG
OpenXG-RAN
Commits
6266239c
Commit
6266239c
authored
Feb 03, 2025
by
Teodora
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add <subscribe> RPC for M-plane
parent
07bab2a7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
177 additions
and
0 deletions
+177
-0
radio/fhi_72/mplane/CMakeLists.txt
radio/fhi_72/mplane/CMakeLists.txt
+1
-0
radio/fhi_72/mplane/init-mplane.c
radio/fhi_72/mplane/init-mplane.c
+12
-0
radio/fhi_72/mplane/subscribe-mplane.c
radio/fhi_72/mplane/subscribe-mplane.c
+133
-0
radio/fhi_72/mplane/subscribe-mplane.h
radio/fhi_72/mplane/subscribe-mplane.h
+31
-0
No files found.
radio/fhi_72/mplane/CMakeLists.txt
View file @
6266239c
...
...
@@ -29,6 +29,7 @@ target_sources(oran_fhlib_5g_mplane PRIVATE
connect-mplane.c
rpc-send-recv.c
get-mplane.c
subscribe-mplane.c
xml/get-xml.c
)
...
...
radio/fhi_72/mplane/init-mplane.c
View file @
6266239c
...
...
@@ -22,6 +22,7 @@
#include "init-mplane.h"
#include "radio/fhi_72/oran-params.h"
#include "get-mplane.h"
#include "subscribe-mplane.h"
#include "xml/get-xml.h"
#include <libyang/libyang.h>
...
...
@@ -147,6 +148,17 @@ bool manage_ru(ru_session_t *ru_session, const openair0_config_t *oai, const siz
ptp_state
=
true
;
}
/* 1) as per M-plane spec, RU must be in supervised mode,
where stream = NULL && filter = "/o-ran-supervision:supervision-notification";
2) additionally, we want to subscribe to PTP state change,
where stream = NULL && filter = "/o-ran-sync:synchronization-state-change";
=> since more than one subscription at the time within one session is not possible, we will subscribe to all notifications */
const
char
*
stream
=
"NETCONF"
;
const
char
*
filter
=
NULL
;
ru_session
->
ru_notif
.
ptp_state
=
ptp_state
;
success
=
subscribe_mplane
(
ru_session
,
stream
,
filter
,
(
void
*
)
&
ru_session
->
ru_notif
);
AssertError
(
success
,
return
false
,
"[MPLANE] Unable to continue: could not get RU answer via subscribe_mplane().
\n
"
);
free
(
operational_ds
);
return
true
;
...
...
radio/fhi_72/mplane/subscribe-mplane.c
0 → 100644
View file @
6266239c
/*
* 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 "subscribe-mplane.h"
#include "rpc-send-recv.h"
#include "common/utils/assertions.h"
#include <libyang/libyang.h>
#include <nc_client.h>
#ifdef MPLANE_V1
static
void
recv_notif_v1
(
const
struct
nc_notif
*
notif
,
ru_notif_t
*
answer
)
{
const
char
*
node_name
=
notif
->
tree
->
child
->
attr
->
name
;
const
char
*
value
=
notif
->
tree
->
child
->
attr
->
value_str
;
if
(
strcmp
(
node_name
,
"sync-state"
))
{
if
(
strcmp
(
value
,
"LOCKED"
)
==
0
)
{
answer
->
ptp_state
=
true
;
}
else
{
answer
->
ptp_state
=
false
;
}
}
// carriers state - to be filled
}
static
void
notif_clb_v1
(
struct
nc_session
*
session
,
const
struct
nc_notif
*
notif
)
{
ru_notif_t
*
answer
=
nc_session_get_data
(
session
);
LYD_FORMAT
output_format
=
LYD_JSON
;
char
*
subs_reply
=
NULL
;
lyd_print_mem
(
&
subs_reply
,
notif
->
tree
,
output_format
,
LYP_WITHSIBLINGS
);
MP_LOG_I
(
"
\n
Received notification at (%s)
\n
%s
\n
"
,
notif
->
datetime
,
subs_reply
);
recv_notif_v1
(
notif
,
answer
);
}
#elif MPLANE_V2
static
void
recv_notif_v2
(
struct
lyd_node_inner
*
op
,
ru_notif_t
*
answer
)
{
const
char
*
notif
=
op
->
schema
->
name
;
if
(
strcmp
(
notif
,
"synchronization-state-change"
)
==
0
)
{
const
char
*
value
=
lyd_get_value
(
op
->
child
);
if
(
strcmp
(
value
,
"LOCKED"
)
==
0
)
{
answer
->
ptp_state
=
true
;
}
else
{
// "FREERUN" or "HOLDOVER"
answer
->
ptp_state
=
false
;
}
}
else
if
(
strcmp
(
notif
,
"rx-array-carriers-state-change"
)
==
0
)
{
const
char
*
value
=
lyd_get_value
(
lyd_child
(
op
->
child
)
->
next
);
if
(
strcmp
(
value
,
"READY"
)
==
0
)
{
answer
->
rx_carrier_state
=
true
;
}
else
{
// "DISABLED" or "BUSY"
answer
->
rx_carrier_state
=
false
;
}
}
else
if
(
strcmp
(
notif
,
"tx-array-carriers-state-change"
)
==
0
)
{
const
char
*
value
=
lyd_get_value
(
lyd_child
(
op
->
child
)
->
next
);
if
(
strcmp
(
value
,
"READY"
)
==
0
)
{
answer
->
tx_carrier_state
=
true
;
}
else
{
// "DISABLED" or "BUSY"
answer
->
tx_carrier_state
=
false
;
}
}
}
static
void
notif_clb_v2
(
struct
nc_session
*
session
,
const
struct
lyd_node
*
envp
,
const
struct
lyd_node
*
op
,
void
*
user_data
)
{
ru_notif_t
*
answer
=
(
ru_notif_t
*
)
user_data
;
LYD_FORMAT
output_format
=
LYD_JSON
;
char
*
subs_reply
=
NULL
;
lyd_print_mem
(
&
subs_reply
,
op
,
output_format
,
LYD_PRINT_WITHSIBLINGS
);
const
char
*
ru_ip_add
=
nc_session_get_host
(
session
);
MP_LOG_I
(
"Received notification from RU
\"
%s
\"
at (%s)
\n
%s
\n
"
,
ru_ip_add
,
((
struct
lyd_node_opaq
*
)
lyd_child
(
envp
))
->
value
,
subs_reply
);
recv_notif_v2
((
struct
lyd_node_inner
*
)
op
,
answer
);
}
#endif
bool
subscribe_mplane
(
ru_session_t
*
ru_session
,
const
char
*
stream
,
const
char
*
filter
,
void
*
answer
)
{
int
timeout
=
CLI_RPC_REPLY_TIMEOUT
;
struct
nc_rpc
*
rpc
;
NC_WD_MODE
wd
=
NC_WD_ALL
;
NC_PARAMTYPE
param
=
NC_PARAMTYPE_CONST
;
char
*
start_time
=
NULL
,
*
stop_time
=
NULL
;
MP_LOG_I
(
"RPC request to RU
\"
%s
\"
= <subscribe> with stream
\"
%s
\"
and filter
\"
%s
\"
.
\n
"
,
ru_session
->
ru_ip_add
,
stream
,
filter
);
rpc
=
nc_rpc_subscribe
(
stream
,
NULL
,
start_time
,
stop_time
,
param
);
AssertError
(
rpc
!=
NULL
,
return
false
,
"[MPLANE] <subscribe> RPC creation failed.
\n
"
);
/* create notification thread so that notifications can immediately be received */
#ifdef MPLANE_V1
if
(
!
nc_session_ntf_thread_running
(
ru_session
->
session
))
{
nc_session_set_data
(
ru_session
->
session
,
answer
);
int
ret
=
nc_recv_notif_dispatch
(
ru_session
->
session
,
notif_clb_v1
);
AssertError
(
ret
==
0
,
return
false
,
"[MPLANE] Failed to create notification thread.
\n
"
);
}
else
{
MP_LOG_I
(
"Notification thread is already running for RU %s.
\n
"
,
ru_session
->
ru_ip_add
);
}
#elif MPLANE_V2
int
ret
=
nc_recv_notif_dispatch_data
(
ru_session
->
session
,
notif_clb_v2
,
answer
,
NULL
);
AssertError
(
ret
==
0
,
return
false
,
"[MPLANE] Failed to create notification thread.
\n
"
);
#endif
bool
success
=
rpc_send_recv
((
struct
nc_session
*
)
ru_session
->
session
,
rpc
,
wd
,
timeout
,
NULL
);
AssertError
(
success
,
return
false
,
"[MPLANE] Failed to subscribe to: stream
\"
%s
\"
, filter
\"
%s
\"
.
\n
"
,
stream
,
filter
);
MP_LOG_I
(
"Successfully subscribed to all notifications from RU
\"
%s
\"
.
\n
"
,
ru_session
->
ru_ip_add
);
nc_rpc_free
(
rpc
);
return
true
;
}
radio/fhi_72/mplane/subscribe-mplane.h
0 → 100644
View file @
6266239c
/*
* 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 SUBSCRIBE_MPLANE_H
#define SUBSCRIBE_MPLANE_H
#include "ru-mplane-api.h"
#include <stdbool.h>
bool
subscribe_mplane
(
ru_session_t
*
ru_session
,
const
char
*
stream
,
const
char
*
filter
,
void
*
answer
);
#endif
/* SUBSCRIBE_MPLANE_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