2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 * Copyright (c) 1982, 1989, 1993
30 * The Regents of the University of California. All rights reserved.
32 * Redistribution and use in source and binary forms, with or without
33 * modification, are permitted provided that the following conditions
35 * 1. Redistributions of source code must retain the above copyright
36 * notice, this list of conditions and the following disclaimer.
37 * 2. Redistributions in binary form must reproduce the above copyright
38 * notice, this list of conditions and the following disclaimer in the
39 * documentation and/or other materials provided with the distribution.
40 * 3. All advertising materials mentioning features or use of this software
41 * must display the following acknowledgement:
42 * This product includes software developed by the University of
43 * California, Berkeley and its contributors.
44 * 4. Neither the name of the University nor the names of its contributors
45 * may be used to endorse or promote products derived from this software
46 * without specific prior written permission.
48 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
49 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64 #include <sys/param.h>
65 #include <sys/systm.h>
66 #include <sys/kernel.h>
67 #include <sys/malloc.h>
69 #include <sys/socket.h>
70 #include <sys/sockio.h>
71 #include <sys/sysctl.h>
74 #include <net/route.h>
75 #include <net/if_llc.h>
76 #include <net/if_dl.h>
77 #include <net/if_types.h>
78 #include <netinet/if_ether.h>
79 #include <net/kpi_interface.h>
80 #include <net/kpi_protocol.h>
82 #include <sys/socketvar.h>
85 #include <netat/at_pat.h>
87 extern struct ifqueue atalkintrq
;
92 #include <net/bridge.h>
95 /* #include "vlan.h" */
97 #include <net/if_vlan_var.h>
98 #endif /* NVLAN > 0 */
100 #include <net/ether_if_module.h>
103 * Process a received Ethernet packet;
104 * the packet is in the mbuf chain m without
105 * the ether header, which is provided separately.
109 __unused ifnet_t ifp
,
110 __unused protocol_family_t protocol_family
,
112 __unused
char *frame_header
)
116 * note: for AppleTalk we need to pass the enet header of the
117 * packet up stack. To do so, we made sure in that the FULL packet
118 * is copied in the mbuf by the driver, and only the m_data and
119 * length have been shifted to make IP and the other guys happy.
122 m
->m_data
-= sizeof(struct ether_header
);
123 m
->m_len
+= sizeof(struct ether_header
);
124 m
->m_pkthdr
.len
+= sizeof(struct ether_header
);
126 error
= proto_input(PF_APPLETALK
, m
);
139 __unused protocol_family_t protocol_family
,
141 const struct sockaddr
*dst_netaddr
,
142 __unused
void *route
,
146 struct mbuf
*m
= *m0
;
147 const struct ether_header
*eh
;
148 int hlen
; /* link layer header length */
150 if ((ifp
->if_flags
& (IFF_UP
|IFF_RUNNING
)) != (IFF_UP
|IFF_RUNNING
))
153 hlen
= ETHER_HDR_LEN
;
156 * Tell ether_frameout it's ok to loop packet unless negated below.
158 m
->m_flags
|= M_LOOP
;
160 switch (dst_netaddr
->sa_family
) {
162 m
->m_flags
&= ~M_LOOP
;
163 eh
= (const struct ether_header
*)dst_netaddr
->sa_data
;
164 (void)memcpy(edst
, eh
->ether_dhost
, 6);
165 *(u_short
*)type
= eh
->ether_type
;
169 eh
= (const struct ether_header
*)dst_netaddr
->sa_data
;
170 (void)memcpy(edst
, eh
->ether_dhost
, 6);
171 *(u_short
*)type
= htons(m
->m_pkthdr
.len
);
175 printf("%s%d: can't handle af%d\n", ifp
->if_name
, ifp
->if_unit
,
176 dst_netaddr
->sa_family
);
187 ether_at_prmod_ioctl(
189 __unused protocol_family_t protocol_family
,
193 struct ifreq
*ifr
= data
;
199 if ((ifp
->if_flags
& IFF_RUNNING
) == 0) {
200 ifnet_set_flags(ifp
, IFF_UP
, IFF_UP
);
201 ifnet_ioctl(ifp
, 0, SIOCSIFFLAGS
, NULL
);
207 ifnet_lladdr_copy_bytes(ifp
, ifr
->ifr_addr
.sa_data
, ETHER_ADDR_LEN
);
219 __private_extern__ errno_t
222 __unused protocol_family_t proto_family
)
224 struct ifnet_attach_proto_param proto
;
225 struct ifnet_demux_desc demux
[2];
226 u_int8_t atalk_snap
[5] = {0x08, 0x00, 0x07, 0x80, 0x9b};
227 u_int8_t aarp_snap
[5] = {0x00, 0x00, 0x00, 0x80, 0xf3};
230 bzero(demux
, sizeof(demux
));
231 demux
[0].type
= DLIL_DESC_SNAP
;
232 demux
[0].data
= atalk_snap
;
233 demux
[0].datalen
= sizeof(atalk_snap
);
234 demux
[1].type
= DLIL_DESC_SNAP
;
235 demux
[1].data
= aarp_snap
;
236 demux
[1].datalen
= sizeof(aarp_snap
);
238 bzero(&proto
, sizeof(proto
));
239 proto
.demux_list
= demux
;
240 proto
.demux_count
= sizeof(demux
) / sizeof(demux
[0]);
241 proto
.input
= ether_at_input
;
242 proto
.pre_output
= ether_at_pre_output
;
243 proto
.ioctl
= ether_at_prmod_ioctl
;
245 error
= ifnet_attach_protocol(ifp
, PF_APPLETALK
, &proto
);
246 if (error
&& error
!= EEXIST
) {
247 printf("WARNING: ether_attach_at failed to attach"
248 " AppleTalk to %s%d\n", ifp
->if_name
, ifp
->if_unit
);
253 __private_extern__
void
256 __unused protocol_family_t proto_family
)
258 (void)ifnet_detach_protocol(ifp
, PF_APPLETALK
);