# define NETLINK_SOCK_DIAG NETLINK_INET_DIAG
# endif
-#define INIT_STRUCT(type, name, ...) \
- do { \
- type tmp = { __VA_ARGS__ }; \
- memcpy(name, &tmp, sizeof(tmp)); \
- } while (0)
static void
test_nlmsg_type(const int fd)
{
/* unspecified family only */
nlh = nlh0 - sizeof(*family);
/* beware of unaligned access to nlh members */
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*family),
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
.nlmsg_flags = NLM_F_REQUEST
/* unspecified family and string */
nlh = nlh0 - (sizeof(*family) + 4);
/* beware of unaligned access to nlh members */
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*family) + 4,
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
.nlmsg_flags = NLM_F_REQUEST
/* unspecified family only */
nlh = nlh0 - sizeof(*family);
/* beware of unaligned access to nlh members */
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*family),
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
.nlmsg_flags = NLM_F_DUMP
/* unspecified family and string */
nlh = nlh0 - (sizeof(*family) + 4);
/* beware of unaligned access to nlh members */
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*family) + 4,
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
.nlmsg_flags = NLM_F_DUMP
/* family only */
nlh = nlh0 - sizeof(*family);
/* beware of unaligned access to nlh members */
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*family),
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
.nlmsg_flags = NLM_F_REQUEST
/* family and string */
nlh = nlh0 - (sizeof(*family) + 4);
/* beware of unaligned access to nlh members */
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*family) + 4,
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
.nlmsg_flags = NLM_F_REQUEST
/* unix_diag_req */
nlh = nlh0 - sizeof(*req);
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*req),
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
.nlmsg_flags = NLM_F_REQUEST
/* family only */
nlh = nlh0 - sizeof(*family);
/* beware of unaligned access to nlh members */
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*family),
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
.nlmsg_flags = NLM_F_DUMP
/* family and string */
nlh = nlh0 - (sizeof(*family) + 4);
/* beware of unaligned access to nlh members */
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*family) + 4,
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
.nlmsg_flags = NLM_F_DUMP
/* unix_diag_msg */
nlh = nlh0 - sizeof(*msg);
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*msg),
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
.nlmsg_flags = NLM_F_DUMP
/* family only */
nlh = nlh0 - sizeof(*family);
/* beware of unaligned access to nlh members */
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*family),
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
.nlmsg_flags = NLM_F_REQUEST
/* family and string */
nlh = nlh0 - (sizeof(*family) + 4);
/* beware of unaligned access to nlh members */
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*family) + 4,
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
.nlmsg_flags = NLM_F_REQUEST
/* netlink_diag_req */
nlh = nlh0 - sizeof(*req);
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*req),
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
.nlmsg_flags = NLM_F_REQUEST
/* family only */
nlh = nlh0 - sizeof(*family);
/* beware of unaligned access to nlh members */
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*family),
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
.nlmsg_flags = NLM_F_DUMP
/* family and string */
nlh = nlh0 - (sizeof(*family) + 4);
/* beware of unaligned access to nlh members */
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*family) + 4,
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
.nlmsg_flags = NLM_F_DUMP
/* netlink_diag_msg */
nlh = nlh0 - sizeof(*msg);
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*msg),
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
.nlmsg_flags = NLM_F_DUMP
/* family only */
nlh = nlh0 - sizeof(*family);
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*family),
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
.nlmsg_flags = NLM_F_REQUEST
/* family and string */
nlh = nlh0 - (sizeof(*family) + 4);
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*family) + 4,
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
.nlmsg_flags = NLM_F_REQUEST
/* packet_diag_req */
nlh = nlh0 - sizeof(*req);
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*req),
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
.nlmsg_flags = NLM_F_REQUEST
/* family only */
nlh = nlh0 - sizeof(*family);
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*family),
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
.nlmsg_flags = NLM_F_DUMP
/* family and string */
nlh = nlh0 - (sizeof(*family) + 4);
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*family) + 4,
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
.nlmsg_flags = NLM_F_DUMP
/* packet_diag_msg */
nlh = nlh0 - sizeof(*msg);
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*msg),
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
.nlmsg_flags = NLM_F_DUMP
nlh = nlh0 - sizeof(*req);
/* beware of unaligned access to nlh members */
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*req),
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
.nlmsg_flags = NLM_F_REQUEST
/* family only */
nlh = nlh0 - sizeof(*family);
/* beware of unaligned access to nlh members */
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*family),
.nlmsg_type = TCPDIAG_GETSOCK,
.nlmsg_flags = NLM_F_REQUEST
/* family and string */
nlh = nlh0 - (sizeof(*family) + 4);
/* beware of unaligned access to nlh members */
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*family) + 4,
.nlmsg_type = TCPDIAG_GETSOCK,
.nlmsg_flags = NLM_F_REQUEST
/* inet_diag_req */
nlh = nlh0 - sizeof(*req);
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*req),
.nlmsg_type = TCPDIAG_GETSOCK,
.nlmsg_flags = NLM_F_REQUEST
/* family only */
nlh = nlh0 - sizeof(*family);
/* beware of unaligned access to nlh members */
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*family),
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
.nlmsg_flags = NLM_F_REQUEST
/* family and string */
nlh = nlh0 - sizeof(*family) - 4;
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*family) + 4,
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
.nlmsg_flags = NLM_F_REQUEST
/* inet_diag_req_v2 */
nlh = nlh0 - sizeof(*req);
/* beware of unaligned access to nlh members */
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*req),
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
.nlmsg_flags = NLM_F_REQUEST
/* family only */
nlh = nlh0 - sizeof(*family);
/* beware of unaligned access to nlh members */
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*family),
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
.nlmsg_flags = NLM_F_DUMP
/* family and string */
nlh = nlh0 - sizeof(*family) - 4;
/* beware of unaligned access to nlh members */
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*family) + 4,
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
.nlmsg_flags = NLM_F_DUMP
/* inet_diag_msg */
nlh = nlh0 - sizeof(*msg);
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*msg),
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
.nlmsg_flags = NLM_F_DUMP
/* family only */
nlh = nlh0 - sizeof(*family);
/* beware of unaligned access to nlh members */
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*family),
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
.nlmsg_flags = NLM_F_REQUEST
/* family and string */
nlh = nlh0 - sizeof(*family) - 4;
/* beware of unaligned access to nlh members */
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*family) + 4,
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
.nlmsg_flags = NLM_F_REQUEST
/* smc_diag_req */
nlh = nlh0 - sizeof(*req);
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*req),
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
.nlmsg_flags = NLM_F_REQUEST
/* family only */
nlh = nlh0 - sizeof(*family);
/* beware of unaligned access to nlh members */
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*family),
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
.nlmsg_flags = NLM_F_DUMP
/* family and string */
nlh = nlh0 - sizeof(*family) - 4;
/* beware of unaligned access to nlh members */
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*family) + 4,
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
.nlmsg_flags = NLM_F_DUMP
/* smc_diag_msg */
nlh = nlh0 - sizeof(*msg);
- INIT_STRUCT(struct nlmsghdr, nlh,
+ SET_STRUCT(struct nlmsghdr, nlh,
.nlmsg_len = NLMSG_HDRLEN + sizeof(*msg),
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
.nlmsg_flags = NLM_F_DUMP