]>
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_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
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
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.
23 * @APPLE_LICENSE_HEADER_END@
26 * Copyright (c) 1996 Apple Computer, Inc.
28 * Created April 8, 1996 by Tuyen Nguyen
29 * Modified, March 17, 1997 by Tuyen Nguyen for MacOSX.
33 #include <sys/errno.h>
34 #include <sys/types.h>
35 #include <sys/param.h>
36 #include <machine/spl.h>
37 #include <sys/systm.h>
38 #include <sys/kernel.h>
40 #include <sys/filedesc.h>
41 #include <sys/fcntl.h>
43 #include <sys/socket.h>
44 #include <sys/socketvar.h>
47 #include <netat/sysglue.h>
48 #include <netat/appletalk.h>
49 #include <netat/at_var.h>
50 #include <netat/rtmp.h>
51 #include <netat/routing_tables.h>
52 #include <netat/at_pcb.h>
53 #include <netat/aurp.h>
54 #include <netat/debug.h>
57 void AURPiocack(gref
, m
)
61 /* send ok reply to ioctl command */
62 gbuf_set_type(m
, MSG_IOCACK
);
63 atalk_putnext(gref
, m
);
66 void AURPiocnak(gref
, m
, error
)
71 ioc_t
*iocbp
= (ioc_t
*)gbuf_rptr(m
);
73 /* send error reply to ioctl command */
75 gbuf_freem(gbuf_cont(m
));
78 iocbp
->ioc_error
= error
;
81 gbuf_set_type(m
, MSG_IOCNAK
);
82 atalk_putnext(gref
, m
);
90 boolean_t funnel_state
;
93 funnel_state
= thread_funnel_set(network_flock
, TRUE
);
95 state
= (aurp_state_t
*)&aurp_state
[1];
98 (void) thread_funnel_set(network_flock
, FALSE
);
102 * for every tunnel peer, do the following periodically:
103 * 1. send zone requests to determine zone names of networks
104 * that still do not have asssociated zone names.
105 * 2. send any RI update that are pending
107 for (node
=1; node
<= dst_addr_cnt
; node
++, state
++) {
112 /* restart the periodic update timer */
113 timeout(AURPupdate
, arg
, AURP_UpdateRate
*10*HZ
);
116 (void) thread_funnel_set(network_flock
, FALSE
);
125 while ((tmp_m
= m
) != 0) {
127 gbuf_next(tmp_m
) = 0;
136 aurp_state_t
*state
= (aurp_state_t
*)&aurp_state
[1];
138 RT_entry
*entry
= (RT_entry
*)RT_table
;
140 /* start the periodic update timer */
141 timeout(AURPupdate
, 0, AURP_UpdateRate
*10*HZ
);
144 /* initialize AURP flags for entries in the RT table */
145 for (entry_num
=0; entry_num
< RT_maxentry
; entry_num
++,entry
++)
148 /* initiate connections to peers */
149 for (node
=1; node
<= dst_addr_cnt
; node
++, state
++) {
150 bzero((char *)state
, sizeof(*state
));
151 state
->rem_node
= node
;
152 state
->snd_state
= AURPSTATE_Unconnected
;
153 state
->rcv_state
= AURPSTATE_Unconnected
;
154 dPrintf(D_M_AURP
, D_L_STARTUP_INFO
,
155 ("AURPinit: sending OpenReq to node %u\n", node
));
156 AURPsndOpenReq(state
);
163 void AURPcleanup(state
)
167 gbuf_freem(state
->rsp_m
);
172 gbuf_freem(state
->upd_m
);
183 aurp_state_t
*state
= (aurp_state_t
*)&aurp_state
[1];
185 /* cancel the periodic update timer */
186 untimeout(AURPupdate
, 0);
189 /* notify tunnel peers of router going-down */
190 for (node
=1; node
<= dst_addr_cnt
; node
++, state
++) {
195 /* bring down the router */
196 aurp_wakeup(NULL
, (caddr_t
) AE_SHUTDOWN
, 0);
205 entry
= (RT_entry
*)RT_table
;
206 for (entry_num
=0; entry_num
< RT_maxentry
; entry_num
++,entry
++)
207 entry
->AURPFlag
= net_export
? AURP_NetHiden
: 0;
209 for (i
=0; i
< net_access_cnt
; i
++) {
210 /* export or hide networks as configured */
211 if ((entry
= rt_blookup(net_access
[i
])) != 0)
212 entry
->AURPFlag
= net_export
? 0 : AURP_NetHiden
;