Lines Matching refs:filter
59 lck_group = lck_grp_alloc_init("socket filter lock", grp_attrib);
72 struct socket_filter *filter;
76 TAILQ_FOREACH(filter, &proto->pr_filter_head, sf_protosw_next) {
77 sflt_attach_private(so, filter, 0, 0);
87 struct socket_filter_entry *filter;
90 for (filter = so->so_filt; filter; filter = filter_next) {
91 filter_next = filter->sfe_next_onsocket;
92 sflt_detach_private(filter, 0);
110 struct socket_filter_entry *filter;
113 for (filter = so->so_filt; filter; filter = next_filter) {
114 next_filter = filter->sfe_next_onsocket;
116 if (filter->sfe_flags & SFEF_DETACHUSEZERO) {
117 sflt_detach_private(filter, 0);
129 struct socket_filter_entry *filter;
132 for (filter = so->so_filt; filter;
133 filter = filter->sfe_next_onsocket) {
134 if (filter->sfe_filter->sf_filter.sf_notify) {
140 filter->sfe_filter->sf_filter.sf_notify(
141 filter->sfe_cookie, so, event, param);
160 struct socket_filter_entry *filter;
168 for (filter = so->so_filt; filter && (error == 0);
169 filter = filter->sfe_next_onsocket) {
170 if (filter->sfe_filter->sf_filter.sf_data_in) {
176 error = filter->sfe_filter->sf_filter.sf_data_in(
177 filter->sfe_cookie, so, from, data, control, flags);
191 * Assumptions: If filter is not NULL, socket_filter_lock is held.
197 struct socket_filter *filter,
205 if (filter == NULL) {
206 /* Find the filter by the handle */
210 TAILQ_FOREACH(filter, &sock_filter_head, sf_global_next) {
211 if (filter->sf_filter.sf_handle == handle)
216 if (filter == NULL)
220 /* allocate the socket filter entry */
228 /* Initialize the socket filter entry and call the attach function */
229 entry->sfe_filter = filter;
234 filter->sf_usecount++;
242 filter->sf_usecount--;
244 /* If the attach function returns an error, this filter is not attached */
257 /* Put the entry in the filter list */
258 entry->sfe_next_onfilter = filter->sf_entry_head;
259 filter->sf_entry_head = entry;
261 /* Incremenet the parent filter's usecount */
262 filter->sf_usecount++;
277 * the second parameter, it is assumed that the entry is not on the filter's
295 * Attempt to find the entry on the filter's list and
296 * remove it. This prevents a filter detaching at the
303 * Another thread is unregistering the filter, we
304 * need to avoid detaching the filter here so the
307 * the filter unregistration has been completed;
362 * Check if we are removing the last attached filter and
363 * the parent filter is being unregistered.
411 struct socket_filter_entry *filter;
419 for (filter = socket->so_filt; filter;
420 filter = filter->sfe_next_onsocket) {
421 if (filter->sfe_filter->sf_filter.sf_handle == handle)
425 if (filter != NULL) {
426 sflt_detach_private(filter, 0);
441 const struct sflt_filter *filter,
455 if (filter->sf_attach == NULL || filter->sf_detach == NULL ||
456 filter->sf_handle == 0 || filter->sf_name == NULL)
459 /* Allocate the socket filter */
469 len = sizeof (*filter) - sizeof (struct sflt_filter_ext);
471 * Include extended fields if filter defines SFLT_EXTENDED.
475 if (filter->sf_flags & SFLT_EXTENDED) {
476 unsigned int ext_len = filter->sf_len;
483 bcopy(filter, &sock_filt->sf_filter, len);
517 struct socket_filter *filter;
523 TAILQ_FOREACH(filter, &sock_filter_head, sf_global_next) {
524 if (filter->sf_filter.sf_handle == handle)
528 if (filter) {
529 TAILQ_REMOVE(&sock_filter_head, filter, sf_global_next);
530 if ((filter->sf_filter.sf_flags & SFLT_GLOBAL) != 0) {
531 TAILQ_REMOVE(&filter->sf_proto->pr_filter_head, filter, sf_protosw_next);
533 entry_head = filter->sf_entry_head;
534 filter->sf_entry_head = NULL;
535 filter->sf_flags |= SFF_DETACHING;
559 if (filter == NULL)
562 /* We need to detach the filter from any sockets it's attached to */
564 if (filter->sf_filter.sf_unregistered)
565 filter->sf_filter.sf_unregistered(filter->sf_filter.sf_handle);