]>
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_LICENSE_OSREFERENCE_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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
31 * Copyright (c) 1996 Apple Computer, Inc.
33 * Created April 8, 1996 by Tuyen Nguyen
34 * Modified, March 17, 1997 by Tuyen Nguyen for MacOSX.
41 #include <sys/errno.h>
42 #include <sys/types.h>
43 #include <sys/param.h>
44 #include <machine/spl.h>
45 #include <sys/systm.h>
46 #include <sys/kernel.h>
48 #include <sys/filedesc.h>
49 #include <sys/fcntl.h>
51 #include <sys/socket.h>
52 #include <sys/socketvar.h>
55 #include <netat/sysglue.h>
56 #include <netat/appletalk.h>
57 #include <netat/at_var.h>
58 #include <netat/rtmp.h>
59 #include <netat/routing_tables.h>
60 #include <netat/at_pcb.h>
61 #include <netat/aurp.h>
62 #include <netat/debug.h>
65 void AURPiocack(gref
, m
)
69 /* send ok reply to ioctl command */
70 gbuf_set_type(m
, MSG_IOCACK
);
71 atalk_putnext(gref
, m
);
74 void AURPiocnak(gref
, m
, error
)
79 ioc_t
*iocbp
= (ioc_t
*)gbuf_rptr(m
);
81 /* send error reply to ioctl command */
83 gbuf_freem(gbuf_cont(m
));
86 iocbp
->ioc_error
= error
;
89 gbuf_set_type(m
, MSG_IOCNAK
);
90 atalk_putnext(gref
, m
);
102 state
= (aurp_state_t
*)&aurp_state
[1];
104 if (aurp_gref
== 0) {
109 * for every tunnel peer, do the following periodically:
110 * 1. send zone requests to determine zone names of networks
111 * that still do not have asssociated zone names.
112 * 2. send any RI update that are pending
114 for (node
=1; node
<= dst_addr_cnt
; node
++, state
++) {
119 /* restart the periodic update timer */
120 timeout(AURPupdate
, arg
, AURP_UpdateRate
*10*HZ
);
132 while ((tmp_m
= m
) != 0) {
134 gbuf_next(tmp_m
) = 0;
143 aurp_state_t
*state
= (aurp_state_t
*)&aurp_state
[1];
145 RT_entry
*entry
= (RT_entry
*)RT_table
;
147 /* start the periodic update timer */
148 timeout(AURPupdate
, 0, AURP_UpdateRate
*10*HZ
);
151 /* initialize AURP flags for entries in the RT table */
152 for (entry_num
=0; entry_num
< RT_maxentry
; entry_num
++,entry
++)
155 /* initiate connections to peers */
156 for (node
=1; node
<= dst_addr_cnt
; node
++, state
++) {
157 bzero((char *)state
, sizeof(*state
));
158 state
->rem_node
= node
;
159 state
->snd_state
= AURPSTATE_Unconnected
;
160 state
->rcv_state
= AURPSTATE_Unconnected
;
161 dPrintf(D_M_AURP
, D_L_STARTUP_INFO
,
162 ("AURPinit: sending OpenReq to node %u\n", node
));
163 AURPsndOpenReq(state
);
170 void AURPcleanup(state
)
174 gbuf_freem(state
->rsp_m
);
179 gbuf_freem(state
->upd_m
);
190 aurp_state_t
*state
= (aurp_state_t
*)&aurp_state
[1];
192 /* cancel the periodic update timer */
193 untimeout(AURPupdate
, 0);
196 /* notify tunnel peers of router going-down */
197 for (node
=1; node
<= dst_addr_cnt
; node
++, state
++) {
202 /* bring down the router */
203 aurp_wakeup(NULL
, (caddr_t
) AE_SHUTDOWN
, 0);
212 entry
= (RT_entry
*)RT_table
;
213 for (entry_num
=0; entry_num
< RT_maxentry
; entry_num
++,entry
++)
214 entry
->AURPFlag
= net_export
? AURP_NetHiden
: 0;
216 for (i
=0; i
< net_access_cnt
; i
++) {
217 /* export or hide networks as configured */
218 if ((entry
= rt_blookup(net_access
[i
])) != 0)
219 entry
->AURPFlag
= net_export
? 0 : AURP_NetHiden
;
223 #endif /* AURP_SUPPORT */