rather than binding the socket. This will be mostly useful
when we gain support for arbitrary number of server addresses
*/
- pktinfo = (struct in_pktinfo*) CMSG_DATA(cmsg);
+ pktinfo = CMSG_TYPED_DATA(cmsg, struct in_pktinfo);
assert(pktinfo);
pktinfo->ipi_ifindex = server->ifindex;
cmsg->cmsg_type = SCM_CREDENTIALS;
cmsg->cmsg_len = CMSG_LEN(sizeof(struct ucred));
- ucred = (struct ucred*) CMSG_DATA(cmsg);
+ ucred = CMSG_TYPED_DATA(cmsg, struct ucred);
ucred->pid = pid != 0 ? pid : getpid_cached();
ucred->uid = getuid();
ucred->gid = getgid();
cmsg->cmsg_level = IPPROTO_IP;
cmsg->cmsg_type = IP_PKTINFO;
- pi = (struct in_pktinfo*) CMSG_DATA(cmsg);
+ pi = CMSG_TYPED_DATA(cmsg, struct in_pktinfo);
pi->ipi_ifindex = ifindex;
if (source)
cmsg->cmsg_level = IPPROTO_IPV6;
cmsg->cmsg_type = IPV6_PKTINFO;
- pi = (struct in6_pktinfo*) CMSG_DATA(cmsg);
+ pi = CMSG_TYPED_DATA(cmsg, struct in6_pktinfo);
pi->ipi6_ifindex = ifindex;
if (source)