Merge local changes, add build glue.

This commit is contained in:
christos 2013-11-28 22:33:42 +00:00
parent 95d1a8853c
commit 84b263706c
70 changed files with 4714 additions and 487 deletions

5
external/bsd/ppp/Makefile vendored Normal file
View File

@ -0,0 +1,5 @@
# $NetBSD: Makefile,v 1.1 2013/11/28 22:33:42 christos Exp $
SUBDIR= usr.sbin
.include <bsd.subdir.mk>

View File

@ -1,4 +1,4 @@
.\" -*- nroff -*-
.\" $NetBSD: chat.8,v 1.2 2013/11/28 22:33:42 christos Exp $
.\" manual page [] for chat 1.8
.\" Id: chat.8,v 1.11 2004/11/13 12:22:49 paulus Exp
.\" SH section heading
@ -18,35 +18,47 @@ chat \- Automated conversational script with a modem
.SH DESCRIPTION
.LP
The \fIchat\fR program defines a conversational exchange between the
computer and the modem. Its primary purpose is to establish the
computer and the modem.
Its primary purpose is to establish the
connection between the Point-to-Point Protocol Daemon (\fIpppd\fR) and
the remote's \fIpppd\fR process.
.SH OPTIONS
.TP
.B \-f \fI<chat file>
Read the chat script from the chat \fIfile\fR. The use of this option
is mutually exclusive with the chat script parameters. The user must
have read access to the file. Multiple lines are permitted in the
file. Space or horizontal tab characters should be used to separate
.B \-f \fI\*[Lt]chat file\*[Gt]
Read the chat script from the chat \fIfile\fR.
The use of this option
is mutually exclusive with the chat script parameters.
The user must
have read access to the file.
Multiple lines are permitted in the
file.
Space or horizontal tab characters should be used to separate
the strings.
.TP
.B \-t \fI<timeout>
Set the timeout for the expected string to be received. If the string
.B \-t \fI\*[Lt]timeout\*[Gt]
Set the timeout for the expected string to be received.
If the string
is not received within the time limit then the reply string is not
sent. An alternate reply may be sent or the script will fail if there
is no alternate reply string. A failed script will cause the
sent.
An alternate reply may be sent or the script will fail if there
is no alternate reply string.
A failed script will cause the
\fIchat\fR program to terminate with a non-zero error code.
.TP
.B \-r \fI<report file>
Set the file for output of the report strings. If you use the keyword
\fIREPORT\fR, the resulting strings are written to this file. If this
.B \-r \fI\*[Lt]report file\*[Gt]
Set the file for output of the report strings.
If you use the keyword
\fIREPORT\fR, the resulting strings are written to this file.
If this
option is not used and you still use \fIREPORT\fR keywords, the
\fIstderr\fR file is used for the report strings.
.TP
.B \-e
Start with the echo option turned on. Echoing may also be turned on
Start with the echo option turned on.
Echoing may also be turned on
or off at specific points in the chat script by using the \fIECHO\fR
keyword. When echoing is enabled, all output from the modem is echoed
keyword.
When echoing is enabled, all output from the modem is echoed
to \fIstderr\fR.
.TP
.B \-E
@ -54,33 +66,40 @@ Enables environment variable substitution within chat scripts using the
standard \fI$xxx\fR syntax.
.TP
.B \-v
Request that the \fIchat\fR script be executed in a verbose mode. The
Request that the \fIchat\fR script be executed in a verbose mode.
The
\fIchat\fR program will then log the execution state of the chat
script as well as all text received from the modem and the output
strings sent to the modem. The default is to log through the SYSLOG;
strings sent to the modem.
The default is to log through the SYSLOG;
the logging method may be altered with the \-S and \-s flags.
.TP
.B \-V
Request that the \fIchat\fR script be executed in a stderr verbose
mode. The \fIchat\fR program will then log all text received from the
modem and the output strings sent to the modem to the stderr device. This
mode.
The \fIchat\fR program will then log all text received from the
modem and the output strings sent to the modem to the stderr device.
This
device is usually the local console at the station running the chat or
pppd program.
.TP
.B \-s
Use stderr. All log messages from '\-v' and all error messages will be
Use stderr.
All log messages from '\-v' and all error messages will be
sent to stderr.
.TP
.B \-S
Do not use the SYSLOG. By default, error messages are sent to the
SYSLOG. The use of \-S will prevent both log messages from '\-v' and
Do not use the SYSLOG.
By default, error messages are sent to the
SYSLOG.
The use of \-S will prevent both log messages from '\-v' and
error messages from being sent to the SYSLOG.
.TP
.B \-T \fI<phone number>
.B \-T \fI\*[Lt]phone number\*[Gt]
Pass in an arbitrary string, usually a phone number, that will be
substituted for the \eT substitution metacharacter in a send string.
.TP
.B \-U \fI<phone number 2>
.B \-U \fI\*[Lt]phone number 2\*[Gt]
Pass in a second string, usually a phone number, that will be
substituted for the \eU substitution metacharacter in a send string.
This is useful when dialing an ISDN terminal adapter that requires two
@ -100,29 +119,37 @@ separated by a dash as in the following example:
ogin:\-BREAK\-ogin: ppp ssword: hello2u2
.LP
This line indicates that the \fIchat\fR program should expect the string
"ogin:". If it fails to receive a login prompt within the time interval
"ogin:".
If it fails to receive a login prompt within the time interval
allotted, it is to send a break sequence to the remote and then expect the
string "ogin:". If the first "ogin:" is received then the break sequence is
string "ogin:".
If the first "ogin:" is received then the break sequence is
not generated.
.LP
Once it received the login prompt the \fIchat\fR program will send the
string ppp and then expect the prompt "ssword:". When it receives the
string ppp and then expect the prompt "ssword:".
When it receives the
prompt for the password, it will send the password hello2u2.
.LP
A carriage return is normally sent following the reply string. It is not
A carriage return is normally sent following the reply string.
It is not
expected in the "expect" string unless it is specifically requested by using
the \er character sequence.
.LP
The expect sequence should contain only what is needed to identify the
string. Since it is normally stored on a disk file, it should not contain
variable information. It is generally not acceptable to look for time
string.
Since it is normally stored on a disk file, it should not contain
variable information.
It is generally not acceptable to look for time
strings, network identification strings, or other variable pieces of data as
an expect string.
.LP
To help correct for characters which may be corrupted during the initial
sequence, look for the string "ogin:" rather than "login:". It is possible
sequence, look for the string "ogin:" rather than "login:".
It is possible
that the leading "l" character may be received in error and you may never
find the string even though it was sent by the system. For this reason,
find the string even though it was sent by the system.
For this reason,
scripts look for "ogin:" rather than "login:" and "ssword:" rather than
"password:".
.LP
@ -132,21 +159,27 @@ ogin: ppp ssword: hello2u2
.LP
In other words, expect ....ogin:, send ppp, expect ...ssword:, send hello2u2.
.LP
In actual practice, simple scripts are rare. At the vary least, you
In actual practice, simple scripts are rare.
At the vary least, you
should include sub-expect sequences should the original string not be
received. For example, consider the following script:
received.
For example, consider the following script:
.IP
ogin:\-\-ogin: ppp ssword: hello2u2
.LP
This would be a better script than the simple one used earlier. This would look
This would be a better script than the simple one used earlier.
This would look
for the same login: prompt, however, if one was not received, a single
return sequence is sent and then it will look for login: again. Should line
return sequence is sent and then it will look for login: again.
Should line
noise obscure the first login prompt then sending the empty line will
usually generate a login prompt again.
.SH COMMENTS
Comments can be embedded in the chat script. A comment is a line which
starts with the \fB#\fR (hash) character in column 1. Such comment
lines are just ignored by the chat program. If a '#' character is to
Comments can be embedded in the chat script.
A comment is a line which
starts with the \fB#\fR (hash) character in column 1.
Such comment lines are just ignored by the chat program.
If a '#' character is to
be expected as the first character of the expect sequence, you should
quote the expect string.
If you want to wait for a prompt that starts with a # (hash)
@ -160,36 +193,47 @@ character, you would have to write something like this:
.SH SENDING DATA FROM A FILE
If the string to send starts with an at sign (@), the rest of the
string is taken to be the name of a file to read to get the string to
send. If the last character of the data read is a newline, it is
removed. The file can be a named pipe (or fifo) instead of a regular
file. This provides a way for \fBchat\fR to communicate with another
send.
If the last character of the data read is a newline, it is removed.
The file can be a named pipe (or fifo) instead of a regular file.
This provides a way for \fBchat\fR to communicate with another
program, for example, a program to prompt the user and receive a
password typed in.
.LP
.SH ABORT STRINGS
Many modems will report the status of the call as a string. These
strings may be \fBCONNECTED\fR or \fBNO CARRIER\fR or \fBBUSY\fR. It
is often desirable to terminate the script should the modem fail to
connect to the remote. The difficulty is that a script would not know
exactly which modem string it may receive. On one attempt, it may
Many modems will report the status of the call as a string.
These
strings may be \fBCONNECTED\fR or \fBNO CARRIER\fR or \fBBUSY\fR.
It is often desirable to terminate the script should the modem fail to
connect to the remote.
The difficulty is that a script would not know
exactly which modem string it may receive.
On one attempt, it may
receive \fBBUSY\fR while the next time it may receive \fBNO CARRIER\fR.
.LP
These "abort" strings may be specified in the script using the \fIABORT\fR
sequence. It is written in the script as in the following example:
sequence.
It is written in the script as in the following example:
.IP
ABORT BUSY ABORT 'NO CARRIER' '' ATZ OK ATDT5551212 CONNECT
.LP
This sequence will expect nothing; and then send the string ATZ. The
expected response to this is the string \fIOK\fR. When it receives \fIOK\fR,
the string ATDT5551212 to dial the telephone. The expected string is
\fICONNECT\fR. If the string \fICONNECT\fR is received the remainder of the
script is executed. However, should the modem find a busy telephone, it will
send the string \fIBUSY\fR. This will cause the string to match the abort
character sequence. The script will then fail because it found a match to
the abort string. If it received the string \fINO CARRIER\fR, it will abort
for the same reason. Either string may be received. Either string will
terminate the \fIchat\fR script.
This sequence will expect nothing; and then send the string ATZ.
The expected response to this is the string \fIOK\fR.
When it receives \fIOK\fR,
the string ATDT5551212 to dial the telephone.
The expected string is
\fICONNECT\fR.
If the string \fICONNECT\fR is received the remainder of the
script is executed.
However, should the modem find a busy telephone, it will
send the string \fIBUSY\fR.
This will cause the string to match the abort character sequence.
The script will then fail because it found a match to the abort string.
If it received the string \fINO CARRIER\fR, it will abort
for the same reason.
Either string may be received.
Either string will terminate the \fIchat\fR script.
.SH CLR_ABORT STRINGS
This sequence allows for clearing previously set \fBABORT\fR strings.
\fBABORT\fR strings are kept in an array of a pre-determined size (at
@ -197,18 +241,21 @@ compilation time); \fBCLR_ABORT\fR will reclaim the space for cleared
entries so that new strings can use that space.
.SH SAY STRINGS
The \fBSAY\fR directive allows the script to send strings to the user
at the terminal via standard error. If \fBchat\fR is being run by
at the terminal via standard error.
If \fBchat\fR is being run by
pppd, and pppd is running as a daemon (detached from its controlling
terminal), standard error will normally be redirected to the file
/etc/ppp/connect\-errors.
.LP
\fBSAY\fR strings must be enclosed in single or double quotes. If
\fBSAY\fR strings must be enclosed in single or double quotes.
If
carriage return and line feed are needed in the string to be output,
you must explicitly add them to your string.
.LP
The SAY strings could be used to give progress messages in sections of
the script where you want to have 'ECHO OFF' but still let the user
know what is happening. An example is:
know what is happening.
An example is:
.IP
ABORT BUSY
.br
@ -220,7 +267,8 @@ SAY "Dialling your ISP...\en"
.br
TIMEOUT 120
.br
SAY "Waiting up to 2 minutes for connection ... "
SAY "Waiting up to 2 minutes for connection ...
"
.br
CONNECT ''
.br
@ -236,39 +284,47 @@ SAY "Logged in OK ...\en"
\fIetc ...\fR
.LP
This sequence will only present the SAY strings to the user and all
the details of the script will remain hidden. For example, if the
the details of the script will remain hidden.
For example, if the
above script works, the user will see:
.IP
Dialling your ISP...
.br
Waiting up to 2 minutes for connection ... Connected, now logging in ...
Waiting up to 2 minutes for connection ...
Connected, now logging in ...
.br
Logged in OK ...
.LP
.SH REPORT STRINGS
A \fBreport\fR string is similar to the ABORT string. The difference
A \fBreport\fR string is similar to the ABORT string.
The difference
is that the strings, and all characters to the next control character
such as a carriage return, are written to the report file.
.LP
The report strings may be used to isolate the transmission rate of the
modem's connect string and return the value to the chat user. The
analysis of the report string logic occurs in conjunction with the
other string processing such as looking for the expect string. The use
modem's connect string and return the value to the chat user.
The analysis of the report string logic occurs in conjunction with the
other string processing such as looking for the expect string.
The use
of the same string for a report and abort sequence is probably not
very useful, however, it is possible.
.LP
The report strings to no change the completion code of the program.
.LP
These "report" strings may be specified in the script using the \fIREPORT\fR
sequence. It is written in the script as in the following example:
sequence.
It is written in the script as in the following example:
.IP
REPORT CONNECT ABORT BUSY '' ATDT5551212 CONNECT '' ogin: account
.LP
This sequence will expect nothing; and then send the string
ATDT5551212 to dial the telephone. The expected string is
\fICONNECT\fR. If the string \fICONNECT\fR is received the remainder
of the script is executed. In addition the program will write to the
ATDT5551212 to dial the telephone.
The expected string is
\fICONNECT\fR.
If the string \fICONNECT\fR is received the remainder
of the script is executed.
In addition the program will write to the
expect\-file the string "CONNECT" plus any characters which follow it
such as the connection rate.
.SH CLR_REPORT STRINGS
@ -278,11 +334,15 @@ compilation time); \fBCLR_REPORT\fR will reclaim the space for cleared
entries so that new strings can use that space.
.SH ECHO
The echo options controls whether the output from the modem is echoed
to \fIstderr\fR. This option may be set with the \fI\-e\fR option, but
it can also be controlled by the \fIECHO\fR keyword. The "expect\-send"
to \fIstderr\fR.
This option may be set with the \fI\-e\fR option, but
it can also be controlled by the \fIECHO\fR keyword.
The "expect\-send"
pair \fIECHO\fR \fION\fR enables echoing, and \fIECHO\fR \fIOFF\fR
disables it. With this keyword you can select which parts of the
conversation should be visible. For instance, with the following
disables it.
With this keyword you can select which parts of the
conversation should be visible.
For instance, with the following
script:
.IP
ABORT 'BUSY'
@ -306,16 +366,20 @@ but starting with the \fICONNECT\fR (or \fIBUSY\fR) message, everything
will be echoed.
.SH HANGUP
The HANGUP options control whether a modem hangup should be considered
as an error or not. This option is useful in scripts for dialling
systems which will hang up and call your system back. The HANGUP
as an error or not.
This option is useful in scripts for dialling
systems which will hang up and call your system back.
The HANGUP
options can be \fBON\fR or \fBOFF\fR.
.br
When HANGUP is set OFF and the modem hangs up (e.g., after the first
stage of logging in to a callback system), \fBchat\fR will continue
running the script (e.g., waiting for the incoming call and second
stage login prompt). As soon as the incoming call is connected, you
stage login prompt).
As soon as the incoming call is connected, you
should use the \fBHANGUP ON\fR directive to reinstall normal hang up
signal behavior. Here is an (simple) example script:
signal behavior.
Here is an (simple) example script:
.IP
ABORT 'BUSY'
.br
@ -348,8 +412,8 @@ ogin:\-\-BREAK\-\-ogin: real_account
\fIetc ...\fR
.LP
.SH TIMEOUT
The initial timeout value is 45 seconds. This may be changed using the \fB\-t\fR
parameter.
The initial timeout value is 45 seconds.
This may be changed using the \fB\-t\fR parameter.
.LP
To change the timeout value for the next expect string, the following
example may be used:
@ -357,47 +421,60 @@ example may be used:
ATZ OK ATDT5551212 CONNECT TIMEOUT 10 ogin:\-\-ogin: TIMEOUT 5 assword: hello2u2
.LP
This will change the timeout to 10 seconds when it expects the login:
prompt. The timeout is then changed to 5 seconds when it looks for the
prompt.
The timeout is then changed to 5 seconds when it looks for the
password prompt.
.LP
The timeout, once changed, remains in effect until it is changed again.
.SH SENDING EOT
The special reply string of \fIEOT\fR indicates that the chat program
should send an EOT character to the remote. This is normally the
End-of-file character sequence. A return character is not sent
should send an EOT character to the remote.
This is normally the
End-of-file character sequence.
A return character is not sent
following the EOT.
The EOT sequence may be embedded into the send string using the
sequence \fI^D\fR.
.SH GENERATING BREAK
The special reply string of \fIBREAK\fR will cause a break condition
to be sent. The break is a special signal on the transmitter. The
to be sent.
The break is a special signal on the transmitter.
The
normal processing on the receiver is to change the transmission rate.
It may be used to cycle through the available transmission rates on
the remote until you are able to receive a valid login prompt.
The break sequence may be embedded into the send string using the
\fI\eK\fR sequence.
.SH ESCAPE SEQUENCES
The expect and reply strings may contain escape sequences. All of the
sequences are legal in the reply string. Many are legal in the expect.
The expect and reply strings may contain escape sequences.
All of the
sequences are legal in the reply string.
Many are legal in the expect.
Those which are not valid in the expect sequence are so indicated.
.TP
.B ''
Expects or sends a null string. If you send a null string then it will still
send the return character. This sequence may either be a pair of apostrophe
Expects or sends a null string.
If you send a null string then it will still
send the return character.
This sequence may either be a pair of apostrophe
or quote characters.
.TP
.B \eb
represents a backspace character.
.TP
.B \ec
Suppresses the newline at the end of the reply string. This is the only
method to send a string without a trailing return character. It must
be at the end of the send string. For example,
Suppresses the newline at the end of the reply string.
This is the only
method to send a string without a trailing return character.
It must
be at the end of the send string.
For example,
the sequence hello\ec will simply send the characters h, e, l, l, o.
.I (not valid in expect.)
.TP
.B \ed
Delay for one second. The program uses sleep(1) which will delay to a
Delay for one second.
The program uses sleep(1) which will delay to a
maximum of one second.
.I (not valid in expect.)
.TP
@ -409,15 +486,18 @@ Insert a BREAK
Send a newline or linefeed character.
.TP
.B \eN
Send a null character. The same sequence may be represented by \e0.
Send a null character.
The same sequence may be represented by \e0.
.I (not valid in expect.)
.TP
.B \ep
Pause for a fraction of a second. The delay is 1/10th of a second.
Pause for a fraction of a second.
The delay is 1/10th of a second.
.I (not valid in expect.)
.TP
.B \eq
Suppress writing the string to the SYSLOG file. The string ?????? is
Suppress writing the string to the SYSLOG file.
The string ?????? is
written to the log in its place.
.I (not valid in expect.)
.TP
@ -425,8 +505,10 @@ written to the log in its place.
Send or expect a carriage return.
.TP
.B \es
Represents a space character in the string. This may be used when it
is not desirable to quote the strings which contains spaces. The
Represents a space character in the string.
This may be used when it
is not desirable to quote the strings which contains spaces.
The
sequence 'HI TIM' and HI\esTIM are the same.
.TP
.B \et
@ -454,8 +536,10 @@ For example, the character DC1 (17) is shown as \^^Q.
.I (some characters are not valid in expect.)
.SH ENVIRONMENT VARIABLES
Environment variables are available within chat scripts, if the \fI\-E\fR
option was specified in the command line. The metacharacter \fI$\fR is used
to introduce the name of the environment variable to substitute. If the
option was specified in the command line.
The metacharacter \fI$\fR is used
to introduce the name of the environment variable to substitute.
If the
substitution fails, because the requested environment variable is not set,
\fInothing\fR is replaced for the variable.
.SH TERMINATION CODES
@ -463,22 +547,26 @@ The \fIchat\fR program will terminate with the following completion
codes.
.TP
.B 0
The normal termination of the program. This indicates that the script
The normal termination of the program.
This indicates that the script
was executed without error to the normal conclusion.
.TP
.B 1
One or more of the parameters are invalid or an expect string was too
large for the internal buffers. This indicates that the program as not
large for the internal buffers.
This indicates that the program as not
properly executed.
.TP
.B 2
An error occurred during the execution of the program. This may be due
An error occurred during the execution of the program.
This may be due
to a read or write operation failing for some reason or chat receiving
a signal such as SIGINT.
.TP
.B 3
A timeout event occurred when there was an \fIexpect\fR string without
having a "\-subsend" string. This may mean that you did not program the
having a "\-subsend" string.
This may mean that you did not program the
script correctly for the condition or that some unexpected event has
occurred and the expected string could not be found.
.TP
@ -499,16 +587,13 @@ The other termination codes are also strings marked as an \fIABORT\fR
condition.
.LP
Using the termination code, it is possible to determine which event
terminated the script. It is possible to decide if the string "BUSY"
was received from the modem as opposed to "NO DIAL TONE". While the
terminated the script.
It is possible to decide if the string "BUSY"
was received from the modem as opposed to "NO DIAL TONE".
While the
first event may be retried, the second will probably have little
chance of succeeding during a retry.
.SH SEE ALSO
Additional information about \fIchat\fR scripts may be found with UUCP
documentation. The \fIchat\fR script was taken from the ideas proposed
by the scripts used by the \fIuucico\fR program.
.LP
uucico(1), uucp(1)
.SH COPYRIGHT
The \fIchat\fR program is in public domain. This is not the GNU public
license. If it breaks then you get to keep both pieces.
The \fIchat\fR program is in public domain.
This is not the GNU public license.
If it breaks then you get to keep both pieces.

View File

@ -85,10 +85,14 @@
#ifndef __STDC__
#define const
#endif
#include <sys/cdefs.h>
#if 0
#ifndef lint
static const char rcsid[] = "Id: chat.c,v 1.30 2004/01/17 05:47:55 carlsonj Exp ";
#endif
#else
__RCSID("$NetBSD: chat.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
#endif
#include <stdio.h>
#include <ctype.h>
@ -147,20 +151,9 @@ extern char *sys_errlist[];
"unknown error")
#endif
/*************** Micro getopt() *********************************************/
#define OPTION(c,v) (_O&2&&**v?*(*v)++:!c||_O&4?0:(!(_O&1)&& \
(--c,++v),_O=4,c&&**v=='-'&&v[0][1]?*++*v=='-'\
&&!v[0][1]?(--c,++v,0):(_O=2,*(*v)++):0))
#define OPTARG(c,v) (_O&2?**v||(++v,--c)?(_O=1,--c,*v++): \
(_O=4,(char*)0):(char*)0)
#define OPTONLYARG(c,v) (_O&2&&**v?(_O=1,--c,*v++):(char*)0)
#define ARG(c,v) (c?(--c,*v++):(char*)0)
static int _O = 0; /* Internal state */
/*************** Micro getopt() *********************************************/
char *program_name;
#define BUFFER_SIZE 256
#define MAX_ABORTS 50
#define MAX_REPORTS 50
#define DEFAULT_CHAT_TIMEOUT 45
@ -198,12 +191,12 @@ struct termios saved_tty_parameters;
#endif
char *abort_string[MAX_ABORTS], *fail_reason = (char *)0,
fail_buffer[50];
fail_buffer[BUFFER_SIZE];
int n_aborts = 0, abort_next = 0, timeout_next = 0, echo_next = 0;
int clear_abort_next = 0;
char *report_string[MAX_REPORTS] ;
char report_buffer[256] ;
char report_buffer[BUFFER_SIZE] ;
int n_reports = 0, report_next = 0, report_gathering = 0 ;
int clear_report_next = 0;
@ -226,15 +219,15 @@ void echo_stderr __P((int));
void break_sequence __P((void));
void terminate __P((int status));
void do_file __P((char *chat_file));
int get_string __P((register char *string));
int put_string __P((register char *s));
int get_string __P((char *string));
int put_string __P((char *s));
int write_char __P((int c));
int put_char __P((int c));
int get_char __P((void));
void chat_send __P((register char *s));
void chat_send __P((char *s));
char *character __P((int c));
void chat_expect __P((register char *s));
char *clean __P((register char *s, int sending));
void chat_expect __P((char *s));
char *clean __P((char *s, int sending));
void break_sequence __P((void));
void terminate __P((int status));
void pack_array __P((char **array, int end));
@ -289,12 +282,12 @@ main(argc, argv)
char **argv;
{
int option;
char *arg;
int i;
program_name = *argv;
tzset();
while ((option = OPTION(argc, argv)) != 0) {
while ((option = getopt(argc, argv, ":eEvVf:t:r:sST:U:")) != -1) {
switch (option) {
case 'e':
++echo;
@ -321,25 +314,24 @@ main(argc, argv)
break;
case 'f':
if ((arg = OPTARG(argc, argv)) != NULL)
chat_file = copy_of(arg);
if (optarg != NULL)
chat_file = copy_of(optarg);
else
usage();
break;
case 't':
if ((arg = OPTARG(argc, argv)) != NULL)
timeout = atoi(arg);
if (optarg != NULL)
timeout = atoi(optarg);
else
usage();
break;
case 'r':
arg = OPTARG (argc, argv);
if (arg) {
if (optarg) {
if (report_fp != NULL)
fclose (report_fp);
report_file = copy_of (arg);
report_file = copy_of (optarg);
report_fp = fopen (report_file, "a");
if (report_fp != NULL) {
if (verbose)
@ -351,15 +343,15 @@ main(argc, argv)
break;
case 'T':
if ((arg = OPTARG(argc, argv)) != NULL)
phone_num = copy_of(arg);
if (optarg != NULL)
phone_num = copy_of(optarg);
else
usage();
break;
case 'U':
if ((arg = OPTARG(argc, argv)) != NULL)
phone_num2 = copy_of(arg);
if (optarg != NULL)
phone_num2 = copy_of(optarg);
else
usage();
break;
@ -369,6 +361,8 @@ main(argc, argv)
break;
}
}
argc -= optind;
argv += optind;
/*
* Default the report file to the stderr location
*/
@ -391,17 +385,15 @@ main(argc, argv)
init();
if (chat_file != NULL) {
arg = ARG(argc, argv);
if (arg != NULL)
if (argc)
usage();
else
do_file (chat_file);
} else {
while ((arg = ARG(argc, argv)) != NULL) {
chat_expect(arg);
if ((arg = ARG(argc, argv)) != NULL)
chat_send(arg);
for (i = 0; i < argc; i++) {
chat_expect(argv[i]);
if (++i < argc)
chat_send(argv[i]);
}
}
@ -508,6 +500,7 @@ void msgf __V((const char *fmt, ...))
#endif
vfmtmsg(line, sizeof(line), fmt, args);
va_end(args);
if (to_log)
syslog(LOG_INFO, "%s", line);
if (to_stderr)
@ -533,6 +526,7 @@ void fatal __V((int code, const char *fmt, ...))
#endif
vfmtmsg(line, sizeof(line), fmt, args);
va_end(args);
if (to_log)
syslog(LOG_ERR, "%s", line);
if (to_stderr)
@ -614,7 +608,7 @@ void set_tty_parameters()
have_tty_parameters = 1;
t.c_iflag |= IGNBRK | ISTRIP | IGNPAR;
t.c_oflag = 0;
t.c_oflag |= OPOST | ONLCR;
t.c_lflag = 0;
t.c_cc[VERASE] =
t.c_cc[VKILL] = 0;
@ -649,7 +643,7 @@ int status;
int c, rep_len;
rep_len = strlen(report_buffer);
while (rep_len + 1 <= sizeof(report_buffer)) {
while (rep_len < sizeof(report_buffer) - 1) {
alarm(1);
c = get_char();
alarm(0);
@ -682,7 +676,7 @@ int status;
* 'Clean up' this string.
*/
char *clean(s, sending)
register char *s;
char *s;
int sending; /* set to 1 when sending (putting) this string. */
{
char cur_chr;
@ -1022,11 +1016,11 @@ int c;
c &= 0x7F;
if (c < 32)
sprintf(string, "%s^%c", meta, (int)c + '@');
snprintf(string, sizeof(string), "%s^%c", meta, (int)c + '@');
else if (c == 127)
sprintf(string, "%s^?", meta);
snprintf(string, sizeof(string), "%s^?", meta);
else
sprintf(string, "%s%c", meta, c);
snprintf(string, sizeof(string), "%s%c", meta, c);
return (string);
}
@ -1035,7 +1029,7 @@ int c;
* process the reply string
*/
void chat_send (s)
register char *s;
char *s;
{
char file_data[STR_LEN];
@ -1297,10 +1291,11 @@ int c;
}
int put_string (s)
register char *s;
char *s;
{
char *ss;
quiet = 0;
s = clean(s, 1);
s = ss = clean(s, 1);
if (verbose) {
if (quiet)
@ -1312,11 +1307,13 @@ register char *s;
alarm(timeout); alarmed = 0;
while (*s) {
register char c = *s++;
char c = *s++;
if (c != '\\') {
if (!write_char (c))
if (!write_char (c)) {
free(ss);
return 0;
}
continue;
}
@ -1335,14 +1332,17 @@ register char *s;
break;
default:
if (!write_char (c))
if (!write_char (c)) {
free(ss);
return 0;
}
break;
}
}
alarm(0);
alarmed = 0;
free(ss);
return (1);
}
@ -1380,11 +1380,11 @@ int n;
* 'Wait for' this string to appear on this file descriptor.
*/
int get_string(string)
register char *string;
char *string;
{
char temp[STR_LEN];
int c, printed = 0, len, minlen;
register char *s = temp, *end = s + STR_LEN;
int c, len, minlen;
char *s = temp, *end = s + STR_LEN;
char *logged = temp;
fail_reason = (char *)0;
@ -1398,12 +1398,14 @@ register char *string;
if (len > STR_LEN) {
msgf("expect string is too long");
exit_code = 1;
free(string);
return 0;
}
if (len == 0) {
if (verbose)
msgf("got it");
free(string);
return (1);
}
@ -1447,6 +1449,8 @@ register char *string;
strftime (report_buffer, 20, "%b %d %H:%M:%S ", tm_now);
strcat (report_buffer, report_string[n]);
strlcat(report_buffer, report_string[n],
sizeof(report_buffer));
report_string[n] = (char *) NULL;
report_gathering = 1;
@ -1477,6 +1481,7 @@ register char *string;
alarm(0);
alarmed = 0;
free(string);
return (1);
}
@ -1492,7 +1497,9 @@ register char *string;
alarm(0);
alarmed = 0;
exit_code = n + 4;
strcpy(fail_reason = fail_buffer, abort_string[n]);
strlcpy(fail_buffer, abort_string[n], sizeof(fail_buffer));
fail_reason = fail_buffer;
free(string);
return (0);
}
}
@ -1514,16 +1521,10 @@ register char *string;
}
alarm(0);
if (verbose && printed) {
if (alarmed)
msgf(" -- read timed out");
else
msgf(" -- read failed: %m");
}
exit_code = 3;
alarmed = 0;
free(string);
return (0);
}

View File

@ -1,3 +1,5 @@
/* $NetBSD: auth.c,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* auth.c - PPP authentication and phase control.
*
@ -68,7 +70,13 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/cdefs.h>
#if 0
#define RCSID "Id: auth.c,v 1.117 2008/07/01 12:27:56 paulus Exp "
static const char rcsid[] = RCSID;
#else
__RCSID("$NetBSD: auth.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
#endif
#include <stdio.h>
#include <stddef.h>
@ -81,7 +89,6 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <utmp.h>
#include <fcntl.h>
#if defined(_PATH_LASTLOG) && defined(__linux__)
#include <lastlog.h>
@ -115,7 +122,6 @@
#include "pathnames.h"
#include "session.h"
static const char rcsid[] = RCSID;
/* Bits in scan_authfile return value */
#define NONWILD_SERVER 1
@ -415,34 +421,37 @@ setupapfile(argv)
int l;
uid_t euid;
char u[MAXNAMELEN], p[MAXSECRETLEN];
char *fname;
lcp_allowoptions[0].neg_upap = 1;
if (*argv == NULL)
novm("+ua file name");
if (uafname != NULL)
free(uafname);
/* open user info file */
fname = strdup(*argv);
if (fname == NULL)
uafname = strdup(*argv);
if (uafname == NULL)
novm("+ua file name");
euid = geteuid();
if (seteuid(getuid()) == -1) {
option_error("unable to reset uid before opening %s: %m", fname);
option_error("unable to reset uid before opening %s: %m", uafname);
return 0;
}
ufile = fopen(fname, "r");
ufile = fopen(uafname, "r");
if (seteuid(euid) == -1)
fatal("unable to regain privileges: %m");
if (ufile == NULL) {
option_error("unable to open user login data file %s", fname);
option_error("unable to open user login data file %s", uafname);
return 0;
}
check_access(ufile, fname);
uafname = fname;
check_access(ufile, uafname);
/* get username */
if (fgets(u, MAXNAMELEN - 1, ufile) == NULL
|| fgets(p, MAXSECRETLEN - 1, ufile) == NULL) {
fclose(ufile);
option_error("unable to read user login data file %s", fname);
option_error("unable to read user login data file %s", uafname);
return 0;
}
fclose(ufile);
@ -455,11 +464,11 @@ setupapfile(argv)
if (l > 0 && p[l-1] == '\n')
p[l-1] = 0;
if (override_value("user", option_priority, fname)) {
if (override_value("user", option_priority, uafname)) {
strlcpy(user, u, sizeof(user));
explicit_user = 1;
}
if (override_value("passwd", option_priority, fname)) {
if (override_value("passwd", option_priority, uafname)) {
strlcpy(passwd, p, sizeof(passwd));
explicit_passwd = 1;
}
@ -871,7 +880,8 @@ start_networks(unit)
#ifdef PPP_FILTER
if (!demand)
set_filters(&pass_filter, &active_filter);
set_filters(&pass_filter_in, &pass_filter_out,
&active_filter_in, &active_filter_out);
#endif
/* Start CCP and ECP */
for (i = 0; (protp = protocols[i]) != NULL; ++i)
@ -2223,14 +2233,15 @@ scan_authfile(f, client, server, secret, addrs, opts, filename, flags)
*/
app = &alist;
for (;;) {
size_t len;
if (!getword(f, word, &newline, filename) || newline)
break;
ap = (struct wordlist *)
malloc(sizeof(struct wordlist) + strlen(word) + 1);
len = strlen(word) + 1;
ap = (struct wordlist *)malloc(sizeof(struct wordlist) + len);
if (ap == NULL)
novm("authorized addresses");
ap->word = (char *) (ap + 1);
strcpy(ap->word, word);
memcpy(ap->word, word, len);
*app = ap;
app = &ap->next;
}

View File

@ -1,3 +1,5 @@
/* $NetBSD: cbcp.c,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* cbcp - Call Back Configuration Protocol.
*
@ -33,7 +35,13 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/cdefs.h>
#if 0
#define RCSID "Id: cbcp.c,v 1.17 2006/05/22 00:04:07 paulus Exp "
static const char rcsid[] = RCSID;
#else
__RCSID("$NetBSD: cbcp.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
#endif
#include <stdio.h>
#include <string.h>
@ -45,8 +53,6 @@
#include "fsm.h"
#include "lcp.h"
static const char rcsid[] = RCSID;
/*
* Options.
*/
@ -166,7 +172,7 @@ cbcp_input(unit, inpacket, pktlen)
if (pktlen < CBCP_MINLEN) {
if (debug)
dbglog("CBCP packet is too small");
dbglog("CBCP: Packet too short (%d)", pktlen);
return;
}
@ -176,7 +182,7 @@ cbcp_input(unit, inpacket, pktlen)
if (len > pktlen || len < CBCP_MINLEN) {
if (debug)
dbglog("CBCP packet: invalid length %d", len);
dbglog("CBCP: Invalid packet length (%d/%d)", len, pktlen);
return;
}
@ -280,6 +286,7 @@ cbcp_printpkt(p, plen, printer, arg)
char str[256];
GETCHAR(addrt, p);
__USE(addrt);
memcpy(str, p, olen - 4);
str[olen - 4] = 0;
printer(arg, " number = %s", str);
@ -318,11 +325,16 @@ cbcp_recvreq(us, pckt, pcktlen)
GETCHAR(type, pckt);
GETCHAR(opt_len, pckt);
if (opt_len < 2 || opt_len > len)
if (opt_len < 2 || opt_len > len) {
if (debug)
dbglog("CBCP: Malformed option length (%d/%d)", opt_len, len);
break;
}
if (opt_len > 2)
if (opt_len > 2) {
GETCHAR(delay, pckt);
__USE(delay);
}
us->us_allowed |= (1 << type);
@ -335,6 +347,7 @@ cbcp_recvreq(us, pckt, pcktlen)
dbglog("user callback allowed");
if (opt_len > 4) {
GETCHAR(addr_type, pckt);
__USE(addr_type);
memcpy(address, pckt, opt_len - 4);
address[opt_len - 4] = 0;
if (address[0])
@ -457,11 +470,14 @@ cbcp_recvack(us, pckt, len)
GETCHAR(opt_len, pckt);
if (opt_len >= 2 && opt_len <= len) {
if (opt_len > 2)
if (opt_len > 2) {
GETCHAR(delay, pckt);
__USE(delay);
}
if (opt_len > 4) {
GETCHAR(addr_type, pckt);
__USE(addr_type);
memcpy(address, pckt, opt_len - 4);
address[opt_len - 4] = 0;
if (address[0])

View File

@ -1,3 +1,5 @@
/* $NetBSD: cbcp.h,v 1.2 2013/11/28 22:33:42 christos Exp $ */
#ifndef CBCP_H
#define CBCP_H

View File

@ -1,3 +1,5 @@
/* $NetBSD: ccp.c,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* ccp.c - PPP Compression Control Protocol.
*
@ -28,7 +30,13 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/cdefs.h>
#if 0
#define RCSID "Id: ccp.c,v 1.50 2005/06/26 19:34:41 carlsonj Exp "
static const char rcsid[] = RCSID;
#else
__RCSID("$NetBSD: ccp.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
#endif
#include <stdlib.h>
#include <string.h>
@ -43,8 +51,6 @@
#include "lcp.h" /* lcp_close(), lcp_fsm */
#endif
static const char rcsid[] = RCSID;
/*
* Unfortunately there is a bug in zlib which means that using a
* size of 8 (window size = 256) for Deflate compression will cause

View File

@ -1,3 +1,5 @@
/* $NetBSD: ccp.h,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* ccp.h - Definitions for PPP Compression Control Protocol.
*
@ -37,7 +39,7 @@ typedef struct ccp_options {
bool predictor_2; /* do Predictor-2? */
bool deflate_correct; /* use correct code for deflate? */
bool deflate_draft; /* use draft RFC code for deflate? */
bool mppe; /* do MPPE? */
u_short mppe; /* do MPPE? */
u_short bsd_bits; /* # bits/code for BSD Compress */
u_short deflate_size; /* lg(window size) for Deflate */
short method; /* code for chosen compression method */

View File

@ -1,3 +1,5 @@
/* $NetBSD: chap-md5.c,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* chap-md5.c - New CHAP/MD5 implementation.
*
@ -28,15 +30,21 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/cdefs.h>
#if 0
#define RCSID "Id: chap-md5.c,v 1.4 2004/11/09 22:39:25 paulus Exp "
static const char rcsid[] = RCSID;
#else
__RCSID("$NetBSD: chap-md5.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
#endif
#include <stdlib.h>
#include <string.h>
#include <md5.h>
#include "pppd.h"
#include "chap-new.h"
#include "chap-md5.h"
#include "magic.h"
#include "md5.h"
#define MD5_HASH_SIZE 16
#define MD5_MIN_CHALLENGE 16
@ -68,11 +76,11 @@ chap_md5_verify_response(int id, char *name,
response_len = *response++;
if (response_len == MD5_HASH_SIZE) {
/* Generate hash of ID, secret, challenge */
MD5_Init(&ctx);
MD5_Update(&ctx, &idbyte, 1);
MD5_Update(&ctx, secret, secret_len);
MD5_Update(&ctx, challenge, challenge_len);
MD5_Final(hash, &ctx);
MD5Init(&ctx);
MD5Update(&ctx, &idbyte, 1);
MD5Update(&ctx, secret, secret_len);
MD5Update(&ctx, challenge, challenge_len);
MD5Final(hash, &ctx);
/* Test if our hash matches the peer's response */
if (memcmp(hash, response, MD5_HASH_SIZE) == 0) {
@ -93,11 +101,11 @@ chap_md5_make_response(unsigned char *response, int id, char *our_name,
unsigned char idbyte = id;
int challenge_len = *challenge++;
MD5_Init(&ctx);
MD5_Update(&ctx, &idbyte, 1);
MD5_Update(&ctx, (u_char *)secret, secret_len);
MD5_Update(&ctx, challenge, challenge_len);
MD5_Final(&response[1], &ctx);
MD5Init(&ctx);
MD5Update(&ctx, &idbyte, 1);
MD5Update(&ctx, secret, secret_len);
MD5Update(&ctx, challenge, challenge_len);
MD5Final(&response[1], &ctx);
response[0] = MD5_HASH_SIZE;
}

View File

@ -1,3 +1,5 @@
/* $NetBSD: chap-md5.h,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* chap-md5.h - New CHAP/MD5 implementation.
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: chap-new.c,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* chap-new.c - New CHAP implementation.
*
@ -28,7 +30,13 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/cdefs.h>
#if 0
#define RCSID "Id: chap-new.c,v 1.9 2007/06/19 02:08:35 carlsonj Exp "
static const char rcsid[] = RCSID;
#else
__RCSID("$NetBSD: chap-new.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
#endif
#include <stdlib.h>
#include <string.h>

View File

@ -1,3 +1,5 @@
/* $NetBSD: chap-new.h,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* chap-new.c - New CHAP implementation.
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: chap_ms.c,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* chap_ms.c - Microsoft MS-CHAP compatible implementation.
*
@ -74,7 +76,13 @@
*
*/
#include <sys/cdefs.h>
#if 0
#define RCSID "Id: chap_ms.c,v 1.38 2007/12/01 20:10:51 carlsonj Exp "
static const char rcsid[] = RCSID;
#else
__RCSID("$NetBSD: chap_ms.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
#endif
#ifdef CHAPMS
@ -85,16 +93,17 @@
#include <sys/types.h>
#include <sys/time.h>
#include <unistd.h>
#include <md4.h>
#include <sha1.h>
#define SHA1_SIGNATURE_SIZE SHA1_DIGEST_LENGTH
#include "pppd.h"
#include "chap-new.h"
#include "chap_ms.h"
#include "md4.h"
#include "sha1.h"
#include "pppcrypt.h"
#include "magic.h"
static const char rcsid[] = RCSID;
static void ascii2unicode __P((char[], int, u_char[]));
@ -545,11 +554,11 @@ ChallengeHash(u_char PeerChallenge[16], u_char *rchallenge,
else
user = username;
SHA1_Init(&sha1Context);
SHA1_Update(&sha1Context, PeerChallenge, 16);
SHA1_Update(&sha1Context, rchallenge, 16);
SHA1_Update(&sha1Context, (unsigned char *)user, strlen(user));
SHA1_Final(sha1Hash, &sha1Context);
SHA1Init(&sha1Context);
SHA1Update(&sha1Context, PeerChallenge, 16);
SHA1Update(&sha1Context, rchallenge, 16);
SHA1Update(&sha1Context, (unsigned char *)user, strlen(user));
SHA1Final(sha1Hash, &sha1Context);
BCOPY(sha1Hash, Challenge, 8);
}
@ -639,7 +648,7 @@ ChapMS_LANMan(u_char *rchallenge, char *secret, int secret_len,
/* LANMan password is case insensitive */
BZERO(UcasePassword, sizeof(UcasePassword));
for (i = 0; i < secret_len; i++)
UcasePassword[i] = (u_char)toupper(secret[i]);
UcasePassword[i] = (u_char)toupper((unsigned char)secret[i]);
(void) DesSetkey(UcasePassword + 0);
DesEncrypt( StdText, PasswordHash + 0 );
(void) DesSetkey(UcasePassword + 7);
@ -675,19 +684,19 @@ GenerateAuthenticatorResponse(u_char PasswordHashHash[MD4_SIGNATURE_SIZE],
u_char Digest[SHA1_SIGNATURE_SIZE];
u_char Challenge[8];
SHA1_Init(&sha1Context);
SHA1_Update(&sha1Context, PasswordHashHash, MD4_SIGNATURE_SIZE);
SHA1_Update(&sha1Context, NTResponse, 24);
SHA1_Update(&sha1Context, Magic1, sizeof(Magic1));
SHA1_Final(Digest, &sha1Context);
SHA1Init(&sha1Context);
SHA1Update(&sha1Context, PasswordHashHash, MD4_SIGNATURE_SIZE);
SHA1Update(&sha1Context, NTResponse, 24);
SHA1Update(&sha1Context, Magic1, sizeof(Magic1));
SHA1Final(Digest, &sha1Context);
ChallengeHash(PeerChallenge, rchallenge, username, Challenge);
SHA1_Init(&sha1Context);
SHA1_Update(&sha1Context, Digest, sizeof(Digest));
SHA1_Update(&sha1Context, Challenge, sizeof(Challenge));
SHA1_Update(&sha1Context, Magic2, sizeof(Magic2));
SHA1_Final(Digest, &sha1Context);
SHA1Init(&sha1Context);
SHA1Update(&sha1Context, Digest, sizeof(Digest));
SHA1Update(&sha1Context, Challenge, sizeof(Challenge));
SHA1Update(&sha1Context, Magic2, sizeof(Magic2));
SHA1Final(Digest, &sha1Context);
/* Convert to ASCII hex string. */
for (i = 0; i < MAX((MS_AUTH_RESPONSE_LENGTH / 2), sizeof(Digest)); i++)
@ -728,11 +737,11 @@ mppe_set_keys(u_char *rchallenge, u_char PasswordHashHash[MD4_SIGNATURE_SIZE])
SHA1_CTX sha1Context;
u_char Digest[SHA1_SIGNATURE_SIZE]; /* >= MPPE_MAX_KEY_LEN */
SHA1_Init(&sha1Context);
SHA1_Update(&sha1Context, PasswordHashHash, MD4_SIGNATURE_SIZE);
SHA1_Update(&sha1Context, PasswordHashHash, MD4_SIGNATURE_SIZE);
SHA1_Update(&sha1Context, rchallenge, 8);
SHA1_Final(Digest, &sha1Context);
SHA1Init(&sha1Context);
SHA1Update(&sha1Context, PasswordHashHash, MD4_SIGNATURE_SIZE);
SHA1Update(&sha1Context, PasswordHashHash, MD4_SIGNATURE_SIZE);
SHA1Update(&sha1Context, rchallenge, 8);
SHA1Final(Digest, &sha1Context);
/* Same key in both directions. */
BCOPY(Digest, mppe_send_key, sizeof(mppe_send_key));
@ -815,11 +824,11 @@ mppe_set_keys2(u_char PasswordHashHash[MD4_SIGNATURE_SIZE],
0x6b, 0x65, 0x79, 0x2e };
u_char *s;
SHA1_Init(&sha1Context);
SHA1_Update(&sha1Context, PasswordHashHash, MD4_SIGNATURE_SIZE);
SHA1_Update(&sha1Context, NTResponse, 24);
SHA1_Update(&sha1Context, Magic1, sizeof(Magic1));
SHA1_Final(MasterKey, &sha1Context);
SHA1Init(&sha1Context);
SHA1Update(&sha1Context, PasswordHashHash, MD4_SIGNATURE_SIZE);
SHA1Update(&sha1Context, NTResponse, 24);
SHA1Update(&sha1Context, Magic1, sizeof(Magic1));
SHA1Final(MasterKey, &sha1Context);
/*
* generate send key
@ -828,12 +837,12 @@ mppe_set_keys2(u_char PasswordHashHash[MD4_SIGNATURE_SIZE],
s = Magic3;
else
s = Magic2;
SHA1_Init(&sha1Context);
SHA1_Update(&sha1Context, MasterKey, 16);
SHA1_Update(&sha1Context, SHApad1, sizeof(SHApad1));
SHA1_Update(&sha1Context, s, 84);
SHA1_Update(&sha1Context, SHApad2, sizeof(SHApad2));
SHA1_Final(Digest, &sha1Context);
SHA1Init(&sha1Context);
SHA1Update(&sha1Context, MasterKey, 16);
SHA1Update(&sha1Context, SHApad1, sizeof(SHApad1));
SHA1Update(&sha1Context, s, 84);
SHA1Update(&sha1Context, SHApad2, sizeof(SHApad2));
SHA1Final(Digest, &sha1Context);
BCOPY(Digest, mppe_send_key, sizeof(mppe_send_key));
@ -844,12 +853,12 @@ mppe_set_keys2(u_char PasswordHashHash[MD4_SIGNATURE_SIZE],
s = Magic2;
else
s = Magic3;
SHA1_Init(&sha1Context);
SHA1_Update(&sha1Context, MasterKey, 16);
SHA1_Update(&sha1Context, SHApad1, sizeof(SHApad1));
SHA1_Update(&sha1Context, s, 84);
SHA1_Update(&sha1Context, SHApad2, sizeof(SHApad2));
SHA1_Final(Digest, &sha1Context);
SHA1Init(&sha1Context);
SHA1Update(&sha1Context, MasterKey, 16);
SHA1Update(&sha1Context, SHApad1, sizeof(SHApad1));
SHA1Update(&sha1Context, s, 84);
SHA1Update(&sha1Context, SHApad2, sizeof(SHApad2));
SHA1Final(Digest, &sha1Context);
BCOPY(Digest, mppe_recv_key, sizeof(mppe_recv_key));

View File

@ -1,3 +1,5 @@
/* $NetBSD: chap_ms.h,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* chap_ms.h - Challenge Handshake Authentication Protocol definitions.
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: demand.c,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* demand.c - Support routines for demand-dialling.
*
@ -28,7 +30,13 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/cdefs.h>
#if 0
#define RCSID "Id: demand.c,v 1.20 2005/08/25 12:14:18 paulus Exp "
static const char rcsid[] = RCSID;
#else
__RCSID("$NetBSD: demand.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
#endif
#include <stdio.h>
#include <stdlib.h>
@ -44,7 +52,7 @@
#include <sys/stat.h>
#include <sys/socket.h>
#ifdef PPP_FILTER
#include <pcap-bpf.h>
#include <pcap.h>
#endif
#include "pppd.h"
@ -52,7 +60,6 @@
#include "ipcp.h"
#include "lcp.h"
static const char rcsid[] = RCSID;
char *frame;
int framelen;
@ -100,7 +107,8 @@ demand_conf()
fatal("Couldn't set up demand-dialled PPP interface: %m");
#ifdef PPP_FILTER
set_filters(&pass_filter, &active_filter);
set_filters(&pass_filter_in, &pass_filter_out,
&active_filter_in, &active_filter_out);
#endif
/*
@ -330,6 +338,9 @@ demand_rexmit(proto)
* that is, whether it is worth bringing up the link for.
*/
static int
/*###340 [cc] error: static declaration of 'active_packet' follows non-static declaration%%%*/
/*###340 [cc] error: function declaration isn't a prototype%%%*/
/*###340 [cc] error: 'active_packet' defined but not used%%%*/
active_packet(p, len)
unsigned char *p;
int len;
@ -342,10 +353,10 @@ active_packet(p, len)
proto = PPP_PROTOCOL(p);
#ifdef PPP_FILTER
p[0] = 1; /* outbound packet indicator */
if ((pass_filter.bf_len != 0
&& bpf_filter(pass_filter.bf_insns, p, len, len) == 0)
|| (active_filter.bf_len != 0
&& bpf_filter(active_filter.bf_insns, p, len, len) == 0)) {
if ((pass_filter_out.bf_len != 0
&& bpf_filter(pass_filter_out.bf_insns, p, len, len) == 0)
|| (active_filter_out.bf_len != 0
&& bpf_filter(active_filter_out.bf_insns, p, len, len) == 0)) {
p[0] = 0xff;
return 0;
}

View File

@ -1,3 +1,4 @@
/* $NetBSD: eap.c,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* eap.c - Extensible Authentication Protocol for PPP (RFC 2284)
*
@ -43,7 +44,13 @@
* Based on draft-ietf-pppext-eap-srp-03.txt.
*/
#include <sys/cdefs.h>
#if 0
#define RCSID "Id: eap.c,v 1.4 2004/11/09 22:39:25 paulus Exp "
static const char rcsid[] = RCSID;
#else
__RCSID("$NetBSD: eap.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
#endif
/*
* TODO:
@ -59,10 +66,10 @@
#include <fcntl.h>
#include <assert.h>
#include <errno.h>
#include <md5.h>
#include "pppd.h"
#include "pathnames.h"
#include "md5.h"
#include "eap.h"
#ifdef USE_SRP
@ -76,7 +83,6 @@
#define SHA_DIGESTSIZE 20
#endif
static const char rcsid[] = RCSID;
eap_state eap_states[NUM_PPP]; /* EAP state; one for each unit */
#ifdef USE_SRP
@ -142,6 +148,7 @@ struct protent eap_protent = {
/*
* A well-known 2048 bit modulus.
*/
#ifdef USE_SRP
static const u_char wkmodulus[] = {
0xAC, 0x6B, 0xDB, 0x41, 0x32, 0x4A, 0x9A, 0x9B,
0xF1, 0x66, 0xDE, 0x5E, 0x13, 0x89, 0x58, 0x2F,
@ -176,9 +183,25 @@ static const u_char wkmodulus[] = {
0x9B, 0x65, 0xE3, 0x72, 0xFC, 0xD6, 0x8E, 0xF2,
0x0F, 0xA7, 0x11, 0x1F, 0x9E, 0x4A, 0xFF, 0x73
};
#endif
/* Local forward declarations. */
static void eap_server_timeout __P((void *arg));
static const char *eap_state_name __P((enum eap_state_code));
static void eap_client_timeout __P((void *arg));
static void eap_send_failure __P((eap_state *));
static void eap_send_success __P((eap_state *));
static void eap_figure_next_state __P((eap_state *, int));
static void eap_send_request __P((eap_state *));
static void eap_rechallenge __P((void *));
static void srp_lwrechallenge __P((void *));
static void eap_send_response __P((eap_state *, u_char, u_char, const u_char *, int));
static void eap_chap_response __P((eap_state *, u_char, const u_char *, const char *, int));
static void eap_send_nak __P((eap_state *,u_char,u_char));
static void eap_request __P((eap_state *, u_char *, int, int));
static void eap_response __P((eap_state *, u_char *, int, int));
static void eap_success __P((eap_state *, u_char *, int, int));
static void eap_failure __P((eap_state *, u_char *, int, int));
/*
* Convert EAP state code to printable string for debug.
@ -1039,12 +1062,8 @@ int unit;
* Format and send a regular EAP Response message.
*/
static void
eap_send_response(esp, id, typenum, str, lenstr)
eap_state *esp;
u_char id;
u_char typenum;
u_char *str;
int lenstr;
eap_send_response(eap_state *esp, u_char id, u_char typenum,
const u_char *str, int lenstr)
{
u_char *outp;
int msglen;
@ -1070,12 +1089,8 @@ int lenstr;
* Format and send an MD5-Challenge EAP Response message.
*/
static void
eap_chap_response(esp, id, hash, name, namelen)
eap_state *esp;
u_char id;
u_char *hash;
char *name;
int namelen;
eap_chap_response(eap_state *esp, u_char id, const u_char *hash,
const char *name, int namelen)
{
u_char *outp;
int msglen;
@ -1167,10 +1182,7 @@ u_char *str;
#endif /* USE_SRP */
static void
eap_send_nak(esp, id, type)
eap_state *esp;
u_char id;
u_char type;
eap_send_nak(eap_state *esp, u_char id, u_char type)
{
u_char *outp;
int msglen;
@ -1445,13 +1457,13 @@ int len;
eap_send_nak(esp, id, EAPT_SRP);
break;
}
MD5_Init(&mdContext);
MD5Init(&mdContext);
typenum = id;
MD5_Update(&mdContext, &typenum, 1);
MD5_Update(&mdContext, (u_char *)secret, secret_len);
MD5Update(&mdContext, &typenum, 1);
MD5Update(&mdContext, secret, secret_len);
BZERO(secret, sizeof (secret));
MD5_Update(&mdContext, inp, vallen);
MD5_Final(hash, &mdContext);
MD5Update(&mdContext, inp, vallen);
MD5Final(hash, &mdContext);
eap_chap_response(esp, id, hash, esp->es_client.ea_name,
esp->es_client.ea_namelen);
break;
@ -1871,12 +1883,12 @@ int len;
eap_send_failure(esp);
break;
}
MD5_Init(&mdContext);
MD5_Update(&mdContext, &esp->es_server.ea_id, 1);
MD5_Update(&mdContext, (u_char *)secret, secret_len);
MD5Init(&mdContext);
MD5Update(&mdContext, &esp->es_server.ea_id, 1);
MD5Update(&mdContext, secret, secret_len);
BZERO(secret, sizeof (secret));
MD5_Update(&mdContext, esp->es_challenge, esp->es_challen);
MD5_Final(hash, &mdContext);
MD5Update(&mdContext, esp->es_challenge, esp->es_challen);
MD5Final(hash, &mdContext);
if (BCMP(hash, inp, MD5_SIGNATURE_SIZE) != 0) {
eap_send_failure(esp);
break;

View File

@ -1,3 +1,5 @@
/* $NetBSD: eap.h,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* eap.h - Extensible Authentication Protocol for PPP (RFC 2284)
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: ecp.c,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* ecp.c - PPP Encryption Control Protocol.
*
@ -57,9 +59,13 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/cdefs.h>
#if 0
#define RCSID "Id: ecp.c,v 1.4 2004/11/04 10:02:26 paulus Exp "
static const char rcsid[] = RCSID;
#else
__RCSID("$NetBSD: ecp.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
#endif
#include <string.h>

View File

@ -1,3 +1,5 @@
/* $NetBSD: ecp.h,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* ecp.h - Definitions for PPP Encryption Control Protocol.
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: eui64.c,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* eui64.c - EUI64 routines for IPv6CP.
*
@ -35,11 +37,16 @@
* Id: eui64.c,v 1.6 2002/12/04 23:03:32 paulus Exp
*/
#include <sys/cdefs.h>
#if 0
#define RCSID "Id: eui64.c,v 1.6 2002/12/04 23:03:32 paulus Exp "
static const char rcsid[] = RCSID;
#else
__RCSID("$NetBSD: eui64.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
#endif
#include "pppd.h"
static const char rcsid[] = RCSID;
/*
* eui64_ntoa - Make an ascii representation of an interface identifier

View File

@ -1,3 +1,5 @@
/* $NetBSD: eui64.h,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* eui64.h - EUI64 routines for IPv6CP.
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: fsm.c,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* fsm.c - {Link, IP} Control Protocol Finite State Machine.
*
@ -40,7 +42,13 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#define RCSID "Id: fsm.c,v 1.23 2004/11/13 02:28:15 paulus Exp "
#include <sys/cdefs.h>
#if 0
#define RCSID "Id: fsm.c,v 1.23 2004/11/13 02:28:15 paulus Exp "
static const char rcsid[] = RCSID;
#else
__RCSID("$NetBSD: fsm.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
#endif
/*
* TODO:
@ -55,7 +63,6 @@
#include "pppd.h"
#include "fsm.h"
static const char rcsid[] = RCSID;
static void fsm_timeout __P((void *));
static void fsm_rconfreq __P((fsm *, int, u_char *, int));
@ -65,6 +72,7 @@ static void fsm_rtermreq __P((fsm *, int, u_char *, int));
static void fsm_rtermack __P((fsm *));
static void fsm_rcoderej __P((fsm *, u_char *, int));
static void fsm_sconfreq __P((fsm *, int));
static void terminate_layer __P((fsm *, int));
#define PROTO_NAME(f) ((f)->callbacks->proto_name)
@ -306,7 +314,7 @@ fsm_timeout(arg)
case ACKRCVD:
case ACKSENT:
if (f->retransmits <= 0) {
warn("%s: timeout sending Config-Requests\n", PROTO_NAME(f));
warn("%s: timeout sending Config-Requests", PROTO_NAME(f));
f->state = STOPPED;
if( (f->flags & OPT_PASSIVE) == 0 && f->callbacks->finished )
(*f->callbacks->finished)(f);

View File

@ -1,3 +1,5 @@
/* $NetBSD: fsm.h,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* fsm.h - {Link, IP} Control Protocol Finite State Machine definitions.
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: ipcp.c,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* ipcp.c - PPP IP Control Protocol.
*
@ -40,7 +42,13 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/cdefs.h>
#if 0
#define RCSID "Id: ipcp.c,v 1.73 2008/05/26 08:33:22 paulus Exp "
static const char rcsid[] = RCSID;
#else
__RCSID("$NetBSD: ipcp.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
#endif
/*
* TODO:
@ -61,7 +69,6 @@
#include "ipcp.h"
#include "pathnames.h"
static const char rcsid[] = RCSID;
/* global vars */
ipcp_options ipcp_wantoptions[NUM_PPP]; /* Options that we want to request */

View File

@ -1,3 +1,5 @@
/* $NetBSD: ipcp.h,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* ipcp.h - IP Control Protocol definitions.
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: ipv6cp.c,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* ipv6cp.c - PPP IPV6 Control Protocol.
*
@ -138,7 +140,13 @@
* Id: ipv6cp.c,v 1.21 2005/08/25 23:59:34 paulus Exp
*/
#include <sys/cdefs.h>
#if 0
#define RCSID "Id: ipv6cp.c,v 1.21 2005/08/25 23:59:34 paulus Exp "
static const char rcsid[] = RCSID;
#else
__RCSID("$NetBSD: ipv6cp.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
#endif
/*
* TODO:
@ -168,7 +176,7 @@
#include "magic.h"
#include "pathnames.h"
static const char rcsid[] = RCSID;
#define s6_addr32 __u6_addr.__u6_addr32 /* Non-standard */
/* global vars */
ipv6cp_options ipv6cp_wantoptions[NUM_PPP]; /* Options that we want to request */
@ -412,7 +420,7 @@ llv6_ntoa(ifaceid)
{
static char b[64];
sprintf(b, "fe80::%s", eui64_ntoa(ifaceid));
snprintf(b, sizeof(b), "fe80::%s", eui64_ntoa(ifaceid));
return b;
}
@ -1424,9 +1432,10 @@ ipv6cp_script(script)
char strspeed[32], strlocal[32], strremote[32];
char *argv[8];
sprintf(strspeed, "%d", baud_rate);
strcpy(strlocal, llv6_ntoa(ipv6cp_gotoptions[0].ourid));
strcpy(strremote, llv6_ntoa(ipv6cp_hisoptions[0].hisid));
snprintf(strspeed, sizeof(strspeed), "%d", baud_rate);
strlcpy(strlocal, llv6_ntoa(ipv6cp_gotoptions[0].ourid), sizeof(strlocal));
strlcpy(strremote, llv6_ntoa(ipv6cp_hisoptions[0].hisid),
sizeof(strremote));
argv[0] = script;
argv[1] = ifname;

View File

@ -1,3 +1,5 @@
/* $NetBSD: ipv6cp.h,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* ipv6cp.h - PPP IPV6 Control Protocol.
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: ipxcp.c,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* ipxcp.c - PPP IPX Control Protocol.
*
@ -40,9 +42,15 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/cdefs.h>
#if 0
#define RCSID "Id: ipxcp.c,v 1.24 2005/08/25 23:59:34 paulus Exp "
static const char rcsid[] = RCSID;
#else
__RCSID("$NetBSD: ipxcp.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
#endif
#ifdef IPX_CHANGE
#define RCSID "Id: ipxcp.c,v 1.24 2005/08/25 23:59:34 paulus Exp "
/*
* TODO:
@ -62,7 +70,6 @@
#include "pathnames.h"
#include "magic.h"
static const char rcsid[] = RCSID;
/* global vars */
ipxcp_options ipxcp_wantoptions[NUM_PPP]; /* Options that we want to request */

View File

@ -1,3 +1,5 @@
/* $NetBSD: ipxcp.h,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* ipxcp.h - IPX Control Protocol definitions.
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: lcp.c,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* lcp.c - PPP Link Control Protocol.
*
@ -40,7 +42,13 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/cdefs.h>
#if 0
#define RCSID "Id: lcp.c,v 1.76 2006/05/22 00:04:07 paulus Exp "
static const char rcsid[] = RCSID;
#else
__RCSID("$NetBSD: lcp.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
#endif
/*
* TODO:
@ -56,7 +64,6 @@
#include "chap-new.h"
#include "magic.h"
static const char rcsid[] = RCSID;
/*
* When the link comes up we want to be able to wait for a short while,

View File

@ -1,3 +1,5 @@
/* $NetBSD: lcp.h,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* lcp.h - Link Control Protocol definitions.
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: magic.c,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* magic.c - PPP Magic Number routines.
*
@ -40,7 +42,13 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/cdefs.h>
#if 0
#define RCSID "Id: magic.c,v 1.11 2003/06/11 23:56:26 paulus Exp "
static const char rcsid[] = RCSID;
#else
__RCSID("$NetBSD: magic.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
#endif
#include <stdio.h>
#include <stdlib.h>
@ -51,7 +59,6 @@
#include "pppd.h"
#include "magic.h"
static const char rcsid[] = RCSID;
extern long mrand48 __P((void));
extern void srand48 __P((long));

View File

@ -1,3 +1,5 @@
/* $NetBSD: magic.h,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* magic.h - PPP Magic Number definitions.
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: main.c,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* main.c - Point-to-Point Protocol main module
*
@ -66,7 +68,13 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/cdefs.h>
#if 0
#define RCSID "Id: main.c,v 1.156 2008/06/23 11:47:18 paulus Exp "
static const char rcsid[] = RCSID;
#else
__RCSID("$NetBSD: main.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
#endif
#include <stdio.h>
#include <ctype.h>
@ -121,7 +129,6 @@
#include "atcp.h"
#endif
static const char rcsid[] = RCSID;
/* interface vars */
char ifname[32]; /* Interface name */
@ -1616,9 +1623,7 @@ safe_fork(int infd, int outfd, int errfd)
}
static bool
add_script_env(pos, newstring)
int pos;
char *newstring;
add_script_env(int pos, char *newstring)
{
if (pos + 1 >= s_env_nalloc) {
int new_n = pos + 17;
@ -1636,8 +1641,7 @@ add_script_env(pos, newstring)
}
static void
remove_script_env(pos)
int pos;
remove_script_env(int pos)
{
free(script_env[pos] - 1);
while ((script_env[pos] = script_env[pos + 1]) != NULL)
@ -1649,7 +1653,7 @@ remove_script_env(pos)
* and update the system environment.
*/
static void
update_system_environment()
update_system_environment(void)
{
struct userenv *uep;
@ -1732,7 +1736,7 @@ device_script(program, in, out, dont_wait)
* script_unsetenv() safely after this routine is run.
*/
static void
update_script_environment()
update_script_environment(void)
{
struct userenv *uep;

View File

@ -1,3 +1,5 @@
/* $NetBSD: mppe.h,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* mppe.h - Definitions for MPPE
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: multilink.c,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* multilink.c - support routines for multilink.
*
@ -27,6 +29,10 @@
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: multilink.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
@ -573,7 +579,7 @@ str_to_epdisc(ep, str)
if (*str == 0)
break;
if (p <= str)
for (p = str; isxdigit(*p); ++p)
for (p = str; isxdigit((unsigned char)*p); ++p)
;
i = p - str;
if (i == 0)

View File

@ -1,3 +1,5 @@
/* $NetBSD: options.c,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* options.c - handles option processing for PPP.
*
@ -40,7 +42,13 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/cdefs.h>
#if 0
#define RCSID "Id: options.c,v 1.102 2008/06/15 06:53:06 paulus Exp "
static const char rcsid[] = RCSID;
#else
__RCSID("$NetBSD: options.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
#endif
#include <ctype.h>
#include <stdio.h>
@ -79,7 +87,6 @@
char *strdup __P((char *));
#endif
static const char rcsid[] = RCSID;
struct option_value {
struct option_value *next;
@ -133,8 +140,13 @@ extern option_t auth_options[];
extern struct stat devstat;
#ifdef PPP_FILTER
struct bpf_program pass_filter;/* Filter program for packets to pass */
struct bpf_program active_filter; /* Filter program for link-active pkts */
/* Filter program for packets to pass */
struct bpf_program pass_filter_in;
struct bpf_program pass_filter_out;
/* Filter program for link-active packets */
struct bpf_program active_filter_in;
struct bpf_program active_filter_out;
#endif
static option_t *curopt; /* pointer to option being processed */
@ -162,8 +174,10 @@ static int loadplugin __P((char **));
#endif
#ifdef PPP_FILTER
static int setpassfilter __P((char **));
static int setactivefilter __P((char **));
static int setpassfilter_in __P((char **));
static int setpassfilter_out __P((char **));
static int setactivefilter_in __P((char **));
static int setactivefilter_out __P((char **));
#endif
#ifdef MAXOCTETS
@ -319,11 +333,15 @@ option_t general_options[] = {
#endif
#ifdef PPP_FILTER
{ "pass-filter", o_special, setpassfilter,
"set filter for packets to pass", OPT_PRIO },
{ "pass-filter-in", o_special, setpassfilter_in,
"set filter for packets to pass inwards", OPT_PRIO },
{ "pass-filter-out", o_special, setpassfilter_out,
"set filter for packets to pass outwards", OPT_PRIO },
{ "active-filter", o_special, setactivefilter,
"set filter for active pkts", OPT_PRIO },
{ "active-filter-in", o_special, setactivefilter_in,
"set filter for active pkts inwards", OPT_PRIO },
{ "active-filter-out", o_special, setactivefilter_out,
"set filter for active pkts outwards", OPT_PRIO },
#endif
#ifdef MAXOCTETS
@ -346,7 +364,7 @@ option_t general_options[] = {
#define IMPLEMENTATION ""
#endif
static char *usage_string = "\
static const char *usage_string = "\
pppd version %s\n\
Usage: %s [ options ], where options are:\n\
<device> Communicate over the named device\n\
@ -357,6 +375,7 @@ Usage: %s [ options ], where options are:\n\
auth Require authentication from peer\n\
connect <p> Invoke shell command <p> to set up the serial line\n\
crtscts Use hardware RTS/CTS flow control\n\
cdtrcts Use hardware DTR/CTS flow control (if supported)\n\
defaultroute Add default route through interface\n\
file <f> Take options from file <f>\n\
modem Use modem control lines\n\
@ -590,18 +609,15 @@ err:
* match_option - see if this option matches an option_t structure.
*/
static int
match_option(name, opt, dowild)
char *name;
option_t *opt;
int dowild;
match_option(const char *name, option_t *opt, int dowild)
{
int (*match) __P((char *, char **, int));
int (*match) __P((const char *, char **, int));
if (dowild != (opt->type == o_wild))
return 0;
if (!dowild)
return strcmp(name, opt->name) == 0;
match = (int (*) __P((char *, char **, int))) opt->addr;
match = (int (*) __P((const char *, char **, int))) opt->addr;
return (*match)(name, NULL, 0);
}
@ -898,10 +914,7 @@ check_options()
* print_option - print out an option and its value
*/
static void
print_option(opt, mainopt, printer, arg)
option_t *opt, *mainopt;
printer_func printer;
void *arg;
print_option(option_t *opt, option_t *mainopt, printer_func printer, void *arg)
{
int i, v;
char *p;
@ -1000,10 +1013,7 @@ print_option(opt, mainopt, printer, arg)
* array of options.
*/
static void
print_option_list(opt, printer, arg)
option_t *opt;
printer_func printer;
void *arg;
print_option_list(option_t *opt, printer_func printer, void *arg)
{
while (opt->name != NULL) {
if (opt->priority != OPRIO_DEFAULT
@ -1249,12 +1259,12 @@ getword(f, word, newlinep, filename)
break;
default:
if (isoctal(c)) {
if (isoctal((unsigned char)c)) {
/*
* \ddd octal sequence
*/
value = 0;
for (n = 0; n < 3 && isoctal(c); ++n) {
for (n = 0; n < 3 && isoctal((unsigned char)c); ++n) {
value = (value << 3) + (c & 07);
c = getc(f);
}
@ -1268,8 +1278,8 @@ getword(f, word, newlinep, filename)
*/
value = 0;
c = getc(f);
for (n = 0; n < 2 && isxdigit(c); ++n) {
digit = toupper(c) - '0';
for (n = 0; n < 2 && isxdigit((unsigned char)c); ++n) {
digit = toupper((unsigned char)c) - '0';
if (digit > 10)
digit += '0' + 10 - 'A';
value = (value << 4) + digit;
@ -1472,18 +1482,18 @@ callfile(argv)
#ifdef PPP_FILTER
/*
* setpassfilter - Set the pass filter for packets
* setpassfilter_in - Set the pass filter for incoming packets
*/
static int
setpassfilter(argv)
setpassfilter_in(argv)
char **argv;
{
pcap_t *pc;
int ret = 1;
pc = pcap_open_dead(DLT_PPP_PPPD, 65535);
if (pcap_compile(pc, &pass_filter, *argv, 1, netmask) == -1) {
option_error("error in pass-filter expression: %s\n",
if (pcap_compile(pc, &pass_filter_in, *argv, 1, netmask) == -1) {
option_error("error in pass-filter-in expression: %s\n",
pcap_geterr(pc));
ret = 0;
}
@ -1493,17 +1503,59 @@ setpassfilter(argv)
}
/*
* setactivefilter - Set the active filter for packets
* setpassfilter_out - Set the pass filter for outgoing packets
*/
static int
setactivefilter(argv)
setpassfilter_out(argv)
char **argv;
{
pcap_t *pc;
int ret = 1;
pc = pcap_open_dead(DLT_PPP_PPPD, 65535);
if (pcap_compile(pc, &active_filter, *argv, 1, netmask) == -1) {
if (pcap_compile(pc, &pass_filter_out, *argv, 1, netmask) == -1) {
option_error("error in pass-filter-out expression: %s\n",
pcap_geterr(pc));
ret = 0;
}
pcap_close(pc);
return ret;
}
/*
* setactivefilter_in - Set the active filter for incoming packets
*/
static int
setactivefilter_in(argv)
char **argv;
{
pcap_t *pc;
int ret = 1;
pc = pcap_open_dead(DLT_PPP_PPPD, 65535);
if (pcap_compile(pc, &active_filter_in, *argv, 1, netmask) == -1) {
option_error("error in active-filter expression: %s\n",
pcap_geterr(pc));
ret = 0;
}
pcap_close(pc);
return ret;
}
/*
* setactivefilter_out - Set the active filter for outgoing packets
*/
static int
setactivefilter_out(argv)
char **argv;
{
pcap_t *pc;
int ret = 1;
pc = pcap_open_dead(DLT_PPP_PPPD, 65535);
if (pcap_compile(pc, &active_filter_out, *argv, 1, netmask) == -1) {
option_error("error in active-filter expression: %s\n",
pcap_geterr(pc));
ret = 0;

View File

@ -1,2 +1,4 @@
/* $NetBSD: patchlevel.h,v 1.2 2013/11/28 22:33:42 christos Exp $ */
#define VERSION "2.4.5"
#define DATE "17 November 2009"

View File

@ -1,3 +1,5 @@
/* $NetBSD: pathnames.h,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* define path names
*
@ -46,20 +48,15 @@
#endif /* IPX_CHANGE */
#ifdef __STDC__
#define _PATH_PPPDB _ROOT_PATH _PATH_VARRUN "pppd2.tdb"
#define _PATH_PPPDB _ROOT_PATH _PATH_VARRUN "pppd.tdb"
#else /* __STDC__ */
#ifdef HAVE_PATHS_H
#define _PATH_PPPDB "/var/run/pppd2.tdb"
#define _PATH_PPPDB "/var/run/pppd.tdb"
#else
#define _PATH_PPPDB "/etc/ppp/pppd2.tdb"
#define _PATH_PPPDB "/etc/ppp/pppd.tdb"
#endif
#endif /* __STDC__ */
#ifdef PLUGIN
#ifdef __STDC__
#define _PATH_PLUGIN DESTDIR "/lib/pppd/" VERSION
#else /* __STDC__ */
#define _PATH_PLUGIN "/usr/lib/pppd"
#endif /* __STDC__ */
#define _PATH_PLUGIN "/usr/libexec/pppd/"
#endif /* PLUGIN */

View File

@ -1,3 +1,5 @@
/* $NetBSD: pppcrypt.c,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* pppcrypt.c - PPP/DES linkage for MS-CHAP and EAP SRP-SHA1
*
@ -30,14 +32,17 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: pppcrypt.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include "pppd.h"
#include "pppcrypt.h"
static u_char
Get7Bits(input, startBit)
u_char *input;
int startBit;
Get7Bits(u_char *input, int startBit)
{
unsigned int word;
@ -50,9 +55,10 @@ int startBit;
}
static void
MakeKey(key, des_key)
u_char *key; /* IN 56 bit DES key missing parity bits */
u_char *des_key; /* OUT 64 bit DES key with parity bits added */
MakeKey(
u_char *key, /* IN 56 bit DES key missing parity bits */
u_char *des_key /* OUT 64 bit DES key with parity bits added */
)
{
des_key[0] = Get7Bits(key, 0);
des_key[1] = Get7Bits(key, 7);
@ -75,9 +81,7 @@ u_char *des_key; /* OUT 64 bit DES key with parity bits added */
* Note that the low-order "bit" is always ignored by by setkey()
*/
static void
Expand(in, out)
u_char *in;
u_char *out;
Expand(u_char *in, u_char *out)
{
int j, c;
int i;
@ -93,9 +97,7 @@ u_char *out;
/* The inverse of Expand
*/
static void
Collapse(in, out)
u_char *in;
u_char *out;
Collapse(u_char *in, u_char *out)
{
int j;
int i;

View File

@ -1,3 +1,5 @@
/* $NetBSD: pppcrypt.h,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* pppcrypt.c - PPP/DES linkage for MS-CHAP and EAP SRP-SHA1
*

View File

@ -1,3 +1,4 @@
.\" $NetBSD: pppd.8,v 1.2 2013/11/28 22:33:42 christos Exp $
.\" manual page [] for pppd 2.4
.\" Id: pppd.8,v 1.90 2008/03/26 12:09:40 paulus Exp
.\" SH section heading

View File

@ -1,3 +1,5 @@
/* $NetBSD: pppd.h,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* pppd.h - PPP daemon global declarations.
*
@ -84,8 +86,7 @@
/*
* Option descriptor structure.
*/
typedef unsigned char bool;
#include <stdbool.h>
enum opt_type {
o_special_noarg = 0,
@ -341,8 +342,13 @@ extern int maxoctets_timeout; /* Timeout for check of octets limit */
#endif
#ifdef PPP_FILTER
extern struct bpf_program pass_filter; /* Filter for pkts to pass */
extern struct bpf_program active_filter; /* Filter for link-active pkts */
/* Filter for packets to pass */
extern struct bpf_program pass_filter_in;
extern struct bpf_program pass_filter_out;
/* Filter for link-active packets */
extern struct bpf_program active_filter_in;
extern struct bpf_program active_filter_out;
#endif
#ifdef MSLANMAN
@ -679,7 +685,8 @@ void logwtmp __P((const char *, const char *, const char *));
int get_host_seed __P((void)); /* Get host-dependent random number seed */
int have_route_to __P((u_int32_t)); /* Check if route to addr exists */
#ifdef PPP_FILTER
int set_filters __P((struct bpf_program *pass, struct bpf_program *active));
int set_filters __P((struct bpf_program *, struct bpf_program *,
struct bpf_program *, struct bpf_program *));
/* Set filter programs in kernel */
#endif
#ifdef IPX_CHANGE

View File

@ -1,3 +1,5 @@
/* $NetBSD: session.c,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* session.c - PPP session control.
*
@ -68,16 +70,25 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: session.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pwd.h>
#include <crypt.h>
#ifdef HAS_SHADOW
#include <shadow.h>
#endif
#include <time.h>
#ifdef SUPPORT_UTMP
#include <utmp.h>
#endif
#ifdef SUPPORT_UTMPX
#include <utmpx.h>
#endif
#include <util.h>
#include <fcntl.h>
#include <unistd.h>
#include "pppd.h"
@ -365,7 +376,13 @@ session_start(flags, user, passwd, ttyName, msg)
if (SESS_ACCT & flags) {
if (strncmp(ttyName, "/dev/", 5) == 0)
ttyName += 5;
logwtmp(ttyName, user, ifname); /* Add wtmp login entry */
#ifdef SUPPORT_UTMP
logwtmp(ttyName, user, ifname); /* Add wtmp login entry */
#endif
#ifdef SUPPORT_UTMPX
logwtmpx(ttyName, user, ifname, 0, USER_PROCESS); /* Add wtmpx login entry */
#endif
logged_in = 1;
#if defined(_PATH_LASTLOG) && !defined(USE_PAM)
@ -418,7 +435,12 @@ session_end(const char* ttyName)
if (logged_in) {
if (strncmp(ttyName, "/dev/", 5) == 0)
ttyName += 5;
#ifdef SUPPORT_UTMP
logwtmp(ttyName, "", ""); /* Wipe out utmp logout entry */
#endif
#ifdef SUPPORT_UTMPX
logwtmpx(ttyName, "", "", 0, DEAD_PROCESS); /* Wipe out utmpx logout entry */
#endif
logged_in = 0;
}
}

View File

@ -1,3 +1,5 @@
/* $NetBSD: session.h,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* session.c - PPP session control.
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: tty.c,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* tty.c - code for handling serial ports in pppd.
*
@ -68,7 +70,13 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/cdefs.h>
#if 0
#define RCSID "Id: tty.c,v 1.27 2008/07/01 12:27:56 paulus Exp "
static const char rcsid[] = RCSID;
#else
__RCSID("$NetBSD: tty.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
#endif
#include <stdio.h>
#include <ctype.h>

View File

@ -1,3 +1,5 @@
/* $NetBSD: upap.c,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* upap.c - User/Password Authentication Protocol.
*
@ -40,7 +42,13 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/cdefs.h>
#if 0
#define RCSID "Id: upap.c,v 1.30 2005/07/13 10:41:58 paulus Exp "
static const char rcsid[] = RCSID;
#else
__RCSID("$NetBSD: upap.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
#endif
/*
* TODO:
@ -52,7 +60,6 @@
#include "pppd.h"
#include "upap.h"
static const char rcsid[] = RCSID;
static bool hide_password = 1;

View File

@ -1,3 +1,5 @@
/* $NetBSD: upap.h,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* upap.h - User/Password Authentication Protocol definitions.
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: utils.c,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* utils.c - various utility functions used in pppd.
*
@ -28,7 +30,13 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/cdefs.h>
#if 0
#define RCSID "Id: utils.c,v 1.25 2008/06/03 12:06:37 paulus Exp "
static const char rcsid[] = RCSID;
#else
__RCSID("$NetBSD: utils.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
#endif
#include <stdio.h>
#include <ctype.h>
@ -59,7 +67,6 @@
#include "fsm.h"
#include "lcp.h"
static const char rcsid[] = RCSID;
#if defined(SUNOS4)
extern char *strerror();
@ -75,45 +82,6 @@ struct buffer_info {
int len;
};
/*
* strlcpy - like strcpy/strncpy, doesn't overflow destination buffer,
* always leaves destination null-terminated (for len > 0).
*/
size_t
strlcpy(dest, src, len)
char *dest;
const char *src;
size_t len;
{
size_t ret = strlen(src);
if (len != 0) {
if (ret < len)
strcpy(dest, src);
else {
strncpy(dest, src, len - 1);
dest[len-1] = 0;
}
}
return ret;
}
/*
* strlcat - like strcat/strncat, doesn't overflow destination buffer,
* always leaves destination null-terminated (for len > 0).
*/
size_t
strlcat(dest, src, len)
char *dest;
const char *src;
size_t len;
{
size_t dlen = strlen(dest);
return dlen + strlcpy(dest + dlen, src, (len > dlen? len - dlen: 0));
}
/*
* slprintf - format a message into a buffer. Like sprintf except we
* also specify the length of the output buffer, and we handle
@ -289,8 +257,12 @@ vslprintf(buf, buflen, fmt, args)
case 't':
time(&t);
str = ctime(&t);
str += 4; /* chop off the day name */
str[15] = 0; /* chop off year and newline */
if ((str = ctime(&t)) == NULL)
strlcpy(str = num, "?", sizeof(num));
else {
str += 4; /* chop off the day name */
str[15] = 0; /* chop off year and newline */
}
break;
case 'v': /* "visible" string */
case 'q': /* quoted string */

View File

@ -1 +0,0 @@
pppdump

View File

@ -1,3 +1,5 @@
/* $NetBSD: bsd-comp.c,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/* Because this code is derived from the 4.3BSD compress source:
*
*
@ -37,8 +39,11 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: bsd-comp.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
/*
* Id: bsd-comp.c,v 1.4 2004/01/17 05:47:55 carlsonj Exp
* Id: bsd-comp.c,v 1.4 2004/01/17 05:47:55 carlsonj Exp
*/
#include <sys/types.h>
@ -46,6 +51,7 @@
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include "pppdump.h"
#include "ppp_defs.h"
#include "ppp-comp.h"
@ -128,9 +134,8 @@ static void *bsd_decomp_alloc __P((u_char *options, int opt_len));
static void bsd_free __P((void *state));
static int bsd_decomp_init __P((void *state, u_char *options, int opt_len,
int unit, int hdrlen, int mru, int debug));
static void bsd_incomp __P((void *state, u_char *dmsg, int len));
static int bsd_decompress __P((void *state, u_char *cmp, int inlen,
u_char *dmp, int *outlen));
static void bsd_incomp __P((void *state, PACKETPTR in));
static int bsd_decompress __P((void *state, PACKETPTR in, PACKETPTR *out));
static void bsd_reset __P((void *state));
static void bsd_comp_stats __P((void *state, struct compstat *stats));
@ -139,6 +144,12 @@ static void bsd_comp_stats __P((void *state, struct compstat *stats));
*/
struct compressor ppp_bsd_compress = {
CI_BSD_COMPRESS, /* compress_proto */
NULL, /* comp_alloc */
NULL, /* comp_free */
NULL, /* comp_init */
NULL, /* comp_reset */
NULL, /* comp_compress */
NULL, /* comp_stat */
bsd_decomp_alloc, /* decomp_alloc */
bsd_free, /* decomp_free */
bsd_decomp_init, /* decomp_init */
@ -170,6 +181,12 @@ struct compressor ppp_bsd_compress = {
#define RATIO_SCALE (1<<RATIO_SCALE_LOG)
#define RATIO_MAX (0x7fffffff>>RATIO_SCALE_LOG)
static void bsd_clear __P((struct bsd_db *));
static int bsd_check __P((struct bsd_db *));
static void *bsd_alloc __P((u_char *, int, int));
static int bsd_init __P((struct bsd_db *, u_char *, int, int, int, int,
int, int));
/*
* clear the dictionary
*/
@ -424,10 +441,9 @@ bsd_decomp_init(state, options, opt_len, unit, hdrlen, mru, debug)
* incompressible data by pretending to compress the incoming data.
*/
static void
bsd_incomp(state, dmsg, mlen)
bsd_incomp(state, in)
void *state;
u_char *dmsg;
int mlen;
PACKETPTR in;
{
struct bsd_db *db = (struct bsd_db *) state;
u_int hshift = db->hshift;
@ -442,11 +458,11 @@ bsd_incomp(state, dmsg, mlen)
u_char *rptr;
u_int ent;
rptr = dmsg;
rptr = in->buf;
ent = rptr[0]; /* get the protocol */
if (ent == 0) {
++rptr;
--mlen;
in->len--;
ent = rptr[0];
}
if ((ent & 1) == 0 || ent < 0x21 || ent > 0xf9)
@ -455,7 +471,7 @@ bsd_incomp(state, dmsg, mlen)
db->seqno++;
ilen = 1; /* count the protocol as 1 byte */
++rptr;
slen = dmsg + mlen - rptr;
slen = in->buf + in->len - rptr;
ilen += slen;
for (; slen > 0; --slen) {
c = *rptr++;
@ -544,10 +560,10 @@ bsd_incomp(state, dmsg, mlen)
* compression, even though they are detected by inspecting the input.
*/
static int
bsd_decompress(state, cmsg, inlen, dmp, outlenp)
bsd_decompress(state, in, out)
void *state;
u_char *cmsg, *dmp;
int inlen, *outlenp;
PACKETPTR in;
PACKETPTR *out;
{
struct bsd_db *db = (struct bsd_db *) state;
u_int max_ent = db->max_ent;
@ -562,13 +578,13 @@ bsd_decompress(state, cmsg, inlen, dmp, outlenp)
int ilen;
int codelen, extra;
rptr = cmsg;
rptr = in->buf;
if (*rptr == 0)
++rptr;
++rptr; /* skip protocol (assumed 0xfd) */
seq = (rptr[0] << 8) + rptr[1];
rptr += BSD_OVHD;
ilen = len = cmsg + inlen - rptr;
ilen = len = in->buf + in->len - rptr;
/*
* Check the sequence number and give up if it is not what we expect.
@ -580,7 +596,7 @@ bsd_decompress(state, cmsg, inlen, dmp, outlenp)
return DECOMP_ERROR;
}
wptr = dmp + db->hdrlen;
wptr = (*out)->buf + db->hdrlen;
oldcode = CLEAR;
explen = 0;
@ -729,7 +745,7 @@ bsd_decompress(state, cmsg, inlen, dmp, outlenp)
}
oldcode = incode;
}
*outlenp = wptr - (dmp + db->hdrlen);
(*out)->len = wptr - ((*out)->buf + db->hdrlen);
/*
* Keep the checkpoint right so that incompressible packets

View File

@ -1,3 +1,5 @@
/* $NetBSD: deflate.c,v 1.2 2013/11/28 22:33:42 christos Exp $ */
/*
* ppp_deflate.c - interface the zlib procedures for Deflate compression
* and decompression (as used by gzip) to the PPP code.
@ -33,17 +35,20 @@
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Id: deflate.c,v 1.5 2004/01/17 05:47:55 carlsonj Exp
* Id: deflate.c,v 1.5 2004/01/17 05:47:55 carlsonj Exp
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: deflate.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
#include <sys/types.h>
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include "ppp_defs.h"
#include "ppp-comp.h"
#include "zlib.h"
#include "pppdump.h"
#include <net/ppp_defs.h>
#include <net/ppp-comp.h>
#include <zlib.h>
#if DO_DEFLATE
@ -71,9 +76,8 @@ static void *z_decomp_alloc __P((u_char *options, int opt_len));
static void z_decomp_free __P((void *state));
static int z_decomp_init __P((void *state, u_char *options, int opt_len,
int unit, int hdrlen, int mru, int debug));
static void z_incomp __P((void *state, u_char *dmsg, int len));
static int z_decompress __P((void *state, u_char *cmp, int inlen,
u_char *dmp, int *outlenp));
static void z_incomp __P((void *state, PACKETPTR mi));
static int z_decompress __P((void *state, PACKETPTR mi, PACKETPTR *mo));
static void z_decomp_reset __P((void *state));
static void z_comp_stats __P((void *state, struct compstat *stats));
@ -82,6 +86,12 @@ static void z_comp_stats __P((void *state, struct compstat *stats));
*/
struct compressor ppp_deflate = {
CI_DEFLATE, /* compress_proto */
NULL, /* comp_alloc */
NULL, /* comp_free */
NULL, /* comp_init */
NULL, /* comp_reset */
NULL, /* comp_compress */
NULL, /* comp_stat */
z_decomp_alloc, /* decomp_alloc */
z_decomp_free, /* decomp_free */
z_decomp_init, /* decomp_init */
@ -230,17 +240,17 @@ z_decomp_reset(arg)
* compression, even though they are detected by inspecting the input.
*/
static int
z_decompress(arg, mi, inlen, mo, outlenp)
z_decompress(arg, mi, mo)
void *arg;
u_char *mi, *mo;
int inlen, *outlenp;
PACKETPTR mi;
PACKETPTR *mo;
{
struct deflate_state *state = (struct deflate_state *) arg;
u_char *rptr, *wptr;
int rlen, olen;
int seq, r;
rptr = mi;
rptr = mi->buf;
if (*rptr == 0)
++rptr;
++rptr;
@ -261,9 +271,9 @@ z_decompress(arg, mi, inlen, mo, outlenp)
/*
* Set up to call inflate.
*/
wptr = mo;
wptr = (*mo)->buf;
state->strm.next_in = rptr;
state->strm.avail_in = mi + inlen - rptr;
state->strm.avail_in = mi->buf + mi->len - rptr;
rlen = state->strm.avail_in + PPP_HDRLEN + DEFLATE_OVHD;
state->strm.next_out = wptr;
state->strm.avail_out = state->mru + 2;
@ -278,7 +288,7 @@ z_decompress(arg, mi, inlen, mo, outlenp)
return DECOMP_FATALERROR;
}
olen = state->mru + 2 - state->strm.avail_out;
*outlenp = olen;
(*mo)->len = olen;
if ((wptr[0] & 1) != 0)
++olen; /* for suppressed protocol high byte */
@ -302,10 +312,9 @@ z_decompress(arg, mi, inlen, mo, outlenp)
* Incompressible data has arrived - add it to the history.
*/
static void
z_incomp(arg, mi, mlen)
z_incomp(arg, mi)
void *arg;
u_char *mi;
int mlen;
PACKETPTR mi;
{
struct deflate_state *state = (struct deflate_state *) arg;
u_char *rptr;
@ -314,7 +323,7 @@ z_incomp(arg, mi, mlen)
/*
* Check that the protocol is one we handle.
*/
rptr = mi;
rptr = mi->buf;
proto = rptr[0];
if ((proto & 1) == 0)
proto = (proto << 8) + rptr[1];
@ -325,7 +334,7 @@ z_incomp(arg, mi, mlen)
if (rptr[0] == 0)
++rptr;
rlen = mi + mlen - rptr;
rlen = mi->buf + mi->len - rptr;
state->strm.next_in = rptr;
state->strm.avail_in = rlen;
r = inflateIncomp(&state->strm);

View File

@ -38,6 +38,7 @@
#include <stdlib.h>
#include <time.h>
#include <sys/types.h>
#include "pppdump.h"
#include "ppp_defs.h"
#include "ppp-comp.h"
@ -51,18 +52,14 @@ time_t start_time;
int start_time_tenths;
int tot_sent, tot_rcvd;
extern int optind;
extern char *optarg;
void dumplog();
void dumpppp();
void show_time();
void handle_ccp();
void dumplog(FILE *);
void dumpppp(FILE *);
void show_time(FILE *, int);
struct pkt;
void handle_ccp(struct pkt *, u_char *, int);
int
main(ac, av)
int ac;
char **av;
main(int ac, char **av)
{
int i;
char *p;
@ -113,8 +110,7 @@ main(ac, av)
}
void
dumplog(f)
FILE *f;
dumplog(FILE *f)
{
int c, n, k, col;
int nb, c2;
@ -253,8 +249,7 @@ struct pkt {
unsigned char dbuf[8192];
void
dumpppp(f)
FILE *f;
dumpppp(FILE *f)
{
int c, n, k;
int nb, nl, dn, proto, rv;
@ -320,7 +315,7 @@ dumpppp(f)
++r;
++r;
if (endp - r > mru)
printf(" ERROR: length (%d) > MRU (%d)\n",
printf(" ERROR: length (%td) > MRU (%d)\n",
endp - r, mru);
if (decompress && fcs == PPP_GOODFCS) {
/* See if this is a CCP or compressed packet */
@ -340,8 +335,15 @@ dumpppp(f)
&& (pkt->flags & CCP_DECOMP_RUN)
&& pkt->state
&& (pkt->flags & CCP_ERR) == 0) {
rv = pkt->comp->decompress(pkt->state, r,
endp - r, d, &dn);
struct packet in, out, *outp;
in.buf = r;
in.len = endp - r;
out.buf = d;
outp = &out;
rv = pkt->comp->decompress(pkt->state, &in,
&outp);
dn = outp->len;
d = outp->buf;
switch (rv) {
case DECOMP_OK:
p = dbuf;
@ -364,7 +366,10 @@ dumpppp(f)
}
} else if (pkt->state
&& (pkt->flags & CCP_DECOMP_RUN)) {
pkt->comp->incomp(pkt->state, r, endp - r);
struct packet in;
in.buf = r;
in.len = endp - r;
pkt->comp->incomp(pkt->state, &in);
}
}
do {
@ -439,10 +444,7 @@ struct compressor *compressors[] = {
};
void
handle_ccp(cp, dp, len)
struct pkt *cp;
u_char *dp;
int len;
handle_ccp(struct pkt *cp, u_char *dp, int len)
{
int clen;
struct compressor **comp;
@ -496,9 +498,7 @@ handle_ccp(cp, dp, len)
}
void
show_time(f, c)
FILE *f;
int c;
show_time(FILE *f, int c)
{
time_t t;
int n;

View File

@ -1 +0,0 @@
pppstats

View File

@ -1,3 +1,5 @@
/* $NetBSD: pppstats.c,v 1.2 2013/11/28 22:33:43 christos Exp $ */
/*
* print PPP statistics:
* pppstats [-a|-d] [-v|-r|-z] [-c count] [-w wait] [interface]
@ -35,9 +37,14 @@
#define const
#endif
#include <sys/cdefs.h>
#if 0
#ifndef lint
static const char rcsid[] = "Id: pppstats.c,v 1.29 2002/10/27 12:56:26 fcusack Exp ";
#endif
#else
__RCSID("$NetBSD: pppstats.c,v 1.2 2013/11/28 22:33:43 christos Exp $");
#endif
#include <stdio.h>
#include <stddef.h>
@ -93,6 +100,7 @@ int s; /* socket or /dev/ppp file descriptor */
int signalled; /* set if alarm goes off "early" */
char *progname;
char *interface;
char *fmt;
#if defined(SUNOS4) || defined(ULTRIX) || defined(NeXT)
extern int optind;
@ -106,6 +114,9 @@ extern char *optarg;
#if !defined(PPP_DRV_NAME)
#define PPP_DRV_NAME "ppp"
#endif /* !defined(PPP_DRV_NAME) */
#if !defined(SL_DRV_NAME)
#define SL_DRV_NAME "sl"
#endif /* !defined(SL_DRV_NAME) */
static void usage __P((void));
static void catchalarm __P((int));
@ -295,9 +306,11 @@ intpr()
struct ppp_stats cur, old;
struct ppp_comp_stats ccs, ocs;
memset(&ccs, 0, sizeof(ccs));
memset(&old, 0, sizeof(old));
memset(&ocs, 0, sizeof(ocs));
interface = PPP_DRV_NAME "0";
while (1) {
get_ppp_stats(&cur);
if (zflag || rflag)
@ -458,6 +471,13 @@ main(argc, argv)
else
++progname;
if (strncmp(progname, SL_DRV_NAME, sizeof(SL_DRV_NAME) - 1) == 0) {
interface = SL_DRV_NAME "0";
fmt = SL_DRV_NAME "%d";
} else {
interface = PPP_DRV_NAME "0";
fmt = PPP_DRV_NAME "%d";
}
while ((c = getopt(argc, argv, "advrzc:w:")) != -1) {
switch (c) {
case 'a':
@ -506,7 +526,7 @@ main(argc, argv)
if (argc > 0)
interface = argv[0];
if (sscanf(interface, PPP_DRV_NAME "%d", &unit) != 1) {
if (sscanf(interface, fmt, &unit) != 1) {
fprintf(stderr, "%s: invalid interface '%s' specified\n",
progname, interface);
}

70
external/bsd/ppp/ppp2netbsd vendored Executable file
View File

@ -0,0 +1,70 @@
#!/bin/sh
#
# NetBSD: ppp2netbsd,v 1.4 2008/04/30 13:10:47 martin Exp
#
# Copyright (c) 2005 The NetBSD Foundation.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Execute this at the top of the ppp distribution
# then import it.
#
# cvs import src/external/bsd/ppp/dist MACKERRAS PPP2_4_X
# Stuff we don't need
UNUSED_DIRS="common contrib etc.ppp include linux modules solaris scripts"
UNUSED_DIRS="${UNUSED_DIRS} .git"
UNUSED_FILES="Changes-2.3 README.linux README.pppoe README.sol2 configure"
UNUSED_FILES="${UNUSED_FILES} pppd/md[45].* pppd/sha1.* pppd/srp-entry.*"
UNUSED_FILES="${UNUSED_FILES} pppd/sys-linux.c pppd/sys-solaris.c"
UNUSED_FILES="${UNUSED_FILES} pppdump/zlib.* pppdump/ppp-comp.h .gitignore"
UNUSED_FILES="${UNUSED_FILES} pppdump/.gitignore pppdump/bsd-comp.c"
# Stuff we don't want
GPL_DIRS="pppd/plugins/pppoatm pppd/plugins/radius pppd/plugins/rp-pppoe"
GPL_FILES="pppd/tdb.* pppd/spinlock.* pppd/plugins/passprompt.c
pppd/plugins/winbind.c"
if [ -z "$1" ]
then
echo "Usage: $0 <dir>" 1>&2
exit 1
fi
cd $1
echo -n "Removing unwanted stuf... "
for obj in ${UNUSED_DIRS} ${GPL_DIRS} ${UNUSED_FILES} ${GPL_FILES}; do
rm -Rf ${obj}
echo -n "${obj} "
done
echo; echo
# Remove Makefiles
echo -n "Removing Makefiles... "
find . -type f -name 'Makefile*' | while read m; do
rm -f ${m}
echo -n "${m} "
done
echo; echo
cleantags .

5
external/bsd/ppp/usr.sbin/Makefile vendored Normal file
View File

@ -0,0 +1,5 @@
# $NetBSD: Makefile,v 1.1 2013/11/28 22:33:43 christos Exp $
SUBDIR= chat pppd pppdump pppstats
.include <bsd.subdir.mk>

13
external/bsd/ppp/usr.sbin/Makefile.inc vendored Normal file
View File

@ -0,0 +1,13 @@
# $NetBSD: Makefile.inc,v 1.1 2013/11/28 22:33:43 christos Exp $
WARNS?= 1 # XXX -Wshadow -Wcast-qual -Wsign-compare
USE_FORT?=yes # network client/server
.include <bsd.own.mk>
DIST=${NETBSDSRCDIR}/external/bsd/ppp/dist
BINDIR=/usr/sbin
.if defined(HAVE_GCC) || defined(HAVE_LLVM)
COPTS+= -fno-strict-aliasing
.endif

10
external/bsd/ppp/usr.sbin/chat/Makefile vendored Normal file
View File

@ -0,0 +1,10 @@
# $NetBSD: Makefile,v 1.1 2013/11/28 22:33:43 christos Exp $
.include "../Makefile.inc"
.PATH: ${DIST}/chat
PROG= chat
MAN= chat.8
.include <bsd.prog.mk>

View File

@ -0,0 +1,16 @@
# $NetBSD: Makefile,v 1.1 2013/11/28 22:33:43 christos Exp $
NOLINT= # defined
.include <bsd.own.mk>
.PATH: ${NETBSDSRCDIR}/dist/pppd/pppd/plugins
LIB=minconn
SRCS=minconn.c
CPPFLAGS+=-I${NETBSDSRCDIR}/dist/pppd/pppd
LIBPREFIX=
SHLIB_FULLVERSION=
.include <bsd.lib.mk>

View File

@ -0,0 +1,16 @@
# $NetBSD: Makefile,v 1.1 2013/11/28 22:33:43 christos Exp $
NOLINT= # defined
.include <bsd.own.mk>
.PATH: ${NETBSDSRCDIR}/dist/pppd/pppd/plugins
LIB=passwordfd
SRCS=passwordfd.c
CPPFLAGS+=-I${NETBSDSRCDIR}/dist/pppd/pppd
LIBPREFIX=
SHLIB_FULLVERSION=
.include <bsd.lib.mk>

View File

@ -0,0 +1,14 @@
# $NetBSD: Makefile,v 1.1 2013/11/28 22:33:43 christos Exp $
NOLINT= # defined
.include <bsd.own.mk>
LIB=status
SRCS=status.c
CPPFLAGS+=-I${NETBSDSRCDIR}/dist/pppd/pppd
LIBPREFIX=
SHLIB_FULLVERSION=
.include <bsd.lib.mk>

View File

@ -0,0 +1,146 @@
/* NetBSD: status.c,v 1.3 2008/05/04 13:30:54 martin Exp */
/*
* status.c - pppd plugin to implement an `lcpstatus' option.
* This is intended as more of an example than perfected feature,
* but this code has been in use on my local network for a year and
* is quite useful as is (with a bit of external help, at any rate).
*
* Written January 2003 by John F. Woods, jfw@funhouse.com
*/
/*
* Copyright (c) 2004 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by John F. Woods, jfw@funhouse.com.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <stddef.h>
#include <time.h>
#include <stdio.h>
#include "pppd.h"
/* this version string will be checked against pppd's version string when
* this plugin is loaded.
*/
char pppd_version[] = VERSION;
/*
* Usage: to use this status plug as-is, add the lines:
plugin status
lcpstatus /var/run/ppp0.status
* to your PPP options file (or add the appropriate options to your
* pppd command line), where /var/run/ppp0.status can vary to taste.
* This plugin will then proceed to create the lcp status file and
* write one of four strings to the file based on the most recent LCP
* event: "up", "down", "?", or "!", representing LCP up, LCP down,
* LCP echo not received, and received-our-own-LCP-echo (probably
* indicating a loopback or a disconnected modem echoing back characters).
* On my system, I have a separate program which reads that file every
* second and sends a UDP broadcast packet on my ethernet with the contents
* of the file; each of the other computers on my ethernet (all Macs) have
* a tiny little program which listens for that UDP broadcast packet and
* updates a menubar status indicator; the end result is that when PPP
* shuts down, users on my LAN immediately know without having to go look
* at the modem. (Or without demanding that *I* go look at the modem...)
*
* If you want to modify this plugin, other ways you could use and display
* the data generated by the transitions would include:
* + directly broadcasting the results from inside the pppd task (rather
* than having a separate process do it)
* + store the ppp state in an SNMP database so it could be displayed with
* a standard form of client rather than a goofy little Mac OS X menubar
* widget.
*/
static char *statusfilename = 0;
static char *laststatus = 0;
static char UP[] = "up";
static char DOWN[] = "down";
static char MISS[] = "?";
static char MINE[] = "!";
static option_t status_options[] = {
{ "lcpstatus", o_string, &statusfilename,
"Name of file to which LCP status string will be written" },
{ NULL }
};
/* status should be one of the canned constants above. */
static void writestatus(char *status)
{
FILE *statusfile;
if (status == laststatus) return; /* we knew that already */
statusfile = fopen(statusfilename, "w");
if (!statusfile) {
warn("can't write %s to log LCP status", statusfilename);
free(statusfilename);
statusfilename = 0;
return;
}
fprintf(statusfile, "%s\n", status);
fclose(statusfile);
laststatus = status;
}
static void status_lcp_up(void)
{
if (!statusfilename) return; /* not enabled */
writestatus(UP);
}
static void status_lcp_down(void)
{
if (!statusfilename) return; /* not enabled */
writestatus(DOWN);
}
static void status_lcp_echo(int pending)
{
if (!statusfilename) return; /* not enabled */
if (pending == 0)
writestatus(UP);
else if (laststatus != MINE)
writestatus(MISS);
}
static void status_lcp_echoreply(int mine)
{
if (!statusfilename) return; /* not enabled */
if (mine == 0)
writestatus(UP);
else
writestatus(MINE);
}
void plugin_init(void)
{
info("Initialize PPP status plugin.");
add_options(status_options);
lcp_up_hook = status_lcp_up;
lcp_down_hook = status_lcp_down;
lcp_echo_hook = status_lcp_echo;
lcp_echoreply_hook = status_lcp_echoreply;
}

42
external/bsd/ppp/usr.sbin/pppd/Makefile vendored Normal file
View File

@ -0,0 +1,42 @@
# $NetBSD: Makefile,v 1.1 2013/11/28 22:33:43 christos Exp $
.include "../Makefile.inc"
PROG= pppd
SRCS= auth.c cbcp.c ccp.c chap-md5.c chap-new.c chap_ms.c demand.c eap.c \
ecp.c fsm.c ipcp.c ipxcp.c lcp.c magic.c main.c multilink.c \
options.c pppcrypt.c session.c sys-bsd.c tdb.c tty.c upap.c utils.c
PPPDDIR= ${DIST}/pppd
.PATH: ${PPPDDIR}
MAN= pppd.8
BINMODE=4555
BINOWN= root
CPPFLAGS+= -I${.CURDIR} -DHAVE_PATHS_H -DSUPPORT_UTMP -DSUPPORT_UTMPX -DPLUGIN
CPPFLAGS+= -I${PPPDDIR} -DPPP_FILTER
CPPFLAGS+= -DCBCP_SUPPORT -DUSE_CRYPT -DCHAPMS -DMSLANMAN -DMPPE
CPPFLAGS+= -DHAVE_MULTILINK -DUSE_TDB
.if (!defined(SMALLPROG) || defined(SMALLPROG_INET6)) && (${USE_INET6} != "no")
CPPFLAGS+= -DINET6
SRCS+= eui64.c ipv6cp.c
.endif
.if (!defined(SMALLPROG)) && (${USE_PAM} != "no")
CPPFLAGS+= -DUSE_PAM
LDADD+=-lpam ${PAM_STATIC_LDADD}
DPADD+=${LIBPAM} ${PAM_STATIC_DPADD}
.endif
LDADD+= -lpcap -lcrypt -lutil -Wl,--export-dynamic
DPADD+= ${LIBPCAP} ${LIBCRYPT} ${LIBUTIL}
.for f in chap-md5 chap_ms eap
COPTS.${f}.c+= -Wno-pointer-sign
.endfor
CWARNFLAGS.clang+= -Wno-tautological-compare
.include <bsd.prog.mk>

2071
external/bsd/ppp/usr.sbin/pppd/sys-bsd.c vendored Normal file

File diff suppressed because it is too large Load Diff

1293
external/bsd/ppp/usr.sbin/pppd/tdb.c vendored Normal file

File diff suppressed because it is too large Load Diff

79
external/bsd/ppp/usr.sbin/pppd/tdb.h vendored Normal file
View File

@ -0,0 +1,79 @@
#define STANDALONE 1
/*
* Database functions
* Copyright (C) Andrew Tridgell 1999
*
* 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 provided that this software or
* any derived work is only used as part of the PPP daemon (pppd)
* and related utilities.
* The name of the author 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.
*
* Note: this software is also available under the Gnu Public License
* version 2 or later.
*/
typedef unsigned tdb_len;
typedef unsigned tdb_off;
#define TDB_MAGIC_FOOD "TDB file\n"
/* this is stored at the front of every database */
struct tdb_header {
char magic_food[32]; /* for /etc/magic */
unsigned version; /* version of the code */
unsigned hash_size; /* number of hash entries */
};
typedef struct {
char *dptr;
size_t dsize;
} TDB_DATA;
/* this is the context structure that is returned from a db open */
typedef struct {
char *name; /* the name of the database */
void *map_ptr; /* where it is currently mapped */
int fd; /* open file descriptor for the database */
tdb_len map_size; /* how much space has been mapped */
int read_only; /* opened read-only */
int *locked; /* set if we have a chain locked */
int ecode; /* error code for last tdb error */
struct tdb_header header; /* a cached copy of the header */
} TDB_CONTEXT;
/* flags to tdb_store() */
#define TDB_REPLACE 1
#define TDB_INSERT 2
/* flags for tdb_open() */
#define TDB_CLEAR_IF_FIRST 1
/* error codes */
enum TDB_ERROR {TDB_SUCCESS=0, TDB_ERR_CORRUPT, TDB_ERR_IO, TDB_ERR_LOCK,
TDB_ERR_OOM, TDB_ERR_EXISTS};
#if STANDALONE
TDB_CONTEXT *tdb_open(char *name, int hash_size, int tdb_flags,
int open_flags, mode_t mode);
char *tdb_errorstr(TDB_CONTEXT *tdb);
int tdb_writelock(TDB_CONTEXT *tdb);
int tdb_writeunlock(TDB_CONTEXT *tdb);
TDB_DATA tdb_fetch(TDB_CONTEXT *tdb, TDB_DATA key);
int tdb_delete(TDB_CONTEXT *tdb, TDB_DATA key);
int tdb_store(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, int flag);
int tdb_close(TDB_CONTEXT *tdb);
TDB_DATA tdb_firstkey(TDB_CONTEXT *tdb);
TDB_DATA tdb_nextkey(TDB_CONTEXT *tdb, TDB_DATA key);
int tdb_traverse(TDB_CONTEXT *tdb,
int (*fn)(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, void *state),
void *state);
int tdb_exists(TDB_CONTEXT *tdb, TDB_DATA key);
int tdb_chainlock(TDB_CONTEXT *tdb, TDB_DATA key);
int tdb_chainunlock(TDB_CONTEXT *tdb, TDB_DATA key);
#endif

View File

@ -0,0 +1,14 @@
# $NetBSD: Makefile,v 1.1 2013/11/28 22:33:43 christos Exp $
.include "../Makefile.inc"
.PATH: ${DIST}/pppdump ${NETBSDSRCDIR}/sys/net
PROG= pppdump
SRCS= pppdump.c deflate.c bsd-comp.c zlib.c
MAN= pppdump.8
CPPFLAGS+= -I${NETBSDSRCDIR}/sys/net -I${.CURDIR}
CPPFLAGS+= -DDO_BSD_COMPRESS -DDO_DEFLATE
.include <bsd.prog.mk>

View File

@ -0,0 +1,37 @@
/* $NetBSD: pppdump.h,v 1.1 2013/11/28 22:33:43 christos Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Christos Zoulas.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
struct packet {
u_char *buf;
int len;
};
#define PACKETPTR struct packet *

View File

@ -0,0 +1,12 @@
# $NetBSD: Makefile,v 1.1 2013/11/28 22:33:43 christos Exp $
.include "../Makefile.inc"
.PATH: ${DIST}/pppstats
PROG= pppstats
MAN= pppstats.8
LINKS= ${BINDIR}/pppstats ${BINDIR}/slstats
MLINKS= pppstats.8 slstats.8
.include <bsd.prog.mk>