srv6-mobile
[vpp.git] / src / vnet / srv6 / sr.h
index 1193583..6a228c8 100755 (executable)
@@ -77,6 +77,9 @@ typedef struct
   dpo_id_t bsid_dpo;                           /**< DPO for Encaps/Insert for BSID */
   dpo_id_t ip6_dpo;                            /**< DPO for Encaps/Insert IPv6 */
   dpo_id_t ip4_dpo;                            /**< DPO for Encaps IPv6 */
+
+  u16 plugin;
+  void *plugin_mem;
 } ip6_sr_sl_t;
 
 /* SR policy types */
@@ -102,8 +105,13 @@ typedef struct
   u32 fib_table;                       /**< FIB table */
 
   u8 is_encap;                         /**< Mode (0 is SRH insert, 1 Encaps) */
+
+  u16 plugin;
+  void *plugin_mem;
 } ip6_sr_policy_t;
 
+typedef int (sr_p_plugin_callback_t) (ip6_sr_policy_t * sr);
+
 /**
  * @brief SR LocalSID
  */
@@ -164,6 +172,34 @@ typedef struct
   sr_plugin_callback_t *removal;                       /**< Function within plugin that will be called before localsid removal */
 } sr_localsid_fn_registration_t;
 
+/**
+ * @brief SR Policy behavior registration
+ */
+typedef struct
+{
+  u16 sr_policy_function_number;                       /**< SR Policy plugin function */
+
+  u8 *function_name;                                   /**< Function name. (key). */
+
+  u8 *keyword_str;                                     /**< Behavior keyword (i.e. End.X) */
+
+  u8 *def_str;                                         /**< Behavior definition (i.e. Endpoint with cross-connect) */
+
+  u8 *params_str;                                      /**< Behavior parameters (i.e. <oif> <IP46next_hop>) */
+
+  u8 prefix_length;
+
+  dpo_type_t dpo;                                      /**< DPO type registration */
+
+  format_function_t *ls_format;                                /**< LocalSID format function */
+
+  unformat_function_t *ls_unformat;                    /**< LocalSID unformat function */
+
+  sr_p_plugin_callback_t *creation;                    /**< Function within plugin that will be called after localsid creation*/
+
+  sr_p_plugin_callback_t *removal;                     /**< Function within plugin that will be called before localsid removal */
+} sr_policy_fn_registration_t;
+
 /**
  * @brief Steering db key
  *
@@ -236,6 +272,12 @@ typedef struct
   /* Find plugin function by name */
   uword *plugin_functions_by_key;
 
+  /* Plugin functions for Policy */
+  sr_policy_fn_registration_t *policy_plugin_functions;
+
+  /* Find plugin function by name */
+  uword *policy_plugin_functions_by_key;
+
   /* Counters */
   vlib_combined_counter_main_t sr_ls_valid_counters;
   vlib_combined_counter_main_t sr_ls_invalid_counters;
@@ -269,9 +311,20 @@ sr_localsid_register_function (vlib_main_t * vm, u8 * fn_name,
                               sr_plugin_callback_t * creation_fn,
                               sr_plugin_callback_t * removal_fn);
 
+extern int
+sr_policy_register_function (vlib_main_t * vm, u8 * fn_name,
+                            u8 * keyword_str, u8 * def_str,
+                            u8 * params_str, u8 prefix_length,
+                            dpo_type_t * dpo,
+                            format_function_t * ls_format,
+                            unformat_function_t * ls_unformat,
+                            sr_p_plugin_callback_t * creation_fn,
+                            sr_p_plugin_callback_t * removal_fn);
+
 extern int
 sr_policy_add (ip6_address_t * bsid, ip6_address_t * segments,
-              u32 weight, u8 behavior, u32 fib_table, u8 is_encap);
+              u32 weight, u8 behavior, u32 fib_table, u8 is_encap,
+              u16 plugin, void *plugin_mem);
 extern int sr_policy_mod (ip6_address_t * bsid, u32 index, u32 fib_table,
                          u8 operation, ip6_address_t * segments,
                          u32 sl_index, u32 weight);