diff options
author | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2016-12-07 14:11:28 +0100 |
---|---|---|
committer | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2016-12-07 14:20:52 +0100 |
commit | d15b0b0a1b494c14b139d2d28706d82cd6e2f139 (patch) | |
tree | f704869689e1acab9a4f3417849ac5853188310d /lib/unaligned.h | |
parent | 5df4073c81942ea119de90a81431bae71c87157b (diff) |
BGP redesign
Integrated and extensible BGP with generalized AFI handling,
support for IPv4+IPv6 AFI and unicast+multicast SAFI.
Diffstat (limited to 'lib/unaligned.h')
-rw-r--r-- | lib/unaligned.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/unaligned.h b/lib/unaligned.h index ad5811ab..4e841f3a 100644 --- a/lib/unaligned.h +++ b/lib/unaligned.h @@ -69,4 +69,22 @@ put_u64(void *p, u64 x) memcpy(p+4, &xl, 4); } +static inline void +get_u32s(const void *p, u32 *x, int n) +{ + int i; + memcpy(x, p, 4*n); + for (i = 0; i < n; i++) + x[i] = ntohl(x[i]); +} + +static inline void +put_u32s(void *p, const u32 *x, int n) +{ + int i; + for (i = 0; i < n; i++) + put_u32((byte *) p + 4*i, x[i]); +} + + #endif |