## <summary>implementation of the Precision Time Protocol (PTP) according to IEEE standard 1588 for Linux.</summary>

########################################
## <summary>
##	Execute domain in the phc2sys domain.
## </summary>
## <param name="domain">
## <summary>
##	Domain allowed to transition.
## </summary>
## </param>
#
interface(`linuxptp_domtrans_phc2sys',`
	gen_require(`
		type phc2sys_t, phc2sys_exec_t;
	')

	corecmd_search_bin($1)
	domtrans_pattern($1, phc2sys_exec_t, phc2sys_t)
')

########################################
## <summary>
##	Execute domain in the phc2sys domain.
## </summary>
## <param name="domain">
## <summary>
##	Domain allowed to transition.
## </summary>
## </param>
#
interface(`linuxptp_domtrans_ptp4l',`
	gen_require(`
		type ptp4l_t, ptp4l_exec_t;
	')

	corecmd_search_bin($1)
	domtrans_pattern($1, ptp4l_exec_t, ptp4l_t)
')
######################################
## <summary>
##  Connect to timemaster using a unix
##  domain stream socket.
## </summary>
## <param name="domain">
##  <summary>
##  Domain allowed access.
##  </summary>
## </param>
#
interface(`timemaster_stream_connect',`
	gen_require(`
        	type timemaster_t, timemaster_var_run_t;
        ')

        files_search_pids($1)
        stream_connect_pattern($1, timemaster_var_run_t, timemaster_var_run_t, timemaster_t)
')

########################################
## <summary>
## Read timemaster conf files.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`timemaster_read_pid_files',`
	gen_require(`
		type timemaster_var_run_t;
	')

    read_files_pattern($1, timemaster_var_run_t, timemaster_var_run_t)
')

########################################
## <summary>
## Read and write timemaster shared memory.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`timemaster_rw_shm',`
	gen_require(`
		type timemaster_t, timemaster_tmpfs_t;
	')

	allow $1 timemaster_t:shm rw_shm_perms;
	list_dirs_pattern($1, timemaster_tmpfs_t, timemaster_tmpfs_t)
	rw_files_pattern($1, timemaster_tmpfs_t, timemaster_tmpfs_t)
	read_lnk_files_pattern($1, timemaster_tmpfs_t, timemaster_tmpfs_t)
	fs_search_tmpfs($1)
')

########################################
## <summary>
## Read and write ptp4l_t shared memory.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`ptp4l_rw_shm',`
	gen_require(`
		type ptp4l_t, timemaster_tmpfs_t;
	')

	allow $1 ptp4l_t:shm rw_shm_perms;
	list_dirs_pattern($1, timemaster_tmpfs_t, timemaster_tmpfs_t)
	rw_files_pattern($1, timemaster_tmpfs_t, timemaster_tmpfs_t)
	read_lnk_files_pattern($1, timemaster_tmpfs_t, timemaster_tmpfs_t)
	fs_search_tmpfs($1)
')

########################################
## <summary>
## Read and write phc2sys_t shared memory.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`phc2sys_rw_shm',`
	gen_require(`
		type phc2sys_t, timemaster_tmpfs_t;
	')

	allow $1 phc2sys_t:shm rw_shm_perms;
	list_dirs_pattern($1, timemaster_tmpfs_t, timemaster_tmpfs_t)
	rw_files_pattern($1, timemaster_tmpfs_t, timemaster_tmpfs_t)
	read_lnk_files_pattern($1, timemaster_tmpfs_t, timemaster_tmpfs_t)
	fs_search_tmpfs($1)
')
