# HG changeset patch # User Sebastien Decugis # Date 1281510831 -32400 # Node ID 65efe8ff2c3018bfc56e4e7b317e3172463f6eff # Parent 23e1fae23c75bf777ff98259789a8f5d2bad3fa8 Change creation of anciliary data to avoid padding, should close #12 diff -r 23e1fae23c75 -r 65efe8ff2c30 freeDiameter/sctp.c --- a/freeDiameter/sctp.c Tue Aug 10 14:24:05 2010 +0900 +++ b/freeDiameter/sctp.c Wed Aug 11 16:13:51 2010 +0900 @@ -1000,10 +1000,9 @@ { struct msghdr mhdr; struct iovec iov; - struct { - struct cmsghdr hdr; - struct sctp_sndrcvinfo sndrcv; - } anci; + struct cmsghdr *hdr; + struct sctp_sndrcvinfo *sndrcv; + uint8_t anci[CMSG_SPACE(sizeof(struct sctp_sndrcvinfo))]; ssize_t ret; int timedout = 0; @@ -1019,10 +1018,12 @@ iov.iov_len = len; /* Anciliary data: specify SCTP stream */ - anci.hdr.cmsg_len = sizeof(anci); - anci.hdr.cmsg_level = IPPROTO_SCTP; - anci.hdr.cmsg_type = SCTP_SNDRCV; - anci.sndrcv.sinfo_stream = strid; + hdr = (struct cmsghdr *)anci; + sndrcv = (struct sctp_sndrcvinfo *)CMSG_DATA(hdr); + hdr->cmsg_len = sizeof(anci); + hdr->cmsg_level = IPPROTO_SCTP; + hdr->cmsg_type = SCTP_SNDRCV; + sndrcv->sinfo_stream = strid; /* note : we could store other data also, for example in .sinfo_ppid for remote peer or in .sinfo_context for errors. */ /* We don't use mhdr.msg_name here; it could be used to specify an address different from the primary */ @@ -1030,7 +1031,7 @@ mhdr.msg_iov = &iov; mhdr.msg_iovlen = 1; - mhdr.msg_control = &anci; + mhdr.msg_control = anci; mhdr.msg_controllen = sizeof(anci); TRACE_DEBUG(FULL, "Sending %db data on stream %hu of socket %d", len, strid, sock);