- size_t cmsg_data[( CMSG_SPACE(sizeof(struct in_pktinfo)) / sizeof(size_t)) + 1];
- unsigned char buffer[MAX_NAME_LEN];
- struct dns_header h = { 0 };
- struct dns_question q = { 0 };
- struct msghdr m = { 0 };
- struct iovec iov[3] = { {0}, {0}, {0} };
- struct sockaddr_in a = { 0 };
+ static size_t cmsg_data[( CMSG_SPACE(sizeof(struct in_pktinfo)) / sizeof(size_t)) + 1];
+ static unsigned char buffer[MAX_NAME_LEN];
+ static struct dns_header h = {
+ .questions = cpu_to_be16(1),
+ };
+ static struct dns_question q = {
+ .class = cpu_to_be16(1),
+ };
+ static struct iovec iov[] = {
+ {
+ .iov_base = &h,
+ .iov_len = sizeof(h),
+ },
+ {
+ .iov_base = buffer,
+ },
+ {
+ .iov_base = &q,
+ .iov_len = sizeof(q),
+ }
+ };
+ static struct sockaddr_in a = {
+ .sin_family = AF_INET,
+ .sin_port = htons(MCAST_PORT),
+ };
+ static struct msghdr m = {
+ .msg_name = (struct sockaddr *) &a,
+ .msg_namelen = sizeof(a),
+ .msg_iov = iov,
+ .msg_iovlen = ARRAY_SIZE(iov),
+ .msg_control = cmsg_data,
+ .msg_controllen = CMSG_LEN(sizeof(struct in_pktinfo)),
+ };