1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* DL_6TO4 MAC Type plugin for the Nemo mac module
*/
#include <sys/modctl.h>
#include <sys/dlpi.h>
#include <inet/ip.h>
#include <sys/mac.h>
#include <sys/mac_6to4.h>
#include <sys/mac_ipv4_impl.h>
static struct modlmisc mac_6to4_modlmisc = {
&mod_miscops,
"6to4 tunneling MAC plugin"
};
static struct modlinkage mac_6to4_modlinkage = {
MODREV_1,
&mac_6to4_modlmisc,
NULL
};
static mactype_ops_t mac_6to4_type_ops;
int
_init(void)
{
mactype_register_t *mtrp;
int err;
if ((mtrp = mactype_alloc(MACTYPE_VERSION)) == NULL)
return (ENOTSUP);
mtrp->mtr_ident = MAC_PLUGIN_IDENT_6TO4;
mtrp->mtr_ops = &mac_6to4_type_ops;
mtrp->mtr_mactype = DL_6TO4;
mtrp->mtr_nativetype = DL_6TO4;
mtrp->mtr_addrlen = sizeof (ipaddr_t);
if ((err = mactype_register(mtrp)) == 0) {
if ((err = mod_install(&mac_6to4_modlinkage)) != 0)
(void) mactype_unregister(MAC_PLUGIN_IDENT_6TO4);
}
mactype_free(mtrp);
return (err);
}
int
_fini(void)
{
int err;
if ((err = mactype_unregister(MAC_PLUGIN_IDENT_6TO4)) != 0)
return (err);
return (mod_remove(&mac_6to4_modlinkage));
}
int
_info(struct modinfo *modinfop)
{
return (mod_info(&mac_6to4_modlinkage, modinfop));
}
/*
* MAC Type plugin operations. Note that because 6to4 is a form of
* tunneling over IPv4, this plugin is able to steal most of its operations
* from the IPv4 plugin.
*/
/*
* Check the legality of a 6to4 tunnel SAP value. The only acceptable
* values are IPPROTO_IPV6 (IPv6 in IPv4 tunneling) and 0 (for snoop).
*/
/* ARGSUSED */
boolean_t
mac_6to4_sap_verify(uint32_t sap, uint32_t *bind_sap, void *pdata)
{
if (sap == IPPROTO_IPV6 || sap == 0) {
if (bind_sap != NULL)
*bind_sap = sap;
return (B_TRUE);
}
return (B_FALSE);
}
static mactype_ops_t mac_6to4_type_ops = {
MTOPS_PDATA_VERIFY,
mac_ipv4_unicst_verify,
mac_ipv4_multicst_verify,
mac_6to4_sap_verify,
mac_ipv4_header,
mac_ipv4_header_info,
mac_ipv4_pdata_verify,
NULL,
NULL,
NULL
};
|