|
|
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: * File: tickle.c
35: */
36: #include <sysglue.h>
37: #include <at/appletalk.h>
38: #include <lap.h>
39: #include <routing_tables.h>
40: #define _AURP
41: #include <at_aurp.h>
42: #include <at/aurp.h>
43:
44: /* */
45: void AURPsndTickle(state)
46: aurp_state_t *state;
47: {
48: int msize;
49: gbuf_t *m;
50: aurp_hdr_t *hdrp;
51:
52: if (state->rcv_state == AURPSTATE_Unconnected)
53: return;
54:
55: /* stop trying if the retry count exceeds the maximum retry value */
56: if (++state->tickle_retry > AURP_MaxTickleRetry) {
57: dPrintf(D_M_AURP, D_L_WARNING,
58: ("AURPsndTickle: no response, %d\n", state->rem_node));
59: /*
60: * the tunnel peer seems to have disappeared, update state info
61: */
62: state->snd_state = AURPSTATE_Unconnected;
63: state->rcv_state = AURPSTATE_Unconnected;
64: state->tickle_retry = 0;
65: AURPcleanup(state);
66:
67: /* purge all routes associated with the tunnel peer */
68: AURPpurgeri(state->rem_node);
69: return;
70: }
71:
72: if (state->tickle_retry > 1) {
73: msize = sizeof(aurp_hdr_t);
74: if ((m = (gbuf_t *)gbuf_alloc(msize, PRI_MED)) != 0) {
75: gbuf_wset(m,msize);
76:
77: /* construct the tickle packet */
78: hdrp = (aurp_hdr_t *)gbuf_rptr(m);
79: hdrp->connection_id = state->rcv_connection_id;
80: hdrp->sequence_number = 0;
81: hdrp->command_code = AURPCMD_Tickle;
82: hdrp->flags = 0;
83:
84: /* send the packet */
85: AURPsend(m, AUD_AURP, state->rem_node);
86: }
87: }
88:
89: /* start the retry timer */
90: atalk_timeout(AURPsndTickle, state, AURP_TickleRetryInterval*HZ);
91: }
92:
93: /* */
94: void AURPrcvTickle(state, m)
95: aurp_state_t *state;
96: gbuf_t *m;
97: {
98: aurp_hdr_t *hdrp = (aurp_hdr_t *)gbuf_rptr(m);
99:
100: /* make sure we're in a valid state to accept it */
101: if (state->snd_state == AURPSTATE_Unconnected) {
102: dPrintf(D_M_AURP, D_L_WARNING,
103: ("AURPrcvTickle: unexpected request\n"));
104: gbuf_freem(m);
105: return;
106: }
107:
108: /* construct the tickle ack packet */
109: gbuf_wset(m,sizeof(aurp_hdr_t));
110: hdrp->command_code = AURPCMD_TickleAck;
111: hdrp->flags = 0;
112:
113: /* send the packet */
114: AURPsend(m, AUD_AURP, state->rem_node);
115: }
116:
117: /* */
118: void AURPrcvTickleAck(state, m)
119: aurp_state_t *state;
120: gbuf_t *m;
121: {
122: aurp_hdr_t *hdrp = (aurp_hdr_t *)gbuf_rptr(m);
123:
124: /* make sure we're in a valid state to accept it */
125: if (state->rcv_state == AURPSTATE_Unconnected) {
126: dPrintf(D_M_AURP, D_L_WARNING,
127: ("AURPrcvTickleAck: unexpected response\n"));
128: gbuf_freem(m);
129: return;
130: }
131:
132: /* check for the correct connection id */
133: if (hdrp->connection_id != state->rcv_connection_id) {
134: dPrintf(D_M_AURP, D_L_WARNING,
135: ("AURPrcvTickleAck: invalid connection id, r=%d, m=%d\n",
136: hdrp->connection_id, state->rcv_connection_id));
137: gbuf_freem(m);
138: return;
139: }
140: gbuf_freem(m);
141:
142: /* update state info */
143: state->tickle_retry = 0;
144: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.