On Mon, 4 May 2026 16:52:47 +0200
Laurent Vivier
On 5/3/26 23:55, Stefano Brivio wrote:
From: David Gibson
Most things in ip.[ch] related purely to IP addresses and headers with no dependency on other passt/pasta internals. A number of these will be useful to re-use in pesto. The exception is ipv6_l4hdr() which uses iov_tail.
The only caller of this is in tap.c, so move the function there. Along with moving the constant byteswapping functions to common.h, that lets ip.[ch] to be linked into pesto as well as passt/pasta.
Signed-off-by: David Gibson
Signed-off-by: Stefano Brivio Reviewed-by: Laurent Vivier
But we can fix a pre-existing error while doing the move, see below:
--- common.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ inany.h | 2 ++ ip.c | 56 +++----------------------------------------------------- ip.h | 4 +--- tap.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ util.h | 48 ------------------------------------------------ 6 files changed, 106 insertions(+), 104 deletions(-)
diff --git a/common.h b/common.h index 45f66ea..4a167ae 100644 --- a/common.h +++ b/common.h @@ -55,4 +55,52 @@ static inline const char *strerror_(int errnum)
#define ARRAY_SIZE(a) ((int)(sizeof(a) / sizeof((a)[0])))
+#ifndef __bswap_constant_16 +#define __bswap_constant_16(x) \ + ((uint16_t) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))) +#endif + +#ifndef __bswap_constant_32 +#define __bswap_constant_32(x) \ + ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ + (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) +#endif + +#ifndef __bswap_constant_32 +#define __bswap_constant_32(x) \ + ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ + (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) +#endif
__bswap_constant_32 block is written twice.
Fixed in v7. -- Stefano