178189Sbrian/*-
278189Sbrian * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
378189Sbrian *          based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
478189Sbrian *                           Internet Initiative Japan, Inc (IIJ)
578189Sbrian * All rights reserved.
630715Sbrian *
778189Sbrian * Redistribution and use in source and binary forms, with or without
878189Sbrian * modification, are permitted provided that the following conditions
978189Sbrian * are met:
1078189Sbrian * 1. Redistributions of source code must retain the above copyright
1178189Sbrian *    notice, this list of conditions and the following disclaimer.
1278189Sbrian * 2. Redistributions in binary form must reproduce the above copyright
1378189Sbrian *    notice, this list of conditions and the following disclaimer in the
1478189Sbrian *    documentation and/or other materials provided with the distribution.
1530715Sbrian *
1678189Sbrian * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1778189Sbrian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1878189Sbrian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1978189Sbrian * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2078189Sbrian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2178189Sbrian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2278189Sbrian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2378189Sbrian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2478189Sbrian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2578189Sbrian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2678189Sbrian * SUCH DAMAGE.
2730715Sbrian *
2850479Speter * $FreeBSD: releng/11.0/usr.sbin/ppp/timer.h 78189 2001-06-13 21:52:19Z brian $
2930715Sbrian */
3030715Sbrian
3136285Sbrian#define	TICKUNIT	100000			/* usec's per Unit */
3236285Sbrian#define	SECTICKS	(1000000/TICKUNIT)	/* Units per second */
3330715Sbrian
3430715Sbrianstruct pppTimer {
3530715Sbrian  int state;
3636285Sbrian  const char *name;
3730715Sbrian  u_long rest;			/* Ticks to expire */
3830715Sbrian  u_long load;			/* Initial load value */
3931343Sbrian  void (*func)(void *);		/* Function called when timer is expired */
4030715Sbrian  void *arg;			/* Argument passed to timeout function */
4130715Sbrian  struct pppTimer *next;	/* Link to next timer */
4230715Sbrian  struct pppTimer *enext;	/* Link to next expired timer */
4330715Sbrian};
4430715Sbrian
4530715Sbrian#define	TIMER_STOPPED	0
4630715Sbrian#define	TIMER_RUNNING	1
4730715Sbrian#define	TIMER_EXPIRED	2
4830715Sbrian
4936285Sbrianstruct prompt;
5030733Sbrian
5136285Sbrianextern void timer_Start(struct pppTimer *);
5236285Sbrianextern void timer_Stop(struct pppTimer *);
5341799Sbrianextern void timer_InitService(int);
5436285Sbrianextern void timer_TermService(void);
5536285Sbrianextern void timer_Show(int LogLevel, struct prompt *);
56