file modes have to agree
[unix-history] / usr / src / sys / netiso / clnp_timer.c
CommitLineData
94648d00
KS
1/***********************************************************
2 Copyright IBM Corporation 1987
3
4 All Rights Reserved
5
6Permission to use, copy, modify, and distribute this software and its
7documentation for any purpose and without fee is hereby granted,
8provided that the above copyright notice appear in all copies and that
9both that copyright notice and this permission notice appear in
10supporting documentation, and that the name of IBM not be
11used in advertising or publicity pertaining to distribution of the
12software without specific, written prior permission.
13
14IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
15ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
16IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
17ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
18WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
19ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
20SOFTWARE.
21
22******************************************************************/
23
24/*
25 * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison
26 */
27/* $Header: clnp_timer.c,v 4.2 88/06/29 14:59:05 hagens Exp $ */
28/* $Source: /usr/argo/sys/netiso/RCS/clnp_timer.c,v $ */
29
30#ifndef lint
31static char *rcsid = "$Header: clnp_timer.c,v 4.2 88/06/29 14:59:05 hagens Exp $";
32#endif lint
33
34#ifdef ISO
35
36#include "../h/types.h"
37#include "../h/param.h"
38#include "../h/mbuf.h"
39#include "../h/domain.h"
40#include "../h/protosw.h"
41#include "../h/socket.h"
42#include "../h/socketvar.h"
43#include "../h/errno.h"
44
45#include "../net/if.h"
46#include "../net/route.h"
47
48#include "../netiso/iso.h"
49#include "../netiso/clnp.h"
50#include "../netiso/clnp_stat.h"
51#include "../netiso/argo_debug.h"
52
53extern struct clnp_fragl *clnp_frags;
54
55/*
56 * FUNCTION: clnp_freefrags
57 *
58 * PURPOSE: Free the resources associated with a fragment
59 *
60 * RETURNS: pointer to next fragment in list of fragments
61 *
62 * SIDE EFFECTS:
63 *
64 * NOTES:
65 * TODO: send ER back to source
66 */
67struct clnp_fragl *
68clnp_freefrags(cfh)
69register struct clnp_fragl *cfh; /* fragment header to delete */
70{
71 struct clnp_fragl *next = cfh->cfl_next;
72 struct clnp_frag *cf;
73
74 /* free any frags hanging around */
75 cf = cfh->cfl_frags;
76 while (cf != NULL) {
77 struct clnp_frag *cf_next = cf->cfr_next;
78 m_freem(cf->cfr_data);
79 cf = cf_next;
80 }
81
82 /* free the copy of the header */
83 m_freem(cfh->cfl_orighdr);
84
85 if (clnp_frags == cfh) {
86 clnp_frags = cfh->cfl_next;
87 } else {
88 struct clnp_fragl *scan;
89
90 for (scan = clnp_frags; scan != NULL; scan = scan->cfl_next) {
91 if (scan->cfl_next == cfh) {
92 scan->cfl_next = cfh->cfl_next;
93 break;
94 }
95 }
96 }
97
98 /* free the fragment header */
99 m_freem(dtom(cfh));
100
101 return(next);
102}
103
104/*
105 * FUNCTION: clnp_slowtimo
106 *
107 * PURPOSE: clnp timer processing; if the ttl expires on a
108 * packet on the reassembly queue, discard it.
109 *
110 * RETURNS: none
111 *
112 * SIDE EFFECTS:
113 *
114 * NOTES:
115 */
116clnp_slowtimo()
117{
118 register struct clnp_fragl *cfh = clnp_frags;
119 int s = splnet();
120
121 while (cfh != NULL) {
122 if (--cfh->cfl_ttl == 0) {
123 cfh = clnp_freefrags(cfh);
124 } else {
125 cfh = cfh->cfl_next;
126 }
127 }
128 splx(s);
129}
130
131/*
132 * FUNCTION: clnp_drain
133 *
134 * PURPOSE: drain off all datagram fragments
135 *
136 * RETURNS: none
137 *
138 * SIDE EFFECTS:
139 *
140 * NOTES:
141 * TODO: should send back ER
142 */
143clnp_drain()
144{
145 register struct clnp_fragl *cfh = clnp_frags;
146
147 while (cfh != NULL)
148 cfh = clnp_freefrags(cfh);
149}
150
151#endif ISO