Commit Graph

183 Commits

Author SHA1 Message Date
Brian Somers
1d1fc0171e Remember if MYADDR or HISADDR is used in a filter add tweak all
filters any time either value changes.
1999-05-31 23:57:40 +00:00
Brian Somers
3377c28cd9 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.
1999-05-09 20:02:29 +00:00
Brian Somers
5d9e610366 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''.
1999-05-08 11:07:56 +00:00
Brian Somers
7884358fdd Add support for NetBSD 1999-04-26 08:54:34 +00:00
Brian Somers
119386a38b #include <errno.h>, not <sys/errno.h> 1999-04-26 08:54:25 +00:00
Brian Somers
bc76350ef9 Correct some ntohl/htonl bogons in the netmask handling.
This was pretty harmless as netmasks on a POINTOPOINT
interface are pretty much ignored, but it looked funny.

Mention the configured netmask in ``show ipcp''.

Describe in more detail what a proxy arp entry is.
1999-03-03 23:00:41 +00:00
Brian Somers
479508cf28 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.
1999-02-26 21:28:14 +00:00
Brian Somers
f0cdd9c021 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
1999-02-06 02:54:47 +00:00
Brian Somers
7686a20048 Encode & Decode the PROTOCOMP fields correctly.
When NAKing the peer, get as close as we can to what
he REQd.
When the peer NAKs us, get as close as we can to what
they NAKd with on our next REQ.
1999-02-02 20:27:12 +00:00
Brian Somers
972a1bcf5d 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
1999-01-28 01:56:34 +00:00
Brian Somers
3afe5ccb75 Add ``enable proxyall'' support. This adds proxy ARP entries
for every machine on every class C or smaller subnet that we
route to.
Add ``set {send,recv}pipe'' for controlling our socket buffer
sizes.
Mention the IP number with the problem in a few error messages.
All submitted by:     Craig Leres <leres@ee.lbl.gov>
Modified slightly by: me
1998-10-26 19:07:39 +00:00
Brian Somers
8fa6ebe47d Solve the ``first connection'' problem that occurs on
demand-dial links with dynamic IP numbers where the program
that causes the dial bind()s to an interface address that is
subsequently changed after ppp negotiation.

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

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

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

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

It's also now possible to manually add interface aliases with
something like ``iface add 1.2.3.4/24 5.6.7.8''.  This allows
multi-homed ppp links :-)
1998-10-22 02:32:50 +00:00
Brian Somers
1595bacdf6 Sync with OpenBSD ifdefs 1998-09-17 00:45:27 +00:00
Brian Somers
9e8ec64b6b 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.
1998-09-04 18:26:00 +00:00
Brian Somers
5a72b6eda3 Put the IP buffer queues into struct ipcp.
Forgotten by: me
1998-08-26 17:39:37 +00:00
Brian Somers
92b0955883 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.
1998-08-07 18:42:51 +00:00
Brian Somers
3a2e4f621c 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.
1998-06-27 23:48:54 +00:00
Brian Somers
2d42ffabf1 More u_long -> u_int32_t 1998-06-27 16:24:52 +00:00
Brian Somers
10a9be1e88 Remove redundant includes 1998-06-27 14:18:15 +00:00
Brian Somers
615ad4f957 Don't dlopen()/dlsym() libalias, use it in the same way
as the rest of the world uses libraries.
1998-06-27 14:17:28 +00:00
Brian Somers
897f9429f9 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.
1998-06-25 22:33:31 +00:00
Brian Somers
a33b2ef772 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.
1998-06-16 19:40:42 +00:00
Brian Somers
c9e11a112d Fix a rather nasty use of `static'. This caused a SEGV
when running ``link * load label'' as we ended up recursing
back into command_Interpret after nuking our command arg list.
1998-06-15 19:06:25 +00:00
Brian Somers
30291ffb15 Give ``load'' optional context. It's now possible to
``link 1,2,3 load label'' for people that want to set
up their links in a more mpd-like manner.
1998-06-15 19:05:51 +00:00
Brian Somers
ff0f9439b4 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>
1998-06-12 17:45:10 +00:00
Brian Somers
81358fa3fc 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>
1998-05-29 18:32:11 +00:00
Brian Somers
0f2f3eb395 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.
1998-05-23 22:24:50 +00:00
Brian Somers
d91d286164 MFMP: Make ppp multilink capable.
See the file README.changes, and re-read the man page.
1998-05-21 21:49:08 +00:00
Brian Somers
641684cdba Don't accept IPCP packets before NETWORK phase.
Pointed out by: Ralf Rutherford <ralf@philips.oz.au>
1998-05-21 01:26:10 +00:00
Brian Somers
0f8037a9db Close some file descriptors.
Pointed at by: Ruslan Ermilov <ru@ucb.crimea.ua>
1998-05-19 21:51:24 +00:00
Brian Somers
dd0645c5b7 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.
1998-05-15 23:58:30 +00:00
Brian Somers
faefde08e0 Categorize the fields in struct bundle, and make the tunnel
device speed available in ``show bundle''.
1998-05-06 23:50:25 +00:00
Brian Somers
610b185f37 Create `struct sticky_route'.
Any `add' or `delete' command that uses MYADDR or HISADDR
will be added to the sticky route list (show ipcp).  When
MYADDR or HISADDR change due to IPCP negotiations, and if
`sroutes' is enabled (the default), all sticky route
entries are updated in the routing table.

The end result is that `add default hisaddr' will ``stick'',
as will ``add myaddr 255.255.255.255 127.0.0.1'' and
``add 1.2.3.4 255.255.255.0 hisaddr''.
1998-05-05 23:30:13 +00:00
Brian Somers
dd7e261079 Cosmetic: Make our external function names consistent. 1998-05-01 19:26:12 +00:00
Brian Somers
6f38457323 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....
1998-04-30 23:53:56 +00:00
Brian Somers
1fa665f5b3 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).
1998-04-28 01:25:46 +00:00
Brian Somers
e43ebac1c2 Make gcc-2.8.1 build ppp cleanly.
Support OpenBSD again.
1998-04-25 10:49:52 +00:00
Brian Somers
50abd4c820 Make ``show ipcp'' prettier and remove a few redundant includes. 1998-04-25 00:09:14 +00:00
Brian Somers
d47dceb8ab 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.
1998-04-24 19:15:48 +00:00
Brian Somers
ce828a6ecc 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.
1998-04-23 18:56:21 +00:00
Brian Somers
49052c9523 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.
1998-04-23 03:23:03 +00:00
Brian Somers
fdf6117177 o Remove some unused #includes.
o Make sure our ipcp throughput timer is stopped before being nuked
  with a memset.
o Don't initialise struct async & struct hdlc twice in modem_Create().
o Clarify some comments.
1998-04-21 01:02:32 +00:00
Brian Somers
fe3125a0c3 o Use __attribute__ (#ifdef __GNUC__) to type-check
LogPrintf() and prompt_Printf(), and fix the bits
  identified as being wrong as a result.
1998-04-19 23:09:03 +00:00
Brian Somers
ba081e4360 o Allocate new CCP protocol options if they've been
enabled since we first REQ'd.
o Delete the allocated options when CCP is down (TLF).
o Clean the IPCP interface on the way down when we're
  *not* in auto mode (rather than when we are) - typo.
o Don't produce two similar IpcpLayerUp messages.
1998-04-19 03:41:01 +00:00
Brian Somers
3edeb0c69e Support client side DNS server negotiation, disabled
and denied by default (POLA).

o Remove ``enable'' msext.  Now, doing a ``set nbns'' will
  automatically enable a NBNS ACK/NAK rather than a REJ.
o Add accept|disable|deny|enable dns.  If we ``accept'',
  we'll tell the peer what our nameservers are (if he asks).
  The values in resolv.conf can be overridden with the
  ``set dns'' command.  If we ``enable'', we'll REQ using
  our resolv.conf entries, and any NAKs are written back to
  resolv.conf.
o Remove ``show msext'' and show the relevent IP numbers in
  ``show ipcp''.
1998-04-17 22:05:37 +00:00
Brian Somers
1342caed9c 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.
1998-04-16 00:26:21 +00:00
Brian Somers
250920922b 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().
1998-04-14 23:17:24 +00:00
Brian Somers
565e35e50e 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.
1998-04-10 13:19:23 +00:00
Brian Somers
85602e5267 Remove MODE_ALIAS and add AliasEnabled() macro.
Remove IsInteractive().
1998-04-07 23:46:09 +00:00
Brian Somers
2764b86afd 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.
1998-04-07 00:54:26 +00:00
Brian Somers
d24f017be8 Remove unused includes. 1998-04-06 09:12:38 +00:00
Brian Somers
b6217683dc 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.
1998-04-03 19:26:02 +00:00
Brian Somers
8390b57662 o Drop packets that fail the dial filter when we're in
phase DEAD.  They'll almost definitely have timed out
  by the time we dial anyway.
o Log dial filters again (LogTCPIP).
o Make DEBUG diagnostics for filter checking actually mean
  something to the common observer.
o Do our best to keep any already-configured IP numbers at
  IPCP negotiation time.  We always first request our configured
  IP, and if the peer asks for an invalid IP, we NAK with HISADDR

Cosmetic:
  o Add a linefeed to the `set timeout' arg count error message.
  o Log unacceptable address errors to LogPHASE if LogIPCP is
    switched off.
  o Fix ``destination system not found'' error message.
  o Get out immediately if we get a fatal error before entering
    the main loop.
1998-04-03 19:25:07 +00:00
Brian Somers
cd9647a100 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.
1998-04-03 19:24:07 +00:00
Brian Somers
3b0f8d2ed6 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.
1998-04-03 19:21:56 +00:00
Brian Somers
1e991daad5 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.
1998-03-24 18:47:32 +00:00
Brian Somers
2f7866811e Make struct bundle into a sort of `struct descriptor'.
It does the fdsets/reads/writes for each of it's
datalinks.
1998-03-20 19:48:28 +00:00
Brian Somers
2267893f11 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.
1998-03-20 19:47:10 +00:00
Brian Somers
eaa4df37f4 Move VJ compression state and stats into struct ipcp. 1998-03-16 22:54:35 +00:00
Brian Somers
5ca5389af4 Move filter sets into struct bundle. 1998-03-16 22:52:54 +00:00
Brian Somers
30c2f2ffe2 Remove more globals 1998-03-13 21:08:05 +00:00
Brian Somers
5828db6d2d Move the IPCP into struct bundle. 1998-03-13 21:07:46 +00:00
Brian Somers
879ed6fa82 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.
1998-03-13 00:44:26 +00:00
Brian Somers
ab886ad0f6 Move the idle timer into struct bundle. There's no
link-level idle timer for the moment.
1998-03-09 19:26:41 +00:00
Brian Somers
5454ccd9e0 Reset fsm.maxconfig in the *_Setup() routines. 1998-02-27 21:46:26 +00:00
Brian Somers
6d6667755e 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.
1998-02-27 01:22:39 +00:00
Brian Somers
6eddf53ee8 Move our Layer*() FSM callbacks into their own structure. 1998-02-24 03:36:50 +00:00
Brian Somers
503a7782d8 Shuffle around our FSMs a bit. This'll make it
easier to remove the CcpInfo, LcpInfo and IpcpInfo
globals.
1998-02-21 01:45:26 +00:00
Brian Somers
7e80369b76 Move some FSM initialisation into FsmInit(). 1998-02-19 19:57:01 +00:00
Brian Somers
85b542cf4f Move the terminal/diagnostic socket stuff out of main.c
and into the new `prompt.c'.  struct prompt is (of course)
a `sort' of descriptor.
1998-02-10 03:23:50 +00:00
Brian Somers
42d4d39668 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.
1998-02-09 19:21:11 +00:00
Brian Somers
68a0f0ccdd o Add bundle_Destroy().
o Don't remove routes and DOWN the interface when we're
  closed in auto mode.
o Initialize the FSMs in bundle_Create.
o Initialize ipcp::if_mine & ipcp::if_peer only once (so
  that we don't forget that we've SIOCAIFADDR'd the interface).
o Do a SIOCDIFADDR on the specific address to avoid hurting any
  other (still non-existent) NCPs.
o Fix some error/diagnostic messages.
1998-02-08 19:29:45 +00:00
Brian Somers
aad81d1ecf Rename ccpstate to ccp, ipcpstate to ipcp and lcpstate to lcp. 1998-02-08 11:05:01 +00:00
Brian Somers
455aabc3f8 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.
1998-02-07 20:50:08 +00:00
Brian Somers
83d1af558c Isolate fsm callback functions
Derive {lcp,ipcp,ccp}state structures from struct fsm
where convenient.
Create bundle_Down() and remove LcpDown()
1998-02-06 02:24:29 +00:00
Brian Somers
6140ba1177 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.
1998-02-02 19:33:40 +00:00
Brian Somers
42e91bc7b3 Cosmetic: Merge the show vj' command into show ipcp'
and make it prettier.
1998-02-02 19:32:31 +00:00
Brian Somers
7a6f872047 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.
1998-02-02 19:32:16 +00:00
Brian Somers
7308ec6890 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).
1998-01-31 02:48:30 +00:00
Brian Somers
8c07a7b2e0 Create `struct link' - the logical link from which
`struct physical' (and the future `struct logical')
are derived.
1998-01-30 19:46:07 +00:00
Brian Somers
29e275cee4 o Move global/static IPCP data into IpcpInfo.
o Use INADDR_ANY and INADDR_BROADCAST instead of 0 and 0xffffffff
  for IP addresses & masks.
o Move struct compreq into ipcp.c (it's none of anyone elses
  business).
o Rename MAX_STATES to MAX_VJ_STATES.
1998-01-29 23:11:44 +00:00
Brian Somers
63b7346316 Create a new MP branch for `multilink protocol'.
Do lots of initial shuffling and grouping.
Submitted by: Eivind Eklund <perhaps@yes.no>
1998-01-29 00:49:32 +00:00
cvs2svn
1ae349f52c This commit was manufactured by cvs2svn to create branch 'MP'. 1998-01-29 00:44:16 +00:00
Brian Somers
aa8e05197c Remove unused #includes.
Make various bits static.
Remove unused variables.
Submitted by: eivind
1998-01-21 02:15:33 +00:00
Brian Somers
49b239e0d2 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.
1998-01-20 22:47:48 +00:00
Brian Somers
d1a3ea477c Allow "set vj" for changing the default number of slots
and whether slot compression is requested.
Don't show current values with "show ipcp" if IPCP isn't
"opened".
1998-01-18 20:49:22 +00:00
Brian Somers
9c97abd8c3 o Allow the use of HISADDR as the first arg to "add".
o Allow a forth argument in ppp.secret, specifying a new
  label.  This gives control over which section of
  ppp.link{up,down} is used based on the authenticated user.
o Support random address ranges in ppp.secret (not just in ppp.conf).
o Add a AUTHENTICATING INCOMING CONNECTIONS section to the man page.
o Add a bit more about DEFLATE in the man page.
o Fix the incorrect "you must specify a password in interactive
  mode" bit of the manual.
o Space things in the man page consistently.
o Be more precice about where you can use MYADDR, HISADDR and INTERFACE
  in the "add" command documentation.
1998-01-05 01:35:20 +00:00
Brian Somers
e7250038b6 Show who closes the diagnostic connection.
Show the IP range (if specified) in "show ipcp".
Close unused descriptors 0 and 2 in interactive mode.
Pass (size_t *) rather than (int *) to sysctl().
1997-12-27 13:45:57 +00:00
Brian Somers
70ee81ff6b Cosmetic (style):
sizeof(var) -> sizeof var
  sizeof type -> sizeof(type)

Suggested by: J Wunsch <j@uriah.heep.sax.de>
1997-12-24 09:29:17 +00:00
Brian Somers
f9925914f1 Use sizeof cftypes128 for NCFTYPES128 macro, not sizeof cftypes !
Lucky that sizeof cftypes < sizeof cftypes128
1997-12-24 09:28:11 +00:00
Brian Somers
f5fb6bd02a If the peer asks for IP 0.0.0.0, choose an IP ourselves
without looking for it in our IP list (and if found, trying
to ifconfig it!).
1997-12-19 04:49:53 +00:00
Brian Somers
bcc332bdb0 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.
1997-12-13 02:37:33 +00:00
Brian Somers
b6871831e5 Correct cftypes128 index. 1997-12-06 22:43:58 +00:00
Brian Somers
702026bc21 Remove duplicate REJECTED macro.
Remove extraneous pointers.
1997-12-04 18:49:35 +00:00
Brian Somers
0053cc58a9 Abstract the CCP layer a level.
Add DEFLATE support.
1997-12-03 10:23:54 +00:00
Brian Somers
b6e82f33ef 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).
1997-11-22 03:37:54 +00:00
Brian Somers
9a0b991f97 Add throughput logging (disabled by default).
Use "enable throughput" to see modem & IPCP throughput.
Removed an extraneous prompt()
1997-11-18 14:52:08 +00:00
Brian Somers
9e836af5d9 Update the cftypes arrays according to rfc1700.
Log IPCP reqests as IPCP.
1997-11-14 15:39:15 +00:00
Brian Somers
12ef29a81a Finish the security improvements:
o Add "allow" command:
      "allow users a b c" gives access to users a, b and c.
      "allow modes auto"  gives those users access to auto mode only.
      "allow users *" and  "allow modes *" are accepted.
      No users and all modes are allowed by default.
    UID 0 can do anything.
  o Set the current label with the "load" and "dial" commands
    so that the call to ppp.linkdown makes sense.
  o Up the verison number.
  o Don't OR MODE_AUTO for -background and -ddial.
  o Don't OR MODE_INTER when we get a diagnostic connection.
  o Allow up to 40 args per line (was 20).
  o "set ifaddr" only changes the interface in AUTO mode (with other
    modes, it happens after IPCP negotiation).
  o Sort command descriptions in the man page.
  o Support -dedicated mode where we just talk ppp forever (no login etc).
1997-11-11 22:58:14 +00:00
Brian Somers
9780ef311d Don't pass global vars as args.
Remove local/global conflicts.
1997-11-08 00:28:11 +00:00