summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp/datalink.c
Commit message (Collapse)AuthorAgeFilesLines
* Remove whitespace at the end of lines.brian2002-06-151-3/+3
|
* o Clean up some #includesbrian2002-05-141-1/+0
| | | | | | | | | | | | | | | | | | o Bump version number to 3.0.4 o When talking to a RADIUS server, provide a NAS-Port-Type. When the NAS-Port-Type is Ethernet, provide a NAS-Port value equal to the SESSIONID from the environment in direct mode or the NGM_PPPOE_SESSIONID message in other modes. If no SESSIONID is found, default to the interface index in client mode or zero in server mode. When the NAS-Port-Type is ISDN, set the NAS-Port to the minor number of the physical device (ie, the N in /dev/i4brbchN). This makes it easier for the RADIUS server to identify the client WRT accounting data etc. Prompted by: lsz8425 <lsz8425@mail.cd.hn.cn>
* Merge the NETGRAPH branch into HEAD. tty devices now use netgraph's linebrian2002-03-301-4/+19
| | | | | | | | discipline to do the async escaping, but no other benefits are available yet. Change ``ifdef HAVE_DES'' to ``ifndef NODES'' for consistency. Make the Makefile a little more sane WRT RELEASE_CRUNCH.
* Don't blow away ``set escape'' settings when we've completed thebrian2002-03-041-1/+1
| | | | | | login phase. Just initialise the correct parts. Originially submitted by: Vladimir B. Machulsky <bofhmail@yahoo.com>
* Don't avoid setting a 0 second timer in datalink_StartDialTimer() bybrian2001-10-231-12/+10
| | | | | | | | | | | | | not setting any timer. Instead, set a 1 millisecond timer. This ensures that ppp will come out of it's select() call after losing carrier in -ddial mode with a reconnect period of 0 and going to ST_OPENING, rather than waiting indefinitely for some other event to wake ppp up. Bump the ppp version number to indicate the event. MFC after: 3 days
* o Add ipv6 support, abstracting most NCP addresses into opaquebrian2001-08-141-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | structures (well, they're treated as opaque). It's now possible to manage IPv6 interface addresses and routing table entries and to filter IPV6 traffic whether encapsulated or not. IPV6CP support is crude for now, and hasn't been tested against any other implementations. RADIUS and IPv6 are independent of eachother for now. ppp.linkup/ppp.linkdown aren't currently used by IPV6CP o Understand all protocols(5) in filter rules rather than only a select few. o Allow a mask specification for the ``delete'' command. It's now possible to specifically delete one of two conflicting routes. o When creating and deleting proxy arp entries, do it for all IPv4 interface addresses rather than doing it just for the ``current'' peer address. o When iface-alias isn't in effect, don't blow away manually (via ``iface add'') added interface addresses. o When listening on a tcp server (diagnostic) socket, bind so that a tcp46 socket is created -- allowing both IPv4 and IPv6 connections. o When displaying ICMP traffic, don't display the icmp type twice. When display traffic, display at least some information about unrecognised traffic. o Bump version Inspired after filtering work by: Makoto MATSUSHITA <matusita@jp.FreeBSD.org>
* Reduce the interface MTU by 2 when MPPE has been successfully negotiated.brian2001-07-031-1/+2
| | | | | | This is necessary because MPPE will combine the protocol id with the payload received on the tun interface, encrypt it, then prepend its own protocol id, effectively increasing the payload by two bytes.
* Don't say ``Enter pause (-1) for redialing when we're using a random interval.brian2001-05-221-6/+3
| | | | | | Show the calculated random value instead. Suggested by: Bill Richter <richterb@binkley.foothill.net>
* Untangle some cunfusion between the CLOSE_STAYDOWN, CLOSE_LCP andbrian2001-02-041-16/+19
| | | | | | | | CLOSE_NORMAL meanings. CLOSE_NORMAL doesn't change the currently required state, the others do. This should stop ppp from entering DATALINK_READY when LCP shutdown doesn't end up happening cleanly. Bump our version number to reflect this change.
* Various whitespace changes.brian2000-10-301-1/+2
| | | | Make some functions static.
* Support link identification from rfc1570brian2000-07-191-1/+1
| | | | Two new commands are available; ``ident'' and ``sendident''.
* When we do a ``dial'' or ``open'' from DATALINK_READY, go tobrian2000-05-261-2/+4
| | | | | | | | | | DATALINK_CARRIER and turn off scripting. This should fix instances where ``term'' is used followed by ~. and then ``dial''/``open'' (it currently just sits there looking at you). Reported by: Tim Vanderhoek <vanderh@ecf.utoronto.ca>
* When running ppp -background, show comfort messages showingbrian2000-04-071-2/+8
| | | | | | | | when we're redialing/reconnecting. While we're here, log redial, reconnect and phone number announcements to LogCHAT, and reduce some other logging to LogDEBUG.
* Don't bother setting the dial timer if we've closed abrian2000-03-221-1/+2
| | | | | background/foreground/direct and zero'd the redial/reconnect counts.
* To avoid namespace polution in NetBSD:brian2000-03-141-4/+4
| | | | ``struct descriptor'' -> ``struct fdescriptor''
* If we're in callback mode, don't forget this fact when webrian2000-01-271-0/+2
| | | | | | get into datalink_Down(). Submitted by: David Hedley <david@inty.co.uk>
* Add a bunch of `const's and fix a typo.brian1999-12-271-1/+1
| | | | Submitted by: Rich Neswold <rneswold@MCS.Net>
* Notice and warn about unterminated quoted strings in commands.brian1999-12-201-9/+18
| | | | The entire command is ignored if the syntax is invalid...
* Be careful not to re-initialise `struct stat' while it still hasbrian1999-12-031-16/+16
| | | | | | a running timer. This fixes a problem where a dial is manually aborted, the hangup script kicks in and the chat timer ends up on the timer queue twice (tick tick tick tick *boom*)
* Make -foreground a proper option (allowing ``allow mode foreground'',brian1999-11-281-5/+7
| | | | ``set mode foreground'' etc.
* Rewrite the link descriptor transfer code in MP mode.brian1999-11-251-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, ppp attempted to bind() to a local domain tcp socket based on the peer authname & enddisc. If it succeeded, it listen()ed and became MP server. If it failed, it connect()ed and became MP client. The server then select()ed on the descriptor, accept()ed it and wrote its pid to it then read the link data & link file descriptor, and finally sent an ack (``!''). The client would read() the server pid, transfer the link lock to that pid, send the link data & descriptor and read the ack. It would then close the descriptor and clean up. There was a race between the bind() and listen() where someone could attempt to connect() and fail. This change removes the race. Now ppp makes the RCVBUF big enough on a socket descriptor and attempts to bind() to a local domain *udp* socket (same name as before). If it succeeds, it becomes MP server. If it fails, it sets the SNDBUF and connect()s, becoming MP client. The server select()s on the descriptor and recvmsg()s the message, insisting on at least two descriptors (plus the link data). It uses the second descriptor to write() its pid then read()s an ack (``!''). The client creates a socketpair() and sendmsg()s the link data, link descriptor and one of the socketpair descriptors. It then read()s the server pid from the other socketpair descriptor, transfers any locks and write()s an ack. Now, there can be no race, and a connect() failure indicates a stale socket file. This also fixes MP ppp over ethernet, where the struct msghdr was being misconstructed when transferring the control socket descriptor. Also, if we fail to send the link, don't hang around in a ``session owner'' state, just do the setsid() and fork() if it's required to disown a tty. UDP idea suggested by: Chris Bennet from Mindspring at FreeBSDCon
* Don't recurse into datalink_UpdateSet() afterbrian1999-11-091-2/+4
| | | | | | | | | | | doing a HangupDone(). The HangupDone() may fuel bundle_CleanDatalinks(), and if so, the bogus UpdateSet() ends up select()ing on a closed descriptor..... Change the main `do/while' loop to a `for' loop so that any `continue's do the bundle_CleanDatalinks() & bundle_IsDead() bit.
* Support PPPoEbrian1999-11-061-4/+5
| | | | | Help (lots) from: julian, archie Facilities from: ahebert@pubnix.net
* Introduce ``set logout''; another chat script. This is in preparationbrian1999-10-251-17/+40
| | | | for the abstraction of ``set dial'' and ``set hangup''.
* Don't go from PHASE_NETWORK to PHASE_ESTABLISH when we want tobrian1999-10-211-2/+4
| | | | | | re-open a device. The fact that we're in NETWORK phase indicates that there are other links in DATALINK_OPEN and that we don't want to stop using them.
* Revert the 1.44 -> 1.45 change. It doesn't work as expected.brian1999-10-081-1/+1
|
* Don't go from datalink state opening directly to lcp, go viabrian1999-10-071-5/+11
| | | | | | | | | carrier instead so that we can set up our carrier detect timer and eventually notice when we lose carrier. Honour the script.run value when coming out of carrier state. PR: 14145
* Bring links down gently when their throughput isn't enough forbrian1999-10-051-1/+1
| | | | | the ``set autoload'' value. Don't just ``down'' the link. Don't get stuck in ``ready'' the first time we ``close'' a link.
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* Add ISDN support via isdnd & i4b. This requires versionbrian1999-08-061-6/+27
| | | | | | | | | | | | | | | | | | | | | | | | | 0.81.1 of the i4b code - namely support of the I4B_VR_REQ ioctl via the i4brbchX device. Ppp controls the phone number, but idle timers and SYNC/RAW decisions are still made by isdnd (in isdnd.rc). This involves a new datalink state machine phase. The ``wait for carrier'' phase happens after dialing but before logging in. The whole dial state should really be abstracted so that each device type can deal with it in its own way (thinking about PPPoE) - but that'll have to wait. The ``set cd'' symantics remain the same for tty devices, but we now delay until we either get CD or timeout waiting (at which time we drop the link if we require CD). For i4b devices we always insist on carrier. Thanks to hm@ for his help, and especially for pointing out that I *don't* need to re-implement isdnd (that was a huge waste of time !) :-]
* o Obsolete the undocumented ``set weight'' command.brian1999-08-051-1/+4
| | | | | | | | | | | | | | | | | | | | | | | o If we're using RADIUS and the RADIUS mtu is less than our peers mru/mrru, reduce our mtu to this value for NetBSD too. o Make struct throughput's sample period dynamic and tweak the ppp version number to reflect the extra stuff being passed through the local domain socket as a result (MP mode). o Measure the current throughput based on the number of samples actually taken rather than on the full sample period. o Keep the throughput statisics persistent while being passed to another ppp invocation through the local domain socket. o When showing throughput statistics after the timer has stopped, use the stopped time for overall calculations, not the current time. Also show the stopped time and how long the current throughput has been sampled for. o Use time() consistently in throughput.c o Tighten up the ``show bundle'' output. o Introduce the ``set bandwidth'' command. o Rewrite the ``set autoload'' command. It now takes three arguments and works based on a rolling bundle throughput average compared against the theoretical bundle bandwidth over a given period (read: it's now functional).
* Don't use the ``next'' redial timer if we have no phone number at all.brian1999-06-181-1/+3
|
* Never bring a link back up after receiving a terminating signal,brian1999-06-101-2/+2
| | | | don't rely on already being in PHASE_DEAD.
* Allow ``host:port/udp'' devices and support ``host:port/tcp'' asbrian1999-05-121-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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().
* o Redesign the layering mechanism and make the aliasing code part ofbrian1999-05-081-19/+19
| | | | | | | | | | | | | | | | | | | | | 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''.
* When going from DATALINK_HANGUP directly tobrian1999-04-061-1/+5
| | | | | | DATALINK_OPENING, don't forget to change phase to ESTABLISH if we're currently TERMINATE'ing. Helped locate by: Chuck Robey <chuckr@mat.net>
* When we get an LCP TLU, go into PHASE_AUTHENTICATEbrian1999-04-051-2/+2
| | | | | | from any other phase besides PHASE_NETWORK, otherwise there's a chance that we end up sending auth packets and dropping the replies.
* Extend the ``set redial'' command to allow incrementalbrian1999-03-041-46/+97
| | | | redial timeouts.
* Allow control over the number of ConfigREQ & TermREQ attemptsbrian1999-02-261-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* When our dial timeout is ``random'', display its valuebrian1999-02-251-9/+14
| | | | | | | | | correctly by invoking the timer to get the value before displaying the message. Don't assume that a value of 0 is ``random'' in ``show datalink''. Make the random value between 1 and DIAL_TIMEOUT rather than between 0 and DIAL_TIMEOUT-1
* Fully support both NT and LANMan CHAP type 0x80 as bothbrian1999-02-181-10/+9
| | | | authenticator and authenticatee.
* Nuke any remaining auth timers when datalinks come back downbrian1999-02-171-9/+17
| | | | to DATALINK_LCP.
* When resending chap challenges, resend the same challengebrian1999-02-111-5/+21
| | | | | | | | | | | | | | | | | | | each time rather than making up a new one. Increase the authname/authkey max sizes to 100 characters. Allow ``authkey'' specifications beginning with ``!''. When a challenge is received, the text following the ``!'' is executed as a program (expanding stuff in the same way that ``sh'' and ``!bg'' do). The program is passed the peer name, peer challenge and local ``authname'' on standard input and is expected to output the name/key combination that should be used to build the CHAP response. This provides support for Secure ID cards (guess what I was given at work recently!) using CHAP. Examples will follow.
* Decouple pap & chap output routines from the correspondingbrian1999-02-061-25/+24
| | | | | | | | | | | | | | | | | | | | | | | 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
* Reimplement the previous fix (no response to PAP requests)brian1999-02-021-5/+3
| | | | | | at the authentication layer rather than at the PAP layer so that it also applies to CHAP (no response to CHAP challenges).
* If we receive no answer from the server when sending PAPbrian1999-02-011-3/+5
| | | | requests, give up (don't sit there indefinitely).
* Initial RADIUS support (using libradius). See the man page forbrian1999-01-281-2/+5
| | | | | | | | | | | | | | | | | | | 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
* Recurse when we've switched state via LoginDone(). If we'vebrian1999-01-201-2/+2
| | | | | got an open link, we want it to be select()d on - otherwise we get a freeze when ``openmode'' is passive.
* If we've configured CBCP *and* another not-so-importantbrian1999-01-121-5/+9
| | | | | | | CALLBACK protocol and end up agreeing CBCP, DTRT and go into CBCP phase rather than mistakenly terminating as if CBCP wasn't agreed. Problem reported by: Alexander Dubinin <alex@nstl.nnov.ru>
* Don't use the next phone number after the ``|'' if thebrian1999-01-081-1/+2
| | | | | | dial & login are successful. Submitted by: Toshiomi Moriki <Toshiomi.Moriki@ma1.seikyou.ne.jp> PR: 9382
OpenPOWER on IntegriCloud