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