-#ifdef __linux__
- case AF_INET:
- {
- struct msghdr m;
- struct cmsghdr *cm;
- struct iovec iov[2];
- u_char cmsgbuf[256];
- struct in_pktinfo *pi;
- int ifindex = 0;
- struct sockaddr_in src6, dst6;
-
- memcpy(&src6, src, sizeof(src6));
- memcpy(&dst6, dst, sizeof(dst6));
-
- memset(&m, 0, sizeof(m));
- m.msg_name = (caddr_t)&dst6;
- m.msg_namelen = sizeof(dst6);
- iov[0].iov_base = (char *)buf;
- iov[0].iov_len = buflen;
- m.msg_iov = iov;
- m.msg_iovlen = 1;
-
- memset(cmsgbuf, 0, sizeof(cmsgbuf));
- cm = (struct cmsghdr *)cmsgbuf;
- m.msg_control = (caddr_t)cm;
- m.msg_controllen = CMSG_SPACE(sizeof(struct in_pktinfo));
-
- cm->cmsg_len = CMSG_LEN(sizeof(struct in_pktinfo));
- cm->cmsg_level = IPPROTO_IP;
- cm->cmsg_type = IP_PKTINFO;
- pi = (struct in_pktinfo *)CMSG_DATA(cm);
- memcpy(&pi->ipi_spec_dst, &src6.sin_addr, sizeof(src6.sin_addr));
- pi->ipi_ifindex = ifindex;
-
- plog(LLV_DEBUG, LOCATION, NULL,
- "src4 %s\n",
- saddr2str((struct sockaddr *)&src6));
- plog(LLV_DEBUG, LOCATION, NULL,
- "dst4 %s\n",
- saddr2str((struct sockaddr *)&dst6));
-
- for (i = 0; i < cnt; i++) {
- len = sendmsg(s, &m, 0 /*MSG_DONTROUTE*/);
- if (len < 0) {
- plog(LLV_ERROR, LOCATION, NULL,
- "sendmsg (%s)\n", strerror(errno));
- return -1;
- }
- plog(LLV_DEBUG, LOCATION, NULL,
- "%d times of %d bytes message will be sent "
- "to %s\n",
- i + 1, len, saddr2str(dst));
- }
- plogdump(LLV_DEBUG, (char *)buf, buflen);
-
- return len;
- }
-#endif /* __linux__ */