aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/ppp/bundle.c
Commit message (Collapse)AuthorAgeFilesLines
* Allow ``host:port/udp'' devices and support ``host:port/tcp'' asBrian Somers1999-05-121-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | being the same as the previous (still supported) ``host:port'' syntax for tcp socket devices. A udp device uses synchronous ppp rather than async, and avoids the double-retransmit overhead that comes with ppp over tcp (it's usually a bad idea to transport IP over a reliable transport that itself is using an unreliable transport). PPP over UDP provides througput of ** 1.5Mb per second ** with all compression disabled, maxing out a PPro/200 when running ppp twice, back-to-back. This proves that PPPoE is plausable in userland.... This change adds a few more handler functions to struct device and allows derivations of struct device (which may contain their own data etc) to pass themselves through the unix domain socket for MP. ** At last **, struct physical has lost all the tty crud ! iov2physical() is now smart enough to restore the correct stack of layers so that MP servers will work again. The version number has bumped as our MP link transfer contents have changed (they now may contain a `struct device'). Don't extract the protocol twice in MP mode (resulting in protocol rejects for every MP packet). This was broken with my original layering changes. Add ``Physical'' and ``Sync'' log levels for logging the relevent raw packets and add protocol-tracking LogDEBUG stuff in various LayerPush & LayerPull functions. Assign our physical device name for incoming tcp connections by calling getpeername(). Assign our physical device name for incoming udp connections from the address retrieved by the first recvfrom(). Notes: svn path=/head/; revision=47061
* o Redesign the layering mechanism and make the aliasing code part ofBrian Somers1999-05-081-32/+15
| | | | | | | | | | | | | | | | | | | | | | | | 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''. Notes: svn path=/head/; revision=46686
* Add support for NetBSDBrian Somers1999-04-261-4/+4
| | | | Notes: svn path=/head/; revision=46086
* Undo possible damage done by the new TUNSIFMODE ioctlBrian Somers1999-03-251-1/+13
| | | | | | | in FreeBSD-current. Notes: svn path=/head/; revision=45032
* Read from fd[0] and write to fd[1] where `fd' is theBrian Somers1999-03-071-12/+12
| | | | | | | result of a pipe(). This matters under OpenBSD. Notes: svn path=/head/; revision=44541
* Extend the ``set redial'' command to allow incrementalBrian Somers1999-03-041-4/+4
| | | | | | | redial timeouts. Notes: svn path=/head/; revision=44468
* Bring up auto links despite there being no data queued ifBrian Somers1999-03-011-5/+5
| | | | | | | | | | | | | | | we're already in network phase and our autoload values are set with no minimum threshold (the default). Tell the autoload timer that it's ``coming up'' *before* calling AutoLoadTimeout() directly... not after. This prevents the very first demand-dial connection from immediately disconnecting when there are other auto links. Problem diagnosis: Ted Mittelstaedt <tedm@toybox.placo.com> Notes: svn path=/head/; revision=44352
* Don't immediately bring auto links back up in multilinkBrian Somers1999-02-251-3/+3
| | | | | | | | | mode (when there is more than one auto link) if there is no data queued to go out. Reviewed by: Tom Torrance <tom@tomqnx.com> Notes: svn path=/head/; revision=44260
* Decouple pap & chap output routines from the correspondingBrian Somers1999-02-061-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=43693
* Initial RADIUS support (using libradius). See the man page forBrian Somers1999-01-281-2/+17
| | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=43313
* Don't warn when ``add xxxx HISADDR'' fails because HISADDRBrian Somers1999-01-061-3/+4
| | | | | | | | | is 0.0.0.0. This isn't a problem as the sticky route is still added. Suggested by: Chris Timmons <skynyrd@opus.cts.cwu.edu> Notes: svn path=/head/; revision=42321
* Rather than interrupting 10 times per second then checkingBrian Somers1998-12-141-2/+2
| | | | | | | | | | | | | | to see if there's anything to do, schedule the next alarm based on the next required timeout. This decreases the load when there are lots of relatively idle ppp processes. While I'm in there, handle the possibility that a timeout makes the timer element go out of scope by grabbing the enext pointer before executing the timer function. Notes: svn path=/head/; revision=41799
* When using ``set device !someprogram'', when ``someprogram''Brian Somers1998-12-101-1/+15
| | | | | | | | | | exits, it causes a select() exception. Handle these select() exceptions on link descriptors in pretty much the same way as loss of carrier rather than dropping out in confusion. Notes: svn path=/head/; revision=41654
* Don't call PacketAliasIn() when we turn around packets destinedBrian Somers1998-10-291-7/+1
| | | | | | | | | for our interface address. We're about to call ip_Input() anyway, and ip_Input() does the PacketAliasIn(). Stack trace provided by: Cameron Grant <gandalf@vilnya.demon.co.uk> Notes: svn path=/head/; revision=40744
* Add ``set proctitle'' for changing argv[0]. All substitutionsBrian Somers1998-10-271-1/+4
| | | | | | | | | | are done in the same way as command execution. For example, ``set proctitle USER INTERFACE PROCESSID'' would be useful in a -direct profile for identifying who's connected. Notes: svn path=/head/; revision=40679
* Add ``enable proxyall'' support. This adds proxy ARP entriesBrian Somers1998-10-261-2/+26
| | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=40665
* Loosen our restrictions on setting enddisc, mrru,Brian Somers1998-10-241-1/+14
| | | | | | | | | | | shortseq, authname and authkey. o Auth{name,key} may additionally be set in PHASE_ESTABLISH. o The others may be set in PHASE_ESTABLISH as long as no links have yet reached DATALINK_LCP. Notes: svn path=/head/; revision=40622
* Solve the ``first connection'' problem that occurs onBrian Somers1998-10-221-94/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 :-) Notes: svn path=/head/; revision=40561
* Sync with OpenBSD ifdefsBrian Somers1998-09-171-4/+8
| | | | Notes: svn path=/head/; revision=39395
* Put the IP buffer queues into struct ipcp.Brian Somers1998-08-261-6/+6
| | | | | | | Forgotten by: me Notes: svn path=/head/; revision=38557
* If we've got a full output buffer queue and cannot sendBrian Somers1998-08-251-1/+44
| | | | | | | | | | | anything for two mintues (see ``set choked'' and ``show bundle''), nuke the ip, mp and link level buffer queues. This should fix problems where ``ppp -auto'' seems to stop responding after failing to connect to the peer a few times. Notes: svn path=/head/; revision=38544
* When entering ``term'' mode, don't output any messages untilBrian Somers1998-08-091-1/+3
| | | | | | | | | | the device is successfully opened. If we fail to open it, mention the fact. Also go back into command mode as soon as the device is closed rather than waiting for the user to type something before noticing. Notes: svn path=/head/; revision=38200
* o Support callback types NONE, E.164, AUTH and CBCP.Brian Somers1998-08-071-2/+3
| | | | | | | | | | | | | | | | | (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. Notes: svn path=/head/; revision=38174
* On receipt of a sig 15, do a full bundle_Close() even ifBrian Somers1998-08-021-4/+1
| | | | | | | | our current phase is PHASE_DEAD as it's possible that there are links stuck in OPENING waiting for a redial timer. Notes: svn path=/head/; revision=38008
* Allow an optional ``!'' in the open, dial & call commands.Brian Somers1998-07-291-5/+10
| | | | | | | | When used, the redial timer is ignored and the modem is opened immediately. Notes: svn path=/head/; revision=37955
* Silence ``Network unreachable'' warnings when usingBrian Somers1998-07-281-7/+8
| | | | | | | | | | | | | | | | | | | | | ``add .... HISADDR''. The network will never be reachable at this point unless we're in -auto or reading the command from ppp.linkup. We can now run the following lines and get the expected results: set ifaddr 1.2.3.4/0 5.6.7.8/0 add default HISADDR where a route is added immediately in auto mode and the whole thing is delayed 'till the IP numbers have been agreed in other modes. Essentially, ppp.linkup is no longer required. Notes: svn path=/head/; revision=37927
* Remove redundant includesBrian Somers1998-06-271-3/+1
| | | | Notes: svn path=/head/; revision=37192
* Don't dlopen()/dlsym() libalias, use it in the same wayBrian Somers1998-06-271-5/+9
| | | | | | | as the rest of the world uses libraries. Notes: svn path=/head/; revision=37191
* Cast void * to char * for log_Printf().Brian Somers1998-06-271-2/+2
| | | | Notes: svn path=/head/; revision=37188
* ``struct tunnel_header'' -> u_int32_t in OpenBSD.Brian Somers1998-06-271-2/+1
| | | | | | | | | struct tunnel_header is going soon. Suggested by: Theo Notes: svn path=/head/; revision=37187
* o If we come out of select() with only write descriptors thatBrian Somers1998-06-241-3/+6
| | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=37141
* Re-initialise our timer service after fork()ingBrian Somers1998-06-201-1/+2
| | | | | | | | | to lose our terminal session. Is this a bug in setitimer() ? - it must be called again in the child ! Notes: svn path=/head/; revision=37061
* Create & use fsm2initial(), a function to bring aBrian Somers1998-06-201-16/+6
| | | | | | | | state machine back to ST_INITIAL without going through any unnecessary TLS/TLF pairs. Notes: svn path=/head/; revision=37060
* Make sure our recvmsg() is a SCM_RIGHTS message whenBrian Somers1998-06-181-11/+11
| | | | | | | we receive a link from another ppp. Notes: svn path=/head/; revision=37054
* Change some log levels. ALERTs are only logged whenBrian Somers1998-06-161-14/+12
| | | | | | | | | something that can't happen happens or when everyone needs to know. ERRORs are only logged when something unexpected happens. Notes: svn path=/head/; revision=37019
* Don't bring the modem offline or hangup when ``down lcp''Brian Somers1998-06-161-3/+3
| | | | | | | is done. Instead, behave like ``close lcp''. Notes: svn path=/head/; revision=37018
* Fix a rather nasty use of `static'. This caused a SEGVBrian Somers1998-06-151-2/+2
| | | | | | | | when running ``link * load label'' as we ended up recursing back into command_Interpret after nuking our command arg list. Notes: svn path=/head/; revision=37009
* Make `close lcp' just close the LCP layer and not hangup. This isBrian Somers1998-06-151-10/+16
| | | | | | | | | useful for slirp users that wish to get their shell back after the ppp session. `close' with no args still hangs up as expected. Required by: jmz Notes: svn path=/head/; revision=37007
* o Maintain a link-type mask for open datalinks as well asBrian Somers1998-06-121-55/+77
| | | | | | | | | | | | | | 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> Notes: svn path=/head/; revision=36928
* Update the write descriptor selection set for our data linksBrian Somers1998-06-071-3/+5
| | | | | | | | | | *after* shuffling fragments from the IP queue into the individual link queues. This fixes a latency problem pointed out by: Bruce Evans <bde@zeta.org.au> Notes: svn path=/head/; revision=36714
* Put the correct pid in /var/run/tunX.pidBrian Somers1998-06-061-2/+2
| | | | | | | Suggested by: many Notes: svn path=/head/; revision=36709
* o If there's a session leader left running for a descriptorBrian Somers1998-05-291-2/+6
| | | | | | | | | | | | | | that we're now closing, manually HUP that session leader so that the tty is fully released. o Always restart our carrier detect timer in the receiving process if it was running in the sending process (as we now *always* pass the descriptor). o Tweak argv when we go into pause() mode to keep our session so that ps can see what's going on (without checking for a `pause' state in `ps -l'). Notes: svn path=/head/; revision=36467
* o Make modes consistent throughout ppp. The same strings are usedBrian Somers1998-05-291-18/+18
| | | | | | | | | | | | | | | | | | 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> Notes: svn path=/head/; revision=36465
* o #define the name "tun" in defs.h against the future possibilityBrian Somers1998-05-281-86/+149
| | | | | | | | | | | | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=36452
* o Don't forget to close our transfer socket if we cannotBrian Somers1998-05-281-4/+10
| | | | | | | | | | generate the data to transfer. o Transfer uucp lock ownership for the transferred device. o Don't assume we know the correct values of dev_is_modem and mbits after the transfer. Notes: svn path=/head/; revision=36450
* o Only do the /bin/cat bit when we're transferring our ctty.Brian Somers1998-05-251-3/+3
| | | | Notes: svn path=/head/; revision=36368
* o Don't try to transfer tty device descriptors as there's no way ofBrian Somers1998-05-251-13/+103
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | transferring session rights with them. Instead, create two `/bin/cat' processes. A new child is spawned and disassociated from the terminal and the parent, which continues with the rest of the ppp process. Meanwhile, the parent spawns another child, and both the parent and child exec the `/bin/cat' commands with the appropriate descriptors. This way, the session is owned by the parent, and the tty is held open. o Close LCPs that have done a TLF and are now in ST_STOPPED before calling Down. This prevents them from trying to come back up again after the peer has shut them down (it seems a bit strange that the rfc says that a Down in ST_STOPPED will cause a TLS etc). o Don't try to set the physical link name pointer when we're receiving and renaming a datalink. The physical hasn't been created yet, and as it happens, the garbage physical pointer happens to be the value of another physical - so we're pointing that other physical name at ourselves. yeuck. o Re-arrange the order of things in main (DoLoop()). We now handle signals only after the select and not before the UpdateSet. It's possible that either a signal (FSM timeout) or a descriptor_Read() brings a link down, after which we'd better tidy up any dead direct and 1off descriptors before calling UpdateSet() again. o Mention when we detect a PPP packet when we see one before the link is up (then start LCP as before). Notes: svn path=/head/; revision=36345
* Show the link mode in `show links'.Brian Somers1998-05-231-3/+4
| | | | Notes: svn path=/head/; revision=36316
* Oops - patch failed in last commit ????Brian Somers1998-05-231-7/+1
| | | | Notes: svn path=/head/; revision=36315
* o Move our prompt descriptor list outside of the bundle.Brian Somers1998-05-231-129/+18
| | | | | | | | | | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=36314