1
0

debian-369714_support-ppd-2.4.4.patch 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902
  1. Description: Use pppd.h provided by ppp-dev
  2. Author: Stu Teasdale <stu@drogna.org.uk>
  3. Author: Christoph Biedl <debian.axhn@manchmal.in-ulm.de>
  4. Forwarded: http://sourceforge.net/mailarchive/forum.php?thread_name=1360194160%40msgid.manchmal.in-ulm.de&forum_name=poptop-server
  5. Bug-Debian: http://bugs.debian.org/369714
  6. --- a/plugins/pptpd-logwtmp.c
  7. +++ b/plugins/pptpd-logwtmp.c
  8. @@ -12,7 +12,7 @@
  9. #include <unistd.h>
  10. #include <utmp.h>
  11. #include <string.h>
  12. -#include "pppd.h"
  13. +#include <pppd/pppd.h>
  14. char pppd_version[] = VERSION;
  15. --- a/plugins/pppd.h
  16. +++ /dev/null
  17. @@ -1,882 +0,0 @@
  18. -/*
  19. - * pppd.h - PPP daemon global declarations.
  20. - *
  21. - * Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved.
  22. - *
  23. - * Redistribution and use in source and binary forms, with or without
  24. - * modification, are permitted provided that the following conditions
  25. - * are met:
  26. - *
  27. - * 1. Redistributions of source code must retain the above copyright
  28. - * notice, this list of conditions and the following disclaimer.
  29. - *
  30. - * 2. Redistributions in binary form must reproduce the above copyright
  31. - * notice, this list of conditions and the following disclaimer in
  32. - * the documentation and/or other materials provided with the
  33. - * distribution.
  34. - *
  35. - * 3. The name "Carnegie Mellon University" must not be used to
  36. - * endorse or promote products derived from this software without
  37. - * prior written permission. For permission or any legal
  38. - * details, please contact
  39. - * Office of Technology Transfer
  40. - * Carnegie Mellon University
  41. - * 5000 Forbes Avenue
  42. - * Pittsburgh, PA 15213-3890
  43. - * (412) 268-4387, fax: (412) 268-7395
  44. - * tech-transfer@andrew.cmu.edu
  45. - *
  46. - * 4. Redistributions of any form whatsoever must retain the following
  47. - * acknowledgment:
  48. - * "This product includes software developed by Computing Services
  49. - * at Carnegie Mellon University (http://www.cmu.edu/computing/)."
  50. - *
  51. - * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
  52. - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  53. - * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
  54. - * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  55. - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
  56. - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  57. - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  58. - *
  59. - * upstream pppd.h,v 1.82 2003/04/07 00:01:46 paulus Exp
  60. - * $Id: pppd.h,v 1.1 2004/04/28 11:36:07 quozl Exp $
  61. - */
  62. -
  63. -/*
  64. - * TODO:
  65. - */
  66. -
  67. -#ifndef __PPPD_H__
  68. -#define __PPPD_H__
  69. -
  70. -#include <stdio.h> /* for FILE */
  71. -#include <limits.h> /* for NGROUPS_MAX */
  72. -#include <sys/param.h> /* for MAXPATHLEN and BSD4_4, if defined */
  73. -#include <sys/types.h> /* for u_int32_t, if defined */
  74. -#include <sys/time.h> /* for struct timeval */
  75. -#include <net/ppp_defs.h>
  76. -#include "patchlevel.h"
  77. -
  78. -#if defined(__STDC__)
  79. -#include <stdarg.h>
  80. -#define __V(x) x
  81. -#else
  82. -#include <varargs.h>
  83. -#define __V(x) (va_alist) va_dcl
  84. -#define const
  85. -#define volatile
  86. -#endif
  87. -
  88. -#ifdef INET6
  89. -#include "eui64.h"
  90. -#endif
  91. -
  92. -/*
  93. - * Limits.
  94. - */
  95. -
  96. -#define NUM_PPP 1 /* One PPP interface supported (per process) */
  97. -#define MAXWORDLEN 1024 /* max length of word in file (incl null) */
  98. -#define MAXARGS 1 /* max # args to a command */
  99. -#define MAXNAMELEN 256 /* max length of hostname or name for auth */
  100. -#define MAXSECRETLEN 256 /* max length of password or secret */
  101. -
  102. -/*
  103. - * Option descriptor structure.
  104. - */
  105. -
  106. -typedef unsigned char bool;
  107. -
  108. -enum opt_type {
  109. - o_special_noarg = 0,
  110. - o_special = 1,
  111. - o_bool,
  112. - o_int,
  113. - o_uint32,
  114. - o_string,
  115. - o_wild
  116. -};
  117. -
  118. -typedef struct {
  119. - char *name; /* name of the option */
  120. - enum opt_type type;
  121. - void *addr;
  122. - char *description;
  123. - unsigned int flags;
  124. - void *addr2;
  125. - int upper_limit;
  126. - int lower_limit;
  127. - const char *source;
  128. - short int priority;
  129. - short int winner;
  130. -} option_t;
  131. -
  132. -/* Values for flags */
  133. -#define OPT_VALUE 0xff /* mask for presupplied value */
  134. -#define OPT_HEX 0x100 /* int option is in hex */
  135. -#define OPT_NOARG 0x200 /* option doesn't take argument */
  136. -#define OPT_OR 0x400 /* OR in argument to value */
  137. -#define OPT_INC 0x800 /* increment value */
  138. -#define OPT_A2OR 0x800 /* for o_bool, OR arg to *(u_char *)addr2 */
  139. -#define OPT_PRIV 0x1000 /* privileged option */
  140. -#define OPT_STATIC 0x2000 /* string option goes into static array */
  141. -#define OPT_LLIMIT 0x4000 /* check value against lower limit */
  142. -#define OPT_ULIMIT 0x8000 /* check value against upper limit */
  143. -#define OPT_LIMITS (OPT_LLIMIT|OPT_ULIMIT)
  144. -#define OPT_ZEROOK 0x10000 /* 0 value is OK even if not within limits */
  145. -#define OPT_HIDE 0x10000 /* for o_string, print value as ?????? */
  146. -#define OPT_A2LIST 0x10000 /* for o_special, keep list of values */
  147. -#define OPT_A2CLRB 0x10000 /* o_bool, clr val bits in *(u_char *)addr2 */
  148. -#define OPT_NOINCR 0x20000 /* value mustn't be increased */
  149. -#define OPT_ZEROINF 0x40000 /* with OPT_NOINCR, 0 == infinity */
  150. -#define OPT_PRIO 0x80000 /* process option priorities for this option */
  151. -#define OPT_PRIOSUB 0x100000 /* subsidiary member of priority group */
  152. -#define OPT_ALIAS 0x200000 /* option is alias for previous option */
  153. -#define OPT_A2COPY 0x400000 /* addr2 -> second location to rcv value */
  154. -#define OPT_ENABLE 0x800000 /* use *addr2 as enable for option */
  155. -#define OPT_A2CLR 0x1000000 /* clear *(bool *)addr2 */
  156. -#define OPT_PRIVFIX 0x2000000 /* user can't override if set by root */
  157. -#define OPT_INITONLY 0x4000000 /* option can only be set in init phase */
  158. -#define OPT_DEVEQUIV 0x8000000 /* equiv to device name */
  159. -#define OPT_DEVNAM (OPT_INITONLY | OPT_DEVEQUIV)
  160. -#define OPT_A2PRINTER 0x10000000 /* *addr2 is a fn for printing option */
  161. -#define OPT_A2STRVAL 0x20000000 /* *addr2 points to current string value */
  162. -#define OPT_NOPRINT 0x40000000 /* don't print this option at all */
  163. -
  164. -#define OPT_VAL(x) ((x) & OPT_VALUE)
  165. -
  166. -/* Values for priority */
  167. -#define OPRIO_DEFAULT 0 /* a default value */
  168. -#define OPRIO_CFGFILE 1 /* value from a configuration file */
  169. -#define OPRIO_CMDLINE 2 /* value from the command line */
  170. -#define OPRIO_SECFILE 3 /* value from options in a secrets file */
  171. -#define OPRIO_ROOT 100 /* added to priority if OPT_PRIVFIX && root */
  172. -
  173. -#ifndef GIDSET_TYPE
  174. -#define GIDSET_TYPE gid_t
  175. -#endif
  176. -
  177. -/* Structure representing a list of permitted IP addresses. */
  178. -struct permitted_ip {
  179. - int permit; /* 1 = permit, 0 = forbid */
  180. - u_int32_t base; /* match if (addr & mask) == base */
  181. - u_int32_t mask; /* base and mask are in network byte order */
  182. -};
  183. -
  184. -/*
  185. - * Unfortunately, the linux kernel driver uses a different structure
  186. - * for statistics from the rest of the ports.
  187. - * This structure serves as a common representation for the bits
  188. - * pppd needs.
  189. - */
  190. -struct pppd_stats {
  191. - unsigned int bytes_in;
  192. - unsigned int bytes_out;
  193. - unsigned int pkts_in;
  194. - unsigned int pkts_out;
  195. -};
  196. -
  197. -/* Used for storing a sequence of words. Usually malloced. */
  198. -struct wordlist {
  199. - struct wordlist *next;
  200. - char *word;
  201. -};
  202. -
  203. -/* An endpoint discriminator, used with multilink. */
  204. -#define MAX_ENDP_LEN 20 /* maximum length of discriminator value */
  205. -struct epdisc {
  206. - unsigned char class;
  207. - unsigned char length;
  208. - unsigned char value[MAX_ENDP_LEN];
  209. -};
  210. -
  211. -/* values for epdisc.class */
  212. -#define EPD_NULL 0 /* null discriminator, no data */
  213. -#define EPD_LOCAL 1
  214. -#define EPD_IP 2
  215. -#define EPD_MAC 3
  216. -#define EPD_MAGIC 4
  217. -#define EPD_PHONENUM 5
  218. -
  219. -typedef void (*notify_func) __P((void *, int));
  220. -
  221. -struct notifier {
  222. - struct notifier *next;
  223. - notify_func func;
  224. - void *arg;
  225. -};
  226. -
  227. -/*
  228. - * Global variables.
  229. - */
  230. -
  231. -extern int hungup; /* Physical layer has disconnected */
  232. -extern int ifunit; /* Interface unit number */
  233. -extern char ifname[]; /* Interface name */
  234. -extern char hostname[]; /* Our hostname */
  235. -extern u_char outpacket_buf[]; /* Buffer for outgoing packets */
  236. -extern int phase; /* Current state of link - see values below */
  237. -extern int baud_rate; /* Current link speed in bits/sec */
  238. -extern char *progname; /* Name of this program */
  239. -extern int redirect_stderr;/* Connector's stderr should go to file */
  240. -extern char peer_authname[];/* Authenticated name of peer */
  241. -extern int auth_done[NUM_PPP]; /* Methods actually used for auth */
  242. -extern int privileged; /* We were run by real-uid root */
  243. -extern int need_holdoff; /* Need holdoff period after link terminates */
  244. -extern char **script_env; /* Environment variables for scripts */
  245. -extern int detached; /* Have detached from controlling tty */
  246. -extern GIDSET_TYPE groups[NGROUPS_MAX]; /* groups the user is in */
  247. -extern int ngroups; /* How many groups valid in groups */
  248. -extern struct pppd_stats link_stats; /* byte/packet counts etc. for link */
  249. -extern int link_stats_valid; /* set if link_stats is valid */
  250. -extern unsigned link_connect_time; /* time the link was up for */
  251. -extern int using_pty; /* using pty as device (notty or pty opt.) */
  252. -extern int log_to_fd; /* logging to this fd as well as syslog */
  253. -extern bool log_default; /* log_to_fd is default (stdout) */
  254. -extern char *no_ppp_msg; /* message to print if ppp not in kernel */
  255. -extern volatile int status; /* exit status for pppd */
  256. -extern bool devnam_fixed; /* can no longer change devnam */
  257. -extern int unsuccess; /* # unsuccessful connection attempts */
  258. -extern int do_callback; /* set if we want to do callback next */
  259. -extern int doing_callback; /* set if this is a callback */
  260. -extern int error_count; /* # of times error() has been called */
  261. -extern char ppp_devnam[MAXPATHLEN];
  262. -extern char remote_number[MAXNAMELEN]; /* Remote telephone number, if avail. */
  263. -extern int ppp_session_number; /* Session number (eg PPPoE session) */
  264. -
  265. -extern int listen_time; /* time to listen first (ms) */
  266. -extern struct notifier *pidchange; /* for notifications of pid changing */
  267. -extern struct notifier *phasechange; /* for notifications of phase changes */
  268. -extern struct notifier *exitnotify; /* for notification that we're exiting */
  269. -extern struct notifier *sigreceived; /* notification of received signal */
  270. -extern struct notifier *ip_up_notifier; /* IPCP has come up */
  271. -extern struct notifier *ip_down_notifier; /* IPCP has gone down */
  272. -extern struct notifier *auth_up_notifier; /* peer has authenticated */
  273. -extern struct notifier *link_down_notifier; /* link has gone down */
  274. -extern struct notifier *fork_notifier; /* we are a new child process */
  275. -
  276. -/* Values for do_callback and doing_callback */
  277. -#define CALLBACK_DIALIN 1 /* we are expecting the call back */
  278. -#define CALLBACK_DIALOUT 2 /* we are dialling out to call back */
  279. -
  280. -/*
  281. - * Variables set by command-line options.
  282. - */
  283. -
  284. -extern int debug; /* Debug flag */
  285. -extern int kdebugflag; /* Tell kernel to print debug messages */
  286. -extern int default_device; /* Using /dev/tty or equivalent */
  287. -extern char devnam[MAXPATHLEN]; /* Device name */
  288. -extern int crtscts; /* Use hardware flow control */
  289. -extern bool modem; /* Use modem control lines */
  290. -extern int inspeed; /* Input/Output speed requested */
  291. -extern u_int32_t netmask; /* IP netmask to set on interface */
  292. -extern bool lockflag; /* Create lock file to lock the serial dev */
  293. -extern bool nodetach; /* Don't detach from controlling tty */
  294. -extern bool updetach; /* Detach from controlling tty when link up */
  295. -extern char *initializer; /* Script to initialize physical link */
  296. -extern char *connect_script; /* Script to establish physical link */
  297. -extern char *disconnect_script; /* Script to disestablish physical link */
  298. -extern char *welcomer; /* Script to welcome client after connection */
  299. -extern char *ptycommand; /* Command to run on other side of pty */
  300. -extern int maxconnect; /* Maximum connect time (seconds) */
  301. -extern char user[MAXNAMELEN];/* Our name for authenticating ourselves */
  302. -extern char passwd[MAXSECRETLEN]; /* Password for PAP or CHAP */
  303. -extern bool auth_required; /* Peer is required to authenticate */
  304. -extern bool persist; /* Reopen link after it goes down */
  305. -extern bool uselogin; /* Use /etc/passwd for checking PAP */
  306. -extern char our_name[MAXNAMELEN];/* Our name for authentication purposes */
  307. -extern char remote_name[MAXNAMELEN]; /* Peer's name for authentication */
  308. -extern bool explicit_remote;/* remote_name specified with remotename opt */
  309. -extern bool demand; /* Do dial-on-demand */
  310. -extern char *ipparam; /* Extra parameter for ip up/down scripts */
  311. -extern bool cryptpap; /* Others' PAP passwords are encrypted */
  312. -extern int idle_time_limit;/* Shut down link if idle for this long */
  313. -extern int holdoff; /* Dead time before restarting */
  314. -extern bool holdoff_specified; /* true if user gave a holdoff value */
  315. -extern bool notty; /* Stdin/out is not a tty */
  316. -extern char *pty_socket; /* Socket to connect to pty */
  317. -extern char *record_file; /* File to record chars sent/received */
  318. -extern bool sync_serial; /* Device is synchronous serial device */
  319. -extern int maxfail; /* Max # of unsuccessful connection attempts */
  320. -extern char linkname[MAXPATHLEN]; /* logical name for link */
  321. -extern bool tune_kernel; /* May alter kernel settings as necessary */
  322. -extern int connect_delay; /* Time to delay after connect script */
  323. -extern int max_data_rate; /* max bytes/sec through charshunt */
  324. -extern int req_unit; /* interface unit number to use */
  325. -extern bool multilink; /* enable multilink operation */
  326. -extern bool noendpoint; /* don't send or accept endpt. discrim. */
  327. -extern char *bundle_name; /* bundle name for multilink */
  328. -extern bool dump_options; /* print out option values */
  329. -extern bool dryrun; /* check everything, print options, exit */
  330. -
  331. -#ifdef MAXOCTETS
  332. -extern unsigned int maxoctets; /* Maximum octetes per session (in bytes) */
  333. -extern int maxoctets_dir; /* Direction :
  334. - 0 - in+out (default)
  335. - 1 - in
  336. - 2 - out
  337. - 3 - max(in,out) */
  338. -extern int maxoctets_timeout; /* Timeout for check of octets limit */
  339. -#define PPP_OCTETS_DIRECTION_SUM 0
  340. -#define PPP_OCTETS_DIRECTION_IN 1
  341. -#define PPP_OCTETS_DIRECTION_OUT 2
  342. -#define PPP_OCTETS_DIRECTION_MAXOVERAL 3
  343. -/* same as previos, but little different on RADIUS side */
  344. -#define PPP_OCTETS_DIRECTION_MAXSESSION 4
  345. -#endif
  346. -
  347. -#ifdef PPP_FILTER
  348. -extern struct bpf_program pass_filter; /* Filter for pkts to pass */
  349. -extern struct bpf_program active_filter; /* Filter for link-active pkts */
  350. -#endif
  351. -
  352. -#ifdef MSLANMAN
  353. -extern bool ms_lanman; /* Use LanMan password instead of NT */
  354. - /* Has meaning only with MS-CHAP challenges */
  355. -#endif
  356. -
  357. -/* Values for auth_pending, auth_done */
  358. -#define PAP_WITHPEER 0x1
  359. -#define PAP_PEER 0x2
  360. -#define CHAP_WITHPEER 0x4
  361. -#define CHAP_PEER 0x8
  362. -#define EAP_WITHPEER 0x10
  363. -#define EAP_PEER 0x20
  364. -
  365. -/* Values for auth_done only */
  366. -#define CHAP_MD5_WITHPEER 0x40
  367. -#define CHAP_MD5_PEER 0x80
  368. -#ifdef CHAPMS
  369. -#define CHAP_MS_SHIFT 8 /* LSB position for MS auths */
  370. -#define CHAP_MS_WITHPEER 0x100
  371. -#define CHAP_MS_PEER 0x200
  372. -#define CHAP_MS2_WITHPEER 0x400
  373. -#define CHAP_MS2_PEER 0x800
  374. -#endif
  375. -
  376. -extern char *current_option; /* the name of the option being parsed */
  377. -extern int privileged_option; /* set iff the current option came from root */
  378. -extern char *option_source; /* string saying where the option came from */
  379. -extern int option_priority; /* priority of current options */
  380. -
  381. -/*
  382. - * Values for phase.
  383. - */
  384. -#define PHASE_DEAD 0
  385. -#define PHASE_INITIALIZE 1
  386. -#define PHASE_SERIALCONN 2
  387. -#define PHASE_DORMANT 3
  388. -#define PHASE_ESTABLISH 4
  389. -#define PHASE_AUTHENTICATE 5
  390. -#define PHASE_CALLBACK 6
  391. -#define PHASE_NETWORK 7
  392. -#define PHASE_RUNNING 8
  393. -#define PHASE_TERMINATE 9
  394. -#define PHASE_DISCONNECT 10
  395. -#define PHASE_HOLDOFF 11
  396. -
  397. -/*
  398. - * The following struct gives the addresses of procedures to call
  399. - * for a particular protocol.
  400. - */
  401. -struct protent {
  402. - u_short protocol; /* PPP protocol number */
  403. - /* Initialization procedure */
  404. - void (*init) __P((int unit));
  405. - /* Process a received packet */
  406. - void (*input) __P((int unit, u_char *pkt, int len));
  407. - /* Process a received protocol-reject */
  408. - void (*protrej) __P((int unit));
  409. - /* Lower layer has come up */
  410. - void (*lowerup) __P((int unit));
  411. - /* Lower layer has gone down */
  412. - void (*lowerdown) __P((int unit));
  413. - /* Open the protocol */
  414. - void (*open) __P((int unit));
  415. - /* Close the protocol */
  416. - void (*close) __P((int unit, char *reason));
  417. - /* Print a packet in readable form */
  418. - int (*printpkt) __P((u_char *pkt, int len,
  419. - void (*printer) __P((void *, char *, ...)),
  420. - void *arg));
  421. - /* Process a received data packet */
  422. - void (*datainput) __P((int unit, u_char *pkt, int len));
  423. - bool enabled_flag; /* 0 iff protocol is disabled */
  424. - char *name; /* Text name of protocol */
  425. - char *data_name; /* Text name of corresponding data protocol */
  426. - option_t *options; /* List of command-line options */
  427. - /* Check requested options, assign defaults */
  428. - void (*check_options) __P((void));
  429. - /* Configure interface for demand-dial */
  430. - int (*demand_conf) __P((int unit));
  431. - /* Say whether to bring up link for this pkt */
  432. - int (*active_pkt) __P((u_char *pkt, int len));
  433. -};
  434. -
  435. -/* Table of pointers to supported protocols */
  436. -extern struct protent *protocols[];
  437. -
  438. -/*
  439. - * This struct contains pointers to a set of procedures for
  440. - * doing operations on a "channel". A channel provides a way
  441. - * to send and receive PPP packets - the canonical example is
  442. - * a serial port device in PPP line discipline (or equivalently
  443. - * with PPP STREAMS modules pushed onto it).
  444. - */
  445. -struct channel {
  446. - /* set of options for this channel */
  447. - option_t *options;
  448. - /* find and process a per-channel options file */
  449. - void (*process_extra_options) __P((void));
  450. - /* check all the options that have been given */
  451. - void (*check_options) __P((void));
  452. - /* get the channel ready to do PPP, return a file descriptor */
  453. - int (*connect) __P((void));
  454. - /* we're finished with the channel */
  455. - void (*disconnect) __P((void));
  456. - /* put the channel into PPP `mode' */
  457. - int (*establish_ppp) __P((int));
  458. - /* take the channel out of PPP `mode', restore loopback if demand */
  459. - void (*disestablish_ppp) __P((int));
  460. - /* set the transmit-side PPP parameters of the channel */
  461. - void (*send_config) __P((int, u_int32_t, int, int));
  462. - /* set the receive-side PPP parameters of the channel */
  463. - void (*recv_config) __P((int, u_int32_t, int, int));
  464. - /* cleanup on error or normal exit */
  465. - void (*cleanup) __P((void));
  466. - /* close the device, called in children after fork */
  467. - void (*close) __P((void));
  468. -};
  469. -
  470. -extern struct channel *the_channel;
  471. -
  472. -/*
  473. - * Prototypes.
  474. - */
  475. -
  476. -/* Procedures exported from main.c. */
  477. -void set_ifunit __P((int)); /* set stuff that depends on ifunit */
  478. -void detach __P((void)); /* Detach from controlling tty */
  479. -void die __P((int)); /* Cleanup and exit */
  480. -void quit __P((void)); /* like die(1) */
  481. -void novm __P((char *)); /* Say we ran out of memory, and die */
  482. -void timeout __P((void (*func)(void *), void *arg, int s, int us));
  483. - /* Call func(arg) after s.us seconds */
  484. -void untimeout __P((void (*func)(void *), void *arg));
  485. - /* Cancel call to func(arg) */
  486. -void record_child __P((int, char *, void (*) (void *), void *));
  487. -pid_t safe_fork __P((void)); /* Fork & close stuff in child */
  488. -int device_script __P((char *cmd, int in, int out, int dont_wait));
  489. - /* Run `cmd' with given stdin and stdout */
  490. -pid_t run_program __P((char *prog, char **args, int must_exist,
  491. - void (*done)(void *), void *arg));
  492. - /* Run program prog with args in child */
  493. -void reopen_log __P((void)); /* (re)open the connection to syslog */
  494. -void update_link_stats __P((int)); /* Get stats at link termination */
  495. -void script_setenv __P((char *, char *, int)); /* set script env var */
  496. -void script_unsetenv __P((char *)); /* unset script env var */
  497. -void new_phase __P((int)); /* signal start of new phase */
  498. -void add_notifier __P((struct notifier **, notify_func, void *));
  499. -void remove_notifier __P((struct notifier **, notify_func, void *));
  500. -void notify __P((struct notifier *, int));
  501. -int ppp_send_config __P((int, int, u_int32_t, int, int));
  502. -int ppp_recv_config __P((int, int, u_int32_t, int, int));
  503. -
  504. -/* Procedures exported from tty.c. */
  505. -void tty_init __P((void));
  506. -
  507. -/* Procedures exported from utils.c. */
  508. -void log_packet __P((u_char *, int, char *, int));
  509. - /* Format a packet and log it with syslog */
  510. -void print_string __P((char *, int, void (*) (void *, char *, ...),
  511. - void *)); /* Format a string for output */
  512. -int slprintf __P((char *, int, char *, ...)); /* sprintf++ */
  513. -int vslprintf __P((char *, int, char *, va_list)); /* vsprintf++ */
  514. -size_t strlcpy __P((char *, const char *, size_t)); /* safe strcpy */
  515. -size_t strlcat __P((char *, const char *, size_t)); /* safe strncpy */
  516. -void dbglog __P((char *, ...)); /* log a debug message */
  517. -void info __P((char *, ...)); /* log an informational message */
  518. -void notice __P((char *, ...)); /* log a notice-level message */
  519. -void warn __P((char *, ...)); /* log a warning message */
  520. -void error __P((char *, ...)); /* log an error message */
  521. -void fatal __P((char *, ...)); /* log an error message and die(1) */
  522. -void init_pr_log __P((char *, int)); /* initialize for using pr_log */
  523. -void pr_log __P((void *, char *, ...)); /* printer fn, output to syslog */
  524. -void end_pr_log __P((void)); /* finish up after using pr_log */
  525. -void dump_packet __P((const char *, u_char *, int));
  526. - /* dump packet to debug log if interesting */
  527. -ssize_t complete_read __P((int, void *, size_t));
  528. - /* read a complete buffer */
  529. -
  530. -/* Procedures exported from auth.c */
  531. -void link_required __P((int)); /* we are starting to use the link */
  532. -void link_terminated __P((int)); /* we are finished with the link */
  533. -void link_down __P((int)); /* the LCP layer has left the Opened state */
  534. -void link_established __P((int)); /* the link is up; authenticate now */
  535. -void start_networks __P((int)); /* start all the network control protos */
  536. -void continue_networks __P((int)); /* start network [ip, etc] control protos */
  537. -void np_up __P((int, int)); /* a network protocol has come up */
  538. -void np_down __P((int, int)); /* a network protocol has gone down */
  539. -void np_finished __P((int, int)); /* a network protocol no longer needs link */
  540. -void auth_peer_fail __P((int, int));
  541. - /* peer failed to authenticate itself */
  542. -void auth_peer_success __P((int, int, int, char *, int));
  543. - /* peer successfully authenticated itself */
  544. -void auth_withpeer_fail __P((int, int));
  545. - /* we failed to authenticate ourselves */
  546. -void auth_withpeer_success __P((int, int, int));
  547. - /* we successfully authenticated ourselves */
  548. -void auth_check_options __P((void));
  549. - /* check authentication options supplied */
  550. -void auth_reset __P((int)); /* check what secrets we have */
  551. -int check_passwd __P((int, char *, int, char *, int, char **));
  552. - /* Check peer-supplied username/password */
  553. -int get_secret __P((int, char *, char *, char *, int *, int));
  554. - /* get "secret" for chap */
  555. -int get_srp_secret __P((int unit, char *client, char *server, char *secret,
  556. - int am_server));
  557. -int auth_ip_addr __P((int, u_int32_t));
  558. - /* check if IP address is authorized */
  559. -int auth_number __P((void)); /* check if remote number is authorized */
  560. -int bad_ip_adrs __P((u_int32_t));
  561. - /* check if IP address is unreasonable */
  562. -
  563. -/* Procedures exported from demand.c */
  564. -void demand_conf __P((void)); /* config interface(s) for demand-dial */
  565. -void demand_block __P((void)); /* set all NPs to queue up packets */
  566. -void demand_unblock __P((void)); /* set all NPs to pass packets */
  567. -void demand_discard __P((void)); /* set all NPs to discard packets */
  568. -void demand_rexmit __P((int)); /* retransmit saved frames for an NP */
  569. -int loop_chars __P((unsigned char *, int)); /* process chars from loopback */
  570. -int loop_frame __P((unsigned char *, int)); /* should we bring link up? */
  571. -
  572. -/* Procedures exported from multilink.c */
  573. -void mp_check_options __P((void)); /* Check multilink-related options */
  574. -int mp_join_bundle __P((void)); /* join our link to an appropriate bundle */
  575. -char *epdisc_to_str __P((struct epdisc *)); /* string from endpoint discrim. */
  576. -int str_to_epdisc __P((struct epdisc *, char *)); /* endpt disc. from str */
  577. -
  578. -/* Procedures exported from sys-*.c */
  579. -void sys_init __P((void)); /* Do system-dependent initialization */
  580. -void sys_cleanup __P((void)); /* Restore system state before exiting */
  581. -int sys_check_options __P((void)); /* Check options specified */
  582. -void sys_close __P((void)); /* Clean up in a child before execing */
  583. -int ppp_available __P((void)); /* Test whether ppp kernel support exists */
  584. -int get_pty __P((int *, int *, char *, int)); /* Get pty master/slave */
  585. -int open_ppp_loopback __P((void)); /* Open loopback for demand-dialling */
  586. -int tty_establish_ppp __P((int)); /* Turn serial port into a ppp interface */
  587. -void tty_disestablish_ppp __P((int)); /* Restore port to normal operation */
  588. -void generic_disestablish_ppp __P((int dev_fd)); /* Restore device setting */
  589. -int generic_establish_ppp __P((int dev_fd)); /* Make a ppp interface */
  590. -void make_new_bundle __P((int, int, int, int)); /* Create new bundle */
  591. -int bundle_attach __P((int)); /* Attach link to existing bundle */
  592. -void cfg_bundle __P((int, int, int, int)); /* Configure existing bundle */
  593. -void clean_check __P((void)); /* Check if line was 8-bit clean */
  594. -void set_up_tty __P((int, int)); /* Set up port's speed, parameters, etc. */
  595. -void restore_tty __P((int)); /* Restore port's original parameters */
  596. -void setdtr __P((int, int)); /* Raise or lower port's DTR line */
  597. -void output __P((int, u_char *, int)); /* Output a PPP packet */
  598. -void wait_input __P((struct timeval *));
  599. - /* Wait for input, with timeout */
  600. -void add_fd __P((int)); /* Add fd to set to wait for */
  601. -void remove_fd __P((int)); /* Remove fd from set to wait for */
  602. -int read_packet __P((u_char *)); /* Read PPP packet */
  603. -int get_loop_output __P((void)); /* Read pkts from loopback */
  604. -void tty_send_config __P((int, u_int32_t, int, int));
  605. - /* Configure i/f transmit parameters */
  606. -void tty_set_xaccm __P((ext_accm));
  607. - /* Set extended transmit ACCM */
  608. -void tty_recv_config __P((int, u_int32_t, int, int));
  609. - /* Configure i/f receive parameters */
  610. -int ccp_test __P((int, u_char *, int, int));
  611. - /* Test support for compression scheme */
  612. -void ccp_flags_set __P((int, int, int));
  613. - /* Set kernel CCP state */
  614. -int ccp_fatal_error __P((int)); /* Test for fatal decomp error in kernel */
  615. -int get_idle_time __P((int, struct ppp_idle *));
  616. - /* Find out how long link has been idle */
  617. -int get_ppp_stats __P((int, struct pppd_stats *));
  618. - /* Return link statistics */
  619. -void netif_set_mtu __P((int, int)); /* Set PPP interface MTU */
  620. -int netif_get_mtu __P((int)); /* Get PPP interface MTU */
  621. -int sifvjcomp __P((int, int, int, int));
  622. - /* Configure VJ TCP header compression */
  623. -int sifup __P((int)); /* Configure i/f up for one protocol */
  624. -int sifnpmode __P((int u, int proto, enum NPmode mode));
  625. - /* Set mode for handling packets for proto */
  626. -int sifdown __P((int)); /* Configure i/f down for one protocol */
  627. -int sifaddr __P((int, u_int32_t, u_int32_t, u_int32_t));
  628. - /* Configure IPv4 addresses for i/f */
  629. -int cifaddr __P((int, u_int32_t, u_int32_t));
  630. - /* Reset i/f IP addresses */
  631. -#ifdef INET6
  632. -int sif6addr __P((int, eui64_t, eui64_t));
  633. - /* Configure IPv6 addresses for i/f */
  634. -int cif6addr __P((int, eui64_t, eui64_t));
  635. - /* Remove an IPv6 address from i/f */
  636. -#endif
  637. -int sifdefaultroute __P((int, u_int32_t, u_int32_t));
  638. - /* Create default route through i/f */
  639. -int cifdefaultroute __P((int, u_int32_t, u_int32_t));
  640. - /* Delete default route through i/f */
  641. -int sifproxyarp __P((int, u_int32_t));
  642. - /* Add proxy ARP entry for peer */
  643. -int cifproxyarp __P((int, u_int32_t));
  644. - /* Delete proxy ARP entry for peer */
  645. -u_int32_t GetMask __P((u_int32_t)); /* Get appropriate netmask for address */
  646. -int lock __P((char *)); /* Create lock file for device */
  647. -int relock __P((int)); /* Rewrite lock file with new pid */
  648. -void unlock __P((void)); /* Delete previously-created lock file */
  649. -void logwtmp __P((const char *, const char *, const char *));
  650. - /* Write entry to wtmp file */
  651. -int get_host_seed __P((void)); /* Get host-dependent random number seed */
  652. -int have_route_to __P((u_int32_t)); /* Check if route to addr exists */
  653. -#ifdef PPP_FILTER
  654. -int set_filters __P((struct bpf_program *pass, struct bpf_program *active));
  655. - /* Set filter programs in kernel */
  656. -#endif
  657. -#ifdef IPX_CHANGE
  658. -int sipxfaddr __P((int, unsigned long, unsigned char *));
  659. -int cipxfaddr __P((int));
  660. -#endif
  661. -int get_if_hwaddr __P((u_char *addr, char *name));
  662. -char *get_first_ethernet __P((void));
  663. -
  664. -/* Procedures exported from options.c */
  665. -int setipaddr __P((char *, char **, int)); /* Set local/remote ip addresses */
  666. -int parse_args __P((int argc, char **argv));
  667. - /* Parse options from arguments given */
  668. -int options_from_file __P((char *filename, int must_exist, int check_prot,
  669. - int privileged));
  670. - /* Parse options from an options file */
  671. -int options_from_user __P((void)); /* Parse options from user's .ppprc */
  672. -int options_for_tty __P((void)); /* Parse options from /etc/ppp/options.tty */
  673. -int options_from_list __P((struct wordlist *, int privileged));
  674. - /* Parse options from a wordlist */
  675. -int getword __P((FILE *f, char *word, int *newlinep, char *filename));
  676. - /* Read a word from a file */
  677. -void option_error __P((char *fmt, ...));
  678. - /* Print an error message about an option */
  679. -int int_option __P((char *, int *));
  680. - /* Simplified number_option for decimal ints */
  681. -void add_options __P((option_t *)); /* Add extra options */
  682. -void check_options __P((void)); /* check values after all options parsed */
  683. -int override_value __P((const char *, int, const char *));
  684. - /* override value if permitted by priority */
  685. -void print_options __P((void (*) __P((void *, char *, ...)), void *));
  686. - /* print out values of all options */
  687. -
  688. -int parse_dotted_ip __P((char *, u_int32_t *));
  689. -
  690. -/*
  691. - * Hooks to enable plugins to change various things.
  692. - */
  693. -extern int (*new_phase_hook) __P((int));
  694. -extern int (*idle_time_hook) __P((struct ppp_idle *));
  695. -extern int (*holdoff_hook) __P((void));
  696. -extern int (*pap_check_hook) __P((void));
  697. -extern int (*pap_auth_hook) __P((char *user, char *passwd, char **msgp,
  698. - struct wordlist **paddrs,
  699. - struct wordlist **popts));
  700. -extern void (*pap_logout_hook) __P((void));
  701. -extern int (*pap_passwd_hook) __P((char *user, char *passwd));
  702. -extern int (*allowed_address_hook) __P((u_int32_t addr));
  703. -extern void (*ip_up_hook) __P((void));
  704. -extern void (*ip_down_hook) __P((void));
  705. -extern void (*ip_choose_hook) __P((u_int32_t *));
  706. -
  707. -extern int (*chap_check_hook) __P((void));
  708. -extern int (*chap_passwd_hook) __P((char *user, char *passwd));
  709. -
  710. -/* Let a plugin snoop sent and received packets. Useful for L2TP */
  711. -extern void (*snoop_recv_hook) __P((unsigned char *p, int len));
  712. -extern void (*snoop_send_hook) __P((unsigned char *p, int len));
  713. -
  714. -/*
  715. - * Inline versions of get/put char/short/long.
  716. - * Pointer is advanced; we assume that both arguments
  717. - * are lvalues and will already be in registers.
  718. - * cp MUST be u_char *.
  719. - */
  720. -#define GETCHAR(c, cp) { \
  721. - (c) = *(cp)++; \
  722. -}
  723. -#define PUTCHAR(c, cp) { \
  724. - *(cp)++ = (u_char) (c); \
  725. -}
  726. -
  727. -
  728. -#define GETSHORT(s, cp) { \
  729. - (s) = *(cp)++ << 8; \
  730. - (s) |= *(cp)++; \
  731. -}
  732. -#define PUTSHORT(s, cp) { \
  733. - *(cp)++ = (u_char) ((s) >> 8); \
  734. - *(cp)++ = (u_char) (s); \
  735. -}
  736. -
  737. -#define GETLONG(l, cp) { \
  738. - (l) = *(cp)++ << 8; \
  739. - (l) |= *(cp)++; (l) <<= 8; \
  740. - (l) |= *(cp)++; (l) <<= 8; \
  741. - (l) |= *(cp)++; \
  742. -}
  743. -#define PUTLONG(l, cp) { \
  744. - *(cp)++ = (u_char) ((l) >> 24); \
  745. - *(cp)++ = (u_char) ((l) >> 16); \
  746. - *(cp)++ = (u_char) ((l) >> 8); \
  747. - *(cp)++ = (u_char) (l); \
  748. -}
  749. -
  750. -#define INCPTR(n, cp) ((cp) += (n))
  751. -#define DECPTR(n, cp) ((cp) -= (n))
  752. -
  753. -/*
  754. - * System dependent definitions for user-level 4.3BSD UNIX implementation.
  755. - */
  756. -
  757. -#define TIMEOUT(r, f, t) timeout((r), (f), (t), 0)
  758. -#define UNTIMEOUT(r, f) untimeout((r), (f))
  759. -
  760. -#define BCOPY(s, d, l) memcpy(d, s, l)
  761. -#define BZERO(s, n) memset(s, 0, n)
  762. -#define BCMP(s1, s2, l) memcmp(s1, s2, l)
  763. -
  764. -#define PRINTMSG(m, l) { info("Remote message: %0.*v", l, m); }
  765. -
  766. -/*
  767. - * MAKEHEADER - Add Header fields to a packet.
  768. - */
  769. -#define MAKEHEADER(p, t) { \
  770. - PUTCHAR(PPP_ALLSTATIONS, p); \
  771. - PUTCHAR(PPP_UI, p); \
  772. - PUTSHORT(t, p); }
  773. -
  774. -/*
  775. - * Exit status values.
  776. - */
  777. -#define EXIT_OK 0
  778. -#define EXIT_FATAL_ERROR 1
  779. -#define EXIT_OPTION_ERROR 2
  780. -#define EXIT_NOT_ROOT 3
  781. -#define EXIT_NO_KERNEL_SUPPORT 4
  782. -#define EXIT_USER_REQUEST 5
  783. -#define EXIT_LOCK_FAILED 6
  784. -#define EXIT_OPEN_FAILED 7
  785. -#define EXIT_CONNECT_FAILED 8
  786. -#define EXIT_PTYCMD_FAILED 9
  787. -#define EXIT_NEGOTIATION_FAILED 10
  788. -#define EXIT_PEER_AUTH_FAILED 11
  789. -#define EXIT_IDLE_TIMEOUT 12
  790. -#define EXIT_CONNECT_TIME 13
  791. -#define EXIT_CALLBACK 14
  792. -#define EXIT_PEER_DEAD 15
  793. -#define EXIT_HANGUP 16
  794. -#define EXIT_LOOPBACK 17
  795. -#define EXIT_INIT_FAILED 18
  796. -#define EXIT_AUTH_TOPEER_FAILED 19
  797. -#ifdef MAXOCTETS
  798. -#define EXIT_TRAFFIC_LIMIT 20
  799. -#endif
  800. -#define EXIT_CNID_AUTH_FAILED 21
  801. -
  802. -/*
  803. - * Debug macros. Slightly useful for finding bugs in pppd, not particularly
  804. - * useful for finding out why your connection isn't being established.
  805. - */
  806. -#ifdef DEBUGALL
  807. -#define DEBUGMAIN 1
  808. -#define DEBUGFSM 1
  809. -#define DEBUGLCP 1
  810. -#define DEBUGIPCP 1
  811. -#define DEBUGIPV6CP 1
  812. -#define DEBUGUPAP 1
  813. -#define DEBUGCHAP 1
  814. -#endif
  815. -
  816. -#ifndef LOG_PPP /* we use LOG_LOCAL2 for syslog by default */
  817. -#if defined(DEBUGMAIN) || defined(DEBUGFSM) || defined(DEBUGSYS) \
  818. - || defined(DEBUGLCP) || defined(DEBUGIPCP) || defined(DEBUGUPAP) \
  819. - || defined(DEBUGCHAP) || defined(DEBUG) || defined(DEBUGIPV6CP)
  820. -#define LOG_PPP LOG_LOCAL2
  821. -#else
  822. -#define LOG_PPP LOG_DAEMON
  823. -#endif
  824. -#endif /* LOG_PPP */
  825. -
  826. -#ifdef DEBUGMAIN
  827. -#define MAINDEBUG(x) if (debug) dbglog x
  828. -#else
  829. -#define MAINDEBUG(x)
  830. -#endif
  831. -
  832. -#ifdef DEBUGSYS
  833. -#define SYSDEBUG(x) if (debug) dbglog x
  834. -#else
  835. -#define SYSDEBUG(x)
  836. -#endif
  837. -
  838. -#ifdef DEBUGFSM
  839. -#define FSMDEBUG(x) if (debug) dbglog x
  840. -#else
  841. -#define FSMDEBUG(x)
  842. -#endif
  843. -
  844. -#ifdef DEBUGLCP
  845. -#define LCPDEBUG(x) if (debug) dbglog x
  846. -#else
  847. -#define LCPDEBUG(x)
  848. -#endif
  849. -
  850. -#ifdef DEBUGIPCP
  851. -#define IPCPDEBUG(x) if (debug) dbglog x
  852. -#else
  853. -#define IPCPDEBUG(x)
  854. -#endif
  855. -
  856. -#ifdef DEBUGIPV6CP
  857. -#define IPV6CPDEBUG(x) if (debug) dbglog x
  858. -#else
  859. -#define IPV6CPDEBUG(x)
  860. -#endif
  861. -
  862. -#ifdef DEBUGUPAP
  863. -#define UPAPDEBUG(x) if (debug) dbglog x
  864. -#else
  865. -#define UPAPDEBUG(x)
  866. -#endif
  867. -
  868. -#ifdef DEBUGCHAP
  869. -#define CHAPDEBUG(x) if (debug) dbglog x
  870. -#else
  871. -#define CHAPDEBUG(x)
  872. -#endif
  873. -
  874. -#ifdef DEBUGIPXCP
  875. -#define IPXCPDEBUG(x) if (debug) dbglog x
  876. -#else
  877. -#define IPXCPDEBUG(x)
  878. -#endif
  879. -
  880. -#ifndef SIGTYPE
  881. -#if defined(sun) || defined(SYSV) || defined(POSIX_SOURCE)
  882. -#define SIGTYPE void
  883. -#else
  884. -#define SIGTYPE int
  885. -#endif /* defined(sun) || defined(SYSV) || defined(POSIX_SOURCE) */
  886. -#endif /* SIGTYPE */
  887. -
  888. -#ifndef MIN
  889. -#define MIN(a, b) ((a) < (b)? (a): (b))
  890. -#endif
  891. -#ifndef MAX
  892. -#define MAX(a, b) ((a) > (b)? (a): (b))
  893. -#endif
  894. -
  895. -#ifndef offsetof
  896. -#define offsetof(type, member) ((size_t) &((type *)0)->member)
  897. -#endif
  898. -
  899. -#endif /* __PPP_H__ */