xref: /freebsd/usr.sbin/ppp/defs.h (revision 2e3f49888ec8851bafb22011533217487764fdb0)
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 
31 /* Check the following definitions for your machine environment */
32 #ifdef __FreeBSD__
33 # define  MODEM_LIST	"/dev/cuau1\0/dev/cuau0"	/* name of tty device */
34 #else
35 # ifdef __OpenBSD__
36 #  define MODEM_LIST	"/dev/cua01\0/dev/cua00"	/* name of tty device */
37 # else
38 #  define MODEM_LIST	"/dev/tty01\0/dev/tty00"	/* name of tty device */
39 # endif
40 #endif
41 #define NMODEMS		2
42 
43 #ifndef PPP_CONFDIR
44 #define PPP_CONFDIR	"/etc/ppp"
45 #endif
46 
47 #define TUN_NAME	"tun"
48 #define TUN_PREFIX	(_PATH_DEV TUN_NAME)	/* /dev/tun */
49 
50 #define MODEM_SPEED	B38400	/* tty speed */
51 #define	SERVER_PORT	3000	/* Base server port no. */
52 #define	MODEM_CTSRTS	1	/* Default (true): use CTS/RTS signals */
53 #define	RECONNECT_TIMEOUT 3	/* Default timer for carrier loss */
54 #define	DIAL_TIMEOUT	30	/* Default and Max random time to redial */
55 #define	DIAL_NEXT_TIMEOUT 3	/* Default Hold time to next number redial */
56 #define SCRIPT_LEN 512		/* Size of login/dial/hangup scripts */
57 #define LINE_LEN SCRIPT_LEN 	/* Size of lines */
58 #define DEVICE_LEN SCRIPT_LEN	/* Size of individual devices */
59 #define AUTHLEN 100 		/* Size of authname/authkey */
60 #define CHAPDIGESTLEN 100	/* Maximum chap digest */
61 #define CHAPCHALLENGELEN 48	/* Maximum chap challenge */
62 #define CHAPAUTHRESPONSELEN 48	/* Maximum chap authresponse (chap81) */
63 #define MAXARGS 40		/* How many args per config line */
64 #define NCP_IDLE_TIMEOUT 180	/* Drop all links */
65 #define CHOKED_TIMEOUT 120	/* Delete queued packets w/ blocked tun */
66 
67 #define MIN_LQRPERIOD 1		/* Minimum LQR frequency */
68 #define DEF_LQRPERIOD 30	/* Default LQR frequency */
69 #define MIN_FSMRETRY 1		/* Minimum FSM retry frequency */
70 #define DEF_FSMRETRY 3		/* FSM retry frequency */
71 #define DEF_FSMTRIES 5		/* Default max retries */
72 #define DEF_FSMAUTHTRIES 3	/* Default max auth retries */
73 #define DEF_IFQUEUE 30		/* Default interface queue size */
74 
75 #define	CONFFILE 	"ppp.conf"
76 #define	LINKUPFILE 	"ppp.linkup"
77 #define	LINKDOWNFILE 	"ppp.linkdown"
78 #define	SECRETFILE	"ppp.secret"
79 
80 #define	EX_SIG		-1
81 #define	EX_NORMAL	0
82 #define	EX_START	1
83 #define	EX_SOCK		2
84 #define	EX_MODEM	3
85 #define	EX_DIAL		4
86 #define	EX_DEAD		5
87 #define	EX_DONE		6
88 #define	EX_REBOOT	7
89 #define	EX_ERRDEAD	8
90 #define	EX_HANGUP	9
91 #define	EX_TERM		10
92 #define EX_NODIAL	11
93 #define EX_NOLOGIN	12
94 /* return values for -background mode, not really exits */
95 #define EX_REDIAL	13
96 #define EX_RECONNECT	14
97 
98 /* physical::type values (OR'd in bundle::phys_type) */
99 #define PHYS_NONE		0
100 #define PHYS_INTERACTIVE	1  /* Manual link */
101 #define PHYS_AUTO		2  /* Dial-on-demand link */
102 #define	PHYS_DIRECT		4  /* Incoming link, deleted when closed */
103 #define	PHYS_DEDICATED		8  /* Dedicated link */
104 #define	PHYS_DDIAL		16 /* Dial immediately, stay connected */
105 #define PHYS_BACKGROUND		32 /* Dial immediately, deleted when closed */
106 #define PHYS_FOREGROUND		64 /* Pseudo mode, same as background */
107 #define PHYS_ALL		127
108 
109 /* flags passed to findblank() and MakeArgs() */
110 #define PARSE_NORMAL	0
111 #define PARSE_REDUCE	1
112 #define PARSE_NOHASH	2
113 
114 /* flags passed to loadmodules */
115 #define	LOAD_QUIETLY	1
116 #define	LOAD_VERBOSLY	2
117 
118 #define ROUNDUP(x) ((x) ? (1 + (((x) - 1) | (sizeof(long) - 1))) : sizeof(long))
119 
120 #define NCP_ASCIIBUFFERSIZE	52
121 
122 #ifdef __NetBSD__
123 extern void randinit(void);
124 #else
125 #define random arc4random
126 #define randinit()
127 #endif
128 
129 extern ssize_t fullread(int, void *, size_t);
130 extern const char *mode2Nam(int);
131 extern int Nam2mode(const char *);
132 extern struct in_addr GetIpAddr(const char *);
133 extern unsigned SpeedToUnsigned(speed_t);
134 extern speed_t UnsignedToSpeed(unsigned);
135 extern char *findblank(char *, int);
136 extern int MakeArgs(char *, char **, int, int);
137 extern const char *NumStr(long, char *, size_t);
138 extern const char *HexStr(long, char *, size_t);
139 extern const char *ex_desc(int);
140 extern void SetTitle(const char *);
141 extern fd_set *mkfdset(void);
142 extern void zerofdset(fd_set *);
143 extern void Concatinate(char *, size_t, int, const char *const *);
144 extern int loadmodules(int, const char *, ...);
145