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