2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
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)
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
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.
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
33 /* Check the following definitions for your machine environment */
35 # define MODEM_LIST "/dev/cuau1\0/dev/cuau0" /* name of tty device */
38 # define MODEM_LIST "/dev/cua01\0/dev/cua00" /* name of tty device */
40 # define MODEM_LIST "/dev/tty01\0/dev/tty00" /* name of tty device */
46 #define PPP_CONFDIR "/etc/ppp"
49 #define TUN_NAME "tun"
50 #define TUN_PREFIX (_PATH_DEV TUN_NAME) /* /dev/tun */
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 */
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 */
77 #define CONFFILE "ppp.conf"
78 #define LINKUPFILE "ppp.linkup"
79 #define LINKDOWNFILE "ppp.linkdown"
80 #define SECRETFILE "ppp.secret"
96 /* return values for -background mode, not really exits */
98 #define EX_RECONNECT 14
100 /* physical::type values (OR'd in bundle::phys_type) */
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 */
111 /* flags passed to findblank() and MakeArgs() */
112 #define PARSE_NORMAL 0
113 #define PARSE_REDUCE 1
114 #define PARSE_NOHASH 2
116 /* flags passed to loadmodules */
117 #define LOAD_QUIETLY 1
118 #define LOAD_VERBOSLY 2
120 #define ROUNDUP(x) ((x) ? (1 + (((x) - 1) | (sizeof(long) - 1))) : sizeof(long))
122 #define NCP_ASCIIBUFFERSIZE 52
125 extern void randinit(void);
127 #define random arc4random
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 *, ...);