summaryrefslogtreecommitdiffstats
path: root/hicn-plugin/src/hicn_api.c
diff options
context:
space:
mode:
authorAlberto Compagno <acompagn+fdio@cisco.com>2019-11-18 14:52:25 +0100
committerAlberto Compagno <acompagn+fdio@cisco.com>2019-11-18 14:52:25 +0100
commit569dda3ae64bbfa3579d4c42e30ee684d51b88d9 (patch)
treed74c4cb17ea687d7e34473f424ab077f5f44bafc /hicn-plugin/src/hicn_api.c
parentf1590834352d863d238d38c5a58d5a31ab042e3f (diff)
[HICN-397] Added punting add message for punting on udp ports
Change-Id: Ieb5faf5d01e460179028eaba92170ee95cf35edf Signed-off-by: Alberto Compagno <acompagn+fdio@cisco.com>
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 */ );
}