Commit Graph

63 Commits

Author SHA1 Message Date
Brian Somers
58d5533465 Add the `rename' command for renaming links. 1998-05-16 23:47:28 +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
ea7229694b 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.
1998-05-15 18:21:45 +00:00
Brian Somers
0a1b5c9d9e 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.
1998-05-15 18:21:12 +00:00
Brian Somers
66f634b6df 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.
1998-05-11 23:39:30 +00:00
Brian Somers
9ae588829e Log datalink state transitions consistently. 1998-05-09 13:52:12 +00:00
Brian Somers
b7c5748e5e 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.
1998-05-08 01:15:19 +00:00
Brian Somers
84917b87ba Log link name changes correctly. 1998-05-06 23:49:33 +00:00
Brian Somers
078c562e54 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.
1998-05-06 18:49:45 +00:00
Brian Somers
96c9bb21aa 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>
1998-05-02 21:57:50 +00:00
Brian Somers
dd7e261079 Cosmetic: Make our external function names consistent. 1998-05-01 19:26:12 +00:00
Brian Somers
47723d29e5 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.
1998-05-01 19:20:09 +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
9c281ab21b Don't forget to set up our ppp.secret IP numbers & label
in non-MP mode.
1998-04-30 23:52:53 +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
184d1da22a Show our link name when we fail to mp_Up(). 1998-04-25 00:09:22 +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
643f49047e 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.
1998-04-24 19:16:15 +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
dbf60d74f8 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.
1998-04-23 18:55:50 +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
e3c70ce931 Tidy up the use of struct pppTimer. 1998-04-19 15:24:50 +00:00
Brian Somers
39d946522c 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.
1998-04-18 23:17:26 +00:00
Brian Somers
cdbbb6b571 Cosmetic: Clean up warnings. 1998-04-18 01:01:28 +00:00
Brian Somers
030e4ebba8 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.
1998-04-17 22:04:36 +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
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
cd7bd93a81 Add the clone' and remove' commands for creating and destroying
links.
1998-04-05 22:48:25 +00:00
Brian Somers
833882f740 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.
1998-04-03 19:26:29 +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
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
9e46ce35b5 Use bundle_Phase(), not bundle->phase. 1998-03-25 00:59:38 +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
92e872e70c Bring LCP back to INITIAL in LayerFinish(). 1998-03-18 21:54:03 +00:00
Brian Somers
c17d3e984d Don't increment dial_tries twice. 1998-03-18 21:53:56 +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
5828db6d2d Move the IPCP into struct bundle. 1998-03-13 21:07:46 +00:00
Brian Somers
a611cad61d 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.
1998-03-13 21:07:14 +00:00
Brian Somers
dc0fdb6bc1 "dial" now may optionally have context.
Tidy up some LcpInfo uses.
1998-03-13 00:44:51 +00:00
Brian Somers
5563ebde73 Remove the second bundle_NewPhase argument and do
the tun config from bundle_LayerUp.
1998-03-13 00:44:33 +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
f95458053f Move phone numbers into struct datalink.
Make "show modem" look a bit prettier.
1998-03-09 19:24:58 +00:00
Brian Somers
e2ebb036fd 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.
1998-03-01 01:07:49 +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
4bc1da96a9 Don't enter DATALINK_HANGUP state if we're currently in
DATALINK_OPENING.... we'll hang there forever with no
open device.
1998-02-26 17:53:15 +00:00