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
canghaiwuhen
OpenXG-RAN
Commits
f63cf659
Commit
f63cf659
authored
Aug 28, 2019
by
Robert Schmidt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FlexRAN: Improve handling of received shared objects
parent
5d9c61ea
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
16 deletions
+59
-16
openair2/ENB_APP/flexran_agent_common.c
openair2/ENB_APP/flexran_agent_common.c
+58
-16
openair2/ENB_APP/flexran_agent_common.h
openair2/ENB_APP/flexran_agent_common.h
+1
-0
No files found.
openair2/ENB_APP/flexran_agent_common.c
View file @
f63cf659
...
...
@@ -29,6 +29,9 @@
#include <stdio.h>
#include <time.h>
#include <sys/stat.h>
#include <dlfcn.h>
#include <fcntl.h>
#include <errno.h>
#include "flexran_agent_common.h"
#include "flexran_agent_common_internal.h"
...
...
@@ -424,26 +427,49 @@ long timer_end(struct timespec start_time) {
int
flexran_agent_control_delegation
(
mid_t
mod_id
,
const
void
*
params
,
Protocol__FlexranMessage
**
msg
)
{
Protocol__FlexranMessage
*
input
=
(
Protocol__FlexranMessage
*
)
params
;
Protocol__FlexControlDelegation
*
control_delegation_msg
=
input
->
control_delegation_msg
;
// struct timespec vartime = timer_start();
//Write the payload lib into a file in the cache and load the lib
char
lib_name
[
120
];
*
msg
=
NULL
;
char
target
[
512
];
snprintf
(
lib_name
,
sizeof
(
lib_name
),
"/%s.so"
,
control_delegation_msg
->
name
);
strcpy
(
target
,
RC
.
flexran
[
mod_id
]
->
cache_name
);
strcat
(
target
,
lib_name
);
FILE
*
f
;
f
=
fopen
(
target
,
"wb"
);
if
(
f
)
{
fwrite
(
control_delegation_msg
->
payload
.
data
,
control_delegation_msg
->
payload
.
len
,
1
,
f
);
fclose
(
f
);
int
len
=
snprintf
(
target
,
sizeof
(
target
),
"%s/libflex.%s.so"
,
RC
.
flexran
[
mod_id
]
->
cache_name
,
control_delegation_msg
->
name
);
if
(
len
>=
sizeof
(
target
))
{
LOG_E
(
FLEXRAN_AGENT
,
"target has been truncated, cannot write file
\n
"
);
return
0
;
}
/* use low-level API: check whether exists while creating so we can abort if
* it exists to not overwrite anything */
int
fd
=
open
(
target
,
O_CREAT
|
O_WRONLY
|
O_EXCL
,
S_IRUSR
|
S_IWUSR
);
if
(
fd
>=
0
)
{
ssize_t
l
=
write
(
fd
,
control_delegation_msg
->
payload
.
data
,
control_delegation_msg
->
payload
.
len
);
close
(
fd
);
if
(
l
<
control_delegation_msg
->
payload
.
len
)
{
LOG_E
(
FLEXRAN_AGENT
,
"could not write complete control delegation to %s: only %ld out of "
"%ld bytes
\n
"
,
target
,
l
,
control_delegation_msg
->
payload
.
len
);
return
0
;
}
else
if
(
l
<
0
)
{
LOG_E
(
FLEXRAN_AGENT
,
"can not write control delegation data to %s: %s
\n
"
,
target
,
strerror
(
errno
));
return
0
;
}
LOG_I
(
FLEXRAN_AGENT
,
"wrote shared object %s
\n
"
,
target
);
}
else
{
LOG_W
(
FLEXRAN_AGENT
,
"[%d] can not write control delegation data to %s
\n
"
,
mod_id
,
target
);
if
(
errno
==
EEXIST
)
{
LOG_I
(
FLEXRAN_AGENT
,
"file %s already exists, remove it first
\n
"
,
target
);
}
else
{
LOG_E
(
FLEXRAN_AGENT
,
"can not write control delegation data to %s: %s
\n
"
,
target
,
strerror
(
errno
));
return
0
;
}
}
// long time_elapsed_nanos = timer_end(vartime);
*
msg
=
NULL
;
return
0
;
}
...
...
@@ -452,6 +478,22 @@ int flexran_agent_destroy_control_delegation(Protocol__FlexranMessage *msg) {
return
0
;
}
void
*
flexran_agent_load_delegated_code
(
mid_t
mod_id
,
const
char
*
name
)
{
char
target
[
512
];
int
len
=
snprintf
(
target
,
sizeof
(
target
),
"%s/libflex.%s.so"
,
RC
.
flexran
[
mod_id
]
->
cache_name
,
name
);
if
(
len
>=
sizeof
(
target
))
{
LOG_E
(
FLEXRAN_AGENT
,
"target has been truncated, cannot read object
\n
"
);
return
0
;
}
LOG_I
(
FLEXRAN_AGENT
,
"Opening pushed code: %s
\n
"
,
target
);
void
*
lib
=
dlopen
(
target
,
RTLD_NOW
);
if
(
lib
==
NULL
)
LOG_E
(
FLEXRAN_AGENT
,
"Could not load library: %s
\n
"
,
dlerror
());
return
lib
;
}
int
flexran_agent_reconfiguration
(
mid_t
mod_id
,
const
void
*
params
,
Protocol__FlexranMessage
**
msg
)
{
Protocol__FlexranMessage
*
input
=
(
Protocol__FlexranMessage
*
)
params
;
Protocol__FlexAgentReconfiguration
*
agent_reconfiguration_msg
=
input
->
agent_reconfiguration_msg
;
...
...
openair2/ENB_APP/flexran_agent_common.h
View file @
f63cf659
...
...
@@ -131,6 +131,7 @@ int flexran_agent_destroy_lc_config_request(Protocol__FlexranMessage *msg);
/* Control delegation message constructor and destructor */
int
flexran_agent_control_delegation
(
mid_t
mod_id
,
const
void
*
params
,
Protocol__FlexranMessage
**
msg
);
int
flexran_agent_destroy_control_delegation
(
Protocol__FlexranMessage
*
msg
);
void
*
flexran_agent_load_delegated_code
(
mid_t
mod_id
,
const
char
*
name
);
/* Policy reconfiguration message constructor and destructor */
int
flexran_agent_reconfiguration
(
mid_t
mod_id
,
const
void
*
params
,
Protocol__FlexranMessage
**
msg
);
...
...
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