FreeBSD/sys/security/audit/bsm_token.c
/*
 * token ID                1 byte
 * socket family           2 bytes
 * path                    (up to) 104 bytes + NULL  (NULL terminated string)
 */
token ID                1 byte
socket family           2 bytes
path                    (up to) 104 bytes + NULL  (NULL terminated string)
token ID 1 byte socket family 2 bytes path ( up to ) 104 bytes + NULL ( NULL terminated string )
token_t *
au_to_sock_unix(struct sockaddr_un *so)
{
	token_t *t;
	u_char *dptr;
	GET_TOKEN_AREA(t, dptr, 3 * sizeof(u_char) + strlen(so->sun_path) + 1);
	ADD_U_CHAR(dptr, AUT_SOCKUNIX);
	ADD_U_CHAR(dptr, 0);
	ADD_U_CHAR(dptr, so->sun_family);
	ADD_STRING(dptr, so->sun_path, strlen(so->sun_path) + 1);
	return (t);
}
token_t * au_to_sock_unix ( struct sockaddr_un * so ) { token_t * t ; u_char * dptr ; GET_TOKEN_AREA ( t , dptr , 3 * sizeof ( u_char ) + strlen ( so -> sun_path ) + 1 ) ; ADD_U_CHAR ( dptr , AUT_SOCKUNIX ) ; ADD_U_CHAR ( dptr , 0 ) ; ADD_U_CHAR ( dptr , so -> sun_family ) ; ADD_STRING ( dptr , so -> sun_path , strlen ( so -> sun_path ) + 1 ) ; return ( t ) ; }
token ID                1 byte
 socket family           2 bytes
 path                    (up to) 104 bytes + NULL  (NULL terminated string)
token ID 1 byte socket family 2 bytes path ( up to ) 104 bytes + NULL ( NULL terminated string )
/* BSM token has two bytes for family */