X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvat%2Fapi_format.c;h=c6b6317ef18a35f49e9cd4d0247f1c2d9fb12b4f;hb=1c7104514cd40d2377caca36cf40c13b791bc5aa;hp=d8f72090ef72dd2163ade004265fea76fc82a75b;hpb=ca514fda1125573d513215cb6ea7f22057a82d6b;p=vpp.git diff --git a/src/vat/api_format.c b/src/vat/api_format.c index d8f72090ef7..c6b6317ef18 100644 --- a/src/vat/api_format.c +++ b/src/vat/api_format.c @@ -5183,7 +5183,8 @@ _(sw_interface_set_lldp_reply) \ _(tcp_configure_src_addresses_reply) \ _(app_namespace_add_del_reply) \ _(dns_enable_disable_reply) \ -_(dns_name_server_add_del_reply) +_(dns_name_server_add_del_reply) \ +_(session_rule_add_del_reply) #define _(n) \ static void vl_api_##n##_t_handler \ @@ -5494,7 +5495,8 @@ _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \ _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \ _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \ _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \ -_(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) +_(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \ +_(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) #define foreach_standalone_reply_msg \ _(SW_INTERFACE_EVENT, sw_interface_event) \ @@ -20984,7 +20986,7 @@ api_app_namespace_add_del (vat_main_t * vam) clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id)); mp->namespace_id_len = vec_len (ns_id); - mp->secret = secret; + mp->secret = clib_host_to_net_u64 (secret); mp->sw_if_index = clib_host_to_net_u32 (sw_if_index); mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id); mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id); @@ -21189,6 +21191,93 @@ api_dns_name_server_add_del (vat_main_t * vam) return ret; } +static int +api_session_rule_add_del (vat_main_t * vam) +{ + vl_api_session_rule_add_del_t *mp; + unformat_input_t *i = vam->input; + u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen; + u32 appns_index = 0, scope = 0; + ip4_address_t lcl_ip4, rmt_ip4; + ip6_address_t lcl_ip6, rmt_ip6; + u8 is_ip4 = 1, conn_set = 0; + u8 is_add = 1; + int ret; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "del")) + is_add = 0; + else if (unformat (i, "add")) + ; + else if (unformat (i, "proto tcp")) + proto = 0; + else if (unformat (i, "proto udp")) + proto = 1; + else if (unformat (i, "appns %d", &appns_index)) + ; + else if (unformat (i, "scope %d", &scope)) + ; + else + if (unformat + (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4, + &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen, + &rmt_port)) + { + is_ip4 = 1; + conn_set = 1; + } + else + if (unformat + (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6, + &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen, + &rmt_port)) + { + is_ip4 = 0; + conn_set = 1; + } + else if (unformat (i, "action %d", &action)) + ; + else + break; + } + if (proto == ~0 || !conn_set || action == ~0) + { + errmsg ("transport proto, connection and action must be set"); + return -99; + } + + if (scope > 3) + { + errmsg ("scope should be 0-3"); + return -99; + } + + M (SESSION_RULE_ADD_DEL, mp); + + mp->is_ip4 = is_ip4; + mp->transport_proto = proto; + mp->lcl_plen = clib_host_to_net_u16 (lcl_plen); + mp->rmt_plen = clib_host_to_net_u16 (rmt_plen); + mp->action_index = clib_host_to_net_u32 (action); + mp->appns_index = clib_host_to_net_u32 (appns_index); + mp->scope = scope; + mp->is_add = is_add; + if (is_ip4) + { + clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4)); + clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4)); + } + else + { + clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6)); + clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6)); + } + + S (mp); + W (ret); + return ret; +} static int q_or_quit (vat_main_t * vam) @@ -21987,7 +22076,11 @@ _(app_namespace_add_del, "[add] id secret sw_if_index ")\ _(dns_enable_disable, "[enable][disable]") \ _(dns_name_server_add_del, " [del]") \ _(dns_resolve_name, "") \ -_(dns_resolve_ip, "") +_(dns_resolve_ip, "") \ +_(dns_name_server_add_del, " [del]") \ +_(dns_resolve_name, "") \ +_(session_rule_add_del, "[add|del] proto / " \ + " / action ") \ /* List of command functions, CLI names map directly to functions */ #define foreach_cli_function \