aboutsummaryrefslogtreecommitdiffstats
path: root/ctrl
diff options
context:
space:
mode:
Diffstat (limited to 'ctrl')
-rw-r--r--ctrl/libhicnctrl/includes/hicn/ctrl/api.h4
-rw-r--r--ctrl/libhicnctrl/includes/hicn/ctrl/hicn-light.h24
-rw-r--r--ctrl/libhicnctrl/includes/hicn/ctrl/objects/mapme.h7
-rw-r--r--ctrl/libhicnctrl/src/CMakeLists.txt6
-rw-r--r--ctrl/libhicnctrl/src/commands/command_cache.c20
-rw-r--r--ctrl/libhicnctrl/src/commands/command_connection.c19
-rw-r--r--ctrl/libhicnctrl/src/commands/command_face.c19
-rw-r--r--ctrl/libhicnctrl/src/commands/command_listener.c19
-rw-r--r--ctrl/libhicnctrl/src/commands/command_mapme.c19
-rw-r--r--ctrl/libhicnctrl/src/commands/command_policy.c20
-rw-r--r--ctrl/libhicnctrl/src/commands/command_punting.c20
-rw-r--r--ctrl/libhicnctrl/src/commands/command_route.c65
-rw-r--r--ctrl/libhicnctrl/src/commands/command_stats.c19
-rw-r--r--ctrl/libhicnctrl/src/commands/command_strategy.c19
-rw-r--r--ctrl/libhicnctrl/src/commands/command_subscription.c19
-rw-r--r--ctrl/libhicnctrl/src/hicnctrl.c9
-rw-r--r--ctrl/libhicnctrl/src/module.h22
-rw-r--r--ctrl/libhicnctrl/src/module_object_vft.h4
-rw-r--r--ctrl/libhicnctrl/src/modules/CMakeLists.txt4
-rw-r--r--ctrl/libhicnctrl/src/modules/hicn_light.c12
-rw-r--r--ctrl/libhicnctrl/src/modules/hicn_light/mapme.c183
-rw-r--r--ctrl/libhicnctrl/src/modules/hicn_light/mapme.h28
-rw-r--r--ctrl/libhicnctrl/src/object_private.h24
-rw-r--r--ctrl/libhicnctrl/src/object_vft.c28
-rw-r--r--ctrl/libhicnctrl/src/objects/mapme.c95
-rw-r--r--ctrl/libhicnctrl/src/objects/mapme.h30
-rw-r--r--ctrl/libhicnctrl/src/objects/route.c25
27 files changed, 584 insertions, 179 deletions
diff --git a/ctrl/libhicnctrl/includes/hicn/ctrl/api.h b/ctrl/libhicnctrl/includes/hicn/ctrl/api.h
index ad3f8fcc3..87f0e955d 100644
--- a/ctrl/libhicnctrl/includes/hicn/ctrl/api.h
+++ b/ctrl/libhicnctrl/includes/hicn/ctrl/api.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021 Cisco and/or its affiliates.
+ * Copyright (c) 2021-2023 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -303,7 +303,7 @@ int hc_mapme_set(hc_sock_t *s, hc_mapme_t *mapme);
int hc_mapme_set_discovery(hc_sock_t *s, hc_mapme_t *mapme);
int hc_mapme_set_timescale(hc_sock_t *s, hc_mapme_t *mapme);
int hc_mapme_set_retx(hc_sock_t *s, hc_mapme_t *mapme);
-int hc_mapme_send_update(hc_sock_t *s, hc_mapme_t *mapme);
+int hc_mapme_create(hc_sock_t *s, hc_mapme_t *mapme);
int hc_policy_create(hc_sock_t *s, hc_policy_t *policy);
int hc_policy_delete(hc_sock_t *s, hc_policy_t *policy);
diff --git a/ctrl/libhicnctrl/includes/hicn/ctrl/hicn-light.h b/ctrl/libhicnctrl/includes/hicn/ctrl/hicn-light.h
index 426b82fa9..3e3e98c35 100644
--- a/ctrl/libhicnctrl/includes/hicn/ctrl/hicn-light.h
+++ b/ctrl/libhicnctrl/includes/hicn/ctrl/hicn-light.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022 Cisco and/or its affiliates.
+ * Copyright (c) 2021-2023 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -14,14 +14,14 @@
*/
/*
- * @file commands.h
- * @brief All hicn-light commands: 14 in total.
+ * @file hicn-light.h
+ * @brief hicn-light specifics.
*
* Header and payload in binary format.
*/
-#ifndef HICN_CTRL_HICNLIGHTNG_H
-#define HICN_CTRL_HICNLIGHTNG_H
+#ifndef HICN_CTRL_HICNLIGHT_H
+#define HICN_CTRL_HICNLIGHT_H
#ifndef _WIN32
#include <netinet/in.h>
@@ -84,7 +84,7 @@ typedef enum {
_(mapme_set_discovery, MAPME_SET_DISCOVERY) \
_(mapme_set_timescale, MAPME_SET_TIMESCALE) \
_(mapme_set_retx, MAPME_SET_RETX) \
- _(mapme_send_update, MAPME_SEND_UPDATE) \
+ _(mapme_add, MAPME_ADD) \
_(policy_add, POLICY_ADD) \
_(policy_remove, POLICY_REMOVE) \
_(policy_list, POLICY_LIST) \
@@ -302,8 +302,16 @@ typedef cmd_mapme_timing_t cmd_mapme_set_timescale_t;
typedef cmd_mapme_timing_t cmd_mapme_set_retx_t;
typedef struct {
+ hicn_ip_address_t address;
+ uint32_t face_id;
+ uint8_t family;
+ uint8_t len;
+} cmd_mapme_add_t;
+
+/* dummy */
+typedef struct {
void *_;
-} cmd_mapme_send_update_t;
+} cmd_mapme_list_item_t;
/* Policy */
@@ -538,4 +546,4 @@ ssize_t hc_light_command_serialize(hc_action_t action,
int hc_sock_initialize_module(hc_sock_t *s);
-#endif /* HICN_CTRL_HICNLIGHTNG_H */
+#endif /* HICN_CTRL_HICNLIGHT_H */
diff --git a/ctrl/libhicnctrl/includes/hicn/ctrl/objects/mapme.h b/ctrl/libhicnctrl/includes/hicn/ctrl/objects/mapme.h
index 37623ebfe..3eda1bfaa 100644
--- a/ctrl/libhicnctrl/includes/hicn/ctrl/objects/mapme.h
+++ b/ctrl/libhicnctrl/includes/hicn/ctrl/objects/mapme.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022 Cisco and/or its affiliates.
+ * Copyright (c) 2021-2023 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -51,8 +51,9 @@ typedef struct {
uint32_t timescale; // Milliseconds
hicn_ip_address_t address;
- int family;
- u8 len;
+ uint8_t family;
+ uint8_t len;
+ uint32_t face_id;
} hc_mapme_t;
#endif /* HICNCTRL_OBJECTS_MAPME_H */
diff --git a/ctrl/libhicnctrl/src/CMakeLists.txt b/ctrl/libhicnctrl/src/CMakeLists.txt
index 5dbd70ffe..3ea5c5db9 100644
--- a/ctrl/libhicnctrl/src/CMakeLists.txt
+++ b/ctrl/libhicnctrl/src/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2021-2022 Cisco and/or its affiliates.
+# Copyright (c) 2021-2023 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
@@ -39,6 +39,7 @@ set(SOURCE_FILES
objects/connection.c
objects/face.c
objects/listener.c
+ objects/mapme.c
objects/route.c
objects/strategy.c
objects/stats.c
@@ -56,6 +57,7 @@ set(HEADER_FILES
objects/connection.h
objects/face.h
objects/listener.h
+ objects/mapme.h
objects/route.h
objects/stats.h
objects/strategy.h
@@ -115,6 +117,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES Android OR ${CMAKE_SYSTEM_NAME} MATCHES iOS)
${CMAKE_CURRENT_SOURCE_DIR}/modules/hicn_light/connection.c
${CMAKE_CURRENT_SOURCE_DIR}/modules/hicn_light/face.c
${CMAKE_CURRENT_SOURCE_DIR}/modules/hicn_light/listener.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/modules/hicn_light/mapme.c
${CMAKE_CURRENT_SOURCE_DIR}/modules/hicn_light/route.c
${CMAKE_CURRENT_SOURCE_DIR}/modules/hicn_light/stats.c
${CMAKE_CURRENT_SOURCE_DIR}/modules/hicn_light/strategy.c
@@ -124,6 +127,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES Android OR ${CMAKE_SYSTEM_NAME} MATCHES iOS)
${CMAKE_CURRENT_SOURCE_DIR}/modules/hicn_light/connection.h
${CMAKE_CURRENT_SOURCE_DIR}/modules/hicn_light/face.h
${CMAKE_CURRENT_SOURCE_DIR}/modules/hicn_light/listener.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/modules/hicn_light/mapme.h
${CMAKE_CURRENT_SOURCE_DIR}/modules/hicn_light/route.h
${CMAKE_CURRENT_SOURCE_DIR}/modules/hicn_light/stats.h
${CMAKE_CURRENT_SOURCE_DIR}/modules/hicn_light/strategy.h
diff --git a/ctrl/libhicnctrl/src/commands/command_cache.c b/ctrl/libhicnctrl/src/commands/command_cache.c
index 124fcd761..22cb8baaa 100644
--- a/ctrl/libhicnctrl/src/commands/command_cache.c
+++ b/ctrl/libhicnctrl/src/commands/command_cache.c
@@ -1,3 +1,23 @@
+/*
+ * Copyright (c) 2021-2023 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+/**
+ * \file command_cache.h
+ * \brief Implementation of cache command.
+ */
+
#include <math.h>
#include <hicn/ctrl/command.h>
diff --git a/ctrl/libhicnctrl/src/commands/command_connection.c b/ctrl/libhicnctrl/src/commands/command_connection.c
index 1659a9860..a43934fdf 100644
--- a/ctrl/libhicnctrl/src/commands/command_connection.c
+++ b/ctrl/libhicnctrl/src/commands/command_connection.c
@@ -1,3 +1,22 @@
+/*
+ * Copyright (c) 2021-2023 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+/**
+ * \file command_connection.h
+ * \brief Implementation of connection command.
+ */
#include <math.h>
#include <hicn/ctrl/command.h>
diff --git a/ctrl/libhicnctrl/src/commands/command_face.c b/ctrl/libhicnctrl/src/commands/command_face.c
index f60bef18d..e383de1b5 100644
--- a/ctrl/libhicnctrl/src/commands/command_face.c
+++ b/ctrl/libhicnctrl/src/commands/command_face.c
@@ -1,3 +1,22 @@
+/*
+ * Copyright (c) 2021-2023 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+/**
+ * \file command_face.h
+ * \brief Implementation of face command.
+ */
#include <hicn/ctrl/command.h>
/* Parameters */
diff --git a/ctrl/libhicnctrl/src/commands/command_listener.c b/ctrl/libhicnctrl/src/commands/command_listener.c
index cfcd22f48..604c0a672 100644
--- a/ctrl/libhicnctrl/src/commands/command_listener.c
+++ b/ctrl/libhicnctrl/src/commands/command_listener.c
@@ -1,3 +1,22 @@
+/*
+ * Copyright (c) 2021-2023 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+/**
+ * \file command_listener.h
+ * \brief Implementation of listener command.
+ */
#include <math.h>
#include <hicn/ctrl/command.h>
diff --git a/ctrl/libhicnctrl/src/commands/command_mapme.c b/ctrl/libhicnctrl/src/commands/command_mapme.c
index c67b7704f..7dcca038c 100644
--- a/ctrl/libhicnctrl/src/commands/command_mapme.c
+++ b/ctrl/libhicnctrl/src/commands/command_mapme.c
@@ -1,3 +1,22 @@
+/*
+ * Copyright (c) 2021-2023 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+/**
+ * \file command_mapme.h
+ * \brief Implementation of mapme command.
+ */
#include <math.h>
#include <hicn/ctrl/command.h>
diff --git a/ctrl/libhicnctrl/src/commands/command_policy.c b/ctrl/libhicnctrl/src/commands/command_policy.c
index 2fc7a0a42..eaf949880 100644
--- a/ctrl/libhicnctrl/src/commands/command_policy.c
+++ b/ctrl/libhicnctrl/src/commands/command_policy.c
@@ -1,3 +1,23 @@
+/*
+ * Copyright (c) 2021-2023 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+/**
+ * \file command_policy.h
+ * \brief Implementation of policy command.
+ */
+
#if 0
#include <hicn/policy.h>
diff --git a/ctrl/libhicnctrl/src/commands/command_punting.c b/ctrl/libhicnctrl/src/commands/command_punting.c
index b845c52ee..a274583b1 100644
--- a/ctrl/libhicnctrl/src/commands/command_punting.c
+++ b/ctrl/libhicnctrl/src/commands/command_punting.c
@@ -1,3 +1,23 @@
+/*
+ * Copyright (c) 2021-2023 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+/**
+ * \file command_punting.h
+ * \brief Implementation of punting command.
+ */
+
#if 0
#include <hicn/ctrl/command.h>
diff --git a/ctrl/libhicnctrl/src/commands/command_route.c b/ctrl/libhicnctrl/src/commands/command_route.c
index 5db710111..95d0a3a43 100644
--- a/ctrl/libhicnctrl/src/commands/command_route.c
+++ b/ctrl/libhicnctrl/src/commands/command_route.c
@@ -1,3 +1,23 @@
+/*
+ * Copyright (c) 2021-2023 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+/**
+ * \file command_route.c
+ * \brief Implementation of route command.
+ */
+
#include <math.h>
#include <hicn/ctrl/command.h>
#include "../objects/route.h"
@@ -22,7 +42,7 @@
.offset3 = offsetof(hc_route_t, family), \
}
-#define cost \
+#define p_cost \
{ \
.name = "cost", .help = "Positive integer representing cost.", \
.type = TYPE_INT(1, 255), .offset = offsetof(hc_route_t, cost), \
@@ -73,19 +93,41 @@
}
/* Commands */
-int on_route_create(hc_route_t* route) {
+
+int on_route_parsed(hc_route_t* route) {
if (hc_route_has_face(route)) {
route->face.admin_state = FACE_STATE_UP;
route->face.id = INVALID_FACE_ID;
}
+ route->face_id = INVALID_FACE_ID; // we populate face name
+ if (route->cost == 0) route->cost = 1;
return 0;
}
+static const command_parser_t command_route_create1 = {
+ .action = ACTION_CREATE,
+ .object_type = OBJECT_TYPE_ROUTE,
+ .nparams = 1,
+ .parameters = {prefix},
+ .post_hook = (parser_hook_t)on_route_parsed,
+};
+COMMAND_REGISTER(command_route_create1);
+
+static const command_parser_t command_route_create2 = {
+ .action = ACTION_CREATE,
+ .object_type = OBJECT_TYPE_ROUTE,
+ .nparams = 2,
+ .parameters = {symbolic_or_id, prefix},
+ .post_hook = (parser_hook_t)on_route_parsed,
+};
+COMMAND_REGISTER(command_route_create2);
+
static const command_parser_t command_route_create3 = {
.action = ACTION_CREATE,
.object_type = OBJECT_TYPE_ROUTE,
.nparams = 3,
- .parameters = {symbolic_or_id, prefix, cost},
+ .parameters = {symbolic_or_id, prefix, p_cost},
+ .post_hook = (parser_hook_t)on_route_parsed,
};
COMMAND_REGISTER(command_route_create3);
@@ -93,8 +135,8 @@ static const command_parser_t command_route_create5 = {
.action = ACTION_CREATE,
.object_type = OBJECT_TYPE_ROUTE,
.nparams = 5,
- .parameters = {prefix, cost, type_tcp_udp, remote_address, remote_port},
- .post_hook = (parser_hook_t)on_route_create,
+ .parameters = {prefix, p_cost, type_tcp_udp, remote_address, remote_port},
+ .post_hook = (parser_hook_t)on_route_parsed,
};
COMMAND_REGISTER(command_route_create5);
@@ -102,9 +144,9 @@ static const command_parser_t command_route_create6 = {
.action = ACTION_CREATE,
.object_type = OBJECT_TYPE_ROUTE,
.nparams = 6,
- .parameters = {prefix, cost, type_tcp_udp, remote_address, remote_port,
+ .parameters = {prefix, p_cost, type_tcp_udp, remote_address, remote_port,
interface},
- .post_hook = (parser_hook_t)on_route_create,
+ .post_hook = (parser_hook_t)on_route_parsed,
};
COMMAND_REGISTER(command_route_create6);
@@ -112,9 +154,9 @@ static const command_parser_t command_route_create7 = {
.action = ACTION_CREATE,
.object_type = OBJECT_TYPE_ROUTE,
.nparams = 7,
- .parameters = {prefix, cost, type_tcp_udp, local_address, local_port,
+ .parameters = {prefix, p_cost, type_tcp_udp, local_address, local_port,
remote_address, remote_port},
- .post_hook = (parser_hook_t)on_route_create,
+ .post_hook = (parser_hook_t)on_route_parsed,
};
COMMAND_REGISTER(command_route_create7);
@@ -122,9 +164,9 @@ static const command_parser_t command_route_create8 = {
.action = ACTION_CREATE,
.object_type = OBJECT_TYPE_ROUTE,
.nparams = 8,
- .parameters = {prefix, cost, type_tcp_udp, local_address, local_port,
+ .parameters = {prefix, p_cost, type_tcp_udp, local_address, local_port,
remote_address, remote_port, interface},
- .post_hook = (parser_hook_t)on_route_create,
+ .post_hook = (parser_hook_t)on_route_parsed,
};
COMMAND_REGISTER(command_route_create8);
@@ -140,5 +182,6 @@ static const command_parser_t command_route_remove = {
.object_type = OBJECT_TYPE_ROUTE,
.nparams = 2,
.parameters = {symbolic_or_id, prefix},
+ .post_hook = (parser_hook_t)on_route_parsed,
};
COMMAND_REGISTER(command_route_remove);
diff --git a/ctrl/libhicnctrl/src/commands/command_stats.c b/ctrl/libhicnctrl/src/commands/command_stats.c
index f02a68069..d69f22a19 100644
--- a/ctrl/libhicnctrl/src/commands/command_stats.c
+++ b/ctrl/libhicnctrl/src/commands/command_stats.c
@@ -1,3 +1,22 @@
+/*
+ * Copyright (c) 2021-2023 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+/**
+ * \file command_stats.h
+ * \brief Implementation of stats command.
+ */
#include <math.h>
#include <hicn/ctrl/command.h>
diff --git a/ctrl/libhicnctrl/src/commands/command_strategy.c b/ctrl/libhicnctrl/src/commands/command_strategy.c
index f7f5974d1..2aac924c4 100644
--- a/ctrl/libhicnctrl/src/commands/command_strategy.c
+++ b/ctrl/libhicnctrl/src/commands/command_strategy.c
@@ -1,3 +1,22 @@
+/*
+ * Copyright (c) 2021-2023 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+/**
+ * \file command_strategy.h
+ * \brief Implementation of strategy command.
+ */
#include <hicn/ctrl/command.h>
/* Parameters */
diff --git a/ctrl/libhicnctrl/src/commands/command_subscription.c b/ctrl/libhicnctrl/src/commands/command_subscription.c
index 886ee454a..ee2455b1c 100644
--- a/ctrl/libhicnctrl/src/commands/command_subscription.c
+++ b/ctrl/libhicnctrl/src/commands/command_subscription.c
@@ -1,3 +1,22 @@
+/*
+ * Copyright (c) 2021-2023 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+/**
+ * \file command_subscription.h
+ * \brief Implementation of subscription command.
+ */
#include <limits.h>
#include <hicn/ctrl/command.h>
diff --git a/ctrl/libhicnctrl/src/hicnctrl.c b/ctrl/libhicnctrl/src/hicnctrl.c
index fd028f64a..478997ec1 100644
--- a/ctrl/libhicnctrl/src/hicnctrl.c
+++ b/ctrl/libhicnctrl/src/hicnctrl.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022 Cisco and/or its affiliates.
+ * Copyright (c) 2021-2023 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -14,7 +14,7 @@
*/
/**
- * \file cli.c
+ * \file hicnctrl.c
* \brief Command line interface
*/
#include <ctype.h> // isalpha isalnum
@@ -122,7 +122,7 @@ void usage_forwarding_strategy(const char *prog, bool header, bool verbose) {
void usage_listener_create(const char *prog, bool header, bool verbose) {
if (header) usage_header();
- fprintf(stderr, "%s -l NAME TYPE LOCAL_ADDRESS LOCAL_PORT [INTERFACE_NAME]\n",
+ fprintf(stderr, "%s -l TYPE NAME LOCAL_ADDRESS LOCAL_PORT [INTERFACE_NAME]\n",
prog);
if (verbose)
fprintf(stderr, " Create a listener on specified address and port.\n");
@@ -323,7 +323,8 @@ USAGE:
int main(int argc, char *argv[]) {
int rc = 1;
- hc_command_t command = {0};
+ hc_command_t command;
+ memset(&command, 0, sizeof(command));
char buf[MAXSZ_HC_OBJECT];
log_conf.log_level = LOG_INFO;
diff --git a/ctrl/libhicnctrl/src/module.h b/ctrl/libhicnctrl/src/module.h
index c06f3ce86..51fd9f942 100644
--- a/ctrl/libhicnctrl/src/module.h
+++ b/ctrl/libhicnctrl/src/module.h
@@ -1,3 +1,23 @@
+/*
+ * Copyright (c) 2021-2023 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+/**
+ * \file modules.h
+ * \brief hicn-light module interface.
+ */
+
#ifndef HICNCTRL_MODULE_H
#define HICNCTRL_MODULE_H
@@ -31,11 +51,13 @@ typedef struct {
[ACTION_CREATE] = NULL, \
[ACTION_DELETE] = NULL, \
[ACTION_LIST] = NULL, \
+ [ACTION_SET] = NULL, \
}, \
.serialize = { \
[ACTION_CREATE] = NULL, \
[ACTION_DELETE] = NULL, \
[ACTION_LIST] = NULL, \
+ [ACTION_SET] = NULL, \
}, \
}
diff --git a/ctrl/libhicnctrl/src/module_object_vft.h b/ctrl/libhicnctrl/src/module_object_vft.h
deleted file mode 100644
index 2651b50a3..000000000
--- a/ctrl/libhicnctrl/src/module_object_vft.h
+++ /dev/null
@@ -1,4 +0,0 @@
-#ifndef HICNCTRL_MODULES_OBJECT_MODULE_VFT_H
-#define HICNCTRL_MODULES_OBJECT_MODULE_VFT_H
-
-#endif /* HICNCTRL_MODULES_OBJECT_MODULE_VFT_H */
diff --git a/ctrl/libhicnctrl/src/modules/CMakeLists.txt b/ctrl/libhicnctrl/src/modules/CMakeLists.txt
index f7bd2f83a..f3e1a6342 100644
--- a/ctrl/libhicnctrl/src/modules/CMakeLists.txt
+++ b/ctrl/libhicnctrl/src/modules/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2021-2022 Cisco and/or its affiliates.
+# Copyright (c) 2021-2023 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
@@ -19,6 +19,7 @@ list(APPEND HICNLIGHT_MODULE_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/hicn_light/connection.c
${CMAKE_CURRENT_SOURCE_DIR}/hicn_light/face.c
${CMAKE_CURRENT_SOURCE_DIR}/hicn_light/listener.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/hicn_light/mapme.c
${CMAKE_CURRENT_SOURCE_DIR}/hicn_light/route.c
${CMAKE_CURRENT_SOURCE_DIR}/hicn_light/stats.c
${CMAKE_CURRENT_SOURCE_DIR}/hicn_light/strategy.c
@@ -30,6 +31,7 @@ list(APPEND HICNLIGHT_MODULE_HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/hicn_light/connection.h
${CMAKE_CURRENT_SOURCE_DIR}/hicn_light/face.h
${CMAKE_CURRENT_SOURCE_DIR}/hicn_light/listener.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/hicn_light/mapme.h
${CMAKE_CURRENT_SOURCE_DIR}/hicn_light/route.h
${CMAKE_CURRENT_SOURCE_DIR}/hicn_light/stats.h
${CMAKE_CURRENT_SOURCE_DIR}/hicn_light/strategy.h
diff --git a/ctrl/libhicnctrl/src/modules/hicn_light.c b/ctrl/libhicnctrl/src/modules/hicn_light.c
index a2577c31b..96cdda2d2 100644
--- a/ctrl/libhicnctrl/src/modules/hicn_light.c
+++ b/ctrl/libhicnctrl/src/modules/hicn_light.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022 Cisco and/or its affiliates.
+ * Copyright (c) 2021-2023 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -48,8 +48,9 @@
#include "hicn_light/base.h"
#include "hicn_light/connection.h"
-#include "hicn_light/listener.h"
#include "hicn_light/face.h"
+#include "hicn_light/listener.h"
+#include "hicn_light/mapme.h"
#include "hicn_light/route.h"
#include "hicn_light/stats.h"
#include "hicn_light/strategy.h"
@@ -200,8 +201,13 @@ static int hicnlight_process_header(hc_sock_t *sock) {
}
if (!request) {
ERROR("[hc_sock_light_process] No request matching sequence number");
+ /*
+ * Currently: Ignore packet (alternatively: return 0 to discard in case of
+ * error; move s->got_header later in this case)
+ */
return -1;
}
+
sock->current_request = request;
hc_request_t *current_request = hc_request_get_current(request);
hc_data_t *data = hc_request_get_data(current_request);
@@ -1412,7 +1418,7 @@ int hc_sock_initialize_module(hc_sock_t *s) {
hc_sock_light.object_vft[OBJECT_TYPE_FACE] = HC_MODULE_OBJECT_OPS_EMPTY;
hc_sock_light.object_vft[OBJECT_TYPE_PUNTING] = HC_MODULE_OBJECT_OPS_EMPTY;
hc_sock_light.object_vft[OBJECT_TYPE_CACHE] = HC_MODULE_OBJECT_OPS_EMPTY;
- hc_sock_light.object_vft[OBJECT_TYPE_MAPME] = HC_MODULE_OBJECT_OPS_EMPTY;
+ hc_sock_light.object_vft[OBJECT_TYPE_MAPME] = hicnlight_mapme_module_ops;
hc_sock_light.object_vft[OBJECT_TYPE_WLDR] = HC_MODULE_OBJECT_OPS_EMPTY;
hc_sock_light.object_vft[OBJECT_TYPE_POLICY] = HC_MODULE_OBJECT_OPS_EMPTY;
hc_sock_light.object_vft[OBJECT_TYPE_ROUTE] = hicnlight_route_module_ops;
diff --git a/ctrl/libhicnctrl/src/modules/hicn_light/mapme.c b/ctrl/libhicnctrl/src/modules/hicn_light/mapme.c
index de75d82a8..04eb36e24 100644
--- a/ctrl/libhicnctrl/src/modules/hicn_light/mapme.c
+++ b/ctrl/libhicnctrl/src/modules/hicn_light/mapme.c
@@ -1,139 +1,68 @@
+/*
+ * Copyright (c) 2021-2023 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+/**
+ * \file modules/hicn_light/mapme.c
+ * \brief Implementation of mapme object VFT for hicn_light.
+ */
+
+#include <hicn/ctrl/hicn-light.h>
#include "mapme.h"
-static int _hcng_mapme_set(hc_sock_t *socket, int enabled) {
-#if 0
- msg_mapme_enable_t msg = {.header =
- {
- .message_type = REQUEST_LIGHT,
- .command_id = COMMAND_TYPE_MAPME_ENABLE,
- .length = 1,
- .seq_num = 0,
- },
- .payload = {
- .activate = enabled,
- }};
-
- hc_command_params_t params = {
- .cmd = ACTION_SET,
- .cmd_id = COMMAND_TYPE_MAPME_ENABLE,
- .size_in = sizeof(cmd_mapme_enable_t),
- .size_out = 0,
- .parse = NULL,
- };
-
- return _hcng_execute_command(socket, (hc_msg_t *)&msg, sizeof(msg), &params,
- NULL, false);
-#endif
- return 0; // XXX added
+static int hicnlight_mapme_parse(const uint8_t *buffer, size_t size,
+ hc_mapme_t *mapme) {
+ return -1;
}
-static int _hcng_mapme_set_discovery(hc_sock_t *socket, int enabled) {
-#if 0
- msg_mapme_enable_t msg = {
- .header =
- {
- .message_type = REQUEST_LIGHT,
- .command_id = COMMAND_TYPE_MAPME_SET_DISCOVERY,
- .length = 1,
- .seq_num = 0,
- },
- .payload = {
- .activate = enabled,
- }};
-
- hc_command_params_t params = {
- .cmd = ACTION_SET,
- .cmd_id = COMMAND_TYPE_MAPME_SET_DISCOVERY,
- .size_in = sizeof(cmd_mapme_set_discovery_t),
- .size_out = 0,
- .parse = NULL,
- };
-
- return _hcng_execute_command(socket, (hc_msg_t *)&msg, sizeof(msg), &params,
- NULL, false);
-#endif
- return 0; // XXX added
+int _hicnlight_mapme_parse(const uint8_t *buffer, size_t size,
+ hc_object_t *object) {
+ return hicnlight_mapme_parse(buffer, size, &object->mapme);
}
-static int _hcng_mapme_set_timescale(hc_sock_t *socket, uint32_t timescale) {
-#if 0
- msg_mapme_set_timescale_t msg = {
- .header =
- {
- .message_type = REQUEST_LIGHT,
- .command_id = COMMAND_TYPE_MAPME_SET_TIMESCALE,
- .length = 1,
- .seq_num = 0,
- },
- .payload = {
- .timePeriod = timescale,
- }};
-
- hc_command_params_t params = {
- .cmd = ACTION_SET,
- .cmd_id = COMMAND_TYPE_MAPME_SET_TIMESCALE,
- .size_in = sizeof(cmd_mapme_set_timescale_t),
- .size_out = 0,
- .parse = NULL,
- };
-
- return _hcng_execute_command(socket, (hc_msg_t *)&msg, sizeof(msg), &params,
- NULL, false);
-#endif
- return 0; // XXX added
+int hicnlight_mapme_serialize_create(const hc_object_t *object,
+ uint8_t *packet) {
+ const hc_mapme_t *mapme = &object->mapme;
+
+ msg_mapme_add_t *msg = (msg_mapme_add_t *)packet;
+ *msg = (msg_mapme_add_t){.header =
+ {
+ .message_type = REQUEST_LIGHT,
+ .command_id = COMMAND_TYPE_MAPME_ADD,
+ .length = 1,
+ .seq_num = 0,
+ },
+
+ .payload = {.face_id = mapme->face_id,
+ .family = mapme->family,
+ .address = mapme->address,
+ .len = mapme->len}};
+
+ return sizeof(msg_mapme_add_t);
}
-static int _hcng_mapme_set_retx(hc_sock_t *socket, uint32_t timescale) {
-#if 0
- msg_mapme_set_retx_t msg = {.header =
- {
- .message_type = REQUEST_LIGHT,
- .command_id = COMMAND_TYPE_MAPME_SET_RETX,
- .length = 1,
- .seq_num = 0,
- },
- .payload = {
- .timePeriod = timescale,
- }};
-
- hc_command_params_t params = {
- .cmd = ACTION_SET,
- .cmd_id = COMMAND_TYPE_MAPME_SET_RETX,
- .size_in = sizeof(msg_mapme_set_retx_t),
- .size_out = 0,
- .parse = NULL,
- };
-
- return _hcng_execute_command(socket, (hc_msg_t *)&msg, sizeof(msg), &params,
- NULL, false);
-#endif
- return 0; // XXX added
+int hicnlight_mapme_serialize_delete(const hc_object_t *object,
+ uint8_t *packet) {
+ return -1;
}
-static int _hcng_mapme_send_update(hc_sock_t *socket, hc_mapme_t *mapme) {
-#if 0
- if (!IS_VALID_FAMILY(mapme->family)) return -1;
-
- msg_mapme_send_update_t msg = {
- .header =
- {
- .message_type = REQUEST_LIGHT,
- .command_id = COMMAND_TYPE_MAPME_SEND_UPDATE,
- .length = 1,
- .seq_num = 0,
- },
- };
-
- hc_command_params_t params = {
- .cmd = ACTION_UPDATE,
- .cmd_id = COMMAND_TYPE_MAPME_SEND_UPDATE,
- .size_in = sizeof(msg_mapme_send_update_t),
- .size_out = 0,
- .parse = NULL,
- };
+int hicnlight_mapme_serialize_list(const hc_object_t *object, uint8_t *packet) {
+ return -1;
+}
- return _hcng_execute_command(socket, (hc_msg_t *)&msg, sizeof(msg), &params,
- NULL, false);
-#endif
- return 0; // XXX added
+int hicnlight_mapme_serialize_set(const hc_object_t *object, uint8_t *packet) {
+ return -1;
}
+
+DECLARE_MODULE_OBJECT_OPS(hicnlight, mapme);
diff --git a/ctrl/libhicnctrl/src/modules/hicn_light/mapme.h b/ctrl/libhicnctrl/src/modules/hicn_light/mapme.h
new file mode 100644
index 000000000..58a943b67
--- /dev/null
+++ b/ctrl/libhicnctrl/src/modules/hicn_light/mapme.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2023 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+/**
+ * \file modules/hicn_light/mapme.h
+ * \brief mapme object VFT for hicn_light.
+ */
+
+#ifndef HICNCTRL_MODULE_HICNLIGHT_MAPME_H
+#define HICNCTRL_MODULE_HICNLIGHT_MAPME_H
+
+#include "../../module.h"
+
+DECLARE_MODULE_OBJECT_OPS_H(hicnlight, mapme);
+
+#endif /* HICNCTRL_MODULE_HICNLIGHT_MAPME_H */
diff --git a/ctrl/libhicnctrl/src/object_private.h b/ctrl/libhicnctrl/src/object_private.h
index 2be12fd5e..1aea86639 100644
--- a/ctrl/libhicnctrl/src/object_private.h
+++ b/ctrl/libhicnctrl/src/object_private.h
@@ -1,11 +1,33 @@
+/*
+ * Copyright (c) 2021-2023 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+/**
+ * \file object_private.h
+ * \brief Helper functions for object management.
+ */
+
#ifndef HICNCTRL_OBJECT_PRIVATE_H
#define HICNCTRL_OBJECT_PRIVATE_H
+#include <hicn/face.h>
+
#define INT_CMP(x, y) ((x > y) ? 1 : (x < y) ? -1 : 0)
// XXX Those are always true
#define IS_VALID_ADDRESS(x) (1)
-#define IS_VALID_CONNECTION_ID(x) (1) // XXX ID
+#define IS_VALID_CONNECTION_ID(x) (x != INVALID_FACE_ID)
#define IS_VALID_ROUTE_COST(x) (1)
#define IS_VALID_PREFIX_LEN(x) (1)
#define IS_VALID_POLICY(x) (1)
diff --git a/ctrl/libhicnctrl/src/object_vft.c b/ctrl/libhicnctrl/src/object_vft.c
index 01d2dab88..4dc59c378 100644
--- a/ctrl/libhicnctrl/src/object_vft.c
+++ b/ctrl/libhicnctrl/src/object_vft.c
@@ -1,22 +1,44 @@
+/*
+ * Copyright (c) 2021-2023 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+/**
+ * \file object_vft.c
+ * \brief Implementation of object VFT.
+ */
+
#include "object_vft.h"
#include "objects/listener.h"
#include "objects/connection.h"
#include "objects/route.h"
#include "objects/face.h"
+#include "objects/mapme.h"
#include "objects/stats.h"
#include "objects/strategy.h"
#include "objects/subscription.h"
#include "objects/active_interface.h"
const hc_object_ops_t *object_vft[] = {
- [OBJECT_TYPE_LISTENER] = &hc_listener_ops,
[OBJECT_TYPE_CONNECTION] = &hc_connection_ops,
+ [OBJECT_TYPE_LISTENER] = &hc_listener_ops,
[OBJECT_TYPE_ROUTE] = &hc_route_ops,
[OBJECT_TYPE_FACE] = &hc_face_ops,
- [OBJECT_TYPE_FACE_STATS] = &hc_face_stats_ops,
- [OBJECT_TYPE_STATS] = &hc_stats_ops,
[OBJECT_TYPE_STRATEGY] = &hc_strategy_ops,
+ [OBJECT_TYPE_MAPME] = &hc_mapme_ops,
[OBJECT_TYPE_SUBSCRIPTION] = &hc_subscription_ops,
[OBJECT_TYPE_ACTIVE_INTERFACE] = &hc_active_interface_ops,
+ [OBJECT_TYPE_STATS] = &hc_stats_ops,
+ [OBJECT_TYPE_FACE_STATS] = &hc_face_stats_ops,
};
diff --git a/ctrl/libhicnctrl/src/objects/mapme.c b/ctrl/libhicnctrl/src/objects/mapme.c
new file mode 100644
index 000000000..1acdcb35a
--- /dev/null
+++ b/ctrl/libhicnctrl/src/objects/mapme.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2021-2023 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+/**
+ * \file mapme.c
+ * \brief Implementation of mapme object.
+ */
+
+#include <hicn/ctrl/api.h>
+#include <hicn/ctrl/object.h>
+#include <hicn/ctrl/objects/mapme.h>
+#include <hicn/util/log.h>
+
+#include "../object_private.h"
+#include "../object_vft.h"
+#include "face.h"
+#include "base.h"
+
+/* MAPME VALIDATE */
+
+int hc_mapme_validate(const hc_mapme_t *mapme, bool allow_partial) {
+ int has_family = 0;
+ int has_address = 0;
+ int has_len = 0;
+
+ if (allow_partial) return 0;
+
+ if (mapme->family != AF_UNSPEC) {
+ if (!IS_VALID_FAMILY(mapme->family)) {
+ ERROR("[hc_mapme_validate] Invalid family specified");
+ return -1;
+ }
+ has_family = 1;
+ }
+
+ if (!hicn_ip_address_empty(&mapme->address)) {
+ if (!IS_VALID_ADDRESS(mapme->address)) {
+ ERROR("[hc_mapme_validate] Invalid remote_addr specified");
+ return -1;
+ }
+ has_address = 1;
+ }
+
+ if (!IS_VALID_PREFIX_LEN(mapme->len)) {
+ ERROR("[hc_mapme_validate] Invalid len");
+ return -1;
+ }
+ has_len = 1;
+ return has_family && has_address && has_len;
+}
+
+int _hc_mapme_validate(const hc_object_t *object, bool allow_partial) {
+ return hc_mapme_validate(&object->mapme, allow_partial);
+}
+
+/* MAPME CMP */
+
+int hc_mapme_cmp(const hc_mapme_t *mapme1, const hc_mapme_t *mapme2) {
+ return -1;
+}
+
+int _hc_mapme_cmp(const hc_object_t *object1, const hc_object_t *object2) {
+ return -1;
+}
+
+/* MAPME SNPRINTF */
+
+int hc_mapme_snprintf(char *s, size_t size, const hc_mapme_t *mapme) {
+ return -1;
+}
+
+int _hc_mapme_snprintf(char *s, size_t size, const hc_object_t *object) {
+ return -1;
+}
+
+int hc_mapme_create(hc_sock_t *s, hc_mapme_t *mapme) {
+ hc_object_t object;
+ memset(&object, 0, sizeof(hc_object_t));
+ object.mapme = *mapme;
+ return hc_execute(s, ACTION_CREATE, OBJECT_TYPE_MAPME, &object, NULL);
+}
+
+DECLARE_OBJECT_OPS(OBJECT_TYPE_MAPME, mapme);
diff --git a/ctrl/libhicnctrl/src/objects/mapme.h b/ctrl/libhicnctrl/src/objects/mapme.h
new file mode 100644
index 000000000..488f97cd5
--- /dev/null
+++ b/ctrl/libhicnctrl/src/objects/mapme.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2021-2023 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+/**
+ * \file mapme.h
+ * \brief Route.
+ */
+
+#ifndef HICNCTRL_IMPL_OBJECTS_MAPME_H
+#define HICNCTRL_IMPL_OBJECTS_MAPME_H
+
+#include "../object_vft.h"
+
+bool hc_mapme_has_face(const hc_mapme_t* mapme);
+
+DECLARE_OBJECT_OPS_H(OBJECT_TYPE_MAPME, mapme);
+
+#endif /* HICNCTRL_IMPL_OBJECTS_MAPME_H */
diff --git a/ctrl/libhicnctrl/src/objects/route.c b/ctrl/libhicnctrl/src/objects/route.c
index f2d0636a7..4bdaa0afb 100644
--- a/ctrl/libhicnctrl/src/objects/route.c
+++ b/ctrl/libhicnctrl/src/objects/route.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022 Cisco and/or its affiliates.
+ * Copyright (c) 2021-2023 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -42,11 +42,9 @@ int hc_route_validate(const hc_route_t *route, bool allow_partial) {
int has_family = 0;
int has_remote_addr = 0;
- if (!IS_VALID_CONNECTION_ID(route->face_id)) {
- ERROR("[hc_route_validate] Invalid face id");
- return -1;
+ if (IS_VALID_CONNECTION_ID(route->face_id)) {
+ has_id = 1;
}
- has_id = 1;
if (!isempty(route->face_name)) {
if (!IS_VALID_NAME(route->face_name)) {
@@ -64,6 +62,8 @@ int hc_route_validate(const hc_route_t *route, bool allow_partial) {
has_family = 1;
}
+ //::/0 is a valid remote addr
+#if 0
if (!hicn_ip_address_empty(&route->remote_addr)) {
if (!IS_VALID_ADDRESS(route->remote_addr)) {
ERROR("[hc_route_validate] Invalid remote_addr specified");
@@ -71,16 +71,21 @@ int hc_route_validate(const hc_route_t *route, bool allow_partial) {
}
has_remote_addr = 1;
}
+#else
+ has_remote_addr = 1;
+#endif
if (!IS_VALID_ROUTE_COST(route->cost)) {
ERROR("[hc_route_validate] Invalid cost");
return -1;
}
+#if 0
if (!IS_VALID_PREFIX_LEN(route->len)) {
ERROR("[hc_route_validate] Invalid len");
return -1;
}
+#endif
if (hc_route_has_face(route)) {
if (hc_face_validate(&route->face, allow_partial) < 0) {
@@ -90,12 +95,10 @@ int hc_route_validate(const hc_route_t *route, bool allow_partial) {
has_face = 1;
}
- int has_face_info = has_id || has_name || has_face;
-
- if (!has_face_info) return -1;
- if (allow_partial && (has_name + has_face != 1)) return -1;
-
- if (has_face_info && has_family && has_remote_addr) return 0;
+ /* We also allow routes without faces, hence the '>' sign */
+ if (allow_partial && (has_id + has_name + has_face > 1)) return -1;
+ // if (has_face_info && has_family && has_remote_addr) return 0;
+ if (has_family && has_remote_addr) return 0;
return -1;
}