1 /*
2 * Copyright (c) 2007 The DragonFly Project. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
14 * 3. Neither the name of The DragonFly Project nor the names of its
15 * contributors may be used to endorse or promote products derived
16 * from this software without specific, prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
24 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
28 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32 #include <sys/domain.h>
33 #include <sys/kernel.h> /* SYSINIT via DOMAIN_SET */
34 #include <sys/protosw.h>
35 #include <sys/socket.h>
36 #include <sys/globaldata.h>
37 #include <sys/thread.h>
38
39 #include <net/radix.h> /* rn_inithead */
40
41 #include <netproto/mpls/mpls.h>
42 #include <netproto/mpls/mpls_var.h>
43
44 /* forward declarations */
45 static struct domain mplsdomain;
46 static struct pr_usrreqs nousrreqs; /* XXX use this for something */
47
48 struct protosw mplssw[] = {
49 {
50 .pr_type = 0,
51 .pr_domain = &mplsdomain,
52
53 .pr_init = mpls_init,
54 .pr_usrreqs = &nousrreqs
55 },
56 {
57 .pr_type = SOCK_RAW,
58 .pr_domain = &mplsdomain,
59 .pr_protocol = 0,
60 .pr_flags = PR_ATOMIC|PR_ADDR,
61
62 .pr_usrreqs = &nousrreqs
63 }
64 };
65
66 static int
mpls_inithead(void ** head,int off)67 mpls_inithead(void **head, int off)
68 {
69 struct radix_node_head *rnh;
70
71 rnh = *head;
72 KKASSERT(rnh == rt_tables[mycpuid][AF_MPLS]);
73
74 if (!rn_inithead(&rnh, rn_cpumaskhead(mycpuid), off))
75 return 0;
76
77 *head = rnh;
78 return 1;
79 }
80
81 static struct domain mplsdomain = {
82 .dom_family = AF_MPLS,
83 .dom_name = "mpls",
84 .dom_init = NULL,
85 .dom_externalize = NULL,
86 .dom_dispose = NULL,
87 .dom_protosw = mplssw,
88 .dom_protoswNPROTOSW = &mplssw[NELEM(mplssw)],
89 .dom_next = SLIST_ENTRY_INITIALIZER,
90 .dom_rtattach = mpls_inithead,
91 .dom_rtoffset = offsetof(struct sockaddr_mpls, smpls_addr),
92 .dom_maxrtkey = sizeof(struct sockaddr_mpls),
93 .dom_ifattach = NULL,
94 .dom_ifdetach = NULL,
95 .dom_if_up = NULL,
96 .dom_if_down = NULL,
97 };
98
99 DOMAIN_SET(mpls);
100
101 #if 0
102 SYSCTL_NODE(_net, PF_MPLS, mpls, CTLFLAG_RW, 0,
103 "MPLS Family");
104 #endif
105
106