]> git.saurik.com Git - apple/xnu.git/blob - bsd/netat/aurp_cfg.c
xnu-517.3.15.tar.gz
[apple/xnu.git] / bsd / netat / aurp_cfg.c
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /*
26 * Copyright (c) 1996 Apple Computer, Inc.
27 *
28 * Created April 8, 1996 by Tuyen Nguyen
29 * Modified, March 17, 1997 by Tuyen Nguyen for MacOSX.
30 *
31 * File: cfg.c
32 */
33 #define RESOLVE_DBG
34 #include <sys/errno.h>
35 #include <sys/types.h>
36 #include <sys/param.h>
37 #include <machine/spl.h>
38 #include <sys/systm.h>
39 #include <sys/kernel.h>
40 #include <sys/proc.h>
41 #include <sys/filedesc.h>
42 #include <sys/fcntl.h>
43 #include <sys/mbuf.h>
44 #include <sys/socket.h>
45 #include <sys/socketvar.h>
46 #include <net/if.h>
47
48 #include <netat/sysglue.h>
49 #include <netat/appletalk.h>
50 #include <netat/at_var.h>
51 #include <netat/routing_tables.h>
52 #include <netat/at_pcb.h>
53 #include <netat/aurp.h>
54
55 extern atlock_t aurpgen_lock;
56 static int aurp_inited = 0;
57 static char aurp_minor_no[4];
58
59 int aurp_open(gref)
60 gref_t *gref;
61 {
62 extern void AURPcmdx();
63 int i;
64
65 if (!aurp_inited) {
66 aurp_inited = 1;
67 ATLOCKINIT(aurpgen_lock);
68 }
69
70 for (i=1; i < sizeof(aurp_minor_no); i++) {
71 if (aurp_minor_no[i] == 0) {
72 aurp_minor_no[i] = (char )i;
73 break;
74 }
75 }
76 if (i == sizeof(aurp_minor_no))
77 return EAGAIN;
78 if (i == 1) {
79 aurp_gref = gref;
80 if (ddp_AURPfuncx(AURPCODE_REG, AURPcmdx, 0)) {
81 aurp_gref = 0;
82 aurp_minor_no[i] = 0;
83 return EPROTO;
84 }
85 }
86
87 gref->info = (void *)&aurp_minor_no[i];
88 return 0;
89 }
90
91 int aurp_close(gref)
92 gref_t *gref;
93 {
94 if (*(char *)gref->info == 1) {
95 aurp_gref = 0;
96 aurp_inited = 0;
97 ddp_AURPfuncx(AURPCODE_REG, 0, 0);
98 }
99
100 *(char *)gref->info = 0;
101 gref->info = 0;
102 return 0;
103 }