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