xref: /original-bsd/sys/netiso/clnp_timer.c (revision 82ca1924)
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 
30 #ifndef lint
31 static 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 "types.h"
37 #include "param.h"
38 #include "mbuf.h"
39 #include "domain.h"
40 #include "protosw.h"
41 #include "socket.h"
42 #include "socketvar.h"
43 #include "errno.h"
44 
45 #include "../net/if.h"
46 #include "../net/route.h"
47 
48 #include "iso.h"
49 #include "clnp.h"
50 #include "clnp_stat.h"
51 #include "argo_debug.h"
52 
53 extern 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  */
67 struct clnp_fragl *
68 clnp_freefrags(cfh)
69 register 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  */
116 clnp_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  */
143 clnp_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
152