aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/ppp/ip.c
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Deal with PROTO_IGMP and PROTO_IPIP packets correctly.Brian Somers1998-06-141-2/+28
| | | | | | | | | | Submitted by: Mark Tinguely <tinguely@plains.NoDak.edu> This change will allow a PPP host enabled with the "-alias" option to run mrouted. This does not intend to forward the IGMP nor tunneled packets to another host on the far side if the tun0 interface. Notes: svn path=/head/; revision=36961
* MFMP: Make ppp multilink capable.Brian Somers1998-05-211-183/+161
|\ | | | | | | | | | | | | See the file README.changes, and re-read the man page. Notes: svn path=/head/; revision=36285
| * Categorize the fields in struct bundle, and make the tunnelBrian Somers1998-05-061-4/+4
| | | | | | | | | | | | | | device speed available in ``show bundle''. Notes: svn path=/cvs2svn/branches/MP/; revision=35818
| * Cosmetic: Make our external function names consistent.Brian Somers1998-05-011-41/+41
| | | | | | | | Notes: svn path=/cvs2svn/branches/MP/; revision=35605
| * 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
| * Make gcc-2.8.1 build ppp cleanly.Brian Somers1998-04-251-5/+11
| | | | | | | | | | | | | | Support OpenBSD again. Notes: svn path=/cvs2svn/branches/MP/; revision=35451
| * o Understand ``syn'' and ``finrst'' in filter rules. ThisBrian Somers1998-04-161-12/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | is particularily useful when creating dial filters. Original work by: Junichi SATOH (junichi@astec.co.jp) o Parse a filter IP of ``0.0.0.0'' as having a width of 0, not 32. o Correct "set filter" usage message. o Warn about bad filter names. o Expand and correct a number of the man page sections. Notes: svn path=/cvs2svn/branches/MP/; revision=35237
| * Remove MODE_ALIAS and add AliasEnabled() macro.Brian Somers1998-04-071-2/+2
| | | | | | | | | | | | | | Remove IsInteractive(). Notes: svn path=/cvs2svn/branches/MP/; revision=35098
| * o Move alias function pointers into loadalias.cBrian Somers1998-04-071-8/+6
| | | | | | | | | | | | | | | | | | | | | | 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-8/+1
| | | | | | | | Notes: svn path=/cvs2svn/branches/MP/; revision=35059
| * o Drop packets that fail the dial filter when we're inBrian Somers1998-04-031-18/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | phase DEAD. They'll almost definitely have timed out by the time we dial anyway. o Log dial filters again (LogTCPIP). o Make DEBUG diagnostics for filter checking actually mean something to the common observer. o Do our best to keep any already-configured IP numbers at IPCP negotiation time. We always first request our configured IP, and if the peer asks for an invalid IP, we NAK with HISADDR Cosmetic: o Add a linefeed to the `set timeout' arg count error message. o Log unacceptable address errors to LogPHASE if LogIPCP is switched off. o Fix ``destination system not found'' error message. o Get out immediately if we get a fatal error before entering the main loop. Notes: svn path=/cvs2svn/branches/MP/; revision=35015
| * o Move struct lcp and struct ccp into struct link.Brian Somers1998-04-031-6/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * Remove some more globals:Brian Somers1998-03-241-17/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | o int modem was unused. o StateNames[] is now accessed via State2Nam() o ipKeepAlive is no more. As a result, we must call FilterCheck() twice if we're doing TCP/IP logging (once when we queue and log the packet and once when we transmit it and need to know if the idle timer should be reset), but this won't be the case in normal life. Notes: svn path=/cvs2svn/branches/MP/; revision=34883
| * Make struct bundle into a sort of `struct descriptor'.Brian Somers1998-03-201-1/+2
| | | | | | | | | | | | | | | | It does the fdsets/reads/writes for each of it's datalinks. Notes: svn path=/cvs2svn/branches/MP/; revision=34722
| * Move VJ compression state and stats into struct ipcp.Brian Somers1998-03-161-1/+2
| | | | | | | | Notes: svn path=/cvs2svn/branches/MP/; revision=34633
| * Move filter sets into struct bundle.Brian Somers1998-03-161-21/+19
| | | | | | | | Notes: svn path=/cvs2svn/branches/MP/; revision=34631
| * Move the IPCP into struct bundle.Brian Somers1998-03-131-9/+9
| | | | | | | | Notes: svn path=/cvs2svn/branches/MP/; revision=34557
| * 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
| * Move the idle timer into struct bundle. There's noBrian Somers1998-03-091-67/+7
| | | | | | | | | | | | | | link-level idle timer for the moment. Notes: svn path=/cvs2svn/branches/MP/; revision=34436
| * Force IPCP back to initial in bundle_Close().Brian Somers1998-03-021-1/+2
| | | | | | | | | | | | | | | | | | Add a few un-necessary includes to make us build under 2.2.5. These'll go when the code is cleaned up at the end. Notes: svn path=/cvs2svn/branches/MP/; revision=33995
| * o Remove the global CcpInfo. It's now part of the datalink.Brian Somers1998-02-231-14/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * Create struct datalink.Brian Somers1998-02-161-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * o Hook the FSMs into our bundle.Brian Somers1998-02-071-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | o The FSM layering is now more sane. o Move a lot of the NCP stuff into our ipcpstate rather than having it in the bundle, including control of the configured IP addresses. We don't need hacks like the global `linkup' variable any more as the FSM decides when our ppp.link* files get run. This is going to eventually be configurable based on FSM events anyway. o Fix a few inconsistencies when both sides require authentication. o We now have "Ppp..." and "PPp" prompts, reflecting authentication and network phase. We don't print loads of spurious prompts as we change phases any more. o Our phase is part of the bundle now. o Fix a bug where the FSM wasn't calling LayerFinish. o Close the FSM down correctly with a signal rather than slamming it down as if the line was dropped (the undocumented ``down'' command is still available though). o Remove the forgotten `tunno' variable and fix references to it. Notes: svn path=/cvs2svn/branches/MP/; revision=33162
| * Create `struct bundle' - the top level control structure.Brian Somers1998-02-021-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | 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
| * Move the global FSMs into their relevent structures.Brian Somers1998-01-311-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | IPCP, CCP and LCP are now just derived FSMs. Comment each of the FSM implementations so that we can tell what's going on. Revise the state transitions so that CCP and IPCP actually send terminate REQs when appropriate. The OS & IPCP layers are still like spagetti (next job). Notes: svn path=/cvs2svn/branches/MP/; revision=32915
| * Create `struct link' - the logical link from whichBrian Somers1998-01-301-3/+3
| | | | | | | | | | | | | | | | `struct physical' (and the future `struct logical') are derived. Notes: svn path=/cvs2svn/branches/MP/; revision=32903
| * o Move global/static IPCP data into IpcpInfo.Brian Somers1998-01-291-1/+3
| | | | | | | | | | | | | | | | | | | | | | o Use INADDR_ANY and INADDR_BROADCAST instead of 0 and 0xffffffff for IP addresses & masks. o Move struct compreq into ipcp.c (it's none of anyone elses business). o Rename MAX_STATES to MAX_VJ_STATES. Notes: svn path=/cvs2svn/branches/MP/; revision=32878
| * Create a new MP branch for `multilink protocol'.Brian Somers1998-01-291-4/+4
| | | | | | | | | | | | | | | | 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/+537
| | | | Notes: svn path=/cvs2svn/branches/MP/; revision=32861
* Quieten gcc-2.8.1Brian Somers1998-04-251-3/+5
| | | | Notes: svn path=/head/; revision=35449
* Add extraneous braces to stiffle warnings from gcc-2.8Brian Somers1998-03-131-2/+3
| | | | Notes: svn path=/head/; revision=34536
* Remove unused #includes.Brian Somers1998-01-211-5/+3
| | | | | | | | | Make various bits static. Remove unused variables. Submitted by: eivind Notes: svn path=/head/; revision=32663
* Lose <net/if_var.h> !Brian Somers1998-01-111-4/+1
| | | | | | | This'll require a `make installworld'. Notes: svn path=/head/; revision=32442
* Don't scribble on the stack if our input packet isBrian Somers1998-01-041-1/+7
| | | | | | | | bigger than our MRU. Moan and drop the packet instead. Notes: svn path=/head/; revision=32247
* Show how much time is left before timing out in theBrian Somers1997-12-291-2/+15
| | | | | | | | `show timeout' output. Remove ipIdleSecs variable - it's not used. Notes: svn path=/head/; revision=32102
* If a packet causes a dial, continue to test whether it'sBrian Somers1997-12-281-2/+2
| | | | | | | | blocked in the output filter. If so, proceed with the dial despite dropping the packet. Notes: svn path=/head/; revision=32039
* Cosmetic (style):Brian Somers1997-12-241-7/+8
| | | | | | | | | | sizeof(var) -> sizeof var sizeof type -> sizeof(type) Suggested by: J Wunsch <j@uriah.heep.sax.de> Notes: svn path=/head/; revision=31962
* Fix prototypes.Brian Somers1997-11-221-12/+17
| | | | | | | | | | | | | | | | | 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
* Add throughput logging (disabled by default).Brian Somers1997-11-181-5/+5
| | | | | | | | Use "enable throughput" to see modem & IPCP throughput. Removed an extraneous prompt() Notes: svn path=/head/; revision=31272
* Abstract data read from and written to the tun device,Brian Somers1997-11-161-19/+33
| | | | | | | | | | | | | | | | | allowing for a possible header on the front of all packets. In OpenBSD, there's a structure containing the address family here. If we're building under OpenBSD, set up the ``flags'' part of struct tuninfo (not there under FreeBSD) so that we config the interface as POINTOPOINT. Prefix prototypes with ``extern'' in os.c for consistency. These changes are cosmetic under FreeBSD, but allow ppp to build & work under OpenBSD (bar the srandomdev() stuff, the inclusing of <net/if_var.h> and some Makefile symantecs). Notes: svn path=/head/; revision=31195
* Understand networks in the filter rules. We don'tBrian Somers1997-11-121-3/+5
| | | | | | | insist on x.x.x.0/24 - x.x.x.x/24 is ok too. Notes: svn path=/head/; revision=31143
* Log whether or not IP packets are bloked due toBrian Somers1997-11-121-5/+7
| | | | | | | a filter. Notes: svn path=/head/; revision=31142
* Cosmetic:Brian Somers1997-10-261-1/+3
| | | | | | | Move prototypes into the correct headers. Notes: svn path=/head/; revision=30733
* Cosmetic (no functional changes):Brian Somers1997-10-261-15/+30
| | | | | | | | | | | | | | | | | | 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
* Cosmetic: Log a strerror(errno) when failing to write toBrian Somers1997-10-041-4/+16
| | | | | | | the tun device. Notes: svn path=/head/; revision=30092
* Allow the transition from an idle timeout valueBrian Somers1997-09-031-2/+3
| | | | | | | | | of zero (no timeout) while IPCP is up. Move some prototypes into .h files and re-order some includes. Notes: svn path=/head/; revision=29043
* Make the code format more in line with style(9).Brian Somers1997-08-251-146/+132
| | | | | | | | Update loadalias to use the new libalias api. Update to version 1.1. Notes: svn path=/head/; revision=28679
* Put TCP/IP logs back on one line.Brian Somers1997-06-161-18/+46
| | | | Notes: svn path=/head/; revision=26692
* Overhaul ppp:Brian Somers1997-06-091-43/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | o Use syslog o Remove references to stdout/stderr (incl perror()) o Introduce VarTerm - the interactive terminal or zero o Allow "set timeout" to affect current session o Change "set debug" to "set log" o Allow "set log [+|-]flag" o Make MSEXT and PASSWDAUTH stuff the default o Move all #ifdef DEBUG stuff into the code - this shouldn't be too much overhead. It's now controlled with "set log +debug" o Add "set log command, debug, tun, warn, error, alert" o Remove cdefs.h, and assume an ansi compiler. o Improve all diagnostic output o Don't trap SIGSEGV o SIGHUP now terminates again (log files are controlled by syslog) o Call CloseModem() when changing devices o Fix parsing of third arg of "delete" I think this fixes the "magic is same" problems that some people have been experiencing. The man page is being rewritten. It'll follow soon. Notes: svn path=/head/; revision=26516