]>
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
);
91 state
= (aurp_state_t
*)&aurp_state
[1];
98 * for every tunnel peer, do the following periodically:
99 * 1. send zone requests to determine zone names of networks
100 * that still do not have asssociated zone names.
101 * 2. send any RI update that are pending
103 for (node
=1; node
<= dst_addr_cnt
; node
++, state
++) {
108 /* restart the periodic update timer */
109 timeout(AURPupdate
, arg
, AURP_UpdateRate
*10*HZ
);
121 while ((tmp_m
= m
) != 0) {
123 gbuf_next(tmp_m
) = 0;
132 aurp_state_t
*state
= (aurp_state_t
*)&aurp_state
[1];
134 RT_entry
*entry
= (RT_entry
*)RT_table
;
136 /* start the periodic update timer */
137 timeout(AURPupdate
, 0, AURP_UpdateRate
*10*HZ
);
140 /* initialize AURP flags for entries in the RT table */
141 for (entry_num
=0; entry_num
< RT_maxentry
; entry_num
++,entry
++)
144 /* initiate connections to peers */
145 for (node
=1; node
<= dst_addr_cnt
; node
++, state
++) {
146 bzero((char *)state
, sizeof(*state
));
147 state
->rem_node
= node
;
148 state
->snd_state
= AURPSTATE_Unconnected
;
149 state
->rcv_state
= AURPSTATE_Unconnected
;
150 dPrintf(D_M_AURP
, D_L_STARTUP_INFO
,
151 ("AURPinit: sending OpenReq to node %u\n", node
));
152 AURPsndOpenReq(state
);
159 void AURPcleanup(state
)
163 gbuf_freem(state
->rsp_m
);
168 gbuf_freem(state
->upd_m
);
179 aurp_state_t
*state
= (aurp_state_t
*)&aurp_state
[1];
181 /* cancel the periodic update timer */
182 untimeout(AURPupdate
, 0);
185 /* notify tunnel peers of router going-down */
186 for (node
=1; node
<= dst_addr_cnt
; node
++, state
++) {
191 /* bring down the router */
192 aurp_wakeup(NULL
, (caddr_t
) AE_SHUTDOWN
, 0);
201 entry
= (RT_entry
*)RT_table
;
202 for (entry_num
=0; entry_num
< RT_maxentry
; entry_num
++,entry
++)
203 entry
->AURPFlag
= net_export
? AURP_NetHiden
: 0;
205 for (i
=0; i
< net_access_cnt
; i
++) {
206 /* export or hide networks as configured */
207 if ((entry
= rt_blookup(net_access
[i
])) != 0)
208 entry
->AURPFlag
= net_export
? 0 : AURP_NetHiden
;