3 * ===================================
4 * HARP | Host ATM Research Platform
5 * ===================================
8 * This Host ATM Research Platform ("HARP") file (the "Software") is
9 * made available by Network Computing Services, Inc. ("NetworkCS")
10 * "AS IS". NetworkCS does not provide maintenance, improvements or
11 * support of any kind.
13 * NETWORKCS MAKES NO WARRANTIES OR REPRESENTATIONS, EXPRESS OR IMPLIED,
14 * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
15 * AND FITNESS FOR A PARTICULAR PURPOSE, AS TO ANY ELEMENT OF THE
16 * SOFTWARE OR ANY SUPPORT PROVIDED IN CONNECTION WITH THIS SOFTWARE.
17 * In no event shall NetworkCS be responsible for any damages, including
18 * but not limited to consequential damages, arising from or relating to
19 * any use of the Software or related support.
21 * Copyright 1994-1998 Network Computing Services, Inc.
23 * Copies of this Software may be made, however, the above copyright
24 * notice must be reproduced on all copies.
31 * User Space Library Functions
32 * ----------------------------
38 #include <sys/types.h>
39 #include <sys/param.h>
40 #include <sys/socket.h>
42 #include <netinet/in.h>
43 #include <netatm/port.h>
44 #include <netatm/queue.h>
45 #include <netatm/atm.h>
46 #include <netatm/atm_if.h>
47 #include <netatm/atm_sap.h>
48 #include <netatm/atm_sys.h>
49 #include <netatm/atm_ioctl.h>
57 __RCSID("@(#) $FreeBSD$");
61 Harp_timer *harp_timer_head;
66 * Process a HARP timer tick
68 * This function is called via the SIGALRM signal. It increments
69 * harp_timer_exec. The user should check this flag frequently and
70 * call timer_proc when it is set.
92 * This function is called after a SIGALRM signal is posted. It runs
93 * down the list of timer entries, calling the specified functions
94 * for any timers that have expired.
110 * Reset marks in all timers on the queue
112 for (htp = harp_timer_head; htp; htp = htp->ht_next) {
117 * Run through timer chain decrementing each timer.
118 * If an expired timer is found, take the timer block
119 * off the chain and call the specified function. A
120 * timer's action can result in other timers being
121 * cancelled (taken off the queue), so every time we
122 * call a user function, we start over from the top of
126 for (htp = harp_timer_head; htp; htp = htp->ht_next) {
128 * Make sure we only process each entry once and
129 * don't process entries that are put on the queue
130 * by user functions we call for this tick
132 if (htp->ht_mark == -1) {
134 * Decrement the timer and mark that we've
135 * processed the entry
137 htp->ht_ticks -= harp_timer_exec;
141 * Check whether the timer is expired
143 if (htp->ht_ticks <= 0) {
145 * Unlink the timer block and call
149 UNLINK(htp, Harp_timer, harp_timer_head,
162 * Reset the timer exec flag
171 * Set up the SIGALRM signal handler and set up the real-time
172 * timer to tick once per second.
179 * errno reason for failure
186 struct itimerval timeval;
189 * Clear the timer flag
194 * Set up signal handler
196 if ((int)signal(SIGALRM, timer_tick) == -1) {
203 timeval.it_value.tv_sec = 1;
204 timeval.it_value.tv_usec = 0;
205 timeval.it_interval.tv_sec = 1;
206 timeval.it_interval.tv_usec = 0;
208 if (setitimer(ITIMER_REAL, &timeval,
209 (struct itimerval *)0) == -1) {
211 (void)signal(SIGALRM, SIG_DFL);
219 * Block timers from firing
221 * Block the SIGALRM signal.
227 * mask the previous blocked signal mask
234 * Block the SIGALRM signal
236 return(sigblock(sigmask(SIGALRM)));
243 * Restore the signal mask (presumably one that was returned by
247 * mask the signal mask to be restored
250 * mask the previous blocked signal mask
258 * Set the signal mask