1 /*- 2 * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org> 3 * based on work by Toshiharu OHNO <tony-o@iij.ad.jp> 4 * Internet Initiative Japan, Inc (IIJ) 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * 28 * $FreeBSD$ 29 */ 30 31 /* Check the following definitions for your machine environment */ 32 #ifdef __FreeBSD__ 33 # define MODEM_LIST "/dev/cuaa1\0/dev/cuaa0" /* 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 #define ROUNDUP(x) ((x) ? (1 + (((x) - 1) | (sizeof(long) - 1))) : sizeof(long)) 115 116 #if defined(__NetBSD__) || __FreeBSD__ < 3 117 extern void randinit(void); 118 #else 119 #define random arc4random 120 #define randinit() 121 #endif 122 123 extern ssize_t fullread(int, void *, size_t); 124 extern const char *mode2Nam(int); 125 extern int Nam2mode(const char *); 126 extern struct in_addr GetIpAddr(const char *); 127 extern int SpeedToInt(speed_t); 128 extern speed_t IntToSpeed(int); 129 extern char *findblank(char *, int); 130 extern int MakeArgs(char *, char **, int, int); 131 extern const char *NumStr(long, char *, size_t); 132 extern const char *HexStr(long, char *, size_t); 133 extern const char *ex_desc(int); 134 extern void SetTitle(const char *); 135 extern fd_set *mkfdset(void); 136 extern void zerofdset(fd_set *); 137 extern void Concatinate(char *, size_t, int, const char *const *); 138