summaryrefslogtreecommitdiffstats
path: root/ctrl/facemgr/src
diff options
context:
space:
mode:
authorJordan Augé <jordan.auge+fdio@cisco.com>2019-11-24 23:51:45 +0100
committerJordan Augé <jordan.auge+fdio@cisco.com>2019-11-24 23:51:45 +0100
commit93b0b7a95922defa19951dde01b1dce4047bb0e7 (patch)
tree4eb6b79102522e7b58461e00436cac9e1e823657 /ctrl/facemgr/src
parent02fef955058d47f869f18f9c675f7cdca2be0695 (diff)
[HICN-408] Add a face manager interface for face priority control
Change-Id: I768112c920154380a614d0c5858f50efa135903d Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com>
Diffstat (limited to 'ctrl/facemgr/src')
-rw-r--r--ctrl/facemgr/src/api.c20
-rw-r--r--ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c2
-rw-r--r--ctrl/facemgr/src/interfaces/priority_controller/priority_controller.c29
3 files changed, 17 insertions, 34 deletions
diff --git a/ctrl/facemgr/src/api.c b/ctrl/facemgr/src/api.c
index 01b6e52f3..18a25d6a1 100644
--- a/ctrl/facemgr/src/api.c
+++ b/ctrl/facemgr/src/api.c
@@ -549,26 +549,6 @@ facelet_cache_lookup(const facelet_set_t * facelet_cache, facelet_t * facelet,
facelet_t ***cached_facelets)
{
assert(facelet);
- if (!facelet_has_family(facelet))
- return 0;
-#if 0 // key is no more sufficient now that we support multiple faces per interface
- /*
- * If the facelet is uniquely identified by its key, it is used to perform
- * an efficient lookup directly...
- */
- if (facelet_has_key(facelet)) {
- facelet_t * found = NULL;
- if (facelet_set_get(facelet_cache, facelet, &found) < 0) {
- ERROR("[facelet_cache_lookup] Error during cache lookup");
- return -1;
- }
- if (!found)
- return 0;
- *cached_facelets = malloc(sizeof(facelet_t*));
- *cached_facelets[0] = found;
- return 1;
- }
-#endif
/* ...otherwise, we iterate over the facelet
* cache to find matching elements.
diff --git a/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c b/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c
index 4ba4c5b1f..cb1a0040d 100644
--- a/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c
+++ b/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c
@@ -449,7 +449,7 @@ int hl_on_event(interface_t * interface, const facelet_t * facelet)
}
INFO("Admin state updated");
}
- if (facelet_get_admin_state_status(facelet) == FACELET_ATTR_STATUS_DIRTY) {
+ if (facelet_get_priority_status(facelet) == FACELET_ATTR_STATUS_DIRTY) {
hc_face.face = *face;
hc_face_t * face_found;
diff --git a/ctrl/facemgr/src/interfaces/priority_controller/priority_controller.c b/ctrl/facemgr/src/interfaces/priority_controller/priority_controller.c
index 5c5afdb6c..b8e7271bb 100644
--- a/ctrl/facemgr/src/interfaces/priority_controller/priority_controller.c
+++ b/ctrl/facemgr/src/interfaces/priority_controller/priority_controller.c
@@ -22,7 +22,7 @@ int priority_controller_initialize(interface_t * interface, void * cfg)
pc_data_t * data = malloc(sizeof(pc_data_t));
if (!data) {
INFO("Priority controller data memory allocation error");
- return -1;
+ goto ERR_MALLOC;
}
interface->data = data;
@@ -32,7 +32,7 @@ int priority_controller_initialize(interface_t * interface, void * cfg)
if (data->fd < 0) {
INFO("Priority controller socket error");
perror("socket error");
- return -1;
+ goto ERR_SOCKET;
}
memset(&addr, 0, sizeof(addr));
@@ -43,12 +43,23 @@ int priority_controller_initialize(interface_t * interface, void * cfg)
if (bind(data->fd, (struct sockaddr*)&addr, sizeof(addr)) < 0) {
INFO("Priority controller socket bind error");
perror("bind error");
- return -1;
+ goto ERR_BIND;
+ }
+ if (interface_register_fd(interface, data->fd, NULL) < 0) {
+ ERROR("[priority_controller_initialize] Error registering fd");
+ goto ERR_FD;
}
- interface_register_fd(interface, data->fd, NULL);
INFO("Priority controller successfully initialized");
- return data->fd;
+ return 0;
+
+ERR_FD:
+ERR_BIND:
+ close(data->fd);
+ERR_SOCKET:
+ free(data);
+ERR_MALLOC:
+ return -1;
}
int priority_controller_finalize(interface_t * interface)
@@ -67,12 +78,6 @@ int priority_controller_callback(interface_t * interface, int fd, void * unused)
char buf[100];
int rc;
- struct sockaddr_in addr;
- memset(&addr, 0, sizeof(addr));
- addr.sin_family = AF_INET;
- addr.sin_addr.s_addr = inet_addr("127.0.0.1");
- addr.sin_port = htons(9533);
-
INFO("Priority controller receiving command");
rc = recv(data->fd, buf, 100, 0);
@@ -119,8 +124,6 @@ int priority_controller_callback(interface_t * interface, int fd, void * unused)
interface_raise_event(interface, facelet_w);
interface_raise_event(interface, facelet_c);
- facelet_free(facelet_w);
- facelet_free(facelet_c);
return 0;
}
8'>378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424