Home | History | Annotate | Line # | Download | only in kern
uipc_domain.c revision 1.41.2.7
      1  1.41.2.7     skrll /*	$NetBSD: uipc_domain.c,v 1.41.2.7 2005/11/10 14:09:45 skrll Exp $	*/
      2      1.12       cgd 
      3       1.1       cgd /*
      4      1.11   mycroft  * Copyright (c) 1982, 1986, 1993
      5      1.11   mycroft  *	The Regents of the University of California.  All rights reserved.
      6       1.1       cgd  *
      7       1.1       cgd  * Redistribution and use in source and binary forms, with or without
      8       1.1       cgd  * modification, are permitted provided that the following conditions
      9       1.1       cgd  * are met:
     10       1.1       cgd  * 1. Redistributions of source code must retain the above copyright
     11       1.1       cgd  *    notice, this list of conditions and the following disclaimer.
     12       1.1       cgd  * 2. Redistributions in binary form must reproduce the above copyright
     13       1.1       cgd  *    notice, this list of conditions and the following disclaimer in the
     14       1.1       cgd  *    documentation and/or other materials provided with the distribution.
     15  1.41.2.2     skrll  * 3. Neither the name of the University nor the names of its contributors
     16       1.1       cgd  *    may be used to endorse or promote products derived from this software
     17       1.1       cgd  *    without specific prior written permission.
     18       1.1       cgd  *
     19       1.1       cgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     20       1.1       cgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     21       1.1       cgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     22       1.1       cgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     23       1.1       cgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     24       1.1       cgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     25       1.1       cgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26       1.1       cgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     27       1.1       cgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     28       1.1       cgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     29       1.1       cgd  * SUCH DAMAGE.
     30       1.1       cgd  *
     31      1.18      fvdl  *	@(#)uipc_domain.c	8.3 (Berkeley) 2/14/95
     32       1.1       cgd  */
     33      1.36     lukem 
     34      1.36     lukem #include <sys/cdefs.h>
     35  1.41.2.7     skrll __KERNEL_RCSID(0, "$NetBSD: uipc_domain.c,v 1.41.2.7 2005/11/10 14:09:45 skrll Exp $");
     36       1.1       cgd 
     37       1.5   mycroft #include <sys/param.h>
     38       1.5   mycroft #include <sys/socket.h>
     39  1.41.2.6     skrll #include <sys/socketvar.h>
     40       1.5   mycroft #include <sys/protosw.h>
     41       1.5   mycroft #include <sys/domain.h>
     42       1.5   mycroft #include <sys/mbuf.h>
     43       1.5   mycroft #include <sys/time.h>
     44       1.5   mycroft #include <sys/kernel.h>
     45      1.11   mycroft #include <sys/systm.h>
     46      1.30   thorpej #include <sys/callout.h>
     47  1.41.2.5     skrll #include <sys/queue.h>
     48      1.10       cgd #include <sys/proc.h>
     49      1.10       cgd #include <sys/sysctl.h>
     50  1.41.2.6     skrll #include <sys/un.h>
     51  1.41.2.6     skrll #include <sys/unpcb.h>
     52  1.41.2.6     skrll #include <sys/file.h>
     53      1.13  christos 
     54  1.41.2.2     skrll void	pffasttimo(void *);
     55  1.41.2.2     skrll void	pfslowtimo(void *);
     56      1.37      matt 
     57  1.41.2.5     skrll struct domainhead domains = STAILQ_HEAD_INITIALIZER(domains);
     58      1.11   mycroft 
     59      1.30   thorpej struct callout pffasttimo_ch, pfslowtimo_ch;
     60      1.30   thorpej 
     61      1.19   thorpej /*
     62      1.19   thorpej  * Current time values for fast and slow timeouts.  We can use u_int
     63      1.19   thorpej  * relatively safely.  The fast timer will roll over in 27 years and
     64      1.19   thorpej  * the slow timer in 68 years.
     65      1.19   thorpej  */
     66      1.19   thorpej u_int	pfslowtimo_now;
     67      1.19   thorpej u_int	pffasttimo_now;
     68      1.19   thorpej 
     69       1.4    andrew void
     70       1.1       cgd domaininit()
     71       1.1       cgd {
     72  1.41.2.5     skrll 	__link_set_decl(domains, struct domain);
     73  1.41.2.5     skrll 	struct domain * const * dpp;
     74  1.41.2.5     skrll 	struct domain *rt_domain = NULL;
     75       1.1       cgd 
     76      1.26    itojun 	/*
     77  1.41.2.5     skrll 	 * Add all of the domains.  Make sure the PF_ROUTE
     78  1.41.2.5     skrll 	 * domain is added last.
     79      1.26    itojun 	 */
     80  1.41.2.5     skrll 	__link_set_foreach(dpp, domains) {
     81  1.41.2.5     skrll 		if ((*dpp)->dom_family == PF_ROUTE)
     82  1.41.2.5     skrll 			rt_domain = *dpp;
     83  1.41.2.5     skrll 		else
     84  1.41.2.5     skrll 			domain_attach(*dpp);
     85  1.41.2.5     skrll 	}
     86  1.41.2.5     skrll 	if (rt_domain)
     87  1.41.2.5     skrll 		domain_attach(rt_domain);
     88  1.41.2.5     skrll 
     89  1.41.2.5     skrll 	callout_init(&pffasttimo_ch);
     90  1.41.2.5     skrll 	callout_init(&pfslowtimo_ch);
     91  1.41.2.5     skrll 
     92  1.41.2.5     skrll 	callout_reset(&pffasttimo_ch, 1, pffasttimo, NULL);
     93  1.41.2.5     skrll 	callout_reset(&pfslowtimo_ch, 1, pfslowtimo, NULL);
     94  1.41.2.5     skrll }
     95  1.41.2.5     skrll 
     96  1.41.2.5     skrll void
     97  1.41.2.5     skrll domain_attach(struct domain *dp)
     98  1.41.2.5     skrll {
     99  1.41.2.5     skrll 	const struct protosw *pr;
    100  1.41.2.5     skrll 
    101  1.41.2.5     skrll 	STAILQ_INSERT_TAIL(&domains, dp, dom_link);
    102  1.41.2.5     skrll 
    103  1.41.2.5     skrll 	if (dp->dom_init)
    104  1.41.2.5     skrll 		(*dp->dom_init)();
    105       1.1       cgd 
    106      1.38      matt #ifdef MBUFTRACE
    107  1.41.2.5     skrll 	if (dp->dom_mowner.mo_name[0] == '\0') {
    108  1.41.2.5     skrll 		strncpy(dp->dom_mowner.mo_name, dp->dom_name,
    109  1.41.2.5     skrll 		    sizeof(dp->dom_mowner.mo_name));
    110  1.41.2.5     skrll 		MOWNER_ATTACH(&dp->dom_mowner);
    111  1.41.2.5     skrll 	}
    112      1.38      matt #endif
    113  1.41.2.5     skrll 	for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) {
    114  1.41.2.5     skrll 		if (pr->pr_init)
    115  1.41.2.5     skrll 			(*pr->pr_init)();
    116       1.1       cgd 	}
    117       1.1       cgd 
    118      1.16  explorer 	if (max_linkhdr < 16)		/* XXX */
    119      1.16  explorer 		max_linkhdr = 16;
    120       1.1       cgd 	max_hdr = max_linkhdr + max_protohdr;
    121       1.1       cgd 	max_datalen = MHLEN - max_hdr;
    122       1.1       cgd }
    123       1.1       cgd 
    124      1.29   thorpej struct domain *
    125  1.41.2.5     skrll pffinddomain(int family)
    126      1.29   thorpej {
    127      1.29   thorpej 	struct domain *dp;
    128      1.29   thorpej 
    129  1.41.2.5     skrll 	DOMAIN_FOREACH(dp)
    130      1.29   thorpej 		if (dp->dom_family == family)
    131      1.29   thorpej 			return (dp);
    132      1.29   thorpej 	return (NULL);
    133      1.29   thorpej }
    134      1.29   thorpej 
    135  1.41.2.2     skrll const struct protosw *
    136  1.41.2.5     skrll pffindtype(int family, int type)
    137       1.1       cgd {
    138      1.29   thorpej 	struct domain *dp;
    139  1.41.2.2     skrll 	const struct protosw *pr;
    140      1.29   thorpej 
    141      1.29   thorpej 	dp = pffinddomain(family);
    142      1.29   thorpej 	if (dp == NULL)
    143      1.29   thorpej 		return (NULL);
    144       1.1       cgd 
    145       1.1       cgd 	for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
    146       1.1       cgd 		if (pr->pr_type && pr->pr_type == type)
    147       1.1       cgd 			return (pr);
    148      1.29   thorpej 
    149      1.29   thorpej 	return (NULL);
    150       1.1       cgd }
    151       1.1       cgd 
    152  1.41.2.2     skrll const struct protosw *
    153  1.41.2.5     skrll pffindproto(int family, int protocol, int type)
    154       1.1       cgd {
    155      1.29   thorpej 	struct domain *dp;
    156  1.41.2.2     skrll 	const struct protosw *pr;
    157  1.41.2.2     skrll 	const struct protosw *maybe = NULL;
    158       1.1       cgd 
    159       1.1       cgd 	if (family == 0)
    160      1.29   thorpej 		return (NULL);
    161      1.29   thorpej 
    162      1.29   thorpej 	dp = pffinddomain(family);
    163      1.29   thorpej 	if (dp == NULL)
    164      1.29   thorpej 		return (NULL);
    165      1.29   thorpej 
    166       1.1       cgd 	for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) {
    167       1.1       cgd 		if ((pr->pr_protocol == protocol) && (pr->pr_type == type))
    168       1.1       cgd 			return (pr);
    169       1.1       cgd 
    170       1.1       cgd 		if (type == SOCK_RAW && pr->pr_type == SOCK_RAW &&
    171      1.29   thorpej 		    pr->pr_protocol == 0 && maybe == NULL)
    172       1.1       cgd 			maybe = pr;
    173       1.1       cgd 	}
    174       1.1       cgd 	return (maybe);
    175      1.10       cgd }
    176      1.10       cgd 
    177  1.41.2.6     skrll /*
    178  1.41.2.6     skrll  * sysctl helper to stuff PF_LOCAL pcbs into sysctl structures
    179  1.41.2.6     skrll  */
    180  1.41.2.6     skrll static void
    181  1.41.2.6     skrll sysctl_dounpcb(struct kinfo_pcb *pcb, const struct socket *so)
    182  1.41.2.6     skrll {
    183  1.41.2.6     skrll 	struct unpcb *unp = sotounpcb(so);
    184  1.41.2.6     skrll 	struct sockaddr_un *un = unp->unp_addr;
    185  1.41.2.6     skrll 
    186  1.41.2.6     skrll 	memset(pcb, 0, sizeof(*pcb));
    187  1.41.2.6     skrll 
    188  1.41.2.6     skrll 	pcb->ki_family = so->so_proto->pr_domain->dom_family;
    189  1.41.2.6     skrll 	pcb->ki_type = so->so_proto->pr_type;
    190  1.41.2.6     skrll 	pcb->ki_protocol = so->so_proto->pr_protocol;
    191  1.41.2.6     skrll 	pcb->ki_pflags = unp->unp_flags;
    192  1.41.2.6     skrll 
    193  1.41.2.6     skrll 	pcb->ki_pcbaddr = PTRTOUINT64(unp);
    194  1.41.2.6     skrll 	/* pcb->ki_ppcbaddr = unp has no ppcb... */
    195  1.41.2.6     skrll 	pcb->ki_sockaddr = PTRTOUINT64(so);
    196  1.41.2.6     skrll 
    197  1.41.2.6     skrll 	pcb->ki_sostate = so->so_state;
    198  1.41.2.6     skrll 	/* pcb->ki_prstate = unp has no state... */
    199  1.41.2.6     skrll 
    200  1.41.2.6     skrll 	pcb->ki_rcvq = so->so_rcv.sb_cc;
    201  1.41.2.6     skrll 	pcb->ki_sndq = so->so_snd.sb_cc;
    202  1.41.2.6     skrll 
    203  1.41.2.6     skrll 	un = (struct sockaddr_un *)&pcb->ki_src;
    204  1.41.2.6     skrll 	/*
    205  1.41.2.6     skrll 	 * local domain sockets may bind without having a local
    206  1.41.2.6     skrll 	 * endpoint.  bleah!
    207  1.41.2.6     skrll 	 */
    208  1.41.2.6     skrll 	if (unp->unp_addr != NULL) {
    209  1.41.2.6     skrll 		un->sun_len = unp->unp_addr->sun_len;
    210  1.41.2.6     skrll 		un->sun_family = unp->unp_addr->sun_family;
    211  1.41.2.6     skrll 		strlcpy(un->sun_path, unp->unp_addr->sun_path,
    212  1.41.2.6     skrll 		    sizeof(pcb->ki_s));
    213  1.41.2.6     skrll 	}
    214  1.41.2.6     skrll 	else {
    215  1.41.2.6     skrll 		un->sun_len = offsetof(struct sockaddr_un, sun_path);
    216  1.41.2.6     skrll 		un->sun_family = pcb->ki_family;
    217  1.41.2.6     skrll 	}
    218  1.41.2.6     skrll 	if (unp->unp_conn != NULL) {
    219  1.41.2.6     skrll 		un = (struct sockaddr_un *)&pcb->ki_dst;
    220  1.41.2.6     skrll 		if (unp->unp_conn->unp_addr != NULL) {
    221  1.41.2.6     skrll 			un->sun_len = unp->unp_conn->unp_addr->sun_len;
    222  1.41.2.6     skrll 			un->sun_family = unp->unp_conn->unp_addr->sun_family;
    223  1.41.2.6     skrll 			un->sun_family = unp->unp_conn->unp_addr->sun_family;
    224  1.41.2.6     skrll 			strlcpy(un->sun_path, unp->unp_conn->unp_addr->sun_path,
    225  1.41.2.6     skrll 				sizeof(pcb->ki_d));
    226  1.41.2.6     skrll 		}
    227  1.41.2.6     skrll 		else {
    228  1.41.2.6     skrll 			un->sun_len = offsetof(struct sockaddr_un, sun_path);
    229  1.41.2.6     skrll 			un->sun_family = pcb->ki_family;
    230  1.41.2.6     skrll 		}
    231  1.41.2.6     skrll 	}
    232  1.41.2.6     skrll 
    233  1.41.2.6     skrll 	pcb->ki_inode = unp->unp_ino;
    234  1.41.2.6     skrll 	pcb->ki_vnode = PTRTOUINT64(unp->unp_vnode);
    235  1.41.2.6     skrll 	pcb->ki_conn = PTRTOUINT64(unp->unp_conn);
    236  1.41.2.6     skrll 	pcb->ki_refs = PTRTOUINT64(unp->unp_refs);
    237  1.41.2.6     skrll 	pcb->ki_nextref = PTRTOUINT64(unp->unp_nextref);
    238  1.41.2.6     skrll }
    239  1.41.2.6     skrll 
    240  1.41.2.6     skrll static int
    241  1.41.2.6     skrll sysctl_unpcblist(SYSCTLFN_ARGS)
    242  1.41.2.6     skrll {
    243  1.41.2.6     skrll 	struct file *fp;
    244  1.41.2.6     skrll 	struct socket *so;
    245  1.41.2.6     skrll 	struct kinfo_pcb pcb;
    246  1.41.2.6     skrll 	char *dp;
    247  1.41.2.6     skrll 	u_int op, arg;
    248  1.41.2.6     skrll 	size_t len, needed, elem_size, out_size;
    249  1.41.2.6     skrll 	int error, elem_count, pf, type, pf2;
    250  1.41.2.6     skrll 
    251  1.41.2.6     skrll 	if (namelen == 1 && name[0] == CTL_QUERY)
    252  1.41.2.6     skrll 		return (sysctl_query(SYSCTLFN_CALL(rnode)));
    253  1.41.2.6     skrll 
    254  1.41.2.6     skrll 	if (namelen != 4)
    255  1.41.2.6     skrll 		return (EINVAL);
    256  1.41.2.6     skrll 
    257  1.41.2.6     skrll 	error = 0;
    258  1.41.2.6     skrll 	dp = oldp;
    259  1.41.2.6     skrll 	len = (oldp != NULL) ? *oldlenp : 0;
    260  1.41.2.6     skrll 	op = name[0];
    261  1.41.2.6     skrll 	arg = name[1];
    262  1.41.2.6     skrll 	elem_size = name[2];
    263  1.41.2.6     skrll 	elem_count = name[3];
    264  1.41.2.6     skrll 	out_size = MIN(sizeof(pcb), elem_size);
    265  1.41.2.6     skrll 	needed = 0;
    266  1.41.2.6     skrll 
    267  1.41.2.6     skrll 	elem_count = INT_MAX;
    268  1.41.2.6     skrll 	elem_size = out_size = sizeof(pcb);
    269  1.41.2.6     skrll 
    270  1.41.2.6     skrll 	if (name - oname != 4)
    271  1.41.2.6     skrll 		return (EINVAL);
    272  1.41.2.6     skrll 
    273  1.41.2.6     skrll 	pf = oname[1];
    274  1.41.2.6     skrll 	type = oname[2];
    275  1.41.2.6     skrll 	pf2 = (oldp == NULL) ? 0 : pf;
    276  1.41.2.6     skrll 
    277  1.41.2.6     skrll 	/*
    278  1.41.2.6     skrll 	 * there's no "list" of local domain sockets, so we have
    279  1.41.2.6     skrll 	 * to walk the file list looking for them.  :-/
    280  1.41.2.6     skrll 	 */
    281  1.41.2.6     skrll 	LIST_FOREACH(fp, &filehead, f_list) {
    282  1.41.2.7     skrll 		if (CURTAIN(l->l_proc->p_ucred->cr_uid, fp->f_cred->cr_uid))
    283  1.41.2.7     skrll 			continue;
    284  1.41.2.6     skrll 		if (fp->f_type != DTYPE_SOCKET)
    285  1.41.2.6     skrll 			continue;
    286  1.41.2.6     skrll 		so = (struct socket *)fp->f_data;
    287  1.41.2.6     skrll 		if (so->so_type != type)
    288  1.41.2.6     skrll 			continue;
    289  1.41.2.6     skrll 		if (so->so_proto->pr_domain->dom_family != pf)
    290  1.41.2.6     skrll 			continue;
    291  1.41.2.6     skrll 		if (len >= elem_size && elem_count > 0) {
    292  1.41.2.6     skrll 			sysctl_dounpcb(&pcb, so);
    293  1.41.2.6     skrll 			error = copyout(&pcb, dp, out_size);
    294  1.41.2.6     skrll 			if (error)
    295  1.41.2.6     skrll 				break;
    296  1.41.2.6     skrll 			dp += elem_size;
    297  1.41.2.6     skrll 			len -= elem_size;
    298  1.41.2.6     skrll 		}
    299  1.41.2.6     skrll 		if (elem_count > 0) {
    300  1.41.2.6     skrll 			needed += elem_size;
    301  1.41.2.6     skrll 			if (elem_count != INT_MAX)
    302  1.41.2.6     skrll 				elem_count--;
    303  1.41.2.6     skrll 		}
    304  1.41.2.6     skrll 	}
    305  1.41.2.6     skrll 
    306  1.41.2.6     skrll 	*oldlenp = needed;
    307  1.41.2.6     skrll 	if (oldp == NULL)
    308  1.41.2.6     skrll 		*oldlenp += PCB_SLOP * sizeof(struct kinfo_pcb);
    309  1.41.2.6     skrll 
    310  1.41.2.6     skrll 	return (error);
    311  1.41.2.6     skrll }
    312  1.41.2.6     skrll 
    313  1.41.2.2     skrll SYSCTL_SETUP(sysctl_net_setup, "sysctl net subtree setup")
    314      1.10       cgd {
    315  1.41.2.2     skrll 	sysctl_createv(clog, 0, NULL, NULL,
    316  1.41.2.2     skrll 		       CTLFLAG_PERMANENT,
    317  1.41.2.2     skrll 		       CTLTYPE_NODE, "net", NULL,
    318  1.41.2.2     skrll 		       NULL, 0, NULL, 0,
    319  1.41.2.2     skrll 		       CTL_NET, CTL_EOL);
    320  1.41.2.2     skrll 	sysctl_createv(clog, 0, NULL, NULL,
    321  1.41.2.2     skrll 		       CTLFLAG_PERMANENT,
    322  1.41.2.2     skrll 		       CTLTYPE_NODE, "local",
    323  1.41.2.2     skrll 		       SYSCTL_DESCR("PF_LOCAL related settings"),
    324  1.41.2.2     skrll 		       NULL, 0, NULL, 0,
    325  1.41.2.2     skrll 		       CTL_NET, PF_LOCAL, CTL_EOL);
    326  1.41.2.6     skrll 	sysctl_createv(clog, 0, NULL, NULL,
    327  1.41.2.6     skrll 		       CTLFLAG_PERMANENT,
    328  1.41.2.6     skrll 		       CTLTYPE_NODE, "stream",
    329  1.41.2.6     skrll 		       SYSCTL_DESCR("SOCK_STREAM settings"),
    330  1.41.2.6     skrll 		       NULL, 0, NULL, 0,
    331  1.41.2.6     skrll 		       CTL_NET, PF_LOCAL, SOCK_STREAM, CTL_EOL);
    332  1.41.2.6     skrll 	sysctl_createv(clog, 0, NULL, NULL,
    333  1.41.2.6     skrll 		       CTLFLAG_PERMANENT,
    334  1.41.2.6     skrll 		       CTLTYPE_NODE, "dgram",
    335  1.41.2.6     skrll 		       SYSCTL_DESCR("SOCK_DGRAM settings"),
    336  1.41.2.6     skrll 		       NULL, 0, NULL, 0,
    337  1.41.2.6     skrll 		       CTL_NET, PF_LOCAL, SOCK_DGRAM, CTL_EOL);
    338      1.10       cgd 
    339  1.41.2.6     skrll 	sysctl_createv(clog, 0, NULL, NULL,
    340  1.41.2.6     skrll 		       CTLFLAG_PERMANENT,
    341  1.41.2.6     skrll 		       CTLTYPE_STRUCT, "pcblist",
    342  1.41.2.6     skrll 		       SYSCTL_DESCR("SOCK_STREAM protocol control block list"),
    343  1.41.2.6     skrll 		       sysctl_unpcblist, 0, NULL, 0,
    344  1.41.2.6     skrll 		       CTL_NET, PF_LOCAL, SOCK_STREAM, CTL_CREATE, CTL_EOL);
    345  1.41.2.6     skrll 	sysctl_createv(clog, 0, NULL, NULL,
    346  1.41.2.6     skrll 		       CTLFLAG_PERMANENT,
    347  1.41.2.6     skrll 		       CTLTYPE_STRUCT, "pcblist",
    348  1.41.2.6     skrll 		       SYSCTL_DESCR("SOCK_DGRAM protocol control block list"),
    349  1.41.2.6     skrll 		       sysctl_unpcblist, 0, NULL, 0,
    350  1.41.2.6     skrll 		       CTL_NET, PF_LOCAL, SOCK_DGRAM, CTL_CREATE, CTL_EOL);
    351       1.1       cgd }
    352       1.1       cgd 
    353       1.4    andrew void
    354  1.41.2.5     skrll pfctlinput(int cmd, struct sockaddr *sa)
    355       1.1       cgd {
    356      1.31  augustss 	struct domain *dp;
    357  1.41.2.2     skrll 	const struct protosw *pr;
    358       1.1       cgd 
    359  1.41.2.5     skrll 	DOMAIN_FOREACH(dp)
    360       1.1       cgd 		for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
    361       1.1       cgd 			if (pr->pr_ctlinput)
    362      1.13  christos 				(*pr->pr_ctlinput)(cmd, sa, NULL);
    363      1.34    itojun }
    364      1.34    itojun 
    365      1.34    itojun void
    366  1.41.2.5     skrll pfctlinput2(int cmd, struct sockaddr *sa, void *ctlparam)
    367      1.34    itojun {
    368      1.34    itojun 	struct domain *dp;
    369  1.41.2.2     skrll 	const struct protosw *pr;
    370      1.34    itojun 
    371      1.34    itojun 	if (!sa)
    372      1.34    itojun 		return;
    373  1.41.2.5     skrll 
    374  1.41.2.5     skrll 	DOMAIN_FOREACH(dp) {
    375      1.34    itojun 		/*
    376      1.34    itojun 		 * the check must be made by xx_ctlinput() anyways, to
    377      1.34    itojun 		 * make sure we use data item pointed to by ctlparam in
    378      1.34    itojun 		 * correct way.  the following check is made just for safety.
    379      1.34    itojun 		 */
    380      1.34    itojun 		if (dp->dom_family != sa->sa_family)
    381      1.34    itojun 			continue;
    382      1.34    itojun 
    383      1.34    itojun 		for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
    384      1.34    itojun 			if (pr->pr_ctlinput)
    385      1.34    itojun 				(*pr->pr_ctlinput)(cmd, sa, ctlparam);
    386      1.34    itojun 	}
    387       1.1       cgd }
    388       1.1       cgd 
    389       1.4    andrew void
    390  1.41.2.5     skrll pfslowtimo(void *arg)
    391       1.1       cgd {
    392      1.31  augustss 	struct domain *dp;
    393  1.41.2.2     skrll 	const struct protosw *pr;
    394       1.1       cgd 
    395      1.19   thorpej 	pfslowtimo_now++;
    396      1.19   thorpej 
    397  1.41.2.5     skrll 	DOMAIN_FOREACH(dp) {
    398       1.1       cgd 		for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
    399       1.1       cgd 			if (pr->pr_slowtimo)
    400       1.1       cgd 				(*pr->pr_slowtimo)();
    401  1.41.2.5     skrll 	}
    402      1.30   thorpej 	callout_reset(&pfslowtimo_ch, hz / 2, pfslowtimo, NULL);
    403       1.1       cgd }
    404       1.1       cgd 
    405       1.4    andrew void
    406  1.41.2.5     skrll pffasttimo(void *arg)
    407       1.1       cgd {
    408      1.31  augustss 	struct domain *dp;
    409  1.41.2.2     skrll 	const struct protosw *pr;
    410      1.19   thorpej 
    411      1.19   thorpej 	pffasttimo_now++;
    412       1.1       cgd 
    413  1.41.2.5     skrll 	DOMAIN_FOREACH(dp) {
    414       1.1       cgd 		for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
    415       1.1       cgd 			if (pr->pr_fasttimo)
    416       1.1       cgd 				(*pr->pr_fasttimo)();
    417  1.41.2.5     skrll 	}
    418      1.30   thorpej 	callout_reset(&pffasttimo_ch, hz / 5, pffasttimo, NULL);
    419       1.1       cgd }
    420