aboutsummaryrefslogtreecommitdiffstats
path: root/ctrl/libhicnctrl/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'ctrl/libhicnctrl/src/commands')
-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
11 files changed, 247 insertions, 11 deletions
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>