/*
* pppd.h - PPP daemon global declarations.
*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation is hereby granted, provided that the above copyright
* notice appears in all copies.
*
* SUN MAKES NO REPRESENTATION OR WARRANTIES ABOUT THE SUITABILITY OF
* THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
* TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
* ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
* DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES
*
* Copyright (c) 1989 Carnegie Mellon University.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by Carnegie Mellon University. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: pppd.h,v 1.54 2000/04/15 10:10:25 paulus Exp $
*/
#ifndef __PPPD_H__
#define __PPPD_H__
#include <stdio.h> /* for FILE */
#include <limits.h> /* for NGROUPS_MAX */
#include <net/ppp_defs.h>
#if defined(__STDC__)
#include <stdarg.h>
#define __V(x) x
#else
#include <varargs.h>
#define const
#define volatile
#endif /* __STDC__ */
#ifdef INET6
#include "eui64.h"
#endif /* INET6 */
#ifdef HAVE_MULTILINK
#include "tdb.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
* Limits.
*/
#ifndef MAXHOSTNAMELEN
#endif /* MAXHOSTNAMELEN */
/*
* If this evaluates non-zero, then sifup() must be called before
* sifaddr().
*/
#define SIFUPFIRST \
/*
* If this evaluates non-zero, then sif6up() must be called before
* sif6addr().
*/
#define SIF6UPFIRST \
/*
* Option descriptor structure.
*/
typedef unsigned char bool;
enum opt_type {
o_special_noarg = 0,
};
typedef struct {
void *addr;
char *description;
int flags;
void *addr2;
int upper_limit;
int lower_limit;
} option_t;
/*
* Values for flags.
*/
#ifndef GIDSET_TYPE
#endif /* GIDSET_TYPE */
/*
* Structure representing a list of permitted IP addresses.
*/
struct permitted_ip {
};
/*
* Unfortunately, the linux kernel driver uses a different structure
* for statistics from the rest of the ports.
* This structure serves as a common representation for the bits
* pppd needs.
*/
struct pppd_stats {
};
/*
* Used for storing a sequence of words. Usually malloced.
*/
struct wordlist {
char *word;
};
/*
* Global variables.
*/
extern bool hungup; /* Physical layer has disconnected */
extern int ifunit; /* Interface unit number */
extern int ttyfd; /* Serial device file descriptor */
extern char hostname[]; /* Our hostname */
extern int phase; /* Current state of link - see values below */
extern char *progname; /* Name of this program */
extern int redirect_stderr;/* Connector's stderr should go to file */
extern char peer_authname[];/* Authenticated name of peer */
extern bool privileged; /* We were run by real-uid root */
extern bool need_holdoff; /* Need holdoff period after link terminates */
extern char **script_env; /* Environment variables for scripts */
extern bool detached; /* Have detached from controlling tty */
extern int ngroups; /* How many groups valid in groups */
extern bool link_stats_valid; /* set if link_stats is valid */
extern int link_connect_time; /* time the link was up for */
extern int using_pty; /* using pty as device (notty or pty opt.) */
extern int log_to_fd; /* logging to this fd as well as syslog */
extern bool log_to_file; /* log_to_fd is a file */
extern bool log_to_specific_fd; /* log_to_fd was specified by user */
extern char *no_ppp_msg; /* message to print if ppp not in kernel */
extern volatile int status; /* exit status for pppd */
extern int devnam_fixed; /* can no longer change devnam */
extern int unsuccess; /* # unsuccessful connection attempts */
extern int do_callback; /* set if we want to do callback next */
extern int doing_callback; /* set if this is a callback */
extern bool direct_tty; /* use standard input directly; not a tty */
extern int absmax_mru; /* absolute maximum link (not i/f) MRU */
extern int absmax_mtu; /* absolute maximum link (not i/f) MTU */
extern int pty_slave; /* slave side of PTY, if any */
extern bool early_log; /* avoid logging to stdout */
/*
* Values for do_callback and doing_callback.
*/
/*
* Variables set by command-line options.
*/
extern int debug; /* Debug flag */
extern int kdebugflag; /* Tell kernel to print debug messages */
extern int default_device; /* Using /dev/tty or equivalent */
extern int crtscts; /* Use hardware flow control */
extern bool modem; /* Use modem control lines */
extern bool lockflag; /* Create lock file to lock the serial dev */
extern bool nodetach; /* Don't detach from controlling tty */
extern bool updetach; /* Detach from controlling tty when link up */
extern char *initializer; /* Script to initialize physical link */
extern char *connect_script; /* Script to establish physical link */
extern char *disconnect_script; /* Script to disestablish physical link */
extern char *welcomer; /* Script to welcome client after connection */
extern char *ptycommand; /* Command to run on other side of pty */
extern int maxconnect; /* Maximum connect time (seconds) */
extern bool auth_required; /* Peer is required to authenticate */
extern bool persist; /* Reopen link after it goes down */
extern bool explicit_remote;/* remote_name specified with remotename opt */
extern bool demand; /* Do dial-on-demand */
extern bool cryptpap; /* Others' PAP passwords are encrypted */
extern int idle_time_limit;/* Shut down link if idle for this long */
extern int holdoff; /* Dead time before restarting */
extern bool holdoff_specified; /* true if user gave a holdoff value */
extern char *pty_socket; /* Socket to connect to pty */
extern char *record_file; /* File to record chars sent/received */
extern bool sync_serial; /* Device is synchronous serial device */
extern int maxfail; /* Max # of unsuccessful connection attempts */
extern bool tune_kernel; /* May alter kernel settings as necessary */
extern int connect_delay; /* Time to delay after connect script */
extern int max_data_rate; /* max bytes/sec through charshunt */
extern int req_unit; /* interface unit number to use */
extern bool multilink; /* enable multilink operation */
extern bool noendpoint; /* don't send or accept endpt. discrim. */
extern char *bundle_name; /* bundle name for multilink */
#ifdef HAVE_MULTILINK
extern char db_key[]; /* multilink database key */
#endif
#ifdef PPP_FILTER
#endif /* PPP_FILTER */
#ifdef MSLANMAN
extern bool ms_lanman; /* Use LanMan password instead of NT */
/* Has meaning only with MS-CHAP challenges */
#endif /* MXLANMAN */
extern char *current_option; /* the name of the option being parsed */
extern bool privileged_option; /* set iff the current option came from root */
extern char *option_source; /* string saying where the option came from */
extern int option_line; /* and from which line in the file */
extern bool already_ppp; /* device is already in PPP mode */
extern bool prepass; /* Doing pre-pass to find device name */
extern bool peer_nak_auth; /* Peer sent nak for our auth request */
extern bool unsolicited_nak_auth; /* Peer asked us to authenticate */
extern bool peer_reject_auth; /* Peer sent reject for auth */
extern bool rejected_peers_auth; /* We sent a reject to the peer */
extern bool naked_peers_auth; /* We sent a nak to the peer */
/*
* Values for phase.
*/
#define PHASE__NAMES \
"Dead", "Initialize", "Initialized", "Serialconn", "Connected", \
"Dormant", "Establish", "Authenticate", "Callback", "Network", \
"Running", "Terminate", "Disconnect", "Holdoff", "Callingback", \
"Exit"
/*
* The following struct gives the addresses of procedures to call
* for a particular protocol.
*/
struct protent {
/* Initialization procedure */
/* Process a received packet */
/* Process a received protocol-reject */
/* Lower layer has come up */
/* Lower layer has gone down */
/* Open the protocol */
/* Close the protocol */
/* Print a packet in readable form */
void *arg));
/* Process a received data packet */
/* Check requested options, assign defaults */
/* Configure interface for demand-dial */
/* Say whether to bring up link for this pkt */
/* Print current status to file or syslog (if strptr == NULL) */
};
/*
* This structure is used to store information about certain
* command line, etc.) and whether it came from a privileged source.
*/
struct option_info {
};
extern struct option_info devnam_info;
extern struct option_info initializer_info;
extern struct option_info connect_script_info;
extern struct option_info disconnect_script_info;
extern struct option_info welcomer_info;
extern struct option_info ptycommand_info;
extern struct option_info ipsrc_info;
extern struct option_info ipdst_info;
extern struct option_info speed_info;
/*
* Table of pointers to supported protocols.
*/
/*
* Prototypes.
*/
/*
* Procedures exported from main.c.
*/
/* Call func(arg) after t seconds */
/* Cancel call to func(arg) */
/* Run program prog with args in child */
/* set script env var */
extern void script_setenv __P((const char *, const char *, int));
/*
* Procedures exported from utils.c.
*/
/* Format a packet and log it with syslog */
extern void print_string __P((char *, int, void (*)(void *, const char *, ...),
void *)); /* Format a string for output */
/* log an error message and die(1) */
/* Code to string */
/*
* Procedures exported from auth.c
*/
/* the LCP layer has left the Opened state */
extern void start_networks __P((void));
/* start all the network control protos */
extern void np_finished __P((int, int));
/* a network protocol no longer needs link */
extern void auth_peer_fail __P((int, int));
/* peer failed to authenticate itself */
extern void auth_peer_success __P((int, int, char *, int));
/* peer successfully authenticated itself */
extern void auth_withpeer_fail __P((int, int));
/* we failed to authenticate ourselves */
extern void auth_withpeer_success __P((int, int));
/* we successfully authenticated ourselves */
extern void auth_check_options __P((void));
/* check authentication options supplied */
extern void auth_reset __P((int));
/* check what secrets we have */
extern int check_passwd __P((int, char *, int, char *, int, char **));
extern int get_secret __P((int, char *, char *, char *, int *, int));
/* get "secret" for chap */
/* check if IP address is authorized */
/* check if IP address is unreasonable */
/*
* Procedures exported from demand.c
*/
extern void demand_conf __P((void));
/* config interface(s) for demand-dial */
extern int loop_chars __P((unsigned char *, int));
/* process chars from loopback */
extern int loop_frame __P((unsigned char *, int));
/* should we bring link up? */
/*
* Procedures exported from multilink.c
*/
extern int mp_join_bundle __P((void));
/* join our link to an appropriate bundle */
/*
* Procedures exported from sys-*.c
*/
extern int ppp_available __P((void));
/* Test whether ppp kernel support exists */
extern int open_ppp_loopback __P((void));
/* Open loopback for demand-dialling */
extern int establish_ppp __P((int));
/* Turn serial port into a ppp interface */
extern void restore_loop __P((void));
/* Transfer ppp unit back to loopback */
extern void disestablish_ppp __P((int));
/* Restore port to normal operation */
extern void cfg_bundle __P((int, int, int, int));
/* Configure existing bundle */
extern void set_up_tty __P((int, int));
/* Set up port's speed, parameters, etc. */
/* Wait for input, with timeout */
/* Configure i/f transmit parameters */
/* Set extended transmit ACCM */
/* Configure i/f receive parameters */
#ifdef NEGOTIATE_FCS
#endif /* NEGOTIATE_FCS */
#ifdef MUX_FRAME
#endif /* MUX_FRAME */
/* Test support for compression scheme */
#ifdef COMP_TUNE
#endif /* COMP_TUNE */
extern void ccp_flags_set __P((int, int, int));
/* Set kernel CCP state */
extern int ccp_fatal_error __P((int));
/* Test for fatal decomp error in kernel */
/* Find out how long link has been idle */
/* Return link statistics */
/* Configure VJ TCP header compression */
/* Set mode for handling packets for proto */
/* Configure IPv4 addresses for i/f */
/* Reset i/f IP addresses */
#ifdef INET6
/* Configure IPv6 addresses for i/f */
/* Remove an IPv6 address from i/f */
#endif /* INET6 */
/* Create default route through i/f */
/* Delete default route through i/f */
/* Add proxy ARP entry for peer */
/* Delete proxy ARP entry for peer */
/* Get appropriate netmask for address */
/* Write entry to wtmp file */
extern int get_host_seed __P((void));
/* Get host-dependent random number seed */
#ifdef PPP_FILTER
struct bpf_program *active));
/* Set filter programs in kernel */
#endif /* PPP_FILTER */
#ifdef IPX_CHANGE
#endif /* IPX_CHANGE */
#endif /* INET6 && SOL2*/
#endif
extern void sys_ifname __P((void));
extern int sys_extra_fd __P((void));
/*
* Procedures exported from options.c
*/
/* Parse options from arguments given */
bool check_prot, bool privileged));
/* Parse options from an options file */
extern int options_from_user __P((void));
/* Parse options from user's .ppprc */
extern int options_for_tty __P((void));
/* Parse options from /etc/ppp/options.tty */
/* Parse options from a wordlist */
/* Read a word from a file */
/* Print an error message about an option */
extern int int_option __P((char *, int *));
/* Simplified number_option for decimal ints */
/* Add extra options */
/* Parse dotted IP notation */
/* Remove (disable) an option */
/* Save the source information (where an option comes from) */
/* Set the source (for logging option errors detected after parsing) */
/* Return a string containing the option source and line number */
/*
* Hooks to enable plugins to change various things.
*/
extern int (*holdoff_hook) __P((void));
extern int (*pap_check_hook) __P((void));
extern void (*pap_logout_hook) __P((void));
extern void (*ip_up_hook) __P((void));
extern void (*ip_down_hook) __P((void));
/* extern int (*attach_device_hook) __P((uid_t uid, char *devnam)); */
struct strbuf; /* forward declaration */
/*
* Pointer is advanced; we assume that both arguments
* are lvalues and will already be in registers.
* cp MUST be u_char *.
*/
(c) = *(cp)++; \
}
}
(s) = *(cp)++ << 8; \
(s) |= *(cp)++; \
}
}
(l) = *(cp)++ << 8; \
(l) |= *(cp)++; (l) <<= 8; \
(l) |= *(cp)++; (l) <<= 8; \
(l) |= *(cp)++; \
}
}
/*
* For values that are kept internally in network byte order.
*/
getnlong_val |= *(cp)++; \
(l) = htonl(getnlong_val); \
}
}
/*
* System dependent definitions for user-level 4.3BSD UNIX implementation.
*/
#ifndef SOL2
#else
#include <strings.h>
#endif
/*
* MAKEHEADER - Add Header fields to a packet.
*/
#define MAKEHEADER(p, t) { \
PUTCHAR(PPP_ALLSTATIONS, p); \
PUTSHORT(t, p); }
/*
* Exit status values.
*/
#define EXIT_OK 0
/*
* Character shunt constants.
*/
/*
* Debug macros. Slightly useful for finding bugs in pppd, not particularly
* useful for finding out why your connection isn't being established.
*/
#ifdef DEBUGALL
#endif /* DEBUGALL */
#ifndef LOG_PPP /* we use LOG_DAEMON for syslog by default */
#endif /* LOG_PPP */
#ifdef DEBUGMAIN
#else
#define MAINDEBUG(x) ((void) 0)
#endif /* DEBUGMAIN */
#ifdef DEBUGSYS
#else
#define SYSDEBUG(x) ((void) 0)
#endif /* DEBUGSYS */
#ifdef DEBUGLCP
#else
#define LCPDEBUG(x) ((void) 0)
#endif /* DEBUGLCP */
#ifdef DEBUGIPCP
#else
#define IPCPDEBUG(x) ((void) 0)
#endif /* DEBUGIPCP */
#ifdef DEBUGIPV6CP
#else
#define IPV6CPDEBUG(x) ((void) 0)
#endif /* DEBUGIPV6CP */
#ifdef DEBUGCHAP
#else
#define CHAPDEBUG(x) ((void) 0)
#endif /* DEBUGCHAP */
#ifdef DEBUGIPXCP
#else
#define IPXCPDEBUG(x) ((void) 0)
#endif /* DEBUGIPXCP */
#ifndef SIGTYPE
#define SIGTYPE void
#else
#define SIGTYPE int
#endif /* defined(sun) || defined(SYSV) || defined(POSIX_SOURCE) */
#endif /* SIGTYPE */
#ifndef MIN
#define MIN(a, b) ((a) < (b)? (a): (b))
#endif /* MIN */
#ifndef MAX
#define MAX(a, b) ((a) > (b)? (a): (b))
#endif /* MAX */
#ifndef Dim
#define Dim(x) (sizeof (x) / sizeof (*(x)))
#endif /* Dim */
#ifndef NBBY
#endif /* NBBY */
#ifndef isset
#endif /* isset */
#ifndef setbit
#endif /* setbit */
/*
* We use these macros because the IP header may be at an odd address,
* and some compilers might use word loads to get th_off or ip_hl.
*/
net_short((unsigned char *)(x) + 2)))
/* Ports for both UDP and TCP are first */
/* Check for RFC 1918 (local use) addresses */
#ifdef __cplusplus
}
#endif
#endif /* __PPPD_H__ */