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 $ */ 2936376Ssklower 3036376Ssklower #ifndef lint 3136376Ssklower static char *rcsid = "$Header: clnp_timer.c,v 4.2 88/06/29 14:59:05 hagens Exp $"; 3236376Ssklower #endif lint 3336376Ssklower 3436376Ssklower #ifdef ISO 3536376Ssklower 36*37469Ssklower #include "types.h" 37*37469Ssklower #include "param.h" 38*37469Ssklower #include "mbuf.h" 39*37469Ssklower #include "domain.h" 40*37469Ssklower #include "protosw.h" 41*37469Ssklower #include "socket.h" 42*37469Ssklower #include "socketvar.h" 43*37469Ssklower #include "errno.h" 4436376Ssklower 4536376Ssklower #include "../net/if.h" 4636376Ssklower #include "../net/route.h" 4736376Ssklower 48*37469Ssklower #include "iso.h" 49*37469Ssklower #include "clnp.h" 50*37469Ssklower #include "clnp_stat.h" 51*37469Ssklower #include "argo_debug.h" 5236376Ssklower 5336376Ssklower extern struct clnp_fragl *clnp_frags; 5436376Ssklower 5536376Ssklower /* 5636376Ssklower * FUNCTION: clnp_freefrags 5736376Ssklower * 5836376Ssklower * PURPOSE: Free the resources associated with a fragment 5936376Ssklower * 6036376Ssklower * RETURNS: pointer to next fragment in list of fragments 6136376Ssklower * 6236376Ssklower * SIDE EFFECTS: 6336376Ssklower * 6436376Ssklower * NOTES: 6536376Ssklower * TODO: send ER back to source 6636376Ssklower */ 6736376Ssklower struct clnp_fragl * 6836376Ssklower clnp_freefrags(cfh) 6936376Ssklower register struct clnp_fragl *cfh; /* fragment header to delete */ 7036376Ssklower { 7136376Ssklower struct clnp_fragl *next = cfh->cfl_next; 7236376Ssklower struct clnp_frag *cf; 7336376Ssklower 7436376Ssklower /* free any frags hanging around */ 7536376Ssklower cf = cfh->cfl_frags; 7636376Ssklower while (cf != NULL) { 7736376Ssklower struct clnp_frag *cf_next = cf->cfr_next; 7836376Ssklower m_freem(cf->cfr_data); 7936376Ssklower cf = cf_next; 8036376Ssklower } 8136376Ssklower 8236376Ssklower /* free the copy of the header */ 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); 12436376Ssklower } else { 12536376Ssklower cfh = cfh->cfl_next; 12636376Ssklower } 12736376Ssklower } 12836376Ssklower splx(s); 12936376Ssklower } 13036376Ssklower 13136376Ssklower /* 13236376Ssklower * FUNCTION: clnp_drain 13336376Ssklower * 13436376Ssklower * PURPOSE: drain off all datagram fragments 13536376Ssklower * 13636376Ssklower * RETURNS: none 13736376Ssklower * 13836376Ssklower * SIDE EFFECTS: 13936376Ssklower * 14036376Ssklower * NOTES: 14136376Ssklower * TODO: should send back ER 14236376Ssklower */ 14336376Ssklower clnp_drain() 14436376Ssklower { 14536376Ssklower register struct clnp_fragl *cfh = clnp_frags; 14636376Ssklower 14736376Ssklower while (cfh != NULL) 14836376Ssklower cfh = clnp_freefrags(cfh); 14936376Ssklower } 15036376Ssklower 15136376Ssklower #endif ISO 152