aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/ppp/server.c
Commit message (Collapse)AuthorAgeFilesLines
* MFC: EverythingBrian Somers2002-09-011-23/+67
| | | | | | | | | | | | | | | | | | | | Notably, this includes the following: o IPv6 support o Better RADIUS support (including MS-CHAP) o Improved handling of bad negotiation options o Improved negotiation diagnostics o Improved sockaddr (RTAX) parsing o More consistent compile time options (NOXXX to compile something out) o More available macros o Firewall punching o Improved ``proxy'' and ``proxyall'' handling o Handle connected UDP sockets on descriptor 0 in -direct mode o Fix a load of typos o Update to internal version 3.1 Notes: svn path=/stable/4/; revision=102753
* MFC: Support -DPPP_CONFDIRBrian Somers2001-05-171-39/+112
| | | | | | | | | | | | | | | | | | | Send PROTO_IP traffic when possible in single-link MP mode MAXPATHLEN -> PATH_MAX Update route MTUs when the interface MTU changes Show diagnostic socket info in ``show bundle'' Support ``set server open'', ``set server closed'' and SIGUSR1 Load netgraph.ko when required Support ipencap packets Be more consistent with the NET_RT_IFLIST sysctl when creating an interface Optimise out deleting and re-adding the same ifaddr on the tun interface Fix some man page markup and add some further examples. Call ourself ``localhost'' if we have no hostname Allow embedded NULs in radius passwords and challenges Do ioctl(TUNSIFINFO) as uid 0 Notes: svn path=/stable/4/; revision=76758
* MFC: Reset MPPE_MasterKeyValid when the bundle closesBrian Somers2001-02-221-0/+4
| | | | | | | | | | | | Don't try to negotiate MPPE when CHAP81 hasn't been agreed Don't drop to state DATALINK_READY when we close a link that never actually opened Tone down some MPPE diagnostics Various man page fixes Handle sa_len == 0 from accept() Notes: svn path=/stable/4/; revision=72834
* MFC: Add MPPE, MSChapv2 and tcpmssfixupBrian Somers2000-12-181-1/+2
| | | | | | | | | | | | | | | | | | | | Add ``set log all'' Display the mtu with ``show iface'' Support RADIUS accounting Use the correct negotiated CCP options Document how to tunnel using PPP/UDP and MPPE Fix examples of using ``add'' Fix another comment parsing bug Make pppoe netgraph messages consistent with -current Fix some lines >80 characters Mention what mbuf type can't be allocated Increase M_MAXLEN so that it's consistent with HDLCSIZE Retry sending data when we get ENOBUFS Don't assuming UDP sockets to be unconnected in -direct mode Bump to version 2.3 Notes: svn path=/stable/4/; revision=70135
* MFC: Handle open/dial from state DATALINK_READY properlyBrian Somers2000-06-031-1/+1
| | | | | | | | | | | | | | | | | Don't disable the autoload timer at the wrong time Use a SOCK_DGRAM socketpair() for synchronous "!program" devices Send a HUP to "!program" devices when they're closed Drop packets when the fsm header length is bigger than the payload Create /etc/resolv.conf with the correct umask (when dns is enabled) Don't dump core when trying to write a new resolv.conf Add some more verbose ``inappropriate peer'' diagnostics in MP mode Pass all packets through libalias in NAT mode Describe ``enable proxy'' a bit more chmod local-domain diagnostic sockets correctly When a PPPoTCP connection fails, don't moan about invalid syntax Notes: svn path=/stable/4/; revision=61195
* MFC:Brian Somers2000-03-211-5/+5
| | | | | | | | | | | | | | | | | | | | Understand environment variables in commands Understand IP6 addresses in ``show route'' Correct an alignment bug in ``show route'' Add the ``resolv'' command Add ``dns'' logging Rename struct descriptor -> struct fdescriptor Fix some printf-style parameter-type bugs Use <nnn> instead of <???> when something's not understood Log (debug) information about incoming fragment handling Correct two bugs in the timer code Add some {Net,Open}BSD compatibility stuff Fix some gramar and line breaks in ppp.8 Requested by: peter Notes: svn path=/stable/4/; revision=58419
* Back out the bogus #ifdef __NetBSD__ #include <signal.h> lines.Brian Somers1999-09-211-3/+0
| | | | | | | | | | The original report was due to a mis-installation of the NetBS header files :-/ Submitted by: Kazuyoshi Kato <kazk@yyy.or.jp> Notes: svn path=/head/; revision=51517
* NetBSD has moved ``extern int errno;'' to signal.h :-/Brian Somers1999-09-201-0/+3
| | | | | | | Submitted by: Kazuyoshi Kato <kazk@yyy.or.jp> Notes: svn path=/head/; revision=51449
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50479
* Don't destroy the old server socket another ``set server''Brian Somers1999-03-081-5/+11
| | | | | | | call fails. Notes: svn path=/head/; revision=44588
* Correctly drop existing connections when reopening the diagnosticBrian Somers1999-03-071-2/+2
| | | | | | | socket. Notes: svn path=/head/; revision=44544
* PR: 7469Brian Somers1998-08-021-2/+6
| | | | | | | | | Be careful that the current or next prompt in the list that we're iterating through doesn't get changed by descriptor_Read(). Notes: svn path=/head/; revision=38013
* Remove redundant includesBrian Somers1998-06-271-19/+1
| | | | Notes: svn path=/head/; revision=37192
* o If we come out of select() with only write descriptors thatBrian Somers1998-06-241-2/+3
| | | | | | | | | | | | | | 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
* Change some log levels. ALERTs are only logged whenBrian Somers1998-06-161-2/+2
| | | | | | | | | 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
* o Move our prompt descriptor list outside of the bundle.Brian Somers1998-05-231-46/+71
| | | | | | | | | | | | | | | | | | | | | | | 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
* MFMP: Make ppp multilink capable.Brian Somers1998-05-211-62/+166
|\ | | | | | | | | | | | | See the file README.changes, and re-read the man page. Notes: svn path=/head/; revision=36285
| * o Protect against expected NULL fdset pointers.Brian Somers1998-05-101-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | o Log FD_SET()s in LogTIMER. o Identify the descriptor that causes an EBADF from select() if LogTIMER is enabled (then exit). o Call the MP server UpdateSet() function after calling the UpdateSet() for all links - the link may enter PHASE_TERMINATE and bring down the MP server - breaking the imminent select(). Notes: svn path=/cvs2svn/branches/MP/; revision=35924
| * Cosmetic: Make our external function names consistent.Brian Somers1998-05-011-21/+21
| | | | | | | | Notes: svn path=/cvs2svn/branches/MP/; revision=35605
| * o Add the link name to modem diagnostics.Brian Somers1998-04-281-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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). Notes: svn path=/cvs2svn/branches/MP/; revision=35481
| * Cosmetic: Clean up warnings.Brian Somers1998-04-181-6/+6
| | | | | | | | Notes: svn path=/cvs2svn/branches/MP/; revision=35258
| * o Remove the `mode' global - it's now per physical device.Brian Somers1998-04-101-17/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * Remove MODE_ALIAS and add AliasEnabled() macro.Brian Somers1998-04-071-3/+1
| | | | | | | | | | | | | | Remove IsInteractive(). Notes: svn path=/cvs2svn/branches/MP/; revision=35098
| * o Move alias function pointers into loadalias.cBrian Somers1998-04-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | 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
| * Remove unused includes.Brian Somers1998-04-061-4/+1
| | | | | | | | Notes: svn path=/cvs2svn/branches/MP/; revision=35059
| * Deglobalise `struct prompt':Brian Somers1998-04-031-40/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | o Our diagnostic socket has its password set in the `set socket' line only (not in ppp.secret). o Passwords are per server socket (*VarAuthKey are gone) o Authority is per prompt (VarLocalAuth is gone). o Local logging is per prompt. o Add a `show who' command to see who's connected. No identd routine - just a `where the connection came from' display. o SIGUSR1 is disabled for now - we have no way of choosing a password for the socket created :-( Prompts are attached as a list of `struct descriptor's in struct bundle, and serviced under the bundles descriptor service routines. Ultimately, everything should be done like this. Cosmetic: o alphabeticalise SRCS in Makefile. o Add a few comments in command.h TODO: Start checking that we don't overflow the descriptor sets in select() now that we can have any number of descriptors. Notes: svn path=/cvs2svn/branches/MP/; revision=35016
| * o Move struct lcp and struct ccp into struct link.Brian Somers1998-04-031-6/+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
| * o Remove the global CcpInfo. It's now part of the datalink.Brian Somers1998-02-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * LogWARN rather than LogERROR when we can't createBrian Somers1998-02-181-5/+5
| | | | | | | | | | | | | | our diagnostic socket. Notes: svn path=/cvs2svn/branches/MP/; revision=33588
| * Create struct datalink.Brian Somers1998-02-161-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a type of physical link that can chat and talk LCP & CCP. A bundle contains a list of these (only one in the list for the moment). The datalink is a type of descriptor, and dials, enters LCP (& does CCP), kicks the bundle when its FSMs do something interesting and does the hangup chat script on the way down. It also handles redials and reconnects. There are lots of loose ends, and probably lots of bugs, but the data structures are getting there ! Notes: svn path=/cvs2svn/branches/MP/; revision=33415
| * Update to version 2.0-betaBrian Somers1998-02-131-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * Move the terminal/diagnostic socket stuff out of main.cBrian Somers1998-02-101-10/+10
| | | | | | | | | | | | | | | | and into the new `prompt.c'. struct prompt is (of course) a `sort' of descriptor. Notes: svn path=/cvs2svn/branches/MP/; revision=33209
| * Pass the fdset to descriptor_Read & descriptor_WriteBrian Somers1998-02-101-3/+3
| | | | | | | | | | | | | | allowing support for the use of multiple file descriptors. Notes: svn path=/cvs2svn/branches/MP/; revision=33207
| * Make the server descriptor into a `sort' of struct descriptor.Brian Somers1998-02-091-8/+108
| | | | | | | | Notes: svn path=/cvs2svn/branches/MP/; revision=33195
| * Create `struct bundle' - the top level control structure.Brian Somers1998-02-021-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | This structure will eventually contain a list of NCPs (currently only IPCP is supported) and a list of physical `struct link's. It will also derive from a struct link itself. Make ModemTimeout() static - it's way to dangerous to be called from outside ! Bump version to 1.9. Our first MP release should be 2.0. Notes: svn path=/cvs2svn/branches/MP/; revision=33029
| * This commit was manufactured by cvs2svn to create branch 'MP'.cvs2svn1998-01-291-0/+169
| | | | Notes: svn path=/cvs2svn/branches/MP/; revision=32861
* MFMP: LogWARN rather than LogERROR when we can't createBrian Somers1998-02-181-5/+5
| | | | | | | our diagnostic socket. Notes: svn path=/head/; revision=33589
* Remove unused #includes.Brian Somers1998-01-211-2/+1
| | | | | | | | | Make various bits static. Remove unused variables. Submitted by: eivind Notes: svn path=/head/; revision=32663
* Cosmetic (style):Brian Somers1997-12-241-3/+3
| | | | | | | | | | sizeof(var) -> sizeof var sizeof type -> sizeof(type) Suggested by: J Wunsch <j@uriah.heep.sax.de> Notes: svn path=/head/; revision=31962
* Add (BSD) copyright headers.Brian Somers1997-12-211-2/+26
| | | | Notes: svn path=/head/; revision=31921
* Zero struct sockaddr_??s before filling them in.Brian Somers1997-12-211-1/+3
| | | | | | | Suggested by: Theo de Raadt <deraadt@cvs.openbsd.org> Notes: svn path=/head/; revision=31914
* Abstract the CCP layer a level.Brian Somers1997-12-031-2/+1
| | | | | | | Add DEFLATE support. Notes: svn path=/head/; revision=31514
* Fix prototypes.Brian Somers1997-11-221-3/+2
| | | | | | | | | | | | | | | | | 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). Notes: svn path=/head/; revision=31343
* Finish the security improvements:Brian Somers1997-11-111-3/+3
| | | | | | | | | | | | | | | | | | | | | | o Add "allow" command: "allow users a b c" gives access to users a, b and c. "allow modes auto" gives those users access to auto mode only. "allow users *" and "allow modes *" are accepted. No users and all modes are allowed by default. UID 0 can do anything. o Set the current label with the "load" and "dial" commands so that the call to ppp.linkdown makes sense. o Up the verison number. o Don't OR MODE_AUTO for -background and -ddial. o Don't OR MODE_INTER when we get a diagnostic connection. o Allow up to 40 args per line (was 20). o "set ifaddr" only changes the interface in AUTO mode (with other modes, it happens after IPCP negotiation). o Sort command descriptions in the man page. o Support -dedicated mode where we just talk ppp forever (no login etc). Notes: svn path=/head/; revision=31121
* Don't create a diagnostic socket by default.Brian Somers1997-11-091-5/+8
| | | | | | | | | Allow a password spec on the "set server" command line. Use SIGUSR2 to close the diagnostic socket. Some man page corrections. Notes: svn path=/head/; revision=31081
* Increase chat script sizes to 512Brian Somers1997-11-091-2/+2
| | | | | | | Requested by: Michael Reifenberger <root@totum.plaut.de> Notes: svn path=/head/; revision=31070
* Introduce ID0 logging.Brian Somers1997-11-091-6/+7
| | | | | | | | | | | 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. Notes: svn path=/head/; revision=31061
* Cosmetic (no functional changes):Brian Somers1997-10-261-19/+15
| | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=30715
* Correct ppp authentication defaults in interactiveBrian Somers1997-09-091-0/+12
| | | | | | | | | | | | mode. We don't want to be forced to type a password here :-( Pointed out by: mouth@ibm.net (John Kelly) While I'm there, don't allow a "set server" in interactive mode. Notes: svn path=/head/; revision=29252