]>
git.saurik.com Git - apple/xnu.git/blob - bsd/netat/aurp_tickle.c
91994a9bc7487bd298902fd19133d2e1b4fdd3fc
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/routing_tables.h>
48 #include <netat/at_pcb.h>
49 #include <netat/aurp.h>
50 #include <netat/debug.h>
53 void AURPsndTickle(state
)
62 if (state
->rcv_state
== AURPSTATE_Unconnected
) {
66 /* stop trying if the retry count exceeds the maximum retry value */
67 if (++state
->tickle_retry
> AURP_MaxTickleRetry
) {
68 dPrintf(D_M_AURP
, D_L_WARNING
,
69 ("AURPsndTickle: no response, %d\n", state
->rem_node
));
71 * the tunnel peer seems to have disappeared, update state info
73 state
->snd_state
= AURPSTATE_Unconnected
;
74 state
->rcv_state
= AURPSTATE_Unconnected
;
75 state
->tickle_retry
= 0;
78 /* purge all routes associated with the tunnel peer */
79 AURPpurgeri(state
->rem_node
);
84 if (state
->tickle_retry
> 1) {
85 msize
= sizeof(aurp_hdr_t
);
86 if ((m
= (gbuf_t
*)gbuf_alloc(msize
, PRI_MED
)) != 0) {
89 /* construct the tickle packet */
90 hdrp
= (aurp_hdr_t
*)gbuf_rptr(m
);
91 hdrp
->connection_id
= state
->rcv_connection_id
;
92 hdrp
->sequence_number
= 0;
93 hdrp
->command_code
= AURPCMD_Tickle
;
97 AURPsend(m
, AUD_AURP
, state
->rem_node
);
101 /* start the retry timer */
102 timeout(AURPsndTickle
, state
, AURP_TickleRetryInterval
*HZ
);
108 void AURPrcvTickle(state
, m
)
112 aurp_hdr_t
*hdrp
= (aurp_hdr_t
*)gbuf_rptr(m
);
114 /* make sure we're in a valid state to accept it */
115 if (state
->snd_state
== AURPSTATE_Unconnected
) {
116 dPrintf(D_M_AURP
, D_L_WARNING
,
117 ("AURPrcvTickle: unexpected request\n"));
122 /* construct the tickle ack packet */
123 gbuf_wset(m
,sizeof(aurp_hdr_t
));
124 hdrp
->command_code
= AURPCMD_TickleAck
;
127 /* send the packet */
128 AURPsend(m
, AUD_AURP
, state
->rem_node
);
132 void AURPrcvTickleAck(state
, m
)
136 aurp_hdr_t
*hdrp
= (aurp_hdr_t
*)gbuf_rptr(m
);
138 /* make sure we're in a valid state to accept it */
139 if (state
->rcv_state
== AURPSTATE_Unconnected
) {
140 dPrintf(D_M_AURP
, D_L_WARNING
,
141 ("AURPrcvTickleAck: unexpected response\n"));
146 /* check for the correct connection id */
147 if (hdrp
->connection_id
!= state
->rcv_connection_id
) {
148 dPrintf(D_M_AURP
, D_L_WARNING
,
149 ("AURPrcvTickleAck: invalid connection id, r=%d, m=%d\n",
150 hdrp
->connection_id
, state
->rcv_connection_id
));
156 /* update state info */
157 state
->tickle_retry
= 0;