aboutsummaryrefslogtreecommitdiffstats
path: root/ctrl/libhicnctrl
diff options
context:
space:
mode:
authorJordan Augé <jordan.auge+fdio@cisco.com>2019-11-12 00:15:11 +0100
committerJordan Augé <jordan.auge+fdio@cisco.com>2019-11-17 00:56:51 +0100
commit45bc09ae553e7ac5bf6cd7ab2e77e7f6d0877596 (patch)
tree347cd702a5d3914e003401158b916c709caa302e /ctrl/libhicnctrl
parent547acf3eed92d3564139cccf205c852178bcc310 (diff)
[HICN-395] Static face/route maintainance though face manager
Change-Id: I8f2287a262412bacc50f3c89756ec9fd6ce30d33 Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com>
Diffstat (limited to 'ctrl/libhicnctrl')
-rw-r--r--ctrl/libhicnctrl/includes/hicn/ctrl/api.h1
-rw-r--r--ctrl/libhicnctrl/includes/hicn/ctrl/route.h1
-rw-r--r--ctrl/libhicnctrl/src/api.c17
-rw-r--r--ctrl/libhicnctrl/src/cli.c2
-rw-r--r--ctrl/libhicnctrl/src/face.c1
-rw-r--r--ctrl/libhicnctrl/src/route.c10
6 files changed, 23 insertions, 9 deletions
diff --git a/ctrl/libhicnctrl/includes/hicn/ctrl/api.h b/ctrl/libhicnctrl/includes/hicn/ctrl/api.h
index b3032d0f3..d6bb282cb 100644
--- a/ctrl/libhicnctrl/includes/hicn/ctrl/api.h
+++ b/ctrl/libhicnctrl/includes/hicn/ctrl/api.h
@@ -599,6 +599,7 @@ int hc_route_parse(void * in, hc_route_t * route);
int hc_route_create(hc_sock_t * s, hc_route_t * route);
int hc_route_delete(hc_sock_t * s, hc_route_t * route);
int hc_route_list(hc_sock_t * s, hc_data_t ** pdata);
+int hc_route_list_async(hc_sock_t * s);
#define foreach_route(VAR, data) foreach_type(hc_route_t, VAR, data)
diff --git a/ctrl/libhicnctrl/includes/hicn/ctrl/route.h b/ctrl/libhicnctrl/includes/hicn/ctrl/route.h
index f67cccf93..2b96d22cc 100644
--- a/ctrl/libhicnctrl/includes/hicn/ctrl/route.h
+++ b/ctrl/libhicnctrl/includes/hicn/ctrl/route.h
@@ -31,6 +31,7 @@ typedef struct hicn_route_s hicn_route_t;
#define MAXSZ_ROUTE MAXSZ_ROUTE_ + NULLTERM
hicn_route_t * hicn_route_create(ip_prefix_t * prefix, face_id_t face_id, route_cost_t cost);
+hicn_route_t * hicn_route_dup(const hicn_route_t * route);
void hicn_route_free(hicn_route_t * route);
int hicn_route_cmp(const hicn_route_t * route1, const hicn_route_t * route2);
diff --git a/ctrl/libhicnctrl/src/api.c b/ctrl/libhicnctrl/src/api.c
index 6c9b54a92..74a8821e2 100644
--- a/ctrl/libhicnctrl/src/api.c
+++ b/ctrl/libhicnctrl/src/api.c
@@ -715,7 +715,6 @@ hc_sock_process(hc_sock_t * s, hc_data_t ** data)
available -= num_chunks * s->cur_request->data->in_element_size;
s->roff += num_chunks * s->cur_request->data->in_element_size;
if (s->remaining == 0) {
- printf("done, sock map remove\n");
if (hc_sock_map_remove(s->map, s->cur_request->seq, NULL) < 0) {
ERROR("[hc_sock_process] Error removing request from map");
return -1;
@@ -856,7 +855,6 @@ hc_execute_command(hc_sock_t * s, hc_msg_t * msg, size_t msg_len,
ERROR("[hc_execute_command] Could not get next sequence number");
goto ERR_SEQ;
}
- printf("Sending message with seq %d\n", seq);
/* Create state used to process the request */
hc_sock_request_t * request = NULL;
@@ -867,7 +865,6 @@ hc_execute_command(hc_sock_t * s, hc_msg_t * msg, size_t msg_len,
}
/* Add state to map */
- printf("sock map add\n");
if (hc_sock_map_add(s->map, seq, request) < 0) {
ERROR("[hc_execute_command] Error adding request state to map");
goto ERR_MAP;
@@ -1815,9 +1812,9 @@ hc_route_list(hc_sock_t * s, hc_data_t ** pdata)
}
int
-hc_route_list_async(hc_sock_t * s, hc_data_t ** pdata)
+hc_route_list_async(hc_sock_t * s)
{
- return _hc_route_list(s, pdata, true);
+ return _hc_route_list(s, NULL, true);
}
/* ROUTE PARSE */
@@ -1978,6 +1975,8 @@ hc_face_to_connection(const hc_face_t * face, hc_connection_t * connection, bool
} else {
memset(connection->name, 0, SYMBOLIC_NAME_LEN);
}
+ snprintf(connection->interface_name, INTERFACE_LEN, "%s",
+ f->netdevice.name);
break;
default:
return -1;
@@ -2366,7 +2365,7 @@ hc_connection_parse_to_face(void * in, hc_face_t * face)
int
-hc_face_list_async(hc_sock_t * s) //, hc_data_t ** pdata)
+hc_face_list_async(hc_sock_t * s)
{
struct {
header_control_message hdr;
@@ -2451,9 +2450,10 @@ hc_face_snprintf(char * s, size_t size, hc_face_t * face)
if (rc < 0)
return rc;
- return snprintf(s, size, "[#%d %s] %s %s %s %s/%s (%s)",
+ return snprintf(s, size, "[#%d %s] %s %s %s %s %s/%s (%s)",
face->id,
face->name,
+ face->face.netdevice.index != NETDEVICE_UNDEFINED_INDEX ? face->face.netdevice.name : "*",
face_type_str[face->face.type],
local,
remote,
@@ -2461,9 +2461,10 @@ hc_face_snprintf(char * s, size_t size, hc_face_t * face)
face_state_str[face->face.admin_state],
tags);
#else
- return snprintf(s, size, "[#%d %s] %s %s %s %s/%s",
+ return snprintf(s, size, "[#%d %s] %s %s %s %s %s/%s",
face->id,
face->name,
+ face->face.netdevice.index != NETDEVICE_UNDEFINED_INDEX ? face->face.netdevice.name : "*",
face_type_str[face->face.type],
local,
remote,
diff --git a/ctrl/libhicnctrl/src/cli.c b/ctrl/libhicnctrl/src/cli.c
index a171f7045..879454c3a 100644
--- a/ctrl/libhicnctrl/src/cli.c
+++ b/ctrl/libhicnctrl/src/cli.c
@@ -379,7 +379,7 @@ parse_options(int argc, char *argv[], hc_command_t * command)
case OBJECT_FACE:
switch(command->action) {
case ACTION_CREATE:
- if ((argc - optind != 6) && (argc - optind != 7)) {
+ if ((argc - optind != 5) && (argc - optind != 6)) {
usage_face_create(argv[0], true, false);
goto ERR_PARAM;
}
diff --git a/ctrl/libhicnctrl/src/face.c b/ctrl/libhicnctrl/src/face.c
index 41ff58f81..0e25890da 100644
--- a/ctrl/libhicnctrl/src/face.c
+++ b/ctrl/libhicnctrl/src/face.c
@@ -129,6 +129,7 @@ netdevice_get_name(const netdevice_t * netdevice, const char ** name)
int
netdevice_set_name(netdevice_t * netdevice, const char * name)
{
+ memset(netdevice->name, 0, sizeof(netdevice->name));
int rc = snprintf(netdevice->name, IFNAMSIZ, "%s", name);
if (rc < 0)
return -1;
diff --git a/ctrl/libhicnctrl/src/route.c b/ctrl/libhicnctrl/src/route.c
index 61434871b..703b4763f 100644
--- a/ctrl/libhicnctrl/src/route.c
+++ b/ctrl/libhicnctrl/src/route.c
@@ -43,6 +43,16 @@ hicn_route_create(ip_prefix_t * prefix, face_id_t face_id, route_cost_t cost)
return route;
}
+hicn_route_t *
+hicn_route_dup(const hicn_route_t * route)
+{
+ hicn_route_t * new_route = malloc(sizeof(hicn_route_t));
+ if (!route)
+ return NULL;
+ memcpy(new_route, route, sizeof(hicn_route_t));
+ return new_route;
+}
+
void hicn_route_free(hicn_route_t * route)
{
free(route);