xref: /netbsd-src/sys/netcan/can_proto.c (revision ca257ba439336a262e8064dd27042e81a7d39c2f)
1*ca257ba4Sthorpej /*	$NetBSD: can_proto.c,v 1.3 2022/09/03 02:07:32 thorpej Exp $	*/
26e4cb2b9Sbouyer 
36e4cb2b9Sbouyer /*-
46e4cb2b9Sbouyer  * Copyright (c) 2003, 2017 The NetBSD Foundation, Inc.
56e4cb2b9Sbouyer  * All rights reserved.
66e4cb2b9Sbouyer  *
76e4cb2b9Sbouyer  * This code is derived from software contributed to The NetBSD Foundation
86e4cb2b9Sbouyer  * by Robert Swindells and Manuel Bouyer
96e4cb2b9Sbouyer  *
106e4cb2b9Sbouyer  * Redistribution and use in source and binary forms, with or without
116e4cb2b9Sbouyer  * modification, are permitted provided that the following conditions
126e4cb2b9Sbouyer  * are met:
136e4cb2b9Sbouyer  * 1. Redistributions of source code must retain the above copyright
146e4cb2b9Sbouyer  *    notice, this list of conditions and the following disclaimer.
156e4cb2b9Sbouyer  * 2. Redistributions in binary form must reproduce the above copyright
166e4cb2b9Sbouyer  *    notice, this list of conditions and the following disclaimer in the
176e4cb2b9Sbouyer  *    documentation and/or other materials provided with the distribution.
186e4cb2b9Sbouyer  *
196e4cb2b9Sbouyer  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
206e4cb2b9Sbouyer  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
216e4cb2b9Sbouyer  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
226e4cb2b9Sbouyer  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
236e4cb2b9Sbouyer  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
246e4cb2b9Sbouyer  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
256e4cb2b9Sbouyer  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
266e4cb2b9Sbouyer  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
276e4cb2b9Sbouyer  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
286e4cb2b9Sbouyer  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
296e4cb2b9Sbouyer  * POSSIBILITY OF SUCH DAMAGE.
306e4cb2b9Sbouyer  */
316e4cb2b9Sbouyer 
326e4cb2b9Sbouyer #include <sys/cdefs.h>
33*ca257ba4Sthorpej __KERNEL_RCSID(0, "$NetBSD: can_proto.c,v 1.3 2022/09/03 02:07:32 thorpej Exp $");
346e4cb2b9Sbouyer 
356e4cb2b9Sbouyer #include <sys/param.h>
366e4cb2b9Sbouyer #include <sys/socket.h>
376e4cb2b9Sbouyer #include <sys/protosw.h>
386e4cb2b9Sbouyer #include <sys/domain.h>
396e4cb2b9Sbouyer #include <sys/mbuf.h>
406e4cb2b9Sbouyer 
416e4cb2b9Sbouyer #include <net/if.h>
426e4cb2b9Sbouyer #include <net/radix.h>
436e4cb2b9Sbouyer #include <net/route.h>
446e4cb2b9Sbouyer 
456e4cb2b9Sbouyer /*
466e4cb2b9Sbouyer  * CAN protocol family
476e4cb2b9Sbouyer  */
486e4cb2b9Sbouyer #include <netcan/can.h>
496e4cb2b9Sbouyer #include <netcan/can_var.h>
506e4cb2b9Sbouyer 
516e4cb2b9Sbouyer DOMAIN_DEFINE(candomain);	/* forward declare and add to link set */
526e4cb2b9Sbouyer 
536e4cb2b9Sbouyer const struct protosw cansw[] = {
546e4cb2b9Sbouyer {
556e4cb2b9Sbouyer 	.pr_type = SOCK_RAW,
566e4cb2b9Sbouyer 	.pr_domain = &candomain,
576e4cb2b9Sbouyer 	.pr_init = can_init,
586e4cb2b9Sbouyer 	.pr_flags = PR_ATOMIC|PR_ADDR,
596e4cb2b9Sbouyer 	.pr_usrreqs = &can_usrreqs,
606e4cb2b9Sbouyer 	.pr_ctloutput = &can_ctloutput,
616e4cb2b9Sbouyer }
626e4cb2b9Sbouyer };
636e4cb2b9Sbouyer 
646e4cb2b9Sbouyer struct domain candomain = {
656e4cb2b9Sbouyer 	.dom_family = PF_CAN,
666e4cb2b9Sbouyer 	.dom_name = "can",
676e4cb2b9Sbouyer 	.dom_init = can_init,
686e4cb2b9Sbouyer 	.dom_externalize = NULL, .dom_dispose = NULL,
696e4cb2b9Sbouyer 	.dom_protosw = cansw,
706e4cb2b9Sbouyer 	.dom_protoswNPROTOSW = &cansw[__arraycount(cansw)],
716e4cb2b9Sbouyer 	.dom_link = { NULL },
726e4cb2b9Sbouyer 	.dom_mowner = MOWNER_INIT("",""),
736e4cb2b9Sbouyer 	.dom_sa_cmpofs = offsetof(struct sockaddr_can, can_ifindex),
746e4cb2b9Sbouyer 	.dom_sa_cmplen = sizeof(int)
756e4cb2b9Sbouyer };
76