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>
52 void AURPsndRDReq(state
)
59 if ((state
->rcv_state
== AURPSTATE_Unconnected
) ||
60 (state
->snd_state
== AURPSTATE_Unconnected
))
63 /* update state info */
64 state
->rcv_state
= AURPSTATE_Unconnected
;
65 state
->snd_state
= AURPSTATE_Unconnected
;
67 /* notify tunnel peer of router going-down for the data receiver side */
68 msize
= sizeof(aurp_hdr_t
) + sizeof(short);
69 if ((m
= (gbuf_t
*)gbuf_alloc(msize
, PRI_MED
)) != 0) {
72 /* construct the router down packet */
73 hdrp
= (aurp_hdr_t
*)gbuf_rptr(m
);
74 hdrp
->connection_id
= state
->rcv_connection_id
;
75 hdrp
->sequence_number
= 0;
76 hdrp
->command_code
= AURPCMD_RDReq
;
78 *(short *)(hdrp
+1) = AURPERR_NormalConnectionClose
;
81 AURPsend(m
, AUD_AURP
, state
->rem_node
);
84 /* notify tunnel peer of router going-down for the data sender side */
85 msize
= sizeof(aurp_hdr_t
) + sizeof(short);
86 if ((m
= (gbuf_t
*)gbuf_alloc(msize
, PRI_MED
)) != 0) {
89 /* construct the router down packet */
90 hdrp
= (aurp_hdr_t
*)gbuf_rptr(m
);
91 hdrp
->connection_id
= state
->snd_connection_id
;
92 hdrp
->sequence_number
= state
->snd_sequence_number
;
93 hdrp
->command_code
= AURPCMD_RDReq
;
95 *(short *)(hdrp
+1) = AURPERR_NormalConnectionClose
;
98 AURPsend(m
, AUD_AURP
, state
->rem_node
);
103 void AURPrcvRDReq(state
, m
)
107 /* update state info */
108 state
->rcv_state
= AURPSTATE_Unconnected
;
109 state
->snd_state
= AURPSTATE_Unconnected
;
112 /* purge all routes associated with the tunnel peer going-down */
113 AURPpurgeri(state
->rem_node
);
115 /* respond to the going-down peer with an RI Ack packet */
116 AURPsndRIAck(state
, m
, 0);