|
|
1.1 root 1: /*
2: * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3: *
4: * @APPLE_LICENSE_HEADER_START@
5: *
6: * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7: * Reserved. This file contains Original Code and/or Modifications of
8: * Original Code as defined in and that are subject to the Apple Public
9: * Source License Version 1.1 (the "License"). You may not use this file
10: * except in compliance with the License. Please obtain a copy of the
11: * License at http://www.apple.com/publicsource and read it before using
12: * this file.
13: *
14: * The Original Code and all software distributed under the License are
15: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
19: * License for the specific language governing rights and limitations
20: * under the License.
21: *
22: * @APPLE_LICENSE_HEADER_END@
23: */
24:
25: /*
26: * Copyright (c) 1996 Apple Computer, Inc.
27: *
28: * The information contained herein is subject to change without
29: * notice and should not be construed as a commitment by Apple
30: * Computer, Inc. Apple Computer, Inc. assumes no responsibility
31: * for any errors that may appear.
32: *
33: * Confidential and Proprietary to Apple Computer, Inc.
34: *
35: * File: misc.c
36: */
37: #include <sys/socketvar.h>
38: #include <sysglue.h>
39: #include <at/appletalk.h>
40: #include <lap.h>
41: #include <rtmp.h>
42: #include <routing_tables.h>
43: #include <at/aurp.h>
44: #define _AURP
45: #define _KERNSYS
46: #include <at_aurp.h>
47:
48: /* */
49: void AURPiocack(gref, m)
50: gref_t *gref;
51: gbuf_t *m;
52: {
53: /* send ok reply to ioctl command */
54: gbuf_set_type(m, MSG_IOCACK);
55: atalk_putnext(gref, m);
56: }
57:
58: void AURPiocnak(gref, m, error)
59: gref_t *gref;
60: gbuf_t *m;
61: int error;
62: {
63: ioc_t *iocbp = (ioc_t *)gbuf_rptr(m);
64:
65: /* send error reply to ioctl command */
66: if (gbuf_cont(m)) {
67: gbuf_freem(gbuf_cont(m));
68: gbuf_cont(m) = 0;
69: }
70: iocbp->ioc_error = error;
71: iocbp->ioc_count = 0;
72: iocbp->ioc_rval = -1;
73: gbuf_set_type(m, MSG_IOCNAK);
74: atalk_putnext(gref, m);
75: }
76:
77: /* */
78: void AURPupdate(arg)
79: void *arg;
80: {
81: unsigned char node;
82: aurp_state_t *state = (aurp_state_t *)&aurp_state[1];
83:
84: if (aurp_gref == 0)
85: return;
86:
87: /*
88: * for every tunnel peer, do the following periodically:
89: * 1. send zone requests to determine zone names of networks
90: * that still do not have asssociated zone names.
91: * 2. send any RI update that are pending
92: */
93: for (node=1; node <= dst_addr_cnt; node++, state++) {
94: AURPsndZReq(state);
95: AURPsndRIUpd(state);
96: }
97:
98: /* restart the periodic update timer */
99: update_tmo = (void *)atalk_timeout(AURPupdate, arg, AURP_UpdateRate*10*HZ);
100: }
101:
102: /* */
103: void AURPfreemsg(m)
104: gbuf_t *m;
105: {
106: gbuf_t *tmp_m;
107:
108: while ((tmp_m = m) != 0) {
109: m = gbuf_next(m);
110: gbuf_next(tmp_m) = 0;
111: gbuf_freem(tmp_m);
112: }
113: }
114:
115: /* */
116: int AURPinit()
117: {
118: unsigned char node;
119: aurp_state_t *state = (aurp_state_t *)&aurp_state[1];
120: short entry_num;
121: RT_entry *entry = (RT_entry *)RT_table;
122:
123: /* start the periodic update timer */
124: update_tmo = (void *)atalk_timeout(AURPupdate, 0, AURP_UpdateRate*10*HZ);
125:
126: /* initialize AURP flags for entries in the RT table */
127: for (entry_num=0; entry_num < RT_maxentry; entry_num++,entry++)
128: entry->AURPFlag = 0;
129:
130: /* initiate connections to peers */
131: for (node=1; node <= dst_addr_cnt; node++, state++) {
132: bzero((char *)state, sizeof(*state));
133: state->rem_node = node;
134: state->snd_state = AURPSTATE_Unconnected;
135: state->rcv_state = AURPSTATE_Unconnected;
136: AURPsndOpenReq(state);
137: }
138:
139: return 0;
140: }
141:
142: /* */
143: void AURPcleanup(state)
144: aurp_state_t *state;
145: {
146: if (state->rsp_m) {
147: gbuf_freem(state->rsp_m);
148: state->rsp_m = 0;
149: }
150:
151: if (state->upd_m) {
152: gbuf_freem(state->upd_m);
153: state->upd_m = 0;
154: }
155: }
156:
157: /*
158: *
159: */
160: void AURPshutdown()
161: {
162: unsigned char node;
163: aurp_state_t *state = (aurp_state_t *)&aurp_state[1];
164:
165: /* cancel the periodic update timer */
166: atalk_untimeout(AURPupdate, 0, update_tmo);
167: update_tmo = 0;
168:
169: /* notify tunnel peers of router going-down */
170: for (node=1; node <= dst_addr_cnt; node++, state++) {
171: AURPcleanup(state);
172: AURPsndRDReq(state);
173: }
174:
175: /* bring down the router */
176: aurp_wakeup(AE_SHUTDOWN, 0);
177: }
178:
179: void AURPaccess()
180: {
181: unsigned char i;
182: short entry_num;
183: RT_entry *entry;
184:
185: entry = (RT_entry *)RT_table;
186: for (entry_num=0; entry_num < RT_maxentry; entry_num++,entry++)
187: entry->AURPFlag = net_export ? AURP_NetHiden : 0;
188:
189: for (i=0; i < net_access_cnt; i++) {
190: /* export or hide networks as configured */
191: if ((entry = RT_lookup(net_access[i])) != 0)
192: entry->AURPFlag = net_export ? 0 : AURP_NetHiden;
193: }
194: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.