summaryrefslogtreecommitdiff
path: root/usr.sbin/ppp/chat.c
Commit message (Collapse)AuthorAgeFilesLines
* This commit was manufactured by cvs2svn to create tagrelease/3.5.0_cvscvs2svn2000-06-251-1/+1
| | | | | | | 'RELENG_3_5_0_RELEASE'. This commit was manufactured to restore the state of the 3.5-RELEASE image. Releases prior to 5.3-RELEASE are omitting the secure/ and crypto/ subdirs.
* MF4: Include netgraph support when building with RELEASE_CRUNCHBrian Somers2000-06-011-8/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make mbufs more like kernel mbufs Allocate mbufs in buckets rather than individually Tidy up (and fix) sockaddr parsing of mib structures Parse quotes properly and complain about unbalanced ones Allow comments at the end of lines Use ioctl(TUNSIFHEAD) on the tun device if possible Correct CBCP redials Correct cmsghdr handling when passing links Don't fork to lose the current session when we're about to exit Tell the tun device when we change pid Show hex/decimal values rather than ??? for things not understood Depricate (but still support) -alias in favour of -nat Support DNS0/DNS1 macros, add the ``resolv'' command and dns logging Support redial/reconnect properly, and tell the -background parent Some constification, staticising, spelling and better diagnostics Default carrier behaviour based on the device type Differentiate between failing to start a program and the program exiting Fix the MP link-passing race by using a local-domain UDP socket Add "nat target" Fix some timer issues where timers are removed before they are triggered Handle pap text messages longer than 255 bytes Make -foreground a real option Bump version Notes: svn path=/stable/3/; revision=61140
* MFC: Don't memset active chat timers.Brian Somers1999-12-031-8/+23
| | | | Notes: svn path=/stable/3/; revision=54056
* MFC: Support PPPoE (PPP over Ethernet), but disabled for now.Brian Somers1999-11-191-2/+2
| | | | | | | | | | | | | Moan about -alias (but still honour it). kldload the tun module if required. Add -unit and -foreground command line arguments. Support fast-queue configuration. Make ``set autoload'' functional. Allow GRE packet filtering Many bug fixes Notes: svn path=/stable/3/; revision=53438
* $Id$ -> $FreeBSD$Peter Wemm1999-08-291-1/+1
| | | | Notes: svn path=/stable/3/; revision=50581
* MFC: Abstract the physical device layer (``show modem'' is now ``showBrian Somers1999-08-231-85/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | physical''). Support ``physical'' and ``sync'' logging. ``set weight'' -> ``set bandwidth'' and a ``set autoload'' rewrite. ``set cd'' and better carrier detection. PPPoISDN support (.defined out in the Makefile as it's only functional with i4b-00.83.00 or better installed) PPPoUDP support -alias -> -nat Add -foreground and -quiet command lines switches Minimum idle timer support ``alias port'' range support Some alignment wrinkles ironed out Support for TUNSIFMODE and TUNSLMODE (if defined) Assorted throughput measurement improvements ``enable/disable keep-session'' support Adjust filter sets built with MYADDR and HISADDR when the IPs change Allow forward jumps in filter rules Support ospf filtering Better handing of ``no number'' CBCP REQs Handle file descriptor close-on-exec flags properly before exec()s Drop packets received when the current state is wrong Expand PROCESSID correctly when executing commands Add a new CARRIER phase (this is temporary - 'till ``set dial'' is abstracted and made device specific) Handle IPCP code rejects Support ``deny enddisc'' Don't moan about group write permissions to ppp.conf More verbiage (now I'm making words up) in ``show mp'' Show the correct `next' values in ``show timer'' Plus an assortment of other minor changes Notes: svn path=/stable/3/; revision=50259
* MFC: Don't scribble if our last arg is expect-send-expectBrian Somers1999-06-261-2/+6
| | | | Notes: svn path=/stable/3/; revision=48228
* MFC:Brian Somers1999-03-241-7/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | o Add radius support. o Add ``alias proxy'' and ``alias pptp'' support. o Support server-side M$Chap authentication. o Support client & server-side M$LANMan authentication. o Support ``!program'' passwords. o Use pipes only for unidirectional IPC. o Extend ``set *retries'' commands. o Don't ResetReq when doing Predictor compression. o Delay carrier detection by a default of 1 second and implement ``set cd''. o Implement incremental redial timeouts via ``set redial''. o Don't use hard-coded quotes or brackets in the man page. o ``random'' redials means 1-30 seconds, not 0-29. o Close rather than hanging if the peer never responds to auth requests. o Nuke outstanding authentication request timers when the layer is closed unexpectedly. o Log CCP errors as in the CCP log (not as a WARNING). o Ensure that all TLU/TLD and TLS/TLF pairs are balanced. o OR the peers ACCMAP with our own during LCP negotiations. o Set the interface netmask correctly and show it in ``show ipcp''. o Drop the correct diagnostic connections and remove the correct local domain socket from ``set server''. o If our config file doesn't exist, moan about that rather than claiming that the ``default'' section doesn't exist. Notes: svn path=/stable/3/; revision=45007
* Untimeout the chat expect timer as soon as we get aBrian Somers1998-10-271-1/+2
| | | | | | | | | match - otherwise, with a delayed (\\d) ``send'', the timeout may happen during the send and cause a failure. Problem reported by: David L. Vondrasek <dallas.tx@airmail.net> Notes: svn path=/head/; revision=40680
* o Support callback types NONE, E.164, AUTH and CBCP.Brian Somers1998-08-071-4/+7
| | | | | | | | | | | | | | | | | (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
* Remove redundant includesBrian Somers1998-06-271-2/+1
| | | | Notes: svn path=/head/; revision=37192
* o If we come out of select() with only write descriptors thatBrian Somers1998-06-241-2/+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
* o De-staticise things that don't need to be static.Brian Somers1998-06-151-2/+2
| | | | | | | | | | | | | o Bring the static ``ttystate'' into struct prompt so that the tilde context is per prompt and not global. o Comment the remaining static variables so that it's clear why they're static. o Add some XXX comments suggesting that our interface list and our hostname should be re-generated after a signal (say SIGUSR1) so that a machine with PCCARDs has a chance. Notes: svn path=/head/; revision=37010
* o #define the name "tun" in defs.h against the future possibilityBrian Somers1998-05-281-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | 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 Move our prompt descriptor list outside of the bundle.Brian Somers1998-05-231-2/+1
| | | | | | | | | | | | | | | | | | | | | | | 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-458/+572
|\ | | | | | | | | | | | | See the file README.changes, and re-read the man page. Notes: svn path=/head/; revision=36285
| * Cosmetic: Make our external function names consistent.Brian Somers1998-05-011-37/+37
| | | | | | | | Notes: svn path=/cvs2svn/branches/MP/; revision=35605
| * o Explicitly set the close-on-exec flag of descriptor 3 beforeBrian Somers1998-05-011-19/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * o Create a new ``timer'' log level. This lets us ``setBrian Somers1998-04-301-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | log debug'' without filling our filesystem/screen with junk that we don't really want to see. o change PHYS_STDIN to PHYS_DIRECT - we can handle incoming connections that aren't on STDIN_FILENO now. o Allow return values from our FSM LayerUp functions. If LayerUp() fails, the FSM does an immediate FsmDown() without calling the fsm_parent's Layer{Up,Down} functions. o Clear the close-on-exec flag of file descriptor 3 when executing chat programs so that our documented ability to communicate with /dev/tty via that descriptor works. Also document it as descriptor 3, not 4 :-O o Allow a ``rm'' command as an alias for ``remove''. o Fix the bind()/connect()/accept() calls made by the MP server. o Create bundle_SendDatalink() and bundle_ReceiveDatalink(). This allows `struct datalink's to flatten themselves, pass through a pipe (read: the eye of a needle !) and come alive at the other end. The donator then fork()s & exec()s pppmpipe, ``passing'' the connection to another ppp instance. *** PPP NOW TALKS MULTILINK :-))) *** Our link utilization is hideous, and lots of code needs tidying still. It's also probably riddled with bugs ! It's been tested against itself only, and has hung once, so confidence isn't high.... Notes: svn path=/cvs2svn/branches/MP/; revision=35568
| * o Add the link name to modem diagnostics.Brian Somers1998-04-281-1/+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
| * Tidy up the use of struct pppTimer.Brian Somers1998-04-191-4/+1
| | | | | | | | Notes: svn path=/cvs2svn/branches/MP/; revision=35297
| * Destroy struct chat when it's finished in struct datalink.Brian Somers1998-04-181-6/+6
| | | | | | | | | | | | | | | | Initialise chat timers correctly as they're malloc()ed as part of struct datalink, and initially contain garbage. Notes: svn path=/cvs2svn/branches/MP/; revision=35276
| * Cosmetic: Clean up warnings.Brian Somers1998-04-181-10/+11
| | | | | | | | Notes: svn path=/cvs2svn/branches/MP/; revision=35258
| * o Fix chats expect-send-expect - it shouldn't beBrian Somers1998-04-101-6/+7
| | | | | | | | | | | | | | | | | | | | | | 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 Move alias function pointers into loadalias.cBrian Somers1998-04-071-3/+3
| | | | | | | | | | | | | | | | | | | | | | 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-10/+1
| | | | | | | | Notes: svn path=/cvs2svn/branches/MP/; revision=35059
| * Move authname and authkey into struct bundle and only allowBrian Somers1998-04-031-4/+16
| | | | | | | | | | | | | | | | their alteration in PHASE_DEAD. Remove redundant pppConfs array element. Notes: svn path=/cvs2svn/branches/MP/; revision=35014
| * o Move struct lcp and struct ccp into struct link.Brian Somers1998-04-031-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 more globalsBrian Somers1998-03-131-2/+1
| | | | | | | | Notes: svn path=/cvs2svn/branches/MP/; revision=34558
| * De-staticise LQR informationBrian Somers1998-03-131-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Increment OutPackets for any packet - not just LQRs MFC: o Fix a few comment typos. o Fix ``set timeout'' usage message and documentation. o Change ifOutPackets, ifOutOctets and ifOutLQRs to `u_int32_t's so that they wrap correctly. o Put the LQR in network byte order using the correct struct size (sizeof u_int32_t, not sizeof u_long). o Wrap LQR ECHO counters correctly. o Don't increment OutLQR count if the last LQR hasn't been replied to. o Initialise last received LQR in StartLqm. o Don't start the LQR timer if we're `disabled' and `accepted'. o Generate LQR responses when both sides are using a timer and we're not going to send our next LQR before the peers max timeout. Notes: svn path=/cvs2svn/branches/MP/; revision=34530
| * o Allow "*" in the password field in ppp.secret (forcing aBrian Somers1998-03-091-12/+9
| | | | | | | | | | | | | | | | | | | | getpwnam() lookup). o Don't use chat_ExpandString on the password field in ppp.secret. It's still possible to quote the string for embedded spaces. o Don't allow multiple entries with the same name in ppp.secret. Notes: svn path=/cvs2svn/branches/MP/; revision=34434
| * Move phone numbers into struct datalink.Brian Somers1998-03-091-16/+9
| | | | | | | | | | | | | | Make "show modem" look a bit prettier. Notes: svn path=/cvs2svn/branches/MP/; revision=34433
| * Implement ABORT strings.Brian Somers1998-02-261-34/+90
| | | | | | | | Notes: svn path=/cvs2svn/branches/MP/; revision=33855
| * 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
| * Fix empty string skipping when chatting.Brian Somers1998-02-181-2/+4
| | | | | | | | Notes: svn path=/cvs2svn/branches/MP/; revision=33526
| * Move the dial, login and hangup scripts into struct datalink.Brian Somers1998-02-161-4/+9
| | | | | | | | | | | | | | | | Don't set these scripts in -direct mode. Always set reconnect_tries to zero for -direct mode. Notes: svn path=/cvs2svn/branches/MP/; revision=33435
| * Remove some unused variables.Brian Somers1998-02-131-26/+13
| | | | | | | | Notes: svn path=/cvs2svn/branches/MP/; revision=33308
| * Update to version 2.0-betaBrian Somers1998-02-131-388/+453
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-3/+3
| | | | | | | | | | | | | | | | and into the new `prompt.c'. struct prompt is (of course) a `sort' of descriptor. Notes: svn path=/cvs2svn/branches/MP/; revision=33209
| * o Introduce struct descriptor.Brian Somers1998-02-091-1/+2
| | | | | | | | | | | | | | | | | | | | 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
| * Move pppVars.physical into the bundle (for the moment).Brian Somers1998-02-061-2/+2
| | | | | | | | Notes: svn path=/cvs2svn/branches/MP/; revision=33127
| * Shuffle names and args in modem.hBrian Somers1998-02-061-2/+2
| | | | | | | | Notes: svn path=/cvs2svn/branches/MP/; revision=33125
| * Create `struct async' and make it part of `struct physical'.Brian Somers1998-02-021-1/+7
| | | | | | | | | | | | | | | | | | | | 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 a new MP branch for `multilink protocol'.Brian Somers1998-01-291-30/+33
| | | | | | | | | | | | | | | | Do lots of initial shuffling and grouping. Submitted by: Eivind Eklund <perhaps@yes.no> Notes: svn path=/cvs2svn/branches/MP/; revision=32863
| * This commit was manufactured by cvs2svn to create branch 'MP'.cvs2svn1998-01-291-0/+678
| | | | Notes: svn path=/cvs2svn/branches/MP/; revision=32861
* Remove unused #includes.Brian Somers1998-01-211-4/+1
| | | | | | | | | Make various bits static. Remove unused variables. Submitted by: eivind Notes: svn path=/head/; revision=32663
* Allow (and document) execution of commands from withinBrian Somers1997-12-271-85/+124
| | | | | | | | our chat script. You can now even run chat(8) - see ppp.conf.sample. Notes: svn path=/head/; revision=32017
* Cosmetic (style):Brian Somers1997-12-241-8/+8
| | | | | | | | | | sizeof(var) -> sizeof var sizeof type -> sizeof(type) Suggested by: J Wunsch <j@uriah.heep.sax.de> Notes: svn path=/head/; revision=31962
* strncpy(x,y,sizeof(x)) --> strncpy(x,y,sizeof(x)-1)Brian Somers1997-12-231-2/+2
| | | | | | | | Suggested by: Philippe Charnier <charnier@lirmm.fr> Theo de Raadt <deraadt@cvs.openbsd.org> Notes: svn path=/head/; revision=31953