]>
git.saurik.com Git - apple/xnu.git/blob - bsd/netat/at_proto.c
2 * Copyright (c) 2000-2006 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) 1998 Apple Computer, Inc.
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/ioctl.h>
38 #include <sys/errno.h>
39 #include <sys/malloc.h>
40 #include <sys/socket.h>
41 #include <sys/socketvar.h>
42 #include <sys/protosw.h>
43 #include <sys/domain.h>
45 #include <kern/locks.h>
47 #include <sys/sysctl.h>
51 #include <netat/sysglue.h>
52 #include <netat/appletalk.h>
53 #include <netat/at_pcb.h>
54 #include <netat/at_var.h>
55 #include <netat/ddp.h>
59 * Dummy usrreqs struct created by Ted for FreeBSD 3.x integration.
60 * Fill in supported functions as appropriate.
62 struct pr_usrreqs ddp_usrreqs
= {
63 ddp_pru_abort
, pru_accept_notsupp
, ddp_pru_attach
, ddp_pru_bind
,
64 ddp_pru_connect
, pru_connect2_notsupp
, ddp_pru_control
, ddp_pru_detach
,
65 ddp_pru_disconnect
, pru_listen_notsupp
, ddp_pru_peeraddr
, pru_rcvd_notsupp
,
66 pru_rcvoob_notsupp
, ddp_pru_send
, pru_sense_null
, ddp_pru_shutdown
,
67 ddp_pru_sockaddr
, sosend
, soreceive
, pru_sopoll_notsupp
70 extern struct domain atalkdomain
;
71 extern void atalk_dominit(void);
73 struct protosw atalksw
[] = {
74 { SOCK_RAW
, &atalkdomain
, /*protocol*/ 0, PR_ATOMIC
|PR_ADDR
,
75 /*input*/ 0, /*output*/ 0, /*clinput*/ 0, ddp_ctloutput
,
77 ddp_init
, /*fastto*/ 0, /*slowto*/ 0, /*drain*/ 0,
78 /*sysctl*/ 0, &ddp_usrreqs
,
79 0, 0, 0, /*lock, unlock, getlock */
80 {0, 0}, 0, {0} /* filters */
84 struct domain atalkdomain
=
93 0, 0, /* dom_rtoffset, dom_maxrtkey */
95 0, /* domain global mutex */
97 {0, 0} /*reserved[2] */
100 struct domain
* atalkdom
= &atalkdomain
;
101 lck_mtx_t
*atalk_mutex
= NULL
;
103 lck_mtx_t
*atalk_cluster_lock
= NULL
;
104 static lck_attr_t
*atalk_lock_attr
;
105 static lck_grp_t
*atalk_lock_grp
;
106 static lck_grp_attr_t
*atalk_lock_grp_attr
;
108 static int at_saved_lock
, at_saved_unlock
;
110 SYSCTL_NODE(_net
, PF_APPLETALK
, appletalk
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0, "AppleTalk Family");
115 atalk_mutex
= atalkdom
->dom_mtx
;
117 atalk_lock_grp_attr
= lck_grp_attr_alloc_init();
118 atalk_lock_grp
= lck_grp_alloc_init("appletalk", atalk_lock_grp_attr
);
119 atalk_lock_attr
= lck_attr_alloc_init();
120 atalk_cluster_lock
= lck_mtx_alloc_init(atalk_lock_grp
,
128 lr_saved
= (unsigned int) __builtin_return_address(0);
130 lck_mtx_assert(atalkdom
->dom_mtx
, LCK_MTX_ASSERT_NOTOWNED
);
131 lck_mtx_lock(atalkdom
->dom_mtx
);
132 at_saved_lock
= lr_saved
;
139 lr_saved
= (unsigned int) __builtin_return_address(0);
141 lck_mtx_assert(atalkdom
->dom_mtx
, LCK_MTX_ASSERT_OWNED
);
142 at_saved_unlock
= lr_saved
;
143 lck_mtx_unlock(atalkdom
->dom_mtx
);