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


# 1814213e 05-Sep-2004 Marcel Moolenaar <marcel@FreeBSD.org>

Fix the build on 64-bit platforms.


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

Make ppp WARNS=5 clean


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

Replace various spelling with FALLTHROUGH which is lint()able


# 3627fe88 15-Jun-2002 Brian Somers <brian@FreeBSD.org>

A better prinflike fix...


# 3db95184 14-Jun-2002 Brian Somers <brian@FreeBSD.org>

Fix a printflike format error


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

Increase the maximum FSM option length to 50


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


# d14cc5f9 01-May-2002 Brian Somers <brian@FreeBSD.org>

If we receive a config request while Open, call TLD *before* decoding
the request as TLD may initialise fields that are set when decoding the
request.

MFC after: 1 week


# ff360cc9 16-Apr-2002 Brian Somers <brian@FreeBSD.org>

Make the way FSM options are processed easier to read by using structures
instead of u_char *.

The changes are cosmetic except:

RecvConfigAck() now displays the options that are being ACK'd
Huge (bogus) options sent from the peer won't cause an infinite loop
SendIdent and ReceiveIdent are displayed consistenlty with other FSM data
LCP AUTHPROTO options that aren't understood are NAK'd, not REJ'd


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

Add a missing break


# 1136c6ac 18-Aug-2001 Brian Somers <brian@FreeBSD.org>

Back out the previous fix to deal with kernels that don't support IPv6,
and implement a far more subtle and correct fix.

The reason behind the infinite loop was that ppp was trying to make up
initial IPv6 numbers and wasn't giving up when it failed unexpectedly to
assign the addresses it just fabricated to it's interface (thinking that
the reason was because another interface was using the same address).
It now attempts this up to 100 times before just failing and trying to
muddle along (in reality, this should never happen more than a couple
of times unless our random number generator doesn't work).

Also, when IPv6 is not available, don't even try to assign the IPv6
interface address in the first place...


# c5109a32 18-Aug-2001 Brian Somers <brian@FreeBSD.org>

Run correctly on a machine built without AF_INET6 support


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


# 6cf6ee76 18-Jun-2001 Brian Somers <brian@FreeBSD.org>

Add support for stateful MPPE (microsoft encryption) providing
encryption compatibility with Windows 2000. Stateful encryption
uses less CPU but is bad on lossy transports.

The ``set mppe'' command has been expanded. If it's used with any
arguments, ppp will insist on encryption, closing LCP if the other
end refuses.

Unfortunately, Microsoft have abused the CCP reset request so that
receiving a reset request does not result in a reset ack when using
MPPE...

Sponsored by: Monzoon Networks AG and FreeBSD Services Limited


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

Convert IIJ copyrights to BSD copyrights.

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


# 15c8dc2a 25-Jan-2001 Brian Somers <brian@FreeBSD.org>

If executing the stuff from ppp.linkdown results in a state change,
don't continue adjusting the ipcp state machine.

This allows ``down'' to work in ppp.linkdown - useful for a tunnel
setup.


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

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


# e97b220c 10-Jun-2000 Brian Somers <brian@FreeBSD.org>

Don't oan about padding characters


# 962a3cbc 26-May-2000 Brian Somers <brian@FreeBSD.org>

If the fsm header reports a length greater than the packet size,
drop the packet rather than just whinging about it in the log.
If the fsm header has a smaller length, continue to whinge.


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


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

Cosmetic: Make struct mbuf more like kernel mbufs.


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

Support PPPoE

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


# 990a543f 06-Oct-1999 Brian Somers <brian@FreeBSD.org>

Mention the received/expected magic for dodgy ECHO LQRs.


# 442f8495 03-Sep-1999 Brian Somers <brian@FreeBSD.org>

o Split the two IPCP queues into three - one for FSM data
(LCP/CCP/IPCP), one for urgent IP traffic and one for
everything else.
o Add the ``set urgent'' command for adjusting the list of
urgent port numbers. The default urgent ports are 21, 22,
23, 513, 514, 543 and 544 (Ports 80 and 81 have been
removed from the default priority list).
o Increase the buffered packet threshold from 20 to 30.
o Report the number of packets in the IP output queue and the
list of urgent ports under ``show ipcp''.


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

$Id$ -> $FreeBSD$


# 8a59beb7 10-Aug-1999 Brian Somers <brian@FreeBSD.org>

If we receive an IPCP protocol reject, bring it down.


# 411675ba 02-Jun-1999 Brian Somers <brian@FreeBSD.org>

o Alter the mbuf type as it's processed by different layers.
o Show more information about missing MP fragments in ``show mp''.
o Do away with mbuf_Log(). It was showing mbuf stats twice on
receipt of LCP/CCP/IPCP packets.... ???!!?
o Pre-allocate a bit extra when creating LQR packets to avoid having
to allocate another mbuf in mbuf_Prepend().


# 6471628d 14-May-1999 Brian Somers <brian@FreeBSD.org>

Handle LCP echo reqs properly again (broken with the
layering changes).


# 3377c28c 09-May-1999 Brian Somers <brian@FreeBSD.org>

Deal with the fact that as we now mbuf_Read the fsm
header in fsm_Input() we often end up with a NULL mbuf.

Deal with a possible NULL mbuf being passed into
mbuf_Prepend().

Adjust some spacing to make things more consistent.


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


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

Ensure that the thing we're casting to struct ip
is aligned for non-i386 architectures.


# 8a8d9927 28-Feb-1999 Brian Somers <brian@FreeBSD.org>

Comment why we do a TLF when we get a ``Down'' event in state
``closing''.

Pointed out by: archie

Don't do a TLF when we get a ``Catastrphic Protocol Reject'' event
in state ``closed'' or ``stopped''.

Pointed out but not suggested by: archie

This makes no difference in the current implementation as
LcpLayerFinish() does nothing but log the event, but I disagree
in principle because it unbalances the TLF/TLS calls which
(IMHO) doesn't fit with the intentions of the RFC.

Maybe the RFC author had a reason for this. It can only happen
in two circumstances:

- if LCP has already been negotiated then stopped or closed and we
receive a protocol reject, then we must already have done a TLF.
Why do one again and stay in the same state ?

- if LCP hasn't yet been started and we receive an unsolicted
protocol reject, why should we TLF when we haven't done a TLS ?


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


# 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


# 9e8ec64b 04-Sep-1998 Brian Somers <brian@FreeBSD.org>

Don't cast potentially unaligned addresses to pointers to
non-char types on non-i386 architectures.
On Alpha and Sparc we get a bus error if we do.


# 68a0e171 31-Jul-1998 Brian Somers <brian@FreeBSD.org>

When we receive an LCP config REQ in Opened state,
do TLD *before* processing the config request as
TLD initialises the peers LCP values.

It's strange that an IRC isn't required here - but
I'll bow to the wisdom of the rfc.


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


# 3a2e4f62 27-Jun-1998 Brian Somers <brian@FreeBSD.org>

o Fix remaining sizeof problems for 64 bit machines.
o Allow ``set ....'' when we have multiple links but aren't in
multilink mode.
o Do a TLS when we receive a ``Open'' event in ``Closed'' state,
despite the rfc state transition table. This is clearly an
error in the RFC as TLS cannot have yet been called (without
TLF) in the ``Closed'' state.
I've posted a message to comp.protocols.ppp for confirmation.


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


# 74d14b4c 19-Jun-1998 Brian Somers <brian@FreeBSD.org>

Do an InitRestartCounter when we get a TerminateReq
in Opened state..... I have no idea why this never
caused problems in the past - maybe the restart
counter was bogusly initialised somewhere else :-/


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


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


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


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


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

o Remove LINK level logging.
o change the default link name to ``deflink'' rather
than ``default''.
o Prepend the link name to CCP and LCP FSM diagnostics.
o Protect against 0 length options in CCP and IPCP REQ
interpreters (already done for LCP).
o Allow optional context for the `show' command.
o Use MPs link when interpreting commands if the multilink
mrru is configured rather than when multilink is active.
This means that once we've ``set mrru xxx'', we then need
to ``link deflink show ccp'' etc if we want to do link-level
stuff (based on the command requiring optional or manditory
context).
o Use the ifconfig'd interface address in `set enddisc {ip,mac}'
if it's there, otherwise the configuration file value.


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

o Initialise MP correctly depending on if we're the
first link in mp_Up().
o Bring MP and its CCP down when we enter phase TERMINATE,
and ditch everything in the incoming packet queue.
o Enable MRRU negotiation. Now, we can multilink
mode, but only with one physical link.
o Close the link if the peer PROTO REJs PROTO_MP.
o Prepend our protocol before passing a packet to
struct mp for fragmentation.
o Log info messages to DEBUG, not ERROR (oops).
o Align `show mp' output (again).


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

o Use __attribute__ (#ifdef __GNUC__) to type-check
LogPrintf() and prompt_Printf(), and fix the bits
identified as being wrong as a result.


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

Tidy up the use of struct pppTimer.


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


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


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


# 1e991daa 24-Mar-1998 Brian Somers <brian@FreeBSD.org>

Remove some more globals:
o int modem was unused.
o StateNames[] is now accessed via State2Nam()
o ipKeepAlive is no more. As a result, we must call FilterCheck()
twice if we're doing TCP/IP logging (once when we queue and log
the packet and once when we transmit it and need to know if the
idle timer should be reset), but this won't be the case
in normal life.


# 2267893f 20-Mar-1998 Brian Somers <brian@FreeBSD.org>

o Check the LCP Identifier field for correctness and drop
dodgy packets by default.
The old behaviour is still available with ``disable idcheck''.
o Make all FSM diagnostics consistent and tidy up the way
we build our LCP/CCP/IPCP requests.
o Don't assume sizeof(u_long) == 4.


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


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

Remove more globals


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

Move the IPCP into struct bundle.


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

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


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


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


# 6eddf53e 23-Feb-1998 Brian Somers <brian@FreeBSD.org>

Move our Layer*() FSM callbacks into their own structure.


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


# 7e80369b 19-Feb-1998 Brian Somers <brian@FreeBSD.org>

Move some FSM initialisation into FsmInit().


# 63258dcc 18-Feb-1998 Brian Somers <brian@FreeBSD.org>

o Create `struct hdlc' - a part of struct physical.
o Move our LCP report timer into struct hdlc - it's really
a hdlc timer (fcs errors etc).
o Make `show hdlc' require context and make the output more
friendly.
o Remove all non-const globals from hdlc.c
o Output peer-rejected protocols by name - not just ones
that we reject.


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


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


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


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


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


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


# 98baf7c8 09-Jan-1998 Brian Somers <brian@FreeBSD.org>

Implement Reset{Req,Ack} properly, as per rfc 1962.
(I completely mis-read the rfc last time 'round!)

This means:
o Better CCP/WARN Reset diagnostics.
o After we've sent a REQ and before we've received an ACK, we drop
incoming compressed data and send another REQ.
o Before sending an ACK, re-sequence all pending PRI_NORMAL data in
the modem queue so that pending packets won't get to the peer
*after* the ResetAck.
o Send ACKs with the `identifier' from the REQ frame.
o After we've received a correct ACK, duplicate ACKs are ok (and will
reset our history).
o Incorrect ACKs (not matching the last REQ) are moaned about and dropped.

Also,

o Calculate the correct FCS after compressing a packet. DEFLATE
*may* produce an mbuf with more than a single link in the chain,
but HdlcOutput didn't know how to calculate the FCS :-(
o Make `struct fsm'::reqid a u_char, not an int.
This fix will prevent us from sending id `255' 2,000,000,000 times
before wrapping to `0' for another 2,000,000,000 sends :-/
o Bump the version number a little.

The end result: DEFLATE now works over an unreliable link layer.
I can txfr a 1.5Mb kernel over a (rather bad) null-modem
cable at an average of 21679 bytes per second using rcp.
Repeat after me: Don't test compression using a loopback ppp/tcp setup as
we never lose packets and therefore never have to reset!


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


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


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

Don't moan about unexpected config req's when in ST_STOPPING.


# 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


# b0f5f9ed 10-Sep-1997 Brian Somers <brian@FreeBSD.org>

Get rid of missing-prototype-warning


# 29a6597c 10-Sep-1997 Brian Somers <brian@FreeBSD.org>

o Initialize the PRED1 input queue when we
receive the ResetAck, NOT when we send the
ResetReq (as per the rfc).
o SILENTLY ignore CCPs that arrive *before*
the network phase (as per the rfc).
o Check that we've actually negotiated PRED1
before sending PRED1 output.
This bug has been around for a *VERY* long
time ! We shouldn't need to explicitly disable
PRED1 now :-)


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

Cosmetic: Make LogPrintf() calls consistent.


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


# cb611434 20-Aug-1997 Brian Somers <brian@FreeBSD.org>

Expand the "set stopped" command so that it can
idependently time out any of the FSMs.

Split LCP logging into LCP, IPCP and CCP logging,
and make room in "struct fsm" for the log level
that the state machine should use.


# 71144dc5 17-Aug-1997 Brian Somers <brian@FreeBSD.org>

Allow the use of a "stopped" timeout via the
"set stopped" directive. If the timeout occurs
it will cause a "Down" event, hanging up the line
if it's still up. This *isn't* part of the FSM
diagram, but I consider it ok as a "higher level
implementation specific timeout" as specified in
the rfc ;-}

Discussed briefly with: joerg


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


# 8f2fa0ee 01-Jun-1997 Brian Somers <brian@FreeBSD.org>

Back out last change (which in fact breaks rfc1661)
and modify the behaviour so that a timer is started
and the restart counter is zeroed (as per the State
Machine Diagram).

Pointed-out-by: joerg


# ceb1cfa4 01-Jun-1997 Brian Somers <brian@FreeBSD.org>

Go directly to ST_STOPPED when a TerminateReq is
received and after the TerminateAck is sent (as
per rfc1661) rather than to ST_STOPPING. Going
to ST_STOPPING will leave us in a state where
we're waiting for the other side to do something -
not a good idea, especially as the client side sends
a TerminateReq then exits on idle timeout.


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

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

Submitted by: eivind


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

Revert $FreeBSD$ to $Id$


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


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


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


# 85c59f05 09-Sep-1995 Joerg Wunsch <joerg@FreeBSD.org>

Be gentle and allow both magic's (the own one and the other side's
one) as a valid answer to an echo request. This makes the log less
noisy when connecting to Trumpet Winsock or FreeBSD 2.0.5's pppd. :)

Submitted by: melvin@zytek.com (Stephen Melvin)


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

Remove trailing whitespace.


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