Trusted Solaris Developer's Guide

Examining Attributes

You can retrieve the security attributes for either the next byte of data to be read or the last byte of data read. This example uses the sensitivity label mask to peek at the sensitivity label of the next byte of data and look up the sensitivity label on the last byte of data.

#include <tsix/t6attrs.h>
#include <tsol/label.h>

main()
{
	char buf[512]
	int retval, sock;
	int len = sizeof(buf);
	t6mask_t recvmask;
	t6attr_t recvattrs;

	recvmask = T6M_SL;
	recvattrs = t6alloc_blk(recvmask);

/* Code to set up socket communications */
/* ... */

/* Peek at sensitivity label on next byte of data */
	 retval = t6peek_attr(sock, recvattrs, &recvmask);

/* Look up sensitivity label on last byte of data */
	 retval = t6last_attr(sock, recvattrs, &recvmask);
}