aboutsummaryrefslogtreecommitdiffstats
path: root/src/vppinfra
diff options
context:
space:
mode:
authorNathan Skrzypczak <nathan.skrzypczak@gmail.com>2022-02-02 19:31:58 +0100
committerBeno�t Ganne <bganne@cisco.com>2022-10-17 16:25:01 +0000
commitf284c14c7bd8731367ba3527cdfffa610a8c6de4 (patch)
tree504a326f6577225909894bf8c918eabaa2b1c0d7 /src/vppinfra
parent2a6f35f24c6ab5aba63c0dfa21e865a8cd89f7cf (diff)
cnat: Add sctp support
This patch adds SCTP support in the CNat translation primitives. It also exposes a clib_crc32c_with_init function allowing to set the init value to start the crc32 with instead of 0. Type: feature Change-Id: I86add4cfcac08f2a5a34d1e1841122fafd349fe7 Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com>
Diffstat (limited to 'src/vppinfra')
-rw-r--r--src/vppinfra/crc32.h20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/vppinfra/crc32.h b/src/vppinfra/crc32.h
index 3b81daf28ca..2b20fef9027 100644
--- a/src/vppinfra/crc32.h
+++ b/src/vppinfra/crc32.h
@@ -76,23 +76,27 @@ clib_crc32c_u64 (u32 last, u64 data)
#ifdef clib_crc32c_uses_intrinsics
static_always_inline u32
-clib_crc32c (u8 * s, int len)
+clib_crc32c_with_init (u8 *s, int len, u32 last)
{
- u32 v = 0;
-
for (; len >= 8; len -= 8, s += 8)
- v = clib_crc32c_u64 (v, *((u64u *) s));
+ last = clib_crc32c_u64 (last, *((u64u *) s));
for (; len >= 4; len -= 4, s += 4)
- v = clib_crc32c_u32 (v, *((u32u *) s));
+ last = clib_crc32c_u32 (last, *((u32u *) s));
for (; len >= 2; len -= 2, s += 2)
- v = clib_crc32c_u16 (v, *((u16u *) s));
+ last = clib_crc32c_u16 (last, *((u16u *) s));
for (; len >= 1; len -= 1, s += 1)
- v = clib_crc32c_u8 (v, *((u8 *) s));
+ last = clib_crc32c_u8 (last, *((u8 *) s));
+
+ return last;
+}
- return v;
+static_always_inline u32
+clib_crc32c (u8 *s, int len)
+{
+ return clib_crc32c_with_init (s, len, 0);
}
#endif