Commit Graph

84 Commits

Author SHA1 Message Date
Brian Somers
a8103305cb When executing a command as part of a dial/login/hangup
script, expand words in the same way as !bg does.
1999-02-12 00:52:30 +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
ca618bcfc9 Untimeout the chat expect timer as soon as we get a
match - otherwise, with a delayed (\\d) ``send'', the
timeout may happen during the send and cause a failure.
Problem reported by: David L. Vondrasek <dallas.tx@airmail.net>
1998-10-27 22:53:25 +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
10a9be1e88 Remove redundant includes 1998-06-27 14:18:15 +00:00
Brian Somers
1af29a6e96 o If we come out of select() with only write descriptors that
end up writing zero bytes, sleep for 1/10 of a second so that
  we don't end up using up too much cpu.
  This should only ever happen on systems that wrongly report a
  descriptor as writable despite the tty buffer being full.
  Discussed with: Jeff Evarts

o Do an initial run-time check to see if select() alters the passed
  timeval.  This knowledge isn't yet used, but will be soon.
1998-06-24 19:33:36 +00:00
Brian Somers
d93d3a9c32 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.
1998-06-15 19:06:58 +00:00
Brian Somers
1384bd27d8 o #define the name "tun" in defs.h against the future possibility
of supporting architectures with different device names.
o Close /dev/tunX when destroying the bundle.
o Don't forget to close the parent end of the pipe in the child
  process when exec'ing a program from a chat script.
o If we close our controlling terminal, ditch the current session
  with it, allowing getty(8) (or whatever) to regain control.
o After transferring our controlling terminal descriptor to another
  ppp instance, we now fork a new ppp to continue where we left off,
  transferring ownership of all uucp locks and the /var/run/tunX.pid
  file.  Meanwhile the parent closes all file descriptors, defaults
  all signals and does a pause() to wait for a HUP after the
  transferred descriptor is finally closed.
  We don't run /bin/cat any more (again!).

  Suggested by: bde

TODO: It seems clocal devices need their pause()d session leader
      to be given a manual HUP, as closing the last open descriptor
      doesn't do the job.
1998-05-28 23:17:51 +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
dd7e261079 Cosmetic: Make our external function names consistent. 1998-05-01 19:26:12 +00:00
Brian Somers
b762af4f95 o Explicitly set the close-on-exec flag of descriptor 3 before
exec()ing.  Tidy up file dups in general prior to exec().
  This prevents our tun device (fd 3) from staying open (and
  configured) despite handing off all it's links and exiting
  (because ``cat'' holds it open).
o Don't bother SIG_DFL'ing signals before exec() as they're
  already trapped with specific handlers and will be handled
  correctly by the exec.
o Use values from paths.h for "/dev/" and "/dev/tty".
o Don't assert() in physical.c.
1998-05-01 19:22:23 +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
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
99294c8bfa o Fix chats expect-send-expect - it shouldn't be
expect-send-send !
o Say `disabled' rather than 0s in `show timeout'.
o Set all arguments in ``set device'' rather than just
  the first (read: quotes aren't necessary).
o Set the device speed correctly (broken in last commit).
1998-04-10 23:51:33 +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
92f4ff1ccd Move authname and authkey into struct bundle and only allow
their alteration in PHASE_DEAD.
Remove redundant pppConfs array element.
1998-04-03 19:24:49 +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
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
30c2f2ffe2 Remove more globals 1998-03-13 21:08:05 +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
d501527213 o Allow "*" in the password field in ppp.secret (forcing a
getpwnam() lookup).
o Don't use chat_ExpandString on the password field in ppp.secret.
  It's still possible to quote the string for embedded spaces.
o Don't allow multiple entries with the same name in ppp.secret.
1998-03-09 19:25:35 +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
486f40c95c Implement ABORT strings. 1998-02-26 17:54:43 +00:00
Brian Somers
f4768038f0 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.
1998-02-23 00:38:44 +00:00
Brian Somers
56c9cf9d98 Fix empty string skipping when chatting. 1998-02-18 00:28:06 +00:00
Brian Somers
5b8b8060c1 Move the dial, login and hangup scripts into struct datalink.
Don't set these scripts in -direct mode.
Always set reconnect_tries to zero for -direct mode.
1998-02-16 19:10:03 +00:00
Brian Somers
c78db105b5 Remove some unused variables. 1998-02-13 05:31:03 +00:00
Brian Somers
b6dec9f07f Update to version 2.0-beta
Allow for NULL fd_sets in descriptor_UpdateSet()
Reimplement the entire chat module, creating
`struct chat' - a `type' of struct descriptor.
Remove CARRIER logging.
CONNECT logging now only logs "CONNECT" lines.  CHAT logging
masks it with an entire log of the conversation.

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

The hooks in DoLoop() in main.c are *very* messy !  I'll have
to rewrite DoLoop fairly soon, so I don't care too much for the
moment.  This code is pretty raw.
1998-02-13 05:10:26 +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
2289f24698 Move pppVars.physical into the bundle (for the moment). 1998-02-06 02:23:48 +00:00
Brian Somers
ecd5172a68 Shuffle names and args in modem.h 1998-02-06 02:22:28 +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
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
313572f3e3 Allow (and document) execution of commands from within
our chat script.
You can now even run chat(8) - see ppp.conf.sample.
1997-12-27 07:22:12 +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
6fefd43684 strncpy(x,y,sizeof(x)) --> strncpy(x,y,sizeof(x)-1)
Suggested by: Philippe Charnier <charnier@lirmm.fr>
              Theo de Raadt <deraadt@cvs.openbsd.org>
1997-12-23 22:38:55 +00:00
Brian Somers
16f81f6873 Replace
strcpy(a, b);  /* a and b are the same size */

with

  strncpy(a, b, sizeof(a));
  a[sizeof(a)-1] = '\0';

Making the code `correct at a glance'.

Suggested by: Theo de Raadt <deraadt@cvs.openbsd.org>
1997-12-18 01:10:13 +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
86e0293468 Increase chat script sizes to 512
Requested by: Michael Reifenberger <root@totum.plaut.de>
1997-11-09 14:18:55 +00:00
Brian Somers
5106c67149 Introduce ID0 logging.
Stay as the invoking uid as much as possible.
Execution as a normal user is still forbidden for now,
so these changes are pretty ineffective.
The next commit will implement the modifications suggested
on -hackers a number of days ago.
1997-11-09 06:22:49 +00:00
Brian Somers
0fe7ca3165 o Bump version to 1.3 to reflect major changes
o  Report modem connect time properly
o  Report bytes in/out over physical media
o  Fix phases (TERMINATE is *higher than* DEAD)
o  Do a LayerFinish from LcpDown
o  Bring down IPCP & CCP when we enter PHASE_TERMINATE
o  Give a new prompt when we go to PHASE_DEAD
o  Stop the modem timer properly when idle
o  Treat sig 15 like an exiting carrier loss
o  Log (DEBUG) offline & online transitions
1997-10-29 01:19:51 +00:00
Brian Somers
75240ed178 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
1997-10-26 01:04:02 +00:00