17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * pppd.h - PPP daemon global declarations. 37c478bd9Sstevel@tonic-gate * 4*f53eecf5SJames Carlson * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 57c478bd9Sstevel@tonic-gate * Use is subject to license terms. 67c478bd9Sstevel@tonic-gate * 77c478bd9Sstevel@tonic-gate * Permission to use, copy, modify, and distribute this software and its 87c478bd9Sstevel@tonic-gate * documentation is hereby granted, provided that the above copyright 97c478bd9Sstevel@tonic-gate * notice appears in all copies. 107c478bd9Sstevel@tonic-gate * 117c478bd9Sstevel@tonic-gate * SUN MAKES NO REPRESENTATION OR WARRANTIES ABOUT THE SUITABILITY OF 127c478bd9Sstevel@tonic-gate * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 137c478bd9Sstevel@tonic-gate * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 147c478bd9Sstevel@tonic-gate * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR 157c478bd9Sstevel@tonic-gate * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR 167c478bd9Sstevel@tonic-gate * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES 177c478bd9Sstevel@tonic-gate * 187c478bd9Sstevel@tonic-gate * Copyright (c) 1989 Carnegie Mellon University. 197c478bd9Sstevel@tonic-gate * All rights reserved. 207c478bd9Sstevel@tonic-gate * 217c478bd9Sstevel@tonic-gate * Redistribution and use in source and binary forms are permitted 227c478bd9Sstevel@tonic-gate * provided that the above copyright notice and this paragraph are 237c478bd9Sstevel@tonic-gate * duplicated in all such forms and that any documentation, 247c478bd9Sstevel@tonic-gate * advertising materials, and other materials related to such 257c478bd9Sstevel@tonic-gate * distribution and use acknowledge that the software was developed 267c478bd9Sstevel@tonic-gate * by Carnegie Mellon University. The name of the 277c478bd9Sstevel@tonic-gate * University may not be used to endorse or promote products derived 287c478bd9Sstevel@tonic-gate * from this software without specific prior written permission. 297c478bd9Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 307c478bd9Sstevel@tonic-gate * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 317c478bd9Sstevel@tonic-gate * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 327c478bd9Sstevel@tonic-gate * 337c478bd9Sstevel@tonic-gate * $Id: pppd.h,v 1.54 2000/04/15 10:10:25 paulus Exp $ 347c478bd9Sstevel@tonic-gate */ 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #ifndef __PPPD_H__ 377c478bd9Sstevel@tonic-gate #define __PPPD_H__ 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #include <stdio.h> /* for FILE */ 407c478bd9Sstevel@tonic-gate #include <limits.h> /* for NGROUPS_MAX */ 417c478bd9Sstevel@tonic-gate #include <sys/param.h> /* for MAXPATHLEN and BSD4_4, if defined */ 427c478bd9Sstevel@tonic-gate #include <sys/types.h> /* for u_int32_t, if defined */ 437c478bd9Sstevel@tonic-gate #include <sys/time.h> /* for struct timeval */ 447c478bd9Sstevel@tonic-gate #include <net/ppp_defs.h> 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate #if defined(__STDC__) 477c478bd9Sstevel@tonic-gate #include <stdarg.h> 487c478bd9Sstevel@tonic-gate #define __V(x) x 497c478bd9Sstevel@tonic-gate #else 507c478bd9Sstevel@tonic-gate #include <varargs.h> 517c478bd9Sstevel@tonic-gate #define __V(x) (va_alist) va_dcl 527c478bd9Sstevel@tonic-gate #define const 537c478bd9Sstevel@tonic-gate #define volatile 547c478bd9Sstevel@tonic-gate #endif /* __STDC__ */ 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate #ifdef INET6 577c478bd9Sstevel@tonic-gate #include "eui64.h" 587c478bd9Sstevel@tonic-gate #endif /* INET6 */ 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate #ifdef HAVE_MULTILINK 617c478bd9Sstevel@tonic-gate #include "tdb.h" 627c478bd9Sstevel@tonic-gate #endif 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate #ifdef __cplusplus 657c478bd9Sstevel@tonic-gate extern "C" { 667c478bd9Sstevel@tonic-gate #endif 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate /* 697c478bd9Sstevel@tonic-gate * Limits. 707c478bd9Sstevel@tonic-gate */ 717c478bd9Sstevel@tonic-gate #define NUM_PPP 1 /* One PPP interface supported (per process) */ 727c478bd9Sstevel@tonic-gate #define MAXWORDLEN 1024 /* max length of word in file (incl null) */ 737c478bd9Sstevel@tonic-gate #define MAXARGS 1 /* max # args to a command */ 747c478bd9Sstevel@tonic-gate #define MAXNAMELEN 256 /* max length of name for auth */ 757c478bd9Sstevel@tonic-gate #define MAXSECRETLEN 256 /* max length of password or secret */ 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate #ifndef MAXHOSTNAMELEN 787c478bd9Sstevel@tonic-gate #define MAXHOSTNAMELEN MAXNAMELEN /* max length of hostname */ 797c478bd9Sstevel@tonic-gate #endif /* MAXHOSTNAMELEN */ 807c478bd9Sstevel@tonic-gate 817c478bd9Sstevel@tonic-gate /* 827c478bd9Sstevel@tonic-gate * If this evaluates non-zero, then sifup() must be called before 837c478bd9Sstevel@tonic-gate * sifaddr(). 847c478bd9Sstevel@tonic-gate */ 857c478bd9Sstevel@tonic-gate #define SIFUPFIRST \ 867c478bd9Sstevel@tonic-gate (defined(SVR4) && (defined(SNI) || defined(__USLC__))) 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate /* 897c478bd9Sstevel@tonic-gate * If this evaluates non-zero, then sif6up() must be called before 907c478bd9Sstevel@tonic-gate * sif6addr(). 917c478bd9Sstevel@tonic-gate */ 927c478bd9Sstevel@tonic-gate #define SIF6UPFIRST \ 937c478bd9Sstevel@tonic-gate (defined(__linux__) || (defined(SVR4) && (defined(SNI) || defined(__USLC__)))) 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate /* 967c478bd9Sstevel@tonic-gate * Option descriptor structure. 977c478bd9Sstevel@tonic-gate */ 987c478bd9Sstevel@tonic-gate typedef unsigned char bool; 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate enum opt_type { 1017c478bd9Sstevel@tonic-gate o_special_noarg = 0, 1027c478bd9Sstevel@tonic-gate o_special = 1, 1037c478bd9Sstevel@tonic-gate o_bool, 1047c478bd9Sstevel@tonic-gate o_int, 1057c478bd9Sstevel@tonic-gate o_uint32, 1067c478bd9Sstevel@tonic-gate o_string 1077c478bd9Sstevel@tonic-gate }; 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate typedef struct { 1107c478bd9Sstevel@tonic-gate char *name; /* name of the option */ 1117c478bd9Sstevel@tonic-gate enum opt_type type; 1127c478bd9Sstevel@tonic-gate void *addr; 1137c478bd9Sstevel@tonic-gate char *description; 1147c478bd9Sstevel@tonic-gate int flags; 1157c478bd9Sstevel@tonic-gate void *addr2; 1167c478bd9Sstevel@tonic-gate int upper_limit; 1177c478bd9Sstevel@tonic-gate int lower_limit; 1187c478bd9Sstevel@tonic-gate } option_t; 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate /* 1217c478bd9Sstevel@tonic-gate * Values for flags. 1227c478bd9Sstevel@tonic-gate */ 1237c478bd9Sstevel@tonic-gate #define OPT_VALUE 0xff /* mask for presupplied value */ 1247c478bd9Sstevel@tonic-gate #define OPT_HEX 0x100 /* int option is in hex */ 1257c478bd9Sstevel@tonic-gate #define OPT_NOARG 0x200 /* option doesn't take argument */ 1267c478bd9Sstevel@tonic-gate #define OPT_OR 0x400 /* OR in argument to value */ 1277c478bd9Sstevel@tonic-gate #define OPT_INC 0x800 /* increment value */ 1287c478bd9Sstevel@tonic-gate #define OPT_PRIV 0x1000 /* privileged option */ 1297c478bd9Sstevel@tonic-gate #define OPT_STATIC 0x2000 /* string option goes into static array */ 1307c478bd9Sstevel@tonic-gate #define OPT_LLIMIT 0x4000 /* check value against lower limit */ 1317c478bd9Sstevel@tonic-gate #define OPT_ULIMIT 0x8000 /* check value against upper limit */ 1327c478bd9Sstevel@tonic-gate #define OPT_LIMITS (OPT_LLIMIT|OPT_ULIMIT) 1337c478bd9Sstevel@tonic-gate #define OPT_ZEROOK 0x10000 /* 0 value is OK even if not within limits */ 1347c478bd9Sstevel@tonic-gate #define OPT_NOINCR 0x20000 /* value mustn't be increased */ 1357c478bd9Sstevel@tonic-gate #define OPT_ZEROINF 0x40000 /* with OPT_NOINCR, 0 == infinity */ 1367c478bd9Sstevel@tonic-gate #define OPT_DISABLE 0x80000 /* ignore option */ 1377c478bd9Sstevel@tonic-gate #define OPT_A2INFO 0x100000 /* addr2 -> option_info to update */ 1387c478bd9Sstevel@tonic-gate #define OPT_A2COPY 0x200000 /* addr2 -> second location to rcv value */ 1397c478bd9Sstevel@tonic-gate #define OPT_ENABLE 0x400000 /* use *addr2 as enable for option */ 1407c478bd9Sstevel@tonic-gate #define OPT_PRIVFIX 0x800000 /* can't be overridden if noauth */ 1417c478bd9Sstevel@tonic-gate #define OPT_PREPASS 0x1000000 /* do this opt in pre-pass to find device */ 1427c478bd9Sstevel@tonic-gate #define OPT_INITONLY 0x2000000 /* option can only be set in init phase */ 1437c478bd9Sstevel@tonic-gate #define OPT_DEVEQUIV 0x4000000 /* equiv to device name */ 1447c478bd9Sstevel@tonic-gate #define OPT_DEVNAM (OPT_PREPASS | OPT_INITONLY | OPT_DEVEQUIV) 1457c478bd9Sstevel@tonic-gate 1467c478bd9Sstevel@tonic-gate #define OPT_VAL(x) ((x) & OPT_VALUE) 1477c478bd9Sstevel@tonic-gate 1487c478bd9Sstevel@tonic-gate #ifndef GIDSET_TYPE 1497c478bd9Sstevel@tonic-gate #define GIDSET_TYPE gid_t 1507c478bd9Sstevel@tonic-gate #endif /* GIDSET_TYPE */ 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate /* 1537c478bd9Sstevel@tonic-gate * Structure representing a list of permitted IP addresses. 1547c478bd9Sstevel@tonic-gate */ 1557c478bd9Sstevel@tonic-gate struct permitted_ip { 1567c478bd9Sstevel@tonic-gate int permit; /* 1 = permit, 0 = forbid */ 1577c478bd9Sstevel@tonic-gate u_int32_t base; /* match if (addr & mask) == base */ 1587c478bd9Sstevel@tonic-gate u_int32_t mask; /* base and mask are in network byte order */ 1597c478bd9Sstevel@tonic-gate }; 1607c478bd9Sstevel@tonic-gate 1617c478bd9Sstevel@tonic-gate /* 1627c478bd9Sstevel@tonic-gate * Unfortunately, the linux kernel driver uses a different structure 1637c478bd9Sstevel@tonic-gate * for statistics from the rest of the ports. 1647c478bd9Sstevel@tonic-gate * This structure serves as a common representation for the bits 1657c478bd9Sstevel@tonic-gate * pppd needs. 1667c478bd9Sstevel@tonic-gate */ 1677c478bd9Sstevel@tonic-gate struct pppd_stats { 1687c478bd9Sstevel@tonic-gate ppp_counter_t bytes_in; 1697c478bd9Sstevel@tonic-gate ppp_counter_t bytes_out; 1707c478bd9Sstevel@tonic-gate ppp_counter_t pkts_in; 1717c478bd9Sstevel@tonic-gate ppp_counter_t pkts_out; 1727c478bd9Sstevel@tonic-gate }; 1737c478bd9Sstevel@tonic-gate 1747c478bd9Sstevel@tonic-gate /* 1757c478bd9Sstevel@tonic-gate * Used for storing a sequence of words. Usually malloced. 1767c478bd9Sstevel@tonic-gate */ 1777c478bd9Sstevel@tonic-gate struct wordlist { 1787c478bd9Sstevel@tonic-gate struct wordlist *next; 1797c478bd9Sstevel@tonic-gate char *word; 1807c478bd9Sstevel@tonic-gate }; 1817c478bd9Sstevel@tonic-gate 1827c478bd9Sstevel@tonic-gate /* 1837c478bd9Sstevel@tonic-gate * Global variables. 1847c478bd9Sstevel@tonic-gate */ 1857c478bd9Sstevel@tonic-gate extern bool hungup; /* Physical layer has disconnected */ 1867c478bd9Sstevel@tonic-gate extern int ifunit; /* Interface unit number */ 1877c478bd9Sstevel@tonic-gate extern char ifname[32]; /* Interface name */ 1887c478bd9Sstevel@tonic-gate extern int ttyfd; /* Serial device file descriptor */ 1897c478bd9Sstevel@tonic-gate extern char hostname[]; /* Our hostname */ 1907c478bd9Sstevel@tonic-gate extern u_char outpacket_buf[]; /* Buffer for outgoing packets */ 1917c478bd9Sstevel@tonic-gate extern int phase; /* Current state of link - see values below */ 1927c478bd9Sstevel@tonic-gate extern int baud_rate; /* Current link speed in bits/sec */ 1937c478bd9Sstevel@tonic-gate extern char *progname; /* Name of this program */ 1947c478bd9Sstevel@tonic-gate extern int redirect_stderr;/* Connector's stderr should go to file */ 1957c478bd9Sstevel@tonic-gate extern char peer_authname[];/* Authenticated name of peer */ 1967c478bd9Sstevel@tonic-gate extern bool privileged; /* We were run by real-uid root */ 1977c478bd9Sstevel@tonic-gate extern bool need_holdoff; /* Need holdoff period after link terminates */ 1987c478bd9Sstevel@tonic-gate extern char **script_env; /* Environment variables for scripts */ 1997c478bd9Sstevel@tonic-gate extern bool detached; /* Have detached from controlling tty */ 2007c478bd9Sstevel@tonic-gate extern GIDSET_TYPE groups[NGROUPS_MAX]; /* groups the user is in */ 2017c478bd9Sstevel@tonic-gate extern int ngroups; /* How many groups valid in groups */ 2027c478bd9Sstevel@tonic-gate extern struct pppd_stats link_stats; /* byte/packet counts etc. for link */ 2037c478bd9Sstevel@tonic-gate extern bool link_stats_valid; /* set if link_stats is valid */ 2047c478bd9Sstevel@tonic-gate extern int link_connect_time; /* time the link was up for */ 2057c478bd9Sstevel@tonic-gate extern int using_pty; /* using pty as device (notty or pty opt.) */ 2067c478bd9Sstevel@tonic-gate extern int log_to_fd; /* logging to this fd as well as syslog */ 2077c478bd9Sstevel@tonic-gate extern bool log_to_file; /* log_to_fd is a file */ 2087c478bd9Sstevel@tonic-gate extern bool log_to_specific_fd; /* log_to_fd was specified by user */ 2097c478bd9Sstevel@tonic-gate extern char *no_ppp_msg; /* message to print if ppp not in kernel */ 2107c478bd9Sstevel@tonic-gate extern volatile int status; /* exit status for pppd */ 2117c478bd9Sstevel@tonic-gate extern int devnam_fixed; /* can no longer change devnam */ 2127c478bd9Sstevel@tonic-gate extern int unsuccess; /* # unsuccessful connection attempts */ 2137c478bd9Sstevel@tonic-gate extern int do_callback; /* set if we want to do callback next */ 2147c478bd9Sstevel@tonic-gate extern int doing_callback; /* set if this is a callback */ 2157c478bd9Sstevel@tonic-gate extern u_char nak_buffer[]; /* where we construct a nak packet */ 2167c478bd9Sstevel@tonic-gate extern u_char inpacket_buf[]; /* buffer for incoming packet */ 2177c478bd9Sstevel@tonic-gate extern bool direct_tty; /* use standard input directly; not a tty */ 2187c478bd9Sstevel@tonic-gate extern int absmax_mru; /* absolute maximum link (not i/f) MRU */ 2197c478bd9Sstevel@tonic-gate extern int absmax_mtu; /* absolute maximum link (not i/f) MTU */ 2207c478bd9Sstevel@tonic-gate extern int pty_slave; /* slave side of PTY, if any */ 2217c478bd9Sstevel@tonic-gate extern bool early_log; /* avoid logging to stdout */ 2227c478bd9Sstevel@tonic-gate 2237c478bd9Sstevel@tonic-gate /* 2247c478bd9Sstevel@tonic-gate * Values for do_callback and doing_callback. 2257c478bd9Sstevel@tonic-gate */ 2267c478bd9Sstevel@tonic-gate #define CALLBACK_DIALIN 1 /* we are expecting the call back */ 2277c478bd9Sstevel@tonic-gate #define CALLBACK_DIALOUT 2 /* we are dialling out to call back */ 2287c478bd9Sstevel@tonic-gate 2297c478bd9Sstevel@tonic-gate /* 2307c478bd9Sstevel@tonic-gate * Variables set by command-line options. 2317c478bd9Sstevel@tonic-gate */ 2327c478bd9Sstevel@tonic-gate extern int debug; /* Debug flag */ 2337c478bd9Sstevel@tonic-gate extern int kdebugflag; /* Tell kernel to print debug messages */ 2347c478bd9Sstevel@tonic-gate extern int default_device; /* Using /dev/tty or equivalent */ 2357c478bd9Sstevel@tonic-gate extern char devnam[MAXPATHLEN]; /* Device name */ 2367c478bd9Sstevel@tonic-gate extern char ppp_devnam[MAXPATHLEN]; /* Device name (might be pty) */ 2377c478bd9Sstevel@tonic-gate extern int crtscts; /* Use hardware flow control */ 2387c478bd9Sstevel@tonic-gate extern bool modem; /* Use modem control lines */ 2397c478bd9Sstevel@tonic-gate extern int inspeed; /* Input/Output speed requested */ 2407c478bd9Sstevel@tonic-gate extern u_int32_t netmask; /* IP netmask to set on interface */ 2417c478bd9Sstevel@tonic-gate extern bool lockflag; /* Create lock file to lock the serial dev */ 2427c478bd9Sstevel@tonic-gate extern bool nodetach; /* Don't detach from controlling tty */ 2437c478bd9Sstevel@tonic-gate extern bool updetach; /* Detach from controlling tty when link up */ 2447c478bd9Sstevel@tonic-gate extern char *initializer; /* Script to initialize physical link */ 2457c478bd9Sstevel@tonic-gate extern char *connect_script; /* Script to establish physical link */ 2467c478bd9Sstevel@tonic-gate extern char *disconnect_script; /* Script to disestablish physical link */ 2477c478bd9Sstevel@tonic-gate extern char *welcomer; /* Script to welcome client after connection */ 2487c478bd9Sstevel@tonic-gate extern char *ptycommand; /* Command to run on other side of pty */ 2497c478bd9Sstevel@tonic-gate extern int maxconnect; /* Maximum connect time (seconds) */ 2507c478bd9Sstevel@tonic-gate extern char user[MAXNAMELEN];/* Our name for authenticating ourselves */ 2517c478bd9Sstevel@tonic-gate extern char passwd[MAXSECRETLEN]; /* Password for PAP or CHAP */ 2527c478bd9Sstevel@tonic-gate extern bool auth_required; /* Peer is required to authenticate */ 2537c478bd9Sstevel@tonic-gate extern bool persist; /* Reopen link after it goes down */ 2547c478bd9Sstevel@tonic-gate extern bool uselogin; /* Use /etc/passwd for checking PAP */ 2557c478bd9Sstevel@tonic-gate extern char our_name[MAXNAMELEN];/* Our name for authentication purposes */ 2567c478bd9Sstevel@tonic-gate extern char remote_name[MAXNAMELEN]; /* Peer's name for authentication */ 2577c478bd9Sstevel@tonic-gate extern bool explicit_remote;/* remote_name specified with remotename opt */ 2587c478bd9Sstevel@tonic-gate extern bool demand; /* Do dial-on-demand */ 2597c478bd9Sstevel@tonic-gate extern char *ipparam; /* Extra parameter for ip up/down scripts */ 2607c478bd9Sstevel@tonic-gate extern bool cryptpap; /* Others' PAP passwords are encrypted */ 2617c478bd9Sstevel@tonic-gate extern int idle_time_limit;/* Shut down link if idle for this long */ 2627c478bd9Sstevel@tonic-gate extern int holdoff; /* Dead time before restarting */ 2637c478bd9Sstevel@tonic-gate extern bool holdoff_specified; /* true if user gave a holdoff value */ 2647c478bd9Sstevel@tonic-gate extern bool notty; /* Stdin/out is not a tty */ 2657c478bd9Sstevel@tonic-gate extern char *pty_socket; /* Socket to connect to pty */ 2667c478bd9Sstevel@tonic-gate extern char *record_file; /* File to record chars sent/received */ 2677c478bd9Sstevel@tonic-gate extern bool sync_serial; /* Device is synchronous serial device */ 2687c478bd9Sstevel@tonic-gate extern int maxfail; /* Max # of unsuccessful connection attempts */ 2697c478bd9Sstevel@tonic-gate extern char linkname[MAXPATHLEN]; /* logical name for link */ 2707c478bd9Sstevel@tonic-gate extern bool tune_kernel; /* May alter kernel settings as necessary */ 2717c478bd9Sstevel@tonic-gate extern int connect_delay; /* Time to delay after connect script */ 2727c478bd9Sstevel@tonic-gate extern int max_data_rate; /* max bytes/sec through charshunt */ 2737c478bd9Sstevel@tonic-gate extern int req_unit; /* interface unit number to use */ 2747c478bd9Sstevel@tonic-gate extern bool multilink; /* enable multilink operation */ 2757c478bd9Sstevel@tonic-gate extern bool noendpoint; /* don't send or accept endpt. discrim. */ 2767c478bd9Sstevel@tonic-gate extern char *bundle_name; /* bundle name for multilink */ 2777c478bd9Sstevel@tonic-gate 2787c478bd9Sstevel@tonic-gate #ifdef HAVE_MULTILINK 2797c478bd9Sstevel@tonic-gate extern TDB_CONTEXT *pppdb; /* handle to multilink database context */ 2807c478bd9Sstevel@tonic-gate extern char db_key[]; /* multilink database key */ 2817c478bd9Sstevel@tonic-gate #endif 2827c478bd9Sstevel@tonic-gate 2837c478bd9Sstevel@tonic-gate #ifdef PPP_FILTER 2847c478bd9Sstevel@tonic-gate extern struct bpf_program pass_filter; /* Filter for pkts to pass */ 2857c478bd9Sstevel@tonic-gate extern struct bpf_program active_filter; /* Filter for link-active pkts */ 2867c478bd9Sstevel@tonic-gate #endif /* PPP_FILTER */ 2877c478bd9Sstevel@tonic-gate 2887c478bd9Sstevel@tonic-gate #ifdef MSLANMAN 2897c478bd9Sstevel@tonic-gate extern bool ms_lanman; /* Use LanMan password instead of NT */ 2907c478bd9Sstevel@tonic-gate /* Has meaning only with MS-CHAP challenges */ 2917c478bd9Sstevel@tonic-gate #endif /* MXLANMAN */ 2927c478bd9Sstevel@tonic-gate 2937c478bd9Sstevel@tonic-gate extern char *current_option; /* the name of the option being parsed */ 2947c478bd9Sstevel@tonic-gate extern bool privileged_option; /* set iff the current option came from root */ 2957c478bd9Sstevel@tonic-gate extern char *option_source; /* string saying where the option came from */ 2967c478bd9Sstevel@tonic-gate extern int option_line; /* and from which line in the file */ 2977c478bd9Sstevel@tonic-gate extern bool already_ppp; /* device is already in PPP mode */ 2987c478bd9Sstevel@tonic-gate extern bool prepass; /* Doing pre-pass to find device name */ 2997c478bd9Sstevel@tonic-gate extern struct stat devstat; /* Result of stat() on device */ 3007c478bd9Sstevel@tonic-gate 3017c478bd9Sstevel@tonic-gate extern bool peer_nak_auth; /* Peer sent nak for our auth request */ 3027c478bd9Sstevel@tonic-gate extern u_short nak_auth_orig; /* Auth proto peer naked */ 3037c478bd9Sstevel@tonic-gate extern u_short nak_auth_proto; /* Auth proto peer suggested instead */ 3047c478bd9Sstevel@tonic-gate extern bool unsolicited_nak_auth; /* Peer asked us to authenticate */ 3057c478bd9Sstevel@tonic-gate extern u_short unsolicit_auth_proto; /* Auth proto peer wants */ 3067c478bd9Sstevel@tonic-gate extern bool peer_reject_auth; /* Peer sent reject for auth */ 3077c478bd9Sstevel@tonic-gate extern u_short reject_auth_proto; /* Protocol that peer rejected */ 3087c478bd9Sstevel@tonic-gate extern bool rejected_peers_auth; /* We sent a reject to the peer */ 3097c478bd9Sstevel@tonic-gate extern u_short rejected_auth_proto; /* Protocol that peer wanted to use */ 3107c478bd9Sstevel@tonic-gate extern bool naked_peers_auth; /* We sent a nak to the peer */ 3117c478bd9Sstevel@tonic-gate extern u_short naked_auth_orig; /* Protocol that we wanted to use */ 3127c478bd9Sstevel@tonic-gate extern u_short naked_auth_proto; /* Protocol that peer wants us to use */ 3137c478bd9Sstevel@tonic-gate 3147c478bd9Sstevel@tonic-gate /* 3157c478bd9Sstevel@tonic-gate * Values for phase. 3167c478bd9Sstevel@tonic-gate */ 3177c478bd9Sstevel@tonic-gate #define PHASE_DEAD 0 /* RFC 1661; link terminated */ 3187c478bd9Sstevel@tonic-gate #define PHASE_INITIALIZE 1 /* execution begins */ 3197c478bd9Sstevel@tonic-gate #define PHASE_INITIALIZED 2 /* options ok; entering main loop */ 3207c478bd9Sstevel@tonic-gate #define PHASE_SERIALCONN 3 /* connecting to peer */ 3217c478bd9Sstevel@tonic-gate #define PHASE_CONNECTED 4 /* connecting to peer */ 3227c478bd9Sstevel@tonic-gate #define PHASE_DORMANT 5 /* waiting for demand-dial trigger */ 3237c478bd9Sstevel@tonic-gate #define PHASE_ESTABLISH 6 /* RFC 1661; LCP negotiation begins */ 3247c478bd9Sstevel@tonic-gate #define PHASE_AUTHENTICATE 7 /* RFC 1661; authentication begins */ 3257c478bd9Sstevel@tonic-gate #define PHASE_CALLBACK 8 /* negotiating for callback */ 3267c478bd9Sstevel@tonic-gate #define PHASE_NETWORK 9 /* RFC 1661; NCP negotiation begins */ 3277c478bd9Sstevel@tonic-gate #define PHASE_RUNNING 10 /* first NCP went to Opened state */ 3287c478bd9Sstevel@tonic-gate #define PHASE_TERMINATE 11 /* RFC 1661; LCP left Opened state */ 3297c478bd9Sstevel@tonic-gate #define PHASE_DISCONNECT 12 /* running disconnect script */ 3307c478bd9Sstevel@tonic-gate #define PHASE_HOLDOFF 13 /* waiting before restart */ 3317c478bd9Sstevel@tonic-gate #define PHASE_CALLINGBACK 14 /* calling back */ 3327c478bd9Sstevel@tonic-gate #define PHASE_EXIT 15 /* execution ends */ 3337c478bd9Sstevel@tonic-gate 3347c478bd9Sstevel@tonic-gate #define PHASE__NAMES \ 3357c478bd9Sstevel@tonic-gate "Dead", "Initialize", "Initialized", "Serialconn", "Connected", \ 3367c478bd9Sstevel@tonic-gate "Dormant", "Establish", "Authenticate", "Callback", "Network", \ 3377c478bd9Sstevel@tonic-gate "Running", "Terminate", "Disconnect", "Holdoff", "Callingback", \ 3387c478bd9Sstevel@tonic-gate "Exit" 3397c478bd9Sstevel@tonic-gate 3407c478bd9Sstevel@tonic-gate /* 3417c478bd9Sstevel@tonic-gate * The following struct gives the addresses of procedures to call 3427c478bd9Sstevel@tonic-gate * for a particular protocol. 3437c478bd9Sstevel@tonic-gate */ 3447c478bd9Sstevel@tonic-gate struct protent { 3457c478bd9Sstevel@tonic-gate u_short protocol; /* PPP protocol number */ 3467c478bd9Sstevel@tonic-gate /* Initialization procedure */ 3477c478bd9Sstevel@tonic-gate void (*init) __P((int unit)); 3487c478bd9Sstevel@tonic-gate /* Process a received packet */ 3497c478bd9Sstevel@tonic-gate void (*input) __P((int unit, u_char *pkt, int len)); 3507c478bd9Sstevel@tonic-gate /* Process a received protocol-reject */ 3517c478bd9Sstevel@tonic-gate void (*protrej) __P((int unit)); 3527c478bd9Sstevel@tonic-gate /* Lower layer has come up */ 3537c478bd9Sstevel@tonic-gate void (*lowerup) __P((int unit)); 3547c478bd9Sstevel@tonic-gate /* Lower layer has gone down */ 3557c478bd9Sstevel@tonic-gate void (*lowerdown) __P((int unit)); 3567c478bd9Sstevel@tonic-gate /* Open the protocol */ 3577c478bd9Sstevel@tonic-gate void (*open) __P((int unit)); 3587c478bd9Sstevel@tonic-gate /* Close the protocol */ 3597c478bd9Sstevel@tonic-gate void (*close) __P((int unit, char *reason)); 3607c478bd9Sstevel@tonic-gate /* Print a packet in readable form */ 3617c478bd9Sstevel@tonic-gate int (*printpkt) __P((u_char *pkt, int len, 3627c478bd9Sstevel@tonic-gate void (*printer) __P((void *, const char *, ...)), 3637c478bd9Sstevel@tonic-gate void *arg)); 3647c478bd9Sstevel@tonic-gate /* Process a received data packet */ 3657c478bd9Sstevel@tonic-gate void (*datainput) __P((int unit, u_char *pkt, int len)); 3667c478bd9Sstevel@tonic-gate bool enabled_flag; /* 0 iff protocol is disabled */ 3677c478bd9Sstevel@tonic-gate char *name; /* Text name of protocol */ 3687c478bd9Sstevel@tonic-gate char *data_name; /* Text name of corresponding data protocol */ 3697c478bd9Sstevel@tonic-gate option_t *options; /* List of command-line options */ 3707c478bd9Sstevel@tonic-gate /* Check requested options, assign defaults */ 3717c478bd9Sstevel@tonic-gate void (*check_options) __P((void)); 3727c478bd9Sstevel@tonic-gate /* Configure interface for demand-dial */ 3737c478bd9Sstevel@tonic-gate int (*demand_conf) __P((int unit)); 3747c478bd9Sstevel@tonic-gate /* Say whether to bring up link for this pkt */ 3757c478bd9Sstevel@tonic-gate int (*active_pkt) __P((u_char *pkt, int len)); 3767c478bd9Sstevel@tonic-gate /* Print current status to file or syslog (if strptr == NULL) */ 3777c478bd9Sstevel@tonic-gate void (*print_stat) __P((int unit, FILE *strptr)); 3787c478bd9Sstevel@tonic-gate }; 3797c478bd9Sstevel@tonic-gate 3807c478bd9Sstevel@tonic-gate /* 3817c478bd9Sstevel@tonic-gate * This structure is used to store information about certain 3827c478bd9Sstevel@tonic-gate * options, such as where the option value came from (/etc/ppp/options, 3837c478bd9Sstevel@tonic-gate * command line, etc.) and whether it came from a privileged source. 3847c478bd9Sstevel@tonic-gate */ 3857c478bd9Sstevel@tonic-gate struct option_info { 3867c478bd9Sstevel@tonic-gate bool priv; /* was value set by sysadmin? */ 3877c478bd9Sstevel@tonic-gate char *source; /* where option came from */ 3887c478bd9Sstevel@tonic-gate int line; /* line number where the option came from */ 3897c478bd9Sstevel@tonic-gate }; 3907c478bd9Sstevel@tonic-gate 3917c478bd9Sstevel@tonic-gate extern struct option_info devnam_info; 3927c478bd9Sstevel@tonic-gate extern struct option_info initializer_info; 3937c478bd9Sstevel@tonic-gate extern struct option_info connect_script_info; 3947c478bd9Sstevel@tonic-gate extern struct option_info disconnect_script_info; 3957c478bd9Sstevel@tonic-gate extern struct option_info welcomer_info; 3967c478bd9Sstevel@tonic-gate extern struct option_info ptycommand_info; 3977c478bd9Sstevel@tonic-gate extern struct option_info ipsrc_info; 3987c478bd9Sstevel@tonic-gate extern struct option_info ipdst_info; 3997c478bd9Sstevel@tonic-gate extern struct option_info speed_info; 4007c478bd9Sstevel@tonic-gate 4017c478bd9Sstevel@tonic-gate /* 4027c478bd9Sstevel@tonic-gate * Table of pointers to supported protocols. 4037c478bd9Sstevel@tonic-gate */ 4047c478bd9Sstevel@tonic-gate extern struct protent *protocols[]; 4057c478bd9Sstevel@tonic-gate 4067c478bd9Sstevel@tonic-gate /* 4077c478bd9Sstevel@tonic-gate * Prototypes. 4087c478bd9Sstevel@tonic-gate */ 4097c478bd9Sstevel@tonic-gate 4107c478bd9Sstevel@tonic-gate /* 4117c478bd9Sstevel@tonic-gate * Procedures exported from main.c. 4127c478bd9Sstevel@tonic-gate */ 4137c478bd9Sstevel@tonic-gate extern void set_ifunit __P((int)); /* set stuff that depends on ifunit */ 4147c478bd9Sstevel@tonic-gate extern void detach __P((void)); /* Detach from controlling tty */ 4157c478bd9Sstevel@tonic-gate extern void die __P((int)); /* Cleanup and exit */ 4167c478bd9Sstevel@tonic-gate extern void quit __P((void)); /* like die(1) */ 4177c478bd9Sstevel@tonic-gate extern void novm __P((char *)); /* Say we ran out of memory, and die */ 4187c478bd9Sstevel@tonic-gate extern void timeout __P((void (*func)(void *), void *arg, int t)); 4197c478bd9Sstevel@tonic-gate /* Call func(arg) after t seconds */ 4207c478bd9Sstevel@tonic-gate extern void untimeout __P((void (*func)(void *), void *arg)); 4217c478bd9Sstevel@tonic-gate /* Cancel call to func(arg) */ 4227c478bd9Sstevel@tonic-gate extern pid_t run_program __P((char *prog, char **args, int must_exist, 4237c478bd9Sstevel@tonic-gate void (*done)(void *, int), void *arg)); 4247c478bd9Sstevel@tonic-gate /* Run program prog with args in child */ 4257c478bd9Sstevel@tonic-gate extern void reopen_log __P((void)); /* (re)open the connection to syslog */ 4267c478bd9Sstevel@tonic-gate extern void update_link_stats __P((int)); /* Get stats at link termination */ 4277c478bd9Sstevel@tonic-gate /* set script env var */ 4287c478bd9Sstevel@tonic-gate extern void script_setenv __P((const char *, const char *, int)); 4297c478bd9Sstevel@tonic-gate extern void script_unsetenv __P((const char *)); /* unset script env var */ 4307c478bd9Sstevel@tonic-gate extern const char *script_getenv __P((const char *var)); 4317c478bd9Sstevel@tonic-gate extern void new_phase __P((int)); /* signal start of new phase */ 4327c478bd9Sstevel@tonic-gate extern void print_ncpstate __P((int, FILE *)); /* prints NCP state */ 4337c478bd9Sstevel@tonic-gate extern const char *protocol_name __P((int proto)); /* canonical name */ 4347c478bd9Sstevel@tonic-gate extern const char *phase_name __P((int phaseval)); 4357c478bd9Sstevel@tonic-gate 4367c478bd9Sstevel@tonic-gate /* 4377c478bd9Sstevel@tonic-gate * Procedures exported from utils.c. 4387c478bd9Sstevel@tonic-gate */ 4397c478bd9Sstevel@tonic-gate extern void log_packet __P((u_char *, int, const char *, int)); 4407c478bd9Sstevel@tonic-gate /* Format a packet and log it with syslog */ 4417c478bd9Sstevel@tonic-gate extern void print_string __P((char *, int, void (*)(void *, const char *, ...), 4427c478bd9Sstevel@tonic-gate void *)); /* Format a string for output */ 4437c478bd9Sstevel@tonic-gate extern int slprintf __P((char *, int, const char *, ...)); /* sprintf++ */ 4447c478bd9Sstevel@tonic-gate extern int vslprintf __P((char *, int, const char *, va_list));/* vsprintf++ */ 4457c478bd9Sstevel@tonic-gate extern size_t strlcpy __P((char *, const char *, size_t)); /* safe strcpy */ 4467c478bd9Sstevel@tonic-gate extern size_t strlcat __P((char *, const char *, size_t)); /* safe strncpy */ 4477c478bd9Sstevel@tonic-gate extern void dbglog __P((const char *, ...));/* log a debug message */ 4487c478bd9Sstevel@tonic-gate extern void info __P((const char *, ...)); /* log an informational message */ 4497c478bd9Sstevel@tonic-gate extern void notice __P((const char *, ...));/* log a notice-level message */ 4507c478bd9Sstevel@tonic-gate extern void warn __P((const char *, ...)); /* log a warning message */ 4517c478bd9Sstevel@tonic-gate extern void error __P((const char *, ...)); /* log an error message */ 4527c478bd9Sstevel@tonic-gate extern void fatal __P((const char *, ...)); 4537c478bd9Sstevel@tonic-gate /* log an error message and die(1) */ 4547c478bd9Sstevel@tonic-gate extern const char *code_name __P((int code, int shortflag)); 4557c478bd9Sstevel@tonic-gate /* Code to string */ 4567c478bd9Sstevel@tonic-gate extern int flprintf __P((FILE *, const char *, ...)); /* fprintf++ */ 4577c478bd9Sstevel@tonic-gate extern size_t strllen __P((const char *, size_t)); /* safe strlen */ 4587c478bd9Sstevel@tonic-gate extern const char *signal_name __P((int signum)); 4597c478bd9Sstevel@tonic-gate 4607c478bd9Sstevel@tonic-gate /* 4617c478bd9Sstevel@tonic-gate * Procedures exported from auth.c 4627c478bd9Sstevel@tonic-gate */ 4637c478bd9Sstevel@tonic-gate extern void link_required __P((int)); /* we are starting to use the link */ 4647c478bd9Sstevel@tonic-gate extern void link_terminated __P((int)); /* we are finished with the link */ 4657c478bd9Sstevel@tonic-gate extern void link_down __P((int)); 4667c478bd9Sstevel@tonic-gate /* the LCP layer has left the Opened state */ 4677c478bd9Sstevel@tonic-gate extern void link_established __P((int)); /* the link is up; authenticate now */ 4687c478bd9Sstevel@tonic-gate extern void start_networks __P((void)); 4697c478bd9Sstevel@tonic-gate /* start all the network control protos */ 4707c478bd9Sstevel@tonic-gate extern void np_up __P((int, int)); /* a network protocol has come up */ 4717c478bd9Sstevel@tonic-gate extern void np_down __P((int, int)); /* a network protocol has gone down */ 4727c478bd9Sstevel@tonic-gate extern void np_finished __P((int, int)); 4737c478bd9Sstevel@tonic-gate /* a network protocol no longer needs link */ 4747c478bd9Sstevel@tonic-gate extern void auth_peer_fail __P((int, int)); 4757c478bd9Sstevel@tonic-gate /* peer failed to authenticate itself */ 4767c478bd9Sstevel@tonic-gate extern void auth_peer_success __P((int, int, char *, int)); 4777c478bd9Sstevel@tonic-gate /* peer successfully authenticated itself */ 4787c478bd9Sstevel@tonic-gate extern void auth_withpeer_fail __P((int, int)); 4797c478bd9Sstevel@tonic-gate /* we failed to authenticate ourselves */ 4807c478bd9Sstevel@tonic-gate extern void auth_withpeer_success __P((int, int)); 4817c478bd9Sstevel@tonic-gate /* we successfully authenticated ourselves */ 4827c478bd9Sstevel@tonic-gate extern void auth_check_options __P((void)); 4837c478bd9Sstevel@tonic-gate /* check authentication options supplied */ 4847c478bd9Sstevel@tonic-gate extern void auth_reset __P((int)); 4857c478bd9Sstevel@tonic-gate /* check what secrets we have */ 4867c478bd9Sstevel@tonic-gate extern int check_passwd __P((int, char *, int, char *, int, char **)); 4877c478bd9Sstevel@tonic-gate /* Check peer-supplied username/password */ 4887c478bd9Sstevel@tonic-gate extern int get_secret __P((int, char *, char *, char *, int *, int)); 4897c478bd9Sstevel@tonic-gate /* get "secret" for chap */ 4907c478bd9Sstevel@tonic-gate extern int auth_ip_addr __P((int, u_int32_t)); 4917c478bd9Sstevel@tonic-gate /* check if IP address is authorized */ 4927c478bd9Sstevel@tonic-gate extern int bad_ip_adrs __P((u_int32_t)); 4937c478bd9Sstevel@tonic-gate /* check if IP address is unreasonable */ 4947c478bd9Sstevel@tonic-gate 4957c478bd9Sstevel@tonic-gate /* 4967c478bd9Sstevel@tonic-gate * Procedures exported from demand.c 4977c478bd9Sstevel@tonic-gate */ 4987c478bd9Sstevel@tonic-gate extern void demand_conf __P((void)); 4997c478bd9Sstevel@tonic-gate /* config interface(s) for demand-dial */ 5007c478bd9Sstevel@tonic-gate extern void demand_block __P((void)); /* set all NPs to queue up packets */ 5017c478bd9Sstevel@tonic-gate extern void demand_unblock __P((void)); /* set all NPs to pass packets */ 5027c478bd9Sstevel@tonic-gate extern void demand_discard __P((void)); /* set all NPs to discard packets */ 5037c478bd9Sstevel@tonic-gate extern void demand_rexmit __P((int)); /* retransmit saved frames for an NP */ 5047c478bd9Sstevel@tonic-gate extern int loop_chars __P((unsigned char *, int)); 5057c478bd9Sstevel@tonic-gate /* process chars from loopback */ 5067c478bd9Sstevel@tonic-gate extern int loop_frame __P((unsigned char *, int)); 5077c478bd9Sstevel@tonic-gate /* should we bring link up? */ 5087c478bd9Sstevel@tonic-gate 5097c478bd9Sstevel@tonic-gate /* 5107c478bd9Sstevel@tonic-gate * Procedures exported from multilink.c 5117c478bd9Sstevel@tonic-gate */ 5127c478bd9Sstevel@tonic-gate extern void mp_check_options __P((void)); /* Check multilink-related options */ 5137c478bd9Sstevel@tonic-gate extern int mp_join_bundle __P((void)); 5147c478bd9Sstevel@tonic-gate /* join our link to an appropriate bundle */ 5157c478bd9Sstevel@tonic-gate /* 5167c478bd9Sstevel@tonic-gate * Procedures exported from sys-*.c 5177c478bd9Sstevel@tonic-gate */ 5187c478bd9Sstevel@tonic-gate extern void sys_init __P((bool)); /* Do system-dependent initialization */ 5197c478bd9Sstevel@tonic-gate extern void sys_cleanup __P((void)); /* Restore system state before exiting */ 5207c478bd9Sstevel@tonic-gate extern int sys_check_options __P((void)); /* Check options specified */ 5217c478bd9Sstevel@tonic-gate extern void sys_options __P((void)); /* add or remove system options */ 5227c478bd9Sstevel@tonic-gate extern void sys_close __P((void)); /* Clean up in a child before execing */ 5237c478bd9Sstevel@tonic-gate extern int ppp_available __P((void)); 5247c478bd9Sstevel@tonic-gate /* Test whether ppp kernel support exists */ 5257c478bd9Sstevel@tonic-gate extern int get_pty __P((int *, int *, char *, int)); 5267c478bd9Sstevel@tonic-gate /* Get pty master/slave */ 5277c478bd9Sstevel@tonic-gate extern int open_ppp_loopback __P((void)); 5287c478bd9Sstevel@tonic-gate /* Open loopback for demand-dialling */ 5297c478bd9Sstevel@tonic-gate extern int establish_ppp __P((int)); 5307c478bd9Sstevel@tonic-gate /* Turn serial port into a ppp interface */ 5317c478bd9Sstevel@tonic-gate extern void restore_loop __P((void)); 5327c478bd9Sstevel@tonic-gate /* Transfer ppp unit back to loopback */ 5337c478bd9Sstevel@tonic-gate extern void disestablish_ppp __P((int)); 5347c478bd9Sstevel@tonic-gate /* Restore port to normal operation */ 5357c478bd9Sstevel@tonic-gate extern void make_new_bundle __P((int, int, int, int)); /* Create new bundle */ 5367c478bd9Sstevel@tonic-gate extern int bundle_attach __P((int)); /* Attach link to existing bundle */ 5377c478bd9Sstevel@tonic-gate extern void cfg_bundle __P((int, int, int, int)); 5387c478bd9Sstevel@tonic-gate /* Configure existing bundle */ 5397c478bd9Sstevel@tonic-gate extern void clean_check __P((void)); /* Check if line was 8-bit clean */ 5407c478bd9Sstevel@tonic-gate extern void set_up_tty __P((int, int)); 5417c478bd9Sstevel@tonic-gate /* Set up port's speed, parameters, etc. */ 5427c478bd9Sstevel@tonic-gate extern void restore_tty __P((int)); /* Restore port's original parameters */ 5437c478bd9Sstevel@tonic-gate extern void setdtr __P((int, int)); /* Raise or lower port's DTR line */ 5447c478bd9Sstevel@tonic-gate extern void output __P((int, u_char *, int)); /* Output a PPP packet */ 5457c478bd9Sstevel@tonic-gate extern void wait_input __P((struct timeval *)); 5467c478bd9Sstevel@tonic-gate /* Wait for input, with timeout */ 5477c478bd9Sstevel@tonic-gate extern void add_fd __P((int)); /* Add fd to set to wait for */ 5487c478bd9Sstevel@tonic-gate extern void remove_fd __P((int)); /* Remove fd from set to wait for */ 5497c478bd9Sstevel@tonic-gate extern int read_packet __P((u_char *)); /* Read PPP packet */ 5507c478bd9Sstevel@tonic-gate extern int get_loop_output __P((void)); /* Read pkts from loopback */ 5517c478bd9Sstevel@tonic-gate extern void ppp_send_config __P((int, int, u_int32_t, int, int)); 5527c478bd9Sstevel@tonic-gate /* Configure i/f transmit parameters */ 5537c478bd9Sstevel@tonic-gate extern void ppp_set_xaccm __P((int, ext_accm)); 5547c478bd9Sstevel@tonic-gate /* Set extended transmit ACCM */ 5557c478bd9Sstevel@tonic-gate extern void ppp_recv_config __P((int, int, u_int32_t, int, int)); 5567c478bd9Sstevel@tonic-gate /* Configure i/f receive parameters */ 5577c478bd9Sstevel@tonic-gate #ifdef NEGOTIATE_FCS 5587c478bd9Sstevel@tonic-gate extern void ppp_send_fcs __P((int unit, int fcstype)); 5597c478bd9Sstevel@tonic-gate extern void ppp_recv_fcs __P((int unit, int fcstype)); 5607c478bd9Sstevel@tonic-gate #endif /* NEGOTIATE_FCS */ 5617c478bd9Sstevel@tonic-gate #ifdef MUX_FRAME 5627c478bd9Sstevel@tonic-gate extern void ppp_send_muxoption __P((int ,u_int32_t)); 5637c478bd9Sstevel@tonic-gate extern void ppp_recv_muxoption __P((int ,u_int32_t)); 5647c478bd9Sstevel@tonic-gate #endif /* MUX_FRAME */ 5657c478bd9Sstevel@tonic-gate extern int ccp_test __P((int, u_char *, int, int)); 5667c478bd9Sstevel@tonic-gate /* Test support for compression scheme */ 5677c478bd9Sstevel@tonic-gate #ifdef COMP_TUNE 5687c478bd9Sstevel@tonic-gate extern void ccp_tune __P((int, int)); /* Tune compression effort level */ 5697c478bd9Sstevel@tonic-gate #endif /* COMP_TUNE */ 5707c478bd9Sstevel@tonic-gate extern void ccp_flags_set __P((int, int, int)); 5717c478bd9Sstevel@tonic-gate /* Set kernel CCP state */ 5727c478bd9Sstevel@tonic-gate extern int ccp_fatal_error __P((int)); 5737c478bd9Sstevel@tonic-gate /* Test for fatal decomp error in kernel */ 5747c478bd9Sstevel@tonic-gate extern int get_idle_time __P((int, struct ppp_idle *)); 5757c478bd9Sstevel@tonic-gate /* Find out how long link has been idle */ 5767c478bd9Sstevel@tonic-gate extern int get_ppp_stats __P((int, struct pppd_stats *)); 5777c478bd9Sstevel@tonic-gate /* Return link statistics */ 5787c478bd9Sstevel@tonic-gate extern int sifvjcomp __P((int, int, int, int)); 5797c478bd9Sstevel@tonic-gate /* Configure VJ TCP header compression */ 5807c478bd9Sstevel@tonic-gate extern int sifup __P((int)); /* Configure i/f up for one protocol */ 5817c478bd9Sstevel@tonic-gate extern int sifnpmode __P((int u, int proto, enum NPmode mode)); 5827c478bd9Sstevel@tonic-gate /* Set mode for handling packets for proto */ 5837c478bd9Sstevel@tonic-gate extern int sifdown __P((int)); /* Configure i/f down for one protocol */ 5847c478bd9Sstevel@tonic-gate extern int sifaddr __P((int, u_int32_t, u_int32_t, u_int32_t)); 5857c478bd9Sstevel@tonic-gate /* Configure IPv4 addresses for i/f */ 5867c478bd9Sstevel@tonic-gate extern int cifaddr __P((int, u_int32_t, u_int32_t)); 5877c478bd9Sstevel@tonic-gate /* Reset i/f IP addresses */ 5887c478bd9Sstevel@tonic-gate 5897c478bd9Sstevel@tonic-gate extern void sys_block_proto __P((uint16_t)); 5907c478bd9Sstevel@tonic-gate extern void sys_unblock_proto __P((uint16_t)); 5917c478bd9Sstevel@tonic-gate 5927c478bd9Sstevel@tonic-gate #ifdef INET6 5937c478bd9Sstevel@tonic-gate extern int sif6addr __P((int, eui64_t, eui64_t)); 5947c478bd9Sstevel@tonic-gate /* Configure IPv6 addresses for i/f */ 5957c478bd9Sstevel@tonic-gate extern int cif6addr __P((int, eui64_t, eui64_t)); 5967c478bd9Sstevel@tonic-gate /* Remove an IPv6 address from i/f */ 5977c478bd9Sstevel@tonic-gate #endif /* INET6 */ 5987c478bd9Sstevel@tonic-gate extern int sifdefaultroute __P((int, u_int32_t, u_int32_t)); 5997c478bd9Sstevel@tonic-gate /* Create default route through i/f */ 6007c478bd9Sstevel@tonic-gate extern int cifdefaultroute __P((int, u_int32_t, u_int32_t)); 6017c478bd9Sstevel@tonic-gate /* Delete default route through i/f */ 6027c478bd9Sstevel@tonic-gate extern int sifproxyarp __P((int unit, u_int32_t addr, int flag)); 6037c478bd9Sstevel@tonic-gate /* Add proxy ARP entry for peer */ 6047c478bd9Sstevel@tonic-gate extern int cifproxyarp __P((int unit, u_int32_t addr)); 6057c478bd9Sstevel@tonic-gate /* Delete proxy ARP entry for peer */ 6067c478bd9Sstevel@tonic-gate extern u_int32_t GetMask __P((u_int32_t)); 6077c478bd9Sstevel@tonic-gate /* Get appropriate netmask for address */ 6087c478bd9Sstevel@tonic-gate extern int lock __P((char *)); /* Create lock file for device */ 6097c478bd9Sstevel@tonic-gate extern int relock __P((int)); /* Rewrite lock file with new pid */ 6107c478bd9Sstevel@tonic-gate extern void unlock __P((void)); /* Delete previously-created lock file */ 6117c478bd9Sstevel@tonic-gate extern void logwtmp __P((const char *, const char *, const char *)); 6127c478bd9Sstevel@tonic-gate /* Write entry to wtmp file */ 6137c478bd9Sstevel@tonic-gate extern int get_host_seed __P((void)); 6147c478bd9Sstevel@tonic-gate /* Get host-dependent random number seed */ 6157c478bd9Sstevel@tonic-gate extern int have_route_to __P((u_int32_t)); /* Check if route to addr exists */ 6167c478bd9Sstevel@tonic-gate #ifdef PPP_FILTER 6177c478bd9Sstevel@tonic-gate extern int set_filters __P((struct bpf_program *pass, 6187c478bd9Sstevel@tonic-gate struct bpf_program *active)); 6197c478bd9Sstevel@tonic-gate /* Set filter programs in kernel */ 6207c478bd9Sstevel@tonic-gate #endif /* PPP_FILTER */ 6217c478bd9Sstevel@tonic-gate #ifdef IPX_CHANGE 6227c478bd9Sstevel@tonic-gate extern int sipxfaddr __P((int, unsigned long, unsigned char *)); 6237c478bd9Sstevel@tonic-gate extern int cipxfaddr __P((int)); 6247c478bd9Sstevel@tonic-gate #endif /* IPX_CHANGE */ 6257c478bd9Sstevel@tonic-gate extern int get_if_hwaddr __P((u_char *addr, int msize, char *name)); 6267c478bd9Sstevel@tonic-gate extern int get_first_hwaddr __P((u_char *addr, int msize)); 6277c478bd9Sstevel@tonic-gate #if defined(INET6) && defined(SOL2) 6287c478bd9Sstevel@tonic-gate extern int ether_to_eui64 __P((eui64_t *p_eui64)); 6297c478bd9Sstevel@tonic-gate extern int sif6up __P((int unit)); 6307c478bd9Sstevel@tonic-gate extern int sif6down __P((int unit)); 6317c478bd9Sstevel@tonic-gate extern int sif6mtu __P((int mtu)); 6327c478bd9Sstevel@tonic-gate extern int sif6flags __P((u_int32_t flags, int set)); 6337c478bd9Sstevel@tonic-gate #endif /* INET6 && SOL2*/ 6347c478bd9Sstevel@tonic-gate #if defined(INET6) && !defined(SOL2) 6357c478bd9Sstevel@tonic-gate #define sif6up sifup 6367c478bd9Sstevel@tonic-gate #endif 6377c478bd9Sstevel@tonic-gate extern int sifmtu __P((int mtu)); 6387c478bd9Sstevel@tonic-gate extern int siflags __P((u_int32_t flags, int set)); 6397c478bd9Sstevel@tonic-gate extern void sys_ifname __P((void)); 6407c478bd9Sstevel@tonic-gate extern void sys_print_state __P((FILE *strptr)); 6417c478bd9Sstevel@tonic-gate extern int sys_extra_fd __P((void)); 6427c478bd9Sstevel@tonic-gate 6437c478bd9Sstevel@tonic-gate /* 6447c478bd9Sstevel@tonic-gate * Procedures exported from options.c 6457c478bd9Sstevel@tonic-gate */ 6467c478bd9Sstevel@tonic-gate extern int parse_args __P((int argc, char **argv)); 6477c478bd9Sstevel@tonic-gate /* Parse options from arguments given */ 6487c478bd9Sstevel@tonic-gate extern int options_from_file __P((char *filename, bool must_exist, 6497c478bd9Sstevel@tonic-gate bool check_prot, bool privileged)); 6507c478bd9Sstevel@tonic-gate /* Parse options from an options file */ 6517c478bd9Sstevel@tonic-gate extern int options_from_user __P((void)); 6527c478bd9Sstevel@tonic-gate /* Parse options from user's .ppprc */ 6537c478bd9Sstevel@tonic-gate extern int options_for_tty __P((void)); 6547c478bd9Sstevel@tonic-gate /* Parse options from /etc/ppp/options.tty */ 6557c478bd9Sstevel@tonic-gate extern int options_from_list __P((struct wordlist *, bool privileged)); 6567c478bd9Sstevel@tonic-gate /* Parse options from a wordlist */ 6577c478bd9Sstevel@tonic-gate extern int getword __P((FILE *f, char *word, int *newlinep, char *filename)); 6587c478bd9Sstevel@tonic-gate /* Read a word from a file */ 6597c478bd9Sstevel@tonic-gate extern void option_error __P((char *fmt, ...)); 6607c478bd9Sstevel@tonic-gate /* Print an error message about an option */ 6617c478bd9Sstevel@tonic-gate extern int int_option __P((char *, int *)); 6627c478bd9Sstevel@tonic-gate /* Simplified number_option for decimal ints */ 6637c478bd9Sstevel@tonic-gate extern void add_options __P((option_t *)); 6647c478bd9Sstevel@tonic-gate /* Add extra options */ 6657c478bd9Sstevel@tonic-gate extern int parse_dotted_ip __P((char *, u_int32_t *)); 6667c478bd9Sstevel@tonic-gate /* Parse dotted IP notation */ 6677c478bd9Sstevel@tonic-gate extern option_t *remove_option __P((char *)); 6687c478bd9Sstevel@tonic-gate /* Remove (disable) an option */ 6697c478bd9Sstevel@tonic-gate extern void save_source __P((struct option_info *)); 6707c478bd9Sstevel@tonic-gate /* Save the source information (where an option comes from) */ 6717c478bd9Sstevel@tonic-gate extern void set_source __P((struct option_info *)); 6727c478bd9Sstevel@tonic-gate /* Set the source (for logging option errors detected after parsing) */ 6737c478bd9Sstevel@tonic-gate extern const char *name_source __P((struct option_info *)); 6747c478bd9Sstevel@tonic-gate /* Return a string containing the option source and line number */ 6757c478bd9Sstevel@tonic-gate 6767c478bd9Sstevel@tonic-gate /* 6777c478bd9Sstevel@tonic-gate * Hooks to enable plugins to change various things. 6787c478bd9Sstevel@tonic-gate */ 6797c478bd9Sstevel@tonic-gate extern int (*new_phase_hook) __P((int new, int old)); 6807c478bd9Sstevel@tonic-gate extern int (*idle_time_hook) __P((struct ppp_idle *)); 6817c478bd9Sstevel@tonic-gate extern int (*holdoff_hook) __P((void)); 6827c478bd9Sstevel@tonic-gate extern int (*pap_check_hook) __P((void)); 6837c478bd9Sstevel@tonic-gate extern int (*pap_auth_hook) __P((char *user, char *passwd, char **msgp, 6847c478bd9Sstevel@tonic-gate struct wordlist **paddrs, struct wordlist **popts)); 6857c478bd9Sstevel@tonic-gate extern void (*pap_logout_hook) __P((void)); 6867c478bd9Sstevel@tonic-gate extern int (*pap_passwd_hook) __P((char *user, char *passwd)); 6877c478bd9Sstevel@tonic-gate extern void (*ip_up_hook) __P((void)); 6887c478bd9Sstevel@tonic-gate extern void (*ip_down_hook) __P((void)); 6897c478bd9Sstevel@tonic-gate extern int (*check_options_hook) __P((uid_t uid)); 6907c478bd9Sstevel@tonic-gate /* extern int (*attach_device_hook) __P((uid_t uid, char *devnam)); */ 6917c478bd9Sstevel@tonic-gate extern int (*updown_script_hook) __P((const char ***argsp)); 6927c478bd9Sstevel@tonic-gate struct strbuf; /* forward declaration */ 6937c478bd9Sstevel@tonic-gate extern int (*sys_read_packet_hook) __P((int retv, struct strbuf *ctrl, 6947c478bd9Sstevel@tonic-gate struct strbuf *data, int flags)); 6957c478bd9Sstevel@tonic-gate extern void (*device_pipe_hook) __P((int pipefd)); 6967c478bd9Sstevel@tonic-gate 6977c478bd9Sstevel@tonic-gate /* 6987c478bd9Sstevel@tonic-gate * Inline versions of get/put char/short/long. 6997c478bd9Sstevel@tonic-gate * Pointer is advanced; we assume that both arguments 7007c478bd9Sstevel@tonic-gate * are lvalues and will already be in registers. 7017c478bd9Sstevel@tonic-gate * cp MUST be u_char *. 7027c478bd9Sstevel@tonic-gate */ 7037c478bd9Sstevel@tonic-gate #define GETCHAR(c, cp) { \ 7047c478bd9Sstevel@tonic-gate (c) = *(cp)++; \ 7057c478bd9Sstevel@tonic-gate } 7067c478bd9Sstevel@tonic-gate #define PUTCHAR(c, cp) { \ 7077c478bd9Sstevel@tonic-gate *(cp)++ = (u_char) (c); \ 7087c478bd9Sstevel@tonic-gate } 7097c478bd9Sstevel@tonic-gate 7107c478bd9Sstevel@tonic-gate 7117c478bd9Sstevel@tonic-gate #define GETSHORT(s, cp) { \ 7127c478bd9Sstevel@tonic-gate (s) = *(cp)++ << 8; \ 7137c478bd9Sstevel@tonic-gate (s) |= *(cp)++; \ 7147c478bd9Sstevel@tonic-gate } 7157c478bd9Sstevel@tonic-gate #define PUTSHORT(s, cp) { \ 7167c478bd9Sstevel@tonic-gate *(cp)++ = (u_char) ((s) >> 8); \ 7177c478bd9Sstevel@tonic-gate *(cp)++ = (u_char) (s); \ 7187c478bd9Sstevel@tonic-gate } 7197c478bd9Sstevel@tonic-gate 7207c478bd9Sstevel@tonic-gate #define GETLONG(l, cp) { \ 7217c478bd9Sstevel@tonic-gate (l) = *(cp)++ << 8; \ 7227c478bd9Sstevel@tonic-gate (l) |= *(cp)++; (l) <<= 8; \ 7237c478bd9Sstevel@tonic-gate (l) |= *(cp)++; (l) <<= 8; \ 7247c478bd9Sstevel@tonic-gate (l) |= *(cp)++; \ 7257c478bd9Sstevel@tonic-gate } 7267c478bd9Sstevel@tonic-gate #define PUTLONG(l, cp) { \ 7277c478bd9Sstevel@tonic-gate *(cp)++ = (u_char) ((l) >> 24); \ 7287c478bd9Sstevel@tonic-gate *(cp)++ = (u_char) ((l) >> 16); \ 7297c478bd9Sstevel@tonic-gate *(cp)++ = (u_char) ((l) >> 8); \ 7307c478bd9Sstevel@tonic-gate *(cp)++ = (u_char) (l); \ 7317c478bd9Sstevel@tonic-gate } 7327c478bd9Sstevel@tonic-gate 7337c478bd9Sstevel@tonic-gate /* 7347c478bd9Sstevel@tonic-gate * For values that are kept internally in network byte order. 7357c478bd9Sstevel@tonic-gate */ 7367c478bd9Sstevel@tonic-gate #define GETNLONG(l, cp) { \ 7377c478bd9Sstevel@tonic-gate u_int32_t getnlong_val; \ 7387c478bd9Sstevel@tonic-gate getnlong_val = *(cp)++ << 8; \ 7397c478bd9Sstevel@tonic-gate getnlong_val |= *(cp)++; getnlong_val <<= 8; \ 7407c478bd9Sstevel@tonic-gate getnlong_val |= *(cp)++; getnlong_val <<= 8; \ 7417c478bd9Sstevel@tonic-gate getnlong_val |= *(cp)++; \ 7427c478bd9Sstevel@tonic-gate (l) = htonl(getnlong_val); \ 7437c478bd9Sstevel@tonic-gate } 7447c478bd9Sstevel@tonic-gate #define PUTNLONG(l, cp) { \ 7457c478bd9Sstevel@tonic-gate u_int32_t putnlong_val = ntohl(l); \ 7467c478bd9Sstevel@tonic-gate *(cp)++ = (u_char) (putnlong_val >> 24); \ 7477c478bd9Sstevel@tonic-gate *(cp)++ = (u_char) (putnlong_val >> 16); \ 7487c478bd9Sstevel@tonic-gate *(cp)++ = (u_char) (putnlong_val >> 8); \ 7497c478bd9Sstevel@tonic-gate *(cp)++ = (u_char) putnlong_val; \ 7507c478bd9Sstevel@tonic-gate } 7517c478bd9Sstevel@tonic-gate 7527c478bd9Sstevel@tonic-gate #define INCPTR(n, cp) ((cp) += (n)) 7537c478bd9Sstevel@tonic-gate #define DECPTR(n, cp) ((cp) -= (n)) 7547c478bd9Sstevel@tonic-gate 7557c478bd9Sstevel@tonic-gate /* 7567c478bd9Sstevel@tonic-gate * System dependent definitions for user-level 4.3BSD UNIX implementation. 7577c478bd9Sstevel@tonic-gate */ 7587c478bd9Sstevel@tonic-gate 7597c478bd9Sstevel@tonic-gate #define TIMEOUT(r, f, t) timeout((r), (f), (t)) 7607c478bd9Sstevel@tonic-gate #define UNTIMEOUT(r, f) untimeout((r), (f)) 7617c478bd9Sstevel@tonic-gate 7627c478bd9Sstevel@tonic-gate #ifndef SOL2 7637c478bd9Sstevel@tonic-gate #define BCOPY(s, d, l) memcpy(d, s, l) 7647c478bd9Sstevel@tonic-gate #define BZERO(s, n) memset(s, 0, n) 7657c478bd9Sstevel@tonic-gate #else 7667c478bd9Sstevel@tonic-gate #include <strings.h> 7677c478bd9Sstevel@tonic-gate #define BCOPY bcopy 7687c478bd9Sstevel@tonic-gate #define BZERO bzero 7697c478bd9Sstevel@tonic-gate #endif 7707c478bd9Sstevel@tonic-gate 7717c478bd9Sstevel@tonic-gate #define PRINTMSG(m, l) { info("Remote message: %0.*v", l, m); } 7727c478bd9Sstevel@tonic-gate 7737c478bd9Sstevel@tonic-gate /* 7747c478bd9Sstevel@tonic-gate * MAKEHEADER - Add Header fields to a packet. 7757c478bd9Sstevel@tonic-gate */ 7767c478bd9Sstevel@tonic-gate #define MAKEHEADER(p, t) { \ 7777c478bd9Sstevel@tonic-gate PUTCHAR(PPP_ALLSTATIONS, p); \ 7787c478bd9Sstevel@tonic-gate PUTCHAR(PPP_UI, p); \ 7797c478bd9Sstevel@tonic-gate PUTSHORT(t, p); } 7807c478bd9Sstevel@tonic-gate 7817c478bd9Sstevel@tonic-gate /* 7827c478bd9Sstevel@tonic-gate * Exit status values. 7837c478bd9Sstevel@tonic-gate */ 7847c478bd9Sstevel@tonic-gate #define EXIT_OK 0 7857c478bd9Sstevel@tonic-gate #define EXIT_FATAL_ERROR 1 7867c478bd9Sstevel@tonic-gate #define EXIT_OPTION_ERROR 2 7877c478bd9Sstevel@tonic-gate #define EXIT_NOT_ROOT 3 7887c478bd9Sstevel@tonic-gate #define EXIT_NO_KERNEL_SUPPORT 4 7897c478bd9Sstevel@tonic-gate #define EXIT_USER_REQUEST 5 7907c478bd9Sstevel@tonic-gate #define EXIT_LOCK_FAILED 6 7917c478bd9Sstevel@tonic-gate #define EXIT_OPEN_FAILED 7 7927c478bd9Sstevel@tonic-gate #define EXIT_CONNECT_FAILED 8 7937c478bd9Sstevel@tonic-gate #define EXIT_PTYCMD_FAILED 9 7947c478bd9Sstevel@tonic-gate #define EXIT_NEGOTIATION_FAILED 10 7957c478bd9Sstevel@tonic-gate #define EXIT_PEER_AUTH_FAILED 11 7967c478bd9Sstevel@tonic-gate #define EXIT_IDLE_TIMEOUT 12 7977c478bd9Sstevel@tonic-gate #define EXIT_CONNECT_TIME 13 7987c478bd9Sstevel@tonic-gate #define EXIT_CALLBACK 14 7997c478bd9Sstevel@tonic-gate #define EXIT_PEER_DEAD 15 8007c478bd9Sstevel@tonic-gate #define EXIT_HANGUP 16 8017c478bd9Sstevel@tonic-gate #define EXIT_LOOPBACK 17 8027c478bd9Sstevel@tonic-gate #define EXIT_INIT_FAILED 18 8037c478bd9Sstevel@tonic-gate #define EXIT_AUTH_TOPEER_FAILED 19 8047c478bd9Sstevel@tonic-gate 8057c478bd9Sstevel@tonic-gate /* 8067c478bd9Sstevel@tonic-gate * Character shunt constants. 8077c478bd9Sstevel@tonic-gate */ 8087c478bd9Sstevel@tonic-gate #define MAXLEVELMINSIZE 100 8097c478bd9Sstevel@tonic-gate 8107c478bd9Sstevel@tonic-gate /* 8117c478bd9Sstevel@tonic-gate * Debug macros. Slightly useful for finding bugs in pppd, not particularly 8127c478bd9Sstevel@tonic-gate * useful for finding out why your connection isn't being established. 8137c478bd9Sstevel@tonic-gate */ 8147c478bd9Sstevel@tonic-gate #ifdef DEBUGALL 8157c478bd9Sstevel@tonic-gate #define DEBUGMAIN 1 8167c478bd9Sstevel@tonic-gate #define DEBUGSYS 1 8177c478bd9Sstevel@tonic-gate #define DEBUGLCP 1 8187c478bd9Sstevel@tonic-gate #define DEBUGIPCP 1 8197c478bd9Sstevel@tonic-gate #define DEBUGIPV6CP 1 8207c478bd9Sstevel@tonic-gate #define DEBUGCHAP 1 8217c478bd9Sstevel@tonic-gate #define DEBUGIPXCP 1 8227c478bd9Sstevel@tonic-gate #define LOG_PPP LOG_LOCAL2 /* Log here when debugging all */ 8237c478bd9Sstevel@tonic-gate #endif /* DEBUGALL */ 8247c478bd9Sstevel@tonic-gate 8257c478bd9Sstevel@tonic-gate #ifndef LOG_PPP /* we use LOG_DAEMON for syslog by default */ 8267c478bd9Sstevel@tonic-gate #define LOG_PPP LOG_DAEMON 8277c478bd9Sstevel@tonic-gate #endif /* LOG_PPP */ 8287c478bd9Sstevel@tonic-gate 8297c478bd9Sstevel@tonic-gate #ifdef DEBUGMAIN 8307c478bd9Sstevel@tonic-gate #define MAINDEBUG(x) if (debug) dbglog x 8317c478bd9Sstevel@tonic-gate #else 8327c478bd9Sstevel@tonic-gate #define MAINDEBUG(x) ((void) 0) 8337c478bd9Sstevel@tonic-gate #endif /* DEBUGMAIN */ 8347c478bd9Sstevel@tonic-gate 8357c478bd9Sstevel@tonic-gate #ifdef DEBUGSYS 8367c478bd9Sstevel@tonic-gate #define SYSDEBUG(x) if (debug) dbglog x 8377c478bd9Sstevel@tonic-gate #else 8387c478bd9Sstevel@tonic-gate #define SYSDEBUG(x) ((void) 0) 8397c478bd9Sstevel@tonic-gate #endif /* DEBUGSYS */ 8407c478bd9Sstevel@tonic-gate 8417c478bd9Sstevel@tonic-gate #ifdef DEBUGLCP 8427c478bd9Sstevel@tonic-gate #define LCPDEBUG(x) if (debug) dbglog x 8437c478bd9Sstevel@tonic-gate #else 8447c478bd9Sstevel@tonic-gate #define LCPDEBUG(x) ((void) 0) 8457c478bd9Sstevel@tonic-gate #endif /* DEBUGLCP */ 8467c478bd9Sstevel@tonic-gate 8477c478bd9Sstevel@tonic-gate #ifdef DEBUGIPCP 8487c478bd9Sstevel@tonic-gate #define IPCPDEBUG(x) if (debug) dbglog x 8497c478bd9Sstevel@tonic-gate #else 8507c478bd9Sstevel@tonic-gate #define IPCPDEBUG(x) ((void) 0) 8517c478bd9Sstevel@tonic-gate #endif /* DEBUGIPCP */ 8527c478bd9Sstevel@tonic-gate 8537c478bd9Sstevel@tonic-gate #ifdef DEBUGIPV6CP 8547c478bd9Sstevel@tonic-gate #define IPV6CPDEBUG(x) if (debug) dbglog x 8557c478bd9Sstevel@tonic-gate #else 8567c478bd9Sstevel@tonic-gate #define IPV6CPDEBUG(x) ((void) 0) 8577c478bd9Sstevel@tonic-gate #endif /* DEBUGIPV6CP */ 8587c478bd9Sstevel@tonic-gate 8597c478bd9Sstevel@tonic-gate #ifdef DEBUGCHAP 8607c478bd9Sstevel@tonic-gate #define CHAPDEBUG(x) if (debug) dbglog x 8617c478bd9Sstevel@tonic-gate #else 8627c478bd9Sstevel@tonic-gate #define CHAPDEBUG(x) ((void) 0) 8637c478bd9Sstevel@tonic-gate #endif /* DEBUGCHAP */ 8647c478bd9Sstevel@tonic-gate 8657c478bd9Sstevel@tonic-gate #ifdef DEBUGIPXCP 8667c478bd9Sstevel@tonic-gate #define IPXCPDEBUG(x) if (debug) dbglog x 8677c478bd9Sstevel@tonic-gate #else 8687c478bd9Sstevel@tonic-gate #define IPXCPDEBUG(x) ((void) 0) 8697c478bd9Sstevel@tonic-gate #endif /* DEBUGIPXCP */ 8707c478bd9Sstevel@tonic-gate 8717c478bd9Sstevel@tonic-gate #ifndef SIGTYPE 8727c478bd9Sstevel@tonic-gate #if defined(sun) || defined(SYSV) || defined(POSIX_SOURCE) 8737c478bd9Sstevel@tonic-gate #define SIGTYPE void 8747c478bd9Sstevel@tonic-gate #else 8757c478bd9Sstevel@tonic-gate #define SIGTYPE int 8767c478bd9Sstevel@tonic-gate #endif /* defined(sun) || defined(SYSV) || defined(POSIX_SOURCE) */ 8777c478bd9Sstevel@tonic-gate #endif /* SIGTYPE */ 8787c478bd9Sstevel@tonic-gate 8797c478bd9Sstevel@tonic-gate #ifndef MIN 8807c478bd9Sstevel@tonic-gate #define MIN(a, b) ((a) < (b)? (a): (b)) 8817c478bd9Sstevel@tonic-gate #endif /* MIN */ 8827c478bd9Sstevel@tonic-gate 8837c478bd9Sstevel@tonic-gate #ifndef MAX 8847c478bd9Sstevel@tonic-gate #define MAX(a, b) ((a) > (b)? (a): (b)) 8857c478bd9Sstevel@tonic-gate #endif /* MAX */ 8867c478bd9Sstevel@tonic-gate 8877c478bd9Sstevel@tonic-gate #ifndef Dim 8887c478bd9Sstevel@tonic-gate #define Dim(x) (sizeof (x) / sizeof (*(x))) 8897c478bd9Sstevel@tonic-gate #endif /* Dim */ 8907c478bd9Sstevel@tonic-gate 8917c478bd9Sstevel@tonic-gate #ifndef NBBY 8927c478bd9Sstevel@tonic-gate #define NBBY 8 8937c478bd9Sstevel@tonic-gate #endif /* NBBY */ 8947c478bd9Sstevel@tonic-gate 8957c478bd9Sstevel@tonic-gate #ifndef isset 8967c478bd9Sstevel@tonic-gate #define isset(arr, val) (((u_char *)(arr))[(val)/NBBY] & (1<<((val)%NBBY))) 8977c478bd9Sstevel@tonic-gate #endif /* isset */ 8987c478bd9Sstevel@tonic-gate 8997c478bd9Sstevel@tonic-gate #ifndef setbit 9007c478bd9Sstevel@tonic-gate #define setbit(arr, val) (((u_char *)(arr))[(val)/NBBY] |= (1<<((val)%NBBY))) 9017c478bd9Sstevel@tonic-gate #endif /* setbit */ 9027c478bd9Sstevel@tonic-gate 9037c478bd9Sstevel@tonic-gate #define IP_HDRLEN 20 /* bytes */ 9047c478bd9Sstevel@tonic-gate #define IP_OFFMASK 0x1fff 9057c478bd9Sstevel@tonic-gate #define TCP_HDRLEN 20 9067c478bd9Sstevel@tonic-gate 9077c478bd9Sstevel@tonic-gate /* 9087c478bd9Sstevel@tonic-gate * We use these macros because the IP header may be at an odd address, 9097c478bd9Sstevel@tonic-gate * and some compilers might use word loads to get th_off or ip_hl. 9107c478bd9Sstevel@tonic-gate */ 9117c478bd9Sstevel@tonic-gate 9127c478bd9Sstevel@tonic-gate #define net_short(x) (((x)[0] << 8) + (x)[1]) 913*f53eecf5SJames Carlson #define native_long(x) (htonl((net_short(x) << 16) + \ 914*f53eecf5SJames Carlson net_short((unsigned char *)(x) + 2))) 9157c478bd9Sstevel@tonic-gate #define get_ipv(x) ((((unsigned char *)(x))[0] >> 4) & 0xF) 9167c478bd9Sstevel@tonic-gate #define get_iphl(x) (((unsigned char *)(x))[0] & 0xF) 9177c478bd9Sstevel@tonic-gate #define get_iplen(x) net_short((unsigned char *)(x) + 2) 9187c478bd9Sstevel@tonic-gate #define get_ipoff(x) net_short((unsigned char *)(x) + 6) 9197c478bd9Sstevel@tonic-gate #define get_ipproto(x) (((unsigned char *)(x))[9]) 920*f53eecf5SJames Carlson #define get_ipsrc(x) native_long((unsigned char *)(x) + 12) 921*f53eecf5SJames Carlson #define get_ipdst(x) native_long((unsigned char *)(x) + 16) 922*f53eecf5SJames Carlson #define get_ip6nh(x) (((unsigned char *)(x))[6]) 923*f53eecf5SJames Carlson #define get_ip6src(x) (((unsigned char *)(x))+8) 924*f53eecf5SJames Carlson #define get_ip6dst(x) (((unsigned char *)(x))+24) 9257c478bd9Sstevel@tonic-gate /* Ports for both UDP and TCP are first */ 9267c478bd9Sstevel@tonic-gate #define get_sport(x) net_short(x) 9277c478bd9Sstevel@tonic-gate #define get_dport(x) net_short((unsigned char *)(x) + 2) 9287c478bd9Sstevel@tonic-gate #define get_tcpoff(x) (((unsigned char *)(x))[12] >> 4) 9297c478bd9Sstevel@tonic-gate #define get_tcpflags(x) (((unsigned char *)(x))[13]) 9307c478bd9Sstevel@tonic-gate 9317c478bd9Sstevel@tonic-gate /* Check for RFC 1918 (local use) addresses */ 9327c478bd9Sstevel@tonic-gate #define LOCAL_IP_ADDR(addr) \ 9337c478bd9Sstevel@tonic-gate (((addr) & 0xff000000) == 0x0a000000 || /* 10.x.x.x */ \ 9347c478bd9Sstevel@tonic-gate ((addr) & 0xfff00000) == 0xac100000 || /* 172.16.x.x */ \ 9357c478bd9Sstevel@tonic-gate ((addr) & 0xffff0000) == 0xc0a80000) /* 192.168.x.x */ 9367c478bd9Sstevel@tonic-gate 9377c478bd9Sstevel@tonic-gate #ifdef __cplusplus 9387c478bd9Sstevel@tonic-gate } 9397c478bd9Sstevel@tonic-gate #endif 9407c478bd9Sstevel@tonic-gate 9417c478bd9Sstevel@tonic-gate #endif /* __PPPD_H__ */ 942