aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/ppp/datalink.c
Commit message (Collapse)AuthorAgeFilesLines
* various: general adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-271-0/+2
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. No functional change intended. Notes: svn path=/head/; revision=326276
* Add a bunch of malloc() return checksBrian Somers2004-10-111-6/+14
| | | | | | | | PR: 71592 Submitted by: Dan Lukes <dan@obluda.cz> with further changes Notes: svn path=/head/; revision=136375
* Make ppp WARNS=5 cleanBrian Somers2004-09-051-5/+5
| | | | Notes: svn path=/head/; revision=134789
* Add a ``force-scripts'' option for using chat scripts with -direct andBrian Somers2003-03-261-1/+2
| | | | | | | | | -dedicated links. Submitted by: Maksim Yevmenkin <myevmenk@exodus.net> Notes: svn path=/head/; revision=112659
* Include the correct file (stdarg.h) and use va_list rather than _BSD_VA_LIST_Brian Somers2002-08-271-0/+1
| | | | | | | Suggested by: mike Notes: svn path=/head/; revision=102500
* Replace various spelling with FALLTHROUGH which is lint()ablePhilippe Charnier2002-08-251-8/+8
| | | | Notes: svn path=/head/; revision=102413
* Remove whitespace at the end of lines.Brian Somers2002-06-151-3/+3
| | | | Notes: svn path=/head/; revision=98243
* o Clean up some #includesBrian Somers2002-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> Notes: svn path=/head/; revision=96582
* Merge the NETGRAPH branch into HEAD. tty devices now use netgraph's lineBrian Somers2002-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. Notes: svn path=/head/; revision=93418
* Don't blow away ``set escape'' settings when we've completed theBrian Somers2002-03-041-1/+1
| | | | | | | | | login phase. Just initialise the correct parts. Originially submitted by: Vladimir B. Machulsky <bofhmail@yahoo.com> Notes: svn path=/head/; revision=91623
* Don't avoid setting a 0 second timer in datalink_StartDialTimer() byBrian Somers2001-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 Notes: svn path=/head/; revision=85362
* o Add ipv6 support, abstracting most NCP addresses into opaqueBrian Somers2001-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> Notes: svn path=/head/; revision=81634
* Reduce the interface MTU by 2 when MPPE has been successfully negotiated.Brian Somers2001-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. Notes: svn path=/head/; revision=79165
* Don't say ``Enter pause (-1) for redialing when we're using a random interval.Brian Somers2001-05-221-6/+3
| | | | | | | | | Show the calculated random value instead. Suggested by: Bill Richter <richterb@binkley.foothill.net> Notes: svn path=/head/; revision=77012
* Untangle some cunfusion between the CLOSE_STAYDOWN, CLOSE_LCP andBrian Somers2001-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. Notes: svn path=/head/; revision=71970
* Various whitespace changes.Brian Somers2000-10-301-1/+2
| | | | | | | Make some functions static. Notes: svn path=/head/; revision=67912
* Support link identification from rfc1570Brian Somers2000-07-191-1/+1
| | | | | | | Two new commands are available; ``ident'' and ``sendident''. Notes: svn path=/head/; revision=63484
* When we do a ``dial'' or ``open'' from DATALINK_READY, go toBrian Somers2000-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> Notes: svn path=/head/; revision=60945
* When running ppp -background, show comfort messages showingBrian Somers2000-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. Notes: svn path=/head/; revision=59084
* Don't bother setting the dial timer if we've closed aBrian Somers2000-03-221-1/+2
| | | | | | | | background/foreground/direct and zero'd the redial/reconnect counts. Notes: svn path=/head/; revision=58455
* To avoid namespace polution in NetBSD:Brian Somers2000-03-141-4/+4
| | | | | | | ``struct descriptor'' -> ``struct fdescriptor'' Notes: svn path=/head/; revision=58028
* If we're in callback mode, don't forget this fact when weBrian Somers2000-01-271-0/+2
| | | | | | | | | get into datalink_Down(). Submitted by: David Hedley <david@inty.co.uk> Notes: svn path=/head/; revision=56656
* Add a bunch of `const's and fix a typo.Brian Somers1999-12-271-1/+1
| | | | | | | Submitted by: Rich Neswold <rneswold@MCS.Net> Notes: svn path=/head/; revision=55146
* Notice and warn about unterminated quoted strings in commands.Brian Somers1999-12-201-9/+18
| | | | | | | The entire command is ignored if the syntax is invalid... Notes: svn path=/head/; revision=54914
* Be careful not to re-initialise `struct stat' while it still hasBrian Somers1999-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*) Notes: svn path=/head/; revision=54055
* Make -foreground a proper option (allowing ``allow mode foreground'',Brian Somers1999-11-281-5/+7
| | | | | | | ``set mode foreground'' etc. Notes: svn path=/head/; revision=53830
* Rewrite the link descriptor transfer code in MP mode.Brian Somers1999-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 Notes: svn path=/head/; revision=53684
* Don't recurse into datalink_UpdateSet() afterBrian Somers1999-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. Notes: svn path=/head/; revision=53070
* Support PPPoEBrian Somers1999-11-061-4/+5
| | | | | | | | Help (lots) from: julian, archie Facilities from: ahebert@pubnix.net Notes: svn path=/head/; revision=52942
* Introduce ``set logout''; another chat script. This is in preparationBrian Somers1999-10-251-17/+40
| | | | | | | for the abstraction of ``set dial'' and ``set hangup''. Notes: svn path=/head/; revision=52488
* Don't go from PHASE_NETWORK to PHASE_ESTABLISH when we want toBrian Somers1999-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. Notes: svn path=/head/; revision=52412
* Revert the 1.44 -> 1.45 change. It doesn't work as expected.Brian Somers1999-10-081-1/+1
| | | | Notes: svn path=/head/; revision=52029
* Don't go from datalink state opening directly to lcp, go viaBrian Somers1999-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 Notes: svn path=/head/; revision=51978
* Bring links down gently when their throughput isn't enough forBrian Somers1999-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. Notes: svn path=/head/; revision=51945
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50479
* Add ISDN support via isdnd & i4b. This requires versionBrian Somers1999-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 !) :-] Notes: svn path=/head/; revision=49472
* o Obsolete the undocumented ``set weight'' command.Brian Somers1999-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). Notes: svn path=/head/; revision=49434
* Don't use the ``next'' redial timer if we have no phone number at all.Brian Somers1999-06-181-1/+3
| | | | Notes: svn path=/head/; revision=48003
* Never bring a link back up after receiving a terminating signal,Brian Somers1999-06-101-2/+2
| | | | | | | don't rely on already being in PHASE_DEAD. Notes: svn path=/head/; revision=47863
* Allow ``host:port/udp'' devices and support ``host:port/tcp'' asBrian Somers1999-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(). Notes: svn path=/head/; revision=47061
* o Redesign the layering mechanism and make the aliasing code part ofBrian Somers1999-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''. Notes: svn path=/head/; revision=46686
* When going from DATALINK_HANGUP directly toBrian Somers1999-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> Notes: svn path=/head/; revision=45385
* When we get an LCP TLU, go into PHASE_AUTHENTICATEBrian Somers1999-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. Notes: svn path=/head/; revision=45350
* Extend the ``set redial'' command to allow incrementalBrian Somers1999-03-041-46/+97
| | | | | | | redial timeouts. Notes: svn path=/head/; revision=44468
* Allow control over the number of ConfigREQ & TermREQ attemptsBrian Somers1999-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. Notes: svn path=/head/; revision=44305
* When our dial timeout is ``random'', display its valueBrian Somers1999-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 Notes: svn path=/head/; revision=44261
* Fully support both NT and LANMan CHAP type 0x80 as bothBrian Somers1999-02-181-10/+9
| | | | | | | authenticator and authenticatee. Notes: svn path=/head/; revision=44106
* Nuke any remaining auth timers when datalinks come back downBrian Somers1999-02-171-9/+17
| | | | | | | to DATALINK_LCP. Notes: svn path=/head/; revision=44094
* When resending chap challenges, resend the same challengeBrian Somers1999-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. Notes: svn path=/head/; revision=43888
* Decouple pap & chap output routines from the correspondingBrian Somers1999-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 Notes: svn path=/head/; revision=43693