1301 */
1302 bcopy(&tv, CMSG_CONTENT(cmsg), sizeof (tv));
1303 } else {
1304 struct timeval32 *time32;
1305
1306 cmsg->cmsg_len = sizeof (struct timeval32) +
1307 sizeof (struct cmsghdr);
1308 time32 = (struct timeval32 *)CMSG_CONTENT(cmsg);
1309 time32->tv_sec = (time32_t)timestamp->tv_sec;
1310 time32->tv_usec =
1311 (int32_t)(timestamp->tv_nsec /
1312 (NANOSEC / MICROSEC));
1313 }
1314
1315 } else {
1316 if (oldflg)
1317 continue;
1318
1319 cmsg->cmsg_level = tohp->level;
1320 cmsg->cmsg_type = tohp->name;
1321 cmsg->cmsg_len = (socklen_t)(_TPI_TOPT_DATALEN(tohp) +
1322 sizeof (struct cmsghdr));
1323
1324 /* copy content to control data part */
1325 bcopy(&tohp[1], CMSG_CONTENT(cmsg),
1326 CMSG_CONTENTLEN(cmsg));
1327 }
1328 /* move to next CMSG structure! */
1329 cmsg = CMSG_NEXT(cmsg);
1330 }
1331 dprint(1, ("so_opt2cmsg: buf %p len %d; cend %p; final cmsg %p\n",
1332 control, controllen, (void *)cend, (void *)cmsg));
1333 ASSERT(cmsg <= cend);
1334 return (0);
1335 }
1336
1337 /*
1338 * Extract the SO_SRCADDR option value if present.
1339 */
1340 void
1341 so_getopt_srcaddr(void *opt, t_uscalar_t optlen, void **srcp,
1342 t_uscalar_t *srclenp)
|
1301 */
1302 bcopy(&tv, CMSG_CONTENT(cmsg), sizeof (tv));
1303 } else {
1304 struct timeval32 *time32;
1305
1306 cmsg->cmsg_len = sizeof (struct timeval32) +
1307 sizeof (struct cmsghdr);
1308 time32 = (struct timeval32 *)CMSG_CONTENT(cmsg);
1309 time32->tv_sec = (time32_t)timestamp->tv_sec;
1310 time32->tv_usec =
1311 (int32_t)(timestamp->tv_nsec /
1312 (NANOSEC / MICROSEC));
1313 }
1314
1315 } else {
1316 if (oldflg)
1317 continue;
1318
1319 cmsg->cmsg_level = tohp->level;
1320 cmsg->cmsg_type = tohp->name;
1321 cmsg->cmsg_len = (socklen_t)sizeof (struct cmsghdr);
1322 if (tohp->level == IPPROTO_IP &&
1323 (tohp->name == IP_RECVTOS ||
1324 tohp->name == IP_RECVTTL)) {
1325 /*
1326 * The data for these is a uint8_t but, in
1327 * order to maintain alignment for any
1328 * following TPI primitives in the message,
1329 * there will be some trailing padding bytes
1330 * which are included in the TPI_TOPT_DATALEN.
1331 * For these types, we set the cmsg_len
1332 * explicitly to the correct value.
1333 */
1334 cmsg->cmsg_len += (socklen_t)sizeof (uint8_t);
1335 } else {
1336 cmsg->cmsg_len +=
1337 (socklen_t)(_TPI_TOPT_DATALEN(tohp));
1338 }
1339
1340 /* copy content to control data part */
1341 bcopy(&tohp[1], CMSG_CONTENT(cmsg),
1342 CMSG_CONTENTLEN(cmsg));
1343 }
1344 /* move to next CMSG structure! */
1345 cmsg = CMSG_NEXT(cmsg);
1346 }
1347 dprint(1, ("so_opt2cmsg: buf %p len %d; cend %p; final cmsg %p\n",
1348 control, controllen, (void *)cend, (void *)cmsg));
1349 ASSERT(cmsg <= cend);
1350 return (0);
1351 }
1352
1353 /*
1354 * Extract the SO_SRCADDR option value if present.
1355 */
1356 void
1357 so_getopt_srcaddr(void *opt, t_uscalar_t optlen, void **srcp,
1358 t_uscalar_t *srclenp)
|