Go to the first, previous, next, last section, table of contents.
device_set_filter
makes it possible to filter out
selected data arriving at the device and forward it to a port.
filter is a list of filter commands, which are applied to incoming
data to determine if the data should be sent to receive_port. The
IPC type of the send right is specified by receive_port_right, it
is either MACH_MSG_TYPE_MAKE_SEND
or
MACH_MSG_TYPE_MOVE_SEND
. The priority value is used to
order multiple filters.
There can be up to NET_MAX_FILTER
commands in filter. The
actual number of commands is passed in filter_count. For the
purpose of the filter test, an internal stack is provided. After all
commands have been processed, the value on the top of the stack
determines if the data is forwarded or the next filter is tried.
Each word of the command list specifies a data (push) operation (high order NETF_NBPO bits) as well as a binary operator (low order NETF_NBPA bits). The value to be pushed onto the stack is chosen as follows.
ETF_PUSHLIT
NETF_PUSHZERO
NETF_PUSHWORD+N
NETF_PUSHHDR+N
NETF_PUSHIND+N
NETF_PUSHHDRIND+N
NETF_PUSHSTK+N
NETF_NOPUSH
The unsigned value so chosen is promoted to a long word before being
pushed. Once a value is pushed (except for the case of
NETF_NOPUSH
), the top two long words of the stack are popped and
a binary operator applied to them (with the old top of stack as the
second operand). The result of the operator is pushed on the stack.
These operators are:
NETF_NOP
NETF_EQ
NETF_LT
NETF_LE
NETF_GT
NETF_GE
NETF_AND
NETF_OR
NETF_XOR
NETF_NEQ
NETF_LSH
NETF_RSH
NETF_ADD
NETF_SUB
NETF_COR
TRUE
, terminate
the filter list. Otherwise, pop the result of the comparison off the
stack.
NETF_CAND
FALSE
,
terminate the filter list. Otherwise, pop the result of the comparison
off the stack.
NETF_CNOR
FALSE
,
terminate the filter list. Otherwise, pop the result of the comparison
off the stack.
NETF_CNAND
TRUE
,
terminate the filter list. Otherwise, pop the result of the comparison
off the stack. The scan of the filter list terminates when the filter
list is emptied, or a NETF_C...
operation terminates the list. At
this time, if the final value of the top of the stack is TRUE
,
then the message is accepted for the filter.
The function returns D_SUCCESS
if some data was successfully
written, D_INVALID_OPERATION
if receive_port is not a valid
send right, and D_NO_SUCH_DEVICE
if device does not denote
a device port or the device is dead or not completely open.
Go to the first, previous, next, last section, table of contents.