1 |
1026 |
ivang |
/*
|
2 |
|
|
* pppd.h - PPP daemon global declarations.
|
3 |
|
|
*
|
4 |
|
|
* Copyright (c) 1989 Carnegie Mellon University.
|
5 |
|
|
* All rights reserved.
|
6 |
|
|
*
|
7 |
|
|
* Redistribution and use in source and binary forms are permitted
|
8 |
|
|
* provided that the above copyright notice and this paragraph are
|
9 |
|
|
* duplicated in all such forms and that any documentation,
|
10 |
|
|
* advertising materials, and other materials related to such
|
11 |
|
|
* distribution and use acknowledge that the software was developed
|
12 |
|
|
* by Carnegie Mellon University. The name of the
|
13 |
|
|
* University may not be used to endorse or promote products derived
|
14 |
|
|
* from this software without specific prior written permission.
|
15 |
|
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
16 |
|
|
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
17 |
|
|
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
18 |
|
|
*
|
19 |
|
|
* pppd.h,v 1.7 2002/02/27 22:43:31 joel Exp
|
20 |
|
|
*/
|
21 |
|
|
|
22 |
|
|
#ifndef __PPPD_H__
|
23 |
|
|
#define __PPPD_H__
|
24 |
|
|
|
25 |
|
|
#include <stdio.h> /* for FILE */
|
26 |
|
|
#include <limits.h> /* for NGROUPS_MAX */
|
27 |
|
|
#include <sys/param.h> /* for MAXPATHLEN and BSD4_4, if defined */
|
28 |
|
|
#include <sys/types.h> /* for u_int32_t, if defined */
|
29 |
|
|
#include <sys/time.h> /* for struct timeval */
|
30 |
|
|
#include <net/ppp_defs.h>
|
31 |
|
|
#include "rtemsdialer.h"
|
32 |
|
|
|
33 |
|
|
#if defined(__STDC__)
|
34 |
|
|
#include <stdarg.h>
|
35 |
|
|
#define __V(x) x
|
36 |
|
|
#else
|
37 |
|
|
#include <varargs.h>
|
38 |
|
|
#define __V(x) (va_alist) va_dcl
|
39 |
|
|
#define const
|
40 |
|
|
#define volatile
|
41 |
|
|
#endif
|
42 |
|
|
|
43 |
|
|
#ifdef INET6
|
44 |
|
|
#include "eui64.h"
|
45 |
|
|
#endif
|
46 |
|
|
|
47 |
|
|
/*
|
48 |
|
|
* Limits.
|
49 |
|
|
*/
|
50 |
|
|
|
51 |
|
|
#define NUM_PPP 1 /* One PPP interface supported (per process) */
|
52 |
|
|
#define MAXWORDLEN 1024 /* max length of word in file (incl null) */
|
53 |
|
|
#define MAXARGS 1 /* max # args to a command */
|
54 |
|
|
#define MAXNAMELEN 256 /* max length of hostname or name for auth */
|
55 |
|
|
#define MAXSECRETLEN 256 /* max length of password or secret */
|
56 |
|
|
|
57 |
|
|
/*
|
58 |
|
|
* Option descriptor structure.
|
59 |
|
|
*/
|
60 |
|
|
|
61 |
|
|
typedef unsigned char bool;
|
62 |
|
|
|
63 |
|
|
enum opt_type {
|
64 |
|
|
o_special_noarg = 0,
|
65 |
|
|
o_special = 1,
|
66 |
|
|
o_bool,
|
67 |
|
|
o_int,
|
68 |
|
|
o_uint32,
|
69 |
|
|
o_string,
|
70 |
|
|
};
|
71 |
|
|
|
72 |
|
|
typedef struct {
|
73 |
|
|
char *name; /* name of the option */
|
74 |
|
|
enum opt_type type;
|
75 |
|
|
void *addr;
|
76 |
|
|
char *description;
|
77 |
|
|
int flags;
|
78 |
|
|
void *addr2;
|
79 |
|
|
int upper_limit;
|
80 |
|
|
int lower_limit;
|
81 |
|
|
} option_t;
|
82 |
|
|
|
83 |
|
|
/* Values for flags */
|
84 |
|
|
#define OPT_VALUE 0xff /* mask for presupplied value */
|
85 |
|
|
#define OPT_HEX 0x100 /* int option is in hex */
|
86 |
|
|
#define OPT_NOARG 0x200 /* option doesn't take argument */
|
87 |
|
|
#define OPT_OR 0x400 /* OR in argument to value */
|
88 |
|
|
#define OPT_INC 0x800 /* increment value */
|
89 |
|
|
#define OPT_PRIV 0x1000 /* privileged option */
|
90 |
|
|
#define OPT_STATIC 0x2000 /* string option goes into static array */
|
91 |
|
|
#define OPT_LLIMIT 0x4000 /* check value against lower limit */
|
92 |
|
|
#define OPT_ULIMIT 0x8000 /* check value against upper limit */
|
93 |
|
|
#define OPT_LIMITS (OPT_LLIMIT|OPT_ULIMIT)
|
94 |
|
|
#define OPT_ZEROOK 0x10000 /* 0 value is OK even if not within limits */
|
95 |
|
|
#define OPT_NOINCR 0x20000 /* value mustn't be increased */
|
96 |
|
|
#define OPT_ZEROINF 0x40000 /* with OPT_NOINCR, 0 == infinity */
|
97 |
|
|
#define OPT_A2INFO 0x100000 /* addr2 -> option_info to update */
|
98 |
|
|
#define OPT_A2COPY 0x200000 /* addr2 -> second location to rcv value */
|
99 |
|
|
#define OPT_ENABLE 0x400000 /* use *addr2 as enable for option */
|
100 |
|
|
#define OPT_PRIVFIX 0x800000 /* can't be overridden if noauth */
|
101 |
|
|
#define OPT_PREPASS 0x1000000 /* do this opt in pre-pass to find device */
|
102 |
|
|
#define OPT_INITONLY 0x2000000 /* option can only be set in init phase */
|
103 |
|
|
#define OPT_DEVEQUIV 0x4000000 /* equiv to device name */
|
104 |
|
|
#define OPT_DEVNAM (OPT_PREPASS | OPT_INITONLY | OPT_DEVEQUIV)
|
105 |
|
|
|
106 |
|
|
#define OPT_VAL(x) ((x) & OPT_VALUE)
|
107 |
|
|
|
108 |
|
|
#ifndef GIDSET_TYPE
|
109 |
|
|
#define GIDSET_TYPE gid_t
|
110 |
|
|
#endif
|
111 |
|
|
|
112 |
|
|
/* Structure representing a list of permitted IP addresses. */
|
113 |
|
|
struct permitted_ip {
|
114 |
|
|
int permit; /* 1 = permit, 0 = forbid */
|
115 |
|
|
u_int32_t base; /* match if (addr & mask) == base */
|
116 |
|
|
u_int32_t mask; /* base and mask are in network byte order */
|
117 |
|
|
};
|
118 |
|
|
|
119 |
|
|
/*
|
120 |
|
|
* Unfortunately, the linux kernel driver uses a different structure
|
121 |
|
|
* for statistics from the rest of the ports.
|
122 |
|
|
* This structure serves as a common representation for the bits
|
123 |
|
|
* pppd needs.
|
124 |
|
|
*/
|
125 |
|
|
struct pppd_stats {
|
126 |
|
|
unsigned int bytes_in;
|
127 |
|
|
unsigned int bytes_out;
|
128 |
|
|
};
|
129 |
|
|
|
130 |
|
|
/* Used for storing a sequence of words. Usually malloced. */
|
131 |
|
|
struct wordlist {
|
132 |
|
|
struct wordlist *next;
|
133 |
|
|
char *word;
|
134 |
|
|
};
|
135 |
|
|
|
136 |
|
|
/*
|
137 |
|
|
* Global variables.
|
138 |
|
|
*/
|
139 |
|
|
|
140 |
|
|
extern int kill_link; /* Signal to terminate processing loop */
|
141 |
|
|
extern int hungup; /* Physical layer has disconnected */
|
142 |
|
|
extern int pppifunit; /* Interface unit number */
|
143 |
|
|
extern char ifname[]; /* Interface name */
|
144 |
|
|
extern int ttyfd; /* Serial device file descriptor */
|
145 |
|
|
extern char hostname[]; /* Our hostname */
|
146 |
|
|
extern u_char outpacket_buf[]; /* Buffer for outgoing packets */
|
147 |
|
|
extern int phase; /* Current state of link - see values below */
|
148 |
|
|
extern int baud_rate; /* Current link speed in bits/sec */
|
149 |
|
|
extern char *progname; /* Name of this program */
|
150 |
|
|
extern int redirect_stderr;/* Connector's stderr should go to file */
|
151 |
|
|
extern char peer_authname[];/* Authenticated name of peer */
|
152 |
|
|
extern int privileged; /* We were run by real-uid root */
|
153 |
|
|
extern int need_holdoff; /* Need holdoff period after link terminates */
|
154 |
|
|
extern char **script_env; /* Environment variables for scripts */
|
155 |
|
|
extern int detached; /* Have detached from controlling tty */
|
156 |
|
|
extern GIDSET_TYPE groups[NGROUPS_MAX]; /* groups the user is in */
|
157 |
|
|
extern int ngroups; /* How many groups valid in groups */
|
158 |
|
|
extern struct pppd_stats link_stats; /* byte/packet counts etc. for link */
|
159 |
|
|
extern int using_pty; /* using pty as device (notty or pty opt.) */
|
160 |
|
|
extern int log_to_fd; /* logging to this fd as well as syslog */
|
161 |
|
|
extern char *no_ppp_msg; /* message to print if ppp not in kernel */
|
162 |
|
|
extern volatile int status; /* exit status for pppd */
|
163 |
|
|
extern int devnam_fixed; /* can no longer change devnam */
|
164 |
|
|
extern int unsuccess; /* # unsuccessful connection attempts */
|
165 |
|
|
extern int do_callback; /* set if we want to do callback next */
|
166 |
|
|
extern int doing_callback; /* set if this is a callback */
|
167 |
|
|
extern dialerfp pppd_dialer; /* script dialer function callback */
|
168 |
|
|
|
169 |
|
|
/* Values for do_callback and doing_callback */
|
170 |
|
|
#define CALLBACK_DIALIN 1 /* we are expecting the call back */
|
171 |
|
|
#define CALLBACK_DIALOUT 2 /* we are dialling out to call back */
|
172 |
|
|
|
173 |
|
|
/*
|
174 |
|
|
* Variables set by command-line options.
|
175 |
|
|
*/
|
176 |
|
|
|
177 |
|
|
extern int debug; /* Debug flag */
|
178 |
|
|
extern int kdebugflag; /* Tell kernel to print debug messages */
|
179 |
|
|
extern int default_device; /* Using /dev/tty or equivalent */
|
180 |
|
|
extern char devnam[MAXPATHLEN]; /* Device name */
|
181 |
|
|
extern int crtscts; /* Use hardware flow control */
|
182 |
|
|
extern bool modem; /* Use modem control lines */
|
183 |
|
|
extern int inspeed; /* Input/Output speed requested */
|
184 |
|
|
extern u_int32_t netmask; /* IP netmask to set on interface */
|
185 |
|
|
extern bool lockflag; /* Create lock file to lock the serial dev */
|
186 |
|
|
extern bool nodetach; /* Don't detach from controlling tty */
|
187 |
|
|
extern bool updetach; /* Detach from controlling tty when link up */
|
188 |
|
|
extern char *initializer; /* Script to initialize physical link */
|
189 |
|
|
extern char *connect_script; /* Script to establish physical link */
|
190 |
|
|
extern char *disconnect_script; /* Script to disestablish physical link */
|
191 |
|
|
extern char *welcomer; /* Script to welcome client after connection */
|
192 |
|
|
extern char *ptycommand; /* Command to run on other side of pty */
|
193 |
|
|
extern int maxconnect; /* Maximum connect time (seconds) */
|
194 |
|
|
extern char user[MAXNAMELEN];/* Our name for authenticating ourselves */
|
195 |
|
|
extern char passwd[MAXSECRETLEN]; /* Password for PAP or CHAP */
|
196 |
|
|
extern bool auth_required; /* Peer is required to authenticate */
|
197 |
|
|
extern bool persist; /* Reopen link after it goes down */
|
198 |
|
|
extern bool uselogin; /* Use /etc/passwd for checking PAP */
|
199 |
|
|
extern char our_name[MAXNAMELEN];/* Our name for authentication purposes */
|
200 |
|
|
extern char remote_name[MAXNAMELEN]; /* Peer's name for authentication */
|
201 |
|
|
extern bool explicit_remote;/* remote_name specified with remotename opt */
|
202 |
|
|
extern bool demand; /* Do dial-on-demand */
|
203 |
|
|
extern char *ipparam; /* Extra parameter for ip up/down scripts */
|
204 |
|
|
extern bool cryptpap; /* Others' PAP passwords are encrypted */
|
205 |
|
|
extern int idle_time_limit;/* Shut down link if idle for this long */
|
206 |
|
|
extern int holdoff; /* Dead time before restarting */
|
207 |
|
|
extern bool holdoff_specified; /* true if user gave a holdoff value */
|
208 |
|
|
extern bool notty; /* Stdin/out is not a tty */
|
209 |
|
|
extern char *record_file; /* File to record chars sent/received */
|
210 |
|
|
extern bool sync_serial; /* Device is synchronous serial device */
|
211 |
|
|
extern int maxfail; /* Max # of unsuccessful connection attempts */
|
212 |
|
|
extern char linkname[MAXPATHLEN]; /* logical name for link */
|
213 |
|
|
extern bool tune_kernel; /* May alter kernel settings as necessary */
|
214 |
|
|
extern int connect_delay; /* Time to delay after connect script */
|
215 |
|
|
|
216 |
|
|
#ifdef PPP_FILTER
|
217 |
|
|
extern struct bpf_program pass_filter; /* Filter for pkts to pass */
|
218 |
|
|
extern struct bpf_program active_filter; /* Filter for link-active pkts */
|
219 |
|
|
#endif
|
220 |
|
|
|
221 |
|
|
#ifdef MSLANMAN
|
222 |
|
|
extern bool ms_lanman; /* Use LanMan password instead of NT */
|
223 |
|
|
/* Has meaning only with MS-CHAP challenges */
|
224 |
|
|
#endif
|
225 |
|
|
|
226 |
|
|
extern char *current_option; /* the name of the option being parsed */
|
227 |
|
|
extern int privileged_option; /* set iff the current option came from root */
|
228 |
|
|
extern char *option_source; /* string saying where the option came from */
|
229 |
|
|
|
230 |
|
|
/*
|
231 |
|
|
* Values for phase.
|
232 |
|
|
*/
|
233 |
|
|
#define PHASE_DEAD 0
|
234 |
|
|
#define PHASE_INITIALIZE 1
|
235 |
|
|
#define PHASE_SERIALCONN 2
|
236 |
|
|
#define PHASE_DORMANT 3
|
237 |
|
|
#define PHASE_ESTABLISH 4
|
238 |
|
|
#define PHASE_AUTHENTICATE 5
|
239 |
|
|
#define PHASE_CALLBACK 6
|
240 |
|
|
#define PHASE_NETWORK 7
|
241 |
|
|
#define PHASE_RUNNING 8
|
242 |
|
|
#define PHASE_TERMINATE 9
|
243 |
|
|
#define PHASE_DISCONNECT 10
|
244 |
|
|
#define PHASE_HOLDOFF 11
|
245 |
|
|
|
246 |
|
|
/*
|
247 |
|
|
* The following struct gives the addresses of procedures to call
|
248 |
|
|
* for a particular protocol.
|
249 |
|
|
*/
|
250 |
|
|
struct protent {
|
251 |
|
|
u_short protocol; /* PPP protocol number */
|
252 |
|
|
/* Initialization procedure */
|
253 |
|
|
void (*init) __P((int unit));
|
254 |
|
|
/* Process a received packet */
|
255 |
|
|
void (*input) __P((int unit, u_char *pkt, int len));
|
256 |
|
|
/* Process a received protocol-reject */
|
257 |
|
|
void (*protrej) __P((int unit));
|
258 |
|
|
/* Lower layer has come up */
|
259 |
|
|
void (*lowerup) __P((int unit));
|
260 |
|
|
/* Lower layer has gone down */
|
261 |
|
|
void (*lowerdown) __P((int unit));
|
262 |
|
|
/* Open the protocol */
|
263 |
|
|
void (*open) __P((int unit));
|
264 |
|
|
/* Close the protocol */
|
265 |
|
|
void (*close) __P((int unit, char *reason));
|
266 |
|
|
/* Print a packet in readable form */
|
267 |
|
|
int (*printpkt) __P((u_char *pkt, int len,
|
268 |
|
|
void (*printer) __P((void *, char *, ...)),
|
269 |
|
|
void *arg));
|
270 |
|
|
/* Process a received data packet */
|
271 |
|
|
void (*datainput) __P((int unit, u_char *pkt, int len));
|
272 |
|
|
bool enabled_flag; /* 0 iff protocol is disabled */
|
273 |
|
|
char *name; /* Text name of protocol */
|
274 |
|
|
char *data_name; /* Text name of corresponding data protocol */
|
275 |
|
|
option_t *options; /* List of command-line options */
|
276 |
|
|
/* Check requested options, assign defaults */
|
277 |
|
|
void (*check_options) __P((void));
|
278 |
|
|
/* Configure interface for demand-dial */
|
279 |
|
|
int (*demand_conf) __P((int unit));
|
280 |
|
|
/* Say whether to bring up link for this pkt */
|
281 |
|
|
int (*active_pkt) __P((u_char *pkt, int len));
|
282 |
|
|
};
|
283 |
|
|
|
284 |
|
|
/* Table of pointers to supported protocols */
|
285 |
|
|
extern struct protent *protocols[];
|
286 |
|
|
|
287 |
|
|
/*
|
288 |
|
|
* Prototypes.
|
289 |
|
|
*/
|
290 |
|
|
|
291 |
|
|
/* Procedures exported from main.c. */
|
292 |
|
|
void die __P((int)); /* Cleanup and exit */
|
293 |
|
|
void quit __P((void)); /* like die(1) */
|
294 |
|
|
void novm __P((char *)); /* Say we ran out of memory, and die */
|
295 |
|
|
void ppptimeout __P((void (*func)(void *), void *arg, int t));
|
296 |
|
|
/* Call func(arg) after t seconds */
|
297 |
|
|
void untimeout __P((void (*func)(void *), void *arg));
|
298 |
|
|
/* Cancel call to func(arg) */
|
299 |
|
|
void update_link_stats __P((int)); /* Get stats at link termination */
|
300 |
|
|
void new_phase __P((int)); /* signal start of new phase */
|
301 |
|
|
|
302 |
|
|
/* Procedures exported from utils.c. */
|
303 |
|
|
void log_packet __P((u_char *, int, char *, int));
|
304 |
|
|
/* Format a packet and log it with syslog */
|
305 |
|
|
void print_string __P((char *, int, void (*) (void *, char *, ...),
|
306 |
|
|
void *)); /* Format a string for output */
|
307 |
|
|
int slprintf __P((char *, int, char *, ...)); /* sprintf++ */
|
308 |
|
|
int vslprintf __P((char *, int, char *, va_list)); /* vsprintf++ */
|
309 |
|
|
size_t strlcpy __P((char *, const char *, size_t)); /* safe strcpy */
|
310 |
|
|
size_t strlcat __P((char *, const char *, size_t)); /* safe strncpy */
|
311 |
|
|
void pppd_dbglog __P((char *, ...)); /* log a debug message */
|
312 |
|
|
void pppd_info __P((char *, ...)); /* log an informational message */
|
313 |
|
|
void pppd_notice __P((char *, ...)); /* log a notice-level message */
|
314 |
|
|
void pppd_warn __P((char *, ...)); /* log a warning message */
|
315 |
|
|
void pppd_error __P((char *, ...)); /* log an error message */
|
316 |
|
|
void pppd_fatal __P((char *, ...)); /* log an error message and die(1) */
|
317 |
|
|
|
318 |
|
|
#define dbglog pppd_dbglog
|
319 |
|
|
#define info pppd_info
|
320 |
|
|
#define notice pppd_notice
|
321 |
|
|
#define warn pppd_warn
|
322 |
|
|
#define error pppd_error
|
323 |
|
|
#define fatal pppd_fatal
|
324 |
|
|
|
325 |
|
|
/* Procedures exported from auth.c */
|
326 |
|
|
void link_required __P((int)); /* we are starting to use the link */
|
327 |
|
|
void link_terminated __P((int)); /* we are finished with the link */
|
328 |
|
|
void link_down __P((int)); /* the LCP layer has left the Opened state */
|
329 |
|
|
void link_established __P((int)); /* the link is up; authenticate now */
|
330 |
|
|
void start_networks __P((void)); /* start all the network control protos */
|
331 |
|
|
void np_up __P((int, int)); /* a network protocol has come up */
|
332 |
|
|
void np_down __P((int, int)); /* a network protocol has gone down */
|
333 |
|
|
void np_finished __P((int, int)); /* a network protocol no longer needs link */
|
334 |
|
|
void auth_peer_fail __P((int, int));
|
335 |
|
|
/* peer failed to authenticate itself */
|
336 |
|
|
void auth_peer_success __P((int, int, char *, int));
|
337 |
|
|
/* peer successfully authenticated itself */
|
338 |
|
|
void auth_withpeer_fail __P((int, int));
|
339 |
|
|
/* we failed to authenticate ourselves */
|
340 |
|
|
void auth_withpeer_success __P((int, int));
|
341 |
|
|
/* we successfully authenticated ourselves */
|
342 |
|
|
int auth_check_options __P((void));
|
343 |
|
|
/* check authentication options supplied */
|
344 |
|
|
void auth_reset __P((int)); /* check what secrets we have */
|
345 |
|
|
int check_passwd __P((int, char *, int, char *, int, char **));
|
346 |
|
|
/* Check peer-supplied username/password */
|
347 |
|
|
int get_secret __P((int, char *, char *, char *, int *, int));
|
348 |
|
|
/* get "secret" for chap */
|
349 |
|
|
int auth_ip_addr __P((int, u_int32_t));
|
350 |
|
|
/* check if IP address is authorized */
|
351 |
|
|
int bad_ip_adrs __P((u_int32_t));
|
352 |
|
|
/* check if IP address is unreasonable */
|
353 |
|
|
|
354 |
|
|
/* Procedures exported from demand.c */
|
355 |
|
|
void demand_conf __P((void)); /* config interface(s) for demand-dial */
|
356 |
|
|
void demand_block __P((void)); /* set all NPs to queue up packets */
|
357 |
|
|
void demand_unblock __P((void)); /* set all NPs to pass packets */
|
358 |
|
|
void demand_discard __P((void)); /* set all NPs to discard packets */
|
359 |
|
|
void demand_rexmit __P((int)); /* retransmit saved frames for an NP */
|
360 |
|
|
int loop_chars __P((unsigned char *, int)); /* process chars from loopback */
|
361 |
|
|
int loop_frame __P((unsigned char *, int)); /* should we bring link up? */
|
362 |
|
|
|
363 |
|
|
/* Procedures exported from sys-*.c */
|
364 |
|
|
void sys_init __P((void)); /* Do system-dependent initialization */
|
365 |
|
|
void sys_cleanup __P((void)); /* Restore system state before exiting */
|
366 |
|
|
int sys_check_options __P((void)); /* Check options specified */
|
367 |
|
|
void sys_close __P((void)); /* Clean up in a child before execing */
|
368 |
|
|
int ppp_available __P((void)); /* Test whether ppp kernel support exists */
|
369 |
|
|
int get_pty __P((int *, int *, char *, int)); /* Get pty master/slave */
|
370 |
|
|
int open_ppp_loopback __P((void)); /* Open loopback for demand-dialling */
|
371 |
|
|
int establish_ppp __P((int)); /* Turn serial port into a ppp interface */
|
372 |
|
|
void restore_loop __P((void)); /* Transfer ppp unit back to loopback */
|
373 |
|
|
void disestablish_ppp __P((int)); /* Restore port to normal operation */
|
374 |
|
|
void clean_check __P((void)); /* Check if line was 8-bit clean */
|
375 |
|
|
void set_up_tty __P((int, int)); /* Set up port's speed, parameters, etc. */
|
376 |
|
|
void restore_tty __P((int)); /* Restore port's original parameters */
|
377 |
|
|
void setdtr __P((int, int)); /* Raise or lower port's DTR line */
|
378 |
|
|
void output __P((int, u_char *, int)); /* Output a PPP packet */
|
379 |
|
|
void wait_input __P((struct timeval *)); /* Wait for input, with timeout */
|
380 |
|
|
|
381 |
|
|
void ppp_delay __P((void)); /* delay task for a little while */
|
382 |
|
|
int read_packet __P((u_char *)); /* Read PPP packet */
|
383 |
|
|
int get_loop_output __P((void)); /* Read pkts from loopback */
|
384 |
|
|
void ppp_send_config __P((int, int, u_int32_t, int, int));
|
385 |
|
|
/* Configure i/f transmit parameters */
|
386 |
|
|
void ppp_set_xaccm __P((int, ext_accm));
|
387 |
|
|
/* Set extended transmit ACCM */
|
388 |
|
|
void ppp_recv_config __P((int, int, u_int32_t, int, int));
|
389 |
|
|
/* Configure i/f receive parameters */
|
390 |
|
|
int ccp_test __P((int, u_char *, int, int));
|
391 |
|
|
/* Test support for compression scheme */
|
392 |
|
|
void ccp_flags_set __P((int, int, int));
|
393 |
|
|
/* Set kernel CCP state */
|
394 |
|
|
int ccp_fatal_error __P((int)); /* Test for fatal decomp error in kernel */
|
395 |
|
|
int get_idle_time __P((int, struct ppp_idle *));
|
396 |
|
|
/* Find out how long link has been idle */
|
397 |
|
|
int get_ppp_stats __P((int, struct pppd_stats *));
|
398 |
|
|
/* Return link statistics */
|
399 |
|
|
int sifvjcomp __P((int, int, int, int));
|
400 |
|
|
/* Configure VJ TCP header compression */
|
401 |
|
|
int sifup __P((int)); /* Configure i/f up for one protocol */
|
402 |
|
|
int sifnpmode __P((int u, int proto, enum NPmode mode));
|
403 |
|
|
/* Set mode for handling packets for proto */
|
404 |
|
|
int sifdown __P((int)); /* Configure i/f down for one protocol */
|
405 |
|
|
int sifaddr __P((int, u_int32_t, u_int32_t, u_int32_t));
|
406 |
|
|
/* Configure IPv4 addresses for i/f */
|
407 |
|
|
int cifaddr __P((int, u_int32_t, u_int32_t));
|
408 |
|
|
/* Reset i/f IP addresses */
|
409 |
|
|
#ifdef INET6
|
410 |
|
|
int sif6addr __P((int, eui64_t, eui64_t));
|
411 |
|
|
/* Configure IPv6 addresses for i/f */
|
412 |
|
|
int cif6addr __P((int, eui64_t, eui64_t));
|
413 |
|
|
/* Remove an IPv6 address from i/f */
|
414 |
|
|
#endif
|
415 |
|
|
int sifdefaultroute __P((int, u_int32_t, u_int32_t));
|
416 |
|
|
/* Create default route through i/f */
|
417 |
|
|
int cifdefaultroute __P((int, u_int32_t, u_int32_t));
|
418 |
|
|
/* Delete default route through i/f */
|
419 |
|
|
int sifproxyarp __P((int, u_int32_t));
|
420 |
|
|
/* Add proxy ARP entry for peer */
|
421 |
|
|
int cifproxyarp __P((int, u_int32_t));
|
422 |
|
|
/* Delete proxy ARP entry for peer */
|
423 |
|
|
u_int32_t GetMask __P((u_int32_t)); /* Get appropriate netmask for address */
|
424 |
|
|
int lock __P((char *)); /* Create lock file for device */
|
425 |
|
|
int relock __P((int)); /* Rewrite lock file with new pid */
|
426 |
|
|
void unlock __P((void)); /* Delete previously-created lock file */
|
427 |
|
|
void logwtmp __P((const char *, const char *, const char *));
|
428 |
|
|
/* Write entry to wtmp file */
|
429 |
|
|
int get_host_seed __P((void)); /* Get host-dependent random number seed */
|
430 |
|
|
int have_route_to __P((u_int32_t)); /* Check if route to addr exists */
|
431 |
|
|
#ifdef PPP_FILTER
|
432 |
|
|
int set_filters __P((struct bpf_program *pass, struct bpf_program *active));
|
433 |
|
|
/* Set filter programs in kernel */
|
434 |
|
|
#endif
|
435 |
|
|
#ifdef IPX_CHANGE
|
436 |
|
|
int sipxfaddr __P((int, unsigned long, unsigned char *));
|
437 |
|
|
int cipxfaddr __P((int));
|
438 |
|
|
#endif
|
439 |
|
|
|
440 |
|
|
/* Procedures exported from options.c */
|
441 |
|
|
int parse_args __P((int argc, char **argv));
|
442 |
|
|
/* Parse options from arguments given */
|
443 |
|
|
int options_from_file __P((char *filename, int must_exist, int check_prot,
|
444 |
|
|
int privileged));
|
445 |
|
|
/* Parse options from an options file */
|
446 |
|
|
int options_from_user __P((void)); /* Parse options from user's .ppprc */
|
447 |
|
|
int options_for_tty __P((void)); /* Parse options from /etc/ppp/options.tty */
|
448 |
|
|
int options_from_list __P((struct wordlist *, int privileged));
|
449 |
|
|
/* Parse options from a wordlist */
|
450 |
|
|
int getword __P((FILE *f, char *word, int *newlinep, char *filename));
|
451 |
|
|
/* Read a word from a file */
|
452 |
|
|
void option_error __P((char *fmt, ...));
|
453 |
|
|
/* Print an error message about an option */
|
454 |
|
|
int int_option __P((char *, int *));
|
455 |
|
|
/* Simplified number_option for decimal ints */
|
456 |
|
|
void add_options __P((option_t *)); /* Add extra options */
|
457 |
|
|
|
458 |
|
|
/*
|
459 |
|
|
* This structure is used to store information about certain
|
460 |
|
|
* options, such as where the option value came from (/etc/ppp/options,
|
461 |
|
|
* command line, etc.) and whether it came from a privileged source.
|
462 |
|
|
*/
|
463 |
|
|
|
464 |
|
|
struct option_info {
|
465 |
|
|
int priv; /* was value set by sysadmin? */
|
466 |
|
|
char *source; /* where option came from */
|
467 |
|
|
};
|
468 |
|
|
|
469 |
|
|
extern struct option_info devnam_info;
|
470 |
|
|
extern struct option_info initializer_info;
|
471 |
|
|
extern struct option_info connect_script_info;
|
472 |
|
|
extern struct option_info disconnect_script_info;
|
473 |
|
|
extern struct option_info welcomer_info;
|
474 |
|
|
extern struct option_info ptycommand_info;
|
475 |
|
|
|
476 |
|
|
/*
|
477 |
|
|
* Hooks to enable plugins to change various things.
|
478 |
|
|
*/
|
479 |
|
|
extern int (*new_phase_hook) __P((int));
|
480 |
|
|
extern int (*idle_time_hook) __P((struct ppp_idle *));
|
481 |
|
|
extern int (*holdoff_hook) __P((void));
|
482 |
|
|
extern int (*pap_check_hook) __P((void));
|
483 |
|
|
extern int (*pap_auth_hook) __P((char *user, char *passwd/*, char **msgp,
|
484 |
|
|
struct wordlist **paddrs,
|
485 |
|
|
struct wordlist **popts*/));
|
486 |
|
|
extern void (*pap_logout_hook) __P((void));
|
487 |
|
|
extern int (*pap_passwd_hook) __P((char *user, char *passwd));
|
488 |
|
|
extern void (*ip_up_hook) __P((void));
|
489 |
|
|
extern void (*ip_down_hook) __P((void));
|
490 |
|
|
extern void (*auth_linkup_hook) __P((void));
|
491 |
|
|
extern void (*auth_linkdown_hook) __P((void));
|
492 |
|
|
|
493 |
|
|
/*
|
494 |
|
|
* Inline versions of get/put char/short/long.
|
495 |
|
|
* Pointer is advanced; we assume that both arguments
|
496 |
|
|
* are lvalues and will already be in registers.
|
497 |
|
|
* cp MUST be u_char *.
|
498 |
|
|
*/
|
499 |
|
|
#define GETCHAR(c, cp) { \
|
500 |
|
|
(c) = *(cp)++; \
|
501 |
|
|
}
|
502 |
|
|
#define PUTCHAR(c, cp) { \
|
503 |
|
|
*(cp)++ = (u_char) (c); \
|
504 |
|
|
}
|
505 |
|
|
|
506 |
|
|
|
507 |
|
|
#define GETSHORT(s, cp) { \
|
508 |
|
|
(s) = *(cp)++ << 8; \
|
509 |
|
|
(s) |= *(cp)++; \
|
510 |
|
|
}
|
511 |
|
|
#define PUTSHORT(s, cp) { \
|
512 |
|
|
*(cp)++ = (u_char) ((s) >> 8); \
|
513 |
|
|
*(cp)++ = (u_char) (s); \
|
514 |
|
|
}
|
515 |
|
|
|
516 |
|
|
#define GETLONG(l, cp) { \
|
517 |
|
|
(l) = *(cp)++ << 8; \
|
518 |
|
|
(l) |= *(cp)++; (l) <<= 8; \
|
519 |
|
|
(l) |= *(cp)++; (l) <<= 8; \
|
520 |
|
|
(l) |= *(cp)++; \
|
521 |
|
|
}
|
522 |
|
|
#define PUTLONG(l, cp) { \
|
523 |
|
|
*(cp)++ = (u_char) ((l) >> 24); \
|
524 |
|
|
*(cp)++ = (u_char) ((l) >> 16); \
|
525 |
|
|
*(cp)++ = (u_char) ((l) >> 8); \
|
526 |
|
|
*(cp)++ = (u_char) (l); \
|
527 |
|
|
}
|
528 |
|
|
|
529 |
|
|
#define INCPTR(n, cp) ((cp) += (n))
|
530 |
|
|
#define DECPTR(n, cp) ((cp) -= (n))
|
531 |
|
|
|
532 |
|
|
/*
|
533 |
|
|
* System dependent definitions for user-level 4.3BSD UNIX implementation.
|
534 |
|
|
*/
|
535 |
|
|
|
536 |
|
|
#define TIMEOUT(r, f, t) ppptimeout((r), (f), (t))
|
537 |
|
|
#define UNTIMEOUT(r, f) untimeout((r), (f))
|
538 |
|
|
|
539 |
|
|
#define BCOPY(s, d, l) memcpy(d, s, l)
|
540 |
|
|
#define BZERO(s, n) memset(s, 0, n)
|
541 |
|
|
|
542 |
|
|
#define PRINTMSG(m, l) { info("Remote message: %0.*v", l, m); }
|
543 |
|
|
|
544 |
|
|
/*
|
545 |
|
|
* MAKEHEADER - Add Header fields to a packet.
|
546 |
|
|
*/
|
547 |
|
|
#define MAKEHEADER(p, t) { \
|
548 |
|
|
PUTCHAR(PPP_ALLSTATIONS, p); \
|
549 |
|
|
PUTCHAR(PPP_UI, p); \
|
550 |
|
|
PUTSHORT(t, p); }
|
551 |
|
|
|
552 |
|
|
/*
|
553 |
|
|
* Exit status values.
|
554 |
|
|
*/
|
555 |
|
|
#define EXIT_OK 0
|
556 |
|
|
#define EXIT_FATAL_ERROR 1
|
557 |
|
|
#define EXIT_OPTION_ERROR 2
|
558 |
|
|
#define EXIT_NOT_ROOT 3
|
559 |
|
|
#define EXIT_NO_KERNEL_SUPPORT 4
|
560 |
|
|
#define EXIT_USER_REQUEST 5
|
561 |
|
|
#define EXIT_LOCK_FAILED 6
|
562 |
|
|
#define EXIT_OPEN_FAILED 7
|
563 |
|
|
#define EXIT_CONNECT_FAILED 8
|
564 |
|
|
#define EXIT_PTYCMD_FAILED 9
|
565 |
|
|
#define EXIT_NEGOTIATION_FAILED 10
|
566 |
|
|
#define EXIT_PEER_AUTH_FAILED 11
|
567 |
|
|
#define EXIT_IDLE_TIMEOUT 12
|
568 |
|
|
#define EXIT_CONNECT_TIME 13
|
569 |
|
|
#define EXIT_CALLBACK 14
|
570 |
|
|
#define EXIT_PEER_DEAD 15
|
571 |
|
|
#define EXIT_HANGUP 16
|
572 |
|
|
#define EXIT_LOOPBACK 17
|
573 |
|
|
#define EXIT_INIT_FAILED 18
|
574 |
|
|
#define EXIT_AUTH_TOPEER_FAILED 19
|
575 |
|
|
|
576 |
|
|
/*
|
577 |
|
|
* Debug macros. Slightly useful for finding bugs in pppd, not particularly
|
578 |
|
|
* useful for finding out why your connection isn't being established.
|
579 |
|
|
*/
|
580 |
|
|
|
581 |
|
|
#ifdef DEBUGALL
|
582 |
|
|
#define DEBUGMAIN 1
|
583 |
|
|
#define DEBUGFSM 1
|
584 |
|
|
#define DEBUGLCP 1
|
585 |
|
|
#define DEBUGIPCP 1
|
586 |
|
|
#define DEBUGIPV6CP 1
|
587 |
|
|
#define DEBUGUPAP 1
|
588 |
|
|
#define DEBUGCHAP 1
|
589 |
|
|
#endif
|
590 |
|
|
#define DEBUGMAIN 1
|
591 |
|
|
#define DEBUGUPAP 1
|
592 |
|
|
#define DEBUGCHAP 1
|
593 |
|
|
|
594 |
|
|
|
595 |
|
|
#ifdef DEBUGMAIN
|
596 |
|
|
#define MAINDEBUG(x) if (debug) dbglog x
|
597 |
|
|
#else
|
598 |
|
|
#define MAINDEBUG(x)
|
599 |
|
|
#endif
|
600 |
|
|
|
601 |
|
|
#ifdef DEBUGSYS
|
602 |
|
|
#define SYSDEBUG(x) if (debug) dbglog x
|
603 |
|
|
#else
|
604 |
|
|
#define SYSDEBUG(x)
|
605 |
|
|
#endif
|
606 |
|
|
|
607 |
|
|
#ifdef DEBUGFSM
|
608 |
|
|
#define FSMDEBUG(x) if (debug) dbglog x
|
609 |
|
|
#else
|
610 |
|
|
#define FSMDEBUG(x)
|
611 |
|
|
#endif
|
612 |
|
|
|
613 |
|
|
#ifdef DEBUGLCP
|
614 |
|
|
#define LCPDEBUG(x) if (debug) dbglog x
|
615 |
|
|
#else
|
616 |
|
|
#define LCPDEBUG(x)
|
617 |
|
|
#endif
|
618 |
|
|
|
619 |
|
|
#ifdef DEBUGIPCP
|
620 |
|
|
#define IPCPDEBUG(x) if (debug) dbglog x
|
621 |
|
|
#else
|
622 |
|
|
#define IPCPDEBUG(x)
|
623 |
|
|
#endif
|
624 |
|
|
|
625 |
|
|
#ifdef DEBUGIPV6CP
|
626 |
|
|
#define IPV6CPDEBUG(x) if (debug) dbglog x
|
627 |
|
|
#else
|
628 |
|
|
#define IPV6CPDEBUG(x)
|
629 |
|
|
#endif
|
630 |
|
|
|
631 |
|
|
#ifdef DEBUGUPAP
|
632 |
|
|
#define UPAPDEBUG(x) if (debug) dbglog x
|
633 |
|
|
#else
|
634 |
|
|
#define UPAPDEBUG(x)
|
635 |
|
|
#endif
|
636 |
|
|
|
637 |
|
|
#ifdef DEBUGCHAP
|
638 |
|
|
#define CHAPDEBUG(x) if (debug) dbglog x
|
639 |
|
|
#else
|
640 |
|
|
#define CHAPDEBUG(x)
|
641 |
|
|
#endif
|
642 |
|
|
|
643 |
|
|
#ifdef DEBUGIPXCP
|
644 |
|
|
#define IPXCPDEBUG(x) if (debug) dbglog x
|
645 |
|
|
#else
|
646 |
|
|
#define IPXCPDEBUG(x)
|
647 |
|
|
#endif
|
648 |
|
|
|
649 |
|
|
#ifndef SIGTYPE
|
650 |
|
|
#if defined(sun) || defined(SYSV) || defined(POSIX_SOURCE)
|
651 |
|
|
#define SIGTYPE void
|
652 |
|
|
#else
|
653 |
|
|
#define SIGTYPE int
|
654 |
|
|
#endif /* defined(sun) || defined(SYSV) || defined(POSIX_SOURCE) */
|
655 |
|
|
#endif /* SIGTYPE */
|
656 |
|
|
|
657 |
|
|
#ifndef MIN
|
658 |
|
|
#define MIN(a, b) ((a) < (b)? (a): (b))
|
659 |
|
|
#endif
|
660 |
|
|
#ifndef MAX
|
661 |
|
|
#define MAX(a, b) ((a) > (b)? (a): (b))
|
662 |
|
|
#endif
|
663 |
|
|
|
664 |
|
|
#endif /* __PPP_H__ */
|