u32 h_n_bytes = sizeof (h[0]);
vec_add2 (*result, p, g_n_bytes);
- memcpy (p, g, g_n_bytes);
+ clib_memcpy (p, g, g_n_bytes);
vec_add2 (*result, p, h_n_bytes);
- memcpy (p, h, h_n_bytes);
+ clib_memcpy (p, h, h_n_bytes);
}
return 1;
tx_fib_index_or_output_swif_index = tx_fib_id;
}
- key = ((u64)rx_fib_index<<32) | ((u64) (label_host_byte_order<<12))
+ key = ((u64) rx_fib_index<<32) | ((u64) label_host_byte_order<<12)
| ((u64) s_bit<<8);
p = hash_get (mm->mpls_decap_by_rx_fib_and_label, key);
.function = mpls_del_decap_command_fn,
};
-typedef struct {
- u32 fib_index;
- u32 entry_index;
- u32 dest;
- u32 s_bit;
- u32 label;
-} show_mpls_fib_t;
+int
+mpls_dest_cmp(void * a1, void * a2)
+{
+ show_mpls_fib_t * r1 = a1;
+ show_mpls_fib_t * r2 = a2;
+
+ return clib_net_to_host_u32(r1->dest) - clib_net_to_host_u32(r2->dest);
+}
+
+int
+mpls_fib_index_cmp(void * a1, void * a2)
+{
+ show_mpls_fib_t * r1 = a1;
+ show_mpls_fib_t * r2 = a2;
+
+ return r1->fib_index - r2->fib_index;
+}
+
+int
+mpls_label_cmp(void * a1, void * a2)
+{
+ show_mpls_fib_t * r1 = a1;
+ show_mpls_fib_t * r2 = a2;
+
+ return r1->label - r2->label;
+}
static clib_error_t *
show_mpls_fib_command_fn (vlib_main_t * vm,
goto decap_table;
}
/* sort output by dst address within fib */
- vec_sort (records, r0, r1, clib_net_to_host_u32(r0->dest) -
- clib_net_to_host_u32(r1->dest));
- vec_sort (records, r0, r1, r0->fib_index - r1->fib_index);
+ vec_sort_with_function (records, mpls_dest_cmp);
+ vec_sort_with_function (records, mpls_fib_index_cmp);
vlib_cli_output (vm, "MPLS encap table");
vlib_cli_output (vm, "%=6s%=16s%=16s", "Table", "Dest address", "Labels");
vec_foreach (s, records)
goto out;
}
- vec_sort (records, r0, r1, r0->label - r1->label);
+ vec_sort_with_function (records, mpls_label_cmp);
vlib_cli_output (vm, "MPLS decap table");
vlib_cli_output (vm, "%=10s%=15s%=6s%=6s", "RX Table", "TX Table/Intfc",
vec_foreach (s, records)
{
- key = ((u64)fib_index <<32) | ((u64)(s->dest<<12)) |
- ((u64)s->s_bit);
+ key = ((u64) fib_index <<32) | ((u64) s->dest<<12) |
+ ((u64) s->s_bit);
hash_unset (mm->mpls_decap_by_rx_fib_and_label, key);
pool_put_index (mm->decaps, s->entry_index);