xref: /csrg-svn/sys/netiso/clnp_timer.c (revision 39195)
136376Ssklower /***********************************************************
236376Ssklower 		Copyright IBM Corporation 1987
336376Ssklower 
436376Ssklower                       All Rights Reserved
536376Ssklower 
636376Ssklower Permission to use, copy, modify, and distribute this software and its
736376Ssklower documentation for any purpose and without fee is hereby granted,
836376Ssklower provided that the above copyright notice appear in all copies and that
936376Ssklower both that copyright notice and this permission notice appear in
1036376Ssklower supporting documentation, and that the name of IBM not be
1136376Ssklower used in advertising or publicity pertaining to distribution of the
1236376Ssklower software without specific, written prior permission.
1336376Ssklower 
1436376Ssklower IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
1536376Ssklower ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
1636376Ssklower IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
1736376Ssklower ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
1836376Ssklower WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
1936376Ssklower ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
2036376Ssklower SOFTWARE.
2136376Ssklower 
2236376Ssklower ******************************************************************/
2336376Ssklower 
2436376Ssklower /*
2536376Ssklower  * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison
2636376Ssklower  */
2736376Ssklower /* $Header: clnp_timer.c,v 4.2 88/06/29 14:59:05 hagens Exp $ */
2836376Ssklower /* $Source: /usr/argo/sys/netiso/RCS/clnp_timer.c,v $ */
29*39195Ssklower /*	@(#)clnp_timer.c	7.4 (Berkeley) 09/22/89 */
3036376Ssklower 
3136376Ssklower #ifndef lint
3236376Ssklower static char *rcsid = "$Header: clnp_timer.c,v 4.2 88/06/29 14:59:05 hagens Exp $";
3336376Ssklower #endif lint
3436376Ssklower 
3537469Ssklower #include "param.h"
3637469Ssklower #include "mbuf.h"
3737469Ssklower #include "domain.h"
3837469Ssklower #include "protosw.h"
3937469Ssklower #include "socket.h"
4037469Ssklower #include "socketvar.h"
4137469Ssklower #include "errno.h"
4236376Ssklower 
4336376Ssklower #include "../net/if.h"
4436376Ssklower #include "../net/route.h"
4536376Ssklower 
4637469Ssklower #include "iso.h"
4737469Ssklower #include "clnp.h"
4837469Ssklower #include "clnp_stat.h"
4937469Ssklower #include "argo_debug.h"
5036376Ssklower 
5136376Ssklower extern struct clnp_fragl *clnp_frags;
5236376Ssklower 
5336376Ssklower /*
5436376Ssklower  * FUNCTION:		clnp_freefrags
5536376Ssklower  *
5636376Ssklower  * PURPOSE:			Free the resources associated with a fragment
5736376Ssklower  *
5836376Ssklower  * RETURNS:			pointer to next fragment in list of fragments
5936376Ssklower  *
6036376Ssklower  * SIDE EFFECTS:
6136376Ssklower  *
6236376Ssklower  * NOTES:
6336376Ssklower  *			TODO: send ER back to source
6436376Ssklower  */
6536376Ssklower struct clnp_fragl *
6636376Ssklower clnp_freefrags(cfh)
6736376Ssklower register struct clnp_fragl	*cfh;	/* fragment header to delete */
6836376Ssklower {
6936376Ssklower 	struct clnp_fragl	*next = cfh->cfl_next;
7036376Ssklower 	struct clnp_frag	*cf;
7136376Ssklower 
7236376Ssklower 	/* free any frags hanging around */
7336376Ssklower 	cf = cfh->cfl_frags;
7436376Ssklower 	while (cf != NULL) {
7536376Ssklower 		struct clnp_frag	*cf_next = cf->cfr_next;
76*39195Ssklower 		INCSTAT(cns_fragdropped);
7736376Ssklower 		m_freem(cf->cfr_data);
7836376Ssklower 		cf = cf_next;
7936376Ssklower 	}
8036376Ssklower 
8136376Ssklower 	/* free the copy of the header */
82*39195Ssklower 	INCSTAT(cns_fragdropped);
8336376Ssklower 	m_freem(cfh->cfl_orighdr);
8436376Ssklower 
8536376Ssklower 	if (clnp_frags == cfh) {
8636376Ssklower 		clnp_frags = cfh->cfl_next;
8736376Ssklower 	} else {
8836376Ssklower 		struct clnp_fragl	*scan;
8936376Ssklower 
9036376Ssklower 		for (scan = clnp_frags; scan != NULL; scan = scan->cfl_next) {
9136376Ssklower 			if (scan->cfl_next == cfh) {
9236376Ssklower 				scan->cfl_next = cfh->cfl_next;
9336376Ssklower 				break;
9436376Ssklower 			}
9536376Ssklower 		}
9636376Ssklower 	}
9736376Ssklower 
9836376Ssklower 	/* free the fragment header */
9936376Ssklower 	m_freem(dtom(cfh));
10036376Ssklower 
10136376Ssklower 	return(next);
10236376Ssklower }
10336376Ssklower 
10436376Ssklower /*
10536376Ssklower  * FUNCTION:		clnp_slowtimo
10636376Ssklower  *
10736376Ssklower  * PURPOSE:			clnp timer processing; if the ttl expires on a
10836376Ssklower  *					packet on the reassembly queue, discard it.
10936376Ssklower  *
11036376Ssklower  * RETURNS:			none
11136376Ssklower  *
11236376Ssklower  * SIDE EFFECTS:
11336376Ssklower  *
11436376Ssklower  * NOTES:
11536376Ssklower  */
11636376Ssklower clnp_slowtimo()
11736376Ssklower {
11836376Ssklower 	register struct clnp_fragl	*cfh = clnp_frags;
11936376Ssklower 	int s = splnet();
12036376Ssklower 
12136376Ssklower 	while (cfh != NULL) {
12236376Ssklower 		if (--cfh->cfl_ttl == 0) {
12336376Ssklower 			cfh = clnp_freefrags(cfh);
124*39195Ssklower 			INCSTAT(cns_fragtimeout);
12536376Ssklower 		} else {
12636376Ssklower 			cfh = cfh->cfl_next;
12736376Ssklower 		}
12836376Ssklower 	}
12936376Ssklower 	splx(s);
13036376Ssklower }
13136376Ssklower 
13236376Ssklower /*
13336376Ssklower  * FUNCTION:		clnp_drain
13436376Ssklower  *
13536376Ssklower  * PURPOSE:			drain off all datagram fragments
13636376Ssklower  *
13736376Ssklower  * RETURNS:			none
13836376Ssklower  *
13936376Ssklower  * SIDE EFFECTS:
14036376Ssklower  *
14136376Ssklower  * NOTES:
14236376Ssklower  *	TODO: should send back ER
14336376Ssklower  */
14436376Ssklower clnp_drain()
14536376Ssklower {
14636376Ssklower 	register struct clnp_fragl	*cfh = clnp_frags;
14736376Ssklower 
14836376Ssklower 	while (cfh != NULL)
14936376Ssklower 		cfh = clnp_freefrags(cfh);
15036376Ssklower }
151