]> git.saurik.com Git - apple/xnu.git/blame - bsd/netat/aurp_rd.c
xnu-792.6.61.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 *
37839358
A
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.
1c79356b 11 *
37839358
A
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
1c79356b
A
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
37839358
A
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
1c79356b
A
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22/*
23 * Copyright (c) 1996 Apple Computer, Inc.
24 *
25 * Created April 8, 1996 by Tuyen Nguyen
26 * Modified, March 17, 1997 by Tuyen Nguyen for MacOSX.
27 *
28 * File: rd.c
29 */
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>
36#include <sys/proc.h>
37#include <sys/filedesc.h>
38#include <sys/fcntl.h>
39#include <sys/mbuf.h>
40#include <sys/socket.h>
41#include <sys/socketvar.h>
42#include <net/if.h>
43
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
51/* */
52void AURPsndRDReq(state)
53 aurp_state_t *state;
54{
55 int msize;
56 gbuf_t *m;
57 aurp_hdr_t *hdrp;
58
59 if ((state->rcv_state == AURPSTATE_Unconnected) ||
60 (state->snd_state == AURPSTATE_Unconnected))
61 return;
62
63 /* update state info */
64 state->rcv_state = AURPSTATE_Unconnected;
65 state->snd_state = AURPSTATE_Unconnected;
66
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) {
70 gbuf_wset(m,msize);
71
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;
77 hdrp->flags = 0;
78 *(short *)(hdrp+1) = AURPERR_NormalConnectionClose;
79
80 /* send the packet */
81 AURPsend(m, AUD_AURP, state->rem_node);
82 }
83
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) {
87 gbuf_wset(m,msize);
88
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;
94 hdrp->flags = 0;
95 *(short *)(hdrp+1) = AURPERR_NormalConnectionClose;
96
97 /* send the packet */
98 AURPsend(m, AUD_AURP, state->rem_node);
99 }
100}
101
102/* */
103void AURPrcvRDReq(state, m)
104 aurp_state_t *state;
105 gbuf_t *m;
106{
107 /* update state info */
108 state->rcv_state = AURPSTATE_Unconnected;
109 state->snd_state = AURPSTATE_Unconnected;
110 AURPcleanup(state);
111
112 /* purge all routes associated with the tunnel peer going-down */
113 AURPpurgeri(state->rem_node);
114
115 /* respond to the going-down peer with an RI Ack packet */
116 AURPsndRIAck(state, m, 0);
117}