From 23a60e62707725c79ccb0e724839562577994261 Mon Sep 17 00:00:00 2001 From: Oleg Hahm <oleg@hobbykeller.org> Date: Tue, 18 Aug 2015 19:31:49 +0200 Subject: [PATCH] universal_address: determine biggest address size --- sys/include/universal_address.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sys/include/universal_address.h b/sys/include/universal_address.h index a7be5337b8..86525f4aad 100644 --- a/sys/include/universal_address.h +++ b/sys/include/universal_address.h @@ -29,7 +29,18 @@ extern "C" { #include <stdlib.h> #include "net/ipv6/addr.h" -#define UNIVERSAL_ADDRESS_SIZE (16) /**< size of the used addresses in bytes */ +/** @brief size of the used addresses in bytes */ +/* determine the widest possible address type */ +#ifndef UNIVERSAL_ADDRESS_SIZE +#define UNIVERSAL_ADDRESS_SIZE (0) /* rather senseless default, should + trigger warnings */ +#endif + +/* IPv6 address has 128 bit -> 16 bytes */ +#if defined(MODULE_IPV6_ADDR) && ((IPV6_ADDR_BIT_LEN >> 3) > UNIVERSAL_ADDRESS_SIZE) +#undef UNIVERSAL_ADDRESS_SIZE +#define UNIVERSAL_ADDRESS_SIZE (IPV6_ADDR_BIT_LEN >> 3) +#endif /** * @brief The container descriptor used to identify a universal address entry -- GitLab