timer.c (3b0f8d2ed641ceeded11c0d3f253b0cacbf00880) timer.c (b6217683dc0269a53b799399522dbdfb5a4919cc)
1/*
2 * PPP Timer Processing Module
3 *
4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp)
5 *
6 * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
7 *
8 * Redistribution and use in source and binary forms are permitted
9 * provided that the above copyright notice and this paragraph are
10 * duplicated in all such forms and that any documentation,
11 * advertising materials, and other materials related to such
12 * distribution and use acknowledge that the software was developed
13 * by the Internet Initiative Japan, Inc. The name of the
14 * IIJ may not be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 *
1/*
2 * PPP Timer Processing Module
3 *
4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp)
5 *
6 * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
7 *
8 * Redistribution and use in source and binary forms are permitted
9 * provided that the above copyright notice and this paragraph are
10 * duplicated in all such forms and that any documentation,
11 * advertising materials, and other materials related to such
12 * distribution and use acknowledge that the software was developed
13 * by the Internet Initiative Japan, Inc. The name of the
14 * IIJ may not be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 *
20 * $Id: timer.c,v 1.27 1998/01/21 02:15:29 brian Exp $
20 * $Id: timer.c,v 1.27.2.1 1998/04/03 19:21:54 brian Exp $
21 *
22 * TODO:
23 */
24
25#include <errno.h>
26#include <signal.h>
27#include <stdio.h>
28#include <sys/time.h>

--- 121 unchanged lines hidden (view full) ---

150{
151 struct pppTimer *tp, *exp, *wt;
152
153 if (LogIsKept(LogDEBUG)) {
154 static time_t t;
155 time_t n = time(NULL); /* Only show timers every second */
156
157 if (n > t)
21 *
22 * TODO:
23 */
24
25#include <errno.h>
26#include <signal.h>
27#include <stdio.h>
28#include <sys/time.h>

--- 121 unchanged lines hidden (view full) ---

150{
151 struct pppTimer *tp, *exp, *wt;
152
153 if (LogIsKept(LogDEBUG)) {
154 static time_t t;
155 time_t n = time(NULL); /* Only show timers every second */
156
157 if (n > t)
158 ShowTimers(LogDEBUG);
158 ShowTimers(LogDEBUG, NULL);
159 t = n;
160 }
161 tp = TimerList;
162 if (tp) {
163 tp->rest--;
164 if (tp->rest == 0) {
165
166 /*

--- 28 unchanged lines hidden (view full) ---

195 */
196 exp = exp->enext;
197 }
198 }
199 }
200}
201
202void
159 t = n;
160 }
161 tp = TimerList;
162 if (tp) {
163 tp->rest--;
164 if (tp->rest == 0) {
165
166 /*

--- 28 unchanged lines hidden (view full) ---

195 */
196 exp = exp->enext;
197 }
198 }
199 }
200}
201
202void
203ShowTimers(int LogLevel)
203ShowTimers(int LogLevel, struct prompt *prompt)
204{
205 struct pppTimer *pt;
206 int rest = 0;
207
208#define SECS(val) ((val) / SECTICKS)
209#define HSECS(val) (((val) % SECTICKS) * 100 / SECTICKS)
210#define DISP \
211 "%s timer[%p]: freq = %d.%02ds, next = %d.%02ds, state = %s\n", \
212 pt->name, pt, SECS(pt->load), HSECS(pt->load), SECS(rest), \
213 HSECS(rest), tState2Nam(pt->state)
214
204{
205 struct pppTimer *pt;
206 int rest = 0;
207
208#define SECS(val) ((val) / SECTICKS)
209#define HSECS(val) (((val) % SECTICKS) * 100 / SECTICKS)
210#define DISP \
211 "%s timer[%p]: freq = %d.%02ds, next = %d.%02ds, state = %s\n", \
212 pt->name, pt, SECS(pt->load), HSECS(pt->load), SECS(rest), \
213 HSECS(rest), tState2Nam(pt->state)
214
215 if (LogIsKept(LogLevel))
215 if (!prompt)
216 LogPrintf(LogLevel, "---- Begin of Timer Service List---\n");
217
218 for (pt = TimerList; pt; pt = pt->next) {
219 rest += pt->rest;
216 LogPrintf(LogLevel, "---- Begin of Timer Service List---\n");
217
218 for (pt = TimerList; pt; pt = pt->next) {
219 rest += pt->rest;
220 if (LogIsKept(LogLevel))
220 if (prompt)
221 prompt_Printf(prompt, DISP);
222 else
221 LogPrintf(LogLevel, DISP);
223 LogPrintf(LogLevel, DISP);
222 else if (LogLevel < LogMIN)
223 prompt_Printf(&prompt, DISP);
224 }
225
224 }
225
226 if (LogIsKept(LogLevel))
226 if (!prompt)
227 LogPrintf(LogLevel, "---- End of Timer Service List ---\n");
228}
229
230static void
231nointr_dosleep(u_int sec, u_int usec)
232{
233 struct timeval to, st, et;
234

--- 74 unchanged lines hidden ---
227 LogPrintf(LogLevel, "---- End of Timer Service List ---\n");
228}
229
230static void
231nointr_dosleep(u_int sec, u_int usec)
232{
233 struct timeval to, st, et;
234

--- 74 unchanged lines hidden ---