xref: /freebsd/usr.sbin/ppp/defs.h (revision b3e7694832e81d7a904a10f525f8797b753bf0d3)
165309e5cSBrian Somers /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
31de7b4b8SPedro 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.
8af57ed9fSAtsushi Murai  *
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.
17af57ed9fSAtsushi Murai  *
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.
29af57ed9fSAtsushi Murai  */
30af57ed9fSAtsushi Murai 
313bf710a4SBrian Somers /* Check the following definitions for your machine environment */
3253c9f6c0SAtsushi Murai #ifdef __FreeBSD__
33839f11a4SEitan Adler # define  MODEM_LIST	"/dev/cuau1\0/dev/cuau0"	/* name of tty device */
3453c9f6c0SAtsushi Murai #else
3510a91a42SBrian Somers # ifdef __OpenBSD__
36a8d7acdcSBrian Somers #  define MODEM_LIST	"/dev/cua01\0/dev/cua00"	/* name of tty device */
3710a91a42SBrian Somers # else
38a8d7acdcSBrian Somers #  define MODEM_LIST	"/dev/tty01\0/dev/tty00"	/* name of tty device */
3953c9f6c0SAtsushi Murai # endif
4010a91a42SBrian Somers #endif
41a8d7acdcSBrian Somers #define NMODEMS		2
4275240ed1SBrian Somers 
437a66a36dSBrian Somers #ifndef PPP_CONFDIR
447a66a36dSBrian Somers #define PPP_CONFDIR	"/etc/ppp"
457a66a36dSBrian Somers #endif
46dd7e2610SBrian Somers 
471384bd27SBrian Somers #define TUN_NAME	"tun"
481384bd27SBrian Somers #define TUN_PREFIX	(_PATH_DEV TUN_NAME)	/* /dev/tun */
49565e35e5SBrian Somers 
50af57ed9fSAtsushi Murai #define MODEM_SPEED	B38400	/* tty speed */
51af57ed9fSAtsushi Murai #define	SERVER_PORT	3000	/* Base server port no. */
5275240ed1SBrian Somers #define	MODEM_CTSRTS	1	/* Default (true): use CTS/RTS signals */
53abff9baeSBrian Somers #define	RECONNECT_TIMEOUT 3	/* Default timer for carrier loss */
54e718d1d7SBrian Somers #define	DIAL_TIMEOUT	30	/* Default and Max random time to redial */
55e718d1d7SBrian Somers #define	DIAL_NEXT_TIMEOUT 3	/* Default Hold time to next number redial */
56e6923505SBrian Somers #define SCRIPT_LEN 512		/* Size of login/dial/hangup scripts */
57e6923505SBrian Somers #define LINE_LEN SCRIPT_LEN 	/* Size of lines */
58e6923505SBrian Somers #define DEVICE_LEN SCRIPT_LEN	/* Size of individual devices */
5958330d7bSBrian Somers #define AUTHLEN 100 		/* Size of authname/authkey */
60972a1bcfSBrian Somers #define CHAPDIGESTLEN 100	/* Maximum chap digest */
61972a1bcfSBrian Somers #define CHAPCHALLENGELEN 48	/* Maximum chap challenge */
62a8d604abSBrian Somers #define CHAPAUTHRESPONSELEN 48	/* Maximum chap authresponse (chap81) */
63b6e82f33SBrian Somers #define MAXARGS 40		/* How many args per config line */
64ab886ad0SBrian Somers #define NCP_IDLE_TIMEOUT 180	/* Drop all links */
656f8e9f0aSBrian Somers #define CHOKED_TIMEOUT 120	/* Delete queued packets w/ blocked tun */
661ae349f5Scvs2svn 
67e3771825SRoger Hardiman #define MIN_LQRPERIOD 1		/* Minimum LQR frequency */
6814593dfdSBrian Somers #define DEF_LQRPERIOD 30	/* Default LQR frequency */
69e3771825SRoger Hardiman #define MIN_FSMRETRY 1		/* Minimum FSM retry frequency */
70cd9647a1SBrian Somers #define DEF_FSMRETRY 3		/* FSM retry frequency */
71479508cfSBrian Somers #define DEF_FSMTRIES 5		/* Default max retries */
72479508cfSBrian Somers #define DEF_FSMAUTHTRIES 3	/* Default max auth retries */
736c1d6731SBrian Somers #define DEF_IFQUEUE 30		/* Default interface queue size */
74af57ed9fSAtsushi Murai 
75af57ed9fSAtsushi Murai #define	CONFFILE 	"ppp.conf"
7694b3022eSBrian Somers #define	LINKUPFILE 	"ppp.linkup"
7794b3022eSBrian Somers #define	LINKDOWNFILE 	"ppp.linkdown"
78af57ed9fSAtsushi Murai #define	SECRETFILE	"ppp.secret"
79af57ed9fSAtsushi Murai 
80368aee2bSBrian Somers #define	EX_SIG		-1
81af57ed9fSAtsushi Murai #define	EX_NORMAL	0
82af57ed9fSAtsushi Murai #define	EX_START	1
83af57ed9fSAtsushi Murai #define	EX_SOCK		2
84af57ed9fSAtsushi Murai #define	EX_MODEM	3
85af57ed9fSAtsushi Murai #define	EX_DIAL		4
86af57ed9fSAtsushi Murai #define	EX_DEAD		5
87af57ed9fSAtsushi Murai #define	EX_DONE		6
88af57ed9fSAtsushi Murai #define	EX_REBOOT	7
89af57ed9fSAtsushi Murai #define	EX_ERRDEAD	8
90b42135deSBrian Somers #define	EX_HANGUP	9
91b42135deSBrian Somers #define	EX_TERM		10
92b42135deSBrian Somers #define EX_NODIAL	11
93b42135deSBrian Somers #define EX_NOLOGIN	12
94b42135deSBrian Somers /* return values for -background mode, not really exits */
95b42135deSBrian Somers #define EX_REDIAL	13
96b42135deSBrian Somers #define EX_RECONNECT	14
97af57ed9fSAtsushi Murai 
98565e35e5SBrian Somers /* physical::type values (OR'd in bundle::phys_type) */
99dd0645c5SBrian Somers #define PHYS_NONE		0
10081358fa3SBrian Somers #define PHYS_INTERACTIVE	1  /* Manual link */
10181358fa3SBrian Somers #define PHYS_AUTO		2  /* Dial-on-demand link */
10281358fa3SBrian Somers #define	PHYS_DIRECT		4  /* Incoming link, deleted when closed */
10381358fa3SBrian Somers #define	PHYS_DEDICATED		8  /* Dedicated link */
10481358fa3SBrian Somers #define	PHYS_DDIAL		16 /* Dial immediately, stay connected */
10581358fa3SBrian Somers #define PHYS_BACKGROUND		32 /* Dial immediately, deleted when closed */
106f6a4e748SBrian Somers #define PHYS_FOREGROUND		64 /* Pseudo mode, same as background */
107f6a4e748SBrian Somers #define PHYS_ALL		127
10853c9f6c0SAtsushi Murai 
1095b78bdf8SBrian Somers /* flags passed to findblank() and MakeArgs() */
1105b78bdf8SBrian Somers #define PARSE_NORMAL	0
1115b78bdf8SBrian Somers #define PARSE_REDUCE	1
1125b78bdf8SBrian Somers #define PARSE_NOHASH	2
1135b78bdf8SBrian Somers 
114fb11a9c2SBrian Somers /* flags passed to loadmodules */
115fb11a9c2SBrian Somers #define	LOAD_QUIETLY	1
116fb11a9c2SBrian Somers #define	LOAD_VERBOSLY	2
117fb11a9c2SBrian Somers 
1186b457978SBrian Somers #define ROUNDUP(x) ((x) ? (1 + (((x) - 1) | (sizeof(long) - 1))) : sizeof(long))
1196b457978SBrian Somers 
1206cd3353bSEugene Grosbein #define NCP_ASCIIBUFFERSIZE	52
1216cd3353bSEugene Grosbein 
122fe24bdd4SRobert Millan #ifdef __NetBSD__
12375240ed1SBrian Somers extern void randinit(void);
1248507c35eSBrian Somers #else
1258507c35eSBrian Somers #define random arc4random
1268507c35eSBrian Somers #define randinit()
1278507c35eSBrian Somers #endif
1288507c35eSBrian Somers 
1296f384573SBrian Somers extern ssize_t fullread(int, void *, size_t);
130dd0645c5SBrian Somers extern const char *mode2Nam(int);
131dd0645c5SBrian Somers extern int Nam2mode(const char *);
13226baedc5SBrian Somers extern struct in_addr GetIpAddr(const char *);
133057f1760SBrian Somers extern unsigned SpeedToUnsigned(speed_t);
134057f1760SBrian Somers extern speed_t UnsignedToSpeed(unsigned);
1351bbd8362SBrian Somers extern char *findblank(char *, int);
136abab7303SBrian Somers extern int MakeArgs(char *, char **, int, int);
137d6d3eeabSBrian Somers extern const char *NumStr(long, char *, size_t);
138d6d3eeabSBrian Somers extern const char *HexStr(long, char *, size_t);
139b42135deSBrian Somers extern const char *ex_desc(int);
140ebe96675SBrian Somers extern void SetTitle(const char *);
1418a52f3ecSBrian Somers extern fd_set *mkfdset(void);
1428a52f3ecSBrian Somers extern void zerofdset(fd_set *);
14346df5aa7SBrian Somers extern void Concatinate(char *, size_t, int, const char *const *);
1445476d2e5SBrian Somers extern int loadmodules(int, const char *, ...);
145