]> git.saurik.com Git - apple/xnu.git/blame - bsd/netat/aurp_cfg.c
xnu-344.23.tar.gz
[apple/xnu.git] / bsd / netat / aurp_cfg.c
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
de355530
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.
1c79356b 11 *
de355530
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
1c79356b
A
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
de355530
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.
1c79356b
A
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22/*
23 * Copyright (c) 1996 Apple Computer, Inc.
24 *
25 * Created April 8, 1996 by Tuyen Nguyen
26 * Modified, March 17, 1997 by Tuyen Nguyen for MacOSX.
27 *
28 * File: cfg.c
29 */
30#define RESOLVE_DBG
31#include <sys/errno.h>
32#include <sys/types.h>
33#include <sys/param.h>
34#include <machine/spl.h>
35#include <sys/systm.h>
36#include <sys/kernel.h>
37#include <sys/proc.h>
38#include <sys/filedesc.h>
39#include <sys/fcntl.h>
40#include <sys/mbuf.h>
41#include <sys/socket.h>
42#include <sys/socketvar.h>
43#include <net/if.h>
44
45#include <netat/sysglue.h>
46#include <netat/appletalk.h>
47#include <netat/at_var.h>
48#include <netat/routing_tables.h>
49#include <netat/at_pcb.h>
50#include <netat/aurp.h>
51
52extern atlock_t aurpgen_lock;
53static int aurp_inited = 0;
54static char aurp_minor_no[4];
55
56int aurp_open(gref)
57 gref_t *gref;
58{
59 extern void AURPcmdx();
60 int i;
61
62 if (!aurp_inited) {
63 aurp_inited = 1;
64 ATLOCKINIT(aurpgen_lock);
65 }
66
67 for (i=1; i < sizeof(aurp_minor_no); i++) {
68 if (aurp_minor_no[i] == 0) {
69 aurp_minor_no[i] = (char )i;
70 break;
71 }
72 }
73 if (i == sizeof(aurp_minor_no))
74 return EAGAIN;
75 if (i == 1) {
76 aurp_gref = gref;
77 if (ddp_AURPfuncx(AURPCODE_REG, AURPcmdx, 0)) {
78 aurp_gref = 0;
79 aurp_minor_no[i] = 0;
80 return EPROTO;
81 }
82 }
83
84 gref->info = (void *)&aurp_minor_no[i];
85 return 0;
86}
87
88int aurp_close(gref)
89 gref_t *gref;
90{
91 if (*(char *)gref->info == 1) {
92 aurp_gref = 0;
93 aurp_inited = 0;
94 ddp_AURPfuncx(AURPCODE_REG, 0, 0);
95 }
96
97 *(char *)gref->info = 0;
98 gref->info = 0;
99 return 0;
100}