]> git.saurik.com Git - apple/xnu.git/blame - bsd/netat/at_proto.c
xnu-792.6.56.tar.gz
[apple/xnu.git] / bsd / netat / at_proto.c
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
ff6e181a
A
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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
1c79356b 12 *
ff6e181a
A
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
1c79356b
A
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
ff6e181a
A
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
1c79356b
A
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23/*
24 * Copyright (c) 1998 Apple Computer, Inc.
25 */
26
27/* at_proto.c
28 */
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/ioctl.h>
33#include <sys/errno.h>
34#include <sys/malloc.h>
35#include <sys/socket.h>
36#include <sys/socketvar.h>
37#include <sys/protosw.h>
38#include <sys/domain.h>
39#include <sys/mbuf.h>
91447636 40#include <kern/locks.h>
1c79356b
A
41
42#include <sys/sysctl.h>
43
44#include <net/if.h>
45
46#include <netat/appletalk.h>
47#include <netat/at_var.h>
48#include <netat/ddp.h>
49
1c79356b
A
50
51extern int ddp_pru_abort(struct socket *so);
52
53extern int ddp_pru_attach(struct socket *so, int proto,
54 struct proc *p);
55extern int ddp_pru_bind(struct socket *so, struct sockaddr *nam,
56 struct proc *p);
57extern int ddp_pru_connect(struct socket *so, struct sockaddr *nam,
58 struct proc *p);
59
60extern int ddp_pru_control(struct socket *so, u_long cmd, caddr_t data,
61 struct ifnet *ifp, struct proc *p);
62extern int ddp_pru_detach(struct socket *so);
63extern int ddp_pru_disconnect(struct socket *so);
64
65extern int ddp_pru_peeraddr(struct socket *so,
66 struct sockaddr **nam);
67
68extern int ddp_pru_send(struct socket *so, int flags, struct mbuf *m,
69 struct sockaddr *addr, struct mbuf *control,
70 struct proc *p);
71
72extern int ddp_pru_shutdown(struct socket *so);
73extern int ddp_pru_sockaddr(struct socket *so,
74 struct sockaddr **nam);
91447636 75void atalk_dominit();
1c79356b
A
76
77/*
78 * Dummy usrreqs struct created by Ted for FreeBSD 3.x integration.
79 * Fill in supported functions as appropriate.
80 */
81struct pr_usrreqs ddp_usrreqs = {
82 ddp_pru_abort, pru_accept_notsupp, ddp_pru_attach, ddp_pru_bind,
83 ddp_pru_connect, pru_connect2_notsupp, ddp_pru_control, ddp_pru_detach,
84 ddp_pru_disconnect, pru_listen_notsupp, ddp_pru_peeraddr, pru_rcvd_notsupp,
85 pru_rcvoob_notsupp, ddp_pru_send, pru_sense_null, ddp_pru_shutdown,
91447636 86 ddp_pru_sockaddr, sosend, soreceive, pru_sopoll_notsupp
1c79356b
A
87};
88
91447636 89struct domain atalkdomain;
1c79356b
A
90struct protosw atalksw[] = {
91 { SOCK_RAW, &atalkdomain, /*protocol*/ 0, PR_ATOMIC|PR_ADDR,
92 /*input*/ 0, /*output*/ 0, /*clinput*/ 0, ddp_ctloutput,
93 /*ousrreq*/ 0,
94 ddp_init, /*fastto*/ 0, /*slowto*/ 0, /*drain*/ 0,
91447636
A
95 /*sysctl*/ 0, &ddp_usrreqs,
96 0, 0, 0
1c79356b
A
97 }
98};
99
100struct domain atalkdomain =
91447636 101{ AF_APPLETALK, "appletalk", atalk_dominit, 0, 0,
1c79356b
A
102 atalksw, 0,
103 0, 0, 0,
104 DDP_X_HDR_SIZE, 0
105};
106
91447636
A
107struct domain * atalkdom = &atalkdomain;
108lck_mtx_t *atalk_mutex = NULL;
109
1c79356b
A
110SYSCTL_NODE(_net, PF_APPLETALK, appletalk, CTLFLAG_RW, 0, "AppleTalk Family");
111
91447636
A
112void
113atalk_dominit()
114{
115 atalk_mutex = atalkdom->dom_mtx;
116}
117
118void
119atalk_lock()
120{
121 int error = 0, lr, lr_saved;
122#ifdef __ppc__
123 __asm__ volatile("mflr %0" : "=r" (lr));
124 lr_saved = lr;
125#endif
126 lck_mtx_assert(atalkdom->dom_mtx, LCK_MTX_ASSERT_NOTOWNED);
127 lck_mtx_lock(atalkdom->dom_mtx);
128}
129
130void
131atalk_unlock()
132{
133 int error = 0, lr, lr_saved;
134#ifdef __ppc__
135 __asm__ volatile("mflr %0" : "=r" (lr));
136 lr_saved = lr;
137#endif
138 lck_mtx_assert(atalkdom->dom_mtx, LCK_MTX_ASSERT_OWNED);
139 lck_mtx_unlock(atalkdom->dom_mtx);
140
141}
142
143
144
145
146