xref: /freebsd/usr.sbin/ppp/defs.h (revision 99e8005137088aafb1350e23b113d69b01b0820f)
1 /*
2  *	    Written by Toshiharu OHNO (tony-o@iij.ad.jp)
3  *
4  *   Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
5  *
6  * Redistribution and use in source and binary forms are permitted
7  * provided that the above copyright notice and this paragraph are
8  * duplicated in all such forms and that any documentation,
9  * advertising materials, and other materials related to such
10  * distribution and use acknowledge that the software was developed
11  * by the Internet Initiative Japan.  The name of the
12  * IIJ may not be used to endorse or promote products derived
13  * from this software without specific prior written permission.
14  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
15  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
16  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17  *
18  * $FreeBSD$
19  *
20  *	TODO:
21  */
22 
23 /* Check the following definitions for your machine environment */
24 #ifdef __FreeBSD__
25 # define  MODEM_LIST	"/dev/cuaa1\0/dev/cuaa0"	/* name of tty device */
26 #else
27 # ifdef __OpenBSD__
28 #  define MODEM_LIST	"/dev/cua01\0/dev/cua00"	/* name of tty device */
29 # else
30 #  define MODEM_LIST	"/dev/tty01\0/dev/tty00"	/* name of tty device */
31 # endif
32 #endif
33 #define NMODEMS		2
34 
35 #ifndef PPP_CONFDIR
36 #define PPP_CONFDIR	"/etc/ppp"
37 #endif
38 
39 #define TUN_NAME	"tun"
40 #define TUN_PREFIX	(_PATH_DEV TUN_NAME)	/* /dev/tun */
41 
42 #define MODEM_SPEED	B38400	/* tty speed */
43 #define	SERVER_PORT	3000	/* Base server port no. */
44 #define	MODEM_CTSRTS	1	/* Default (true): use CTS/RTS signals */
45 #define	RECONNECT_TIMEOUT 3	/* Default timer for carrier loss */
46 #define	DIAL_TIMEOUT	30	/* Default and Max random time to redial */
47 #define	DIAL_NEXT_TIMEOUT 3	/* Default Hold time to next number redial */
48 #define SCRIPT_LEN 512		/* Size of login/dial/hangup scripts */
49 #define LINE_LEN SCRIPT_LEN 	/* Size of lines */
50 #define DEVICE_LEN SCRIPT_LEN	/* Size of individual devices */
51 #define AUTHLEN 100 		/* Size of authname/authkey */
52 #define CHAPDIGESTLEN 100	/* Maximum chap digest */
53 #define CHAPCHALLENGELEN 48	/* Maximum chap challenge */
54 #define CHAPAUTHRESPONSELEN 48	/* Maximum chap authresponse (chap81) */
55 #define MAXARGS 40		/* How many args per config line */
56 #define NCP_IDLE_TIMEOUT 180	/* Drop all links */
57 #define CHOKED_TIMEOUT 120	/* Delete queued packets w/ blocked tun */
58 
59 #define MIN_LQRPERIOD 1		/* Minimum LQR frequency */
60 #define DEF_LQRPERIOD 30	/* Default LQR frequency */
61 #define MIN_FSMRETRY 1		/* Minimum FSM retry frequency */
62 #define DEF_FSMRETRY 3		/* FSM retry frequency */
63 #define DEF_FSMTRIES 5		/* Default max retries */
64 #define DEF_FSMAUTHTRIES 3	/* Default max auth retries */
65 #define DEF_IFQUEUE 30		/* Default interface queue size */
66 
67 #define	CONFFILE 	"ppp.conf"
68 #define	LINKUPFILE 	"ppp.linkup"
69 #define	LINKDOWNFILE 	"ppp.linkdown"
70 #define	SECRETFILE	"ppp.secret"
71 
72 #define	EX_SIG		-1
73 #define	EX_NORMAL	0
74 #define	EX_START	1
75 #define	EX_SOCK		2
76 #define	EX_MODEM	3
77 #define	EX_DIAL		4
78 #define	EX_DEAD		5
79 #define	EX_DONE		6
80 #define	EX_REBOOT	7
81 #define	EX_ERRDEAD	8
82 #define	EX_HANGUP	9
83 #define	EX_TERM		10
84 #define EX_NODIAL	11
85 #define EX_NOLOGIN	12
86 /* return values for -background mode, not really exits */
87 #define EX_REDIAL	13
88 #define EX_RECONNECT	14
89 
90 /* physical::type values (OR'd in bundle::phys_type) */
91 #define PHYS_NONE		0
92 #define PHYS_INTERACTIVE	1  /* Manual link */
93 #define PHYS_AUTO		2  /* Dial-on-demand link */
94 #define	PHYS_DIRECT		4  /* Incoming link, deleted when closed */
95 #define	PHYS_DEDICATED		8  /* Dedicated link */
96 #define	PHYS_DDIAL		16 /* Dial immediately, stay connected */
97 #define PHYS_BACKGROUND		32 /* Dial immediately, deleted when closed */
98 #define PHYS_FOREGROUND		64 /* Pseudo mode, same as background */
99 #define PHYS_ALL		127
100 
101 /* flags passed to findblank() and MakeArgs() */
102 #define PARSE_NORMAL	0
103 #define PARSE_REDUCE	1
104 #define PARSE_NOHASH	2
105 
106 #define ROUNDUP(x) ((x) ? (1 + (((x) - 1) | (sizeof(long) - 1))) : sizeof(long))
107 
108 #if defined(__NetBSD__) || __FreeBSD__ < 3
109 extern void randinit(void);
110 #else
111 #define random arc4random
112 #define randinit()
113 #endif
114 
115 extern ssize_t fullread(int, void *, size_t);
116 extern const char *mode2Nam(int);
117 extern int Nam2mode(const char *);
118 extern struct in_addr GetIpAddr(const char *);
119 extern int SpeedToInt(speed_t);
120 extern speed_t IntToSpeed(int);
121 extern char *findblank(char *, int);
122 extern int MakeArgs(char *, char **, int, int);
123 extern const char *NumStr(long, char *, size_t);
124 extern const char *HexStr(long, char *, size_t);
125 extern const char *ex_desc(int);
126 extern void SetTitle(const char *);
127 extern fd_set *mkfdset(void);
128 extern void zerofdset(fd_set *);
129