#include <mach/mach_port.h>
mach/mach_port.h
Module mach_port
functionmach_port_allocate_name
extern kern_return_t mach_port_allocate_name( ipc_space_t task, mach_port_right_t right, mach_port_name_t name )
Allocates the specified kind of object, with the given name.
The right must be one of
MACH_PORT_RIGHT_RECEIVE
MACH_PORT_RIGHT_PORT_SET
MACH_PORT_RIGHT_DEAD_NAME
New port sets are empty. New ports don't have any
send/send-once rights or queued messages. The make-send
count is zero and their queue limit is MACH_PORT_QLIMIT_DEFAULT.
New sets, ports, and dead names have one user reference.
CMU/MIT Mach reference · manual page · © Carnegie Mellon
Create a port right with the caller-specified name.
The mach_port_allocate_name function creates a new right in the specified task, with a specified name for the new right.
Notes. This interface is machine word length specific because of the port name parameter.
| KERN_NAME_EXISTS | name was already in use for a port right. |
functionmach_port_destroy
extern kern_return_t mach_port_destroy(ipc_space_t task, mach_port_name_t name)
Destroys all rights associated with the name and makes it
available for recycling immediately. The name can be a
port (possibly with multiple user refs), a port set, or
a dead name (again, with multiple user refs).
CMU/MIT Mach reference · manual page · © Carnegie Mellon
Deallocate all port rights associated with specified name.
The mach_port_destroy function de-allocates all rights denoted by a name. The name becomes immediately available for reuse.
For most purposes, mach_port_mod_refs and mach_port_deallocate are preferable.
If name denotes a port set, then all members of the port set are implicitly removed from the port set.
If name denotes a receive right that is a member of a port set, the receive right is implicitly removed from the port set. Remaining messages queued to the port are destroyed and extant send and send-once rights turn into dead names. If those send and send-once rights have dead-name requests registered, then dead-name notifications are generated for them.
If name denotes a send-once right, then the destruction of the send-once right produces a send-once notification for the port.
If name denotes a send-once, send, and/or receive right, and it has a dead-name request registered, then a port-deleted notification is generated (as opposed to a dead-name notification).
Notes. This interface is machine word length specific because of the port name parameter.
| KERN_INVALID_NAME | The name parameter did not denote a right. |
functiontask_set_port_space
extern kern_return_t task_set_port_space(ipc_space_t task, int table_entries)
Pre-expand task port name space.
OBSOLETE. Do nothing and return success.
CMU/MIT Mach reference · manual page · © Carnegie Mellon
Set the size of the target task's port name space table.
The task_set_port_space function preallocates the specified number of entries in the specified task's IPC name space.
| KERN_NO_SPACE | The requested table size exceeds the maximum allowable table size. |
functionmach_port_get_context
extern kern_return_t mach_port_get_context( ipc_space_read_t task, mach_port_name_t name, mach_vm_address_t *context /* out */ )
Only valid for receive rights.
Gets the context pointer for the port.
functionmach_port_set_context
extern kern_return_t mach_port_set_context( ipc_space_t task, mach_port_name_t name, mach_vm_address_t context )
Only valid for receive rights.
Sets the context pointer for the port.
functionmach_port_construct
extern kern_return_t mach_port_construct( ipc_space_t task, mach_port_options_ptr_t options, uint64_t context, mach_port_name_t *name /* out */ )
Constructs a right based on the options passed
in. Also allows guarding the port as one of the
options if the requested right is a receive
right.
functionmach_port_destruct
extern kern_return_t mach_port_destruct( ipc_space_t task, mach_port_name_t name, mach_port_delta_t srdelta, uint64_t guard )
Destroys a mach port using the guard provided
for guarded ports. Also reduces the user ref
count for send rights as specified by srdelta.
functionmach_port_guard
extern kern_return_t mach_port_guard( ipc_space_t task, mach_port_name_t name, uint64_t guard, boolean_t strict )
Guard an already existing port. Allows guarding
receive rights only. Uses the context field in the
port structure to store the guard.
functionmach_port_unguard
extern kern_return_t mach_port_unguard( ipc_space_t task, mach_port_name_t name, uint64_t guard )
Unguard a port guarded previously. For unguarded ports
or incorrect guards passed in it raises an exception
indicating guarding misbehavior.
functionmach_port_special_reply_port_reset_link
extern kern_return_t mach_port_special_reply_port_reset_link( ipc_space_t task, mach_port_name_t name, boolean_t *srp_lost_link /* out */ )
Returns sync ipc turnstile link status
for special reply ports.
functionmach_port_guard_with_flags
extern kern_return_t mach_port_guard_with_flags( ipc_space_t task, mach_port_name_t name, uint64_t guard, uint64_t flags )
Guard an already existing port. Allows guarding
receive rights only. Uses the context field in the
port structure to store the guard.
functionmach_port_swap_guard
extern kern_return_t mach_port_swap_guard( ipc_space_t task, mach_port_name_t name, uint64_t old_guard, uint64_t new_guard )
Swap guard value of an existing guarded port. Works
only if it is not a strict guard.
macrosubsystem_to_name_map_mach_port
#define subsystem_to_name_map_mach_port { "mach_port_names", 3200 },
{ "mach_port_type", 3201 },
{ "mach_port_rename", 3202 },
{ "mach_port_allocate_name", 3203 },
{ "mach_port_allocate", 3204 },
{ "mach_port_destroy", 3205 },
{ "mach_port_deallocate", 3206 },
{ "mach_port_get_refs", 3207 },
{ "mach_port_mod_refs", 3208 },
{ "mach_port_peek", 3209 },
{ "mach_port_set_mscount", 3210 },
{ "mach_port_get_set_status", 3211 },
{ "mach_port_move_member", 3212 },
{ "mach_port_request_notification", 3213 },
{ "mach_port_insert_right", 3214 },
{ "mach_port_extract_right", 3215 },
{ "mach_port_set_seqno", 3216 },
{ "mach_port_get_attributes", 3217 },
{ "mach_port_set_attributes", 3218 },
{ "mach_port_allocate_qos", 3219 },
{ "mach_port_allocate_full", 3220 },
{ "task_set_port_space", 3221 },
{ "mach_port_get_srights", 3222 },
{ "mach_port_space_info", 3223 },
{ "mach_port_dnrequest_info", 3224 },
{ "mach_port_kernel_object", 3225 },
{ "mach_port_insert_member", 3226 },
{ "mach_port_extract_member", 3227 },
{ "mach_port_get_context", 3228 },
{ "mach_port_set_context", 3229 },
{ "mach_port_kobject", 3230 },
{ "mach_port_construct", 3231 },
{ "mach_port_destruct", 3232 },
{ "mach_port_guard", 3233 },
{ "mach_port_unguard", 3234 },
{ "mach_port_space_basic_info", 3235 },
{ "mach_port_special_reply_port_reset_link", 3236 },
{ "mach_port_guard_with_flags", 3237 },
{ "mach_port_swap_guard", 3238 },
{ "mach_port_kobject_description", 3239 },
{ "mach_port_is_connection_for_service", 3240 },
{ "mach_port_get_service_port_info", 3241 },
{ "mach_port_assert_attributes", 3242 }