ip: Replace Sematics for Interface IP addresses
[vpp.git] / src / vnet / ip / ip6_hop_by_hop.h
index 9574f0a..e8ecab6 100644 (file)
@@ -40,6 +40,11 @@ typedef struct
   u8 flow_name[64];
 } flow_data_t;
 
+typedef struct
+{
+  u8 next_index_by_protocol[256];
+} ip6_local_hop_by_hop_runtime_t;
+
 typedef struct
 {
   /* The current rewrite we're using */
@@ -85,6 +90,8 @@ typedef struct
     u32 (*flow_handler[MAX_IP6_HBH_OPTION]) (u32 flow_ctx, u8 add);
   flow_data_t *flows;
 
+  ip6_local_hop_by_hop_runtime_t *ip6_local_hbh_runtime;
+
   /* convenience */
   vlib_main_t *vlib_main;
   vnet_main_t *vnet_main;
@@ -214,7 +221,7 @@ ioam_flow_add (u8 encap, u8 * flow_name)
   u8 i;
 
   pool_get (hm->flows, flow);
-  memset (flow, 0, sizeof (flow_data_t));
+  clib_memset (flow, 0, sizeof (flow_data_t));
 
   index = flow - hm->flows;
   strncpy ((char *) flow->flow_name, (char *) flow_name, 31);
@@ -230,6 +237,42 @@ ioam_flow_add (u8 encap, u8 * flow_name)
   return (index);
 }
 
+always_inline ip6_hop_by_hop_option_t *
+ip6_hbh_get_option (ip6_hop_by_hop_header_t * hbh0, u8 option_to_search)
+{
+  ip6_hop_by_hop_option_t *opt0, *limit0;
+  u8 type0;
+
+  if (!hbh0)
+    return NULL;
+
+  opt0 = (ip6_hop_by_hop_option_t *) (hbh0 + 1);
+  limit0 = (ip6_hop_by_hop_option_t *)
+    ((u8 *) hbh0 + ((hbh0->length + 1) << 3));
+
+  /* Scan the set of h-b-h options, process ones that we understand */
+  while (opt0 < limit0)
+    {
+      type0 = opt0->type;
+      switch (type0)
+       {
+       case 0:         /* Pad1 */
+         opt0 = (ip6_hop_by_hop_option_t *) ((u8 *) opt0) + 1;
+         continue;
+       case 1:         /* PadN */
+         break;
+       default:
+         if (type0 == option_to_search)
+           return opt0;
+         break;
+       }
+      opt0 =
+       (ip6_hop_by_hop_option_t *) (((u8 *) opt0) + opt0->length +
+                                    sizeof (ip6_hop_by_hop_option_t));
+    }
+  return NULL;
+}
+
 #endif /* __included_ip6_hop_by_hop_ioam_h__ */
 
 /*