]>
git.saurik.com Git - apple/xnu.git/blob - bsd/netat/at_proto.c
2849b11677117b6b1580dfb69c397178a67cf480
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
31 * Copyright (c) 1998 Apple Computer, Inc.
37 #include <sys/param.h>
38 #include <sys/systm.h>
39 #include <sys/ioctl.h>
40 #include <sys/errno.h>
41 #include <sys/malloc.h>
42 #include <sys/socket.h>
43 #include <sys/socketvar.h>
44 #include <sys/protosw.h>
45 #include <sys/domain.h>
47 #include <kern/locks.h>
49 #include <sys/sysctl.h>
53 #include <netat/appletalk.h>
54 #include <netat/at_var.h>
55 #include <netat/ddp.h>
58 extern int ddp_pru_abort(struct socket
*so
);
60 extern int ddp_pru_attach(struct socket
*so
, int proto
,
62 extern int ddp_pru_bind(struct socket
*so
, struct sockaddr
*nam
,
64 extern int ddp_pru_connect(struct socket
*so
, struct sockaddr
*nam
,
67 extern int ddp_pru_control(struct socket
*so
, u_long cmd
, caddr_t data
,
68 struct ifnet
*ifp
, struct proc
*p
);
69 extern int ddp_pru_detach(struct socket
*so
);
70 extern int ddp_pru_disconnect(struct socket
*so
);
72 extern int ddp_pru_peeraddr(struct socket
*so
,
73 struct sockaddr
**nam
);
75 extern int ddp_pru_send(struct socket
*so
, int flags
, struct mbuf
*m
,
76 struct sockaddr
*addr
, struct mbuf
*control
,
79 extern int ddp_pru_shutdown(struct socket
*so
);
80 extern int ddp_pru_sockaddr(struct socket
*so
,
81 struct sockaddr
**nam
);
84 * Dummy usrreqs struct created by Ted for FreeBSD 3.x integration.
85 * Fill in supported functions as appropriate.
87 struct pr_usrreqs ddp_usrreqs
= {
88 ddp_pru_abort
, pru_accept_notsupp
, ddp_pru_attach
, ddp_pru_bind
,
89 ddp_pru_connect
, pru_connect2_notsupp
, ddp_pru_control
, ddp_pru_detach
,
90 ddp_pru_disconnect
, pru_listen_notsupp
, ddp_pru_peeraddr
, pru_rcvd_notsupp
,
91 pru_rcvoob_notsupp
, ddp_pru_send
, pru_sense_null
, ddp_pru_shutdown
,
92 ddp_pru_sockaddr
, sosend
, soreceive
, pru_sopoll_notsupp
95 extern struct domain atalkdomain
;
96 extern void atalk_dominit(void);
98 struct protosw atalksw
[] = {
99 { SOCK_RAW
, &atalkdomain
, /*protocol*/ 0, PR_ATOMIC
|PR_ADDR
,
100 /*input*/ 0, /*output*/ 0, /*clinput*/ 0, ddp_ctloutput
,
102 ddp_init
, /*fastto*/ 0, /*slowto*/ 0, /*drain*/ 0,
103 /*sysctl*/ 0, &ddp_usrreqs
,
104 0, 0, 0, /*lock, unlock, getlock */
105 {0, 0}, 0, {0} /* filters */
109 struct domain atalkdomain
=
117 0, /* dom_rtattach */
118 0, 0, /* dom_rtoffset, dom_maxrtkey */
120 0, /* domain global mutex */
121 0, /* domain flags */
122 {0, 0} /*reserved[2] */
125 struct domain
* atalkdom
= &atalkdomain
;
126 lck_mtx_t
*atalk_mutex
= NULL
;
128 static int at_saved_lock
, at_saved_unlock
;
130 SYSCTL_NODE(_net
, PF_APPLETALK
, appletalk
, CTLFLAG_RW
, 0, "AppleTalk Family");
135 atalk_mutex
= atalkdom
->dom_mtx
;
142 lr_saved
= (unsigned int) __builtin_return_address(0);
144 lck_mtx_assert(atalkdom
->dom_mtx
, LCK_MTX_ASSERT_NOTOWNED
);
145 lck_mtx_lock(atalkdom
->dom_mtx
);
146 at_saved_lock
= lr_saved
;
153 lr_saved
= (unsigned int) __builtin_return_address(0);
155 lck_mtx_assert(atalkdom
->dom_mtx
, LCK_MTX_ASSERT_OWNED
);
156 at_saved_unlock
= lr_saved
;
157 lck_mtx_unlock(atalkdom
->dom_mtx
);