xref: /freebsd/usr.sbin/ppp/timer.h (revision 1de7b4b805ddbf2429da511c053686ac4591ed89)
165309e5cSBrian Somers /*-
2*1de7b4b8SPedro F. Giffuni  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3*1de7b4b8SPedro F. Giffuni  *
465309e5cSBrian Somers  * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
565309e5cSBrian Somers  *          based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
665309e5cSBrian Somers  *                           Internet Initiative Japan, Inc (IIJ)
765309e5cSBrian Somers  * All rights reserved.
875240ed1SBrian Somers  *
965309e5cSBrian Somers  * Redistribution and use in source and binary forms, with or without
1065309e5cSBrian Somers  * modification, are permitted provided that the following conditions
1165309e5cSBrian Somers  * are met:
1265309e5cSBrian Somers  * 1. Redistributions of source code must retain the above copyright
1365309e5cSBrian Somers  *    notice, this list of conditions and the following disclaimer.
1465309e5cSBrian Somers  * 2. Redistributions in binary form must reproduce the above copyright
1565309e5cSBrian Somers  *    notice, this list of conditions and the following disclaimer in the
1665309e5cSBrian Somers  *    documentation and/or other materials provided with the distribution.
1775240ed1SBrian Somers  *
1865309e5cSBrian Somers  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1965309e5cSBrian Somers  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2065309e5cSBrian Somers  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2165309e5cSBrian Somers  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2265309e5cSBrian Somers  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2365309e5cSBrian Somers  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2465309e5cSBrian Somers  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2565309e5cSBrian Somers  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2665309e5cSBrian Somers  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2765309e5cSBrian Somers  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2865309e5cSBrian Somers  * SUCH DAMAGE.
2975240ed1SBrian Somers  *
3097d92980SPeter Wemm  * $FreeBSD$
3175240ed1SBrian Somers  */
3275240ed1SBrian Somers 
333b0f8d2eSBrian Somers #define	TICKUNIT	100000			/* usec's per Unit */
343b0f8d2eSBrian Somers #define	SECTICKS	(1000000/TICKUNIT)	/* Units per second */
3575240ed1SBrian Somers 
3675240ed1SBrian Somers struct pppTimer {
3775240ed1SBrian Somers   int state;
383b0f8d2eSBrian Somers   const char *name;
3975240ed1SBrian Somers   u_long rest;			/* Ticks to expire */
4075240ed1SBrian Somers   u_long load;			/* Initial load value */
41b6e82f33SBrian Somers   void (*func)(void *);		/* Function called when timer is expired */
4275240ed1SBrian Somers   void *arg;			/* Argument passed to timeout function */
4375240ed1SBrian Somers   struct pppTimer *next;	/* Link to next timer */
4475240ed1SBrian Somers   struct pppTimer *enext;	/* Link to next expired timer */
4575240ed1SBrian Somers };
4675240ed1SBrian Somers 
4775240ed1SBrian Somers #define	TIMER_STOPPED	0
4875240ed1SBrian Somers #define	TIMER_RUNNING	1
4975240ed1SBrian Somers #define	TIMER_EXPIRED	2
5075240ed1SBrian Somers 
51b6217683SBrian Somers struct prompt;
526eaa6ac5SBrian Somers 
53dd7e2610SBrian Somers extern void timer_Start(struct pppTimer *);
54dd7e2610SBrian Somers extern void timer_Stop(struct pppTimer *);
557e778f13SBrian Somers extern void timer_InitService(int);
56dd7e2610SBrian Somers extern void timer_TermService(void);
57dd7e2610SBrian Somers extern void timer_Show(int LogLevel, struct prompt *);
58