xref: /freebsd/usr.sbin/ppp/defs.h (revision 37c8ee8847faa53432809cae2ecc11b80c4eab2f)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
5  *          based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
6  *                           Internet Initiative Japan, Inc (IIJ)
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  *
30  * $FreeBSD$
31  */
32 
33 /* Check the following definitions for your machine environment */
34 #ifdef __FreeBSD__
35 # define  MODEM_LIST	"/dev/cuau1\0/dev/cuau0"	/* name of tty device */
36 #else
37 # ifdef __OpenBSD__
38 #  define MODEM_LIST	"/dev/cua01\0/dev/cua00"	/* name of tty device */
39 # else
40 #  define MODEM_LIST	"/dev/tty01\0/dev/tty00"	/* name of tty device */
41 # endif
42 #endif
43 #define NMODEMS		2
44 
45 #ifndef PPP_CONFDIR
46 #define PPP_CONFDIR	"/etc/ppp"
47 #endif
48 
49 #define TUN_NAME	"tun"
50 #define TUN_PREFIX	(_PATH_DEV TUN_NAME)	/* /dev/tun */
51 
52 #define MODEM_SPEED	B38400	/* tty speed */
53 #define	SERVER_PORT	3000	/* Base server port no. */
54 #define	MODEM_CTSRTS	1	/* Default (true): use CTS/RTS signals */
55 #define	RECONNECT_TIMEOUT 3	/* Default timer for carrier loss */
56 #define	DIAL_TIMEOUT	30	/* Default and Max random time to redial */
57 #define	DIAL_NEXT_TIMEOUT 3	/* Default Hold time to next number redial */
58 #define SCRIPT_LEN 512		/* Size of login/dial/hangup scripts */
59 #define LINE_LEN SCRIPT_LEN 	/* Size of lines */
60 #define DEVICE_LEN SCRIPT_LEN	/* Size of individual devices */
61 #define AUTHLEN 100 		/* Size of authname/authkey */
62 #define CHAPDIGESTLEN 100	/* Maximum chap digest */
63 #define CHAPCHALLENGELEN 48	/* Maximum chap challenge */
64 #define CHAPAUTHRESPONSELEN 48	/* Maximum chap authresponse (chap81) */
65 #define MAXARGS 40		/* How many args per config line */
66 #define NCP_IDLE_TIMEOUT 180	/* Drop all links */
67 #define CHOKED_TIMEOUT 120	/* Delete queued packets w/ blocked tun */
68 
69 #define MIN_LQRPERIOD 1		/* Minimum LQR frequency */
70 #define DEF_LQRPERIOD 30	/* Default LQR frequency */
71 #define MIN_FSMRETRY 1		/* Minimum FSM retry frequency */
72 #define DEF_FSMRETRY 3		/* FSM retry frequency */
73 #define DEF_FSMTRIES 5		/* Default max retries */
74 #define DEF_FSMAUTHTRIES 3	/* Default max auth retries */
75 #define DEF_IFQUEUE 30		/* Default interface queue size */
76 
77 #define	CONFFILE 	"ppp.conf"
78 #define	LINKUPFILE 	"ppp.linkup"
79 #define	LINKDOWNFILE 	"ppp.linkdown"
80 #define	SECRETFILE	"ppp.secret"
81 
82 #define	EX_SIG		-1
83 #define	EX_NORMAL	0
84 #define	EX_START	1
85 #define	EX_SOCK		2
86 #define	EX_MODEM	3
87 #define	EX_DIAL		4
88 #define	EX_DEAD		5
89 #define	EX_DONE		6
90 #define	EX_REBOOT	7
91 #define	EX_ERRDEAD	8
92 #define	EX_HANGUP	9
93 #define	EX_TERM		10
94 #define EX_NODIAL	11
95 #define EX_NOLOGIN	12
96 /* return values for -background mode, not really exits */
97 #define EX_REDIAL	13
98 #define EX_RECONNECT	14
99 
100 /* physical::type values (OR'd in bundle::phys_type) */
101 #define PHYS_NONE		0
102 #define PHYS_INTERACTIVE	1  /* Manual link */
103 #define PHYS_AUTO		2  /* Dial-on-demand link */
104 #define	PHYS_DIRECT		4  /* Incoming link, deleted when closed */
105 #define	PHYS_DEDICATED		8  /* Dedicated link */
106 #define	PHYS_DDIAL		16 /* Dial immediately, stay connected */
107 #define PHYS_BACKGROUND		32 /* Dial immediately, deleted when closed */
108 #define PHYS_FOREGROUND		64 /* Pseudo mode, same as background */
109 #define PHYS_ALL		127
110 
111 /* flags passed to findblank() and MakeArgs() */
112 #define PARSE_NORMAL	0
113 #define PARSE_REDUCE	1
114 #define PARSE_NOHASH	2
115 
116 /* flags passed to loadmodules */
117 #define	LOAD_QUIETLY	1
118 #define	LOAD_VERBOSLY	2
119 
120 #define ROUNDUP(x) ((x) ? (1 + (((x) - 1) | (sizeof(long) - 1))) : sizeof(long))
121 
122 #define NCP_ASCIIBUFFERSIZE	52
123 
124 #ifdef __NetBSD__
125 extern void randinit(void);
126 #else
127 #define random arc4random
128 #define randinit()
129 #endif
130 
131 extern ssize_t fullread(int, void *, size_t);
132 extern const char *mode2Nam(int);
133 extern int Nam2mode(const char *);
134 extern struct in_addr GetIpAddr(const char *);
135 extern unsigned SpeedToUnsigned(speed_t);
136 extern speed_t UnsignedToSpeed(unsigned);
137 extern char *findblank(char *, int);
138 extern int MakeArgs(char *, char **, int, int);
139 extern const char *NumStr(long, char *, size_t);
140 extern const char *HexStr(long, char *, size_t);
141 extern const char *ex_desc(int);
142 extern void SetTitle(const char *);
143 extern fd_set *mkfdset(void);
144 extern void zerofdset(fd_set *);
145 extern void Concatinate(char *, size_t, int, const char *const *);
146 extern int loadmodules(int, const char *, ...);
147