Custom adjacency formatting fix (Revived) 08/2308/3
authorPierre Pfister <ppfister@cisco.com>
Thu, 4 Aug 2016 13:25:01 +0000 (14:25 +0100)
committerDave Barach <openvpp@barachs.net>
Thu, 11 Aug 2016 14:55:35 +0000 (14:55 +0000)
Looks like something strange is going on with indentation.

Change-Id: I8e734a2119a4a744d7ce76ce83ecc7b237828d3b
Signed-off-by: Pierre Pfister <ppfister@cisco.com>
plugins/ila-plugin/ila/ila.c
vnet/vnet/ip/lookup.h

index c0e6da1..a43aca1 100644 (file)
@@ -795,11 +795,11 @@ vlib_plugin_register (vlib_main_t * vm, vnet_plugin_handoff_t * h,
   return error;
 }
 
-u8 *ila_format_adjacency(u8 * s,
-                        struct ip_lookup_main_t * lm,
-                        ip_adjacency_t *adj)
+u8 *ila_format_adjacency(u8 * s, va_list * va)
 {
   ila_main_t *ilm = &ila_main;
+  __attribute((unused)) ip_lookup_main_t *lm = va_arg (*va, ip_lookup_main_t *);
+  ip_adjacency_t *adj = va_arg (*va, ip_adjacency_t *);
   ila_adj_data_t * ad = (ila_adj_data_t *) & adj->opaque;
   ila_entry_t *ie = pool_elt_at_index (ilm->entries, ad->entry_index);
   return format(s, "idx:%d sir:%U", ad->entry_index, format_ip6_address, &ie->sir_address);
index 808f78d..2b682d2 100644 (file)
@@ -365,16 +365,31 @@ typedef struct {
   u32 * config_index_by_sw_if_index;
 } ip_config_main_t;
 
-//Function type used to register formatting of a custom adjacency formatting
-typedef u8 *(* ip_adjacency_format_fn)(u8 * s,
-                                        struct ip_lookup_main_t * lm,
-                                        ip_adjacency_t *adj);
-
+/**
+ * This structure is used to dynamically register a custom adjacency
+ * for ip lookup.
+ * Typically used with
+ *  VNET_IP4_REGISTER_ADJACENCY or
+ *  VNET_IP6_REGISTER_ADJACENCY macros.
+ */
 typedef struct ip_adj_register_struct {
+  /** Name of the node for this registered adjacency. */
+  char *node_name;
+
+  /** Formatting function for the adjacency.
+   * Variadic arguments given to the function are:
+   * - struct ip_lookup_main_t *
+   * - ip_adjacency_t *adj
+   */
+  format_function_t *fn;
+
+  /**
+   * When the adjacency is registered, the ip-lookup next index will
+   * be written where this pointer points.
+   */
+  u32 *next_index;
+
   struct ip_adj_register_struct *next;
-  char *node_name; //Name of the node for this registered adjacency
-  ip_adjacency_format_fn fn; //Formatting function of this adjacency
-  u32 *next_index; //some place where the next index to be used will be put at init
 } ip_adj_register_t;
 
 typedef struct ip_lookup_main_t {