summaryrefslogtreecommitdiffstats
path: root/hicn-plugin/src/hicn_api.c
diff options
context:
space:
mode:
authorAlberto Compagno <acompagn+fdio@cisco.com>2019-11-19 08:16:29 +0000
committerGerrit Code Review <gerrit@fd.io>2019-11-19 08:16:29 +0000
commit40fde5ad542c30e59ac02639e29389085de89de5 (patch)
tree50dbe79c5db59bd8a465956b8f84c6cc7314fe56 /hicn-plugin/src/hicn_api.c
parentda5d56e2d7d6c62a8eeca572103ba97e92b2eab9 (diff)
parent569dda3ae64bbfa3579d4c42e30ee684d51b88d9 (diff)
Merge "[HICN-397] Added punting add message for punting on udp ports"
Diffstat (limited to 'hicn-plugin/src/hicn_api.c')
-rw-r--r--hicn-plugin/src/hicn_api.c40
1 files changed, 35 insertions, 5 deletions
diff --git a/hicn-plugin/src/hicn_api.c b/hicn-plugin/src/hicn_api.c
index b1e6bccb9..1cb14fe1b 100644
--- a/hicn-plugin/src/hicn_api.c
+++ b/hicn-plugin/src/hicn_api.c
@@ -890,20 +890,50 @@ static void vl_api_hicn_api_strategy_get_t_handler
/****** PUNTING *******/
+static hicn_error_t add_ip_punting (vl_api_hicn_punting_ip_t * mp)
+{
+ vlib_main_t *vm = vlib_get_main ();
+ fib_prefix_t prefix;
+ ip_prefix_decode (&mp->prefix, &prefix);
+ u32 swif = clib_net_to_host_u32 (mp->swif);
+
+ return hicn_punt_interest_data_for_ip (vm, &prefix, swif, HICN_PUNT_IP_TYPE, NO_L2);
+}
+
+static hicn_error_t add_udp_punting (vl_api_hicn_punting_udp_t * mp)
+{
+ vlib_main_t *vm = vlib_get_main ();
+ fib_prefix_t prefix;
+ ip_prefix_decode (&mp->prefix, &prefix);
+ u32 swif = clib_net_to_host_u32 (mp->swif);
+ u16 sport = clib_net_to_host_u16 (mp->sport);
+ u16 dport = clib_net_to_host_u16 (mp->sport);
+ u8 type = mp->ip_version == ADDRESS_IP6 ? HICN_PUNT_UDP6_TYPE : HICN_PUNT_UDP4_TYPE;
+
+ return hicn_punt_interest_data_for_udp (vm, &prefix, swif, type, sport, dport, NO_L2);
+}
+
static void vl_api_hicn_api_punting_add_t_handler
(vl_api_hicn_api_punting_add_t * mp)
{
vl_api_hicn_api_punting_add_reply_t *rmp;
int rv = HICN_ERROR_NONE;
- vlib_main_t *vm = vlib_get_main ();
hicn_main_t *sm = &hicn_main;
- fib_prefix_t prefix;
- ip_prefix_decode (&mp->prefix, &prefix);
- u32 swif = clib_net_to_host_u32 (mp->swif);
+ if (mp->type == IP_PUNT)
+ {
+ rv = add_ip_punting(&(mp->rule.ip));
+ }
+ else if (mp->type == UDP_PUNT)
+ {
+ rv = add_udp_punting(&(mp->rule.udp));
+ }
+ else
+ {
+ rv = HICN_ERROR_PUNT_INVAL;
+ }
- rv = hicn_punt_interest_data_for_ip (vm, &prefix, swif, 0, NO_L2);
REPLY_MACRO (VL_API_HICN_API_PUNTING_ADD_REPLY /* , rmp, mp, rv */ );
}