]>
git.saurik.com Git - apple/xnu.git/blob - bsd/netat/aurp_misc.c
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 * Copyright (c) 1996 Apple Computer, Inc.
31 * Created April 8, 1996 by Tuyen Nguyen
32 * Modified, March 17, 1997 by Tuyen Nguyen for MacOSX.
39 #include <sys/errno.h>
40 #include <sys/types.h>
41 #include <sys/param.h>
42 #include <machine/spl.h>
43 #include <sys/systm.h>
44 #include <sys/kernel.h>
46 #include <sys/filedesc.h>
47 #include <sys/fcntl.h>
49 #include <sys/socket.h>
50 #include <sys/socketvar.h>
53 #include <netat/sysglue.h>
54 #include <netat/appletalk.h>
55 #include <netat/at_pcb.h>
56 #include <netat/at_var.h>
57 #include <netat/rtmp.h>
58 #include <netat/routing_tables.h>
59 #include <netat/aurp.h>
60 #include <netat/debug.h>
63 void AURPiocack(gref
, m
)
67 /* send ok reply to ioctl command */
68 gbuf_set_type(m
, MSG_IOCACK
);
69 atalk_putnext(gref
, m
);
72 void AURPiocnak(gref
, m
, error
)
77 ioc_t
*iocbp
= (ioc_t
*)gbuf_rptr(m
);
79 /* send error reply to ioctl command */
81 gbuf_freem(gbuf_cont(m
));
84 iocbp
->ioc_error
= error
;
87 gbuf_set_type(m
, MSG_IOCNAK
);
88 atalk_putnext(gref
, m
);
100 state
= (aurp_state_t
*)&aurp_state
[1];
102 if (aurp_gref
== 0) {
107 * for every tunnel peer, do the following periodically:
108 * 1. send zone requests to determine zone names of networks
109 * that still do not have asssociated zone names.
110 * 2. send any RI update that are pending
112 for (node
=1; node
<= dst_addr_cnt
; node
++, state
++) {
117 /* restart the periodic update timer */
118 timeout(AURPupdate
, arg
, AURP_UpdateRate
*10*HZ
);
130 while ((tmp_m
= m
) != 0) {
132 gbuf_next(tmp_m
) = 0;
141 aurp_state_t
*state
= (aurp_state_t
*)&aurp_state
[1];
143 RT_entry
*entry
= (RT_entry
*)RT_table
;
145 /* start the periodic update timer */
146 timeout(AURPupdate
, 0, AURP_UpdateRate
*10*HZ
);
149 /* initialize AURP flags for entries in the RT table */
150 for (entry_num
=0; entry_num
< RT_maxentry
; entry_num
++,entry
++)
153 /* initiate connections to peers */
154 for (node
=1; node
<= dst_addr_cnt
; node
++, state
++) {
155 bzero((char *)state
, sizeof(*state
));
156 state
->rem_node
= node
;
157 state
->snd_state
= AURPSTATE_Unconnected
;
158 state
->rcv_state
= AURPSTATE_Unconnected
;
159 dPrintf(D_M_AURP
, D_L_STARTUP_INFO
,
160 ("AURPinit: sending OpenReq to node %u\n", node
));
161 AURPsndOpenReq(state
);
168 void AURPcleanup(state
)
172 gbuf_freem(state
->rsp_m
);
177 gbuf_freem(state
->upd_m
);
188 aurp_state_t
*state
= (aurp_state_t
*)&aurp_state
[1];
190 /* cancel the periodic update timer */
191 untimeout(AURPupdate
, 0);
194 /* notify tunnel peers of router going-down */
195 for (node
=1; node
<= dst_addr_cnt
; node
++, state
++) {
200 /* bring down the router */
201 aurp_wakeup(NULL
, (caddr_t
) AE_SHUTDOWN
, 0);
210 entry
= (RT_entry
*)RT_table
;
211 for (entry_num
=0; entry_num
< RT_maxentry
; entry_num
++,entry
++)
212 entry
->AURPFlag
= net_export
? AURP_NetHiden
: 0;
214 for (i
=0; i
< net_access_cnt
; i
++) {
215 /* export or hide networks as configured */
216 if ((entry
= rt_blookup(net_access
[i
])) != 0)
217 entry
->AURPFlag
= net_export
? 0 : AURP_NetHiden
;
221 #endif /* AURP_SUPPORT */