| 1 |
/* |
| 2 |
* pppd-private.h - PPP daemon private declarations. |
| 3 |
* |
| 4 |
* Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved. |
| 5 |
* |
| 6 |
* Redistribution and use in source and binary forms, with or without |
| 7 |
* modification, are permitted provided that the following conditions |
| 8 |
* are met: |
| 9 |
* |
| 10 |
* 1. Redistributions of source code must retain the above copyright |
| 11 |
* notice, this list of conditions and the following disclaimer. |
| 12 |
* |
| 13 |
* 2. Redistributions in binary form must reproduce the above copyright |
| 14 |
* notice, this list of conditions and the following disclaimer in |
| 15 |
* the documentation and/or other materials provided with the |
| 16 |
* distribution. |
| 17 |
* |
| 18 |
* 3. The name "Carnegie Mellon University" must not be used to |
| 19 |
* endorse or promote products derived from this software without |
| 20 |
* prior written permission. For permission or any legal |
| 21 |
* details, please contact |
| 22 |
* Office of Technology Transfer |
| 23 |
* Carnegie Mellon University |
| 24 |
* 5000 Forbes Avenue |
| 25 |
* Pittsburgh, PA 15213-3890 |
| 26 |
* (412) 268-4387, fax: (412) 268-7395 |
| 27 |
* [email protected] |
| 28 |
* |
| 29 |
* 4. Redistributions of any form whatsoever must retain the following |
| 30 |
* acknowledgment: |
| 31 |
* "This product includes software developed by Computing Services |
| 32 |
* at Carnegie Mellon University (http://www.cmu.edu/computing/)." |
| 33 |
* |
| 34 |
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO |
| 35 |
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY |
| 36 |
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE |
| 37 |
* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 38 |
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN |
| 39 |
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING |
| 40 |
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 41 |
*/ |
| 42 |
|
| 43 |
#ifndef PPP_PPPD_PRIVATE_H |
| 44 |
#define PPP_PPPD_PRIVATE_H |
| 45 |
|
| 46 |
#include <stdio.h> /* for FILE */ |
| 47 |
#include <stdlib.h> /* for encrypt */ |
| 48 |
#include <unistd.h> /* for setkey */ |
| 49 |
#if defined(SOL2) |
| 50 |
#include <net/ppp_defs.h> |
| 51 |
#else |
| 52 |
#include <linux/ppp_defs.h> |
| 53 |
#endif |
| 54 |
|
| 55 |
#include "pppd.h" |
| 56 |
|
| 57 |
#ifdef PPP_WITH_IPV6CP |
| 58 |
#include "eui64.h" |
| 59 |
#endif |
| 60 |
|
| 61 |
/* |
| 62 |
* If PPP_DRV_NAME is not defined, use the default "ppp" as the device name. |
| 63 |
* Where should PPP_DRV_NAME come from? Do we include it here? |
| 64 |
*/ |
| 65 |
#if !defined(PPP_DRV_NAME) |
| 66 |
#if defined(SOL2) |
| 67 |
#define PPP_DRV_NAME "sppp" |
| 68 |
#else |
| 69 |
#define PPP_DRV_NAME "ppp" |
| 70 |
#endif /* defined(SOL2) */ |
| 71 |
#endif /* !defined(PPP_DRV_NAME) */ |
| 72 |
|
| 73 |
|
| 74 |
#ifndef GIDSET_TYPE |
| 75 |
#define GIDSET_TYPE gid_t |
| 76 |
#endif |
| 77 |
|
| 78 |
/* Structure representing a list of permitted IP addresses. */ |
| 79 |
struct permitted_ip { |
| 80 |
int permit; /* 1 = permit, 0 = forbid */ |
| 81 |
u_int32_t base; /* match if (addr & mask) == base */ |
| 82 |
u_int32_t mask; /* base and mask are in network byte order */ |
| 83 |
}; |
| 84 |
|
| 85 |
struct notifier { |
| 86 |
struct notifier *next; |
| 87 |
ppp_notify_fn *func; |
| 88 |
void *arg; |
| 89 |
}; |
| 90 |
|
| 91 |
/* |
| 92 |
* Global variables. |
| 93 |
*/ |
| 94 |
|
| 95 |
extern int hungup; /* Physical layer has disconnected */ |
| 96 |
extern int ifunit; /* Interface unit number */ |
| 97 |
extern char ifname[]; /* Interface name (IFNAMSIZ) */ |
| 98 |
extern char hostname[]; /* Our hostname */ |
| 99 |
extern unsigned char outpacket_buf[]; /* Buffer for outgoing packets */ |
| 100 |
extern int devfd; /* fd of underlying device */ |
| 101 |
extern int fd_ppp; /* fd for talking PPP */ |
| 102 |
extern int baud_rate; /* Current link speed in bits/sec */ |
| 103 |
extern char *progname; /* Name of this program */ |
| 104 |
extern int redirect_stderr;/* Connector's stderr should go to file */ |
| 105 |
extern char peer_authname[];/* Authenticated name of peer */ |
| 106 |
extern int auth_done[NUM_PPP]; /* Methods actually used for auth */ |
| 107 |
extern int privileged; /* We were run by real-uid root */ |
| 108 |
extern int need_holdoff; /* Need holdoff period after link terminates */ |
| 109 |
extern char **script_env; /* Environment variables for scripts */ |
| 110 |
extern int detached; /* Have detached from controlling tty */ |
| 111 |
extern GIDSET_TYPE groups[]; /* groups the user is in */ |
| 112 |
extern int ngroups; /* How many groups valid in groups */ |
| 113 |
extern int link_stats_valid; /* set if link_stats is valid */ |
| 114 |
extern int link_stats_print; /* set if link_stats is to be printed on link termination */ |
| 115 |
extern int log_to_fd; /* logging to this fd as well as syslog */ |
| 116 |
extern bool log_default; /* log_to_fd is default (stdout) */ |
| 117 |
extern char *no_ppp_msg; /* message to print if ppp not in kernel */ |
| 118 |
extern bool devnam_fixed; /* can no longer change devnam */ |
| 119 |
extern int unsuccess; /* # unsuccessful connection attempts */ |
| 120 |
extern int do_callback; /* set if we want to do callback next */ |
| 121 |
extern int doing_callback; /* set if this is a callback */ |
| 122 |
extern int error_count; /* # of times error() has been called */ |
| 123 |
extern char ppp_devname[]; /* name of PPP tty (maybe ttypx) */ |
| 124 |
extern int fd_devnull; /* fd open to /dev/null */ |
| 125 |
|
| 126 |
extern int listen_time; /* time to listen first (ms) */ |
| 127 |
extern bool bundle_eof; |
| 128 |
extern bool bundle_terminating; |
| 129 |
|
| 130 |
extern struct notifier *pidchange; /* for notifications of pid changing */ |
| 131 |
extern struct notifier *phasechange; /* for notifications of phase changes */ |
| 132 |
extern struct notifier *exitnotify; /* for notification that we're exiting */ |
| 133 |
extern struct notifier *sigreceived; /* notification of received signal */ |
| 134 |
extern struct notifier *ip_up_notifier; /* IPCP has come up */ |
| 135 |
extern struct notifier *ip_down_notifier; /* IPCP has gone down */ |
| 136 |
extern struct notifier *ipv6_up_notifier; /* IPV6CP has come up */ |
| 137 |
extern struct notifier *ipv6_down_notifier; /* IPV6CP has gone down */ |
| 138 |
extern struct notifier *auth_up_notifier; /* peer has authenticated */ |
| 139 |
extern struct notifier *link_down_notifier; /* link has gone down */ |
| 140 |
extern struct notifier *fork_notifier; /* we are a new child process */ |
| 141 |
|
| 142 |
|
| 143 |
/* Values for do_callback and doing_callback */ |
| 144 |
#define CALLBACK_DIALIN 1 /* we are expecting the call back */ |
| 145 |
#define CALLBACK_DIALOUT 2 /* we are dialling out to call back */ |
| 146 |
|
| 147 |
/* |
| 148 |
* Variables set by command-line options. |
| 149 |
*/ |
| 150 |
|
| 151 |
extern int debug; /* Debug flag */ |
| 152 |
extern int kdebugflag; /* Tell kernel to print debug messages */ |
| 153 |
extern int default_device; /* Using /dev/tty or equivalent */ |
| 154 |
extern char devnam[]; /* Device name */ |
| 155 |
extern char remote_number[MAXNAMELEN]; /* Remote telephone number, if avail. */ |
| 156 |
extern int ppp_session_number; /* Session number (eg PPPoE session) */ |
| 157 |
extern int crtscts; /* Use hardware flow control */ |
| 158 |
extern int stop_bits; /* Number of serial port stop bits */ |
| 159 |
extern bool modem; /* Use modem control lines */ |
| 160 |
extern int inspeed; /* Input/Output speed requested */ |
| 161 |
extern u_int32_t netmask; /* IP netmask to set on interface */ |
| 162 |
extern bool lockflag; /* Create lock file to lock the serial dev */ |
| 163 |
extern bool nodetach; /* Don't detach from controlling tty */ |
| 164 |
#ifdef SYSTEMD |
| 165 |
extern bool up_sdnotify; /* Notify systemd once link is up (implies nodetach) */ |
| 166 |
#endif |
| 167 |
extern bool updetach; /* Detach from controlling tty when link up */ |
| 168 |
extern bool master_detach; /* Detach when multilink master without link (options.c) */ |
| 169 |
extern char *initializer; /* Script to initialize physical link */ |
| 170 |
extern char *connect_script; /* Script to establish physical link */ |
| 171 |
extern char *disconnect_script; /* Script to disestablish physical link */ |
| 172 |
extern char *welcomer; /* Script to welcome client after connection */ |
| 173 |
extern char *ptycommand; /* Command to run on other side of pty */ |
| 174 |
extern char user[MAXNAMELEN];/* Our name for authenticating ourselves */ |
| 175 |
extern char passwd[MAXSECRETLEN]; /* Password for PAP or CHAP */ |
| 176 |
extern bool auth_required; /* Peer is required to authenticate */ |
| 177 |
extern bool persist; /* Reopen link after it goes down */ |
| 178 |
extern bool uselogin; /* Use /etc/passwd for checking PAP */ |
| 179 |
extern bool session_mgmt; /* Do session management (login records) */ |
| 180 |
extern char our_name[MAXNAMELEN];/* Our name for authentication purposes */ |
| 181 |
extern char remote_name[MAXNAMELEN]; /* Peer's name for authentication */ |
| 182 |
extern char path_upapfile[];/* Pathname of pap-secrets file */ |
| 183 |
extern char path_chapfile[];/* Pathname of chap-secrets file */ |
| 184 |
extern bool explicit_remote;/* remote_name specified with remotename opt */ |
| 185 |
extern bool demand; /* Do dial-on-demand */ |
| 186 |
extern char *ipparam; /* Extra parameter for ip up/down scripts */ |
| 187 |
extern bool cryptpap; /* Others' PAP passwords are encrypted */ |
| 188 |
extern int holdoff; /* Dead time before restarting */ |
| 189 |
extern bool holdoff_specified; /* true if user gave a holdoff value */ |
| 190 |
extern bool notty; /* Stdin/out is not a tty */ |
| 191 |
extern char *pty_socket; /* Socket to connect to pty */ |
| 192 |
extern char *record_file; /* File to record chars sent/received */ |
| 193 |
extern int maxfail; /* Max # of unsuccessful connection attempts */ |
| 194 |
extern char linkname[]; /* logical name for link */ |
| 195 |
extern bool tune_kernel; /* May alter kernel settings as necessary */ |
| 196 |
extern int connect_delay; /* Time to delay after connect script */ |
| 197 |
extern int max_data_rate; /* max bytes/sec through charshunt */ |
| 198 |
extern int req_unit; /* interface unit number to use */ |
| 199 |
extern char path_net_init[]; /* pathname of net-init script */ |
| 200 |
extern char path_net_preup[];/* pathname of net-pre-up script */ |
| 201 |
extern char path_net_down[]; /* pathname of net-down script */ |
| 202 |
extern char path_ipup[]; /* pathname of ip-up script */ |
| 203 |
extern char path_ipdown[]; /* pathname of ip-down script */ |
| 204 |
extern char path_ippreup[]; /* pathname of ip-pre-up script */ |
| 205 |
extern char req_ifname[]; /* interface name to use (IFNAMSIZ) */ |
| 206 |
extern bool multilink; /* enable multilink operation (options.c) */ |
| 207 |
extern bool noendpoint; /* don't send or accept endpt. discrim. */ |
| 208 |
extern char *bundle_name; /* bundle name for multilink */ |
| 209 |
extern bool dump_options; /* print out option values */ |
| 210 |
extern bool show_options; /* show all option names and descriptions */ |
| 211 |
extern bool dryrun; /* check everything, print options, exit */ |
| 212 |
extern int child_wait; /* # seconds to wait for children at end */ |
| 213 |
extern char *current_option; /* the name of the option being parsed */ |
| 214 |
extern int privileged_option; /* set iff the current option came from root */ |
| 215 |
extern char *option_source; /* string saying where the option came from */ |
| 216 |
extern int option_priority; /* priority of current options */ |
| 217 |
|
| 218 |
#ifdef PPP_WITH_IPV6CP |
| 219 |
extern char path_ipv6up[]; /* pathname of ipv6-up script */ |
| 220 |
extern char path_ipv6down[]; /* pathname of ipv6-down script */ |
| 221 |
#endif |
| 222 |
|
| 223 |
#if defined(PPP_WITH_EAPTLS) || defined(PPP_WITH_PEAP) |
| 224 |
#define TLS_VERIFY_NONE "none" |
| 225 |
#define TLS_VERIFY_NAME "name" |
| 226 |
#define TLS_VERIFY_SUBJECT "subject" |
| 227 |
#define TLS_VERIFY_SUFFIX "suffix" |
| 228 |
|
| 229 |
extern char *crl_dir; |
| 230 |
extern char *crl_file; |
| 231 |
extern char *ca_path; |
| 232 |
extern char *cacert_file; |
| 233 |
|
| 234 |
extern char *max_tls_version; |
| 235 |
extern bool tls_verify_key_usage; |
| 236 |
extern char *tls_verify_method; |
| 237 |
#endif /* PPP_WITH_EAPTLS || PPP_WITH_PEAP */ |
| 238 |
|
| 239 |
#ifdef PPP_WITH_EAPTLS |
| 240 |
extern char *pkcs12_file; |
| 241 |
#endif /* PPP_WITH_EAPTLS */ |
| 242 |
|
| 243 |
typedef enum { |
| 244 |
PPP_OCTETS_DIRECTION_SUM, |
| 245 |
PPP_OCTETS_DIRECTION_IN, |
| 246 |
PPP_OCTETS_DIRECTION_OUT, |
| 247 |
PPP_OCTETS_DIRECTION_MAXOVERAL, |
| 248 |
PPP_OCTETS_DIRECTION_MAXSESSION /* Same as MAXOVERALL, but a little different for RADIUS */ |
| 249 |
} session_limit_dir_t; |
| 250 |
|
| 251 |
extern unsigned int maxoctets; /* Maximum octetes per session (in bytes) */ |
| 252 |
extern session_limit_dir_t maxoctets_dir; /* Direction */ |
| 253 |
extern int maxoctets_timeout; /* Timeout for check of octets limit */ |
| 254 |
|
| 255 |
#ifdef PPP_WITH_FILTER |
| 256 |
extern struct bpf_program pass_filter; /* Filter for pkts to pass */ |
| 257 |
extern struct bpf_program active_filter; /* Filter for link-active pkts */ |
| 258 |
#endif |
| 259 |
|
| 260 |
#ifdef PPP_WITH_MSLANMAN |
| 261 |
extern bool ms_lanman; /* Use LanMan password instead of NT */ |
| 262 |
/* Has meaning only with MS-CHAP challenges */ |
| 263 |
#endif |
| 264 |
|
| 265 |
/* Values for auth_pending, auth_done */ |
| 266 |
#define PAP_WITHPEER 0x1 |
| 267 |
#define PAP_PEER 0x2 |
| 268 |
#define CHAP_WITHPEER 0x4 |
| 269 |
#define CHAP_PEER 0x8 |
| 270 |
#define EAP_WITHPEER 0x10 |
| 271 |
#define EAP_PEER 0x20 |
| 272 |
|
| 273 |
/* Values for auth_done only */ |
| 274 |
#define CHAP_MD5_WITHPEER 0x40 |
| 275 |
#define CHAP_MD5_PEER 0x80 |
| 276 |
#define CHAP_MS_SHIFT 8 /* LSB position for MS auths */ |
| 277 |
#define CHAP_MS_WITHPEER 0x100 |
| 278 |
#define CHAP_MS_PEER 0x200 |
| 279 |
#define CHAP_MS2_WITHPEER 0x400 |
| 280 |
#define CHAP_MS2_PEER 0x800 |
| 281 |
|
| 282 |
|
| 283 |
/* |
| 284 |
* This structure contains environment variables that are set or unset |
| 285 |
* by the user. |
| 286 |
*/ |
| 287 |
struct userenv { |
| 288 |
struct userenv *ue_next; |
| 289 |
char *ue_value; /* value (set only) */ |
| 290 |
bool ue_isset; /* 1 for set, 0 for unset */ |
| 291 |
bool ue_priv; /* from privileged source */ |
| 292 |
const char *ue_source; /* source name */ |
| 293 |
char ue_name[1]; /* variable name */ |
| 294 |
}; |
| 295 |
|
| 296 |
extern struct userenv *userenv_list; |
| 297 |
|
| 298 |
/* |
| 299 |
* Prototypes. |
| 300 |
*/ |
| 301 |
|
| 302 |
/* Procedures exported from main.c. */ |
| 303 |
void set_ifunit(int); /* set stuff that depends on ifunit */ |
| 304 |
void detach(void); /* Detach from controlling tty */ |
| 305 |
void die(int); /* Cleanup and exit */ |
| 306 |
void quit(void); /* like die(1) */ |
| 307 |
|
| 308 |
void record_child(int, char *, void (*) (void *), void *, int); |
| 309 |
int device_script(char *cmd, int in, int out, int dont_wait); |
| 310 |
/* Run `cmd' with given stdin and stdout */ |
| 311 |
pid_t run_program(char *prog, char * const * args, int must_exist, |
| 312 |
void (*done)(void *), void *arg, int wait); |
| 313 |
/* Run program prog with args in child */ |
| 314 |
void reopen_log(void); /* (re)open the connection to syslog */ |
| 315 |
void print_link_stats(void); /* Print stats, if available */ |
| 316 |
void reset_link_stats(int); /* Reset (init) stats when link goes up */ |
| 317 |
void new_phase(ppp_phase_t); /* signal start of new phase */ |
| 318 |
bool in_phase(ppp_phase_t); |
| 319 |
void notify(struct notifier *, int); |
| 320 |
int ppp_send_config(int, int, u_int32_t, int, int); |
| 321 |
int ppp_recv_config(int, int, u_int32_t, int, int); |
| 322 |
const char *protocol_name(int); |
| 323 |
void remove_pidfiles(void); |
| 324 |
void lock_db(void); |
| 325 |
void unlock_db(void); |
| 326 |
|
| 327 |
/* Procedures exported from tty.c. */ |
| 328 |
void tty_init(void); |
| 329 |
|
| 330 |
void print_string(char *, int, printer_func, void *); |
| 331 |
/* Format a string for output */ |
| 332 |
ssize_t complete_read(int, void *, size_t); |
| 333 |
/* read a complete buffer */ |
| 334 |
|
| 335 |
/* Procedures exported from auth.c */ |
| 336 |
void link_required(int); /* we are starting to use the link */ |
| 337 |
void start_link(int); /* bring the link up now */ |
| 338 |
void link_terminated(int); /* we are finished with the link */ |
| 339 |
void link_down(int); /* the LCP layer has left the Opened state */ |
| 340 |
void upper_layers_down(int);/* take all NCPs down */ |
| 341 |
void link_established(int); /* the link is up; authenticate now */ |
| 342 |
void start_networks(int); /* start all the network control protos */ |
| 343 |
void continue_networks(int); /* start network [ip, etc] control protos */ |
| 344 |
void np_up(int, int); /* a network protocol has come up */ |
| 345 |
void np_down(int, int); /* a network protocol has gone down */ |
| 346 |
void np_finished(int, int); /* a network protocol no longer needs link */ |
| 347 |
void auth_peer_fail(int, int); |
| 348 |
/* peer failed to authenticate itself */ |
| 349 |
void auth_peer_success(int, int, int, char *, int); |
| 350 |
/* peer successfully authenticated itself */ |
| 351 |
void auth_withpeer_fail(int, int); |
| 352 |
/* we failed to authenticate ourselves */ |
| 353 |
void auth_withpeer_success(int, int, int); |
| 354 |
/* we successfully authenticated ourselves */ |
| 355 |
void auth_check_options(void); |
| 356 |
/* check authentication options supplied */ |
| 357 |
void auth_reset(int); /* check what secrets we have */ |
| 358 |
int check_passwd(int, char *, int, char *, int, char **); |
| 359 |
/* Check peer-supplied username/password */ |
| 360 |
int get_secret(int, char *, char *, char *, int *, int); |
| 361 |
/* get "secret" for chap */ |
| 362 |
int get_srp_secret(int unit, char *client, char *server, char *secret, |
| 363 |
int am_server); |
| 364 |
int auth_ip_addr(int, u_int32_t); |
| 365 |
/* check if IP address is authorized */ |
| 366 |
int auth_number(void); /* check if remote number is authorized */ |
| 367 |
|
| 368 |
/* Procedures exported from demand.c */ |
| 369 |
void demand_conf(void); /* config interface(s) for demand-dial */ |
| 370 |
void demand_block(void); /* set all NPs to queue up packets */ |
| 371 |
void demand_unblock(void); /* set all NPs to pass packets */ |
| 372 |
void demand_discard(void); /* set all NPs to discard packets */ |
| 373 |
void demand_rexmit(int, u_int32_t); /* retransmit saved frames for an NP */ |
| 374 |
int loop_chars(unsigned char *, int); /* process chars from loopback */ |
| 375 |
int loop_frame(unsigned char *, int); /* should we bring link up? */ |
| 376 |
|
| 377 |
/* Procedures exported from sys-*.c */ |
| 378 |
void sys_init(void); /* Do system-dependent initialization */ |
| 379 |
void sys_cleanup(void); /* Restore system state before exiting */ |
| 380 |
int sys_check_options(void); /* Check options specified */ |
| 381 |
int get_pty(int *, int *, char *, int); /* Get pty master/slave */ |
| 382 |
int open_ppp_loopback(void); /* Open loopback for demand-dialling */ |
| 383 |
int tty_establish_ppp(int); /* Turn serial port into a ppp interface */ |
| 384 |
void tty_disestablish_ppp(int); /* Restore port to normal operation */ |
| 385 |
void make_new_bundle(int, int, int, int); /* Create new bundle */ |
| 386 |
int bundle_attach(int); /* Attach link to existing bundle */ |
| 387 |
void cfg_bundle(int, int, int, int); /* Configure existing bundle */ |
| 388 |
void destroy_bundle(void); /* Tell driver to destroy bundle */ |
| 389 |
void clean_check(void); /* Check if line was 8-bit clean */ |
| 390 |
void set_up_tty(int, int); /* Set up port's speed, parameters, etc. */ |
| 391 |
void restore_tty(int); /* Restore port's original parameters */ |
| 392 |
void setdtr(int, int); /* Raise or lower port's DTR line */ |
| 393 |
void output(int, unsigned char *, int); /* Output a PPP packet */ |
| 394 |
void wait_input(struct timeval *); |
| 395 |
/* Wait for input, with timeout */ |
| 396 |
void add_fd(int); /* Add fd to set to wait for */ |
| 397 |
void remove_fd(int); /* Remove fd from set to wait for */ |
| 398 |
int read_packet(unsigned char *); /* Read PPP packet */ |
| 399 |
int get_loop_output(void); /* Read pkts from loopback */ |
| 400 |
void tty_send_config(int, u_int32_t, int, int); |
| 401 |
/* Configure i/f transmit parameters */ |
| 402 |
void tty_set_xaccm(ext_accm); |
| 403 |
/* Set extended transmit ACCM */ |
| 404 |
void tty_recv_config(int, u_int32_t, int, int); |
| 405 |
/* Configure i/f receive parameters */ |
| 406 |
int ccp_test(int, unsigned char *, int, int); |
| 407 |
/* Test support for compression scheme */ |
| 408 |
void ccp_flags_set(int, int, int); |
| 409 |
/* Set kernel CCP state */ |
| 410 |
int ccp_fatal_error(int); /* Test for fatal decomp error in kernel */ |
| 411 |
int get_idle_time(int, struct ppp_idle *); |
| 412 |
/* Find out how long link has been idle */ |
| 413 |
int get_ppp_stats(int, struct pppd_stats *); |
| 414 |
/* Return link statistics */ |
| 415 |
int sifvjcomp(int, int, int, int); |
| 416 |
/* Configure VJ TCP header compression */ |
| 417 |
int sifup(int); /* Configure i/f up for one protocol */ |
| 418 |
int sifnpmode(int u, int proto, enum NPmode mode); |
| 419 |
/* Set mode for handling packets for proto */ |
| 420 |
int sifdown(int); /* Configure i/f down for one protocol */ |
| 421 |
int sifaddr(int, u_int32_t, u_int32_t, u_int32_t); |
| 422 |
/* Configure IPv4 addresses for i/f */ |
| 423 |
int cifaddr(int, u_int32_t, u_int32_t); |
| 424 |
/* Reset i/f IP addresses */ |
| 425 |
#ifdef PPP_WITH_IPV6CP |
| 426 |
int sif6up(int); /* Configure i/f up for IPv6 */ |
| 427 |
int sif6down(int); /* Configure i/f down for IPv6 */ |
| 428 |
int sif6addr(int, eui64_t, eui64_t); |
| 429 |
/* Configure IPv6 addresses for i/f */ |
| 430 |
int cif6addr(int, eui64_t, eui64_t); |
| 431 |
/* Remove an IPv6 address from i/f */ |
| 432 |
#endif |
| 433 |
int sifdefaultroute(int, u_int32_t, u_int32_t, bool replace_default_rt); |
| 434 |
/* Create default route through i/f */ |
| 435 |
int cifdefaultroute(int, u_int32_t, u_int32_t); |
| 436 |
/* Delete default route through i/f */ |
| 437 |
#ifdef PPP_WITH_IPV6CP |
| 438 |
int sif6defaultroute(int, eui64_t, eui64_t); |
| 439 |
/* Create default IPv6 route through i/f */ |
| 440 |
int cif6defaultroute(int, eui64_t, eui64_t); |
| 441 |
/* Delete default IPv6 route through i/f */ |
| 442 |
#endif |
| 443 |
int sifproxyarp(int, u_int32_t); |
| 444 |
/* Add proxy ARP entry for peer */ |
| 445 |
int cifproxyarp(int, u_int32_t); |
| 446 |
/* Delete proxy ARP entry for peer */ |
| 447 |
u_int32_t GetMask(u_int32_t); /* Get appropriate netmask for address */ |
| 448 |
int mkdir_recursive(const char *); /* Recursively create directory */ |
| 449 |
int lock(char *); /* Create lock file for device */ |
| 450 |
int relock(int); /* Rewrite lock file with new pid */ |
| 451 |
void unlock(void); /* Delete previously-created lock file */ |
| 452 |
void logwtmp(const char *, const char *, const char *); |
| 453 |
/* Write entry to wtmp file */ |
| 454 |
int get_host_seed(void); /* Get host-dependent random number seed */ |
| 455 |
int have_route_to(u_int32_t); /* Check if route to addr exists */ |
| 456 |
#ifdef PPP_WITH_FILTER |
| 457 |
int set_filters(struct bpf_program *pass, struct bpf_program *active); |
| 458 |
/* Set filter programs in kernel */ |
| 459 |
#endif |
| 460 |
int get_if_hwaddr(unsigned char *addr, char *name); |
| 461 |
int get_first_ether_hwaddr(unsigned char *addr); |
| 462 |
|
| 463 |
/* Procedures exported from options.c */ |
| 464 |
int setipaddr(char *, char **, int); /* Set local/remote ip addresses */ |
| 465 |
int parse_args(int argc, char **argv); |
| 466 |
/* Parse options from arguments given */ |
| 467 |
int getword(FILE *f, char *word, int *newlinep, char *filename); |
| 468 |
/* Read a word from a file */ |
| 469 |
int options_from_user(void); /* Parse options from user's .ppprc */ |
| 470 |
int options_for_tty(void); /* Parse options from /etc/ppp/options.tty */ |
| 471 |
struct wordlist; |
| 472 |
int options_from_list(struct wordlist *, int privileged); |
| 473 |
/* Parse options from a wordlist */ |
| 474 |
void check_options(void); /* check values after all options parsed */ |
| 475 |
int override_value(char *, int, const char *); |
| 476 |
/* override value if permitted by priority */ |
| 477 |
void print_options(printer_func, void *); |
| 478 |
/* print out values of all options */ |
| 479 |
void showopts(void); |
| 480 |
/* show all option names and description */ |
| 481 |
int parse_dotted_ip(char *, u_int32_t *); |
| 482 |
|
| 483 |
/* |
| 484 |
* Inline versions of get/put char/short/long. |
| 485 |
* Pointer is advanced; we assume that both arguments |
| 486 |
* are lvalues and will already be in registers. |
| 487 |
* cp MUST be unsigned char *. |
| 488 |
*/ |
| 489 |
#define GETCHAR(c, cp) { \ |
| 490 |
(c) = *(cp)++; \ |
| 491 |
} |
| 492 |
#define PUTCHAR(c, cp) { \ |
| 493 |
*(cp)++ = (unsigned char) (c); \ |
| 494 |
} |
| 495 |
|
| 496 |
|
| 497 |
#define GETSHORT(s, cp) { \ |
| 498 |
(s) = *(cp)++ << 8; \ |
| 499 |
(s) |= *(cp)++; \ |
| 500 |
} |
| 501 |
#define PUTSHORT(s, cp) { \ |
| 502 |
*(cp)++ = (unsigned char) ((s) >> 8); \ |
| 503 |
*(cp)++ = (unsigned char) (s); \ |
| 504 |
} |
| 505 |
|
| 506 |
#define GETLONG(l, cp) { \ |
| 507 |
(l) = *(cp)++ << 8; \ |
| 508 |
(l) |= *(cp)++; (l) <<= 8; \ |
| 509 |
(l) |= *(cp)++; (l) <<= 8; \ |
| 510 |
(l) |= *(cp)++; \ |
| 511 |
} |
| 512 |
#define PUTLONG(l, cp) { \ |
| 513 |
*(cp)++ = (unsigned char) ((l) >> 24); \ |
| 514 |
*(cp)++ = (unsigned char) ((l) >> 16); \ |
| 515 |
*(cp)++ = (unsigned char) ((l) >> 8); \ |
| 516 |
*(cp)++ = (unsigned char) (l); \ |
| 517 |
} |
| 518 |
|
| 519 |
#define INCPTR(n, cp) ((cp) += (n)) |
| 520 |
#define DECPTR(n, cp) ((cp) -= (n)) |
| 521 |
|
| 522 |
/* |
| 523 |
* System dependent definitions for user-level 4.3BSD UNIX implementation. |
| 524 |
*/ |
| 525 |
|
| 526 |
#define TIMEOUT(r, f, t) ppp_timeout((r), (f), (t), 0) |
| 527 |
#define UNTIMEOUT(r, f) ppp_untimeout((r), (f)) |
| 528 |
|
| 529 |
#define BCOPY(s, d, l) memcpy(d, s, l) |
| 530 |
#define BZERO(s, n) memset(s, 0, n) |
| 531 |
#define BCMP(s1, s2, l) memcmp(s1, s2, l) |
| 532 |
|
| 533 |
#define PRINTMSG(m, l) { info("Remote message: %0.*v", l, m); } |
| 534 |
|
| 535 |
/* |
| 536 |
* MAKEHEADER - Add Header fields to a packet. |
| 537 |
*/ |
| 538 |
#define MAKEHEADER(p, t) { \ |
| 539 |
PUTCHAR(PPP_ALLSTATIONS, p); \ |
| 540 |
PUTCHAR(PPP_UI, p); \ |
| 541 |
PUTSHORT(t, p); } |
| 542 |
|
| 543 |
/* |
| 544 |
* Debug macros. Slightly useful for finding bugs in pppd, not particularly |
| 545 |
* useful for finding out why your connection isn't being established. |
| 546 |
*/ |
| 547 |
#ifdef DEBUGALL |
| 548 |
#define DEBUGMAIN 1 |
| 549 |
#define DEBUGFSM 1 |
| 550 |
#define DEBUGLCP 1 |
| 551 |
#define DEBUGIPCP 1 |
| 552 |
#define DEBUGIPV6CP 1 |
| 553 |
#define DEBUGUPAP 1 |
| 554 |
#define DEBUGCHAP 1 |
| 555 |
#endif |
| 556 |
|
| 557 |
#define LOG_PPP LOG_LOCAL2 |
| 558 |
#ifndef LOG_PPP /* we use LOG_LOCAL2 for syslog by default */ |
| 559 |
#if defined(DEBUGMAIN) || defined(DEBUGFSM) || defined(DEBUGSYS) \ |
| 560 |
|| defined(DEBUGLCP) || defined(DEBUGIPCP) || defined(DEBUGUPAP) \ |
| 561 |
|| defined(DEBUGCHAP) || defined(DEBUG) || defined(DEBUGIPV6CP) |
| 562 |
#define LOG_PPP LOG_LOCAL2 |
| 563 |
#else |
| 564 |
#define LOG_PPP LOG_DAEMON |
| 565 |
#endif |
| 566 |
#endif /* LOG_PPP */ |
| 567 |
|
| 568 |
#ifdef DEBUGMAIN |
| 569 |
#define MAINDEBUG(x) if (debug) dbglog x |
| 570 |
#else |
| 571 |
#define MAINDEBUG(x) |
| 572 |
#endif |
| 573 |
|
| 574 |
#ifdef DEBUGSYS |
| 575 |
#define SYSDEBUG(x) if (debug) dbglog x |
| 576 |
#else |
| 577 |
#define SYSDEBUG(x) |
| 578 |
#endif |
| 579 |
|
| 580 |
#ifdef DEBUGFSM |
| 581 |
#define FSMDEBUG(x) if (debug) dbglog x |
| 582 |
#else |
| 583 |
#define FSMDEBUG(x) |
| 584 |
#endif |
| 585 |
|
| 586 |
#ifdef DEBUGLCP |
| 587 |
#define LCPDEBUG(x) if (debug) dbglog x |
| 588 |
#else |
| 589 |
#define LCPDEBUG(x) |
| 590 |
#endif |
| 591 |
|
| 592 |
#ifdef DEBUGIPCP |
| 593 |
#define IPCPDEBUG(x) if (debug) dbglog x |
| 594 |
#else |
| 595 |
#define IPCPDEBUG(x) |
| 596 |
#endif |
| 597 |
|
| 598 |
#ifdef DEBUGIPV6CP |
| 599 |
#define IPV6CPDEBUG(x) if (debug) dbglog x |
| 600 |
#else |
| 601 |
#define IPV6CPDEBUG(x) |
| 602 |
#endif |
| 603 |
|
| 604 |
#ifdef DEBUGUPAP |
| 605 |
#define UPAPDEBUG(x) if (debug) dbglog x |
| 606 |
#else |
| 607 |
#define UPAPDEBUG(x) |
| 608 |
#endif |
| 609 |
|
| 610 |
#ifdef DEBUGCHAP |
| 611 |
#define CHAPDEBUG(x) if (debug) dbglog x |
| 612 |
#else |
| 613 |
#define CHAPDEBUG(x) |
| 614 |
#endif |
| 615 |
|
| 616 |
#ifndef SIGTYPE |
| 617 |
#if defined(sun) || defined(SYSV) || defined(POSIX_SOURCE) |
| 618 |
#define SIGTYPE void |
| 619 |
#else |
| 620 |
#define SIGTYPE int |
| 621 |
#endif /* defined(sun) || defined(SYSV) || defined(POSIX_SOURCE) */ |
| 622 |
#endif /* SIGTYPE */ |
| 623 |
|
| 624 |
#ifndef MIN |
| 625 |
#define MIN(a, b) ((a) < (b)? (a): (b)) |
| 626 |
#endif |
| 627 |
#ifndef MAX |
| 628 |
#define MAX(a, b) ((a) > (b)? (a): (b)) |
| 629 |
#endif |
| 630 |
|
| 631 |
#ifndef offsetof |
| 632 |
#define offsetof(type, member) ((size_t) &((type *)0)->member) |
| 633 |
#endif |
| 634 |
|
| 635 |
#endif |