| 1 |
786 |
skrzyp |
//==========================================================================
|
| 2 |
|
|
//
|
| 3 |
|
|
// include/pppd.h
|
| 4 |
|
|
//
|
| 5 |
|
|
//==========================================================================
|
| 6 |
|
|
// ####ECOSGPLCOPYRIGHTBEGIN####
|
| 7 |
|
|
// -------------------------------------------
|
| 8 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
| 9 |
|
|
// Copyright (C) 2003 Free Software Foundation, Inc.
|
| 10 |
|
|
//
|
| 11 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
| 12 |
|
|
// the terms of the GNU General Public License as published by the Free
|
| 13 |
|
|
// Software Foundation; either version 2 or (at your option) any later
|
| 14 |
|
|
// version.
|
| 15 |
|
|
//
|
| 16 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
| 17 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
| 18 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
| 19 |
|
|
// for more details.
|
| 20 |
|
|
//
|
| 21 |
|
|
// You should have received a copy of the GNU General Public License
|
| 22 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
| 23 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
| 24 |
|
|
//
|
| 25 |
|
|
// As a special exception, if other files instantiate templates or use
|
| 26 |
|
|
// macros or inline functions from this file, or you compile this file
|
| 27 |
|
|
// and link it with other works to produce a work based on this file,
|
| 28 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
| 29 |
|
|
// the GNU General Public License. However the source code for this file
|
| 30 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
| 31 |
|
|
// General Public License v2.
|
| 32 |
|
|
//
|
| 33 |
|
|
// This exception does not invalidate any other reasons why a work based
|
| 34 |
|
|
// on this file might be covered by the GNU General Public License.
|
| 35 |
|
|
// -------------------------------------------
|
| 36 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
| 37 |
|
|
// ####BSDALTCOPYRIGHTBEGIN####
|
| 38 |
|
|
// -------------------------------------------
|
| 39 |
|
|
// Portions of this software may have been derived from FreeBSD, OpenBSD,
|
| 40 |
|
|
// or other sources, and if so are covered by the appropriate copyright
|
| 41 |
|
|
// and license included herein.
|
| 42 |
|
|
// -------------------------------------------
|
| 43 |
|
|
// ####BSDALTCOPYRIGHTEND####
|
| 44 |
|
|
//==========================================================================
|
| 45 |
|
|
|
| 46 |
|
|
/*
|
| 47 |
|
|
* pppd.h - PPP daemon global declarations.
|
| 48 |
|
|
*
|
| 49 |
|
|
* Copyright (c) 1989 Carnegie Mellon University.
|
| 50 |
|
|
* All rights reserved.
|
| 51 |
|
|
*
|
| 52 |
|
|
* Redistribution and use in source and binary forms are permitted
|
| 53 |
|
|
* provided that the above copyright notice and this paragraph are
|
| 54 |
|
|
* duplicated in all such forms and that any documentation,
|
| 55 |
|
|
* advertising materials, and other materials related to such
|
| 56 |
|
|
* distribution and use acknowledge that the software was developed
|
| 57 |
|
|
* by Carnegie Mellon University. The name of the
|
| 58 |
|
|
* University may not be used to endorse or promote products derived
|
| 59 |
|
|
* from this software without specific prior written permission.
|
| 60 |
|
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
| 61 |
|
|
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
| 62 |
|
|
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 63 |
|
|
*
|
| 64 |
|
|
* $FreeBSD: src/usr.sbin/pppd/pppd.h,v 1.13 1999/08/28 01:19:08 peter Exp $
|
| 65 |
|
|
*/
|
| 66 |
|
|
|
| 67 |
|
|
/*
|
| 68 |
|
|
* TODO:
|
| 69 |
|
|
*/
|
| 70 |
|
|
|
| 71 |
|
|
#ifndef __PPPD_H__
|
| 72 |
|
|
#define __PPPD_H__
|
| 73 |
|
|
|
| 74 |
|
|
#include <cyg/io/io.h>
|
| 75 |
|
|
#include <cyg/io/serialio.h>
|
| 76 |
|
|
|
| 77 |
|
|
#include <cyg/ppp/names.h>
|
| 78 |
|
|
|
| 79 |
|
|
#include <stdio.h> /* for FILE */
|
| 80 |
|
|
#include <sys/param.h> /* for MAXPATHLEN and BSD4_4, if defined */
|
| 81 |
|
|
#include <sys/types.h> /* for u_int32_t, if defined */
|
| 82 |
|
|
#include <sys/time.h> /* for struct timeval */
|
| 83 |
|
|
#include <cyg/ppp/net/ppp_defs.h>
|
| 84 |
|
|
#include <cyg/ppp/ppp.h>
|
| 85 |
|
|
|
| 86 |
|
|
#if __STDC__
|
| 87 |
|
|
#include <stdarg.h>
|
| 88 |
|
|
#define __V(x) x
|
| 89 |
|
|
#else
|
| 90 |
|
|
#include <varargs.h>
|
| 91 |
|
|
#define __V(x) (va_alist) va_dcl
|
| 92 |
|
|
#define const
|
| 93 |
|
|
#endif
|
| 94 |
|
|
|
| 95 |
|
|
/*
|
| 96 |
|
|
* Limits.
|
| 97 |
|
|
*/
|
| 98 |
|
|
|
| 99 |
|
|
#define NUM_PPP 1 /* One PPP interface supported (per process) */
|
| 100 |
|
|
#define MAXWORDLEN 1024 /* max length of word in file (incl null) */
|
| 101 |
|
|
#define MAXARGS 1 /* max # args to a command */
|
| 102 |
|
|
#define MAXNAMELEN 256 /* max length of hostname or name for auth */
|
| 103 |
|
|
#define MAXSECRETLEN 256 /* max length of password or secret */
|
| 104 |
|
|
|
| 105 |
|
|
/*
|
| 106 |
|
|
* Global variables.
|
| 107 |
|
|
*/
|
| 108 |
|
|
|
| 109 |
|
|
extern int hungup; /* Physical layer has disconnected */
|
| 110 |
|
|
extern char ifname[]; /* Interface name */
|
| 111 |
|
|
extern int ttyfd; /* Serial device file descriptor */
|
| 112 |
|
|
extern char cyg_ppp_hostname[]; /* Our hostname */
|
| 113 |
|
|
extern u_char outpacket_buf[]; /* Buffer for outgoing packets */
|
| 114 |
|
|
extern int phase; /* Current state of link - see values below */
|
| 115 |
|
|
extern int baud_rate; /* Current link speed in bits/sec */
|
| 116 |
|
|
extern char *progname; /* Name of this program */
|
| 117 |
|
|
extern int redirect_stderr;/* Connector's stderr should go to file */
|
| 118 |
|
|
extern char peer_authname[];/* Authenticated name of peer */
|
| 119 |
|
|
extern int privileged; /* We were run by real-uid root */
|
| 120 |
|
|
extern int need_holdoff; /* Need holdoff period after link terminates */
|
| 121 |
|
|
extern char **script_env; /* Environment variables for scripts */
|
| 122 |
|
|
extern int detached; /* Have detached from controlling tty */
|
| 123 |
|
|
|
| 124 |
|
|
/*
|
| 125 |
|
|
* Variables set by command-line options.
|
| 126 |
|
|
*/
|
| 127 |
|
|
|
| 128 |
|
|
extern int debug; /* Debug flag */
|
| 129 |
|
|
extern int kdebugflag; /* Tell kernel to print debug messages */
|
| 130 |
|
|
extern int default_device; /* Using /dev/tty or equivalent */
|
| 131 |
|
|
extern char devnam[]; /* Device name */
|
| 132 |
|
|
extern int flowctl; /* Flow control */
|
| 133 |
|
|
extern int modem; /* Use modem control lines */
|
| 134 |
|
|
extern cyg_serial_baud_rate_t inspeed; /* Input/Output speed requested */
|
| 135 |
|
|
extern u_int32_t netmask; /* IP netmask to set on interface */
|
| 136 |
|
|
extern int lockflag; /* Create lock file to lock the serial dev */
|
| 137 |
|
|
extern int nodetach; /* Don't detach from controlling tty */
|
| 138 |
|
|
extern char *connector; /* Script to establish physical link */
|
| 139 |
|
|
extern char *disconnector; /* Script to disestablish physical link */
|
| 140 |
|
|
extern char *welcomer; /* Script to welcome client after connection */
|
| 141 |
|
|
extern int max_con_attempts;/* Maximum number of times to try dialing */
|
| 142 |
|
|
extern int maxconnect; /* Maximum connect time (seconds) */
|
| 143 |
|
|
extern char user[]; /* Our name for authenticating ourselves */
|
| 144 |
|
|
extern char passwd[]; /* Password for PAP */
|
| 145 |
|
|
extern int auth_required; /* Peer is required to authenticate */
|
| 146 |
|
|
extern int neg_accm; /* Flag to enable ACCM negotiation */
|
| 147 |
|
|
extern int conf_accm; /* Configurable value of ACCM */
|
| 148 |
|
|
extern int proxyarp; /* Set up proxy ARP entry for peer */
|
| 149 |
|
|
extern int persist; /* Reopen link after it goes down */
|
| 150 |
|
|
extern int uselogin; /* Use /etc/passwd for checking PAP */
|
| 151 |
|
|
extern int lcp_echo_interval; /* Interval between LCP echo-requests */
|
| 152 |
|
|
extern int lcp_echo_fails; /* Tolerance to unanswered echo-requests */
|
| 153 |
|
|
extern char our_name[]; /* Our name for authentication purposes */
|
| 154 |
|
|
extern char remote_name[]; /* Peer's name for authentication */
|
| 155 |
|
|
extern int explicit_remote;/* remote_name specified with remotename opt */
|
| 156 |
|
|
extern int usehostname; /* Use hostname for our_name */
|
| 157 |
|
|
extern int disable_defaultip; /* Don't use hostname for default IP adrs */
|
| 158 |
|
|
//extern int demand; /* Do dial-on-demand */
|
| 159 |
|
|
#define demand 0
|
| 160 |
|
|
extern char *ipparam; /* Extra parameter for ip up/down scripts */
|
| 161 |
|
|
extern int cryptpap; /* Others' PAP passwords are encrypted */
|
| 162 |
|
|
extern int idle_time_limit;/* Shut down link if idle for this long */
|
| 163 |
|
|
extern int holdoff; /* Dead time before restarting */
|
| 164 |
|
|
extern int refuse_pap; /* Don't wanna auth. ourselves with PAP */
|
| 165 |
|
|
extern int refuse_chap; /* Don't wanna auth. ourselves with CHAP */
|
| 166 |
|
|
#ifdef PPP_FILTER
|
| 167 |
|
|
extern struct bpf_program pass_filter; /* Filter for pkts to pass */
|
| 168 |
|
|
extern struct bpf_program active_filter; /* Filter for link-active pkts */
|
| 169 |
|
|
#endif
|
| 170 |
|
|
|
| 171 |
|
|
|
| 172 |
|
|
#ifdef MSLANMAN
|
| 173 |
|
|
extern int ms_lanman; /* Nonzero if use LanMan password instead of NT */
|
| 174 |
|
|
/* Has meaning only with MS-CHAP challenges */
|
| 175 |
|
|
#endif
|
| 176 |
|
|
|
| 177 |
|
|
/*
|
| 178 |
|
|
* Values for phase.
|
| 179 |
|
|
*/
|
| 180 |
|
|
#define PHASE_DEAD 0
|
| 181 |
|
|
#define PHASE_INITIALIZE 1
|
| 182 |
|
|
#define PHASE_DORMANT 2
|
| 183 |
|
|
#define PHASE_ESTABLISH 3
|
| 184 |
|
|
#define PHASE_AUTHENTICATE 4
|
| 185 |
|
|
#define PHASE_CALLBACK 5
|
| 186 |
|
|
#define PHASE_NETWORK 6
|
| 187 |
|
|
#define PHASE_TERMINATE 7
|
| 188 |
|
|
#define PHASE_HOLDOFF 8
|
| 189 |
|
|
|
| 190 |
|
|
/*
|
| 191 |
|
|
* The following struct gives the addresses of procedures to call
|
| 192 |
|
|
* for a particular protocol.
|
| 193 |
|
|
*/
|
| 194 |
|
|
struct protent {
|
| 195 |
|
|
u_short protocol; /* PPP protocol number */
|
| 196 |
|
|
/* Initialization procedure */
|
| 197 |
|
|
void (*init) __P((int unit));
|
| 198 |
|
|
/* Process a received packet */
|
| 199 |
|
|
void (*input) __P((int unit, u_char *pkt, int len));
|
| 200 |
|
|
/* Process a received protocol-reject */
|
| 201 |
|
|
void (*protrej) __P((int unit));
|
| 202 |
|
|
/* Lower layer has come up */
|
| 203 |
|
|
void (*lowerup) __P((int unit));
|
| 204 |
|
|
/* Lower layer has gone down */
|
| 205 |
|
|
void (*lowerdown) __P((int unit));
|
| 206 |
|
|
/* Open the protocol */
|
| 207 |
|
|
void (*open) __P((int unit));
|
| 208 |
|
|
/* Close the protocol */
|
| 209 |
|
|
void (*close) __P((int unit, char *reason));
|
| 210 |
|
|
/* Print a packet in readable form */
|
| 211 |
|
|
int (*printpkt) __P((u_char *pkt, int len,
|
| 212 |
|
|
void (*printer) __P((void *, char *, ...)),
|
| 213 |
|
|
void *arg));
|
| 214 |
|
|
/* Process a received data packet */
|
| 215 |
|
|
void (*datainput) __P((int unit, u_char *pkt, int len));
|
| 216 |
|
|
int enabled_flag; /* 0 iff protocol is disabled */
|
| 217 |
|
|
char *name; /* Text name of protocol */
|
| 218 |
|
|
/* Check requested options, assign defaults */
|
| 219 |
|
|
void (*check_options) __P((void));
|
| 220 |
|
|
/* Configure interface for demand-dial */
|
| 221 |
|
|
int (*demand_conf) __P((int unit));
|
| 222 |
|
|
/* Say whether to bring up link for this pkt */
|
| 223 |
|
|
int (*active_pkt) __P((u_char *pkt, int len));
|
| 224 |
|
|
};
|
| 225 |
|
|
|
| 226 |
|
|
/* Table of pointers to supported protocols */
|
| 227 |
|
|
extern struct protent *protocols[];
|
| 228 |
|
|
|
| 229 |
|
|
/*
|
| 230 |
|
|
* Prototypes.
|
| 231 |
|
|
*/
|
| 232 |
|
|
|
| 233 |
|
|
/* Procedures exported from main.c. */
|
| 234 |
|
|
void detach __P((void)); /* Detach from controlling tty */
|
| 235 |
|
|
void die __P((int)); /* Cleanup and exit */
|
| 236 |
|
|
void quit __P((void)); /* like die(1) */
|
| 237 |
|
|
void novm __P((char *)); /* Say we ran out of memory, and die */
|
| 238 |
|
|
void cyg_ppp_timeout __P((void (*func)(void *), void *arg, int t));
|
| 239 |
|
|
/* Call func(arg) after t seconds */
|
| 240 |
|
|
void cyg_ppp_untimeout __P((void (*func)(void *), void *arg));
|
| 241 |
|
|
/* Cancel call to func(arg) */
|
| 242 |
|
|
int run_program __P((char *prog, char **args, int must_exist));
|
| 243 |
|
|
/* Run program prog with args in child */
|
| 244 |
|
|
void demuxprotrej __P((int, int));
|
| 245 |
|
|
/* Demultiplex a Protocol-Reject */
|
| 246 |
|
|
void format_packet __P((u_char *, int, void (*) (void *, char *, ...),
|
| 247 |
|
|
void *)); /* Format a packet in human-readable form */
|
| 248 |
|
|
void log_packet __P((u_char *, int, char *, int));
|
| 249 |
|
|
/* Format a packet and log it with syslog */
|
| 250 |
|
|
void print_string __P((unsigned char *, int, void (*) (void *, char *, ...),
|
| 251 |
|
|
void *)); /* Format a string for output */
|
| 252 |
|
|
int fmtmsg __P((char *, int, char *, ...)); /* sprintf++ */
|
| 253 |
|
|
int vfmtmsg __P((char *, int, char *, va_list)); /* vsprintf++ */
|
| 254 |
|
|
void script_setenv __P((char *, char *)); /* set script env var */
|
| 255 |
|
|
void script_unsetenv __P((char *)); /* unset script env var */
|
| 256 |
|
|
|
| 257 |
|
|
/* Procedures exported from auth.c */
|
| 258 |
|
|
void link_required __P((int)); /* we are starting to use the link */
|
| 259 |
|
|
void link_terminated __P((int)); /* we are finished with the link */
|
| 260 |
|
|
void link_down __P((int)); /* the LCP layer has left the Opened state */
|
| 261 |
|
|
void link_established __P((int)); /* the link is up; authenticate now */
|
| 262 |
|
|
void np_up __P((int, int)); /* a network protocol has come up */
|
| 263 |
|
|
void np_down __P((int, int)); /* a network protocol has gone down */
|
| 264 |
|
|
void np_finished __P((int, int)); /* a network protocol no longer needs link */
|
| 265 |
|
|
void auth_peer_fail __P((int, int));
|
| 266 |
|
|
/* peer failed to authenticate itself */
|
| 267 |
|
|
void auth_peer_success __P((int, int, char *, int));
|
| 268 |
|
|
/* peer successfully authenticated itself */
|
| 269 |
|
|
void auth_withpeer_fail __P((int, int));
|
| 270 |
|
|
/* we failed to authenticate ourselves */
|
| 271 |
|
|
void auth_withpeer_success __P((int, int));
|
| 272 |
|
|
/* we successfully authenticated ourselves */
|
| 273 |
|
|
void auth_check_options __P((void));
|
| 274 |
|
|
/* check authentication options supplied */
|
| 275 |
|
|
void auth_reset __P((int)); /* check what secrets we have */
|
| 276 |
|
|
int check_passwd __P((int, char *, int, char *, int, char **, int *));
|
| 277 |
|
|
/* Check peer-supplied username/password */
|
| 278 |
|
|
int get_secret __P((int, char *, char *, char *, int *, int));
|
| 279 |
|
|
/* get "secret" for chap */
|
| 280 |
|
|
int auth_ip_addr __P((int, u_int32_t));
|
| 281 |
|
|
/* check if IP address is authorized */
|
| 282 |
|
|
int bad_ip_adrs __P((u_int32_t));
|
| 283 |
|
|
/* check if IP address is unreasonable */
|
| 284 |
|
|
void check_access __P((FILE *, char *));
|
| 285 |
|
|
/* check permissions on secrets file */
|
| 286 |
|
|
|
| 287 |
|
|
/* Procedures exported from demand.c */
|
| 288 |
|
|
void demand_conf __P((void)); /* config interface(s) for demand-dial */
|
| 289 |
|
|
void demand_block __P((void)); /* set all NPs to queue up packets */
|
| 290 |
|
|
void demand_unblock __P((void)); /* set all NPs to pass packets */
|
| 291 |
|
|
void demand_discard __P((void)); /* set all NPs to discard packets */
|
| 292 |
|
|
void demand_rexmit __P((int)); /* retransmit saved frames for an NP */
|
| 293 |
|
|
int loop_chars __P((unsigned char *, int)); /* process chars from loopback */
|
| 294 |
|
|
int loop_frame __P((unsigned char *, int)); /* process frame from loopback */
|
| 295 |
|
|
|
| 296 |
|
|
/* Procedures exported from sys-*.c */
|
| 297 |
|
|
void sys_init __P((void)); /* Do system-dependent initialization */
|
| 298 |
|
|
void sys_cleanup __P((void)); /* Restore system state before exiting */
|
| 299 |
|
|
void sys_check_options __P((void)); /* Check options specified */
|
| 300 |
|
|
void sys_close __P((void)); /* Clean up in a child before execing */
|
| 301 |
|
|
int ppp_available __P((void)); /* Test whether ppp kernel support exists */
|
| 302 |
|
|
void open_ppp_loopback __P((void)); /* Open loopback for demand-dialling */
|
| 303 |
|
|
void establish_ppp __P((cyg_io_handle_t)); /* Turn serial port into a ppp interface */
|
| 304 |
|
|
void restore_loop __P((void)); /* Transfer ppp unit back to loopback */
|
| 305 |
|
|
void disestablish_ppp __P((cyg_io_handle_t)); /* Restore port to normal operation */
|
| 306 |
|
|
void clean_check __P((void)); /* Check if line was 8-bit clean */
|
| 307 |
|
|
void set_up_tty __P((cyg_io_handle_t, int)); /* Set up port's speed, parameters, etc. */
|
| 308 |
|
|
void restore_tty __P((cyg_io_handle_t)); /* Restore port's original parameters */
|
| 309 |
|
|
void setdtr __P((int, int)); /* Raise or lower port's DTR line */
|
| 310 |
|
|
void output __P((int, u_char *, int)); /* Output a PPP packet */
|
| 311 |
|
|
void wait_input __P((struct timeval *));
|
| 312 |
|
|
/* Wait for input, with timeout */
|
| 313 |
|
|
void wait_loop_output __P((struct timeval *));
|
| 314 |
|
|
/* Wait for pkt from loopback, with timeout */
|
| 315 |
|
|
void wait_time __P((struct timeval *)); /* Wait for given length of time */
|
| 316 |
|
|
int read_packet __P((u_char *)); /* Read PPP packet */
|
| 317 |
|
|
int get_loop_output __P((void)); /* Read pkts from loopback */
|
| 318 |
|
|
void ppp_send_config __P((int, int, u_int32_t, int, int));
|
| 319 |
|
|
/* Configure i/f transmit parameters */
|
| 320 |
|
|
void ppp_set_xaccm __P((int, ext_accm));
|
| 321 |
|
|
/* Set extended transmit ACCM */
|
| 322 |
|
|
void ppp_recv_config __P((int, int, u_int32_t, int, int));
|
| 323 |
|
|
/* Configure i/f receive parameters */
|
| 324 |
|
|
int ccp_test __P((int, u_char *, int, int));
|
| 325 |
|
|
/* Test support for compression scheme */
|
| 326 |
|
|
void ccp_flags_set __P((int, int, int));
|
| 327 |
|
|
/* Set kernel CCP state */
|
| 328 |
|
|
int ccp_fatal_error __P((int)); /* Test for fatal decomp error in kernel */
|
| 329 |
|
|
int get_idle_time __P((int, struct ppp_idle *));
|
| 330 |
|
|
/* Find out how long link has been idle */
|
| 331 |
|
|
int sifvjcomp __P((int, int, int, int));
|
| 332 |
|
|
/* Configure VJ TCP header compression */
|
| 333 |
|
|
int sifup __P((int)); /* Configure i/f up (for IP) */
|
| 334 |
|
|
int sifnpmode __P((int u, int proto, enum NPmode mode));
|
| 335 |
|
|
/* Set mode for handling packets for proto */
|
| 336 |
|
|
int sifdown __P((int)); /* Configure i/f down (for IP) */
|
| 337 |
|
|
int sifaddr __P((int, u_int32_t, u_int32_t, u_int32_t));
|
| 338 |
|
|
/* Configure IP addresses for i/f */
|
| 339 |
|
|
int cifaddr __P((int, u_int32_t, u_int32_t));
|
| 340 |
|
|
/* Reset i/f IP addresses */
|
| 341 |
|
|
int sifdefaultroute __P((int, u_int32_t, u_int32_t));
|
| 342 |
|
|
/* Create default route through i/f */
|
| 343 |
|
|
int cifdefaultroute __P((int, u_int32_t, u_int32_t));
|
| 344 |
|
|
/* Delete default route through i/f */
|
| 345 |
|
|
int sifproxyarp __P((int, u_int32_t));
|
| 346 |
|
|
/* Add proxy ARP entry for peer */
|
| 347 |
|
|
int cifproxyarp __P((int, u_int32_t));
|
| 348 |
|
|
/* Delete proxy ARP entry for peer */
|
| 349 |
|
|
u_int32_t GetMask __P((u_int32_t)); /* Get appropriate netmask for address */
|
| 350 |
|
|
int lock __P((char *)); /* Create lock file for device */
|
| 351 |
|
|
void unlock __P((void)); /* Delete previously-created lock file */
|
| 352 |
|
|
int daemon __P((int, int)); /* Detach us from terminal session */
|
| 353 |
|
|
void logwtmp __P((const char *, const char *, const char *));
|
| 354 |
|
|
/* Write entry to wtmp file */
|
| 355 |
|
|
int get_host_seed __P((void)); /* Get host-dependent random number seed */
|
| 356 |
|
|
#ifdef PPP_FILTER
|
| 357 |
|
|
int set_filters __P((struct bpf_program *pass, struct bpf_program *active));
|
| 358 |
|
|
/* Set filter programs in kernel */
|
| 359 |
|
|
#endif
|
| 360 |
|
|
|
| 361 |
|
|
/* Procedures exported from options.c */
|
| 362 |
|
|
int parse_args __P((int argc, char **argv));
|
| 363 |
|
|
/* Parse options from arguments given */
|
| 364 |
|
|
void usage __P((void)); /* Print a usage message */
|
| 365 |
|
|
int options_from_file __P((char *filename, int must_exist, int check_prot,
|
| 366 |
|
|
int privileged));
|
| 367 |
|
|
/* Parse options from an options file */
|
| 368 |
|
|
int options_from_user __P((void)); /* Parse options from user's .ppprc */
|
| 369 |
|
|
int options_for_tty __P((void)); /* Parse options from /etc/ppp/options.tty */
|
| 370 |
|
|
void scan_args __P((int argc, char **argv));
|
| 371 |
|
|
/* Look for tty name in command-line args */
|
| 372 |
|
|
int getword __P((FILE *f, char *word, int *newlinep, char *filename));
|
| 373 |
|
|
/* Read a word from a file */
|
| 374 |
|
|
void option_error __P((char *fmt, ...));
|
| 375 |
|
|
/* Print an error message about an option */
|
| 376 |
|
|
int setipaddr __P((char *)); /* set IP addresses */
|
| 377 |
|
|
int gettimeofday __P((struct timeval *tv, struct timezone *tz));
|
| 378 |
|
|
|
| 379 |
|
|
|
| 380 |
|
|
/*
|
| 381 |
|
|
* This structure is used to store information about certain
|
| 382 |
|
|
* options, such as where the option value came from (/etc/ppp/options,
|
| 383 |
|
|
* command line, etc.) and whether it came from a privileged source.
|
| 384 |
|
|
*/
|
| 385 |
|
|
|
| 386 |
|
|
struct option_info {
|
| 387 |
|
|
int priv; /* was value set by sysadmin? */
|
| 388 |
|
|
char *source; /* where option came from */
|
| 389 |
|
|
};
|
| 390 |
|
|
|
| 391 |
|
|
extern struct option_info auth_req_info;
|
| 392 |
|
|
extern struct option_info connector_info;
|
| 393 |
|
|
extern struct option_info disconnector_info;
|
| 394 |
|
|
extern struct option_info welcomer_info;
|
| 395 |
|
|
extern struct option_info devnam_info;
|
| 396 |
|
|
|
| 397 |
|
|
/*
|
| 398 |
|
|
* Inline versions of get/put char/short/long.
|
| 399 |
|
|
* Pointer is advanced; we assume that both arguments
|
| 400 |
|
|
* are lvalues and will already be in registers.
|
| 401 |
|
|
* cp MUST be u_char *.
|
| 402 |
|
|
*/
|
| 403 |
|
|
#define GETCHAR(c, cp) { \
|
| 404 |
|
|
(c) = *(cp)++; \
|
| 405 |
|
|
}
|
| 406 |
|
|
#define PUTCHAR(c, cp) { \
|
| 407 |
|
|
*(cp)++ = (u_char) (c); \
|
| 408 |
|
|
}
|
| 409 |
|
|
|
| 410 |
|
|
|
| 411 |
|
|
#define GETSHORT(s, cp) { \
|
| 412 |
|
|
(s) = *(cp)++ << 8; \
|
| 413 |
|
|
(s) |= *(cp)++; \
|
| 414 |
|
|
}
|
| 415 |
|
|
#define PUTSHORT(s, cp) { \
|
| 416 |
|
|
*(cp)++ = (u_char) ((s) >> 8); \
|
| 417 |
|
|
*(cp)++ = (u_char) (s); \
|
| 418 |
|
|
}
|
| 419 |
|
|
|
| 420 |
|
|
#define GETLONG(l, cp) { \
|
| 421 |
|
|
(l) = *(cp)++ << 8; \
|
| 422 |
|
|
(l) |= *(cp)++; (l) <<= 8; \
|
| 423 |
|
|
(l) |= *(cp)++; (l) <<= 8; \
|
| 424 |
|
|
(l) |= *(cp)++; \
|
| 425 |
|
|
}
|
| 426 |
|
|
#define PUTLONG(l, cp) { \
|
| 427 |
|
|
*(cp)++ = (u_char) ((l) >> 24); \
|
| 428 |
|
|
*(cp)++ = (u_char) ((l) >> 16); \
|
| 429 |
|
|
*(cp)++ = (u_char) ((l) >> 8); \
|
| 430 |
|
|
*(cp)++ = (u_char) (l); \
|
| 431 |
|
|
}
|
| 432 |
|
|
|
| 433 |
|
|
#define INCPTR(n, cp) ((cp) += (n))
|
| 434 |
|
|
#define DECPTR(n, cp) ((cp) -= (n))
|
| 435 |
|
|
|
| 436 |
|
|
#undef FALSE
|
| 437 |
|
|
#define FALSE 0
|
| 438 |
|
|
#undef TRUE
|
| 439 |
|
|
#define TRUE 1
|
| 440 |
|
|
|
| 441 |
|
|
/*
|
| 442 |
|
|
* System dependent definitions for user-level 4.3BSD UNIX implementation.
|
| 443 |
|
|
*/
|
| 444 |
|
|
|
| 445 |
|
|
#define DEMUXPROTREJ(u, p) demuxprotrej(u, p)
|
| 446 |
|
|
|
| 447 |
|
|
#define TIMEOUT(r, f, t) cyg_ppp_timeout((r), (f), (t))
|
| 448 |
|
|
#define UNTIMEOUT(r, f) cyg_ppp_untimeout((r), (f))
|
| 449 |
|
|
|
| 450 |
|
|
#define BCOPY(s, d, l) memcpy(d, s, l)
|
| 451 |
|
|
#define BZERO(s, n) memset(s, 0, n)
|
| 452 |
|
|
#define EXIT(u) quit()
|
| 453 |
|
|
|
| 454 |
|
|
#define PRINTMSG(m, l) { m[l] = '\0'; syslog(LOG_INFO, "Remote message: %s", m); }
|
| 455 |
|
|
|
| 456 |
|
|
/*
|
| 457 |
|
|
* MAKEHEADER - Add Header fields to a packet.
|
| 458 |
|
|
*/
|
| 459 |
|
|
#define MAKEHEADER(p, t) { \
|
| 460 |
|
|
PUTCHAR(PPP_ALLSTATIONS, p); \
|
| 461 |
|
|
PUTCHAR(PPP_UI, p); \
|
| 462 |
|
|
PUTSHORT(t, p); }
|
| 463 |
|
|
|
| 464 |
|
|
//#define DEBUGALL
|
| 465 |
|
|
|
| 466 |
|
|
#ifdef DEBUGALL
|
| 467 |
|
|
#define DEBUGMAIN 1
|
| 468 |
|
|
#define DEBUGFSM 1
|
| 469 |
|
|
#define DEBUGLCP 1
|
| 470 |
|
|
#define DEBUGIPCP 1
|
| 471 |
|
|
#define DEBUGUPAP 1
|
| 472 |
|
|
#define DEBUGCHAP 1
|
| 473 |
|
|
#endif
|
| 474 |
|
|
|
| 475 |
|
|
#ifndef LOG_PPP /* we use LOG_LOCAL2 for syslog by default */
|
| 476 |
|
|
#if defined(DEBUGMAIN) || defined(DEBUGFSM) || defined(DEBUGSYS) \
|
| 477 |
|
|
|| defined(DEBUGLCP) || defined(DEBUGIPCP) || defined(DEBUGUPAP) \
|
| 478 |
|
|
|| defined(DEBUGCHAP) || defined(DEBUG)
|
| 479 |
|
|
#define LOG_PPP LOG_LOCAL2
|
| 480 |
|
|
#else
|
| 481 |
|
|
#define LOG_PPP LOG_DAEMON
|
| 482 |
|
|
#endif
|
| 483 |
|
|
#endif /* LOG_PPP */
|
| 484 |
|
|
|
| 485 |
|
|
#ifdef DEBUGMAIN
|
| 486 |
|
|
#define MAINDEBUG(x) if (debug) syslog x
|
| 487 |
|
|
#else
|
| 488 |
|
|
#define MAINDEBUG(x)
|
| 489 |
|
|
#endif
|
| 490 |
|
|
|
| 491 |
|
|
#ifdef DEBUGSYS
|
| 492 |
|
|
#define SYSDEBUG(x) if (debug) syslog x
|
| 493 |
|
|
#else
|
| 494 |
|
|
#define SYSDEBUG(x)
|
| 495 |
|
|
#endif
|
| 496 |
|
|
|
| 497 |
|
|
#ifdef DEBUGFSM
|
| 498 |
|
|
#define FSMDEBUG(x) if (debug) syslog x
|
| 499 |
|
|
#else
|
| 500 |
|
|
#define FSMDEBUG(x)
|
| 501 |
|
|
#endif
|
| 502 |
|
|
|
| 503 |
|
|
#ifdef DEBUGLCP
|
| 504 |
|
|
#define LCPDEBUG(x) if (debug) syslog x
|
| 505 |
|
|
#else
|
| 506 |
|
|
#define LCPDEBUG(x)
|
| 507 |
|
|
#endif
|
| 508 |
|
|
|
| 509 |
|
|
#ifdef DEBUGIPCP
|
| 510 |
|
|
#define IPCPDEBUG(x) if (debug) syslog x
|
| 511 |
|
|
#else
|
| 512 |
|
|
#define IPCPDEBUG(x)
|
| 513 |
|
|
#endif
|
| 514 |
|
|
|
| 515 |
|
|
#ifdef DEBUGUPAP
|
| 516 |
|
|
#define UPAPDEBUG(x) if (debug) syslog x
|
| 517 |
|
|
#else
|
| 518 |
|
|
#define UPAPDEBUG(x)
|
| 519 |
|
|
#endif
|
| 520 |
|
|
|
| 521 |
|
|
#ifdef DEBUGCHAP
|
| 522 |
|
|
#define CHAPDEBUG(x) if (debug) syslog x
|
| 523 |
|
|
#else
|
| 524 |
|
|
#define CHAPDEBUG(x)
|
| 525 |
|
|
#endif
|
| 526 |
|
|
|
| 527 |
|
|
#ifdef DEBUGIPXCP
|
| 528 |
|
|
#define IPXCPDEBUG(x) if (debug) syslog x
|
| 529 |
|
|
#else
|
| 530 |
|
|
#define IPXCPDEBUG(x)
|
| 531 |
|
|
#endif
|
| 532 |
|
|
|
| 533 |
|
|
#ifndef SIGTYPE
|
| 534 |
|
|
#if defined(sun) || defined(SYSV) || defined(POSIX_SOURCE)
|
| 535 |
|
|
#define SIGTYPE void
|
| 536 |
|
|
#else
|
| 537 |
|
|
#define SIGTYPE int
|
| 538 |
|
|
#endif /* defined(sun) || defined(SYSV) || defined(POSIX_SOURCE) */
|
| 539 |
|
|
#endif /* SIGTYPE */
|
| 540 |
|
|
|
| 541 |
|
|
#ifndef MIN
|
| 542 |
|
|
#define MIN(a, b) ((a) < (b)? (a): (b))
|
| 543 |
|
|
#endif
|
| 544 |
|
|
#ifndef MAX
|
| 545 |
|
|
#define MAX(a, b) ((a) > (b)? (a): (b))
|
| 546 |
|
|
#endif
|
| 547 |
|
|
|
| 548 |
|
|
#endif /* __PPP_H__ */
|