]>
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 * 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.
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
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 * Copyright (c) 1996 Apple Computer, Inc.
25 * Created April 8, 1996 by Tuyen Nguyen
26 * Modified, March 17, 1997 by Tuyen Nguyen for MacOSX.
30 #include <sys/errno.h>
31 #include <sys/types.h>
32 #include <sys/param.h>
33 #include <machine/spl.h>
34 #include <sys/systm.h>
35 #include <sys/kernel.h>
37 #include <sys/filedesc.h>
38 #include <sys/fcntl.h>
40 #include <sys/socket.h>
41 #include <sys/socketvar.h>
44 #include <netat/sysglue.h>
45 #include <netat/appletalk.h>
46 #include <netat/at_var.h>
47 #include <netat/rtmp.h>
48 #include <netat/routing_tables.h>
49 #include <netat/at_pcb.h>
50 #include <netat/aurp.h>
51 #include <netat/debug.h>
54 void AURPiocack(gref
, m
)
58 /* send ok reply to ioctl command */
59 gbuf_set_type(m
, MSG_IOCACK
);
60 atalk_putnext(gref
, m
);
63 void AURPiocnak(gref
, m
, error
)
68 ioc_t
*iocbp
= (ioc_t
*)gbuf_rptr(m
);
70 /* send error reply to ioctl command */
72 gbuf_freem(gbuf_cont(m
));
75 iocbp
->ioc_error
= error
;
78 gbuf_set_type(m
, MSG_IOCNAK
);
79 atalk_putnext(gref
, m
);
87 boolean_t funnel_state
;
90 funnel_state
= thread_funnel_set(network_flock
, TRUE
);
92 state
= (aurp_state_t
*)&aurp_state
[1];
95 (void) thread_funnel_set(network_flock
, FALSE
);
99 * for every tunnel peer, do the following periodically:
100 * 1. send zone requests to determine zone names of networks
101 * that still do not have asssociated zone names.
102 * 2. send any RI update that are pending
104 for (node
=1; node
<= dst_addr_cnt
; node
++, state
++) {
109 /* restart the periodic update timer */
110 timeout(AURPupdate
, arg
, AURP_UpdateRate
*10*HZ
);
113 (void) thread_funnel_set(network_flock
, FALSE
);
122 while ((tmp_m
= m
) != 0) {
124 gbuf_next(tmp_m
) = 0;
133 aurp_state_t
*state
= (aurp_state_t
*)&aurp_state
[1];
135 RT_entry
*entry
= (RT_entry
*)RT_table
;
137 /* start the periodic update timer */
138 timeout(AURPupdate
, 0, AURP_UpdateRate
*10*HZ
);
141 /* initialize AURP flags for entries in the RT table */
142 for (entry_num
=0; entry_num
< RT_maxentry
; entry_num
++,entry
++)
145 /* initiate connections to peers */
146 for (node
=1; node
<= dst_addr_cnt
; node
++, state
++) {
147 bzero((char *)state
, sizeof(*state
));
148 state
->rem_node
= node
;
149 state
->snd_state
= AURPSTATE_Unconnected
;
150 state
->rcv_state
= AURPSTATE_Unconnected
;
151 dPrintf(D_M_AURP
, D_L_STARTUP_INFO
,
152 ("AURPinit: sending OpenReq to node %u\n", node
));
153 AURPsndOpenReq(state
);
160 void AURPcleanup(state
)
164 gbuf_freem(state
->rsp_m
);
169 gbuf_freem(state
->upd_m
);
180 aurp_state_t
*state
= (aurp_state_t
*)&aurp_state
[1];
182 /* cancel the periodic update timer */
183 untimeout(AURPupdate
, 0);
186 /* notify tunnel peers of router going-down */
187 for (node
=1; node
<= dst_addr_cnt
; node
++, state
++) {
192 /* bring down the router */
193 aurp_wakeup(NULL
, (caddr_t
) AE_SHUTDOWN
, 0);
202 entry
= (RT_entry
*)RT_table
;
203 for (entry_num
=0; entry_num
< RT_maxentry
; entry_num
++,entry
++)
204 entry
->AURPFlag
= net_export
? AURP_NetHiden
: 0;
206 for (i
=0; i
< net_access_cnt
; i
++) {
207 /* export or hide networks as configured */
208 if ((entry
= rt_blookup(net_access
[i
])) != 0)
209 entry
->AURPFlag
= net_export
? 0 : AURP_NetHiden
;