FlexRAN delegation: mapper function to return path name
This commit is contained in:
@@ -478,20 +478,22 @@ int flexran_agent_destroy_control_delegation(Protocol__FlexranMessage *msg) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *flexran_agent_load_delegated_code(mid_t mod_id, const char *name) {
|
int flexran_agent_map_name_to_delegated_object(mid_t mod_id, const char *name,
|
||||||
char target[512];
|
char *path, int maxlen) {
|
||||||
int len = snprintf(target, sizeof(target), "%s/libflex.%s.so",
|
int len = snprintf(path, maxlen, "%s/libflex.%s.so",
|
||||||
RC.flexran[mod_id]->cache_name, name);
|
RC.flexran[mod_id]->cache_name, name);
|
||||||
if (len >= sizeof(target)) {
|
if (len >= maxlen) {
|
||||||
LOG_E(FLEXRAN_AGENT, "target has been truncated, cannot read object\n");
|
LOG_E(FLEXRAN_AGENT, "path has been truncated, cannot read object\n");
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_I(FLEXRAN_AGENT, "Opening pushed code: %s\n", target);
|
struct stat buf;
|
||||||
void *lib = dlopen(target, RTLD_NOW);
|
int status = stat(path, &buf);
|
||||||
if (lib == NULL)
|
if (status < 0) {
|
||||||
LOG_E(FLEXRAN_AGENT, "Could not load library: %s\n", dlerror());
|
LOG_E(FLEXRAN_AGENT, "Could not stat object %s: %s\n", path, strerror(errno));
|
||||||
return lib;
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int flexran_agent_reconfiguration(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg) {
|
int flexran_agent_reconfiguration(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg) {
|
||||||
|
|||||||
@@ -131,7 +131,12 @@ int flexran_agent_destroy_lc_config_request(Protocol__FlexranMessage *msg);
|
|||||||
/* Control delegation message constructor and destructor */
|
/* Control delegation message constructor and destructor */
|
||||||
int flexran_agent_control_delegation(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg);
|
int flexran_agent_control_delegation(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg);
|
||||||
int flexran_agent_destroy_control_delegation(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);
|
/* Map a name from a control_delegation message to a file name. The function
|
||||||
|
* stat()s the file to check existence and returns the complete path name in
|
||||||
|
* path. The length in path needs to be maxlen, the maximum length the path may
|
||||||
|
* have. */
|
||||||
|
int flexran_agent_map_name_to_delegated_object(mid_t mod_id, const char *name,
|
||||||
|
char *path, int maxlen);
|
||||||
|
|
||||||
/* Policy reconfiguration message constructor and destructor */
|
/* Policy reconfiguration message constructor and destructor */
|
||||||
int flexran_agent_reconfiguration(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg);
|
int flexran_agent_reconfiguration(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg);
|
||||||
|
|||||||
Reference in New Issue
Block a user