From 0bfe5d8c792abcdbcf27bfcc7b7b353fba04aee2 Mon Sep 17 00:00:00 2001 From: Neale Ranns Date: Thu, 25 Aug 2016 15:29:12 +0100 Subject: A Protocol Independent Hierarchical FIB (VPP-352) Main Enhancements: - Protocol Independent FIB API - Hierarchical FIB entries. Dynamic recursive route resolution. - Extranet Support. - Integration of IP and MPLS forwarding. - Separation of FIB and Adjacency databases. - Data-Plane Object forwarding model. Change-Id: I52dc815c0d0aa8b493e3cf6b978568f3cc82296c Signed-off-by: Neale Ranns --- vppinfra/vppinfra/vec.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'vppinfra/vppinfra/vec.h') diff --git a/vppinfra/vppinfra/vec.h b/vppinfra/vppinfra/vec.h index 353a06b0..eed96d6b 100644 --- a/vppinfra/vppinfra/vec.h +++ b/vppinfra/vppinfra/vec.h @@ -892,6 +892,26 @@ do { \ (_v(cmp) < 0 ? -1 : (_v(cmp) > 0 ? +1 : 0)); \ }) +/** \brief Search a vector for the index of the entry that matches. + + @param v1 Pointer to a vector + @param v2 Entry to match + @return index of match or ~0 +*/ +#define vec_search(v,E) \ +({ \ + word _v(i) = 0; \ + while (_v(i) < vec_len(v)) \ + { \ + if (v[_v(i)] == E) \ + break; \ + _v(i)++; \ + } \ + if (_v(i) == vec_len(v)) \ + _v(i) = ~0; \ + _v(i); \ +}) + /** \brief Sort a vector using the supplied element comparison function @param vec vector to sort -- cgit 1.2.3-korg