OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [libnetworking/] [pppd/] [options.c] - Blame information for rev 389

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
2
 * options.c - handles option processing for PPP.
3
 *
4
 * Copyright (c) 1989 Carnegie Mellon University.
5
 * All rights reserved.
6
 *
7
 * Redistribution and use in source and binary forms are permitted
8
 * provided that the above copyright notice and this paragraph are
9
 * duplicated in all such forms and that any documentation,
10
 * advertising materials, and other materials related to such
11
 * distribution and use acknowledge that the software was developed
12
 * by Carnegie Mellon University.  The name of the
13
 * University may not be used to endorse or promote products derived
14
 * from this software without specific prior written permission.
15
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
16
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
17
 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18
 */
19
 
20
#ifndef lint
21
/* static char rcsid[] = "$Id: options.c,v 1.2 2001-09-27 12:01:57 chris Exp $"; */
22
#endif
23
 
24
#include <ctype.h>
25
#include <stdio.h>
26
#include <errno.h>
27
#include <unistd.h>
28
#include <limits.h>
29
/* #include <stdlib.h> */
30
#include <termios.h>
31
#include <syslog.h>
32
#include <string.h>
33
#include <netdb.h>
34
#include <pwd.h>
35
#include <sys/types.h>
36
#include <sys/stat.h>
37
#include <netinet/in.h>
38
#include <arpa/inet.h>
39
#ifdef PPP_FILTER
40
#include <pcap.h>
41
#include <pcap-int.h>   /* XXX: To get struct pcap */
42
#endif
43
 
44
#include "pppd.h"
45
#include "pathnames.h"
46
#include "patchlevel.h"
47
#include "fsm.h"
48
#include "lcp.h"
49
#include "ipcp.h"
50
#include "upap.h"
51
#include "chap.h"
52
#include "ccp.h"
53
#ifdef CBCP_SUPPORT
54
#include "cbcp.h"
55
#endif
56
 
57
#ifdef IPX_CHANGE
58
#include "ipxcp.h"
59
#endif /* IPX_CHANGE */
60
 
61
#include <net/ppp-comp.h>
62
 
63
#define FALSE   0
64
#define TRUE    1
65
 
66
 
67
#ifndef GIDSET_TYPE
68
#define GIDSET_TYPE     gid_t
69
#endif
70
#if 0
71
static int privileged_option;   /* set iff the current option came from root */
72
static char *option_source;     /* string saying where the option came from */
73
#endif
74
 
75
/*
76
 * Option variables and default values.
77
 */
78
#ifdef PPP_FILTER
79
int     dflag = 0;               /* Tell libpcap we want debugging */
80
#endif
81
int     debug = 1;              /* Debug flag */
82
int     kdebugflag = 1;         /* Tell kernel to print debug messages */
83
int     default_device = 1;     /* Using /dev/tty or equivalent */
84
char    devnam[MAXPATHLEN] = "/dev/sccppp";     /* Device name */
85
int     crtscts = 0;             /* Use hardware flow control */
86
int     modem = 0;               /* Use modem control lines */
87
int     inspeed = B115200;              /* Input/Output speed requested */
88
u_int32_t netmask = 0;           /* IP netmask to set on interface */
89
int     lockflag = 0;            /* Create lock file to lock the serial dev */
90
int     nodetach = 0;            /* Don't detach from controlling tty */
91
char *connector[]={"TIMEOUT","3","ABORT","\nBUSY\r","ABORT","\nNO DIALTONE\r","ABORT","\nNO CARRIER\r","ABORT","\nNO ANSWER\r","ABORT","\nRINGING\r\n\r\nRINGING\r",
92
                                                                                                "","\rAT","OK-+++\\c-OK","ATH0","TIMEOUT","30","OK","ATDT13","CONNECT",""};
93
/*char *connector[]={"TIMEOUT","3","ABORT","\nBUSY\r","ABORT","\nNO DIALTONE\r","ABORT","\nNO CARRIER\r","ABORT","\nNO ANSWER\r","ABORT","\nRINGING\r\n\r\nRINGING\r",
94
                                                                                                "","\rAT","OK-+++\\c-OK","ATH0","TIMEOUT","30","OK","ATDT0202122","CONNECT","","ppp","","Username:","ppp","Password:","ppp"};
95
*/
96
char    **disconnector; /* Script to disestablish physical link */
97
char    **welcomer;     /* Script to run after phys link estab. */
98
int     maxconnect = 0;          /* Maximum connect time */
99
char    user[MAXNAMELEN]="stb"; /* Username for PAP */
100
char    passwd[MAXSECRETLEN]="stb";     /* Password for PAP */
101
int     auth_required = 0;       /* Peer is required to authenticate */
102
int     defaultroute = 1;       /* assign default route through interface */
103
int     proxyarp = 0;            /* Set up proxy ARP entry for peer */
104
int     persist = 1;            /* Reopen link after it goes down */
105
int     uselogin = 0;            /* Use /etc/passwd for checking PAP */
106
int     lcp_echo_interval = 0;   /* Interval between LCP echo-requests */
107
int     lcp_echo_fails = 0;      /* Tolerance to unanswered echo-requests */
108
char    our_name[MAXNAMELEN]="infotel"; /* Our name for authentication purposes */
109
char    remote_name[MAXNAMELEN]; /* Peer's name for authentication */
110
int     explicit_remote = 0;     /* User specified explicit remote name */
111
int     usehostname = 0; /* Use hostname for our_name */
112
int     disable_defaultip = 1;  /* Don't use hostname for default IP adrs */
113
int     demand = 0;              /* do dial-on-demand */
114
char    *ipparam = NULL;        /* Extra parameter for ip up/down scripts */
115
int     cryptpap;               /* Passwords in pap-secrets are encrypted */
116
int     idle_time_limit = 0;     /* Disconnect if idle for this many seconds */
117
int     holdoff = 30;           /* # seconds to pause before reconnecting */
118
int     refuse_pap = 0;          /* Set to say we won't do PAP */
119
int     refuse_chap = 1;        /* Set to say we won't do CHAP */
120
 
121
#ifdef MSLANMAN
122
int     ms_lanman = 0;           /* Nonzero if use LanMan password instead of NT */
123
                                /* Has meaning only with MS-CHAP challenges */
124
#endif
125
 
126
struct option_info auth_req_info;
127
struct option_info connector_info;
128
struct option_info disconnector_info;
129
struct option_info welcomer_info;
130
struct option_info devnam_info;
131
#ifdef PPP_FILTER
132
struct  bpf_program pass_filter;/* Filter program for packets to pass */
133
struct  bpf_program active_filter; /* Filter program for link-active pkts */
134
pcap_t  pc;                     /* Fake struct pcap so we can compile expr */
135
#endif
136
 
137
/*
138
 * Prototypes
139
 */
140
#if 0
141
static int setdevname __P((char *, int));
142
static int setipaddr __P((char *));
143
static int setspeed __P((char *));
144
static int setdebug __P((char **));
145
static int setkdebug __P((char **));
146
static int setpassive __P((char **));
147
static int setsilent __P((char **));
148
static int noopt __P((char **));
149
static int setnovj __P((char **));
150
static int setnovjccomp __P((char **));
151
static int setvjslots __P((char **));
152
static int reqpap __P((char **));
153
static int nopap __P((char **));
154
#ifdef OLD_OPTIONS
155
static int setupapfile __P((char **));
156
#endif
157
static int nochap __P((char **));
158
static int reqchap __P((char **));
159
static int noaccomp __P((char **));
160
static int noasyncmap __P((char **));
161
static int noip __P((char **));
162
static int nomagicnumber __P((char **));
163
static int setasyncmap __P((char **));
164
static int setescape __P((char **));
165
static int setmru __P((char **));
166
static int setmtu __P((char **));
167
#ifdef CBCP_SUPPORT
168
static int setcbcp __P((char **));
169
#endif
170
static int nomru __P((char **));
171
static int nopcomp __P((char **));
172
static int setconnector __P((char **));
173
static int setdisconnector __P((char **));
174
static int setwelcomer __P((char **));
175
static int setmaxconnect __P((char **));
176
static int setdomain __P((char **));
177
static int setnetmask __P((char **));
178
static int setcrtscts __P((char **));
179
static int setnocrtscts __P((char **));
180
static int setxonxoff __P((char **));
181
static int setnodetach __P((char **));
182
static int setupdetach __P((char **));
183
static int setmodem __P((char **));
184
static int setlocal __P((char **));
185
static int setlock __P((char **));
186
static int setname __P((char **));
187
static int setuser __P((char **));
188
static int setremote __P((char **));
189
static int setauth __P((char **));
190
static int setnoauth __P((char **));
191
static int readfile __P((char **));
192
static int callfile __P((char **));
193
static int setdefaultroute __P((char **));
194
static int setnodefaultroute __P((char **));
195
static int setproxyarp __P((char **));
196
static int setnoproxyarp __P((char **));
197
static int setpersist __P((char **));
198
static int setnopersist __P((char **));
199
static int setdologin __P((char **));
200
static int setusehostname __P((char **));
201
static int setnoipdflt __P((char **));
202
static int setlcptimeout __P((char **));
203
static int setlcpterm __P((char **));
204
static int setlcpconf __P((char **));
205
static int setlcpfails __P((char **));
206
static int setipcptimeout __P((char **));
207
static int setipcpterm __P((char **));
208
static int setipcpconf __P((char **));
209
static int setipcpfails __P((char **));
210
static int setpaptimeout __P((char **));
211
static int setpapreqs __P((char **));
212
static int setpapreqtime __P((char **));
213
static int setchaptimeout __P((char **));
214
static int setchapchal __P((char **));
215
static int setchapintv __P((char **));
216
static int setipcpaccl __P((char **));
217
static int setipcpaccr __P((char **));
218
static int setlcpechointv __P((char **));
219
static int setlcpechofails __P((char **));
220
static int noccp __P((char **));
221
static int setbsdcomp __P((char **));
222
static int setnobsdcomp __P((char **));
223
static int setdeflate __P((char **));
224
static int setnodeflate __P((char **));
225
static int setnodeflatedraft __P((char **));
226
static int setdemand __P((char **));
227
static int setpred1comp __P((char **));
228
static int setnopred1comp __P((char **));
229
static int setipparam __P((char **));
230
static int setpapcrypt __P((char **));
231
static int setidle __P((char **));
232
static int setholdoff __P((char **));
233
static int setdnsaddr __P((char **));
234
static int resetipxproto __P((char **));
235
static int setwinsaddr __P((char **));
236
static int showversion __P((char **));
237
static int showhelp __P((char **));
238
 
239
#ifdef PPP_FILTER
240
static int setpdebug __P((char **));
241
static int setpassfilter __P((char **));
242
static int setactivefilter __P((char **));
243
#endif
244
 
245
#ifdef IPX_CHANGE
246
static int setipxproto __P((char **));
247
static int setipxanet __P((char **));
248
static int setipxalcl __P((char **));
249
static int setipxarmt __P((char **));
250
static int setipxnetwork __P((char **));
251
static int setipxnode __P((char **));
252
static int setipxrouter __P((char **));
253
static int setipxname __P((char **));
254
static int setipxcptimeout __P((char **));
255
static int setipxcpterm __P((char **));
256
static int setipxcpconf __P((char **));
257
static int setipxcpfails __P((char **));
258
#endif /* IPX_CHANGE */
259
 
260
#ifdef MSLANMAN
261
static int setmslanman __P((char **));
262
#endif
263
 
264
static int number_option __P((char *, u_int32_t *, int));
265
static int int_option __P((char *, int *));
266
static int readable __P((int fd));
267
#endif
268
 
269
/*
270
 * Valid arguments.
271
 */
272
 
273
/*
274
 * parse_args - parse a string of arguments from the command line.
275
 */
276
int
277
parse_args(argc, argv)
278
    int argc;
279
    char **argv;
280
{
281
 
282
 
283
return 0;
284
}
285
 
286
/*
287
 * scan_args - scan the command line arguments to get the tty name,
288
 * if specified.
289
 */
290
 
291
/*
292
 * usage - print out a message telling how to use the program.
293
 */
294
void
295
usage()
296
{
297
 }
298
 
299
/*
300
 * showhelp - print out usage message and exit.
301
 */
302
static int
303
showhelp(argv)
304
    char **argv;
305
{
306
    return 0;
307
}
308
 
309
/*
310
 * showversion - print out the version number and exit.
311
 */
312
static int
313
showversion(argv)
314
    char **argv;
315
{
316
    return 0;
317
}
318
 
319
void
320
option_error __V((char *fmt, ...))
321
{
322
}
323
/*
324
 * readable - check if a file is readable by the real user.
325
 */
326
/*static int
327
readable(fd)
328
    int fd;
329
{
330
    uid_t uid;
331
    int ngroups, i;
332
    struct stat sbuf;
333
    GIDSET_TYPE groups[NGROUPS_MAX];
334
 
335
    uid = getuid();
336
    if (uid == 0)
337
        return 1;
338
    if (fstat(fd, &sbuf) != 0)
339
        return 0;
340
    if (sbuf.st_uid == uid)
341
        return sbuf.st_mode & S_IRUSR;
342
    if (sbuf.st_gid == getgid())
343
        return sbuf.st_mode & S_IRGRP;
344
    ngroups = getgroups(NGROUPS_MAX, groups);
345
    for (i = 0; i < ngroups; ++i)
346
        if (sbuf.st_gid == groups[i])
347
            return sbuf.st_mode & S_IRGRP;
348
    return sbuf.st_mode & S_IROTH;
349
}
350
*/
351
/*
352
 * Read a word from a file.
353
 * Words are delimited by white-space or by quotes (" or ').
354
 * Quotes, white-space and \ may be escaped with \.
355
 * \<newline> is ignored.
356
 */
357
 
358
 /*
359
 * The following procedures parse options.
360
 */
361
 
362
/*
363
 * readfile - take commands from a file.
364
 */
365
 
366
/*
367
 * callfile - take commands from /etc/ppp/peers/<name>.
368
 * Name may not contain /../, start with / or ../, or end in /..
369
 */
370
 /*
371
 * setdebug - Set debug (command line argument).
372
 */
373
 
374
 
375
/*
376
 * noopt - Disable all options.
377
 */
378
static int
379
noopt(argv)
380
    char **argv;
381
{
382
    BZERO((char *) &lcp_wantoptions[0], sizeof (struct lcp_options));
383
    BZERO((char *) &lcp_allowoptions[0], sizeof (struct lcp_options));
384
    BZERO((char *) &ipcp_wantoptions[0], sizeof (struct ipcp_options));
385
    BZERO((char *) &ipcp_allowoptions[0], sizeof (struct ipcp_options));
386
 
387
#ifdef IPX_CHANGE
388
    BZERO((char *) &ipxcp_wantoptions[0], sizeof (struct ipxcp_options));
389
    BZERO((char *) &ipxcp_allowoptions[0], sizeof (struct ipxcp_options));
390
#endif /* IPX_CHANGE */
391
 
392
    return (1);
393
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.