From 68ac244283b60cbaf6356ab732f1d31583bb3e7a Mon Sep 17 00:00:00 2001 From: Takeru Hayasaka Date: Fri, 28 Oct 2022 04:26:05 +0900 Subject: srv6-mobile: Implement SRv6 mobile API funcs This merge request adds the feature to manipulate localsids and policies for SRv6 mobile via API. Type: feature Signed-off-by: Takeru Hayasaka Change-Id: Ibb46bf71ae1d9d4591ce2c8ccf66f520887dad70 --- src/plugins/srv6-mobile/gtp4_dt.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'src/plugins/srv6-mobile/gtp4_dt.c') diff --git a/src/plugins/srv6-mobile/gtp4_dt.c b/src/plugins/srv6-mobile/gtp4_dt.c index 1f6bab1d055..c4752b77557 100644 --- a/src/plugins/srv6-mobile/gtp4_dt.c +++ b/src/plugins/srv6-mobile/gtp4_dt.c @@ -90,11 +90,31 @@ clb_format_srv6_t_m_gtp4_dt (u8 * s, va_list * args) return s; } +void +alloc_param_srv6_t_m_gtp4_dt (void **plugin_mem_p, const u32 fib_index, + const u32 local_fib_index, const u8 type) +{ + srv6_t_gtp4_dt_param_t *ls_mem; + ls_mem = clib_mem_alloc (sizeof *ls_mem); + clib_memset (ls_mem, 0, sizeof *ls_mem); + *plugin_mem_p = ls_mem; + + ls_mem->fib4_index = fib_table_find (FIB_PROTOCOL_IP4, fib_index); + ls_mem->fib6_index = fib_table_find (FIB_PROTOCOL_IP6, fib_index); + + if (type == SRV6_GTP4_DT6 || type == SRV6_GTP4_DT46) + { + ls_mem->local_fib_index = + fib_table_find (FIB_PROTOCOL_IP6, local_fib_index); + } + + ls_mem->type = type; +} + static uword clb_unformat_srv6_t_m_gtp4_dt (unformat_input_t * input, va_list * args) { void **plugin_mem_p = va_arg (*args, void **); - srv6_t_gtp4_dt_param_t *ls_mem; u32 fib_index = 0; u32 local_fib_index = 0; u32 type; @@ -118,20 +138,8 @@ clb_unformat_srv6_t_m_gtp4_dt (unformat_input_t * input, va_list * args) return 0; } - ls_mem = clib_mem_alloc (sizeof *ls_mem); - clib_memset (ls_mem, 0, sizeof *ls_mem); - *plugin_mem_p = ls_mem; - - ls_mem->fib4_index = fib_table_find (FIB_PROTOCOL_IP4, fib_index); - ls_mem->fib6_index = fib_table_find (FIB_PROTOCOL_IP6, fib_index); - - if (type == SRV6_GTP4_DT6 || type == SRV6_GTP4_DT46) - { - ls_mem->local_fib_index = - fib_table_find (FIB_PROTOCOL_IP6, local_fib_index); - } - - ls_mem->type = type; + alloc_param_srv6_t_m_gtp4_dt (plugin_mem_p, fib_index, local_fib_index, + type); return 1; } -- cgit 1.2.3-korg