ikev2: add support for custom ipsec-over-udp port
[vpp.git] / src / plugins / ioam / lib-trace / trace_util.h
index 7065b41..61f18d9 100644 (file)
@@ -62,7 +62,6 @@ typedef struct
   vnet_main_t *vnet_main;
 } trace_main_t;
 
-extern trace_main_t trace_main;
 
 /*
  * Initialize Trace profile
@@ -70,19 +69,6 @@ extern trace_main_t trace_main;
 int trace_util_init (void);
 
 
-/*
- * Find a trace profile
- */
-
-always_inline trace_profile *
-trace_profile_find (void)
-{
-  trace_main_t *sm = &trace_main;
-
-  return (&(sm->profile));
-}
-
-
 /* setup and clean up profile */
 int trace_profile_create (trace_profile * profile, u8 trace_type, u8 num_elts,
                          u32 trace_tsp, u32 node_id, u32 app_data);
@@ -94,16 +80,22 @@ typedef CLIB_PACKED (struct
 {
   u8 ioam_trace_type;
   u8 data_list_elts_left;
-  u32 elts[0]; /* Variable type. So keep it generic */
+  u32 elts[0]; /* Variable type. So keep it generic */
 }) ioam_trace_hdr_t;
 /* *INDENT-ON* */
 
+
+
 #define    BIT_TTL_NODEID       (1<<0)
 #define    BIT_ING_INTERFACE    (1<<1)
 #define    BIT_EGR_INTERFACE    (1<<2)
 #define    BIT_TIMESTAMP        (1<<3)
 #define    BIT_APPDATA          (1<<4)
-#define    TRACE_TYPE_MASK      0x1F   /* Mask of all above bits */
+#define    BIT_LOOPBACK         (1<<5)
+#define    BIT_LOOPBACK_REPLY   (1<<6)
+#define    TRACE_TYPE_MASK      0x7F   /* Mask of all above bits */
+
+#define    TRACE_TYPE_IF_TS_APP_LOOP    0x3F
 
 /*
      0x00011111  iOAM-trace-type is 0x00011111 then the format of node
@@ -214,24 +206,36 @@ typedef struct
 } ioam_trace_ts_app_t;
 
 static inline u8
-fetch_trace_data_size (u8 trace_type)
+fetch_trace_data_size (u16 trace_type)
 {
   u8 trace_data_size = 0;
 
-  if (trace_type == TRACE_TYPE_IF_TS_APP)
+  if ((trace_type & TRACE_TYPE_IF_TS_APP) == TRACE_TYPE_IF_TS_APP)
     trace_data_size = sizeof (ioam_trace_if_ts_app_t);
-  else if (trace_type == TRACE_TYPE_IF)
+  else if ((trace_type & TRACE_TYPE_IF) == TRACE_TYPE_IF)
     trace_data_size = sizeof (ioam_trace_if_t);
-  else if (trace_type == TRACE_TYPE_TS)
+  else if ((trace_type & TRACE_TYPE_TS) == TRACE_TYPE_TS)
     trace_data_size = sizeof (ioam_trace_ts_t);
-  else if (trace_type == TRACE_TYPE_APP)
+  else if ((trace_type & TRACE_TYPE_APP) == TRACE_TYPE_APP)
     trace_data_size = sizeof (ioam_trace_app_t);
-  else if (trace_type == TRACE_TYPE_TS_APP)
+  else if ((trace_type & TRACE_TYPE_TS_APP) == TRACE_TYPE_TS_APP)
     trace_data_size = sizeof (ioam_trace_ts_app_t);
 
   return trace_data_size;
 }
 
+always_inline void
+ioam_trace_set_bit (ioam_trace_hdr_t * trace_hdr, u8 trace_bit)
+{
+  trace_hdr->ioam_trace_type |= trace_bit;
+}
+
+always_inline void
+ioam_trace_reset_bit (ioam_trace_hdr_t * trace_hdr, u8 trace_bit)
+{
+  trace_hdr->ioam_trace_type &= (~trace_bit);
+}
+
 int ioam_trace_get_sizeof_handler (u32 * result);
 int ip6_trace_profile_setup (void);
 int ip6_trace_profile_cleanup (void);