History log of /freebsd-current/usr.sbin/ppp/main.c
Revision Date Author Comments
# b3e76948 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: two-line .h pattern

Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# 672eba24 24-Apr-2023 John Baldwin <jhb@FreeBSD.org>

ppp: Use valid prototypes for function declarations with no arguments.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D39730


# 1de7b4b8 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

various: general adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.


# f2f5156f 07-Feb-2011 Brian Somers <brian@FreeBSD.org>

Add "iface name" and "iface description" commands.

PR: 151400
Submitted by: Aragon Gouveia - aragon at phat dot za dot net with minor fixes
MFC after: 3 weeks


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# 61a651a4 27-Aug-2009 Brian Somers <brian@FreeBSD.org>

MFC: When ``ppp -direct'' is invoked by a program that uses pipe(2) to
create stdin and stdout, don't blindly try to use stdin as a bi-directional
channel. Instead, detect the pipe and set up a special exec handler
that indirects write() calls through stdout.

This fixes the problem where ``set device "!ssh -e none host ppp
-direct label"'' no longer works with an openssh-5.2 server side as
that version of openssh ignores the USE_PIPES config setting and
*always* uses pipes (rather than socketpair) for stdin/stdout channels.

Approved by: re (kib)


# 887ff31f 24-Aug-2009 Brian Somers <brian@FreeBSD.org>

When ``ppp -direct'' is invoked by a program that uses pipe(2) to
create stdin and stdout, don't blindly try to use stdin as a bi-directional
channel. Instead, detect the pipe and set up a special exec handler
that indirects write() calls through stdout.

This fixes the problem where ``set device "!ssh -e none host ppp
-direct label"'' no longer works with an openssh-5.2 server side as
that version of openssh ignores the USE_PIPES config setting and
*always* uses pipes (rather than socketpair) for stdin/stdout channels.

MFC after: 3 days


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# a5625ae7 12-Mar-2008 Paolo Pisati <piso@FreeBSD.org>

Update to the "new" libalias API (and thus fix world breakage).


# 564299ef 21-Dec-2004 Ruslan Ermilov <ru@FreeBSD.org>

The C define is NONAT.


# 0508c09a 29-Nov-2004 Brian Somers <brian@FreeBSD.org>

Send NAS-IP-Address as well as NAS-Identifier
Add ``disable NAS-IP-Address'' and ``disable NAS-Identifier'' options to
support pre-rfc2865 RADIUS servers.
This pushes our enable/disable items over the 32 bit limit, so reoganise
things to allow a bunch more options.
Go to version 3.4.1 so that any compatability problems can be identified.


# 057f1760 04-Sep-2004 Brian Somers <brian@FreeBSD.org>

Make ppp WARNS=5 clean


# 6eafd353 27-Aug-2002 Brian Somers <brian@FreeBSD.org>

Include the correct file (stdarg.h) and use va_list rather than _BSD_VA_LIST_

Suggested by: mike


# 23ddebe2 28-Jun-2002 Brian Somers <brian@FreeBSD.org>

Don't use SignalBundle if it's not set

Submitted by: Federico G. Schwindt <fgsch@olimpo.com.br>


# b08bf2de 22-May-2002 Brian Somers <brian@FreeBSD.org>

Add some missing #includes that weren't required due to namespace polution
in our headers.

Submitted by: bde


# de59e178 13-May-2002 Brian Somers <brian@FreeBSD.org>

o Clean up some #includes
o Bump version number to 3.0.4
o When talking to a RADIUS server, provide a NAS-Port-Type.

When the NAS-Port-Type is Ethernet, provide a NAS-Port value equal
to the SESSIONID from the environment in direct mode or the
NGM_PPPOE_SESSIONID message in other modes. If no SESSIONID is found,
default to the interface index in client mode or zero in server mode.

When the NAS-Port-Type is ISDN, set the NAS-Port to the minor number
of the physical device (ie, the N in /dev/i4brbchN).

This makes it easier for the RADIUS server to identify the client
WRT accounting data etc.

Prompted by: lsz8425 <lsz8425@mail.cd.hn.cn>


# d3974088 22-Apr-2002 Dag-Erling Smørgrav <des@FreeBSD.org>

Usage style sweep: spell "usage" with a small 'u'.
Also change one case of blatant __progname abuse (several more remain)
This commit does not touch anything in src/{contrib,crypto,gnu}/.


# fb11a9c2 29-Mar-2002 Brian Somers <brian@FreeBSD.org>

Merge the NETGRAPH branch into HEAD. tty devices now use netgraph's line
discipline to do the async escaping, but no other benefits are available yet.

Change ``ifdef HAVE_DES'' to ``ifndef NODES'' for consistency.

Make the Makefile a little more sane WRT RELEASE_CRUNCH.


# 971abb29 15-Aug-2001 Brian Somers <brian@FreeBSD.org>

Probe for the availability of AF_INET6 at startup. If it's not
available, default ipv6cp to disabled and refuse to let the user
enable it.


# 30949fd4 14-Aug-2001 Brian Somers <brian@FreeBSD.org>

o Add ipv6 support, abstracting most NCP addresses into opaque
structures (well, they're treated as opaque).

It's now possible to manage IPv6 interface addresses and routing
table entries and to filter IPV6 traffic whether encapsulated or
not.

IPV6CP support is crude for now, and hasn't been tested against
any other implementations.

RADIUS and IPv6 are independent of eachother for now.

ppp.linkup/ppp.linkdown aren't currently used by IPV6CP

o Understand all protocols(5) in filter rules rather than only a select
few.

o Allow a mask specification for the ``delete'' command. It's now
possible to specifically delete one of two conflicting routes.

o When creating and deleting proxy arp entries, do it for all IPv4
interface addresses rather than doing it just for the ``current''
peer address.

o When iface-alias isn't in effect, don't blow away manually (via ``iface
add'') added interface addresses.

o When listening on a tcp server (diagnostic) socket, bind so that a
tcp46 socket is created -- allowing both IPv4 and IPv6 connections.

o When displaying ICMP traffic, don't display the icmp type twice.
When display traffic, display at least some information about unrecognised
traffic.

o Bump version

Inspired after filtering work by: Makoto MATSUSHITA <matusita@jp.FreeBSD.org>


# dd1a52b9 04-Jul-2001 Brian Somers <brian@FreeBSD.org>

Make the last fix work properly on descriptors 1 and 2 (not just 0)


# 108e336a 03-Jul-2001 Brian Somers <brian@FreeBSD.org>

Handle any of descriptors 0, 1 or 2 being closed when we're
envoked -- don't use them (as return values from open()), then
(say) close(STDIN_FILENO) when daemonising.

This is done by grabbing 3 descriptors to /dev/null at startup and
releasing them after we've daemonised.

MFC after: 1 week


# 65309e5c 13-Jun-2001 Brian Somers <brian@FreeBSD.org>

Convert IIJ copyrights to BSD copyrights.

Approved by: Toshiharu OHNO <tohno@sirius.ocn.ne.jp>


# 0fea4ed0 03-Apr-2001 Brian Somers <brian@FreeBSD.org>

Don't say ``PPP enabled'' if we're given the -quiet switch


# 7a66a36d 23-Mar-2001 Brian Somers <brian@FreeBSD.org>

Change _PATH_PPP to PPP_CONFDIR and allow it to be overridden at compile time


# 74457d3d 25-Jan-2001 Brian Somers <brian@FreeBSD.org>

Allow ``set server closed'' to close the diagnostic socket.
Allow ``set server open'' to re-open the diagnostic socket.
Handle SIGUSR1 by re-opening the diagnostic socket
When receiving SIGUSR2 (and in ``set server none''), don't forget the
socket details so that ``set server open'' and SIGUSR1 open it again.

Don't create the diagnostic socket as uid 0 ! It's far to dangerous.


# 9b996792 29-Oct-2000 Brian Somers <brian@FreeBSD.org>

Various whitespace changes.
Make some functions static.


# 8a52f3ec 09-Oct-2000 Brian Somers <brian@FreeBSD.org>

Create fd_sets big enough to handle getdtablesize() descriptors.


# 9bf01bcb 09-Apr-2000 Brian Somers <brian@FreeBSD.org>

Add a missing ``break''


# b42135de 07-Apr-2000 Brian Somers <brian@FreeBSD.org>

When running ppp -background, show comfort messages showing
when we're redialing/reconnecting.

While we're here, log redial, reconnect and phone number
announcements to LogCHAT, and reduce some other logging to
LogDEBUG.


# 0cd8e902 21-Mar-2000 Brian Somers <brian@FreeBSD.org>

Call bundle_CleanDatalinks() after UpdateSet() in case we're
dropping out of background/foreground/direct mode.

This avoids either having to wait for the redial timer before
exiting or jaming up in select() waiting for something that'll
never happen.


# 8e7bd08e 13-Mar-2000 Brian Somers <brian@FreeBSD.org>

Correct some typos introduced in the descriptor -> fdescriptor change.


# 10e629b9 13-Mar-2000 Brian Somers <brian@FreeBSD.org>

Introduce LOCALNAT and LOCALRAD defines so that the sources can stay
exactly the same in FreeBSD & OpenBSD despite libalias and libradius
being local to the ppp sources under OpenBSD.


# 6b457978 13-Mar-2000 Brian Somers <brian@FreeBSD.org>

The interface list that comes back from the PF_ROUTE/NET_RT_IFLIST mib
is aligned. Teach this to ``show route''.

Clean up some of the sockaddr parsing routines.


# f013f33e 13-Mar-2000 Brian Somers <brian@FreeBSD.org>

To avoid namespace polution in NetBSD:

``struct descriptor'' -> ``struct fdescriptor''


# 06b47306 20-Jan-2000 Brian Somers <brian@FreeBSD.org>

Use TUNSIFPID when we change our PID (if it exists).


# 182c898a 27-Dec-1999 Brian Somers <brian@FreeBSD.org>

Add a bunch of `const's and fix a typo.

Submitted by: Rich Neswold <rneswold@MCS.Net>


# 886530ab 29-Nov-1999 Brian Somers <brian@FreeBSD.org>

depricated -> deprecated + mention the -alias flag status in README.changes


# f6a4e748 28-Nov-1999 Brian Somers <brian@FreeBSD.org>

Make -foreground a proper option (allowing ``allow mode foreground'',
``set mode foreground'' etc.


# cf0a3940 17-Nov-1999 Brian Somers <brian@FreeBSD.org>

Fix ``set proctitle'' by using setproctitle().


# da8b7034 09-Nov-1999 Brian Somers <brian@FreeBSD.org>

Don't recurse into datalink_UpdateSet() after
doing a HangupDone(). The HangupDone() may fuel
bundle_CleanDatalinks(), and if so, the bogus
UpdateSet() ends up select()ing on a closed
descriptor.....

Change the main `do/while' loop to a `for' loop so
that any `continue's do the bundle_CleanDatalinks()
& bundle_IsDead() bit.


# 9d06928d 09-Nov-1999 Brian Somers <brian@FreeBSD.org>

Correct the ``-unix X'' parsing (last time I only corrected
``-unitX''.

Pointed out twice by: Gert-Jan Vons <gert-jan@bigfoot.com>


# 0d3751e7 08-Nov-1999 Brian Somers <brian@FreeBSD.org>

Don't treat -unit as a mode flag when counting mode flags.

Submitted by: Gert-Jan Vons <gert-jan@bigfoot.com>


# c0593e34 19-Oct-1999 Brian Somers <brian@FreeBSD.org>

Add the -unit command line switch for specifying the tun device.
Warn about -alias being depricated (but still allow it).
Don't moan twice about failing to open any tun device.
Fix a diagnostic and add the -quiet switch to the usage message.


# 97d92980 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# 67b072f7 19-Aug-1999 Brian Somers <brian@FreeBSD.org>

o Add the -foreground switch. This switch behaves like -background except
that ppp stays in the foreground.
o Add the -quiet switch to quieten ppps startup
o Add the -nat flag and discourage the use of the -alias flag. Both do
the same thing.
o Correct some nat usage strings.
o Change the internal ``alias'' command to ``nat''.


# 1080ea25 09-Aug-1999 Brian Somers <brian@FreeBSD.org>

Insist that ppp.conf and it's parent directories aren't `other'
writable rather than not being writable at all.

PR: 13009
Kind-of submitted by: Anthony Kimball <alk@pobox.com>


# ac37ab22 13-May-1999 Brian Somers <brian@FreeBSD.org>

Ignore repeated signals sent to the parent in background
mode.


# 5d9e6103 08-May-1999 Brian Somers <brian@FreeBSD.org>

o Redesign the layering mechanism and make the aliasing code part of
the layering.

We now ``stack'' layers as soon as we open the device (when we figure
out what we're dealing with). A static set of `dispatch' routines are
also declared for dealing with incoming packets after they've been
`pulled' up through the stacked layers.

Physical devices are now assigned handlers based on the device type
when they're opened. For the moment there are three device types;
ttys, execs and tcps.

o Increment version number to 2.2
o Make an entry in [uw]tmp for non-tty -direct invocations (after
pap/chap authentication).
o Make throughput counters quad_t's
o Account for the absolute number of mbuf malloc()s and free()s in
``show mem''.
o ``show modem'' becomes ``show physical''.


# 7884358f 26-Apr-1999 Brian Somers <brian@FreeBSD.org>

Add support for NetBSD


# 486105bc 29-Mar-1999 Brian Somers <brian@FreeBSD.org>

Maintain a `necessary' marker to indicate that we *probably*
need to process a signal (usually a SIGALRM). Check to see
if we need to process a signal both before *and* after calling
select() as older (pre-2.0) versions of ppp used to.

This handles the possibility that ppp may block at some
point (maybe due to an open() of a misconfigured device).
Previously, we'd potentially lock up in select().

The `necessary' marker reduces the increased signal checking
overhead so that at full speed with no compression transferring
an 83Mb file via a ``!ppp -direct'' device, we get a 1%
throughput gain.


# a611383f 06-Mar-1999 Brian Somers <brian@FreeBSD.org>

Reopen descriptor 0 as /dev/tty when in interactive mode
in OpenBSD as well as FreeBSD (I still don't know why).
Add a debug diagnostic when creating a child process as
a link.


# f0cdd9c0 05-Feb-1999 Brian Somers <brian@FreeBSD.org>

Decouple pap & chap output routines from the corresponding
input routines and take advantage of the new init/continue
interface in libradius. This allows a timely response on
other links in an MP setup while RADIUS requests are in
progress as well as the ability to handle other data from
the peer in parallel. It should also make the future addition
of PAM support trivial.

While I'm in there, validate pap & chap header IDs if
``idcheck'' is enabled (the default) for other FSM packet
types.

NOTE: This involved integrating the generation of chap
challenges and the validation of chap responses
(and commenting what's going on in those routines).
I currently have no way of testing ppps ability
to respond to M$Chap CHALLENGEs correctly, so if
someone could do the honours, it'd be much
appreciated (it *looks* ok!).

Sponsored by: Internet Business Solutions Ltd., Switzerland


# ed0e9269 02-Feb-1999 Brian Somers <brian@FreeBSD.org>

Don't allow root to specify non-existent labels on
the command line.
Revise the error diagnostics so that invalid labels
are reported immediately.


# 972a1bcf 27-Jan-1999 Brian Somers <brian@FreeBSD.org>

Initial RADIUS support (using libradius). See the man page for
details. Compiling with -DNORADIUS (the default for `release')
removes support.

TODO: The functionality in libradius::rad_send_request() needs
to be supplied as a set of routines so that ppp doesn't
have to wait indefinitely for the radius server(s). Instead,
we need to get a descriptor back, select() on the descriptor,
and ask libradius to service it when necessary.
For now, ppp blocks SIGALRM while in rad_send_request(), so
it misses PAP/CHAP retries & timeouts if they occur.

Only PAP is functional. When CHAP is attempted, libradius
complains that no User-Password has been specified... rfc2138
says that it *mustn't* be used for CHAP :-(

Sponsored by: Internet Business Solutions Ltd., Switzerland


# 756783fc 25-Jan-1999 Brian Somers <brian@FreeBSD.org>

Don't SEGV when ``set proctitle'' is used in the default
section.
Submitted by: Dan Lukes <dan@obluda.cz>
PR: 9669


# 991c2a7b 10-Dec-1998 Brian Somers <brian@FreeBSD.org>

When using ``set device !someprogram'', when ``someprogram''
exits, it causes a select() exception.
Handle these select() exceptions on link descriptors in pretty
much the same way as loss of carrier rather than dropping out
in confusion.


# 7cf368eb 31-Oct-1998 Brian Somers <brian@FreeBSD.org>

Allow multiple systems (config labels) on the command
line and in the ``load'' & ``dial'' commands. The last
label loaded becomes the current label name.
Only require a label for -auto mode.


# 8fa6ebe4 21-Oct-1998 Brian Somers <brian@FreeBSD.org>

Solve the ``first connection'' problem that occurs on
demand-dial links with dynamic IP numbers where the program
that causes the dial bind()s to an interface address that is
subsequently changed after ppp negotiation.

The problem is defeated by adding negotiated addresses to the
tun interface as additional alias addresses and providing a set
of ``iface'' commands for managing the interface. Libalias is
also required (and what a name clash!) - it happily IP-aliases
the address so that the source is that of the primary (negotiated)
interface and un-IP-aliases it on the way back.

An ``enable iface-alias'' is done implicitly by the -alias command
line switch. If -alias isn't given, iface-aliasing is disabled by
default and can't be enabled 'till an ``alias enable yes'' is done.
``alias enable no'' silently disables iface-alias.

So, for dynamic-IP-type-connections, running ``ppp -alias -auto blah''
will work for the first connection, although existing bindings will
not survive a disconnect/connect as the TCP peer will be trying to
send to the old IP address - the packets won't route.

It's now a lot easier to add IPXCP to ppp with minor updates to
the new iface.[ch] (if anyone ever gets 'round to it).

It's also now possible to manually add interface aliases with
something like ``iface add 1.2.3.4/24 5.6.7.8''. This allows
multi-homed ppp links :-)


# 1595bacd 16-Sep-1998 Brian Somers <brian@FreeBSD.org>

Sync with OpenBSD ifdefs


# 2a630835 09-Aug-1998 Brian Somers <brian@FreeBSD.org>

Don't forget to call PacketAliasInit().
PR: 7515


# 92b09558 07-Aug-1998 Brian Somers <brian@FreeBSD.org>

o Support callback types NONE, E.164, AUTH and CBCP.
(see the new ``set callback'' and ``set cbcp'' commands)
o Add a ``cbcp'' log level and mbuf type.
o Don't dump core when \T is given in ``set login'' or
``set hangup''.
o Allow ``*'' and blanks as placeholders in ppp.secret and
allow a fifth field for specifying auth/cbcp dialback
parameters.
o Remove a few extraneous #includes
o Define the default number of REQs (restart counter) in defs.h
rather than hardcoding ``5'' all over the place.
o Fix a few man page inconsistencies.


# 94245ac6 02-Aug-1998 Brian Somers <brian@FreeBSD.org>

On receipt of a sig 15, do a full bundle_Close() even if
our current phase is PHASE_DEAD as it's possible that there
are links stuck in OPENING waiting for a redial timer.


# 10a9be1e 27-Jun-1998 Brian Somers <brian@FreeBSD.org>

Remove redundant includes


# 615ad4f9 27-Jun-1998 Brian Somers <brian@FreeBSD.org>

Don't dlopen()/dlsym() libalias, use it in the same way
as the rest of the world uses libraries.


# 032d4276 26-Jun-1998 Brian Somers <brian@FreeBSD.org>

``struct tunnel_header'' -> u_int32_t in OpenBSD.
struct tunnel_header is going soon.

Suggested by: Theo


# 1af29a6e 24-Jun-1998 Brian Somers <brian@FreeBSD.org>

o If we come out of select() with only write descriptors that
end up writing zero bytes, sleep for 1/10 of a second so that
we don't end up using up too much cpu.
This should only ever happen on systems that wrongly report a
descriptor as writable despite the tty buffer being full.
Discussed with: Jeff Evarts

o Do an initial run-time check to see if select() alters the passed
timeval. This knowledge isn't yet used, but will be soon.


# a33b2ef7 16-Jun-1998 Brian Somers <brian@FreeBSD.org>

Change some log levels. ALERTs are only logged when
something that can't happen happens or when everyone
needs to know. ERRORs are only logged when something
unexpected happens.


# 899011c4 16-Jun-1998 Brian Somers <brian@FreeBSD.org>

Don't bring the modem offline or hangup when ``down lcp''
is done. Instead, behave like ``close lcp''.


# d93d3a9c 15-Jun-1998 Brian Somers <brian@FreeBSD.org>

o De-staticise things that don't need to be static.
o Bring the static ``ttystate'' into struct prompt so that
the tilde context is per prompt and not global.
o Comment the remaining static variables so that it's
clear why they're static.
o Add some XXX comments suggesting that our interface list
and our hostname should be re-generated after a signal
(say SIGUSR1) so that a machine with PCCARDs has a chance.


# 30291ffb 15-Jun-1998 Brian Somers <brian@FreeBSD.org>

Give ``load'' optional context. It's now possible to
``link 1,2,3 load label'' for people that want to set
up their links in a more mpd-like manner.


# 9c81b87d 15-Jun-1998 Brian Somers <brian@FreeBSD.org>

Make `close lcp' just close the LCP layer and not hangup. This is
useful for slirp users that wish to get their shell back after the
ppp session. `close' with no args still hangs up as expected.
Required by: jmz


# da66dd13 06-Jun-1998 Brian Somers <brian@FreeBSD.org>

Put the correct pid in /var/run/tunX.pid
Suggested by: many


# 8e7b8599 29-May-1998 Brian Somers <brian@FreeBSD.org>

o If there's a session leader left running for a descriptor
that we're now closing, manually HUP that session leader
so that the tty is fully released.
o Always restart our carrier detect timer in the receiving
process if it was running in the sending process (as we
now *always* pass the descriptor).
o Tweak argv when we go into pause() mode to keep our session
so that ps can see what's going on (without checking for a
`pause' state in `ps -l').


# 81358fa3 29-May-1998 Brian Somers <brian@FreeBSD.org>

o Make modes consistent throughout ppp. The same strings are used
in `set mode', `allow modes', on the command line and when
outputting mode names. The strings are matched so that only
enough characters to uniquely identify the string are required,
so you can now

ppp -a mylabel (for auto mode)
ppp -b mylabel (for background mode)
ppp -dd mylabel (for direct dial mode)

etc.
o Make -ddial dial when specified on the command line (oops).
Pointed out by: Alex <garbanzo@hooked.net>


# 1384bd27 28-May-1998 Brian Somers <brian@FreeBSD.org>

o #define the name "tun" in defs.h against the future possibility
of supporting architectures with different device names.
o Close /dev/tunX when destroying the bundle.
o Don't forget to close the parent end of the pipe in the child
process when exec'ing a program from a chat script.
o If we close our controlling terminal, ditch the current session
with it, allowing getty(8) (or whatever) to regain control.
o After transferring our controlling terminal descriptor to another
ppp instance, we now fork a new ppp to continue where we left off,
transferring ownership of all uucp locks and the /var/run/tunX.pid
file. Meanwhile the parent closes all file descriptors, defaults
all signals and does a pause() to wait for a HUP after the
transferred descriptor is finally closed.
We don't run /bin/cat any more (again!).

Suggested by: bde

TODO: It seems clocal devices need their pause()d session leader
to be given a manual HUP, as closing the last open descriptor
doesn't do the job.


# 0f78c7a7 27-May-1998 Brian Somers <brian@FreeBSD.org>

Don't assume stdout is a tty in interactive mode
Analyzed by: dmaddox@scsn.net (Donald J. Maddox)


# 54cd8e13 24-May-1998 Brian Somers <brian@FreeBSD.org>

o Don't try to transfer tty device descriptors as there's no way of
transferring session rights with them. Instead, create two
`/bin/cat' processes. A new child is spawned and disassociated from
the terminal and the parent, which continues with the rest of the ppp
process. Meanwhile, the parent spawns another child, and both the
parent and child exec the `/bin/cat' commands with the appropriate
descriptors. This way, the session is owned by the parent, and the
tty is held open.
o Close LCPs that have done a TLF and are now in ST_STOPPED before
calling Down. This prevents them from trying to come back up again
after the peer has shut them down (it seems a bit strange that the
rfc says that a Down in ST_STOPPED will cause a TLS etc).
o Don't try to set the physical link name pointer when we're receiving
and renaming a datalink. The physical hasn't been created yet, and as
it happens, the garbage physical pointer happens to be the value of another
physical - so we're pointing that other physical name at ourselves.
yeuck.
o Re-arrange the order of things in main (DoLoop()). We now handle
signals only after the select and not before the UpdateSet. It's
possible that either a signal (FSM timeout) or a descriptor_Read()
brings a link down, after which we'd better tidy up any dead direct
and 1off descriptors before calling UpdateSet() again.
o Mention when we detect a PPP packet when we see one before the link
is up (then start LCP as before).


# 0f2f3eb3 23-May-1998 Brian Somers <brian@FreeBSD.org>

o Move our prompt descriptor list outside of the bundle.
It's now dealt with by the `server' object. This simplifies
things as we only have one list of prompt descriptors and
the log_ routines check prompt::logactive to determine
whether it should be used for output.
o Include the MP socket UpdateSet() result in bundle::UpdateSet().
o Don't select on the tun device unless we're in NETWORK
phase or AUTO mode.
o Stop the idle timer when we go to DEAD phase. We may
have transferred a link and not had a chance to kill
it.
o Don't fail when trying to unlink our transferred datalink
from our descriptor lists just before the transfer.
o Add our link descriptor to the write set if we got a short
write the last time (physical::out is set).
o Log the connection source address when a connection is closed.
o Remove descriptor::next field. Descriptor lists are not required
any more.


# ea722969 15-May-1998 Brian Somers <brian@FreeBSD.org>

o Call bundle_LinkClosed() when transferring a datalink so that
the bundle has the opportunity to go PHASE_DEAD and cleanup
the interface (if it's the last link).
o Regnerate our phys_type value when we transfer the link.
o Always clean up the interface when destroying our bundle in case
we're abending.
o Always clean up our interface when the last link is gone rather than
delaying things 'till exit time in the -direct case (the interface
is useless anyway). Do this *after* slamming down our NCPs (if
they're still around).
o Our MP server descriptor now clears the relevent device descriptor
from our descriptor [fd]sets when a datalink is on death-row (to
be transferred to another running ppp), thus avoiding the possibility
of passing a bum descriptor to select() and having ppp abend.
o Handle the MP socket descriptor functions from within the bundle
descriptor functions. Now we ensure that the MP socket descriptor
functions see the descriptor sets *after* they've been seen by our
datalinks.
o Add/fix a few more comments.


# 24989c68 10-May-1998 Brian Somers <brian@FreeBSD.org>

o Protect against expected NULL fdset pointers.
o Log FD_SET()s in LogTIMER.
o Identify the descriptor that causes an EBADF from select()
if LogTIMER is enabled (then exit).
o Call the MP server UpdateSet() function after calling
the UpdateSet() for all links - the link may enter
PHASE_TERMINATE and bring down the MP server - breaking
the imminent select().


# 846af6dc 08-May-1998 Brian Somers <brian@FreeBSD.org>

o When specifying the diagnostic port (`set server'), replace
the first ``%d'' in the unix-domain socket name with the
current interface unit number. In the case of tcp ports, allow
a ``+'' prefix to add the unit number to the specified port
number.
o Remove all mention of SIGUSR1 (was already #ifdef'd out). We
can't create diagnostic sockets on-the-fly with a signal any
more because there's no way of specifying the password without
confusing matters with the previous ppp.secret scenario.


# b7c5748e 07-May-1998 Brian Somers <brian@FreeBSD.org>

o Rename datalinks as soon as the name has been received so that
LQM and HDLC timer diagnostics come out with the correct name.
o Don't send an LQR immediately upon reviving a datalink. Leave
it 'till the next timeout.
o Add the link name to some more LQR diagnostics.
o Break out of the main loop when a descriptor exception is seen
in select().
o Remove the evil nointr_[u]sleep() functions. Timers should be
(and are) used instead.
o Treat a read() of 0 bytes as an error that's fatal to the link
on which the read() is done. We should never read() 0 after
select() says there's something there - not unless the link
has been closed by the other side.
o Write the data seen before a HDLC header to the terminal in
`term' mode, *not* back to the modem :-/
o Initialise our transmitted file descriptor before starting any
timers.
o Only send data links that have *no* pending output data. This
means that our final ACK will be written rather than being
nuked with the datalink transmission.


# 1bc9b5ba 06-May-1998 Brian Somers <brian@FreeBSD.org>

o Make sure we don't dereference NULL when we've lost all our links.
o Use srandomdev() for __FreeBSD__ >= 2, not just >2.
o Use srandom((time(NULL)^getpid())+random()), random() when we
haven't got srandomdev().


# 078c562e 06-May-1998 Brian Somers <brian@FreeBSD.org>

o Don't enter phase TERMINATE in the LCP TLD, leave it exclusively
for the last NCP TLF.
o Move tun reading from the main loop into the bundle descriptor
handling routines.
o Cosmetic: Add a few `const's and make some diagnostics clearer.


# dd7e2610 01-May-1998 Brian Somers <brian@FreeBSD.org>

Cosmetic: Make our external function names consistent.


# 6f384573 30-Apr-1998 Brian Somers <brian@FreeBSD.org>

o Create a new ``timer'' log level. This lets us ``set
log debug'' without filling our filesystem/screen with
junk that we don't really want to see.
o change PHYS_STDIN to PHYS_DIRECT - we can handle incoming
connections that aren't on STDIN_FILENO now.
o Allow return values from our FSM LayerUp functions. If
LayerUp() fails, the FSM does an immediate FsmDown() without
calling the fsm_parent's Layer{Up,Down} functions.
o Clear the close-on-exec flag of file descriptor 3 when executing
chat programs so that our documented ability to communicate with
/dev/tty via that descriptor works. Also document it as
descriptor 3, not 4 :-O
o Allow a ``rm'' command as an alias for ``remove''.
o Fix the bind()/connect()/accept() calls made by the MP server.
o Create bundle_SendDatalink() and bundle_ReceiveDatalink().
This allows `struct datalink's to flatten themselves, pass
through a pipe (read: the eye of a needle !) and come alive
at the other end. The donator then fork()s & exec()s pppmpipe,
``passing'' the connection to another ppp instance.

*** PPP NOW TALKS MULTILINK :-))) ***

Our link utilization is hideous, and lots of code needs
tidying still. It's also probably riddled with bugs !
It's been tested against itself only, and has hung once,
so confidence isn't high....


# 1fa665f5 27-Apr-1998 Brian Somers <brian@FreeBSD.org>

o Add the link name to modem diagnostics.
o Create struct mpserver as part of struct mp.
mpserver creates a unix-domain socket based on the
peers auth name and endpoint discriminator. If it
already exists, ppp will ``pass the link'' over to
the owner of the socket, joining it into the bundle
of another ppp invocation, otherwise ppp waits for
other invocations to pass it links through this
socket.
The final piece of code will be the code that flattens
our datalink info and passes it down this channel
(not yet implemented).


# e43ebac1 25-Apr-1998 Brian Somers <brian@FreeBSD.org>

Make gcc-2.8.1 build ppp cleanly.
Support OpenBSD again.


# 49052c95 22-Apr-1998 Brian Somers <brian@FreeBSD.org>

Negotiate MRRU, SHORTSEQ and ENDDISC. ENDDISC doesn't imply
multilink ('cos I've seen my ISP REQ it without multilink).

Setting MRRU is ifdef'd out until it's debugged and we can
merge -direct links with other running programs.

Fix MTU setting.


# 1342caed 15-Apr-1998 Brian Somers <brian@FreeBSD.org>

o Move the accept/deny/disable/enable globals either to the
bundle (non-negotiated vars) or to their respective IPCP,
LCP or CCP.
o Enable rolling throughput statistics by default.
o Remove the `display' command. These values now appear in
`show bundle', `show ipcp', `show ccp' and `show lcp'.
o Initialise auth name & key at bundle create time (oops).
o Rename pppd-deflate (the id-24 hack) to deflate24.
o Don't send both a REJ and a NAK to an IPCP or LCP REQ.
Favour the REJ (already done at the CCP level).
o Recurse in datalink_UpdateSet() when we change state, otherwise
we end up setting no descriptors and getting jammed in the
imminent select() instead of doing the dial/login/hangup.
o Display our CHAP encryption method despite being built with DES.
o Display VJ as not negotiated in ``show ipcp'' when necessary.


# 565e35e5 10-Apr-1998 Brian Somers <brian@FreeBSD.org>

o Remove the `mode' global - it's now per physical device.
o Shuffle things that live at the datalink level into
``show link'' rather than ``show modem''.
o Make both ``show'' commands prettier and more consistent,
and display carrier status, link type and our name in
``show modem''.
o Show redial and reconnect information in ``show link''
and remove ``show redial'' and ``show reconnect''.
o Down the correct link in bundle_LinkLost().
o Remove stale -direct and -background links at the end
of our main loop, not when we know they're going. This
prevents unexpected pointer-invalidations...
o If we ``set server'' with the same values twice, notice
and don't moan about failure.
o Record dial script despite our link mode. The mode may
be changed later (next mod) :-) We never run scripts
in -direct and -dedicated modes.
o Make ``set server none'' functional again.
o Correct datalink state array so that we don't report an
``unknown'' state.
o Pass struct ipcp to IpcpCleanInterface, not struct fsm.
o Create TUN_PREFIX define rather than hard-coding in main.c
o prompt_TtyInit now handles a NULL prompt for -direct mode
rather than having to create one then destroy it uncleanly.
o Mention our mode in the "PPP Started" LogPHASE message.
o Bring all auto links up when we have something to send.
o Remove some redundant Physical_*() functions.
o Show which connection is running a command when logging
commands.
o Initialise throughput uptime correctly.


# 85602e52 07-Apr-1998 Brian Somers <brian@FreeBSD.org>

Remove MODE_ALIAS and add AliasEnabled() macro.
Remove IsInteractive().


# 2764b86a 06-Apr-1998 Brian Somers <brian@FreeBSD.org>

o Move alias function pointers into loadalias.c
o Move Var*Version into command.c
o Remove struct pppVars (and there was much rejoicing) !
o Forward-decl some structs in .h files to avoid include
ordering requirements and remove a few more redundant
#includes.


# d24f017b 06-Apr-1998 Brian Somers <brian@FreeBSD.org>

Remove unused includes.


# f91ad6b0 05-Apr-1998 Brian Somers <brian@FreeBSD.org>

Make ^Z, bg & fg work. We don't muck around with
SIGTTIN or SIGTTOU, we just disable use of the prompt
for the controlling terminal (and put a ^Z next to it
in a ``show who'' listing).

Unfortunately, we need to enable a timer to ``poll''
for the terminal having us as the controlling pgrp
when a user does a ``bg''. If anyone knows how to
do this better - please speak up (is there any
indication to the process group leader when it's
ctrling terminal gets tcsetpgrp()'d back ?)....


# b6217683 03-Apr-1998 Brian Somers <brian@FreeBSD.org>

Deglobalise `struct prompt':
o Our diagnostic socket has its password set in the `set socket'
line only (not in ppp.secret).
o Passwords are per server socket (*VarAuthKey are gone)
o Authority is per prompt (VarLocalAuth is gone).
o Local logging is per prompt.
o Add a `show who' command to see who's connected. No identd
routine - just a `where the connection came from' display.
o SIGUSR1 is disabled for now - we have no way of choosing a
password for the socket created :-(

Prompts are attached as a list of `struct descriptor's in
struct bundle, and serviced under the bundles descriptor
service routines. Ultimately, everything should be done
like this.

Cosmetic:
o alphabeticalise SRCS in Makefile.
o Add a few comments in command.h

TODO: Start checking that we don't overflow the descriptor sets
in select() now that we can have any number of descriptors.


# 8390b576 03-Apr-1998 Brian Somers <brian@FreeBSD.org>

o Drop packets that fail the dial filter when we're in
phase DEAD. They'll almost definitely have timed out
by the time we dial anyway.
o Log dial filters again (LogTCPIP).
o Make DEBUG diagnostics for filter checking actually mean
something to the common observer.
o Do our best to keep any already-configured IP numbers at
IPCP negotiation time. We always first request our configured
IP, and if the peer asks for an invalid IP, we NAK with HISADDR

Cosmetic:
o Add a linefeed to the `set timeout' arg count error message.
o Log unacceptable address errors to LogPHASE if LogIPCP is
switched off.
o Fix ``destination system not found'' error message.
o Get out immediately if we get a fatal error before entering
the main loop.


# 0b3acc6e 03-Apr-1998 Brian Somers <brian@FreeBSD.org>

Remove `set loopback' and `show loopback' and add
`enable loopback' and `disable loopback'. Re-write
the explaination of `enable idcheck'.


# 3b0f8d2e 03-Apr-1998 Brian Somers <brian@FreeBSD.org>

o Move struct lcp and struct ccp into struct link.
o Remove bundle2lcp(), bundle2ccp() and bundle2link().
They're too resource-hungry and we have `owner pointers'
to do their job.
o Make our FSM understand LCPs that are always ST_OPENED
(with a minimum code that != 1).
o Send FSM code rejects for invalid codes.
o Make our bundle fsm_parent deal with multiple links.
o Make timer diagnostics pretty and allow access via ~t
in `term' mode (not just when logging debug) and
`show timers'. Only show timers every second in debug
mode, otherwise we get too many diagnostics to be useful
(we probably still do). Also, don't restrict ~m in term
mode to depend on debug logging.
o Rationalise our bundles' phases.
o Create struct mp (multilink protocol). This is both an
NCP and a type of struct link. It feeds off other NCPs
for output, passing fragmented packets into the queues
of available datalinks. It also gets PROTO_MP input,
reassembles the fragments into ppp frames, and passes
them back to the HDLC layer that the fragments were passed
from.
** It's not yet possible to enter multilink mode :-( **
o Add `set weight' (requires context) for deciding on a links
weighting in multilink mode. Weighting is simplistic (and
probably badly implemented) for now.
o Remove the function pointers in struct link. They ended up
only applying to physical links.
o Configure our tun device with an MTU equal to the MRU from
struct mp's LCP and a speed equal to the sum of our link
speeds.
o `show {lcp,ccp,proto}' and `set deflate' now have optional
context and use ChooseLink() to decide on which `struct link'
to use. This allows behaviour as before when in non-multilink
mode, and allows access to the MP logical link in multilink
mode.
o Ignore reconnect and redial values when in -direct mode and
when cleaning up. Always redial when in -ddial or -dedicated
mode (unless cleaning up).
o Tell our links to `staydown' when we close them due to a signal.
o Remove remaining `#ifdef SIGALRM's (ppp doesn't function without
alarms).
o Don't bother strdup()ing our physical link name.
o Various other cosmetic changes.


# 5cf4388b 25-Mar-1998 Brian Somers <brian@FreeBSD.org>

Tidy up the parent notification stuff for -background mode.
Remove extraneous extern decls of tun_{in,out} and netfd.


# 75b8d283 25-Mar-1998 Brian Somers <brian@FreeBSD.org>

Handle sig 1, 2, 3 and 15 when we're the parent in background mode
by sending a SIGINT to the child. This was intended before, but
pending_signal() was wrongly used - resulting in no action being
taken as the parent will never enter the main processing loop.


# 9e46ce35 24-Mar-1998 Brian Somers <brian@FreeBSD.org>

Use bundle_Phase(), not bundle->phase.


# 2f786681 20-Mar-1998 Brian Somers <brian@FreeBSD.org>

Make struct bundle into a sort of `struct descriptor'.
It does the fdsets/reads/writes for each of it's
datalinks.


# eaa4df37 16-Mar-1998 Brian Somers <brian@FreeBSD.org>

Move VJ compression state and stats into struct ipcp.


# a0cbd833 16-Mar-1998 Brian Somers <brian@FreeBSD.org>

Move `CleaningUp' into struct bundle.


# 5ca5389a 16-Mar-1998 Brian Somers <brian@FreeBSD.org>

Move filter sets into struct bundle.


# 5828db6d 13-Mar-1998 Brian Somers <brian@FreeBSD.org>

Move the IPCP into struct bundle.


# a611cad6 13-Mar-1998 Brian Somers <brian@FreeBSD.org>

o Don't immediately reply to the first LQR thinking
it's a duplicate ('cos it compares with our initial
values).
o Move the LCP into struct datalink.


# 879ed6fa 12-Mar-1998 Brian Somers <brian@FreeBSD.org>

De-staticise LQR information
Increment OutPackets for any packet - not just LQRs

MFC:
o Fix a few comment typos.
o Fix ``set timeout'' usage message and documentation.
o Change ifOutPackets, ifOutOctets and ifOutLQRs to `u_int32_t's
so that they wrap correctly.
o Put the LQR in network byte order using the correct struct size
(sizeof u_int32_t, not sizeof u_long).
o Wrap LQR ECHO counters correctly.
o Don't increment OutLQR count if the last LQR hasn't been replied
to.
o Initialise last received LQR in StartLqm.
o Don't start the LQR timer if we're `disabled' and `accepted'.
o Generate LQR responses when both sides are using a timer and
we're not going to send our next LQR before the peers max timeout.


# e2ebb036 28-Feb-1998 Brian Somers <brian@FreeBSD.org>

Do authentication at the datalink level, not the bundle level.
The bundle doesn't get a LayerUp 'till we're authenticated.

Introduce DATALINK_LCP and DATALINK_AUTH phases.


# f4768038 22-Feb-1998 Brian Somers <brian@FreeBSD.org>

o Remove the global CcpInfo. It's now part of the datalink.
Struct bundle will have its own struct ccp in the future
too.
o The ``set stopped'' command now requires context and doesn't
work on the IPCP FSM.
o Check if it's time to break out of our top level loop before
doing a select - otherwise, we'll select forever :-(
o Remove `struct link'::ccp (a temporary hack). It turns out
that IpStartOutput() calls link_Output() and link_Output()
incorrectly calls StartOutput() (really modem_StartOutput)
requiring the ccp knowledge so that it can call
IpStartOutput()... The end result is that the whole IP
output queue gets dumped into the modem output queue
and a pile of physical writes are done prematurely. This
makes the (original) code in main() actually work in that
it would not bother selecting() on the tun descriptor when
our modem queue length was 20 or greater. Instead, we now
make that decision based on the overall queue length.

This will need improvement later.


# 503a7782 20-Feb-1998 Brian Somers <brian@FreeBSD.org>

Shuffle around our FSMs a bit. This'll make it
easier to remove the CcpInfo, LcpInfo and IpcpInfo
globals.


# d345321b 17-Feb-1998 Brian Somers <brian@FreeBSD.org>

Close the link(s) properly from bundle_Close() even
if we're in PHASE_DEAD already.
Don't modem_Raw() 'till we're in packet mode.


# c7cc5030 17-Feb-1998 Brian Somers <brian@FreeBSD.org>

Add datalink state DATALINK_READY to indicate when the datalink
is available, but LCP hasn't yet been started. We get to this
state in ``term'' mode.
Remove PacketMode(). LCP startup and shutdown is now controlled
by the datalink.
Add ``show links'' command.
Make ``close'' capable of running with and without a context.
Make ``down'' require a context.
Make ``set parity'' and ``set rtscts'' use the correct context.


# c5a5a6ca 16-Feb-1998 Brian Somers <brian@FreeBSD.org>

Sort out (fix) the `term' command.
datalink_Up() can now be told to skip the dial/login/hangup
scripts and can be told whether to enter packet mode when
entering the DATALINK_OPENED state.


# 5b8b8060 16-Feb-1998 Brian Somers <brian@FreeBSD.org>

Move the dial, login and hangup scripts into struct datalink.
Don't set these scripts in -direct mode.
Always set reconnect_tries to zero for -direct mode.


# 3006ec67 15-Feb-1998 Brian Somers <brian@FreeBSD.org>

Create struct datalink.

This is a type of physical link that can chat and talk
LCP & CCP. A bundle contains a list of these (only one
in the list for the moment).

The datalink is a type of descriptor, and dials, enters
LCP (& does CCP), kicks the bundle when its FSMs do
something interesting and does the hangup chat script
on the way down. It also handles redials and reconnects.

There are lots of loose ends, and probably lots of bugs,
but the data structures are getting there !


# b6dec9f0 12-Feb-1998 Brian Somers <brian@FreeBSD.org>

Update to version 2.0-beta
Allow for NULL fd_sets in descriptor_UpdateSet()
Reimplement the entire chat module, creating
`struct chat' - a `type' of struct descriptor.
Remove CARRIER logging.
CONNECT logging now only logs "CONNECT" lines. CHAT logging
masks it with an entire log of the conversation.

Modem dialing is now asynchronous, including pauses
and timeouts :-)

The hooks in DoLoop() in main.c are *very* messy ! I'll have
to rewrite DoLoop fairly soon, so I don't care too much for the
moment. This code is pretty raw.


# dcf9e6a5 10-Feb-1998 Brian Somers <brian@FreeBSD.org>

Move handle_signals() to before the FD_SETs. handle_signals()
may result in a our modem closing after it's made its way into
the fd_set, resulting in a program exit (with select(): bad file
descriptor) rather than a dropped link.


# 6b5fb63d 10-Feb-1998 Brian Somers <brian@FreeBSD.org>

Oops - put that handle_signals() call back.


# 85b542cf 09-Feb-1998 Brian Somers <brian@FreeBSD.org>

Move the terminal/diagnostic socket stuff out of main.c
and into the new `prompt.c'. struct prompt is (of course)
a `sort' of descriptor.


# b77776a7 09-Feb-1998 Brian Somers <brian@FreeBSD.org>

Pass the fdset to descriptor_Read & descriptor_Write
allowing support for the use of multiple file descriptors.


# 77ff88ad 09-Feb-1998 Brian Somers <brian@FreeBSD.org>

Make the server descriptor into a `sort' of struct descriptor.


# 42d4d396 09-Feb-1998 Brian Somers <brian@FreeBSD.org>

o Introduce struct descriptor.
This will ultimately be a member of a list of descriptors and
their handler functions on which we need to select() in the
main loop.
o Make struct physical into a `sort' of struct descriptor.


# 68a0f0cc 08-Feb-1998 Brian Somers <brian@FreeBSD.org>

o Add bundle_Destroy().
o Don't remove routes and DOWN the interface when we're
closed in auto mode.
o Initialize the FSMs in bundle_Create.
o Initialize ipcp::if_mine & ipcp::if_peer only once (so
that we don't forget that we've SIOCAIFADDR'd the interface).
o Do a SIOCDIFADDR on the specific address to avoid hurting any
other (still non-existent) NCPs.
o Fix some error/diagnostic messages.


# 1afedc4b 08-Feb-1998 Brian Somers <brian@FreeBSD.org>

Create an AbortProgram() function for getting out of
ppp immediately.


# aad81d1e 08-Feb-1998 Brian Somers <brian@FreeBSD.org>

Rename ccpstate to ccp, ipcpstate to ipcp and lcpstate to lcp.


# 4a3762fb 07-Feb-1998 Brian Somers <brian@FreeBSD.org>

Remove two SIGSEGVs.


# 455aabc3 07-Feb-1998 Brian Somers <brian@FreeBSD.org>

o Hook the FSMs into our bundle.
o The FSM layering is now more sane.
o Move a lot of the NCP stuff into our ipcpstate rather than having it
in the bundle, including control of the configured IP addresses. We
don't need hacks like the global `linkup' variable any more as the
FSM decides when our ppp.link* files get run. This is going to eventually
be configurable based on FSM events anyway.
o Fix a few inconsistencies when both sides require authentication.
o We now have "Ppp..." and "PPp" prompts, reflecting authentication
and network phase. We don't print loads of spurious prompts as we
change phases any more.
o Our phase is part of the bundle now.
o Fix a bug where the FSM wasn't calling LayerFinish.
o Close the FSM down correctly with a signal rather than slamming it
down as if the line was dropped (the undocumented ``down'' command
is still available though).
o Remove the forgotten `tunno' variable and fix references to it.


# 83d1af55 05-Feb-1998 Brian Somers <brian@FreeBSD.org>

Isolate fsm callback functions
Derive {lcp,ipcp,ccp}state structures from struct fsm
where convenient.
Create bundle_Down() and remove LcpDown()


# 2289f246 05-Feb-1998 Brian Somers <brian@FreeBSD.org>

Move pppVars.physical into the bundle (for the moment).


# 6f1bc4e5 05-Feb-1998 Brian Somers <brian@FreeBSD.org>

Remove static phys_modem


# ecd5172a 05-Feb-1998 Brian Somers <brian@FreeBSD.org>

Shuffle names and args in modem.h


# 6140ba11 02-Feb-1998 Brian Somers <brian@FreeBSD.org>

Create `struct async' and make it part of `struct physical'.
This structure contains the asynchronous state of the physical
link.
Unfortunately, just about every .h file is included in every .c
file now. Fixing this can be one of the last jobs.


# 7a6f8720 02-Feb-1998 Brian Somers <brian@FreeBSD.org>

Create `struct bundle' - the top level control structure.
This structure will eventually contain a list of NCPs (currently
only IPCP is supported) and a list of physical `struct link's.
It will also derive from a struct link itself.
Make ModemTimeout() static - it's way to dangerous to be called
from outside !
Bump version to 1.9. Our first MP release should be 2.0.


# 7308ec68 30-Jan-1998 Brian Somers <brian@FreeBSD.org>

Move the global FSMs into their relevent structures.
IPCP, CCP and LCP are now just derived FSMs.
Comment each of the FSM implementations so that we can
tell what's going on.
Revise the state transitions so that CCP and IPCP actually
send terminate REQs when appropriate.

The OS & IPCP layers are still like spagetti (next job).


# 8c07a7b2 30-Jan-1998 Brian Somers <brian@FreeBSD.org>

Create `struct link' - the logical link from which
`struct physical' (and the future `struct logical')
are derived.


# 29e275ce 29-Jan-1998 Brian Somers <brian@FreeBSD.org>

o Move global/static IPCP data into IpcpInfo.
o Use INADDR_ANY and INADDR_BROADCAST instead of 0 and 0xffffffff
for IP addresses & masks.
o Move struct compreq into ipcp.c (it's none of anyone elses
business).
o Rename MAX_STATES to MAX_VJ_STATES.


# 63b73463 28-Jan-1998 Brian Somers <brian@FreeBSD.org>

Create a new MP branch for `multilink protocol'.

Do lots of initial shuffling and grouping.
Submitted by: Eivind Eklund <perhaps@yes.no>


# 1ae349f5 28-Jan-1998 cvs2svn <cvs2svn@FreeBSD.org>

This commit was manufactured by cvs2svn to create branch 'MP'.


# 48cf2a79 28-Jan-1998 Brian Somers <brian@FreeBSD.org>

Don't moan about not creating tunX.pid and ttyX.if if RELEASE_CRUNCH
is defined.


# baef0a69 27-Jan-1998 Brian Somers <brian@FreeBSD.org>

Cosmetic:
Don't mention the authors name at startup. He's already credited
in the man page. Instead, make the message consistent with the
one given to the diagnostic port (and fix the grammar when entering
`term' mode).
Don't credit the zlib author in the man page as ppp isn't linked
directly with zlib (it's shared).
Mention when the OpenBSD port was first made available.


# aa8e0519 20-Jan-1998 Brian Somers <brian@FreeBSD.org>

Remove unused #includes.
Make various bits static.
Remove unused variables.
Submitted by: eivind


# 49b239e0 20-Jan-1998 Brian Somers <brian@FreeBSD.org>

Allow an optional delay when specifying "set openmode active".
The delay defaults to 1 sec (as it always has) unless we've done
a ~p in interactive mode or we've actually detected a HDLC frame.
This is now cleanly implemented (via async timers) so that it is
possible for LCP to come up despite the delay if an LCP REQ is
received.

This will hopefully solve situations with slow servers or slirp
scenarios (where ECHO is left on the port for a second or so before
the peer enters packet mode).

Also, ~p in interactive mode no longer changes the value of the default
openmode delay and -dedicated mode enters packet mode in the right state
according to the value of openmode.


# cc924f9e 11-Jan-1998 Brian Somers <brian@FreeBSD.org>

Lose <net/if_var.h> !
This'll require a `make installworld'.


# 0ca7cafb 08-Jan-1998 Brian Somers <brian@FreeBSD.org>

Zap any addresses on the network side of the `tun' as soon
as we've successfully opened the /dev side.


# 2a279fed 30-Dec-1997 Brian Somers <brian@FreeBSD.org>

Allow "set device" to close the open modem if we're in
interactive mode.
Use `netfd' in fcntl() and tc[gs]etattr() calls rather than
the hard coded descriptor 0.
Use _FILENO constants from unistd.h

This un-breaks things after my recent `close(0)' in interactive
mode.

Close STDIN_FILENO, and open _PATH_TTY O_RDONLY as `netfd'. This
has the effect of allowing `show route' to output more than about
a page of data (on FreeBSD, not OpenBSD....). I have no idea why,
except that it was a direct consequence of the tcsetattr() in
TtyCommandMode(). My previous fix (closing descriptor 0) `fixed'
this because all calls to tcsetattr() failed :-(


# b1cbb71c 28-Dec-1997 Brian Somers <brian@FreeBSD.org>

Don't expect select() to adjust the passed time when it's
interrupted with a SIGALRM. In fact, select() sets the
passed time to zero, making the previous implementation
terminate always after 1/10th of a second !

Also, deal with someone changing the clock while we're
sleeping (and restart the whole sleep).

Dangers pointed out by: Theo de Raadt <deraadt@cvs.openbsd.org>


# c60f92ca 27-Dec-1997 Brian Somers <brian@FreeBSD.org>

If a packet causes a dial, continue to test whether it's
blocked in the output filter. If so, proceed with the
dial despite dropping the packet.


# e7250038 27-Dec-1997 Brian Somers <brian@FreeBSD.org>

Show who closes the diagnostic connection.
Show the IP range (if specified) in "show ipcp".
Close unused descriptors 0 and 2 in interactive mode.
Pass (size_t *) rather than (int *) to sysctl().


# 70ee81ff 24-Dec-1997 Brian Somers <brian@FreeBSD.org>

Cosmetic (style):
sizeof(var) -> sizeof var
sizeof type -> sizeof(type)

Suggested by: J Wunsch <j@uriah.heep.sax.de>


# 4401489a 21-Dec-1997 Brian Somers <brian@FreeBSD.org>

Don't forget to ntohs(sin.sin_port) (DUH!)


# 58f264e1 17-Dec-1997 Brian Somers <brian@FreeBSD.org>

Log the source of client connections to the diagnostic port.
Disallow connections from port numbers <1024 as low port numbers
can only really mean trouble (ftp bounces etc.).

Discussed at length with: Theo de Raadt <deraadt@cvs.openbsd.org>


# e3b4c400 17-Dec-1997 Brian Somers <brian@FreeBSD.org>

If we've got a descriptor table that's bigger than an
fd_set, make sure that all descriptors >2 are closed
when we start - otherwise we're asking for a dump in
FD_SET().

Problem pointed out by: Theo de Raadt <deraadt@cvs.openbsd.org>


# bcc332bd 12-Dec-1997 Brian Somers <brian@FreeBSD.org>

Allow random IP number allocation to peer.
Validate the peers suggested IP by attempting to make a routing table
entry.
Give up IPCP negotiation if the peer NAKs us with an unusable IP.
Always SIOCDIFADDR then SIOCAIFADDR when configuring the tun device.
Using SIOCSIFDSTADDR allows duplicate dst addresses (which we don't
want)!!!
Allow up to 200 interface names (was 50) (now that ppp can play server
properly).
Up the version number (1.5 -> 1.6).

Cosmetic:
Log unexpected CCP packets in the CCP log rather than the ERROR log.
Log unexpected Config Reqs in the appropriate LCP/IPCP/CCP log rather
than the ERROR log.
Log failed route additions and deletions with WARN, not TCPIP.
Log the option id and length for unrecognised IPCP options.
Change some .Sq to .Ar in the man page.


# 0053cc58 03-Dec-1997 Brian Somers <brian@FreeBSD.org>

Abstract the CCP layer a level.
Add DEFLATE support.


# b6e82f33 21-Nov-1997 Brian Somers <brian@FreeBSD.org>

Fix prototypes.
Remove extraneous decls.
Add ``const'' to several places.
Allow ``make NOALIAS=1'' to remove IP aliasing.
Merge with OpenBSD - only the Makefiles vary.

We can now survive a compile with
-Wall -Wbad-function-cast -Wcast-align -Wcast-qual
-Winline -Wmissing-declarations -Wmissing-prototypes
-Wnested-externs -Wpointer-arith -Wredundant-decls
-Wshadow -Wstrict-prototypes -Wwrite-strings -Wchar-subscripts
(although the Makefile just contains -Wall).


# 082798e7 18-Nov-1997 Brian Somers <brian@FreeBSD.org>

Fix interactive mode so that it doesn't require a passwd (again!).


# b264e1d2 18-Nov-1997 Brian Somers <brian@FreeBSD.org>

DropClient() when read() returns 0 (as it did before).


# 3b7eb4fb 17-Nov-1997 Brian Somers <brian@FreeBSD.org>

Add and use a DropClient() function for closing the diagnostic port.
Call DropClient() from Cleanup() too.


# 39f94edd 16-Nov-1997 Brian Somers <brian@FreeBSD.org>

Don't SetLabel() 'till we've done the SelectSystem(). This
avoids the situation where we specify label ``x'' on the command
line, and label ``x'' has a ``load y'' command embedded in it.
When the line comes up, we want to use ``x'' from ppp.linkup,
not ``y''.


# c7d4711f 16-Nov-1997 Brian Somers <brian@FreeBSD.org>

Add id strings to tun.[ch].
Don't try to open ppp.secret if we're never going to use it.


# 6a6b4bbb 16-Nov-1997 Brian Somers <brian@FreeBSD.org>

Abstract data read from and written to the tun device,
allowing for a possible header on the front of all packets.
In OpenBSD, there's a structure containing the address
family here.
If we're building under OpenBSD, set up the ``flags'' part
of struct tuninfo (not there under FreeBSD) so that we config
the interface as POINTOPOINT.
Prefix prototypes with ``extern'' in os.c for consistency.

These changes are cosmetic under FreeBSD, but allow ppp to
build & work under OpenBSD (bar the srandomdev() stuff,
the inclusing of <net/if_var.h> and some Makefile symantecs).


# 4562be74 13-Nov-1997 Brian Somers <brian@FreeBSD.org>

Don't run if ppp.conf is writable.


# 815624cf 13-Nov-1997 Brian Somers <brian@FreeBSD.org>

Log a warning when a -direct invocation is denied.


# d9181b05 13-Nov-1997 Brian Somers <brian@FreeBSD.org>

Fix command logging (broken with the "allow" command).


# 04da22ce 12-Nov-1997 Brian Somers <brian@FreeBSD.org>

Null commit: The last commit made some warning messages clearer.


# e4450123 12-Nov-1997 Brian Somers <brian@FreeBSD.org>

Don't delete interface routes when we do an LcpDown.
They'll get deleted in Cleanup().


# 12ef29a8 11-Nov-1997 Brian Somers <brian@FreeBSD.org>

Finish the security improvements:
o Add "allow" command:
"allow users a b c" gives access to users a, b and c.
"allow modes auto" gives those users access to auto mode only.
"allow users *" and "allow modes *" are accepted.
No users and all modes are allowed by default.
UID 0 can do anything.
o Set the current label with the "load" and "dial" commands
so that the call to ppp.linkdown makes sense.
o Up the verison number.
o Don't OR MODE_AUTO for -background and -ddial.
o Don't OR MODE_INTER when we get a diagnostic connection.
o Allow up to 40 args per line (was 20).
o "set ifaddr" only changes the interface in AUTO mode (with other
modes, it happens after IPCP negotiation).
o Sort command descriptions in the man page.
o Support -dedicated mode where we just talk ppp forever (no login etc).


# 8ea8442c 09-Nov-1997 Brian Somers <brian@FreeBSD.org>

Don't create a diagnostic socket by default.
Allow a password spec on the "set server" command line.
Use SIGUSR2 to close the diagnostic socket.
Some man page corrections.


# d025849c 09-Nov-1997 Brian Somers <brian@FreeBSD.org>

Don't ask for a password if it's specified as empty.


# 86e02934 09-Nov-1997 Brian Somers <brian@FreeBSD.org>

Increase chat script sizes to 512
Requested by: Michael Reifenberger <root@totum.plaut.de>


# 5106c671 08-Nov-1997 Brian Somers <brian@FreeBSD.org>

Introduce ID0 logging.
Stay as the invoking uid as much as possible.
Execution as a normal user is still forbidden for now,
so these changes are pretty ineffective.
The next commit will implement the modifications suggested
on -hackers a number of days ago.


# 9780ef31 07-Nov-1997 Brian Somers <brian@FreeBSD.org>

Don't pass global vars as args.
Remove local/global conflicts.


# a1e8f937 03-Nov-1997 Brian Somers <brian@FreeBSD.org>

Introduce [local] to "set log [local] ...". This spits
logging out to the screen in terminal mode - should be
good for installation problem diagnosis.


# 0fe7ca31 28-Oct-1997 Brian Somers <brian@FreeBSD.org>

o Bump version to 1.3 to reflect major changes
o Report modem connect time properly
o Report bytes in/out over physical media
o Fix phases (TERMINATE is *higher than* DEAD)
o Do a LayerFinish from LcpDown
o Bring down IPCP & CCP when we enter PHASE_TERMINATE
o Give a new prompt when we go to PHASE_DEAD
o Stop the modem timer properly when idle
o Treat sig 15 like an exiting carrier loss
o Log (DEBUG) offline & online transitions


# 75240ed1 25-Oct-1997 Brian Somers <brian@FreeBSD.org>

Cosmetic (no functional changes):
o Add missing $Id$s
o Move extern decls from .c -> .h files
o Staticize
o Remove #includes from .h files
o style(9)ify includes
o bcopy -> memcpy
bzero -> memset
bcmp -> memcmp
index -> strchr
rindex -> strrchr
o Move timeout.h -> timer.h (making it consistent w/ timer.c)
o Add -Wmissing-prototypes


# 9a571ec7 24-Oct-1997 Brian Somers <brian@FreeBSD.org>

sleep => nointr_sleep
usleep => nointr_usleep
(not just a #define)
Already done by: ache


# 331953ab 16-Oct-1997 Brian Somers <brian@FreeBSD.org>

cosmetic:
o Log client connection commands when "set log +command"
o Don't display PAP password in the log unless we're
"set log +debug".


# 03604f35 06-Oct-1997 Brian Somers <brian@FreeBSD.org>

Support VJ maximum slot identifiers != 15.
Support VJ slot id compression.

Previously, ppp would negotiate a max slot between 2 & 15
(if asked), and would agree to slot id compression (if asked).
It would then proceed to use 16 slots and no compression
anyway. The result was a rather unusable connection.


# 35495bec 21-Sep-1997 Brian Somers <brian@FreeBSD.org>

Correct the way the uucp lock file and the ttyXX.if lock
file get created. We don't create lock files over non-tty
connections, but we *do* create lock files in -direct mode.
This leaves us capable of adding utmp/wtmp support for
successful pap & chap logins (coming soon).


# c47cab61 21-Sep-1997 Brian Somers <brian@FreeBSD.org>

It turns out that the following:
close(1);
close(2);
x = open(ctermid(NULL), O_RDWR|O_NONBLOCK);
close(0)
on a tty causes select() to return an exception for descriptor x !
This is the case in RELENG_2_2, but not in 2.2.2. I'm not sure why.
Instead of doing the x=open() and close(0), we just do x=0 now.
Problem pointed out by: Greg Lehey <grog@lemis.com>
Tomi Vainio <tomppa@fidata.fi>


# fd2bc5eb 17-Sep-1997 Brian Somers <brian@FreeBSD.org>

Don't close(1) in direct mode and then proceed to
isatty(1) ! Keep 0 open for this till the modem's
been set up by either dup()ing 0 or by opening
ctermid(NULL) (if isatty(0)).

Discussed problem with: Tomi Vainio <tomppa@fidata.fi>
Made it finally dawn on me: Angelo Turetta <ATuretta@stylo.it>


# bc240299 16-Sep-1997 Brian Somers <brian@FreeBSD.org>

o Fix two unlikely descriptor leaks.
o Output the correct device for "show modem"
while in -direct mode.
o Cosmetic: Moan a bit more when we can't open
the [modem] device.
o Call OpenModem() in a more "natural" way.
o Add some LogDEBUG in OpenModem().


# 683cef3c 03-Sep-1997 Brian Somers <brian@FreeBSD.org>

Install as group ``network''
Insist that uid == 0 for client ppp
Disallow client sockets if no password is specified
Don't exit on failure to open client socket for listening
Allow specification of null local password
Use reasonable size (smaller) ``vector''s in auth.c
Fix "passwd ..." usage message
Insist on "all" as arg to "quit" (if any)
Drop client socket connection before Cleanup() when "quit all"


# afc7fa2c 31-Aug-1997 Brian Somers <brian@FreeBSD.org>

Cosmetic: Make LogPrintf() calls consistent.


# 709db7fb 31-Aug-1997 Brian Somers <brian@FreeBSD.org>

Remove use of login_progok()
Suggested by: guido


# ce28475d 27-Aug-1997 Brian Somers <brian@FreeBSD.org>

Use login_progok().


# 4e752f44 26-Aug-1997 Brian Somers <brian@FreeBSD.org>

Check the "prog.deny" login.conf capability and
refuse to run if "ppp" is in the list.
Suggested by: "Daniel O'Callaghan" <danny@panda.hilink.com.au>


# f525ead3 24-Aug-1997 Brian Somers <brian@FreeBSD.org>

Lose a couple of extraneous backslashes.


# 944f7098 24-Aug-1997 Brian Somers <brian@FreeBSD.org>

Make the code format more in line with style(9).
Update loadalias to use the new libalias api.
Update to version 1.1.


# de451c68 21-Aug-1997 Brian Somers <brian@FreeBSD.org>

Add "set loopback on|off", defaulting to "on".
This tells ppp to loopback packets addressed to
the ppp interface IP coming *from* the tun
device.

This means that you can ping the tun interface IP
from inside :-)


# 873725cc 01-Jul-1997 Brian Somers <brian@FreeBSD.org>

Make HUP cause an exit (as it used to), and make
INT cause a hangup - not exiting for -ddial & -auto.

HUP must exit because init sends this at system shutdown
time (why, I don't know), and we don't want to end up
redialing after the HUP (due to another dfilter packet).

Pointed out by and discussed with: ache


# 76c5241d 29-Jun-1997 Brian Somers <brian@FreeBSD.org>

Fix HUP handling while dialing.

Pointed out by: ache


# 4ef16f24 25-Jun-1997 Brian Somers <brian@FreeBSD.org>

Add "set server" to control the server socket.
Catch SIGUSR1 to re-init listening socket.
Document signal behaviour.

Add missing '\n's to LogPrintf(LogWARN,...)
Main() returns int not void.

AF_LOCAL ideal suggested a long time ago by: joerg


# 030d3ce6 24-Jun-1997 Brian Somers <brian@FreeBSD.org>

Fix ~? output in "term" mode.

Spotted by: Harry Starr <starr@gccs.com.au>


# 368aee2b 23-Jun-1997 Brian Somers <brian@FreeBSD.org>

o Fix uptime for direct connections.
o Style police
o Make hangup abort the current connection, not
necessarily exiting (-auto/-ddial).
o Trap HUP and INT during DoChat and abort the
connection attempt. This means you can now
type "dial" and change your mind with ^C, or
HUP the process to stop it dialing.

Slapped into doing it by: Chuck Robey <chuckr@glue.umd.edu>


# 712ae387 16-Jun-1997 Brian Somers <brian@FreeBSD.org>

Handle redial tries correctly under -ddial


# cc39a98f 16-Jun-1997 Brian Somers <brian@FreeBSD.org>

Set netfd to STDOUT_FILENO rather than STDIN_FILENO.


# d656a4c5 16-Jun-1997 Brian Somers <brian@FreeBSD.org>

Remove call to daemon(). Just call setsid() and close
any relevent descriptors (0,2,[1]). We've already fork()d.
PR: 3874


# 0706ff38 10-Jun-1997 Brian Somers <brian@FreeBSD.org>

Sort out ppp over tcp:
o Allow "set var" with no args to blank var (don't req "").
o Zero VarTerm ASAP if not in interactive mode.
o Never print anything to stdout in -direct mode.
o Count redial when failing to open modem.
o Increase device size to 40 characters (for host:port).
o Remove missed "if (fd == 0) fd = 1;".
o Don't give up on incoming non-terminal connections.


# 927145be 08-Jun-1997 Brian Somers <brian@FreeBSD.org>

Overhaul ppp:
o Use syslog
o Remove references to stdout/stderr (incl perror())
o Introduce VarTerm - the interactive terminal or zero
o Allow "set timeout" to affect current session
o Change "set debug" to "set log"
o Allow "set log [+|-]flag"
o Make MSEXT and PASSWDAUTH stuff the default
o Move all #ifdef DEBUG stuff into the code - this
shouldn't be too much overhead. It's now controlled
with "set log +debug"
o Add "set log command, debug, tun, warn, error, alert"
o Remove cdefs.h, and assume an ansi compiler.
o Improve all diagnostic output
o Don't trap SIGSEGV
o SIGHUP now terminates again (log files are controlled
by syslog)
o Call CloseModem() when changing devices
o Fix parsing of third arg of "delete"

I think this fixes the "magic is same" problems that some
people have been experiencing.
The man page is being rewritten. It'll follow soon.


# 1f3dee4c 31-May-1997 Brian Somers <brian@FreeBSD.org>

Remove initial startup printf's in -direct mode.
Make "same magic" error send a NAK (as per rfc).


# e83481f9 28-May-1997 Brian Somers <brian@FreeBSD.org>

Correct the return of DialModem()

Suggested by: kfurge <kfurge@worldnet.att.net>


# 6ed9fb2f 25-May-1997 Brian Somers <brian@FreeBSD.org>

De-couple ppp from libalias. If libalias isn't there, the
alias commands simply won't work. Only root may specify the
location of the alias lib (otherwise, it's hard-coded).

Make logprintf silently fail if LogOpen hasn't been called.

Suggested by: eivind


# 25aa96ac 24-May-1997 Brian Somers <brian@FreeBSD.org>

Fix the reconnect option, and add an explanation to vars.h


# c9bf343a 22-May-1997 Brian Somers <brian@FreeBSD.org>

Add SO_REUSEADDR socket opt in case the last telnet
connection is in a time_wait.

Submitted by: Brian Campbell <brianc@pobox.com>


# 6db75539 22-May-1997 Brian Somers <brian@FreeBSD.org>

Use the latest alias engine - now in libalias.

Submitted by: Charles Mott <cmott@srv.net>


# 80e37c72 18-May-1997 Brian Somers <brian@FreeBSD.org>

Output exit status description of child in background mode.


# 6efd9292 18-May-1997 Brian Somers <brian@FreeBSD.org>

Mega update to sort out bad implementations
of reconnect & -background.

o Fix reconnect anomolies.
o Make reconnect apply to failed LQR hangups (& mention in man page).
o Make reconnect effective in -background mode.
o Listen on socket in -background mode.
o Try all phone numbers in -background mode.
o Insist on system arg in -background mode.
o Make a control-connection close command exit in -background mode.
o Output status message to stdout on exit of parent in -background mode.
o Don't notify parent of success too soon.
o Describe termination EX_* code.
o Miscelaneous diagnostic corrections.
o Remove redundant connect_time from modem.c.
o Don't repeatedly DownConnection().


# 220e07d4 17-May-1997 Brian Somers <brian@FreeBSD.org>

Make openmode active by default (for both client/server).

Requested by: The masses.


# 298091da 13-May-1997 Brian Somers <brian@FreeBSD.org>

Build pid_filename without a double slash.
Make ``Dial attempt'' diagnostics consistent.

Reset lostCarrier when it has reached max.
Suggested by: Kevin Street <street@iName.com>


# aefd026a 11-May-1997 Brian Somers <brian@FreeBSD.org>

Create ttyXX.if and tunX.pid irrespective of
whether we're -dedicated.

Required by: David Nugent <davidn@labs.usn.blaze.net.au>


# 41c6c543 09-May-1997 Brian Somers <brian@FreeBSD.org>

Add a ttyXX.if file in /var/run that points to
the tunX.pid file. Change the ppp.tunX.pid name
to tunX.pid

Requested by: Daniel O Callaghan <danny@panda.hilink.com.au>


# 274e766c 09-May-1997 Brian Somers <brian@FreeBSD.org>

Tidy up the code - bounds checking, return
value checking etc.

Submitted by: eivind


# 63202ff1 03-May-1997 Andrey A. Chernov <ache@FreeBSD.org>

Log each ppp line to separate /var/log/ppp.tunX.log instead mixing of
all lines into single /var/log/ppp.log


# 07030d97 20-Apr-1997 Brian Somers <brian@FreeBSD.org>

Add a reconnect capability directing ppp to re-establish
the connection after an unexpected loss of carrier:

set reconnect timer ntries

The man page warns against using this command when your
timeout value is slightly more than the other sides :{}

Suggested by: burton@bsampley.vip.best.com (Burton Sampley)


# 43ea9d19 14-Apr-1997 Brian Somers <brian@FreeBSD.org>

Make the next number redial ability configurable. The
"set redial pause [times]" command becomes
"set redial end-pause[.next-pause] [times]" and next-pause
defaults to 3 seconds. This keeps things backwards
compatable.

Suggested by: ache


# 4ed9958f 12-Apr-1997 Brian Somers <brian@FreeBSD.org>

Make -background option attempt each phone number at most
once. Make -background ignore redial. Output exit value
to syslog with "PPP Terminated" message.


# c0139fb2 12-Apr-1997 Brian Somers <brian@FreeBSD.org>

Only wait for the redial timeout when the last phone number in the
list has been dialed. Alternate number dialing has no "pause".

Suggested by: joerg

Document this behaviour. Document that the number of dial attempts
applies to the number of phone calls rather than the number of times
each number is dialed. Add a missing .El. Give a decent description
of how to connect to an ISP.


# e0d3e233 09-Apr-1997 Andrey A. Chernov <ache@FreeBSD.org>

Ignore SIGPIPE or any user can quit ppp just telnetting to it
and quitting telnet immediately (while phone number dialed)
Log client connection/disconnection with PHASE_BIT now.
Add more error recovery on client disconnection


# 6e4959f0 13-Mar-1997 Brian Somers <brian@FreeBSD.org>

Closes pr 2711
Fix -background option. Parent returns after the line is established
(or not established).
Definitely a candidate for 2.2


# c6c740be 13-Mar-1997 Brian Somers <brian@FreeBSD.org>

Requested by: Harlan Stenn <Harlan.Stenn@pfcs.com>

Accept SIGHUP as a "re-open logfile" signal. As ppp
doesn't set it's serial line to it's controlling terminal,
we can use HUP :)

This is a candidate for 2.2. The log.[ch] changes won't
conflict, but the main.c changes will. We just want to change the
kill(...,SIGHUP) to a SIGTERM and change the signal(SIGHUP,Hangup)
to a pending_signal(SIGHUP,LogReOpen).


# f5ff0f7c 12-Mar-1997 Brian Somers <brian@FreeBSD.org>

Reviewed by: ache@freebsd.org
These changes should fix the signal "problems" in ppp.
The signal changes should really be put into 2.2 too !
The following patches should do it. There were some other
changes made by Andrey recently that havn't been brought
into 2.2, it may be worth doing them now.


# 780700e5 09-Mar-1997 Andrey A. Chernov <ache@FreeBSD.org>

Don't waste time scanning tun_in+10 descriptors, scan exactly what
we need now.
Don't assume that file descriptor can't be 0 (many places)
Protect FD_* macros from being used with negative descriptors
Shorten MS EXT show help to fit 80 cols


# bbea88d0 09-Mar-1997 Andrey A. Chernov <ache@FreeBSD.org>

I remove pending signals completely, they are not useless, they are
dangerous! Signal handlers themself must be fixed to not call malloc,
but no pended handlers, it will be correct fix. In finite case each signal
handler can set some variable which will be analized later, but calling
handler functions manually is too dangerous (f.e. signals not blocked while
the handler or handlers switch executed in this case). Of course this
code can be fixed instead of removing, but it not worth fixing in any case.

Should go into 2.2

In addition sig.c code shows following dangerous fragments (there can be more,
but I stop after two):

This fragment

if (fn == SIG_DFL || fn == SIG_IGN) {
handler[sig-1] = (sig_type)0;
<------------- here
signal(sig,fn);
} else {

cause NULL pointer reference when signal comes
"here", but more worse fragment is below:

void handle_signals() {
int sig;

if (caused)
for (sig=0; sig<__MAXSIG; sig++, caused>>=1)
if (caused&1)
(*handler[sig])(sig+1);
}

caused is bitmask which set corresponding bit on each signal coming.
And now imagine, what happens when some signal comes (bit sets) while loop
is executed (see caused>>=1 !!!)

In this light carrier drop situation was (as gdb shows)
1. SIGSEGV in handle_signals because some junk called as *handler reference.
2. Since SIGSEGV was pended too (== never happens),
it can cause various range of disasters.


# d7f5ee41 07-Mar-1997 Andrey A. Chernov <ache@FreeBSD.org>

Unpend fault signals like SIGSEGV, etc
It is too dangerous to continue with them in any case

Should go into 2.2


# 06257ca4 08-Mar-1997 Andrey A. Chernov <ache@FreeBSD.org>

Unpend all killing signals to shut down this thing immediately,
or it is impossible to kill it in some situations.
Unpend yet one SIGARLM (see timer.c commit)

Should go into 2.2


# c3b6ad66 25-Feb-1997 Brian Somers <brian@FreeBSD.org>

osreldate.h stuff suggested by: Eivind Eklund

Remove #include's from sig.h and get dependant modules to include them
themselves. Make inclusion of if_var.h depend on __FreeBSD_version so
that the -current version of ppp can be used with 2.1.*

2.2 Candidate ?


# 476602a9 22-Feb-1997 Peter Wemm <peter@FreeBSD.org>

Revert $FreeBSD$ to $Id$


# 52cc0880 18-Feb-1997 Brian Somers <brian@FreeBSD.org>

Tidy up signal handling.
All signal() calls have been changed to pending_signal() calls.
pending_signal() is defined in the new sig.c file. It remembers
the handler and traps the signal with a function that will remember
the signal.

main.c now calls handle_signals() to actually call the required
handlers (if the above handler was called).

If this doesn't close PR2662 (was PR2347), I'll cry.

Joerg, I think this should go into 2.2, but I havn't done anything
about it because I'm bound to botch it with the new sig.[ch] files.

I've just "cvs add"'d sig.[ch] so far.... can you update to 2.2 and
tell me what you did ? Thanks.


# 534fe541 29-Jan-1997 Brian Somers <brian@FreeBSD.org>

Check the timer request flag irrespective of wheter select() came back with
EINTR - it's possible that it happened at some other point in the loop.


# 6b0b88d8 28-Jan-1997 Brian Somers <brian@FreeBSD.org>

Move the call to TimerService() into main.c - just after the select()
call. The SIGALRM just sets a flag now, preventing the possibility of
any nasty recursivness in the handler itself.


# 1130b656 14-Jan-1997 Jordan K. Hubbard <jkh@FreeBSD.org>

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


# 99c02d39 10-Jan-1997 Warner Losh <imp@FreeBSD.org>

Fix many buffer overruns in the code. Specifically, disallow ExpandString
to be used to expand things beyond the size of the buffer passed in. Also
do a general cleanup of sprintf -> snprintf as well as strcpy and strncat
safety. Also expand some buffers to allow for the largest possible data
that might be used.

This is a 2.2 candidate. However, it needs to be vetted on -current
since little testing has been done on this due to my lack of PPP on
this machine.

Reviewed by: Jordan Hubbard, Peter Wemm, Guido van Rooij


# 6d14e2a8 22-Dec-1996 Jordan K. Hubbard <jkh@FreeBSD.org>

For /usr/sbin/ppp, you must choose between running ppp in the background or
connecting to a host immediately in the foreground.

I would like to be able to run ppp from a script so that my script can be
sure that it is connected to the 'net before it continues running:

# Dial up the internet.
ppp -background myprovider || exit 1

do-some-net-command

# Hang up the modem.
kill -HUP `cat /var/run/ppp.tun0.pid`

Another problem is that the current ppp calls its process id file
`/var/run/PPP.server', which may conflict if you have more than one IP
tunnel interface available.

Closes PR#1469
Submitted by: Gord Matzigkeit <gord@enci.ucalgary.ca>


# 3b92d2de 18-Dec-1996 Nate Williams <nate@FreeBSD.org>

Fixed prototypes of PacketAliasIn/Out. (cosmetic)

Submitted by: Brian Somers <brian@awfulhak.demon.co.uk>


# a9f484e5 12-Dec-1996 Jordan K. Hubbard <jkh@FreeBSD.org>

The infamous IP aliasing code for ppp, modified to work as a runtime option
(otherwise ppp's behavior remains unchanged) and documented by myself,
Steve Sims, Nate Williams, Martin Renters and god-only-knows who else. :-)
Submitted by: nate
Obtained from: Charles Mott <cmott@srv.net>


# 680026d6 03-Dec-1996 Nate Williams <nate@FreeBSD.org>

Added my 'ddial' patches to user-PPP. The new mode tries it's darndest
to keep the link up, so it re-dials whenever it detects the link go
down. This is useful for 'dedicated' links who use PPP.

It's been used for over a year w/out problems at different sites.


# b0cdb3ce 12-Oct-1996 Jordan K. Hubbard <jkh@FreeBSD.org>

1. Room to calculate MD5 for CHAP negotiation is shorter than
required. a core is not dumped at first connecting time and
dumped at second or third time. (patch I)
2. A routine for "show route" refers out of allocated space.
Values pointed by "lp" should be read as CHAR, I think.
there is also no free() for disallocation. (patch II)

Here is also a patch for an improvement: In current imprementation,
even if PPP connection is disconnected by time out, prompt of
interactive mode does not change from "PPP>" to "ppp>" to
indicate the disconnection on a terminal.
So I modified the code to do that. (patch III)

Submitted-By: NAKAMURA Motonori <motonori@econ.kyoto-u.ac.jp>


# 9f202f0c 06-Oct-1996 Jordan K. Hubbard <jkh@FreeBSD.org>

Properly include prototypes.
Submitted-by: "Daniel O'Callaghan" <danny@panda.hilink.com.au>


# af83607c 09-Jul-1996 Andrey A. Chernov <ache@FreeBSD.org>

Dump core on SIGSEGV instead of silent exiting. I saw SIGSEGV few times,
but they are VERY rare to tracking down this bug. I hope core
helps to track it down.


# 9c749ffb 11-May-1996 Poul-Henning Kamp <phk@FreeBSD.org>

Here is a diff of /usr/src/usr.sbin/ppp against current. The diffs
add some logging functionality which I find very useful.
'set debug link' will record just link up/down and address assignments.
'set debug connect' will record the entire chat dialog
'set debug carrier' will record just chat lines including 'CARRIER'
(so that I can be sure I'm getting a 28.8 line).

There was a global change required to permit LogPrintf to take a bit
mask instead of a bit position value (to permit logging some events
on either of two flags, so that no change in 'set debug lcp' would
result from the code supporting 'link'. Thus the diffs are rather
long for such a small change. The man page is also touched.

Oh, and there was a slight syntax problem in route.c

Reviewed by: phk
Submitted by: Tony Kimball <alk@Think.COM>


# 93d2c1bd 13-Apr-1996 Bruce Evans <bde@FreeBSD.org>

Fixed a couple of format strings to match the change of pid_t from long
to int32_t. I only fixed the ones that I noticed the warnings for.
Perhaps most of the format strings are correct now because they were
wrong before. Except of course if int32_t isn't compatible with `int'.


# 7a8ef19e 30-Mar-1996 Andrey A. Chernov <ache@FreeBSD.org>

Put signal number into logfile


# d91680ea 09-Mar-1996 Andrey A. Chernov <ache@FreeBSD.org>

1) Open /dev/null for std* after setsid() to be shure that modem is
*not* our controlling terminal (SIGHUP can coming in other case)

2) Add HUPCL for non-dedicated lines to be shure that modem
properly resetted.

3) Correct usage string.


# 1dff3fc5 08-Mar-1996 Andrey A. Chernov <ache@FreeBSD.org>

1) Add multi-phone dialing/redialing, several phones separated by ':'
2) Improve on-line help subsystem
3) Make 'term' mode works even carrier dropped (old code
close line forever here)
4) Make 'term' mode 8bit clean.
5) Improve manual page
6) #ifdef DEBUG diagnostic about missing optional files.
7) Don't put interactive dialing info to logfile


# 76bd0c0a 30-Jan-1996 Doug Rabson <dfr@FreeBSD.org>

Some patches to ppp which improve stability. I have been running a
ppp based on these patches for about 3 weeks with no downtime.

The original submitters comments:

Two features iijppp has over kernel ppp that I like are predictor1
compression and demand dialing. Here are a few bug fixes.

I expanded the priority queueing scheme and discovered it was broken
due to the assignment at ip.c line 300. All packets were being
queued at the same priority.

Fixing priority queueing broke predictor1 compression. Packets
were compressed before being queued and predictor1 worked as long
as the packets were popped off the queue in the same order they
were pushed onto the queue.

There were a few byte order problems in IP header tests also.

There is a recursion problem in SendLqrReport(). LcpClose() is
called when "Too many echo packets are lost" which winds up in
SendLqrReport() again. I believe the original intention was to
just stop the LQR timer with the call to StopLqr() but the side
effects hurt.

Submitted by: John Capo <jc@irbs.com>


# ed6a16c1 11-Jan-1996 Poul-Henning Kamp <phk@FreeBSD.org>

Final cleanup for now. -Wall is now silent. A couple of bogons found.


# 7b64106a 10-Jan-1996 Poul-Henning Kamp <phk@FreeBSD.org>

A random bunch of cleanup changes.


# a9c6b5df 08-Oct-1995 Atsushi Murai <amurai@FreeBSD.org>

1. Add a settable redial timer and logging of the process id in a file.
A settable redial timer helps to avoid the problem where both ends
of a link want to dial at the same time and the line winds up busy
for both ends. The process id is logged in /var/run/PPP.system where
system is the name of the called system. When both ends of a link
are running in demand dial mode, you need an easy way to get the pid
of the ppp on the called end so it can be killed and re-started with
-direct or pppd started to handle the incoming ppp session.

2. Add secret description for "set timeout" to man.

Reviewed by: Atsushi Murai <amurai@spec.co.jp>
Submitted by: John Capo <jc@irbs.com>


# 68d2b4d6 17-Sep-1995 Bruce Evans <bde@FreeBSD.org>

Fix a comment that became wrong when it was moved in rev. 1.7. Fix nearby
indentation. Cosmetic.


# f1884650 17-Sep-1995 Atsushi Murai <amurai@FreeBSD.org>

1. All fragments (except the first one) of a fragmented packet were
dropped - devet@adv.IAEhv.nl (Arjan de Vet)
2. Will not read data from telnet connection - John Capo <jc@irbs.com>
3. Using LQM option could be drop the link due to LcpLayerDown() doesn't
stop LQR timer. - Brian <brian@awfulhak.demon.co.uk>
4. Allow to describe a syntax of filters that is not only port number
but also by name in /etc/service. - Rich Murphey <rich@lamprey.utmb.edu>

Reviewed by: Atsushi Murai <amurai@spec.co.jp>
Submitted by: devet@adv.IAEhv.nl, jc@irbs.com, brian@awfulhak.demon.co.uk,
rich@lamprey.utmb.edu


# c3899f8d 02-Sep-1995 Atsushi Murai <amurai@FreeBSD.org>

1. Do not log the password itself to ppp.log ( Mr. Rich Murphey )
2. Add ability to execute shell commands and suspend back into
invoking shell (Mr. J Wunsch)

Reviewed by: amurai@spec.co.jp
Submitted by: joerg_wunsch@uriah.heep.sax.de (Joerg Wunsch)
Rich Murphey <rich@lamprey.utmb.edu>


# 60e218e4 08-Jul-1995 Atsushi Murai <amurai@FreeBSD.org>

1. Clean up log message.
2. Optimize ModemQlen.
3. Sending ProtoReject for Unknow protocol (i.e. IPX)
4. Avoid select looping by reading tun under the high system load.
5. Adding Local version String for maintenance.
6. Just more speak rather silent ignore if you type invalid key words.


# bea0b497 05-Jul-1995 Satoshi Asami <asami@FreeBSD.org>

"anyone in a world" -> "anyone in the world".

(Yes, I'm just testing my ppp connection :)


# 709e8f9a 29-May-1995 Rodney W. Grimes <rgrimes@FreeBSD.org>

Remove trailing whitespace.


# 84b8a6eb 11-Mar-1995 Atsushi Murai <amurai@FreeBSD.org>

1.Reducing cpu usage at off connection.
2.Implment Redail function as working correctly.
3.Clean up a code as I notice.
4.Now, RTT getting close to 50ms with ISDN/TA 38400bps !!

Reviewed by: amurai@spec.co.jp
Submitted by: amurai@spec.co.jp


# 41db6564 27-Feb-1995 Atsushi Murai <amurai@FreeBSD.org>

Fixing minor bug and allow help(Not for all command) and quit
but not close line connection by "quit all" command if not
authorized.

Reviewed by: amurai@spec.co.jp
Submitted by: tony-o@iij.ad.jp amurai@spec.co.jp


# 53c9f6c0 25-Feb-1995 Atsushi Murai <amurai@FreeBSD.org>

New user Process PPP based on iij-ppp0.94beta2.

o Supporting SYNC SIO device (But need a device driver)
- add "set speed sync"
o Fixing bug for Predictor-1 function.
o Add new parameter that re-sent interval for set timeout commands.
o Improving RTT (Round Trip Time) and reducing processor time.
- Previous Timer service was using polling, and now using
SIGALRM ;-)
- A 0.94beta2 will not work correctly....

-- Follows are additinal feature not including 0.94beta2
o Support Proxy ARP
- add "enable/disable proxy" commands
o Marging common routine in CHAP/PAP.
o Enhancing LCP/IPCP log information.
o Support local Authfication connection on port 300x and tty.
- You can set up pair of your "hostname -s" and
password in ppp.secret. if either ppp.secret file nor
your hostname line don't exist, It will notify a message
and working as same as previous version.(Backword compatibility)
- If you did set up them, It's allow connection but nothing to do
except help and passwd command.
- add "passwd yourpasswd" commands
o Support afilter - keep Alive filter that a packet can send/receiving
according to ifilter/ofilter but doesn't count it as preventing idle
timer expires.
- Same syntax of other filters.
o Fixing bugs reported by current user for previous one. Thanks !!

Reviewed by: Atsushi Murai (amurai@spec.co.jp)


# af57ed9f 30-Jan-1995 Atsushi Murai <amurai@FreeBSD.org>