178556Sobrien/*-
278556Sobrien * SPDX-License-Identifier: BSD-3-Clause
378556Sobrien *
4215041Sobrien * Copyright (c) 1982, 1986, 1993
578556Sobrien *	The Regents of the University of California.  All rights reserved.
678556Sobrien *
778556Sobrien * Redistribution and use in source and binary forms, with or without
878556Sobrien * modification, are permitted provided that the following conditions
978556Sobrien * are met:
1078556Sobrien * 1. Redistributions of source code must retain the above copyright
1178556Sobrien *    notice, this list of conditions and the following disclaimer.
1278556Sobrien * 2. Redistributions in binary form must reproduce the above copyright
1378556Sobrien *    notice, this list of conditions and the following disclaimer in the
1478556Sobrien *    documentation and/or other materials provided with the distribution.
1578556Sobrien * 3. Neither the name of the University nor the names of its contributors
1678556Sobrien *    may be used to endorse or promote products derived from this software
1778556Sobrien *    without specific prior written permission.
1878556Sobrien *
1978556Sobrien * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2078556Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2178556Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2278556Sobrien * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2378556Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2478556Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2578556Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2678556Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2778556Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2878556Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2978556Sobrien * SUCH DAMAGE.
3078556Sobrien */
3178556Sobrien
3278556Sobrien#ifndef _SYS_DOMAIN_H_
3378556Sobrien#define _SYS_DOMAIN_H_
3478556Sobrien#include <sys/queue.h>
3578556Sobrien
3678556Sobrien/*
3778556Sobrien * Structure per communications domain.
3878556Sobrien */
3978556Sobrien
4078556Sobrien/*
4178556Sobrien * Forward structure declarations for function prototypes [sic].
4278556Sobrien */
4378556Sobrienstruct	mbuf;
4478556Sobrienstruct	ifnet;
4578556Sobrienstruct	socket;
4678556Sobrienstruct	rib_head;
4778556Sobrien
4878556Sobrienstruct domain {
4978556Sobrien	SLIST_ENTRY(domain) dom_next;
5078556Sobrien	int	dom_family;		/* AF_xxx */
5178556Sobrien	u_int	dom_nprotosw;		/* length of dom_protosw[] */
5278556Sobrien	char	*dom_name;
5378556Sobrien	int	dom_flags;
5478556Sobrien	int	(*dom_probe)(void);	/* check for support (optional) */
5578556Sobrien	int	(*dom_externalize)	/* externalize access rights */
5678556Sobrien		(struct mbuf *, struct mbuf **, int);
5778556Sobrien	struct rib_head *(*dom_rtattach)	/* initialize routing table */
5878556Sobrien		(uint32_t);
5978556Sobrien	void	(*dom_rtdetach)		/* clean up routing table */
6078556Sobrien		(struct rib_head *);
6178556Sobrien	void	*(*dom_ifattach)(struct ifnet *);
6278556Sobrien	void	(*dom_ifdetach)(struct ifnet *, void *);
6378556Sobrien	int	(*dom_ifmtu)(struct ifnet *);
6478556Sobrien					/* af-dependent data on ifnet */
6578556Sobrien	struct	protosw *dom_protosw[];
6678556Sobrien};
6778556Sobrien
6878556Sobrien/* dom_flags */
6978556Sobrien#define	DOMF_UNLOADABLE	0x0004	/* Can be unloaded */
7078556Sobrien
7178556Sobrien#ifdef _KERNEL
7278556Sobrienextern int	domain_init_status;
7378556Sobrienextern SLIST_HEAD(domainhead, domain) domains;
7478556Sobrienvoid		domain_add(struct domain *);
7578556Sobrienvoid		domain_remove(struct domain *);
7678556Sobrien#ifdef VIMAGE
7778556Sobrienvoid		vnet_domain_init(void *);
7878556Sobrienvoid		vnet_domain_uninit(void *);
7978556Sobrien#endif
8078556Sobrien
8178556Sobrien#define	DOMAIN_SET(name)						\
8278556Sobrien	SYSINIT(domain_add_ ## name, SI_SUB_PROTO_DOMAIN,		\
8378556Sobrien	    SI_ORDER_FIRST, domain_add, & name ## domain);		\
8478556Sobrien	SYSUNINIT(domain_remove_ ## name, SI_SUB_PROTO_DOMAIN,		\
8578556Sobrien	    SI_ORDER_FIRST, domain_remove, & name ## domain);
8678556Sobrien#endif /* _KERNEL */
8778556Sobrien
8878556Sobrien#endif /* !_SYS_DOMAIN_H_ */
8978556Sobrien