aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/ppp/physical.h
Commit message (Collapse)AuthorAgeFilesLines
* o Clean up some #includesBrian Somers2002-05-141-0/+2
| | | | | | | | | | | | | | | | | | | | | 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-0/+3
| | | | | | | | | | | 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
* Handle hardware-imposed MTU/MRU limitations. PPPoE will no longerBrian Somers2001-06-181-0/+2
| | | | | | | | | | | | | | | allow MRU/MTU negotiations to exceed 1492. Add an optional ``max'' specifier to ``set m[rt]u'', ie. set mtu max 1480 Bump the ppp version number. Sponsored by: Monzoon Networks AG and FreeBSD Services Limited Notes: svn path=/head/; revision=78410
* Support PPPoATM, disabled for now as /usr/include/netnatm doesn't existBrian Somers2000-09-141-0/+1
| | | | | | | Submitted by: Jakob Stoklund Olesen <stoklund@taxidriver.dk> Notes: svn path=/head/; revision=65862
* Correct some typos introduced in the descriptor -> fdescriptor change.Brian Somers2000-03-141-1/+1
| | | | Notes: svn path=/head/; revision=58038
* To avoid namespace polution in NetBSD:Brian Somers2000-03-141-5/+5
| | | | | | | ``struct descriptor'' -> ``struct fdescriptor'' Notes: svn path=/head/; revision=58028
* Change ``set cd'' so that its default value is device specific. TheBrian Somers1999-11-261-7/+11
| | | | | | | | default is still 1 second for ttys, but is now 6 seconds for i4b (ISDN) devices and 5 seconds for ethernet (PPPoE) devices. Notes: svn path=/head/; revision=53733
* Rewrite the link descriptor transfer code in MP mode.Brian Somers1999-11-251-4/+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
* Support PPPoEBrian Somers1999-11-061-7/+15
| | | | | | | | Help (lots) from: julian, archie Facilities from: ahebert@pubnix.net Notes: svn path=/head/; revision=52942
* Manually create a correct(*) entry in wtmp when logging out a PPPoTCP orBrian Somers1999-10-211-1/+1
| | | | | | | | | | | PPPoUDP connection. (*) This is as correct as ftp and uucp wtmp entries are - that is, multiple concurrent connections will not record enough information in wtmp to tell last(1) who was logged in for how long. Notes: svn path=/head/; revision=52429
* Support ``set cd off'' to tell ppp not to even look for carrier on theBrian Somers1999-09-261-1/+6
| | | | | | | device. Notes: svn path=/head/; revision=51699
* $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-5/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Correct the way ppp transfers links on the server side in MPBrian Somers1999-06-051-2/+3
| | | | | | | | | | | | mode by padding out the ``struct device'' to the maximum device size. Bump the ppp version number to indicate the transfer format change. This should make MP over tty and udp devices functional again. Notes: svn path=/head/; revision=47769
* Increase the length of an individual device name to LINE_LEN.Brian Somers1999-06-011-2/+2
| | | | | | | | Adjust the base physical device name correctly after a link transfer (allowing correct multilink callbacks). Notes: svn path=/head/; revision=47682
* Correct the ``ignoring sync/async'' warnings so that they showBrian Somers1999-05-241-2/+2
| | | | | | | | | up with the correct device type. Reassign the correct tcpdevice or execdevice after transfering a link in MP server mode. Notes: svn path=/head/; revision=47461
* Allow ``host:port/udp'' devices and support ``host:port/tcp'' asBrian Somers1999-05-121-13/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-26/+52
| | | | | | | | | | | | | | | | | | | | | | | | 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
* Change ``set device'' so that it parses its arguments as oneBrian Somers1999-04-271-2/+3
| | | | | | | | | | | | | device per argument rather than the old way of concatenating everything then splitting the result at commas and whitespace. Old syntax of ``set device /dev/cuaa0, /dev/cuaa1'' may no longer contain the comma, but syntax such as ``set device "!ssh host ppp -direct label"'' is now possible. Notes: svn path=/head/; revision=46102
* Handle the detection of frames even if we read themBrian Somers1999-04-031-1/+6
| | | | | | | | | | | | with more than one read(). When we detect one, don't forget to pass it to async_Input() and drop our terminal back into command mode. Don't output an extraneous \r if we're passed \r\n to prompt_vprintf in raw mode. Notes: svn path=/head/; revision=45264
* Wait by default for one second after the login scriptBrian Somers1999-02-161-1/+5
| | | | | | | | | | | | | | | | | | | | is complete before checking carrier. If it's there, the device supports carrier. If it's not it doesn't. Add the ``set cd'' command for deciding how soon to check for carrier, and for deciding if carrier is REQUIRED. The default has changed: Pre 2.0 versions of ppp waited for 1 second. Version 2 didn't wait, but this causes problems with some (few?) modems that don't assert carrier immediately on reporting CONNECT. The one second delay is back now and can be removed with ``set cd 0''. Bump the ppp version number in case this needs to be changed again.... Notes: svn path=/head/; revision=44073
* Only call isatty() when we open our descriptor, and rememberBrian Somers1999-01-101-7/+2
| | | | | | | | | | | | | | the answer. If we later get a descriptor exception from select(), we know that it's a tty (isatty() returns 0 after the exception on a tty) and remember to call modem_LogicalClose(). The upshot of it all is that descriptor exceptions dont leave the tty locked any more. Notes: svn path=/head/; revision=42452
* If we've got a full output buffer queue and cannot sendBrian Somers1998-08-251-1/+2
| | | | | | | | | | | 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
* o If there's a session leader left running for a descriptorBrian Somers1998-05-291-1/+2
| | | | | | | | | | | | | | 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
* MFMP: Make ppp multilink capable.Brian Somers1998-05-211-1/+1
| | | | | | | See the file README.changes, and re-read the man page. Notes: svn path=/head/; revision=36285
* o Add the `set mode' command for change a links current mode. ItBrian Somers1998-05-151-1/+2
| | | | | | | | | | | | | | | | 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. Notes: svn path=/cvs2svn/branches/MP/; revision=36088
* o Call bundle_LinkClosed() when transferring a datalink so thatBrian Somers1998-05-151-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | 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. Notes: svn path=/cvs2svn/branches/MP/; revision=36076
* Cosmetic: Make our external function names consistent.Brian Somers1998-05-011-30/+26
| | | | Notes: svn path=/cvs2svn/branches/MP/; revision=35605
* o Explicitly set the close-on-exec flag of descriptor 3 beforeBrian Somers1998-05-011-2/+1
| | | | | | | | | | | | | | | 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. Notes: svn path=/cvs2svn/branches/MP/; revision=35603
* Do away with the static struct timeoutArg. Move theBrian Somers1998-04-201-1/+3
| | | | | | | | struct pppTimer from struct link to struct physical for doing carrier checking. Notes: svn path=/cvs2svn/branches/MP/; revision=35320
* o Fix chats expect-send-expect - it shouldn't beBrian Somers1998-04-101-2/+2
| | | | | | | | | | | 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). Notes: svn path=/cvs2svn/branches/MP/; revision=35122
* o Remove the `mode' global - it's now per physical device.Brian Somers1998-04-101-11/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. Notes: svn path=/cvs2svn/branches/MP/; revision=35118
* o Move alias function pointers into loadalias.cBrian Somers1998-04-071-12/+14
| | | | | | | | | | | 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. Notes: svn path=/cvs2svn/branches/MP/; revision=35089
* o Move struct lcp and struct ccp into struct link.Brian Somers1998-04-031-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. Notes: svn path=/cvs2svn/branches/MP/; revision=35009
* Make struct bundle into a sort of `struct descriptor'.Brian Somers1998-03-201-2/+2
| | | | | | | | It does the fdsets/reads/writes for each of it's datalinks. Notes: svn path=/cvs2svn/branches/MP/; revision=34722
* Remove struct physical::abort.Brian Somers1998-03-201-2/+1
| | | | Notes: svn path=/cvs2svn/branches/MP/; revision=34720
* "dial" now may optionally have context.Brian Somers1998-03-131-1/+2
| | | | | | | Tidy up some LcpInfo uses. Notes: svn path=/cvs2svn/branches/MP/; revision=34532
* Move `Utmp' into struct physical. We can be logged inBrian Somers1998-03-101-2/+7
| | | | | | | once for every -direct physical connection. Notes: svn path=/cvs2svn/branches/MP/; revision=34446
* o Move all device names into struct physical.Brian Somers1998-03-061-2/+8
| | | | | | | | | o Use the correct device name in -direct mode. o Use a default list of "cuaa1, cuaa0" rather than just cuaa1 and allow embedded spaces as separators. Notes: svn path=/cvs2svn/branches/MP/; revision=34062
* o Remove the global CcpInfo. It's now part of the datalink.Brian Somers1998-02-231-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | 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. Notes: svn path=/cvs2svn/branches/MP/; revision=33754
* Shuffle around our FSMs a bit. This'll make itBrian Somers1998-02-211-3/+3
| | | | | | | | easier to remove the CcpInfo, LcpInfo and IpcpInfo globals. Notes: svn path=/cvs2svn/branches/MP/; revision=33702
* o Create `struct hdlc' - a part of struct physical.Brian Somers1998-02-181-1/+2
| | | | | | | | | | | | | o Move our LCP report timer into struct hdlc - it's really a hdlc timer (fcs errors etc). o Make `show hdlc' require context and make the output more friendly. o Remove all non-const globals from hdlc.c o Output peer-rejected protocols by name - not just ones that we reject. Notes: svn path=/cvs2svn/branches/MP/; revision=33582
* Cosmetic: Group configuration items in struct physical.Brian Somers1998-02-171-6/+10
| | | | Notes: svn path=/cvs2svn/branches/MP/; revision=33512
* Update to version 2.0-betaBrian Somers1998-02-131-2/+3
| | | | | | | | | | | | | | | | | | | 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. Notes: svn path=/cvs2svn/branches/MP/; revision=33305
* Pass the fdset to descriptor_Read & descriptor_WriteBrian Somers1998-02-101-2/+2
| | | | | | | allowing support for the use of multiple file descriptors. Notes: svn path=/cvs2svn/branches/MP/; revision=33207
* o Introduce struct descriptor.Brian Somers1998-02-091-3/+15
| | | | | | | | | | 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. Notes: svn path=/cvs2svn/branches/MP/; revision=33194
* Isolate fsm callback functionsBrian Somers1998-02-061-1/+2
| | | | | | | | | Derive {lcp,ipcp,ccp}state structures from struct fsm where convenient. Create bundle_Down() and remove LcpDown() Notes: svn path=/cvs2svn/branches/MP/; revision=33128
* Shuffle names and args in modem.hBrian Somers1998-02-061-1/+2
| | | | Notes: svn path=/cvs2svn/branches/MP/; revision=33125
* Create `struct async' and make it part of `struct physical'.Brian Somers1998-02-021-5/+2
| | | | | | | | | | 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. Notes: svn path=/cvs2svn/branches/MP/; revision=33032
* Create `struct link' - the logical link from whichBrian Somers1998-01-301-27/+24
| | | | | | | | `struct physical' (and the future `struct logical') are derived. Notes: svn path=/cvs2svn/branches/MP/; revision=32903