History log of /freebsd-current/usr.sbin/ppp/datalink.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


# 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.


# 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.


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

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


# 5d604c11 11-Oct-2004 Brian Somers <brian@FreeBSD.org>

Add a bunch of malloc() return checks

PR: 71592
Submitted by: Dan Lukes <dan@obluda.cz> with further changes


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

Make ppp WARNS=5 clean


# 9603d5b4 25-Mar-2003 Brian Somers <brian@FreeBSD.org>

Add a ``force-scripts'' option for using chat scripts with -direct and
-dedicated links.

Submitted by: Maksim Yevmenkin <myevmenk@exodus.net>


# 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


# f0067240 25-Aug-2002 Philippe Charnier <charnier@FreeBSD.org>

Replace various spelling with FALLTHROUGH which is lint()able


# 10be78d3 15-Jun-2002 Brian Somers <brian@FreeBSD.org>

Remove whitespace at the end of lines.


# 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>


# 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.


# ea59de37 04-Mar-2002 Brian Somers <brian@FreeBSD.org>

Don't blow away ``set escape'' settings when we've completed the
login phase. Just initialise the correct parts.

Originially submitted by: Vladimir B. Machulsky <bofhmail@yahoo.com>


# dad51e5c 23-Oct-2001 Brian Somers <brian@FreeBSD.org>

Don't avoid setting a 0 second timer in datalink_StartDialTimer() by
not setting any timer. Instead, set a 1 millisecond timer.

This ensures that ppp will come out of it's select() call after
losing carrier in -ddial mode with a reconnect period of 0 and
going to ST_OPENING, rather than waiting indefinitely for some
other event to wake ppp up.

Bump the ppp version number to indicate the event.

MFC after: 3 days


# 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>


# 6301d506 03-Jul-2001 Brian Somers <brian@FreeBSD.org>

Reduce the interface MTU by 2 when MPPE has been successfully negotiated.

This is necessary because MPPE will combine the protocol id with the
payload received on the tun interface, encrypt it, then prepend its
own protocol id, effectively increasing the payload by two bytes.


# a65be227 22-May-2001 Brian Somers <brian@FreeBSD.org>

Don't say ``Enter pause (-1) for redialing when we're using a random interval.
Show the calculated random value instead.

Suggested by: Bill Richter <richterb@binkley.foothill.net>


# 2fc2f705 03-Feb-2001 Brian Somers <brian@FreeBSD.org>

Untangle some cunfusion between the CLOSE_STAYDOWN, CLOSE_LCP and
CLOSE_NORMAL meanings. CLOSE_NORMAL doesn't change the currently
required state, the others do. This should stop ppp from entering
DATALINK_READY when LCP shutdown doesn't end up happening cleanly.

Bump our version number to reflect this change.


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

Various whitespace changes.
Make some functions static.


# 1038894e 18-Jul-2000 Brian Somers <brian@FreeBSD.org>

Support link identification from rfc1570
Two new commands are available; ``ident'' and ``sendident''.


# 5e269efe 26-May-2000 Brian Somers <brian@FreeBSD.org>

When we do a ``dial'' or ``open'' from DATALINK_READY, go to
DATALINK_CARRIER and turn off scripting.

This should fix instances where ``term'' is used followed by ~.
and then ``dial''/``open'' (it currently just sits there looking
at you).

Reported by: Tim Vanderhoek <vanderh@ecf.utoronto.ca>


# 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.


# 4b567bf2 21-Mar-2000 Brian Somers <brian@FreeBSD.org>

Don't bother setting the dial timer if we've closed a
background/foreground/direct and zero'd the redial/reconnect
counts.


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

To avoid namespace polution in NetBSD:

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


# 225e259d 26-Jan-2000 Brian Somers <brian@FreeBSD.org>

If we're in callback mode, don't forget this fact when we
get into datalink_Down().

Submitted by: David Hedley <david@inty.co.uk>


# 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>


# c39aa54e 20-Dec-1999 Brian Somers <brian@FreeBSD.org>

Notice and warn about unterminated quoted strings in commands.
The entire command is ignored if the syntax is invalid...


# ffcfaec7 02-Dec-1999 Brian Somers <brian@FreeBSD.org>

Be careful not to re-initialise `struct stat' while it still has
a running timer. This fixes a problem where a dial is manually
aborted, the hangup script kicks in and the chat timer ends up
on the timer queue twice (tick tick tick tick *boom*)


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

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


# 2cb305af 24-Nov-1999 Brian Somers <brian@FreeBSD.org>

Rewrite the link descriptor transfer code in MP mode.

Previously, ppp attempted to bind() to a local domain tcp socket
based on the peer authname & enddisc. If it succeeded, it listen()ed
and became MP server. If it failed, it connect()ed and became MP
client. The server then select()ed on the descriptor, accept()ed
it and wrote its pid to it then read the link data & link file descriptor,
and finally sent an ack (``!''). The client would read() the server
pid, transfer the link lock to that pid, send the link data & descriptor
and read the ack. It would then close the descriptor and clean up.

There was a race between the bind() and listen() where someone could
attempt to connect() and fail.

This change removes the race. Now ppp makes the RCVBUF big enough on a
socket descriptor and attempts to bind() to a local domain *udp* socket
(same name as before). If it succeeds, it becomes MP server. If it
fails, it sets the SNDBUF and connect()s, becoming MP client. The server
select()s on the descriptor and recvmsg()s the message, insisting on at
least two descriptors (plus the link data). It uses the second descriptor
to write() its pid then read()s an ack (``!''). The client creates a
socketpair() and sendmsg()s the link data, link descriptor and one of
the socketpair descriptors. It then read()s the server pid from the
other socketpair descriptor, transfers any locks and write()s an ack.

Now, there can be no race, and a connect() failure indicates a stale
socket file.

This also fixes MP ppp over ethernet, where the struct msghdr was being
misconstructed when transferring the control socket descriptor.

Also, if we fail to send the link, don't hang around in a ``session
owner'' state, just do the setsid() and fork() if it's required to
disown a tty.

UDP idea suggested by: Chris Bennet from Mindspring at FreeBSDCon


# 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.


# 87c3786e 06-Nov-1999 Brian Somers <brian@FreeBSD.org>

Support PPPoE

Help (lots) from: julian, archie
Facilities from: ahebert@pubnix.net


# c116e0c0 25-Oct-1999 Brian Somers <brian@FreeBSD.org>

Introduce ``set logout''; another chat script. This is in preparation
for the abstraction of ``set dial'' and ``set hangup''.


# 1b02dfb4 20-Oct-1999 Brian Somers <brian@FreeBSD.org>

Don't go from PHASE_NETWORK to PHASE_ESTABLISH when we want to
re-open a device. The fact that we're in NETWORK phase indicates
that there are other links in DATALINK_OPEN and that we don't want
to stop using them.


# d81ecf9a 08-Oct-1999 Brian Somers <brian@FreeBSD.org>

Revert the 1.44 -> 1.45 change. It doesn't work as expected.


# 14e34a55 07-Oct-1999 Brian Somers <brian@FreeBSD.org>

Don't go from datalink state opening directly to lcp, go via
carrier instead so that we can set up our carrier detect
timer and eventually notice when we lose carrier.

Honour the script.run value when coming out of carrier state.

PR: 14145


# d2f5232d 04-Oct-1999 Brian Somers <brian@FreeBSD.org>

Bring links down gently when their throughput isn't enough for
the ``set autoload'' value. Don't just ``down'' the link.
Don't get stuck in ``ready'' the first time we ``close'' a link.


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

$Id$ -> $FreeBSD$


# eb6e5e05 06-Aug-1999 Brian Somers <brian@FreeBSD.org>

Add ISDN support via isdnd & i4b. This requires version
0.81.1 of the i4b code - namely support of the I4B_VR_REQ
ioctl via the i4brbchX device.

Ppp controls the phone number, but idle timers and
SYNC/RAW decisions are still made by isdnd (in isdnd.rc).

This involves a new datalink state machine phase. The
``wait for carrier'' phase happens after dialing but
before logging in. The whole dial state should really
be abstracted so that each device type can deal with it
in its own way (thinking about PPPoE) - but that'll have
to wait.

The ``set cd'' symantics remain the same for tty devices,
but we now delay until we either get CD or timeout waiting
(at which time we drop the link if we require CD).

For i4b devices we always insist on carrier.

Thanks to hm@ for his help, and especially for pointing out
that I *don't* need to re-implement isdnd (that was a huge
waste of time !) :-]


# ab2de065 05-Aug-1999 Brian Somers <brian@FreeBSD.org>

o Obsolete the undocumented ``set weight'' command.
o If we're using RADIUS and the RADIUS mtu is less than our
peers mru/mrru, reduce our mtu to this value for NetBSD too.
o Make struct throughput's sample period dynamic and tweak the ppp
version number to reflect the extra stuff being passed through
the local domain socket as a result (MP mode).
o Measure the current throughput based on the number of samples actually
taken rather than on the full sample period.
o Keep the throughput statisics persistent while being passed to
another ppp invocation through the local domain socket.
o When showing throughput statistics after the timer has stopped, use
the stopped time for overall calculations, not the current time.
Also show the stopped time and how long the current throughput has
been sampled for.
o Use time() consistently in throughput.c
o Tighten up the ``show bundle'' output.
o Introduce the ``set bandwidth'' command.
o Rewrite the ``set autoload'' command. It now takes three arguments
and works based on a rolling bundle throughput average compared against
the theoretical bundle bandwidth over a given period (read: it's now
functional).


# 08da4867 18-Jun-1999 Brian Somers <brian@FreeBSD.org>

Don't use the ``next'' redial timer if we have no phone number at all.


# 194c225d 10-Jun-1999 Brian Somers <brian@FreeBSD.org>

Never bring a link back up after receiving a terminating signal,
don't rely on already being in PHASE_DEAD.


# 6815097b 12-May-1999 Brian Somers <brian@FreeBSD.org>

Allow ``host:port/udp'' devices and support ``host:port/tcp'' as
being the same as the previous (still supported) ``host:port''
syntax for tcp socket devices.

A udp device uses synchronous ppp rather than async, and avoids
the double-retransmit overhead that comes with ppp over tcp (it's
usually a bad idea to transport IP over a reliable transport that
itself is using an unreliable transport). PPP over UDP provides
througput of ** 1.5Mb per second ** with all compression disabled,
maxing out a PPro/200 when running ppp twice, back-to-back.

This proves that PPPoE is plausable in userland....

This change adds a few more handler functions to struct device and
allows derivations of struct device (which may contain their own
data etc) to pass themselves through the unix domain socket for MP.
** At last **, struct physical has lost all the tty crud !

iov2physical() is now smart enough to restore the correct stack of
layers so that MP servers will work again.

The version number has bumped as our MP link transfer contents have
changed (they now may contain a `struct device').

Don't extract the protocol twice in MP mode (resulting in protocol
rejects for every MP packet). This was broken with my original
layering changes.

Add ``Physical'' and ``Sync'' log levels for logging the relevent
raw packets and add protocol-tracking LogDEBUG stuff in various
LayerPush & LayerPull functions.

Assign our physical device name for incoming tcp connections by
calling getpeername().

Assign our physical device name for incoming udp connections from
the address retrieved by the first recvfrom().


# 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''.


# 0ca6f91b 06-Apr-1999 Brian Somers <brian@FreeBSD.org>

When going from DATALINK_HANGUP directly to
DATALINK_OPENING, don't forget to change phase
to ESTABLISH if we're currently TERMINATE'ing.
Helped locate by: Chuck Robey <chuckr@mat.net>


# 5945a079 05-Apr-1999 Brian Somers <brian@FreeBSD.org>

When we get an LCP TLU, go into PHASE_AUTHENTICATE
from any other phase besides PHASE_NETWORK, otherwise
there's a chance that we end up sending auth packets
and dropping the replies.


# c11e57a3 04-Mar-1999 Brian Somers <brian@FreeBSD.org>

Extend the ``set redial'' command to allow incremental
redial timeouts.


# 479508cf 26-Feb-1999 Brian Somers <brian@FreeBSD.org>

Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.

Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.

Don't suggest that CHAP 0x05 isn't supported when it's not configured.

Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).

Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !

This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.


# b5c347a3 24-Feb-1999 Brian Somers <brian@FreeBSD.org>

When our dial timeout is ``random'', display its value
correctly by invoking the timer to get the value before
displaying the message.
Don't assume that a value of 0 is ``random'' in
``show datalink''.
Make the random value between 1 and DIAL_TIMEOUT rather
than between 0 and DIAL_TIMEOUT-1


# 5e315498 17-Feb-1999 Brian Somers <brian@FreeBSD.org>

Fully support both NT and LANMan CHAP type 0x80 as both
authenticator and authenticatee.


# 64cfdfc6 16-Feb-1999 Brian Somers <brian@FreeBSD.org>

Nuke any remaining auth timers when datalinks come back down
to DATALINK_LCP.


# 58330d7b 11-Feb-1999 Brian Somers <brian@FreeBSD.org>

When resending chap challenges, resend the same challenge
each time rather than making up a new one.

Increase the authname/authkey max sizes to 100 characters.

Allow ``authkey'' specifications beginning with ``!''.
When a challenge is received, the text following the
``!'' is executed as a program (expanding stuff in the same
way that ``sh'' and ``!bg'' do). The program is passed the
peer name, peer challenge and local ``authname'' on standard
input and is expected to output the name/key combination that
should be used to build the CHAP response.

This provides support for Secure ID cards (guess what I was
given at work recently!) using CHAP.

Examples will follow.


# 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


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

Reimplement the previous fix (no response to PAP requests)
at the authentication layer rather than at the PAP layer
so that it also applies to CHAP (no response to CHAP
challenges).


# 8db502bb 01-Feb-1999 Brian Somers <brian@FreeBSD.org>

If we receive no answer from the server when sending PAP
requests, give up (don't sit there indefinitely).


# 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


# b51a60cc 20-Jan-1999 Brian Somers <brian@FreeBSD.org>

Recurse when we've switched state via LoginDone(). If we've
got an open link, we want it to be select()d on - otherwise
we get a freeze when ``openmode'' is passive.


# 5165af6f 12-Jan-1999 Brian Somers <brian@FreeBSD.org>

If we've configured CBCP *and* another not-so-important
CALLBACK protocol and end up agreeing CBCP, DTRT and go
into CBCP phase rather than mistakenly terminating as
if CBCP wasn't agreed.
Problem reported by: Alexander Dubinin <alex@nstl.nnov.ru>


# 47dd77c1 08-Jan-1999 Brian Somers <brian@FreeBSD.org>

Don't use the next phone number after the ``|'' if the
dial & login are successful.
Submitted by: Toshiomi Moriki <Toshiomi.Moriki@ma1.seikyou.ne.jp>
PR: 9382


# 8b09cf1c 15-Dec-1998 Brian Somers <brian@FreeBSD.org>

Fix a rather bad latency problem (uncovered by the recent timer commit).
Problem reported by: Christopher Hall <hsw@acm.org>


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

Boy, this was tricky to find:
Remove any dial timer that might be hanging around at
datalink_Destroy() time. This timer may be left running
after the link is closed (making sure it's not automatically
opened again too soon).


# cf784a89 16-Oct-1998 Brian Somers <brian@FreeBSD.org>

Explain what the ``*'' means for a CBCP phone number
in ``show link''.


# b6f5f442 17-Aug-1998 Brian Somers <brian@FreeBSD.org>

Destroy any existing chat timeouts in datalink_ComeDown()
If we're told to close/down while in DIAL or LOGIN state,
we don't want to keep our timeout running :-/


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

When entering ``term'' mode, don't output any messages until
the device is successfully opened. If we fail to open it,
mention the fact.
Also go back into command mode as soon as the device is closed
rather than waiting for the user to type something before noticing.


# 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.


# d4af231c 03-Jul-1998 Brian Somers <brian@FreeBSD.org>

Only start checking carrier when the datalink state machine
exceeds DATALINK_READY. When we go back to READY or less
(eg. ``close lcp''), switch the carrier-checking-timer off again.

This fixes the callback example in ppp.conf.sample.
Noted as broken by: Damian Kuczynski <damian@best.pw.edu.pl>


# 06337856 30-Jun-1998 Brian Somers <brian@FreeBSD.org>

The CCP layer now behaves as follows:
o If we've denied and disabled all compression protocols, stay
in ST_INITIAL and do an LCP protocol reject if we receive any
CCP packets.
o If we've disabled all compression protocols, go to ST_STOPPED
and wait for the other side to ask for something.
o If we've got anything enabled, start REQing as soon as the auth
layer is up.
o If we're in multilink mode, than the link level CCP goes
straight to ST_STOPPED irrespective of what's configured so that
we never try to compress compressed stuff by default.


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

Remove redundant includes


# 897f9429 25-Jun-1998 Brian Somers <brian@FreeBSD.org>

Add ``ipcp'' as an optional argument to ``open'', and make
open capable of re-negotiatiating the various layers.

It is now possible to change various link options and then
re-open the relevant layer, making the changes effective -
for example, switching off VJ compression or starting ECHO
LQRs on-the-fly.


# 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.


# 09206a6f 19-Jun-1998 Brian Somers <brian@FreeBSD.org>

Create & use fsm2initial(), a function to bring a
state machine back to ST_INITIAL without going
through any unnecessary TLS/TLF pairs.


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

Only set the datalink::stayonline flag if we
close/down with CLOSE_LCP when our state is
DATALINK_READY or higher.


# 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


# ff0f9439 12-Jun-1998 Brian Somers <brian@FreeBSD.org>

o Maintain a link-type mask for open datalinks as well as
for all datalinks in a bundle. Ppp now deals correctly
with link types that are changed while open
o When changing the type of the last AUTO link, only clear
the interface if we're not in PHASE_NETWORK. This allows
us to switch to -ddial mode while we have a connection
without suddenly unexpectedly throttling ourselves by
clearing the interface configuration.
Problem area noted by: Aaron Jeremias Luz <aaron@csh.rit.edu>


# 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>


# 85fd273a 28-May-1998 Brian Somers <brian@FreeBSD.org>

o Don't forget to close our transfer socket if we cannot
generate the data to transfer.
o Transfer uucp lock ownership for the transferred device.
o Don't assume we know the correct values of dev_is_modem and
mbits after the transfer.


# 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.


# 1df0a3b9 23-May-1998 Brian Somers <brian@FreeBSD.org>

o If all CCPs are disabled & denied, don't send a REQ - just enter
STOPPED state waiting for the peer to say something.


# 58d55334 16-May-1998 Brian Somers <brian@FreeBSD.org>

Add the `rename' command for renaming links.


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

o Add the `set mode' command for change a links current mode. It
is not possible to switch to or from dedicated or direct mode,
but all other combinations are ok (eg. -auto -> -ddial).
o Cope with the fact that commands with optional context may not
be able to obtain a link with command_ChooseLink() (if all links
have been deleted for example).
o Allow `clone'ing in non-multilink mode. We may for example want
to configure two links in unilink mode and dial them both, using
the one that comes up first. It's also possible to rename
``deflink'' by cloning it, deleting the original, then setting
the mode of the new link.


# 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.


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

o Activate link-level CCPs in multilink mode, by bringing them
into the ST_STOPPED state.
o Allow an optional ccp|lcp argument to `down'. The default is
still lcp (as before). You can now call down with no context
in multilink mode, in which case it'll down the multilink ccp
or the entire bundle (*very* rude).
o Allow an optional `!' after `close ccp' (close ccp!) to tell
ccp to stay in the CLOSED state after the terminate ACK. The
default is now to re-enter STOPPED so that the peer can bring
the layer back up if desired.
o Always handle proto-compressed packets, even if we've agreed
(in LCP) that the peer will not send us 1 byte protocols.
If the peer violates the LCP agreement, log it to the HDLC
log.
o Fix some comments.


# 66f634b6 11-May-1998 Brian Somers <brian@FreeBSD.org>

o Do an mp_Down() when aborting ppp.
o Re-assign the link name when strdup()ing the datalink name.
o Add the link name to some more hdlc log messages.


# 9ae58882 09-May-1998 Brian Somers <brian@FreeBSD.org>

Log datalink state transitions consistently.


# 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.


# 84917b87 06-May-1998 Brian Somers <brian@FreeBSD.org>

Log link name changes correctly.


# 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.


# 96c9bb21 02-May-1998 Brian Somers <brian@FreeBSD.org>

o Transfer file descriptors using {send,recv}msg & SCM_RIGHTS,
using the scatter/gather array to transfer the link
information. The whole link is now passed in one message.

This is far better than the two `/bin/cat' processes per additional
link :-) I remember years ago thinking that file descriptor
transferral would be a really amazing facility !

Suggested by: Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
and: Eivind Eklund <eivind@yes.no>


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

Cosmetic: Make our external function names consistent.


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

o Use two `cat' processes to connect the modem to an
already-running ppp.
Suggested by: Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
o Use _PATH_DEVNULL rather than "/dev/null"
o Be more paranoid about nuking running timers when
transferring links.


# 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....


# 9c281ab2 30-Apr-1998 Brian Somers <brian@FreeBSD.org>

Don't forget to set up our ppp.secret IP numbers & label
in non-MP mode.


# 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).


# 184d1da2 24-Apr-1998 Brian Somers <brian@FreeBSD.org>

Show our link name when we fail to mp_Up().


# 50abd4c8 24-Apr-1998 Brian Somers <brian@FreeBSD.org>

Make ``show ipcp'' prettier and remove a few redundant includes.


# 643f4904 24-Apr-1998 Brian Somers <brian@FreeBSD.org>

o Defer setting up pap/chap based IP numbers & labels until after
we've determined if we're going to join another ppp invocation.
o Make ``show link'' show all link details, and ``show links''
just give a list of links and their current status.
o Show our current label in ``show bundle''.
o Allow link cloning and removal as soon as our MRRU is set.
o Make ``show lcp'' require context as nothing will ever change
in our MP LCP (it's auto-configured as per rfc1990).
o Initialise our LQM owner in hdlc_Init().
o Store our endpoint discriminator and authentication name at both
the datalink and multilink level and compare them when we've
finished AUTHENTICATE phase and before entering NETWORK phase.
If they don't match, close the link again.
Display the information in the appropriate ``show'' command.
o Initialise datalink::phone and datalink::fsmp.object properly
when we're cloning the link.
o Show which link we're passing LQRs on in our diagnostics.
o Reject endpoint discriminator REQs at the logical multilink
level.
o Remove the rest of our CARRIER and LINK logging setup.


# ce828a6e 23-Apr-1998 Brian Somers <brian@FreeBSD.org>

o Add ipcp_SetLink() for attaching IPCP to the correct link, and
call it after link authentication.
o Pretty print our bundle MTU.
o Correct MP header encoding and decoding (should be network byte order).
o Add some debug diagnostics so that we can see MP fragment sending and
re-assembly.


# dbf60d74 23-Apr-1998 Brian Somers <brian@FreeBSD.org>

o Don't go multilink if the peer hasn't asked for it
o Don't go multilink if the peer hasn't agreed
o When negotiating multilink, don't try to push the peers
MRU up according to our `set mtu' setting. Instead, accept
whatever MRU they want and push their MRRU up instead.
o When *not* negotiating multilink, REJ short sequence number
REQs.


# 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.


# e3c70ce9 19-Apr-1998 Brian Somers <brian@FreeBSD.org>

Tidy up the use of struct pppTimer.


# 39d94652 18-Apr-1998 Brian Somers <brian@FreeBSD.org>

Destroy struct chat when it's finished in struct datalink.
Initialise chat timers correctly as they're malloc()ed as
part of struct datalink, and initially contain garbage.


# cdbbb6b5 17-Apr-1998 Brian Somers <brian@FreeBSD.org>

Cosmetic: Clean up warnings.


# 030e4ebb 17-Apr-1998 Brian Somers <brian@FreeBSD.org>

o Remove bundle_LinkLost() and have the modem routines simply
call datalink_Down() where appropriate rather than
modem_Hangup().
o Now, when something horrible happens (failed read/write, loss
of carrier etc), we go offline and run any hangup scripts etc
in a controlled manner - exactly the same as if someone says
``down'' at the prompt or sends us a HUP.
o -dedicated links that fail to make the modem raw close it,
suffer the redial timeout then try to open it again.
o Add a ``carrier lost'' warning diagnostic.


# 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.


# 25092092 14-Apr-1998 Brian Somers <brian@FreeBSD.org>

Pass all command arguments around with struct cmdargs rather
than incrementing argv and decrementing argc. Now individual
functions can determine their caller. This also removes the
"prefix" hack in FindExec().


# 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.


# 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.


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

Add the `clone' and `remove' commands for creating and destroying
links.


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

o Move VarMSChap into struct chap, and remove `set encrypt'
option. We never ask a client for MSChap when we've got
chap `enabled', and we dynamically answer using MSChap
if the peer demands it.
o Remove all of the bundle2*() series of functions except
bundle2datalink() as they're too expensive. The only
calls to bundle2datalink() are made from command.c when
determining context.
o Write to the correct modem in term mode, and check the
return value, dropping back to command mode if the write
fails.

Cosmetic:
Make the PPP COMMAND LIST section of the man page
prettier, better and more consistent. Alphabeticalise
all command lists and document missing commands.


# 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.


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

o Move default MRU, MTU, ACCMAP and OPENMODE config values into
struct lcp and display them in `show lcp'.
o Remove `show mru' and `show mtu' and make the data part of
`show lcp'. Also merge `set m[tr]u' and `set openmode'
implementations into the SetVariable function.
o `set timeout' only accepts the idle timer value as an argument.
o Move our lqr period into struct lcp, and create a `set lqrperiod'
command. Display it in `show lcp'.
o Remove VarRetryTimeout, and implement it at the LCP, PAP, CHAP,
CCP and IPCP levels, creating individual `set XXXretry' commands
for each. They must be separate because they have different
context requirements in multilink mode.
o Display default config values in `show ccp'.
o Tart the man page up a bit (wrt PPP/TCP, compression and LQR) and
explain the new commands.


# 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.


# 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.


# 92e872e7 18-Mar-1998 Brian Somers <brian@FreeBSD.org>

Bring LCP back to INITIAL in LayerFinish().


# c17d3e98 18-Mar-1998 Brian Somers <brian@FreeBSD.org>

Don't increment dial_tries twice.


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

Move VJ compression state and stats into struct ipcp.


# 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.


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

"dial" now may optionally have context.
Tidy up some LcpInfo uses.


# 5563ebde 12-Mar-1998 Brian Somers <brian@FreeBSD.org>

Remove the second bundle_NewPhase argument and do
the tun config from bundle_LayerUp.


# 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.


# f9545805 09-Mar-1998 Brian Somers <brian@FreeBSD.org>

Move phone numbers into struct datalink.
Make "show modem" look a bit prettier.


# 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.


# 6d666775 26-Feb-1998 Brian Somers <brian@FreeBSD.org>

Create struct fsm_parent. FSMs are created with one of these,
and the FSM passes subsequent events to them.

The datalink now hides its CCP from the bundle layer.


# 4bc1da96 26-Feb-1998 Brian Somers <brian@FreeBSD.org>

Don't enter DATALINK_HANGUP state if we're currently in
DATALINK_OPENING.... we'll hang there forever with no
open device.


# 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.


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

Merge LcpOpen functionality into datalink_LoginDone


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

Cosmetic: Group configuration items in struct datalink.


# 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.


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

Introduce the ``link'' command for controlling
individual links.


# 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.


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

Move the redial timeouts and max tries into struct datalink.


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

Move the reconnect timeout and max tries into struct datalink.


# 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.


# 310c3bab 15-Feb-1998 Brian Somers <brian@FreeBSD.org>

Cosmetic: Stop a warning


# 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 !