]> git.saurik.com Git - apple/xnu.git/blame - bsd/netat/aurp_rd.c
xnu-792.6.56.tar.gz
[apple/xnu.git] / bsd / netat / aurp_rd.c
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
ff6e181a
A
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
1c79356b 12 *
ff6e181a
A
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
1c79356b
A
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
ff6e181a
A
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
1c79356b
A
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23/*
24 * Copyright (c) 1996 Apple Computer, Inc.
25 *
26 * Created April 8, 1996 by Tuyen Nguyen
27 * Modified, March 17, 1997 by Tuyen Nguyen for MacOSX.
28 *
29 * File: rd.c
30 */
31#include <sys/errno.h>
32#include <sys/types.h>
33#include <sys/param.h>
34#include <machine/spl.h>
35#include <sys/systm.h>
36#include <sys/kernel.h>
37#include <sys/proc.h>
38#include <sys/filedesc.h>
39#include <sys/fcntl.h>
40#include <sys/mbuf.h>
41#include <sys/socket.h>
42#include <sys/socketvar.h>
43#include <net/if.h>
44
45#include <netat/sysglue.h>
46#include <netat/appletalk.h>
47#include <netat/at_var.h>
48#include <netat/routing_tables.h>
49#include <netat/at_pcb.h>
50#include <netat/aurp.h>
51
52/* */
53void AURPsndRDReq(state)
54 aurp_state_t *state;
55{
56 int msize;
57 gbuf_t *m;
58 aurp_hdr_t *hdrp;
59
60 if ((state->rcv_state == AURPSTATE_Unconnected) ||
61 (state->snd_state == AURPSTATE_Unconnected))
62 return;
63
64 /* update state info */
65 state->rcv_state = AURPSTATE_Unconnected;
66 state->snd_state = AURPSTATE_Unconnected;
67
68 /* notify tunnel peer of router going-down for the data receiver side */
69 msize = sizeof(aurp_hdr_t) + sizeof(short);
70 if ((m = (gbuf_t *)gbuf_alloc(msize, PRI_MED)) != 0) {
71 gbuf_wset(m,msize);
72
73 /* construct the router down packet */
74 hdrp = (aurp_hdr_t *)gbuf_rptr(m);
75 hdrp->connection_id = state->rcv_connection_id;
76 hdrp->sequence_number = 0;
77 hdrp->command_code = AURPCMD_RDReq;
78 hdrp->flags = 0;
79 *(short *)(hdrp+1) = AURPERR_NormalConnectionClose;
80
81 /* send the packet */
82 AURPsend(m, AUD_AURP, state->rem_node);
83 }
84
85 /* notify tunnel peer of router going-down for the data sender side */
86 msize = sizeof(aurp_hdr_t) + sizeof(short);
87 if ((m = (gbuf_t *)gbuf_alloc(msize, PRI_MED)) != 0) {
88 gbuf_wset(m,msize);
89
90 /* construct the router down packet */
91 hdrp = (aurp_hdr_t *)gbuf_rptr(m);
92 hdrp->connection_id = state->snd_connection_id;
93 hdrp->sequence_number = state->snd_sequence_number;
94 hdrp->command_code = AURPCMD_RDReq;
95 hdrp->flags = 0;
96 *(short *)(hdrp+1) = AURPERR_NormalConnectionClose;
97
98 /* send the packet */
99 AURPsend(m, AUD_AURP, state->rem_node);
100 }
101}
102
103/* */
104void AURPrcvRDReq(state, m)
105 aurp_state_t *state;
106 gbuf_t *m;
107{
108 /* update state info */
109 state->rcv_state = AURPSTATE_Unconnected;
110 state->snd_state = AURPSTATE_Unconnected;
111 AURPcleanup(state);
112
113 /* purge all routes associated with the tunnel peer going-down */
114 AURPpurgeri(state->rem_node);
115
116 /* respond to the going-down peer with an RI Ack packet */
117 AURPsndRIAck(state, m, 0);
118}