]>
Commit | Line | Data |
---|---|---|
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) 1996 Apple Computer, Inc. | |
25 | * | |
26 | * Created April 8, 1996 by Tuyen Nguyen | |
27 | * Modified, March 17, 1997 by Tuyen Nguyen for MacOSX. | |
28 | * | |
29 | * File: cfg.c | |
30 | */ | |
31 | #define RESOLVE_DBG | |
32 | #include <sys/errno.h> | |
33 | #include <sys/types.h> | |
34 | #include <sys/param.h> | |
35 | #include <machine/spl.h> | |
36 | #include <sys/systm.h> | |
37 | #include <sys/kernel.h> | |
38 | #include <sys/proc.h> | |
39 | #include <sys/filedesc.h> | |
40 | #include <sys/fcntl.h> | |
41 | #include <sys/mbuf.h> | |
42 | #include <sys/socket.h> | |
43 | #include <sys/socketvar.h> | |
44 | #include <net/if.h> | |
45 | ||
46 | #include <netat/sysglue.h> | |
47 | #include <netat/appletalk.h> | |
48 | #include <netat/at_var.h> | |
49 | #include <netat/routing_tables.h> | |
50 | #include <netat/at_pcb.h> | |
51 | #include <netat/aurp.h> | |
52 | ||
53 | extern atlock_t aurpgen_lock; | |
54 | static int aurp_inited = 0; | |
55 | static char aurp_minor_no[4]; | |
56 | ||
57 | int aurp_open(gref) | |
58 | gref_t *gref; | |
59 | { | |
60 | extern void AURPcmdx(); | |
61 | int i; | |
62 | ||
63 | if (!aurp_inited) { | |
64 | aurp_inited = 1; | |
65 | ATLOCKINIT(aurpgen_lock); | |
66 | } | |
67 | ||
68 | for (i=1; i < sizeof(aurp_minor_no); i++) { | |
69 | if (aurp_minor_no[i] == 0) { | |
70 | aurp_minor_no[i] = (char )i; | |
71 | break; | |
72 | } | |
73 | } | |
74 | if (i == sizeof(aurp_minor_no)) | |
75 | return EAGAIN; | |
76 | if (i == 1) { | |
77 | aurp_gref = gref; | |
78 | if (ddp_AURPfuncx(AURPCODE_REG, AURPcmdx, 0)) { | |
79 | aurp_gref = 0; | |
80 | aurp_minor_no[i] = 0; | |
91447636 | 81 | return EPROTOTYPE; |
1c79356b A |
82 | } |
83 | } | |
84 | ||
85 | gref->info = (void *)&aurp_minor_no[i]; | |
86 | return 0; | |
87 | } | |
88 | ||
89 | int aurp_close(gref) | |
90 | gref_t *gref; | |
91 | { | |
92 | if (*(char *)gref->info == 1) { | |
93 | aurp_gref = 0; | |
94 | aurp_inited = 0; | |
95 | ddp_AURPfuncx(AURPCODE_REG, 0, 0); | |
96 | } | |
97 | ||
98 | *(char *)gref->info = 0; | |
99 | gref->info = 0; | |
100 | return 0; | |
101 | } |