+ vl_api_session_rules_details_t *rmp = 0;
+ session_mask_or_match_6_t *match =
+ (session_mask_or_match_6_t *) & rule->match;
+ session_mask_or_match_6_t *mask =
+ (session_mask_or_match_6_t *) & rule->mask;
+ fib_prefix_t lcl, rmt;
+
+ rmp = vl_msg_api_alloc (sizeof (*rmp));
+ clib_memset (rmp, 0, sizeof (*rmp));
+ rmp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_SESSION_RULES_DETAILS);
+ rmp->context = context;
+
+ clib_memset (&lcl, 0, sizeof (lcl));
+ clib_memset (&rmt, 0, sizeof (rmt));
+ ip_set (&lcl.fp_addr, &match->lcl_ip, 0);
+ ip_set (&rmt.fp_addr, &match->rmt_ip, 0);
+ lcl.fp_len = ip6_mask_to_preflen (&mask->lcl_ip);
+ rmt.fp_len = ip6_mask_to_preflen (&mask->rmt_ip);
+
+ ip_prefix_encode (&lcl, &rmp->lcl);
+ ip_prefix_encode (&rmt, &rmp->rmt);
+ rmp->lcl_port = match->lcl_port;
+ rmp->rmt_port = match->rmt_port;
+ rmp->action_index = clib_host_to_net_u32 (rule->action_index);
+ rmp->scope =
+ is_local ? SESSION_RULE_SCOPE_API_LOCAL : SESSION_RULE_SCOPE_API_GLOBAL;
+ rmp->transport_proto = api_session_transport_proto_encode (transport_proto);
+ rmp->appns_index = clib_host_to_net_u32 (appns_index);
+ if (tag)
+ {
+ clib_memcpy_fast (rmp->tag, tag, vec_len (tag));
+ rmp->tag[vec_len (tag)] = 0;
+ }
+
+ vl_api_send_msg (reg, (u8 *) rmp);
+}
+
+static void
+send_session_rules_table_details (session_rules_table_t * srt, u8 fib_proto,
+ u8 tp, u8 is_local, u32 appns_index,
+ vl_api_registration_t * reg, u32 context)
+{
+ mma_rule_16_t *rule16;
+ mma_rule_40_t *rule40;
+ mma_rules_table_16_t *srt16;
+ mma_rules_table_40_t *srt40;
+ u32 ri;
+
+ if (is_local || fib_proto == FIB_PROTOCOL_IP4)
+ {
+ u8 *tag = 0;
+ /* *INDENT-OFF* */
+ srt16 = &srt->session_rules_tables_16;
+ pool_foreach (rule16, srt16->rules) {
+ ri = mma_rules_table_rule_index_16 (srt16, rule16);
+ tag = session_rules_table_rule_tag (srt, ri, 1);
+ send_session_rule_details4 (rule16, is_local, tp, appns_index, tag,
+ reg, context);
+ }
+ /* *INDENT-ON* */
+ }
+ if (is_local || fib_proto == FIB_PROTOCOL_IP6)
+ {
+ u8 *tag = 0;
+ /* *INDENT-OFF* */
+ srt40 = &srt->session_rules_tables_40;
+ pool_foreach (rule40, srt40->rules) {
+ ri = mma_rules_table_rule_index_40 (srt40, rule40);
+ tag = session_rules_table_rule_tag (srt, ri, 1);
+ send_session_rule_details6 (rule40, is_local, tp, appns_index, tag,
+ reg, context);
+ }
+ /* *INDENT-ON* */
+ }
+}
+
+static void
+vl_api_session_rules_dump_t_handler (vl_api_session_rules_dump_t * mp)
+{
+ vl_api_registration_t *reg;
+ session_table_t *st;
+ u8 tp;
+
+ reg = vl_api_client_index_to_registration (mp->client_index);
+ if (!reg)
+ return;
+
+ /* *INDENT-OFF* */
+ session_table_foreach (st, ({
+ for (tp = 0; tp < TRANSPORT_N_PROTOS; tp++)
+ {
+ send_session_rules_table_details (&st->session_rules[tp],
+ st->active_fib_proto, tp,
+ st->is_local, st->appns_index, reg,
+ mp->context);
+ }
+ }));
+ /* *INDENT-ON* */
+}
+
+static void
+vl_api_app_add_cert_key_pair_t_handler (vl_api_app_add_cert_key_pair_t * mp)
+{
+ vl_api_app_add_cert_key_pair_reply_t *rmp;
+ vnet_app_add_cert_key_pair_args_t _a, *a = &_a;
+ u32 certkey_len, key_len, cert_len;
+ int rv = 0;
+ if (session_main_is_enabled () == 0)
+ {