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