+void
+vnet_lisp_create_retry_process (lisp_cp_main_t * lcm)
+{
+ if (lcm->retry_service_index)
+ return;
+
+ lcm->retry_service_index = vlib_process_create (vlib_get_main (),
+ "lisp-retry-service",
+ send_map_resolver_service,
+ 16 /* stack_bytes */ );
+}
+
+u32
+vnet_lisp_set_transport_protocol (u8 protocol)
+{
+ lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
+
+ if (protocol < LISP_TRANSPORT_PROTOCOL_UDP ||
+ protocol > LISP_TRANSPORT_PROTOCOL_API)
+ return VNET_API_ERROR_INVALID_ARGUMENT;
+
+ lcm->transport_protocol = protocol;
+ return 0;
+}
+
+lisp_transport_protocol_t
+vnet_lisp_get_transport_protocol (void)
+{
+ lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
+ return lcm->transport_protocol;
+}
+
+int
+vnet_lisp_enable_disable_xtr_mode (u8 is_enabled)
+{
+ lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
+ u8 pitr_mode = lcm->flags & LISP_FLAG_PITR_MODE;
+ u8 xtr_mode = lcm->flags & LISP_FLAG_XTR_MODE;
+ u8 petr_mode = lcm->flags & LISP_FLAG_PETR_MODE;
+
+ if (pitr_mode && is_enabled)
+ return VNET_API_ERROR_INVALID_ARGUMENT;
+
+ if (is_enabled && xtr_mode)
+ return 0;
+ if (!is_enabled && !xtr_mode)
+ return 0;
+
+ if (is_enabled)
+ {
+ if (!petr_mode)
+ {
+ lisp_cp_register_dst_port (lcm->vlib_main);
+ }
+ lisp_cp_enable_l2_l3_ifaces (lcm, 1 /* with_default_route */ );
+ lcm->flags |= LISP_FLAG_XTR_MODE;
+ }
+ else
+ {
+ if (!petr_mode)
+ {
+ lisp_cp_unregister_dst_port (lcm->vlib_main);
+ }
+ lisp_cp_disable_l2_l3_ifaces (lcm);
+ lcm->flags &= ~LISP_FLAG_XTR_MODE;
+ }
+ return 0;
+}
+
+int
+vnet_lisp_enable_disable_pitr_mode (u8 is_enabled)
+{
+ lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
+ u8 xtr_mode = lcm->flags & LISP_FLAG_XTR_MODE;
+ u8 pitr_mode = lcm->flags & LISP_FLAG_PITR_MODE;
+
+ if (xtr_mode && is_enabled)
+ return VNET_API_ERROR_INVALID_VALUE;
+
+ if (is_enabled && pitr_mode)
+ return 0;
+ if (!is_enabled && !pitr_mode)
+ return 0;
+
+ if (is_enabled)
+ {
+ /* create iface, no default route */
+ lisp_cp_enable_l2_l3_ifaces (lcm, 0 /* with_default_route */ );
+ lcm->flags |= LISP_FLAG_PITR_MODE;
+ }
+ else
+ {
+ lisp_cp_disable_l2_l3_ifaces (lcm);
+ lcm->flags &= ~LISP_FLAG_PITR_MODE;
+ }
+ return 0;
+}
+
+int
+vnet_lisp_enable_disable_petr_mode (u8 is_enabled)
+{
+ lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
+ u8 xtr_mode = lcm->flags & LISP_FLAG_XTR_MODE;
+ u8 petr_mode = lcm->flags & LISP_FLAG_PETR_MODE;
+
+ if (is_enabled && petr_mode)
+ return 0;
+ if (!is_enabled && !petr_mode)
+ return 0;
+
+ if (is_enabled)
+ {
+ if (!xtr_mode)
+ {
+ lisp_cp_register_dst_port (lcm->vlib_main);
+ }
+ lcm->flags |= LISP_FLAG_PETR_MODE;
+ }
+ else
+ {
+ if (!xtr_mode)
+ {
+ lisp_cp_unregister_dst_port (lcm->vlib_main);
+ }
+ lcm->flags &= ~LISP_FLAG_PETR_MODE;
+ }
+ return 0;
+}
+
+u8
+vnet_lisp_get_xtr_mode (void)
+{
+ lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
+ return (lcm->flags & LISP_FLAG_XTR_MODE);
+}
+
+u8
+vnet_lisp_get_pitr_mode (void)
+{
+ lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
+ return (lcm->flags & LISP_FLAG_PITR_MODE);
+}
+
+u8
+vnet_lisp_get_petr_mode (void)
+{
+ lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
+ return (lcm->flags & LISP_FLAG_PETR_MODE);
+}