net: ip: Verify that in_addr/in6_addr struct sizes are correct
Make sure that in_addr/in6_addr structure size match the respective binary IP address size with BUILD_ASSERT. Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
parent
984ebd519a
commit
0da228c57c
3 changed files with 10 additions and 0 deletions
|
@ -144,6 +144,9 @@ struct in6_addr {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Binary size of the IPv6 address */
|
||||||
|
#define NET_IPV6_ADDR_SIZE 16
|
||||||
|
|
||||||
/** IPv4 address struct */
|
/** IPv4 address struct */
|
||||||
struct in_addr {
|
struct in_addr {
|
||||||
union {
|
union {
|
||||||
|
@ -154,6 +157,9 @@ struct in_addr {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Binary size of the IPv4 address */
|
||||||
|
#define NET_IPV4_ADDR_SIZE 4
|
||||||
|
|
||||||
/** Socket address family type */
|
/** Socket address family type */
|
||||||
typedef unsigned short int sa_family_t;
|
typedef unsigned short int sa_family_t;
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,8 @@ LOG_MODULE_REGISTER(net_ipv4, CONFIG_NET_IPV4_LOG_LEVEL);
|
||||||
#include "tcp_internal.h"
|
#include "tcp_internal.h"
|
||||||
#include "ipv4.h"
|
#include "ipv4.h"
|
||||||
|
|
||||||
|
BUILD_ASSERT(sizeof(struct in_addr) == NET_IPV4_ADDR_SIZE);
|
||||||
|
|
||||||
/* Timeout for various buffer allocations in this file. */
|
/* Timeout for various buffer allocations in this file. */
|
||||||
#define NET_BUF_TIMEOUT K_MSEC(50)
|
#define NET_BUF_TIMEOUT K_MSEC(50)
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,8 @@ LOG_MODULE_REGISTER(net_ipv6, CONFIG_NET_IPV6_LOG_LEVEL);
|
||||||
#include "route.h"
|
#include "route.h"
|
||||||
#include "net_stats.h"
|
#include "net_stats.h"
|
||||||
|
|
||||||
|
BUILD_ASSERT(sizeof(struct in6_addr) == NET_IPV6_ADDR_SIZE);
|
||||||
|
|
||||||
/* Timeout value to be used when allocating net buffer during various
|
/* Timeout value to be used when allocating net buffer during various
|
||||||
* neighbor discovery procedures.
|
* neighbor discovery procedures.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue